Today you implement register-to-register loads and run your first real program, a short sequence of opcodes that carries a value from one register into another. It is a small proof that your fetch-decode-execute loop, registers, and memory all work together as one machine.
Implement LD A, B and run a short program of loads end to end.
The largest single block of the opcode table, 0x40 through 0x7F, is nothing
but register-to-register copies: LD A, B, LD C, H, LD E, A, and so on.
Each just moves one register’s byte into another and costs 4 cycles. LD A, B
(opcode 0x78) is a representative example.
This is also your first real program: load a constant into B, then copy
B into A, and watch two steps of your loop carry the value through. That end
-to-end run - a sequence of opcodes producing a predictable final state - is
exactly what an emulator does, just at a smaller scale than a whole game. You now
have registers, memory, flags, and a working fetch–decode–execute core.
case 0x78: // LD A, Bc.A = c.Breturn 4// every opcode in 0x40..0x7F is one LD r, r' - same shape, different pair.// Implement just LD A, B today; the rest of the block follows identically.
The LD r, r' block - opcodes 0x40 to 0x7F copy one register to another.