Difference between revisions of "Z80:Opcodes:LD"

From Learn @ Cemetech
Jump to navigationJump to search
(Initial automated import)
 
(Fixed table)
Line 13: Line 13:
  
 
{| class="wikitable"
 
{| class="wikitable"
! || 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 !! 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  
+
| 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 !! !!
+
| 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 !! !!
+
| 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 !! !!
+
| 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 !! !!
+
| 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 !! !!
+
| H || x || x || x || x || x || x || x || || || || || || || || || || || || || || || x || x || x || x || ||
 
|-
 
|-
| L || 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 !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!
+
| I || x || || || || || || || || || || || || || || || || || || || || || || || || || ||
 
|-
 
|-
| R || x !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!
+
| R || x || || || || || || || || || || || || || || || || || || || || || || || || || ||
 
|-
 
|-
| IXH || x || x || x || x || x !! !! !! !! || x || x !! !! !! !! !! !! !! !! !! !! !! !! !! ||x !! !!
+
| IXH || x || x || x || x || x || || || || || x || x || || || || || || || || || || || || || ||x || ||
 
|-
 
|-
| IXL || 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 !! !!
+
| IYH || x || x || x || x || x || || || || || || || x || x || || || || || || || || || || || ||x || ||
 
|-
 
|-
| IYL || x || x || x || x || x !! !! !! !! !! !! || x || x !! !! !! !! !! !! !! !! !! !! !! ||x !! !!
+
| IYL || x || x || x || x || x || || || || || || || x || x || || || || || || || || || || || ||x || ||
 
|-
 
|-
| BC !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! || x || x  
+
| BC || || || || || || || || || || || || || || || || || || || || || || || || || || x || x  
 
|-
 
|-
| DE !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! || x || x  
+
| DE || || || || || || || || || || || || || || || || || || || || || || || || || || x || x  
 
|-
 
|-
| HL !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! || x || x  
+
| HL || || || || || || || || || || || || || || || || || || || || || || || || || || x || x  
 
|-
 
|-
| SP !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! || x !! || x || x !! !! !! !! !! !! || x || x  
+
| SP || || || || || || || || || || || || || || || || x || || x || x || || || || || || || x || x  
 
|-
 
|-
| IX !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! || x || x  
+
| IX || || || || || || || || || || || || || || || || || || || || || || || || || || x || x  
 
|-
 
|-
| IY !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! || x || x  
+
| IY || || || || || || || || || || || || || || || || || || || || || || || || || || x || x  
 
|-
 
|-
| (BC) || x !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!
+
| (BC) || x || || || || || || || || || || || || || || || || || || || || || || || || || ||
 
|-
 
|-
| (DE) || x !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!
+
| (DE) || x || || || || || || || || || || || || || || || || || || || || || || || || || ||
 
|-
 
|-
| (HL) || x || x || x || x || x || x || x !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!
+
| (HL) || x || x || x || x || x || x || x || || || || || || || || || || || || || || || || || || || ||
 
|-
 
|-
| (IX+N) || 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 !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!
+
| (IY+N) || x || x || x || x || x || x || x || || || || || || || || || || || || || || || || || || || ||
 
|-
 
|-
| (NN) || x !! !! !! !! !! !! !! !! !! !! !! !! || x || x || x || x || x || x !! !! !! !! !! !! !! !!
+
| (NN) || x || || || || || || || || || || || || || x || x || x || x || x || x || || || || || || || ||
 
|}
 
|}
  
Line 153: Line 153:
 
[[Z80:/instructions-set:ldd|LDD]],[[Z80:/instructions-set:lddr|LDDR]],[[Z80:/instructions-set:ldi|LDI]],[[Z80:/instructions-set:ldir|LDIR]]
 
[[Z80:/instructions-set:ldd|LDD]],[[Z80:/instructions-set:lddr|LDDR]],[[Z80:/instructions-set:ldi|LDI]],[[Z80:/instructions-set:ldir|LDIR]]
  
Source: http://www.zilog.com/appnotes_download.php?FromPage=DirectLink&dn=UM0080&ft=User%20Manual&f=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTk2T0RBdmRXMHdNRGd3TG5Ca1pnPT0=
+
Source: [http://www.zilog.com/manage_directlink.php?filepath=docs/z80/um0080&extn=.pdf]
  
 
{{lowercase}}
 
{{lowercase}}

Revision as of 22:04, 5 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

LDD,LDDR,LDI,LDIR

Source: [1]