
		BASIC INTERPRETER
		PART 2
		CCII  V8.79


LINBF		8046H		;LINE BUFFER
BUFP		8047H		;BASIC BUFFER
		80ABH		;DATA FLAG
		80ACH		;MAX RAM AVAIL
		80AEH		;STRING SPACE ADDR
		80CCH		;CURRENT LINE NO
		80D2H		;STACK
		80D2H		;$ SPACE ALLOCATION
		80D4H		;START OF BASIC ADDR
		80D6H		;END OF BASIC ADDR
				;START OF VARIABLES
		80D8H		;START OF ARRAYS ADDR
		80DAH		;END OF ARRAYS ADDR
TEMPHL		80DEH		;BUFFER POINTER
BRTRY		80E0H
RFLG		80E1H
CRTRY		80E2H
OBC		80E3H
FPBP		80F3H
FPB		80F7H		;FILE PARA BLOCK
FATR		80F8H
FNAM		80F9H
FTYP		80FFH
FVER		8102H
FSBK		8103H
FSIZ		8105H
FLBC		8107H
FLAD		8108H
FSAD		810AH
FDBK		810DH
FDEN		810EH
FAUX		810FH
FHAN		8111H
FFCN		8113H
FDRV		8114H
FBLK		8115H
FBUF		8117H
FXBC		8119H
FPTR		811BH
FPBE		811DH
DBFE		819DH
XFFCN		819FH
XFBLK		81A1H
XFBUF		81A3H
XFXBC		81A5H
PUP		81B7H		;POWER UP FLAG
THRUFL		81DEH
KBDFL		81DFH		;KYBD STATUS FLAG
		81F1H		;BASIC OUTPUT FLAG
		81E3H		;SERIAL INPUT FLAG
BASFL		81F1H		;BASIC FLAG
KBCHA		81FEH		;KYBD CHAR
READY		81FFH		;CHAR READY FLAG
		8200H		;INPUT FLAG PTR



		ORG	0338AH


338AH	L312:	LXI	H,0
		MOV	A,B
		ORA	C
		RZ
		MVI	A,16
3392H	L313:	DAD	H
		JC	L194
		XCHG
		DAD	H
		XCHG
		JNC	L314
		DAD	B
		JC	L194
33A0H	L314:	DCR	A
		JNZ	L313
		RET


33A5H	L315:	CPI	'-'
		PUSH	PSW
		JZ	L316
		CPI	'+'
		JZ	L316
		DCX	H
33B1H	L316:	CALL	L265
		MOV	B,A
		MOV	D,A
		MOV	E,A
		CMA
		MOV	C,A
33B9H	L317:	CALL	L096	;NEXT CHAR-SKIP SPACES
				;<C> IF ASCII #,
				;<Z> IF : OR 0
		JC	L325
		CPI	'.'
		JZ	L319
		CPI	'E'
		JNZ	L320
		CALL	L096	;NEXT CHAR-SKIP SPACES
				;<C> IF ASCII #,
				;<Z> IF : OR 0
		PUSH	H
		LXI	H,L318
		XTHL
		DCR	D
		CPI	165
		RZ
		CPI	'-'
		RZ
		INR	D
		CPI	'+'
		RZ
		CPI	164
		RZ
		POP	PSW
		DCX	H
33E1H	L318:	CALL	L096	;NEXT CHAR-SKIP SPACES
				;<C> IF ASCII #,
				;<Z> IF : OR 0
		JC	L327
		INR	D
		JNZ	L320
		XRA	A
		SUB	E
		MOV	E,A
		INR	C
33EFH	L319:	INR	C
		JZ	L317
33F3H	L320:	PUSH	H
		MOV	A,E
		SUB	B
33F6H	L321:	CP	L323
		JP	L322
		PUSH	PSW
		CALL	L284
		POP	PSW
		INR	A
3402H	L322:	JNZ	L321
		POP	D
		POP	PSW
		CZ	L296
		XCHG
		RET


340CH	L323:	RZ
340DH	L324:	PUSH	PSW
		CALL	L291
		POP	PSW
		DCR	A
		RET


3414H	L325:	PUSH	D
		MOV	D,A
		MOV	A,B
		ADC	C
		MOV	B,A
		PUSH	B
		PUSH	H
		PUSH	D
		CALL	L291
		POP	PSW
		SUI	'0'
		CALL	L326
		POP	H
		POP	B
		POP	D
		JMP	L317


342BH	L326:	CALL	L297
		CALL	L294
		POP	B
		POP	D
		JMP	L259


3436H	L327:	MOV	A,E
		RLC
		RLC
		ADD	E
		RLC
		ADD	M
		SUI	'0'
		MOV	E,A
		JMP	L318


;	PRINT "IN "


3442H	L328:	PUSH	H
		LXI	H,20FFH	;' IN' MSG
		CALL	DISPLAY
		POP	H


;	PRINT BYTES FREE


344AH	L329:	XCHG
		XRA	A
		MVI	B,152
		CALL	L295
		LXI	H,2E1CH
		PUSH	H
3455H	L330:	LXI	H,80E3H
		PUSH	H
		CALL	L292
		MVI	M,' '
		JP	L331
		MVI	M,'-'
3463H	L331:	INX	H
		MVI	M,'0'
		JZ	L342
		PUSH	H
		CM	L296
		XRA	A
		PUSH	PSW
		CALL	L344
3472H	L332:	LXI	B,9143H
		LXI	D,4FF8H
		CALL	L307
		JPO	L334
		POP	PSW
		CALL	L324
		PUSH	PSW
		JMP	L332


3486H	L333:	CALL	L284
		POP	PSW
		INR	A
		PUSH	PSW
		CALL	L344
