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LECT'
;
	DW	VCOLL-1
;
;	'BACKUP'
;
	DW	VBACK-1
;
;	'COPY'
;
	DW	VCOPY-1
;
;	'APPEND'
;
	DW	VAPEND-1
;
;	'DSAVE'
;
	DW	VDSAVE-1
;
;	'DLOAD'
;
	DW	VDLOAD-1
;
;	'CATALOG'
;
	DW	VCATAL-1
;
;	'RENAME'
;
	DW	VRENAM-1
;
;	'SCRATCH'
;
	DW	VSCR-1
;
;	'DIRECTORY'
;
	DW	VDIREC-1
 endif
;.PAGE 'Function address table'
;
;
;
FUNCAD	EQU	*
;
;	SGN
;
	DW	A3AB1
;
;	INT
;
	DW	A3B44
;
;	ABS
;
	DW	A3AD0
;
;	USER FUNCTION
;
	DW	USERFN
;
;	FRE
;
	DW	A3181
;
;	POS
;
	DW	A31A2
;
;	SQR
;
	DW	FPSQRT
;
;	RND
;
	DW	FPRND
;
;	LOG
;
	DW	FPLOG
;
;	EXP
;
	DW	FPEXP
;
;	COS
;
	DW	FPCOS
;
;	SIN
;
	DW	FPSIN
;
;	TAN
;
	DW	FPTAN
;
;	ATN
;
	DW	FPARCT
;
;	PEEK
;
	DW	FPEEK
;
;	LEN
;
	DW	A3573
;
;	STR$
;
	DW	A3266
;
;	VAL
;
	DW	FVAL
;
;	ASC
;
	DW	FASC
;
;	CHR$
;
	DW	A34E3
;
;	LEFT$
;
	DW	A34F7
;
;	RIGHT$
;
	DW	A3523
;
;	MID$
;
	DW	A352E
;.PAGE 'Operator table with priority and address'
;
;	+
;
A2068	DB	$79
	DW	FPADD-1
;
;	-
;
	DB	$79
	DW	FPSUB-1
;
;	*
;
	DB	$7B
	DW	FPMULT-1
;
;	/
;
	DB	$7B
	DW	FPDIV-1
;
;	^
;
	DB	$7F
	DW	A3DCC-1
;
;	AND
;
	DB	$50
	DW	A2E07-1
;
;	OR
;
	DB	$46
	DW	A2E04-1
;
;	NEGATE
;
	DB	$7D
	DW	A3E05-1
;
;
;
	DB	$5A
	DW	A2D65-1
;
;
;
	DB	$64
	DW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DB	0
;
;
;
INK	ASC	' IN '
	DB	0
;
;
;
OKK	DB	$0D
 ifndef cbmB4
	DB	$0A
 endif
	ASC	'READY.'
	DB	$0D
 ifndef cbmB4
	DB	$0A
 endif
	DB	0
;
;
;
BREAKK	DB	$0D
 ifndef cbmB4
	DB	$0A
 endif
	ASC	'BREAK'
	DB	0
;.PAGE 'Find FOR/GOSUB Entry on Stack'
;
;
;
A2274	TSX
	INX
	INX
	INX
	INX
;
;
;
GC	LDA	BSTACK+1,X
	CMP	#TKFOR	; $81
	BNE	RTSM
;
;
;
	LDA	Z96+1
	BNZ	GD
;
;
;
	LDA	BSTACK+2,X
	STA	Z96
	LDA	BSTACK+3,X
	STA	Z96+1
;
;
;
GD	CMP	BSTACK+3,X
	BNE	GE
	LDA	Z96
	CMP	BSTACK+2,X
	BE	RTSM
;
;	Update index by size of 'FOR' stack entry
;
GE	TXA
	CLC
	ADC	#18
	TAX
;
;	Unconditional branch
;
	BNZ	GC
;
;	Return to caller
;
RTSM	RTS
;.PAGE 'Open Space in Memory'
;
;
;
A22A2	JSR	A22F2
	STA	AREPTR
	STY	AREPTR+1
;
;
;
A22A9	SEC
	LDA	ZA7
	SBC	ZAC
	STA	Z6F
	TAY
	LDA	ZA7+1
	SBC	ZAC+1
	TAX
	INX
	TYA
	BZ	GJ
	LDA	ZA7
	SEC
	SBC	Z6F
	STA	ZA7
	BC	GF
	DEC	ZA7+1
	SEC
GF	LDA	ZA5
	SBC	Z6F
	STA	ZA5
	BC	GH
	DEC	ZA5+1
	BNC	GH
;
;
;
GG	LDA	(ZA7),Y
	STA	(ZA5),Y
GH	DEY
	BNZ	GG
;
;
;
	LDA	(ZA7),Y
	STA	(ZA5),Y
GJ	DEC	ZA7+1
	DEC	ZA5+1
	DEX
	BNZ	GH
;
;	Return to caller
;
	RTS
;.PAGE 'Check Stack Depth'
;
;
;
A22E5	ASL	A
 ifdef cbmB1
	ADC	#$36
 endif
 ifndef cbmB1
	ADC	#$3E
 endif
	BC	PROME
	STA	Z6F
	TSX
	CPX	Z6F
	BL	PROME
;
;
;
	RTS
;.PAGE 'Check Memory Overlap'
;
;
;
A22F2	CPY	STRPTR+1
	BL	RTSF
	BNE	DC
	CMP	STRPTR
	BL	RTSF
;
;
;
DC	PHA
	LDX	#9
	TYA
DD	PHA
	LDA	ZA4,X
	DEX
	BNM	DD
;
;
;
	JSR	A3321
;
;
;
	LDX	#-9
DE	PLA
	STA	ZAE,X
	INX
	BM	DE
;
;
;
	PLA
	TAY
	PLA
;
;
;
	CPY	STRPTR+1
	BL	RTSF
	BNE	PROME
	CMP	STRPTR
	BGE	PROME
;
;
;
RTSF	RTS
*******************************************************************************
;
;
;
PROME	LDX	#OUTMK-ERRSK
;
;
;
PRERR
 ifndef cbmB4
	LSR	Z14
 endif
	LDA	CURDVC
	BZ	PAA
;
;
;
	JSR	RESTIO
;
;
;
	LDA	#0
	STA	CURDVC
;
;
;
PAA	JSR	CRLF
;
;	Display '?'
;
	JSR	OUTQM
;
;	Display error message
;
CL	LDA	ERRSK,X
	PHA
	AND	#$7F
	JSR	CONOUT
	INX
	PLA
	BNM	CL
;
;
;
AC379	JSR	A2555
;
;
;
	LDA	#>ERRK
	LDY	#<ERRK
;
;
;
BKB4GN	JSR	OPSTRA
	LDY	CURLNO+1
	INY
	BZ	GETNXT
;
;
;
	JSR	PELNO
;.PAGE 'Print prompt (OK) and react to next input from terminal'
;
;
;
GETNXT
 ifndef cbmB4
	LSR	Z14
 endif
	LDA	#>OKK
	LDY	#<OKK
	JSR	OPSTRA
;
;
;
BS	JSR	IPSTR
	STX	CTXPTR
	STY	CTXPTR+1
;
;	Get next BASIC text character
;
	JSR	NXTTCE
 ifndef cbmB1
	TAX
 endif
	BZ	BS
	LDX	#-1
	STX	CURLNO+1
	BNC	BT
;
;
;
	JSR	CVTTKN
;
;
;
	JMP	EXECST
;
;
;
BT	JSR	ASCBIN
;
;
;
	JSR	CVTTKN
	STY	Z0C
;
;
;
	JSR	SRCLNA
	BNC	CU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
	BZ	NRC46E
 endif
;
;
;
	LDY	#4
GK	INY
	LDA	(Z6F),Y
	BNZ	GK
	INY
	TYA
	ADC	Z6F
	TAX
	LDY	#0
	STA	(Z6F),Y
 ifndef cbmB4
	LDA	Z6F+1
	ADC	#0
 endif
 ifdef cbmB4
	TYA
	ADC	Z6F+1
 endif
	INY
	STA	(Z6F),Y
	STX	Z6F
	STA	Z6F+1
	BNC	CY
 ifndef cbmB1
;
;
;
NRC46E	RTS
 endif
;.PAGE 'Input string from console'
 ifdef cbmB1
;
;
;
AG	DEX
	BNM	AE
AF	JSR	CRLF
 endif
;
;	Clear string length counter register
;
IPSTR	LDX	#0
 ifndef cbmB4
;
;	Get character from console while checking for ctrl-O
;
AE	JSR	GIACK
 endif
 ifdef cbmB4
;
;	Get character from console
;
AE	JSR	INPCH
 endif
;
;	Branch if end of line
;
	CMP	#CR
	BE	AK
;
;	Store character in buffer
;
	STA	CONBUF,X
;
;	Increment length counter register
;
	INX
 ifndef cbmB4
;
;	Unconditional branch (assumes string length will not exceed 255)
;
	BNZ	AE
 endif
 ifdef cbmB4
;
;	Branch if string length less than 80
;
	CPX	#81
	BNE	AE
;
;	Display "?STRING TOO LONG"
;
	LDX	#STRTLK-ERRSK
	JMP	PRERR
 endif
;
;	Go null terminate string
;
AK	JMP	STNUL
 ifndef cbmB4
;.PAGE 'Get input and check for ctrl-O'
;
;
;
GIACK	JSR	INPCH
;
;
;
	LDY	CURDVC
	BNZ	AD
;
;
;
	CMP	#SI
	BNE	AD
;
;	Save character on stack
;
	PHA
;
;	Toggle switch
;
	LDA	Z14
	EOR	#%11111111
	STA	Z14
;
;	Restore character from stack
;
	PLA
;
;
;
AD	RTS
 endif
;.PAGE 'Tokenize input buffer'
;
;
;
CVTTKN	LDX	CTXPTR
	LDY	#4
	STY	Z10
CD
 ifdef cbmB1
	LDA	ZPSTRT,X
 endif
 ifndef cbmB1
	LDA	CONBUF,X
 endif
	BNM	PCD
	CMP	#$FF
	BE	CB
	INX
	B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	BZ
	LDA	(Z6F),Y
	BNZ	CA
 endif
;
;
;
 ifdef cbmB1
	LDA	ZPSTRT,X
 endif
 ifndef cbmB1
	LDA	CONBUF,X
 endif
	BNM	CH
;
;
;
CJ	STA	CONBUF-3,Y
 ifndef cbmB1
	DEC	CTXPTR+1
 endif
	LDA	#>CONBUF-1
	STA	CTXPTR
	RTS
;.PAGE 'Search for line number'
;
;
;
SRCLNA	LDA	TXSPTR
	LDX	TXSPTR+1
;
;
;
SRCLNB	LDY	#1
;
;	Set pointer
;
	STA	ZAC
	STX	ZAC+1
;
;
;
	LDA	(ZAC),Y
	BZ	HC
;
;
;
	INY
	INY
	LDA	Z19+1
	CMP	(ZAC),Y
	BL	RTSH
	BE	HA
	DEY
	BNZ	HB
;
;
;
HA	LDA	Z19
	DEY
	CMP	(ZAC),Y
	BL	RTSH
	BE	RTSH
HB	DEY
	LDA	(ZAC),Y
	TAX
	DEY
	LDA	(ZAC),Y
	BC	SRCLNB
HC	CLC
;
;
;
RTSH	RTS
;.PAGE 'NEW AND CLEAR'
;
;
;
VNEW	BNZ	RTSH
;
;
;
DONEW	LDA	#0
	TAY
	STA	(TXSPTR),Y
	INY
	STA	(TXSPTR),Y
	LDA	TXSPTR
 ifndef cbmB1
	CLC
 endif
	ADC	#2
	STA	VASPTR
	LDA	TXSPTR+1
	ADC	#0
	STA	VASPTR+1
;
;	Initialize 'CTXPTR' to start of text area
;
A2537	JSR	ICTPTR
 ifndef cbmB1
;
;
;
	LDA	#0
 endif
 ifndef cbmB1
;
;
;
VCLR	BNZ	RTSG
 endif
;
;
;
DOCLR	LDA	HMEPTR
	LDY	HMEPTR+1
	STA	STRPTR
	STY	STRPTR+1
 ifdef cbmB4
;
;
;
	LDA	#0
	STA	SZ0D
 endif
;
;
;
	JSR	ABRTIO
;
;
;
	LDA	VASPTR
	LDY	VASPTR+1
	STA	ARSPTR
	STY	ARSPTR+1
	STA	AREPTR
	STY	AREPTR+1
;
;	Initialize 'DATPTR' to start of text area
;
AC581	JSR	VRESTR
;
;
;
*	JSR	A2555
;
;
;
*	RTS
*******************************************************************************
;
;
;
A2555	LDX	#>Z66
	STX	Z63
;
;	Move return from current stack to top of stack minus 1
;
	PLA
	TAY
	PLA
 ifdef cbmB1
	LDX	#>$01FE
 endif
 ifndef cbmB1
	LDX	#>$01FA
 endif
	TXS
	PHA
	TYA
	PHA
;
;
;
	LDA	#0
	STA	Z8A+1
	STA	Z11
 ifdef cbmB1
;
;
;
	RTS
	DB	$51
 endif
;
;
;
RTSG	RTS
;.PAGE 'Initialize text extract routine to address of text start'
;
;
;
ICTPTR	CLC
	LDA	TXSPTR
	ADC	#>-1
	STA	CTXPTR
	LDA	TXSPTR+1
	ADC	#<-1
	STA	CTXPTR+1
;
;
;
	RTS
;.PAGE 'LIST'
;
;
;
VLIST	BNC	EG
	BZ	EG
;
;	Branch if accumulator is not token for minus sign
;
	CMP	#TKMIN
	BNE	RTSG
;
;
;
EG	JSR	ASCBIN
;
;
;
	JSR	SRCLNA
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;	Branch if end of statement
;
	BZ	EP
;
;	Branch if accumulator is not token for minus sign
;
	CMP	#TKMIN
	BNE	RTSH
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;
;
	JSR	ASCBIN
	BNZ	RTSH
;
;
;
EP	PLA
	PLA
;
;
;
	LDA	Z19
	ORA	Z19+1
	BNZ	EH
;
;
;
	LDA	#-1
	STA	Z19
	STA	Z19+1
;
;
;
EH	LDY	#1
	STY	Z10
	LDA	(ZAC),Y
	BZ	EL
;
;
;
	JSR	CKSTOP
;
;
;
	JSR	CRLF
;
;
;
	INY
	LDA	(ZAC),Y
	TAX
	INY
	LDA	(ZAC),Y
	CMP	Z19+1
	BNE	EJ
	CPX	Z19
	BE	EK
EJ	BC	EL
EK	STY	Z96
	JSR	A3C59
	LDA	#$20
ET	LDY	Z96
	AND	#$7F
EN	JSR	CONOUT
	CMP	#'"
	BNE	PENA
;
;
;
	LDA	Z10
	EOR	#$FF
	STA	Z10
;
;
;
PENA	INY
 ifndef cbmB1
	BZ	EL
 endif
	LDA	(ZAC),Y
	BNZ	EM
	TAY
	LDA	(ZAC),Y
	TAX
	INY
	LDA	(ZAC),Y
	STX	ZAC
	STA	ZAC+1
	BNZ	EH
