; LIST3.ASM BY JOHN M. STEELE
;
; THIS PROGRAM IS BASED ON LIST.COM WHICH IS FOUND
; ON -FOG/UTL.002.  LIST.COM WAS DISASSEMBLED AND
; THE RESULTANT PSUED0-SOURCE CODE MODIFIED TO 
; PRODUCE LIST3.ASM.
;
; LIST3 HAS THE FOLLOWING FEATURES VS LIST:
;
;	*READS FILE INTO LARGE BUFFER ( >48K )
;	 TO REDUCE WEAR ON DRIVES
;
;	*SENDS FORM FEED TO PRINTER AT END OF
;	 FILE, NOT BEGINNING
;
;	*"More...." MESSAGE STARTS ONLY AFTER THE
;	 FIRST SCREENFULL AND IS ALWAYS ERASED
;
;	*CONSOLE IS DEFAULT. TO LIST ON PRINTER
;	 YOU MUST TYPE P (SAVES A LOT OF PAPER)
;
;	*SUPPORTS LEFT MARGIN OF 0-9 SPACES IN
;	 PRINTER MODE. DEFAULT IS 5 SPACES.
;
;	*2 LINE HEADER MODIFIED TO PUT FILE NAME IN
;	 TOP LINE AND LEAVE 2ND LINE BLANK.
;
;	*LINES/PAGE REDUCED TO 57 FOR BETTER 
;	 BOTTOM MARGIN.
;
;  USAGE
;  -----
;
; LIST3			   Describes LIST3 on console
; LIST3 x:filename ext	   Displays file on console
; LIST3 x:filename.ext Pn  Prints file, n space margin
;
; Where x: is optional drive specification
;       filename.ext is any standard CP/M filename
;         (wildcard ? or * selects first match)
;       n is a digit 0,...,9 controls number of added
;         spaces in left margin.  If not specified, or
;         out-of-bounds, a default of 5 is used.
;
;---------------------------------------------------
;
; EQUATES SECTION
;
BDOS	EQU	05H
COMBUF	EQU	80H
CONINCH	EQU	01H
CONSTAT	EQU	0BH
CR	EQU	0DH
FCB1	EQU	5CH
FCB2	EQU	6CH
FF	EQU	0CH
LF	EQU	0AH
OPNFIL	EQU	0FH
OUTSTR	EQU	09H
READSEQ	EQU	14H
WARMST	EQU	00H
;--------------------------------------------------
;
; MAINLINE SECTION
;
	ORG	0100H
;SAVE OLD STACK POINTER AND SET NEW STACK POINTER
	LXI	H,0
	DAD	SP
	SHLD	OLDSTK	
	LXI	SP,NEWSTK	
;CALL INITIALIZATION SUB, OPEN FILE, DO PAGE HEADER
	CALL	INIT	
	CALL	OPNFILE	
	CALL	NXTPAGE	
;
; MAIN LOOP OF PROGRAM
MAINLP:	CALL	READCHR	;READ CHAR. FROM FILE BUFFER
	CALL	WRITCHR	;WRITE CHAR. ON SELECTED DEVICE
	CALL	CONCHK	;CHECK CONSOLE STATUS
	JC	EXIT	;EXIT IF ^C WAS TYPED
	JMP	MAINLP	;CONTINUE
;
;EXIT ROUTINE:CALLED FROM MAINLP, 
; AND FROM ERROR MESSAGE ROUTINES.
;OUTPUT <CR>, RECOVER STACK, AND RETURN TO CP/M.
;EXITFF ROUTINE IS CALLED WHEN EOF OR ^Z IS FOUND.
;PROVIDES FORM FEED PRIOR TO EXIT.
EXITFF:	MVI	A,FF
	CALL	OUTCHR
EXIT:	MVI	A,CR
	CALL	OUTCHR	
	LHLD	OLDSTK	
	SPHL
	MVI	A,0
	RET
;--------------------------------------------------
;END OF MAINLINE ROUTINE
;SUBROUTINE SECTION FOLLOWS
;--------------------------------------------------
;
;SUBROUTINE CONCHK:GETS CONSOLE STATUS BY BDOS CALL
;
CONCHK:	MVI	C,CONSTAT
	CALL	BDOS	
	RAR		;ROTATE BIT 0 TO CARRY
; 0 = NO CHARACTER, RETURN; ELSE GET CHARACTER
	RNC
