Z80:Opcodes:LD: Difference between revisions
From Learn @ Cemetech
Jump to navigationJump to search
KermMartian (talk | contribs) No edit summary |
KermMartian (talk | contribs) mNo edit summary |
||
| Line 151: | Line 151: | ||
== See also == | == See also == | ||
[[Z80:Opcodes:LDD|LDD]],[[Z80:Opcodes:LDDR|LDDR]],[[Z80: | [[Z80:Opcodes:LDD|LDD]],[[Z80:Opcodes:LDDR|LDDR]],[[Z80:Opcodes:LDI|LDI]],[[Z80:Opcodes:LDIR|LDIR]] | ||
Source: [http://www.zilog.com/manage_directlink.php?filepath=docs/z80/um0080&extn=.pdf] | Source: [http://www.zilog.com/manage_directlink.php?filepath=docs/z80/um0080&extn=.pdf] | ||
Latest revision as of 08:25, 6 February 2016
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]