;
;
;
EL	JMP	GETNXT
;
;
;
EM	BNM	EN
	CMP	#$FF
	BE	EN
	BIT	Z10
	BM	EN
 ifndef cbmB4
	SEC
	SBC	#$7F
	TAX
	STY	Z96
	LDY	#$FF
 endif
 ifdef cbmB4
	TAX
	STY	Z96
	LDY	#<VERBSK
	STY	Z6F+1
	LDY	#>VERBSK
	STY	Z6F
	LDY	#0
	ASL	A
	BZ	P80ES
 endif
EQ	DEX
 ifndef cbmB4
	BZ	ES
 endif
 ifdef cbmB4
	BNM	ES
 endif
ER
 ifndef cbmB4
	INY
	LDA	VERBSK,Y
 endif
 ifdef cbmB4
	INC	Z6F
	BNZ	P80ER
	INC	Z6F+1
P80ER	LDA	(Z6F),Y
 endif
	BNM	ER
;
;	Unconditional branch
;
	BM	EQ
;
;
;
ES	INY
 ifndef cbmB4
	LDA	VERBSK,Y
 endif
 ifdef cbmB4
P80ES	LDA	(Z6F),Y
 endif
	BM	ET
	JSR	CONOUT
	BNZ	ES
;.PAGE 'Handle ''FOR'' statement'
;
;
;
VFOR	LDA	#$80
	STA	Z11
;
;
;
	JSR	VLET
;
;
;
	JSR	A2274
	BNZ	EU
;
;
;
	TXA
	ADC	#$0F
	TAX
	TXS
;
;
;
EU	PLA
	PLA
;
;	Ensure sufficient space on stack for 18 byte 'FOR' stack entry
;
	LDA	#18/2
	JSR	A22E5
;
;	Load accumulator with length of 'FOR' statement
;
	JSR	FESTA
;
;	Calculate and push pointer to first statement in 'FOR' loop onto stack
;
	CLC
	TYA
	ADC	CTXPTR
	PHA
	LDA	CTXPTR+1
	ADC	#0
	PHA
;
;	Push line number of first statement in 'FOR' loop onto stack
;
	LDA	CURLNO+1
	PHA
	LDA	CURLNO
	PHA
;
;	Validate that the current BASIC text character is token for 'TO'
;
	LDA	#TKTO
	JSR	CKTERM
;
;	Check for type mismatch
;
	JSR	A2C37
;
;	Evaluate 'TO' value
;
	JSR	A2C34
;
;
;
	LDA	ZB3
	ORA	#%01111111	; $7F
	AND	ZAF
	STA	ZAF
;
;	Set return address
;
	LDA	#>A2651
	LDY	#<A2651
	STA	Z6F
	STY	Z6F+1
;
;	Push 'TO' value onto stack
;
	JMP	A2CED
;
;	Load 'STEP' default value into 'FAC'
;
A2651	LDA	#>FPONE
	LDY	#<FPONE
	JSR	MFPACC
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;	Branch if not toen for 'STEP'
;
	CMP	#TKSTEP
	BNE	EV
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;	Evaluate 'STEP' expression
;
	JSR	A2C34
;
;	Get sign of 'STEP' value
;
EV	JSR	A3AA3
;
;	Push sign of 'STEP' value and 'STEP' value onto stack
;
	JSR	A2CE2
;
;	Push pointer to 'FOR' variable onto stack
;
	LDA	Z96+1
	PHA
	LDA	Z96
	PHA
;
;	Push token onto stack
;
	LDA	#TKFOR	; $81
	PHA
;.PAGE 'BASIC Warm Start'
;
;
;
A2674	JSR	CKSTOP
;
;
;
	LDA	CTXPTR
	LDY	CTXPTR+1
 ifndef cbmB1
	CPY	#<CONBUF
 endif
 ifdef cbmB2
	NOP
 endif
	BE	EC
;
;
;
	STA	Z8A
	STY	Z8A+1
 ifdef cbmB1
	LDY	#0
 endif
;
;	Branch if end of BASIC text
;
EC
 ifdef cbmB1
	LDA	(CTXPTR),Y
	BZ	PECA
;
;
;
	CMP	#':
	BE	EXECST
;
;
;
CK	JMP	PRSYNE
 endif
 ifndef cbmB1
	LDY	#0
	LDA	(CTXPTR),Y
	BNZ	NRDB
 endif
PECA	LDY	#2
	LDA	(CTXPTR),Y
	CLC
 ifdef cbmB1
	BZ	JH
 endif
 ifndef cbmB1
	BNZ	NRECA
	JMP	JH
NRECA
 endif
	INY
	LDA	(CTXPTR),Y
	STA	CURLNO
	INY
	LDA	(CTXPTR),Y
	STA	CURLNO+1
	TYA
	ADC	CTXPTR
	STA	CTXPTR
	BNC	EXECST
	INC	CTXPTR+1
;
;	Get next BASIC text character
;
EXECST	JSR	NXTTCE
;
;
;
	JSR	XFERTK
	JMP	A2674
;.PAGE
;
;
;
XFERTK
 ifdef cbmB1
	BZ	RTSJ
 endif
 ifndef cbmB1
	BZ	RTSE
 endif
;
;	Branch if token
;
 ifdef cbmB1
	SEC
 endif
A26AC	SBC	#$80
 ifdef cbmB1
	BGE	DA
;
;	Not token, assume 'LET'
;
	JMP	VLET
;
;
;
DA
 endif
 ifndef cbmB1
	BL	NRDA
 endif
	CMP	#(EROUAD-ROUTAD)/2
 ifdef cbmB1
	BGE	CK
 endif
 ifdef cbmB2
	BGE	NRDD
 endif
 ifdef cbmB4
	BL	P80DA
	CMP	#$4B
	BL	NRDC
	SBC	#40
P80DA
 endif
;
;	Push address of routine for token (less 1) on stack
;
	ASL	A
	TAY
	LDA	ROUTAD+1,Y
	PHA
	LDA	ROUTAD,Y
	PHA
;
;	Get next BASIC text character and execute routine
;
	JMP	NXTTCE
 ifndef cbmB1
;
;	Not token, assume 'LET'
;
NRDA	JMP	VLET
;
;
;
NRDB	CMP	#$3A
	BE	EXECST
;
;
;
NRDC	JMP	PRSYNE
  ifndef cbmB4
;
;
;
NRDD	CMP	#$4B
	BNE	NRDC
;
;	Get next BASIC text character
;
	JSR	NXTTCE
  endif
  ifdef cbmB4
;
;	Re-get current BASIC text character
;
NSB7AC	JSR	CURTCE
  endif
;
;	Validate that the current BASIC text character is token for 'TO'
;
	LDA	#TKTO
	JSR	CKTERM
;
;
;
	JMP	VGOTO
 endif
;.PAGE 'RESTORE'
;
;	'TXSPTR' - 1 -> 'DATPTR'
;
VRESTR	SEC
	LDA	TXSPTR
	SBC	#1
	LDY	TXSPTR+1
	BC	A26D5
	DEY
A26D5	STA	DATPTR
	STY	DATPTR+1
;
;
;
RTSE	RTS
;.PAGE 'STOP AND END'
;
;
;
VSTOP	BGE	JC
;
;
;
VEND	CLC
JC	BNE	RTSJ
;
;
;
	LDA	CTXPTR
	LDY	CTXPTR+1
 ifndef cbmB1
	LDX	CURLNO+1
	INX
 endif
	BZ	JD
	STA	Z8A
	STY	Z8A+1
;
;
;
A26F7	LDA	CURLNO
	LDY	CURLNO+1
	STA	Z88
	STY	Z88+1
;
;
;
JD	PLA
	PLA
;
;
;
JH	LDA	#>BREAKK
	LDY	#<BREAKK
 ifndef cbmB4
	LDX	#0
	STX	Z14
 endif
	BNC	JE
	JMP	BKB4GN
JE	JMP	GETNXT
;.PAGE 'CONTINUE'
;
;
;
VCONT	BNZ	RTSJ
;
;
;
	LDX	#CANTCK-ERRSK
;
;
;
	LDY	Z8A+1
	BNZ	JJ
;
;
;
	JMP	PRERR
;
;
;
JJ	LDA	Z8A
	STA	CTXPTR
	STY	CTXPTR+1
;
;
;
	LDA	Z88
	LDY	Z88+1
	STA	CURLNO
	STY	CURLNO+1
;
;
;
RTSJ	RTS
 ifdef cbmB1
;.PAGE 'SUBROUTINES'
;
;
;
A272B	JSR	A3595
	BNZ	RTSJ
	INX
	CPX	#$0A
	BGE	JF
	DEX
	STX	Z15
;
;
;
	RTS
;
;
;
JF	JMP	A304B
 endif
;.PAGE 'RUN AND GOSUB'
 ifdef cbmB1
;
;	'CLR'
;
VCLR	BNZ	RTSJ
	JMP	DOCLR
 endif
;
;	'RUN'
;
VRUN	BNZ	FA
	JMP	A2537
FA	JSR	DOCLR
	JMP	FB
;
;	'GOSUB'
;
VGOSUB	LDA	#6/2
	JSR	A22E5
;
;	Push current text pointer on stack
;
	LDA	CTXPTR+1
	PHA
	LDA	CTXPTR
	PHA
;
;	Push current line number on stack
;
	LDA	CURLNO+1
	PHA
	LDA	CURLNO
	PHA
;
;	Push 'GOSUB' token on stack
;
	LDA	#TKGSUB
	PHA
;
;	Re-get current BASIC text character
;
FB	JSR	CURTCE
;
;
;
	JSR	VGOTO
;
;
;
	JMP	A2674
;.PAGE 'GO TO'
;
;
;
VGOTO	JSR	ASCBIN
;
;
;
	JSR	FESTB
;
;
;
	LDA	CURLNO+1
	CMP	Z19+1
	BGE	FC
;
;
;
	TYA
;
;
;
	SEC
	ADC	CTXPTR
	LDX	CTXPTR+1
	BNC	FD
;
;
;
	INX
;
;	Unconditional branch
;
	BC	FD
;
;
;
FC	LDA	TXSPTR
	LDX	TXSPTR+1
FD	JSR	SRCLNB
	BNC	ED
;
;
;
	LDA	ZAC
	SBC	#1
	STA	CTXPTR
	LDA	ZAC+1
	SBC	#0
	STA	CTXPTR+1
;
;
;
RTSK	RTS
;.PAGE 'RETURN AND DATA'
;
;
;
VRETRN	BNZ	RTSK
;
;
;
	LDA	#-1	; $FF
 ifdef cbmB1
	STA	Z96
 endif
 ifndef cbmB1
	STA	Z96+1
 endif
;
;
;
	JSR	A2274
	TXS
;
;
;
	CMP	#TKGSUB	; $8D
	BE	EE
;
;
;
	LDX	#RNGOSK-ERRSK
	DB	$2C
ED	LDX	#UNKSK-ERRSK
	JMP	PRERR
;
;
;
AZ	JMP	PRSYNE
;
;	Remove 'GOSUB' token from stack
;
EE	PLA
;
;	Set line number from 'GOSUB' stack entry
;
	PLA
	STA	CURLNO
	PLA
	STA	CURLNO+1
;
;	Set pointer to statement from 'GOSUB' stack entry
;
	PLA
	STA	CTXPTR
	PLA
	STA	CTXPTR+1
;
;	Load accumulator with length of current statement
;
VDATA	JSR	FESTA
;
;	Update current text pointer
;
UPCTPT	TYA
	CLC
	ADC	CTXPTR
	STA	CTXPTR
	BNC	RTSL
	INC	CTXPTR+1
;
;
;
RTSL	RTS
;.PAGE 'Get length of statement'
;
;
;
FESTA	LDX	#':
;
;	Skip past 'FESTB' instruction
;
	DB	$2C
;
;
;
FESTB	LDX	#0
;
;
;
	STX	Z0A
;
;
;
	LDY	#0
	STY	Z0B
;
;	Exchange variable values
;
EF	LDA	Z0B
	LDX	Z0A
	STA	Z0A
	STX	Z0B
;
;	Branch if end of statement
;
EW	LDA	(CTXPTR),Y
	BZ	RTSL
;
;
;
	CMP	Z0B
	BE	RTSL
;
;
;
	INY
;
;
;
 ifdef cbmB1
	CMP	#'"
	BE	EF
	BNE	EW
 endif
 ifndef cbmB1
	CMP	#'"
	BNE	EW
	BE	EF
 endif
;.PAGE 'IF AND REM'
;
;	Evaluate expression in text
;
VIF	JSR	A2C48
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;	Branch if 'GOTO' token
;
	CMP	#TKGOTO
	BE	EX
;
;	Validate that the current BASIC text character is token for 'THEN'
;
	LDA	#TKTHEN
	JSR	CKTERM
;
;
;
EX	LDA	ZAE
	BNZ	EY
;
;	'REM'
;
VREM	JSR	FESTB
	BZ	UPCTPT
;
;	Re-get current BASIC text character
;
EY	JSR	CURTCE
;
;	Branch if character is non-numeric
;
	BC	EZ
;
;
;
	JMP	VGOTO
;
;
;
EZ	JMP	XFERTK
;.PAGE 'ON'
;
;
;
VON	JSR	A3595
;
;	Save accumulator on stack
;
	PHA
;
;
;
	CMP	#TKGSUB
	BE	AY
;
;
;
AW	CMP	#TKGOTO
	BNE	AZ
;
;
;
AY	DEC	ZB1+1
	BNZ	AX
;
;	Restore accumulator from stack
;
	PLA
;
;
;
	JMP	A26AC
;
;	Get next BASIC text character
;
AX	JSR	NXTTCE
;
;
;
	JSR	ASCBIN
	CMP	#',
	BE	AY
	PLA
RTSB	RTS
;.PAGE 'Subroutines'
;
;
;
ASCBIN	LDX	#0
	STX	Z19
	STX	Z19+1
;
;
;
AV	BC	RTSB
;
;
;
	SBC	#'0-1	; $2F
	STA	Z0A
	LDA	Z19+1
	STA	Z6F
	CMP	#$19
	BGE	AW
	LDA	Z19
	ASL	A
	ROL	Z6F
	ASL	A
	ROL	Z6F
	ADC	Z19
	STA	Z19
	LDA	Z6F
	ADC	Z19+1
	STA	Z19+1
	ASL	Z19
	ROL	Z19+1
;
;	Update result
;
	LDA	Z19
	ADC	Z0A
	STA	Z19
	BNC	AU
	INC	Z19+1
;
;	Get next BASIC text character
;
AU	JSR	NXTTCE
;
;
;
	JMP	AV
;.PAGE 'LET'
;
;	Search for variable
;
VLET	JSR	A2EA9
	STA	Z96
	STY	Z96+1
;
;	Validate that the current BASIC text character is token for '='
;
	LDA	#TKEQUS
	JSR	CKTERM
;
;	Save destination type flags on stack
;
	LDA	Z0F
	PHA
	LDA	Z0E
	PHA
;
;	Evaluate expression in text
;
	JSR	A2C48
;
;	Test if type mismatch
;
	PLA
	ROL	A
	JSR	A2C3A
;
;	Test if string
;
	BNZ	HE
	PLA
A290F	BNM	HD
;
;	Round
;
	JSR	ROUNDA
;
;	Fix
;
	JSR	A2FC2
;
;	Store integer
;
	LDY	#0
	LDA	ZB1
	STA	(Z96),Y
	INY
	LDA	ZB1+1
	STA	(Z96),Y
	RTS
;
;	Store real
;
HD	JMP	A3A48
;
;	Fix stack
;
HE	PLA
;
;	Test if timer
;
A2927	LDY	Z96+1
 ifndef cbmB2
	CPY	#$D0
 endif
 ifdef cbmB2
	CPY	#$DE
 endif
	BNE	PHE
	JSR	A349D
	CMP	#$06
 ifdef cbmB1
	BE	PHF
	JMP	A304B