;--------------------------------------------------
;
;SUBROUTINE INCHAR: GETS CHARACTER BY BDOS CALL
;
INCHAR:	MVI	C,CONINCH
	CALL	BDOS	
	CPI	3	;TEST FOR ^C. IF ^C
	STC		;RETURN WITH CARRY SET
	RZ
	CMC		;ELSE RETURN WITH IT CLEAR.
	RET
;--------------------------------------------------
;SUBROUTINE SAYERR: SET ERROR MESSAGE ADDRESS,
;CONTINUE INTO SUBROUTINE CONSTRG. 
SAYERR:		
	LXI	D,ERRMESS	
;--------------------------------------------------
;
;SUBROUTINE CONSTRG: PRINTS MESSAGE STRING ON CONSOLE 
;VIA BDOS CALL AND EXITS.
;
CONSTRG:MVI	C,OUTSTR
	CALL	BDOS	
	JMP	EXIT	
;
; MESSAGE TABLE FOR CONSTRG
;
ERRMESS:DB	CR,LF,'SOME KIND OF ERROR'
	DB	CR,LF,'$'
NFMESS:	DB	'FILE NOT FOUND',CR,LF,'$'
;--------------------------------------------------
;
;SUBROUTINE DISKRD: READS SEQUENTIAL RECORDS USING 
;FCB1 AT 5CH, INTO FILE BUFFER.  PROCESS STOPS AT
;LAST SECTOR, OR WHEN BUFFER REACHES BOTTOM OF CCP.
;DISKRD IS ENTERED FROM READCHR AND FLOWS BACK
; INTO SUBROUTINE READCHR
;
DISKRD:	LDA	DSKFLG	;CHECK WHETHER LAST SECTOR
	CPI	0FFH	;WAS ALREADY READ.
	JZ	EXITFF	;IF SO, EXIT
	LXI	H,BUFFER;LOAD BUFFER ADDRESS AS POINTER
DISKLP:	XCHG		;POINTER TO <DE>
	MVI	C,1AH	;SET DMA ADDRESS=POINTER
	CALL	BDOS
	LXI	D,FCB1	;READ SEQUENTIAL RECORD	
	MVI	C,READSEQ
	CALL	BDOS	
	CPI	1	;TEST FOR LAST SECTOR
	JZ	FILEND
	ORA	A	;IF A<>0, CALL ERROR
	JNZ	SAYERR	;MESSAGE ROUTINE.
	LXI	D,80H	;ADD 128 TO FBCNTR
	LHLD	FBCNTR
	DAD	D
	SHLD	FBCNTR	;AND STORE IT.
	LDA	FILPAGS	;COMPARE H TO # OPEN PAGES
	CMP	H
	JZ	BUFFULL	;IF =, THEN BUFFER FULL
	LXI	D,BUFFER;ADD BUFFER TO FBCNTR
	DAD	D
	JMP	DISKLP	;GET NEXT SECTOR
FILEND:	MVI	A,0FFH	;SET LAST SECTOR FLAG
	STA	DSKFLG
BUFFULL:LHLD	FBCNTR	;CORRECT FBCNTR
	DCX	H
	SHLD	FBCNTR
	LXI	D,COMBUF;RESET TO NORMAL DMA
	MVI	C,1AH
	CALL	BDOS
	LXI	H,BUFFER;RESET POINTER TO BUFFER START
	SHLD	FBPNTER
;-------------------------------------------------
;
;SUBROUTINE READCHR: TESTS STATUS OF FILE BUFFER,
;REFILLS IT WHEN EMPTY, AND MOVES CHARACTERS TO A.
;INCLUDES TEST FOR ^Z END-OF-FILE AND CALL TO EXIT.
;
READCHR:LHLD	FBCNTR	;CHECK FOR FILE BUFFER
	MOV	A,H	;COUNTER EQUAL TO ZERO.
	ORA	L
	JZ	DISKRD	;YES, READ DISK.
	LHLD	FBPNTER	;LOAD FILE BUFFER POINTER
	MOV	A,M	;GET CHARACTER
	CPI	1AH	;TEST IT FOR ^Z (EOF)
	JZ	EXITFF	;IF SO EXIT
	INX	H	;ELSE, INCREMENT FILE
	SHLD	FBPNTER	;BUFFER POINTER, RESTORE H
	LHLD	FBCNTR	;DECREMENT THE FILE BUFFER
	DCX	H	;COUNTER
	SHLD	FBCNTR
	RET
