Indirect addressing mode needs to return entire page when lo(0xFF)
Opened this issue · 1 comments
lucascebertin commented
Following the 6502 spec, there is a bug in architecture when indirect
addressing mode is used.
Not sure if this thing affects all the indirect
addressing like indirect, x
and indirect, y
but probably yes.
We need to check if the lo(ADDRESS) is 0xFF and, then, consider a full page return, so:
LDX #$02
STX $3000
LDX #$04
STX $3100
LDX #$03
STX $30FF
JMP ($30FF)
the jump will consider the hi(0x3000) + lo(0x30FF) = 0x0203
NB: WE CAN'T USE EASY6502 TO VALIDATE THIS BECAUSE THEY ARE NOT RESPECTING THIS BEHAVIOUR AS WE CAN SEE IN THE PICTURE:
rafaeldelboni commented
So, if I understood correctly, to simulate this bug we need to do something like this In the indirect function?
If address & 0x00FF = 0xFF
Then:
Address & 0xFF00 = hi
Address = lo
Else:
Address + 1 = hi
Address = lo