PHF
 endif
 ifndef cbmB1
	BNE	PHF
 endif
	LDY	#0
	STY	ZAE
	STY	ZB3
PHK	STY	ZBE
	JSR	AC91C
	JSR	A395A
	INC	ZBE
	LDY	ZBE
	JSR	AC91C
	JSR	A3A84
	TAX
	BZ	PHG
	INX
	TXA
	JSR	AD9BF
PHG	LDY	ZBE
	INY
	CPY	#$06
	BNE	PHK
;
;
;
	JSR	A395A
;
;
;
	JSR	A3B13
;
;
;
	LDX	#2
	SEI
PHH	LDA	ZAF+1,X
	STA	TIMER,X
	DEX
	BNM	PHH
	CLI
;
;
;
	RTS
;.PAGE 'Subroutines'
;
;
;
AC91C	LDA	(Z6F),Y
	JSR	ZCD
	BNC	PHJ
;
;
;
 ifndef cbmB1
PHF
 endif
	JMP	A304B
;
;
;
PHJ	SBC	#$2F
	JMP	A3C0A
;.PAGE
;
;
;
PHE	LDY	#2
	LDA	(ZB1),Y
 ifdef cbmB4
	CMP	SZ0E+1
	BNE	P80HE
	PHA
	DEY
	LDA	SZ0D
	BZ	P80HF
	LDA	(ZB1),Y
	CMP	SZ0E
	BNE	P80HF
	PLA
	JMP	HH
P80HF	PLA
	INY
P80HE
 endif
	CMP	STRPTR+1
	BL	HG
	BNZ	HF
	DEY
	LDA	(ZB1),Y
	CMP	STRPTR
	BL	HG
;
;	Test if descriptor in variable area
;
HF	LDY	ZB1+1
	CPY	VASPTR+1
	BL	HG
	BNE	HH
	LDA	ZB1
	CMP	VASPTR
	BGE	HH
HG	LDA	ZB1
	LDY	ZB1+1
	JMP	HJ
;
;
;
HH	LDY	#0
	LDA	(ZB1),Y
	JSR	A3276
	LDA	Z9D
	LDY	Z9D+1
	STA	ZBC
	STY	ZBC+1
	JSR	A3471
 ifdef cbmB4
	LDA	ZBC
	LDY	ZBC+1
	JSR	A34D2
 endif
	LDA	#>ZAE
	LDY	#<ZAE
HJ	STA	Z9D
	STY	Z9D+1
 ifdef cbmB4
	STA	Z6F
	STY	Z6F+1
 endif
	JSR	A34D2
 ifndef cbmB4
	LDY	#0
	LDA	(Z9D),Y
	STA	(Z96),Y
	INY
	LDA	(Z9D),Y
	STA	(Z96),Y
	INY
	LDA	(Z9D),Y
	STA	(Z96),Y
	RTS
 endif
 ifdef cbmB4
	JSR	NSBA4E
	BNC	P80HN
	LDY	#0
	LDA	Z96
	STA	(Z6F),Y
	INY
	LDA	Z96+1
	STA	(Z6F),Y
P80HN	LDA	Z96
	STA	Z6F
	LDA	Z96+1
	STA	Z6F+1
	JSR	NSBA4E
	BNC	P80HO
	DEY
	LDA	#$FF
	STA	(Z6F),Y
	DEY
	TXA
	STA	(Z6F),Y
P80HO	LDY	#2
P80HP	LDA	(Z9D),Y
	STA	(Z96),Y
	DEY
	BNM	P80HP
	RTS
*******************************************************************************
;
;
;
NSBA4E	LDY	#0
	LDA	(Z6F),Y
	PHA
	BZ	P80HQ
	INY
	LDA	(Z6F),Y
	TAX
	INY
	LDA	(Z6F),Y
	BM	P80HQ
	CMP	#$B0
	BGE	P80HQ
	CMP	STRPTR+1
	BL	P80HQ
	BNE	P80HU
	CPX	STRPTR
	BL	P80HQ
P80HU	CMP	SZ0E+1
	BNE	P80HW
	CPX	SZ0E
	BE	P80HQ
;
;
;
P80HW	STX	Z6F
	STA	Z6F+1
;
;
;
	PLA
	TAX
;
;
;
	CLC
	ADC	Z6F
	STA	Z6F
	BNC	P80HY
	INC	Z6F+1
;
;
;
P80HY	SEC
;
;
;
	RTS
;
;
;
P80HQ	PLA
;
;
;
	CLC
;
;
;
	RTS
 endif
;.PAGE 'PRINT# AND CMD'
;
;	'PRINT#'
;
VPRTA	JSR	VCMD
	JMP	ACAD6
;
;	'CMD'
;
VCMD	JSR	A3595
	BZ	PHJA
;
;	Validate that the current BASIC text character is a comma
;
	LDA	#',
	JSR	CKTERM
;
;
;
PHJA	PHP
	JSR	SETOPD
	STX	CURDVC
	PLP
	JMP	VPRINT
;.PAGE 'PRINT'
;
;
;
A297B	JSR	OPSTRB
;
;	Re-get current BASIC text character
;
GB	JSR	CURTCE
;
;
;
VPRINT	BZ	CRLF
;
;
;
A2983	BZ	RTSC
;
;	Branch if accumulator is 'TAB(' token
;
	CMP	#TKTAB
	BE	FY
;
;	Branch if accumulator is 'SPC(' token
;
	CMP	#TKSPC
 ifndef cbmB1
	CLC
 endif
	BE	FY
	CMP	#',
	BE	A29DE
	CMP	#';
	BE	FV
;
;	Evaluate expression in text
;
	JSR	A2C48
;
;
;
	BIT	Z0E
	BM	A297B
	JSR	A3C69
	JSR	A3288
*FZ
	JSR	OPSTRB
	JSR	OUTSP
	BNZ	GB
;.PAGE 'SUBROUTINES'
;
;
;
STNUL
 ifdef cbmB1
	LDY	#0
	STY	CONBUF,X
 endif
 ifndef cbmB1
	LDA	#0
	STA	CONBUF,X
 endif
	LDX	#>CONBUF-1
 ifndef cbmB1
	LDY	#<CONBUF-1
 endif
	LDA	CURDVC
	BNZ	RTSC
CRLF
 ifdef cbmB1
	LDA	CURDVC
	BNZ	PAAA
	STA	Z16
PAAA
 endif
	LDA	#CR
	JSR	CONOUT
 ifdef cbmB4
	LDA	CURDVC
	BNM	A29CB
 endif
	LDA	#LF
	JSR	CONOUT
A29CB
 ifdef cbmB1
	LDA	CURDVC
	BNZ	RTSC
	TXA
	PHA
	LDX	Z15
	BE	AA
	LDA	#0
NULLP	JSR	CONOUT
	DEX
	BNZ	NULLP
AA	STX	Z16
	PLA
	TAX
 endif
 ifndef cbmB1
	EOR	#$FF
 endif
RTSC	RTS
;.PAGE
A29DE
 ifdef cbmB1
	LDA	Z16
 endif
 ifndef cbmB1
	LDA	SCRNDX
 endif
	SEC
FR	SBC	#$0A
	BC	FR
	EOR	#$FF
	ADC	#1
	BNZ	FT
FY
 ifdef cbmB1
	PHA
 endif
 ifndef cbmB1
	PHP
 endif
	JSR	A3592
	CMP	#')
	BNE	JPSE
FS
 ifdef cbmB1
	PLA
	CMP	#$A3
	BNE	FU
 endif
 ifndef cbmB1
	PLP
	BNC	FU
 endif
	TXA
 ifdef cbmB1
	SBC	Z16
 endif
 ifndef cbmB1
	SBC	SCRNDX
 endif
	BNC	FV
 ifdef cbmB1
	BZ	FV
 endif
FT	TAX
FU
 ifdef cbmB1
	JSR	OUTSP
	DEX
	BNZ	FU
 endif
 ifndef cbmB1
	INX
NRFU	DEX
	BNZ	NRFV
 endif
;
;	Get next BASIC text character
;
FV	JSR	NXTTCE
;
;
;
	JMP	A2983
 ifndef cbmB1
;
;
;
NRFV	JSR	OUTSP
	BNZ	NRFU
 endif
;.PAGE
;
;
;
OPSTRA	JSR	A3288
OPSTRB	JSR	A349D
	TAX
	LDY	#0
	INX
BE	DEX
	BZ	RTSC
	LDA	(Z6F),Y
	JSR	CONOUT
	INY
	CMP	#CR
	BNE	BE
	JSR	A29CB
	JMP	BE
;.PAGE
;
;
;
OUTSP
 ifndef cbmB1
	LDA	CURDVC
	BZ	NRL
	LDA	#SPACE
	DB	$2C
NRL
 endif
	LDA	#$1D
	DB	$2C
OUTQM	LDA	#'?
CONOUT
 ifndef cbmB4
	BIT	Z14
	BM	PXH
 endif
 ifdef cbmB1
	PHA
	CMP	#$1D
	BE	PXG
	CMP	#$9D
	BE	PXE
	CMP	#$14
	BNE	PXF
PXE	LDA	Z16
	BZ	AB
	LDA	CURDVC
	BNZ	AB
	DEC	Z16
PXF	AND	#$7F
	CMP	#SPACE
	BL	AB
PXG	LDA	CURDVC
	JSR	PATCH6
	NOP
AB	PLA
 endif
	JSR	OUTCH
PXH	AND	#$FF
	RTS
;.PAGE
;
;
;
ACA77	LDA	Z12
	BZ	BB
 ifdef cbmB1
	JSR	PATCH5
	NOP
 endif
 ifndef cbmB1
	BM	PXJ
	LDY	#$FF
	BNZ	BD
PXJ	LDA	Z8C
	LDY	Z8C+1
 endif
BD	STA	CURLNO
	STY	CURLNO+1
;
;
;
JPSE	JMP	PRSYNE
;
;
;
BB	LDA	CURDVC
	BZ	PBB
;
;
;
	LDX	#NGDATK-ERRSK
	JMP	PRERR
;
;
;
PBB	LDA	#>REDOK
	LDY	#<REDOK
	JSR	OPSTRA
;
;
;
	LDA	Z8A
	LDY	Z8A+1
	STA	CTXPTR
	STY	CTXPTR+1
;
;
;
	RTS
;.PAGE 'GET'
;
;
;
VGET	JSR	CKIDIR
	CMP	#'#
	BNE	PBC
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;
;
	JSR	A3595
;
;	Validate that the current BASIC text character is a comma
;
	LDA	#',
	JSR	CKTERM
;
;
;
	JSR	SETIPD
	STX	CURDVC
PBC	LDX	#>CONBUF+1
	LDY	#<CONBUF+1
 ifdef cbmB1
	STY	CONBUF+1
 endif
 ifndef cbmB1
	LDA	#0
	STA	CONBUF+1
 endif
	LDA	#$40
	JSR	A2ABF
	LDX	CURDVC
	BNZ	ACAD8
	RTS
;.PAGE 'INPUT#, INPUT AND READ'
;
;	'INPUT#'
;
VINPA	JSR	A3595
;
;	Validate that the current BASIC text character is a comma
;
	LDA	#',
	JSR	CKTERM
;
;
;
	JSR	SETIPD
	STX	CURDVC
	JSR	ACAF1
ACAD6	LDA	CURDVC
ACAD8	JSR	RESTIO
;
;
;
	LDX	#0
	STX	CURDVC
;
;
;
	RTS
;
;	'INPUT'
;
VINPUT
 ifndef cbmB4
	LSR	Z14
 endif
	CMP	#'"
	BNE	ACAF1
	JSR	A2D4E
;
;	Validate that the current BASIC text character is a semicolon
;
	LDA	#';
	JSR	CKTERM
;
;
;
	JSR	OPSTRB
ACAF1	JSR	CKIDIR
	LDA	#',
	STA	CONBUF-1
PFPA	JSR	GETIP
	LDA	CURDVC
	BZ	PFPB
	LDA	STATUS
 ifdef cbmB4
	AND	#%00000011
 endif
 ifndef cbmB4
	AND	#%00000010
 endif
	BZ	PFPB
	JSR	ACAD6
	JMP	VDATA
PFPB	LDA	CONBUF
	BNZ	A2ABE
	LDA	CURDVC
	BNZ	PFPA
 ifdef cbmB1
	JMP	PATCH1
 endif
 ifndef cbmB1
	CLC
	JMP	A26F7
 endif
;
;	SUBROUTINE FOR 'INPUT'
;
GETIP	LDA	CURDVC
	BNZ	PFPC
	JSR	OUTQM
	JSR	OUTSP
PFPC	JMP	IPSTR
;
;	'READ'
;
VREAD	LDX	DATPTR
	LDY	DATPTR+1
 ifdef cbmB1
	DB	$A9
A2ABE	TYA
 endif
 ifndef cbmB1
	LDA	#$98
	DB	$2C
A2ABE	LDA	#0
 endif
A2ABF	STA	Z12
	STX	Z90
	STY	Z90+1
A2AC5	JSR	A2EA9
	STA	Z96
	STY	Z96+1
;
;	Copy pointer
;
	LDA	CTXPTR
	LDY	CTXPTR+1
 ifdef cbmB1
	STA	Z19
	STY	Z19+1
 endif
 ifndef cbmB1
	STA	Z98
	STY	Z98+1
 endif
;
;	Copy pointer
;
	LDX	Z90
	LDY	Z90+1
	STX	CTXPTR
	STY	CTXPTR+1
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;	Branch if not end of statement
;
	BNZ	A2AFC
;
;
;
	BIT	Z12
	BNV	FG
;
;
;
	JSR	GETCH
	STA	CONBUF
;
;
;
 ifdef cbmB1
	LDY	#<CONBUF-1
	LDX	#>CONBUF-1
 endif
 ifndef cbmB1
	LDX	#>CONBUF-1
	LDY	#<CONBUF-1
 endif
	BNZ	FH
FG	BM	A2B63
	LDA	CURDVC
	BNZ	PFG
	JSR	OUTQM
PFG	JSR	GETIP
FH	STX	CTXPTR
	STY	CTXPTR+1
;
;	Get next BASIC text character
;
A2AFC	JSR	NXTTCE
;
;
;
	BIT	Z0E
	BPL	A2B34
	BIT	Z12
	BNV	FK
 ifndef cbmB1
	INX
	STX	CTXPTR
 endif
	LDA	#0
 ifdef cbmB1
	JSR	PATCH4
	NOP
 endif
 ifndef cbmB1
	STA	Z0A
	BZ	FL
 endif
FK	STA	Z0A
	CMP	#'"
	BE	FM
	LDA	#':
	STA	Z0A
	LDA	#',
FL	CLC
FM	STA	Z0B
	LDA	CTXPTR
	LDY	CTXPTR+1
	ADC	#0
	BNC	FN
	INY
FN	JSR	A328E
	JSR	A35DA
	JSR	A2927
	JMP	DB
;.PAGE 'Subroutines'
;
;
;
A2B34	JSR	ASC2FP
	LDA	Z0F
	JSR	A290F
;
;	Re-get current BASIC text character
;
DB	JSR	CURTCE
;
;	Branch if end of statement
;
	BZ	GL
;
;
;
	CMP	#',
	BE	GL
;
;
;
	JMP	ACA77
;
;	Copy pointer
;
GL	LDA	CTXPTR
	LDY	CTXPTR+1
	STA	Z90
	STY	Z90+1
