Hello I'm writing an emulator for Game Boy.
I use this reference : Gameboy CPU (LR35902) instruction set
This document states that opcodes :
0xE2 LD (C),A
and
0xF2 LD A,(C)
have a length of 2.
The Game Boy CPU Manual says that these instructions respectively :
Put value at address $FF00 + register C into A.
and
Put A into address $FF00 + register C.
I think it has length of 1 because the opcode is self sufficient, it doesn't need another value to be interpreted. If it has a length of 2, what's the purpose of the second byte ?
You are absolutely right. LD (C),A
and LD A,(C)
are 1 byte long.
I have even emailed the responsible (Pastraiser) asking for clarification (or if he could fixed the website) but I got no answer.
Another thing that bothers me is the fact that prefix CB
is considered to be 1 byte long and consume 4 cycles. And all the extended instructions are considered to be 2 bytes long and consume 8 cycles (16 if they access (HL)
). It would make more sense to me to leave blank the space below Prefix CB
so it is clear that all extended instructions already include the size and processing cycles of their prefix.
And the other thing that bothers me is the fact that STOP
length is 2. It is actually just one byte long. There is a hardware bug on Gameboy Classic that causes the instruction following a STOP
to be skipped. So Nintendo started to tell developers to add a NOP
always after a STOP
. So, to be 100% correct I would consider STOP
to be (1,4) instead of (2,4). This issue does not exist on Gameboy Color.
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