;; ;; Z80.LIB INCLUDES Z80 INSTRUCTIONS SET-UP FOR THIS ;; MACHINE PLEASE READ OVER THESE INSTRUCTIONS AND ;; INSTRUCTIONS FOUND IN Z80EXT.LIB BEFORE PROGRAMING ;; ;;****************************************************************** ;;*** *** ;;*** INSTRUCTION SET LISTING AS FOUND IN LIBRARY *** ;;*** *** ;;****************************************************************** ;; ;; LDX R,D * LDY R,D ;; STX R,D * STY R,D ;; MVIX N,D * MVIY N,D ;; LDAI * LDAR ;; STAI * STAR ;; LXIX NNNN * LXIY NNNN ;; LDED NNNN * LBCD NNNN ;; LSPD NNNN * LIXD NNNN ;; LIYD NNNN * SBCD NNNN ;; SDED NNNN * SSPD NNNN ;; SIXD NNNN * SIYD NNNN ;; SPIX * SPIY ;; PUSHIX * PUSHIY ;; POPIX * POPIY ;; EXAF * EXX ;; XTIX * XTIY ;; LDI * LDIR ;; LDD * LDDR ;; CCI * CCIR ;; CCD * CCDR ;; ADDX D * ADDY D ;; ADCX D * ADCY D ;; SUBX D * SUBY D ;; SBCX D * SBCY D ;; ANDX D * ANDY D ;; XORX D * XORY D ;; ORX D * ORY D ;; CMPX D * CMPY D ;; INRX D * INRY D ;; DCRX D * DCRY D ;; NEG * IM0 ;; IM1 * IM2 ;; DADC RP * DSBC RP ;; DADX RP * DADY RP ;; INXIX * INXIY ;; DCXIX * DCXIY ;; BIT N,R * SETB N,R ;; RES N,R * BITX N,D ;; BITY N,D * SETX N,D ;; SETY N,D * RESX N,D ;; RESY N,D * JR N ;; JMPR N * JRC N ;; JRNC N * JRZ N ;; JRNZ N * ;; DJNZ N * PCIX ;; PCIY * RETI ;; RETN * RETEI ;; INP R * OUTP R ;; INI * INIR ;; IND * INDR ;; OUTI * OUTIR ;; OUTD * OUTDR ;; RLCR R * RLCX D ;; RLCY D * RALR R ;; RALX D * RALY D ;; RRCR R * RRCX D ;; RRCY D * RARR R ;; RARX D * RARY D ;; SLAR R * SLAX D ;; SLAY D * SRAR R ;; SRAX D * SRAY D ;; SRLR R * SRLX D ;; SRLY D * RLD ;; RRD ;; ;;****************************************************************** ;; ;; @CHK MACRO USED FOR CHECKING 8 BIT DISPLACMENTS ;; @CHK MACRO ?DD ;; USED FOR CHECKING RANGE OF 8-BIT DISP.S IF (?DD GT 07FH) AND (?DD LT 0FF80H) 'DISPLACEMENT RANGE ERROR - Z80 LIB' ENDIF ENDM @CHECK MACRO ?N ?DD SET ?N-$-2 IF (?DD GT 07FH) AND (?DD LT 0FF80H) 'RANGE ERROR - Z80 LIB' ?DD SET 0FEH ENDIF ENDM ;; ;; LDX MACRO ?R,?D ;;LOAD REG R FROM MEMORY AT (IX+D) @CHK ?D DB 0DDH,?R*8+46H,?D ENDM LDY MACRO ?R,?D ;;LOAD REG R FROM MEMORY AT (IY+D) @CHK ?D DB 0FDH,?R*8+46H,?D ENDM STX MACRO ?R,?D ;;STORE REG R AT MEMORY (IX+D) @CHK ?D DB 0DDH,70H+?R,?D ENDM STY MACRO ?R,?D ;;STORE REG R AT MEMORY (IY+D) @CHK ?D DB 0FDH,70H+?R,?D ENDM MVIX MACRO ?N,?D ;;MOV #N (8 BITS) INTO MEMORY AT (IX+D) @CHK ?D DB 0DDH,36H,?D,?N ENDM MVIY MACRO ?N,?D ;;MOV #N (8 BITS) INTO MEMORY AT (IY+D) @CHK ?D DB 0FDH,36H,?D,?N ENDM LDAI MACRO ;;LOAD ACC WITH REG I (INTERRUPT VECTOR) DB 0EDH,57H ENDM LDAR MACRO ;;LOAD ACC WITH THE REFRESH REG DB 0EDH,5FH ENDM STAI MACRO ;;STORE ACC INTO REG I DB 0EDH,47H ENDM STAR MACRO ;;STORE ACC INTO THE REFRESH REG DB 0EDH,4FH ENDM LXIX MACRO ?NNNN ;;LOAD IMMEDIATE (LDI) IX WITH #NNNN (16 BITS) DB 0DDH,21H DW ?NNNN ENDM LXIY MACRO ?NNNN ;;LDI REG PAIR IY WITH #NNNN (16 BITS) DB 0FDH,21H DW ?NNNN ENDM LDED MACRO ?NNNN ;;LOAD DE WITH CONTENTS OF MEMORY AT NNNN DB 0EDH,5BH ;; (E)=((NN)(NN)) DW ?NNNN ;; (D)=((NN)(NN+1)) ENDM LBCD MACRO ?NNNN ;;LOAD BC WITH CONTENTS OF MEMORY AT NNNN DB 0EDH,4BH DW ?NNNN ENDM LSPD MACRO ?NNNN ;;LOAD STACK POINTER WITH CONTENTS OF MEMORY DB 0EDH,07BH ;; AT NNNN DW ?NNNN ENDM LIXD MACRO ?NNNN ;;LOAD IX WITH CONTENTS OF MEMORY AT NNNN DB 0DDH,2AH DW ?NNNN ENDM LIYD MACRO ?NNNN ;;LOAD IY WITH CONTENTS OF MEMORY AT NNNN DB 0FDH,2AH DW ?NNNN ENDM SBCD MACRO ?NNNN ;;STORE BC IN MEMORY LOCATION NNNN DB 0EDH,43H ;; ((NN)(NN))=(C) DW ?NNNN ;; ((NN)(NN+1))=(B) ENDM SDED MACRO ?NNNN ;;STORE DE IN MEMORY LOC NNNN DB 0EDH,53H DW ?NNNN ENDM SSPD MACRO ?NNNN ;;STORE STACK POINTER IN MEMORY LOC NNNN DB 0EDH,73H DW ?NNNN ENDM SIXD MACRO ?NNNN ;;STORE IX IN MEMORY LOC NNNN DB 0DDH,22H DW ?NNNN ENDM SIYD MACRO ?NNNN ;;STORE IY IN MEMORY LOC NNNN DB 0FDH,22H DW ?NNNN ENDM SPIX MACRO ;;MOV IX INTO STACK POINTER (SP) DB 0DDH,0F9H ENDM SPIY MACRO ;;MOV IY INTO STACK POINTER (SP) DB 0FDH,0F9H ENDM PUSHIX MACRO ;;PUSH IX ONTO STACK DB 0DDH,0E5H ENDM PUSHIY MACRO ;;PUSH IY ONTO STACK DB 0FDH,0E5H ENDM POPIX MACRO ;;POP IX OFF STACK DB 0DDH,0E1H ENDM POPIY MACRO ;;POP IY OFF STACK DB 0FDH,0E1H ENDM EXAF MACRO ;;EXCHANGE AF AND AF' REGS DB 08H ENDM EXX MACRO ;;EXCHANGE BC AND BC' DB 0D9H ;; DE AND DE' ;; HL AND HL' ENDM XTIX MACRO ;;EXCHANGE TOP OF STACK WITH IX DB 0DDH,0E3H ENDM XTIY MACRO ;;EXCHANGE TOP OF STACK WITH IY DB 0FDH,0E3H ENDM LDI MACRO ;;LOAD MEMORY AT (H,L) TO MEMORY AT (D,E) DB 0EDH,0A0H ;; INC D,E INC H,L DEC B,C ENDM LDIR MACRO ;;AS ABOVE REPEAT UNTIL B=0 DB 0EDH,0B0H ENDM LDD MACRO ;;LOAD MEMORY AT (H,L) TO MEMORY AT (D,E) DB 0EDH,0A8H ;; DEC H,L DEC D,E DEC B,C ENDM LDDR MACRO ;;AS ABOVE REPEAT UNTIL B=0 DB 0EDH,0B8H ENDM CCI MACRO ;;COMPARE ACC WITH MEMORY AT (H,L) DB 0EDH,0A1H ;; INC H,L DEC B,C (P/V=0 IF B=0) ;; (ACC=(H,L) IF Z=0) ENDM CCIR MACRO ;;AS ABOVE REPEAT UNTIL (B,C) = 0 OR ;; (A) = (H,L) DB 0EDH,0B1H ENDM CCD MACRO ;;COMPARE ACC WITH MEMORY AT (H,L) DB 0EDH,0A9H ;; DEC H,L DEC B,C ENDM CCDR MACRO ;;AS ABOVE REPEAT UNTIL (BC) = 0 OR ;; (A) = (H,L) DB 0EDH,0B9H ENDM ADDX MACRO ?D ;;ACC=ACC+CONTENTS OF MEMORY AT (IX+D) @CHK ?D ;; ACC=ACC+((IX+D)) DB 0DDH,86H,?D ENDM ADDY MACRO ?D ;;ACC=ACC+((IY+D)) @CHK ?D DB 0FDH,86H,?D ENDM ADCX MACRO ?D ;;ACC=ACC+((IX+D))+CARRY @CHK ?D DB 0DDH,8EH,?D ENDM ADCY MACRO ?D ;;ACC=ACC+((IY+D))+CARRY @CHK ?D DB 0FDH,8EH,?D ENDM SUBX MACRO ?D ;;ACC=ACC-((IX+D)) @CHK ?D DB 0DDH,96H,?D ENDM SUBY MACRO ?D ;;ACC=ACC-((IY+D)) @CHK ?D DB 0FDH,96H,?D ENDM SBCX MACRO ?D ;;ACC=ACC-((IX+D))-BORROW @CHK ?D DB 0DDH,9EH,?D ENDM SBCY MACRO ?D ;;ACC=ACC-((IY+D))-BORROW @CHK ?D DB 0FDH,9EH,?D ENDM ANDX MACRO ?D ;;AND ACC WITH CONTENTS OF MEMORY (IX+D) @CHK ?D DB 0DDH,0A6H,?D ENDM ANDY MACRO ?D ;;AND ACC WITH CONTENTS OF MEMORY (IY+D) @CHK ?D DB 0FDH,0A6H,?D ENDM XORX MACRO ?D ;;EXCLUSIVE OR THE ACC WITH CONTEMTS OF @CHK ?D ;; MEMORY AT (IX+D) DB 0DDH,0AEH,?D ENDM XORY MACRO ?D ;;XOR ACC WITH CONTENTS OF MEMORY (IY+D) @CHK ?D DB 0FDH,0AEH,?D ENDM ORX MACRO ?D ;;OR THE ACC WITH CONTENTS OF MEMORY (IX+D) @CHK ?D DB 0DDH,0B6H,?D ENDM ORY MACRO ?D ;;OR ACC WITH CONTENTS OF MEMORY (IY+D) @CHK ?D DB 0FDH,0B6H,?D ENDM CMPX MACRO ?D ;;COMPARE THE ACC WITH CONTENTS OF MEMORY @CHK ?D ;; AT LOC (IX+D) DB 0DDH,0BEH,?D ENDM CMPY MACRO ?D ;;CMP ACC WITH CONTENTS OF MEMORY (IY+D) @CHK ?D DB 0FDH,0BEH,?D ENDM INRX MACRO ?D ;;INC MEMORY CONTENTS AT (IX+D) @CHK ?D DB 0DDH,34H,?D ENDM INRY MACRO ?D ;;INC MEMORY CONTENTS AT (IY+D) @CHK ?D DB 0FDH,34H,?D ENDM DCRX MACRO ?D ;;DEC MEMORY CONTENTS AT (IX+D) @CHK ?D DB 0DDH,035H,?D ENDM DCRY MACRO ?D ;;DEC MEMORY CONTENTS AT (IY+D) @CHK ?D DB 0FDH,35H,?D ENDM NEG MACRO ;;NEGATE ACC (2'S COMPLEMENT) DB 0EDH,44H ENDM IM0 MACRO ;;SET INTERRUPT MODE #0 DB 0EDH,46H ENDM IM1 MACRO ;;SET INTERRUPT MODE #1 (RESTART 0038H) DB 0EDH,56H ENDM IM2 MACRO ;;SET INTERRUPT MODE #2 DB 0EDH,5EH ;; RESTART AT LOC (INT REG I)(DEV SUPPLIED) ENDM BC EQU 0 DE EQU 2 HL EQU 4 IX EQU 4 IY EQU 4 DADC MACRO ?R ;;DOUBLE ADD (H,L)=(H,L)+(RP)+CARRY DB 0EDH,?R*8+4AH ENDM DSBC MACRO ?R ;;DOUBLE SUB (H,L)=(H,L)-(RP)-CARRY DB 0EDH,?R*8+42H ENDM DADX MACRO ?R ;;DOUBLE ADD (IX)=(IX)+(RP) DB 0DDH,?R*8+09H ENDM DADY MACRO ?R ;;DOUBLE ADD (IY)=(IY)+(RP) DB 0FDH,?R*8+09H ENDM INXIX MACRO ;;INC (IX) DB 0DDH,23H ENDM INXIY MACRO ;;INC (IY) DB 0FDH,23H ENDM DCXIX MACRO ;;DEC (IX) DB 0DDH,2BH ENDM DCXIY MACRO ;;DEC (IY) DB 0FDH,2BH ENDM BIT MACRO ?N,?R ;;TEST BIT N IN REG R DB 0CBH,?N*8+?R+40H ENDM SETB MACRO ?N,?R ;;SET BIT N IN REG R DB 0CBH,?N*8+?R+0C0H ENDM RES MACRO ?N,?R ;;RESET BIT N IN REG R DB 0CBH,?N*8+?R+80H ENDM BITX MACRO ?N,?D ;;TEST BIT N IN MEMORY LOC (IX+D) @CHK ?D DB 0DDH,0CBH,?D,?N*8+46H ENDM BITY MACRO ?N,?D ;;TEST BIT N IN MEMORY LOC (IY+D) @CHK ?D DB 0FDH,0CBH,?D,?N*8+46H ENDM SETX MACRO ?N,?D ;;SET BIT N IN MEMORY LOC (IX+D) @CHK ?D DB 0DDH,0CBH,?D,?N*8+0C6H ENDM SETY MACRO ?N,?D ;;SET BIT N IN MEMORY LOC (IY+D) @CHK ?D DB 0FDH,0CBH,?D,?N*8+0C6H ENDM RESX MACRO ?N,?D ;;RESET BIT N IN MEMORY LOC (IX+D) @CHK ?D DB 0DDH,0CBH,?D,?N*8+86H ENDM RESY MACRO ?N,?D ;;RESET BIT N IN MEMORY LOC (IY+D) @CHK ?D DB 0FDH,0CBH,?D,?N*8+86H ENDM JR MACRO ?N ;;JUMP RELATIVE @CHECK ?N DB 18H,?DD ENDM JMPR MACRO ?N ;;JUMP RELATIVE AS ABOVE @CHECK ?N DB 18H,?DD ENDM JRC MACRO ?N ;;JUMP RELATIVE ON CARRY @CHECK ?N DB 38H,?DD ENDM JRNC MACRO ?N ;;JUMP RELATIVE ON NOT CARRY @CHECK ?N DB 30H,?DD ENDM JRZ MACRO ?N ;;JUMP RELATIVE ON ZERO @CHECK ?N DB 28H,?DD ENDM JRNZ MACRO ?N ;;JUMP RELATIVE ON NOT ZERO @CHECK ?N DB 20H,?DD ENDM DJNZ MACRO ?N ;;DEC B AND JUMP RELATIVE ON B NOT ZERO @CHECK ?N DB 10H,?DD ENDM PCIX MACRO ;;MOV IX INTO PROGRAM COUNTER DB 0DDH,0E9H ENDM PCIY MACRO ;;MOV IY INTO PROGRAM COUNTER DB 0FDH,0E9H ENDM RETI MACRO ;;RETURN FROM INTERRUPT (EI NOT ENABLED) DB 0EDH,4DH ENDM RETN MACRO ;;RETURN FROM NON-MASKABLE INTERRUPT DB 0EDH,45H ENDM RETEI MACRO ;;RETURN FROM INTERRUPT (EI ENABLED) DB EI,0EDH,4DH ENDM INP MACRO ?R ;;GO TO INPUT PORT (SPECIFIED BY REG C) DB 0EDH,?R*8+40H ;; AND LOAD INTO REG R ENDM OUTP MACRO ?R ;;OUTPUT TO PORT (SPECIFIED BY REG C) DB 0EDH,?R*8+41H ;; FROM REG R ENDM INI MACRO ;;LOAD MEMORY (H,L) WITH INPUT PORT DB 0EDH,0A2H ;; (SPECIFIED BY REG C) INC H,L DEC B ENDM INIR MACRO ;;AS ABOVE REPEAT UNTIL B=0 DB 0EDH,0B2H ENDM IND MACRO ;;LOAD MEMORY (H,L) WITH INPUT PORT DB 0EDH,0AAH ;; (SPECIFIED BY REG C) DEC H,L DEC B ENDM INDR MACRO ;;AS ABOVE REPEAT UNTIL B=0 DB 0EDH,0BAH ENDM OUTI MACRO ;;OUTPUT TO PORT (SPECIFIED BY REG C) DB 0EDH,0A3H ;; FROM MEMORY (H,L) INC H,L DEC B ENDM OUTIR MACRO ;;AS ABOVE REPEAT UNTIL B=0 DB 0EDH,0B3H ENDM OUTD MACRO ;;OUTPUT TO PORT (SPECIFIED BY REG C) DB 0EDH,0ABH ;; FROM MEMORY (H,L) DEC H,L DEC B ENDM OUTDR MACRO ;;AS ABOVE REPEAT UNTIL B=0 DB 0EDH,0BBH ENDM RLCR MACRO ?R ;;ROTATE LEFT CIRCULAR REG R DB 0CBH, 00H + ?R ENDM RLCX MACRO ?D ;;ROTATE LEFT CIRCULAR CONTENTS OF MEMORY ;; AT (IX+D) @CHK ?D DB 0DDH, 0CBH, ?D, 06H ENDM RLCY MACRO ?D ;;ROTATE LEFT CIRCULAR CONTENTS OF MEMORY ;; AT (IY+D) @CHK ?D DB 0FDH, 0CBH, ?D, 06H ENDM RALR MACRO ?R ;;ROTATE ARITHMETIC LEFT REG R DB 0CBH, 10H+?R ENDM RALX MACRO ?D ;;ROTATE ARITHMETIC LEFT CONTENTS OF MEMORY ;; AT (IX+D) @CHK ?D DB 0DDH, 0CBH, ?D, 16H ENDM RALY MACRO ?D ;;ROTATE ARITHMETIC LEFT CONTENTS OF MEMORY ;; AT (IY+D) @CHK ?D DB 0FDH, 0CBH, ?D, 16H ENDM RRCR MACRO ?R ;;ROTATE RIGHT CIRCULAR REG R DB 0CBH, 08H + ?R ENDM RRCX MACRO ?D ;;ROTATE RIGHT CIRCULAR CONTENTS OF MEMORY ;; AT (IX+D) @CHK ?D DB 0DDH, 0CBH, ?D, 0EH ENDM RRCY MACRO ?D ;;ROTATE RIGHT CIRCULAR CONTENTS OF MEMORY ;; AT (IY+D) @CHK ?D DB 0FDH, 0CBH, ?D, 0EH ENDM RARR MACRO ?R ;;ROTATE ARITHMETIC RIGHT REG R DB 0CBH, 18H + ?R ENDM RARX MACRO ?D ;;ROTATE ARITHMETIC RIGHT CONTENTS OF MEMORY ;; AT (IX+D) @CHK ?D DB 0DDH, 0CBH, ?D, 1EH ENDM RARY MACRO ?D ;;ROTATE ARITHMETIC RIGHT CONTENTS OF MEMORY ;; AT (IY+D) @CHK ?D DB 0FDH, 0CBH, ?D, 1EH ENDM SLAR MACRO ?R ;;SHIFT LEFT ARITHMETIC REG R DB 0CBH, 20H + ?R ENDM SLAX MACRO ?D ;;SHIFT LEFT ARITHMETIC CONTENTS OF MEMORY ;; AT(IX+D) @CHK ?D DB 0DDH, 0CBH, ?D, 26H ENDM SLAY MACRO ?D ;;SHIFT LEFT ARITHMETIC CONTENTS OF MEMORY ;; AT (IY+D) @CHK ?D DB 0FDH, 0CBH, ?D, 26H ENDM SRAR MACRO ?R ;;SHIFT RIGHT ARITHMETIC REG R DB 0CBH, 28H+?R ENDM SRAX MACRO ?D ;;SHIFT RIGHT ARITHMETIC CONTENTS OF MEMORY ;; AT (IX+D) @CHK ?D DB 0DDH, 0CBH, ?D, 2EH ENDM SRAY MACRO ?D ;;SHIFT RIGHT ARITHMETIC CONTENTS OF MEMORY ;; AT (IY+D) @CHK ?D DB 0FDH, 0CBH, ?D, 2EH ENDM SRLR MACRO ?R ;;SHIFT RIGHT LOGICALLY REG R DB 0CBH, 38H + ?R ENDM SRLX MACRO ?D ;;SHIFT RIGHT LOGICALLY CONTENTS OF MEMORY ;; AT (IX+D) @CHK ?D DB 0DDH, 0CBH, ?D, 3EH ENDM SRLY MACRO ?D ;;SHIFT RIGHT LOGICALLY CONTENTS OF MEMORY ;; AT (IY+D) @CHK ?D DB 0FDH, 0CBH, ?D, 3EH ENDM RLD MACRO ;;ROTATE NIBBLE LEFT & RIGHT BETWEEN ACC DB 0EDH, 6FH ;; AND CONTENTS AT (H,L) ENDM RRD MACRO ;;ROTATE NIBBLE RIGHT & LEFT BETWEEN ACC DB 0EDH, 67H ;; AND CONTENTS AT (H,L) ENDM