;--------------------------------------------------
;
;SUBROUTINE WRITCHR: MAINTAINS CHARACTER/LINE AND
;LINES PER PAGE COUNTS. HANDLES SPECIAL CHARACTERS
;AND OUTPUTS CHARACTERS BY CALLS TO OUTCHR.
;
WRITCHR:LXI	H,CHRCNT;INCREMENT CHARACTER COUNT
	INR	M	;ZERO HIGH ORDER BIT OF CHAR.
	ANI	7FH
	CPI	' '	;TEST FOR PRINTABLE CHAR.
	JM	CNTLCHR	;IF NOT, JUMP TO CNTLCHR
;IF CHRCNT=1 AND DEVICE=PRINTER, EXPAND MARGIN
	PUSH PSW
	LDA	PTRFLG	;CHECK DEVICE
	CPI	0	;IF CONSOLE, PRINT CHAR
	JZ	PRTCHR
	MOV	A,M	;ELSE CHECK CHAR. COUNT
	CPI	1
	CZ	MARGIN	;IF 1, CALL MARGIN
PRTCHR:	POP	PSW	;PRINT PRINTABLE CHARACTER
	JMP	OUTCHR
;
;THIS SECTION HANDLES CONTROL CHARACTERS
;IT DOES <CR>, <LF>, <FF>, SUPPORTS <TAB> EVERY
;8TH COLUMN, SUPPORTS <DLE> SEQUENCE FOR COMPRESSED
;SPACES, PRINTS ALL OTHER CONTROL CHAR IN ^ FORMAT.
;
CNTLCHR:DCR	M	;SUBTRACT FROM LINE COUNT
	PUSH	PSW	;SAVE CHAR. ON STACK
TESTCR:	CPI	CR	;TEST FOR CARRIAGE RETURN
	JNZ	TESTLF	
	XRA	A	; IS <CR>. ZERO CHAR. COUNT
	STA	CHRCNT	;AND OUTPUT THE <CR>.
	POP	PSW
	JMP	OUTCHR	
TESTLF:	CPI	LF	;TEST FOR LINE FEED
	JNZ	TESTFF	
	LDA	LINECNT	;IS <LF>. CHECK LINE COUNT
LINES:	CPI	56	;COMPARE TO MAX LINES/PAGE
;NOTE: 56 GIVES 57 LINES PER PAGE ON PRINTER, BUT
;SUBROUTINE SETCON CHANGES THE OPERAND AT LINES+1
;FOR CONSOLE MODE TO BE NUMBER OF LINES PER SCREEN.
	JP	FORMFD	;IF PAGE FULL GO TO FORMFD
	MVI	A,LF	;ELSE OUTPUT <LF>
	CALL	OUTCHR	;
	LXI	H,LINECNT
	INR	M	;INCREMENT LINE COUNT
	POP	PSW	;RESTORE STACK AND RETURN
	RET
TESTFF:	CPI	FF	;TEST FOR FORM FEED
	JNZ	TESTTAB	
FORMFD:	CALL	ENDPAGE	;IS <FF>. CALL END PAGE
	CALL	NXTPAGE	; AND NEXT PAGE ROUTINES
	POP	PSW	;RESTORE STACK
	RET		;AND RETURN
TESTTAB:CPI	9	;TEST FOR TAB
	JNZ	TESTDLE	
TABLOOP:		;IS <TAB>.SEND BLANKS UNTIL
	MVI	A,' '	;CHRCNT IS A MULTIPLE OF 8.
	CALL	WRITCHR	
	LDA	CHRCNT	
	ANI	7	;NOTE 1 SPACE SENT BEFORE
	JNZ	TABLOOP	;TEST IS MADE.
	POP	PSW	;RESTORE STACK, RETURN
	RET
TESTDLE:CPI	10H	;TEST FOR <DLE> SEQUENCE
	JNZ	ELSE	
	POP	PSW	;IS <DLE>. DISCARD CHAR.
	CALL	READCHR	;NEXT CHAR IS NUMBER OF BLANKS
	SUI	20H	;AFTER 20h IS SUBTRACTED.
	MOV	C,A	;PUT BLANK COUNT IN C.
DLELOOP:MVI	A,' '	;SEND A BLANK
	CALL	WRITCHR	
	DCR	C	;DECREMENT COUNT AND
	JNZ	DLELOOP	;TEST IF DONE
	RET