348FH	L334:	CALL	L255
		INR	A
		CALL	L309
		CALL	L299
		LXI	B,774
		POP	PSW
		ADD	C
		INR	A
		JM	L335
		CPI	8
		JNC	L335
		INR	A
		MOV	B,A
		MVI	A,2
34ABH	L335:	DCR	A
		DCR	A
		POP	H
		PUSH	PSW
		LXI	D,3530H
		DCR	B
		JNZ	L336
		MVI	M,'.'
		INX	H
		MVI	M,'0'
		INX	H
34BCH	L336:	DCR	B
		MVI	M,'.'
		CZ	L302
		PUSH	B
		PUSH	H
		PUSH	D
		CALL	L300
		POP	H
		MVI	B,'/'
34CBH	L337:	INR	B
		MOV	A,E
		SUB	M
		MOV	E,A
		INX	H
		MOV	A,D
		SBB	M
		MOV	D,A
		INX	H
		MOV	A,C
		SBB	M
		MOV	C,A
		DCX	H
		DCX	H
		JNC	L337
		CALL	L273
		INX	H
		CALL	L299
		XCHG
		POP	H
		MOV	M,B
		INX	H
		POP	B
		DCR	C
		JNZ	L336
		DCR	B
		JZ	L339
34F0H	L338:	DCX	H
		MOV	A,M
		CPI	'0'
		JZ	L338
		CPI	'.'
		CNZ	L302
34FCH	L339:	POP	PSW
		JZ	L343
		MVI	M,'E'
		INX	H
		MVI	M,'+'
		JP	L340
		MVI	M,'-'
		CMA
		INR	A
350CH	L340:	MVI	B,'/'
350EH	L341:	INR	B
		SUI	10
		JNC	L341
		ADI	'9'+1
		INX	H
		MOV	M,B
3518H	L342:	INX	H
		MOV	M,A
		INX	H
351BH	L343:	MOV	M,C
		POP	H
		RET


351EH	L344:	LXI	B,9474H
		LXI	D,23F7H
		CALL	L307
		POP	H
		JPO	L333
		PCHL


352CH		DB	0,0,0


352FH		ADD	B	;80,A0,86,01	(HEX)
3530H		ANA	B	;10,27,00,E8	(HEX)
		ADD	M
		LXI	B,2710H
		NOP
		RPE


3537H		DB	3,0,100,0,0,10,0,0,1,0,0


3542H	L345:	LXI	H,L296
		XTHL
		PCHL


;	"SQR" TOKEN


3547H		CALL	L297
		LXI	H,352CH
		CALL	L298
		POP	B
		POP	D
		CALL	L292
		JZ	L347
		MOV	A,B
		ORA	A
		JZ	L266
		PUSH	D
		PUSH	B
		MOV	A,C
		ORI	127
		CALL	L300
		JP	L346
		PUSH	D
		PUSH	B
		CALL	L311
		POP	B
		POP	D
		PUSH	PSW
		CALL	L307
		POP	H
		MOV	A,H
		RAR
3576H	L346:	POP	H
		SHLD	BRTRY
		POP	H
		SHLD	TEMPHL
		CC	L345
		CZ	L296
		PUSH	D
		PUSH	B
		CALL	L280
		POP	B
		POP	D
		CALL	L282


;	"EXP" TOKEN


358EH	L347:	CALL	L297
		LXI	B,8138H
		LXI	D,0AA3BH
		CALL	L282
		LDA	RFLG
		CPI	136
		JNC	L288
		CALL	L311
		ADI	128
		ADI	2
		JC	L288
		PUSH	PSW
		LXI	H,31A1H
		CALL	L256
		CALL	L281
		POP	PSW
		POP	B
		POP	D
		PUSH	PSW
		CALL	L258
		CALL	L296
		LXI	H,35CEH
		CALL	L349
		LXI	D,0
		POP	B
		MOV	C,D
		JMP	L282


35CEH		DB	008H,040H,02EH,094H
		DB	074H,070H,04FH,02EH
		DB	077H,06EH,002H,088H
		DB	07AH,0E6H,0A0H,02AH
		DB	07CH,050H,0AAH,0AAH
		DB	07EH,0FFH,0FFH,07FH
		DB	07FH,000H,000H,080H
		DB	081H,000H,000H,000H
		DB	081H


35EFH	L348:	CALL	L297
		LXI	D,31F0H
		PUSH	D
		PUSH	H
		CALL	L300
		CALL	L282
		POP	H
35FEH	L349:	CALL	L297
		MOV	A,M
		INX	H
		CALL	L298
		MVI	B,0F1H


		ORG	$-1


3607H	L350:	POP	PSW
		POP	B
		POP	D
		DCR	A
		RZ
		PUSH	D
		PUSH	B
		PUSH	PSW
		PUSH	H
		CALL	L282
		POP	H
		CALL	L301
		PUSH	H
		CALL	L259
		POP	H
		JMP	L350


;	"RND" TOKEN


361FH	L3501:	CALL	L292
		JM	L351
		LXI	H,820DH
		CALL	L298
362BH	L3502:	RZ
		LXI	B,9835H
		LXI	D,447AH
		CALL	L282
		LXI	B,6828H
		LXI	D,0B146H
		CALL	L259
363EH	L351:	CALL	L300
		MOV	A,E
		MOV	E,C
		MOV	C,A
		MVI	M,128
		DCX	H
		MOV	B,M
		MVI	M,128
		CALL	L263
		LXI	H,820DH
		JMP	L303


;	"COS" TOKEN


3653H	L352:	LXI	H,369DH
		CALL	L256


;	"SIN" TOKEN


3659H	L353:	CALL	L297
		LXI	B,8349H
		LXI	D,0FDBH
		CALL	L299
		POP	B
		POP	D
		CALL	L286
		CALL	L297
		CALL	L311
		POP	B
		POP	D
		CALL	L258
		LXI	H,36A1H
		CALL	L257
		CALL	L292
		STC
		JP	L354
		CALL	L255
		CALL	L292
		ORA	A
