z80:Opcodes:LD
From Learn @ Cemetech
Jump to navigationJump to search
The LD instruction is used to put the value from one place into another place.
Syntax
LD N,M
puts M into N.
Allowed instructions (across: M Down: N)
If x, it means allowed. If blank, it means not allowed.
| A | B | C | D | E | H | L | I | R | IXH | IXL | IYH | IYL | BC | DE | HL | SP | IX | IY | (BC) | (DE) | (HL) | (IX+N) | (IY+N) | N | NN | (NN) | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |||||||
| B | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||
| C | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||
| D | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||
| E | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||
| H | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||||||
| L | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||||||
| I | x | ||||||||||||||||||||||||||
| R | x | ||||||||||||||||||||||||||
| IXH | x | x | x | x | x | x | x | x | |||||||||||||||||||
| IXL | x | x | x | x | x | x | x | x | |||||||||||||||||||
| IYH | x | x | x | x | x | x | x | x | |||||||||||||||||||
| IYL | x | x | x | x | x | x | x | x | |||||||||||||||||||
| BC | x | x | |||||||||||||||||||||||||
| DE | x | x | |||||||||||||||||||||||||
| HL | x | x | |||||||||||||||||||||||||
| SP | x | x | x | x | x | ||||||||||||||||||||||
| IX | x | x | |||||||||||||||||||||||||
| IY | x | x | |||||||||||||||||||||||||
| (BC) | x | ||||||||||||||||||||||||||
| (DE) | x | ||||||||||||||||||||||||||
| (HL) | x | x | x | x | x | x | x | ||||||||||||||||||||
| (IX+N) | x | x | x | x | x | x | x | ||||||||||||||||||||
| (IY+N) | x | x | x | x | x | x | x | ||||||||||||||||||||
| (NN) | x | x | x | x | x | x | x |
Effects
No flags are altered except in the cases of the I or R registers.
In those cases, C is preserved, H and N are reset, and alters Z and S. P/V is set if interrupts are enabled, reset otherwise.
Uses
Use to load numbers into operands. They can either be numbers used in the code (usually 8-bits), or labels (usually 16-bits).
ld b,$05 ;Counter ld hl,var ;Variable label ld a,(var) ;Write data to var
T-States
r denotes 8-bit register. rr represents a two byte register pair: BC, DE, HL, SP
| r, r' | 4 |
| r,X | 7 |
| r,(hl) | 7 |
| r,(ix+X) | 19 |
| r,(iy+X) | 19 |
| a, (vc) | 7 |
| a, (de) | 7 |
| a, (XX) | 13 |
| (bc),a | 7 |
| (de),a | 7 |
| (XX),a | 13 |
| a, i | 9 |
| a, r | 9 |
| i, a | 9 |
| r, a | 9 |
| a, (BC) | 7 |
| (XX), a | 13 |
| rr,XX | 10 |
| ix, XX | 14 |
| iy, XX | 14 |
| hl, (XX) | 20 |
| ix, (XX) | 20 |
| iy, (XX) | 20 |
| (XX), hl | 20 |
| (XX), rr | 20 |
| (XX), ix | 20 |
| (XX), iy | 20 |
| sp, hl | 6 |
| sp, ix | 10 |
| sp, iy | 10 |
See also
Source: [1]