;ALL OTHER CONTROL CHRACTERS, SEND "^" AND FORM
;PRINTING CHAR = CHR. + 40H
ELSE:	MVI	A,5EH
	CALL	WRITCHR
	POP	PSW
	ORI	40H
	CALL	WRITCHR	;023FH
	RET
;--------------------------------------------------
;
;SUBROUTINE MARGIN: OUTPUTS SPACES FOR LEFT MARGIN
;USING NUMBER IN MARGCNT.
;
MARGIN:	LDA	MARGCNT	;LOAD MARGIN COUNT TO B
	MOV	B,A
MARGLP:	DCR	B	;DECRMENT MARGIN COUNT
	RM		;RETURN IF MINUS
	MVI	A,' '	;ELSE, SEND BLANK AND LOOP
	CALL	OUTCHR
	JMP	MARGLP
;--------------------------------------------------
;
;SUBROUTINE OUTCHR: SENDS ONE CHAR. VIA BDOS CALL
;NOTE: OPERAND AT "DEVICE" IS SET FOR PRINTER
;BUT SUBROUTINE "SETCON" CHANGES DEVICE+1 TO 2
;IN CONSOLE MODE.
;
OUTCHR:	PUSH	B	;SAVE REGISTERS
	PUSH	D
	MOV	E,A	;PUT CHAR. IN E
DEVICE:	MVI	C,5	;SET BDOS FUNCTION
	CALL	BDOS	
	POP	D	;RECOVER REGISTERS
	POP	B
	RET
;--------------------------------------------------
;
;SUBROUTINE OPNFILE: OPENS FILE WHOSE NAME IS IN 
;FCB1 OR SENDS MESSAGE IF FILE NOT FOUND.
;
OPNFILE:MVI	C,OPNFIL;SET BDOS FUNCTION
	LXI	D,FCB1	;LOAD FCB ADDRESS
	CALL	BDOS	
	CPI	0FFH	;CHECK FOR NO FILE (FFh)
	LXI	D,NFMESS;LOAD MESSAGE ADDRESS
	JZ	CONSTRG	;AND SEND IF NO FILE
	RET
;--------------------------------------------------
;
;SUBROUTINE INIT: INITIALIZATION ROUTINE SETS
;COUNTERS, DISPLAYS HELP MESSAGE IF REQUIRED,
;SETS CONSOLE/PRINTER MODE, PUTS FILE NAME IN
;PRINT MODE HEADER.
;
INIT:	LDA	WARMST+2;GET HI BYTE OF WARMST
	SUI	16H	;GET CCP PAGE
	LXI	H,BUFFER;GET BUFFER PAGE
	SUB	H	;PAGES OPEN FOR FILE BUFFER
	STA	FILPAGS	;SAVE # OF PAGES
	LDA	FCB1+1	;GET 1ST CHAR. OF FCB1
	CPI	' '	;IF NO FILE NAME OR "?"
	JZ	DESCRIB	;DISPLAY DESCRIPTION OF LIST
	CPI	'?'	
	JZ	DESCRIB	
	LDA	FCB2+1	;GET 1ST CHAR. OF FCB2
	CPI	'P'	;CHECK FOR "P" = PRINTER
	JNZ	SETCON	;IF NOT, SET CONSOLE MODE
;THIS SECTION DONE FOR PRINTER MODE ONLY
	LDA	FCB2+2	;GET DESIRED MARGIN
	CPI	30h	;CHECK CHAR BETWEEN 30-39h
	JM	MOVNAM
	CPI	3Ah
	JP	MOVNAM
	SUI	30H	;OK-CONVERT FROM ASCII
	STA	MARGCNT	;AND STORE MARGIN.
;MOVE FILE NAME TO NAME BUFFER
MOVNAM	LXI	D,NAMBUF;POINT TO NAME BUFFER
	LXI	H,FCB1+1;POINT TO NAME IN FCB1
	MVI	C,11	;LOAD LENGTH OF NAME+EXT
LOOP1:	DCR	C	;DECREMENT AND TEST IF 
	RM		;RETURN IF DONE
	MOV	A,C	;ELSE MOVE COUNT TO A
	CPI	2	;CHECK COUNT.IF 2, SEND "."
	JNZ	NOTDOT	;BETWEEN FILE NAME
	MVI	A,'.'	;AND EXTENSION
	STAX	D
	INX	D