3689H	L354:	PUSH	PSW
		CP	L296
		LXI	H,36A1H
		CALL	L256
		POP	PSW
		CNC	L296
		LXI	H,36A5H
		JMP	L348


369DH		DB	0DBH,00FH,049H,081H

36A1H		DB	000H,000H,000H,07FH

36A5H		DB	005H,0BAH,0D7H,01EH
		DB	086H,064H,026H,099H
		DB	087H,058H,034H,023H
		DB	087H,0E0H,05DH,0A5H
		DB	086H,0DAH,00FH,049H
		DB	083H


;	"TAN" TOKEN


36BAH		CALL	L297
		CALL	L353
		POP	B
		POP	H
		CALL	L297
		XCHG
		CALL	L299
		CALL	L352
		JMP	L285


;	"ATN" TOKEN


36CFH		CALL	L292
		CM	L345
		CM	L296
		LDA	80E1H
		CPI	129
		JC	L355
		LXI	B,FTYP+1
		MOV	D,C
		MOV	E,C
		CALL	L286
		LXI	H,L257
		PUSH	H
36ECH	L355:	LXI	H,36F6H
		CALL	L348
		LXI	H,369DH
		RET


36F6H		DB	009H,04AH,0D7H,03BH
		DB	078H,002H,06EH,084H
		DB	07BH,0FEH,0C1H,02FH
		DB	07CH,074H,031H,09AH
		DB	07DH,084H,03DH,05AH
		DB	07DH,0C8H,07FH,091H
		DB	07EH,0E4H,0BBH,04CH
		DB	07EH,06CH,0AAH,0AAH
		DB	07FH,000H,000H,000H
		DB	081H




;============================================================
;	INITIALIZE BASIC GROUP


;	DIRECT INPUT TO BASIC
;	SELECTS OUTPUT, USUALLY TO SCREEN
;	TRANSFER PROGRAM FROM ROM TO RAM


371BH	L356:	MVI	M,23	;KYBD TO BASIC
		SHLD	8200H	;BASIC INPUT FLAG
		MOV	A,L
		LXI	H,BASFL	;BASIC OUTPUT FLAG
		MVI	M,0	;TO SCREEN
		CPI	0DFH	;81DFH?
		JZ	L357	;YES!
		MVI	M,14	;NO-OUT TO SERIAL PORT
372DH	L357:	LXI	H,393FH
		LXI	D,8202H
3733H	L358:	MOV	A,M	;DATA FROM 393FH
		STAX	D	;THRU 39D5H IS MOVED
		INX	D	;TO 8202H THRU 8298H
		INX	H	;	"
		MOV	A,L	;	"
		SUI	0D6H	;	"
		JNZ	L358	;	"
		LHLD	001EH	;81FFH TO HL
		MOV	M,A	;0 TO KBRDY
		RET


;	LOCATE END OF MEMORY


3742H	L359:	CALL	L135	;CR/LF,0 TO 8208H
3745H	L360:	LXI	H,8299H	;START OF BASIC-1
3748H	L361:	INX	H	;+1
		MOV	A,M	;GET CHAR
		CMA
		MOV	M,A	;STUFF IT
		CMP	M	;CK IF SAME
		CMA
		MOV	M,A	;STUFF AGAIN
		JZ	L361	;OK IF 0
		DCX	H	;OOPS - BUF-1
		JMP	L364	;ABORT


;	ESC-I ENTRY


3756H	L3611:	MVI	A,90	;90 TO FLAG TO
		STA	80E3H	;INDICATE BASIC-I
		LXI	H,KBDFL
		CALL	L356	;SET BASIC
		JMP	L362	;SKIP


;	ESC-W ENTRY


3764H		XRA	A	;00 TO FLAG TO
		STA	80E3H	;INDICATE BASIC-W
3768H	L362:	LXI	H,-1	;-1 TO INIT
		SHLD	80CCH	;CURRENT LINE #
		LXI	H,80B0H	;BUFFER
		SHLD	80AEH	;SAVED
3774H	L363:	LXI	H,M8002	;"DISK BASIC" MESSAGE (IN ROM)
		CALL	DISPLAY	;PRINTED
		LDA	80E3H	;0=W, 90=I
		CPI	90	;BASIC-I?
		JZ	L359	;YES-JUMP AND FIND END OF MEMY
				;THEN JUMP TO 37A3H
		CALL	L062	;WAIT FOR MAX BASIC RAM TO
				;BE ENTERED (FROM MSG PROMPT)
		INX	H	;8047H IN HL
		MOV	A,M	;GET CHAR
		ORA	A	;0 IF CR HIT
		JZ	L360	;YES-JUMP, FIND END OF MEMY,
				;THEN JUMP TO 37A3H
		CALL	L112	;CONVERT # TO HEX TO DE
		ORA	A	;A=0?
		JNZ	L363	;NO-FROM L112 FIRST NON BUF
				;CHAR IN A.  IF A<>0, BAD
				;INPUT AND START AGAIN
		XCHG		;MAX RAM IN HL
		LXI	D,7FFFH	;32767 TO DE
		DAD	D	;ADDED...<C> IF MAX =>32768
				;IE, MAX REQUESTED >32K
		JC	L360	;FIND END OF MEMY, GOTO 37A3H
		MOV	A,M	;CHECK TO SEE IF MEMORY EXISTS
		CMA		;AT HL ADDRESS (FOR CCII <32K)
		MOV	M,A	;IF MEMY EXISTS YOU CAN WRITE
		CMP	M	;TO IT.  IF NOT, JUMP AND FIND
		CMA		;END OF MEMORY.
		MOV	M,A
		JNZ	L360