;
;
;
 ifdef cbmB1
	LDA	Z19
	LDY	Z19+1
 endif
 ifndef cbmB1
	LDA	Z98
	LDY	Z98+1
 endif
	STA	CTXPTR
	STY	CTXPTR+1
;
;
;
	JSR	CURTCE
;
;	Branch if end of statement
;
	BZ	A2B89
;
;	Current BASIC text character must be a comma
;
	JSR	MBCOMA
;
;
;
	JMP	A2AC5
;.PAGE
;
;
;
A2B63	JSR	FESTA
	INY
	TAX
	BNZ	GM
	LDX	#OUTDK-ERRSK
	INY
	LDA	(CTXPTR),Y
	BZ	A2BDA
	INY
	LDA	(CTXPTR),Y
	STA	Z8C
	INY
	LDA	(CTXPTR),Y
	INY
	STA	Z8C+1
GM	LDA	(CTXPTR),Y
	TAX
	JSR	UPCTPT
	CPX	#$83
	BNE	A2B63
	JMP	A2AFC
;.PAGE
;
;
;
A2B89	LDA	Z90
	LDY	Z90+1
	LDX	Z12
	BNM	GN
	JMP	A26D5
GN	LDY	#0
	LDA	(Z90),Y
	BZ	GP
	LDA	CURDVC
	BNZ	GP
	LDA	#>A2BA2
	LDY	#<A2BA2
	JMP	OPSTRA
GP	RTS
;
;
;
A2BA2	ASC	'?EXTRA IGNORED'
	DB	$0D
 ifndef cbmB4
	DB	$0A
 endif
	DB	0
;
;
;
REDOK	ASC	'?REDO FROM START'
	DB	$0D
 ifndef cbmB4
	DB	$0A
 endif
	DB	0
;.PAGE
;
;
;
A2BC6	BNZ	A2BCC
;
;
;
	LDY	#0
;
;	Unconditional branch
;
	BZ	GR
;
;
;
A2BCC	JSR	A2EA9
;
;
;
GR	STA	Z96
	STY	Z96+1
;
;
;
	JSR	A2274
	BZ	GS
;
;
;
	LDX	#0
A2BDA	BZ	J1PERR
;
;
;
GS	TXS
 ifdef cbmB1
	INX
	INX
	INX
	INX
 endif
	TXA
 ifdef cbmB1
	INX
	INX
	INX
	INX
	INX
	INX
	STX	Z71
 endif
 ifndef cbmB1
	CLC
	ADC	#4
	PHA
	ADC	#6
	STA	Z71
	PLA
 endif
;
;	Load 'FAC' from memory pointed to by 'Y' register and accumulator
;
	LDY	#1
	JSR	MFPACC
;
;
;
	TSX
	LDA	BSTACK+9,X
	STA	ZB3
	LDA	Z96
	LDY	Z96+1
	JSR	A3653
	JSR	A3A48
	LDY	#1
	JSR	A3AD5
	TSX
	SEC
	SBC	BSTACK+9,X
	BZ	GU
	LDA	BSTACK+15,X
	STA	CURLNO
	LDA	BSTACK+16,X
	STA	CURLNO+1
	LDA	BSTACK+18,X
	STA	CTXPTR
	LDA	BSTACK+17,X
	STA	CTXPTR+1
GT	JMP	A2674
;
;
;
GU	TXA
	ADC	#17
	TAX
	TXS
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;
;
	CMP	#',
	BNE	GT
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;
;
	JSR	A2BCC
;
;	Evaluate expression in text
;
A2C34	JSR	A2C48
;
;
;
*	JSR	A2C37
*	RTS
*******************************************************************************
;
;
;
A2C37	CLC
	DB	$24
A2C39	SEC
;
;
;
A2C3A	BIT	Z0E
	BM	GW
	BC	GX
;
;
;
GV	RTS
;
;
;
GW	BC	GV
;
;
;
GX	LDX	#TYPMMK-ERRSK
J1PERR	JMP	PRERR
;.PAGE 'Evaluate expression in text'
;
;	Decrement 'CTXPTR'
;
A2C48	LDX	CTXPTR
	BNZ	GY
	DEC	CTXPTR+1
GY	DEC	CTXPTR
;
;
;
	LDX	#0
;
;	Skip past 'JY' instruction
;
	DB	$24
;
;
;
JY	PHA
	TXA
	PHA
;
;
;
	LDA	#2/2
	JSR	A22E5
;
;	Evaluate single term
;
	JSR	A2D2D
;
;
;
	LDA	#0
	STA	Z9A
;
;	Re-get current BASIC text character
;
A2C62	JSR	CURTCE
;
;
;
HT	CLB
	SBB	#$B1
	BB	HU
	CMP	#3
	BGE	HU
	CMP	#1
	ROL	A
	EOR	#1
	EOR	Z9A
	CMP	Z9A
	BL	JM
	STA	Z9A
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;
;
	JMP	HT
;
;
;
HU	LDX	Z9A
	BNZ	HY
	BC	JP
	ADC	#7
	BNC	JP
	ADC	Z0E
	BNZ	HV
;
;
;
	JMP	A3434
;
;
;
HV	ADC	#$FF
	STA	Z6F
	ASL	A
	ADC	Z6F
	TAY
HW	PLA
	CMP	A2068,Y
	BC	JR
;
;	Check for type mismatch
;
	JSR	A2C37
;
;
;
HX	PHA
;
;
;
A2CA4	JSR	A2CCA
	PLA
	LDY	Z98
	BNM	JL
	TAX
	BZ	JQ
;
;	Unconditional branch
;
	BNZ	JT
;
;
;
HY	LSR	Z0E
	TXA
	ROL	A
;
;	Decrement pointer
;
	LDX	CTXPTR
	BNZ	HZ
	DEC	CTXPTR+1
HZ	DEC	CTXPTR
;
;
;
	LDY	#$1B
;
;
;
	STA	Z9A
;
;	Unconditional branch
;
	BNZ	HW
;
;
;
JL	CMP	A2068,Y
	BC	JT
;
;	Unconditional branch
;
	BNC	HX
;
;
;
A2CCA	LDA	A2068+2,Y
	PHA
	LDA	A2068+1,Y
	PHA
	JSR	A2CDD
	LDA	Z9A
;
;
;
	JMP	JY
;
;
;
JM	JMP	PRSYNE
*******************************************************************************
;
;
;
A2CDD	LDA	ZB3
	LDX	A2068,Y
*	JSR	A2CE2
*	RTS
*******************************************************************************
;
;	Save accumulator
;
A2CE2	TAY
;
;
;
	PLA
	STA	Z6F
 ifndef cbmB4
	INC	Z6F
 endif
	PLA
	STA	Z6F+1
;
;	Restore accumulator
;
	TYA
;
;	Push sign onto stack
;
	PHA
 ifdef cbmB4
;
;	Increment return address
;
	INC	Z6F
	BNZ	A2CED
	INC	Z6F+1
 endif
;
;	Round 'FAC'
;
A2CED	JSR	ROUNDA
;
;	Push floating point accumulator on stack
;
	LDA	FAC+4
	PHA
	LDA	FAC+3
	PHA
	LDA	FAC+2
	PHA
	LDA	FAC+1
	PHA
	LDA	FAC
	PHA
;
;	Return to caller
;
	JMP	(Z6F)
*******************************************************************************
;
;
;
JP	LDY	#$FF
	PLA
JQ	BZ	JU
JR	CMP	#$64
	BE	JS
;
;	Check for type mismatch
;
	JSR	A2C37
;
;
;
JS	STY	Z98
;
;
;
JT	PLA
	LSR	A
	STA	Z13
;
;	Pull floating point argument from stack
;
	PLA
	STA	FARG
	PLA
	STA	FARG+1
	PLA
	STA	FARG+2
	PLA
	STA	FARG+3
	PLA
	STA	FARG+4
	PLA
	STA	FARG+5
	EOR	FAC+5
	STA	FARG+6
;
;
;
JU	LDA	FAC
;
;
;
	RTS
;.PAGE 'Evaluate single term'
;
;
;
A2D2D	LDA	#0
	STA	Z0E
;
;	Get next BASIC text character
;
JV	JSR	NXTTCE
;
;	Branch if not numeric character
;
	BC	JX
;
;
;
JW	JMP	ASC2FP
;
;	Branch if character is alphabetic
;
JX	JSR	A2F33
 ifndef cbmB4
	BC	A2DA5
 endif
 ifdef cbmB4
	BC	JA2DA5
 endif
;
;	Branch if not Pi character
;
	CMP	#$FF
	BNE	PJX
;
;	Load 'FAC' from memory pointed to by 'Y' register and accumulator
;
	LDA	#>ACDBC
	LDY	#<ACDBC
	JSR	MFPACC
;
;	Get next BASIC text character and return
;
	JMP	NXTTCE
;
;	Value of Pi
;
ACDBC	DB	$82,$49,$0F,$DA,$A1
;
;
;
PJX	CMP	#'.
	BE	JW
;
;	Branch if accumulator is token for '-'
;
	CMP	#TKMIN
	BE	A2D9E
;
;	Branch if accumulator is token for '+'
;
	CMP	#TKPLUS
	BE	JV
;
;
;
	CMP	#'"
	BNE	KA
;
;
;
A2D4E	LDA	CTXPTR
	LDY	CTXPTR+1
	ADC	#0
	BNC	JZ
	INY
JZ	JSR	A3288
;
;
;
	JMP	A35DA
;
;
;
KA	CMP	#TKNOT
	BNE	KB
;
;
;
	LDY	#$18
;
;	Unconditonal branch
;
	BNZ	A2DA0
;
;
;
A2D65	JSR	A2FC2
	LDA	ZB1+1
	EOR	#$FF
	TAY
	LDA	ZB1
	EOR	#$FF
	JMP	A3195
;
;
;
KB	CMP	#TKFN
	BNE	KC
;
;
;
	JMP	A31F3
;
;
;
KC	CMP	#$B4
	BNC	A2D82
	JMP	A2DC5
;
;	Current BASIC text character must be left parenthesis
;
A2D82	JSR	MBLPAR
;
;	Evaluate expression in text
;
	JSR	A2C48
;
;	Syntax error if current BASIC text character is not a right parenthesis
;
MBRPAR	LDA	#')
	DB	$2C
;
;	Syntax error if current BASIC text character is not a left parenthesis
;
MBLPAR	LDA	#'(
	DB	$2C
;
;	Syntax error if current BASIC text character is not a comma
;
MBCOMA	LDA	#',
;
;	Syntax error if current BASIC text character does not match accumulator
;
CKTERM	LDY	#0
	CMP	(CTXPTR),Y
	BNE	PRSYNE
;
;	Get next BASIC text character and return
;
	JMP	NXTTCE
;
;
;
PRSYNE	LDX	#SYNTEK-ERRSK
	JMP	PRERR
;.PAGE
;
;
;
A2D9E	LDY	#$15
;
;
;
A2DA0	PLA
	PLA
;
;
;
	JMP	A2CA4
 ifdef cbmB4
;
;
;
	DB	$E1
;
;	Jump around filler
;
JA2DA5	JMP	A2DA5
;
;
;
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA
 endif
;.PAGE 'Search for variable'
;
;
;
A2DA5	JSR	A2EA9
	STA	ZB1
	STY	ZB1+1
;
;
;
	LDA	Z92
	LDY	Z92+1
	LDX	Z0E
	BZ	KE
 ifdef cbmB1
	JMP	PATCH2
 endif
 ifndef cbmB1
	LDX	#0
	STX	ZBC+1
 endif
;
;
;
 ifdef cbmB2
	BIT	ZB1+1
	BNM	PKE
 endif
 ifdef cbmB4
	LDX	ZB1+1
	CPX	#$8B
	BL	P80KE
 endif
;
;
;
 ifdef cbmB1
ACE3A	CLC
ACE3B
 endif
 ifndef cbmB1
	CMP	#'T
	BNE	PKE
 endif
	CPY	#'I+$80
	BNE	PKE
	JSR	ACE76
	STY	ZAA+1
	DEY
	STY	ZBE
	LDY	#6
	STY	ZAA
	LDY	#$24
	JSR	ADD3A
	JMP	AD353
PKE
 ifdef cbmB4
;
;
;
	CMP	#'D
	BNE	P80KE
	CPY	#'S+$80
	BNE	P80KE
	JSR	NSBFFC
	LDA	SZ0E
	LDY	SZ0E+1
	JMP	A3288
P80KE
 endif
	RTS
;
;
;
KE	LDX	Z0F
	BNM	KF
	LDY	#0
	LDA	(ZB1),Y
	TAX
	INY
	LDA	(ZB1),Y
	TAY
	TXA
	JMP	A3195
;
;
;
KF
 ifdef cbmB1
	JMP	PATCH3
 endif
 ifdef cbmB2
	BIT	ZB1+1
	BNM	ACE90
 endif
 ifdef cbmB4
	LDX	ZB1+1
	CPX	#$8B
	BL	P80KF
 endif
;
;
;
 ifdef cbmB1
ACE68	DB	$19
ACE69	CPY	#$49
	BNE	ACE82
 endif
 ifndef cbmB1
	CMP	#'T
	BNE	ACE82
	CPY	#'I
 endif
 ifdef cbmB2
	BNE	ACE90
 endif
 ifdef cbmB4
	BNE	P80KF
 endif
;
;
;
	JSR	ACE76
	TYA
	LDX	#$A0
	JMP	ADB21
 ifdef cbmB4
;
;
;
NSBFFC	LDA	SZ0D
	BNZ	P80KE
	JMP	NSFFBD
 endif
;
;	Load 'FAC' from memory pointed to by 'Y' register and accumulator
;
ACE76	LDA	#>TIMER-2
	LDY	#<TIMER-2
	SEI
	JSR	MFPACC
	CLI
	STY	ZAF
;
;
;
	RTS
;
;
;
ACE82	CMP	#'S
	BNE	ACE90
	CPY	#'T
	BNE	ACE90
	LDA	STATUS
	JMP	A3AB4
ACE90
 ifdef cbmB4
	CMP	#'D
	BNE	P80KF
	CPY	#'S
	BNE	P80KF
	JSR	NSBFFC
	LDY	#0
	LDA	(SZ0E),Y
	AND	#$0F
	ASL	A
	STA	Z10
	ASL	A
	ASL	A
	ADC	Z10
	STA	Z10
	INY
	LDA	(SZ0E),Y
	AND	#$0F
	ADC	Z10
	JMP	A3AB4
P80KF
 endif
;
;	Load 'FAC' from memory pointed to by 'Y' register and accumulator
;
	LDA	ZB1
	LDY	ZB1+1
	JMP	MFPACC
;.PAGE
;
;
;
A2DC5	ASL	A
	PHA
	TAX
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;
;
	CPX	#$8F
	BNC	KG
;
;	Current BASIC text character must be left parenthesis
;
	JSR	MBLPAR
;
;	Evaluate expression in text
;
	JSR	A2C48
;
;	Current BASIC text character must be a comma
;
	JSR	MBCOMA
;
;
;
	JSR	A2C39
;
;
;
	PLA
	TAX
	LDA	ZB1+1
	PHA
	LDA	ZB1
	PHA
	TXA
	PHA
	JSR	A3595
	PLA
	TAY
	TXA
	PHA
	JMP	KH
KG	JSR	A2D82
	PLA
	TAY
KH
 ifndef cbmB4
	LDA	ROUTAD-34,Y
 endif
 ifdef cbmB4
	LDA	ROUTAD-2,Y
 endif
	STA	ZA2
 ifndef cbmB4
	LDA	ROUTAD-33,Y
 endif
 ifdef cbmB4
	LDA	ROUTAD-1,Y
 endif
	STA	ZA2+1
	JSR	ZA1
