Listing 2:
An 8080 program to facilitate the examination and correction of load X immediate (LXI) instructions.
(Because of the multiple uses of the LXI instruction, the relocator program of listing 1 can, in certain circumstances, mishandle the 2 bytes of information following the LXI code.)
The program is designed to run with the Dynamic Debugging Tool (DDT) of the CP/M software.
Given the starting and ending addresses of a source program block, this program finds LXI operation codes.
It then displays the following information on the user's terminal:
the memory address where the LXI instruction is located; the operation code; the 2 bytes following the operation code.
Control is then passed to the monitor to allow the operator to make any needed corrections.
Upon reentry the search for LXI operation codes is resumed at the next operation code following the LXI operation code previously found.
[8080 source
and
Z80 source]
2D00 ORG 2D00H ;SET ORIGIN
2D00 01182E START: LXI B,TABL3 ;B,C=TABLE PTR
2D03 2A422E LHLD SSTAR ;D,E=MEMORY PTR.
2D06 EB XCHG
2D07 314E2E LXI SP,STACK+8 ;INTIALIZE STACK
2D0A CDEB2D CALL BUSY ;CHECK CRT STATUS
2D0D 3E0A MVI A,0AH ;LINE FEED
2D0F D304 OUT CRT ;TO CRT
2D11 CDEB2D CALL BUSY ;CHECK STATUS
2D14 3E0D MVI A,0DH ;CARR. RET
2D16 D304 OUT CRT ;TO CRT
2D18 3A452E CHEKF: LDA SSTP+1 ;CHECK FOR END OF FILE
2D1B 92 SUB D
2D1C C2262D JNZ NEXT ;CONTINUE IF NOT
2D1F 3A442E LDA SSTP
2D22 93 SUB E
2D23 CA9D2D JZ ENDF ;QUIT IF END
2D26 1A NEXT: LDAX D ;LOAD MEM.CONTENTS USING PTR.
2D27 67 MOV H,A ;SAVE IN H
2D28 AF XRA A ;ZERO ACCUM.
2D29 6F MOV L,A ;SET UP CNTR.
2D2A 2C COMP3: INR L ;BUMP CNTR
2D2B 7D MOV A,L
2D2C FE1B CPI 27D ;CHECK FOR END OF TABLE
2D2E CA3A2D JZ AGAIN ;JMP IF THRU
2D31 0A LDAX B ;LOAD TABLE ENTRY
2D32 94 SUB H ;COMP. WITH CURR. MEM.
2D33 CA4F2D JZ MTCH3 ;JMP IF MATCH
2D36 03 INX B ;ELSE BUMP TABLE PTR.
2D37 C32A2D JMP COMP3 ;LOOK AGAIN
2D3A 01062E AGAIN: LXI B,TABL2 ;PTR HAS ADDR 2 BYTE OPS
2D3D AF XRA A ;ZERO ACCUM.
2D3E 6F MOV L,A ;SET CTR.
2D3F 2C COMP2: INR L ;BUMP CTR.
2D40 7D MOV A,L
2D41 FE13 CPI 19D ;CHECK FOR END TABLE
2D43 CA572D JZ NOMAT ;JMP IF THRU
2D46 0A LDAX B ;LOAD TABLE ENTRY
2D47 94 SUB H ;COMP. WITH GURRENT MEM.
2D48 CA562D JZ MTCH2 ;JMP IF MATCH
2D4B 03 INX B ;ELSE BUMP TABLE PTR.
2D4C C33F2D JMP COMP2 ;LOOK AGAIN
2D4F 7D MTCH3: MOV A,L ;FOUND 3 BYTE OP CODE
2D50 FE05 CPI 05D ;LXI'S FIRST FOUR IN TABL3
2D52 DA5E2D JC FDLXI ;IF L<=4 OP IS LXI
2D55 13 NOLXI: INX D ;NOT LXI IF HERE, SO
2D56 13 MTCH2: INX D ;MOV MEM. PTR. TO NEXT LOC.
2D57 13 NOMAT: INX D
2D58 01182E LXI B,TABL3 ;RESET TABLE PTR.
2D5B C3182D JMP CHEKF ;CONTINUE SEARCH
2D5E 7A FDLXI: MOV A,D ;FOUND LXI,PREP FOR OUT
2D5F CDAD2D ADDR: CALL BYTE1 ;OUTPUT 1ST DIGIT:HI ADDR
2D62 7A MOV A,D
2D63 CDB52D CALL BYTE2 ;OUTPUT 2ND DIGIT:HI ADDR
2D66 7B MOV A,E
2D67 CDAD2D CALL BYTE1 ;OUTPUT 1ST DIGIT:LO ADDR
2D6A 7B MOV A,E
2D6B CDB52D CALL BYTE2 ;OUTPUT 2ND DIGIT:LO ADDR
2D6E CDDC2D CALL SPACE ;INSERT TWO SPACES
2D71 1A LDAX D
2D72 CDAD2D CALL BYTE1 ;OUTPUT OPCODE BYTES
2D75 1A LDAX D ;OF LXI INSTRUCTION
2D76 CDB52D CALL BYTE2
2D79 CDDC2D CALL SPACE ;INSERT TWO SPACES
2D7C 13 INX D ;D,E POINT5 TO 16 BIT
2D7D 13 INX D ;CONSTANT FOLLOWING LXI OP
2D7E 1A LDAX D ;LOAD IT IN ACCUM.
2D7F CDAD2D CALL BYTE1 ;OUTPUT IST DIGIT OF CONSTANT
2D82 1A LDAX D ;LOAD AGAIN (BYTE1 CLOBBERS)
2D83 CDB52D CALL BYTE2 ;OUTPUT 2ND DIGIT(ASCII CODE)
2D86 1B DCX D ;POINT TO 3RD&4TH DIGITS
2D87 1A LDAX D ;LOAD IN ACCUM.
2D88 CDAD2D CALL BYTE1 ;OUTPUT 3RD DIGIT
2D8B 1A LDAX D ;LOAD AGAIN
2D8C CDB52D CALL BYTE2 ;OUTPUT 4TH DIGIT
2D8F CDDC2D CALL SPACE ;INSERT TWO SPACES
2D92 13 THRU: INX D ;ADVANCE MEM PTR
2D93 13 INX D ;TO NEXT OP CODE
2D94 01422E LXI B,SSTAR ;SAVE MEM PTR
2D97 7B MOV A,E ;TO NEXT LOC.
2D98 02 STAX B ;SO CAN LOOK FOR
2D99 7A MOV A,D ;NEXT OP CODE
2D9A 03 INX B ;UPON REENTRY
2D9B 02 STAX B ;TO PROG.
2D9C FF RST 07 ;GO MANUAL CONTROL
2D9D 01F12D ENDF: LXI B,MESGE-1 ;FIND EOF MESSAGE
2DA0 03 LOOPO: INX B ;LOAD IT,BYTE AT A TIME
2DA1 CDEB2D CALL BUSY ;CHECK STAT OF CRT
2DA4 0A LDAX B
2DA5 D304 OUT CRT ;PUT IT OUT
2DA7 FE48 CPI 'H' ;TILL END
2DA9 C2A02D JNZ LOOPO ;GO TO MANUAL
2DAC FF RST 07 ;CONTROL WHEN FINIS
;***** OUTPUT SUBROUTINES *****
2DAD E6F0 BYTE1: ANI 0F0H ;MASK LEAST SIG. BITS
2DAF 47 MOV B,A ;SAVE IT
2DB0 AF XRA A ;SET FLAG=0
2DB1 CDBE2D CALL OUTT ;OUTPUT TO CRT
2DB4 C9 RET ;RETURN FOR NEXT
2DB5 E60F BYTE2: ANI 0FH ;MASK MOST SIG. BITS
2DB7 47 MOV B,A ;SAVE
2DB8 AF XRA A ;A=0
2DB9 3C INR A ;SET FLAG-1
2DBA CDBE2D CALL OUTT ;OUTPUT TO CRT
2DBD C9 RET ;MORE?
2DBE FE00 OUTT: CPI 00H ;CHECK FLAG
2DC0 C2CB2D JNZ RESTR ;IF 01 BR AROUND
2DC3 78 MOV A,B ;GET OUT BYTE
2DC4 1F RAR ;SHIFT INTO
2DC5 1F RAR ;LOWEST 4 BITS
2DC6 1F RAR ;PREP FOR CONV
2DC7 1F RAR ;TO ASCII
2DC8 C3CC2D JMP TYPOT ;CONVERT & OUTPUT
2DCB 78 RESTR: MOV A,B ;GET OUT BYTE
2DCC 6F TYPOT: MOV L,A ;SET UP FOR CONV
2DCD AF XRA A
2DCE 67 MOV H,A ;0 IN TOP 8 BITS
2DCF 01322E LXI B,ASCTB ;LOAD ADDR TABLE IN B,C
2DD2 09 DAD B ;GET POS IN TABLE
2DD3 EB XCHG ;SAVE D,E
2DD4 CDEB2D CALL BUSY ;CHECK STAT OF CRT
2DD7 1A LDAX D ;LOAD CONV. VALUE
2DD8 D304 OUT CRT ;PUT IT OUT
2DDA EB XCHG ;GET D,E BACK
2DDB C9 RET ;RETURN FOR NEXT BYTE
2DDC CDEB2D SPACE: CALL BUSY ;CHECK CRT STAT
2DDF 3E20 MVI A,' ' ;SPACE
2DE1 D304 OUT CRT ;TO CRT
2DE3 CDEB2D CALL BUSY ;CHECK STAT
2DE6 3E20 MVI A,' ' ;ANOTHER SPACE
2DE8 D304 OUT CRT ;TO CRT
2DEA C9 RET
;***** STATUS CHECK OF OUTPUT PORT *****
2DEB DB05 BUSY: IN CRTS ;CHECK IF READY
2DED 1F RAR
2DEE D2EB2D JNC BUSY
2DF1 C9 RET ;RETURN IF READY
2DF2 0A0D MESGE: DB 0AH,0DH
2DF4 454E44204F DB 'END OF FILE SEARCH'
;***** TABLES AND CONSTANTS *****
2E06 060E16 TABL2: DB 06H,0EH,16H ;TABLE OF 2 BYTE
2E09 1E262E DB 1EH,26H,2EH ;OP CODES
2E0C 363EC6 DB 36H,3EH,0C6H
2E0F CEDED6 DB 0CEH,0DEH,0D6H
2E12 DBDEE6 DB 0DBH,0DEH,0E6H
2E15 EEF6FE DB 0EEH,0F6H,0FEH
2E18 011121 TABL3: DB 01H,11H,21H ;TABLE OF 3 BYTE
2E1B 312A22 DB 31H,2AH,22H ;OP CODES.
2E1E 323AC2 DB 32H,3AH,0C2H ;LXI INSTR. ARE FIRST
2E21 C3C4CA DB 0C3H,0C4H,0CAH
2E24 CCCDD2 DB 0CCH,0CDH,0D2H
2E27 D4DADC DB 0D4H,0DAH,0DCH
2E2A E2E4EA DB 0E2H,0E4H,0EAH
2E2D ECF2F4 DB 0ECH,0F2H,0F4H
2E30 FAFC DB 0FAH,0FCH
2E32 30313233 ASCTB: DB 30H,31H,32H,33H ;TABLE OF ASCII
2E36 34353637 DB 34H,35H,36H,37H ;EQUIVALENTS OF
2E3A 38394142 DB 38H,39H,41H,42H ;NOS. 1-F HEX
2E3E 43444546 DB 43H,44H,45H,46H
2E42 SSTAR: DS 02H ;START OF SOURCE
2E44 SSTP: DS 02H ;END OF SOURCE
2E46 STACK: DS 08H ;SPACE FOR STACK
0004 = CRT EQU 04 ;CRT PORT
0005 = CRTS EQU 05 ;CRT STATUS PORT