37A3H	L364:	LXI	D,-50	;-50 STRING SPACE
		SHLD	80ACH	;SAVE MAX RAM
		SHLD	80C0H
		DAD	D	;ROOM FOR STRING SPACE
		SPHL		;IS NEW STACK POINTER
		SHLD	80D2H	;START OF STRING SPACE
		LXI	D,8299H	;START OF BASIC-1
		XCHG		;STACK PTR TO DE
		XRA	A
		MOV	M,A	;0 TO 8299H.  IF <>0 WILL
		INX	H	;GET SN ERROR ON RUN
		SHLD	80D4H	;START OF BASIC
		MOV	M,A	;0 TO 829AH
		INX	H	;AND
		MOV	M,A	;0 TO 829BH
		INX	H
		SHLD	80D6H	;END OF BASIC FILE
		MVI	A,151	;SET POWER
		STA	PUP	; UP FLAG
		CALL	L016	;CK FREE MEMORY
		MOV	A,E	;IF NO GOOD GET OM ERROR
		SUB	L	;HL HAS 809CH
		MOV	L,A	;DE HAS STACK POINTER
		MOV	A,D
		SBB	H
		MOV	H,A	;FREE SPACE SIZE IN HL
		CALL	L329	;PRINT # BYTES FREE
		LXI	H,37DFH	;BYTES FREE MSG
		CALL	DISPLAY	;PRINTED
		CALL	INIT	;INITIALIZE BASIC
		JMP	L025	;TO READY INPUT


37DFH		DB	' BYTES FRE','E'+128,0




;==============================================================

37EBH		CALL	L378
		PUSH	H
		JZ	L368
		JM	L369
		POP	D
		LXI	H,8047H
		MVI	M,':'
37FBH	L365:	INX	D
		INX	H
		LDAX	D
		MOV	M,A
		ANA	A
		JNZ	L365
		LHLD	80D4H
		PUSH	H
		CALL	L376
		POP	D
		LHLD	FXBC
		DAD	D
		LDA	8048H
		CPI	137
		JZ	L366
		ANA	A
		JZ	L366
		XCHG
		POP	H
		LHLD	80D6H
		CALL	L004	;CMPHD
		JC	L017
		JMP	L367


3829H	L366:	SHLD	80D6H
382CH	L367:	LXI	H,-1
		SHLD	80CCH
		LXI	H,LINBF
		JMP	L027


3838H	L368:	CALL	L384
		JMP	L370


383EH	L369:	LHLD	80ACH
		INX	H
		XCHG
		LXI	H,0
3846H	L370:	CALL	L377
		JMP	L375


384CH		CALL	L378
		PUSH	H
		JZ	L371
		JM	L373
		LHLD	80D4H
		XCHG
		LHLD	80D6H
		JMP	L372


3860H	L371:	CALL	L384
3863H	L372:	CALL	SUBHD
		MOV	B,H
		MOV	C,L
		JMP	L374


386BH	L373:	LHLD	80ACH
		INX	H
		MOV	C,M
		INX	H
		MOV	B,M
		DCX	H
		XCHG
		INX	B
		INX	B
3876H	L374:	LHLD	80D4H
		SHLD	FLAD
		LHLD	80D6H
		SHLD	FSAD
		CALL	WF2
		JC	L387	;FILE ERROR
3888H	L375:	POP	H
		JMP	L097


388CH	L376:	XCHG
		LXI	H,-28
		DAD	SP
3891H	L377:	CALL	SUBHD
		MOV	B,H
		MOV	C,L
		CALL	RF2
		JC	L387	;FILE ERROR
		RET


389DH	L378:	CALL	L163
		PUSH	H
		CALL	L243
		JZ	L019	;SN ERROR
		INX	H
		INX	H
		MOV	E,M
		INX	H
		MOV	D,M
		LXI	H,DBFE
		MOV	B,A
		MVI	A,20
		CMP	B
		JC	L388
38B6H	L379:	LDAX	D
		MOV	M,A
		INX	H
		INX	D
		DCR	B
		JNZ	L379
		MVI	M,0
		LXI	H,DBFE
		LXI	D,FPB
		LXI	B,392BH	;FILE TYPES
		CALL	PFSPC	;PARSE
		JC	L387	;ERROR!
		CALL	SPNOR
		MVI	B,9
		JNZ	L387	;FILE ERROR
		LXI	D,392BH	;FILE TYPES
		MVI	C,2
38DCH	L380:	LXI	H,FTYP
		MVI	B,3
38E1H	L381:	LDAX	D
		INX	D
		CMP	M
		INX	H
		JZ	L383
		DCR	B
38E9H	L382:	INX	D
		DCR	B
		JNZ	L382
		DCR	C
		JP	L380
		MVI	B,15
		JMP	L387	;FILE ERROR


38F7H	L383:	DCR	B
		JNZ	L381
		POP	H
		DCR	C
		RET


38FEH	L384:	LHLD	FNAM
		MOV	B,L
		MOV	C,H
		MVI	A,' '
		XRA	C
		JNZ	L385
		MOV	C,A
390AH	L385:	CALL	L430
		JC	L388
		XCHG
		DAD	D
		LDAX	D
		INX	D
3914H	L386:	INX	D
		INX	D
		DCR	A
		JNZ	L386
		RET


;	FILE ERROR MSG


391BH	L387:	CALL	EMESS
		LXI	H,FHAN
		MVI	A,252
		CALL	CHDLR
3926H	L388:	MVI	E,36
		JMP	L022	;SL ERROR


392BH		DB	'BAS'
		DB	'ARY'
		DB	'DAT'


;	"CALL" TOKEN


3934H		CALL	L254
		CALL	8202H
		MOV	A,D
		MOV	B,E
		JMP	L204