;
;	Check for type mismatch
;
*	JSR	A2C37
*	RTS
	JMP	A2C37
;.PAGE
;
;	OR
;
A2E04	LDY	#$FF
	DB	$2C
;
;	AND
;
A2E07	LDY	#0
	STY	Z0C
;
;
;
	JSR	A2FC2
;
;
;
	LDA	ZB1
	EOR	Z0C
	STA	Z0A
	LDA	ZB1+1
	EOR	Z0C
	STA	Z0B
	JSR	A3A74
	JSR	A2FC2
	LDA	ZB1+1
	EOR	Z0C
	AND	Z0B
	EOR	Z0C
	TAY
	LDA	ZB1
	EOR	Z0C
	AND	Z0A
	EOR	Z0C
	JMP	A3195
;.PAGE
;
;
;
A2E34	JSR	A2C3A
	BC	KJ
	LDA	ZB6+5
	ORA	#$7F
	AND	ZB6+1
	STA	ZB6+1
	LDA	#>ZB6
	LDY	#<ZB6
	JSR	A3AD3
	TAX
	JMP	A2E7F
;
;
;
KJ	LDA	#0
	STA	Z0E
	DEC	Z9A
	JSR	A349D
	STA	ZAE
	STX	ZAF
	STY	ZAF+1
;
;
;
	LDA	ZB9
	LDY	ZB9+1
	JSR	A34A1
	STX	ZB9
	STY	ZB9+1
;
;
;
	TAX
;
;
;
	CLB
	SBB	ZAE
	BZ	KK
	LDA	#1
	BB	KK
	LDX	ZAE
	LDA	#$FF
KK	STA	ZB3
	LDY	#$FF
	INX
KL	INY
	DEX
	BNZ	KM
	LDX	ZB3
A2E7F	BM	KN
	CLC
	BNC	KN
KM	LDA	(ZB9),Y
	CMP	(ZAF),Y
	BE	KL
	LDX	#$FF
	BC	KN
	LDX	#1
KN	INX
	TXA
	ROL	A
	AND	Z13
	BZ	KP
	LDA	#$FF
KP	JMP	A3AB4
;
;	Current BASIC text character must be a comma
;
KQ	JSR	MBCOMA
;
;
;
A2E9F	TAX
	JSR	A2EAE
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;	Branch if not end of statement
;
	BNZ	KQ
;
;
;
	RTS
;.PAGE
;
;
;
A2EA9	LDX	#0
	JSR	CURTCE
;
;
;
*	JSR	A2EAE
;
;
;
*	RTS
*******************************************************************************
;
;
;
A2EAE	STX	Z0D
;
;
;
*	JSR	A2EB0
;
;
;
*	RTS
*******************************************************************************
;
;	Store 1st character of variable name
;
A2EB0	STA	Z92
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;	Branch if character is alphabetic
;
	JSR	A2F33
	BC	HK
;
;
;
HS	JMP	PRSYNE
;
;
;
HK	LDX	#0
	STX	Z0E
	STX	Z0F
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;	Branch if numeric character
;
	BNC	HL
;
;	Branch if character is not alphabetic
;
	JSR	A2F33
	BNC	HN
;
;	Hold 2nd character in 'X'
;
HL	TAX
;
;	Get next BASIC text character
;
HM	JSR	NXTTCE
;
;	Branch if numeric character
;
	BNC	HM
;
;	Branch if character is alphabetic
;
	JSR	A2F33
	BC	HM
;
;	Branch if not string variable designator
;
HN	CMP	#'$
	BNE	HP
;
;	Set string flag
;
	LDA	#$FF
	STA	Z0E
;
;	Unconditional branch
;
	BNE	HQ
;
;	Branch if not integer variable designator
;
HP	CMP	#'%
	BNE	HR
;
;
;
	LDA	Z11
	BNZ	HS
;
;
;
	LDA	#$80
	STA	Z0F
;
;	Set bit in 1st character
;
	ORA	Z92
	STA	Z92
;
;
;
HQ	TXA
	ORA	#$80
	TAX
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;	Store 2nd character of variable name
;
HR	STX	Z92+1
;
;
;
	CLB
	ORA	Z11
	SBB	#'(
	BNZ	MA
;
;
;
	JMP	A2FD4
;
;	Locate variable
;
MA
 ifndef cbmB4
	LDA	#0
	STA	Z11
 endif
 ifdef cbmB4
	LDY	#0
	STY	Z11
 endif
;
;	Initialize pointer to start of simple variables
;
	LDA	VASPTR
	LDX	VASPTR+1
 ifndef cbmB4
	LDY	#0
 endif
;
;	Store initial or updated pointer
;
NA	STX	ZAC+1
NB	STA	ZAC
;
;	Drop through if not at end of simple variables
;
	CPX	ARSPTR+1
	BNE	NC
	CMP	ARSPTR
	BE	NF
;
;
;
NC	LDA	Z92
	CMP	(ZAC),Y
	BNE	ND
	LDA	Z92+1
	INY
	CMP	(ZAC),Y
 ifndef cbmB4
	BE	PL
 endif
 ifdef cbmB4
	BNE	P80NC
	JMP	PL
P80NC
 endif
	DEY
;
;	Add 7 to pointer
;
ND	CLC
	LDA	ZAC
	ADC	#7
	BNC	NB
	INX
	BNZ	NA
*******************************************************************************
;
;	Subroutine for 'A' to 'Z' test
;
A2F33	CMP	#'A
	BL	NE
	SBC	#'Z+1
	SEC
	SBC	#256-'Z-1	; $A5
NE	RTS
*******************************************************************************
;
;	Variable not in simple variable array
;
NF	PLA
	PHA
 ifdef cbmB1
	CMP	#$2A
 endif
 ifdef cbmB2
	CMP	#$11
 endif
 ifdef cbmB4
	CMP	#$8E
 endif
	BNE	PNG
;
;	Return pointer to integer zero
;
PNK
 ifdef cbmB1
	LDA	#>A2F50
	LDY	#<A2F50
 endif
 ifndef cbmB1
	LDA	#>A3D99+2
	LDY	#<A3D99+2
 endif
;
;
;
	RTS
 ifdef cbmB1
;
;
;
A2F50	DB	0,0
 endif
;
;
;
PNG	LDA	Z92
	LDY	Z92+1
;
;
;
	CMP	#'T
	BNE	PNJ
	CPY	#'I+$80
	BE	PNK
	CPY	#'I
	BNE	PNJ
;
;
;
PNH	JMP	PRSYNE
;
;
;
PNJ	CMP	#'S
	BNE	NG
	CPY	#'T
	BE	PNH
NG
 ifdef cbmB4
	CMP	#'D
	BNE	P80NG
	CPY	#'S
	BE	PNH
	CPY	#'S+$80
	BE	PNH
P80NG
 endif
	LDA	ARSPTR
	LDY	ARSPTR+1
	STA	ZAC
	STY	ZAC+1
;
;
;
	LDA	AREPTR
	LDY	AREPTR+1
	STA	ZA7
	STY	ZA7+1
;
;
;
	CLC
	ADC	#7
	BNC	NH
	INY
NH	STA	ZA5
	STY	ZA5+1
;
;
;
	JSR	A22A2
;
;
;
	LDA	ZA5
	LDY	ZA5+1
	INY
	STA	ARSPTR
	STY	ARSPTR+1
 ifdef cbmB4
	STA	ZA5                ; 2/10/83
	STY	ZA5+1
;
;
;
P80NJ	LDA	ZA5
	LDX	ZA5+1
P80NN	CPX	AREPTR+1
	BNE	P80NH
	CMP	AREPTR
	BE	P80NI
P80NH	STA	Z6F
	STX	Z6F+1
;
;
;
	LDY	#0
	LDA	(Z6F),Y
	TAX
	INY
	LDA	(Z6F),Y
	PHP
	INY
	LDA	(Z6F),Y
	ADC	ZA5
	STA	ZA5
	INY
	LDA	(Z6F),Y
	ADC	ZA5+1
	STA	ZA5+1
	PLP
	BNM	P80NJ
	TXA
	BM	P80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endif
A2FBE
 ifndef cbmB1
;
;	Check for type mismatch
;
	JSR	A2C37
 endif
;
;
;
	LDA	ZB3
	BM	NL
;
;	Convert 'FAC' to integer in 'ZB1' and 'ZB2'
;
A2FC2	LDA	FAC
	CMP	#$90
	BL	NM
;
;
;
	LDA	#>A2FB4
	LDY	#<A2FB4
	JSR	A3AD3
NL	BNZ	A304B
;
;
;
NM	JMP	A3B13
;.PAGE
;
;
;
A2FD4	LDA	Z0D
	ORA	Z0F
	PHA
	LDA	Z0E
	PHA
;
;
;
	LDY	#0
;
;	Save 'Y' register on stack
;
NN	TYA
	PHA
;
;	Save pointer on stack
;
	LDA	Z92+1
	PHA
	LDA	Z92
	PHA
;
;
;
	JSR	A2FB8
;
;	Restore pointer from stack
;
	PLA
	STA	Z92
	PLA
	STA	Z92+1
;
;	Restore 'Y' register from stack
;
	PLA
	TAY
;
;
;
	TSX
	LDA	BSTACK+2,X
	PHA
	LDA	BSTACK+1,X
	PHA
;
;
;
	LDA	ZB1
	STA	BSTACK+2,X
	LDA	ZB1+1
	STA	BSTACK+1,X
;
;
;
	INY
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;
;
	CMP	#',
	BE	NN
;
;
;
	STY	Z0C
;
;	Current BASIC text character must be right parenthesis
;
	JSR	MBRPAR
;
;
;
	PLA
	STA	Z0E
	PLA
	STA	Z0F
;
;
;
	AND	#$7F
	STA	Z0D
	LDX	ARSPTR
	LDA	ARSPTR+1
NP	STX	ZAC
	STA	ZAC+1
	CMP	AREPTR+1
	BNE	NQ
	CPX	AREPTR
	BE	NV
NQ	LDY	#0
	LDA	(ZAC),Y
	INY
	CMP	Z92
	BNE	NR
	LDA	Z92+1
	CMP	(ZAC),Y
	BE	NU
NR	INY
	LDA	(ZAC),Y
	CLC
	ADC	ZAC
	TAX
	INY
	LDA	(ZAC),Y
	ADC	ZAC+1
	BNC	NP
;
;
;
NS	LDX	#NGSUBK-ERRSK
	DB	$2C
A304B	LDX	#ILLQK-ERRSK
J2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	BNC	PG
PE	JMP	NS
JMPDF	JMP	PROME
PF	INY
PG	LDA	ZBE+1
	ORA	ZBE
	CLC
	BZ	PH
	JSR	A3150
	TXA
	ADC	ZB1
	TAX
	TYA
	LDY	Z6F
PH	ADC	ZB1+1
	STX	ZBE
	DEC	Z0C
	BNZ	PD
 ifndef cbmB1
	STA	ZBE+1
 endif
	LDX	#5
	LDA	Z92
	BNM	PJ
	DEX
PJ	LDA	Z92+1
	BNM	PK
	DEX
	DEX
PK	STX	Z75
	LDA	#0
	JSR	A3159
	TXA
	ADC	ZA5
	STA	Z94
	TYA
	ADC	ZA5+1
	STA	Z94+1
	TAY
	LDA	Z94
RTSP	RTS
;.PAGE
;
;
;
A3150	STY	Z6F
	LDA	(ZAC),Y
	STA	Z75
	DEY
	LDA	(ZAC),Y
A3159	STA	Z75+1
	LDA	#16
	STA	ZAA
	LDX	#0
	LDY	#0
MJ	TXA
	ASL	A
	TAX
	TYA
	ROL	A
	TAY
	BC	JMPDF
	ASL	ZBE
	ROL	ZBE+1
	BNC	MK
	CLC
	TXA
	ADC	Z75
	TAX
	TYA
	ADC	Z75+1
	TAY
	BC	JMPDF
MK	DEC	ZAA
	BNZ	MJ
	RTS
;.PAGE
;
;	FRE
;
A3181	LDA	Z0E
	BZ	ML
;
;
;
	JSR	A349D
;
;
;
ML	JSR	A3321
;
;
;
	SEC
	LDA	STRPTR
	SBC	AREPTR
	TAY
	LDA	STRPTR+1
	SBC	AREPTR+1
;
;	Convert integer ('A' = MSB, 'Y' = LSB) to value in 'FAC'
;
A3195	LDX	#0
	STX	Z0E
;
;
;
	STA	ZAF
	STY	ZAF+1
;
;
;
	LDX	#$90
;
;
;
	JMP	A3ABC
*******************************************************************************
;
;	POS
;
A31A2
 ifdef cbmB1
	LDY	Z16
 endif
 ifndef cbmB1
	LDY	SCRNDX
 endif
A31A4	LDA	#0
	BZ	A3195
;
;
;
CKIDIR	LDX	CURLNO+1
	INX
	BNZ	RTSP
	LDX	#ILDIRK-ERRSK
 ifdef cbmB1
RETA
 endif
 ifndef cbmB1
	DB	$2C
RETB	LDX	#UNDEFK-ERRSK
 endif
	JMP	PRERR
;.PAGE
;
;
;
A31B2	JSR	A31E0
	JSR	CKIDIR
;
;	Current BASIC text character must be left parenthesis
;
	JSR	MBLPAR
;
;
;
	LDA	#$80
	STA	Z11
;
;
;
	JSR	A2EA9
;
;	Check for type mismatch
;
	JSR	A2C37
;
;	Current BASIC text character must be right parenthesis
;
	JSR	MBRPAR
;
;	Validate that the current BASIC text character is token for '='
;
	LDA	#TKEQUS
	JSR	CKTERM
;
;
;
	PHA
	LDA	Z94+1
	PHA
	LDA	Z94
	PHA
	LDA	CTXPTR+1
	PHA
	LDA	CTXPTR
	PHA
	JSR	VDATA
	JMP	A3250
;
;	Validate that the current BASIC text character is token for 'FN'
;
A31E0	LDA	#TKFN
	JSR	CKTERM
;
;
;
	ORA	#$80
	STA	Z11
;
;
;
	JSR	A2EB0
	STA	Z9B
	STY	Z9B+1
;
;	Check for type mismatch
;
*	JSR	A2C37
*	RTS
	JMP	A2C37
;.PAGE
;
;
;
A31F3	JSR	A31E0
	LDA	Z9B+1
	PHA
	LDA	Z9B
	PHA
	JSR	A2D82
;
;	Check for type mismatch
;
	JSR	A2C37
;
;
;
	PLA
	STA	Z9B
	PLA
	STA	Z9B+1
	LDY	#2
 ifdef cbmB1
	LDX	#UNDEFK-ERRSK
 endif
	LDA	(Z9B),Y
 ifdef cbmB1
	BZ	RETA
 endif
	STA	Z94
	TAX
	INY
	LDA	(Z9B),Y
 ifndef cbmB1
	BZ	RETB
 endif
	STA	Z94+1
	INY
MN	LDA	(Z94),Y
	PHA
	DEY
	BNM	MN
	LDY	Z94+1
	JSR	A3A4C
	LDA	CTXPTR+1
	PHA
	LDA	CTXPTR
	PHA
	LDA	(Z9B),Y
	STA	CTXPTR
	INY
	LDA	(Z9B),Y
	STA	CTXPTR+1
;
;
;
	LDA	Z94+1
	PHA
	LDA	Z94
	PHA
