fix JSR, RTS, and RTI
JSR was pushing 1 too high PC and RTS was 1 too low RTI was only pulling the low byte of PC
This commit is contained in:
parent
5535e5de70
commit
99082b5528
6
cpu.c
6
cpu.c
@ -472,7 +472,7 @@ jmp(uint16_t arg)
|
||||
static void
|
||||
jsr(uint16_t arg)
|
||||
{
|
||||
uint16_t tmp = regs.pc;
|
||||
uint16_t tmp = regs.pc - 1;
|
||||
|
||||
/*
|
||||
* first push high-byte of return address then low-byte
|
||||
@ -651,13 +651,13 @@ static void
|
||||
rti(void)
|
||||
{
|
||||
plp();
|
||||
regs.pc = PULL();
|
||||
regs.pc = PULL() | (PULL() << 8);
|
||||
}
|
||||
|
||||
static void
|
||||
rts(void)
|
||||
{
|
||||
regs.pc = PULL() | (PULL() << 8);
|
||||
regs.pc = (PULL() | (PULL() << 8)) + 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user