ORG 2D00H ;SET ORIGIN START: LXI B,TABL3 ;B,C=TABLE PTR LHLD SSTAR ;D,E=MEMORY PTR. XCHG LXI SP,STACK+8 ;INTIALIZE STACK CALL BUSY ;CHECK CRT STATUS MVI A,0AH ;LINE FEED OUT CRT ;TO CRT CALL BUSY ;CHECK STATUS MVI A,0DH ;CARR. RET OUT CRT ;TO CRT CHEKF: LDA SSTP+1 ;CHECK FOR END OF FILE SUB D JNZ NEXT ;CONTINUE IF NOT LDA SSTP SUB E JZ ENDF ;QUIT IF END NEXT: LDAX D ;LOAD MEM.CONTENTS USING PTR. MOV H,A ;SAVE IN H XRA A ;ZERO ACCUM. MOV L,A ;SET UP CNTR. COMP3: INR L ;BUMP CNTR MOV A,L CPI 27D ;CHECK FOR END OF TABLE JZ AGAIN ;JMP IF THRU LDAX B ;LOAD TABLE ENTRY SUB H ;COMP. WITH CURR. MEM. JZ MTCH3 ;JMP IF MATCH INX B ;ELSE BUMP TABLE PTR. JMP COMP3 ;LOOK AGAIN AGAIN: LXI B,TABL2 ;PTR HAS ADDR 2 BYTE OPS XRA A ;ZERO ACCUM. MOV L,A ;SET CTR. COMP2: INR L ;BUMP CTR. MOV A,L CPI 19D ;CHECK FOR END TABLE JZ NOMAT ;JMP IF THRU LDAX B ;LOAD TABLE ENTRY SUB H ;COMP. WITH GURRENT MEM. JZ MTCH2 ;JMP IF MATCH INX B ;ELSE BUMP TABLE PTR. JMP COMP2 ;LOOK AGAIN MTCH3: MOV A,L ;FOUND 3 BYTE OP CODE CPI 05D ;LXI'S FIRST FOUR IN TABL3 JC FDLXI ;IF L<=4 OP IS LXI NOLXI: INX D ;NOT LXI IF HERE, SO MTCH2: INX D ;MOV MEM. PTR. TO NEXT LOC. NOMAT: INX D LXI B,TABL3 ;RESET TABLE PTR. JMP CHEKF ;CONTINUE SEARCH FDLXI: MOV A,D ;FOUND LXI,PREP FOR OUT ADDR: CALL BYTE1 ;OUTPUT 1ST DIGIT:HI ADDR MOV A,D CALL BYTE2 ;OUTPUT 2ND DIGIT:HI ADDR MOV A,E CALL BYTE1 ;OUTPUT 1ST DIGIT:LO ADDR MOV A,E CALL BYTE2 ;OUTPUT 2ND DIGIT:LO ADDR CALL SPACE ;INSERT TWO SPACES LDAX D CALL BYTE1 ;OUTPUT OPCODE BYTES LDAX D ;OF LXI INSTRUCTION CALL BYTE2 CALL SPACE ;INSERT TWO SPACES INX D ;D,E POINT5 TO 16 BIT INX D ;CONSTANT FOLLOWING LXI OP LDAX D ;LOAD IT IN ACCUM. CALL BYTE1 ;OUTPUT IST DIGIT OF CONSTANT LDAX D ;LOAD AGAIN (BYTE1 CLOBBERS) CALL BYTE2 ;OUTPUT 2ND DIGIT(ASCII CODE) DCX D ;POINT TO 3RD&4TH DIGITS LDAX D ;LOAD IN ACCUM. CALL BYTE1 ;OUTPUT 3RD DIGIT LDAX D ;LOAD AGAIN CALL BYTE2 ;OUTPUT 4TH DIGIT CALL SPACE ;INSERT TWO SPACES THRU: INX D ;ADVANCE MEM PTR INX D ;TO NEXT OP CODE LXI B,SSTAR ;SAVE MEM PTR MOV A,E ;TO NEXT LOC. STAX B ;SO CAN LOOK FOR MOV A,D ;NEXT OP CODE INX B ;UPON REENTRY STAX B ;TO PROG. RST 07 ;GO MANUAL CONTROL ENDF: LXI B,MESGE-1 ;FIND EOF MESSAGE LOOPO: INX B ;LOAD IT,BYTE AT A TIME CALL BUSY ;CHECK STAT OF CRT LDAX B OUT CRT ;PUT IT OUT CPI 'H' ;TILL END JNZ LOOPO ;GO TO MANUAL RST 07 ;CONTROL WHEN FINIS ;***** OUTPUT SUBROUTINES ***** BYTE1: ANI 0F0H ;MASK LEAST SIG. BITS MOV B,A ;SAVE IT XRA A ;SET FLAG=0 CALL OUTT ;OUTPUT TO CRT RET ;RETURN FOR NEXT BYTE2: ANI 0FH ;MASK MOST SIG. BITS MOV B,A ;SAVE XRA A ;A=0 INR A ;SET FLAG-1 CALL OUTT ;OUTPUT TO CRT RET ;MORE? OUTT: CPI 00H ;CHECK FLAG JNZ RESTR ;IF 01 BR AROUND MOV A,B ;GET OUT BYTE RAR ;SHIFT INTO RAR ;LOWEST 4 BITS RAR ;PREP FOR CONV RAR ;TO ASCII JMP TYPOT ;CONVERT & OUTPUT RESTR: MOV A,B ;GET OUT BYTE TYPOT: MOV L,A ;SET UP FOR CONV XRA A MOV H,A ;0 IN TOP 8 BITS LXI B,ASCTB ;LOAD ADDR TABLE IN B,C DAD B ;GET POS IN TABLE XCHG ;SAVE D,E CALL BUSY ;CHECK STAT OF CRT LDAX D ;LOAD CONV. VALUE OUT CRT ;PUT IT OUT XCHG ;GET D,E BACK RET ;RETURN FOR NEXT BYTE SPACE: CALL BUSY ;CHECK CRT STAT MVI A,' ' ;SPACE OUT CRT ;TO CRT CALL BUSY ;CHECK STAT MVI A,' ' ;ANOTHER SPACE OUT CRT ;TO CRT RET ;***** STATUS CHECK OF OUTPUT PORT ***** BUSY: IN CRTS ;CHECK IF READY RAR JNC BUSY RET ;RETURN IF READY MESGE: DB 0AH,0DH DB 'END OF FILE SEARCH' ;***** TABLES AND CONSTANTS ***** TABL2: DB 06H,0EH,16H ;TABLE OF 2 BYTE DB 1EH,26H,2EH ;OP CODES DB 36H,3EH,0C6H DB 0CEH,0DEH,0D6H DB 0DBH,0DEH,0E6H DB 0EEH,0F6H,0FEH TABL3: DB 01H,11H,21H ;TABLE OF 3 BYTE DB 31H,2AH,22H ;OP CODES. DB 32H,3AH,0C2H ;LXI INSTR. ARE FIRST DB 0C3H,0C4H,0CAH DB 0CCH,0CDH,0D2H DB 0D4H,0DAH,0DCH DB 0E2H,0E4H,0EAH DB 0ECH,0F2H,0F4H DB 0FAH,0FCH ASCTB: DB 30H,31H,32H,33H ;TABLE OF ASCII DB 34H,35H,36H,37H ;EQUIVALENTS OF DB 38H,39H,41H,42H ;NOS. 1-F HEX DB 43H,44H,45H,46H SSTAR: DS 02H ;START OF SOURCE SSTP: DS 02H ;END OF SOURCE STACK: DS 08H ;SPACE FOR STACK CRT EQU 04 ;CRT PORT CRTS EQU 05 ;CRT STATUS PORT