home *** CD-ROM | disk | FTP | other *** search
- ;;
- ;; MACLIB: Z80.LIB
- ;; Author: Joe Wright
- ;; Date: 29 May 1990
- ;;
- ;; For use with MAC, RMAC or M80 to produce Zilog Z80 extensions
- ;; to the Intel 8080 instruction set.
- ;;
- ;; Note: Convention has it that MACRO labels begin with '?'
- ;; internal MACRO's with '@'. Avoid these in your
- ;; source program.
- ;;
- ;; @CHK MACRO FOR CHECKING 8 BIT DISPLACMENTS (-128..+127)
- ;;
- ?M80 SET 2 ; Evaluates False for RMAC or MAC
- ;;
- @CHK MACRO ?DD
- IF ?M80
- IF1
- EXITM
- ELSE
- IF (?DD + 128) GT 255
- 'DISPLACEMENT/RANGE ERROR - Z80 LIB'
- ENDIF
- EXITM
- ENDIF
- ENDIF
- ENDM
- ;;
- ;; MACRO FORMATS
- ;; ----- -------
- ;; INTEL ZILOG TDL
- ;; ----- ------------- ---
- ;; ADDX D ADD A,(IX+D) ADD D(IX)
- ;; ADDY D ADD A,(IY+D) ADD D(IY)
- ;; ADCX D ADC A,(IX+D) ADC D(IX)
- ;; ADCY D ADC A,(IY+D) ADC D(IY)
- ;; ANDX D AND (IX+D) ANA D(IX)
- ;; ANDY D AND (IY+D) ANA D(IY)
- ;; BIT B,R BIT B,R BIT B,R
- ;; BITX B,D BIT B,(IX+D) BIT B,D(IX)
- ;; BITY B,D BIT B,(IY+D) BIT B,D(IY)
- ;; CCD CPD CCD
- ;; CCDR CPDR CCDR
- ;; CCI CPI CCI
- ;; CCIR CPIR CCIR
- ;; CMPX D CP (IX+D) CMP D(IX)
- ;; CMPY D CP (IY+D) CMP D(IY)
- ;; DADC RR ADC HL,RR DADC RR
- ;; DADX RR ADD IX,RR DADX RR
- ;; DADY RR ADD IY,RR DADY RR
- ;; DCRX D INC (IX+D) INR D(IX)
- ;; DCRY D DEC (IY+D) DCR D(IY)
- ;; DCXIX DEC IX DCX IX
- ;; DCXIY DEC IY DCX IY
- ;; DJNZ ADDR DJNZ ADDR DJNZ ADDR
- ;; DSBC RR SBC HL,RR DSBC RR
- ;; EXAF EX AF,AF' EXAF
- ;; EXX EXX EXX
- ;; IM0 IM0 IM0
- ;; IM1 IM1 IM1
- ;; IM2 IM2 IM2
- ;; IND IND IND
- ;; INDR INDR INDR
- ;; INI INI INI
- ;; INIR INIR INIR
- ;; INP R IN R,(C) INP R
- ;; INRX D INC (IX+D) INR D(IX)
- ;; INRY D INC (IY+D) INR D(IY)
- ;; INXIX INC IX INX IX
- ;; INXIY INC IY INX IY
- ;; JR ADDR JR ADDR JMPR ADDR
- ;; JRC ADDR JR C,ADDR JRC ADDR
- ;; JRNC ADDR JR NC,ADDR JRNC ADDR
- ;; JRNZ ADDR JR NZ,ADDR JRNZ ADDR
- ;; JRZ ADDR JR Z,ADDR JRZ ADDR
- ;; LBCD NNNN LD BC,(NNNN) LBCD NNNN
- ;; LDAI LD A,I LDAI
- ;; LDAR LD A,R LDAR
- ;; LDD LDD LDD
- ;; LDDR LDDR LDDR
- ;; LDED NNNN LD DE,(NNNN) LDED NNNN
- ;; LDI LDI LDI
- ;; LDIR LDIR LDIR
- ;; LDX R,D LD R,(IX+D) MOV R,D(IX)
- ;; LDY R,D LD R,(IY+D) MOV R,D(IY)
- ;; LIXD NNNN LD IX,(NNNN) LIXD NNNN
- ;; LIYD NNNN LD IY,(NNNN) LIYD NNNN
- ;; LSPD NNNN LD SP,(NNNN) LSPD NNNN
- ;; LXIX NNNN LD IX,NNNN LXI IX,NNNN
- ;; LXIY NNNN LD IY,NNNN LXI IY,NNNN
- ;; MVIX NN,D LD (IX+D),NN MVI D(IX)
- ;; MVIY NN,D LD (IY+D),NN MVI D(IY)
- ;; NEG NEG NEG
- ;; ORX D OR (IX+D) ORA D(IX)
- ;; ORY D OR (IY+D) ORA D(IY)
- ;; OUTD OTD OUTD
- ;; OUTDR OTDR OUTDR
- ;; OUTI OTI OUTI
- ;; OUTIR OTIR OUTIR
- ;; OUTP R OUT (C),R OUTP R
- ;; PCIX JMP (IX) PCIX
- ;; PCIY JMP (IY) PCIY
- ;; POPIX POP IX POP IX
- ;; POPIY POP IY POP IY
- ;; PUSHIX PUSH IX PUSH IX
- ;; PUSHIY PUSH IY PUSH IY
- ;; RALR R RL R RALR R
- ;; RALX D RL (IX+D) RALR D(IX)
- ;; RALY D RL (IY+D) RALR D(IY)
- ;; RARR R RR R RARR R
- ;; RARX D RR (IX+D) RARR D(IX)
- ;; RARY D RR (IY+D) RARR D(IY)
- ;; RES B,R RES B,R RES B,R
- ;; RESX B,D RES B,(IX+D) RES B,D(IX)
- ;; RESY B,D RES B,(IY+D) RES B,D(IY)
- ;; RETI RETI RETI
- ;; RETN RETN RETN
- ;; RLCR R RLC R RLCR R
- ;; RLCX D RLC (IX+D) RLCR D(IX)
- ;; RLCY D RLC (IY+D) RLCR D(IY)
- ;; RLD RLD RLD
- ;; RRCR R RRC R RRCR R
- ;; RRCX D RRC (IX+D) RRCR D(IX)
- ;; RRCY D RRC (IY+D) RRCR D(IY)
- ;; RRD RRD RRD
- ;; SBCD NNNN LD (NNNN),BC SBCD NNNN
- ;; SBCX D SBC (IX+D) SBB D(IX)
- ;; SBCY D SBC (IY+D) SBB D(IY)
- ;; SDED NNNN LD (NNNN),DE SDED NNNN
- ;; SETB B,R SET B,R SET B,R
- ;; SETX B,D SET B,(IX+D) SET B,D(IX)
- ;; SETY B,D SET B,(IY+D) SET B,D(IY)
- ;; SIXD NNNN LD (NNNN),IX SIXD NNNN
- ;; SIYD NNNN LD (NNNN),IY SIYD NNNN
- ;; SLAR R SLA R SLAR R
- ;; SLAX D SLA (IX+D) SLAR D(IX)
- ;; SLAY D SLA (IY+D) SLAR D(IY)
- ;; SPIX LD SP,IX SPIX
- ;; SPIY LD SP,IY SPIY
- ;; SRAR R SRA R SRAR R
- ;; SRAX D SRA (IX+D) SRAR D(IX)
- ;; SRAY D SRA (IY+D) SRAR D(IY)
- ;; SRLR R SRL R SRLR R
- ;; SRLX D SRL (IX+D) SRLR D(IX)
- ;; SRLY D SRL (IY+D) SRLR D(IY)
- ;; SSPD NNNN LD (NNNN),SP SSPD NNNN
- ;; STAI LD I,A STAI
- ;; STAR LD R,A STAR
- ;; STX R,D LD (IX+D),R MOV D(IX),R
- ;; STY R,D LD (IY+D),R MOV D(IY),R
- ;; SUBX D SUB (IX+D) SUB D(IX)
- ;; SUBY D SUB (IY+D) SUB D(IY)
- ;; XORX D XOR (IX+D) XRA D(IX)
- ;; XORY D XOR (IY+D) XRA D(IY)
- ;; XTIX EX (SP),IX XTIX
- ;; XTIY EX (SP),IY XTIY
- ;;
- ;;
- ;; Standard Zilog Operation Codes
- ;;
- JR MACRO ?N
- @CHK ?N-$-2
- DB 18H,?N-$-1
- ENDM
-
- JRC MACRO ?N
- @CHK ?N-$-2
- DB 38H,?N-$-1
- ENDM
-
- JRNC MACRO ?N
- @CHK ?N-$-2
- DB 30H,?N-$-1
- ENDM
-
- JRZ MACRO ?N
- @CHK ?N-$-2
- DB 28H,?N-$-1
- ENDM
-
- JRNZ MACRO ?N
- @CHK ?N-$-2
- DB 20H,?N-$-1
- ENDM
-
- DJNZ MACRO ?N
- @CHK ?N-$-2
- DB 10H,?N-$-1
- ENDM
- ;;
- ;;
- LDX MACRO ?R,?D
- @CHK ?D
- DB 0DDH,?R*8+46H,?D
- ENDM
-
- LDY MACRO ?R,?D
- @CHK ?D
- DB 0FDH,?R*8+46H,?D
- ENDM
-
- STX MACRO ?R,?D
- @CHK ?D
- DB 0DDH,70H+?R,?D
- ENDM
-
- STY MACRO ?R,?D
- @CHK ?D
- DB 0FDH,70H+?R,?D
- ENDM
-
- MVIX MACRO ?N,?D
- @CHK ?D
- DB 0DDH,36H,?D,?N
- ENDM
-
- MVIY MACRO ?N,?D
- @CHK ?D
- DB 0FDH,36H,?D,?N
- ENDM
-
- LDAI MACRO
- DB 0EDH,57H
- ENDM
-
- LDAR MACRO
- DB 0EDH,5FH
- ENDM
-
- STAI MACRO
- DB 0EDH,47H
- ENDM
-
- STAR MACRO
- DB 0EDH,4FH
- ENDM
-
- LXIX MACRO ?NNNN
- DB 0DDH,21H
- DW ?NNNN
- ENDM
-
- LXIY MACRO ?NNNN
- DB 0FDH,21H
- DW ?NNNN
- ENDM
-
- LDED MACRO ?NNNN
- DB 0EDH,5BH
- DW ?NNNN
- ENDM
-
- LBCD MACRO ?NNNN
- DB 0EDH,4BH
- DW ?NNNN
- ENDM
-
- LSPD MACRO ?NNNN
- DB 0EDH,07BH
- DW ?NNNN
- ENDM
-
- LIXD MACRO ?NNNN
- DB 0DDH,2AH
- DW ?NNNN
- ENDM
-
- LIYD MACRO ?NNNN
- DB 0FDH,2AH
- DW ?NNNN
- ENDM
-
- SBCD MACRO ?NNNN
- DB 0EDH,43H
- DW ?NNNN
- ENDM
-
- SDED MACRO ?NNNN
- DB 0EDH,53H
- DW ?NNNN
- ENDM
-
- SSPD MACRO ?NNNN
- DB 0EDH,73H
- DW ?NNNN
- ENDM
-
- SIXD MACRO ?NNNN
- DB 0DDH,22H
- DW ?NNNN
- ENDM
-
- SIYD MACRO ?NNNN
- DB 0FDH,22H
- DW ?NNNN
- ENDM
-
- SPIX MACRO
- DB 0DDH,0F9H
- ENDM
-
- SPIY MACRO
- DB 0FDH,0F9H
- ENDM
-
- PUSHIX MACRO
- DB 0DDH,0E5H
- ENDM
-
- PUSHIY MACRO
- DB 0FDH,0E5H
- ENDM
-
- POPIX MACRO
- DB 0DDH,0E1H
- ENDM
-
- POPIY MACRO
- DB 0FDH,0E1H
- ENDM
-
- EXAF MACRO
- DB 08H
- ENDM
-
- EXX MACRO
- DB 0D9H
- ENDM
-
- XTIX MACRO
- DB 0DDH,0E3H
- ENDM
-
- XTIY MACRO
- DB 0FDH,0E3H
- ENDM
-
- LDI MACRO
- DB 0EDH,0A0H
- ENDM
-
- LDIR MACRO
- DB 0EDH,0B0H
- ENDM
-
- LDD MACRO
- DB 0EDH,0A8H
- ENDM
-
- LDDR MACRO
- DB 0EDH,0B8H
- ENDM
-
- CCI MACRO
- DB 0EDH,0A1H
- ENDM
-
- CCIR MACRO
- DB 0EDH,0B1H
- ENDM
-
- CCD MACRO
- DB 0EDH,0A9H
- ENDM
-
- CCDR MACRO
- DB 0EDH,0B9H
- ENDM
-
- ADDX MACRO ?D
- @CHK ?D
- DB 0DDH,86H,?D
- ENDM
-
- ADDY MACRO ?D
- @CHK ?D
- DB 0FDH,86H,?D
- ENDM
-
- ADCX MACRO ?D
- @CHK ?D
- DB 0DDH,8EH,?D
- ENDM
-
- ADCY MACRO ?D
- @CHK ?D
- DB 0FDH,8EH,?D
- ENDM
-
- SUBX MACRO ?D
- @CHK ?D
- DB 0DDH,96H,?D
- ENDM
-
- SUBY MACRO ?D
- @CHK ?D
- DB 0FDH,96H,?D
- ENDM
-
- SBCX MACRO ?D
- @CHK ?D
- DB 0DDH,9EH,?D
- ENDM
-
- SBCY MACRO ?D
- @CHK ?D
- DB 0FDH,9EH,?D
- ENDM
-
- ANDX MACRO ?D
- @CHK ?D
- DB 0DDH,0A6H,?D
- ENDM
-
- ANDY MACRO ?D
- @CHK ?D
- DB 0FDH,0A6H,?D
- ENDM
-
- XORX MACRO ?D
- @CHK ?D
- DB 0DDH,0AEH,?D
- ENDM
-
- XORY MACRO ?D
- @CHK ?D
- DB 0FDH,0AEH,?D
- ENDM
-
- ORX MACRO ?D
- @CHK ?D
- DB 0DDH,0B6H,?D
- ENDM
-
- ORY MACRO ?D
- @CHK ?D
- DB 0FDH,0B6H,?D
- ENDM
-
- CMPX MACRO ?D
- @CHK ?D
- DB 0DDH,0BEH,?D
- ENDM
-
- CMPY MACRO ?D
- @CHK ?D
- DB 0FDH,0BEH,?D
- ENDM
-
- INRX MACRO ?D
- @CHK ?D
- DB 0DDH,34H,?D
- ENDM
-
- INRY MACRO ?D
- @CHK ?D
- DB 0FDH,34H,?D
- ENDM
-
- DCRX MACRO ?D
- @CHK ?D
- DB 0DDH,035H,?D
- ENDM
-
- DCRY MACRO ?D
- @CHK ?D
- DB 0FDH,35H,?D
- ENDM
-
- NEG MACRO
- DB 0EDH,44H
- ENDM
-
- IM0 MACRO
- DB 0EDH,46H
- ENDM
-
- IM1 MACRO
- DB 0EDH,56H
- ENDM
-
- IM2 MACRO
- DB 0EDH,5EH
- ENDM
-
- ;;
- ;; Double Register Definitions
- ;;
- ??BC EQU 0
- ??DE EQU 2
- ??HL EQU 4
- ??IX EQU 4
- ??IY EQU 4
- ??SP EQU 6
-
- DADC MACRO ?R
- DB 0EDH,??&?R*8+4AH
- ENDM
-
- DSBC MACRO ?R
- DB 0EDH,??&?R*8+42H
- ENDM
-
- DADX MACRO ?R
- DB 0DDH,??&?R*8+09H
- ENDM
-
- DADY MACRO ?R
- DB 0FDH,??&?R*8+09H
- ENDM
-
- INXIX MACRO
- DB 0DDH,23H
- ENDM
-
- INXIY MACRO
- DB 0FDH,23H
- ENDM
-
- DCXIX MACRO
- DB 0DDH,2BH
- ENDM
-
- DCXIY MACRO
- DB 0FDH,2BH
- ENDM
-
- BIT MACRO ?N,?R
- DB 0CBH,?N*8+?R+40H
- ENDM
-
- SETB MACRO ?N,?R
- DB 0CBH,?N*8+?R+0C0H
- ENDM
-
- RES MACRO ?N,?R
- DB 0CBH,?N*8+?R+80H
- ENDM
-
- BITX MACRO ?N,?D
- @CHK ?D
- DB 0DDH,0CBH,?D,?N*8+46H
- ENDM
-
- BITY MACRO ?N,?D
- @CHK ?D
- DB 0FDH,0CBH,?D,?N*8+46H
- ENDM
-
- SETX MACRO ?N,?D
- @CHK ?D
- DB 0DDH,0CBH,?D,?N*8+0C6H
- ENDM
-
- SETY MACRO ?N,?D
- @CHK ?D
- DB 0FDH,0CBH,?D,?N*8+0C6H
- ENDM
-
- RESX MACRO ?N,?D
- @CHK ?D
- DB 0DDH,0CBH,?D,?N*8+86H
- ENDM
-
- RESY MACRO ?N,?D
- @CHK ?D
- DB 0FDH,0CBH,?D,?N*8+86H
- ENDM
-
-
- PCIX MACRO
- DB 0DDH,0E9H
- ENDM
-
- PCIY MACRO
- DB 0FDH,0E9H
- ENDM
-
- RETI MACRO
- DB 0EDH,4DH
- ENDM
-
- RETN MACRO
- DB 0EDH,45H
- ENDM
-
- INP MACRO ?R
- DB 0EDH,?R*8+40H
- ENDM
-
- OUTP MACRO ?R
- DB 0EDH,?R*8+41H
- ENDM
-
- INI MACRO
- DB 0EDH,0A2H
- ENDM
-
- INIR MACRO
- DB 0EDH,0B2H
- ENDM
-
- IND MACRO
- DB 0EDH,0AAH
- ENDM
-
- INDR MACRO
- DB 0EDH,0BAH
- ENDM
-
- OUTI MACRO
- DB 0EDH,0A3H
- ENDM
-
- OUTIR MACRO
- DB 0EDH,0B3H
- ENDM
-
- OUTD MACRO
- DB 0EDH,0ABH
- ENDM
-
- OUTDR MACRO
- DB 0EDH,0BBH
- ENDM
-
-
- RLCR MACRO ?R
- DB 0CBH,?R
- ENDM
-
- RLCX MACRO ?D
- @CHK ?D
- DB 0DDH,0CBH,?D,06H
- ENDM
-
- RLCY MACRO ?D
- @CHK ?D
- DB 0FDH,0CBH,?D,06H
- ENDM
-
- RALR MACRO ?R
- DB 0CBH,10H+?R
- ENDM
-
- RALX MACRO ?D
- @CHK ?D
- DB 0DDH,0CBH,?D,16H
- ENDM
-
- RALY MACRO ?D
- @CHK ?D
- DB 0FDH,0CBH,?D,16H
- ENDM
-
- RRCR MACRO ?R
- DB 0CBH,08H + ?R
- ENDM
-
- RRCX MACRO ?D
- @CHK ?D
- DB 0DDH,0CBH,?D,0EH
- ENDM
-
- RRCY MACRO ?D
- @CHK ?D
- DB 0FDH,0CBH,?D,0EH
- ENDM
-
- RARR MACRO ?R
- DB 0CBH,18H + ?R
- ENDM
-
- RARX MACRO ?D
- @CHK ?D
- DB 0DDH,0CBH,?D,1EH
- ENDM
-
- RARY MACRO ?D
- @CHK ?D
- DB 0FDH,0CBH,?D,1EH
- ENDM
-
- SLAR MACRO ?R
- DB 0CBH,20H + ?R
- ENDM
-
- SLAX MACRO ?D
- @CHK ?D
- DB 0DDH,0CBH,?D,26H
- ENDM
-
- SLAY MACRO ?D
- @CHK ?D
- DB 0FDH,0CBH,?D,26H
- ENDM
-
- SRAR MACRO ?R
- DB 0CBH,28H+?R
- ENDM
-
- SRAX MACRO ?D
- @CHK ?D
- DB 0DDH,0CBH,?D,2EH
- ENDM
-
- SRAY MACRO ?D
- @CHK ?D
- DB 0FDH,0CBH,?D,2EH
- ENDM
-
- SRLR MACRO ?R
- DB 0CBH,38H + ?R
- ENDM
-
- SRLX MACRO ?D
- @CHK ?D
- DB 0DDH,0CBH,?D,3EH
- ENDM
-
- SRLY MACRO ?D
- @CHK ?D
- DB 0FDH,0CBH,?D,3EH
- ENDM
-
- RLD MACRO
- DB 0EDH,6FH
- ENDM
-
- RRD MACRO
- DB 0EDH,67H
- ENDM
-
- ;; End of Z80.LIB