NOTDOT:	MOV	A,M	;GET CHARACTER
	INX	H	;INC FCB POINTER
	ANI	7Fh	;ZERO HIGH ORDER BIT
	CPI	' '	;CHECK IF SPACE
	JZ	LOOP1	;IF SO, IGNORE
	STAX	D	;ELSE STORE IT IN NAME
	INX	D	;BUFFER, INC. POINTER
	JMP	LOOP1	;AND LOOP
;SET UP FOR CONSOLE PRINTING
SETCON:	MVI	A,2	;MOVE 2 TO DEVICE+1
	STA	DEVICE+1
	MVI	A,21	;SET LINES PER SCREEN
	STA	LINES+1
	MVI	A,0	;SET PRINTER FLAG TO
	STA	PTRFLG	;CONSOLE MODE
	RET
;--------------------------------------------------
;
;SUBROUTINE DESCRIB: OUTPUTS DESCRIPTION OF
;LIST.COM ON CONSOLE AS A HELP MESSAGE
;
DESCRIB:LXI	D,DESCRIP	;LOAD POINTER
	JMP	CONSTRG		;CONSOLE STRING OUTPUT
DESCRIP:DB	CR,LF,'List - will list '
	DB	'a source text file in',CR
	DB	LF,'       ascii form (or '
	DB	'compressed ascii)',CR,LF
	DB	'       from a file to either '
	DB	'the printer',CR,LF,'  '
	DB	'     or console.',CR,LF
	DB	LF,'The 1st argument is '
	DB	'the source filename.',CR
	DB	LF,'The 2nd argument may '
	DB	'be:',CR,LF,'     " "  '
	DB	'= list to console.',CR
	DB	LF,' or  "Pn"  = list to '
	DB	'printer.',CR,LF
	DB	'where n = 0,1...9 is the number'
	DB	CR,LF,'of left margin spaces desired.'
	DB	CR,LF,'$'
;---------------------------------------------------
;
;SUBROUTINE ENDPAGE: HANDLES THE "MORE" MESSAGE IN
;CONSOLE MODE AND THE FORM FEED IN PRINTER MODE.
;
ENDPAGE:LDA	PTRFLG	;TEST PRINTER FLAG
	ORA	A
	JNZ	PTR	;JUMP IF PRINTER MODE
CON:	LXI	H,MORMESS;LOAD THE "MORE" MESSAGE
	CALL	OUTSTRG	;AND SEND IT.
	CALL	INCHAR	;WAIT FOR KEYBOARD INPUT
	JC	EXIT	;EXIT IF IT WAS ^C
	LXI	H,MORERAS ;LOAD THE ERASE-MORE MESSAGE
	CALL	OUTSTRG	;AND SEND IT
	RET
PTR:	MVI	A,FF	;SEND A FORM FEED
	CALL	OUTCHR
	RET
;---------------------------------------------------
;
;SUBROUTINE NXTPAGE: HANDLES PAGING FOR BOTH
;PRINTER AND CONSOLE MODE, AND PRINTS PAGE HEADER
;IN PRINTER MODE
;
NXTPAGE:LDA	PTRFLG	;TEST PRINTER FLAG
	ORA	A
	JZ	ALLPAGE	;JUMP IF CONSOLE MODE
	LHLD	PAGECNT	;CONVERT HEX PAGE COUNT
	LXI	D,DCPAGE;TO ASCII IN HEADER MESSAGE
	CALL	FIXPAGE	
	LXI	H,HEADER;LOAD HEADER ADDRESS
	CALL	OUTSTRG	;AND OUTPUT HEADER
ALLPAGE:LHLD	PAGECNT	;BOTH MODES. INC PAGE COUNT
	INX	H
	SHLD	PAGECNT	
	XRA	A	;ZERO LINE AND CHAR. COUNT
	STA	LINECNT	
	STA	CHRCNT	
	RET
MORMESS:DB	CR,LF,'More....',0
MORERAS:DB	CR,'         ',CR,0
;-------------------------------------------------
;
;SUBROUTINE OUTSTRG: MOVES CHAR. STRING TO 
;CHAR. OUTPUT SUB UNTIL NULL IS FOUND.
;
OUTSTRG:MOV	A,M	;GET CHAR
	ORA	A
	RZ		;RETURN IF CHAR IS <NULL>
	INX	H	;ELSE OUTPUT IT
	PUSH	H
	CALL	OUTCHR	
	POP	H
	JMP	OUTSTRG	;LOOP UNTIL <NULL> FOUND
