easy6502 icon indicating copy to clipboard operation
easy6502 copied to clipboard

Indirect indexed addressing: Addresses are not wrapping within zeropage.

Open mibi88 opened this issue 7 months ago • 0 comments

Addresses are not wrapping within zeropage as they do on a real 6502. When running LDA ($FF), Y with Y = 0, the 6502 simulator takes the low byte from $FF and the high byte from $0100. It can be seen when running this code:

LDA #$00
STA $00

LDA #$02
STA $FF
LDA #$04
STA $0100

LDA #$AC
STA $0402

LDA #$c2
STA $02

LDY #$00
LDA ($FF), Y

After executing this code, A should be equal to C2 and not AC. PinoBatch, on the Nesdev wiki figured out that it is due to getWord() which does not handle wrapping: https://github.com/skilldrick/easy6502/blob/bb213ae3432f1eec37fff1e3e49a99fb75a5dd8b/simulator/assembler.js#L587-L593

mibi88 avatar Jul 05 '24 20:07 mibi88