My question is about the 6502 Assembly language. I'm trying to learn it using this website https://skilldrick.github.io/easy6502/.
On the topic of addressing modes. I don't understand the indirect addressing mode. See the source code example below.
LDA #$01
STA $f0
LDA #$cc
STA $f1
JMP ($00f0) ;dereferences to $cc01
Why is the JMP ($00f0)
dereferenced to $cc01
instead of $01cc
.
My memory looks like this
00f0: 01 cc 00 00 00 00 00 00 00 00 00 00 00 00 84
Here you see 00f0
starts with 01
and then followed by cc
so it looks more logical to me that the jump instruction would dereference to $01cc
, but why is this somehow reversed?
6502 is little endian. That means for 16 bit values, which take two bytes, the lowest byte is stored at the lowest address. After the two STA
s, you have:
00f0: 01
00f1: cc
The JMP
instruction loads the byte at f0
into the low byte of the destination address and the byte at f1
into the high byte of the destination address meaning you jump to cc01
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With