I'm not sure exactly how wrapping works with the indexed x and y address modes. The documentation that I've found is clear that the indexing part is wrapped around within the zero page, but what about the actual dereferenced 16bit address, is that constrained to the zero page as well?
Let's say I have this code:
LDX #$00
LDA #$05
STA $ff
LDA #$07
STA $0100
LDA #$08
STA $00
LDY #$0a
STY $0705
LDY #$0b
STY $0805
LDA ($ff,X)
Will A
be loaded with $0a
, or $0b
?
It is obvious that if X
were loaded with $01
, then the address would be looked up from $00
($ff + $01 == $00
). But in this case, we're going to read the 16bit address lo byte from $ff
- is the hi byte read from $0100
, or from $00
?
Similarly for indirect y, let's say I have this code:
LDY #$00
LDA #$30
STA $ff
LDA #$04
STA $00
LDA #$05
STA $0100
LDX #$0a
STX $0430
LDX #$0b
STX $0530
LDA ($ff),Y
We read a 16bit address from $ff
, is the hi byte read from $0100
or from $00
?
And lastly, also with indirect y:
LDY #$01
LDA #$ff
STA $01
STA $02
LDX #$0a
STX $00
LDA ($01),Y
We dereference $01
and get $ffff
, then add $01
, does this mean we load from $00
and get $0a
in A
?
JMP (address)
. When address is the last byte of a page the 6502 will take the high indirect address byte from the same page rather than the next page which should be expected. So,JMP ($B1FF)
would use $B1FF & $B100 to form the address rather than $B1FF & $B200. See archive.6502.org – Core