;
;
;
	JSR	A2C34
;
;
;
	PLA
	STA	Z9B
	PLA
	STA	Z9B+1
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;	Branch if end of statement
;
	BZ	MP
;
;
;
	JMP	PRSYNE
;
;
;
MP	PLA
	STA	CTXPTR
	PLA
	STA	CTXPTR+1
A3250	LDY	#0
	PLA
	STA	(Z9B),Y
	PLA
	INY
	STA	(Z9B),Y
	PLA
	INY
	STA	(Z9B),Y
	PLA
	INY
	STA	(Z9B),Y
	PLA
	INY
	STA	(Z9B),Y
;
;
;
	RTS
;.PAGE
;
;	STR$
;
A3266	JSR	A2C37
	LDY	#0
	JSR	A3C6B
	PLA
	PLA
AD353	LDA	#$FF
	LDY	#0
	BZ	A3288
;
;
;
A3276	LDX	ZB1
	LDY	ZB1+1
	STX	Z9D
	STY	Z9D+1
*	JSR	A327E
*	RTS
*******************************************************************************
;
;
;
A327E	JSR	A32EF
	STX	ZAF
	STY	ZAF+1
	STA	ZAE
	RTS
;.PAGE
;
;
;
A3288	LDX	#'"
	STX	Z0A
	STX	Z0B
*	JSR	A328E
*	RTS
*******************************************************************************
;
;
;
A328E	STA	ZBC
	STY	ZBC+1
	STA	ZAF
	STY	ZAF+1
	LDY	#-1
BA	INY
	LDA	(ZBC),Y
	BZ	BG
	CMP	Z0A
	BE	BF
	CMP	Z0B
	BNE	BA
BF	CMP	#'"
	BE	BH
BG	CLC
BH	STY	ZAE
	TYA
	ADC	ZBC
	STA	ZBE
	LDX	ZBC+1
	BNC	BJ
	INX
BJ	STX	ZBE+1
	LDA	ZBC+1
 ifdef cbmB1
	BNZ	A32C7
 endif
 ifndef cbmB1
	BZ	NRBJ
	CMP	#<CONBUF
	BNE	A32C7
NRBJ
 endif
	TYA
	JSR	A3276
	LDX	ZBC
	LDY	ZBC+1
	JSR	A347F
;
;
;
A32C7	LDX	Z63
	CPX	#>Z6F
	BNE	BP
;
;
;
	LDX	#FRMTCK-ERRSK
J3PERR	JMP	PRERR
;
;
;
BP	LDA	ZAE
	STA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X	ZA5
	BNM	P80DR
	LSR	ZA5
P80ED	LDY	#0
	LDA	(Z9B),Y
	STA	(ZAC),Y
	INY
	LDA	(Z9B),Y
	STA	(ZAC),Y
	DEY
	LDA	(Z6F),Y
	TAX
	JSR	SBADST
	STA	Z82
	STY	Z82+1
	TXA
	JSR	SBASRC
	TXA
	TAY
P80DU	DEY
	LDA	(Z9B),Y
	STA	(ZAC),Y
	DEX
	BNZ	P80DU
	LDY	#2
P80DV	LDA	ZAC-1,Y
	STA	(Z6F),Y
	DEY
	BNZ	P80DV
	LDA	Z9B
	LDY	Z9B+1
	CPY	STRPTR+1
	BL	JGCEX
	BNE	P80DW
	CMP	STRPTR
	BZ	JGCEX
	BNC	JGCEX
P80DW	JSR	S2BOTH
	LDY	#1
	LDA	(Z9B),Y
	CMP	#$FF
	BE	P80EB
	JSR	SAASRC
	BM	P80ED
;
;	Jump to exit
;
JGCEX	JMP	GCEX
;
;
;
P80DR	LDY	#0
	LDA	(Z6F),Y
	TAX
	JSR	SBADST
	STA	Z82
	STY	Z82+1
	TXA
	JSR	SBASRC
	JMP	P80DP
;
;	Exit
;
GCEX	LDA	Z82
	LDY	Z82+1
	STA	STRPTR
	STY	STRPTR+1
	RTS
*******************************************************************************
;
;	Subtract 2 from both pointers
;
S2BOTH	LDA	#2
	JSR	SBADST
*	JSR	SB2SRC
*	RTS
*******************************************************************************
;
;	Subtract 2 from source pointer
;
SB2SRC	LDA	#2
*	JSR	SBASRC
*	RTS
*******************************************************************************
;
;	Subtract accumulator from source pointer
;
SBASRC	EOR	#$FF
	SEC
	ADC	Z9B
	LDY	Z9B+1
	BC	P80EJ
	DEY
P80EJ	STA	Z9B
	STY	Z9B+1
	RTS
*******************************************************************************
;
;	Subtract accumulator from destination pointer
;
SBADST	EOR	#$FF
	SEC
	ADC	ZAC
	LDY	ZAC+1
	BC	P80EK
	DEY
P80EK	STA	ZAC
	STY	ZAC+1
	RTS
*******************************************************************************
;
;	Save address at source pointer
;
SAASRC	LDY	#2-1
P80EL	LDA	(Z9B),Y
	STA	Z6F,Y
	DEY
	BNM	P80EL
	RTS
 endif
;.PAGE
;
;
;
A3434	LDA	ZB1+1
	PHA
	LDA	ZB1
	PHA
;
;	Evaluate single term
;
	JSR	A2D2D
;
;
;
AD51E	JSR	A2C39
;
;
;
	PLA
	STA	ZBC
	PLA
	STA	ZBC+1
;
;
;
	LDY	#0
	LDA	(ZBC),Y
	CLC
	ADC	(ZB1),Y
	BNC	MH
;
;	Display "?STRING TOO LONG"
;
	LDX	#STRTLK-ERRSK
	JMP	PRERR
;
;
;
MH	JSR	A3276
	JSR	A3471
	LDA	Z9D
	LDY	Z9D+1
	JSR	A34A1
	JSR	A3483
	LDA	ZBC
	LDY	ZBC+1
	JSR	A34A1
	JSR	A32C7
	JMP	A2C62
;.PAGE
;
;
;
A3471	LDY	#0
	LDA	(ZBC),Y
	PHA
	INY
	LDA	(ZBC),Y
	TAX
	INY
	LDA	(ZBC),Y
	TAY
	PLA
*	JSR	A347F
*	RTS
*******************************************************************************
;
;
;
A347F	STX	Z6F
	STY	Z6F+1
;
;
;
*	JSR	A3483
;
;
;
*	RTS
*******************************************************************************
;
;
;
A3483	TAY
	BZ	JK
	PHA
JA	DEY
	LDA	(Z6F),Y
	STA	(Z82),Y
	TYA
	BNZ	JA
	PLA
JK	CLC
	ADC	Z82
	STA	Z82
	BNC	JB
	INC	Z82+1
JB	RTS
;.PAGE
;
;
;
A349A	JSR	A2C39
;
;
;
*	JSR	A349D
;
;
;
*	RTS
*******************************************************************************
;
;
;
A349D	LDA	ZB1
	LDY	ZB1+1
;
;
;
*	JSR	A34A1
;
;
;
*	RTS
*******************************************************************************
;
;
;
A34A1	STA	Z6F
	STY	Z6F+1
;
;
;
	JSR	A34D2
 ifndef cbmB4
	PHP
	LDY	#0
	LDA	(Z6F),Y
	PHA
	INY
	LDA	(Z6F),Y
	TAX
	INY
	LDA	(Z6F),Y
	TAY
	PLA
	PLP
	BNZ	BR
	CPY	STRPTR+1
	BNE	BR
	CPX	STRPTR
	BNE	BR
	PHA
	CLC
	ADC	STRPTR
	STA	STRPTR
	BNC	BQ
	INC	STRPTR+1
BQ	PLA
BR	STX	Z6F
	STY	Z6F+1
	RTS
 endif
 ifdef cbmB4
	BNZ	P80JB
	JSR	NSBA4E
	BNC	P80JB
	DEY
	LDA	#$FF
	STA	(Z6F),Y
	DEY
	TXA
	STA	(Z6F),Y
	PHA
	EOR	#$FF
	SEC
	ADC	Z6F
	LDY	Z6F+1
	BC	P80BS
	DEY
P80BS	STA	Z6F
	STY	Z6F+1
	TAX
	PLA
	CPY	STRPTR+1
	BNE	RTSD
	CPX	STRPTR
	BNE	RTSD
	PHA
	SEC
	ADC	STRPTR
	STA	STRPTR
	BNC	P80BV
	INC	STRPTR+1
P80BV	INC	STRPTR
	BNZ	P80BW
	INC	STRPTR+1
P80BW	PLA
	RTS
;
;
;
P80JB	LDY	#0
	LDA	(Z6F),Y
	PHA
	INY
	LDA	(Z6F),Y
	TAX
	INY
	LDA	(Z6F),Y
	TAY
	STX	Z6F
	STY	Z6F+1
	PLA
	RTS
 endif
;.PAGE
;
;	Clean descriptor stack
;
A34D2	CPY	Z64+1
	BNE	RTSD
	CMP	Z64
	BNE	RTSD
;
;
;
	STA	Z63
	SBC	#3
	STA	Z64
;
;
;
	LDY	#0
;
;
;
RTSD	RTS
*******************************************************************************
;
;	CHR$
;
A34E3	JSR	A3598
	TXA
	PHA
	LDA	#1
	JSR	A327E
	PLA
	LDY	#0
	STA	(ZAF),Y
	PLA
	PLA
	JMP	A32C7
*******************************************************************************
;
;	LEFT$
;
A34F7	JSR	A3556
	CMP	(Z9D),Y
	TYA
A34FD	BNC	MB
	LDA	(Z9D),Y
	TAX
	TYA
MB	PHA
MF	TXA
MG	PHA
	JSR	A327E
	LDA	Z9D
	LDY	Z9D+1
	JSR	A34A1
	PLA
	TAY
	PLA
	CLC
	ADC	Z6F
	STA	Z6F
	BNC	MC
	INC	Z6F+1
MC	TYA
	JSR	A3483
	JMP	A32C7
*******************************************************************************
;
;	RIGHT$
;
A3523	JSR	A3556
	CLC
	SBC	(Z9D),Y
	EOR	#$FF
	JMP	A34FD
;.PAGE 'MID$'
;
;
;
A352E	LDA	#$FF
	STA	ZB1+1
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;
;
	CMP	#')
	BE	MD
;
;	Current BASIC text character must be a comma
;
	JSR	MBCOMA
;
;
;
	JSR	A3595
;
;
;
MD	JSR	A3556
 ifndef cbmB1
	BZ	A358F
 endif
;
;
;
	DEX
	TXA
	PHA
;
;
;
	CLC
	LDX	#0
	SBC	(Z9D),Y
	BC	MF
	EOR	#$FF
	CMP	ZB1+1
	BNC	MG
	LDA	ZB1+1
	BC	MG
;
;	Current BASIC text character must be right parenthesis
;
A3556	JSR	MBRPAR
;
;
;
 ifdef cbmB1
	PLA
	STA	ZA2
	PLA
	STA	ZA2+1
 endif
 ifndef cbmB1
	PLA
	TAY
	PLA
	STA	ZA2
 endif
	PLA
	PLA
	PLA
	TAX
	PLA
	STA	Z9D
	PLA
	STA	Z9D+1
 ifdef cbmB1
	LDY	#0
	TXA
	BZ	A358F
	INC	ZA2
	JMP	(ZA2)
 endif
 ifndef cbmB1
	LDA	ZA2
	PHA
	TYA
	PHA
	LDY	#0
	TXA
	RTS
 endif
;.PAGE
;
;	LEN
;
A3573	JSR	A3579
 ifdef cbmB1
AD657
 endif
	JMP	A31A4
*******************************************************************************
;
;
;
A3579	JSR	A349A
;
;
;
	LDX	#0
	STX	Z0E
;
;
;
	TAY
;
;
;
	RTS
*******************************************************************************
;
;
;
FASC	JSR	A3579
	BZ	A358F
;
;
;
	LDY	#0
	LDA	(Z6F),Y
	TAY
 ifdef cbmB1
	JMP	AD657
 endif
 ifndef cbmB1
	JMP	A31A4
 endif
;
;
;
A358F	JMP	A304B
;
;	Get next BASIC text character
;
A3592	JSR	NXTTCE
;
;
;
A3595	JSR	A2C34
;
;
;
A3598	JSR	A2FBE
	LDX	ZB1
	BNZ	A358F
	LDX	ZB1+1
;
;	Re-get current BASIC text character and return
;
	JMP	CURTCE
;.PAGE
;
;
;
FVAL	JSR	A3579
	BNZ	SU
	JMP	A36E3
;
;	Copy pointer
;
SU	LDX	CTXPTR
	LDY	CTXPTR+1
	STX	ZBE
	STY	ZBE+1
;
;
;
	LDX	Z6F
	STX	CTXPTR
	CLC
	ADC	Z6F
	STA	Z71
	LDX	Z6F+1
	STX	CTXPTR+1
	BNC	SV
	INX
SV	STX	Z71+1
;
;
;
	LDY	#0
	LDA	(Z71),Y
	PHA
 ifndef cbmB4
	LDA	#0
 endif
 ifdef cbmB4
	TYA
 endif
	STA	(Z71),Y
;
;	Re-get current BASIC text character
;
	JSR	CURTCE
;
;
;
	JSR	ASC2FP
;
;
;
	PLA
	LDY	#0
	STA	(Z71),Y
;
;
;
A35DA	LDX	ZBE
	LDY	ZBE+1
	STX	CTXPTR
	STY	CTXPTR+1
;
;
;
	RTS
*******************************************************************************
;
;
;
A35E3	JSR	A2C34
;
;
;
	JSR	A35EF
;
;	Current BASIC text character must be a comma
;
A35E9	JSR	MBCOMA
;
;
;
	JMP	A3595
*******************************************************************************
;
;
;
A35EF	LDA	ZB3
	BM	A358F
	LDA	ZAE
	CMP	#$91
	BC	A358F
;
;
;
	JSR	A3B13
;
;
;
	LDA	ZB1
	LDY	ZB1+1
	STY	Z19
	STA	Z19+1
;
;
;
	RTS
;.PAGE
;
;
;
FPEEK
 ifndef cbmB1
	LDA	Z19+1
	PHA
	LDA	Z19
	PHA
 endif
;
;
;
	JSR	A35EF
;
;
;
	LDY	#0
 ifdef cbmB1
	CMP	#<$C000
	BNC	PSVA
	CMP	#<$E100
	BNC	PSVB
PSVA
 endif
 ifdef cbmB2
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
 endif
	LDA	(Z19),Y
	TAY
 ifndef cbmB1
;
;	Restore pointer
;
	PLA
	STA	Z19
	PLA
	STA	Z19+1
 endif
 ifdef cbmB1
PSVB
 endif
	JMP	A31A4
*******************************************************************************
;
;
;
VPOKE	JSR	A35E3
;
;
;
	TXA
	LDY	#0
	STA	(Z19),Y
;
;
;
	RTS
*******************************************************************************
;
;
;
VWAIT	JSR	A35E3
;
;
;
	STX	Z96
;
;
;
	LDX	#0
;
;
;
	JSR	CURTCE
;
;	Branch if end of statement
;
 ifndef cbmB2
	BZ	SW
 endif
 ifdef cbmB2
	BZ	NRD745
 endif
;
;
;
	JSR	A35E9
;
;
;
SW	STX	Z96+1
;
;
;
	LDY	#0
