Difference between revisions of "Z80 Instruction Set"

From WikiTI
Jump to: navigation, search
Line 1: Line 1:
{{Wikify}}
+
Not a complete list, but most commonly used instructions are given.  For a complete list with opcodes and number of clock cycles taken, go [http://nwps.ws/~dragonfire/Asmin28/lesson/toc.html here]
  
 
== Data Movement ==
 
== Data Movement ==
'''EX'''
+
===EX===
 
Three possible arguments:
 
Three possible arguments:
  
Line 15: Line 15:
  
  
'''EXX'''
+
===EXX===
 
Swap BC, DE and HL with their shadows
 
Swap BC, DE and HL with their shadows
  
  
'''LD'''
+
===LD===
 
Four main arguments:
 
Four main arguments:
  
Line 33: Line 33:
 
''LD reg, (imm16)''
 
''LD reg, (imm16)''
 
Does the opposite of ''LD (imm16), reg''
 
Does the opposite of ''LD (imm16), reg''
 +
 +
 +
===LDIR===
 +
Copies a byte from (HL) to (DE), increments DE and HL, then decrements BC.  The instruction is repeated if BC is not 0.  Interrupts are allowed to trigger while this instruction is running.
 +
 +
 +
===PUSH===
 +
Used as ''PUSH reg16'' where reg16 is a register pair or index register.  Decrements SP, copies regMSB to (SP), decrements SP again, then copies regLSB to (SP).
 +
 +
 +
===POP===
 +
Same syntax as PUSH.  Copies (SP) to regLSB, increments SP, copies (SP) to regMSB, then increments SP again.  The word based at the starting value of SP is zeroed.

Revision as of 18:00, 21 February 2006

Not a complete list, but most commonly used instructions are given. For a complete list with opcodes and number of clock cycles taken, go here

Data Movement

EX

Three possible arguments:

EX DE, HL Swaps H with D and L with E

EX AF, AF' Swaps AF with its shadow

EX (SP), HL Swaps (SP) with L and (SP+1) with H. Index registers are also valid


EXX

Swap BC, DE and HL with their shadows


LD

Four main arguments:

LD reg, # Sets the eight or 16 bit contents of reg to #

LD reg2, reg1 Copies the contents of 8 bit reg1 to reg2

LD (imm16), reg Copies the value of 8 or 16 bit reg to 16 bit memory address imm16. Programmers should remember that 16 bit values are stored little-endian.

LD reg, (imm16) Does the opposite of LD (imm16), reg


LDIR

Copies a byte from (HL) to (DE), increments DE and HL, then decrements BC. The instruction is repeated if BC is not 0. Interrupts are allowed to trigger while this instruction is running.


PUSH

Used as PUSH reg16 where reg16 is a register pair or index register. Decrements SP, copies regMSB to (SP), decrements SP again, then copies regLSB to (SP).


POP

Same syntax as PUSH. Copies (SP) to regLSB, increments SP, copies (SP) to regMSB, then increments SP again. The word based at the starting value of SP is zeroed.