;	DATA FROM 393FH THRU 39D5H IS
;	MOVED TO 8202H THRU 8298H


393FH		JMP	L014	;(8202)

3942H		JMP	BASOUT	;(8205)

3945H		NOP		;(8208)
		MOV	B,B
3947H		JMP	820AH	;(820A)

394AH		MOV	D,D	;(820D)
		RST	0
		MOV	C,A
		ADD	B
394EH		CALL	L253	;(8211)
		STA	8218H
		IN	0
		JMP	L205

3959H		CALL	L250	;(821C)
		OUT	0	;(821F)
		RET

395FH		POP	D	;(8222)
		IN	0	;(8223)
		XRA	E
		ANA	B
		JNZ	8223H
		RET

3968H		RAR		;(822B)
		MOV	D,A
		MOV	A,C
		JNC	8239H
		PUSH	D
		LXI	D,0
		DAD	D
		POP	D
		ACI	0	;(8237)
		RAR		;(8239)
		MOV	C,A
		MOV	A,H
		RAR
		MOV	H,A
		MOV	A,L
		RAR
		MOV	L,A	;(8240)
		MOV	A,B
		RAR
		MOV	B,A
		DCR	E
		MOV	A,D
		JNZ	822BH
		XCHG
3987H		POP	H	;(824A)
		RET

3989H		PUSH	H	;(824C)
		PUSH	B
		MOV	A,L
		SUI	0
		MOV	L,A	;(8251)
		MOV	A,H
		SBI	0
		MOV	H,A
		MOV	A,B
		SBI	0
		MOV	B,A
		MVI	A,0
		SBI	0	;(825B)
		CMC
		JNC	8269H
		STA	825BH	;(8261)
		POP	PSW
		POP	PSW
		STC
		JNC	E1C1H
		MOV	A,C	;(826A)
		INR	A
		DCR	A
		RAR
		JM	L270
		RAL		;(8271)
		MOV	A,E
		RAL
		MOV	E,A
		MOV	A,D
		RAL
		MOV	D,A
		MOV	A,C
		RAL
		MOV	C,A
		DAD	H
		MOV	A,B
		RAL
		MOV	B,A
		LDA	825BH
		RAL		;(8282)
		STA	825BH
		MOV	A,C
		ORA	D
		ORA	E
		JNZ	824CH
		PUSH	H
		LXI	H,RFLG
		DCR	M	;(8290)
		POP	H
		JNZ	824CH
		JMP	L272


;	END OF MOVED DATA
;
;	FILE ERROR TABLE


39D6H		DB	'E','V'+128
		DB	'B','F'+128
		DB	'N','O'+128
		DB	'A','O'+128
		DB	'F','S'+128
		DB	'R','O'+128
		DB	'E','F'+128
		DB	'C','O'+128
		DB	'C','C'+128
		DB	'R','E'+128
39EAH		DB	'W','E'+128


		ORG	$-2


;	"FILE" COMMANDS


39EAH		MOV	D,A
		PUSH	B
39ECH		CALL	L438
		JZ	L019	;SN ERROR
		LDAX	D
		CPI	'C'
		JZ	L390	;FILE "C"
		CPI	'D'
		JZ	L391	;FILE "D"
		CPI	'E'
		JZ	L396	;FILE "E"
		CPI	'N'
		JZ	L397	;FILE "N"
		CPI	'R'
		JZ	L399	;FILE "R"
		CPI	'T'
		JZ	L402	;FILE "T"
		CPI	'A'
		JNZ	L019	;SN ERROR


;	FILE "A" CHECK


		CALL	L434
		POP	D
		LHLD	FNAM+3
		CALL	L447
		XCHG
		CALL	L097
		RZ
		XCHG
		LHLD	FLAD
		CALL	L447
		LHLD	FSAD
		CALL	L447
		LDA	FSAD+2
		MOV	L,A
		MVI	H,0
		CALL	L447
3A3BH	L389:	XCHG
		JMP	L097


;	FILE "C"


3A3FH	L390:	CALL	L392
		PUSH	H
		CALL	L393
		POP	H
		CALL	L097
		JNZ	L390
		RET


;	FILE "D"


3A4EH	L391:	CALL	L392
		CALL	L097
		JNZ	L391
		RET


3A58H	L392:	CALL	L434
		CALL	L466
		POP	H
		RET


3A60H	L393:	LHLD	XFFCN
		PUSH	H
		DCX	H
		MOV	D,M
		DCX	H
		MOV	E,M
		DCX	H
		DCX	H
		XTHL
		DAD	D
		XCHG
		POP	B
		LHLD	80DAH
3A71H	L394:	CALL	CMPHD
		JZ	L395
		LDAX	D
		STAX	B
		INX	D
		INX	B
		JMP	L394


3A7EH	L395:	MOV	H,B
		MOV	L,C
		SHLD	80DAH
		RET


;	FILE "E"


3A84H	L396:	PUSH	H
		XRA	A
		CALL	L429
		MVI	B,0
		JC	L426
		POP	D
		INX	H
		INX	H
		MOV	B,M
		INX	H
		MOV	C,M
		PUSH	B
		INX	H
		MOV	C,M
		INX	H
		MOV	B,M
		POP	H
		PUSH	B
		PUSH	H
		MOV	L,H
		MVI	H,0
		CALL	L451
		POP	H
		MVI	H,0
		CALL	L451
		POP	H
		CALL	L451
		JMP	L389


;	FILE "N"


3AAFH	L397:	CALL	L423
		MVI	A,1
		CALL	L417
		CALL	L420
		XCHG
		LHLD	FSIZ
		CALL	CMPHD
		MVI	B,8
		JC	L426
		XCHG
		SHLD	FAUX
		MVI	A,128
		STA	FLBC
		LXI	H,FPB
		CALL	L418
