diff --git a/cpu.c b/cpu.c index e63760c..87d68c8 100644 --- a/cpu.c +++ b/cpu.c @@ -407,15 +407,23 @@ iny(uint8_t arg) } static void -jmp(uint8_t arg) +jmp(uint16_t arg) { regs.pc = arg; } static void -jsr(uint8_t arg) +jsr(uint16_t arg) { -/* TODO: complete this */ + uint16_t tmp = regs.pc + 2; + + /* + * first push high-byte of return address then low-byte + * https://www.masswerk.at/6502/6502_instruction_set.html + */ + PUSH((tmp & 0xFF00) >> 8); + PUSH(tmp & 0xFF); + regs.pc = arg; } static void @@ -547,13 +555,14 @@ ror(uint8_t arg) static void rti(uint8_t arg) { -/* TODO: complete this */ + plp(); + regs.pc = PULL(); } static void -rts(uint8_t arg) +rts(void) { -/* TODO: complete this */ + regs.pc = PULL() + 1; } static void @@ -1186,7 +1195,7 @@ interpret(void) cycles += 6; break; case 0x60: - rts(opcode_arg(AM_ACC)); + rts(); cycles += 6; break; case 0xe9: