.phase 2d00h ; SET ORIGIN ; ; Slightly modified for outputting data thru standard BDOS call ; start: ld bc,tabl3 ; B,C=TABLE PTR ld hl,(sstar) ; D,E=MEMORY PTR. ex de,hl ld sp,stack+8 ; INTIALIZE STACK ld a,0ah ; LINE FEED call crt ; TO CRT ld a,0dh ; CARR. RET call crt ; TO CRT chekf: ld a,(sstp+1) ; CHECK FOR END OF FILE sub d jp nz,next ; CONTINUE IF NOT ld a,(sstp) sub e jp z,endf ; QUIT IF END next: ld a,(de) ; LOAD MEM.CONTENTS USING PTR. ld h,a ; SAVE IN H xor a ; ZERO ACCUM. ld l,a ; SET UP CNTR. comp3: inc l ; BUMP CNTR ld a,l cp 27d ; CHECK FOR END OF TABLE jp z,again ; JMP IF THRU ld a,(bc) ; LOAD TABLE ENTRY sub h ; COMP. WITH CURR. MEM. jp z,mtch3 ; JMP IF MATCH inc bc ; ELSE BUMP TABLE PTR. jp comp3 ; LOOK AGAIN again: ld bc,tabl2 ; PTR HAS ADDR 2 BYTE OPS xor a ; ZERO ACCUM. ld l,a ; SET CTR. comp2: inc l ; BUMP CTR. ld a,l cp 19d ; CHECK FOR END TABLE jp z,nomat ; JMP IF THRU ld a,(bc) ; LOAD TABLE ENTRY sub h ; COMP. WITH GURRENT MEM. jp z,mtch2 ; JMP IF MATCH inc bc ; ELSE BUMP TABLE PTR. jp comp2 ; LOOK AGAIN mtch3: ld a,l ; FOUND 3 BYTE OP CODE cp 05d ; LXI'S FIRST FOUR IN TABL3 jp c,fdlxi ; IF L<=4 OP IS LXI nolxi: inc de ; NOT LXI IF HERE, SO mtch2: inc de ; MOV MEM. PTR. TO NEXT LOC. nomat: inc de ld bc,tabl3 ; RESET TABLE PTR. jp chekf ; CONTINUE SEARCH fdlxi: ld a,d ; FOUND LXI,PREP FOR OUT addr: call byte1 ; OUTPUT 1ST DIGIT:HI ADDR ld a,d call byte2 ; OUTPUT 2ND DIGIT:HI ADDR ld a,e call byte1 ; OUTPUT 1ST DIGIT:LO ADDR ld a,e call byte2 ; OUTPUT 2ND DIGIT:LO ADDR call space ; INSERT TWO SPACES ld a,(de) call byte1 ; OUTPUT OPCODE BYTES ld a,(de) ; OF LXI INSTRUCTION call byte2 call space ; INSERT TWO SPACES inc de ; D,E POINT5 TO 16 BIT inc de ; CONSTANT FOLLOWING LXI OP ld a,(de) ; LOAD IT IN ACCUM. call byte1 ; OUTPUT IST DIGIT OF CONSTANT ld a,(de) ; LOAD AGAIN (BYTE1 CLOBBERS) call byte2 ; OUTPUT 2ND DIGIT(ASCII CODE) dec de ; POINT TO 3RD&4TH DIGITS ld a,(de) ; LOAD IN ACCUM. call byte1 ; OUTPUT 3RD DIGIT ld a,(de) ; LOAD AGAIN call byte2 ; OUTPUT 4TH DIGIT call space ; INSERT TWO SPACES thru: inc de ; ADVANCE MEM PTR inc de ; TO NEXT OP CODE ld bc,sstar ; SAVE MEM PTR ld a,e ; TO NEXT LOC. ld (bc),a ; SO CAN LOOK FOR ld a,d ; NEXT OP CODE inc bc ; UPON REENTRY ld (bc),a ; TO PROG. rst 8*07 ; GO MANUAL CONTROL endf: ld bc,mesge-1 ; FIND EOF MESSAGE loopo: inc bc ; LOAD IT,BYTE AT A TIME ld a,(bc) call crt ; PUT IT OUT cp 'H' ; TILL END jp nz,loopo ; GO TO MANUAL rst 8*07 ; CONTROL WHEN FINIS ; ***** OUTPUT SUBROUTINES ***** byte1: and 0f0h ; MASK LEAST SIG. BITS ld b,a ; SAVE IT xor a ; SET FLAG=0 call outt ; OUTPUT TO CRT ret ; RETURN FOR NEXT byte2: and 0fh ; MASK MOST SIG. BITS ld b,a ; SAVE xor a ; A=0 inc a ; SET FLAG-1 call outt ; OUTPUT TO CRT ret ; MORE? outt: cp 00h ; CHECK FLAG jp nz,restr ; IF 01 BR AROUND ld a,b ; GET OUT BYTE rra ; SHIFT INTO rra ; LOWEST 4 BITS rra ; PREP FOR CONV rra ; TO ASCII jp typot ; CONVERT & OUTPUT restr: ld a,b ; GET OUT BYTE typot: ld l,a ; SET UP FOR CONV xor a ld h,a ; 0 IN TOP 8 BITS ld bc,asctb ; LOAD ADDR TABLE IN B,C add hl,bc ; GET POS IN TABLE ex de,hl ; SAVE D,E ld a,(de) ; LOAD CONV. VALUE call crt ; PUT IT OUT ex de,hl ; GET D,E BACK ret ; RETURN FOR NEXT BYTE space: ld a,' ' ; SPACE call crt ; TO CRT ld a,' ' ; ANOTHER SPACE call crt ; TO CRT ret crt: push bc push de push hl push af ld e,a ld c,2 call 5 pop af pop hl pop de pop bc ret 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 .dephase end