3AD5H	L398:	POP	H
		JMP	L097


;	FILE "R"


3AD9H	L399:	CALL	L439
		PUSH	PSW
		CALL	L423
		POP	PSW
		STA	819EH
		XRA	A
		CALL	L417
		CALL	L418
		LHLD	80C2H
		CALL	L445
		STA	FATR
		CALL	L097
		JZ	L400
		CPI	';'
		JNZ	L019	;SN ERROR
		INX	H
		CALL	L443
		JZ	L019	;SN ERROR
		CALL	L421
		CALL	L419
		POP	H
3B0DH	L400:	PUSH	H
		CALL	L428
		MVI	B,6
		JNC	L426
		LXI	H,0
		SHLD	FNAM+3
		SHLD	FNAM+5
		CALL	L422
		MOV	A,E
		STA	FNAM
		PUSH	B
		CALL	L419
		POP	H
		LXI	D,127
		DAD	D
		MOV	A,L
		ANI	128
		MOV	L,A
		SHLD	FNAM+1
		LXI	D,4
		DAD	D
		LDA	FATR
		MOV	E,A
		MVI	D,0
		CALL	MULHD
		PUSH	H
		LXI	D,34
		DAD	D
		XCHG
		LHLD	80DAH
		PUSH	H
		DAD	D
		CALL	L016	;CK FREE MEMORY
		SHLD	80DAH
		POP	H
		LDA	819EH
		MOV	M,A
		INX	H
		XRA	A
		MOV	M,A
		INX	H
		XCHG
		POP	B
		PUSH	B
		LXI	H,30
		DAD	B
		XCHG
		MOV	M,E
		INX	H
		MOV	M,D
		INX	H
		CALL	L436
		POP	B
3B6DH	L401:	XRA	A
		MOV	M,A
		INX	H
		DCX	B
		MOV	A,B
		ORA	C
		JNZ	L401
		JMP	L398


;	"FILE "T"


3B79H	L402:	CALL	L097
		JNZ	L403
		PUSH	H
		XRA	A
		CALL	L429
		CNC	L393
		JMP	L398


3B8AH	L403:	CALL	L095
		INR	L
		CALL	L112	;ASCII DECIMAL TO BINARY
		PUSH	H
		PUSH	D
		XRA	A
		CALL	L429
		JNC	L404
		LXI	D,10
		LHLD	80DAH
		PUSH	H
		DAD	D
		CALL	L016	;CK FREE MEMORY
		SHLD	80DAH
		POP	H
		XRA	A
		MOV	M,A
		INX	H
		MOV	M,A
		INX	H
		MVI	M,6
		INX	H
		MOV	M,A
		INX	H
		SHLD	XFFCN
3BB6H	L404:	LHLD	XFFCN
		POP	D
		MOV	M,E
		INX	H
		MOV	M,D
		INX	H
		XRA	A
		MOV	M,A
		INX	H
		MOV	M,A
		INX	H
		DCR	A
		MOV	M,A
		INX	H
		MOV	M,A
		JMP	L398


3BCAH		MVI	E,128
		CALL	L448
3BCFH	L405:	PUSH	H
		CALL	L163
		LDA	80AAH
		ANA	A
		JNZ	L406
		POP	B
		LXI	D,TEMPHL
		MVI	A,4
		MOV	B,A
		MOV	C,B
		JMP	L407


3BE5H	L406:	CALL	L415
		CALL	L447
		XTHL
		PUSH	PSW
		CALL	L438
		CALL	L415
		MOV	C,A
		POP	PSW
		MOV	B,A
		POP	H
3BF7H	L407:	PUSH	H
		PUSH	B
		CALL	L416
		POP	B
		INR	C
		INR	B
3BFFH	L408:	DCR	B
		JZ	L411
		DCR	C
		JNZ	L409
		INR	C
		MVI	A,' '
		JMP	L410


3C0DH	L409:	LDAX	D
3C0EH	L410:	MOV	M,A
		INX	H
		INX	D
		JMP	L408


3C14H	L411:	POP	H
		CALL	L097
		RZ
		CALL	L095
		INR	L
		JMP	L405


3C20H		XRA	A
		CALL	L448
3C24H	L412:	PUSH	H
		CALL	L180
		LDA	80AAH
		ANA	A
		JNZ	L413
		POP	B
		MVI	A,4
		JMP	L414


3C35H	L413:	CALL	L447
		XTHL
		PUSH	PSW
		CALL	L180
		POP	PSW
		PUSH	D
		CALL	L223
		POP	H
		MOV	M,A
		INX	H
		INX	H
		MOV	M,E
		INX	H
		MOV	M,D
		POP	H
3C4AH	L414:	PUSH	H
		CALL	L416
		CALL	MOVDH
		POP	H
		CALL	L097
		RZ
		CALL	L095
		INR	L
		JMP	L412


3C5DH	L415:	PUSH	H
		PUSH	D
		PUSH	PSW
		CALL	L238
		POP	PSW
		POP	D
		POP	H
		RET	


3C67H	L416:	PUSH	D
		PUSH	PSW
		LHLD	XFBUF
		PUSH	H
		CALL	ADHLA
		XCHG
		LHLD	FSAD
		CALL	CMPHD
		MVI	B,10
		JC	L426
		XCHG
		SHLD	XFBUF
		LHLD	XFFCN
		PUSH	H
		CALL	L428
		POP	D
		CALL	SUBHD
		XCHG
		LHLD	81A7H
		DAD	D
		SHLD	81A7H
		POP	D
		DAD	D
		POP	PSW
		POP	D
		MOV	B,A
		RET	


3C99H	L417:	CALL	OPENX
		MVI	B,14
		JC	L426
		RET


