Zilog Z80 注册

寄存器:8 位:ABCDEHLFIR,16 位:SPPCIXIY,以及一些 8b 寄存器的阴影:A'B'C'D'E'H'L'F'

大多数 8 位寄存器也可以成对使用为 16 位寄存器:AFBCDEHL

SP堆栈指针,标记堆栈内存的底部(由 PUSH / POP / CALL / RET 指令使用)。
PC程序计数器,指向当前执行的指令。
I中断寄存器,为 IM 2 中断模式提供高字节的向量表地址。
R刷新寄存器,每次 CPU 取出操作码(或操作码前缀)时递增。
一些 Z80 处理器上存在一些非官方指令来操作 IX 的 8 位部分作为 IXH:IXLIY 作为 IYH:IYL

任何指令都不能直接访问阴影变体,EX AF,AF'指令将在 AFAF'之间交换,EXX 指令将交换 BC,DE,HLBC',DE',HL'

将值加载到寄存器中:

    ; from other register
    LD   I,A        ; copies value in A into I (8 bit)
    LD   BC,HL      ; copies value in HL into BC (16 bit)
    ; directly with value encoded in instruction machine code
    LD   B,d8       ; 8b value d8 into B
    LD   DE,d16     ; 16b value d16 into DE
    ; from a memory (ROM/RAM)
    LD   A,(HL)     ; value from memory addressed by HL into A
    LD   A,(a16)    ; value from memory with address a16 into A
    LD   HL,(a16)   ; 16b value from memory with address a16 into HL
    POP  IX         ; 16b value popped from stack into IX
    LD   A,(IY+a8)  ; IX and IY allows addressing with 8b offset
    ; from I/O port (for writing value at I/O port use "OUT")
    IN   A,(C)      ; reads I/O port C, value goes to A

可能的源操作数和目标操作数的正确组合是有限的(例如,LD H,(a16) 不存在)。

将值存储到内存中:

    LD   (HL),D     ; value D stored into memory addressed by HL
    LD   (a16),A    ; value A into memory with address a16
    LD   (a16),HL   ; value HL into 16b of memory with address a16
    LD   (IX+a8),d8 ; value d8 into memory at address IX+a8
    LD   (IY+a8),B  ; value B into memory at address IY+a8
    ; specials ;)
    PUSH DE         ; 16b value DE pushed to stack
    CALL a16        ; while primarily used for execution branching
      ; it also stores next instruction address into stack