SX	LDA	(Z19),Y
	EOR	Z96+1
	AND	Z96
	BZ	SX
;
;
;
RTSS	RTS
;.PAGE 'Start of floating point logic'
;
;
;
A3635	LDA	#>A3D99
	LDY	#<A3D99
	JMP	A3653
;
;
;
A363C	JSR	A3904
;
;	FAC = FARG - FAC
;
FPSUB	LDA	FAC+5
	EOR	#$FF
	STA	FAC+5
	EOR	FARG+5
	STA	FARG+6
	LDA	FAC
	JMP	FPADD
 ifdef cbmB2
;
;
;
NRD745	LDA	Z19
	CMP	#$66
	BNE	SW
	LDA	Z19+1
	SBC	#25
	BNZ	SW
	STA	Z19
	TAY
	LDA	#$80
	STA	Z19+1
NRSX	LDX	#10
NRSY	LDA	NRE082-1,X
	AND	#$3F
	STA	(Z19),Y
	INY
	BNZ	NRSZ
	INC	Z19+1
NRSZ	DEX
	BNZ	NRSY
	DEC	Z96
	BNZ	NRSX
;
;
;
	RTS
 endif
;.PAGE 'FLOATING POINT ROUTINES  "SMBFPPX"  4/5/81'
;
;
;
SY	JSR	A37B7
	BNC	TH
A3653	JSR	A3904
;
;	FAC = FARG + FAC
;
FPADD	BNZ	TE
	JMP	A3A74
TE	LDX	FARG+7
	STX	ZA2+1
	LDX	#>FARG
	LDA	FARG
*	JSR	A3663
*	RTS
*******************************************************************************
;
;
;
A3663	TAY
	BZ	RTSS
	SEC
	SBC	FAC
	BZ	TH
	BNC	TF
	STY	FAC
	LDY	FARG+5
	STY	FAC+5
	EOR	#$FF
	ADC	#0
	LDY	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4
	ROR	FARG+7
TW	RTS
;
;
;
A3765	LDA	FAC+5
	EOR	#$FF
	STA	FAC+5
A376B	LDA	FAC+1
	EOR	#$FF
	STA	FAC+1
	LDA	FAC+2
	EOR	#$FF
	STA	FAC+2
	LDA	FAC+3
	EOR	#$FF
	STA	FAC+3
	LDA	FAC+4
	EOR	#$FF
	STA	FAC+4
	LDA	FARG+7
	EOR	#$FF
	STA	FARG+7
	INC	FARG+7
	BNZ	TX
A378D	INC	FAC+4
	BNZ	TX
	INC	FAC+3
	BNZ	TX
	INC	FAC+2
	BNZ	TX
	INC	FAC+1
TX	RTS
;
;
;
A379C	LDX	#OFLWEK-ERRSK
	JMP	PRERR
;.PAGE
;
;
;
A37A1	LDX	#>Z71+1
TY	LDY	ZPSTRT+4,X
	STY	FARG+7
	LDY	ZPSTRT+3,X
	STY	ZPSTRT+4,X
	LDY	ZPSTRT+2,X
	STY	ZPSTRT+3,X
	LDY	ZPSTRT+1,X
	STY	ZPSTRT+2,X
	LDY	FAC+7
	STY	ZPSTRT+1,X
A37B7	ADC	#8
	BM	TY
	BZ	TY
	SBC	#8
	TAY
	LDA	FARG+7
	BC	UB
TZ	ASL	ZPSTRT+1,X
	BNC	PUP
	INC	ZPSTRT+1,X
PUP	ROR	ZPSTRT+1,X
	ROR	ZPSTRT+1,X
A37D0	ROR	ZPSTRT+2,X
	ROR	ZPSTRT+3,X
	ROR	ZPSTRT+4,X
	ROR	A
	INY
	BNZ	TZ
UB	CLC
	RTS
;.PAGE
;
;	1.0
;
FPONE	DB	$81,$00,$00,$00,$00
;
;	Count of following floating point constants
;
A3807	DB	4-1
;
;
;
	DB	$7F,$5E,$56,$CB,$79
	DB	$80,$13,$9B,$0B,$64
	DB	$80,$76,$38,$93,$16
	DB	$82,$38,$AA,$3B,$20
;
;	0.707106781 (Square root of 0.5)
;
A381C	DB	$80,$35,$04,$F3,$34
;
;	1.41421356 (Square root of 2.0)
;
A3821	DB	$81,$35,$04,$F3,$34
;
;	-0.5
;
A3826	DB	$80,$80,$00,$00,$00
;
;	0.693147181 (log 2)
;
A382B	DB	$80,$31,$72,$17,$F8
;.PAGE
;
;	FAC = LOG(FAC)
;
FPLOG	JSR	A3AA3
	BZ	UC
	BNM	UD
UC	JMP	A304B
UD	LDA	FAC
	SBC	#$7F
	PHA
	LDA	#$80
	STA	FAC
	LDA	#>A381C
	LDY	#<A381C
	JSR	A3653
	LDA	#>A3821
	LDY	#<A3821
	JSR	A3987
	LDA	#>FPONE
	LDY	#<FPONE
	JSR	A363C
	LDA	#>A3807
	LDY	#<A3807
	JSR	A3E91
	LDA	#>A3826
	LDY	#<A3826
	JSR	A3653
	PLA
	JSR	A3C0A
	LDA	#>A382B
	LDY	#<A382B
A386E	JSR	A3904
;
;	FAC = FARG * FAC
;
FPMULT
 ifdef cbmB1
	BZ	RTSU
 endif
 ifndef cbmB1
	BNZ	NRUD
	JMP	RTSU
NRUD
 endif
	JSR	A392F
	LDA	#0
	STA	Z73
	STA	Z73+1
	STA	Z73+2
	STA	Z73+3
	LDA	FARG+7
	JSR	A389F
	LDA	FAC+4
	JSR	A389F
	LDA	FAC+3
	JSR	A389F
	LDA	FAC+2
	JSR	A389F
	LDA	FAC+1
	JSR	A38A4
	JMP	A3A07
;.PAGE
A389F	BNZ	A38A4
	JMP	A37A1
A38A4	LSR	A
	ORA	#$80
UG	TAY
	BNC	UH
	CLC
	LDA	Z73+3
	ADC	FARG+4
	STA	Z73+3
	LDA	Z73+2
	ADC	FARG+3
	STA	Z73+2
	LDA	Z73+1
	ADC	FARG+2
	STA	Z73+1
	LDA	Z73
	ADC	FARG+1
	STA	Z73
UH	ROR	Z73
	ROR	Z73+1
	ROR	Z73+2
	ROR	Z73+3
	ROR	FARG+7
	TYA
	LSR	A
	BNZ	UG
RTSU	RTS
;.PAGE
;
;	MEMORY TO FARG
;
A3904	STA	Z6F
	STY	Z6F+1
	LDY	#4
	LDA	(Z6F),Y
	STA	FARG+4
	DEY
	LDA	(Z6F),Y
	STA	FARG+3
	DEY
	LDA	(Z6F),Y
	STA	FARG+2
	DEY
	LDA	(Z6F),Y
	STA	FARG+5
	EOR	FAC+5
	STA	FARG+6
	LDA	FARG+5
	ORA	#$80
	STA	FARG+1
	DEY
	LDA	(Z6F),Y
	STA	FARG
	LDA	FAC
	RTS
;.PAGE
A392F	LDA	FARG
A3931	BZ	UU
	CLC
	ADC	FAC
	BNC	US
	BM	UV
	CLC
	DB	$2C
US	BNM	UU
	ADC	#$80
	STA	FAC
	BNZ	UT
	JMP	A36E7
UT	LDA	FARG+6
	STA	FAC+5
	RTS
;
;
;
A394C	LDA	FAC+5
	EOR	#$FF
	BM	UV
UU	PLA
	PLA
	JMP	A36E3
UV	JMP	A379C
A395A	JSR	A3A84
	TAX
	BZ	UW
	CLC
	ADC	#2
	BC	UV
AD9BF	LDX	#0
	STX	FARG+6
	JSR	A3663
	INC	FAC
	BZ	UV
UW	RTS
;
;	10.0
;
A3971	DB	$84,$20,$00,$00,$00
;
;
;
A3976	JSR	A3A84
	LDA	#>A3971
	LDY	#<A3971
	LDX	#0
A397F	STX	FARG+6
;
;	Load 'FAC' from memory pointed to by 'Y' register and accumulator
;
	JSR	MFPACC
;
;
;
	JMP	FPDIV
;.PAGE
A3987	JSR	A3904
;
;	FAC = FARG / FAC
;
FPDIV	BZ	VE
	JSR	ROUNDA
	LDA	#0
	SEC
	SBC	FAC
	STA	FAC
	JSR	A392F
	INC	FAC
	BZ	UV
	LDX	#$FC
	LDA	#$01
UX	LDY	FARG+1
	CPY	FAC+1
	BNE	UY
	LDY	FARG+2
	CPY	FAC+2
	BNE	UY
	LDY	FARG+3
	CPY	FAC+3
	BNE	UY
	LDY	FARG+4
	CPY	FAC+4
UY	PHP
	ROL	A
	BNC	UZ
	INX
	STA	Z75+1,X
	BZ	VC
	BNM	VD
	LDA	#1
UZ	PLP
	BC	VB
VA	ASL	FARG+4
	ROL	FARG+3
	ROL	FARG+2
	ROL	FARG+1
	BC	UY
	BM	UX
	BNM	UY
VB	T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FARG+5
A3A76	STA	FAC+5
;
;
;
	LDX	#5
TA	LDA	FARG-1,X
	STA	FAC-1,X
	DEX
	BNZ	TA
;
;
;
*	LDX	#0
	STX	FARG+7
;
;
;
	RTS
*******************************************************************************
;
;	Move 'FAC' to 'FARG' with rounding
;
A3A84	JSR	ROUNDA
;
;
;
*	JSR	A3A87
*	RTS
*******************************************************************************
;
;	Move 'FAC' to 'FARG' without rounding
;
A3A87	LDX	#6
TB	LDA	FAC-1,X
	STA	FARG-1,X
	DEX
	BNZ	TB
	STX	FARG+7
RTST	RTS
*******************************************************************************
;
;	Round off 'FAC'
;
ROUNDA	LDA	FAC
	BZ	RTST
	ASL	FARG+7
	BNC	RTST
A3A9B	JSR	A378D
	BNZ	RTST
	JMP	A3724
*******************************************************************************
;
;	Move sign of 'FAC' to accumulator
;
A3AA3	LDA	FAC
	BZ	TC
A3AA7	LDA	FAC+5
A3AA9	ROL	A
	LDA	#-1
	BC	TC
	LDA	#1
TC	RTS
*******************************************************************************
;
;	FAC = SGN(FAC)
;
A3AB1	JSR	A3AA3
A3AB4	STA	FAC+1
	LDA	#0
	STA	FAC+2
	LDX	#$88
A3ABC	LDA	FAC+1
	EOR	#$FF
	ROL	A
A3AC1	LDA	#0
	STA	FAC+4
	STA	FAC+3
ADB21	STX	FAC
	STA	FARG+7
	STA	FAC+5
	JMP	A36BE
*******************************************************************************
;
;	FAC = ABS(FAC)
;
A3AD0	LSR	FAC+5
	RTS
;.PAGE
;
;
;
A3AD3	STA	Z71
A3AD5	STY	Z71+1
	LDY	#0
	LDA	(Z71),Y
	INY
	TAX
	BZ	A3AA3
	LDA	(Z71),Y
	EOR	FAC+5
	BM	A3AA7
	CPX	FAC
	BNE	KX
	LDA	(Z71),Y
	ORA	#$80
	CMP	FAC+1
	BNE	KX
	INY
	LDA	(Z71),Y
	CMP	FAC+2
	BNE	KX
	INY
	LDA	(Z71),Y
	CMP	FAC+3
	BNE	KX
	INY
	LDA	#$7F
	CMP	FARG+7
	LDA	(Z71),Y
	SBC	FAC+4
	BZ	RTSN
KX	LDA	FAC+5
	BNC	KY
	EOR	#$FF
KY	JMP	A3AA9
;.PAGE
;
;
;
A3B13	LDA	FAC
	BZ	A3B61
	SEC
	SBC	#$A0
	BIT	FAC+5
	BNM	KZ
	TAX
	LDA	#$FF
	STA	FAC+7
	JSR	A376B
	TXA
KZ	LDX	#>FAC
	CMP	#$F9
	BNM	JN
	JSR	A37B7
	STY	FAC+7
RTSN	RTS
JN	TAY
	LDA	FAC+5
	AND	#$80
	LSR	FAC+1
	ORA	FAC+1
	STA	FAC+1
	JSR	A37D0
	STY	FAC+7
	RTS
;
;	FAC = INT(FAC)
;
A3B44	LDA	FAC
	CMP	#$A0
	BC	RTSR
	JSR	A3B13
	STY	FARG+7
	LDA	FAC+5
	STY	FAC+5
	EOR	#$80
	ROL	A
	LDA	#$A0
	STA	FAC
	LDA	FAC+4
	STA	Z0A
	JMP	A36BE
;
;
;
A3B61	STA	FAC+1
	STA	FAC+2
	STA	FAC+3
	STA	FAC+4
	TAY
;
;
;
RTSR	RTS
;.PAGE
;
;	Clear 11 bytes
;
ASC2FP	LDY	#0
	LDX	#11-1
PM	STY	ZAA,X
	DEX
	BNM	PM
;
;
;
	BNC	PQ
;
;
;
	CMP	#'-
	BNE	PN
	STX	FAC+6
	BE	A3B82
PN	CMP	#'+
	BNE	ST

;
;	Get next BASIC text character
;
A3B82	JSR	NXTTCE
;
;	Branch if numeric character
;
PQ	BNC	A3BF6
;
;
;
ST	CMP	#'.
	BE	PX
	CMP	#'E
	BNE	SJ
;
;	Get next BASIC text character
;
	JSR	NXTTCE
;
;	Branch if numeric character
;
	BNC	PU
;
;	Branch if accumulator is token for '-' or '-'
;
	CMP	#TKMIN
	BE	PR
	CMP	#'-
	BE	PR
;
;	Branch if accumulator is token for '+' or '+'
;
	CMP	#TKPLUS
	BE	A3BB2
	CMP	#'+
	BE	A3BB2
;
;	Unconditiional branch
;
	BNE	PW
;
;
;
PR	ROR	ZAC+1
;
;	Get next BASIC text character
;
A3BB2	JSR	NXTTCE
;
;	Branch if numeric character
;
PU	BNC	A3C1D
;
;
;
PW	BIT	ZAC+1
	BNM	SJ
	LDA	#0
	SEC
	SBC	ZAA+1
	JMP	SK
PX	ROR	ZAC
	BIT	ZAC
	BNV	A3B82
SJ	LDA	ZAA+1
SK	SEC
	SBC	ZAA
	STA	ZAA+1
	BZ	SN
	BNM	SM
SL	JSR	A3976
	INC	ZAA+1
	BNZ	SL
	BZ	SN
SM	JSR	A395A
	DEC	ZAA+1
	BNZ	SM
SN	LDA	FAC+6
	BM	SP
	RTS
SP	JMP	A3E05
;.PAGE
;
;
;
A3BF6	PHA
	BIT	ZAC
	BNM	SQ
	INC	ZAA
SQ	JSR	A395A
	PLA
	SEC
	SBC	#$30
	JSR	A3C0A
	JMP	A3B82
