; STRIP: this program will strip the comments from an assembly language ; source file. Comments are: ; ; 1) CR,LF,";" ; 2) tab,";" ; ; All text following the semi-colon and up to the next CR/LF will be ; eliminated from the destination file. The form of the command is: ; ; STRIP NEWFIL.TYP=ORGFIL.TYP ; ; I assume your operating system will interpret the "=" as a command ; character and store NEWFIL in FCB0 (5Ch) and ORGFIL in FCB1 (6Ch). ; With a little work, this file could strip remarks from MBASIC files. ; Use this file any way that pleases you, but don't sell it. ; - Randy M. ; Santa Ana, CA ; ; 11/03/87 Removes blank lines. Assumption is that each line ends in ; v11 CR/LF. Run source through filtering program before and ; after this program for best effect. That should remove the ; trailing spaces left after eliminating the comment field. ; - Ernest F. Barnhart N8DVE ; ;----------------------------------------------------------------------- ; TAB EQU 09H LF EQU 0AH CR EQU 0DH SC EQU 03BH ; ORG 100H ; START: LXI H,6CH ; Point to second FCB LXI D,SOURCE ; Point to source FCB area LXI B,15 ; Xfer some CALL LDIR ; Do it LXI H,5CH ; Get first FCB LXI D,DEST ; Point to destination FCB LXI B,15 CALL LDIR ; Do it LXI D,SOURCE ; Open source file MVI C,15 CALL 5 INR A ; See if not found JNZ LABL1 ; If we found it LXI D,CANT MVI C,9 CALL 5 JMP 0 ;..... ; CANT: DB 13,10,'Can''t open source file.',13,10,'$' ; LABL1: LXI D,DEST ; Delete the destination file MVI C,19 CALL 5 LXI D,DEST ; Create it MVI C,22 CALL 5 INR A ; See if out of space JNZ LABL2 ; If no LXI D,SPACE MVI C,9 CALL 5 JMP 0 ;..... ; SPACE: DB 13,10,'Out of disk space.',13,10,'$' ; LABL2: CALL GETBYT ; Get a first byte of line JZ LABL3 ; If done CPI CR JZ LABL2 ; Ignore "CR" if first character CPI LF JZ LABL2 ; Ignore "LF" if first character CPI SC JNZ LABL2B ; If not comment character then save ; LABL2A: CALL GETBYT ; Else ignore all characters on line JZ LABL3 ; If done CPI LF JZ LABL2 ; If "EOL" then start new line JMP LABL2A ; Else loop until finished ; LABL2B: PUSH PSW ; Save the character CALL PUTBYTE ; Save it POP PSW ; Get the character back CPI TAB ; See if tab JZ LABL2C ; If yes CPI LF ; See if "LF" JZ LABL2 ; Start new line CALL GETBYT ; Else get next character JZ LABL3 JMP LABL2B ; Loop until "TAB" or "LF" ; LABL2C: CALL GETBYT ; Check next char JZ LABL3 ; If done CPI SC JNZ LABL2B ; Save character if not comment ; LABL2D: CALL GETBYT ; Else ignore chars CPI CR ; If "EOL" then JZ LABL2B ; Save character JMP LABL2D ; Else loop unitl "EOL" ; LABL3: LDA BYTE2 ; Get byte counter MOV B,A ; Save in 'B' MVI A,1AH ; EOF marker LHLD POINT2 ; Get pointer ; LABL3A: MOV M,A ; Save eof marker INX H ; Bump pointer DCR B JNZ LABL3A ; If not done LXI D,DBUF ; Point to destination buffer MVI C,26 CALL 5 LXI D,DEST ; Point to FCB MVI C,21 ; Write it CALL 5 LXI D,DEST ; Close destination MVI C,16 CALL 5 LXI D,MES1 MVI C,9 CALL 5 JMP 0 ;..... ; MES1: DB 13,10,'*** Job Finished ***',13,10,'$' ; GETBYT: LHLD POINT1 MOV A,M ; Get a byte INX H ; Bump pointer SHLD POINT1 ; Save it LXI H,BYTE1 ; Get byte counter DCR M ; Bump it RNZ MVI M,81H ; Re-initialize to 128 bytes LXI H,SBUF ; Point to start of buffer SHLD POINT1 ; Save it LXI D,SBUF ; Point to source buffer MVI C,26 ; Change dma address CALL 5 LXI D,SOURCE ; Point to source FCB MVI C,20 ; Read in a record CALL 5 ORA A ; See if ok JZ GETBYT ; Get a byte from buffer DCR A ; See if done RZ LXI D,MES2 MVI C,9 CALL 5 XRA A RET ;..... ; MES2: DB 13,10,'Disk Error.',13,10,'$' ; PUTBYTE:PUSH PSW ; Save the character LXI H,BYTE2 ; Point to byte counter DCR M JNZ LABL4 ; If not done MVI M,80H ; Reset counter LXI H,DBUF ; Re-initialize pointer SHLD POINT2 LXI D,DBUF ; Point to destination buffer MVI C,26 CALL 5 LXI D,DEST ; Point to FCB MVI C,21 ; Write it CALL 5 ; LABL4: POP PSW ; Get the character LHLD POINT2 ; Get pointer MOV M,A ; Save it INX H ; Bump pointer SHLD POINT2 ; Save it RET ;..... ; LDIR: MOV A,M ; Get a byte from source STAX D ; Save it in destination INX H ; Bump pointers INX D DCX B ; Dec loop count MOV A,B ; Test if done ORA C JNZ LDIR RET ;..... ; COUNT: DB 9 BYTE1: DB 1 ; Sector character counter BYTE2: DB 129 POINT1: DW SBUF POINT2: DW DBUF ; SOURCE: DB 0,' ',0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0 ; DEST: DB 0,' ',0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0 ; SBUF: DS 128 DBUF: DS 128 ; END START