Z80 Instruction Set

From WikiTI
Revision as of 19:00, 21 February 2006 by 207.67.57.99 (Talk)

Jump to: navigation, search

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.