*******************************************************************************
;
;
;
A3C0A	PHA
	JSR	A3A84
	PLA
	JSR	A3AB4
	LDA	FARG+5
	EOR	FAC+5
	STA	FARG+6
	LDX	FAC
	JMP	FPADD
*******************************************************************************
;
;
;
A3C1D	LDA	ZAA+1
 ifdef cbmB1
	CMP	#12
 endif
 ifndef cbmB1
	CMP	#10
 endif
	BL	SR
 ifdef cbmB1
	BIT	ZAC+1
	BM	PSSS
	JMP	A379C
PSSS	LDA	#$0B
 endif
 ifndef cbmB1
	LDA	#$64
	BIT	ZAC+1
	BM	PSS
	JMP	A379C
 endif
SR	ASL	A
	ASL	A
	CLC
	ADC	ZAA+1
	ASL	A
	CLC
	LDY	#0
	ADC	(CTXPTR),Y
	SEC
	SBC	#$30
PSS	STA	ZAA+1
	JMP	A3BB2
;.PAGE
;
;	99999999.9
;
A3C3F	DB	$9B,$3E,$BC,$1F,$FD
;
;	999999999.0
;
A3C44
 ifdef cbmB1
	DB	$9E,$6E,$6B,$27,$FE
 endif
 ifndef cbmB1
	DB	$9E,$6E,$6B,$27,$FD
 endif
;
;	1000000000.0
;
A3C49	DB	$9E,$6E,$6B,$28,0
 ifdef cbmB4
;
;
;
	DB	$F9
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
	DB	$AA,$AA,$AA,$AA,$AA,$AA,$AA
 endif
;.PAGE 'FLOATING POINT ROUTINES  "SMBFPPY"  4/5/81'
;
;	Display " IN "
;
PELNO	LDA	#>INK
	LDY	#<INK
	JSR	A3C66
;
;
;
	LDA	CURLNO+1
	LDX	CURLNO
*	JSR	A3C59
*	RTS
*******************************************************************************
;
;
;
A3C59	STA	FAC+1
	STX	FAC+2
	LDX	#$90
	SEC
	JSR	A3AC1
	JSR	A3C69
*	JSR	A3C66
*	RTS
*******************************************************************************
;
;
;
A3C66	JMP	OPSTRA
;.PAGE
;
;
;
A3C69	LDY	#$01
A3C6B	LDA	#SPACE
	BIT	FAC+5
	BNM	RA
	LDA	#'-
RA	STA	BSTACK-1,Y
	STA	FAC+5
	STY	ZBE
	INY
	LDA	#'0
	LDX	FAC
	BNZ	RB
	JMP	SA
RB	LDA	#0
	CPX	#$80
	BE	RC
	BGE	RD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LDA	FAC
	BZ	SG
;
;
;
	LDA	FAC+5
	EOR	#$FF
	STA	FAC+5
;
;
;
SG	RTS
;.PAGE
;
;	1.44269504 (1/log to base 2 e)
;
A3E10	DB	$81,$38,$AA,$3B,$29
;
;	Count of following floating point constants 
;
A3E15	DB	8-1
;
;
;
	DB	$71,$34,$58,$3E,$56	; 2.149875 E-5
	DB	$74,$16,$7E,$B3,$1B	; 1.435231 E-4
	DB	$77,$2F,$EE,$E3,$85	; 1.342263 E-3
	DB	$7A,$1D,$84,$1C,$2A	; 9.6414017 E-3
	DB	$7C,$63,$59,$58,$0A	; 5.550513 E-2
	DB	$7E,$75,$FD,$E7,$C6	; 2.402263 E-4
	DB	$80,$31,$72,$18,$10	; 6.931471 E-1
	DB	$81,$00,$00,$00,$00	; 1.0
;.PAGE
;
;	FAC = EXP(FAC)
;
FPEXP	LDA	#>A3E10
	LDY	#<A3E10
	JSR	A386E
	LDA	FARG+7
	ADC	#$50
	BNC	KT
	JSR	A3A9B
KT	STA	ZA2+1
	JSR	A3A87
	LDA	FAC
	CMP	#$88
	BNC	KV
KU	JSR	A394C
KV	JSR	A3B44
	LDA	Z0A
	CLC
	ADC	#$81
	BZ	KU
	SEC
	SBC	#1
	PHA
	LDX	#5
KW	LDA	FARG,X
	LDY	FAC,X
	STA	FAC,X
	STY	FARG,X
	DEX
	BNM	KW
	LDA	ZA2+1
	STA	FARG+7
	JSR	FPSUB
	JSR	A3E05
	LDA	#>A3E15
	LDY	#<A3E15
	JSR	A3EA7
	LDA	#0
	STA	FARG+6
	PLA
	JSR	A3931
	RTS
;.PAGE
;
;
;
A3E91	STA	ZBE
	STY	ZBE+1
	JSR	A3A42
	LDA	#>ZA4
	JSR	A386E
	JSR	A3EAB
	LDA	#>ZA4
	LDY	#<ZA4
	JMP	A386E
*******************************************************************************
;
;
;
A3EA7	STA	ZBE
	STY	ZBE+1
A3EAB	JSR	A3A3F
	LDA	(ZBE),Y
	STA	FAC+6
	LDY	ZBE
	INY
	TY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Z13
	EOR	#$FF
	STA	Z13
MU	JSR	A3E05
MV	LDA	#>A3FA5
	LDY	#<A3FA5
	JSR	A3653
	PLA
	BNM	MW
	JSR	A3E05
MW	LDA	#>A3FAA
	LDY	#<A3FAA
	JMP	A3E91
;.PAGE
;
;	FAC = TAN(FAC)
;
FPTAN	JSR	A3A42
	LDA	#0
	STA	Z13
	JSR	FPSIN
;
;
;
	LDX	#>Z9B
	LDY	#<Z9B
	JSR	A3F1C
;
;	Load 'FAC' from memory pointed to by 'Y' register and accumulator
;
	LDA	#>ZA4
	LDY	#<ZA4
	JSR	MFPACC
;
;
;
	LDA	#0
	STA	FAC+5
;
;
;
	LDA	Z13
	JSR	A3F97
	LDA	#>Z9B
	LDY	#<Z9B
	JMP	A3987
;
;
;
A3F97	PHA
	JMP	MU
;
;	1.570796327 (Pi / 2)
;
A3F9B	DB	$81,$49,$0F,$DA,$A2
;
;	6.28318531 (Pi * 2)
;
A3FA0	DB	$83,$49,$0F,$DA,$A2
;
;	0.25
;
A3FA5	DB	$7F,$00,$00,$00,$00
;
;	Count of following floating point constants 
;
A3FAA	DB	6-1
;
;
;
	DB	$84,$E6,$1A,$2D,$1B	; -14.3813907
	DB	$86,$28,$07,$FB,$F8	; 42.0077971
	DB	$87,$99,$68,$89,$01	; -76.7041703
	DB	$87,$23,$35,$DF,$E1	; 81.6052237
	DB	$86,$A5,$5D,$E7,$28	; -41.3417021
	DB	$83,$49,$0F,$DA,$A2	; 6.28318531
 ifdef cbmB2
;
;
;
NRE082	DB	$A1,$54,$46,$8F,$13
	DB	$8F,$52,$43,$89,$CD
 endif
;
;	FLOATING POINT ROUTINES  "SMBFPPZ"  4/3/81
;
;.PAGE
;
;	FAC = ATN(FAC)
;
FPARCT	LDA	FAC+5
	PHA
	BNM	MX
	JSR	A3E05
MX	LDA	FAC
	PHA
	CMP	#$81
	BNC	MY
	LDA	#>FPONE
	LDY	#<FPONE
	JSR	A3987
MY	LDA	#>A4003
	LDY	#<A4003
	JSR	A3E91
	PLA
	CMP	#$81
	BNC	MZ
	LDA	#>A3F9B
	LDY	#<A3F9B
	JSR	A363C
MZ	PLA
	BNM	PZ
	JMP	A3E05
PZ	RTS
;
;	Count of following floating point constants
;
A4003	DB	12-1
;
;
;
	DB	$76,$B3,$83,$BD,$D3	; -0.000684793912
	DB	$79,$1E,$F4,$A6,$F5	; 0.00485094216
	DB	$7B,$83,$FC,$B0,$10	; -0.161117018
	DB	$7C,$0C,$1F,$67,$CA	; 0.034209638
	DB	$7C,$DE,$53,$CB,$C1	; -0.0542791328
	DB	$7D,$14,$64,$70,$4C	; 0.0724571965
	DB	$7D,$B7,$EA,$51,$7A	; -0.0898023954
	DB	$7D,$63,$30,$88,$7E	; 0.110932413
	DB	$7E,$92,$44,$99,$3A	; -0.142839808
	DB	$7E,$4C,$CC,$91,$C7	; 0.19999912
	DB	$7F,$AA,$AA,$AA,$13	; -0.333333316
	DB	$81,$00,$00,$00,$00	; 1.0
;.PAGE 'Logic and constant to be copied to page zero'
;
;	Increment 'CURTCK' operand where it lives in page zero
;
NXTTCK	INC	CTXPTR
	BNZ	CURTCK
	INC	CTXPTR+1
;
;	Get BASIC text character
;
CURTCK	LDA	AEA60
;
;	Branch if alphabetic character
;
	CMP	#'9+1
	BGE	RTSA
;
;	Branch if space (ignore leading spaces)
;
	CMP	#SPACE
	BE	NXTTCK
;
;
;
	SEC
	SBC	#'0
	SEC
	SBC	#256-'0
;
;	Return carry flag clear if numeric character; set if non-numeric
;
RTSA	RTS
*******************************************************************************
;
;	0.811635157 (Random number seed)
;
 ifdef cbmB1
	DB	$80,$4F,$C7,$52,$59
 endif
 ifndef cbmB1
	DB	$80,$4F,$C7,$52,$58
 endif
;
;
;
EPZERO
;.PAGE 'Cold start logic'
;
;	Set stack pointer
;
COLDST
 ifdef cbmB1
	LDX	#>$01FF
	STX	CURLNO+1
 endif
 ifndef cbmB1
	LDX	#>$01FB
 endif
	TXS
;
;
;
	LDA	#$4C
	STA	ZA1
	STA	USERFN
;
;
;
	LDA	#>A304B
	LDY	#<A304B
	STA	USERFN+1
	STY	USERFN+2
 ifdef cbmB2
;
;
;
	LDA	#40
	STA	Z17
	LDA	#30
	STA	Z18
 endif
;
;	Copy text character get routine and random number seed to page zero
;
	LDX	#EPZERO-NXTTCK-1
MVLP	LDA	NXTTCK-1,X
	STA	NXTTCE-1,X
	DEX
	BNZ	MVLP
 ifndef cbmB1
;
;
;
	LDA	#3
	STA	ZA0
 endif
;
;	Clear accumulator
;
	TXA
;
;
;
	STA	ZB5
	STA	CURDVC
	STA	Z64+1
 ifdef cbmB1
	STA	Z15
	STA	Z16
 endif
 ifdef cbmB4
	STA	SZ0D
 endif
	PHA
 ifndef cbmB4
	STA	Z14
 endif
 ifdef cbmB1
	LDA	#$03
	STA	ZA0
	LDA	#',
	STA	Z19+1
	JSR	CRLF
	LDX	#$68
	STX	Z63
 endif
 ifndef cbmB1
	INX
	STX	CONBUF-3
	STX	CONBUF-4
	LDX	#$16
	STX	Z63
 endif
;
;
;
 ifdef cbmB1
	LDA	#>MEMBGN
 endif
	LDY	#<MEMBGN
 ifndef cbmB1
	STA	TXSPTR
	STY	TXSPTR+1
 endif
	STA	Z19
	STY	Z19+1
 ifdef cbmB1
	LDY	#0
 endif
 ifndef cbmB1
	TAY
 endif
 ifdef cbmB4
	LDA	#$80
	BNZ	MEMLP
;
;
;
	LDA	#$00
	LDY	#$B0
	JMP	P80AN
 endif
MEMLP	INC	Z19
	BNZ	AM
	INC	Z19+1
 ifdef cbmB1
	LDA	Z19+1
	CMP	#$80
	BE	AN
 endif
 ifndef cbmB1
	BM	AN
 endif
AM
 ifdef cbmB1
	LDA	#$92
 endif
 ifndef cbmB1
	LDA	#$55
 endif
	STA	(Z19),Y
	CMP	(Z19),Y
	BNE	AN
	ASL	A
	STA	(Z19),Y
	CMP	(Z19),Y
	BE	MEMLP
;
;
;
AN	LDA	Z19
	LDY	Z19+1
 ifdef cbmB4
P80AN
 endif
	STA	HMEPTR
	STY	HMEPTR+1
	STA	STRPTR
	STY	STRPTR+1
 ifndef cbmB4
;
;
;
	LDX	#>MEMBGN
	LDY	#<MEMBGN
	STX	TXSPTR
	STY	TXSPTR+1
 endif
;
;
;
	LDY	#0
	TYA
	STA	(TXSPTR),Y
	INC	TXSPTR
 ifdef cbmB1
	BNZ	AS
	INC	TXSPTR+1
AS
 endif
 ifndef cbmB4
;
;
;
	LDA	TXSPTR
	LDY	TXSPTR+1
	JSR	A22F2
 endif
 ifdef cbmB1
;
;
;
	JSR	CRLF
 endif
 ifndef cbmB1
;
;	Display "xxx COMMODORE BASIC xxx"
;
	LDA	#>CBMBAS
	LDY	#<CBMBAS
	JSR	OPSTRA
 endif
;
;	Calculate and display free space value
;
	LDA	HMEPTR
	SEC
	SBC	TXSPTR
	TAX
	LDA	HMEPTR+1
	SBC	TXSPTR+1
	JSR	A3C59
;
;	Display " BYTES FREE"
;
	LDA	#>FREEK
	LDY	#<FREEK
	JSR	OPSTRA
;
;
;
	JSR	DONEW
;
;	Start BASIC interpreter
;
	JMP	GETNXT
;.PAGE 'Initialization string constants'
 ifdef cbmB1
;
;
;
FREEK	ASC	' BYTES FREE'
	DB	$13
	ASC	'*** COMMODORE BASIC ***'
	DB	$11,$11,$11,0
 endif
 ifndef cbmB1
;
;
;
FREEK	ASC	' BYTES FREE'
	DB	$0D,0
 endif
;
;
;
 ifdef cbmB2
CBMBAS
 endif
 ifndef cbmB1
	ASC	'### COMMODORE BASIC ###'
	DB	$0D,$0D,0
 endif
 ifdef cbmB1
;.PAGE 'Patches'
;
;
;
PATCH1	CLC
	JMP	A26F7
;
;
;
PATCH2	BIT	ZB1+1
	BNM	PXA
	CMP	#$54
	BNE	PXA
	JMP	ACE3B
PXA	RTS
;
;
;
PATCH3	BIT	ZB1+1
	BM	PXB
	JMP	ACE90
PXB	CMP	#$54
	BE	PXC
	JMP	ACE82
PXC	JMP	ACE69
;
;
;
PATCH4	STA	Z0A
	INX
	JMP	PXD
;
;
;
PATCH5	BNM	PXJ
	LDA	Z8C
	LDY	Z8C+1
	RTS
PXJ	LDY	#$FF
	RTS
;
;
;
PATCH6	BNZ	PXL
PXK	INC	Z16
	BNZ	PXL
	LDA	SCRNDX
	STA	Z16
	BNZ	PXK
PXL	RTS
;
;
;
PXD	STX	CTXPTR
	PLA
	PLA
	TYA
	JMP	FL
 endif
