diff options
-rw-r--r-- | instructions/RTS.ts | 2 | ||||
-rw-r--r-- | runtime.ts | 23 | ||||
-rw-r--r-- | thing.s | 11 |
3 files changed, 22 insertions, 14 deletions
diff --git a/instructions/RTS.ts b/instructions/RTS.ts index 483a441..5a69fdd 100644 --- a/instructions/RTS.ts +++ b/instructions/RTS.ts @@ -1,5 +1,5 @@ import type The65c02 from "../65c02.ts"; export default function (this: The65c02) { - this.programCounter.set(this.pop() | (this.pop() << 8)) + this.programCounter.set((this.pop() << 8) | this.pop()) } \ No newline at end of file diff --git a/runtime.ts b/runtime.ts index 2a16536..d400031 100644 --- a/runtime.ts +++ b/runtime.ts @@ -18,15 +18,15 @@ await cpu.loadInstructions() // mem address $0000 ram[0xFFFC] = 0x00 -ram[0xFFFD] = 0x80 +ram[0xFFFD] = 0x00 // read code from file -const code = Deno.readFileSync('msbasic/tmp/eater.bin') +const code = Deno.readFileSync('a.out') // write code to ram before execution for (let offset = 0; offset < code.length; offset++) { const byte = code[offset]; - ram[0x8000 + offset] = byte; + ram[0x0000 + offset] = byte; } // pull RESB low to reset the 65c02 @@ -63,17 +63,20 @@ let instBreakpoints: string[] = [] // repeat until the cpu requests an interrupt while (!cpu.io.interruptRequest.high) { + const instId = ram[cpu.programCounter.num()] + .toString(16) + .padStart(2, '0'); + const goog = (matrix as Record<string, { mnemonic: string, mode: string }>)[instId]; + if (!goog) { + console.log('uh', instId, 'unknown') + break; + } + const instr = goog; + console.debug(cpu.programCounter.num().toString(16).padStart(4, '0'),instr.mnemonic, instr.mode) cpu.cycle(); // debug step-by-step mode dbg: if (debug) { - const goog = Object.entries(matrix).find(([k]) => k == ram[cpu.programCounter.num()].toString(16)); - if (!goog) { - console.log('uh') - break dbg; - } - const instr = goog[1]; - console.debug(cpu.programCounter.num().toString(16).padStart(4, '0'),instr.mnemonic, instr.mode) if (instBreakpoints.includes(instr.mnemonic)) { instBreakpoints = instBreakpoints.filter(k => k != instr.mnemonic) skip = 0; diff --git a/thing.s b/thing.s index d7fabea..d492a15 100644 --- a/thing.s +++ b/thing.s @@ -1,3 +1,8 @@ - lda #$55 ; put 55 into A - sta $00 ; put A into $0 - brk \ No newline at end of file +_start: + lda #$78 + jsr goog + cmp #$78 + brk +goog: + lda #$50 + rts \ No newline at end of file |