home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug034.arc / Z80.DOC < prev    next >
Text File  |  1979-12-31  |  9KB  |  402 lines

  1.         Z-80 Macro Library Documentation
  2.         --------------------------------
  3.  
  4. I.
  5.     The purpose of this library is to enable the assembly of the Z-80
  6.     instruction set on a CP/M sytem using the CP/M MAC macro assembler.
  7.  
  8.     This library is invoked with the pseudo-op:
  9.  
  10.         "  MACLIB  Z80  "
  11.  
  12. II.
  13.     The following symbols and notations are used in the individual macro
  14.     descriptions;
  15.  
  16.     r - Any of the 8 bit registers: A, B, C, D, E, H, L, or M
  17.     rr - Any of the 16 bit register pairs: BC, DE, HL, or SP
  18.     nn - 8 bit immediate data (0 through 255)
  19.     d  - 8 bit signed displacment (-128 through +127)
  20.     nnnn - 16 bit address or immediate data (0 through 65535)
  21.     b  - bit number (0-7, 7 is most significant, 0 is least)
  22.     addr - 16 bit address within PC+127 through PC-128
  23.     m(zzz) - Memory at address "zzz"
  24.  
  25. III.
  26.  
  27.  MACLIB ver.          Zilog ver           TDL ver
  28. --------------        -------------        -------------
  29.  
  30. LDX    r,d        LD    r,(IX+d)    MOV    r,d(IX)
  31.     Load register from indexed memory (with IX)
  32.  
  33. LDY    r,d        LD    r,(IY+d)    MOV    r,d(IY)
  34.     Load register from indexed memory (with IY)
  35.  
  36. STX    r,d        LD    (IX+d),r    MOV    d(IX),r
  37.     Store register to indexed memory (with IX)
  38.  
  39. STY    r,d        LD    (IY+d),r    MOV    d(IY),r
  40.     Store register to indexed memory (with IY)
  41.  
  42. MVIX    nn,d        LD    (IX+d),nn    MVI    d(IX)
  43.     Move immediate to indexed memory (with IX)
  44.  
  45. MVIY    nn,d        LD    (IY+d),nn    MVI    d(IY)
  46.     Move immediate to indexed memory (with IY)
  47.  
  48. LDAI            LD    A,I        LDAI
  49.     Move I to A
  50.  
  51. LDAR            LD    A,R        LDAR
  52.     Move R to A
  53.  
  54. STAI            LD    I,A        STAI
  55.     Move A to I
  56.  
  57. STAR            LD    R,A        STAR
  58.     Move A to R
  59.  
  60. LXIX    nnnn        LD    IX,nnnn        LXI    IX,nnnn
  61.     Load IX immediate (16 bits)
  62.  
  63. LXIY    nnnn        LD    IY,nnnn        LXI    IY,nnnn
  64.     Load IY immediate (16 bits)
  65.  
  66. LBCD    nnnn        LD    BC,(nnnn)    LBCD    nnnn
  67.     Load BC direct (from memory at nnnn)
  68.  
  69. LDED    nnnn        LD    DE,(nnnn)    LDED    nnnn
  70.     Load DE direct
  71.  
  72. LSPD    nnnn        LD    SP,(nnnn)    LSPD    nnnn
  73.     Load SP direct
  74.  
  75. LIXD    nnnn        LD    IX,(nnnn)    LIXD    nnnn
  76.     Load IX direct
  77.  
  78. LIYD    nnnn        LD    IY,(nnnn)    LIYD    nnnn
  79.     Load IY direct
  80.  
  81. SBCD    nnnn        LD    (nnnn),BC    SBCD    nnnn
  82.     Store BC direct (to memory at nnnn)
  83.  
  84. SDED    nnnn        LD    (nnnn),DE    SDED    nnnn
  85.     Store DE direct
  86.  
  87. SSPD    nnnn        LD    (nnnn),SP    SSPD    nnnn
  88.     Store SP direct
  89.  
  90. SIXD    nnnn        LD    (nnnn),IX    SIXD    nnnn
  91.     Store IX direct
  92.  
  93. SIYD    nnnn        LD    (nnnn),IY    SIYD    nnnn
  94.     Store IY direct
  95.  
  96. SPIX            LD    SP,IX        SPIX
  97.     Copy IX to the SP
  98.  
  99. SPIY            LD    SP,IY        SPIY
  100.     Copy IY to the SP
  101.  
  102. PUSHIX            PUSH    IX        PUSH    IX
  103.     Push IX into the stack
  104.  
  105. PUSHIY            PUSH    IY        PUSH    IY
  106.     Push IY into the stack
  107.  
  108. POPIX            POP    IX        POP    IX
  109.     Pop IX from the stack
  110.  
  111. POPIY            POP    IY        POP    IY
  112.     Pop IY from the stack
  113.  
  114. EXAF            EX    AF,AF'        EXAF
  115.     Exchange AF and the alternate, AF'
  116.  
  117. EXX            EXX            EXX
  118.     Exchange BC DE HL with BC' DE' HL'
  119.  
  120. XTIX            EX    (SP),IX        XTIX
  121.     Exchange IX with the top of the stack
  122.  
  123. XTIY            EX    (SP),IY        XTIY
  124.     Exchange IY with the top of the stack
  125.  
  126. LDI            LDI            LDI
  127.     Move m(HL) to m(DE), increment DE and HL, decrement BC
  128.  
  129. LDIR            LDIR            LDIR
  130.     Repeat LDI until BC = 0
  131.  
  132. LDD            LDD            LDD
  133.     Move m(HL) to m(DE), decrement HL, DE, and BC
  134.  
  135. LDDR            LDDR            LDDR
  136.     Repeat LDD until BC = 0
  137.  
  138. CCI            CPI            CCI
  139.     Compare A with m(HL), increment HL, decrement BC
  140.  
  141. CCIR            CPIR            CCIR
  142.     Repeat CCI until BC = 0  or  A = m(HL)
  143.  
  144. CCD            CPD            CCD
  145.     Compare A with m(HL), decrement HL and BC
  146.  
  147. CCDR            CPDR            CCDR
  148.     Repeat CCD until BC = 0 or A = m(HL)
  149.  
  150. ADDX    d        ADD    (IX+d)        ADD    d(IX)
  151.     Indexed add to A
  152.  
  153. ADDY    d        ADD    (IY+d)        ADD    d(IY)
  154.     Indexed add to A
  155.  
  156. ADCX    d        ADC    (IX+d)        ADC    d(IX)
  157.     Indexed add with carry
  158.  
  159. ADCY    d        ADC    (IY+d)        ADC    d(IY)
  160.     Indexed add with carry
  161.  
  162. SUBX    d        SUB    (IX+d)        SUB    d(IX)
  163.     Indexed subtract
  164.  
  165. SUBY    d        SUB    (IY+d)        SUB    d(IY)
  166.     Indexed Subtract
  167.  
  168. SBCX    d        SBC    (IX+d)        SBB    d(IX)
  169.     Indexed subtract with "borrow"
  170.  
  171. SBCY    d        SBC    (IY+d)        SBB    d(IY)
  172.     Indexed subtract with borrow
  173.  
  174. ANDX    d        AND    (IX+d)        ANA    d(IX)
  175.     Indexed logical and
  176.  
  177. ANDY    d        AND    (IY+d)        ANA    d(IY)
  178.     Indexed logical and
  179.  
  180. XORX    d        XOR    (IX+d)        XRA    d(IX)
  181.     Indexed logical exclusive or
  182.  
  183. XORY    d        XOR    (IY+d)        XRA    d(IY)
  184.     Indexed logical exclusive or
  185.  
  186. ORX    d        OR    (IX+d)        ORA    d(IX)
  187.     Indexed logical or
  188.  
  189. ORY    d        OR    (IY+d)        ORA    d(IY)
  190.     Indexed logical exclusive or
  191.  
  192. CMPX    d        CP    (IX+d)        CMP    d(IX)
  193.     Indexed compare
  194.  
  195. CMPY    d        CP    (IY+d)        CMP    d(IY)
  196.     Index compare
  197.  
  198. INRX    d        INC    (IX+d)        INR    d(IX)
  199.     Increment memory at m(IX+d)
  200.  
  201. INRY    d        INC    (IY+d)        INR    d(IY)
  202.     Increment memory at m(IY+d)
  203.  
  204. DCRX    d        INC    (IX+d)        INR    d(IX)
  205.     Decrement memory at m(IX+d)
  206.  
  207. DCRY    d        DEC    (IY+d)        DCR    d(IY)
  208.     Decrement memory at m(IX+d)
  209.  
  210. NEG            NEG            NEG
  211.     Negate A (two's complement)
  212.  
  213. IM0            IM0            IM0
  214.     Set interrupt mode 0
  215.  
  216. IM1            IM1            IM1
  217.     Set interrupt mode 1
  218.  
  219. IM2            IM2            IM2
  220.     Set interrupt mode 2
  221.  
  222. DADC    rr        ADC    HL,rr        DADC    rr
  223.     Add with carry rr to HL
  224.  
  225. DSBC    rr        SBC    HL,rr        DSBC    rr
  226.     Subtract with "borrow" rr from HL
  227.  
  228. DADX    rr        ADD    IX,rr        DADX    rr
  229.     Add rr to IX (rr may be BC, DE, SP, IX)
  230.  
  231. DADY    rr        ADD    IY,rr        DADY    rr
  232.     Add rr to IY (rr may be BC, DE, SP, IY)
  233.  
  234. INXIX            INC    IX        INX    IX
  235.     Increment IX
  236.  
  237. INXIY            INC    IY        INX    IY
  238.     Increment IY
  239.  
  240. DCXIX            DEC    IX        DCX    IX
  241.     Decrement IX
  242.  
  243. DCXIY            DEC    IY        DCX    IY
  244.     Decrement IY
  245.  
  246. BIT    b,r        BIT    b,r        BIT    b,r
  247.     Test bit b in register r
  248.  
  249. SETB    b,r        SET    b,r        SET    b,r
  250.     Set bit b in register r
  251.  
  252. RES    b,r        RES    b,r        RES    b,r
  253.     Reset bit b in register r
  254.  
  255. BITX    b,d        BIT    b,(IX+d)    BIT    b,d(IX)
  256.     Test bit b in memory at m(IX+d)
  257.  
  258. BITY    b,d        BIT    b,(IY+d)    BIT    b,d(IY)
  259.     Test bit b in memory at m(IY+d)
  260.  
  261. SETX    b,d        SET    b,(IX+d)    SET    b,d(IX)
  262.     Set bit b in memory at m(IX+d)
  263.  
  264. SETY    b,d        SET    b,(IY+d)    SET    b,d(IY)
  265.     Set bit b in memory at m(IY+d)
  266.  
  267. RESX    b,d        RES    b,(IX+d)    RES    b,d(IX)
  268.     Reset bit b in memory at m(IX+d)
  269.  
  270. RESY    b,d        RES    b,(IY+d)    RES    b,d(IY)
  271.     Reset bit b in memory at m(IY+d)
  272.  
  273. JR    addr        JR    addr-$        JMPR    addr
  274.     Jump relative unconditional
  275.  
  276. JRC    addr        JR    C,addr-$    JRC    addr
  277.     Jump relative if Carry indicator true
  278.  
  279. JRNC    addr        JR    NC,addr-$    JRNC    addr
  280.     Jump relative if carry indicator false
  281.  
  282. JRZ    addr        JR    Z,addr-$    JRC    addr
  283.     Jump relative if Zero indicator true
  284.  
  285. JRNZ    addr        JR    NZ,addr-$    JRNZ    addr
  286.     Jump relative if Zero indicator false
  287.  
  288. DJNZ    addr        DJNZ    addr-$        DJNZ    addr
  289.     Decrement B, jump relative if non-zero
  290.  
  291. PCIX            JMP    (IX)        PCIX
  292.     Jump to address in IX ie, Load PC from IX
  293.  
  294. PCIY            JMP    (IY)        PCIY
  295.     Jump to address in IY
  296.  
  297. RETI            RETI            RETI
  298.     Return from interrupt
  299.  
  300. RETN            RETN            RETN
  301.     Return from non-maskable interrupt
  302.  
  303. INP    r        IN    r,(C)        INP    r
  304.     Input from port C to register r
  305.  
  306. OUTP    r        OUT    (C),r        OUTP    r
  307.     Output from register r to port (C)
  308.  
  309. INI            INI            INI
  310.     Input from port (C) to m(HL), increment HL, decrement b
  311.  
  312. INIR            INIR            INIR
  313.     Input from port (C) to m(HL), increment HL, decrement B, repeat if B <> 0
  314.  
  315. OUTI            OTI            OUTI
  316.     Output from m(HL) to port (C), increment HL, decrement B
  317.  
  318. OUTIR            OTIR            OUTIR
  319.     Repeat OUTI until B = 0
  320.  
  321. IND            IND            IND
  322.     Input from port (C) to m(HL), decrement HL & B
  323.  
  324. INDR            INDR            INDR
  325.     Repeat IND until B = 0
  326.  
  327. OUTD            OTD            OUTD
  328.     Output from m(HL) to port (C), decrement HL & B
  329.  
  330. OUTDR            OTDR            OUTDR
  331.     Repeat OUTD until B = 0
  332.  
  333. RLCR    r        RLC    r        RLCR    r
  334.     Rotate left circular register
  335.  
  336. RLCX    d        RLC    (IX+d)        RLCR    d(IX)
  337.     Rotate left circular indexed memory
  338.  
  339. RLCY    d        RLC    (IY+d)        RLCR    d(IY)
  340.     Rotate left circular indexed memory
  341.  
  342. RALR    r        RL    r        RALR    r
  343.     Rotate left arithmetic register
  344.  
  345. RALX    d        RL    (IX+d)        RALR    d(IX)
  346.     Rotate left arithmetic indexed memory
  347.  
  348. RALY    d        RL    (IY+d)        RALR    d(IY)
  349.     Rotate left arithmetic indexed memory
  350.  
  351. RRCR    r        RRC    r        RRCR    r
  352.     Rotate right circular register
  353.  
  354. RRCX    d        RRC    (IX+d)        RRCR    d(IX)
  355.     Rotate right circular indexed
  356.  
  357. RRCY    d        RRC    (IY+d)        RRCR    d(IY)
  358.     Rotate right circular indexed
  359.  
  360. RARR    r        RR    r        RARR    r
  361.     Rotate right arithmetic register
  362.  
  363. RARX    d        RR    (IX+d)        RARR    d(IX)
  364.     Rotate right arithmetic indexed memory
  365.  
  366. RARY    d        RR    (IY+d)        RARR    d(IY)
  367.     Rotate right arithmetic indexed memory
  368.  
  369. SLAR    r        SLA    r        SLAR    r
  370.     Shift left register
  371.  
  372. SLAX    d        SLA    (IX+d)        SLAR    d(IX)
  373.     Shift left indexed memory
  374.  
  375. SLAY    d        SLA    (IY+d)        SLAR    d(IY)
  376.     Shift left indexed memory
  377.  
  378. SRAR    r        SRA    r        SRAR    r
  379.     Shift right arithmetic register
  380.  
  381. SRAX    d        SRA    (IX+d)        SRAR    d(IX)
  382.     Shift right arithmetic indexed memory
  383.  
  384. SRAY    d        SRA    (IY+d)        SRAR    d(IY)
  385.     Shift right arithmetic indexed memory
  386.  
  387. SRLR    r        SRL    r        SRLR    r
  388.     Shift right logical register
  389.  
  390. SRLX    d        SRL    (IX+d)        SRLR    d(IX)
  391.     Shift right logical indexed memory
  392.  
  393. SRLY    d        SRL    (IY+d)        SRLR    d(IY)
  394.     Shift right logical indexed memory
  395.  
  396. RLD            RLD            RLD
  397.     Rotate left digit
  398.  
  399. RRD            RRD            RRD
  400.     Rotate right digit
  401.  
  402.