I am working on a GameBoy emulator in C. Right now I am working on the CPU.c file and I am a little confused on some instructions that I see listed here:
http://realboyemulator.files.wordpress.com/2013/01/gbcpuman.pdf
If you refer to page 66 of the above PDF, and look at the instruction corresponding with Opcode 0x7E -- LD,R1,R2 , I am curious about this isntruction..
The GB has eight 8 bit registers, A,B,C,D,E,F,H,L. 16 Bit registers can be made by concatenating two: AF,BC,DE,HL.
I am confused about Opcode 0x7E because it looks like it is attempting to store a 16 bit value (HL) into an 8-bit register (A).
LD,A,(HL)
Am I misinterpreting this document? Can someone explain why an instruction like this would exist? Could it not just be replaced by LD,A,L?
The address is 16 bit but it points into 1 byte (8 bit) which it puts into register A, (register D in the below example).
This instruction loads D with the byte located at the address in register pair HL.
Found this at http://gameboy.mongenel.com/dmg/lesson1.html
Here are all the lessons http://gameboy.mongenel.com/asmschool.html