;
;***********************************************;
;						;
;	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 CHAR	;
;	AND STORE NEWFIL IN FCB0 (5CH) AND	;
;	ORGFIL IN FCB1 (6CH). WITH A LITTLE	;
;	WORK, THIS FILE COULD STRIP REMARKS	;
;	FROM BASIC FILES. USE THIS FILE ANY	;
;	WAY THAT PLEASES YOU, BUT DON'T SELL	;
;	THIS SUCKER. RANDY M., SANTA ANA, CA.	;
;						;
;						;
;***********************************************;
;

	ORG	100H
;
START:	LXI	H,6CH		;POINT TO 2'ND FCB
	LXI	D,SOURCE	;POINT TO SOURCE FCB AREA
	LXI	B,15		;XFER SOME
	CALL	LDIR		;DO IT
	LXI	H,5CH		;GET 1'ST 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		;JIF 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		;JIF 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 BYTE OF DATA
	JZ	LABL3		;JIF DONE
LABL2A:	PUSH	PSW		;SAVE THE CHAR
	CALL	PUTBYTE		;SAVE IT
	POP	PSW		;GET THE CHAR BACK
	CPI	9		;SEE IF TAB
	JZ	LABL2B		;JIF YES
	CPI	13		;SEE IF CARRIAGE RETURN
	JZ	LABL2B
	CPI	10		;SEE IF LF
	JNZ	LABL2		;JIF NO
;
;	SEARCH FOR NEXT CR OR LF
;
LABL2B:	CALL	GETBYT		;GET A BYTE
	JZ	LABL3		;JIF DONE
	CPI	';'		;SEE IF COMMENT
	JNZ	LABL2A		;JIF NO
LABL2C:	CALL	GETBYT		;SEARCH FOR CR/LF
	JZ	LABL3		;JIF DONE
	CPI	13		;SEE IF CR
	JZ	LABL2A		;JIF YES
	CPI	10		;SEE IF LINE FEED
	JZ	LABL2A		;JIF YES
	JMP	LABL2C
;
;
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		;JIF 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-INIT 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 CHAR
	LXI	H,BYTE2		;POINT TO BYTE COUNTER
	DCR	M
	JNZ	LABL4		;JIF NOT DONE
	MVI	M,80H		;RESET COUNTER
	LXI	H,DBUF		;RE-INIT 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 CHAR
	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 CHAR 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
