LD Load instructions
How to decode ld instructions from binary
Table of Contents
Opcode format7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
Set 1 |
0 | 0 | 0 | B | 0 | 1 | 0 |
|
Set 4 |
0 | 0 | B | 0 | 0 | 0 | 1 |
|
Set 2 |
0 | 0 | 1 | B | 0 | 1 | 0 |
7 | nn | 0 |
15 | 8 |
|
Set 3 |
0 | 0 | b | 1 | 1 | 0 |
n |
|
LD r, r' |
0 | 1 | r | r' |
|
LD r, (HL) |
0 | 1 | r | 1 | 1 | 0 |
|
LD SP,HL |
1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |
Registers
Register | r |
B | 000 |
C | 001 |
D | 010 |
E | 011 |
H | 100 |
L | 101 |
A | 111 |
Bits
Value | b | B |
0 | 000 | 00 |
1 | 001 | 01 |
2 | 010 | 10 |
3 | 011 | 11 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
Set 1 store a in memory
4 | 3 | Instruction |
0 | 0 |
LD (BC),A |
1 |
LD (DE),A |
1 | 0 |
LD A,(BC) |
1 |
LD A,(DE) |
Set 2 store in memory
5 | 4 | Instruction |
0 | 0 |
LD (nn),HL |
1 |
LD (nn),A |
1 | 0 |
LD HL,(nn) |
1 |
LD A,(nn) |
Set 3 set to constant n
4 | 3 | 2 | Instruction |
0 | 0 | 0 |
LD B,n |
1 |
LD C,n |
1 | 0 |
LD D,n |
1 |
LD E,n |
1 | 0 | 0 |
LD H,n |
1 |
LD L,n |
1 | 0 |
LD (HL),n |
1 |
LD A,n |
Set 4 set to constant nnn
5 | 4 | Instruction |
0 | 0 |
LD BC,nn |
1 |
LD DE,nn |
1 | 0 |
LD HL,nn |
1 |
LD SP,nn |