3CA2H	L418:	CALL	CLX
		MVI	B,16
		JC	L426
		RET


3CABH	L419:	XCHG
		LHLD	FSIZ
		CALL	CMPHD
		MVI	B,8
		JC	L426
		LDA	FSAD+2
		ANA	A
		JZ	L426
		RET


3CBFH	L420:	LHLD	80C2H
		CALL	L444
3CC5H	L421:	SHLD	FLAD
		XCHG
		CALL	L444
		SHLD	FSAD
		XCHG
		CALL	L445
		STA	FSAD+2
		CALL	L097
		JNZ	L019	;SN ERROR
		XTHL
		PUSH	H
3CDEH	L422:	LHLD	FLAD
		MOV	B,H
		MOV	C,L
		LHLD	FSAD
		XCHG
		LHLD	FSAD+2
		MVI	H,0
		PUSH	H
		CALL	MULHD
		MOV	D,H
		MOV	E,L
		XTHL
		PUSH	H
		LXI	H,127
		DAD	D
		LXI	D,7
		XCHG
		CALL	SHRHD
		XTHL
		PUSH	H
		DAD	B
		DCX	H
		POP	D
		XCHG
		CALL	DIVHD
		POP	D
		PUSH	D
		CALL	MULHD
		POP	D
		POP	B
		RET


3D10H		DB	'RND'


3D13H	L423:	CALL	L437
		JZ	L425	;FILE ERROR
		SHLD	80C2H
		LXI	H,DBFE
		MOV	B,A
		CPI	17
		JNC	L425	;FILE ERROR
3D25H	L424:	LDAX	D
		MOV	M,A
		INX	H
		INX	D
		DCR	B
		JNZ	L424
		MVI	M,0
		LXI	H,DBFE
		LXI	D,FPB
		LXI	B,3D10H	;".RND" FILE
		CALL	PFSPC	;PARSE
		JC	L425	;ERROR!
		CALL	SPNOR
		RZ


;	FILE ERROR


3D42H	L425:	MVI	B,2
3D44H	L426:	PUSH	B
		CALL	RESET
		XRA	A
		CALL	L429
		POP	B
		JNC	L427
		MOV	E,B
		CALL	INIT2
		CALL	L135	;CR/LF,0 TO 8208H
		CMA
		CALL	L073	;TO CRT
		MVI	A,13
		CALL	L136	;ECHO, 0 TO 8208, 0 TO A
		LXI	H,39D6H
		JMP	L023	;PROCESS ERROR


3D66H	L427:	MOV	E,M
		INX	H
		MOV	D,M
		INX	H
		PUSH	D
		LDA	819EH
		MOV	M,A
		INX	H
		MOV	M,B
		INX	H
		XCHG
		LHLD	80CCH
		XCHG
		MOV	M,E
		INX	H
		MOV	M,D
		LXI	H,L091
		XTHL
		PUSH	H
		LHLD	80C8H
		POP	D
		JMP	L117


3D86H	L428:	LDA	819EH
3D89H	L429:	MOV	C,A
		MVI	B,0
		CALL	L430
		SHLD	XFFCN
		RET


3D93H	L430:	LHLD	80D8H
		MVI	A,19H


		ORG	$-1


3D97H	L431:	DAD	D
		XCHG
		LHLD	80DAH
		CALL	CMPHD
		XCHG
		JZ	L433
		MOV	A,M
		INX	H
		CMP	C
		JNZ	L432
		MOV	A,M
		CMP	B
3DABH	L432:	INX	H
		MOV	E,M
		INX	H
		MOV	D,M
		INX	H
		JNZ	L431
		RET


3DB4H	L433:	STC
		RET


3DB6H	L434:	CALL	L095
		INR	L
3DBAH	L435:	CALL	L440
		XTHL
		PUSH	H
		CALL	L428
		MVI	B,4
		JC	L426
		LXI	D,FPB
		MVI	B,30
		JMP	MOVDH


3DCFH	L436:	LXI	D,FPB
		MVI	B,30
		JMP	MOVHD


3DD7H	L437:	CALL	L095
		INR	L
3DDBH	L438:	CALL	L163
		PUSH	H
		CALL	L243
		INX	H
		INX	H
		MOV	E,M
		INX	H
		MOV	D,M
		POP	H
		RET


3DE9H	L439:	CALL	L095
		INR	L
3DEDH	L440:	CALL	L446
		JM	L019	;SN ERROR
		STA	819EH
		RET


3DF7H	L441:	CALL	L097
		CPI	';'
		JZ	L449
3DFFH	L442:	CALL	L095
		INR	L
3E03H	L443:	CALL	L107
		MOV	A,D
		ORA	E
		XCHG
		RET


3E0AH	L444:	CALL	L442
		JZ	L019	;SN ERROR
		RET


3E11H	L445:	CALL	L095
		INR	L
3E15H	L446:	CALL	L252
		ANA	A
		JZ	L019	;SN ERROR
		RET


3E1DH	L447:	CALL	L095
		MOV	E,E
		CALL	L446
		PUSH	PSW
		CALL	L095
		MOV	E,L
		POP	PSW
		RET


3E2BH	L448:	STA	DBFE
		CALL	L435
		LXI	H,0
		SHLD	XFBLK
		SHLD	XFBUF
		POP	H
		CALL	L441
		SHLD	XFBLK
		XCHG
		CALL	L441
		JZ	L019	;SN ERROR
		DCX	H
		SHLD	XFBUF
		XCHG
		MVI	B,0C1H


		ORG	$-1


3E4EH	L449:	POP	B
		CALL	L095
		DCX	SP
		PUSH	H
		LHLD	XFBLK
		MOV	A,H
		ORA	L
		JNZ	L450
		LHLD	FNAM+3
		INX	H
		SHLD	XFBLK
