Could someone please explain what the opcode 0x08
does on the LR35902 processor. The mnemonic is LD (a16),SP
.
I'm confused because the stack pointer is a 16-bit value but (a16)
is an address to somewhere only capable of storing 8 bits (I think!). I could guess that the first 8 bits are placed into (a16)
and the next are placed adjacent to those but I would like confirmation.
Yes, that opcode puts SP value at an address (a16). Here's what it will look like:
void MemoryWrite(uint16_t addr, uint8_t value);
MemoryWrite(a16, SP & 0xFF);
MemoryWrite(a16 + 1, (SP & 0xFF00) >> 8);
Because it's a little-endian processor you put least significant byte first.
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