;--------------------------------------------------
;
;SUBROUTINE FIXPAGE: CONVERTS HEX PAGE NUMBER 
;TO ASCII UP TO PAGE 999.
;
FIXPAGE:LXI	B,0FF9CH;LOAD -100 INTO B
	CALL	CONVERT	;CONVERT HUNDREDS DIGIT
	CALL	LDZERO	;CHECK LEADING ZERO
	LXI	B,0FFF6H;LOAD -10 INTO B
	CALL	CONVERT	;CONVERT TENS DIGIT
	CALL	LDZERO	;CHECK LEADING ZERO
	MOV	A,L	;UNITS DIGIT IS L REMAINDER
	ADI	'0'	;CONVERT TO ASCII
	STAX	D	;AND STORE IT
	MVI	A,'0'	;RESTORE LEADING ZERO FLAG
	STA	LZFLAG	;FOR NEXT TIME
	RET		;AND RETURN
;-------------------------------------------------
;
;SUBROUTINE CONVERT: CONVERTS MOST SIGNIFICANT
;REMAINING DIGIT BY SUBTRACTING ITS DECIMAL VALUE
;AND COUNTING NUMBER OF SUBTRACTS.
;
CONVERT:MVI	A,'0'	;INIT DIGIT TO ASCII 0
	PUSH	D	;SAVE D
;INC. A AND ADD NEGATIVE DIGIT VALUE UNTIL 
;CARRY OCCURS
CONVLP:		;053D 
	MOV	E,L	;SAVE HL IN DE
	MOV	D,H	
	INR	A	;INC. DIGIT VALUE (IN ASCII)
	DAD	B	;SUBTRACT DIGIT VALUE
	JC	CONVLP	;CONTINUE UNTIL NEGATIVE
	DCR	A	;UNDO LAST INCREMENT
	MOV	L,E	;UNDO LAST DAD BY
	MOV	H,D	;RESTORING HL FROM DE
	POP	D	;RESTORE D AND RETURN
	RET
;--------------------------------------------------
;
;SUBROUTINE LDZERO: REPLACE LEADING ZERO WITH BLANK
;
LDZERO:	MOV	B,A	;SAVE DIGIT IN B
	LDA	LZFLAG	;LOAD LEADING ZERO FLAG
	CMP	B	;CHECK FOR LEADING ZERO
	JNZ	NOTLD0	;IF NOT JUMP
	MVI	A,' '	;IF SO, STORE BLANK INSTEAD
	STAX	D	;OF DIGIT IT PAGE NUMBER
	INX	D	;INC. PAGE NUMBER POINTER
	RET
NOTLD0:	MOV	A,B	;NOT LEAD. 0. GET DIGIT
	STAX	D	;STORE IT
	INX	D	;INC PAGE NUMBER POINTER
	MVI	A,0FFH	;TURN OFF LEADING ZERO FLAG
	STA	LZFLAG	;AND RETURN
	RET
;--------------------------------------------------
;
; DATA STORAGE SECTION
;
HEADER:	DB	'     Listing of File: '
NAMBUF	DB	'                       '
	DB	'                      '
	DB	'Page '
DCPAGE:	DB	'123',CR,LF,CR,LF,0
FBPNTER:DW	0,0	;FILE BUFFER POINTER
FBCNTR:	DW	0,0	;FILE BUFFER COUNTER
CHRCNT:	DB	0	;CHARACTER COUNTER
LINECNT:DB	0	;LINE COUNTER
PAGECNT:DW	1,0	;PAGE COUNTER
OLDSTK:	DW	0,0	;RETURN STACK STORGAE
PTRFLG:	DB	0FFH	;PRINTER FLAG MUST BE NONZERO
MARGCNT:DB	5
LZFLAG	DB	'0'	;LZFLAG "0" IF LOOKING FOR
			;LEADING ZERO, FFh IF NOT
FILPAGS:DB	0
DSKFLG:	DB	0	;LAST SECTOR FLAG
	DS	0050H	;RESERVED FOR STACK
NEWSTK:	DW	0,0	;TOP OF NEW STACK
BUFF	EQU	($+127)/128*128 ;GET ON PAGE BOUND.
	ORG	BUFF
BUFFER	DB	0	;FILE BUFFER AREA
;-------------------------------------------------
	END		;end of list program
 