3E63H	L450:	SHLD	FNAM+3
		XCHG
		LHLD	FLAD
		CALL	CMPHD
		MVI	B,12
		JC	L426
		CALL	L452
		LHLD	XFFCN
		CALL	L436
		POP	H
		RET


3E7DH	L451:	PUSH	H
		XCHG
		CALL	L095
		INR	L
		CALL	L180
		LDA	80AAH
		ANA	A
		JNZ	L019	;SN ERROR
		XTHL
		PUSH	D
		MOV	A,H
		MOV	B,L
		CALL	L204
		LXI	H,TEMPHL
		POP	D
		MVI	B,4
		CALL	MOVDH
		POP	D
		RET


3E9FH	L452:	CALL	L468
3EA2H	L453:	SHLD	81A7H
		MOV	E,M
		INX	H
		MOV	D,M
		INX	H
		PUSH	H
		MOV	A,D
		ORA	E
		JZ	L454
		LHLD	XFBLK
		CALL	SUBHD
		JC	L454
		LDA	FSAD+2
		MOV	E,A
		MVI	D,0
		CALL	SUBHD
		JC	L455
3EC4H	L454:	POP	H
		CALL	L470
		JNZ	L453
		CALL	L458
		MVI	D,0E1H


		ORG	$-1


3ECFH	L455:	POP	H
		LHLD	FNAM+5
		LXI	D,7FFFH
		CALL	CMPHD
		JNZ	L457
		CALL	L468
3EDFH	L456:	INX	H
		INX	H
		MVI	M,0
		INX	H
		MOV	A,M
		ANI	128
		MOV	M,A
		CALL	L471
		JNZ	L456
		LXI	H,0
3EF1H	L457:	INX	H
		SHLD	FNAM+5
		XCHG
		LHLD	81A7H
		INX	H
		INX	H
		MOV	M,E
		INX	H
		LDA	DBFE
		ORA	M
		ANI	128
		ORA	D
		MOV	M,A
		LHLD	81A7H
		MOV	E,M
		INX	H
		MOV	D,M
		INX	H
		PUSH	H
		LHLD	XFBLK
		CALL	SUBHD
		XCHG
		LHLD	FSAD
		CALL	MULHD
		POP	D
		DAD	D
		INX	H
		INX	H
		SHLD	81A7H
		RET


3F22H	L458:	LHLD	FNAM+5
		SHLD	XFXBC
		CALL	L468
		SHLD	81A7H
3F2EH	L459:	PUSH	H
		MOV	A,M
		INX	H
		ORA	M
		INX	H
		JNZ	L460
		POP	H
		SHLD	81A7H
		JMP	L462


3F3DH	L460:	MOV	E,M
		INX	H
		MOV	A,M
		ANI	127
		MOV	D,A
		LHLD	XFXBC
		CALL	CMPHD
		JC	L461
		XCHG
		SHLD	XFXBC
		POP	H
		SHLD	81A7H
		MVI	D,0E1H


		ORG	$-1


3F55H	L461:	POP	H
		CALL	L469
		JNZ	L459
		CALL	L463
3F5FH	L462:	LHLD	XFBLK
		CALL	L464
		PUSH	H
		CALL	L465
		CALL	RD
		MVI	B,18
		JC	L426
		LHLD	81A7H
		POP	D
		MOV	M,E
		INX	H
		MOV	M,D
		RET


3F79H	L463:	LHLD	81A7H
		MOV	E,M
		INX	H
		MOV	D,M
		INX	H
		INX	H
		MOV	A,M
		ANA	A
		RP
		ANI	127
		MOV	M,A
		XCHG
		CALL	L464
		CALL	L465
		CALL	WR
		MVI	B,20
		JC	L426
		RET


3F97H	L464:	DCX	H
		LDA	FSAD+2
		MOV	E,A
		MVI	D,0
		XCHG
		CALL	DIVHD
		PUSH	H
		LDA	FNAM
		MOV	E,A
		MVI	D,0
		CALL	MULHD
		XTHL
		LDA	FSAD+2
		MOV	E,A
		MVI	D,0
		CALL	MULHD
		INX	H
		POP	D
		RET


3FB9H	L465:	LHLD	FSBK
		DAD	D
		SHLD	FBLK
		LHLD	81A7H
		LXI	D,4
		DAD	D
		SHLD	FBUF
		LHLD	FNAM+1
		SHLD	FXBC
		LXI	H,FHAN
		RET


3FD4H	L466:	CALL	L468
3FD7H	L467:	SHLD	81A7H
		PUSH	H
		PUSH	B
		CALL	L463
		POP	B
		POP	H
		CALL	L469
		JNZ	L467
		RET


3FE8H	L468:	LHLD	XFFCN
		LXI	D,30
		DAD	D
		LDA	FATR
		MOV	B,A
		RET


3FF4H	L469:	INX	H
		INX	H
3FF6H	L470:	INX	H
3FF7H	L471:	INX	H
		XCHG
		LHLD	FNAM+1
		DAD	D
		DCR	B
		RET



BASOUT	EQU	00033H
EMESS	EQU	00AD6H
RESET	EQU	00B48H
WF2	EQU	00CF2H
CLX	EQU	00CFCH
RF2	EQU	00D26H
OPENX	EQU	010BCH
WR	EQU	0132EH
RD	EQU	01331H
CHDLR	EQU	01332H
PFSPC	EQU	014ADH
MOVDH	EQU	01871H
MOVHD	EQU	0187AH
CMPHD	EQU	01883H
SUBHD	EQU	0188FH
SPNOR	EQU	01896H
ADHLA	EQU	0194EH
SHRHD	EQU	0197AH
MULHD	EQU	01998H
DIVHD	EQU	019B7H

