ca65 V2.15 - Git f7cdfbf
Main file   : basic.asm
Current file: basic.asm

000000r 1               
000000r 1               ; Enhanced BASIC to assemble under 6502 simulator, $ver 2.22
000000r 1               
000000r 1               ; $E7E1 $E7CF $E7C6 $E7D3 $E7D1 $E7D5 $E7CF $E81E $E825
000000r 1               
000000r 1               ; 2.00	new revision numbers start here
000000r 1               ; 2.01	fixed LCASE$() and UCASE$()
000000r 1               ; 2.02	new get value routine done
000000r 1               ; 2.03	changed RND() to galoise method
000000r 1               ; 2.04	fixed SPC()
000000r 1               ; 2.05	new get value routine fixed
000000r 1               ; 2.06	changed USR() code
000000r 1               ; 2.07	fixed STR$()
000000r 1               ; 2.08	changed INPUT and READ to remove need for $00 start to input buffer
000000r 1               ; 2.09	fixed RND()
000000r 1               ; 2.10	integrated missed changes from an earlier version
000000r 1               ; 2.20	added ELSE to IF .. THEN and fixed IF .. GOTO <statement> to cause error
000000r 1               ; 2.21	fixed IF .. THEN RETURN to not cause error
000000r 1               ; 2.22	fixed RND() breaking the get byte routine
000000r 1               
000000r 1               ; zero page use ..
000000r 1               
000000r 1               LAB_WARM 		= $00		; BASIC warm start entry point
000000r 1               Wrmjpl 		= LAB_WARM+1; BASIC warm start vector jump low byte
000000r 1               Wrmjph 		= LAB_WARM+2; BASIC warm start vector jump high byte
000000r 1               
000000r 1               Usrjmp		= $0A		; USR function JMP address
000000r 1               Usrjpl		= Usrjmp+1	; USR function JMP vector low byte
000000r 1               Usrjph		= Usrjmp+2	; USR function JMP vector high byte
000000r 1               Nullct		= $0D		; nulls output after each line
000000r 1               TPos			= $0E		; BASIC terminal position byte
000000r 1               TWidth		= $0F		; BASIC terminal width byte
000000r 1               Iclim			= $10		; input column limit
000000r 1               Itempl		= $11		; temporary integer low byte
000000r 1               Itemph		= Itempl+1	; temporary integer high byte
000000r 1               
000000r 1               nums_1		= Itempl	; number to bin/hex string convert MSB
000000r 1               nums_2		= nums_1+1	; number to bin/hex string convert
000000r 1               nums_3		= nums_1+2	; number to bin/hex string convert LSB
000000r 1               
000000r 1               Srchc			= $5B		; search character
000000r 1               Temp3			= Srchc	; temp byte used in number routines
000000r 1               Scnquo		= $5C		; scan-between-quotes flag
000000r 1               Asrch			= Scnquo	; alt search character
000000r 1               
000000r 1               XOAw_l		= Srchc	; eXclusive OR, OR and AND word low byte
000000r 1               XOAw_h		= Scnquo	; eXclusive OR, OR and AND word high byte
000000r 1               
000000r 1               Ibptr			= $5D		; input buffer pointer
000000r 1               Dimcnt		= Ibptr	; # of dimensions
000000r 1               Tindx			= Ibptr	; token index
000000r 1               
000000r 1               Defdim		= $5E		; default DIM flag
000000r 1               Dtypef		= $5F		; data type flag, $FF=string, $00=numeric
000000r 1               Oquote		= $60		; open quote flag (b7) (Flag: DATA scan; LIST quote; memory)
000000r 1               Gclctd		= $60		; garbage collected flag
000000r 1               Sufnxf		= $61		; subscript/FNX flag, 1xxx xxx = FN(0xxx xxx)
000000r 1               Imode			= $62		; input mode flag, $00=INPUT, $80=READ
000000r 1               
000000r 1               Cflag			= $63		; comparison evaluation flag
000000r 1               
000000r 1               TabSiz		= $64		; TAB step size (was input flag)
000000r 1               
000000r 1               next_s		= $65		; next descriptor stack address
000000r 1               
000000r 1               					; these two bytes form a word pointer to the item
000000r 1               					; currently on top of the descriptor stack
000000r 1               last_sl		= $66		; last descriptor stack address low byte
000000r 1               last_sh		= $67		; last descriptor stack address high byte (always $00)
000000r 1               
000000r 1               des_sk		= $68		; descriptor stack start address (temp strings)
000000r 1               
000000r 1               ;			= $70		; End of descriptor stack
000000r 1               
000000r 1               ut1_pl		= $71		; utility pointer 1 low byte
000000r 1               ut1_ph		= ut1_pl+1	; utility pointer 1 high byte
000000r 1               ut2_pl		= $73		; utility pointer 2 low byte
000000r 1               ut2_ph		= ut2_pl+1	; utility pointer 2 high byte
000000r 1               
000000r 1               Temp_2		= ut1_pl	; temp byte for block move
000000r 1               
000000r 1               FACt_1		= $75		; FAC temp mantissa1
000000r 1               FACt_2		= FACt_1+1	; FAC temp mantissa2
000000r 1               FACt_3		= FACt_2+1	; FAC temp mantissa3
000000r 1               
000000r 1               dims_l		= FACt_2	; array dimension size low byte
000000r 1               dims_h		= FACt_3	; array dimension size high byte
000000r 1               
000000r 1               TempB			= $78		; temp page 0 byte
000000r 1               
000000r 1               Smeml			= $79		; start of mem low byte		(Start-of-Basic)
000000r 1               Smemh			= Smeml+1	; start of mem high byte	(Start-of-Basic)
000000r 1               Svarl			= $7B		; start of vars low byte	(Start-of-Variables)
000000r 1               Svarh			= Svarl+1	; start of vars high byte	(Start-of-Variables)
000000r 1               Sarryl		= $7D		; var mem end low byte		(Start-of-Arrays)
000000r 1               Sarryh		= Sarryl+1	; var mem end high byte		(Start-of-Arrays)
000000r 1               Earryl		= $7F		; array mem end low byte	(End-of-Arrays)
000000r 1               Earryh		= Earryl+1	; array mem end high byte	(End-of-Arrays)
000000r 1               Sstorl		= $81		; string storage low byte	(String storage (moving down))
000000r 1               Sstorh		= Sstorl+1	; string storage high byte	(String storage (moving down))
000000r 1               Sutill		= $83		; string utility ptr low byte
000000r 1               Sutilh		= Sutill+1	; string utility ptr high byte
000000r 1               Ememl			= $85		; end of mem low byte		(Limit-of-memory)
000000r 1               Ememh			= Ememl+1	; end of mem high byte		(Limit-of-memory)
000000r 1               Clinel		= $87		; current line low byte		(Basic line number)
000000r 1               Clineh		= Clinel+1	; current line high byte	(Basic line number)
000000r 1               Blinel		= $89		; break line low byte		(Previous Basic line number)
000000r 1               Blineh		= Blinel+1	; break line high byte		(Previous Basic line number)
000000r 1               
000000r 1               Cpntrl		= $8B		; continue pointer low byte
000000r 1               Cpntrh		= Cpntrl+1	; continue pointer high byte
000000r 1               
000000r 1               Dlinel		= $8D		; current DATA line low byte
000000r 1               Dlineh		= Dlinel+1	; current DATA line high byte
000000r 1               
000000r 1               Dptrl			= $8F		; DATA pointer low byte
000000r 1               Dptrh			= Dptrl+1	; DATA pointer high byte
000000r 1               
000000r 1               Rdptrl		= $91		; read pointer low byte
000000r 1               Rdptrh		= Rdptrl+1	; read pointer high byte
000000r 1               
000000r 1               Varnm1		= $93		; current var name 1st byte
000000r 1               Varnm2		= Varnm1+1	; current var name 2nd byte
000000r 1               
000000r 1               Cvaral		= $95		; current var address low byte
000000r 1               Cvarah		= Cvaral+1	; current var address high byte
000000r 1               
000000r 1               Frnxtl		= $97		; var pointer for FOR/NEXT low byte
000000r 1               Frnxth		= Frnxtl+1	; var pointer for FOR/NEXT high byte
000000r 1               
000000r 1               Tidx1			= Frnxtl	; temp line index
000000r 1               
000000r 1               Lvarpl		= Frnxtl	; let var pointer low byte
000000r 1               Lvarph		= Frnxth	; let var pointer high byte
000000r 1               
000000r 1               prstk			= $99		; precedence stacked flag
000000r 1               
000000r 1               comp_f		= $9B		; compare function flag, bits 0,1 and 2 used
000000r 1               					; bit 2 set if >
000000r 1               					; bit 1 set if =
000000r 1               					; bit 0 set if <
000000r 1               
000000r 1               func_l		= $9C		; function pointer low byte
000000r 1               func_h		= func_l+1	; function pointer high byte
000000r 1               
000000r 1               garb_l		= func_l	; garbage collection working pointer low byte
000000r 1               garb_h		= func_h	; garbage collection working pointer high byte
000000r 1               
000000r 1               des_2l		= $9E		; string descriptor_2 pointer low byte
000000r 1               des_2h		= des_2l+1	; string descriptor_2 pointer high byte
000000r 1               
000000r 1               g_step		= $A0		; garbage collect step size
000000r 1               
000000r 1               Fnxjmp		= $A1		; jump vector for functions
000000r 1               Fnxjpl		= Fnxjmp+1	; functions jump vector low byte
000000r 1               Fnxjph		= Fnxjmp+2	; functions jump vector high byte
000000r 1               
000000r 1               g_indx		= Fnxjpl	; garbage collect temp index
000000r 1               
000000r 1               FAC2_r		= $A3		; FAC2 rounding byte
000000r 1               
000000r 1               Adatal		= $A4		; array data pointer low byte
000000r 1               Adatah		= Adatal+1	; array data pointer high  byte
000000r 1               
000000r 1               Nbendl		= Adatal	; new block end pointer low byte
000000r 1               Nbendh		= Adatah	; new block end pointer high  byte
000000r 1               
000000r 1               Obendl		= $A6		; old block end pointer low byte
000000r 1               Obendh		= Obendl+1	; old block end pointer high  byte
000000r 1               
000000r 1               numexp		= $A8		; string to float number exponent count
000000r 1               expcnt		= $A9		; string to float exponent count
000000r 1               
000000r 1               numbit		= numexp	; bit count for array element calculations
000000r 1               
000000r 1               numdpf		= $AA		; string to float decimal point flag
000000r 1               expneg		= $AB		; string to float eval exponent -ve flag
000000r 1               
000000r 1               Astrtl		= numdpf	; array start pointer low byte
000000r 1               Astrth		= expneg	; array start pointer high  byte
000000r 1               
000000r 1               Histrl		= numdpf	; highest string low byte
000000r 1               Histrh		= expneg	; highest string high  byte
000000r 1               
000000r 1               Baslnl		= numdpf	; BASIC search line pointer low byte
000000r 1               Baslnh		= expneg	; BASIC search line pointer high  byte
000000r 1               
000000r 1               Fvar_l		= numdpf	; find/found variable pointer low byte
000000r 1               Fvar_h		= expneg	; find/found variable pointer high  byte
000000r 1               
000000r 1               Ostrtl		= numdpf	; old block start pointer low byte
000000r 1               Ostrth		= expneg	; old block start pointer high  byte
000000r 1               
000000r 1               Vrschl		= numdpf	; variable search pointer low byte
000000r 1               Vrschh		= expneg	; variable search pointer high  byte
000000r 1               
000000r 1               FAC1_e		= $AC		; FAC1 exponent
000000r 1               FAC1_1		= FAC1_e+1	; FAC1 mantissa1
000000r 1               FAC1_2		= FAC1_e+2	; FAC1 mantissa2
000000r 1               FAC1_3		= FAC1_e+3	; FAC1 mantissa3
000000r 1               FAC1_s		= FAC1_e+4	; FAC1 sign (b7)
000000r 1               
000000r 1               str_ln		= FAC1_e	; string length
000000r 1               str_pl		= FAC1_1	; string pointer low byte
000000r 1               str_ph		= FAC1_2	; string pointer high byte
000000r 1               
000000r 1               des_pl		= FAC1_2	; string descriptor pointer low byte
000000r 1               des_ph		= FAC1_3	; string descriptor pointer high byte
000000r 1               
000000r 1               mids_l		= FAC1_3	; MID$ string temp length byte
000000r 1               
000000r 1               negnum		= $B1		; string to float eval -ve flag
000000r 1               numcon		= $B1		; series evaluation constant count
000000r 1               
000000r 1               FAC1_o		= $B2		; FAC1 overflow byte
000000r 1               
000000r 1               FAC2_e		= $B3		; FAC2 exponent
000000r 1               FAC2_1		= FAC2_e+1	; FAC2 mantissa1
000000r 1               FAC2_2		= FAC2_e+2	; FAC2 mantissa2
000000r 1               FAC2_3		= FAC2_e+3	; FAC2 mantissa3
000000r 1               FAC2_s		= FAC2_e+4	; FAC2 sign (b7)
000000r 1               
000000r 1               FAC_sc		= $B8		; FAC sign comparison, Acc#1 vs #2
000000r 1               FAC1_r		= $B9		; FAC1 rounding byte
000000r 1               
000000r 1               ssptr_l		= FAC_sc	; string start pointer low byte
000000r 1               ssptr_h		= FAC1_r	; string start pointer high byte
000000r 1               
000000r 1               sdescr		= FAC_sc	; string descriptor pointer
000000r 1               
000000r 1               csidx			= $BA		; line crunch save index
000000r 1               Asptl			= csidx	; array size/pointer low byte
000000r 1               Aspth			= $BB		; array size/pointer high byte
000000r 1               
000000r 1               Btmpl			= Asptl	; BASIC pointer temp low byte
000000r 1               Btmph			= Aspth	; BASIC pointer temp low byte
000000r 1               
000000r 1               Cptrl			= Asptl	; BASIC pointer temp low byte
000000r 1               Cptrh			= Aspth	; BASIC pointer temp low byte
000000r 1               
000000r 1               Sendl			= Asptl	; BASIC pointer temp low byte
000000r 1               Sendh			= Aspth	; BASIC pointer temp low byte
000000r 1               
000000r 1               LAB_IGBY		= $BC		; get next BASIC byte subroutine
000000r 1               
000000r 1               LAB_GBYT		= $C2		; get current BASIC byte subroutine
000000r 1               Bpntrl		= $C3		; BASIC execute (get byte) pointer low byte
000000r 1               Bpntrh		= Bpntrl+1	; BASIC execute (get byte) pointer high byte
000000r 1               
000000r 1               ;			= $D7		; end of get BASIC char subroutine
000000r 1               
000000r 1               Rbyte4		= $D8		; extra PRNG byte
000000r 1               Rbyte1		= Rbyte4+1	; most significant PRNG byte
000000r 1               Rbyte2		= Rbyte4+2	; middle PRNG byte
000000r 1               Rbyte3		= Rbyte4+3	; least significant PRNG byte
000000r 1               
000000r 1               NmiBase		= $DC		; NMI handler enabled/setup/triggered flags
000000r 1               					; bit	function
000000r 1               					; ===	========
000000r 1               					; 7	interrupt enabled
000000r 1               					; 6	interrupt setup
000000r 1               					; 5	interrupt happened
000000r 1               ;			= $DD		; NMI handler addr low byte
000000r 1               ;			= $DE		; NMI handler addr high byte
000000r 1               IrqBase		= $DF		; IRQ handler enabled/setup/triggered flags
000000r 1               ;			= $E0		; IRQ handler addr low byte
000000r 1               ;			= $E1		; IRQ handler addr high byte
000000r 1               
000000r 1               ;			= $DE		; unused
000000r 1               ;			= $DF		; unused
000000r 1               ;			= $E0		; unused
000000r 1               ;			= $E1		; unused
000000r 1               ;			= $E2		; unused
000000r 1               ;			= $E3		; unused
000000r 1               ;			= $E4		; unused
000000r 1               ;			= $E5		; unused
000000r 1               ;			= $E6		; unused
000000r 1               ;			= $E7		; unused
000000r 1               ;			= $E8		; unused
000000r 1               ;			= $E9		; unused
000000r 1               ;			= $EA		; unused
000000r 1               ;			= $EB		; unused
000000r 1               ;			= $EC		; unused
000000r 1               ;			= $ED		; unused
000000r 1               ;			= $EE		; unused
000000r 1               
000000r 1               Decss			= $EF		; number to decimal string start
000000r 1               Decssp1		= Decss+1	; number to decimal string start
000000r 1               
000000r 1               ;			= $FF		; decimal string end
000000r 1               
000000r 1               ; token values needed for BASIC
000000r 1               
000000r 1               ; primary command tokens (can start a statement)
000000r 1               
000000r 1               TK_END		= $80			; END token
000000r 1               TK_FOR		= TK_END+1		; FOR token
000000r 1               TK_NEXT		= TK_FOR+1		; NEXT token
000000r 1               TK_DATA		= TK_NEXT+1		; DATA token
000000r 1               TK_INPUT		= TK_DATA+1		; INPUT token
000000r 1               TK_DIM		= TK_INPUT+1	; DIM token
000000r 1               TK_READ		= TK_DIM+1		; READ token
000000r 1               TK_LET		= TK_READ+1		; LET token
000000r 1               TK_DEC		= TK_LET+1		; DEC token
000000r 1               TK_GOTO		= TK_DEC+1		; GOTO token
000000r 1               TK_RUN		= TK_GOTO+1		; RUN token
000000r 1               TK_IF			= TK_RUN+1		; IF token
000000r 1               TK_RESTORE		= TK_IF+1		; RESTORE token
000000r 1               TK_GOSUB		= TK_RESTORE+1	; GOSUB token
000000r 1               TK_RETIRQ		= TK_GOSUB+1	; RETIRQ token
000000r 1               TK_RETNMI		= TK_RETIRQ+1	; RETNMI token
000000r 1               TK_RETURN		= TK_RETNMI+1	; RETURN token
000000r 1               TK_REM		= TK_RETURN+1	; REM token
000000r 1               TK_STOP		= TK_REM+1		; STOP token
000000r 1               TK_ON			= TK_STOP+1		; ON token
000000r 1               TK_NULL		= TK_ON+1		; NULL token
000000r 1               TK_INC		= TK_NULL+1		; INC token
000000r 1               TK_WAIT		= TK_INC+1		; WAIT token
000000r 1               TK_LOAD		= TK_WAIT+1		; LOAD token
000000r 1               TK_SAVE		= TK_LOAD+1		; SAVE token
000000r 1               TK_DEF		= TK_SAVE+1		; DEF token
000000r 1               TK_POKE		= TK_DEF+1		; POKE token
000000r 1               TK_DOKE		= TK_POKE+1		; DOKE token
000000r 1               TK_CALL		= TK_DOKE+1		; CALL token
000000r 1               TK_DO			= TK_CALL+1		; DO token
000000r 1               TK_LOOP		= TK_DO+1		; LOOP token
000000r 1               TK_PRINT		= TK_LOOP+1		; PRINT token
000000r 1               TK_CONT		= TK_PRINT+1	; CONT token
000000r 1               TK_LIST		= TK_CONT+1		; LIST token
000000r 1               TK_CLEAR		= TK_LIST+1		; CLEAR token
000000r 1               TK_NEW		= TK_CLEAR+1	; NEW token
000000r 1               TK_WIDTH		= TK_NEW+1		; WIDTH token
000000r 1               TK_GET		= TK_WIDTH+1	; GET token
000000r 1               TK_SWAP		= TK_GET+1		; SWAP token
000000r 1               TK_BITSET		= TK_SWAP+1		; BITSET token
000000r 1               TK_BITCLR		= TK_BITSET+1	; BITCLR token
000000r 1               TK_IRQ		= TK_BITCLR+1	; IRQ token
000000r 1               TK_NMI		= TK_IRQ+1		; NMI token
000000r 1               TK_SYS          = TK_NMI+1              ; SYS token *** added for SBC-2
000000r 1               
000000r 1               ; secondary command tokens, can't start a statement
000000r 1               
000000r 1               TK_TAB		= TK_SYS+1		; TAB token
000000r 1               TK_ELSE		= TK_TAB+1		; ELSE token
000000r 1               TK_TO			= TK_ELSE+1		; TO token
000000r 1               TK_FN			= TK_TO+1		; FN token
000000r 1               TK_SPC		= TK_FN+1		; SPC token
000000r 1               TK_THEN		= TK_SPC+1		; THEN token
000000r 1               TK_NOT		= TK_THEN+1		; NOT token
000000r 1               TK_STEP		= TK_NOT+1		; STEP token
000000r 1               TK_UNTIL		= TK_STEP+1		; UNTIL token
000000r 1               TK_WHILE		= TK_UNTIL+1	; WHILE token
000000r 1               TK_OFF		= TK_WHILE+1	; OFF token
000000r 1               
000000r 1               ; opperator tokens
000000r 1               
000000r 1               TK_PLUS		= TK_OFF+1		; + token
000000r 1               TK_MINUS		= TK_PLUS+1		; - token
000000r 1               TK_MUL		= TK_MINUS+1	; * token
000000r 1               TK_DIV		= TK_MUL+1		; / token
000000r 1               TK_POWER		= TK_DIV+1		; ^ token
000000r 1               TK_AND		= TK_POWER+1	; AND token
000000r 1               TK_EOR		= TK_AND+1		; EOR token
000000r 1               TK_OR			= TK_EOR+1		; OR token
000000r 1               TK_RSHIFT		= TK_OR+1		; RSHIFT token
000000r 1               TK_LSHIFT		= TK_RSHIFT+1	; LSHIFT token
000000r 1               TK_GT			= TK_LSHIFT+1	; > token
000000r 1               TK_EQUAL		= TK_GT+1		; = token
000000r 1               TK_LT			= TK_EQUAL+1	; < token
000000r 1               
000000r 1               ; functions tokens
000000r 1               
000000r 1               TK_SGN		= TK_LT+1		; SGN token
000000r 1               TK_INT		= TK_SGN+1		; INT token
000000r 1               TK_ABS		= TK_INT+1		; ABS token
000000r 1               TK_USR		= TK_ABS+1		; USR token
000000r 1               TK_FRE		= TK_USR+1		; FRE token
000000r 1               TK_POS		= TK_FRE+1		; POS token
000000r 1               TK_SQR		= TK_POS+1		; SQR token
000000r 1               TK_RND		= TK_SQR+1		; RND token
000000r 1               TK_LOG		= TK_RND+1		; LOG token
000000r 1               TK_EXP		= TK_LOG+1		; EXP token
000000r 1               TK_COS		= TK_EXP+1		; COS token
000000r 1               TK_SIN		= TK_COS+1		; SIN token
000000r 1               TK_TAN		= TK_SIN+1		; TAN token
000000r 1               TK_ATN		= TK_TAN+1		; ATN token
000000r 1               TK_PEEK		= TK_ATN+1		; PEEK token
000000r 1               TK_DEEK		= TK_PEEK+1		; DEEK token
000000r 1               TK_SADD		= TK_DEEK+1		; SADD token
000000r 1               TK_LEN		= TK_SADD+1		; LEN token
000000r 1               TK_STRS		= TK_LEN+1		; STR$ token
000000r 1               TK_VAL		= TK_STRS+1		; VAL token
000000r 1               TK_ASC		= TK_VAL+1		; ASC token
000000r 1               TK_UCASES		= TK_ASC+1		; UCASE$ token
000000r 1               TK_LCASES		= TK_UCASES+1	; LCASE$ token
000000r 1               TK_CHRS		= TK_LCASES+1	; CHR$ token
000000r 1               TK_HEXS		= TK_CHRS+1		; HEX$ token
000000r 1               TK_BINS		= TK_HEXS+1		; BIN$ token
000000r 1               TK_BITTST		= TK_BINS+1		; BITTST token
000000r 1               TK_MAX		= TK_BITTST+1	; MAX token
000000r 1               TK_MIN		= TK_MAX+1		; MIN token
000000r 1               TK_PI			= TK_MIN+1		; PI token
000000r 1               TK_TWOPI		= TK_PI+1		; TWOPI token
000000r 1               TK_VPTR		= TK_TWOPI+1	; VARPTR token
000000r 1               TK_LEFTS		= TK_VPTR+1		; LEFT$ token
000000r 1               TK_RIGHTS		= TK_LEFTS+1	; RIGHT$ token
000000r 1               TK_MIDS		= TK_RIGHTS+1	; MID$ token
000000r 1               
000000r 1               ; offsets from a base of X or Y
000000r 1               
000000r 1               PLUS_0		= $00		; X or Y plus 0
000000r 1               PLUS_1		= $01		; X or Y plus 1
000000r 1               PLUS_2		= $02		; X or Y plus 2
000000r 1               PLUS_3		= $03		; X or Y plus 3
000000r 1               
000000r 1               LAB_STAK		= $0100	; stack bottom, no offset
000000r 1               
000000r 1               LAB_SKFE		= LAB_STAK+$FE
000000r 1               					; flushed stack address
000000r 1               LAB_SKFF		= LAB_STAK+$FF
000000r 1               					; flushed stack address
000000r 1               
000000r 1               ccflag		= $0200	; BASIC CTRL-C flag, 00 = enabled, 01 = dis
000000r 1               ccbyte		= ccflag+1	; BASIC CTRL-C byte
000000r 1               ccnull		= ccbyte+1	; BASIC CTRL-C byte timeout
000000r 1               
000000r 1               VEC_CC		= ccnull+1	; ctrl c check vector
000000r 1               
000000r 1               VEC_IN		= VEC_CC+2	; input vector
000000r 1               VEC_OUT		= VEC_IN+2	; output vector
000000r 1               VEC_LD		= VEC_OUT+2	; load vector
000000r 1               VEC_SV		= VEC_LD+2	; save vector
000000r 1               
000000r 1               ; Ibuffs can now be anywhere in RAM, ensure that the max length is < $80
000000r 1               
000000r 1               Ibuffs		= VEC_SV+2      ; ***changed for SBC-2
000000r 1               					; start of input buffer after IRQ/NMI code
000000r 1               Ibuffe		= Ibuffs+$47; end of input buffer
000000r 1               
000000r 1               Ram_base		= $0400	; start of user RAM (set as needed, should be page aligned)
000000r 1               Ram_top		= $8000	; end of user RAM+1 (set as needed, should be page aligned)
000000r 1               
000000r 1               ; This start can be changed to suit your system
000000r 1               
000000r 1               	;*=	$BC00
000000r 1                   .code
000000r 1               ; BASIC cold start entry point
000000r 1               
000000r 1               ; new page 2 initialisation, copy block to ccflag on
000000r 1               
000000r 1               LAB_COLD
000000r 1  A0 04        	LDY	#PG2_TABE-PG2_TABS-1
000002r 1               					; byte count-1
000002r 1               LAB_2D13
000002r 1  B9 rr rr     	LDA	PG2_TABS,Y		; get byte
000005r 1  99 00 02     	STA	ccflag,Y		; store in page 2
000008r 1  88           	DEY				; decrement count
000009r 1  10 F7        	BPL	LAB_2D13		; loop if not done
00000Br 1               
00000Br 1  A2 FF        	LDX	#$FF			; set byte
00000Dr 1  86 88        	STX	Clineh		; set current line high byte (set immediate mode)
00000Fr 1  9A           	TXS				; reset stack pointer
000010r 1               
000010r 1  A9 4C        	LDA	#$4C			; code for JMP
000012r 1  85 A1        	STA	Fnxjmp		; save for jump vector for functions
000014r 1               
000014r 1               ; copy block from LAB_2CEE to $00BC - $00D3
000014r 1               
000014r 1  A2 1C        	LDX	#StrTab-LAB_2CEE	; set byte count
000016r 1               LAB_2D4E
000016r 1  BD rr rr     	LDA	LAB_2CEE-1,X	; get byte from table
000019r 1  95 BB        	STA	LAB_IGBY-1,X	; save byte in page zero
00001Br 1  CA           	DEX				; decrement count
00001Cr 1  D0 F8        	BNE	LAB_2D4E		; loop if not all done
00001Er 1               
00001Er 1               ; copy block from StrTab to $0000 - $0012
00001Er 1               
00001Er 1               LAB_GMEM
00001Er 1  A2 12        	LDX	#EndTab-StrTab-1	; set byte count-1
000020r 1               TabLoop
000020r 1  BD rr rr     	LDA	StrTab,X		; get byte from table
000023r 1  95 00        	STA	PLUS_0,X		; save byte in page zero
000025r 1  CA           	DEX				; decrement count
000026r 1  10 F8        	BPL	TabLoop		; loop if not all done
000028r 1               
000028r 1               ; set-up start values
000028r 1               
000028r 1  A9 00        	LDA	#$00			; clear A
00002Ar 1  85 DC        	STA	NmiBase		; clear NMI handler enabled flag
00002Cr 1  85 DF        	STA	IrqBase		; clear IRQ handler enabled flag
00002Er 1  85 B2        	STA	FAC1_o		; clear FAC1 overflow byte
000030r 1  85 67        	STA	last_sh		; clear descriptor stack top item pointer high byte
000032r 1               
000032r 1  A9 0E        	LDA	#$0E			; set default tab size
000034r 1  85 64        	STA	TabSiz		; save it
000036r 1  A9 03        	LDA	#$03			; set garbage collect step size for descriptor stack
000038r 1  85 A0        	STA	g_step		; save it
00003Ar 1  A2 68        	LDX	#des_sk		; descriptor stack start
00003Cr 1  86 65        	STX	next_s		; set descriptor stack pointer
00003Er 1  20 rr rr     	JSR	LAB_CRLF		; print CR/LF
000041r 1  A9 rr        	LDA	#<LAB_MSZM		; point to memory size message (low addr)
000043r 1  A0 rr        	LDY	#>LAB_MSZM		; point to memory size message (high addr)
000045r 1  20 rr rr     	JSR	LAB_18C3		; print null terminated string from memory
000048r 1  20 rr rr     	JSR	LAB_INLN		; print "? " and get BASIC input
00004Br 1  86 C3        	STX	Bpntrl		; set BASIC execute pointer low byte
00004Dr 1  84 C4        	STY	Bpntrh		; set BASIC execute pointer high byte
00004Fr 1  20 C2 00     	JSR	LAB_GBYT		; get last byte back
000052r 1               
000052r 1  D0 1F        	BNE	LAB_2DAA		; branch if not null (user typed something)
000054r 1               
000054r 1  A0 00        	LDY	#$00			; else clear Y
000056r 1               					; character was null so get memory size the hard way
000056r 1               					; we get here with Y=0 and Itempl/h = Ram_base
000056r 1               LAB_2D93
000056r 1  E6 11        	INC	Itempl		; increment temporary integer low byte
000058r 1  D0 08        	BNE	LAB_2D99		; branch if no overflow
00005Ar 1               
00005Ar 1  E6 12        	INC	Itemph		; increment temporary integer high byte
00005Cr 1  A5 12        	LDA	Itemph		; get high byte
00005Er 1  C9 80        	CMP	#>Ram_top		; compare with top of RAM+1
000060r 1  F0 1D        	BEQ	LAB_2DB6		; branch if match (end of user RAM)
000062r 1               
000062r 1               LAB_2D99
000062r 1  A9 55        	LDA	#$55			; set test byte
000064r 1  91 11        	STA	(Itempl),Y		; save via temporary integer
000066r 1  D1 11        	CMP	(Itempl),Y		; compare via temporary integer
000068r 1  D0 15        	BNE	LAB_2DB6		; branch if fail
00006Ar 1               
00006Ar 1  0A           	ASL				; shift test byte left (now $AA)
00006Br 1  91 11        	STA	(Itempl),Y		; save via temporary integer
00006Dr 1  D1 11        	CMP	(Itempl),Y		; compare via temporary integer
00006Fr 1  F0 E5        	BEQ	LAB_2D93		; if ok go do next byte
000071r 1               
000071r 1  D0 0C        	BNE	LAB_2DB6		; branch if fail
000073r 1               
000073r 1               LAB_2DAA
000073r 1  20 rr rr     	JSR	LAB_2887		; get FAC1 from string
000076r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
000078r 1  C9 98        	CMP	#$98			; compare with exponent = 2^24
00007Ar 1  B0 A2        	BCS	LAB_GMEM		; if too large go try again
00007Cr 1               
00007Cr 1  20 rr rr     	JSR	LAB_F2FU		; save integer part of FAC1 in temporary integer
00007Fr 1               					; (no range check)
00007Fr 1               
00007Fr 1               LAB_2DB6
00007Fr 1  A5 11        	LDA	Itempl		; get temporary integer low byte
000081r 1  A4 12        	LDY	Itemph		; get temporary integer high byte
000083r 1  C0 01        	CPY	#<Ram_base+1	; compare with start of RAM+$100 high byte
000085r 1  90 97        	BCC	LAB_GMEM		; if too small go try again
000087r 1               
000087r 1               
000087r 1               ; uncomment these lines if you want to check on the high limit of memory. Note if
000087r 1               ; Ram_top is set too low then this will fail. default is ignore it and assume the
000087r 1               ; users know what they"re doing!
000087r 1               
000087r 1               ;	CPY	#>Ram_top		; compare with top of RAM high byte
000087r 1               ;	BCC	MEM_OK		; branch if < RAM top
000087r 1               
000087r 1               ;	BNE	LAB_GMEM		; if too large go try again
000087r 1               					; else was = so compare low bytes
000087r 1               ;	CMP	#<Ram_top		; compare with top of RAM low byte
000087r 1               ;	BEQ	MEM_OK		; branch if = RAM top
000087r 1               
000087r 1               ;	BCS	LAB_GMEM		; if too large go try again
000087r 1               
000087r 1               ;MEM_OK
000087r 1  85 85        	STA	Ememl			; set end of mem low byte
000089r 1  84 86        	STY	Ememh			; set end of mem high byte
00008Br 1  85 81        	STA	Sstorl		; set bottom of string space low byte
00008Dr 1  84 82        	STY	Sstorh		; set bottom of string space high byte
00008Fr 1               
00008Fr 1  A0 00        	LDY	#<Ram_base		; set start addr low byte
000091r 1  A2 04        	LDX	#>Ram_base		; set start addr high byte
000093r 1  84 79        	STY	Smeml			; save start of mem low byte
000095r 1  86 7A        	STX	Smemh			; save start of mem high byte
000097r 1               
000097r 1               ; this line is only needed if Ram_base is not $xx00
000097r 1               
000097r 1               ;	LDY	#$00			; clear Y
000097r 1  98           	TYA				; clear A
000098r 1  91 79        	STA	(Smeml),Y		; clear first byte
00009Ar 1  E6 79        	INC	Smeml			; increment start of mem low byte
00009Cr 1               
00009Cr 1               ; these two lines are only needed if Ram_base is $xxFF
00009Cr 1               
00009Cr 1               ;	BNE	LAB_2E05		; branch if no rollover
00009Cr 1               
00009Cr 1               ;	INC	Smemh			; increment start of mem high byte
00009Cr 1               LAB_2E05
00009Cr 1  20 rr rr     	JSR	LAB_CRLF		; print CR/LF
00009Fr 1  20 rr rr     	JSR	LAB_1463		; do "NEW" and "CLEAR"
0000A2r 1  A5 85        	LDA	Ememl			; get end of mem low byte
0000A4r 1  38           	SEC				; set carry for subtract
0000A5r 1  E5 79        	SBC	Smeml			; subtract start of mem low byte
0000A7r 1  AA           	TAX				; copy to X
0000A8r 1  A5 86        	LDA	Ememh			; get end of mem high byte
0000AAr 1  E5 7A        	SBC	Smemh			; subtract start of mem high byte
0000ACr 1  20 rr rr     	JSR	LAB_295E		; print XA as unsigned integer (bytes free)
0000AFr 1  A9 rr        	LDA	#<LAB_SMSG		; point to sign-on message (low addr)
0000B1r 1  A0 rr        	LDY	#>LAB_SMSG		; point to sign-on message (high addr)
0000B3r 1  20 rr rr     	JSR	LAB_18C3		; print null terminated string from memory
0000B6r 1  A9 rr        	LDA	#<LAB_1274		; warm start vector low byte
0000B8r 1  A0 rr        	LDY	#>LAB_1274		; warm start vector high byte
0000BAr 1  85 01        	STA	Wrmjpl		; save warm start vector low byte
0000BCr 1  84 02        	STY	Wrmjph		; save warm start vector high byte
0000BEr 1  6C 01 00     	JMP	(Wrmjpl)		; go do warm start
0000C1r 1               
0000C1r 1               ; open up space in memory
0000C1r 1               ; move (Ostrtl)-(Obendl) to new block ending at (Nbendl)
0000C1r 1               
0000C1r 1               ; Nbendl,Nbendh - new block end address (A/Y)
0000C1r 1               ; Obendl,Obendh - old block end address
0000C1r 1               ; Ostrtl,Ostrth - old block start address
0000C1r 1               
0000C1r 1               ; returns with ..
0000C1r 1               
0000C1r 1               ; Nbendl,Nbendh - new block start address (high byte - $100)
0000C1r 1               ; Obendl,Obendh - old block start address (high byte - $100)
0000C1r 1               ; Ostrtl,Ostrth - old block start address (unchanged)
0000C1r 1               
0000C1r 1               LAB_11CF
0000C1r 1  20 rr rr     	JSR	LAB_121F		; check available memory, "Out of memory" error if no room
0000C4r 1               					; addr to check is in AY (low/high)
0000C4r 1  85 7F        	STA	Earryl		; save new array mem end low byte
0000C6r 1  84 80        	STY	Earryh		; save new array mem end high byte
0000C8r 1               
0000C8r 1               ; open up space in memory
0000C8r 1               ; move (Ostrtl)-(Obendl) to new block ending at (Nbendl)
0000C8r 1               ; don't set array end
0000C8r 1               
0000C8r 1               LAB_11D6
0000C8r 1  38           	SEC				; set carry for subtract
0000C9r 1  A5 A6        	LDA	Obendl		; get block end low byte
0000CBr 1  E5 AA        	SBC	Ostrtl		; subtract block start low byte
0000CDr 1  A8           	TAY				; copy MOD(block length/$100) byte to Y
0000CEr 1  A5 A7        	LDA	Obendh		; get block end high byte
0000D0r 1  E5 AB        	SBC	Ostrth		; subtract block start high byte
0000D2r 1  AA           	TAX				; copy block length high byte to X
0000D3r 1  E8           	INX				; +1 to allow for count=0 exit
0000D4r 1  98           	TYA				; copy block length low byte to A
0000D5r 1  F0 24        	BEQ	LAB_120A		; branch if length low byte=0
0000D7r 1               
0000D7r 1               					; block is (X-1)*256+Y bytes, do the Y bytes first
0000D7r 1               
0000D7r 1  38           	SEC				; set carry for add + 1, two's complement
0000D8r 1  49 FF        	EOR	#$FF			; invert low byte for subtract
0000DAr 1  65 A6        	ADC	Obendl		; add block end low byte
0000DCr 1               
0000DCr 1  85 A6        	STA	Obendl		; save corrected old block end low byte
0000DEr 1  B0 03        	BCS	LAB_11F3		; branch if no underflow
0000E0r 1               
0000E0r 1  C6 A7        	DEC	Obendh		; else decrement block end high byte
0000E2r 1  38           	SEC				; set carry for add + 1, two's complement
0000E3r 1               LAB_11F3
0000E3r 1  98           	TYA				; get MOD(block length/$100) byte
0000E4r 1  49 FF        	EOR	#$FF			; invert low byte for subtract
0000E6r 1  65 A4        	ADC	Nbendl		; add destination end low byte
0000E8r 1  85 A4        	STA	Nbendl		; save modified new block end low byte
0000EAr 1  B0 08        	BCS	LAB_1203		; branch if no underflow
0000ECr 1               
0000ECr 1  C6 A5        	DEC	Nbendh		; else decrement block end high byte
0000EEr 1  90 04        	BCC	LAB_1203		; branch always
0000F0r 1               
0000F0r 1               LAB_11FF
0000F0r 1  B1 A6        	LDA	(Obendl),Y		; get byte from source
0000F2r 1  91 A4        	STA	(Nbendl),Y		; copy byte to destination
0000F4r 1               LAB_1203
0000F4r 1  88           	DEY				; decrement index
0000F5r 1  D0 F9        	BNE	LAB_11FF		; loop until Y=0
0000F7r 1               
0000F7r 1               					; now do Y=0 indexed byte
0000F7r 1  B1 A6        	LDA	(Obendl),Y		; get byte from source
0000F9r 1  91 A4        	STA	(Nbendl),Y		; save byte to destination
0000FBr 1               LAB_120A
0000FBr 1  C6 A7        	DEC	Obendh		; decrement source pointer high byte
0000FDr 1  C6 A5        	DEC	Nbendh		; decrement destination pointer high byte
0000FFr 1  CA           	DEX				; decrement block count
000100r 1  D0 F2        	BNE	LAB_1203		; loop until count = $0
000102r 1               
000102r 1  60           	RTS
000103r 1               
000103r 1               ; check room on stack for A bytes
000103r 1               ; stack too deep? do OM error
000103r 1               
000103r 1               LAB_1212
000103r 1  85 78        	STA	TempB			; save result in temp byte
000105r 1  BA           	TSX				; copy stack
000106r 1  E4 78        	CPX	TempB			; compare new "limit" with stack
000108r 1  90 30        	BCC	LAB_OMER		; if stack < limit do "Out of memory" error then warm start
00010Ar 1               
00010Ar 1  60           	RTS
00010Br 1               
00010Br 1               ; check available memory, "Out of memory" error if no room
00010Br 1               ; addr to check is in AY (low/high)
00010Br 1               
00010Br 1               LAB_121F
00010Br 1  C4 82        	CPY	Sstorh		; compare bottom of string mem high byte
00010Dr 1  90 2A        	BCC	LAB_124B		; if less then exit (is ok)
00010Fr 1               
00010Fr 1  D0 04        	BNE	LAB_1229		; skip next test if greater (tested <)
000111r 1               
000111r 1               					; high byte was =, now do low byte
000111r 1  C5 81        	CMP	Sstorl		; compare with bottom of string mem low byte
000113r 1  90 24        	BCC	LAB_124B		; if less then exit (is ok)
000115r 1               
000115r 1               					; addr is > string storage ptr (oops!)
000115r 1               LAB_1229
000115r 1  48           	PHA				; push addr low byte
000116r 1  A2 08        	LDX	#$08			; set index to save Adatal to expneg inclusive
000118r 1  98           	TYA				; copy addr high byte (to push on stack)
000119r 1               
000119r 1               					; save misc numeric work area
000119r 1               LAB_122D
000119r 1  48           	PHA				; push byte
00011Ar 1  B5 A3        	LDA	Adatal-1,X		; get byte from Adatal to expneg ( ,$00 not pushed)
00011Cr 1  CA           	DEX				; decrement index
00011Dr 1  10 FA        	BPL	LAB_122D		; loop until all done
00011Fr 1               
00011Fr 1  20 rr rr     	JSR	LAB_GARB		; garbage collection routine
000122r 1               
000122r 1               					; restore misc numeric work area
000122r 1  A2 00        	LDX	#$00			; clear the index to restore bytes
000124r 1               LAB_1238
000124r 1  68           	PLA				; pop byte
000125r 1  95 A4        	STA	Adatal,X		; save byte to Adatal to expneg
000127r 1  E8           	INX				; increment index
000128r 1  E0 08        	CPX	#$08			; compare with end + 1
00012Ar 1  30 F8        	BMI	LAB_1238		; loop if more to do
00012Cr 1               
00012Cr 1  68           	PLA				; pop addr high byte
00012Dr 1  A8           	TAY				; copy back to Y
00012Er 1  68           	PLA				; pop addr low byte
00012Fr 1  C4 82        	CPY	Sstorh		; compare bottom of string mem high byte
000131r 1  90 06        	BCC	LAB_124B		; if less then exit (is ok)
000133r 1               
000133r 1  D0 05        	BNE	LAB_OMER		; if greater do "Out of memory" error then warm start
000135r 1               
000135r 1               					; high byte was =, now do low byte
000135r 1  C5 81        	CMP	Sstorl		; compare with bottom of string mem low byte
000137r 1  B0 01        	BCS	LAB_OMER		; if >= do "Out of memory" error then warm start
000139r 1               
000139r 1               					; ok exit, carry clear
000139r 1               LAB_124B
000139r 1  60           	RTS
00013Ar 1               
00013Ar 1               ; do "Out of memory" error then warm start
00013Ar 1               
00013Ar 1               LAB_OMER
00013Ar 1  A2 0C        	LDX	#$0C			; error code $0C ("Out of memory" error)
00013Cr 1               
00013Cr 1               ; do error #X, then warm start
00013Cr 1               
00013Cr 1               LAB_XERR
00013Cr 1  20 rr rr     	JSR	LAB_CRLF		; print CR/LF
00013Fr 1               
00013Fr 1  BD rr rr     	LDA	LAB_BAER,X		; get error message pointer low byte
000142r 1  BC rr rr     	LDY	LAB_BAER+1,X	; get error message pointer high byte
000145r 1  20 rr rr     	JSR	LAB_18C3		; print null terminated string from memory
000148r 1               
000148r 1  20 rr rr     	JSR	LAB_1491		; flush stack and clear continue flag
00014Br 1  A9 rr        	LDA	#<LAB_EMSG		; point to " Error" low addr
00014Dr 1  A0 rr        	LDY	#>LAB_EMSG		; point to " Error" high addr
00014Fr 1               LAB_1269
00014Fr 1  20 rr rr     	JSR	LAB_18C3		; print null terminated string from memory
000152r 1  A4 88        	LDY	Clineh		; get current line high byte
000154r 1  C8           	INY				; increment it
000155r 1  F0 03        	BEQ	LAB_1274		; go do warm start (was immediate mode)
000157r 1               
000157r 1               					; else print line number
000157r 1  20 rr rr     	JSR	LAB_2953		; print " in line [LINE #]"
00015Ar 1               
00015Ar 1               ; BASIC warm start entry point
00015Ar 1               ; wait for Basic command
00015Ar 1               
00015Ar 1               LAB_1274
00015Ar 1               					; clear ON IRQ/NMI bytes
00015Ar 1  A9 00        	LDA	#$00			; clear A
00015Cr 1  85 DF        	STA	IrqBase		; clear enabled byte
00015Er 1  85 DC        	STA	NmiBase		; clear enabled byte
000160r 1  A9 rr        	LDA	#<LAB_RMSG		; point to "Ready" message low byte
000162r 1  A0 rr        	LDY	#>LAB_RMSG		; point to "Ready" message high byte
000164r 1               
000164r 1  20 rr rr     	JSR	LAB_18C3		; go do print string
000167r 1               
000167r 1               ; wait for Basic command (no "Ready")
000167r 1               
000167r 1               LAB_127D
000167r 1  20 rr rr     	JSR	LAB_1357		; call for BASIC input
00016Ar 1               LAB_1280
00016Ar 1  86 C3        	STX	Bpntrl		; set BASIC execute pointer low byte
00016Cr 1  84 C4        	STY	Bpntrh		; set BASIC execute pointer high byte
00016Er 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000171r 1  F0 F4        	BEQ	LAB_127D		; loop while null
000173r 1               
000173r 1               ; got to interpret input line now ..
000173r 1               
000173r 1  A2 FF        	LDX	#$FF			; current line to null value
000175r 1  86 88        	STX	Clineh		; set current line high byte
000177r 1  90 06        	BCC	LAB_1295		; branch if numeric character (handle new BASIC line)
000179r 1               
000179r 1               					; no line number .. immediate mode
000179r 1  20 rr rr     	JSR	LAB_13A6		; crunch keywords into Basic tokens
00017Cr 1  4C rr rr     	JMP	LAB_15F6		; go scan and interpret code
00017Fr 1               
00017Fr 1               ; handle new BASIC line
00017Fr 1               
00017Fr 1               LAB_1295
00017Fr 1  20 rr rr     	JSR	LAB_GFPN		; get fixed-point number into temp integer
000182r 1  20 rr rr     	JSR	LAB_13A6		; crunch keywords into Basic tokens
000185r 1  84 5D        	STY	Ibptr			; save index pointer to end of crunched line
000187r 1  20 rr rr     	JSR	LAB_SSLN		; search BASIC for temp integer line number
00018Ar 1  90 44        	BCC	LAB_12E6		; branch if not found
00018Cr 1               
00018Cr 1               					; aroooogah! line # already exists! delete it
00018Cr 1  A0 01        	LDY	#$01			; set index to next line pointer high byte
00018Er 1  B1 AA        	LDA	(Baslnl),Y		; get next line pointer high byte
000190r 1  85 72        	STA	ut1_ph		; save it
000192r 1  A5 7B        	LDA	Svarl			; get start of vars low byte
000194r 1  85 71        	STA	ut1_pl		; save it
000196r 1  A5 AB        	LDA	Baslnh		; get found line pointer high byte
000198r 1  85 74        	STA	ut2_ph		; save it
00019Ar 1  A5 AA        	LDA	Baslnl		; get found line pointer low byte
00019Cr 1  88           	DEY				; decrement index
00019Dr 1  F1 AA        	SBC	(Baslnl),Y		; subtract next line pointer low byte
00019Fr 1  18           	CLC				; clear carry for add
0001A0r 1  65 7B        	ADC	Svarl			; add start of vars low byte
0001A2r 1  85 7B        	STA	Svarl			; save new start of vars low byte
0001A4r 1  85 73        	STA	ut2_pl		; save destination pointer low byte
0001A6r 1  A5 7C        	LDA	Svarh			; get start of vars high byte
0001A8r 1  69 FF        	ADC	#$FF			; -1 + carry
0001AAr 1  85 7C        	STA	Svarh			; save start of vars high byte
0001ACr 1  E5 AB        	SBC	Baslnh		; subtract found line pointer high byte
0001AEr 1  AA           	TAX				; copy to block count
0001AFr 1  38           	SEC				; set carry for subtract
0001B0r 1  A5 AA        	LDA	Baslnl		; get found line pointer low byte
0001B2r 1  E5 7B        	SBC	Svarl			; subtract start of vars low byte
0001B4r 1  A8           	TAY				; copy to bytes in first block count
0001B5r 1  B0 03        	BCS	LAB_12D0		; branch if overflow
0001B7r 1               
0001B7r 1  E8           	INX				; increment block count (correct for =0 loop exit)
0001B8r 1  C6 74        	DEC	ut2_ph		; decrement destination high byte
0001BAr 1               LAB_12D0
0001BAr 1  18           	CLC				; clear carry for add
0001BBr 1  65 71        	ADC	ut1_pl		; add source pointer low byte
0001BDr 1  90 03        	BCC	LAB_12D8		; branch if no overflow
0001BFr 1               
0001BFr 1  C6 72        	DEC	ut1_ph		; else decrement source pointer high byte
0001C1r 1  18           	CLC				; clear carry
0001C2r 1               
0001C2r 1               					; close up memory to delete old line
0001C2r 1               LAB_12D8
0001C2r 1  B1 71        	LDA	(ut1_pl),Y		; get byte from source
0001C4r 1  91 73        	STA	(ut2_pl),Y		; copy to destination
0001C6r 1  C8           	INY				; increment index
0001C7r 1  D0 F9        	BNE	LAB_12D8		; while <> 0 do this block
0001C9r 1               
0001C9r 1  E6 72        	INC	ut1_ph		; increment source pointer high byte
0001CBr 1  E6 74        	INC	ut2_ph		; increment destination pointer high byte
0001CDr 1  CA           	DEX				; decrement block count
0001CEr 1  D0 F2        	BNE	LAB_12D8		; loop until all done
0001D0r 1               
0001D0r 1               					; got new line in buffer and no existing same #
0001D0r 1               LAB_12E6
0001D0r 1  AD 0D 02     	LDA	Ibuffs		; get byte from start of input buffer
0001D3r 1  F0 3F        	BEQ	LAB_1319		; if null line just go flush stack/vars and exit
0001D5r 1               
0001D5r 1               					; got new line and it isn't empty line
0001D5r 1  A5 85        	LDA	Ememl			; get end of mem low byte
0001D7r 1  A4 86        	LDY	Ememh			; get end of mem high byte
0001D9r 1  85 81        	STA	Sstorl		; set bottom of string space low byte
0001DBr 1  84 82        	STY	Sstorh		; set bottom of string space high byte
0001DDr 1  A5 7B        	LDA	Svarl			; get start of vars low byte	(end of BASIC)
0001DFr 1  85 A6        	STA	Obendl		; save old block end low byte
0001E1r 1  A4 7C        	LDY	Svarh			; get start of vars high byte	(end of BASIC)
0001E3r 1  84 A7        	STY	Obendh		; save old block end high byte
0001E5r 1  65 5D        	ADC	Ibptr			; add input buffer pointer	(also buffer length)
0001E7r 1  90 01        	BCC	LAB_1301		; branch if no overflow from add
0001E9r 1               
0001E9r 1  C8           	INY				; else increment high byte
0001EAr 1               LAB_1301
0001EAr 1  85 A4        	STA	Nbendl		; save new block end low byte	(move to, low byte)
0001ECr 1  84 A5        	STY	Nbendh		; save new block end high byte
0001EEr 1  20 rr rr     	JSR	LAB_11CF		; open up space in memory
0001F1r 1               					; old start pointer Ostrtl,Ostrth set by the find line call
0001F1r 1  A5 7F        	LDA	Earryl		; get array mem end low byte
0001F3r 1  A4 80        	LDY	Earryh		; get array mem end high byte
0001F5r 1  85 7B        	STA	Svarl			; save start of vars low byte
0001F7r 1  84 7C        	STY	Svarh			; save start of vars high byte
0001F9r 1  A4 5D        	LDY	Ibptr			; get input buffer pointer	(also buffer length)
0001FBr 1  88           	DEY				; adjust for loop type
0001FCr 1               LAB_1311
0001FCr 1  B9 09 02     	LDA	Ibuffs-4,Y		; get byte from crunched line
0001FFr 1  91 AA        	STA	(Baslnl),Y		; save it to program memory
000201r 1  88           	DEY				; decrement count
000202r 1  C0 03        	CPY	#$03			; compare with first byte-1
000204r 1  D0 F6        	BNE	LAB_1311		; continue while count <> 3
000206r 1               
000206r 1  A5 12        	LDA	Itemph		; get line # high byte
000208r 1  91 AA        	STA	(Baslnl),Y		; save it to program memory
00020Ar 1  88           	DEY				; decrement count
00020Br 1  A5 11        	LDA	Itempl		; get line # low byte
00020Dr 1  91 AA        	STA	(Baslnl),Y		; save it to program memory
00020Fr 1  88           	DEY				; decrement count
000210r 1  A9 FF        	LDA	#$FF			; set byte to allow chain rebuild. if you didn't set this
000212r 1               					; byte then a zero already here would stop the chain rebuild
000212r 1               					; as it would think it was the [EOT] marker.
000212r 1  91 AA        	STA	(Baslnl),Y		; save it to program memory
000214r 1               
000214r 1               LAB_1319
000214r 1  20 rr rr     	JSR	LAB_1477		; reset execution to start, clear vars and flush stack
000217r 1  A6 79        	LDX	Smeml			; get start of mem low byte
000219r 1  A5 7A        	LDA	Smemh			; get start of mem high byte
00021Br 1  A0 01        	LDY	#$01			; index to high byte of next line pointer
00021Dr 1               LAB_1325
00021Dr 1  86 71        	STX	ut1_pl		; set line start pointer low byte
00021Fr 1  85 72        	STA	ut1_ph		; set line start pointer high byte
000221r 1  B1 71        	LDA	(ut1_pl),Y		; get it
000223r 1  F0 18        	BEQ	LAB_133E		; exit if end of program
000225r 1               
000225r 1               ; rebuild chaining of Basic lines
000225r 1               
000225r 1  A0 04        	LDY	#$04			; point to first code byte of line
000227r 1               					; there is always 1 byte + [EOL] as null entries are deleted
000227r 1               LAB_1330
000227r 1  C8           	INY				; next code byte
000228r 1  B1 71        	LDA	(ut1_pl),Y		; get byte
00022Ar 1  D0 FB        	BNE	LAB_1330		; loop if not [EOL]
00022Cr 1               
00022Cr 1  38           	SEC				; set carry for add + 1
00022Dr 1  98           	TYA				; copy end index
00022Er 1  65 71        	ADC	ut1_pl		; add to line start pointer low byte
000230r 1  AA           	TAX				; copy to X
000231r 1  A0 00        	LDY	#$00			; clear index, point to this line's next line pointer
000233r 1  91 71        	STA	(ut1_pl),Y		; set next line pointer low byte
000235r 1  98           	TYA				; clear A
000236r 1  65 72        	ADC	ut1_ph		; add line start pointer high byte + carry
000238r 1  C8           	INY				; increment index to high byte
000239r 1  91 71        	STA	(ut1_pl),Y		; save next line pointer low byte
00023Br 1  90 E0        	BCC	LAB_1325		; go do next line, branch always, carry clear
00023Dr 1               
00023Dr 1               
00023Dr 1               LAB_133E
00023Dr 1  4C rr rr     	JMP	LAB_127D		; else we just wait for Basic command, no "Ready"
000240r 1               
000240r 1               ; print "? " and get BASIC input
000240r 1               
000240r 1               LAB_INLN
000240r 1  20 rr rr     	JSR	LAB_18E3		; print "?" character
000243r 1  20 rr rr     	JSR	LAB_18E0		; print " "
000246r 1  D0 05        	BNE	LAB_1357		; call for BASIC input and return
000248r 1               
000248r 1               ; receive line from keyboard
000248r 1               
000248r 1               					; $08 as delete key (BACKSPACE on standard keyboard)
000248r 1               LAB_134B
000248r 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
00024Br 1  CA           	DEX				; decrement the buffer counter (delete)
00024Cr 1  2C           	.byte	$2C			; make LDX into BIT abs
00024Dr 1               
00024Dr 1               ; call for BASIC input (main entry point)
00024Dr 1               
00024Dr 1               LAB_1357
00024Dr 1  A2 00        	LDX	#$00			; clear BASIC line buffer pointer
00024Fr 1               LAB_1359
00024Fr 1  20 rr rr     	JSR	V_INPT		; call scan input device
000252r 1  90 FB        	BCC	LAB_1359		; loop if no byte
000254r 1               
000254r 1  F0 F9        	BEQ	LAB_1359		; loop until valid input (ignore NULLs)
000256r 1               
000256r 1  C9 07        	CMP	#$07			; compare with [BELL]
000258r 1  F0 10        	BEQ	LAB_1378		; branch if [BELL]
00025Ar 1               
00025Ar 1  C9 0D        	CMP	#$0D			; compare with [CR]
00025Cr 1  F0 19        	BEQ	LAB_1384		; do CR/LF exit if [CR]
00025Er 1               
00025Er 1  E0 00        	CPX	#$00			; compare pointer with $00
000260r 1  D0 04        	BNE	LAB_1374		; branch if not empty
000262r 1               
000262r 1               ; next two lines ignore any non print character and [SPACE] if input buffer empty
000262r 1               
000262r 1  C9 21        	CMP	#$21			; compare with [SP]+1
000264r 1  90 E9        	BCC	LAB_1359		; if < ignore character
000266r 1               
000266r 1               LAB_1374
000266r 1  C9 08        	CMP	#$08			; compare with [BACKSPACE] (delete last character)
000268r 1  F0 DE        	BEQ	LAB_134B		; go delete last character
00026Ar 1               
00026Ar 1               LAB_1378
00026Ar 1  E0 47        	CPX	#Ibuffe-Ibuffs	; compare character count with max
00026Cr 1  B0 0C        	BCS	LAB_138E		; skip store and do [BELL] if buffer full
00026Er 1               
00026Er 1  9D 0D 02     	STA	Ibuffs,X		; else store in buffer
000271r 1  E8           	INX				; increment pointer
000272r 1               LAB_137F
000272r 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
000275r 1  D0 D8        	BNE	LAB_1359		; always loop for next character
000277r 1               
000277r 1               LAB_1384
000277r 1  4C rr rr     	JMP	LAB_1866		; do CR/LF exit to BASIC
00027Ar 1               
00027Ar 1               ; announce buffer full
00027Ar 1               
00027Ar 1               LAB_138E
00027Ar 1  A9 07        	LDA	#$07			; [BELL] character into A
00027Cr 1  D0 F4        	BNE	LAB_137F		; go print the [BELL] but ignore input character
00027Er 1               					; branch always
00027Er 1               
00027Er 1               ; crunch keywords into Basic tokens
00027Er 1               ; position independent buffer version ..
00027Er 1               ; faster, dictionary search version ....
00027Er 1               
00027Er 1               LAB_13A6
00027Er 1  A0 FF        	LDY	#$FF			; set save index (makes for easy math later)
000280r 1               
000280r 1  38           	SEC				; set carry for subtract
000281r 1  A5 C3        	LDA	Bpntrl		; get basic execute pointer low byte
000283r 1  E9 0D        	SBC	#<Ibuffs		; subtract input buffer start pointer
000285r 1  AA           	TAX				; copy result to X (index past line # if any)
000286r 1               
000286r 1  86 60        	STX	Oquote		; clear open quote/DATA flag
000288r 1               LAB_13AC
000288r 1  BD 0D 02     	LDA	Ibuffs,X		; get byte from input buffer
00028Br 1  F0 51        	BEQ	LAB_13EC		; if null save byte then exit
00028Dr 1               
00028Dr 1  C9 5F        	CMP	#'_'			; compare with "_"
00028Fr 1  B0 4D        	BCS	LAB_13EC		; if >= go save byte then continue crunching
000291r 1               
000291r 1  C9 3C        	CMP	#'<'			; compare with "<"
000293r 1  B0 0E        	BCS	LAB_13CC		; if >= go crunch now
000295r 1               
000295r 1  C9 30        	CMP	#'0'			; compare with "0"
000297r 1  B0 45        	BCS	LAB_13EC		; if >= go save byte then continue crunching
000299r 1               
000299r 1  85 5C        	STA	Scnquo		; save buffer byte as search character
00029Br 1  C9 22        	CMP	#$22			; is it quote character?
00029Dr 1  F0 61        	BEQ	LAB_1410		; branch if so (copy quoted string)
00029Fr 1               
00029Fr 1  C9 2A        	CMP	#'*'			; compare with "*"
0002A1r 1  90 3B        	BCC	LAB_13EC		; if < go save byte then continue crunching
0002A3r 1               
0002A3r 1               					; else crunch now
0002A3r 1               LAB_13CC
0002A3r 1  24 60        	BIT	Oquote		; get open quote/DATA token flag
0002A5r 1  70 37        	BVS	LAB_13EC		; branch if b6 of Oquote set (was DATA)
0002A7r 1               					; go save byte then continue crunching
0002A7r 1               
0002A7r 1  86 78        	STX	TempB			; save buffer read index
0002A9r 1  84 BA        	STY	csidx			; copy buffer save index
0002ABr 1  A0 rr        	LDY	#<TAB_1STC		; get keyword first character table low address
0002ADr 1  84 73        	STY	ut2_pl		; save pointer low byte
0002AFr 1  A0 rr        	LDY	#>TAB_1STC		; get keyword first character table high address
0002B1r 1  84 74        	STY	ut2_ph		; save pointer high byte
0002B3r 1  A0 00        	LDY	#$00			; clear table pointer
0002B5r 1               
0002B5r 1               LAB_13D0
0002B5r 1  D1 73        	CMP	(ut2_pl),Y		; compare with keyword first character table byte
0002B7r 1  F0 05        	BEQ	LAB_13D1		; go do word_table_chr if match
0002B9r 1               
0002B9r 1  90 21        	BCC	LAB_13EA		; if < keyword first character table byte go restore
0002BBr 1               					; Y and save to crunched
0002BBr 1               
0002BBr 1  C8           	INY				; else increment pointer
0002BCr 1  D0 F7        	BNE	LAB_13D0		; and loop (branch always)
0002BEr 1               
0002BEr 1               ; have matched first character of some keyword
0002BEr 1               
0002BEr 1               LAB_13D1
0002BEr 1  98           	TYA				; copy matching index
0002BFr 1  0A           	ASL				; *2 (bytes per pointer)
0002C0r 1  AA           	TAX				; copy to new index
0002C1r 1  BD rr rr     	LDA	TAB_CHRT,X		; get keyword table pointer low byte
0002C4r 1  85 73        	STA	ut2_pl		; save pointer low byte
0002C6r 1  BD rr rr     	LDA	TAB_CHRT+1,X	; get keyword table pointer high byte
0002C9r 1  85 74        	STA	ut2_ph		; save pointer high byte
0002CBr 1               
0002CBr 1  A0 FF        	LDY	#$FF			; clear table pointer (make -1 for start)
0002CDr 1               
0002CDr 1  A6 78        	LDX	TempB			; restore buffer read index
0002CFr 1               
0002CFr 1               LAB_13D6
0002CFr 1  C8           	INY				; next table byte
0002D0r 1  B1 73        	LDA	(ut2_pl),Y		; get byte from table
0002D2r 1               LAB_13D8
0002D2r 1  30 08        	BMI	LAB_13EA		; all bytes matched so go save token
0002D4r 1               
0002D4r 1  E8           	INX				; next buffer byte
0002D5r 1  DD 0D 02     	CMP	Ibuffs,X		; compare with byte from input buffer
0002D8r 1  F0 F5        	BEQ	LAB_13D6		; go compare next if match
0002DAr 1               
0002DAr 1  D0 2B        	BNE	LAB_1417		; branch if >< (not found keyword)
0002DCr 1               
0002DCr 1               LAB_13EA
0002DCr 1  A4 BA        	LDY	csidx			; restore save index
0002DEr 1               
0002DEr 1               					; save crunched to output
0002DEr 1               LAB_13EC
0002DEr 1  E8           	INX				; increment buffer index (to next input byte)
0002DFr 1  C8           	INY				; increment save index (to next output byte)
0002E0r 1  99 0D 02     	STA	Ibuffs,Y		; save byte to output
0002E3r 1  C9 00        	CMP	#$00			; set the flags, set carry
0002E5r 1  F0 32        	BEQ	LAB_142A		; do exit if was null [EOL]
0002E7r 1               
0002E7r 1               					; A holds token or byte here
0002E7r 1  E9 3A        	SBC	#':'			; subtract ":" (carry set by CMP #00)
0002E9r 1  F0 04        	BEQ	LAB_13FF		; branch if it was ":" (is now $00)
0002EBr 1               
0002EBr 1               					; A now holds token-$3A
0002EBr 1  C9 49        	CMP	#TK_DATA-$3A	; compare with DATA token - $3A
0002EDr 1  D0 02        	BNE	LAB_1401		; branch if not DATA
0002EFr 1               
0002EFr 1               					; token was : or DATA
0002EFr 1               LAB_13FF
0002EFr 1  85 60        	STA	Oquote		; save token-$3A (clear for ":", TK_DATA-$3A for DATA)
0002F1r 1               LAB_1401
0002F1r 1  49 57        	EOR	#TK_REM-$3A		; effectively subtract REM token offset
0002F3r 1  D0 93        	BNE	LAB_13AC		; If wasn't REM then go crunch rest of line
0002F5r 1               
0002F5r 1  85 5C        	STA	Asrch			; else was REM so set search for [EOL]
0002F7r 1               
0002F7r 1               					; loop for REM, "..." etc.
0002F7r 1               LAB_1408
0002F7r 1  BD 0D 02     	LDA	Ibuffs,X		; get byte from input buffer
0002FAr 1  F0 E2        	BEQ	LAB_13EC		; branch if null [EOL]
0002FCr 1               
0002FCr 1  C5 5C        	CMP	Asrch			; compare with stored character
0002FEr 1  F0 DE        	BEQ	LAB_13EC		; branch if match (end quote)
000300r 1               
000300r 1               					; entry for copy string in quotes, don't crunch
000300r 1               LAB_1410
000300r 1  C8           	INY				; increment buffer save index
000301r 1  99 0D 02     	STA	Ibuffs,Y		; save byte to output
000304r 1  E8           	INX				; increment buffer read index
000305r 1  D0 F0        	BNE	LAB_1408		; loop while <> 0 (should never be 0!)
000307r 1               
000307r 1               					; not found keyword this go
000307r 1               LAB_1417
000307r 1  A6 78        	LDX	TempB			; compare has failed, restore buffer index (start byte!)
000309r 1               
000309r 1               					; now find the end of this word in the table
000309r 1               LAB_141B
000309r 1  B1 73        	LDA	(ut2_pl),Y		; get table byte
00030Br 1  08           	PHP				; save status
00030Cr 1  C8           	INY				; increment table index
00030Dr 1  28           	PLP				; restore byte status
00030Er 1  10 F9        	BPL	LAB_141B		; if not end of keyword go do next
000310r 1               
000310r 1  B1 73        	LDA	(ut2_pl),Y		; get byte from keyword table
000312r 1  D0 BE        	BNE	LAB_13D8		; go test next word if not zero byte (end of table)
000314r 1               
000314r 1               					; reached end of table with no match
000314r 1  BD 0D 02     	LDA	Ibuffs,X		; restore byte from input buffer
000317r 1  10 C3        	BPL	LAB_13EA		; branch always (all bytes in buffer are $00-$7F)
000319r 1               					; go save byte in output and continue crunching
000319r 1               
000319r 1               					; reached [EOL]
000319r 1               LAB_142A
000319r 1  C8           	INY				; increment pointer
00031Ar 1  C8           	INY				; increment pointer (makes it next line pointer high byte)
00031Br 1  99 0D 02     	STA	Ibuffs,Y		; save [EOL] (marks [EOT] in immediate mode)
00031Er 1  C8           	INY				; adjust for line copy
00031Fr 1  C8           	INY				; adjust for line copy
000320r 1  C8           	INY				; adjust for line copy
000321r 1  C6 C3        	DEC	Bpntrl		; allow for increment (change if buffer starts at $xxFF)
000323r 1  60           	RTS
000324r 1               
000324r 1               ; search Basic for temp integer line number from start of mem
000324r 1               
000324r 1               LAB_SSLN
000324r 1  A5 79        	LDA	Smeml			; get start of mem low byte
000326r 1  A6 7A        	LDX	Smemh			; get start of mem high byte
000328r 1               
000328r 1               ; search Basic for temp integer line number from AX
000328r 1               ; returns carry set if found
000328r 1               ; returns Baslnl/Baslnh pointer to found or next higher (not found) line
000328r 1               
000328r 1               ; old 541 new 507
000328r 1               
000328r 1               LAB_SHLN
000328r 1  A0 01        	LDY	#$01			; set index
00032Ar 1  85 AA        	STA	Baslnl		; save low byte as current
00032Cr 1  86 AB        	STX	Baslnh		; save high byte as current
00032Er 1  B1 AA        	LDA	(Baslnl),Y		; get pointer high byte from addr
000330r 1  F0 1A        	BEQ	LAB_145F		; pointer was zero so we"re done, do "not found" exit
000332r 1               
000332r 1  A0 03        	LDY	#$03			; set index to line # high byte
000334r 1  B1 AA        	LDA	(Baslnl),Y		; get line # high byte
000336r 1  88           	DEY				; decrement index (point to low byte)
000337r 1  C5 12        	CMP	Itemph		; compare with temporary integer high byte
000339r 1  D0 04        	BNE	LAB_1455		; if <> skip low byte check
00033Br 1               
00033Br 1  B1 AA        	LDA	(Baslnl),Y		; get line # low byte
00033Dr 1  C5 11        	CMP	Itempl		; compare with temporary integer low byte
00033Fr 1               LAB_1455
00033Fr 1  B0 09        	BCS	LAB_145E		; else if temp < this line, exit (passed line#)
000341r 1               
000341r 1               LAB_1456
000341r 1  88           	DEY				; decrement index to next line ptr high byte
000342r 1  B1 AA        	LDA	(Baslnl),Y		; get next line pointer high byte
000344r 1  AA           	TAX				; copy to X
000345r 1  88           	DEY				; decrement index to next line ptr low byte
000346r 1  B1 AA        	LDA	(Baslnl),Y		; get next line pointer low byte
000348r 1  90 DE        	BCC	LAB_SHLN		; go search for line # in temp (Itempl/Itemph) from AX
00034Ar 1               					; (carry always clear)
00034Ar 1               
00034Ar 1               LAB_145E
00034Ar 1  F0 01        	BEQ	LAB_1460		; exit if temp = found line #, carry is set
00034Cr 1               
00034Cr 1               LAB_145F
00034Cr 1  18           	CLC				; clear found flag
00034Dr 1               LAB_1460
00034Dr 1  60           	RTS
00034Er 1               
00034Er 1               ; perform NEW
00034Er 1               
00034Er 1               LAB_NEW
00034Er 1  D0 FD        	BNE	LAB_1460		; exit if not end of statement (to do syntax error)
000350r 1               
000350r 1               LAB_1463
000350r 1  A9 00        	LDA	#$00			; clear A
000352r 1  A8           	TAY				; clear Y
000353r 1  91 79        	STA	(Smeml),Y		; clear first line, next line pointer, low byte
000355r 1  C8           	INY				; increment index
000356r 1  91 79        	STA	(Smeml),Y		; clear first line, next line pointer, high byte
000358r 1  18           	CLC				; clear carry
000359r 1  A5 79        	LDA	Smeml			; get start of mem low byte
00035Br 1  69 02        	ADC	#$02			; calculate end of BASIC low byte
00035Dr 1  85 7B        	STA	Svarl			; save start of vars low byte
00035Fr 1  A5 7A        	LDA	Smemh			; get start of mem high byte
000361r 1  69 00        	ADC	#$00			; add any carry
000363r 1  85 7C        	STA	Svarh			; save start of vars high byte
000365r 1               
000365r 1               ; reset execution to start, clear vars and flush stack
000365r 1               
000365r 1               LAB_1477
000365r 1  18           	CLC				; clear carry
000366r 1  A5 79        	LDA	Smeml			; get start of mem low byte
000368r 1  69 FF        	ADC	#$FF			; -1
00036Ar 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
00036Cr 1  A5 7A        	LDA	Smemh			; get start of mem high byte
00036Er 1  69 FF        	ADC	#$FF			; -1+carry
000370r 1  85 C4        	STA	Bpntrh		; save BASIC execute pointer high byte
000372r 1               
000372r 1               ; "CLEAR" command gets here
000372r 1               
000372r 1               LAB_147A
000372r 1  A5 85        	LDA	Ememl			; get end of mem low byte
000374r 1  A4 86        	LDY	Ememh			; get end of mem high byte
000376r 1  85 81        	STA	Sstorl		; set bottom of string space low byte
000378r 1  84 82        	STY	Sstorh		; set bottom of string space high byte
00037Ar 1  A5 7B        	LDA	Svarl			; get start of vars low byte
00037Cr 1  A4 7C        	LDY	Svarh			; get start of vars high byte
00037Er 1  85 7D        	STA	Sarryl		; save var mem end low byte
000380r 1  84 7E        	STY	Sarryh		; save var mem end high byte
000382r 1  85 7F        	STA	Earryl		; save array mem end low byte
000384r 1  84 80        	STY	Earryh		; save array mem end high byte
000386r 1  20 rr rr     	JSR	LAB_161A		; perform RESTORE command
000389r 1               
000389r 1               ; flush stack and clear continue flag
000389r 1               
000389r 1               LAB_1491
000389r 1  A2 68        	LDX	#des_sk		; set descriptor stack pointer
00038Br 1  86 65        	STX	next_s		; save descriptor stack pointer
00038Dr 1  68           	PLA				; pull return address low byte
00038Er 1  AA           	TAX				; copy return address low byte
00038Fr 1  68           	PLA				; pull return address high byte
000390r 1  8E FE 01     	STX	LAB_SKFE		; save to cleared stack
000393r 1  8D FF 01     	STA	LAB_SKFF		; save to cleared stack
000396r 1  A2 FD        	LDX	#$FD			; new stack pointer
000398r 1  9A           	TXS				; reset stack
000399r 1  A9 00        	LDA	#$00			; clear byte
00039Br 1  85 8C        	STA	Cpntrh		; clear continue pointer high byte
00039Dr 1  85 61        	STA	Sufnxf		; clear subscript/FNX flag
00039Fr 1               LAB_14A6
00039Fr 1  60           	RTS
0003A0r 1               
0003A0r 1               ; perform CLEAR
0003A0r 1               
0003A0r 1               LAB_CLEAR
0003A0r 1  F0 D0        	BEQ	LAB_147A		; if no following token go do "CLEAR"
0003A2r 1               
0003A2r 1               					; else there was a following token (go do syntax error)
0003A2r 1  60           	RTS
0003A3r 1               
0003A3r 1               ; perform LIST [n][-m]
0003A3r 1               ; bigger, faster version (a _lot_ faster)
0003A3r 1               
0003A3r 1               LAB_LIST
0003A3r 1  90 06        	BCC	LAB_14BD		; branch if next character numeric (LIST n..)
0003A5r 1               
0003A5r 1  F0 04        	BEQ	LAB_14BD		; branch if next character [NULL] (LIST)
0003A7r 1               
0003A7r 1  C9 B8        	CMP	#TK_MINUS		; compare with token for -
0003A9r 1  D0 F4        	BNE	LAB_14A6		; exit if not - (LIST -m)
0003ABr 1               
0003ABr 1               					; LIST [[n][-m]]
0003ABr 1               					; this bit sets the n , if present, as the start and end
0003ABr 1               LAB_14BD
0003ABr 1  20 rr rr     	JSR	LAB_GFPN		; get fixed-point number into temp integer
0003AEr 1  20 rr rr     	JSR	LAB_SSLN		; search BASIC for temp integer line number
0003B1r 1               					; (pointer in Baslnl/Baslnh)
0003B1r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0003B4r 1  F0 0C        	BEQ	LAB_14D4		; branch if no more characters
0003B6r 1               
0003B6r 1               					; this bit checks the - is present
0003B6r 1  C9 B8        	CMP	#TK_MINUS		; compare with token for -
0003B8r 1  D0 93        	BNE	LAB_1460		; return if not "-" (will be Syntax error)
0003BAr 1               
0003BAr 1               					; LIST [n]-m
0003BAr 1               					; the - was there so set m as the end value
0003BAr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0003BDr 1  20 rr rr     	JSR	LAB_GFPN		; get fixed-point number into temp integer
0003C0r 1  D0 8B        	BNE	LAB_1460		; exit if not ok
0003C2r 1               
0003C2r 1               LAB_14D4
0003C2r 1  A5 11        	LDA	Itempl		; get temporary integer low byte
0003C4r 1  05 12        	ORA	Itemph		; OR temporary integer high byte
0003C6r 1  D0 06        	BNE	LAB_14E2		; branch if start set
0003C8r 1               
0003C8r 1  A9 FF        	LDA	#$FF			; set for -1
0003CAr 1  85 11        	STA	Itempl		; set temporary integer low byte
0003CCr 1  85 12        	STA	Itemph		; set temporary integer high byte
0003CEr 1               LAB_14E2
0003CEr 1  A0 01        	LDY	#$01			; set index for line
0003D0r 1  84 60        	STY	Oquote		; clear open quote flag
0003D2r 1  20 rr rr     	JSR	LAB_CRLF		; print CR/LF
0003D5r 1  B1 AA        	LDA	(Baslnl),Y		; get next line pointer high byte
0003D7r 1               					; pointer initially set by search at LAB_14BD
0003D7r 1  F0 3E        	BEQ	LAB_152B		; if null all done so exit
0003D9r 1  20 rr rr     	JSR	LAB_1629		; do CRTL-C check vector
0003DCr 1               
0003DCr 1  C8           	INY				; increment index for line
0003DDr 1  B1 AA        	LDA	(Baslnl),Y		; get line # low byte
0003DFr 1  AA           	TAX				; copy to X
0003E0r 1  C8           	INY				; increment index
0003E1r 1  B1 AA        	LDA	(Baslnl),Y		; get line # high byte
0003E3r 1  C5 12        	CMP	Itemph		; compare with temporary integer high byte
0003E5r 1  D0 04        	BNE	LAB_14FF		; branch if no high byte match
0003E7r 1               
0003E7r 1  E4 11        	CPX	Itempl		; compare with temporary integer low byte
0003E9r 1  F0 02        	BEQ	LAB_1501		; branch if = last line to do (< will pass next branch)
0003EBr 1               
0003EBr 1               LAB_14FF				; else ..
0003EBr 1  B0 2A        	BCS	LAB_152B		; if greater all done so exit
0003EDr 1               
0003EDr 1               LAB_1501
0003EDr 1  84 97        	STY	Tidx1			; save index for line
0003EFr 1  20 rr rr     	JSR	LAB_295E		; print XA as unsigned integer
0003F2r 1  A9 20        	LDA	#$20			; space is the next character
0003F4r 1               LAB_1508
0003F4r 1  A4 97        	LDY	Tidx1			; get index for line
0003F6r 1  29 7F        	AND	#$7F			; mask top out bit of character
0003F8r 1               LAB_150C
0003F8r 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
0003FBr 1  C9 22        	CMP	#$22			; was it " character
0003FDr 1  D0 06        	BNE	LAB_1519		; branch if not
0003FFr 1               
0003FFr 1               					; we are either entering or leaving a pair of quotes
0003FFr 1  A5 60        	LDA	Oquote		; get open quote flag
000401r 1  49 FF        	EOR	#$FF			; toggle it
000403r 1  85 60        	STA	Oquote		; save it back
000405r 1               LAB_1519
000405r 1  C8           	INY				; increment index
000406r 1  B1 AA        	LDA	(Baslnl),Y		; get next byte
000408r 1  D0 0E        	BNE	LAB_152E		; branch if not [EOL] (go print character)
00040Ar 1  A8           	TAY				; else clear index
00040Br 1  B1 AA        	LDA	(Baslnl),Y		; get next line pointer low byte
00040Dr 1  AA           	TAX				; copy to X
00040Er 1  C8           	INY				; increment index
00040Fr 1  B1 AA        	LDA	(Baslnl),Y		; get next line pointer high byte
000411r 1  86 AA        	STX	Baslnl		; set pointer to line low byte
000413r 1  85 AB        	STA	Baslnh		; set pointer to line high byte
000415r 1  D0 B7        	BNE	LAB_14E2		; go do next line if not [EOT]
000417r 1               					; else ..
000417r 1               LAB_152B
000417r 1  60           	RTS
000418r 1               
000418r 1               LAB_152E
000418r 1  10 DE        	BPL	LAB_150C		; just go print it if not token byte
00041Ar 1               
00041Ar 1               					; else was token byte so uncrunch it (maybe)
00041Ar 1  24 60        	BIT	Oquote		; test the open quote flag
00041Cr 1  30 DA        	BMI	LAB_150C		; just go print character if open quote set
00041Er 1               
00041Er 1  A2 rr        	LDX	#>LAB_KEYT		; get table address high byte
000420r 1  0A           	ASL				; *2
000421r 1  0A           	ASL				; *4
000422r 1  90 02        	BCC	LAB_152F		; branch if no carry
000424r 1               
000424r 1  E8           	INX				; else increment high byte
000425r 1  18           	CLC				; clear carry for add
000426r 1               LAB_152F
000426r 1  69 rr        	ADC	#<LAB_KEYT		; add low byte
000428r 1  90 01        	BCC	LAB_1530		; branch if no carry
00042Ar 1               
00042Ar 1  E8           	INX				; else increment high byte
00042Br 1               LAB_1530
00042Br 1  85 73        	STA	ut2_pl		; save table pointer low byte
00042Dr 1  86 74        	STX	ut2_ph		; save table pointer high byte
00042Fr 1  84 97        	STY	Tidx1			; save index for line
000431r 1  A0 00        	LDY	#$00			; clear index
000433r 1  B1 73        	LDA	(ut2_pl),Y		; get length
000435r 1  AA           	TAX				; copy length
000436r 1  C8           	INY				; increment index
000437r 1  B1 73        	LDA	(ut2_pl),Y		; get 1st character
000439r 1  CA           	DEX				; decrement length
00043Ar 1  F0 B8        	BEQ	LAB_1508		; if no more characters exit and print
00043Cr 1               
00043Cr 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
00043Fr 1  C8           	INY				; increment index
000440r 1  B1 73        	LDA	(ut2_pl),Y		; get keyword address low byte
000442r 1  48           	PHA				; save it for now
000443r 1  C8           	INY				; increment index
000444r 1  B1 73        	LDA	(ut2_pl),Y		; get keyword address high byte
000446r 1  A0 00        	LDY	#$00
000448r 1  85 74        	STA	ut2_ph		; save keyword pointer high byte
00044Ar 1  68           	PLA				; pull low byte
00044Br 1  85 73        	STA	ut2_pl		; save keyword pointer low byte
00044Dr 1               LAB_1540
00044Dr 1  B1 73        	LDA	(ut2_pl),Y		; get character
00044Fr 1  CA           	DEX				; decrement character count
000450r 1  F0 A2        	BEQ	LAB_1508		; if last character exit and print
000452r 1               
000452r 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
000455r 1  C8           	INY				; increment index
000456r 1  D0 F5        	BNE	LAB_1540		; loop for next character
000458r 1               
000458r 1               ; perform FOR
000458r 1               
000458r 1               LAB_FOR
000458r 1  A9 80        	LDA	#$80			; set FNX
00045Ar 1  85 61        	STA	Sufnxf		; set subscript/FNX flag
00045Cr 1  20 rr rr     	JSR	LAB_LET		; go do LET
00045Fr 1  68           	PLA				; pull return address
000460r 1  68           	PLA				; pull return address
000461r 1  A9 10        	LDA	#$10			; we need 16d bytes !
000463r 1  20 rr rr     	JSR	LAB_1212		; check room on stack for A bytes
000466r 1  20 rr rr     	JSR	LAB_SNBS		; scan for next BASIC statement ([:] or [EOL])
000469r 1  18           	CLC				; clear carry for add
00046Ar 1  98           	TYA				; copy index to A
00046Br 1  65 C3        	ADC	Bpntrl		; add BASIC execute pointer low byte
00046Dr 1  48           	PHA				; push onto stack
00046Er 1  A5 C4        	LDA	Bpntrh		; get BASIC execute pointer high byte
000470r 1  69 00        	ADC	#$00			; add carry
000472r 1  48           	PHA				; push onto stack
000473r 1  A5 88        	LDA	Clineh		; get current line high byte
000475r 1  48           	PHA				; push onto stack
000476r 1  A5 87        	LDA	Clinel		; get current line low byte
000478r 1  48           	PHA				; push onto stack
000479r 1  A9 AE        	LDA	#TK_TO		; get "TO" token
00047Br 1  20 rr rr     	JSR	LAB_SCCA		; scan for CHR$(A) , else do syntax error then warm start
00047Er 1  20 rr rr     	JSR	LAB_CTNM		; check if source is numeric, else do type mismatch
000481r 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
000484r 1               					; else do type mismatch
000484r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
000486r 1  09 7F        	ORA	#$7F			; set all non sign bits
000488r 1  25 AD        	AND	FAC1_1		; and FAC1 mantissa1
00048Ar 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
00048Cr 1  A9 rr        	LDA	#<LAB_159F		; set return address low byte
00048Er 1  A0 rr        	LDY	#>LAB_159F		; set return address high byte
000490r 1  85 71        	STA	ut1_pl		; save return address low byte
000492r 1  84 72        	STY	ut1_ph		; save return address high byte
000494r 1  4C rr rr     	JMP	LAB_1B66		; round FAC1 and put on stack (returns to next instruction)
000497r 1               
000497r 1               LAB_159F
000497r 1  A9 rr        	LDA	#<LAB_259C		; set 1 pointer low addr (default step size)
000499r 1  A0 rr        	LDY	#>LAB_259C		; set 1 pointer high addr
00049Br 1  20 rr rr     	JSR	LAB_UFAC		; unpack memory (AY) into FAC1
00049Er 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0004A1r 1  C9 B3        	CMP	#TK_STEP		; compare with STEP token
0004A3r 1  D0 06        	BNE	LAB_15B3		; jump if not "STEP"
0004A5r 1               
0004A5r 1               					;.was step so ..
0004A5r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0004A8r 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
0004ABr 1               					; else do type mismatch
0004ABr 1               LAB_15B3
0004ABr 1  20 rr rr     	JSR	LAB_27CA		; return A=FF,C=1/-ve A=01,C=0/+ve
0004AEr 1  85 B0        	STA	FAC1_s		; set FAC1 sign (b7)
0004B0r 1               					; this is +1 for +ve step and -1 for -ve step, in NEXT we
0004B0r 1               					; compare the FOR value and the TO value and return +1 if
0004B0r 1               					; FOR > TO, 0 if FOR = TO and -1 if FOR < TO. the value
0004B0r 1               					; here (+/-1) is then compared to that result and if they
0004B0r 1               					; are the same (+ve and FOR > TO or -ve and FOR < TO) then
0004B0r 1               					; the loop is done
0004B0r 1  20 rr rr     	JSR	LAB_1B5B		; push sign, round FAC1 and put on stack
0004B3r 1  A5 98        	LDA	Frnxth		; get var pointer for FOR/NEXT high byte
0004B5r 1  48           	PHA				; push on stack
0004B6r 1  A5 97        	LDA	Frnxtl		; get var pointer for FOR/NEXT low byte
0004B8r 1  48           	PHA				; push on stack
0004B9r 1  A9 81        	LDA	#TK_FOR		; get FOR token
0004BBr 1  48           	PHA				; push on stack
0004BCr 1               
0004BCr 1               ; interpreter inner loop
0004BCr 1               
0004BCr 1               LAB_15C2
0004BCr 1  20 rr rr     	JSR	LAB_1629		; do CRTL-C check vector
0004BFr 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
0004C1r 1  A4 C4        	LDY	Bpntrh		; get BASIC execute pointer high byte
0004C3r 1               
0004C3r 1  A6 88        	LDX	Clineh		; continue line is $FFxx for immediate mode
0004C5r 1               					; ($00xx for RUN from immediate mode)
0004C5r 1  E8           	INX				; increment it (now $00 if immediate mode)
0004C6r 1  F0 04        	BEQ	LAB_15D1		; branch if null (immediate mode)
0004C8r 1               
0004C8r 1  85 8B        	STA	Cpntrl		; save continue pointer low byte
0004CAr 1  84 8C        	STY	Cpntrh		; save continue pointer high byte
0004CCr 1               LAB_15D1
0004CCr 1  A0 00        	LDY	#$00			; clear index
0004CEr 1  B1 C3        	LDA	(Bpntrl),Y		; get next byte
0004D0r 1  F0 07        	BEQ	LAB_15DC		; branch if null [EOL]
0004D2r 1               
0004D2r 1  C9 3A        	CMP	#':'			; compare with ":"
0004D4r 1  F0 1D        	BEQ	LAB_15F6		; branch if = (statement separator)
0004D6r 1               
0004D6r 1               LAB_15D9
0004D6r 1  4C rr rr     	JMP	LAB_SNER		; else syntax error then warm start
0004D9r 1               
0004D9r 1               					; have reached [EOL]
0004D9r 1               LAB_15DC
0004D9r 1  A0 02        	LDY	#$02			; set index
0004DBr 1  B1 C3        	LDA	(Bpntrl),Y		; get next line pointer high byte
0004DDr 1  18           	CLC				; clear carry for no "BREAK" message
0004DEr 1  F0 56        	BEQ	LAB_1651		; if null go to immediate mode (was immediate or [EOT]
0004E0r 1               					; marker)
0004E0r 1               
0004E0r 1  C8           	INY				; increment index
0004E1r 1  B1 C3        	LDA	(Bpntrl),Y		; get line # low byte
0004E3r 1  85 87        	STA	Clinel		; save current line low byte
0004E5r 1  C8           	INY				; increment index
0004E6r 1  B1 C3        	LDA	(Bpntrl),Y		; get line # high byte
0004E8r 1  85 88        	STA	Clineh		; save current line high byte
0004EAr 1  98           	TYA				; A now = 4
0004EBr 1  65 C3        	ADC	Bpntrl		; add BASIC execute pointer low byte
0004EDr 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
0004EFr 1  90 02        	BCC	LAB_15F6		; branch if no overflow
0004F1r 1               
0004F1r 1  E6 C4        	INC	Bpntrh		; else increment BASIC execute pointer high byte
0004F3r 1               LAB_15F6
0004F3r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0004F6r 1               
0004F6r 1               LAB_15F9
0004F6r 1  20 rr rr     	JSR	LAB_15FF		; go interpret BASIC code from (Bpntrl)
0004F9r 1               
0004F9r 1               LAB_15FC
0004F9r 1  4C rr rr     	JMP	LAB_15C2		; loop
0004FCr 1               
0004FCr 1               ; interpret BASIC code from (Bpntrl)
0004FCr 1               
0004FCr 1               LAB_15FF
0004FCr 1  F0 54        	BEQ	LAB_1628		; exit if zero [EOL]
0004FEr 1               
0004FEr 1               LAB_1602
0004FEr 1  0A           	ASL				; *2 bytes per vector and normalise token
0004FFr 1  B0 03        	BCS	LAB_1609		; branch if was token
000501r 1               
000501r 1  4C rr rr     	JMP	LAB_LET		; else go do implied LET
000504r 1               
000504r 1               LAB_1609
000504r 1  C9 58        	CMP	#(TK_TAB-$80)*2	; compare normalised token * 2 with TAB
000506r 1  B0 CE        	BCS	LAB_15D9		; branch if A>=TAB (do syntax error then warm start)
000508r 1               					; only tokens before TAB can start a line
000508r 1  A8           	TAY				; copy to index
000509r 1  B9 rr rr     	LDA	LAB_CTBL+1,Y	; get vector high byte
00050Cr 1  48           	PHA				; onto stack
00050Dr 1  B9 rr rr     	LDA	LAB_CTBL,Y		; get vector low byte
000510r 1  48           	PHA				; onto stack
000511r 1  4C BC 00     	JMP	LAB_IGBY		; jump to increment and scan memory
000514r 1               					; then "return" to vector
000514r 1               
000514r 1               ; CTRL-C check jump. this is called as a subroutine but exits back via a jump if a
000514r 1               ; key press is detected.
000514r 1               
000514r 1               LAB_1629
000514r 1  6C 03 02     	JMP	(VEC_CC)		; ctrl c check vector
000517r 1               
000517r 1               ; if there was a key press it gets back here ..
000517r 1               
000517r 1               LAB_1636
000517r 1  C9 03        	CMP	#$03			; compare with CTRL-C
000519r 1               
000519r 1               ; perform STOP
000519r 1               
000519r 1               LAB_STOP
000519r 1  B0 01        	BCS	LAB_163B		; branch if token follows STOP
00051Br 1               					; else just END
00051Br 1               ; END
00051Br 1               
00051Br 1               LAB_END
00051Br 1  18           	CLC				; clear the carry, indicate a normal program end
00051Cr 1               LAB_163B
00051Cr 1  D0 67        	BNE	LAB_167A		; if wasn't CTRL-C or there is a following byte return
00051Er 1               
00051Er 1  A5 C4        	LDA	Bpntrh		; get the BASIC execute pointer high byte
000520r 1  49 02        	EOR	#>Ibuffs		; compare with buffer address high byte (Cb unchanged)
000522r 1  F0 10        	BEQ	LAB_164F		; branch if the BASIC pointer is in the input buffer
000524r 1               					; (can't continue in immediate mode)
000524r 1               
000524r 1               					; else ..
000524r 1  49 02        	EOR	#>Ibuffs		; correct the bits
000526r 1  A4 C3        	LDY	Bpntrl		; get BASIC execute pointer low byte
000528r 1  84 8B        	STY	Cpntrl		; save continue pointer low byte
00052Ar 1  85 8C        	STA	Cpntrh		; save continue pointer high byte
00052Cr 1               LAB_1647
00052Cr 1  A5 87        	LDA	Clinel		; get current line low byte
00052Er 1  A4 88        	LDY	Clineh		; get current line high byte
000530r 1  85 89        	STA	Blinel		; save break line low byte
000532r 1  84 8A        	STY	Blineh		; save break line high byte
000534r 1               LAB_164F
000534r 1  68           	PLA				; pull return address low
000535r 1  68           	PLA				; pull return address high
000536r 1               LAB_1651
000536r 1  90 07        	BCC	LAB_165E		; if was program end just do warm start
000538r 1               
000538r 1               					; else ..
000538r 1  A9 rr        	LDA	#<LAB_BMSG		; point to "Break" low byte
00053Ar 1  A0 rr        	LDY	#>LAB_BMSG		; point to "Break" high byte
00053Cr 1  4C rr rr     	JMP	LAB_1269		; print "Break" and do warm start
00053Fr 1               
00053Fr 1               LAB_165E
00053Fr 1  4C rr rr     	JMP	LAB_1274		; go do warm start
000542r 1               
000542r 1               ; perform RESTORE
000542r 1               
000542r 1               LAB_RESTORE
000542r 1  D0 0F        	BNE	LAB_RESTOREn	; branch if next character not null (RESTORE n)
000544r 1               
000544r 1               LAB_161A
000544r 1  38           	SEC				; set carry for subtract
000545r 1  A5 79        	LDA	Smeml			; get start of mem low byte
000547r 1  E9 01        	SBC	#$01			; -1
000549r 1  A4 7A        	LDY	Smemh			; get start of mem high byte
00054Br 1  B0 01        	BCS	LAB_1624		; branch if no underflow
00054Dr 1               
00054Dr 1               LAB_uflow
00054Dr 1  88           	DEY				; else decrement high byte
00054Er 1               LAB_1624
00054Er 1  85 8F        	STA	Dptrl			; save DATA pointer low byte
000550r 1  84 90        	STY	Dptrh			; save DATA pointer high byte
000552r 1               LAB_1628
000552r 1  60           	RTS
000553r 1               
000553r 1               					; is RESTORE n
000553r 1               LAB_RESTOREn
000553r 1  20 rr rr     	JSR	LAB_GFPN		; get fixed-point number into temp integer
000556r 1  20 rr rr     	JSR	LAB_SNBL		; scan for next BASIC line
000559r 1  A5 88        	LDA	Clineh		; get current line high byte
00055Br 1  C5 12        	CMP	Itemph		; compare with temporary integer high byte
00055Dr 1  B0 0B        	BCS	LAB_reset_search	; branch if >= (start search from beginning)
00055Fr 1               
00055Fr 1  98           	TYA				; else copy line index to A
000560r 1  38           	SEC				; set carry (+1)
000561r 1  65 C3        	ADC	Bpntrl		; add BASIC execute pointer low byte
000563r 1  A6 C4        	LDX	Bpntrh		; get BASIC execute pointer high byte
000565r 1  90 07        	BCC	LAB_go_search	; branch if no overflow to high byte
000567r 1               
000567r 1  E8           	INX				; increment high byte
000568r 1  B0 04        	BCS	LAB_go_search	; branch always (can never be carry clear)
00056Ar 1               
00056Ar 1               ; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml)
00056Ar 1               
00056Ar 1               LAB_reset_search
00056Ar 1  A5 79        	LDA	Smeml			; get start of mem low byte
00056Cr 1  A6 7A        	LDX	Smemh			; get start of mem high byte
00056Er 1               
00056Er 1               ; search for line # in temp (Itempl/Itemph) from (AX)
00056Er 1               
00056Er 1               LAB_go_search
00056Er 1               
00056Er 1  20 rr rr     	JSR	LAB_SHLN		; search Basic for temp integer line number from AX
000571r 1  B0 03        	BCS	LAB_line_found	; if carry set go set pointer
000573r 1               
000573r 1  4C rr rr     	JMP	LAB_16F7		; else go do "Undefined statement" error
000576r 1               
000576r 1               LAB_line_found
000576r 1               					; carry already set for subtract
000576r 1  A5 AA        	LDA	Baslnl		; get pointer low byte
000578r 1  E9 01        	SBC	#$01			; -1
00057Ar 1  A4 AB        	LDY	Baslnh		; get pointer high byte
00057Cr 1  B0 D0        	BCS	LAB_1624		; branch if no underflow (save DATA pointer and return)
00057Er 1               
00057Er 1  90 CD        	BCC	LAB_uflow		; else decrement high byte then save DATA pointer and
000580r 1               					; return (branch always)
000580r 1               
000580r 1               ; perform NULL
000580r 1               
000580r 1               LAB_NULL
000580r 1  20 rr rr     	JSR	LAB_GTBY		; get byte parameter
000583r 1  86 0D        	STX	Nullct		; save new NULL count
000585r 1               LAB_167A
000585r 1  60           	RTS
000586r 1               
000586r 1               ; perform CONT
000586r 1               
000586r 1               LAB_CONT
000586r 1  D0 FD        	BNE	LAB_167A		; if following byte exit to do syntax error
000588r 1               
000588r 1  A4 8C        	LDY	Cpntrh		; get continue pointer high byte
00058Ar 1  D0 05        	BNE	LAB_166C		; go do continue if we can
00058Cr 1               
00058Cr 1  A2 1E        	LDX	#$1E			; error code $1E ("Can't continue" error)
00058Er 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
000591r 1               
000591r 1               					; we can continue so ..
000591r 1               LAB_166C
000591r 1  A9 93        	LDA	#TK_ON		; set token for ON
000593r 1  20 rr rr     	JSR	LAB_IRQ		; set IRQ flags
000596r 1  A9 93        	LDA	#TK_ON		; set token for ON
000598r 1  20 rr rr     	JSR	LAB_NMI		; set NMI flags
00059Br 1               
00059Br 1  84 C4        	STY	Bpntrh		; save BASIC execute pointer high byte
00059Dr 1  A5 8B        	LDA	Cpntrl		; get continue pointer low byte
00059Fr 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
0005A1r 1  A5 89        	LDA	Blinel		; get break line low byte
0005A3r 1  A4 8A        	LDY	Blineh		; get break line high byte
0005A5r 1  85 87        	STA	Clinel		; set current line low byte
0005A7r 1  84 88        	STY	Clineh		; set current line high byte
0005A9r 1  60           	RTS
0005AAr 1               
0005AAr 1               ; perform RUN
0005AAr 1               
0005AAr 1               LAB_RUN
0005AAr 1  D0 03        	BNE	LAB_1696		; branch if RUN n
0005ACr 1  4C rr rr     	JMP	LAB_1477		; reset execution to start, clear variables, flush stack and
0005AFr 1               					; return
0005AFr 1               
0005AFr 1               ; does RUN n
0005AFr 1               
0005AFr 1               LAB_1696
0005AFr 1  20 rr rr     	JSR	LAB_147A		; go do "CLEAR"
0005B2r 1  F0 2E        	BEQ	LAB_16B0		; get n and do GOTO n (branch always as CLEAR sets Z=1)
0005B4r 1               
0005B4r 1               ; perform DO
0005B4r 1               
0005B4r 1               LAB_DO
0005B4r 1  A9 05        	LDA	#$05			; need 5 bytes for DO
0005B6r 1  20 rr rr     	JSR	LAB_1212		; check room on stack for A bytes
0005B9r 1  A5 C4        	LDA	Bpntrh		; get BASIC execute pointer high byte
0005BBr 1  48           	PHA				; push on stack
0005BCr 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
0005BEr 1  48           	PHA				; push on stack
0005BFr 1  A5 88        	LDA	Clineh		; get current line high byte
0005C1r 1  48           	PHA				; push on stack
0005C2r 1  A5 87        	LDA	Clinel		; get current line low byte
0005C4r 1  48           	PHA				; push on stack
0005C5r 1  A9 9D        	LDA	#TK_DO		; token for DO
0005C7r 1  48           	PHA				; push on stack
0005C8r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0005CBr 1  4C rr rr     	JMP	LAB_15C2		; go do interpreter inner loop
0005CEr 1               
0005CEr 1               ; perform GOSUB
0005CEr 1               
0005CEr 1               LAB_GOSUB
0005CEr 1  A9 05        	LDA	#$05			; need 5 bytes for GOSUB
0005D0r 1  20 rr rr     	JSR	LAB_1212		; check room on stack for A bytes
0005D3r 1  A5 C4        	LDA	Bpntrh		; get BASIC execute pointer high byte
0005D5r 1  48           	PHA				; push on stack
0005D6r 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
0005D8r 1  48           	PHA				; push on stack
0005D9r 1  A5 88        	LDA	Clineh		; get current line high byte
0005DBr 1  48           	PHA				; push on stack
0005DCr 1  A5 87        	LDA	Clinel		; get current line low byte
0005DEr 1  48           	PHA				; push on stack
0005DFr 1  A9 8D        	LDA	#TK_GOSUB		; token for GOSUB
0005E1r 1  48           	PHA				; push on stack
0005E2r 1               LAB_16B0
0005E2r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0005E5r 1  20 rr rr     	JSR	LAB_GOTO		; perform GOTO n
0005E8r 1  4C rr rr     	JMP	LAB_15C2		; go do interpreter inner loop
0005EBr 1               					; (can't RTS, we used the stack!)
0005EBr 1               
0005EBr 1               ; perform GOTO
0005EBr 1               
0005EBr 1               LAB_GOTO
0005EBr 1  20 rr rr     	JSR	LAB_GFPN		; get fixed-point number into temp integer
0005EEr 1  20 rr rr     	JSR	LAB_SNBL		; scan for next BASIC line
0005F1r 1  A5 88        	LDA	Clineh		; get current line high byte
0005F3r 1  C5 12        	CMP	Itemph		; compare with temporary integer high byte
0005F5r 1  B0 0B        	BCS	LAB_16D0		; branch if >= (start search from beginning)
0005F7r 1               
0005F7r 1  98           	TYA				; else copy line index to A
0005F8r 1  38           	SEC				; set carry (+1)
0005F9r 1  65 C3        	ADC	Bpntrl		; add BASIC execute pointer low byte
0005FBr 1  A6 C4        	LDX	Bpntrh		; get BASIC execute pointer high byte
0005FDr 1  90 07        	BCC	LAB_16D4		; branch if no overflow to high byte
0005FFr 1               
0005FFr 1  E8           	INX				; increment high byte
000600r 1  B0 04        	BCS	LAB_16D4		; branch always (can never be carry)
000602r 1               
000602r 1               ; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml)
000602r 1               
000602r 1               LAB_16D0
000602r 1  A5 79        	LDA	Smeml			; get start of mem low byte
000604r 1  A6 7A        	LDX	Smemh			; get start of mem high byte
000606r 1               
000606r 1               ; search for line # in temp (Itempl/Itemph) from (AX)
000606r 1               
000606r 1               LAB_16D4
000606r 1  20 rr rr     	JSR	LAB_SHLN		; search Basic for temp integer line number from AX
000609r 1  90 67        	BCC	LAB_16F7		; if carry clear go do "Undefined statement" error
00060Br 1               					; (unspecified statement)
00060Br 1               
00060Br 1               					; carry already set for subtract
00060Br 1  A5 AA        	LDA	Baslnl		; get pointer low byte
00060Dr 1  E9 01        	SBC	#$01			; -1
00060Fr 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
000611r 1  A5 AB        	LDA	Baslnh		; get pointer high byte
000613r 1  E9 00        	SBC	#$00			; subtract carry
000615r 1  85 C4        	STA	Bpntrh		; save BASIC execute pointer high byte
000617r 1               LAB_16E5
000617r 1  60           	RTS
000618r 1               
000618r 1               LAB_DONOK
000618r 1  A2 22        	LDX	#$22			; error code $22 ("LOOP without DO" error)
00061Ar 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
00061Dr 1               
00061Dr 1               ; perform LOOP
00061Dr 1               
00061Dr 1               LAB_LOOP
00061Dr 1  A8           	TAY				; save following token
00061Er 1  BA           	TSX				; copy stack pointer
00061Fr 1  BD 03 01     	LDA	LAB_STAK+3,X	; get token byte from stack
000622r 1  C9 9D        	CMP	#TK_DO		; compare with DO token
000624r 1  D0 F2        	BNE	LAB_DONOK		; branch if no matching DO
000626r 1               
000626r 1  E8           	INX				; dump calling routine return address
000627r 1  E8           	INX				; dump calling routine return address
000628r 1  9A           	TXS				; correct stack
000629r 1  98           	TYA				; get saved following token back
00062Ar 1  F0 20        	BEQ	LoopAlways		; if no following token loop forever
00062Cr 1               					; (stack pointer in X)
00062Cr 1               
00062Cr 1  C9 3A        	CMP	#':'			; could be ":"
00062Er 1  F0 1C        	BEQ	LoopAlways		; if :... loop forever
000630r 1               
000630r 1  E9 B4        	SBC	#TK_UNTIL		; subtract token for UNTIL, we know carry is set here
000632r 1  AA           	TAX				; copy to X (if it was UNTIL then Y will be correct)
000633r 1  F0 04        	BEQ	DoRest		; branch if was UNTIL
000635r 1               
000635r 1  CA           	DEX				; decrement result
000636r 1  D0 62        	BNE	LAB_16FC		; if not WHILE go do syntax error and warm start
000638r 1               					; only if the token was WHILE will this fail
000638r 1               
000638r 1  CA           	DEX				; set invert result byte
000639r 1               DoRest
000639r 1  86 98        	STX	Frnxth		; save invert result byte
00063Br 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
00063Er 1  20 rr rr     	JSR	LAB_EVEX		; evaluate expression
000641r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
000643r 1  F0 02        	BEQ	DoCmp			; if =0 go do straight compare
000645r 1               
000645r 1  A9 FF        	LDA	#$FF			; else set all bits
000647r 1               DoCmp
000647r 1  BA           	TSX				; copy stack pointer
000648r 1  45 98        	EOR	Frnxth		; EOR with invert byte
00064Ar 1  D0 1A        	BNE	LoopDone		; if <> 0 clear stack and back to interpreter loop
00064Cr 1               
00064Cr 1               					; loop condition wasn't met so do it again
00064Cr 1               LoopAlways
00064Cr 1  BD 02 01     	LDA	LAB_STAK+2,X	; get current line low byte
00064Fr 1  85 87        	STA	Clinel		; save current line low byte
000651r 1  BD 03 01     	LDA	LAB_STAK+3,X	; get current line high byte
000654r 1  85 88        	STA	Clineh		; save current line high byte
000656r 1  BD 04 01     	LDA	LAB_STAK+4,X	; get BASIC execute pointer low byte
000659r 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
00065Br 1  BD 05 01     	LDA	LAB_STAK+5,X	; get BASIC execute pointer high byte
00065Er 1  85 C4        	STA	Bpntrh		; save BASIC execute pointer high byte
000660r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000663r 1  4C rr rr     	JMP	LAB_15C2		; go do interpreter inner loop
000666r 1               
000666r 1               					; clear stack and back to interpreter loop
000666r 1               LoopDone
000666r 1  E8           	INX				; dump DO token
000667r 1  E8           	INX				; dump current line low byte
000668r 1  E8           	INX				; dump current line high byte
000669r 1  E8           	INX				; dump BASIC execute pointer low byte
00066Ar 1  E8           	INX				; dump BASIC execute pointer high byte
00066Br 1  9A           	TXS				; correct stack
00066Cr 1  4C rr rr     	JMP	LAB_DATA		; go perform DATA (find : or [EOL])
00066Fr 1               
00066Fr 1               ; do the return without gosub error
00066Fr 1               
00066Fr 1               LAB_16F4
00066Fr 1  A2 04        	LDX	#$04			; error code $04 ("RETURN without GOSUB" error)
000671r 1  2C           	.byte	$2C			; makes next line BIT LAB_0EA2
000672r 1               
000672r 1               LAB_16F7				; do undefined statement error
000672r 1  A2 0E        	LDX	#$0E			; error code $0E ("Undefined statement" error)
000674r 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
000677r 1               
000677r 1               ; perform RETURN
000677r 1               
000677r 1               LAB_RETURN
000677r 1  D0 9E        	BNE	LAB_16E5		; exit if following token (to allow syntax error)
000679r 1               
000679r 1               LAB_16E8
000679r 1  68           	PLA				; dump calling routine return address
00067Ar 1  68           	PLA				; dump calling routine return address
00067Br 1  68           	PLA				; pull token
00067Cr 1  C9 8D        	CMP	#TK_GOSUB		; compare with GOSUB token
00067Er 1  D0 EF        	BNE	LAB_16F4		; branch if no matching GOSUB
000680r 1               
000680r 1               LAB_16FF
000680r 1  68           	PLA				; pull current line low byte
000681r 1  85 87        	STA	Clinel		; save current line low byte
000683r 1  68           	PLA				; pull current line high byte
000684r 1  85 88        	STA	Clineh		; save current line high byte
000686r 1  68           	PLA				; pull BASIC execute pointer low byte
000687r 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
000689r 1  68           	PLA				; pull BASIC execute pointer high byte
00068Ar 1  85 C4        	STA	Bpntrh		; save BASIC execute pointer high byte
00068Cr 1               
00068Cr 1               					; now do the DATA statement as we could be returning into
00068Cr 1               					; the middle of an ON <var> GOSUB n,m,p,q line
00068Cr 1               					; (the return address used by the DATA statement is the one
00068Cr 1               					; pushed before the GOSUB was executed!)
00068Cr 1               
00068Cr 1               ; perform DATA
00068Cr 1               
00068Cr 1               LAB_DATA
00068Cr 1  20 rr rr     	JSR	LAB_SNBS		; scan for next BASIC statement ([:] or [EOL])
00068Fr 1               
00068Fr 1               					; set BASIC execute pointer
00068Fr 1               LAB_170F
00068Fr 1  98           	TYA				; copy index to A
000690r 1  18           	CLC				; clear carry for add
000691r 1  65 C3        	ADC	Bpntrl		; add BASIC execute pointer low byte
000693r 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
000695r 1  90 02        	BCC	LAB_1719		; skip next if no carry
000697r 1               
000697r 1  E6 C4        	INC	Bpntrh		; else increment BASIC execute pointer high byte
000699r 1               LAB_1719
000699r 1  60           	RTS
00069Ar 1               
00069Ar 1               LAB_16FC
00069Ar 1  4C rr rr     	JMP	LAB_SNER		; do syntax error then warm start
00069Dr 1               
00069Dr 1               ; scan for next BASIC statement ([:] or [EOL])
00069Dr 1               ; returns Y as index to [:] or [EOL]
00069Dr 1               
00069Dr 1               LAB_SNBS
00069Dr 1  A2 3A        	LDX	#':'			; set look for character = ":"
00069Fr 1  2C           	.byte	$2C			; makes next line BIT $00A2
0006A0r 1               
0006A0r 1               ; scan for next BASIC line
0006A0r 1               ; returns Y as index to [EOL]
0006A0r 1               
0006A0r 1               LAB_SNBL
0006A0r 1  A2 00        	LDX	#$00			; set alt search character = [EOL]
0006A2r 1  A0 00        	LDY	#$00			; set search character = [EOL]
0006A4r 1  84 5C        	STY	Asrch			; store search character
0006A6r 1               LAB_1725
0006A6r 1  8A           	TXA				; get alt search character
0006A7r 1  45 5C        	EOR	Asrch			; toggle search character, effectively swap with $00
0006A9r 1  85 5C        	STA	Asrch			; save swapped search character
0006ABr 1               LAB_172D
0006ABr 1  B1 C3        	LDA	(Bpntrl),Y		; get next byte
0006ADr 1  F0 EA        	BEQ	LAB_1719		; exit if null [EOL]
0006AFr 1               
0006AFr 1  C5 5C        	CMP	Asrch			; compare with search character
0006B1r 1  F0 E6        	BEQ	LAB_1719		; exit if found
0006B3r 1               
0006B3r 1  C8           	INY				; increment index
0006B4r 1  C9 22        	CMP	#$22			; compare current character with open quote
0006B6r 1  D0 F3        	BNE	LAB_172D		; if not open quote go get next character
0006B8r 1               
0006B8r 1  F0 EC        	BEQ	LAB_1725		; if found go swap search character for alt search character
0006BAr 1               
0006BAr 1               ; perform IF
0006BAr 1               
0006BAr 1               LAB_IF
0006BAr 1  20 rr rr     	JSR	LAB_EVEX		; evaluate the expression
0006BDr 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0006C0r 1  C9 B1        	CMP	#TK_THEN		; compare with THEN token
0006C2r 1  F0 11        	BEQ	LAB_174B		; if it was THEN go do IF
0006C4r 1               
0006C4r 1               					; wasn't IF .. THEN so must be IF .. GOTO
0006C4r 1  C9 89        	CMP	#TK_GOTO		; compare with GOTO token
0006C6r 1  D0 D2        	BNE	LAB_16FC		; if it wasn't GOTO go do syntax error
0006C8r 1               
0006C8r 1  A6 C3        	LDX	Bpntrl		; save the basic pointer low byte
0006CAr 1  A4 C4        	LDY	Bpntrh		; save the basic pointer high byte
0006CCr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0006CFr 1  B0 C9        	BCS	LAB_16FC		; if not numeric go do syntax error
0006D1r 1               
0006D1r 1  86 C3        	STX	Bpntrl		; restore the basic pointer low byte
0006D3r 1  84 C4        	STY	Bpntrh		; restore the basic pointer high byte
0006D5r 1               LAB_174B
0006D5r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
0006D7r 1  F0 1B        	BEQ	LAB_174E		; if the result was zero go look for an ELSE
0006D9r 1               
0006D9r 1  20 BC 00     	JSR	LAB_IGBY		; else increment and scan memory
0006DCr 1  B0 03        	BCS	LAB_174D		; if not numeric go do var or keyword
0006DEr 1               
0006DEr 1               LAB_174C
0006DEr 1  4C rr rr     	JMP	LAB_GOTO		; else was numeric so do GOTO n
0006E1r 1               
0006E1r 1               					; is var or keyword
0006E1r 1               LAB_174D
0006E1r 1  C9 90        	CMP	#TK_RETURN		; compare the byte with the token for RETURN
0006E3r 1  D0 03        	BNE	LAB_174G		; if it wasn't RETURN go interpret BASIC code from (Bpntrl)
0006E5r 1               					; and return to this code to process any following code
0006E5r 1               
0006E5r 1  4C rr rr     	JMP	LAB_1602		; else it was RETURN so interpret BASIC code from (Bpntrl)
0006E8r 1               					; but don't return here
0006E8r 1               
0006E8r 1               LAB_174G
0006E8r 1  20 rr rr     	JSR	LAB_15FF		; interpret BASIC code from (Bpntrl)
0006EBr 1               
0006EBr 1               ; the IF was executed and there may be a following ELSE so the code needs to return
0006EBr 1               ; here to check and ignore the ELSE if present
0006EBr 1               
0006EBr 1  A0 00        	LDY	#$00			; clear the index
0006EDr 1  B1 C3        	LDA	(Bpntrl),Y		; get the next BASIC byte
0006EFr 1  C9 AD        	CMP	#TK_ELSE		; compare it with the token for ELSE
0006F1r 1  F0 99        	BEQ	LAB_DATA		; if ELSE ignore the following statement
0006F3r 1               
0006F3r 1               ; there was no ELSE so continue execution of IF <expr> THEN <stat> [: <stat>]. any
0006F3r 1               ; following ELSE will, correctly, cause a syntax error
0006F3r 1               
0006F3r 1  60           	RTS				; else return to the interpreter inner loop
0006F4r 1               
0006F4r 1               ; perform ELSE after IF
0006F4r 1               
0006F4r 1               LAB_174E
0006F4r 1  A0 00        	LDY	#$00			; clear the BASIC byte index
0006F6r 1  A2 01        	LDX	#$01			; clear the nesting depth
0006F8r 1               LAB_1750
0006F8r 1  C8           	INY				; increment the BASIC byte index
0006F9r 1  B1 C3        	LDA	(Bpntrl),Y		; get the next BASIC byte
0006FBr 1  F0 0F        	BEQ	LAB_1753		; if EOL go add the pointer and return
0006FDr 1               
0006FDr 1  C9 8B        	CMP	#TK_IF		; compare the byte with the token for IF
0006FFr 1  D0 03        	BNE	LAB_1752		; if not IF token skip the depth increment
000701r 1               
000701r 1  E8           	INX				; else increment the nesting depth ..
000702r 1  D0 F4        	BNE	LAB_1750		; .. and continue looking
000704r 1               
000704r 1               LAB_1752
000704r 1  C9 AD        	CMP	#TK_ELSE		; compare the byte with the token for ELSE
000706r 1  D0 F0        	BNE	LAB_1750		; if not ELSE token continue looking
000708r 1               
000708r 1  CA           	DEX				; was ELSE so decrement the nesting depth
000709r 1  D0 ED        	BNE	LAB_1750		; loop if still nested
00070Br 1               
00070Br 1  C8           	INY				; increment the BASIC byte index past the ELSE
00070Cr 1               
00070Cr 1               ; found the matching ELSE, now do <{n|statement}>
00070Cr 1               
00070Cr 1               LAB_1753
00070Cr 1  98           	TYA				; else copy line index to A
00070Dr 1  18           	CLC				; clear carry for add
00070Er 1  65 C3        	ADC	Bpntrl		; add the BASIC execute pointer low byte
000710r 1  85 C3        	STA	Bpntrl		; save the BASIC execute pointer low byte
000712r 1  90 02        	BCC	LAB_1754		; branch if no overflow to high byte
000714r 1               
000714r 1  E6 C4        	INC	Bpntrh		; else increment the BASIC execute pointer high byte
000716r 1               LAB_1754
000716r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000719r 1  90 C3        	BCC	LAB_174C		; if numeric do GOTO n
00071Br 1               					; the code will return to the interpreter loop at the
00071Br 1               					; tail end of the GOTO <n>
00071Br 1               
00071Br 1  4C rr rr     	JMP	LAB_15FF		; interpret BASIC code from (Bpntrl)
00071Er 1               					; the code will return to the interpreter loop at the
00071Er 1               					; tail end of the <statement>
00071Er 1               
00071Er 1               ; perform REM, skip (rest of) line
00071Er 1               
00071Er 1               LAB_REM
00071Er 1  20 rr rr     	JSR	LAB_SNBL		; scan for next BASIC line
000721r 1  4C rr rr     	JMP	LAB_170F		; go set BASIC execute pointer and return, branch always
000724r 1               
000724r 1               LAB_16FD
000724r 1  4C rr rr     	JMP	LAB_SNER		; do syntax error then warm start
000727r 1               
000727r 1               ; perform ON
000727r 1               
000727r 1               LAB_ON
000727r 1  C9 A9        	CMP	#TK_IRQ		; was it IRQ token ?
000729r 1  D0 03        	BNE	LAB_NOIN		; if not go check NMI
00072Br 1               
00072Br 1  4C rr rr     	JMP	LAB_SIRQ		; else go set-up IRQ
00072Er 1               
00072Er 1               LAB_NOIN
00072Er 1  C9 AA        	CMP	#TK_NMI		; was it NMI token ?
000730r 1  D0 03        	BNE	LAB_NONM		; if not go do normal ON command
000732r 1               
000732r 1  4C rr rr     	JMP	LAB_SNMI		; else go set-up NMI
000735r 1               
000735r 1               LAB_NONM
000735r 1  20 rr rr     	JSR	LAB_GTBY		; get byte parameter
000738r 1  48           	PHA				; push GOTO/GOSUB token
000739r 1  C9 8D        	CMP	#TK_GOSUB		; compare with GOSUB token
00073Br 1  F0 04        	BEQ	LAB_176B		; branch if GOSUB
00073Dr 1               
00073Dr 1  C9 89        	CMP	#TK_GOTO		; compare with GOTO token
00073Fr 1               LAB_1767
00073Fr 1  D0 E3        	BNE	LAB_16FD		; if not GOTO do syntax error then warm start
000741r 1               
000741r 1               
000741r 1               ; next character was GOTO or GOSUB
000741r 1               
000741r 1               LAB_176B
000741r 1  C6 AF        	DEC	FAC1_3		; decrement index (byte value)
000743r 1  D0 04        	BNE	LAB_1773		; branch if not zero
000745r 1               
000745r 1  68           	PLA				; pull GOTO/GOSUB token
000746r 1  4C rr rr     	JMP	LAB_1602		; go execute it
000749r 1               
000749r 1               LAB_1773
000749r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
00074Cr 1  20 rr rr     	JSR	LAB_GFPN		; get fixed-point number into temp integer (skip this n)
00074Fr 1               					; (we could LDX #"," and JSR LAB_SNBL+2, then we
00074Fr 1               					; just BNE LAB_176B for the loop. should be quicker ..
00074Fr 1               					; no we can't, what if we meet a colon or [EOL]?)
00074Fr 1  C9 2C        	CMP	#$2C			; compare next character with ","
000751r 1  F0 EE        	BEQ	LAB_176B		; loop if ","
000753r 1               
000753r 1               LAB_177E
000753r 1  68           	PLA				; else pull keyword token (run out of options)
000754r 1               					; also dump +/-1 pointer low byte and exit
000754r 1               LAB_177F
000754r 1  60           	RTS
000755r 1               
000755r 1               ; takes n * 106 + 11 cycles where n is the number of digits
000755r 1               
000755r 1               ; get fixed-point number into temp integer
000755r 1               
000755r 1               LAB_GFPN
000755r 1  A2 00        	LDX	#$00			; clear reg
000757r 1  86 11        	STX	Itempl		; clear temporary integer low byte
000759r 1               LAB_1785
000759r 1  86 12        	STX	Itemph		; save temporary integer high byte
00075Br 1  B0 F7        	BCS	LAB_177F		; return if carry set, end of scan, character was
00075Dr 1               					; not 0-9
00075Dr 1               
00075Dr 1  E0 19        	CPX	#$19			; compare high byte with $19
00075Fr 1  A8           	TAY				; ensure Zb = 0 if the branch is taken
000760r 1  B0 DD        	BCS	LAB_1767		; branch if >=, makes max line # 63999 because next
000762r 1               					; bit does *$0A, = 64000, compare at target will fail
000762r 1               					; and do syntax error
000762r 1               
000762r 1  E9 2F        	SBC	#'0'-1		; subtract "0", $2F + carry, from byte
000764r 1  A8           	TAY				; copy binary digit
000765r 1  A5 11        	LDA	Itempl		; get temporary integer low byte
000767r 1  0A           	ASL				; *2 low byte
000768r 1  26 12        	ROL	Itemph		; *2 high byte
00076Ar 1  0A           	ASL				; *2 low byte
00076Br 1  26 12        	ROL	Itemph		; *2 high byte, *4
00076Dr 1  65 11        	ADC	Itempl		; + low byte, *5
00076Fr 1  85 11        	STA	Itempl		; save it
000771r 1  8A           	TXA				; get high byte copy to A
000772r 1  65 12        	ADC	Itemph		; + high byte, *5
000774r 1  06 11        	ASL	Itempl		; *2 low byte, *10d
000776r 1  2A           	ROL				; *2 high byte, *10d
000777r 1  AA           	TAX				; copy high byte back to X
000778r 1  98           	TYA				; get binary digit back
000779r 1  65 11        	ADC	Itempl		; add number low byte
00077Br 1  85 11        	STA	Itempl		; save number low byte
00077Dr 1  90 01        	BCC	LAB_17B3		; if no overflow to high byte get next character
00077Fr 1               
00077Fr 1  E8           	INX				; else increment high byte
000780r 1               LAB_17B3
000780r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
000783r 1  4C rr rr     	JMP	LAB_1785		; loop for next character
000786r 1               
000786r 1               ; perform DEC
000786r 1               
000786r 1               LAB_DEC
000786r 1  A9 rr        	LDA	#<LAB_2AFD		; set -1 pointer low byte
000788r 1  2C           	.byte	$2C			; BIT abs to skip the LDA below
000789r 1               
000789r 1               ; perform INC
000789r 1               
000789r 1               LAB_INC
000789r 1  A9 rr        	LDA	#<LAB_259C		; set 1 pointer low byte
00078Br 1               LAB_17B5
00078Br 1  48           	PHA				; save +/-1 pointer low byte
00078Cr 1               LAB_17B7
00078Cr 1  20 rr rr     	JSR	LAB_GVAR		; get var address
00078Fr 1  A6 5F        	LDX	Dtypef		; get data type flag, $FF=string, $00=numeric
000791r 1  30 1E        	BMI	IncrErr		; exit if string
000793r 1               
000793r 1  85 97        	STA	Lvarpl		; save var address low byte
000795r 1  84 98        	STY	Lvarph		; save var address high byte
000797r 1  20 rr rr     	JSR	LAB_UFAC		; unpack memory (AY) into FAC1
00079Ar 1  68           	PLA				; get +/-1 pointer low byte
00079Br 1  48           	PHA				; save +/-1 pointer low byte
00079Cr 1  A0 rr        	LDY	#>LAB_259C		; set +/-1 pointer high byte (both the same)
00079Er 1  20 rr rr     	JSR	LAB_246C		; add (AY) to FAC1
0007A1r 1  20 rr rr     	JSR	LAB_PFAC		; pack FAC1 into variable (Lvarpl)
0007A4r 1               
0007A4r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0007A7r 1  C9 2C        	CMP	#','			; compare with ","
0007A9r 1  D0 A8        	BNE	LAB_177E		; exit if not "," (either end or error)
0007ABr 1               
0007ABr 1               					; was "," so another INCR variable to do
0007ABr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0007AEr 1  4C rr rr     	JMP	LAB_17B7		; go do next var
0007B1r 1               
0007B1r 1               IncrErr
0007B1r 1  4C rr rr     	JMP	LAB_1ABC		; do "Type mismatch" error then warm start
0007B4r 1               
0007B4r 1               ; perform LET
0007B4r 1               
0007B4r 1               LAB_LET
0007B4r 1  20 rr rr     	JSR	LAB_GVAR		; get var address
0007B7r 1  85 97        	STA	Lvarpl		; save var address low byte
0007B9r 1  84 98        	STY	Lvarph		; save var address high byte
0007BBr 1  A9 C2        	LDA	#TK_EQUAL		; get = token
0007BDr 1  20 rr rr     	JSR	LAB_SCCA		; scan for CHR$(A), else do syntax error then warm start
0007C0r 1  A5 5F        	LDA	Dtypef		; get data type flag, $FF=string, $00=numeric
0007C2r 1  48           	PHA				; push data type flag
0007C3r 1  20 rr rr     	JSR	LAB_EVEX		; evaluate expression
0007C6r 1  68           	PLA				; pop data type flag
0007C7r 1  2A           	ROL				; set carry if type = string
0007C8r 1  20 rr rr     	JSR	LAB_CKTM		; type match check, set C for string
0007CBr 1  D0 03        	BNE	LAB_17D5		; branch if string
0007CDr 1               
0007CDr 1  4C rr rr     	JMP	LAB_PFAC		; pack FAC1 into variable (Lvarpl) and return
0007D0r 1               
0007D0r 1               ; string LET
0007D0r 1               
0007D0r 1               LAB_17D5
0007D0r 1  A0 02        	LDY	#$02			; set index to pointer high byte
0007D2r 1  B1 AE        	LDA	(des_pl),Y		; get string pointer high byte
0007D4r 1  C5 82        	CMP	Sstorh		; compare bottom of string space high byte
0007D6r 1  90 17        	BCC	LAB_17F4		; if less assign value and exit (was in program memory)
0007D8r 1               
0007D8r 1  D0 07        	BNE	LAB_17E6		; branch if >
0007DAr 1               					; else was equal so compare low bytes
0007DAr 1  88           	DEY				; decrement index
0007DBr 1  B1 AE        	LDA	(des_pl),Y		; get pointer low byte
0007DDr 1  C5 81        	CMP	Sstorl		; compare bottom of string space low byte
0007DFr 1  90 0E        	BCC	LAB_17F4		; if less assign value and exit (was in program memory)
0007E1r 1               
0007E1r 1               					; pointer was >= to bottom of string space pointer
0007E1r 1               LAB_17E6
0007E1r 1  A4 AF        	LDY	des_ph		; get descriptor pointer high byte
0007E3r 1  C4 7C        	CPY	Svarh			; compare start of vars high byte
0007E5r 1  90 08        	BCC	LAB_17F4		; branch if less (descriptor is on stack)
0007E7r 1               
0007E7r 1  D0 0D        	BNE	LAB_17FB		; branch if greater (descriptor is not on stack)
0007E9r 1               
0007E9r 1               					; else high bytes were equal so ..
0007E9r 1  A5 AE        	LDA	des_pl		; get descriptor pointer low byte
0007EBr 1  C5 7B        	CMP	Svarl			; compare start of vars low byte
0007EDr 1  B0 07        	BCS	LAB_17FB		; branch if >= (descriptor is not on stack)
0007EFr 1               
0007EFr 1               LAB_17F4
0007EFr 1  A5 AE        	LDA	des_pl		; get descriptor pointer low byte
0007F1r 1  A4 AF        	LDY	des_ph		; get descriptor pointer high byte
0007F3r 1  4C rr rr     	JMP	LAB_1811		; clean stack, copy descriptor to variable and return
0007F6r 1               
0007F6r 1               					; make space and copy string
0007F6r 1               LAB_17FB
0007F6r 1  A0 00        	LDY	#$00			; index to length
0007F8r 1  B1 AE        	LDA	(des_pl),Y		; get string length
0007FAr 1  20 rr rr     	JSR	LAB_209C		; copy string
0007FDr 1  A5 9E        	LDA	des_2l		; get descriptor pointer low byte
0007FFr 1  A4 9F        	LDY	des_2h		; get descriptor pointer high byte
000801r 1  85 B8        	STA	ssptr_l		; save descriptor pointer low byte
000803r 1  84 B9        	STY	ssptr_h		; save descriptor pointer high byte
000805r 1  20 rr rr     	JSR	LAB_228A		; copy string from descriptor (sdescr) to (Sutill)
000808r 1  A9 AC        	LDA	#<FAC1_e		; set descriptor pointer low byte
00080Ar 1  A0 00        	LDY	#>FAC1_e		; get descriptor pointer high byte
00080Cr 1               
00080Cr 1               					; clean stack and assign value to string variable
00080Cr 1               LAB_1811
00080Cr 1  85 9E        	STA	des_2l		; save descriptor_2 pointer low byte
00080Er 1  84 9F        	STY	des_2h		; save descriptor_2 pointer high byte
000810r 1  20 rr rr     	JSR	LAB_22EB		; clean descriptor stack, YA = pointer
000813r 1  A0 00        	LDY	#$00			; index to length
000815r 1  B1 9E        	LDA	(des_2l),Y		; get string length
000817r 1  91 97        	STA	(Lvarpl),Y		; copy to let string variable
000819r 1  C8           	INY				; index to string pointer low byte
00081Ar 1  B1 9E        	LDA	(des_2l),Y		; get string pointer low byte
00081Cr 1  91 97        	STA	(Lvarpl),Y		; copy to let string variable
00081Er 1  C8           	INY				; index to string pointer high byte
00081Fr 1  B1 9E        	LDA	(des_2l),Y		; get string pointer high byte
000821r 1  91 97        	STA	(Lvarpl),Y		; copy to let string variable
000823r 1  60           	RTS
000824r 1               
000824r 1               ; perform GET
000824r 1               
000824r 1               LAB_GET
000824r 1  20 rr rr     	JSR	LAB_GVAR		; get var address
000827r 1  85 97        	STA	Lvarpl		; save var address low byte
000829r 1  84 98        	STY	Lvarph		; save var address high byte
00082Br 1  20 rr rr     	JSR	INGET			; get input byte
00082Er 1  A6 5F        	LDX	Dtypef		; get data type flag, $FF=string, $00=numeric
000830r 1  30 07        	BMI	LAB_GETS		; go get string character
000832r 1               
000832r 1               					; was numeric get
000832r 1  A8           	TAY				; copy character to Y
000833r 1  20 rr rr     	JSR	LAB_1FD0		; convert Y to byte in FAC1
000836r 1  4C rr rr     	JMP	LAB_PFAC		; pack FAC1 into variable (Lvarpl) and return
000839r 1               
000839r 1               LAB_GETS
000839r 1  48           	PHA				; save character
00083Ar 1  A9 01        	LDA	#$01			; string is single byte
00083Cr 1  B0 01        	BCS	LAB_IsByte		; branch if byte received
00083Er 1               
00083Er 1  68           	PLA				; string is null
00083Fr 1               LAB_IsByte
00083Fr 1  20 rr rr     	JSR	LAB_MSSP		; make string space A bytes long A=$AC=length,
000842r 1               					; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte
000842r 1  F0 05        	BEQ	LAB_NoSt		; skip store if null string
000844r 1               
000844r 1  68           	PLA				; get character back
000845r 1  A0 00        	LDY	#$00			; clear index
000847r 1  91 AD        	STA	(str_pl),Y		; save byte in string (byte IS string!)
000849r 1               LAB_NoSt
000849r 1  20 rr rr     	JSR	LAB_RTST		; check for space on descriptor stack then put address
00084Cr 1               					; and length on descriptor stack and update stack pointers
00084Cr 1               
00084Cr 1  4C rr rr     	JMP	LAB_17D5		; do string LET and return
00084Fr 1               
00084Fr 1               ; perform PRINT
00084Fr 1               
00084Fr 1               LAB_1829
00084Fr 1  20 rr rr     	JSR	LAB_18C6		; print string from Sutill/Sutilh
000852r 1               LAB_182C
000852r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000855r 1               
000855r 1               ; PRINT
000855r 1               
000855r 1               LAB_PRINT
000855r 1  F0 3B        	BEQ	LAB_CRLF		; if nothing following just print CR/LF
000857r 1               
000857r 1               LAB_1831
000857r 1  C9 AC        	CMP	#TK_TAB		; compare with TAB( token
000859r 1  F0 56        	BEQ	LAB_18A2		; go do TAB/SPC
00085Br 1               
00085Br 1  C9 B0        	CMP	#TK_SPC		; compare with SPC( token
00085Dr 1  F0 52        	BEQ	LAB_18A2		; go do TAB/SPC
00085Fr 1               
00085Fr 1  C9 2C        	CMP	#','			; compare with ","
000861r 1  F0 38        	BEQ	LAB_188B		; go do move to next TAB mark
000863r 1               
000863r 1  C9 3B        	CMP	#';'			; compare with ";"
000865r 1  F0 66        	BEQ	LAB_18BD		; if ";" continue with PRINT processing
000867r 1               
000867r 1  20 rr rr     	JSR	LAB_EVEX		; evaluate expression
00086Ar 1  24 5F        	BIT	Dtypef		; test data type flag, $FF=string, $00=numeric
00086Cr 1  30 E1        	BMI	LAB_1829		; branch if string
00086Er 1               
00086Er 1  20 rr rr     	JSR	LAB_296E		; convert FAC1 to string
000871r 1  20 rr rr     	JSR	LAB_20AE		; print " terminated string to Sutill/Sutilh
000874r 1  A0 00        	LDY	#$00			; clear index
000876r 1               
000876r 1               ; don't check fit if terminal width byte is zero
000876r 1               
000876r 1  A5 0F        	LDA	TWidth		; get terminal width byte
000878r 1  F0 0A        	BEQ	LAB_185E		; skip check if zero
00087Ar 1               
00087Ar 1  38           	SEC				; set carry for subtract
00087Br 1  E5 0E        	SBC	TPos			; subtract terminal position
00087Dr 1  F1 AE        	SBC	(des_pl),Y		; subtract string length
00087Fr 1  B0 03        	BCS	LAB_185E		; branch if less than terminal width
000881r 1               
000881r 1  20 rr rr     	JSR	LAB_CRLF		; else print CR/LF
000884r 1               LAB_185E
000884r 1  20 rr rr     	JSR	LAB_18C6		; print string from Sutill/Sutilh
000887r 1  F0 C9        	BEQ	LAB_182C		; always go continue processing line
000889r 1               
000889r 1               ; CR/LF return to BASIC from BASIC input handler
000889r 1               
000889r 1               LAB_1866
000889r 1  A9 00        	LDA	#$00			; clear byte
00088Br 1  9D 0D 02     	STA	Ibuffs,X		; null terminate input
00088Er 1  A2 0D        	LDX	#<Ibuffs		; set X to buffer start-1 low byte
000890r 1  A0 02        	LDY	#>Ibuffs		; set Y to buffer start-1 high byte
000892r 1               
000892r 1               ; print CR/LF
000892r 1               
000892r 1               LAB_CRLF
000892r 1  A9 0D        	LDA	#$0D			; load [CR]
000894r 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
000897r 1  A9 0A        	LDA	#$0A			; load [LF]
000899r 1  D0 52        	BNE	LAB_PRNA		; go print the character and return, branch always
00089Br 1               
00089Br 1               LAB_188B
00089Br 1  A5 0E        	LDA	TPos			; get terminal position
00089Dr 1  C5 10        	CMP	Iclim			; compare with input column limit
00089Fr 1  90 05        	BCC	LAB_1897		; branch if less
0008A1r 1               
0008A1r 1  20 rr rr     	JSR	LAB_CRLF		; else print CR/LF (next line)
0008A4r 1  D0 27        	BNE	LAB_18BD		; continue with PRINT processing (branch always)
0008A6r 1               
0008A6r 1               LAB_1897
0008A6r 1  38           	SEC				; set carry for subtract
0008A7r 1               LAB_1898
0008A7r 1  E5 64        	SBC	TabSiz		; subtract TAB size
0008A9r 1  B0 FC        	BCS	LAB_1898		; loop if result was +ve
0008ABr 1               
0008ABr 1  49 FF        	EOR	#$FF			; complement it
0008ADr 1  69 01        	ADC	#$01			; +1 (twos complement)
0008AFr 1  D0 12        	BNE	LAB_18B6		; always print A spaces (result is never $00)
0008B1r 1               
0008B1r 1               					; do TAB/SPC
0008B1r 1               LAB_18A2
0008B1r 1  48           	PHA				; save token
0008B2r 1  20 rr rr     	JSR	LAB_SGBY		; scan and get byte parameter
0008B5r 1  C9 29        	CMP	#$29			; is next character )
0008B7r 1  D0 7B        	BNE	LAB_1910		; if not do syntax error then warm start
0008B9r 1               
0008B9r 1  68           	PLA				; get token back
0008BAr 1  C9 AC        	CMP	#TK_TAB		; was it TAB ?
0008BCr 1  D0 06        	BNE	LAB_18B7		; if not go do SPC
0008BEr 1               
0008BEr 1               					; calculate TAB offset
0008BEr 1  8A           	TXA				; copy integer value to A
0008BFr 1  E5 0E        	SBC	TPos			; subtract terminal position
0008C1r 1  90 0A        	BCC	LAB_18BD		; branch if result was < 0 (can't TAB backwards)
0008C3r 1               
0008C3r 1               					; print A spaces
0008C3r 1               LAB_18B6
0008C3r 1  AA           	TAX				; copy result to X
0008C4r 1               LAB_18B7
0008C4r 1  8A           	TXA				; set flags on size for SPC
0008C5r 1  F0 06        	BEQ	LAB_18BD		; branch if result was = $0, already here
0008C7r 1               
0008C7r 1               					; print X spaces
0008C7r 1               LAB_18BA
0008C7r 1  20 rr rr     	JSR	LAB_18E0		; print " "
0008CAr 1  CA           	DEX				; decrement count
0008CBr 1  D0 FA        	BNE	LAB_18BA		; loop if not all done
0008CDr 1               
0008CDr 1               					; continue with PRINT processing
0008CDr 1               LAB_18BD
0008CDr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0008D0r 1  D0 85        	BNE	LAB_1831		; if more to print go do it
0008D2r 1               
0008D2r 1  60           	RTS
0008D3r 1               
0008D3r 1               ; print null terminated string from memory
0008D3r 1               
0008D3r 1               LAB_18C3
0008D3r 1  20 rr rr     	JSR	LAB_20AE		; print " terminated string to Sutill/Sutilh
0008D6r 1               
0008D6r 1               ; print string from Sutill/Sutilh
0008D6r 1               
0008D6r 1               LAB_18C6
0008D6r 1  20 rr rr     	JSR	LAB_22B6		; pop string off descriptor stack, or from top of string
0008D9r 1               					; space returns with A = length, X=$71=pointer low byte,
0008D9r 1               					; Y=$72=pointer high byte
0008D9r 1  A0 00        	LDY	#$00			; reset index
0008DBr 1  AA           	TAX				; copy length to X
0008DCr 1  F0 49        	BEQ	LAB_188C		; exit (RTS) if null string
0008DEr 1               
0008DEr 1               LAB_18CD
0008DEr 1               
0008DEr 1  B1 71        	LDA	(ut1_pl),Y		; get next byte
0008E0r 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
0008E3r 1  C8           	INY				; increment index
0008E4r 1  CA           	DEX				; decrement count
0008E5r 1  D0 F7        	BNE	LAB_18CD		; loop if not done yet
0008E7r 1               
0008E7r 1  60           	RTS
0008E8r 1               
0008E8r 1               					; Print single format character
0008E8r 1               ; print " "
0008E8r 1               
0008E8r 1               LAB_18E0
0008E8r 1  A9 20        	LDA	#$20			; load " "
0008EAr 1  2C           	.byte	$2C			; change next line to BIT LAB_3FA9
0008EBr 1               
0008EBr 1               ; print "?" character
0008EBr 1               
0008EBr 1               LAB_18E3
0008EBr 1  A9 3F        	LDA	#$3F			; load "?" character
0008EDr 1               
0008EDr 1               ; print character in A
0008EDr 1               ; now includes the null handler
0008EDr 1               ; also includes infinite line length code
0008EDr 1               ; note! some routines expect this one to exit with Zb=0
0008EDr 1               
0008EDr 1               LAB_PRNA
0008EDr 1  C9 20        	CMP	#' '			; compare with " "
0008EFr 1  90 19        	BCC	LAB_18F9		; branch if less (non printing)
0008F1r 1               
0008F1r 1               					; else printable character
0008F1r 1  48           	PHA				; save the character
0008F2r 1               
0008F2r 1               ; don't check fit if terminal width byte is zero
0008F2r 1               
0008F2r 1  A5 0F        	LDA	TWidth		; get terminal width
0008F4r 1  D0 0A        	BNE	LAB_18F0		; branch if not zero (not infinite length)
0008F6r 1               
0008F6r 1               ; is "infinite line" so check TAB position
0008F6r 1               
0008F6r 1  A5 0E        	LDA	TPos			; get position
0008F8r 1  E5 64        	SBC	TabSiz		; subtract TAB size, carry set by CMP #$20 above
0008FAr 1  D0 0B        	BNE	LAB_18F7		; skip reset if different
0008FCr 1               
0008FCr 1  85 0E        	STA	TPos			; else reset position
0008FEr 1  F0 07        	BEQ	LAB_18F7		; go print character
000900r 1               
000900r 1               LAB_18F0
000900r 1  C5 0E        	CMP	TPos			; compare with terminal character position
000902r 1  D0 03        	BNE	LAB_18F7		; branch if not at end of line
000904r 1               
000904r 1  20 rr rr     	JSR	LAB_CRLF		; else print CR/LF
000907r 1               LAB_18F7
000907r 1  E6 0E        	INC	TPos			; increment terminal position
000909r 1  68           	PLA				; get character back
00090Ar 1               LAB_18F9
00090Ar 1  20 rr rr     	JSR	V_OUTP		; output byte via output vector
00090Dr 1  C9 0D        	CMP	#$0D			; compare with [CR]
00090Fr 1  D0 14        	BNE	LAB_188A		; branch if not [CR]
000911r 1               
000911r 1               					; else print nullct nulls after the [CR]
000911r 1  86 78        	STX	TempB			; save buffer index
000913r 1  A6 0D        	LDX	Nullct		; get null count
000915r 1  F0 0A        	BEQ	LAB_1886		; branch if no nulls
000917r 1               
000917r 1  A9 00        	LDA	#$00			; load [NULL]
000919r 1               LAB_1880
000919r 1  20 rr rr     	JSR	LAB_PRNA		; go print the character
00091Cr 1  CA           	DEX				; decrement count
00091Dr 1  D0 FA        	BNE	LAB_1880		; loop if not all done
00091Fr 1               
00091Fr 1  A9 0D        	LDA	#$0D			; restore the character (and set the flags)
000921r 1               LAB_1886
000921r 1  86 0E        	STX	TPos			; clear terminal position (X always = zero when we get here)
000923r 1  A6 78        	LDX	TempB			; restore buffer index
000925r 1               LAB_188A
000925r 1  29 FF        	AND	#$FF			; set the flags
000927r 1               LAB_188C
000927r 1  60           	RTS
000928r 1               
000928r 1               ; handle bad input data
000928r 1               
000928r 1               LAB_1904
000928r 1  A5 62        	LDA	Imode			; get input mode flag, $00=INPUT, $00=READ
00092Ar 1  10 0B        	BPL	LAB_1913		; branch if INPUT (go do redo)
00092Cr 1               
00092Cr 1  A5 8D        	LDA	Dlinel		; get current DATA line low byte
00092Er 1  A4 8E        	LDY	Dlineh		; get current DATA line high byte
000930r 1  85 87        	STA	Clinel		; save current line low byte
000932r 1  84 88        	STY	Clineh		; save current line high byte
000934r 1               LAB_1910
000934r 1  4C rr rr     	JMP	LAB_SNER		; do syntax error then warm start
000937r 1               
000937r 1               					; mode was INPUT
000937r 1               LAB_1913
000937r 1  A9 rr        	LDA	#<LAB_REDO		; point to redo message (low addr)
000939r 1  A0 rr        	LDY	#>LAB_REDO		; point to redo message (high addr)
00093Br 1  20 rr rr     	JSR	LAB_18C3		; print null terminated string from memory
00093Er 1  A5 8B        	LDA	Cpntrl		; get continue pointer low byte
000940r 1  A4 8C        	LDY	Cpntrh		; get continue pointer high byte
000942r 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
000944r 1  84 C4        	STY	Bpntrh		; save BASIC execute pointer high byte
000946r 1  60           	RTS
000947r 1               
000947r 1               ; perform INPUT
000947r 1               
000947r 1               LAB_INPUT
000947r 1  C9 22        	CMP	#$22			; compare next byte with open quote
000949r 1  D0 0B        	BNE	LAB_1934		; branch if no prompt string
00094Br 1               
00094Br 1  20 rr rr     	JSR	LAB_1BC1		; print "..." string
00094Er 1  A9 3B        	LDA	#$3B			; load A with ";"
000950r 1  20 rr rr     	JSR	LAB_SCCA		; scan for CHR$(A), else do syntax error then warm start
000953r 1  20 rr rr     	JSR	LAB_18C6		; print string from Sutill/Sutilh
000956r 1               
000956r 1               					; done with prompt, now get data
000956r 1               LAB_1934
000956r 1  20 rr rr     	JSR	LAB_CKRN		; check not Direct, back here if ok
000959r 1  20 rr rr     	JSR	LAB_INLN		; print "? " and get BASIC input
00095Cr 1  A9 00        	LDA	#$00			; set mode = INPUT
00095Er 1  CD 0D 02     	CMP	Ibuffs		; test first byte in buffer
000961r 1  D0 0A        	BNE	LAB_1953		; branch if not null input
000963r 1               
000963r 1  18           	CLC				; was null input so clear carry to exit program
000964r 1  4C rr rr     	JMP	LAB_1647		; go do BREAK exit
000967r 1               
000967r 1               ; perform READ
000967r 1               
000967r 1               LAB_READ
000967r 1  A6 8F        	LDX	Dptrl			; get DATA pointer low byte
000969r 1  A4 90        	LDY	Dptrh			; get DATA pointer high byte
00096Br 1  A9 80        	LDA	#$80			; set mode = READ
00096Dr 1               
00096Dr 1               LAB_1953
00096Dr 1  85 62        	STA	Imode			; set input mode flag, $00=INPUT, $80=READ
00096Fr 1  86 91        	STX	Rdptrl		; save READ pointer low byte
000971r 1  84 92        	STY	Rdptrh		; save READ pointer high byte
000973r 1               
000973r 1               					; READ or INPUT next variable from list
000973r 1               LAB_195B
000973r 1  20 rr rr     	JSR	LAB_GVAR		; get (var) address
000976r 1  85 97        	STA	Lvarpl		; save address low byte
000978r 1  84 98        	STY	Lvarph		; save address high byte
00097Ar 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
00097Cr 1  A4 C4        	LDY	Bpntrh		; get BASIC execute pointer high byte
00097Er 1  85 11        	STA	Itempl		; save as temporary integer low byte
000980r 1  84 12        	STY	Itemph		; save as temporary integer high byte
000982r 1  A6 91        	LDX	Rdptrl		; get READ pointer low byte
000984r 1  A4 92        	LDY	Rdptrh		; get READ pointer high byte
000986r 1  86 C3        	STX	Bpntrl		; set BASIC execute pointer low byte
000988r 1  84 C4        	STY	Bpntrh		; set BASIC execute pointer high byte
00098Ar 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
00098Dr 1  D0 11        	BNE	LAB_1988		; branch if not null
00098Fr 1               
00098Fr 1               					; pointer was to null entry
00098Fr 1  24 62        	BIT	Imode			; test input mode flag, $00=INPUT, $80=READ
000991r 1  30 65        	BMI	LAB_19DD		; branch if READ
000993r 1               
000993r 1               					; mode was INPUT
000993r 1  20 rr rr     	JSR	LAB_18E3		; print "?" character (double ? for extended input)
000996r 1  20 rr rr     	JSR	LAB_INLN		; print "? " and get BASIC input
000999r 1  86 C3        	STX	Bpntrl		; set BASIC execute pointer low byte
00099Br 1  84 C4        	STY	Bpntrh		; set BASIC execute pointer high byte
00099Dr 1               LAB_1985
00099Dr 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0009A0r 1               LAB_1988
0009A0r 1  24 5F        	BIT	Dtypef		; test data type flag, $FF=string, $00=numeric
0009A2r 1  10 24        	BPL	LAB_19B0		; branch if numeric
0009A4r 1               
0009A4r 1               					; else get string
0009A4r 1  85 5B        	STA	Srchc			; save search character
0009A6r 1  C9 22        	CMP	#$22			; was it " ?
0009A8r 1  F0 07        	BEQ	LAB_1999		; branch if so
0009AAr 1               
0009AAr 1  A9 3A        	LDA	#':'			; else search character is ":"
0009ACr 1  85 5B        	STA	Srchc			; set new search character
0009AEr 1  A9 2C        	LDA	#','			; other search character is ","
0009B0r 1  18           	CLC				; clear carry for add
0009B1r 1               LAB_1999
0009B1r 1  85 5C        	STA	Asrch			; set second search character
0009B3r 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
0009B5r 1  A4 C4        	LDY	Bpntrh		; get BASIC execute pointer high byte
0009B7r 1               
0009B7r 1  69 00        	ADC	#$00			; c is =1 if we came via the BEQ LAB_1999, else =0
0009B9r 1  90 01        	BCC	LAB_19A4		; branch if no execute pointer low byte rollover
0009BBr 1               
0009BBr 1  C8           	INY				; else increment high byte
0009BCr 1               LAB_19A4
0009BCr 1  20 rr rr     	JSR	LAB_20B4		; print Srchc or Asrch terminated string to Sutill/Sutilh
0009BFr 1  20 rr rr     	JSR	LAB_23F3		; restore BASIC execute pointer from temp (Btmpl/Btmph)
0009C2r 1  20 rr rr     	JSR	LAB_17D5		; go do string LET
0009C5r 1  4C rr rr     	JMP	LAB_19B6		; go check string terminator
0009C8r 1               
0009C8r 1               					; get numeric INPUT
0009C8r 1               LAB_19B0
0009C8r 1  20 rr rr     	JSR	LAB_2887		; get FAC1 from string
0009CBr 1  20 rr rr     	JSR	LAB_PFAC		; pack FAC1 into (Lvarpl)
0009CEr 1               LAB_19B6
0009CEr 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0009D1r 1  F0 0A        	BEQ	LAB_19C5		; branch if null (last entry)
0009D3r 1               
0009D3r 1  C9 2C        	CMP	#','			; else compare with ","
0009D5r 1  F0 03        	BEQ	LAB_19C2		; branch if ","
0009D7r 1               
0009D7r 1  4C rr rr     	JMP	LAB_1904		; else go handle bad input data
0009DAr 1               
0009DAr 1               					; got good input data
0009DAr 1               LAB_19C2
0009DAr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0009DDr 1               LAB_19C5
0009DDr 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte (temp READ/INPUT ptr)
0009DFr 1  A4 C4        	LDY	Bpntrh		; get BASIC execute pointer high byte (temp READ/INPUT ptr)
0009E1r 1  85 91        	STA	Rdptrl		; save for now
0009E3r 1  84 92        	STY	Rdptrh		; save for now
0009E5r 1  A5 11        	LDA	Itempl		; get temporary integer low byte (temp BASIC execute ptr)
0009E7r 1  A4 12        	LDY	Itemph		; get temporary integer high byte (temp BASIC execute ptr)
0009E9r 1  85 C3        	STA	Bpntrl		; set BASIC execute pointer low byte
0009EBr 1  84 C4        	STY	Bpntrh		; set BASIC execute pointer high byte
0009EDr 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0009F0r 1  F0 2C        	BEQ	LAB_1A03		; if null go do extra ignored message
0009F2r 1               
0009F2r 1  20 rr rr     	JSR	LAB_1C01		; else scan for "," , else do syntax error then warm start
0009F5r 1  4C rr rr     	JMP	LAB_195B		; go INPUT next variable from list
0009F8r 1               
0009F8r 1               					; find next DATA statement or do "Out of DATA" error
0009F8r 1               LAB_19DD
0009F8r 1  20 rr rr     	JSR	LAB_SNBS		; scan for next BASIC statement ([:] or [EOL])
0009FBr 1  C8           	INY				; increment index
0009FCr 1  AA           	TAX				; copy character ([:] or [EOL])
0009FDr 1  D0 12        	BNE	LAB_19F6		; branch if [:]
0009FFr 1               
0009FFr 1  A2 06        	LDX	#$06			; set for "Out of DATA" error
000A01r 1  C8           	INY				; increment index, now points to next line pointer high byte
000A02r 1  B1 C3        	LDA	(Bpntrl),Y		; get next line pointer high byte
000A04r 1  F0 73        	BEQ	LAB_1A54		; branch if end (eventually does error X)
000A06r 1               
000A06r 1  C8           	INY				; increment index
000A07r 1  B1 C3        	LDA	(Bpntrl),Y		; get next line # low byte
000A09r 1  85 8D        	STA	Dlinel		; save current DATA line low byte
000A0Br 1  C8           	INY				; increment index
000A0Cr 1  B1 C3        	LDA	(Bpntrl),Y		; get next line # high byte
000A0Er 1  C8           	INY				; increment index
000A0Fr 1  85 8E        	STA	Dlineh		; save current DATA line high byte
000A11r 1               LAB_19F6
000A11r 1  B1 C3        	LDA	(Bpntrl),Y		; get byte
000A13r 1  C8           	INY				; increment index
000A14r 1  AA           	TAX				; copy to X
000A15r 1  20 rr rr     	JSR	LAB_170F		; set BASIC execute pointer
000A18r 1  E0 83        	CPX	#TK_DATA		; compare with "DATA" token
000A1Ar 1  F0 81        	BEQ	LAB_1985		; was "DATA" so go do next READ
000A1Cr 1               
000A1Cr 1  D0 DA        	BNE	LAB_19DD		; go find next statement if not "DATA"
000A1Er 1               
000A1Er 1               ; end of INPUT/READ routine
000A1Er 1               
000A1Er 1               LAB_1A03
000A1Er 1  A5 91        	LDA	Rdptrl		; get temp READ pointer low byte
000A20r 1  A4 92        	LDY	Rdptrh		; get temp READ pointer high byte
000A22r 1  A6 62        	LDX	Imode			; get input mode flag, $00=INPUT, $80=READ
000A24r 1  10 03        	BPL	LAB_1A0E		; branch if INPUT
000A26r 1               
000A26r 1  4C rr rr     	JMP	LAB_1624		; save AY as DATA pointer and return
000A29r 1               
000A29r 1               					; we were getting INPUT
000A29r 1               LAB_1A0E
000A29r 1  A0 00        	LDY	#$00			; clear index
000A2Br 1  B1 91        	LDA	(Rdptrl),Y		; get next byte
000A2Dr 1  D0 01        	BNE	LAB_1A1B		; error if not end of INPUT
000A2Fr 1               
000A2Fr 1  60           	RTS
000A30r 1               
000A30r 1               					; user typed too much
000A30r 1               LAB_1A1B
000A30r 1  A9 rr        	LDA	#<LAB_IMSG		; point to extra ignored message (low addr)
000A32r 1  A0 rr        	LDY	#>LAB_IMSG		; point to extra ignored message (high addr)
000A34r 1  4C rr rr     	JMP	LAB_18C3		; print null terminated string from memory and return
000A37r 1               
000A37r 1               ; search the stack for FOR activity
000A37r 1               ; exit with z=1 if FOR else exit with z=0
000A37r 1               
000A37r 1               LAB_11A1
000A37r 1  BA           	TSX				; copy stack pointer
000A38r 1  E8           	INX				; +1 pass return address
000A39r 1  E8           	INX				; +2 pass return address
000A3Ar 1  E8           	INX				; +3 pass calling routine return address
000A3Br 1  E8           	INX				; +4 pass calling routine return address
000A3Cr 1               LAB_11A6
000A3Cr 1  BD 01 01     	LDA	LAB_STAK+1,X	; get token byte from stack
000A3Fr 1  C9 81        	CMP	#TK_FOR		; is it FOR token
000A41r 1  D0 21        	BNE	LAB_11CE		; exit if not FOR token
000A43r 1               
000A43r 1               					; was FOR token
000A43r 1  A5 98        	LDA	Frnxth		; get var pointer for FOR/NEXT high byte
000A45r 1  D0 0A        	BNE	LAB_11BB		; branch if not null
000A47r 1               
000A47r 1  BD 02 01     	LDA	LAB_STAK+2,X	; get FOR variable pointer low byte
000A4Ar 1  85 97        	STA	Frnxtl		; save var pointer for FOR/NEXT low byte
000A4Cr 1  BD 03 01     	LDA	LAB_STAK+3,X	; get FOR variable pointer high byte
000A4Fr 1  85 98        	STA	Frnxth		; save var pointer for FOR/NEXT high byte
000A51r 1               LAB_11BB
000A51r 1  DD 03 01     	CMP	LAB_STAK+3,X	; compare var pointer with stacked var pointer (high byte)
000A54r 1  D0 07        	BNE	LAB_11C7		; branch if no match
000A56r 1               
000A56r 1  A5 97        	LDA	Frnxtl		; get var pointer for FOR/NEXT low byte
000A58r 1  DD 02 01     	CMP	LAB_STAK+2,X	; compare var pointer with stacked var pointer (low byte)
000A5Br 1  F0 07        	BEQ	LAB_11CE		; exit if match found
000A5Dr 1               
000A5Dr 1               LAB_11C7
000A5Dr 1  8A           	TXA				; copy index
000A5Er 1  18           	CLC				; clear carry for add
000A5Fr 1  69 10        	ADC	#$10			; add FOR stack use size
000A61r 1  AA           	TAX				; copy back to index
000A62r 1  D0 D8        	BNE	LAB_11A6		; loop if not at start of stack
000A64r 1               
000A64r 1               LAB_11CE
000A64r 1  60           	RTS
000A65r 1               
000A65r 1               ; perform NEXT
000A65r 1               
000A65r 1               LAB_NEXT
000A65r 1  D0 04        	BNE	LAB_1A46		; branch if NEXT var
000A67r 1               
000A67r 1  A0 00        	LDY	#$00			; else clear Y
000A69r 1  F0 03        	BEQ	LAB_1A49		; branch always (no variable to search for)
000A6Br 1               
000A6Br 1               ; NEXT var
000A6Br 1               
000A6Br 1               LAB_1A46
000A6Br 1  20 rr rr     	JSR	LAB_GVAR		; get variable address
000A6Er 1               LAB_1A49
000A6Er 1  85 97        	STA	Frnxtl		; store variable pointer low byte
000A70r 1  84 98        	STY	Frnxth		; store variable pointer high byte
000A72r 1               					; (both cleared if no variable defined)
000A72r 1  20 rr rr     	JSR	LAB_11A1		; search the stack for FOR activity
000A75r 1  F0 04        	BEQ	LAB_1A56		; branch if found
000A77r 1               
000A77r 1  A2 00        	LDX	#$00			; else set error $00 ("NEXT without FOR" error)
000A79r 1               LAB_1A54
000A79r 1  F0 63        	BEQ	LAB_1ABE		; do error #X, then warm start
000A7Br 1               
000A7Br 1               LAB_1A56
000A7Br 1  9A           	TXS				; set stack pointer, X set by search, dumps return addresses
000A7Cr 1               
000A7Cr 1  8A           	TXA				; copy stack pointer
000A7Dr 1  38           	SEC				; set carry for subtract
000A7Er 1  E9 F7        	SBC	#$F7			; point to TO var
000A80r 1  85 73        	STA	ut2_pl		; save pointer to TO var for compare
000A82r 1  69 FB        	ADC	#$FB			; point to STEP var
000A84r 1               
000A84r 1  A0 01        	LDY	#>LAB_STAK		; point to stack page high byte
000A86r 1  20 rr rr     	JSR	LAB_UFAC		; unpack memory (STEP value) into FAC1
000A89r 1  BA           	TSX				; get stack pointer back
000A8Ar 1  BD 08 01     	LDA	LAB_STAK+8,X	; get step sign
000A8Dr 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
000A8Fr 1  A5 97        	LDA	Frnxtl		; get FOR variable pointer low byte
000A91r 1  A4 98        	LDY	Frnxth		; get FOR variable pointer high byte
000A93r 1  20 rr rr     	JSR	LAB_246C		; add (FOR variable) to FAC1
000A96r 1  20 rr rr     	JSR	LAB_PFAC		; pack FAC1 into (FOR variable)
000A99r 1  A0 01        	LDY	#>LAB_STAK		; point to stack page high byte
000A9Br 1  20 rr rr     	JSR	LAB_27FA		; compare FAC1 with (Y,ut2_pl) (TO value)
000A9Er 1  BA           	TSX				; get stack pointer back
000A9Fr 1  DD 08 01     	CMP	LAB_STAK+8,X	; compare step sign
000AA2r 1  F0 17        	BEQ	LAB_1A9B		; branch if = (loop complete)
000AA4r 1               
000AA4r 1               					; loop back and do it all again
000AA4r 1  BD 0D 01     	LDA	LAB_STAK+$0D,X	; get FOR line low byte
000AA7r 1  85 87        	STA	Clinel		; save current line low byte
000AA9r 1  BD 0E 01     	LDA	LAB_STAK+$0E,X	; get FOR line high byte
000AACr 1  85 88        	STA	Clineh		; save current line high byte
000AAEr 1  BD 10 01     	LDA	LAB_STAK+$10,X	; get BASIC execute pointer low byte
000AB1r 1  85 C3        	STA	Bpntrl		; save BASIC execute pointer low byte
000AB3r 1  BD 0F 01     	LDA	LAB_STAK+$0F,X	; get BASIC execute pointer high byte
000AB6r 1  85 C4        	STA	Bpntrh		; save BASIC execute pointer high byte
000AB8r 1               LAB_1A98
000AB8r 1  4C rr rr     	JMP	LAB_15C2		; go do interpreter inner loop
000ABBr 1               
000ABBr 1               					; loop complete so carry on
000ABBr 1               LAB_1A9B
000ABBr 1  8A           	TXA				; stack copy to A
000ABCr 1  69 0F        	ADC	#$0F			; add $10 ($0F+carry) to dump FOR structure
000ABEr 1  AA           	TAX				; copy back to index
000ABFr 1  9A           	TXS				; copy to stack pointer
000AC0r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000AC3r 1  C9 2C        	CMP	#','			; compare with ","
000AC5r 1  D0 F1        	BNE	LAB_1A98		; branch if not "," (go do interpreter inner loop)
000AC7r 1               
000AC7r 1               					; was "," so another NEXT variable to do
000AC7r 1  20 BC 00     	JSR	LAB_IGBY		; else increment and scan memory
000ACAr 1  20 rr rr     	JSR	LAB_1A46		; do NEXT (var)
000ACDr 1               
000ACDr 1               ; evaluate expression and check is numeric, else do type mismatch
000ACDr 1               
000ACDr 1               LAB_EVNM
000ACDr 1  20 rr rr     	JSR	LAB_EVEX		; evaluate expression
000AD0r 1               
000AD0r 1               ; check if source is numeric, else do type mismatch
000AD0r 1               
000AD0r 1               LAB_CTNM
000AD0r 1  18           	CLC				; destination is numeric
000AD1r 1  24           	.byte	$24			; makes next line BIT $38
000AD2r 1               
000AD2r 1               ; check if source is string, else do type mismatch
000AD2r 1               
000AD2r 1               LAB_CTST
000AD2r 1  38           	SEC				; required type is string
000AD3r 1               
000AD3r 1               ; type match check, set C for string, clear C for numeric
000AD3r 1               
000AD3r 1               LAB_CKTM
000AD3r 1  24 5F        	BIT	Dtypef		; test data type flag, $FF=string, $00=numeric
000AD5r 1  30 03        	BMI	LAB_1ABA		; branch if data type is string
000AD7r 1               
000AD7r 1               					; else data type was numeric
000AD7r 1  B0 03        	BCS	LAB_1ABC		; if required type is string do type mismatch error
000AD9r 1               LAB_1AB9
000AD9r 1  60           	RTS
000ADAr 1               
000ADAr 1               					; data type was string, now check required type
000ADAr 1               LAB_1ABA
000ADAr 1  B0 FD        	BCS	LAB_1AB9		; exit if required type is string
000ADCr 1               
000ADCr 1               					; else do type mismatch error
000ADCr 1               LAB_1ABC
000ADCr 1  A2 18        	LDX	#$18			; error code $18 ("Type mismatch" error)
000ADEr 1               LAB_1ABE
000ADEr 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
000AE1r 1               
000AE1r 1               ; evaluate expression
000AE1r 1               
000AE1r 1               LAB_EVEX
000AE1r 1  A6 C3        	LDX	Bpntrl		; get BASIC execute pointer low byte
000AE3r 1  D0 02        	BNE	LAB_1AC7		; skip next if not zero
000AE5r 1               
000AE5r 1  C6 C4        	DEC	Bpntrh		; else decrement BASIC execute pointer high byte
000AE7r 1               LAB_1AC7
000AE7r 1  C6 C3        	DEC	Bpntrl		; decrement BASIC execute pointer low byte
000AE9r 1               
000AE9r 1               LAB_EVEZ
000AE9r 1  A9 00        	LDA	#$00			; set null precedence (flag done)
000AEBr 1               LAB_1ACC
000AEBr 1  48           	PHA				; push precedence byte
000AECr 1  A9 02        	LDA	#$02			; 2 bytes
000AEEr 1  20 rr rr     	JSR	LAB_1212		; check room on stack for A bytes
000AF1r 1  20 rr rr     	JSR	LAB_GVAL		; get value from line
000AF4r 1  A9 00        	LDA	#$00			; clear A
000AF6r 1  85 9B        	STA	comp_f		; clear compare function flag
000AF8r 1               LAB_1ADB
000AF8r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000AFBr 1               LAB_1ADE
000AFBr 1  38           	SEC				; set carry for subtract
000AFCr 1  E9 C1        	SBC	#TK_GT		; subtract token for > (lowest comparison function)
000AFEr 1  90 17        	BCC	LAB_1AFA		; branch if < TK_GT
000B00r 1               
000B00r 1  C9 03        	CMP	#$03			; compare with ">" to "<" tokens
000B02r 1  B0 13        	BCS	LAB_1AFA		; branch if >= TK_SGN (highest evaluation function +1)
000B04r 1               
000B04r 1               					; was token for > = or < (A = 0, 1 or 2)
000B04r 1  C9 01        	CMP	#$01			; compare with token for =
000B06r 1  2A           	ROL				; *2, b0 = carry (=1 if token was = or <)
000B07r 1               					; (A = 0, 3 or 5)
000B07r 1  49 01        	EOR	#$01			; toggle b0
000B09r 1               					; (A = 1, 2 or 4. 1 if >, 2 if =, 4 if <)
000B09r 1  45 9B        	EOR	comp_f		; EOR with compare function flag bits
000B0Br 1  C5 9B        	CMP	comp_f		; compare with compare function flag
000B0Dr 1  90 67        	BCC	LAB_1B53		; if <(comp_f) do syntax error then warm start
000B0Fr 1               					; was more than one <, = or >)
000B0Fr 1               
000B0Fr 1  85 9B        	STA	comp_f		; save new compare function flag
000B11r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
000B14r 1  4C rr rr     	JMP	LAB_1ADE		; go do next character
000B17r 1               
000B17r 1               					; token is < ">" or > "<" tokens
000B17r 1               LAB_1AFA
000B17r 1  A6 9B        	LDX	comp_f		; get compare function flag
000B19r 1  D0 2C        	BNE	LAB_1B2A		; branch if compare function
000B1Br 1               
000B1Br 1  B0 79        	BCS	LAB_1B78		; go do functions
000B1Dr 1               
000B1Dr 1               					; else was <  TK_GT so is operator or lower
000B1Dr 1  69 0A        	ADC	#TK_GT-TK_PLUS	; add # of operators (+, -, *, /, ^, AND, OR or EOR)
000B1Fr 1  90 75        	BCC	LAB_1B78		; branch if < + operator
000B21r 1               
000B21r 1               					; carry was set so token was +, -, *, /, ^, AND, OR or EOR
000B21r 1  D0 07        	BNE	LAB_1B0B		; branch if not + token
000B23r 1               
000B23r 1  24 5F        	BIT	Dtypef		; test data type flag, $FF=string, $00=numeric
000B25r 1  10 03        	BPL	LAB_1B0B		; branch if not string
000B27r 1               
000B27r 1               					; will only be $00 if type is string and token was +
000B27r 1  4C rr rr     	JMP	LAB_224D		; add strings, string 1 is in descriptor des_pl, string 2
000B2Ar 1               					; is in line, and return
000B2Ar 1               
000B2Ar 1               LAB_1B0B
000B2Ar 1  85 71        	STA	ut1_pl		; save it
000B2Cr 1  0A           	ASL				; *2
000B2Dr 1  65 71        	ADC	ut1_pl		; *3
000B2Fr 1  A8           	TAY				; copy to index
000B30r 1               LAB_1B13
000B30r 1  68           	PLA				; pull previous precedence
000B31r 1  D9 rr rr     	CMP	LAB_OPPT,Y		; compare with precedence byte
000B34r 1  B0 65        	BCS	LAB_1B7D		; branch if A >=
000B36r 1               
000B36r 1  20 rr rr     	JSR	LAB_CTNM		; check if source is numeric, else do type mismatch
000B39r 1               LAB_1B1C
000B39r 1  48           	PHA				; save precedence
000B3Ar 1               LAB_1B1D
000B3Ar 1  20 rr rr     	JSR	LAB_1B43		; get vector, execute function then continue evaluation
000B3Dr 1  68           	PLA				; restore precedence
000B3Er 1  A4 99        	LDY	prstk			; get precedence stacked flag
000B40r 1  10 19        	BPL	LAB_1B3C		; branch if stacked values
000B42r 1               
000B42r 1  AA           	TAX				; copy precedence (set flags)
000B43r 1  F0 76        	BEQ	LAB_1B9D		; exit if done
000B45r 1               
000B45r 1  D0 5D        	BNE	LAB_1B86		; else pop FAC2 and return, branch always
000B47r 1               
000B47r 1               LAB_1B2A
000B47r 1  26 5F        	ROL	Dtypef		; shift data type flag into Cb
000B49r 1  8A           	TXA				; copy compare function flag
000B4Ar 1  85 5F        	STA	Dtypef		; clear data type flag, X is 0xxx xxxx
000B4Cr 1  2A           	ROL				; shift data type into compare function byte b0
000B4Dr 1  A6 C3        	LDX	Bpntrl		; get BASIC execute pointer low byte
000B4Fr 1  D0 02        	BNE	LAB_1B34		; branch if no underflow
000B51r 1               
000B51r 1  C6 C4        	DEC	Bpntrh		; else decrement BASIC execute pointer high byte
000B53r 1               LAB_1B34
000B53r 1  C6 C3        	DEC	Bpntrl		; decrement BASIC execute pointer low byte
000B55r 1               TK_LT_PLUS	= TK_LT-TK_PLUS
000B55r 1  A0 24        	LDY	#TK_LT_PLUS*3	; set offset to last operator entry
000B57r 1  85 9B        	STA	comp_f		; save new compare function flag
000B59r 1  D0 D5        	BNE	LAB_1B13		; branch always
000B5Br 1               
000B5Br 1               LAB_1B3C
000B5Br 1  D9 rr rr     	CMP	LAB_OPPT,Y		;.compare with stacked function precedence
000B5Er 1  B0 44        	BCS	LAB_1B86		; branch if A >=, pop FAC2 and return
000B60r 1               
000B60r 1  90 D7        	BCC	LAB_1B1C		; branch always
000B62r 1               
000B62r 1               ;.get vector, execute function then continue evaluation
000B62r 1               
000B62r 1               LAB_1B43
000B62r 1  B9 rr rr     	LDA	LAB_OPPT+2,Y	; get function vector high byte
000B65r 1  48           	PHA				; onto stack
000B66r 1  B9 rr rr     	LDA	LAB_OPPT+1,Y	; get function vector low byte
000B69r 1  48           	PHA				; onto stack
000B6Ar 1               					; now push sign, round FAC1 and put on stack
000B6Ar 1  20 rr rr     	JSR	LAB_1B5B		; function will return here, then the next RTS will call
000B6Dr 1               					; the function
000B6Dr 1  A5 9B        	LDA	comp_f		; get compare function flag
000B6Fr 1  48           	PHA				; push compare evaluation byte
000B70r 1  B9 rr rr     	LDA	LAB_OPPT,Y		; get precedence byte
000B73r 1  4C rr rr     	JMP	LAB_1ACC		; continue evaluating expression
000B76r 1               
000B76r 1               LAB_1B53
000B76r 1  4C rr rr     	JMP	LAB_SNER		; do syntax error then warm start
000B79r 1               
000B79r 1               ; push sign, round FAC1 and put on stack
000B79r 1               
000B79r 1               LAB_1B5B
000B79r 1  68           	PLA				; get return addr low byte
000B7Ar 1  85 71        	STA	ut1_pl		; save it
000B7Cr 1  E6 71        	INC	ut1_pl		; increment it (was ret-1 pushed? yes!)
000B7Er 1               					; note! no check is made on the high byte! if the calling
000B7Er 1               					; routine assembles to a page edge then this all goes
000B7Er 1               					; horribly wrong !!!
000B7Er 1  68           	PLA				; get return addr high byte
000B7Fr 1  85 72        	STA	ut1_ph		; save it
000B81r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
000B83r 1  48           	PHA				; push sign
000B84r 1               
000B84r 1               ; round FAC1 and put on stack
000B84r 1               
000B84r 1               LAB_1B66
000B84r 1  20 rr rr     	JSR	LAB_27BA		; round FAC1
000B87r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
000B89r 1  48           	PHA				; push on stack
000B8Ar 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
000B8Cr 1  48           	PHA				; push on stack
000B8Dr 1  A5 AD        	LDA	FAC1_1		; get FAC1 mantissa1
000B8Fr 1  48           	PHA				; push on stack
000B90r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
000B92r 1  48           	PHA				; push on stack
000B93r 1  6C 71 00     	JMP	(ut1_pl)		; return, sort of
000B96r 1               
000B96r 1               ; do functions
000B96r 1               
000B96r 1               LAB_1B78
000B96r 1  A0 FF        	LDY	#$FF			; flag function
000B98r 1  68           	PLA				; pull precedence byte
000B99r 1               LAB_1B7B
000B99r 1  F0 20        	BEQ	LAB_1B9D		; exit if done
000B9Br 1               
000B9Br 1               LAB_1B7D
000B9Br 1  C9 64        	CMP	#$64			; compare previous precedence with $64
000B9Dr 1  F0 03        	BEQ	LAB_1B84		; branch if was $64 (< function)
000B9Fr 1               
000B9Fr 1  20 rr rr     	JSR	LAB_CTNM		; check if source is numeric, else do type mismatch
000BA2r 1               LAB_1B84
000BA2r 1  84 99        	STY	prstk			; save precedence stacked flag
000BA4r 1               
000BA4r 1               					; pop FAC2 and return
000BA4r 1               LAB_1B86
000BA4r 1  68           	PLA				; pop byte
000BA5r 1  4A           	LSR				; shift out comparison evaluation lowest bit
000BA6r 1  85 63        	STA	Cflag			; save comparison evaluation flag
000BA8r 1  68           	PLA				; pop exponent
000BA9r 1  85 B3        	STA	FAC2_e		; save FAC2 exponent
000BABr 1  68           	PLA				; pop mantissa1
000BACr 1  85 B4        	STA	FAC2_1		; save FAC2 mantissa1
000BAEr 1  68           	PLA				; pop mantissa2
000BAFr 1  85 B5        	STA	FAC2_2		; save FAC2 mantissa2
000BB1r 1  68           	PLA				; pop mantissa3
000BB2r 1  85 B6        	STA	FAC2_3		; save FAC2 mantissa3
000BB4r 1  68           	PLA				; pop sign
000BB5r 1  85 B7        	STA	FAC2_s		; save FAC2 sign (b7)
000BB7r 1  45 B0        	EOR	FAC1_s		; EOR FAC1 sign (b7)
000BB9r 1  85 B8        	STA	FAC_sc		; save sign compare (FAC1 EOR FAC2)
000BBBr 1               LAB_1B9D
000BBBr 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
000BBDr 1  60           	RTS
000BBEr 1               
000BBEr 1               ; print "..." string to string util area
000BBEr 1               
000BBEr 1               LAB_1BC1
000BBEr 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
000BC0r 1  A4 C4        	LDY	Bpntrh		; get BASIC execute pointer high byte
000BC2r 1  69 00        	ADC	#$00			; add carry to low byte
000BC4r 1  90 01        	BCC	LAB_1BCA		; branch if no overflow
000BC6r 1               
000BC6r 1  C8           	INY				; increment high byte
000BC7r 1               LAB_1BCA
000BC7r 1  20 rr rr     	JSR	LAB_20AE		; print " terminated string to Sutill/Sutilh
000BCAr 1  4C rr rr     	JMP	LAB_23F3		; restore BASIC execute pointer from temp and return
000BCDr 1               
000BCDr 1               ; get value from line
000BCDr 1               
000BCDr 1               LAB_GVAL
000BCDr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
000BD0r 1  B0 03        	BCS	LAB_1BAC		; branch if not numeric character
000BD2r 1               
000BD2r 1               					; else numeric string found (e.g. 123)
000BD2r 1               LAB_1BA9
000BD2r 1  4C rr rr     	JMP	LAB_2887		; get FAC1 from string and return
000BD5r 1               
000BD5r 1               ; get value from line .. continued
000BD5r 1               
000BD5r 1               					; wasn't a number so ..
000BD5r 1               LAB_1BAC
000BD5r 1  AA           	TAX				; set the flags
000BD6r 1  30 2F        	BMI	LAB_1BD0		; if -ve go test token values
000BD8r 1               
000BD8r 1               					; else it is either a string, number, variable or (<expr>)
000BD8r 1  C9 24        	CMP	#'$'			; compare with "$"
000BDAr 1  F0 F6        	BEQ	LAB_1BA9		; branch if "$", hex number
000BDCr 1               
000BDCr 1  C9 25        	CMP	#'%'			; else compare with "%"
000BDEr 1  F0 F2        	BEQ	LAB_1BA9		; branch if "%", binary number
000BE0r 1               
000BE0r 1  C9 2E        	CMP	#'.'			; compare with "."
000BE2r 1  F0 EE        	BEQ	LAB_1BA9		; if so get FAC1 from string and return (e.g. was .123)
000BE4r 1               
000BE4r 1               					; it wasn't any sort of number so ..
000BE4r 1  C9 22        	CMP	#$22			; compare with "
000BE6r 1  F0 D6        	BEQ	LAB_1BC1		; branch if open quote
000BE8r 1               
000BE8r 1               					; wasn't any sort of number so ..
000BE8r 1               
000BE8r 1               ; evaluate expression within parentheses
000BE8r 1               
000BE8r 1  C9 28        	CMP	#'('			; compare with "("
000BEAr 1  D0 4F        	BNE	LAB_1C18		; if not "(" get (var), return value in FAC1 and $ flag
000BECr 1               
000BECr 1               LAB_1BF7
000BECr 1  20 rr rr     	JSR	LAB_EVEZ		; evaluate expression, no decrement
000BEFr 1               
000BEFr 1               ; all the "scan for" routines return the character after the sought character
000BEFr 1               
000BEFr 1               ; scan for ")" , else do syntax error then warm start
000BEFr 1               
000BEFr 1               LAB_1BFB
000BEFr 1  A9 29        	LDA	#$29			; load A with ")"
000BF1r 1               
000BF1r 1               ; scan for CHR$(A) , else do syntax error then warm start
000BF1r 1               
000BF1r 1               LAB_SCCA
000BF1r 1  A0 00        	LDY	#$00			; clear index
000BF3r 1  D1 C3        	CMP	(Bpntrl),Y		; check next byte is = A
000BF5r 1  D0 0B        	BNE	LAB_SNER		; if not do syntax error then warm start
000BF7r 1               
000BF7r 1  4C BC 00     	JMP	LAB_IGBY		; increment and scan memory then return
000BFAr 1               
000BFAr 1               ; scan for "(" , else do syntax error then warm start
000BFAr 1               
000BFAr 1               LAB_1BFE
000BFAr 1  A9 28        	LDA	#$28			; load A with "("
000BFCr 1  D0 F3        	BNE	LAB_SCCA		; scan for CHR$(A), else do syntax error then warm start
000BFEr 1               					; (branch always)
000BFEr 1               
000BFEr 1               ; scan for "," , else do syntax error then warm start
000BFEr 1               
000BFEr 1               LAB_1C01
000BFEr 1  A9 2C        	LDA	#$2C			; load A with ","
000C00r 1  D0 EF        	BNE	LAB_SCCA		; scan for CHR$(A), else do syntax error then warm start
000C02r 1               					; (branch always)
000C02r 1               
000C02r 1               ; syntax error then warm start
000C02r 1               
000C02r 1               LAB_SNER
000C02r 1  A2 02        	LDX	#$02			; error code $02 ("Syntax" error)
000C04r 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
000C07r 1               
000C07r 1               ; get value from line .. continued
000C07r 1               ; do tokens
000C07r 1               
000C07r 1               LAB_1BD0
000C07r 1  C9 B8        	CMP	#TK_MINUS		; compare with token for -
000C09r 1  F0 29        	BEQ	LAB_1C11		; branch if - token (do set-up for functions)
000C0Br 1               
000C0Br 1               					; wasn't -n so ..
000C0Br 1  C9 B7        	CMP	#TK_PLUS		; compare with token for +
000C0Dr 1  F0 BE        	BEQ	LAB_GVAL		; branch if + token (+n = n so ignore leading +)
000C0Fr 1               
000C0Fr 1  C9 B2        	CMP	#TK_NOT		; compare with token for NOT
000C11r 1  D0 13        	BNE	LAB_1BE7		; branch if not token for NOT
000C13r 1               
000C13r 1               					; was NOT token
000C13r 1               TK_EQUAL_PLUS	= TK_EQUAL-TK_PLUS
000C13r 1  A0 21        	LDY	#TK_EQUAL_PLUS*3	; offset to NOT function
000C15r 1  D0 1F        	BNE	LAB_1C13		; do set-up for function then execute (branch always)
000C17r 1               
000C17r 1               ; do = compare
000C17r 1               
000C17r 1               LAB_EQUAL
000C17r 1  20 rr rr     	JSR	LAB_EVIR		; evaluate integer expression (no sign check)
000C1Ar 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
000C1Cr 1  49 FF        	EOR	#$FF			; invert it
000C1Er 1  A8           	TAY				; copy it
000C1Fr 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
000C21r 1  49 FF        	EOR	#$FF			; invert it
000C23r 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
000C26r 1               
000C26r 1               ; get value from line .. continued
000C26r 1               
000C26r 1               					; wasn't +, -, or NOT so ..
000C26r 1               LAB_1BE7
000C26r 1  C9 AF        	CMP	#TK_FN		; compare with token for FN
000C28r 1  D0 03        	BNE	LAB_1BEE		; branch if not token for FN
000C2Ar 1               
000C2Ar 1  4C rr rr     	JMP	LAB_201E		; go evaluate FNx
000C2Dr 1               
000C2Dr 1               ; get value from line .. continued
000C2Dr 1               
000C2Dr 1               					; wasn't +, -, NOT or FN so ..
000C2Dr 1               LAB_1BEE
000C2Dr 1  E9 C4        	SBC	#TK_SGN		; subtract with token for SGN
000C2Fr 1  B0 19        	BCS	LAB_1C27		; if a function token go do it
000C31r 1               
000C31r 1  4C rr rr     	JMP	LAB_SNER		; else do syntax error
000C34r 1               
000C34r 1               ; set-up for functions
000C34r 1               
000C34r 1               LAB_1C11
000C34r 1               TK_GT_PLUS	= TK_GT-TK_PLUS
000C34r 1  A0 1E        	LDY	#TK_GT_PLUS*3	; set offset from base to > operator
000C36r 1               LAB_1C13
000C36r 1  68           	PLA				; dump return address low byte
000C37r 1  68           	PLA				; dump return address high byte
000C38r 1  4C rr rr     	JMP	LAB_1B1D		; execute function then continue evaluation
000C3Br 1               
000C3Br 1               ; variable name set-up
000C3Br 1               ; get (var), return value in FAC_1 and $ flag
000C3Br 1               
000C3Br 1               LAB_1C18
000C3Br 1  20 rr rr     	JSR	LAB_GVAR		; get (var) address
000C3Er 1  85 AE        	STA	FAC1_2		; save address low byte in FAC1 mantissa2
000C40r 1  84 AF        	STY	FAC1_3		; save address high byte in FAC1 mantissa3
000C42r 1  A6 5F        	LDX	Dtypef		; get data type flag, $FF=string, $00=numeric
000C44r 1  30 03        	BMI	LAB_1C25		; if string then return (does RTS)
000C46r 1               
000C46r 1               LAB_1C24
000C46r 1  4C rr rr     	JMP	LAB_UFAC		; unpack memory (AY) into FAC1
000C49r 1               
000C49r 1               LAB_1C25
000C49r 1  60           	RTS
000C4Ar 1               
000C4Ar 1               ; get value from line .. continued
000C4Ar 1               ; only functions left so ..
000C4Ar 1               
000C4Ar 1               ; set up function references
000C4Ar 1               
000C4Ar 1               ; new for V2.0+ this replaces a lot of IF .. THEN .. ELSEIF .. THEN .. that was needed
000C4Ar 1               ; to process function calls. now the function vector is computed and pushed on the stack
000C4Ar 1               ; and the preprocess offset is read. if the preprocess offset is non zero then the vector
000C4Ar 1               ; is calculated and the routine called, if not this routine just does RTS. whichever
000C4Ar 1               ; happens the RTS at the end of this routine, or the end of the preprocess routine, calls
000C4Ar 1               ; the function code
000C4Ar 1               
000C4Ar 1               ; this also removes some less than elegant code that was used to bypass type checking
000C4Ar 1               ; for functions that returned strings
000C4Ar 1               
000C4Ar 1               LAB_1C27
000C4Ar 1  0A           	ASL				; *2 (2 bytes per function address)
000C4Br 1  A8           	TAY				; copy to index
000C4Cr 1               
000C4Cr 1  B9 rr rr     	LDA	LAB_FTBM,Y		; get function jump vector high byte
000C4Fr 1  48           	PHA				; push functions jump vector high byte
000C50r 1  B9 rr rr     	LDA	LAB_FTBL,Y		; get function jump vector low byte
000C53r 1  48           	PHA				; push functions jump vector low byte
000C54r 1               
000C54r 1  B9 rr rr     	LDA	LAB_FTPM,Y		; get function pre process vector high byte
000C57r 1  F0 05        	BEQ	LAB_1C56		; skip pre process if null vector
000C59r 1               
000C59r 1  48           	PHA				; push functions pre process vector high byte
000C5Ar 1  B9 rr rr     	LDA	LAB_FTPL,Y		; get function pre process vector low byte
000C5Dr 1  48           	PHA				; push functions pre process vector low byte
000C5Er 1               
000C5Er 1               LAB_1C56
000C5Er 1  60           	RTS				; do function, or pre process, call
000C5Fr 1               
000C5Fr 1               ; process string expression in parenthesis
000C5Fr 1               
000C5Fr 1               LAB_PPFS
000C5Fr 1  20 rr rr     	JSR	LAB_1BF7		; process expression in parenthesis
000C62r 1  4C rr rr     	JMP	LAB_CTST		; check if source is string then do function,
000C65r 1               					; else do type mismatch
000C65r 1               
000C65r 1               ; process numeric expression in parenthesis
000C65r 1               
000C65r 1               LAB_PPFN
000C65r 1  20 rr rr     	JSR	LAB_1BF7		; process expression in parenthesis
000C68r 1  4C rr rr     	JMP	LAB_CTNM		; check if source is numeric then do function,
000C6Br 1               					; else do type mismatch
000C6Br 1               
000C6Br 1               ; set numeric data type and increment BASIC execute pointer
000C6Br 1               
000C6Br 1               LAB_PPBI
000C6Br 1  46 5F        	LSR	Dtypef		; clear data type flag, $FF=string, $00=numeric
000C6Dr 1  4C BC 00     	JMP	LAB_IGBY		; increment and scan memory then do function
000C70r 1               
000C70r 1               ; process string for LEFT$, RIGHT$ or MID$
000C70r 1               
000C70r 1               LAB_LRMS
000C70r 1  20 rr rr     	JSR	LAB_EVEZ		; evaluate (should be string) expression
000C73r 1  20 rr rr     	JSR	LAB_1C01		; scan for ",", else do syntax error then warm start
000C76r 1  20 rr rr     	JSR	LAB_CTST		; check if source is string, else do type mismatch
000C79r 1               
000C79r 1  68           	PLA				; get function jump vector low byte
000C7Ar 1  AA           	TAX				; save functions jump vector low byte
000C7Br 1  68           	PLA				; get function jump vector high byte
000C7Cr 1  A8           	TAY				; save functions jump vector high byte
000C7Dr 1  A5 AF        	LDA	des_ph		; get descriptor pointer high byte
000C7Fr 1  48           	PHA				; push string pointer high byte
000C80r 1  A5 AE        	LDA	des_pl		; get descriptor pointer low byte
000C82r 1  48           	PHA				; push string pointer low byte
000C83r 1  98           	TYA				; get function jump vector high byte back
000C84r 1  48           	PHA				; save functions jump vector high byte
000C85r 1  8A           	TXA				; get function jump vector low byte back
000C86r 1  48           	PHA				; save functions jump vector low byte
000C87r 1  20 rr rr     	JSR	LAB_GTBY		; get byte parameter
000C8Ar 1  8A           	TXA				; copy byte parameter to A
000C8Br 1  60           	RTS				; go do function
000C8Cr 1               
000C8Cr 1               ; process numeric expression(s) for BIN$ or HEX$
000C8Cr 1               
000C8Cr 1               LAB_BHSS
000C8Cr 1  20 rr rr     	JSR	LAB_EVEZ		; process expression
000C8Fr 1  20 rr rr     	JSR	LAB_CTNM		; check if source is numeric, else do type mismatch
000C92r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
000C94r 1  C9 98        	CMP	#$98			; compare with exponent = 2^24
000C96r 1  B0 20        	BCS	LAB_BHER		; branch if n>=2^24 (is too big)
000C98r 1               
000C98r 1  20 rr rr     	JSR	LAB_2831		; convert FAC1 floating-to-fixed
000C9Br 1  A2 02        	LDX	#$02			; 3 bytes to do
000C9Dr 1               LAB_CFAC
000C9Dr 1  B5 AD        	LDA	FAC1_1,X		; get byte from FAC1
000C9Fr 1  95 11        	STA	nums_1,X		; save byte to temp
000CA1r 1  CA           	DEX				; decrement index
000CA2r 1  10 F9        	BPL	LAB_CFAC		; copy FAC1 mantissa to temp
000CA4r 1               
000CA4r 1  20 C2 00     	JSR	LAB_GBYT		; get next BASIC byte
000CA7r 1  A2 00        	LDX	#$00			; set default to no leading "0"s
000CA9r 1  C9 29        	CMP	#')'			; compare with close bracket
000CABr 1  F0 0A        	BEQ	LAB_1C54		; if ")" go do rest of function
000CADr 1               
000CADr 1  20 rr rr     	JSR	LAB_SCGB		; scan for "," and get byte
000CB0r 1  20 C2 00     	JSR	LAB_GBYT		; get last byte back
000CB3r 1  C9 29        	CMP	#')'			; is next character )
000CB5r 1  D0 01        	BNE	LAB_BHER		; if not ")" go do error
000CB7r 1               
000CB7r 1               LAB_1C54
000CB7r 1  60           	RTS				; else do function
000CB8r 1               
000CB8r 1               LAB_BHER
000CB8r 1  4C rr rr     	JMP	LAB_FCER		; do function call error then warm start
000CBBr 1               
000CBBr 1               ; perform EOR
000CBBr 1               
000CBBr 1               ; added operator format is the same as AND or OR, precedence is the same as OR
000CBBr 1               
000CBBr 1               ; this bit worked first time but it took a while to sort out the operator table
000CBBr 1               ; pointers and offsets afterwards!
000CBBr 1               
000CBBr 1               LAB_EOR
000CBBr 1  20 rr rr     	JSR	GetFirst		; get first integer expression (no sign check)
000CBEr 1  45 5B        	EOR	XOAw_l		; EOR with expression 1 low byte
000CC0r 1  A8           	TAY				; save in Y
000CC1r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
000CC3r 1  45 5C        	EOR	XOAw_h		; EOR with expression 1 high byte
000CC5r 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
000CC8r 1               
000CC8r 1               ; perform OR
000CC8r 1               
000CC8r 1               LAB_OR
000CC8r 1  20 rr rr     	JSR	GetFirst		; get first integer expression (no sign check)
000CCBr 1  05 5B        	ORA	XOAw_l		; OR with expression 1 low byte
000CCDr 1  A8           	TAY				; save in Y
000CCEr 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
000CD0r 1  05 5C        	ORA	XOAw_h		; OR with expression 1 high byte
000CD2r 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
000CD5r 1               
000CD5r 1               ; perform AND
000CD5r 1               
000CD5r 1               LAB_AND
000CD5r 1  20 rr rr     	JSR	GetFirst		; get first integer expression (no sign check)
000CD8r 1  25 5B        	AND	XOAw_l		; AND with expression 1 low byte
000CDAr 1  A8           	TAY				; save in Y
000CDBr 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
000CDDr 1  25 5C        	AND	XOAw_h		; AND with expression 1 high byte
000CDFr 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
000CE2r 1               
000CE2r 1               ; get first value for OR, AND or EOR
000CE2r 1               
000CE2r 1               GetFirst
000CE2r 1  20 rr rr     	JSR	LAB_EVIR		; evaluate integer expression (no sign check)
000CE5r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
000CE7r 1  85 5C        	STA	XOAw_h		; save it
000CE9r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
000CEBr 1  85 5B        	STA	XOAw_l		; save it
000CEDr 1  20 rr rr     	JSR	LAB_279B		; copy FAC2 to FAC1 (get 2nd value in expression)
000CF0r 1  20 rr rr     	JSR	LAB_EVIR		; evaluate integer expression (no sign check)
000CF3r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
000CF5r 1               LAB_1C95
000CF5r 1  60           	RTS
000CF6r 1               
000CF6r 1               ; perform comparisons
000CF6r 1               
000CF6r 1               ; do < compare
000CF6r 1               
000CF6r 1               LAB_LTHAN
000CF6r 1  20 rr rr     	JSR	LAB_CKTM		; type match check, set C for string
000CF9r 1  B0 13        	BCS	LAB_1CAE		; branch if string
000CFBr 1               
000CFBr 1               					; do numeric < compare
000CFBr 1  A5 B7        	LDA	FAC2_s		; get FAC2 sign (b7)
000CFDr 1  09 7F        	ORA	#$7F			; set all non sign bits
000CFFr 1  25 B4        	AND	FAC2_1		; and FAC2 mantissa1 (AND in sign bit)
000D01r 1  85 B4        	STA	FAC2_1		; save FAC2 mantissa1
000D03r 1  A9 B3        	LDA	#<FAC2_e		; set pointer low byte to FAC2
000D05r 1  A0 00        	LDY	#>FAC2_e		; set pointer high byte to FAC2
000D07r 1  20 rr rr     	JSR	LAB_27F8		; compare FAC1 with FAC2 (AY)
000D0Ar 1  AA           	TAX				; copy result
000D0Br 1  4C rr rr     	JMP	LAB_1CE1		; go evaluate result
000D0Er 1               
000D0Er 1               					; do string < compare
000D0Er 1               LAB_1CAE
000D0Er 1  46 5F        	LSR	Dtypef		; clear data type flag, $FF=string, $00=numeric
000D10r 1  C6 9B        	DEC	comp_f		; clear < bit in compare function flag
000D12r 1  20 rr rr     	JSR	LAB_22B6		; pop string off descriptor stack, or from top of string
000D15r 1               					; space returns with A = length, X=pointer low byte,
000D15r 1               					; Y=pointer high byte
000D15r 1  85 AC        	STA	str_ln		; save length
000D17r 1  86 AD        	STX	str_pl		; save string pointer low byte
000D19r 1  84 AE        	STY	str_ph		; save string pointer high byte
000D1Br 1  A5 B5        	LDA	FAC2_2		; get descriptor pointer low byte
000D1Dr 1  A4 B6        	LDY	FAC2_3		; get descriptor pointer high byte
000D1Fr 1  20 rr rr     	JSR	LAB_22BA		; pop (YA) descriptor off stack or from top of string space
000D22r 1               					; returns with A = length, X=pointer low byte,
000D22r 1               					; Y=pointer high byte
000D22r 1  86 B5        	STX	FAC2_2		; save string pointer low byte
000D24r 1  84 B6        	STY	FAC2_3		; save string pointer high byte
000D26r 1  AA           	TAX				; copy length
000D27r 1  38           	SEC				; set carry for subtract
000D28r 1  E5 AC        	SBC	str_ln		; subtract string 1 length
000D2Ar 1  F0 08        	BEQ	LAB_1CD6		; branch if str 1 length = string 2 length
000D2Cr 1               
000D2Cr 1  A9 01        	LDA	#$01			; set str 1 length > string 2 length
000D2Er 1  90 04        	BCC	LAB_1CD6		; branch if so
000D30r 1               
000D30r 1  A6 AC        	LDX	str_ln		; get string 1 length
000D32r 1  A9 FF        	LDA	#$FF			; set str 1 length < string 2 length
000D34r 1               LAB_1CD6
000D34r 1  85 B0        	STA	FAC1_s		; save length compare
000D36r 1  A0 FF        	LDY	#$FF			; set index
000D38r 1  E8           	INX				; adjust for loop
000D39r 1               LAB_1CDB
000D39r 1  C8           	INY				; increment index
000D3Ar 1  CA           	DEX				; decrement count
000D3Br 1  D0 07        	BNE	LAB_1CE6		; branch if still bytes to do
000D3Dr 1               
000D3Dr 1  A6 B0        	LDX	FAC1_s		; get length compare back
000D3Fr 1               LAB_1CE1
000D3Fr 1  30 0F        	BMI	LAB_1CF2		; branch if str 1 < str 2
000D41r 1               
000D41r 1  18           	CLC				; flag str 1 <= str 2
000D42r 1  90 0C        	BCC	LAB_1CF2		; go evaluate result
000D44r 1               
000D44r 1               LAB_1CE6
000D44r 1  B1 B5        	LDA	(FAC2_2),Y		; get string 2 byte
000D46r 1  D1 AD        	CMP	(FAC1_1),Y		; compare with string 1 byte
000D48r 1  F0 EF        	BEQ	LAB_1CDB		; loop if bytes =
000D4Ar 1               
000D4Ar 1  A2 FF        	LDX	#$FF			; set str 1 < string 2
000D4Cr 1  B0 02        	BCS	LAB_1CF2		; branch if so
000D4Er 1               
000D4Er 1  A2 01        	LDX	#$01			;  set str 1 > string 2
000D50r 1               LAB_1CF2
000D50r 1  E8           	INX				; x = 0, 1 or 2
000D51r 1  8A           	TXA				; copy to A
000D52r 1  2A           	ROL				; *2 (1, 2 or 4)
000D53r 1  25 63        	AND	Cflag			; AND with comparison evaluation flag
000D55r 1  F0 02        	BEQ	LAB_1CFB		; branch if 0 (compare is false)
000D57r 1               
000D57r 1  A9 FF        	LDA	#$FF			; else set result true
000D59r 1               LAB_1CFB
000D59r 1  4C rr rr     	JMP	LAB_27DB		; save A as integer byte and return
000D5Cr 1               
000D5Cr 1               LAB_1CFE
000D5Cr 1  20 rr rr     	JSR	LAB_1C01		; scan for ",", else do syntax error then warm start
000D5Fr 1               
000D5Fr 1               ; perform DIM
000D5Fr 1               
000D5Fr 1               LAB_DIM
000D5Fr 1  AA           	TAX				; copy "DIM" flag to X
000D60r 1  20 rr rr     	JSR	LAB_1D10		; search for variable
000D63r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000D66r 1  D0 F4        	BNE	LAB_1CFE		; scan for "," and loop if not null
000D68r 1               
000D68r 1  60           	RTS
000D69r 1               
000D69r 1               ; perform << (left shift)
000D69r 1               
000D69r 1               LAB_LSHIFT
000D69r 1  20 rr rr     	JSR	GetPair		; get integer expression and byte (no sign check)
000D6Cr 1  A5 AE        	LDA	FAC1_2		; get expression high byte
000D6Er 1  A6 78        	LDX	TempB			; get shift count
000D70r 1  F0 22        	BEQ	NoShift		; branch if zero
000D72r 1               
000D72r 1  E0 10        	CPX	#$10			; compare bit count with 16d
000D74r 1  B0 23        	BCS	TooBig		; branch if >=
000D76r 1               
000D76r 1               Ls_loop
000D76r 1  06 AF        	ASL	FAC1_3		; shift low byte
000D78r 1  2A           	ROL				; shift high byte
000D79r 1  CA           	DEX				; decrement bit count
000D7Ar 1  D0 FA        	BNE	Ls_loop		; loop if shift not complete
000D7Cr 1               
000D7Cr 1  A4 AF        	LDY	FAC1_3		; get expression low byte
000D7Er 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
000D81r 1               
000D81r 1               ; perform >> (right shift)
000D81r 1               
000D81r 1               LAB_RSHIFT
000D81r 1  20 rr rr     	JSR	GetPair		; get integer expression and byte (no sign check)
000D84r 1  A5 AE        	LDA	FAC1_2		; get expression high byte
000D86r 1  A6 78        	LDX	TempB			; get shift count
000D88r 1  F0 0A        	BEQ	NoShift		; branch if zero
000D8Ar 1               
000D8Ar 1  E0 10        	CPX	#$10			; compare bit count with 16d
000D8Cr 1  B0 0B        	BCS	TooBig		; branch if >=
000D8Er 1               
000D8Er 1               Rs_loop
000D8Er 1  4A           	LSR				; shift high byte
000D8Fr 1  66 AF        	ROR	FAC1_3		; shift low byte
000D91r 1  CA           	DEX				; decrement bit count
000D92r 1  D0 FA        	BNE	Rs_loop		; loop if shift not complete
000D94r 1               
000D94r 1               NoShift
000D94r 1  A4 AF        	LDY	FAC1_3		; get expression low byte
000D96r 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
000D99r 1               
000D99r 1               TooBig
000D99r 1  A9 00        	LDA	#$00			; clear high byte
000D9Br 1  A8           	TAY				; copy to low byte
000D9Cr 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
000D9Fr 1               
000D9Fr 1               GetPair
000D9Fr 1  20 rr rr     	JSR	LAB_EVBY		; evaluate byte expression, result in X
000DA2r 1  86 78        	STX	TempB			; save it
000DA4r 1  20 rr rr     	JSR	LAB_279B		; copy FAC2 to FAC1 (get 2nd value in expression)
000DA7r 1  4C rr rr     	JMP	LAB_EVIR		; evaluate integer expression (no sign check)
000DAAr 1               
000DAAr 1               ; search for variable
000DAAr 1               
000DAAr 1               ; return pointer to variable in Cvaral/Cvarah
000DAAr 1               
000DAAr 1               LAB_GVAR
000DAAr 1  A2 00        	LDX	#$00			; set DIM flag = $00
000DACr 1  20 C2 00     	JSR	LAB_GBYT		; scan memory (1st character)
000DAFr 1               LAB_1D10
000DAFr 1  86 5E        	STX	Defdim		; save DIM flag
000DB1r 1               LAB_1D12
000DB1r 1  85 93        	STA	Varnm1		; save 1st character
000DB3r 1  29 7F        	AND	#$7F			; clear FN flag bit
000DB5r 1  20 rr rr     	JSR	LAB_CASC		; check byte, return C=0 if<"A" or >"Z"
000DB8r 1  B0 03        	BCS	LAB_1D1F		; branch if ok
000DBAr 1               
000DBAr 1  4C rr rr     	JMP	LAB_SNER		; else syntax error then warm start
000DBDr 1               
000DBDr 1               					; was variable name so ..
000DBDr 1               LAB_1D1F
000DBDr 1  A2 00        	LDX	#$00			; clear 2nd character temp
000DBFr 1  86 5F        	STX	Dtypef		; clear data type flag, $FF=string, $00=numeric
000DC1r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory (2nd character)
000DC4r 1  90 05        	BCC	LAB_1D2D		; branch if character = "0"-"9" (ok)
000DC6r 1               
000DC6r 1               					; 2nd character wasn't "0" to "9" so ..
000DC6r 1  20 rr rr     	JSR	LAB_CASC		; check byte, return C=0 if<"A" or >"Z"
000DC9r 1  90 0B        	BCC	LAB_1D38		; branch if <"A" or >"Z" (go check if string)
000DCBr 1               
000DCBr 1               LAB_1D2D
000DCBr 1  AA           	TAX				; copy 2nd character
000DCCr 1               
000DCCr 1               					; ignore further (valid) characters in the variable name
000DCCr 1               LAB_1D2E
000DCCr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory (3rd character)
000DCFr 1  90 FB        	BCC	LAB_1D2E		; loop if character = "0"-"9" (ignore)
000DD1r 1               
000DD1r 1  20 rr rr     	JSR	LAB_CASC		; check byte, return C=0 if<"A" or >"Z"
000DD4r 1  B0 F6        	BCS	LAB_1D2E		; loop if character = "A"-"Z" (ignore)
000DD6r 1               
000DD6r 1               					; check if string variable
000DD6r 1               LAB_1D38
000DD6r 1  C9 24        	CMP	#'$'			; compare with "$"
000DD8r 1  D0 0B        	BNE	LAB_1D47		; branch if not string
000DDAr 1               
000DDAr 1               ; to introduce a new variable type (% suffix for integers say) then this branch
000DDAr 1               ; will need to go to that check and then that branch, if it fails, go to LAB_1D47
000DDAr 1               
000DDAr 1               					; type is string
000DDAr 1  A9 FF        	LDA	#$FF			; set data type = string
000DDCr 1  85 5F        	STA	Dtypef		; set data type flag, $FF=string, $00=numeric
000DDEr 1  8A           	TXA				; get 2nd character back
000DDFr 1  09 80        	ORA	#$80			; set top bit (indicate string var)
000DE1r 1  AA           	TAX				; copy back to 2nd character temp
000DE2r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
000DE5r 1               
000DE5r 1               ; after we have determined the variable type we need to come back here to determine
000DE5r 1               ; if it's an array of type. this would plug in a%(b[,c[,d]])) integer arrays nicely
000DE5r 1               
000DE5r 1               
000DE5r 1               LAB_1D47				; gets here with character after var name in A
000DE5r 1  86 94        	STX	Varnm2		; save 2nd character
000DE7r 1  05 61        	ORA	Sufnxf		; or with subscript/FNX flag (or FN name)
000DE9r 1  C9 28        	CMP	#'('			; compare with "("
000DEBr 1  D0 03        	BNE	LAB_1D53		; branch if not "("
000DEDr 1               
000DEDr 1  4C rr rr     	JMP	LAB_1E17		; go find, or make, array
000DF0r 1               
000DF0r 1               ; either find or create var
000DF0r 1               ; var name (1st two characters only!) is in Varnm1,Varnm2
000DF0r 1               
000DF0r 1               					; variable name wasn't var(... so look for plain var
000DF0r 1               LAB_1D53
000DF0r 1  A9 00        	LDA	#$00			; clear A
000DF2r 1  85 61        	STA	Sufnxf		; clear subscript/FNX flag
000DF4r 1  A5 7B        	LDA	Svarl			; get start of vars low byte
000DF6r 1  A6 7C        	LDX	Svarh			; get start of vars high byte
000DF8r 1  A0 00        	LDY	#$00			; clear index
000DFAr 1               LAB_1D5D
000DFAr 1  86 AB        	STX	Vrschh		; save search address high byte
000DFCr 1               LAB_1D5F
000DFCr 1  85 AA        	STA	Vrschl		; save search address low byte
000DFEr 1  E4 7E        	CPX	Sarryh		; compare high address with var space end
000E00r 1  D0 04        	BNE	LAB_1D69		; skip next compare if <>
000E02r 1               
000E02r 1               					; high addresses were = so compare low addresses
000E02r 1  C5 7D        	CMP	Sarryl		; compare low address with var space end
000E04r 1  F0 2C        	BEQ	LAB_1D8B		; if not found go make new var
000E06r 1               
000E06r 1               LAB_1D69
000E06r 1  A5 93        	LDA	Varnm1		; get 1st character of var to find
000E08r 1  D1 AA        	CMP	(Vrschl),Y		; compare with variable name 1st character
000E0Ar 1  D0 08        	BNE	LAB_1D77		; branch if no match
000E0Cr 1               
000E0Cr 1               					; 1st characters match so compare 2nd characters
000E0Cr 1  A5 94        	LDA	Varnm2		; get 2nd character of var to find
000E0Er 1  C8           	INY				; index to point to variable name 2nd character
000E0Fr 1  D1 AA        	CMP	(Vrschl),Y		; compare with variable name 2nd character
000E11r 1  F0 69        	BEQ	LAB_1DD7		; branch if match (found var)
000E13r 1               
000E13r 1  88           	DEY				; else decrement index (now = $00)
000E14r 1               LAB_1D77
000E14r 1  18           	CLC				; clear carry for add
000E15r 1  A5 AA        	LDA	Vrschl		; get search address low byte
000E17r 1  69 06        	ADC	#$06			; +6 (offset to next var name)
000E19r 1  90 E1        	BCC	LAB_1D5F		; loop if no overflow to high byte
000E1Br 1               
000E1Br 1  E8           	INX				; else increment high byte
000E1Cr 1  D0 DC        	BNE	LAB_1D5D		; loop always (RAM doesn't extend to $FFFF !)
000E1Er 1               
000E1Er 1               ; check byte, return C=0 if<"A" or >"Z" or "a" to "z"
000E1Er 1               
000E1Er 1               LAB_CASC
000E1Er 1  C9 61        	CMP	#'a'			; compare with "a"
000E20r 1  B0 0A        	BCS	LAB_1D83		; go check <"z"+1
000E22r 1               
000E22r 1               ; check byte, return C=0 if<"A" or >"Z"
000E22r 1               
000E22r 1               LAB_1D82
000E22r 1  C9 41        	CMP	#'A'			; compare with "A"
000E24r 1  90 05        	BCC	LAB_1D8A		; exit if less
000E26r 1               
000E26r 1               					; carry is set
000E26r 1  E9 5B        	SBC	#$5B			; subtract "Z"+1
000E28r 1  38           	SEC				; set carry
000E29r 1  E9 A5        	SBC	#$A5			; subtract $A5 (restore byte)
000E2Br 1               					; carry clear if byte>$5A
000E2Br 1               LAB_1D8A
000E2Br 1  60           	RTS
000E2Cr 1               
000E2Cr 1               LAB_1D83
000E2Cr 1  E9 7B        	SBC	#$7B			; subtract "z"+1
000E2Er 1  38           	SEC				; set carry
000E2Fr 1  E9 85        	SBC	#$85			; subtract $85 (restore byte)
000E31r 1               					; carry clear if byte>$7A
000E31r 1  60           	RTS
000E32r 1               
000E32r 1               					; reached end of variable mem without match
000E32r 1               					; .. so create new variable
000E32r 1               LAB_1D8B
000E32r 1  68           	PLA				; pop return address low byte
000E33r 1  48           	PHA				; push return address low byte
000E34r 1               LAB_1C18p2	= LAB_1C18+2
000E34r 1  C9 rr        	CMP	#<LAB_1C18p2	; compare with expected calling routine return low byte
000E36r 1  D0 05        	BNE	LAB_1D98		; if not get (var) go create new var
000E38r 1               
000E38r 1               ; This will only drop through if the call was from LAB_1C18 and is only called
000E38r 1               ; from there if it is searching for a variable from the RHS of a LET a=b statement
000E38r 1               ; it prevents the creation of variables not assigned a value.
000E38r 1               
000E38r 1               ; value returned by this is either numeric zero (exponent byte is $00) or null string
000E38r 1               ; (descriptor length byte is $00). in fact a pointer to any $00 byte would have done.
000E38r 1               
000E38r 1               ; doing this saves 6 bytes of variable memory and 168 machine cycles of time
000E38r 1               
000E38r 1               ; this is where you would put the undefined variable error call e.g.
000E38r 1               
000E38r 1               ;					; variable doesn't exist so flag error
000E38r 1               ;	LDX	#$24			; error code $24 ("undefined variable" error)
000E38r 1               ;	JMP	LAB_XERR		; do error #X then warm start
000E38r 1               
000E38r 1               ; the above code has been tested and works a treat! (it replaces the three code lines
000E38r 1               ; below)
000E38r 1               
000E38r 1               					; else return dummy null value
000E38r 1  A9 rr        	LDA	#<LAB_1D96		; low byte point to $00,$00
000E3Ar 1               					; (uses part of misc constants table)
000E3Ar 1  A0 rr        	LDY	#>LAB_1D96		; high byte point to $00,$00
000E3Cr 1  60           	RTS
000E3Dr 1               
000E3Dr 1               					; create new numeric variable
000E3Dr 1               LAB_1D98
000E3Dr 1  A5 7D        	LDA	Sarryl		; get var mem end low byte
000E3Fr 1  A4 7E        	LDY	Sarryh		; get var mem end high byte
000E41r 1  85 AA        	STA	Ostrtl		; save old block start low byte
000E43r 1  84 AB        	STY	Ostrth		; save old block start high byte
000E45r 1  A5 7F        	LDA	Earryl		; get array mem end low byte
000E47r 1  A4 80        	LDY	Earryh		; get array mem end high byte
000E49r 1  85 A6        	STA	Obendl		; save old block end low byte
000E4Br 1  84 A7        	STY	Obendh		; save old block end high byte
000E4Dr 1  18           	CLC				; clear carry for add
000E4Er 1  69 06        	ADC	#$06			; +6 (space for one var)
000E50r 1  90 01        	BCC	LAB_1DAE		; branch if no overflow to high byte
000E52r 1               
000E52r 1  C8           	INY				; else increment high byte
000E53r 1               LAB_1DAE
000E53r 1  85 A4        	STA	Nbendl		; set new block end low byte
000E55r 1  84 A5        	STY	Nbendh		; set new block end high byte
000E57r 1  20 rr rr     	JSR	LAB_11CF		; open up space in memory
000E5Ar 1  A5 A4        	LDA	Nbendl		; get new start low byte
000E5Cr 1  A4 A5        	LDY	Nbendh		; get new start high byte (-$100)
000E5Er 1  C8           	INY				; correct high byte
000E5Fr 1  85 7D        	STA	Sarryl		; save new var mem end low byte
000E61r 1  84 7E        	STY	Sarryh		; save new var mem end high byte
000E63r 1  A0 00        	LDY	#$00			; clear index
000E65r 1  A5 93        	LDA	Varnm1		; get var name 1st character
000E67r 1  91 AA        	STA	(Vrschl),Y		; save var name 1st character
000E69r 1  C8           	INY				; increment index
000E6Ar 1  A5 94        	LDA	Varnm2		; get var name 2nd character
000E6Cr 1  91 AA        	STA	(Vrschl),Y		; save var name 2nd character
000E6Er 1  A9 00        	LDA	#$00			; clear A
000E70r 1  C8           	INY				; increment index
000E71r 1  91 AA        	STA	(Vrschl),Y		; initialise var byte
000E73r 1  C8           	INY				; increment index
000E74r 1  91 AA        	STA	(Vrschl),Y		; initialise var byte
000E76r 1  C8           	INY				; increment index
000E77r 1  91 AA        	STA	(Vrschl),Y		; initialise var byte
000E79r 1  C8           	INY				; increment index
000E7Ar 1  91 AA        	STA	(Vrschl),Y		; initialise var byte
000E7Cr 1               
000E7Cr 1               					; found a match for var ((Vrschl) = ptr)
000E7Cr 1               LAB_1DD7
000E7Cr 1  A5 AA        	LDA	Vrschl		; get var address low byte
000E7Er 1  18           	CLC				; clear carry for add
000E7Fr 1  69 02        	ADC	#$02			; +2 (offset past var name bytes)
000E81r 1  A4 AB        	LDY	Vrschh		; get var address high byte
000E83r 1  90 01        	BCC	LAB_1DE1		; branch if no overflow from add
000E85r 1               
000E85r 1  C8           	INY				; else increment high byte
000E86r 1               LAB_1DE1
000E86r 1  85 95        	STA	Cvaral		; save current var address low byte
000E88r 1  84 96        	STY	Cvarah		; save current var address high byte
000E8Ar 1  60           	RTS
000E8Br 1               
000E8Br 1               ; set-up array pointer (Adatal/h) to first element in array
000E8Br 1               ; set Adatal,Adatah to Astrtl,Astrth+2*Dimcnt+#$05
000E8Br 1               
000E8Br 1               LAB_1DE6
000E8Br 1  A5 5D        	LDA	Dimcnt		; get # of dimensions (1, 2 or 3)
000E8Dr 1  0A           	ASL				; *2 (also clears the carry !)
000E8Er 1  69 05        	ADC	#$05			; +5 (result is 7, 9 or 11 here)
000E90r 1  65 AA        	ADC	Astrtl		; add array start pointer low byte
000E92r 1  A4 AB        	LDY	Astrth		; get array pointer high byte
000E94r 1  90 01        	BCC	LAB_1DF2		; branch if no overflow
000E96r 1               
000E96r 1  C8           	INY				; else increment high byte
000E97r 1               LAB_1DF2
000E97r 1  85 A4        	STA	Adatal		; save array data pointer low byte
000E99r 1  84 A5        	STY	Adatah		; save array data pointer high byte
000E9Br 1  60           	RTS
000E9Cr 1               
000E9Cr 1               ; evaluate integer expression
000E9Cr 1               
000E9Cr 1               LAB_EVIN
000E9Cr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
000E9Fr 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
000EA2r 1               					; else do type mismatch
000EA2r 1               
000EA2r 1               ; evaluate integer expression (no check)
000EA2r 1               
000EA2r 1               LAB_EVPI
000EA2r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
000EA4r 1  30 0D        	BMI	LAB_1E12		; do function call error if -ve
000EA6r 1               
000EA6r 1               ; evaluate integer expression (no sign check)
000EA6r 1               
000EA6r 1               LAB_EVIR
000EA6r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
000EA8r 1  C9 90        	CMP	#$90			; compare with exponent = 2^16 (n>2^15)
000EAAr 1  90 09        	BCC	LAB_1E14		; branch if n<2^16 (is ok)
000EACr 1               
000EACr 1  A9 rr        	LDA	#<LAB_1DF7		; set pointer low byte to -32768
000EAEr 1  A0 rr        	LDY	#>LAB_1DF7		; set pointer high byte to -32768
000EB0r 1  20 rr rr     	JSR	LAB_27F8		; compare FAC1 with (AY)
000EB3r 1               LAB_1E12
000EB3r 1  D0 74        	BNE	LAB_FCER		; if <> do function call error then warm start
000EB5r 1               
000EB5r 1               LAB_1E14
000EB5r 1  4C rr rr     	JMP	LAB_2831		; convert FAC1 floating-to-fixed and return
000EB8r 1               
000EB8r 1               ; find or make array
000EB8r 1               
000EB8r 1               LAB_1E17
000EB8r 1  A5 5E        	LDA	Defdim		; get DIM flag
000EBAr 1  48           	PHA				; push it
000EBBr 1  A5 5F        	LDA	Dtypef		; get data type flag, $FF=string, $00=numeric
000EBDr 1  48           	PHA				; push it
000EBEr 1  A0 00        	LDY	#$00			; clear dimensions count
000EC0r 1               
000EC0r 1               ; now get the array dimension(s) and stack it (them) before the data type and DIM flag
000EC0r 1               
000EC0r 1               LAB_1E1F
000EC0r 1  98           	TYA				; copy dimensions count
000EC1r 1  48           	PHA				; save it
000EC2r 1  A5 94        	LDA	Varnm2		; get array name 2nd byte
000EC4r 1  48           	PHA				; save it
000EC5r 1  A5 93        	LDA	Varnm1		; get array name 1st byte
000EC7r 1  48           	PHA				; save it
000EC8r 1  20 rr rr     	JSR	LAB_EVIN		; evaluate integer expression
000ECBr 1  68           	PLA				; pull array name 1st byte
000ECCr 1  85 93        	STA	Varnm1		; restore array name 1st byte
000ECEr 1  68           	PLA				; pull array name 2nd byte
000ECFr 1  85 94        	STA	Varnm2		; restore array name 2nd byte
000ED1r 1  68           	PLA				; pull dimensions count
000ED2r 1  A8           	TAY				; restore it
000ED3r 1  BA           	TSX				; copy stack pointer
000ED4r 1  BD 02 01     	LDA	LAB_STAK+2,X	; get DIM flag
000ED7r 1  48           	PHA				; push it
000ED8r 1  BD 01 01     	LDA	LAB_STAK+1,X	; get data type flag
000EDBr 1  48           	PHA				; push it
000EDCr 1  A5 AE        	LDA	FAC1_2		; get this dimension size high byte
000EDEr 1  9D 02 01     	STA	LAB_STAK+2,X	; stack before flag bytes
000EE1r 1  A5 AF        	LDA	FAC1_3		; get this dimension size low byte
000EE3r 1  9D 01 01     	STA	LAB_STAK+1,X	; stack before flag bytes
000EE6r 1  C8           	INY				; increment dimensions count
000EE7r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
000EEAr 1  C9 2C        	CMP	#','			; compare with ","
000EECr 1  F0 D2        	BEQ	LAB_1E1F		; if found go do next dimension
000EEEr 1               
000EEEr 1  84 5D        	STY	Dimcnt		; store dimensions count
000EF0r 1  20 rr rr     	JSR	LAB_1BFB		; scan for ")" , else do syntax error then warm start
000EF3r 1  68           	PLA				; pull data type flag
000EF4r 1  85 5F        	STA	Dtypef		; restore data type flag, $FF=string, $00=numeric
000EF6r 1  68           	PLA				; pull DIM flag
000EF7r 1  85 5E        	STA	Defdim		; restore DIM flag
000EF9r 1  A6 7D        	LDX	Sarryl		; get array mem start low byte
000EFBr 1  A5 7E        	LDA	Sarryh		; get array mem start high byte
000EFDr 1               
000EFDr 1               ; now check to see if we are at the end of array memory (we would be if there were
000EFDr 1               ; no arrays).
000EFDr 1               
000EFDr 1               LAB_1E5C
000EFDr 1  86 AA        	STX	Astrtl		; save as array start pointer low byte
000EFFr 1  85 AB        	STA	Astrth		; save as array start pointer high byte
000F01r 1  C5 80        	CMP	Earryh		; compare with array mem end high byte
000F03r 1  D0 04        	BNE	LAB_1E68		; branch if not reached array mem end
000F05r 1               
000F05r 1  E4 7F        	CPX	Earryl		; else compare with array mem end low byte
000F07r 1  F0 39        	BEQ	LAB_1EA1		; go build array if not found
000F09r 1               
000F09r 1               					; search for array
000F09r 1               LAB_1E68
000F09r 1  A0 00        	LDY	#$00			; clear index
000F0Br 1  B1 AA        	LDA	(Astrtl),Y		; get array name first byte
000F0Dr 1  C8           	INY				; increment index to second name byte
000F0Er 1  C5 93        	CMP	Varnm1		; compare with this array name first byte
000F10r 1  D0 06        	BNE	LAB_1E77		; branch if no match
000F12r 1               
000F12r 1  A5 94        	LDA	Varnm2		; else get this array name second byte
000F14r 1  D1 AA        	CMP	(Astrtl),Y		; compare with array name second byte
000F16r 1  F0 16        	BEQ	LAB_1E8D		; array found so branch
000F18r 1               
000F18r 1               					; no match
000F18r 1               LAB_1E77
000F18r 1  C8           	INY				; increment index
000F19r 1  B1 AA        	LDA	(Astrtl),Y		; get array size low byte
000F1Br 1  18           	CLC				; clear carry for add
000F1Cr 1  65 AA        	ADC	Astrtl		; add array start pointer low byte
000F1Er 1  AA           	TAX				; copy low byte to X
000F1Fr 1  C8           	INY				; increment index
000F20r 1  B1 AA        	LDA	(Astrtl),Y		; get array size high byte
000F22r 1  65 AB        	ADC	Astrth		; add array mem pointer high byte
000F24r 1  90 D7        	BCC	LAB_1E5C		; if no overflow go check next array
000F26r 1               
000F26r 1               ; do array bounds error
000F26r 1               
000F26r 1               LAB_1E85
000F26r 1  A2 10        	LDX	#$10			; error code $10 ("Array bounds" error)
000F28r 1  2C           	.byte	$2C			; makes next bit BIT LAB_08A2
000F29r 1               
000F29r 1               ; do function call error
000F29r 1               
000F29r 1               LAB_FCER
000F29r 1  A2 08        	LDX	#$08			; error code $08 ("Function call" error)
000F2Br 1               LAB_1E8A
000F2Br 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
000F2Er 1               
000F2Er 1               					; found array, are we trying to dimension it?
000F2Er 1               LAB_1E8D
000F2Er 1  A2 12        	LDX	#$12			; set error $12 ("Double dimension" error)
000F30r 1  A5 5E        	LDA	Defdim		; get DIM flag
000F32r 1  D0 F7        	BNE	LAB_1E8A		; if we are trying to dimension it do error #X, then warm
000F34r 1               					; start
000F34r 1               
000F34r 1               ; found the array and we"re not dimensioning it so we must find an element in it
000F34r 1               
000F34r 1  20 rr rr     	JSR	LAB_1DE6		; set-up array pointer (Adatal/h) to first element in array
000F37r 1               					; (Astrtl,Astrth points to start of array)
000F37r 1  A5 5D        	LDA	Dimcnt		; get dimensions count
000F39r 1  A0 04        	LDY	#$04			; set index to array's # of dimensions
000F3Br 1  D1 AA        	CMP	(Astrtl),Y		; compare with no of dimensions
000F3Dr 1  D0 E7        	BNE	LAB_1E85		; if wrong do array bounds error, could do "Wrong
000F3Fr 1               					; dimensions" error here .. if we want a different
000F3Fr 1               					; error message
000F3Fr 1               
000F3Fr 1  4C rr rr     	JMP	LAB_1F28		; found array so go get element
000F42r 1               					; (could jump to LAB_1F28 as all LAB_1F24 does is take
000F42r 1               					; Dimcnt and save it at (Astrtl),Y which is already the
000F42r 1               					; same or we would have taken the BNE)
000F42r 1               
000F42r 1               					; array not found, so build it
000F42r 1               LAB_1EA1
000F42r 1  20 rr rr     	JSR	LAB_1DE6		; set-up array pointer (Adatal/h) to first element in array
000F45r 1               					; (Astrtl,Astrth points to start of array)
000F45r 1  20 rr rr     	JSR	LAB_121F		; check available memory, "Out of memory" error if no room
000F48r 1               					; addr to check is in AY (low/high)
000F48r 1  A0 00        	LDY	#$00			; clear Y (don't need to clear A)
000F4Ar 1  84 BB        	STY	Aspth			; clear array data size high byte
000F4Cr 1  A5 93        	LDA	Varnm1		; get variable name 1st byte
000F4Er 1  91 AA        	STA	(Astrtl),Y		; save array name 1st byte
000F50r 1  C8           	INY				; increment index
000F51r 1  A5 94        	LDA	Varnm2		; get variable name 2nd byte
000F53r 1  91 AA        	STA	(Astrtl),Y		; save array name 2nd byte
000F55r 1  A5 5D        	LDA	Dimcnt		; get dimensions count
000F57r 1  A0 04        	LDY	#$04			; index to dimension count
000F59r 1  84 BA        	STY	Asptl			; set array data size low byte (four bytes per element)
000F5Br 1  91 AA        	STA	(Astrtl),Y		; set array's dimensions count
000F5Dr 1               
000F5Dr 1               					; now calculate the size of the data space for the array
000F5Dr 1  18           	CLC				; clear carry for add (clear on subsequent loops)
000F5Er 1               LAB_1EC0
000F5Er 1  A2 0B        	LDX	#$0B			; set default dimension value low byte
000F60r 1  A9 00        	LDA	#$00			; set default dimension value high byte
000F62r 1  24 5E        	BIT	Defdim		; test default DIM flag
000F64r 1  50 07        	BVC	LAB_1ED0		; branch if b6 of Defdim is clear
000F66r 1               
000F66r 1  68           	PLA				; else pull dimension value low byte
000F67r 1  69 01        	ADC	#$01			; +1 (allow for zeroeth element)
000F69r 1  AA           	TAX				; copy low byte to X
000F6Ar 1  68           	PLA				; pull dimension value high byte
000F6Br 1  69 00        	ADC	#$00			; add carry from low byte
000F6Dr 1               
000F6Dr 1               LAB_1ED0
000F6Dr 1  C8           	INY				; index to dimension value high byte
000F6Er 1  91 AA        	STA	(Astrtl),Y		; save dimension value high byte
000F70r 1  C8           	INY				; index to dimension value high byte
000F71r 1  8A           	TXA				; get dimension value low byte
000F72r 1  91 AA        	STA	(Astrtl),Y		; save dimension value low byte
000F74r 1  20 rr rr     	JSR	LAB_1F7C		; does XY = (Astrtl),Y * (Asptl)
000F77r 1  86 BA        	STX	Asptl			; save array data size low byte
000F79r 1  85 BB        	STA	Aspth			; save array data size high byte
000F7Br 1  A4 71        	LDY	ut1_pl		; restore index (saved by subroutine)
000F7Dr 1  C6 5D        	DEC	Dimcnt		; decrement dimensions count
000F7Fr 1  D0 DD        	BNE	LAB_1EC0		; loop while not = 0
000F81r 1               
000F81r 1  65 A5        	ADC	Adatah		; add size high byte to first element high byte
000F83r 1               					; (carry is always clear here)
000F83r 1  B0 5D        	BCS	LAB_1F45		; if overflow go do "Out of memory" error
000F85r 1               
000F85r 1  85 A5        	STA	Adatah		; save end of array high byte
000F87r 1  A8           	TAY				; copy end high byte to Y
000F88r 1  8A           	TXA				; get array size low byte
000F89r 1  65 A4        	ADC	Adatal		; add array start low byte
000F8Br 1  90 03        	BCC	LAB_1EF3		; branch if no carry
000F8Dr 1               
000F8Dr 1  C8           	INY				; else increment end of array high byte
000F8Er 1  F0 52        	BEQ	LAB_1F45		; if overflow go do "Out of memory" error
000F90r 1               
000F90r 1               					; set-up mostly complete, now zero the array
000F90r 1               LAB_1EF3
000F90r 1  20 rr rr     	JSR	LAB_121F		; check available memory, "Out of memory" error if no room
000F93r 1               					; addr to check is in AY (low/high)
000F93r 1  85 7F        	STA	Earryl		; save array mem end low byte
000F95r 1  84 80        	STY	Earryh		; save array mem end high byte
000F97r 1  A9 00        	LDA	#$00			; clear byte for array clear
000F99r 1  E6 BB        	INC	Aspth			; increment array size high byte (now block count)
000F9Br 1  A4 BA        	LDY	Asptl			; get array size low byte (now index to block)
000F9Dr 1  F0 05        	BEQ	LAB_1F07		; branch if low byte = $00
000F9Fr 1               
000F9Fr 1               LAB_1F02
000F9Fr 1  88           	DEY				; decrement index (do 0 to n-1)
000FA0r 1  91 A4        	STA	(Adatal),Y		; zero byte
000FA2r 1  D0 FB        	BNE	LAB_1F02		; loop until this block done
000FA4r 1               
000FA4r 1               LAB_1F07
000FA4r 1  C6 A5        	DEC	Adatah		; decrement array pointer high byte
000FA6r 1  C6 BB        	DEC	Aspth			; decrement block count high byte
000FA8r 1  D0 F5        	BNE	LAB_1F02		; loop until all blocks done
000FAAr 1               
000FAAr 1  E6 A5        	INC	Adatah		; correct for last loop
000FACr 1  38           	SEC				; set carry for subtract
000FADr 1  A0 02        	LDY	#$02			; index to array size low byte
000FAFr 1  A5 7F        	LDA	Earryl		; get array mem end low byte
000FB1r 1  E5 AA        	SBC	Astrtl		; subtract array start low byte
000FB3r 1  91 AA        	STA	(Astrtl),Y		; save array size low byte
000FB5r 1  C8           	INY				; index to array size high byte
000FB6r 1  A5 80        	LDA	Earryh		; get array mem end high byte
000FB8r 1  E5 AB        	SBC	Astrth		; subtract array start high byte
000FBAr 1  91 AA        	STA	(Astrtl),Y		; save array size high byte
000FBCr 1  A5 5E        	LDA	Defdim		; get default DIM flag
000FBEr 1  D0 53        	BNE	LAB_1F7B		; exit (RET) if this was a DIM command
000FC0r 1               
000FC0r 1               					; else, find element
000FC0r 1  C8           	INY				; index to # of dimensions
000FC1r 1               
000FC1r 1               LAB_1F24
000FC1r 1  B1 AA        	LDA	(Astrtl),Y		; get array's dimension count
000FC3r 1  85 5D        	STA	Dimcnt		; save it
000FC5r 1               
000FC5r 1               ; we have found, or built, the array. now we need to find the element
000FC5r 1               
000FC5r 1               LAB_1F28
000FC5r 1  A9 00        	LDA	#$00			; clear byte
000FC7r 1  85 BA        	STA	Asptl			; clear array data pointer low byte
000FC9r 1               LAB_1F2C
000FC9r 1  85 BB        	STA	Aspth			; save array data pointer high byte
000FCBr 1  C8           	INY				; increment index (point to array bound high byte)
000FCCr 1  68           	PLA				; pull array index low byte
000FCDr 1  AA           	TAX				; copy to X
000FCEr 1  85 AE        	STA	FAC1_2		; save index low byte to FAC1 mantissa2
000FD0r 1  68           	PLA				; pull array index high byte
000FD1r 1  85 AF        	STA	FAC1_3		; save index high byte to FAC1 mantissa3
000FD3r 1  D1 AA        	CMP	(Astrtl),Y		; compare with array bound high byte
000FD5r 1  90 0E        	BCC	LAB_1F48		; branch if within bounds
000FD7r 1               
000FD7r 1  D0 06        	BNE	LAB_1F42		; if outside bounds do array bounds error
000FD9r 1               
000FD9r 1               					; else high byte was = so test low bytes
000FD9r 1  C8           	INY				; index to array bound low byte
000FDAr 1  8A           	TXA				; get array index low byte
000FDBr 1  D1 AA        	CMP	(Astrtl),Y		; compare with array bound low byte
000FDDr 1  90 07        	BCC	LAB_1F49		; branch if within bounds
000FDFr 1               
000FDFr 1               LAB_1F42
000FDFr 1  4C rr rr     	JMP	LAB_1E85		; else do array bounds error
000FE2r 1               
000FE2r 1               LAB_1F45
000FE2r 1  4C rr rr     	JMP	LAB_OMER		; do "Out of memory" error then warm start
000FE5r 1               
000FE5r 1               LAB_1F48
000FE5r 1  C8           	INY				; index to array bound low byte
000FE6r 1               LAB_1F49
000FE6r 1  A5 BB        	LDA	Aspth			; get array data pointer high byte
000FE8r 1  05 BA        	ORA	Asptl			; OR with array data pointer low byte
000FEAr 1  F0 0A        	BEQ	LAB_1F5A		; branch if array data pointer = null (skip multiply)
000FECr 1               
000FECr 1  20 rr rr     	JSR	LAB_1F7C		; does XY = (Astrtl),Y * (Asptl)
000FEFr 1  8A           	TXA				; get result low byte
000FF0r 1  65 AE        	ADC	FAC1_2		; add index low byte from FAC1 mantissa2
000FF2r 1  AA           	TAX				; save result low byte
000FF3r 1  98           	TYA				; get result high byte
000FF4r 1  A4 71        	LDY	ut1_pl		; restore index
000FF6r 1               LAB_1F5A
000FF6r 1  65 AF        	ADC	FAC1_3		; add index high byte from FAC1 mantissa3
000FF8r 1  86 BA        	STX	Asptl			; save array data pointer low byte
000FFAr 1  C6 5D        	DEC	Dimcnt		; decrement dimensions count
000FFCr 1  D0 CB        	BNE	LAB_1F2C		; loop if dimensions still to do
000FFEr 1               
000FFEr 1  06 BA        	ASL	Asptl			; array data pointer low byte * 2
001000r 1  2A           	ROL				; array data pointer high byte * 2
001001r 1  06 BA        	ASL	Asptl			; array data pointer low byte * 4
001003r 1  2A           	ROL				; array data pointer high byte * 4
001004r 1  A8           	TAY				; copy high byte
001005r 1  A5 BA        	LDA	Asptl			; get low byte
001007r 1  65 A4        	ADC	Adatal		; add array data start pointer low byte
001009r 1  85 95        	STA	Cvaral		; save as current var address low byte
00100Br 1  98           	TYA				; get high byte back
00100Cr 1  65 A5        	ADC	Adatah		; add array data start pointer high byte
00100Er 1  85 96        	STA	Cvarah		; save as current var address high byte
001010r 1  A8           	TAY				; copy high byte to Y
001011r 1  A5 95        	LDA	Cvaral		; get current var address low byte
001013r 1               LAB_1F7B
001013r 1  60           	RTS
001014r 1               
001014r 1               ; does XY = (Astrtl),Y * (Asptl)
001014r 1               
001014r 1               LAB_1F7C
001014r 1  84 71        	STY	ut1_pl		; save index
001016r 1  B1 AA        	LDA	(Astrtl),Y		; get dimension size low byte
001018r 1  85 76        	STA	dims_l		; save dimension size low byte
00101Ar 1  88           	DEY				; decrement index
00101Br 1  B1 AA        	LDA	(Astrtl),Y		; get dimension size high byte
00101Dr 1  85 77        	STA	dims_h		; save dimension size high byte
00101Fr 1               
00101Fr 1  A9 10        	LDA	#$10			; count = $10 (16 bit multiply)
001021r 1  85 A8        	STA	numbit		; save bit count
001023r 1  A2 00        	LDX	#$00			; clear result low byte
001025r 1  A0 00        	LDY	#$00			; clear result high byte
001027r 1               LAB_1F8F
001027r 1  8A           	TXA				; get result low byte
001028r 1  0A           	ASL				; *2
001029r 1  AA           	TAX				; save result low byte
00102Ar 1  98           	TYA				; get result high byte
00102Br 1  2A           	ROL				; *2
00102Cr 1  A8           	TAY				; save result high byte
00102Dr 1  B0 B3        	BCS	LAB_1F45		; if overflow go do "Out of memory" error
00102Fr 1               
00102Fr 1  06 BA        	ASL	Asptl			; shift multiplier low byte
001031r 1  26 BB        	ROL	Aspth			; shift multiplier high byte
001033r 1  90 0B        	BCC	LAB_1FA8		; skip add if no carry
001035r 1               
001035r 1  18           	CLC				; else clear carry for add
001036r 1  8A           	TXA				; get result low byte
001037r 1  65 76        	ADC	dims_l		; add dimension size low byte
001039r 1  AA           	TAX				; save result low byte
00103Ar 1  98           	TYA				; get result high byte
00103Br 1  65 77        	ADC	dims_h		; add dimension size high byte
00103Dr 1  A8           	TAY				; save result high byte
00103Er 1  B0 A2        	BCS	LAB_1F45		; if overflow go do "Out of memory" error
001040r 1               
001040r 1               LAB_1FA8
001040r 1  C6 A8        	DEC	numbit		; decrement bit count
001042r 1  D0 E3        	BNE	LAB_1F8F		; loop until all done
001044r 1               
001044r 1  60           	RTS
001045r 1               
001045r 1               ; perform FRE()
001045r 1               
001045r 1               LAB_FRE
001045r 1  A5 5F        	LDA	Dtypef		; get data type flag, $FF=string, $00=numeric
001047r 1  10 03        	BPL	LAB_1FB4		; branch if numeric
001049r 1               
001049r 1  20 rr rr     	JSR	LAB_22B6		; pop string off descriptor stack, or from top of string
00104Cr 1               					; space returns with A = length, X=$71=pointer low byte,
00104Cr 1               					; Y=$72=pointer high byte
00104Cr 1               
00104Cr 1               					; FRE(n) was numeric so do this
00104Cr 1               LAB_1FB4
00104Cr 1  20 rr rr     	JSR	LAB_GARB		; go do garbage collection
00104Fr 1  38           	SEC				; set carry for subtract
001050r 1  A5 81        	LDA	Sstorl		; get bottom of string space low byte
001052r 1  E5 7F        	SBC	Earryl		; subtract array mem end low byte
001054r 1  A8           	TAY				; copy result to Y
001055r 1  A5 82        	LDA	Sstorh		; get bottom of string space high byte
001057r 1  E5 80        	SBC	Earryh		; subtract array mem end high byte
001059r 1               
001059r 1               ; save and convert integer AY to FAC1
001059r 1               
001059r 1               LAB_AYFC
001059r 1  46 5F        	LSR	Dtypef		; clear data type flag, $FF=string, $00=numeric
00105Br 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
00105Dr 1  84 AE        	STY	FAC1_2		; save FAC1 mantissa2
00105Fr 1  A2 90        	LDX	#$90			; set exponent=2^16 (integer)
001061r 1  4C rr rr     	JMP	LAB_27E3		; set exp=X, clear FAC1_3, normalise and return
001064r 1               
001064r 1               ; perform POS()
001064r 1               
001064r 1               LAB_POS
001064r 1  A4 0E        	LDY	TPos			; get terminal position
001066r 1               
001066r 1               ; convert Y to byte in FAC1
001066r 1               
001066r 1               LAB_1FD0
001066r 1  A9 00        	LDA	#$00			; clear high byte
001068r 1  F0 EF        	BEQ	LAB_AYFC		; always save and convert integer AY to FAC1 and return
00106Ar 1               
00106Ar 1               ; check not Direct (used by DEF and INPUT)
00106Ar 1               
00106Ar 1               LAB_CKRN
00106Ar 1  A6 88        	LDX	Clineh		; get current line high byte
00106Cr 1  E8           	INX				; increment it
00106Dr 1  D0 A4        	BNE	LAB_1F7B		; return if can continue not direct mode
00106Fr 1               
00106Fr 1               					; else do illegal direct error
00106Fr 1               LAB_1FD9
00106Fr 1  A2 16        	LDX	#$16			; error code $16 ("Illegal direct" error)
001071r 1               LAB_1FDB
001071r 1  4C rr rr     	JMP	LAB_XERR		; go do error #X, then warm start
001074r 1               
001074r 1               ; perform DEF
001074r 1               
001074r 1               LAB_DEF
001074r 1  20 rr rr     	JSR	LAB_200B		; check FNx syntax
001077r 1  85 9C        	STA	func_l		; save function pointer low byte
001079r 1  84 9D        	STY	func_h		; save function pointer high byte
00107Br 1  20 rr rr     	JSR	LAB_CKRN		; check not Direct (back here if ok)
00107Er 1  20 rr rr     	JSR	LAB_1BFE		; scan for "(" , else do syntax error then warm start
001081r 1  A9 80        	LDA	#$80			; set flag for FNx
001083r 1  85 61        	STA	Sufnxf		; save subscript/FNx flag
001085r 1  20 rr rr     	JSR	LAB_GVAR		; get (var) address
001088r 1  20 rr rr     	JSR	LAB_CTNM		; check if source is numeric, else do type mismatch
00108Br 1  20 rr rr     	JSR	LAB_1BFB		; scan for ")" , else do syntax error then warm start
00108Er 1  A9 C2        	LDA	#TK_EQUAL		; get = token
001090r 1  20 rr rr     	JSR	LAB_SCCA		; scan for CHR$(A), else do syntax error then warm start
001093r 1  A5 96        	LDA	Cvarah		; get current var address high byte
001095r 1  48           	PHA				; push it
001096r 1  A5 95        	LDA	Cvaral		; get current var address low byte
001098r 1  48           	PHA				; push it
001099r 1  A5 C4        	LDA	Bpntrh		; get BASIC execute pointer high byte
00109Br 1  48           	PHA				; push it
00109Cr 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
00109Er 1  48           	PHA				; push it
00109Fr 1  20 rr rr     	JSR	LAB_DATA		; go perform DATA
0010A2r 1  4C rr rr     	JMP	LAB_207A		; put execute pointer and variable pointer into function
0010A5r 1               					; and return
0010A5r 1               
0010A5r 1               ; check FNx syntax
0010A5r 1               
0010A5r 1               LAB_200B
0010A5r 1  A9 AF        	LDA	#TK_FN		; get FN" token
0010A7r 1  20 rr rr     	JSR	LAB_SCCA		; scan for CHR$(A) , else do syntax error then warm start
0010AAr 1               					; return character after A
0010AAr 1  09 80        	ORA	#$80			; set FN flag bit
0010ACr 1  85 61        	STA	Sufnxf		; save FN flag so array variable test fails
0010AEr 1  20 rr rr     	JSR	LAB_1D12		; search for FN variable
0010B1r 1  4C rr rr     	JMP	LAB_CTNM		; check if source is numeric and return, else do type
0010B4r 1               					; mismatch
0010B4r 1               
0010B4r 1               					; Evaluate FNx
0010B4r 1               LAB_201E
0010B4r 1  20 rr rr     	JSR	LAB_200B		; check FNx syntax
0010B7r 1  48           	PHA				; push function pointer low byte
0010B8r 1  98           	TYA				; copy function pointer high byte
0010B9r 1  48           	PHA				; push function pointer high byte
0010BAr 1  20 rr rr     	JSR	LAB_1BFE		; scan for "(", else do syntax error then warm start
0010BDr 1  20 rr rr     	JSR	LAB_EVEX		; evaluate expression
0010C0r 1  20 rr rr     	JSR	LAB_1BFB		; scan for ")", else do syntax error then warm start
0010C3r 1  20 rr rr     	JSR	LAB_CTNM		; check if source is numeric, else do type mismatch
0010C6r 1  68           	PLA				; pop function pointer high byte
0010C7r 1  85 9D        	STA	func_h		; restore it
0010C9r 1  68           	PLA				; pop function pointer low byte
0010CAr 1  85 9C        	STA	func_l		; restore it
0010CCr 1  A2 20        	LDX	#$20			; error code $20 ("Undefined function" error)
0010CEr 1  A0 03        	LDY	#$03			; index to variable pointer high byte
0010D0r 1  B1 9C        	LDA	(func_l),Y		; get variable pointer high byte
0010D2r 1  F0 9D        	BEQ	LAB_1FDB		; if zero go do undefined function error
0010D4r 1               
0010D4r 1  85 96        	STA	Cvarah		; save variable address high byte
0010D6r 1  88           	DEY				; index to variable address low byte
0010D7r 1  B1 9C        	LDA	(func_l),Y		; get variable address low byte
0010D9r 1  85 95        	STA	Cvaral		; save variable address low byte
0010DBr 1  AA           	TAX				; copy address low byte
0010DCr 1               
0010DCr 1               					; now stack the function variable value before use
0010DCr 1  C8           	INY				; index to mantissa_3
0010DDr 1               LAB_2043
0010DDr 1  B1 95        	LDA	(Cvaral),Y		; get byte from variable
0010DFr 1  48           	PHA				; stack it
0010E0r 1  88           	DEY				; decrement index
0010E1r 1  10 FA        	BPL	LAB_2043		; loop until variable stacked
0010E3r 1               
0010E3r 1  A4 96        	LDY	Cvarah		; get variable address high byte
0010E5r 1  20 rr rr     	JSR	LAB_2778		; pack FAC1 (function expression value) into (XY)
0010E8r 1               					; (function variable), return Y=0, always
0010E8r 1  A5 C4        	LDA	Bpntrh		; get BASIC execute pointer high byte
0010EAr 1  48           	PHA				; push it
0010EBr 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
0010EDr 1  48           	PHA				; push it
0010EEr 1  B1 9C        	LDA	(func_l),Y		; get function execute pointer low byte
0010F0r 1  85 C3        	STA	Bpntrl		; save as BASIC execute pointer low byte
0010F2r 1  C8           	INY				; index to high byte
0010F3r 1  B1 9C        	LDA	(func_l),Y		; get function execute pointer high byte
0010F5r 1  85 C4        	STA	Bpntrh		; save as BASIC execute pointer high byte
0010F7r 1  A5 96        	LDA	Cvarah		; get variable address high byte
0010F9r 1  48           	PHA				; push it
0010FAr 1  A5 95        	LDA	Cvaral		; get variable address low byte
0010FCr 1  48           	PHA				; push it
0010FDr 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
001100r 1               					; else do type mismatch
001100r 1  68           	PLA				; pull variable address low byte
001101r 1  85 9C        	STA	func_l		; save variable address low byte
001103r 1  68           	PLA				; pull variable address high byte
001104r 1  85 9D        	STA	func_h		; save variable address high byte
001106r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
001109r 1  F0 03        	BEQ	LAB_2074		; branch if null (should be [EOL] marker)
00110Br 1               
00110Br 1  4C rr rr     	JMP	LAB_SNER		; else syntax error then warm start
00110Er 1               
00110Er 1               ; restore Bpntrl,Bpntrh and function variable from stack
00110Er 1               
00110Er 1               LAB_2074
00110Er 1  68           	PLA				; pull BASIC execute pointer low byte
00110Fr 1  85 C3        	STA	Bpntrl		; restore BASIC execute pointer low byte
001111r 1  68           	PLA				; pull BASIC execute pointer high byte
001112r 1  85 C4        	STA	Bpntrh		; restore BASIC execute pointer high byte
001114r 1               
001114r 1               ; put execute pointer and variable pointer into function
001114r 1               
001114r 1               LAB_207A
001114r 1  A0 00        	LDY	#$00			; clear index
001116r 1  68           	PLA				; pull BASIC execute pointer low byte
001117r 1  91 9C        	STA	(func_l),Y		; save to function
001119r 1  C8           	INY				; increment index
00111Ar 1  68           	PLA				; pull BASIC execute pointer high byte
00111Br 1  91 9C        	STA	(func_l),Y		; save to function
00111Dr 1  C8           	INY				; increment index
00111Er 1  68           	PLA				; pull current var address low byte
00111Fr 1  91 9C        	STA	(func_l),Y		; save to function
001121r 1  C8           	INY				; increment index
001122r 1  68           	PLA				; pull current var address high byte
001123r 1  91 9C        	STA	(func_l),Y		; save to function
001125r 1  60           	RTS
001126r 1               
001126r 1               ; perform STR$()
001126r 1               
001126r 1               LAB_STRS
001126r 1  20 rr rr     	JSR	LAB_CTNM		; check if source is numeric, else do type mismatch
001129r 1  20 rr rr     	JSR	LAB_296E		; convert FAC1 to string
00112Cr 1  A9 F0        	LDA	#<Decssp1		; set result string low pointer
00112Er 1  A0 00        	LDY	#>Decssp1		; set result string high pointer
001130r 1  F0 12        	BEQ	LAB_20AE		; print null terminated string to Sutill/Sutilh
001132r 1               
001132r 1               ; Do string vector
001132r 1               ; copy des_pl/h to des_2l/h and make string space A bytes long
001132r 1               
001132r 1               LAB_209C
001132r 1  A6 AE        	LDX	des_pl		; get descriptor pointer low byte
001134r 1  A4 AF        	LDY	des_ph		; get descriptor pointer high byte
001136r 1  86 9E        	STX	des_2l		; save descriptor pointer low byte
001138r 1  84 9F        	STY	des_2h		; save descriptor pointer high byte
00113Ar 1               
00113Ar 1               ; make string space A bytes long
00113Ar 1               ; A=length, X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
00113Ar 1               
00113Ar 1               LAB_MSSP
00113Ar 1  20 rr rr     	JSR	LAB_2115		; make space in string memory for string A long
00113Dr 1               					; return X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
00113Dr 1  86 AD        	STX	str_pl		; save string pointer low byte
00113Fr 1  84 AE        	STY	str_ph		; save string pointer high byte
001141r 1  85 AC        	STA	str_ln		; save length
001143r 1  60           	RTS
001144r 1               
001144r 1               ; Scan, set up string
001144r 1               ; print " terminated string to Sutill/Sutilh
001144r 1               
001144r 1               LAB_20AE
001144r 1  A2 22        	LDX	#$22			; set terminator to "
001146r 1  86 5B        	STX	Srchc			; set search character (terminator 1)
001148r 1  86 5C        	STX	Asrch			; set terminator 2
00114Ar 1               
00114Ar 1               ; print [Srchc] or [Asrch] terminated string to Sutill/Sutilh
00114Ar 1               ; source is AY
00114Ar 1               
00114Ar 1               LAB_20B4
00114Ar 1  85 B8        	STA	ssptr_l		; store string start low byte
00114Cr 1  84 B9        	STY	ssptr_h		; store string start high byte
00114Er 1  85 AD        	STA	str_pl		; save string pointer low byte
001150r 1  84 AE        	STY	str_ph		; save string pointer high byte
001152r 1  A0 FF        	LDY	#$FF			; set length to -1
001154r 1               LAB_20BE
001154r 1  C8           	INY				; increment length
001155r 1  B1 B8        	LDA	(ssptr_l),Y		; get byte from string
001157r 1  F0 0C        	BEQ	LAB_20CF		; exit loop if null byte [EOS]
001159r 1               
001159r 1  C5 5B        	CMP	Srchc			; compare with search character (terminator 1)
00115Br 1  F0 04        	BEQ	LAB_20CB		; branch if terminator
00115Dr 1               
00115Dr 1  C5 5C        	CMP	Asrch			; compare with terminator 2
00115Fr 1  D0 F3        	BNE	LAB_20BE		; loop if not terminator 2
001161r 1               
001161r 1               LAB_20CB
001161r 1  C9 22        	CMP	#$22			; compare with "
001163r 1  F0 01        	BEQ	LAB_20D0		; branch if " (carry set if = !)
001165r 1               
001165r 1               LAB_20CF
001165r 1  18           	CLC				; clear carry for add (only if [EOL] terminated string)
001166r 1               LAB_20D0
001166r 1  84 AC        	STY	str_ln		; save length in FAC1 exponent
001168r 1  98           	TYA				; copy length to A
001169r 1  65 B8        	ADC	ssptr_l		; add string start low byte
00116Br 1  85 BA        	STA	Sendl			; save string end low byte
00116Dr 1  A6 B9        	LDX	ssptr_h		; get string start high byte
00116Fr 1  90 01        	BCC	LAB_20DC		; branch if no low byte overflow
001171r 1               
001171r 1  E8           	INX				; else increment high byte
001172r 1               LAB_20DC
001172r 1  86 BB        	STX	Sendh			; save string end high byte
001174r 1  A5 B9        	LDA	ssptr_h		; get string start high byte
001176r 1  C9 04        	CMP	#>Ram_base		; compare with start of program memory
001178r 1  B0 0B        	BCS	LAB_RTST		; branch if not in utility area
00117Ar 1               
00117Ar 1               					; string in utility area, move to string memory
00117Ar 1  98           	TYA				; copy length to A
00117Br 1  20 rr rr     	JSR	LAB_209C		; copy des_pl/h to des_2l/h and make string space A bytes
00117Er 1               					; long
00117Er 1  A6 B8        	LDX	ssptr_l		; get string start low byte
001180r 1  A4 B9        	LDY	ssptr_h		; get string start high byte
001182r 1  20 rr rr     	JSR	LAB_2298		; store string A bytes long from XY to (Sutill)
001185r 1               
001185r 1               ; check for space on descriptor stack then ..
001185r 1               ; put string address and length on descriptor stack and update stack pointers
001185r 1               
001185r 1               LAB_RTST
001185r 1  A6 65        	LDX	next_s		; get string stack pointer
001187r 1  E0 71        	CPX	#des_sk+$09		; compare with max+1
001189r 1  D0 05        	BNE	LAB_20F8		; branch if space on string stack
00118Br 1               
00118Br 1               					; else do string too complex error
00118Br 1  A2 1C        	LDX	#$1C			; error code $1C ("String too complex" error)
00118Dr 1               LAB_20F5
00118Dr 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
001190r 1               
001190r 1               ; put string address and length on descriptor stack and update stack pointers
001190r 1               
001190r 1               LAB_20F8
001190r 1  A5 AC        	LDA	str_ln		; get string length
001192r 1  95 00        	STA	PLUS_0,X		; put on string stack
001194r 1  A5 AD        	LDA	str_pl		; get string pointer low byte
001196r 1  95 01        	STA	PLUS_1,X		; put on string stack
001198r 1  A5 AE        	LDA	str_ph		; get string pointer high byte
00119Ar 1  95 02        	STA	PLUS_2,X		; put on string stack
00119Cr 1  A0 00        	LDY	#$00			; clear Y
00119Er 1  86 AE        	STX	des_pl		; save string descriptor pointer low byte
0011A0r 1  84 AF        	STY	des_ph		; save string descriptor pointer high byte (always $00)
0011A2r 1  88           	DEY				; Y = $FF
0011A3r 1  84 5F        	STY	Dtypef		; save data type flag, $FF=string
0011A5r 1  86 66        	STX	last_sl		; save old stack pointer (current top item)
0011A7r 1  E8           	INX				; update stack pointer
0011A8r 1  E8           	INX				; update stack pointer
0011A9r 1  E8           	INX				; update stack pointer
0011AAr 1  86 65        	STX	next_s		; save new top item value
0011ACr 1  60           	RTS
0011ADr 1               
0011ADr 1               ; Build descriptor
0011ADr 1               ; make space in string memory for string A long
0011ADr 1               ; return X=Sutill=ptr low byte, Y=Sutill=ptr high byte
0011ADr 1               
0011ADr 1               LAB_2115
0011ADr 1  46 60        	LSR	Gclctd		; clear garbage collected flag (b7)
0011AFr 1               
0011AFr 1               					; make space for string A long
0011AFr 1               LAB_2117
0011AFr 1  48           	PHA				; save string length
0011B0r 1  49 FF        	EOR	#$FF			; complement it
0011B2r 1  38           	SEC				; set carry for subtract (twos comp add)
0011B3r 1  65 81        	ADC	Sstorl		; add bottom of string space low byte (subtract length)
0011B5r 1  A4 82        	LDY	Sstorh		; get bottom of string space high byte
0011B7r 1  B0 01        	BCS	LAB_2122		; skip decrement if no underflow
0011B9r 1               
0011B9r 1  88           	DEY				; decrement bottom of string space high byte
0011BAr 1               LAB_2122
0011BAr 1  C4 80        	CPY	Earryh		; compare with array mem end high byte
0011BCr 1  90 11        	BCC	LAB_2137		; do out of memory error if less
0011BEr 1               
0011BEr 1  D0 04        	BNE	LAB_212C		; if not = skip next test
0011C0r 1               
0011C0r 1  C5 7F        	CMP	Earryl		; compare with array mem end low byte
0011C2r 1  90 0B        	BCC	LAB_2137		; do out of memory error if less
0011C4r 1               
0011C4r 1               LAB_212C
0011C4r 1  85 81        	STA	Sstorl		; save bottom of string space low byte
0011C6r 1  84 82        	STY	Sstorh		; save bottom of string space high byte
0011C8r 1  85 83        	STA	Sutill		; save string utility ptr low byte
0011CAr 1  84 84        	STY	Sutilh		; save string utility ptr high byte
0011CCr 1  AA           	TAX				; copy low byte to X
0011CDr 1  68           	PLA				; get string length back
0011CEr 1  60           	RTS
0011CFr 1               
0011CFr 1               LAB_2137
0011CFr 1  A2 0C        	LDX	#$0C			; error code $0C ("Out of memory" error)
0011D1r 1  A5 60        	LDA	Gclctd		; get garbage collected flag
0011D3r 1  30 B8        	BMI	LAB_20F5		; if set then do error code X
0011D5r 1               
0011D5r 1  20 rr rr     	JSR	LAB_GARB		; else go do garbage collection
0011D8r 1  A9 80        	LDA	#$80			; flag for garbage collected
0011DAr 1  85 60        	STA	Gclctd		; set garbage collected flag
0011DCr 1  68           	PLA				; pull length
0011DDr 1  D0 D0        	BNE	LAB_2117		; go try again (loop always, length should never be = $00)
0011DFr 1               
0011DFr 1               ; garbage collection routine
0011DFr 1               
0011DFr 1               LAB_GARB
0011DFr 1  A6 85        	LDX	Ememl			; get end of mem low byte
0011E1r 1  A5 86        	LDA	Ememh			; get end of mem high byte
0011E3r 1               
0011E3r 1               ; re-run routine from last ending
0011E3r 1               
0011E3r 1               LAB_214B
0011E3r 1  86 81        	STX	Sstorl		; set string storage low byte
0011E5r 1  85 82        	STA	Sstorh		; set string storage high byte
0011E7r 1  A0 00        	LDY	#$00			; clear index
0011E9r 1  84 9D        	STY	garb_h		; clear working pointer high byte (flag no strings to move)
0011EBr 1  A5 7F        	LDA	Earryl		; get array mem end low byte
0011EDr 1  A6 80        	LDX	Earryh		; get array mem end high byte
0011EFr 1  85 AA        	STA	Histrl		; save as highest string low byte
0011F1r 1  86 AB        	STX	Histrh		; save as highest string high byte
0011F3r 1  A9 68        	LDA	#des_sk		; set descriptor stack pointer
0011F5r 1  85 71        	STA	ut1_pl		; save descriptor stack pointer low byte
0011F7r 1  84 72        	STY	ut1_ph		; save descriptor stack pointer high byte ($00)
0011F9r 1               LAB_2161
0011F9r 1  C5 65        	CMP	next_s		; compare with descriptor stack pointer
0011FBr 1  F0 05        	BEQ	LAB_216A		; branch if =
0011FDr 1               
0011FDr 1  20 rr rr     	JSR	LAB_21D7		; go garbage collect descriptor stack
001200r 1  F0 F7        	BEQ	LAB_2161		; loop always
001202r 1               
001202r 1               					; done stacked strings, now do string vars
001202r 1               LAB_216A
001202r 1  06 A0        	ASL	g_step		; set step size = $06
001204r 1  A5 7B        	LDA	Svarl			; get start of vars low byte
001206r 1  A6 7C        	LDX	Svarh			; get start of vars high byte
001208r 1  85 71        	STA	ut1_pl		; save as pointer low byte
00120Ar 1  86 72        	STX	ut1_ph		; save as pointer high byte
00120Cr 1               LAB_2176
00120Cr 1  E4 7E        	CPX	Sarryh		; compare start of arrays high byte
00120Er 1  D0 04        	BNE	LAB_217E		; branch if no high byte match
001210r 1               
001210r 1  C5 7D        	CMP	Sarryl		; else compare start of arrays low byte
001212r 1  F0 05        	BEQ	LAB_2183		; branch if = var mem end
001214r 1               
001214r 1               LAB_217E
001214r 1  20 rr rr     	JSR	LAB_21D1		; go garbage collect strings
001217r 1  F0 F3        	BEQ	LAB_2176		; loop always
001219r 1               
001219r 1               					; done string vars, now do string arrays
001219r 1               LAB_2183
001219r 1  85 A4        	STA	Nbendl		; save start of arrays low byte as working pointer
00121Br 1  86 A5        	STX	Nbendh		; save start of arrays high byte as working pointer
00121Dr 1  A9 04        	LDA	#$04			; set step size
00121Fr 1  85 A0        	STA	g_step		; save step size
001221r 1               LAB_218B
001221r 1  A5 A4        	LDA	Nbendl		; get pointer low byte
001223r 1  A6 A5        	LDX	Nbendh		; get pointer high byte
001225r 1               LAB_218F
001225r 1  E4 80        	CPX	Earryh		; compare with array mem end high byte
001227r 1  D0 04        	BNE	LAB_219A		; branch if not at end
001229r 1               
001229r 1  C5 7F        	CMP	Earryl		; else compare with array mem end low byte
00122Br 1  F0 75        	BEQ	LAB_2216		; tidy up and exit if at end
00122Dr 1               
00122Dr 1               LAB_219A
00122Dr 1  85 71        	STA	ut1_pl		; save pointer low byte
00122Fr 1  86 72        	STX	ut1_ph		; save pointer high byte
001231r 1  A0 02        	LDY	#$02			; set index
001233r 1  B1 71        	LDA	(ut1_pl),Y		; get array size low byte
001235r 1  65 A4        	ADC	Nbendl		; add start of this array low byte
001237r 1  85 A4        	STA	Nbendl		; save start of next array low byte
001239r 1  C8           	INY				; increment index
00123Ar 1  B1 71        	LDA	(ut1_pl),Y		; get array size high byte
00123Cr 1  65 A5        	ADC	Nbendh		; add start of this array high byte
00123Er 1  85 A5        	STA	Nbendh		; save start of next array high byte
001240r 1  A0 01        	LDY	#$01			; set index
001242r 1  B1 71        	LDA	(ut1_pl),Y		; get name second byte
001244r 1  10 DB        	BPL	LAB_218B		; skip if not string array
001246r 1               
001246r 1               ; was string array so ..
001246r 1               
001246r 1  A0 04        	LDY	#$04			; set index
001248r 1  B1 71        	LDA	(ut1_pl),Y		; get # of dimensions
00124Ar 1  0A           	ASL				; *2
00124Br 1  69 05        	ADC	#$05			; +5 (array header size)
00124Dr 1  20 rr rr     	JSR	LAB_2208		; go set up for first element
001250r 1               LAB_21C4
001250r 1  E4 A5        	CPX	Nbendh		; compare with start of next array high byte
001252r 1  D0 04        	BNE	LAB_21CC		; branch if <> (go do this array)
001254r 1               
001254r 1  C5 A4        	CMP	Nbendl		; else compare element pointer low byte with next array
001256r 1               					; low byte
001256r 1  F0 CD        	BEQ	LAB_218F		; if equal then go do next array
001258r 1               
001258r 1               LAB_21CC
001258r 1  20 rr rr     	JSR	LAB_21D7		; go defrag array strings
00125Br 1  F0 F3        	BEQ	LAB_21C4		; go do next array string (loop always)
00125Dr 1               
00125Dr 1               ; defrag string variables
00125Dr 1               ; enter with XA = variable pointer
00125Dr 1               ; return with XA = next variable pointer
00125Dr 1               
00125Dr 1               LAB_21D1
00125Dr 1  C8           	INY				; increment index (Y was $00)
00125Er 1  B1 71        	LDA	(ut1_pl),Y		; get var name byte 2
001260r 1  10 30        	BPL	LAB_2206		; if not string, step pointer to next var and return
001262r 1               
001262r 1  C8           	INY				; else increment index
001263r 1               LAB_21D7
001263r 1  B1 71        	LDA	(ut1_pl),Y		; get string length
001265r 1  F0 2B        	BEQ	LAB_2206		; if null, step pointer to next string and return
001267r 1               
001267r 1  C8           	INY				; else increment index
001268r 1  B1 71        	LDA	(ut1_pl),Y		; get string pointer low byte
00126Ar 1  AA           	TAX				; copy to X
00126Br 1  C8           	INY				; increment index
00126Cr 1  B1 71        	LDA	(ut1_pl),Y		; get string pointer high byte
00126Er 1  C5 82        	CMP	Sstorh		; compare bottom of string space high byte
001270r 1  90 06        	BCC	LAB_21EC		; branch if less
001272r 1               
001272r 1  D0 1E        	BNE	LAB_2206		; if greater, step pointer to next string and return
001274r 1               
001274r 1               					; high bytes were = so compare low bytes
001274r 1  E4 81        	CPX	Sstorl		; compare bottom of string space low byte
001276r 1  B0 1A        	BCS	LAB_2206		; if >=, step pointer to next string and return
001278r 1               
001278r 1               					; string pointer is < string storage pointer (pos in mem)
001278r 1               LAB_21EC
001278r 1  C5 AB        	CMP	Histrh		; compare to highest string high byte
00127Ar 1  90 17        	BCC	LAB_2207		; if <, step pointer to next string and return
00127Cr 1               
00127Cr 1  D0 04        	BNE	LAB_21F6		; if > update pointers, step to next and return
00127Er 1               
00127Er 1               					; high bytes were = so compare low bytes
00127Er 1  E4 AA        	CPX	Histrl		; compare to highest string low byte
001280r 1  90 11        	BCC	LAB_2207		; if <, step pointer to next string and return
001282r 1               
001282r 1               					; string is in string memory space
001282r 1               LAB_21F6
001282r 1  86 AA        	STX	Histrl		; save as new highest string low byte
001284r 1  85 AB        	STA	Histrh		; save as new highest string high byte
001286r 1  A5 71        	LDA	ut1_pl		; get start of vars(descriptors) low byte
001288r 1  A6 72        	LDX	ut1_ph		; get start of vars(descriptors) high byte
00128Ar 1  85 9C        	STA	garb_l		; save as working pointer low byte
00128Cr 1  86 9D        	STX	garb_h		; save as working pointer high byte
00128Er 1  88           	DEY				; decrement index DIFFERS
00128Fr 1  88           	DEY				; decrement index (should point to descriptor start)
001290r 1  84 A2        	STY	g_indx		; save index pointer
001292r 1               
001292r 1               					; step pointer to next string
001292r 1               LAB_2206
001292r 1  18           	CLC				; clear carry for add
001293r 1               LAB_2207
001293r 1  A5 A0        	LDA	g_step		; get step size
001295r 1               LAB_2208
001295r 1  65 71        	ADC	ut1_pl		; add pointer low byte
001297r 1  85 71        	STA	ut1_pl		; save pointer low byte
001299r 1  90 02        	BCC	LAB_2211		; branch if no overflow
00129Br 1               
00129Br 1  E6 72        	INC	ut1_ph		; else increment high byte
00129Dr 1               LAB_2211
00129Dr 1  A6 72        	LDX	ut1_ph		; get pointer high byte
00129Fr 1  A0 00        	LDY	#$00			; clear Y
0012A1r 1  60           	RTS
0012A2r 1               
0012A2r 1               ; search complete, now either exit or set-up and move string
0012A2r 1               
0012A2r 1               LAB_2216
0012A2r 1  C6 A0        	DEC	g_step		; decrement step size (now $03 for descriptor stack)
0012A4r 1  A6 9D        	LDX	garb_h		; get string to move high byte
0012A6r 1  F0 F5        	BEQ	LAB_2211		; exit if nothing to move
0012A8r 1               
0012A8r 1  A4 A2        	LDY	g_indx		; get index byte back (points to descriptor)
0012AAr 1  18           	CLC				; clear carry for add
0012ABr 1  B1 9C        	LDA	(garb_l),Y		; get string length
0012ADr 1  65 AA        	ADC	Histrl		; add highest string low byte
0012AFr 1  85 A6        	STA	Obendl		; save old block end low pointer
0012B1r 1  A5 AB        	LDA	Histrh		; get highest string high byte
0012B3r 1  69 00        	ADC	#$00			; add any carry
0012B5r 1  85 A7        	STA	Obendh		; save old block end high byte
0012B7r 1  A5 81        	LDA	Sstorl		; get bottom of string space low byte
0012B9r 1  A6 82        	LDX	Sstorh		; get bottom of string space high byte
0012BBr 1  85 A4        	STA	Nbendl		; save new block end low byte
0012BDr 1  86 A5        	STX	Nbendh		; save new block end high byte
0012BFr 1  20 rr rr     	JSR	LAB_11D6		; open up space in memory, don't set array end
0012C2r 1  A4 A2        	LDY	g_indx		; get index byte
0012C4r 1  C8           	INY				; point to descriptor low byte
0012C5r 1  A5 A4        	LDA	Nbendl		; get string pointer low byte
0012C7r 1  91 9C        	STA	(garb_l),Y		; save new string pointer low byte
0012C9r 1  AA           	TAX				; copy string pointer low byte
0012CAr 1  E6 A5        	INC	Nbendh		; correct high byte (move sets high byte -1)
0012CCr 1  A5 A5        	LDA	Nbendh		; get new string pointer high byte
0012CEr 1  C8           	INY				; point to descriptor high byte
0012CFr 1  91 9C        	STA	(garb_l),Y		; save new string pointer high byte
0012D1r 1  4C rr rr     	JMP	LAB_214B		; re-run routine from last ending
0012D4r 1               					; (but don't collect this string)
0012D4r 1               
0012D4r 1               ; concatenate
0012D4r 1               ; add strings, string 1 is in descriptor des_pl, string 2 is in line
0012D4r 1               
0012D4r 1               LAB_224D
0012D4r 1  A5 AF        	LDA	des_ph		; get descriptor pointer high byte
0012D6r 1  48           	PHA				; put on stack
0012D7r 1  A5 AE        	LDA	des_pl		; get descriptor pointer low byte
0012D9r 1  48           	PHA				; put on stack
0012DAr 1  20 rr rr     	JSR	LAB_GVAL		; get value from line
0012DDr 1  20 rr rr     	JSR	LAB_CTST		; check if source is string, else do type mismatch
0012E0r 1  68           	PLA				; get descriptor pointer low byte back
0012E1r 1  85 B8        	STA	ssptr_l		; set pointer low byte
0012E3r 1  68           	PLA				; get descriptor pointer high byte back
0012E4r 1  85 B9        	STA	ssptr_h		; set pointer high byte
0012E6r 1  A0 00        	LDY	#$00			; clear index
0012E8r 1  B1 B8        	LDA	(ssptr_l),Y		; get length_1 from descriptor
0012EAr 1  18           	CLC				; clear carry for add
0012EBr 1  71 AE        	ADC	(des_pl),Y		; add length_2
0012EDr 1  90 05        	BCC	LAB_226D		; branch if no overflow
0012EFr 1               
0012EFr 1  A2 1A        	LDX	#$1A			; else set error code $1A ("String too long" error)
0012F1r 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
0012F4r 1               
0012F4r 1               LAB_226D
0012F4r 1  20 rr rr     	JSR	LAB_209C		; copy des_pl/h to des_2l/h and make string space A bytes
0012F7r 1               					; long
0012F7r 1  20 rr rr     	JSR	LAB_228A		; copy string from descriptor (sdescr) to (Sutill)
0012FAr 1  A5 9E        	LDA	des_2l		; get descriptor pointer low byte
0012FCr 1  A4 9F        	LDY	des_2h		; get descriptor pointer high byte
0012FEr 1  20 rr rr     	JSR	LAB_22BA		; pop (YA) descriptor off stack or from top of string space
001301r 1               					; returns with A = length, ut1_pl = pointer low byte,
001301r 1               					; ut1_ph = pointer high byte
001301r 1  20 rr rr     	JSR	LAB_229C		; store string A bytes long from (ut1_pl) to (Sutill)
001304r 1  A5 B8        	LDA	ssptr_l		;.set descriptor pointer low byte
001306r 1  A4 B9        	LDY	ssptr_h		;.set descriptor pointer high byte
001308r 1  20 rr rr     	JSR	LAB_22BA		; pop (YA) descriptor off stack or from top of string space
00130Br 1               					; returns with A = length, X=ut1_pl=pointer low byte,
00130Br 1               					; Y=ut1_ph=pointer high byte
00130Br 1  20 rr rr     	JSR	LAB_RTST		; check for space on descriptor stack then put string
00130Er 1               					; address and length on descriptor stack and update stack
00130Er 1               					; pointers
00130Er 1  4C rr rr     	JMP	LAB_1ADB		;.continue evaluation
001311r 1               
001311r 1               ; copy string from descriptor (sdescr) to (Sutill)
001311r 1               
001311r 1               LAB_228A
001311r 1  A0 00        	LDY	#$00			; clear index
001313r 1  B1 B8        	LDA	(sdescr),Y		; get string length
001315r 1  48           	PHA				; save on stack
001316r 1  C8           	INY				; increment index
001317r 1  B1 B8        	LDA	(sdescr),Y		; get source string pointer low byte
001319r 1  AA           	TAX				; copy to X
00131Ar 1  C8           	INY				; increment index
00131Br 1  B1 B8        	LDA	(sdescr),Y		; get source string pointer high byte
00131Dr 1  A8           	TAY				; copy to Y
00131Er 1  68           	PLA				; get length back
00131Fr 1               
00131Fr 1               ; store string A bytes long from YX to (Sutill)
00131Fr 1               
00131Fr 1               LAB_2298
00131Fr 1  86 71        	STX	ut1_pl		; save source string pointer low byte
001321r 1  84 72        	STY	ut1_ph		; save source string pointer high byte
001323r 1               
001323r 1               ; store string A bytes long from (ut1_pl) to (Sutill)
001323r 1               
001323r 1               LAB_229C
001323r 1  AA           	TAX				; copy length to index (don't count with Y)
001324r 1  F0 14        	BEQ	LAB_22B2		; branch if = $0 (null string) no need to add zero length
001326r 1               
001326r 1  A0 00        	LDY	#$00			; zero pointer (copy forward)
001328r 1               LAB_22A0
001328r 1  B1 71        	LDA	(ut1_pl),Y		; get source byte
00132Ar 1  91 83        	STA	(Sutill),Y		; save destination byte
00132Cr 1               
00132Cr 1  C8           	INY				; increment index
00132Dr 1  CA           	DEX				; decrement counter
00132Er 1  D0 F8        	BNE	LAB_22A0		; loop while <> 0
001330r 1               
001330r 1  98           	TYA				; restore length from Y
001331r 1               LAB_22A9
001331r 1  18           	CLC				; clear carry for add
001332r 1  65 83        	ADC	Sutill		; add string utility ptr low byte
001334r 1  85 83        	STA	Sutill		; save string utility ptr low byte
001336r 1  90 02        	BCC	LAB_22B2		; branch if no carry
001338r 1               
001338r 1  E6 84        	INC	Sutilh		; else increment string utility ptr high byte
00133Ar 1               LAB_22B2
00133Ar 1  60           	RTS
00133Br 1               
00133Br 1               ; evaluate string
00133Br 1               
00133Br 1               LAB_EVST
00133Br 1  20 rr rr     	JSR	LAB_CTST		; check if source is string, else do type mismatch
00133Er 1               
00133Er 1               ; pop string off descriptor stack, or from top of string space
00133Er 1               ; returns with A = length, X=pointer low byte, Y=pointer high byte
00133Er 1               
00133Er 1               LAB_22B6
00133Er 1  A5 AE        	LDA	des_pl		; get descriptor pointer low byte
001340r 1  A4 AF        	LDY	des_ph		; get descriptor pointer high byte
001342r 1               
001342r 1               ; pop (YA) descriptor off stack or from top of string space
001342r 1               ; returns with A = length, X=ut1_pl=pointer low byte, Y=ut1_ph=pointer high byte
001342r 1               
001342r 1               LAB_22BA
001342r 1  85 71        	STA	ut1_pl		; save descriptor pointer low byte
001344r 1  84 72        	STY	ut1_ph		; save descriptor pointer high byte
001346r 1  20 rr rr     	JSR	LAB_22EB		; clean descriptor stack, YA = pointer
001349r 1  08           	PHP				; save status flags
00134Ar 1  A0 00        	LDY	#$00			; clear index
00134Cr 1  B1 71        	LDA	(ut1_pl),Y		; get length from string descriptor
00134Er 1  48           	PHA				; put on stack
00134Fr 1  C8           	INY				; increment index
001350r 1  B1 71        	LDA	(ut1_pl),Y		; get string pointer low byte from descriptor
001352r 1  AA           	TAX				; copy to X
001353r 1  C8           	INY				; increment index
001354r 1  B1 71        	LDA	(ut1_pl),Y		; get string pointer high byte from descriptor
001356r 1  A8           	TAY				; copy to Y
001357r 1  68           	PLA				; get string length back
001358r 1  28           	PLP				; restore status
001359r 1  D0 13        	BNE	LAB_22E6		; branch if pointer <> last_sl,last_sh
00135Br 1               
00135Br 1  C4 82        	CPY	Sstorh		; compare bottom of string space high byte
00135Dr 1  D0 0F        	BNE	LAB_22E6		; branch if <>
00135Fr 1               
00135Fr 1  E4 81        	CPX	Sstorl		; else compare bottom of string space low byte
001361r 1  D0 0B        	BNE	LAB_22E6		; branch if <>
001363r 1               
001363r 1  48           	PHA				; save string length
001364r 1  18           	CLC				; clear carry for add
001365r 1  65 81        	ADC	Sstorl		; add bottom of string space low byte
001367r 1  85 81        	STA	Sstorl		; save bottom of string space low byte
001369r 1  90 02        	BCC	LAB_22E5		; skip increment if no overflow
00136Br 1               
00136Br 1  E6 82        	INC	Sstorh		; increment bottom of string space high byte
00136Dr 1               LAB_22E5
00136Dr 1  68           	PLA				; restore string length
00136Er 1               LAB_22E6
00136Er 1  86 71        	STX	ut1_pl		; save string pointer low byte
001370r 1  84 72        	STY	ut1_ph		; save string pointer high byte
001372r 1  60           	RTS
001373r 1               
001373r 1               ; clean descriptor stack, YA = pointer
001373r 1               ; checks if AY is on the descriptor stack, if so does a stack discard
001373r 1               
001373r 1               LAB_22EB
001373r 1  C4 67        	CPY	last_sh		; compare pointer high byte
001375r 1  D0 0C        	BNE	LAB_22FB		; exit if <>
001377r 1               
001377r 1  C5 66        	CMP	last_sl		; compare pointer low byte
001379r 1  D0 08        	BNE	LAB_22FB		; exit if <>
00137Br 1               
00137Br 1  85 65        	STA	next_s		; save descriptor stack pointer
00137Dr 1  E9 03        	SBC	#$03			; -3
00137Fr 1  85 66        	STA	last_sl		; save low byte -3
001381r 1  A0 00        	LDY	#$00			; clear high byte
001383r 1               LAB_22FB
001383r 1  60           	RTS
001384r 1               
001384r 1               ; perform CHR$()
001384r 1               
001384r 1               LAB_CHRS
001384r 1  20 rr rr     	JSR	LAB_EVBY		; evaluate byte expression, result in X
001387r 1  8A           	TXA				; copy to A
001388r 1  48           	PHA				; save character
001389r 1  A9 01        	LDA	#$01			; string is single byte
00138Br 1  20 rr rr     	JSR	LAB_MSSP		; make string space A bytes long A=$AC=length,
00138Er 1               					; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte
00138Er 1  68           	PLA				; get character back
00138Fr 1  A0 00        	LDY	#$00			; clear index
001391r 1  91 AD        	STA	(str_pl),Y		; save byte in string (byte IS string!)
001393r 1  4C rr rr     	JMP	LAB_RTST		; check for space on descriptor stack then put string
001396r 1               					; address and length on descriptor stack and update stack
001396r 1               					; pointers
001396r 1               
001396r 1               ; perform LEFT$()
001396r 1               
001396r 1               LAB_LEFT
001396r 1  48           	PHA				; push byte parameter
001397r 1  20 rr rr     	JSR	LAB_236F		; pull string data and byte parameter from stack
00139Ar 1               					; return pointer in des_2l/h, byte in A (and X), Y=0
00139Ar 1  D1 9E        	CMP	(des_2l),Y		; compare byte parameter with string length
00139Cr 1  98           	TYA				; clear A
00139Dr 1  F0 09        	BEQ	LAB_2316		; go do string copy (branch always)
00139Fr 1               
00139Fr 1               ; perform RIGHT$()
00139Fr 1               
00139Fr 1               LAB_RIGHT
00139Fr 1  48           	PHA				; push byte parameter
0013A0r 1  20 rr rr     	JSR	LAB_236F		; pull string data and byte parameter from stack
0013A3r 1               					; return pointer in des_2l/h, byte in A (and X), Y=0
0013A3r 1  18           	CLC				; clear carry for add-1
0013A4r 1  F1 9E        	SBC	(des_2l),Y		; subtract string length
0013A6r 1  49 FF        	EOR	#$FF			; invert it (A=LEN(expression$)-l)
0013A8r 1               
0013A8r 1               LAB_2316
0013A8r 1  90 04        	BCC	LAB_231C		; branch if string length > byte parameter
0013AAr 1               
0013AAr 1  B1 9E        	LDA	(des_2l),Y		; else make parameter = length
0013ACr 1  AA           	TAX				; copy to byte parameter copy
0013ADr 1  98           	TYA				; clear string start offset
0013AEr 1               LAB_231C
0013AEr 1  48           	PHA				; save string start offset
0013AFr 1               LAB_231D
0013AFr 1  8A           	TXA				; copy byte parameter (or string length if <)
0013B0r 1               LAB_231E
0013B0r 1  48           	PHA				; save string length
0013B1r 1  20 rr rr     	JSR	LAB_MSSP		; make string space A bytes long A=$AC=length,
0013B4r 1               					; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte
0013B4r 1  A5 9E        	LDA	des_2l		; get descriptor pointer low byte
0013B6r 1  A4 9F        	LDY	des_2h		; get descriptor pointer high byte
0013B8r 1  20 rr rr     	JSR	LAB_22BA		; pop (YA) descriptor off stack or from top of string space
0013BBr 1               					; returns with A = length, X=ut1_pl=pointer low byte,
0013BBr 1               					; Y=ut1_ph=pointer high byte
0013BBr 1  68           	PLA				; get string length back
0013BCr 1  A8           	TAY				; copy length to Y
0013BDr 1  68           	PLA				; get string start offset back
0013BEr 1  18           	CLC				; clear carry for add
0013BFr 1  65 71        	ADC	ut1_pl		; add start offset to string start pointer low byte
0013C1r 1  85 71        	STA	ut1_pl		; save string start pointer low byte
0013C3r 1  90 02        	BCC	LAB_2335		; branch if no overflow
0013C5r 1               
0013C5r 1  E6 72        	INC	ut1_ph		; else increment string start pointer high byte
0013C7r 1               LAB_2335
0013C7r 1  98           	TYA				; copy length to A
0013C8r 1  20 rr rr     	JSR	LAB_229C		; store string A bytes long from (ut1_pl) to (Sutill)
0013CBr 1  4C rr rr     	JMP	LAB_RTST		; check for space on descriptor stack then put string
0013CEr 1               					; address and length on descriptor stack and update stack
0013CEr 1               					; pointers
0013CEr 1               
0013CEr 1               ; perform MID$()
0013CEr 1               
0013CEr 1               LAB_MIDS
0013CEr 1  48           	PHA				; push byte parameter
0013CFr 1  A9 FF        	LDA	#$FF			; set default length = 255
0013D1r 1  85 AF        	STA	mids_l		; save default length
0013D3r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0013D6r 1  C9 29        	CMP	#')'			; compare with ")"
0013D8r 1  F0 06        	BEQ	LAB_2358		; branch if = ")" (skip second byte get)
0013DAr 1               
0013DAr 1  20 rr rr     	JSR	LAB_1C01		; scan for "," , else do syntax error then warm start
0013DDr 1  20 rr rr     	JSR	LAB_GTBY		; get byte parameter (use copy in mids_l)
0013E0r 1               LAB_2358
0013E0r 1  20 rr rr     	JSR	LAB_236F		; pull string data and byte parameter from stack
0013E3r 1               					; return pointer in des_2l/h, byte in A (and X), Y=0
0013E3r 1  CA           	DEX				; decrement start index
0013E4r 1  8A           	TXA				; copy to A
0013E5r 1  48           	PHA				; save string start offset
0013E6r 1  18           	CLC				; clear carry for sub-1
0013E7r 1  A2 00        	LDX	#$00			; clear output string length
0013E9r 1  F1 9E        	SBC	(des_2l),Y		; subtract string length
0013EBr 1  B0 C2        	BCS	LAB_231D		; if start>string length go do null string
0013EDr 1               
0013EDr 1  49 FF        	EOR	#$FF			; complement -length
0013EFr 1  C5 AF        	CMP	mids_l		; compare byte parameter
0013F1r 1  90 BD        	BCC	LAB_231E		; if length>remaining string go do RIGHT$
0013F3r 1               
0013F3r 1  A5 AF        	LDA	mids_l		; get length byte
0013F5r 1  B0 B9        	BCS	LAB_231E		; go do string copy (branch always)
0013F7r 1               
0013F7r 1               ; pull string data and byte parameter from stack
0013F7r 1               ; return pointer in des_2l/h, byte in A (and X), Y=0
0013F7r 1               
0013F7r 1               LAB_236F
0013F7r 1  20 rr rr     	JSR	LAB_1BFB		; scan for ")" , else do syntax error then warm start
0013FAr 1  68           	PLA				; pull return address low byte (return address)
0013FBr 1  85 A2        	STA	Fnxjpl		; save functions jump vector low byte
0013FDr 1  68           	PLA				; pull return address high byte (return address)
0013FEr 1  85 A3        	STA	Fnxjph		; save functions jump vector high byte
001400r 1  68           	PLA				; pull byte parameter
001401r 1  AA           	TAX				; copy byte parameter to X
001402r 1  68           	PLA				; pull string pointer low byte
001403r 1  85 9E        	STA	des_2l		; save it
001405r 1  68           	PLA				; pull string pointer high byte
001406r 1  85 9F        	STA	des_2h		; save it
001408r 1  A0 00        	LDY	#$00			; clear index
00140Ar 1  8A           	TXA				; copy byte parameter
00140Br 1  F0 79        	BEQ	LAB_23A8		; if null do function call error then warm start
00140Dr 1               
00140Dr 1  E6 A2        	INC	Fnxjpl		; increment function jump vector low byte
00140Fr 1               					; (JSR pushes return addr-1. this is all very nice
00140Fr 1               					; but will go tits up if either call is on a page
00140Fr 1               					; boundary!)
00140Fr 1  6C A2 00     	JMP	(Fnxjpl)		; in effect, RTS
001412r 1               
001412r 1               ; perform LCASE$()
001412r 1               
001412r 1               LAB_LCASE
001412r 1  20 rr rr     	JSR	LAB_EVST		; evaluate string
001415r 1  85 AC        	STA	str_ln		; set string length
001417r 1  A8           	TAY				; copy length to Y
001418r 1  F0 38        	BEQ	NoString		; branch if null string
00141Ar 1               
00141Ar 1  20 rr rr     	JSR	LAB_MSSP		; make string space A bytes long A=length,
00141Dr 1               					; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
00141Dr 1  86 AD        	STX	str_pl		; save string pointer low byte
00141Fr 1  84 AE        	STY	str_ph		; save string pointer high byte
001421r 1  A8           	TAY				; get string length back
001422r 1               
001422r 1               LC_loop
001422r 1  88           	DEY				; decrement index
001423r 1  B1 71        	LDA	(ut1_pl),Y		; get byte from string
001425r 1  20 rr rr     	JSR	LAB_1D82		; is character "A" to "Z"
001428r 1  90 02        	BCC	NoUcase		; branch if not upper case alpha
00142Ar 1               
00142Ar 1  09 20        	ORA	#$20			; convert upper to lower case
00142Cr 1               NoUcase
00142Cr 1  91 83        	STA	(Sutill),Y		; save byte back to string
00142Er 1  98           	TYA				; test index
00142Fr 1  D0 F1        	BNE	LC_loop		; loop if not all done
001431r 1               
001431r 1  F0 1F        	BEQ	NoString		; tidy up and exit, branch always
001433r 1               
001433r 1               ; perform UCASE$()
001433r 1               
001433r 1               LAB_UCASE
001433r 1  20 rr rr     	JSR	LAB_EVST		; evaluate string
001436r 1  85 AC        	STA	str_ln		; set string length
001438r 1  A8           	TAY				; copy length to Y
001439r 1  F0 17        	BEQ	NoString		; branch if null string
00143Br 1               
00143Br 1  20 rr rr     	JSR	LAB_MSSP		; make string space A bytes long A=length,
00143Er 1               					; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
00143Er 1  86 AD        	STX	str_pl		; save string pointer low byte
001440r 1  84 AE        	STY	str_ph		; save string pointer high byte
001442r 1  A8           	TAY				; get string length back
001443r 1               
001443r 1               UC_loop
001443r 1  88           	DEY				; decrement index
001444r 1  B1 71        	LDA	(ut1_pl),Y		; get byte from string
001446r 1  20 rr rr     	JSR	LAB_CASC		; is character "a" to "z" (or "A" to "Z")
001449r 1  90 02        	BCC	NoLcase		; branch if not alpha
00144Br 1               
00144Br 1  29 DF        	AND	#$DF			; convert lower to upper case
00144Dr 1               NoLcase
00144Dr 1  91 83        	STA	(Sutill),Y		; save byte back to string
00144Fr 1  98           	TYA				; test index
001450r 1  D0 F1        	BNE	UC_loop		; loop if not all done
001452r 1               
001452r 1               NoString
001452r 1  4C rr rr     	JMP	LAB_RTST		; check for space on descriptor stack then put string
001455r 1               					; address and length on descriptor stack and update stack
001455r 1               					; pointers
001455r 1               
001455r 1               ; perform SADD()
001455r 1               
001455r 1               LAB_SADD
001455r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
001458r 1  20 rr rr     	JSR	LAB_GVAR		; get var address
00145Br 1               
00145Br 1  20 rr rr     	JSR	LAB_1BFB		; scan for ")", else do syntax error then warm start
00145Er 1  20 rr rr     	JSR	LAB_CTST		; check if source is string, else do type mismatch
001461r 1               
001461r 1  A0 02        	LDY	#$02			; index to string pointer high byte
001463r 1  B1 95        	LDA	(Cvaral),Y		; get string pointer high byte
001465r 1  AA           	TAX				; copy string pointer high byte to X
001466r 1  88           	DEY				; index to string pointer low byte
001467r 1  B1 95        	LDA	(Cvaral),Y		; get string pointer low byte
001469r 1  A8           	TAY				; copy string pointer low byte to Y
00146Ar 1  8A           	TXA				; copy string pointer high byte to A
00146Br 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
00146Er 1               
00146Er 1               ; perform LEN()
00146Er 1               
00146Er 1               LAB_LENS
00146Er 1  20 rr rr     	JSR	LAB_ESGL		; evaluate string, get length in A (and Y)
001471r 1  4C rr rr     	JMP	LAB_1FD0		; convert Y to byte in FAC1 and return
001474r 1               
001474r 1               ; evaluate string, get length in Y
001474r 1               
001474r 1               LAB_ESGL
001474r 1  20 rr rr     	JSR	LAB_EVST		; evaluate string
001477r 1  A8           	TAY				; copy length to Y
001478r 1  60           	RTS
001479r 1               
001479r 1               ; perform ASC()
001479r 1               
001479r 1               LAB_ASC
001479r 1  20 rr rr     	JSR	LAB_ESGL		; evaluate string, get length in A (and Y)
00147Cr 1  F0 08        	BEQ	LAB_23A8		; if null do function call error then warm start
00147Er 1               
00147Er 1  A0 00        	LDY	#$00			; set index to first character
001480r 1  B1 71        	LDA	(ut1_pl),Y		; get byte
001482r 1  A8           	TAY				; copy to Y
001483r 1  4C rr rr     	JMP	LAB_1FD0		; convert Y to byte in FAC1 and return
001486r 1               
001486r 1               ; do function call error then warm start
001486r 1               
001486r 1               LAB_23A8
001486r 1  4C rr rr     	JMP	LAB_FCER		; do function call error then warm start
001489r 1               
001489r 1               ; scan and get byte parameter
001489r 1               
001489r 1               LAB_SGBY
001489r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
00148Cr 1               
00148Cr 1               ; get byte parameter
00148Cr 1               
00148Cr 1               LAB_GTBY
00148Cr 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
00148Fr 1               					; else do type mismatch
00148Fr 1               
00148Fr 1               ; evaluate byte expression, result in X
00148Fr 1               
00148Fr 1               LAB_EVBY
00148Fr 1  20 rr rr     	JSR	LAB_EVPI		; evaluate integer expression (no check)
001492r 1               
001492r 1  A4 AE        	LDY	FAC1_2		; get FAC1 mantissa2
001494r 1  D0 F0        	BNE	LAB_23A8		; if top byte <> 0 do function call error then warm start
001496r 1               
001496r 1  A6 AF        	LDX	FAC1_3		; get FAC1 mantissa3
001498r 1  4C C2 00     	JMP	LAB_GBYT		; scan memory and return
00149Br 1               
00149Br 1               ; perform VAL()
00149Br 1               
00149Br 1               LAB_VAL
00149Br 1  20 rr rr     	JSR	LAB_ESGL		; evaluate string, get length in A (and Y)
00149Er 1  D0 03        	BNE	LAB_23C5		; branch if not null string
0014A0r 1               
0014A0r 1               					; string was null so set result = $00
0014A0r 1  4C rr rr     	JMP	LAB_24F1		; clear FAC1 exponent and sign and return
0014A3r 1               
0014A3r 1               LAB_23C5
0014A3r 1  A6 C3        	LDX	Bpntrl		; get BASIC execute pointer low byte
0014A5r 1  A4 C4        	LDY	Bpntrh		; get BASIC execute pointer high byte
0014A7r 1  86 BA        	STX	Btmpl			; save BASIC execute pointer low byte
0014A9r 1  84 BB        	STY	Btmph			; save BASIC execute pointer high byte
0014ABr 1  A6 71        	LDX	ut1_pl		; get string pointer low byte
0014ADr 1  86 C3        	STX	Bpntrl		; save as BASIC execute pointer low byte
0014AFr 1  18           	CLC				; clear carry
0014B0r 1  65 71        	ADC	ut1_pl		; add string length
0014B2r 1  85 73        	STA	ut2_pl		; save string end low byte
0014B4r 1  A5 72        	LDA	ut1_ph		; get string pointer high byte
0014B6r 1  85 C4        	STA	Bpntrh		; save as BASIC execute pointer high byte
0014B8r 1  69 00        	ADC	#$00			; add carry to high byte
0014BAr 1  85 74        	STA	ut2_ph		; save string end high byte
0014BCr 1  A0 00        	LDY	#$00			; set index to $00
0014BEr 1  B1 73        	LDA	(ut2_pl),Y		; get string end +1 byte
0014C0r 1  48           	PHA				; push it
0014C1r 1  98           	TYA				; clear A
0014C2r 1  91 73        	STA	(ut2_pl),Y		; terminate string with $00
0014C4r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
0014C7r 1  20 rr rr     	JSR	LAB_2887		; get FAC1 from string
0014CAr 1  68           	PLA				; restore string end +1 byte
0014CBr 1  A0 00        	LDY	#$00			; set index to zero
0014CDr 1  91 73        	STA	(ut2_pl),Y		; put string end byte back
0014CFr 1               
0014CFr 1               ; restore BASIC execute pointer from temp (Btmpl/Btmph)
0014CFr 1               
0014CFr 1               LAB_23F3
0014CFr 1  A6 BA        	LDX	Btmpl			; get BASIC execute pointer low byte back
0014D1r 1  A4 BB        	LDY	Btmph			; get BASIC execute pointer high byte back
0014D3r 1  86 C3        	STX	Bpntrl		; save BASIC execute pointer low byte
0014D5r 1  84 C4        	STY	Bpntrh		; save BASIC execute pointer high byte
0014D7r 1  60           	RTS
0014D8r 1               
0014D8r 1               ; get two parameters for POKE or WAIT
0014D8r 1               
0014D8r 1               LAB_GADB
0014D8r 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
0014DBr 1               					; else do type mismatch
0014DBr 1  20 rr rr     	JSR	LAB_F2FX		; save integer part of FAC1 in temporary integer
0014DEr 1               
0014DEr 1               ; scan for "," and get byte, else do Syntax error then warm start
0014DEr 1               
0014DEr 1               LAB_SCGB
0014DEr 1  20 rr rr     	JSR	LAB_1C01		; scan for "," , else do syntax error then warm start
0014E1r 1  A5 12        	LDA	Itemph		; save temporary integer high byte
0014E3r 1  48           	PHA				; on stack
0014E4r 1  A5 11        	LDA	Itempl		; save temporary integer low byte
0014E6r 1  48           	PHA				; on stack
0014E7r 1  20 rr rr     	JSR	LAB_GTBY		; get byte parameter
0014EAr 1  68           	PLA				; pull low byte
0014EBr 1  85 11        	STA	Itempl		; restore temporary integer low byte
0014EDr 1  68           	PLA				; pull high byte
0014EEr 1  85 12        	STA	Itemph		; restore temporary integer high byte
0014F0r 1  60           	RTS
0014F1r 1               
0014F1r 1               ; convert float to fixed routine. accepts any value that fits in 24 bits, +ve or
0014F1r 1               ; -ve and converts it into a right truncated integer in Itempl and Itemph
0014F1r 1               
0014F1r 1               ; save unsigned 16 bit integer part of FAC1 in temporary integer
0014F1r 1               
0014F1r 1               LAB_F2FX
0014F1r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
0014F3r 1  C9 98        	CMP	#$98			; compare with exponent = 2^24
0014F5r 1  B0 8F        	BCS	LAB_23A8		; if >= do function call error then warm start
0014F7r 1               
0014F7r 1               LAB_F2FU
0014F7r 1  20 rr rr     	JSR	LAB_2831		; convert FAC1 floating-to-fixed
0014FAr 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
0014FCr 1  A4 AF        	LDY	FAC1_3		; get FAC1 mantissa3
0014FEr 1  84 11        	STY	Itempl		; save temporary integer low byte
001500r 1  85 12        	STA	Itemph		; save temporary integer high byte
001502r 1  60           	RTS
001503r 1               
001503r 1               ; perform PEEK()
001503r 1               
001503r 1               LAB_PEEK
001503r 1  20 rr rr     	JSR	LAB_F2FX		; save integer part of FAC1 in temporary integer
001506r 1  A2 00        	LDX	#$00			; clear index
001508r 1  A1 11        	LDA	(Itempl,X)		; get byte via temporary integer (addr)
00150Ar 1  A8           	TAY				; copy byte to Y
00150Br 1  4C rr rr     	JMP	LAB_1FD0		; convert Y to byte in FAC1 and return
00150Er 1               
00150Er 1               ; perform POKE
00150Er 1               
00150Er 1               LAB_POKE
00150Er 1  20 rr rr     	JSR	LAB_GADB		; get two parameters for POKE or WAIT
001511r 1  8A           	TXA				; copy byte argument to A
001512r 1  A2 00        	LDX	#$00			; clear index
001514r 1  81 11        	STA	(Itempl,X)		; save byte via temporary integer (addr)
001516r 1  60           	RTS
001517r 1               
001517r 1               ; perform DEEK()
001517r 1               
001517r 1               LAB_DEEK
001517r 1  20 rr rr     	JSR	LAB_F2FX		; save integer part of FAC1 in temporary integer
00151Ar 1  A2 00        	LDX	#$00			; clear index
00151Cr 1  A1 11        	LDA	(Itempl,X)		; PEEK low byte
00151Er 1  A8           	TAY				; copy to Y
00151Fr 1  E6 11        	INC	Itempl		; increment pointer low byte
001521r 1  D0 02        	BNE	Deekh			; skip high increment if no rollover
001523r 1               
001523r 1  E6 12        	INC	Itemph		; increment pointer high byte
001525r 1               Deekh
001525r 1  A1 11        	LDA	(Itempl,X)		; PEEK high byte
001527r 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
00152Ar 1               
00152Ar 1               ; perform DOKE
00152Ar 1               
00152Ar 1               LAB_DOKE
00152Ar 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
00152Dr 1               					; else do type mismatch
00152Dr 1  20 rr rr     	JSR	LAB_F2FX		; convert floating-to-fixed
001530r 1               
001530r 1  84 97        	STY	Frnxtl		; save pointer low byte (float to fixed returns word in AY)
001532r 1  85 98        	STA	Frnxth		; save pointer high byte
001534r 1               
001534r 1  20 rr rr     	JSR	LAB_1C01		; scan for "," , else do syntax error then warm start
001537r 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
00153Ar 1               					; else do type mismatch
00153Ar 1  20 rr rr     	JSR	LAB_F2FX		; convert floating-to-fixed
00153Dr 1               
00153Dr 1  98           	TYA				; copy value low byte (float to fixed returns word in AY)
00153Er 1  A2 00        	LDX	#$00			; clear index
001540r 1  81 97        	STA	(Frnxtl,X)		; POKE low byte
001542r 1  E6 97        	INC	Frnxtl		; increment pointer low byte
001544r 1  D0 02        	BNE	Dokeh			; skip high increment if no rollover
001546r 1               
001546r 1  E6 98        	INC	Frnxth		; increment pointer high byte
001548r 1               Dokeh
001548r 1  A5 12        	LDA	Itemph		; get value high byte
00154Ar 1  81 97        	STA	(Frnxtl,X)		; POKE high byte
00154Cr 1  4C C2 00     	JMP	LAB_GBYT		; scan memory and return
00154Fr 1               
00154Fr 1               ; perform SWAP
00154Fr 1               
00154Fr 1               LAB_SWAP
00154Fr 1  20 rr rr     	JSR	LAB_GVAR		; get var1 address
001552r 1  85 97        	STA	Lvarpl		; save var1 address low byte
001554r 1  84 98        	STY	Lvarph		; save var1 address high byte
001556r 1  A5 5F        	LDA	Dtypef		; get data type flag, $FF=string, $00=numeric
001558r 1  48           	PHA				; save data type flag
001559r 1               
001559r 1  20 rr rr     	JSR	LAB_1C01		; scan for "," , else do syntax error then warm start
00155Cr 1  20 rr rr     	JSR	LAB_GVAR		; get var2 address (pointer in Cvaral/h)
00155Fr 1  68           	PLA				; pull var1 data type flag
001560r 1  45 5F        	EOR	Dtypef		; compare with var2 data type
001562r 1  10 10        	BPL	SwapErr		; exit if not both the same type
001564r 1               
001564r 1  A0 03        	LDY	#$03			; four bytes to swap (either value or descriptor+1)
001566r 1               SwapLp
001566r 1  B1 97        	LDA	(Lvarpl),Y		; get byte from var1
001568r 1  AA           	TAX				; save var1 byte
001569r 1  B1 95        	LDA	(Cvaral),Y		; get byte from var2
00156Br 1  91 97        	STA	(Lvarpl),Y		; save byte to var1
00156Dr 1  8A           	TXA				; restore var1 byte
00156Er 1  91 95        	STA	(Cvaral),Y		; save byte to var2
001570r 1  88           	DEY				; decrement index
001571r 1  10 F3        	BPL	SwapLp		; loop until done
001573r 1               
001573r 1  60           	RTS
001574r 1               
001574r 1               SwapErr
001574r 1  4C rr rr     	JMP	LAB_1ABC		; do "Type mismatch" error then warm start
001577r 1               
001577r 1               ; perform CALL
001577r 1               
001577r 1               LAB_CALL
001577r 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
00157Ar 1               					; else do type mismatch
00157Ar 1  20 rr rr     	JSR	LAB_F2FX		; convert floating-to-fixed
00157Dr 1  A9 rr        	LDA	#>CallExit		; set return address high byte
00157Fr 1  48           	PHA				; put on stack
001580r 1  A9 rr        	LDA	#<CallExit-1	; set return address low byte
001582r 1  48           	PHA				; put on stack
001583r 1  6C 11 00     	JMP	(Itempl)		; do indirect jump to user routine
001586r 1               
001586r 1               ; if the called routine exits correctly then it will return to here. this will then get
001586r 1               ; the next byte for the interpreter and return
001586r 1               
001586r 1               CallExit
001586r 1  4C C2 00     	JMP	LAB_GBYT		; scan memory and return
001589r 1               
001589r 1               ; perform WAIT
001589r 1               
001589r 1               LAB_WAIT
001589r 1  20 rr rr     	JSR	LAB_GADB		; get two parameters for POKE or WAIT
00158Cr 1  86 97        	STX	Frnxtl		; save byte
00158Er 1  A2 00        	LDX	#$00			; clear mask
001590r 1  20 C2 00     	JSR	LAB_GBYT		; scan memory
001593r 1  F0 03        	BEQ	LAB_2441		; skip if no third argument
001595r 1               
001595r 1  20 rr rr     	JSR	LAB_SCGB		; scan for "," and get byte, else SN error then warm start
001598r 1               LAB_2441
001598r 1  86 98        	STX	Frnxth		; save EOR argument
00159Ar 1               LAB_2445
00159Ar 1  B1 11        	LDA	(Itempl),Y		; get byte via temporary integer (addr)
00159Cr 1  45 98        	EOR	Frnxth		; EOR with second argument (mask)
00159Er 1  25 97        	AND	Frnxtl		; AND with first argument (byte)
0015A0r 1  F0 F8        	BEQ	LAB_2445		; loop if result is zero
0015A2r 1               
0015A2r 1               LAB_244D
0015A2r 1  60           	RTS
0015A3r 1               
0015A3r 1               ; perform subtraction, FAC1 from (AY)
0015A3r 1               
0015A3r 1               LAB_2455
0015A3r 1  20 rr rr     	JSR	LAB_264D		; unpack memory (AY) into FAC2
0015A6r 1               
0015A6r 1               ; perform subtraction, FAC1 from FAC2
0015A6r 1               
0015A6r 1               LAB_SUBTRACT
0015A6r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
0015A8r 1  49 FF        	EOR	#$FF			; complement it
0015AAr 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
0015ACr 1  45 B7        	EOR	FAC2_s		; EOR with FAC2 sign (b7)
0015AEr 1  85 B8        	STA	FAC_sc		; save sign compare (FAC1 EOR FAC2)
0015B0r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
0015B2r 1  4C rr rr     	JMP	LAB_ADD		; go add FAC2 to FAC1
0015B5r 1               
0015B5r 1               ; perform addition
0015B5r 1               
0015B5r 1               LAB_2467
0015B5r 1  20 rr rr     	JSR	LAB_257B		; shift FACX A times right (>8 shifts)
0015B8r 1  90 4D        	BCC	LAB_24A8		;.go subtract mantissas
0015BAr 1               
0015BAr 1               ; add 0.5 to FAC1
0015BAr 1               
0015BAr 1               LAB_244E
0015BAr 1  A9 rr        	LDA	#<LAB_2A96		; set 0.5 pointer low byte
0015BCr 1  A0 rr        	LDY	#>LAB_2A96		; set 0.5 pointer high byte
0015BEr 1               
0015BEr 1               ; add (AY) to FAC1
0015BEr 1               
0015BEr 1               LAB_246C
0015BEr 1  20 rr rr     	JSR	LAB_264D		; unpack memory (AY) into FAC2
0015C1r 1               
0015C1r 1               ; add FAC2 to FAC1
0015C1r 1               
0015C1r 1               LAB_ADD
0015C1r 1  D0 10        	BNE	LAB_2474		; branch if FAC1 was not zero
0015C3r 1               
0015C3r 1               ; copy FAC2 to FAC1
0015C3r 1               
0015C3r 1               LAB_279B
0015C3r 1  A5 B7        	LDA	FAC2_s		; get FAC2 sign (b7)
0015C5r 1               
0015C5r 1               ; save FAC1 sign and copy ABS(FAC2) to FAC1
0015C5r 1               
0015C5r 1               LAB_279D
0015C5r 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
0015C7r 1  A2 04        	LDX	#$04			; 4 bytes to copy
0015C9r 1               LAB_27A1
0015C9r 1  B5 B2        	LDA	FAC1_o,X		; get byte from FAC2,X
0015CBr 1  95 AB        	STA	FAC1_e-1,X		; save byte at FAC1,X
0015CDr 1  CA           	DEX				; decrement count
0015CEr 1  D0 F9        	BNE	LAB_27A1		; loop if not all done
0015D0r 1               
0015D0r 1  86 B9        	STX	FAC1_r		; clear FAC1 rounding byte
0015D2r 1  60           	RTS
0015D3r 1               
0015D3r 1               					; FAC1 is non zero
0015D3r 1               LAB_2474
0015D3r 1  A6 B9        	LDX	FAC1_r		; get FAC1 rounding byte
0015D5r 1  86 A3        	STX	FAC2_r		; save as FAC2 rounding byte
0015D7r 1  A2 B3        	LDX	#FAC2_e		; set index to FAC2 exponent addr
0015D9r 1  A5 B3        	LDA	FAC2_e		; get FAC2 exponent
0015DBr 1               LAB_247C
0015DBr 1  A8           	TAY				; copy exponent
0015DCr 1  F0 C4        	BEQ	LAB_244D		; exit if zero
0015DEr 1               
0015DEr 1  38           	SEC				; set carry for subtract
0015DFr 1  E5 AC        	SBC	FAC1_e		; subtract FAC1 exponent
0015E1r 1  F0 24        	BEQ	LAB_24A8		; branch if = (go add mantissa)
0015E3r 1               
0015E3r 1  90 12        	BCC	LAB_2498		; branch if <
0015E5r 1               
0015E5r 1               					; FAC2>FAC1
0015E5r 1  84 AC        	STY	FAC1_e		; save FAC1 exponent
0015E7r 1  A4 B7        	LDY	FAC2_s		; get FAC2 sign (b7)
0015E9r 1  84 B0        	STY	FAC1_s		; save FAC1 sign (b7)
0015EBr 1  49 FF        	EOR	#$FF			; complement A
0015EDr 1  69 00        	ADC	#$00			; +1 (twos complement, carry is set)
0015EFr 1  A0 00        	LDY	#$00			; clear Y
0015F1r 1  84 A3        	STY	FAC2_r		; clear FAC2 rounding byte
0015F3r 1  A2 AC        	LDX	#FAC1_e		; set index to FAC1 exponent addr
0015F5r 1  D0 04        	BNE	LAB_249C		; branch always
0015F7r 1               
0015F7r 1               LAB_2498
0015F7r 1  A0 00        	LDY	#$00			; clear Y
0015F9r 1  84 B9        	STY	FAC1_r		; clear FAC1 rounding byte
0015FBr 1               LAB_249C
0015FBr 1  C9 F9        	CMP	#$F9			; compare exponent diff with $F9
0015FDr 1  30 B6        	BMI	LAB_2467		; branch if range $79-$F8
0015FFr 1               
0015FFr 1  A8           	TAY				; copy exponent difference to Y
001600r 1  A5 B9        	LDA	FAC1_r		; get FAC1 rounding byte
001602r 1  56 01        	LSR	PLUS_1,X		; shift FAC? mantissa1
001604r 1  20 rr rr     	JSR	LAB_2592		; shift FACX Y times right
001607r 1               
001607r 1               					; exponents are equal now do mantissa subtract
001607r 1               LAB_24A8
001607r 1  24 B8        	BIT	FAC_sc		; test sign compare (FAC1 EOR FAC2)
001609r 1  10 4C        	BPL	LAB_24F8		; if = add FAC2 mantissa to FAC1 mantissa and return
00160Br 1               
00160Br 1  A0 AC        	LDY	#FAC1_e		; set index to FAC1 exponent addr
00160Dr 1  E0 B3        	CPX	#FAC2_e		; compare X to FAC2 exponent addr
00160Fr 1  F0 02        	BEQ	LAB_24B4		; branch if =
001611r 1               
001611r 1  A0 B3        	LDY	#FAC2_e		; else set index to FAC2 exponent addr
001613r 1               
001613r 1               					; subtract smaller from bigger (take sign of bigger)
001613r 1               LAB_24B4
001613r 1  38           	SEC				; set carry for subtract
001614r 1  49 FF        	EOR	#$FF			; ones complement A
001616r 1  65 A3        	ADC	FAC2_r		; add FAC2 rounding byte
001618r 1  85 B9        	STA	FAC1_r		; save FAC1 rounding byte
00161Ar 1  B9 03 00     	LDA	PLUS_3,Y		; get FACY mantissa3
00161Dr 1  F5 03        	SBC	PLUS_3,X		; subtract FACX mantissa3
00161Fr 1  85 AF        	STA	FAC1_3		; save FAC1 mantissa3
001621r 1  B9 02 00     	LDA	PLUS_2,Y		; get FACY mantissa2
001624r 1  F5 02        	SBC	PLUS_2,X		; subtract FACX mantissa2
001626r 1  85 AE        	STA	FAC1_2		; save FAC1 mantissa2
001628r 1  B9 01 00     	LDA	PLUS_1,Y		; get FACY mantissa1
00162Br 1  F5 01        	SBC	PLUS_1,X		; subtract FACX mantissa1
00162Dr 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
00162Fr 1               
00162Fr 1               ; do ABS and normalise FAC1
00162Fr 1               
00162Fr 1               LAB_24D0
00162Fr 1  B0 03        	BCS	LAB_24D5		; branch if number is +ve
001631r 1               
001631r 1  20 rr rr     	JSR	LAB_2537		; negate FAC1
001634r 1               
001634r 1               ; normalise FAC1
001634r 1               
001634r 1               LAB_24D5
001634r 1  A0 00        	LDY	#$00			; clear Y
001636r 1  98           	TYA				; clear A
001637r 1  18           	CLC				; clear carry for add
001638r 1               LAB_24D9
001638r 1  A6 AD        	LDX	FAC1_1		; get FAC1 mantissa1
00163Ar 1  D0 3E        	BNE	LAB_251B		; if not zero normalise FAC1
00163Cr 1               
00163Cr 1  A6 AE        	LDX	FAC1_2		; get FAC1 mantissa2
00163Er 1  86 AD        	STX	FAC1_1		; save FAC1 mantissa1
001640r 1  A6 AF        	LDX	FAC1_3		; get FAC1 mantissa3
001642r 1  86 AE        	STX	FAC1_2		; save FAC1 mantissa2
001644r 1  A6 B9        	LDX	FAC1_r		; get FAC1 rounding byte
001646r 1  86 AF        	STX	FAC1_3		; save FAC1 mantissa3
001648r 1  84 B9        	STY	FAC1_r		; clear FAC1 rounding byte
00164Ar 1  69 08        	ADC	#$08			; add x to exponent offset
00164Cr 1  C9 18        	CMP	#$18			; compare with $18 (max offset, all bits would be =0)
00164Er 1  D0 E8        	BNE	LAB_24D9		; loop if not max
001650r 1               
001650r 1               ; clear FAC1 exponent and sign
001650r 1               
001650r 1               LAB_24F1
001650r 1  A9 00        	LDA	#$00			; clear A
001652r 1               LAB_24F3
001652r 1  85 AC        	STA	FAC1_e		; set FAC1 exponent
001654r 1               
001654r 1               ; save FAC1 sign
001654r 1               
001654r 1               LAB_24F5
001654r 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
001656r 1  60           	RTS
001657r 1               
001657r 1               ; add FAC2 mantissa to FAC1 mantissa
001657r 1               
001657r 1               LAB_24F8
001657r 1  65 A3        	ADC	FAC2_r		; add FAC2 rounding byte
001659r 1  85 B9        	STA	FAC1_r		; save FAC1 rounding byte
00165Br 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
00165Dr 1  65 B6        	ADC	FAC2_3		; add FAC2 mantissa3
00165Fr 1  85 AF        	STA	FAC1_3		; save FAC1 mantissa3
001661r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
001663r 1  65 B5        	ADC	FAC2_2		; add FAC2 mantissa2
001665r 1  85 AE        	STA	FAC1_2		; save FAC1 mantissa2
001667r 1  A5 AD        	LDA	FAC1_1		; get FAC1 mantissa1
001669r 1  65 B4        	ADC	FAC2_1		; add FAC2 mantissa1
00166Br 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
00166Dr 1  B0 1A        	BCS	LAB_252A		; if carry then normalise FAC1 for C=1
00166Fr 1               
00166Fr 1  60           	RTS				; else just exit
001670r 1               
001670r 1               LAB_2511
001670r 1  69 01        	ADC	#$01			; add 1 to exponent offset
001672r 1  06 B9        	ASL	FAC1_r		; shift FAC1 rounding byte
001674r 1  26 AF        	ROL	FAC1_3		; shift FAC1 mantissa3
001676r 1  26 AE        	ROL	FAC1_2		; shift FAC1 mantissa2
001678r 1  26 AD        	ROL	FAC1_1		; shift FAC1 mantissa1
00167Ar 1               
00167Ar 1               ; normalise FAC1
00167Ar 1               
00167Ar 1               LAB_251B
00167Ar 1  10 F4        	BPL	LAB_2511		; loop if not normalised
00167Cr 1               
00167Cr 1  38           	SEC				; set carry for subtract
00167Dr 1  E5 AC        	SBC	FAC1_e		; subtract FAC1 exponent
00167Fr 1  B0 CF        	BCS	LAB_24F1		; branch if underflow (set result = $0)
001681r 1               
001681r 1  49 FF        	EOR	#$FF			; complement exponent
001683r 1  69 01        	ADC	#$01			; +1 (twos complement)
001685r 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
001687r 1               
001687r 1               ; test and normalise FAC1 for C=0/1
001687r 1               
001687r 1               LAB_2528
001687r 1  90 0C        	BCC	LAB_2536		; exit if no overflow
001689r 1               
001689r 1               ; normalise FAC1 for C=1
001689r 1               
001689r 1               LAB_252A
001689r 1  E6 AC        	INC	FAC1_e		; increment FAC1 exponent
00168Br 1  F0 36        	BEQ	LAB_2564		; if zero do overflow error and warm start
00168Dr 1               
00168Dr 1  66 AD        	ROR	FAC1_1		; shift FAC1 mantissa1
00168Fr 1  66 AE        	ROR	FAC1_2		; shift FAC1 mantissa2
001691r 1  66 AF        	ROR	FAC1_3		; shift FAC1 mantissa3
001693r 1  66 B9        	ROR	FAC1_r		; shift FAC1 rounding byte
001695r 1               LAB_2536
001695r 1  60           	RTS
001696r 1               
001696r 1               ; negate FAC1
001696r 1               
001696r 1               LAB_2537
001696r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
001698r 1  49 FF        	EOR	#$FF			; complement it
00169Ar 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
00169Cr 1               
00169Cr 1               ; twos complement FAC1 mantissa
00169Cr 1               
00169Cr 1               LAB_253D
00169Cr 1  A5 AD        	LDA	FAC1_1		; get FAC1 mantissa1
00169Er 1  49 FF        	EOR	#$FF			; complement it
0016A0r 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
0016A2r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
0016A4r 1  49 FF        	EOR	#$FF			; complement it
0016A6r 1  85 AE        	STA	FAC1_2		; save FAC1 mantissa2
0016A8r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
0016AAr 1  49 FF        	EOR	#$FF			; complement it
0016ACr 1  85 AF        	STA	FAC1_3		; save FAC1 mantissa3
0016AEr 1  A5 B9        	LDA	FAC1_r		; get FAC1 rounding byte
0016B0r 1  49 FF        	EOR	#$FF			; complement it
0016B2r 1  85 B9        	STA	FAC1_r		; save FAC1 rounding byte
0016B4r 1  E6 B9        	INC	FAC1_r		; increment FAC1 rounding byte
0016B6r 1  D0 0A        	BNE	LAB_2563		; exit if no overflow
0016B8r 1               
0016B8r 1               ; increment FAC1 mantissa
0016B8r 1               
0016B8r 1               LAB_2559
0016B8r 1  E6 AF        	INC	FAC1_3		; increment FAC1 mantissa3
0016BAr 1  D0 06        	BNE	LAB_2563		; finished if no rollover
0016BCr 1               
0016BCr 1  E6 AE        	INC	FAC1_2		; increment FAC1 mantissa2
0016BEr 1  D0 02        	BNE	LAB_2563		; finished if no rollover
0016C0r 1               
0016C0r 1  E6 AD        	INC	FAC1_1		; increment FAC1 mantissa1
0016C2r 1               LAB_2563
0016C2r 1  60           	RTS
0016C3r 1               
0016C3r 1               ; do overflow error (overflow exit)
0016C3r 1               
0016C3r 1               LAB_2564
0016C3r 1  A2 0A        	LDX	#$0A			; error code $0A ("Overflow" error)
0016C5r 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
0016C8r 1               
0016C8r 1               ; shift FCAtemp << A+8 times
0016C8r 1               
0016C8r 1               LAB_2569
0016C8r 1  A2 74        	LDX	#FACt_1-1		; set offset to FACtemp
0016CAr 1               LAB_256B
0016CAr 1  B4 03        	LDY	PLUS_3,X		; get FACX mantissa3
0016CCr 1  84 B9        	STY	FAC1_r		; save as FAC1 rounding byte
0016CEr 1  B4 02        	LDY	PLUS_2,X		; get FACX mantissa2
0016D0r 1  94 03        	STY	PLUS_3,X		; save FACX mantissa3
0016D2r 1  B4 01        	LDY	PLUS_1,X		; get FACX mantissa1
0016D4r 1  94 02        	STY	PLUS_2,X		; save FACX mantissa2
0016D6r 1  A4 B2        	LDY	FAC1_o		; get FAC1 overflow byte
0016D8r 1  94 01        	STY	PLUS_1,X		; save FACX mantissa1
0016DAr 1               
0016DAr 1               ; shift FACX -A times right (> 8 shifts)
0016DAr 1               
0016DAr 1               LAB_257B
0016DAr 1  69 08        	ADC	#$08			; add 8 to shift count
0016DCr 1  30 EC        	BMI	LAB_256B		; go do 8 shift if still -ve
0016DEr 1               
0016DEr 1  F0 EA        	BEQ	LAB_256B		; go do 8 shift if zero
0016E0r 1               
0016E0r 1  E9 08        	SBC	#$08			; else subtract 8 again
0016E2r 1  A8           	TAY				; save count to Y
0016E3r 1  A5 B9        	LDA	FAC1_r		; get FAC1 rounding byte
0016E5r 1  B0 12        	BCS	LAB_259A		;.
0016E7r 1               
0016E7r 1               LAB_2588
0016E7r 1  16 01        	ASL	PLUS_1,X		; shift FACX mantissa1
0016E9r 1  90 02        	BCC	LAB_258E		; branch if +ve
0016EBr 1               
0016EBr 1  F6 01        	INC	PLUS_1,X		; this sets b7 eventually
0016EDr 1               LAB_258E
0016EDr 1  76 01        	ROR	PLUS_1,X		; shift FACX mantissa1 (correct for ASL)
0016EFr 1  76 01        	ROR	PLUS_1,X		; shift FACX mantissa1 (put carry in b7)
0016F1r 1               
0016F1r 1               ; shift FACX Y times right
0016F1r 1               
0016F1r 1               LAB_2592
0016F1r 1  76 02        	ROR	PLUS_2,X		; shift FACX mantissa2
0016F3r 1  76 03        	ROR	PLUS_3,X		; shift FACX mantissa3
0016F5r 1  6A           	ROR				; shift FACX rounding byte
0016F6r 1  C8           	INY				; increment exponent diff
0016F7r 1  D0 EE        	BNE	LAB_2588		; branch if range adjust not complete
0016F9r 1               
0016F9r 1               LAB_259A
0016F9r 1  18           	CLC				; just clear it
0016FAr 1  60           	RTS
0016FBr 1               
0016FBr 1               ; perform LOG()
0016FBr 1               
0016FBr 1               LAB_LOG
0016FBr 1  20 rr rr     	JSR	LAB_27CA		; test sign and zero
0016FEr 1  F0 02        	BEQ	LAB_25C4		; if zero do function call error then warm start
001700r 1               
001700r 1  10 03        	BPL	LAB_25C7		; skip error if +ve
001702r 1               
001702r 1               LAB_25C4
001702r 1  4C rr rr     	JMP	LAB_FCER		; do function call error then warm start (-ve)
001705r 1               
001705r 1               LAB_25C7
001705r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001707r 1  E9 7F        	SBC	#$7F			; normalise it
001709r 1  48           	PHA				; save it
00170Ar 1  A9 80        	LDA	#$80			; set exponent to zero
00170Cr 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
00170Er 1  A9 rr        	LDA	#<LAB_25AD		; set 1/root2 pointer low byte
001710r 1  A0 rr        	LDY	#>LAB_25AD		; set 1/root2 pointer high byte
001712r 1  20 rr rr     	JSR	LAB_246C		; add (AY) to FAC1 (1/root2)
001715r 1  A9 rr        	LDA	#<LAB_25B1		; set root2 pointer low byte
001717r 1  A0 rr        	LDY	#>LAB_25B1		; set root2 pointer high byte
001719r 1  20 rr rr     	JSR	LAB_26CA		; convert AY and do (AY)/FAC1 (root2/(x+(1/root2)))
00171Cr 1  A9 rr        	LDA	#<LAB_259C		; set 1 pointer low byte
00171Er 1  A0 rr        	LDY	#>LAB_259C		; set 1 pointer high byte
001720r 1  20 rr rr     	JSR	LAB_2455		; subtract (AY) from FAC1 ((root2/(x+(1/root2)))-1)
001723r 1  A9 rr        	LDA	#<LAB_25A0		; set pointer low byte to counter
001725r 1  A0 rr        	LDY	#>LAB_25A0		; set pointer high byte to counter
001727r 1  20 rr rr     	JSR	LAB_2B6E		; ^2 then series evaluation
00172Ar 1  A9 rr        	LDA	#<LAB_25B5		; set -0.5 pointer low byte
00172Cr 1  A0 rr        	LDY	#>LAB_25B5		; set -0.5 pointer high byte
00172Er 1  20 rr rr     	JSR	LAB_246C		; add (AY) to FAC1
001731r 1  68           	PLA				; restore FAC1 exponent
001732r 1  20 rr rr     	JSR	LAB_2912		; evaluate new ASCII digit
001735r 1  A9 rr        	LDA	#<LAB_25B9		; set LOG(2) pointer low byte
001737r 1  A0 rr        	LDY	#>LAB_25B9		; set LOG(2) pointer high byte
001739r 1               
001739r 1               ; do convert AY, FCA1*(AY)
001739r 1               
001739r 1               LAB_25FB
001739r 1  20 rr rr     	JSR	LAB_264D		; unpack memory (AY) into FAC2
00173Cr 1               LAB_MULTIPLY
00173Cr 1  F0 4C        	BEQ	LAB_264C		; exit if zero
00173Er 1               
00173Er 1  20 rr rr     	JSR	LAB_2673		; test and adjust accumulators
001741r 1  A9 00        	LDA	#$00			; clear A
001743r 1  85 75        	STA	FACt_1		; clear temp mantissa1
001745r 1  85 76        	STA	FACt_2		; clear temp mantissa2
001747r 1  85 77        	STA	FACt_3		; clear temp mantissa3
001749r 1  A5 B9        	LDA	FAC1_r		; get FAC1 rounding byte
00174Br 1  20 rr rr     	JSR	LAB_2622		; go do shift/add FAC2
00174Er 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
001750r 1  20 rr rr     	JSR	LAB_2622		; go do shift/add FAC2
001753r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
001755r 1  20 rr rr     	JSR	LAB_2622		; go do shift/add FAC2
001758r 1  A5 AD        	LDA	FAC1_1		; get FAC1 mantissa1
00175Ar 1  20 rr rr     	JSR	LAB_2627		; go do shift/add FAC2
00175Dr 1  4C rr rr     	JMP	LAB_273C		; copy temp to FAC1, normalise and return
001760r 1               
001760r 1               LAB_2622
001760r 1  D0 03        	BNE	LAB_2627		; branch if byte <> zero
001762r 1               
001762r 1  4C rr rr     	JMP	LAB_2569		; shift FCAtemp << A+8 times
001765r 1               
001765r 1               					; else do shift and add
001765r 1               LAB_2627
001765r 1  4A           	LSR				; shift byte
001766r 1  09 80        	ORA	#$80			; set top bit (mark for 8 times)
001768r 1               LAB_262A
001768r 1  A8           	TAY				; copy result
001769r 1  90 13        	BCC	LAB_2640		; skip next if bit was zero
00176Br 1               
00176Br 1  18           	CLC				; clear carry for add
00176Cr 1  A5 77        	LDA	FACt_3		; get temp mantissa3
00176Er 1  65 B6        	ADC	FAC2_3		; add FAC2 mantissa3
001770r 1  85 77        	STA	FACt_3		; save temp mantissa3
001772r 1  A5 76        	LDA	FACt_2		; get temp mantissa2
001774r 1  65 B5        	ADC	FAC2_2		; add FAC2 mantissa2
001776r 1  85 76        	STA	FACt_2		; save temp mantissa2
001778r 1  A5 75        	LDA	FACt_1		; get temp mantissa1
00177Ar 1  65 B4        	ADC	FAC2_1		; add FAC2 mantissa1
00177Cr 1  85 75        	STA	FACt_1		; save temp mantissa1
00177Er 1               LAB_2640
00177Er 1  66 75        	ROR	FACt_1		; shift temp mantissa1
001780r 1  66 76        	ROR	FACt_2		; shift temp mantissa2
001782r 1  66 77        	ROR	FACt_3		; shift temp mantissa3
001784r 1  66 B9        	ROR	FAC1_r		; shift temp rounding byte
001786r 1  98           	TYA				; get byte back
001787r 1  4A           	LSR				; shift byte
001788r 1  D0 DE        	BNE	LAB_262A		; loop if all bits not done
00178Ar 1               
00178Ar 1               LAB_264C
00178Ar 1  60           	RTS
00178Br 1               
00178Br 1               ; unpack memory (AY) into FAC2
00178Br 1               
00178Br 1               LAB_264D
00178Br 1  85 71        	STA	ut1_pl		; save pointer low byte
00178Dr 1  84 72        	STY	ut1_ph		; save pointer high byte
00178Fr 1  A0 03        	LDY	#$03			; 4 bytes to get (0-3)
001791r 1  B1 71        	LDA	(ut1_pl),Y		; get mantissa3
001793r 1  85 B6        	STA	FAC2_3		; save FAC2 mantissa3
001795r 1  88           	DEY				; decrement index
001796r 1  B1 71        	LDA	(ut1_pl),Y		; get mantissa2
001798r 1  85 B5        	STA	FAC2_2		; save FAC2 mantissa2
00179Ar 1  88           	DEY				; decrement index
00179Br 1  B1 71        	LDA	(ut1_pl),Y		; get mantissa1+sign
00179Dr 1  85 B7        	STA	FAC2_s		; save FAC2 sign (b7)
00179Fr 1  45 B0        	EOR	FAC1_s		; EOR with FAC1 sign (b7)
0017A1r 1  85 B8        	STA	FAC_sc		; save sign compare (FAC1 EOR FAC2)
0017A3r 1  A5 B7        	LDA	FAC2_s		; recover FAC2 sign (b7)
0017A5r 1  09 80        	ORA	#$80			; set 1xxx xxx (set normal bit)
0017A7r 1  85 B4        	STA	FAC2_1		; save FAC2 mantissa1
0017A9r 1  88           	DEY				; decrement index
0017AAr 1  B1 71        	LDA	(ut1_pl),Y		; get exponent byte
0017ACr 1  85 B3        	STA	FAC2_e		; save FAC2 exponent
0017AEr 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
0017B0r 1  60           	RTS
0017B1r 1               
0017B1r 1               ; test and adjust accumulators
0017B1r 1               
0017B1r 1               LAB_2673
0017B1r 1  A5 B3        	LDA	FAC2_e		; get FAC2 exponent
0017B3r 1               LAB_2675
0017B3r 1  F0 1D        	BEQ	LAB_2696		; branch if FAC2 = $00 (handle underflow)
0017B5r 1               
0017B5r 1  18           	CLC				; clear carry for add
0017B6r 1  65 AC        	ADC	FAC1_e		; add FAC1 exponent
0017B8r 1  90 04        	BCC	LAB_2680		; branch if sum of exponents <$0100
0017BAr 1               
0017BAr 1  30 31        	BMI	LAB_269B		; do overflow error
0017BCr 1               
0017BCr 1  18           	CLC				; clear carry for the add
0017BDr 1  2C           	.byte	$2C			; makes next line BIT $1410
0017BEr 1               LAB_2680
0017BEr 1  10 12        	BPL	LAB_2696		; if +ve go handle underflow
0017C0r 1               
0017C0r 1  69 80        	ADC	#$80			; adjust exponent
0017C2r 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
0017C4r 1  D0 03        	BNE	LAB_268B		; branch if not zero
0017C6r 1               
0017C6r 1  4C rr rr     	JMP	LAB_24F5		; save FAC1 sign and return
0017C9r 1               
0017C9r 1               LAB_268B
0017C9r 1  A5 B8        	LDA	FAC_sc		; get sign compare (FAC1 EOR FAC2)
0017CBr 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
0017CDr 1               LAB_268F
0017CDr 1  60           	RTS
0017CEr 1               
0017CEr 1               ; handle overflow and underflow
0017CEr 1               
0017CEr 1               LAB_2690
0017CEr 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
0017D0r 1  10 1B        	BPL	LAB_269B		; do overflow error
0017D2r 1               
0017D2r 1               					; handle underflow
0017D2r 1               LAB_2696
0017D2r 1  68           	PLA				; pop return address low byte
0017D3r 1  68           	PLA				; pop return address high byte
0017D4r 1  4C rr rr     	JMP	LAB_24F1		; clear FAC1 exponent and sign and return
0017D7r 1               
0017D7r 1               ; multiply by 10
0017D7r 1               
0017D7r 1               LAB_269E
0017D7r 1  20 rr rr     	JSR	LAB_27AB		; round and copy FAC1 to FAC2
0017DAr 1  AA           	TAX				; copy exponent (set the flags)
0017DBr 1  F0 F0        	BEQ	LAB_268F		; exit if zero
0017DDr 1               
0017DDr 1  18           	CLC				; clear carry for add
0017DEr 1  69 02        	ADC	#$02			; add two to exponent (*4)
0017E0r 1  B0 0B        	BCS	LAB_269B		; do overflow error if > $FF
0017E2r 1               
0017E2r 1  A2 00        	LDX	#$00			; clear byte
0017E4r 1  86 B8        	STX	FAC_sc		; clear sign compare (FAC1 EOR FAC2)
0017E6r 1  20 rr rr     	JSR	LAB_247C		; add FAC2 to FAC1 (*5)
0017E9r 1  E6 AC        	INC	FAC1_e		; increment FAC1 exponent (*10)
0017EBr 1  D0 E0        	BNE	LAB_268F		; if non zero just do RTS
0017EDr 1               
0017EDr 1               LAB_269B
0017EDr 1  4C rr rr     	JMP	LAB_2564		; do overflow error and warm start
0017F0r 1               
0017F0r 1               ; divide by 10
0017F0r 1               
0017F0r 1               LAB_26B9
0017F0r 1  20 rr rr     	JSR	LAB_27AB		; round and copy FAC1 to FAC2
0017F3r 1  A9 rr        	LDA	#<LAB_26B5		; set pointer to 10d low addr
0017F5r 1  A0 rr        	LDY	#>LAB_26B5		; set pointer to 10d high addr
0017F7r 1  A2 00        	LDX	#$00			; clear sign
0017F9r 1               
0017F9r 1               ; divide by (AY) (X=sign)
0017F9r 1               
0017F9r 1               LAB_26C2
0017F9r 1  86 B8        	STX	FAC_sc		; save sign compare (FAC1 EOR FAC2)
0017FBr 1  20 rr rr     	JSR	LAB_UFAC		; unpack memory (AY) into FAC1
0017FEr 1  4C rr rr     	JMP	LAB_DIVIDE		; do FAC2/FAC1
001801r 1               
001801r 1               					; Perform divide-by
001801r 1               ; convert AY and do (AY)/FAC1
001801r 1               
001801r 1               LAB_26CA
001801r 1  20 rr rr     	JSR	LAB_264D		; unpack memory (AY) into FAC2
001804r 1               
001804r 1               					; Perform divide-into
001804r 1               LAB_DIVIDE
001804r 1  F0 63        	BEQ	LAB_2737		; if zero go do /0 error
001806r 1               
001806r 1  20 rr rr     	JSR	LAB_27BA		; round FAC1
001809r 1  A9 00        	LDA	#$00			; clear A
00180Br 1  38           	SEC				; set carry for subtract
00180Cr 1  E5 AC        	SBC	FAC1_e		; subtract FAC1 exponent (2s complement)
00180Er 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
001810r 1  20 rr rr     	JSR	LAB_2673		; test and adjust accumulators
001813r 1  E6 AC        	INC	FAC1_e		; increment FAC1 exponent
001815r 1  F0 D6        	BEQ	LAB_269B		; if zero do overflow error
001817r 1               
001817r 1  A2 FF        	LDX	#$FF			; set index for pre increment
001819r 1  A9 01        	LDA	#$01			; set bit to flag byte save
00181Br 1               LAB_26E4
00181Br 1  A4 B4        	LDY	FAC2_1		; get FAC2 mantissa1
00181Dr 1  C4 AD        	CPY	FAC1_1		; compare FAC1 mantissa1
00181Fr 1  D0 0A        	BNE	LAB_26F4		; branch if <>
001821r 1               
001821r 1  A4 B5        	LDY	FAC2_2		; get FAC2 mantissa2
001823r 1  C4 AE        	CPY	FAC1_2		; compare FAC1 mantissa2
001825r 1  D0 04        	BNE	LAB_26F4		; branch if <>
001827r 1               
001827r 1  A4 B6        	LDY	FAC2_3		; get FAC2 mantissa3
001829r 1  C4 AF        	CPY	FAC1_3		; compare FAC1 mantissa3
00182Br 1               LAB_26F4
00182Br 1  08           	PHP				; save FAC2-FAC1 compare status
00182Cr 1  2A           	ROL				; shift the result byte
00182Dr 1  90 0E        	BCC	LAB_2702		; if no carry skip the byte save
00182Fr 1               
00182Fr 1  A0 01        	LDY	#$01			; set bit to flag byte save
001831r 1  E8           	INX				; else increment the index to FACt
001832r 1  E0 02        	CPX	#$02			; compare with the index to FACt_3
001834r 1  30 04        	BMI	LAB_2701		; if not last byte just go save it
001836r 1               
001836r 1  D0 28        	BNE	LAB_272B		; if all done go save FAC1 rounding byte, normalise and
001838r 1               					; return
001838r 1               
001838r 1  A0 40        	LDY	#$40			; set bit to flag byte save for the rounding byte
00183Ar 1               LAB_2701
00183Ar 1  95 75        	STA	FACt_1,X		; write result byte to FACt_1 + index
00183Cr 1  98           	TYA				; copy the next save byte flag
00183Dr 1               LAB_2702
00183Dr 1  28           	PLP				; restore FAC2-FAC1 compare status
00183Er 1  90 14        	BCC	LAB_2704		; if FAC2 < FAC1 then skip the subtract
001840r 1               
001840r 1  A8           	TAY				; save FAC2-FAC1 compare status
001841r 1  A5 B6        	LDA	FAC2_3		; get FAC2 mantissa3
001843r 1  E5 AF        	SBC	FAC1_3		; subtract FAC1 mantissa3
001845r 1  85 B6        	STA	FAC2_3		; save FAC2 mantissa3
001847r 1  A5 B5        	LDA	FAC2_2		; get FAC2 mantissa2
001849r 1  E5 AE        	SBC	FAC1_2		; subtract FAC1 mantissa2
00184Br 1  85 B5        	STA	FAC2_2		; save FAC2 mantissa2
00184Dr 1  A5 B4        	LDA	FAC2_1		; get FAC2 mantissa1
00184Fr 1  E5 AD        	SBC	FAC1_1		; subtract FAC1 mantissa1
001851r 1  85 B4        	STA	FAC2_1		; save FAC2 mantissa1
001853r 1  98           	TYA				; restore FAC2-FAC1 compare status
001854r 1               
001854r 1               					; FAC2 = FAC2*2
001854r 1               LAB_2704
001854r 1  06 B6        	ASL	FAC2_3		; shift FAC2 mantissa3
001856r 1  26 B5        	ROL	FAC2_2		; shift FAC2 mantissa2
001858r 1  26 B4        	ROL	FAC2_1		; shift FAC2 mantissa1
00185Ar 1  B0 CF        	BCS	LAB_26F4		; loop with no compare
00185Cr 1               
00185Cr 1  30 BD        	BMI	LAB_26E4		; loop with compare
00185Er 1               
00185Er 1  10 CB        	BPL	LAB_26F4		; loop always with no compare
001860r 1               
001860r 1               ; do A<<6, save as FAC1 rounding byte, normalise and return
001860r 1               
001860r 1               LAB_272B
001860r 1  4A           	LSR				; shift b1 - b0 ..
001861r 1  6A           	ROR				; ..
001862r 1  6A           	ROR				; .. to b7 - b6
001863r 1  85 B9        	STA	FAC1_r		; save FAC1 rounding byte
001865r 1  28           	PLP				; dump FAC2-FAC1 compare status
001866r 1  4C rr rr     	JMP	LAB_273C		; copy temp to FAC1, normalise and return
001869r 1               
001869r 1               ; do "Divide by zero" error
001869r 1               
001869r 1               LAB_2737
001869r 1  A2 14        	LDX	#$14			; error code $14 ("Divide by zero" error)
00186Br 1  4C rr rr     	JMP	LAB_XERR		; do error #X, then warm start
00186Er 1               
00186Er 1               ; copy temp to FAC1 and normalise
00186Er 1               
00186Er 1               LAB_273C
00186Er 1  A5 75        	LDA	FACt_1		; get temp mantissa1
001870r 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
001872r 1  A5 76        	LDA	FACt_2		; get temp mantissa2
001874r 1  85 AE        	STA	FAC1_2		; save FAC1 mantissa2
001876r 1  A5 77        	LDA	FACt_3		; get temp mantissa3
001878r 1  85 AF        	STA	FAC1_3		; save FAC1 mantissa3
00187Ar 1  4C rr rr     	JMP	LAB_24D5		; normalise FAC1 and return
00187Dr 1               
00187Dr 1               ; unpack memory (AY) into FAC1
00187Dr 1               
00187Dr 1               LAB_UFAC
00187Dr 1  85 71        	STA	ut1_pl		; save pointer low byte
00187Fr 1  84 72        	STY	ut1_ph		; save pointer high byte
001881r 1  A0 03        	LDY	#$03			; 4 bytes to do
001883r 1  B1 71        	LDA	(ut1_pl),Y		; get last byte
001885r 1  85 AF        	STA	FAC1_3		; save FAC1 mantissa3
001887r 1  88           	DEY				; decrement index
001888r 1  B1 71        	LDA	(ut1_pl),Y		; get last-1 byte
00188Ar 1  85 AE        	STA	FAC1_2		; save FAC1 mantissa2
00188Cr 1  88           	DEY				; decrement index
00188Dr 1  B1 71        	LDA	(ut1_pl),Y		; get second byte
00188Fr 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
001891r 1  09 80        	ORA	#$80			; set 1xxx xxxx (add normal bit)
001893r 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
001895r 1  88           	DEY				; decrement index
001896r 1  B1 71        	LDA	(ut1_pl),Y		; get first byte (exponent)
001898r 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
00189Ar 1  84 B9        	STY	FAC1_r		; clear FAC1 rounding byte
00189Cr 1  60           	RTS
00189Dr 1               
00189Dr 1               ; pack FAC1 into Adatal
00189Dr 1               
00189Dr 1               LAB_276E
00189Dr 1  A2 A4        	LDX	#<Adatal		; set pointer low byte
00189Fr 1               LAB_2770
00189Fr 1  A0 00        	LDY	#>Adatal		; set pointer high byte
0018A1r 1  F0 04        	BEQ	LAB_2778		; pack FAC1 into (XY) and return
0018A3r 1               
0018A3r 1               ; pack FAC1 into (Lvarpl)
0018A3r 1               
0018A3r 1               LAB_PFAC
0018A3r 1  A6 97        	LDX	Lvarpl		; get destination pointer low byte
0018A5r 1  A4 98        	LDY	Lvarph		; get destination pointer high byte
0018A7r 1               
0018A7r 1               ; pack FAC1 into (XY)
0018A7r 1               
0018A7r 1               LAB_2778
0018A7r 1  20 rr rr     	JSR	LAB_27BA		; round FAC1
0018AAr 1  86 71        	STX	ut1_pl		; save pointer low byte
0018ACr 1  84 72        	STY	ut1_ph		; save pointer high byte
0018AEr 1  A0 03        	LDY	#$03			; set index
0018B0r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
0018B2r 1  91 71        	STA	(ut1_pl),Y		; store in destination
0018B4r 1  88           	DEY				; decrement index
0018B5r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
0018B7r 1  91 71        	STA	(ut1_pl),Y		; store in destination
0018B9r 1  88           	DEY				; decrement index
0018BAr 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
0018BCr 1  09 7F        	ORA	#$7F			; set bits x111 1111
0018BEr 1  25 AD        	AND	FAC1_1		; AND in FAC1 mantissa1
0018C0r 1  91 71        	STA	(ut1_pl),Y		; store in destination
0018C2r 1  88           	DEY				; decrement index
0018C3r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
0018C5r 1  91 71        	STA	(ut1_pl),Y		; store in destination
0018C7r 1  84 B9        	STY	FAC1_r		; clear FAC1 rounding byte
0018C9r 1  60           	RTS
0018CAr 1               
0018CAr 1               ; round and copy FAC1 to FAC2
0018CAr 1               
0018CAr 1               LAB_27AB
0018CAr 1  20 rr rr     	JSR	LAB_27BA		; round FAC1
0018CDr 1               
0018CDr 1               ; copy FAC1 to FAC2
0018CDr 1               
0018CDr 1               LAB_27AE
0018CDr 1  A2 05        	LDX	#$05			; 5 bytes to copy
0018CFr 1               LAB_27B0
0018CFr 1  B5 AB        	LDA	FAC1_e-1,X		; get byte from FAC1,X
0018D1r 1  95 B2        	STA	FAC1_o,X		; save byte at FAC2,X
0018D3r 1  CA           	DEX				; decrement count
0018D4r 1  D0 F9        	BNE	LAB_27B0		; loop if not all done
0018D6r 1               
0018D6r 1  86 B9        	STX	FAC1_r		; clear FAC1 rounding byte
0018D8r 1               LAB_27B9
0018D8r 1  60           	RTS
0018D9r 1               
0018D9r 1               ; round FAC1
0018D9r 1               
0018D9r 1               LAB_27BA
0018D9r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
0018DBr 1  F0 FB        	BEQ	LAB_27B9		; exit if zero
0018DDr 1               
0018DDr 1  06 B9        	ASL	FAC1_r		; shift FAC1 rounding byte
0018DFr 1  90 F7        	BCC	LAB_27B9		; exit if no overflow
0018E1r 1               
0018E1r 1               ; round FAC1 (no check)
0018E1r 1               
0018E1r 1               LAB_27C2
0018E1r 1  20 rr rr     	JSR	LAB_2559		; increment FAC1 mantissa
0018E4r 1  D0 F2        	BNE	LAB_27B9		; branch if no overflow
0018E6r 1               
0018E6r 1  4C rr rr     	JMP	LAB_252A		; normalise FAC1 for C=1 and return
0018E9r 1               
0018E9r 1               ; get FAC1 sign
0018E9r 1               ; return A=FF,C=1/-ve A=01,C=0/+ve
0018E9r 1               
0018E9r 1               LAB_27CA
0018E9r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
0018EBr 1  F0 09        	BEQ	LAB_27D7		; exit if zero (already correct SGN(0)=0)
0018EDr 1               
0018EDr 1               ; return A=FF,C=1/-ve A=01,C=0/+ve
0018EDr 1               ; no = 0 check
0018EDr 1               
0018EDr 1               LAB_27CE
0018EDr 1  A5 B0        	LDA	FAC1_s		; else get FAC1 sign (b7)
0018EFr 1               
0018EFr 1               ; return A=FF,C=1/-ve A=01,C=0/+ve
0018EFr 1               ; no = 0 check, sign in A
0018EFr 1               
0018EFr 1               LAB_27D0
0018EFr 1  2A           	ROL				; move sign bit to carry
0018F0r 1  A9 FF        	LDA	#$FF			; set byte for -ve result
0018F2r 1  B0 02        	BCS	LAB_27D7		; return if sign was set (-ve)
0018F4r 1               
0018F4r 1  A9 01        	LDA	#$01			; else set byte for +ve result
0018F6r 1               LAB_27D7
0018F6r 1  60           	RTS
0018F7r 1               
0018F7r 1               ; perform SGN()
0018F7r 1               
0018F7r 1               LAB_SGN
0018F7r 1  20 rr rr     	JSR	LAB_27CA		; get FAC1 sign
0018FAr 1               					; return A=$FF/-ve A=$01/+ve
0018FAr 1               ; save A as integer byte
0018FAr 1               
0018FAr 1               LAB_27DB
0018FAr 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
0018FCr 1  A9 00        	LDA	#$00			; clear A
0018FEr 1  85 AE        	STA	FAC1_2		; clear FAC1 mantissa2
001900r 1  A2 88        	LDX	#$88			; set exponent
001902r 1               
001902r 1               ; set exp=X, clearFAC1 mantissa3 and normalise
001902r 1               
001902r 1               LAB_27E3
001902r 1  A5 AD        	LDA	FAC1_1		; get FAC1 mantissa1
001904r 1  49 FF        	EOR	#$FF			; complement it
001906r 1  2A           	ROL				; sign bit into carry
001907r 1               
001907r 1               ; set exp=X, clearFAC1 mantissa3 and normalise
001907r 1               
001907r 1               LAB_STFA
001907r 1  A9 00        	LDA	#$00			; clear A
001909r 1  85 AF        	STA	FAC1_3		; clear FAC1 mantissa3
00190Br 1  86 AC        	STX	FAC1_e		; set FAC1 exponent
00190Dr 1  85 B9        	STA	FAC1_r		; clear FAC1 rounding byte
00190Fr 1  85 B0        	STA	FAC1_s		; clear FAC1 sign (b7)
001911r 1  4C rr rr     	JMP	LAB_24D0		; do ABS and normalise FAC1
001914r 1               
001914r 1               ; perform ABS()
001914r 1               
001914r 1               LAB_ABS
001914r 1  46 B0        	LSR	FAC1_s		; clear FAC1 sign (put zero in b7)
001916r 1  60           	RTS
001917r 1               
001917r 1               ; compare FAC1 with (AY)
001917r 1               ; returns A=$00 if FAC1 = (AY)
001917r 1               ; returns A=$01 if FAC1 > (AY)
001917r 1               ; returns A=$FF if FAC1 < (AY)
001917r 1               
001917r 1               LAB_27F8
001917r 1  85 73        	STA	ut2_pl		; save pointer low byte
001919r 1               LAB_27FA
001919r 1  84 74        	STY	ut2_ph		; save pointer high byte
00191Br 1  A0 00        	LDY	#$00			; clear index
00191Dr 1  B1 73        	LDA	(ut2_pl),Y		; get exponent
00191Fr 1  C8           	INY				; increment index
001920r 1  AA           	TAX				; copy (AY) exponent to X
001921r 1  F0 C6        	BEQ	LAB_27CA		; branch if (AY) exponent=0 and get FAC1 sign
001923r 1               					; A=FF,C=1/-ve A=01,C=0/+ve
001923r 1               
001923r 1  B1 73        	LDA	(ut2_pl),Y		; get (AY) mantissa1 (with sign)
001925r 1  45 B0        	EOR	FAC1_s		; EOR FAC1 sign (b7)
001927r 1  30 C4        	BMI	LAB_27CE		; if signs <> do return A=FF,C=1/-ve
001929r 1               					; A=01,C=0/+ve and return
001929r 1               
001929r 1  E4 AC        	CPX	FAC1_e		; compare (AY) exponent with FAC1 exponent
00192Br 1  D0 1A        	BNE	LAB_2828		; branch if different
00192Dr 1               
00192Dr 1  B1 73        	LDA	(ut2_pl),Y		; get (AY) mantissa1 (with sign)
00192Fr 1  09 80        	ORA	#$80			; normalise top bit
001931r 1  C5 AD        	CMP	FAC1_1		; compare with FAC1 mantissa1
001933r 1  D0 12        	BNE	LAB_2828		; branch if different
001935r 1               
001935r 1  C8           	INY				; increment index
001936r 1  B1 73        	LDA	(ut2_pl),Y		; get mantissa2
001938r 1  C5 AE        	CMP	FAC1_2		; compare with FAC1 mantissa2
00193Ar 1  D0 0B        	BNE	LAB_2828		; branch if different
00193Cr 1               
00193Cr 1  C8           	INY				; increment index
00193Dr 1  A9 7F        	LDA	#$7F			; set for 1/2 value rounding byte
00193Fr 1  C5 B9        	CMP	FAC1_r		; compare with FAC1 rounding byte (set carry)
001941r 1  B1 73        	LDA	(ut2_pl),Y		; get mantissa3
001943r 1  E5 AF        	SBC	FAC1_3		; subtract FAC1 mantissa3
001945r 1  F0 28        	BEQ	LAB_2850		; exit if mantissa3 equal
001947r 1               
001947r 1               ; gets here if number <> FAC1
001947r 1               
001947r 1               LAB_2828
001947r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
001949r 1  90 02        	BCC	LAB_282E		; branch if FAC1 > (AY)
00194Br 1               
00194Br 1  49 FF        	EOR	#$FF			; else toggle FAC1 sign
00194Dr 1               LAB_282E
00194Dr 1  4C rr rr     	JMP	LAB_27D0		; return A=FF,C=1/-ve A=01,C=0/+ve
001950r 1               
001950r 1               ; convert FAC1 floating-to-fixed
001950r 1               
001950r 1               LAB_2831
001950r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001952r 1  F0 4A        	BEQ	LAB_287F		; if zero go clear FAC1 and return
001954r 1               
001954r 1  38           	SEC				; set carry for subtract
001955r 1  E9 98        	SBC	#$98			; subtract maximum integer range exponent
001957r 1  24 B0        	BIT	FAC1_s		; test FAC1 sign (b7)
001959r 1  10 09        	BPL	LAB_2845		; branch if FAC1 +ve
00195Br 1               
00195Br 1               					; FAC1 was -ve
00195Br 1  AA           	TAX				; copy subtracted exponent
00195Cr 1  A9 FF        	LDA	#$FF			; overflow for -ve number
00195Er 1  85 B2        	STA	FAC1_o		; set FAC1 overflow byte
001960r 1  20 rr rr     	JSR	LAB_253D		; twos complement FAC1 mantissa
001963r 1  8A           	TXA				; restore subtracted exponent
001964r 1               LAB_2845
001964r 1  A2 AC        	LDX	#FAC1_e		; set index to FAC1
001966r 1  C9 F9        	CMP	#$F9			; compare exponent result
001968r 1  10 06        	BPL	LAB_2851		; if < 8 shifts shift FAC1 A times right and return
00196Ar 1               
00196Ar 1  20 rr rr     	JSR	LAB_257B		; shift FAC1 A times right (> 8 shifts)
00196Dr 1  84 B2        	STY	FAC1_o		; clear FAC1 overflow byte
00196Fr 1               LAB_2850
00196Fr 1  60           	RTS
001970r 1               
001970r 1               ; shift FAC1 A times right
001970r 1               
001970r 1               LAB_2851
001970r 1  A8           	TAY				; copy shift count
001971r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
001973r 1  29 80        	AND	#$80			; mask sign bit only (x000 0000)
001975r 1  46 AD        	LSR	FAC1_1		; shift FAC1 mantissa1
001977r 1  05 AD        	ORA	FAC1_1		; OR sign in b7 FAC1 mantissa1
001979r 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
00197Br 1  20 rr rr     	JSR	LAB_2592		; shift FAC1 Y times right
00197Er 1  84 B2        	STY	FAC1_o		; clear FAC1 overflow byte
001980r 1  60           	RTS
001981r 1               
001981r 1               ; perform INT()
001981r 1               
001981r 1               LAB_INT
001981r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001983r 1  C9 98        	CMP	#$98			; compare with max int
001985r 1  B0 1E        	BCS	LAB_2886		; exit if >= (already int, too big for fractional part!)
001987r 1               
001987r 1  20 rr rr     	JSR	LAB_2831		; convert FAC1 floating-to-fixed
00198Ar 1  84 B9        	STY	FAC1_r		; save FAC1 rounding byte
00198Cr 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
00198Er 1  84 B0        	STY	FAC1_s		; save FAC1 sign (b7)
001990r 1  49 80        	EOR	#$80			; toggle FAC1 sign
001992r 1  2A           	ROL				; shift into carry
001993r 1  A9 98        	LDA	#$98			; set new exponent
001995r 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
001997r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
001999r 1  85 5B        	STA	Temp3			; save for EXP() function
00199Br 1  4C rr rr     	JMP	LAB_24D0		; do ABS and normalise FAC1
00199Er 1               
00199Er 1               ; clear FAC1 and return
00199Er 1               
00199Er 1               LAB_287F
00199Er 1  85 AD        	STA	FAC1_1		; clear FAC1 mantissa1
0019A0r 1  85 AE        	STA	FAC1_2		; clear FAC1 mantissa2
0019A2r 1  85 AF        	STA	FAC1_3		; clear FAC1 mantissa3
0019A4r 1  A8           	TAY				; clear Y
0019A5r 1               LAB_2886
0019A5r 1  60           	RTS
0019A6r 1               
0019A6r 1               ; get FAC1 from string
0019A6r 1               ; this routine now handles hex and binary values from strings
0019A6r 1               ; starting with "$" and "%" respectively
0019A6r 1               
0019A6r 1               LAB_2887
0019A6r 1  A0 00        	LDY	#$00			; clear Y
0019A8r 1  84 5F        	STY	Dtypef		; clear data type flag, $FF=string, $00=numeric
0019AAr 1  A2 09        	LDX	#$09			; set index
0019ACr 1               LAB_288B
0019ACr 1  94 A8        	STY	numexp,X		; clear byte
0019AEr 1  CA           	DEX				; decrement index
0019AFr 1  10 FB        	BPL	LAB_288B		; loop until numexp to negnum (and FAC1) = $00
0019B1r 1               
0019B1r 1  90 7F        	BCC	LAB_28FE		; branch if 1st character numeric
0019B3r 1               
0019B3r 1               ; get FAC1 from string .. first character wasn't numeric
0019B3r 1               
0019B3r 1  C9 2D        	CMP	#'-'			; else compare with "-"
0019B5r 1  D0 04        	BNE	LAB_289A		; branch if not "-"
0019B7r 1               
0019B7r 1  86 B1        	STX	negnum		; set flag for -ve number (X = $FF)
0019B9r 1  F0 04        	BEQ	LAB_289C		; branch always (go scan and check for hex/bin)
0019BBr 1               
0019BBr 1               ; get FAC1 from string .. first character wasn't numeric or -
0019BBr 1               
0019BBr 1               LAB_289A
0019BBr 1  C9 2B        	CMP	#'+'			; else compare with "+"
0019BDr 1  D0 05        	BNE	LAB_289D		; branch if not "+" (go check for hex/bin)
0019BFr 1               
0019BFr 1               ; was "+" or "-" to start, so get next character
0019BFr 1               
0019BFr 1               LAB_289C
0019BFr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0019C2r 1  90 6E        	BCC	LAB_28FE		; branch if numeric character
0019C4r 1               
0019C4r 1               ; code here for hex and binary numbers
0019C4r 1               
0019C4r 1               LAB_289D
0019C4r 1  C9 24        	CMP	#'$'			; else compare with "$"
0019C6r 1  D0 03        	BNE	LAB_NHEX		; branch if not "$"
0019C8r 1               
0019C8r 1  4C rr rr     	JMP	LAB_CHEX		; branch if "$"
0019CBr 1               
0019CBr 1               LAB_NHEX
0019CBr 1  C9 25        	CMP	#'%'			; else compare with "%"
0019CDr 1  D0 08        	BNE	LAB_28A3		; branch if not "%" (continue original code)
0019CFr 1               
0019CFr 1  4C rr rr     	JMP	LAB_CBIN		; branch if "%"
0019D2r 1               
0019D2r 1               LAB_289E
0019D2r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory (ignore + or get next number)
0019D5r 1               LAB_28A1
0019D5r 1  90 5B        	BCC	LAB_28FE		; branch if numeric character
0019D7r 1               
0019D7r 1               ; get FAC1 from string .. character wasn't numeric, -, +, hex or binary
0019D7r 1               
0019D7r 1               LAB_28A3
0019D7r 1  C9 2E        	CMP	#'.'			; else compare with "."
0019D9r 1  F0 2E        	BEQ	LAB_28D5		; branch if "."
0019DBr 1               
0019DBr 1               ; get FAC1 from string .. character wasn't numeric, -, + or .
0019DBr 1               
0019DBr 1  C9 45        	CMP	#'E'			; else compare with "E"
0019DDr 1  D0 30        	BNE	LAB_28DB		; branch if not "E"
0019DFr 1               
0019DFr 1               					; was "E" so evaluate exponential part
0019DFr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0019E2r 1  90 17        	BCC	LAB_28C7		; branch if numeric character
0019E4r 1               
0019E4r 1  C9 B8        	CMP	#TK_MINUS		; else compare with token for -
0019E6r 1  F0 0E        	BEQ	LAB_28C2		; branch if token for -
0019E8r 1               
0019E8r 1  C9 2D        	CMP	#'-'			; else compare with "-"
0019EAr 1  F0 0A        	BEQ	LAB_28C2		; branch if "-"
0019ECr 1               
0019ECr 1  C9 B7        	CMP	#TK_PLUS		; else compare with token for +
0019EEr 1  F0 08        	BEQ	LAB_28C4		; branch if token for +
0019F0r 1               
0019F0r 1  C9 2B        	CMP	#'+'			; else compare with "+"
0019F2r 1  F0 04        	BEQ	LAB_28C4		; branch if "+"
0019F4r 1               
0019F4r 1  D0 07        	BNE	LAB_28C9		; branch always
0019F6r 1               
0019F6r 1               LAB_28C2
0019F6r 1  66 AB        	ROR	expneg		; set exponent -ve flag (C, which=1, into b7)
0019F8r 1               LAB_28C4
0019F8r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0019FBr 1               LAB_28C7
0019FBr 1  90 5B        	BCC	LAB_2925		; branch if numeric character
0019FDr 1               
0019FDr 1               LAB_28C9
0019FDr 1  24 AB        	BIT	expneg		; test exponent -ve flag
0019FFr 1  10 0E        	BPL	LAB_28DB		; if +ve go evaluate exponent
001A01r 1               
001A01r 1               					; else do exponent = -exponent
001A01r 1  A9 00        	LDA	#$00			; clear result
001A03r 1  38           	SEC				; set carry for subtract
001A04r 1  E5 A9        	SBC	expcnt		; subtract exponent byte
001A06r 1  4C rr rr     	JMP	LAB_28DD		; go evaluate exponent
001A09r 1               
001A09r 1               LAB_28D5
001A09r 1  66 AA        	ROR	numdpf		; set decimal point flag
001A0Br 1  24 AA        	BIT	numdpf		; test decimal point flag
001A0Dr 1  50 C3        	BVC	LAB_289E		; branch if only one decimal point so far
001A0Fr 1               
001A0Fr 1               					; evaluate exponent
001A0Fr 1               LAB_28DB
001A0Fr 1  A5 A9        	LDA	expcnt		; get exponent count byte
001A11r 1               LAB_28DD
001A11r 1  38           	SEC				; set carry for subtract
001A12r 1  E5 A8        	SBC	numexp		; subtract numerator exponent
001A14r 1  85 A9        	STA	expcnt		; save exponent count byte
001A16r 1  F0 12        	BEQ	LAB_28F6		; branch if no adjustment
001A18r 1               
001A18r 1  10 09        	BPL	LAB_28EF		; else if +ve go do FAC1*10^expcnt
001A1Ar 1               
001A1Ar 1               					; else go do FAC1/10^(0-expcnt)
001A1Ar 1               LAB_28E6
001A1Ar 1  20 rr rr     	JSR	LAB_26B9		; divide by 10
001A1Dr 1  E6 A9        	INC	expcnt		; increment exponent count byte
001A1Fr 1  D0 F9        	BNE	LAB_28E6		; loop until all done
001A21r 1               
001A21r 1  F0 07        	BEQ	LAB_28F6		; branch always
001A23r 1               
001A23r 1               LAB_28EF
001A23r 1  20 rr rr     	JSR	LAB_269E		; multiply by 10
001A26r 1  C6 A9        	DEC	expcnt		; decrement exponent count byte
001A28r 1  D0 F9        	BNE	LAB_28EF		; loop until all done
001A2Ar 1               
001A2Ar 1               LAB_28F6
001A2Ar 1  A5 B1        	LDA	negnum		; get -ve flag
001A2Cr 1  30 01        	BMI	LAB_28FB		; if -ve do - FAC1 and return
001A2Er 1               
001A2Er 1  60           	RTS
001A2Fr 1               
001A2Fr 1               ; do - FAC1 and return
001A2Fr 1               
001A2Fr 1               LAB_28FB
001A2Fr 1  4C rr rr     	JMP	LAB_GTHAN		; do - FAC1 and return
001A32r 1               
001A32r 1               ; do unsigned FAC1*10+number
001A32r 1               
001A32r 1               LAB_28FE
001A32r 1  48           	PHA				; save character
001A33r 1  24 AA        	BIT	numdpf		; test decimal point flag
001A35r 1  10 02        	BPL	LAB_2905		; skip exponent increment if not set
001A37r 1               
001A37r 1  E6 A8        	INC	numexp		; else increment number exponent
001A39r 1               LAB_2905
001A39r 1  20 rr rr     	JSR	LAB_269E		; multiply FAC1 by 10
001A3Cr 1  68           	PLA				; restore character
001A3Dr 1  29 0F        	AND	#$0F			; convert to binary
001A3Fr 1  20 rr rr     	JSR	LAB_2912		; evaluate new ASCII digit
001A42r 1  4C rr rr     	JMP	LAB_289E		; go do next character
001A45r 1               
001A45r 1               ; evaluate new ASCII digit
001A45r 1               
001A45r 1               LAB_2912
001A45r 1  48           	PHA				; save digit
001A46r 1  20 rr rr     	JSR	LAB_27AB		; round and copy FAC1 to FAC2
001A49r 1  68           	PLA				; restore digit
001A4Ar 1  20 rr rr     	JSR	LAB_27DB		; save A as integer byte
001A4Dr 1  A5 B7        	LDA	FAC2_s		; get FAC2 sign (b7)
001A4Fr 1  45 B0        	EOR	FAC1_s		; toggle with FAC1 sign (b7)
001A51r 1  85 B8        	STA	FAC_sc		; save sign compare (FAC1 EOR FAC2)
001A53r 1  A6 AC        	LDX	FAC1_e		; get FAC1 exponent
001A55r 1  4C rr rr     	JMP	LAB_ADD		; add FAC2 to FAC1 and return
001A58r 1               
001A58r 1               ; evaluate next character of exponential part of number
001A58r 1               
001A58r 1               LAB_2925
001A58r 1  A5 A9        	LDA	expcnt		; get exponent count byte
001A5Ar 1  C9 0A        	CMP	#$0A			; compare with 10 decimal
001A5Cr 1  90 09        	BCC	LAB_2934		; branch if less
001A5Er 1               
001A5Er 1  A9 64        	LDA	#$64			; make all -ve exponents = -100 decimal (causes underflow)
001A60r 1  24 AB        	BIT	expneg		; test exponent -ve flag
001A62r 1  30 0E        	BMI	LAB_2942		; branch if -ve
001A64r 1               
001A64r 1  4C rr rr     	JMP	LAB_2564		; else do overflow error
001A67r 1               
001A67r 1               LAB_2934
001A67r 1  0A           	ASL				; * 2
001A68r 1  0A           	ASL				; * 4
001A69r 1  65 A9        	ADC	expcnt		; * 5
001A6Br 1  0A           	ASL				; * 10
001A6Cr 1  A0 00        	LDY	#$00			; set index
001A6Er 1  71 C3        	ADC	(Bpntrl),Y		; add character (will be $30 too much!)
001A70r 1  E9 2F        	SBC	#'0'-1		; convert character to binary
001A72r 1               LAB_2942
001A72r 1  85 A9        	STA	expcnt		; save exponent count byte
001A74r 1  4C rr rr     	JMP	LAB_28C4		; go get next character
001A77r 1               
001A77r 1               ; print " in line [LINE #]"
001A77r 1               
001A77r 1               LAB_2953
001A77r 1  A9 rr        	LDA	#<LAB_LMSG		; point to " in line " message low byte
001A79r 1  A0 rr        	LDY	#>LAB_LMSG		; point to " in line " message high byte
001A7Br 1  20 rr rr     	JSR	LAB_18C3		; print null terminated string from memory
001A7Er 1               
001A7Er 1               					; print Basic line #
001A7Er 1  A5 88        	LDA	Clineh		; get current line high byte
001A80r 1  A6 87        	LDX	Clinel		; get current line low byte
001A82r 1               
001A82r 1               ; print XA as unsigned integer
001A82r 1               
001A82r 1               LAB_295E
001A82r 1  85 AD        	STA	FAC1_1		; save low byte as FAC1 mantissa1
001A84r 1  86 AE        	STX	FAC1_2		; save high byte as FAC1 mantissa2
001A86r 1  A2 90        	LDX	#$90			; set exponent to 16d bits
001A88r 1  38           	SEC				; set integer is +ve flag
001A89r 1  20 rr rr     	JSR	LAB_STFA		; set exp=X, clearFAC1 mantissa3 and normalise
001A8Cr 1  A0 00        	LDY	#$00			; clear index
001A8Er 1  98           	TYA				; clear A
001A8Fr 1  20 rr rr     	JSR	LAB_297B		; convert FAC1 to string, skip sign character save
001A92r 1  4C rr rr     	JMP	LAB_18C3		; print null terminated string from memory and return
001A95r 1               
001A95r 1               ; convert FAC1 to ASCII string result in (AY)
001A95r 1               ; not any more, moved scratchpad to page 0
001A95r 1               
001A95r 1               LAB_296E
001A95r 1  A0 01        	LDY	#$01			; set index = 1
001A97r 1  A9 20        	LDA	#$20			; character = " " (assume +ve)
001A99r 1  24 B0        	BIT	FAC1_s		; test FAC1 sign (b7)
001A9Br 1  10 02        	BPL	LAB_2978		; branch if +ve
001A9Dr 1               
001A9Dr 1  A9 2D        	LDA	#$2D			; else character = "-"
001A9Fr 1               LAB_2978
001A9Fr 1  99 EF 00     	STA	Decss,Y		; save leading character (" " or "-")
001AA2r 1               LAB_297B
001AA2r 1  85 B0        	STA	FAC1_s		; clear FAC1 sign (b7)
001AA4r 1  84 BA        	STY	Sendl			; save index
001AA6r 1  C8           	INY				; increment index
001AA7r 1  A6 AC        	LDX	FAC1_e		; get FAC1 exponent
001AA9r 1  D0 05        	BNE	LAB_2989		; branch if FAC1<>0
001AABr 1               
001AABr 1               					; exponent was $00 so FAC1 is 0
001AABr 1  A9 30        	LDA	#'0'			; set character = "0"
001AADr 1  4C rr rr     	JMP	LAB_2A89		; save last character, [EOT] and exit
001AB0r 1               
001AB0r 1               					; FAC1 is some non zero value
001AB0r 1               LAB_2989
001AB0r 1  A9 00        	LDA	#$00			; clear (number exponent count)
001AB2r 1  E0 81        	CPX	#$81			; compare FAC1 exponent with $81 (>1.00000)
001AB4r 1               
001AB4r 1  B0 09        	BCS	LAB_299A		; branch if FAC1=>1
001AB6r 1               
001AB6r 1               					; FAC1<1
001AB6r 1  A9 rr        	LDA	#<LAB_294F		; set pointer low byte to 1,000,000
001AB8r 1  A0 rr        	LDY	#>LAB_294F		; set pointer high byte to 1,000,000
001ABAr 1  20 rr rr     	JSR	LAB_25FB		; do convert AY, FCA1*(AY)
001ABDr 1  A9 FA        	LDA	#$FA			; set number exponent count (-6)
001ABFr 1               LAB_299A
001ABFr 1  85 A8        	STA	numexp		; save number exponent count
001AC1r 1               LAB_299C
001AC1r 1  A9 rr        	LDA	#<LAB_294B		; set pointer low byte to 999999.4375 (max before sci note)
001AC3r 1  A0 rr        	LDY	#>LAB_294B		; set pointer high byte to 999999.4375
001AC5r 1  20 rr rr     	JSR	LAB_27F8		; compare FAC1 with (AY)
001AC8r 1  F0 1E        	BEQ	LAB_29C3		; exit if FAC1 = (AY)
001ACAr 1               
001ACAr 1  10 12        	BPL	LAB_29B9		; go do /10 if FAC1 > (AY)
001ACCr 1               
001ACCr 1               					; FAC1 < (AY)
001ACCr 1               LAB_29A7
001ACCr 1  A9 rr        	LDA	#<LAB_2947		; set pointer low byte to 99999.9375
001ACEr 1  A0 rr        	LDY	#>LAB_2947		; set pointer high byte to 99999.9375
001AD0r 1  20 rr rr     	JSR	LAB_27F8		; compare FAC1 with (AY)
001AD3r 1  F0 02        	BEQ	LAB_29B2		; branch if FAC1 = (AY) (allow decimal places)
001AD5r 1               
001AD5r 1  10 0E        	BPL	LAB_29C0		; branch if FAC1 > (AY) (no decimal places)
001AD7r 1               
001AD7r 1               					; FAC1 <= (AY)
001AD7r 1               LAB_29B2
001AD7r 1  20 rr rr     	JSR	LAB_269E		; multiply by 10
001ADAr 1  C6 A8        	DEC	numexp		; decrement number exponent count
001ADCr 1  D0 EE        	BNE	LAB_29A7		; go test again (branch always)
001ADEr 1               
001ADEr 1               LAB_29B9
001ADEr 1  20 rr rr     	JSR	LAB_26B9		; divide by 10
001AE1r 1  E6 A8        	INC	numexp		; increment number exponent count
001AE3r 1  D0 DC        	BNE	LAB_299C		; go test again (branch always)
001AE5r 1               
001AE5r 1               ; now we have just the digits to do
001AE5r 1               
001AE5r 1               LAB_29C0
001AE5r 1  20 rr rr     	JSR	LAB_244E		; add 0.5 to FAC1 (round FAC1)
001AE8r 1               LAB_29C3
001AE8r 1  20 rr rr     	JSR	LAB_2831		; convert FAC1 floating-to-fixed
001AEBr 1  A2 01        	LDX	#$01			; set default digits before dp = 1
001AEDr 1  A5 A8        	LDA	numexp		; get number exponent count
001AEFr 1  18           	CLC				; clear carry for add
001AF0r 1  69 07        	ADC	#$07			; up to 6 digits before point
001AF2r 1  30 09        	BMI	LAB_29D8		; if -ve then 1 digit before dp
001AF4r 1               
001AF4r 1  C9 08        	CMP	#$08			; A>=8 if n>=1E6
001AF6r 1  B0 06        	BCS	LAB_29D9		; branch if >= $08
001AF8r 1               
001AF8r 1               					; carry is clear
001AF8r 1  69 FF        	ADC	#$FF			; take 1 from digit count
001AFAr 1  AA           	TAX				; copy to A
001AFBr 1  A9 02        	LDA	#$02			;.set exponent adjust
001AFDr 1               LAB_29D8
001AFDr 1  38           	SEC				; set carry for subtract
001AFEr 1               LAB_29D9
001AFEr 1  E9 02        	SBC	#$02			; -2
001B00r 1  85 A9        	STA	expcnt		;.save exponent adjust
001B02r 1  86 A8        	STX	numexp		; save digits before dp count
001B04r 1  8A           	TXA				; copy to A
001B05r 1  F0 02        	BEQ	LAB_29E4		; branch if no digits before dp
001B07r 1               
001B07r 1  10 13        	BPL	LAB_29F7		; branch if digits before dp
001B09r 1               
001B09r 1               LAB_29E4
001B09r 1  A4 BA        	LDY	Sendl			; get output string index
001B0Br 1  A9 2E        	LDA	#$2E			; character "."
001B0Dr 1  C8           	INY				; increment index
001B0Er 1  99 EF 00     	STA	Decss,Y		; save to output string
001B11r 1  8A           	TXA				;.
001B12r 1  F0 06        	BEQ	LAB_29F5		;.
001B14r 1               
001B14r 1  A9 30        	LDA	#'0'			; character "0"
001B16r 1  C8           	INY				; increment index
001B17r 1  99 EF 00     	STA	Decss,Y		; save to output string
001B1Ar 1               LAB_29F5
001B1Ar 1  84 BA        	STY	Sendl			; save output string index
001B1Cr 1               LAB_29F7
001B1Cr 1  A0 00        	LDY	#$00			; clear index (point to 100,000)
001B1Er 1  A2 80        	LDX	#$80			;
001B20r 1               LAB_29FB
001B20r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
001B22r 1  18           	CLC				; clear carry for add
001B23r 1  79 rr rr     	ADC	LAB_2A9C,Y		; add -ve LSB
001B26r 1  85 AF        	STA	FAC1_3		; save FAC1 mantissa3
001B28r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
001B2Ar 1  79 rr rr     	ADC	LAB_2A9B,Y		; add -ve NMSB
001B2Dr 1  85 AE        	STA	FAC1_2		; save FAC1 mantissa2
001B2Fr 1  A5 AD        	LDA	FAC1_1		; get FAC1 mantissa1
001B31r 1  79 rr rr     	ADC	LAB_2A9A,Y		; add -ve MSB
001B34r 1  85 AD        	STA	FAC1_1		; save FAC1 mantissa1
001B36r 1  E8           	INX				;
001B37r 1  B0 04        	BCS	LAB_2A18		;
001B39r 1               
001B39r 1  10 E5        	BPL	LAB_29FB		; not -ve so try again
001B3Br 1               
001B3Br 1  30 02        	BMI	LAB_2A1A		;
001B3Dr 1               
001B3Dr 1               LAB_2A18
001B3Dr 1  30 E1        	BMI	LAB_29FB		;
001B3Fr 1               
001B3Fr 1               LAB_2A1A
001B3Fr 1  8A           	TXA				;
001B40r 1  90 04        	BCC	LAB_2A21		;
001B42r 1               
001B42r 1  49 FF        	EOR	#$FF			;
001B44r 1  69 0A        	ADC	#$0A			;
001B46r 1               LAB_2A21
001B46r 1  69 2F        	ADC	#'0'-1		; add "0"-1 to result
001B48r 1  C8           	INY				; increment index ..
001B49r 1  C8           	INY				; .. to next less ..
001B4Ar 1  C8           	INY				; .. power of ten
001B4Br 1  84 95        	STY	Cvaral		; save as current var address low byte
001B4Dr 1  A4 BA        	LDY	Sendl			; get output string index
001B4Fr 1  C8           	INY				; increment output string index
001B50r 1  AA           	TAX				; copy character to X
001B51r 1  29 7F        	AND	#$7F			; mask out top bit
001B53r 1  99 EF 00     	STA	Decss,Y		; save to output string
001B56r 1  C6 A8        	DEC	numexp		; decrement # of characters before the dp
001B58r 1  D0 06        	BNE	LAB_2A3B		; branch if still characters to do
001B5Ar 1               
001B5Ar 1               					; else output the point
001B5Ar 1  A9 2E        	LDA	#$2E			; character "."
001B5Cr 1  C8           	INY				; increment output string index
001B5Dr 1  99 EF 00     	STA	Decss,Y		; save to output string
001B60r 1               LAB_2A3B
001B60r 1  84 BA        	STY	Sendl			; save output string index
001B62r 1  A4 95        	LDY	Cvaral		; get current var address low byte
001B64r 1  8A           	TXA				; get character back
001B65r 1  49 FF        	EOR	#$FF			;
001B67r 1  29 80        	AND	#$80			;
001B69r 1  AA           	TAX				;
001B6Ar 1  C0 12        	CPY	#$12			; compare index with max
001B6Cr 1  D0 B2        	BNE	LAB_29FB		; loop if not max
001B6Er 1               
001B6Er 1               					; now remove trailing zeroes
001B6Er 1  A4 BA        	LDY	Sendl			; get output string index
001B70r 1               LAB_2A4B
001B70r 1  B9 EF 00     	LDA	Decss,Y		; get character from output string
001B73r 1  88           	DEY				; decrement output string index
001B74r 1  C9 30        	CMP	#'0'			; compare with "0"
001B76r 1  F0 F8        	BEQ	LAB_2A4B		; loop until non "0" character found
001B78r 1               
001B78r 1  C9 2E        	CMP	#'.'			; compare with "."
001B7Ar 1  F0 01        	BEQ	LAB_2A58		; branch if was dp
001B7Cr 1               
001B7Cr 1               					; restore last character
001B7Cr 1  C8           	INY				; increment output string index
001B7Dr 1               LAB_2A58
001B7Dr 1  A9 2B        	LDA	#$2B			; character "+"
001B7Fr 1  A6 A9        	LDX	expcnt		; get exponent count
001B81r 1  F0 2E        	BEQ	LAB_2A8C		; if zero go set null terminator and exit
001B83r 1               
001B83r 1               					; exponent isn't zero so write exponent
001B83r 1  10 08        	BPL	LAB_2A68		; branch if exponent count +ve
001B85r 1               
001B85r 1  A9 00        	LDA	#$00			; clear A
001B87r 1  38           	SEC				; set carry for subtract
001B88r 1  E5 A9        	SBC	expcnt		; subtract exponent count adjust (convert -ve to +ve)
001B8Ar 1  AA           	TAX				; copy exponent count to X
001B8Br 1  A9 2D        	LDA	#'-'			; character "-"
001B8Dr 1               LAB_2A68
001B8Dr 1  99 F1 00     	STA	Decss+2,Y		; save to output string
001B90r 1  A9 45        	LDA	#$45			; character "E"
001B92r 1  99 F0 00     	STA	Decss+1,Y		; save exponent sign to output string
001B95r 1  8A           	TXA				; get exponent count back
001B96r 1  A2 2F        	LDX	#'0'-1		; one less than "0" character
001B98r 1  38           	SEC				; set carry for subtract
001B99r 1               LAB_2A74
001B99r 1  E8           	INX				; increment 10's character
001B9Ar 1  E9 0A        	SBC	#$0A			;.subtract 10 from exponent count
001B9Cr 1  B0 FB        	BCS	LAB_2A74		; loop while still >= 0
001B9Er 1               
001B9Er 1  69 3A        	ADC	#':'			; add character ":" ($30+$0A, result is 10 less that value)
001BA0r 1  99 F3 00     	STA	Decss+4,Y		; save to output string
001BA3r 1  8A           	TXA				; copy 10's character
001BA4r 1  99 F2 00     	STA	Decss+3,Y		; save to output string
001BA7r 1  A9 00        	LDA	#$00			; set null terminator
001BA9r 1  99 F4 00     	STA	Decss+5,Y		; save to output string
001BACr 1  F0 08        	BEQ	LAB_2A91		; go set string pointer (AY) and exit (branch always)
001BAEr 1               
001BAEr 1               					; save last character, [EOT] and exit
001BAEr 1               LAB_2A89
001BAEr 1  99 EF 00     	STA	Decss,Y		; save last character to output string
001BB1r 1               
001BB1r 1               					; set null terminator and exit
001BB1r 1               LAB_2A8C
001BB1r 1  A9 00        	LDA	#$00			; set null terminator
001BB3r 1  99 F0 00     	STA	Decss+1,Y		; save after last character
001BB6r 1               
001BB6r 1               					; set string pointer (AY) and exit
001BB6r 1               LAB_2A91
001BB6r 1  A9 F0        	LDA	#<Decssp1		; set result string low pointer
001BB8r 1  A0 00        	LDY	#>Decssp1		; set result string high pointer
001BBAr 1  60           	RTS
001BBBr 1               
001BBBr 1               ; perform power function
001BBBr 1               
001BBBr 1               LAB_POWER
001BBBr 1  F0 42        	BEQ	LAB_EXP		; go do  EXP()
001BBDr 1               
001BBDr 1  A5 B3        	LDA	FAC2_e		; get FAC2 exponent
001BBFr 1  D0 03        	BNE	LAB_2ABF		; branch if FAC2<>0
001BC1r 1               
001BC1r 1  4C rr rr     	JMP	LAB_24F3		; clear FAC1 exponent and sign and return
001BC4r 1               
001BC4r 1               LAB_2ABF
001BC4r 1  A2 9C        	LDX	#<func_l		; set destination pointer low byte
001BC6r 1  A0 00        	LDY	#>func_l		; set destination pointer high byte
001BC8r 1  20 rr rr     	JSR	LAB_2778		; pack FAC1 into (XY)
001BCBr 1  A5 B7        	LDA	FAC2_s		; get FAC2 sign (b7)
001BCDr 1  10 0F        	BPL	LAB_2AD9		; branch if FAC2>0
001BCFr 1               
001BCFr 1               					; else FAC2 is -ve and can only be raised to an
001BCFr 1               					; integer power which gives an x +j0 result
001BCFr 1  20 rr rr     	JSR	LAB_INT		; perform INT
001BD2r 1  A9 9C        	LDA	#<func_l		; set source pointer low byte
001BD4r 1  A0 00        	LDY	#>func_l		; set source pointer high byte
001BD6r 1  20 rr rr     	JSR	LAB_27F8		; compare FAC1 with (AY)
001BD9r 1  D0 03        	BNE	LAB_2AD9		; branch if FAC1 <> (AY) to allow Function Call error
001BDBr 1               					; this will leave FAC1 -ve and cause a Function Call
001BDBr 1               					; error when LOG() is called
001BDBr 1               
001BDBr 1  98           	TYA				; clear sign b7
001BDCr 1  A4 5B        	LDY	Temp3			; save mantissa 3 from INT() function as sign in Y
001BDEr 1               					; for possible later negation, b0
001BDEr 1               LAB_2AD9
001BDEr 1  20 rr rr     	JSR	LAB_279D		; save FAC1 sign and copy ABS(FAC2) to FAC1
001BE1r 1  98           	TYA				; copy sign back ..
001BE2r 1  48           	PHA				; .. and save it
001BE3r 1  20 rr rr     	JSR	LAB_LOG		; do LOG(n)
001BE6r 1  A9 9C        	LDA	#<garb_l		; set pointer low byte
001BE8r 1  A0 00        	LDY	#>garb_l		; set pointer high byte
001BEAr 1  20 rr rr     	JSR	LAB_25FB		; do convert AY, FCA1*(AY) (square the value)
001BEDr 1  20 rr rr     	JSR	LAB_EXP		; go do EXP(n)
001BF0r 1  68           	PLA				; pull sign from stack
001BF1r 1  4A           	LSR				; b0 is to be tested, shift to Cb
001BF2r 1  90 0A        	BCC	LAB_2AF9		; if no bit then exit
001BF4r 1               
001BF4r 1               					; Perform negation
001BF4r 1               ; do - FAC1
001BF4r 1               
001BF4r 1               LAB_GTHAN
001BF4r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001BF6r 1  F0 06        	BEQ	LAB_2AF9		; exit if FAC1_e = $00
001BF8r 1               
001BF8r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
001BFAr 1  49 FF        	EOR	#$FF			; complement it
001BFCr 1  85 B0        	STA	FAC1_s		; save FAC1 sign (b7)
001BFEr 1               LAB_2AF9
001BFEr 1  60           	RTS
001BFFr 1               
001BFFr 1               ; perform EXP()	(x^e)
001BFFr 1               
001BFFr 1               LAB_EXP
001BFFr 1  A9 rr        	LDA	#<LAB_2AFA		; set 1.443 pointer low byte
001C01r 1  A0 rr        	LDY	#>LAB_2AFA		; set 1.443 pointer high byte
001C03r 1  20 rr rr     	JSR	LAB_25FB		; do convert AY, FCA1*(AY)
001C06r 1  A5 B9        	LDA	FAC1_r		; get FAC1 rounding byte
001C08r 1  69 50        	ADC	#$50			; +$50/$100
001C0Ar 1  90 03        	BCC	LAB_2B2B		; skip rounding if no carry
001C0Cr 1               
001C0Cr 1  20 rr rr     	JSR	LAB_27C2		; round FAC1 (no check)
001C0Fr 1               LAB_2B2B
001C0Fr 1  85 A3        	STA	FAC2_r		; save FAC2 rounding byte
001C11r 1  20 rr rr     	JSR	LAB_27AE		; copy FAC1 to FAC2
001C14r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001C16r 1  C9 88        	CMP	#$88			; compare with EXP limit (256d)
001C18r 1  90 03        	BCC	LAB_2B39		; branch if less
001C1Ar 1               
001C1Ar 1               LAB_2B36
001C1Ar 1  20 rr rr     	JSR	LAB_2690		; handle overflow and underflow
001C1Dr 1               LAB_2B39
001C1Dr 1  20 rr rr     	JSR	LAB_INT		; perform INT
001C20r 1  A5 5B        	LDA	Temp3			; get mantissa 3 from INT() function
001C22r 1  18           	CLC				; clear carry for add
001C23r 1  69 81        	ADC	#$81			; normalise +1
001C25r 1  F0 F3        	BEQ	LAB_2B36		; if $00 go handle overflow
001C27r 1               
001C27r 1  38           	SEC				; set carry for subtract
001C28r 1  E9 01        	SBC	#$01			; now correct for exponent
001C2Ar 1  48           	PHA				; save FAC2 exponent
001C2Br 1               
001C2Br 1               					; swap FAC1 and FAC2
001C2Br 1  A2 04        	LDX	#$04			; 4 bytes to do
001C2Dr 1               LAB_2B49
001C2Dr 1  B5 B3        	LDA	FAC2_e,X		; get FAC2,X
001C2Fr 1  B4 AC        	LDY	FAC1_e,X		; get FAC1,X
001C31r 1  95 AC        	STA	FAC1_e,X		; save FAC1,X
001C33r 1  94 B3        	STY	FAC2_e,X		; save FAC2,X
001C35r 1  CA           	DEX				; decrement count/index
001C36r 1  10 F5        	BPL	LAB_2B49		; loop if not all done
001C38r 1               
001C38r 1  A5 A3        	LDA	FAC2_r		; get FAC2 rounding byte
001C3Ar 1  85 B9        	STA	FAC1_r		; save as FAC1 rounding byte
001C3Cr 1  20 rr rr     	JSR	LAB_SUBTRACT	; perform subtraction, FAC2 from FAC1
001C3Fr 1  20 rr rr     	JSR	LAB_GTHAN		; do - FAC1
001C42r 1  A9 rr        	LDA	#<LAB_2AFE		; set counter pointer low byte
001C44r 1  A0 rr        	LDY	#>LAB_2AFE		; set counter pointer high byte
001C46r 1  20 rr rr     	JSR	LAB_2B84		; go do series evaluation
001C49r 1  A9 00        	LDA	#$00			; clear A
001C4Br 1  85 B8        	STA	FAC_sc		; clear sign compare (FAC1 EOR FAC2)
001C4Dr 1  68           	PLA				;.get saved FAC2 exponent
001C4Er 1  4C rr rr     	JMP	LAB_2675		; test and adjust accumulators and return
001C51r 1               
001C51r 1               ; ^2 then series evaluation
001C51r 1               
001C51r 1               LAB_2B6E
001C51r 1  85 BA        	STA	Cptrl			; save count pointer low byte
001C53r 1  84 BB        	STY	Cptrh			; save count pointer high byte
001C55r 1  20 rr rr     	JSR	LAB_276E		; pack FAC1 into Adatal
001C58r 1  A9 A4        	LDA	#<Adatal		; set pointer low byte (Y already $00)
001C5Ar 1  20 rr rr     	JSR	LAB_25FB		; do convert AY, FCA1*(AY)
001C5Dr 1  20 rr rr     	JSR	LAB_2B88		; go do series evaluation
001C60r 1  A9 A4        	LDA	#<Adatal		; pointer to original # low byte
001C62r 1  A0 00        	LDY	#>Adatal		; pointer to original # high byte
001C64r 1  4C rr rr     	JMP	LAB_25FB		; do convert AY, FCA1*(AY) and return
001C67r 1               
001C67r 1               ; series evaluation
001C67r 1               
001C67r 1               LAB_2B84
001C67r 1  85 BA        	STA	Cptrl			; save count pointer low byte
001C69r 1  84 BB        	STY	Cptrh			; save count pointer high byte
001C6Br 1               LAB_2B88
001C6Br 1  A2 A8        	LDX	#<numexp		; set pointer low byte
001C6Dr 1  20 rr rr     	JSR	LAB_2770		; set pointer high byte and pack FAC1 into numexp
001C70r 1  B1 BA        	LDA	(Cptrl),Y		; get constants count
001C72r 1  85 B1        	STA	numcon		; save constants count
001C74r 1  A4 BA        	LDY	Cptrl			; get count pointer low byte
001C76r 1  C8           	INY				; increment it (now constants pointer)
001C77r 1  98           	TYA				; copy it
001C78r 1  D0 02        	BNE	LAB_2B97		; skip next if no overflow
001C7Ar 1               
001C7Ar 1  E6 BB        	INC	Cptrh			; else increment high byte
001C7Cr 1               LAB_2B97
001C7Cr 1  85 BA        	STA	Cptrl			; save low byte
001C7Er 1  A4 BB        	LDY	Cptrh			; get high byte
001C80r 1               LAB_2B9B
001C80r 1  20 rr rr     	JSR	LAB_25FB		; do convert AY, FCA1*(AY)
001C83r 1  A5 BA        	LDA	Cptrl			; get constants pointer low byte
001C85r 1  A4 BB        	LDY	Cptrh			; get constants pointer high byte
001C87r 1  18           	CLC				; clear carry for add
001C88r 1  69 04        	ADC	#$04			; +4 to  low pointer (4 bytes per constant)
001C8Ar 1  90 01        	BCC	LAB_2BA8		; skip next if no overflow
001C8Cr 1               
001C8Cr 1  C8           	INY				; increment high byte
001C8Dr 1               LAB_2BA8
001C8Dr 1  85 BA        	STA	Cptrl			; save pointer low byte
001C8Fr 1  84 BB        	STY	Cptrh			; save pointer high byte
001C91r 1  20 rr rr     	JSR	LAB_246C		; add (AY) to FAC1
001C94r 1  A9 A8        	LDA	#<numexp		; set pointer low byte to partial @ numexp
001C96r 1  A0 00        	LDY	#>numexp		; set pointer high byte to partial @ numexp
001C98r 1  C6 B1        	DEC	numcon		; decrement constants count
001C9Ar 1  D0 E4        	BNE	LAB_2B9B		; loop until all done
001C9Cr 1               
001C9Cr 1  60           	RTS
001C9Dr 1               
001C9Dr 1               ; RND(n), 32 bit Galoise version. make n=0 for 19th next number in sequence or n<>0
001C9Dr 1               ; to get 19th next number in sequence after seed n. This version of the PRNG uses
001C9Dr 1               ; the Galois method and a sample of 65536 bytes produced gives the following values.
001C9Dr 1               
001C9Dr 1               ; Entropy = 7.997442 bits per byte
001C9Dr 1               ; Optimum compression would reduce these 65536 bytes by 0 percent
001C9Dr 1               
001C9Dr 1               ; Chi square distribution for 65536 samples is 232.01, and
001C9Dr 1               ; randomly would exceed this value 75.00 percent of the time
001C9Dr 1               
001C9Dr 1               ; Arithmetic mean value of data bytes is 127.6724, 127.5 would be random
001C9Dr 1               ; Monte Carlo value for Pi is 3.122871269, error 0.60 percent
001C9Dr 1               ; Serial correlation coefficient is -0.000370, totally uncorrelated would be 0.0
001C9Dr 1               
001C9Dr 1               LAB_RND
001C9Dr 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001C9Fr 1  F0 07        	BEQ	NextPRN		; do next random # if zero
001CA1r 1               
001CA1r 1               					; else get seed into random number store
001CA1r 1  A2 D8        	LDX	#Rbyte4		; set PRNG pointer low byte
001CA3r 1  A0 00        	LDY	#$00			; set PRNG pointer high byte
001CA5r 1  20 rr rr     	JSR	LAB_2778		; pack FAC1 into (XY)
001CA8r 1               NextPRN
001CA8r 1  A2 AF        	LDX	#$AF			; set EOR byte
001CAAr 1  A0 13        	LDY	#$13			; do this nineteen times
001CACr 1               LoopPRN
001CACr 1  06 D9        	ASL	Rbyte1		; shift PRNG most significant byte
001CAEr 1  26 DA        	ROL	Rbyte2		; shift PRNG middle byte
001CB0r 1  26 DB        	ROL	Rbyte3		; shift PRNG least significant byte
001CB2r 1  26 D8        	ROL	Rbyte4		; shift PRNG extra byte
001CB4r 1  90 05        	BCC	Ninc1			; branch if bit 32 clear
001CB6r 1               
001CB6r 1  8A           	TXA				; set EOR byte
001CB7r 1  45 D9        	EOR	Rbyte1		; EOR PRNG extra byte
001CB9r 1  85 D9        	STA	Rbyte1		; save new PRNG extra byte
001CBBr 1               Ninc1
001CBBr 1  88           	DEY				; decrement loop count
001CBCr 1  D0 EE        	BNE	LoopPRN		; loop if not all done
001CBEr 1               
001CBEr 1  A2 02        	LDX	#$02			; three bytes to copy
001CC0r 1               CopyPRNG
001CC0r 1  B5 D9        	LDA	Rbyte1,X		; get PRNG byte
001CC2r 1  95 AD        	STA	FAC1_1,X		; save FAC1 byte
001CC4r 1  CA           	DEX
001CC5r 1  10 F9        	BPL	CopyPRNG		; loop if not complete
001CC7r 1               
001CC7r 1  A9 80        	LDA	#$80			; set the exponent
001CC9r 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
001CCBr 1               
001CCBr 1  0A           	ASL				; clear A
001CCCr 1  85 B0        	STA	FAC1_s		; save FAC1 sign
001CCEr 1               
001CCEr 1  4C rr rr     	JMP	LAB_24D5		; normalise FAC1 and return
001CD1r 1               
001CD1r 1               ; perform COS()
001CD1r 1               
001CD1r 1               LAB_COS
001CD1r 1  A9 rr        	LDA	#<LAB_2C78		; set (pi/2) pointer low byte
001CD3r 1  A0 rr        	LDY	#>LAB_2C78		; set (pi/2) pointer high byte
001CD5r 1  20 rr rr     	JSR	LAB_246C		; add (AY) to FAC1
001CD8r 1               
001CD8r 1               ; perform SIN()
001CD8r 1               
001CD8r 1               LAB_SIN
001CD8r 1  20 rr rr     	JSR	LAB_27AB		; round and copy FAC1 to FAC2
001CDBr 1  A9 rr        	LDA	#<LAB_2C7C		; set (2*pi) pointer low byte
001CDDr 1  A0 rr        	LDY	#>LAB_2C7C		; set (2*pi) pointer high byte
001CDFr 1  A6 B7        	LDX	FAC2_s		; get FAC2 sign (b7)
001CE1r 1  20 rr rr     	JSR	LAB_26C2		; divide by (AY) (X=sign)
001CE4r 1  20 rr rr     	JSR	LAB_27AB		; round and copy FAC1 to FAC2
001CE7r 1  20 rr rr     	JSR	LAB_INT		; perform INT
001CEAr 1  A9 00        	LDA	#$00			; clear byte
001CECr 1  85 B8        	STA	FAC_sc		; clear sign compare (FAC1 EOR FAC2)
001CEEr 1  20 rr rr     	JSR	LAB_SUBTRACT	; perform subtraction, FAC2 from FAC1
001CF1r 1  A9 rr        	LDA	#<LAB_2C80		; set 0.25 pointer low byte
001CF3r 1  A0 rr        	LDY	#>LAB_2C80		; set 0.25 pointer high byte
001CF5r 1  20 rr rr     	JSR	LAB_2455		; perform subtraction, (AY) from FAC1
001CF8r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
001CFAr 1  48           	PHA				; save FAC1 sign
001CFBr 1  10 0D        	BPL	LAB_2C35		; branch if +ve
001CFDr 1               
001CFDr 1               					; FAC1 sign was -ve
001CFDr 1  20 rr rr     	JSR	LAB_244E		; add 0.5 to FAC1
001D00r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
001D02r 1  30 09        	BMI	LAB_2C38		; branch if -ve
001D04r 1               
001D04r 1  A5 63        	LDA	Cflag			; get comparison evaluation flag
001D06r 1  49 FF        	EOR	#$FF			; toggle flag
001D08r 1  85 63        	STA	Cflag			; save comparison evaluation flag
001D0Ar 1               LAB_2C35
001D0Ar 1  20 rr rr     	JSR	LAB_GTHAN		; do - FAC1
001D0Dr 1               LAB_2C38
001D0Dr 1  A9 rr        	LDA	#<LAB_2C80		; set 0.25 pointer low byte
001D0Fr 1  A0 rr        	LDY	#>LAB_2C80		; set 0.25 pointer high byte
001D11r 1  20 rr rr     	JSR	LAB_246C		; add (AY) to FAC1
001D14r 1  68           	PLA				; restore FAC1 sign
001D15r 1  10 03        	BPL	LAB_2C45		; branch if was +ve
001D17r 1               
001D17r 1               					; else correct FAC1
001D17r 1  20 rr rr     	JSR	LAB_GTHAN		; do - FAC1
001D1Ar 1               LAB_2C45
001D1Ar 1  A9 rr        	LDA	#<LAB_2C84		; set pointer low byte to counter
001D1Cr 1  A0 rr        	LDY	#>LAB_2C84		; set pointer high byte to counter
001D1Er 1  4C rr rr     	JMP	LAB_2B6E		; ^2 then series evaluation and return
001D21r 1               
001D21r 1               ; perform TAN()
001D21r 1               
001D21r 1               LAB_TAN
001D21r 1  20 rr rr     	JSR	LAB_276E		; pack FAC1 into Adatal
001D24r 1  A9 00        	LDA	#$00			; clear byte
001D26r 1  85 63        	STA	Cflag			; clear comparison evaluation flag
001D28r 1  20 rr rr     	JSR	LAB_SIN		; go do SIN(n)
001D2Br 1  A2 9C        	LDX	#<func_l		; set sin(n) pointer low byte
001D2Dr 1  A0 00        	LDY	#>func_l		; set sin(n) pointer high byte
001D2Fr 1  20 rr rr     	JSR	LAB_2778		; pack FAC1 into (XY)
001D32r 1  A9 A4        	LDA	#<Adatal		; set n pointer low addr
001D34r 1  A0 00        	LDY	#>Adatal		; set n pointer high addr
001D36r 1  20 rr rr     	JSR	LAB_UFAC		; unpack memory (AY) into FAC1
001D39r 1  A9 00        	LDA	#$00			; clear byte
001D3Br 1  85 B0        	STA	FAC1_s		; clear FAC1 sign (b7)
001D3Dr 1  A5 63        	LDA	Cflag			; get comparison evaluation flag
001D3Fr 1  20 rr rr     	JSR	LAB_2C74		; save flag and go do series evaluation
001D42r 1               
001D42r 1  A9 9C        	LDA	#<func_l		; set sin(n) pointer low byte
001D44r 1  A0 00        	LDY	#>func_l		; set sin(n) pointer high byte
001D46r 1  4C rr rr     	JMP	LAB_26CA		; convert AY and do (AY)/FAC1
001D49r 1               
001D49r 1               LAB_2C74
001D49r 1  48           	PHA				; save comparison evaluation flag
001D4Ar 1  4C rr rr     	JMP	LAB_2C35		; go do series evaluation
001D4Dr 1               
001D4Dr 1               ; perform USR()
001D4Dr 1               
001D4Dr 1               LAB_USR
001D4Dr 1  20 0A 00     	JSR	Usrjmp		; call user code
001D50r 1  4C rr rr     	JMP	LAB_1BFB		; scan for ")", else do syntax error then warm start
001D53r 1               
001D53r 1               ; perform ATN()
001D53r 1               
001D53r 1               LAB_ATN
001D53r 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign (b7)
001D55r 1  48           	PHA				; save sign
001D56r 1  10 03        	BPL	LAB_2CA1		; branch if +ve
001D58r 1               
001D58r 1  20 rr rr     	JSR	LAB_GTHAN		; else do - FAC1
001D5Br 1               LAB_2CA1
001D5Br 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001D5Dr 1  48           	PHA				; push exponent
001D5Er 1  C9 81        	CMP	#$81			; compare with 1
001D60r 1  90 07        	BCC	LAB_2CAF		; branch if FAC1<1
001D62r 1               
001D62r 1  A9 rr        	LDA	#<LAB_259C		; set 1 pointer low byte
001D64r 1  A0 rr        	LDY	#>LAB_259C		; set 1 pointer high byte
001D66r 1  20 rr rr     	JSR	LAB_26CA		; convert AY and do (AY)/FAC1
001D69r 1               LAB_2CAF
001D69r 1  A9 rr        	LDA	#<LAB_2CC9		; set pointer low byte to counter
001D6Br 1  A0 rr        	LDY	#>LAB_2CC9		; set pointer high byte to counter
001D6Dr 1  20 rr rr     	JSR	LAB_2B6E		; ^2 then series evaluation
001D70r 1  68           	PLA				; restore old FAC1 exponent
001D71r 1  C9 81        	CMP	#$81			; compare with 1
001D73r 1  90 07        	BCC	LAB_2CC2		; branch if FAC1<1
001D75r 1               
001D75r 1  A9 rr        	LDA	#<LAB_2C78		; set (pi/2) pointer low byte
001D77r 1  A0 rr        	LDY	#>LAB_2C78		; set (pi/2) pointer high byte
001D79r 1  20 rr rr     	JSR	LAB_2455		; perform subtraction, (AY) from FAC1
001D7Cr 1               LAB_2CC2
001D7Cr 1  68           	PLA				; restore FAC1 sign
001D7Dr 1  10 16        	BPL	LAB_2D04		; exit if was +ve
001D7Fr 1               
001D7Fr 1  4C rr rr     	JMP	LAB_GTHAN		; else do - FAC1 and return
001D82r 1               
001D82r 1               ; perform BITSET
001D82r 1               
001D82r 1               LAB_BITSET
001D82r 1  20 rr rr     	JSR	LAB_GADB		; get two parameters for POKE or WAIT
001D85r 1  E0 08        	CPX	#$08			; only 0 to 7 are allowed
001D87r 1  B0 20        	BCS	FCError		; branch if > 7
001D89r 1               
001D89r 1  A9 00        	LDA	#$00			; clear A
001D8Br 1  38           	SEC				; set the carry
001D8Cr 1               S_Bits
001D8Cr 1  2A           	ROL				; shift bit
001D8Dr 1  CA           	DEX				; decrement bit number
001D8Er 1  10 FC        	BPL	S_Bits		; loop if still +ve
001D90r 1               
001D90r 1  E8           	INX				; make X = $00
001D91r 1  01 11        	ORA	(Itempl,X)		; or with byte via temporary integer (addr)
001D93r 1  81 11        	STA	(Itempl,X)		; save byte via temporary integer (addr)
001D95r 1               LAB_2D04
001D95r 1  60           	RTS
001D96r 1               
001D96r 1               ; perform BITCLR
001D96r 1               
001D96r 1               LAB_BITCLR
001D96r 1  20 rr rr     	JSR	LAB_GADB		; get two parameters for POKE or WAIT
001D99r 1  E0 08        	CPX	#$08			; only 0 to 7 are allowed
001D9Br 1  B0 0C        	BCS	FCError		; branch if > 7
001D9Dr 1               
001D9Dr 1  A9 FF        	LDA	#$FF			; set A
001D9Fr 1               S_Bitc
001D9Fr 1  2A           	ROL				; shift bit
001DA0r 1  CA           	DEX				; decrement bit number
001DA1r 1  10 FC        	BPL	S_Bitc		; loop if still +ve
001DA3r 1               
001DA3r 1  E8           	INX				; make X = $00
001DA4r 1  21 11        	AND	(Itempl,X)		; and with byte via temporary integer (addr)
001DA6r 1  81 11        	STA	(Itempl,X)		; save byte via temporary integer (addr)
001DA8r 1  60           	RTS
001DA9r 1               
001DA9r 1               FCError
001DA9r 1  4C rr rr     	JMP	LAB_FCER		; do function call error then warm start
001DACr 1               
001DACr 1               ; perform BITTST()
001DACr 1               
001DACr 1               LAB_BTST
001DACr 1  20 BC 00     	JSR	LAB_IGBY		; increment BASIC pointer
001DAFr 1  20 rr rr     	JSR	LAB_GADB		; get two parameters for POKE or WAIT
001DB2r 1  E0 08        	CPX	#$08			; only 0 to 7 are allowed
001DB4r 1  B0 F3        	BCS	FCError		; branch if > 7
001DB6r 1               
001DB6r 1  20 C2 00     	JSR	LAB_GBYT		; get next BASIC byte
001DB9r 1  C9 29        	CMP	#')'			; is next character ")"
001DBBr 1  F0 03        	BEQ	TST_OK		; if ")" go do rest of function
001DBDr 1               
001DBDr 1  4C rr rr     	JMP	LAB_SNER		; do syntax error then warm start
001DC0r 1               
001DC0r 1               TST_OK
001DC0r 1  20 BC 00     	JSR	LAB_IGBY		; update BASIC execute pointer (to character past ")")
001DC3r 1  A9 00        	LDA	#$00			; clear A
001DC5r 1  38           	SEC				; set the carry
001DC6r 1               T_Bits
001DC6r 1  2A           	ROL				; shift bit
001DC7r 1  CA           	DEX				; decrement bit number
001DC8r 1  10 FC        	BPL	T_Bits		; loop if still +ve
001DCAr 1               
001DCAr 1  E8           	INX				; make X = $00
001DCBr 1  21 11        	AND	(Itempl,X)		; AND with byte via temporary integer (addr)
001DCDr 1  F0 02        	BEQ	LAB_NOTT		; branch if zero (already correct)
001DCFr 1               
001DCFr 1  A9 FF        	LDA	#$FF			; set for -1 result
001DD1r 1               LAB_NOTT
001DD1r 1  4C rr rr     	JMP	LAB_27DB		; go do SGN tail
001DD4r 1               
001DD4r 1               ; perform BIN$()
001DD4r 1               
001DD4r 1               LAB_BINS
001DD4r 1  E0 19        	CPX	#$19			; max + 1
001DD6r 1  B0 48        	BCS	BinFErr		; exit if too big ( > or = )
001DD8r 1               
001DD8r 1  86 78        	STX	TempB			; save # of characters ($00 = leading zero remove)
001DDAr 1  A9 18        	LDA	#$18			; need A byte long space
001DDCr 1  20 rr rr     	JSR	LAB_MSSP		; make string space A bytes long
001DDFr 1  A0 17        	LDY	#$17			; set index
001DE1r 1  A2 18        	LDX	#$18			; character count
001DE3r 1               NextB1
001DE3r 1  46 11        	LSR	nums_1		; shift highest byte
001DE5r 1  66 12        	ROR	nums_2		; shift middle byte
001DE7r 1  66 13        	ROR	nums_3		; shift lowest byte bit 0 to carry
001DE9r 1  8A           	TXA				; load with "0"/2
001DEAr 1  2A           	ROL				; shift in carry
001DEBr 1  91 AD        	STA	(str_pl),Y		; save to temp string + index
001DEDr 1  88           	DEY				; decrement index
001DEEr 1  10 F3        	BPL	NextB1		; loop if not done
001DF0r 1               
001DF0r 1  A5 78        	LDA	TempB			; get # of characters
001DF2r 1  F0 0A        	BEQ	EndBHS		; branch if truncate
001DF4r 1               
001DF4r 1  AA           	TAX				; copy length to X
001DF5r 1  38           	SEC				; set carry for add !
001DF6r 1  49 FF        	EOR	#$FF			; 1's complement
001DF8r 1  69 18        	ADC	#$18			; add 24d
001DFAr 1  F0 1C        	BEQ	GoPr2			; if zero print whole string
001DFCr 1               
001DFCr 1  D0 0F        	BNE	GoPr1			; else go make output string
001DFEr 1               
001DFEr 1               ; this is the exit code and is also used by HEX$()
001DFEr 1               ; truncate string to remove leading "0"s
001DFEr 1               
001DFEr 1               EndBHS
001DFEr 1  A8           	TAY				; clear index (A=0, X=length here)
001DFFr 1               NextB2
001DFFr 1  B1 AD        	LDA	(str_pl),Y		; get character from string
001E01r 1  C9 30        	CMP	#'0'			; compare with "0"
001E03r 1  D0 07        	BNE	GoPr			; if not "0" then go print string from here
001E05r 1               
001E05r 1  CA           	DEX				; decrement character count
001E06r 1  F0 03        	BEQ	GoPr3			; if zero then end of string so go print it
001E08r 1               
001E08r 1  C8           	INY				; else increment index
001E09r 1  10 F4        	BPL	NextB2		; loop always
001E0Br 1               
001E0Br 1               ; make fixed length output string - ignore overflows!
001E0Br 1               
001E0Br 1               GoPr3
001E0Br 1  E8           	INX				; need at least 1 character
001E0Cr 1               GoPr
001E0Cr 1  98           	TYA				; copy result
001E0Dr 1               GoPr1
001E0Dr 1  18           	CLC				; clear carry for add
001E0Er 1  65 AD        	ADC	str_pl		; add low address
001E10r 1  85 AD        	STA	str_pl		; save low address
001E12r 1  A9 00        	LDA	#$00			; do high byte
001E14r 1  65 AE        	ADC	str_ph		; add high address
001E16r 1  85 AE        	STA	str_ph		; save high address
001E18r 1               GoPr2
001E18r 1  86 AC        	STX	str_ln		; X holds string length
001E1Ar 1  20 BC 00     	JSR	LAB_IGBY		; update BASIC execute pointer (to character past ")")
001E1Dr 1  4C rr rr     	JMP	LAB_RTST		; check for space on descriptor stack then put address
001E20r 1               					; and length on descriptor stack and update stack pointers
001E20r 1               
001E20r 1               BinFErr
001E20r 1  4C rr rr     	JMP	LAB_FCER		; do function call error then warm start
001E23r 1               
001E23r 1               ; perform HEX$()
001E23r 1               
001E23r 1               LAB_HEXS
001E23r 1  E0 07        	CPX	#$07			; max + 1
001E25r 1  B0 F9        	BCS	BinFErr		; exit if too big ( > or = )
001E27r 1               
001E27r 1  86 78        	STX	TempB			; save # of characters
001E29r 1               
001E29r 1  A9 06        	LDA	#$06			; need 6 bytes for string
001E2Br 1  20 rr rr     	JSR	LAB_MSSP		; make string space A bytes long
001E2Er 1  A0 05        	LDY	#$05			; set string index
001E30r 1               
001E30r 1  F8           	SED				; need decimal mode for nibble convert
001E31r 1  A5 13        	LDA	nums_3		; get lowest byte
001E33r 1  20 rr rr     	JSR	LAB_A2HX		; convert A to ASCII hex byte and output
001E36r 1  A5 12        	LDA	nums_2		; get middle byte
001E38r 1  20 rr rr     	JSR	LAB_A2HX		; convert A to ASCII hex byte and output
001E3Br 1  A5 11        	LDA	nums_1		; get highest byte
001E3Dr 1  20 rr rr     	JSR	LAB_A2HX		; convert A to ASCII hex byte and output
001E40r 1  D8           	CLD				; back to binary
001E41r 1               
001E41r 1  A2 06        	LDX	#$06			; character count
001E43r 1  A5 78        	LDA	TempB			; get # of characters
001E45r 1  F0 B7        	BEQ	EndBHS		; branch if truncate
001E47r 1               
001E47r 1  AA           	TAX				; copy length to X
001E48r 1  38           	SEC				; set carry for add !
001E49r 1  49 FF        	EOR	#$FF			; 1's complement
001E4Br 1  69 06        	ADC	#$06			; add 6d
001E4Dr 1  F0 C9        	BEQ	GoPr2			; if zero print whole string
001E4Fr 1               
001E4Fr 1  D0 BC        	BNE	GoPr1			; else go make output string (branch always)
001E51r 1               
001E51r 1               ; convert A to ASCII hex byte and output .. note set decimal mode before calling
001E51r 1               
001E51r 1               LAB_A2HX
001E51r 1  AA           	TAX				; save byte
001E52r 1  29 0F        	AND	#$0F			; mask off top bits
001E54r 1  20 rr rr     	JSR	LAB_AL2X		; convert low nibble to ASCII and output
001E57r 1  8A           	TXA				; get byte back
001E58r 1  4A           	LSR				; /2	shift high nibble to low nibble
001E59r 1  4A           	LSR				; /4
001E5Ar 1  4A           	LSR				; /8
001E5Br 1  4A           	LSR				; /16
001E5Cr 1               LAB_AL2X
001E5Cr 1  C9 0A        	CMP	#$0A			; set carry for +1 if >9
001E5Er 1  69 30        	ADC	#'0'			; add ASCII "0"
001E60r 1  91 AD        	STA	(str_pl),Y		; save to temp string
001E62r 1  88           	DEY				; decrement counter
001E63r 1  60           	RTS
001E64r 1               
001E64r 1               LAB_NLTO
001E64r 1  85 AC        	STA	FAC1_e		; save FAC1 exponent
001E66r 1  A9 00        	LDA	#$00			; clear sign compare
001E68r 1               LAB_MLTE
001E68r 1  85 B8        	STA	FAC_sc		; save sign compare (FAC1 EOR FAC2)
001E6Ar 1  8A           	TXA				; restore character
001E6Br 1  20 rr rr     	JSR	LAB_2912		; evaluate new ASCII digit
001E6Er 1               
001E6Er 1               ; gets here if the first character was "$" for hex
001E6Er 1               ; get hex number
001E6Er 1               
001E6Er 1               LAB_CHEX
001E6Er 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
001E71r 1  90 0A        	BCC	LAB_ISHN		; branch if numeric character
001E73r 1               
001E73r 1  09 20        	ORA	#$20			; case convert, allow "A" to "F" and "a" to "f"
001E75r 1  E9 61        	SBC	#'a'			; subtract "a" (carry set here)
001E77r 1  C9 06        	CMP	#$06			; compare normalised with $06 (max+1)
001E79r 1  B0 2A        	BCS	LAB_EXCH		; exit if >"f" or <"0"
001E7Br 1               
001E7Br 1  69 0A        	ADC	#$0A			; convert to nibble
001E7Dr 1               LAB_ISHN
001E7Dr 1  29 0F        	AND	#$0F			; convert to binary
001E7Fr 1  AA           	TAX				; save nibble
001E80r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001E82r 1  F0 E4        	BEQ	LAB_MLTE		; skip multiply if zero
001E84r 1               
001E84r 1  69 04        	ADC	#$04			; add four to exponent (*16 - carry clear here)
001E86r 1  90 DC        	BCC	LAB_NLTO		; if no overflow do evaluate digit
001E88r 1               
001E88r 1               LAB_MLTO
001E88r 1  4C rr rr     	JMP	LAB_2564		; do overflow error and warm start
001E8Br 1               
001E8Br 1               LAB_NXCH
001E8Br 1  AA           	TAX				; save bit
001E8Cr 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001E8Er 1  F0 06        	BEQ	LAB_MLBT		; skip multiply if zero
001E90r 1               
001E90r 1  E6 AC        	INC	FAC1_e		; increment FAC1 exponent (*2)
001E92r 1  F0 F4        	BEQ	LAB_MLTO		; do overflow error if = $00
001E94r 1               
001E94r 1  A9 00        	LDA	#$00			; clear sign compare
001E96r 1               LAB_MLBT
001E96r 1  85 B8        	STA	FAC_sc		; save sign compare (FAC1 EOR FAC2)
001E98r 1  8A           	TXA				; restore bit
001E99r 1  20 rr rr     	JSR	LAB_2912		; evaluate new ASCII digit
001E9Cr 1               
001E9Cr 1               ; gets here if the first character was  "%" for binary
001E9Cr 1               ; get binary number
001E9Cr 1               
001E9Cr 1               LAB_CBIN
001E9Cr 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
001E9Fr 1  49 30        	EOR	#'0'			; convert "0" to 0 etc.
001EA1r 1  C9 02        	CMP	#$02			; compare with max+1
001EA3r 1  90 E6        	BCC	LAB_NXCH		; branch exit if < 2
001EA5r 1               
001EA5r 1               LAB_EXCH
001EA5r 1  4C rr rr     	JMP	LAB_28F6		; evaluate -ve flag and return
001EA8r 1               
001EA8r 1               ; ctrl-c check routine. includes limited "life" byte save for INGET routine
001EA8r 1               ; now also the code that checks to see if an interrupt has occurred
001EA8r 1               
001EA8r 1               CTRLC
001EA8r 1  AD 00 02     	LDA	ccflag		; get [CTRL-C] check flag
001EABr 1  D0 18        	BNE	LAB_FBA2		; exit if inhibited
001EADr 1               
001EADr 1  20 rr rr     	JSR	V_INPT		; scan input device
001EB0r 1  90 0B        	BCC	LAB_FBA0		; exit if buffer empty
001EB2r 1               
001EB2r 1  8D 01 02     	STA	ccbyte		; save received byte
001EB5r 1  A2 20        	LDX	#$20			; "life" timer for bytes
001EB7r 1  8E 02 02     	STX	ccnull		; set countdown
001EBAr 1  4C rr rr     	JMP	LAB_1636		; return to BASIC
001EBDr 1               
001EBDr 1               LAB_FBA0
001EBDr 1  AE 02 02     	LDX	ccnull		; get countdown byte
001EC0r 1  F0 03        	BEQ	LAB_FBA2		; exit if finished
001EC2r 1               
001EC2r 1  CE 02 02     	DEC	ccnull		; else decrement countdown
001EC5r 1               LAB_FBA2
001EC5r 1  A2 DC        	LDX	#NmiBase		; set pointer to NMI values
001EC7r 1  20 rr rr     	JSR	LAB_CKIN		; go check interrupt
001ECAr 1  A2 DF        	LDX	#IrqBase		; set pointer to IRQ values
001ECCr 1  20 rr rr     	JSR	LAB_CKIN		; go check interrupt
001ECFr 1               LAB_CRTS
001ECFr 1  60           	RTS
001ED0r 1               
001ED0r 1               ; check whichever interrupt is indexed by X
001ED0r 1               
001ED0r 1               LAB_CKIN
001ED0r 1  B5 00        	LDA	PLUS_0,X		; get interrupt flag byte
001ED2r 1  10 FB        	BPL	LAB_CRTS		; branch if interrupt not enabled
001ED4r 1               
001ED4r 1               ; we disable the interrupt here and make two new commands RETIRQ and RETNMI to
001ED4r 1               ; automatically enable the interrupt when we exit
001ED4r 1               
001ED4r 1  0A           	ASL				; move happened bit to setup bit
001ED5r 1  29 40        	AND	#$40			; mask happened bits
001ED7r 1  F0 F6        	BEQ	LAB_CRTS		; if no interrupt then exit
001ED9r 1               
001ED9r 1  95 00        	STA	PLUS_0,X		; save interrupt flag byte
001EDBr 1               
001EDBr 1  8A           	TXA				; copy index ..
001EDCr 1  A8           	TAY				; .. to Y
001EDDr 1               
001EDDr 1  68           	PLA				; dump return address low byte, call from CTRL-C
001EDEr 1  68           	PLA				; dump return address high byte
001EDFr 1               
001EDFr 1  A9 05        	LDA	#$05			; need 5 bytes for GOSUB
001EE1r 1  20 rr rr     	JSR	LAB_1212		; check room on stack for A bytes
001EE4r 1  A5 C4        	LDA	Bpntrh		; get BASIC execute pointer high byte
001EE6r 1  48           	PHA				; push on stack
001EE7r 1  A5 C3        	LDA	Bpntrl		; get BASIC execute pointer low byte
001EE9r 1  48           	PHA				; push on stack
001EEAr 1  A5 88        	LDA	Clineh		; get current line high byte
001EECr 1  48           	PHA				; push on stack
001EEDr 1  A5 87        	LDA	Clinel		; get current line low byte
001EEFr 1  48           	PHA				; push on stack
001EF0r 1  A9 8D        	LDA	#TK_GOSUB		; token for GOSUB
001EF2r 1  48           	PHA				; push on stack
001EF3r 1               
001EF3r 1  B9 01 00     	LDA	PLUS_1,Y		; get interrupt code pointer low byte
001EF6r 1  85 C3        	STA	Bpntrl		; save as BASIC execute pointer low byte
001EF8r 1  B9 02 00     	LDA	PLUS_2,Y		; get interrupt code pointer high byte
001EFBr 1  85 C4        	STA	Bpntrh		; save as BASIC execute pointer high byte
001EFDr 1               
001EFDr 1  4C rr rr     	JMP	LAB_15C2		; go do interpreter inner loop
001F00r 1               					; can't RTS, we used the stack! the RTS from the ctrl-c
001F00r 1               					; check will be taken when the RETIRQ/RETNMI/RETURN is
001F00r 1               					; executed at the end of the subroutine
001F00r 1               
001F00r 1               ; get byte from input device, no waiting
001F00r 1               ; returns with carry set if byte in A
001F00r 1               
001F00r 1               INGET
001F00r 1  20 rr rr     	JSR	V_INPT		; call scan input device
001F03r 1  B0 09        	BCS	LAB_FB95		; if byte go reset timer
001F05r 1               
001F05r 1  AD 02 02     	LDA	ccnull		; get countdown
001F08r 1  F0 09        	BEQ	LAB_FB96		; exit if empty
001F0Ar 1               
001F0Ar 1  AD 01 02     	LDA	ccbyte		; get last received byte
001F0Dr 1  38           	SEC				; flag we got a byte
001F0Er 1               LAB_FB95
001F0Er 1  A2 00        	LDX	#$00			; clear X
001F10r 1  8E 02 02     	STX	ccnull		; clear timer because we got a byte
001F13r 1               LAB_FB96
001F13r 1  60           	RTS
001F14r 1               
001F14r 1               ; these routines only enable the interrupts if the set-up flag is set
001F14r 1               ; if not they have no effect
001F14r 1               
001F14r 1               ; perform IRQ {ON|OFF|CLEAR}
001F14r 1               
001F14r 1               LAB_IRQ
001F14r 1  A2 DF        	LDX	#IrqBase		; set pointer to IRQ values
001F16r 1  2C           	.byte	$2C			; make next line BIT abs.
001F17r 1               
001F17r 1               ; perform NMI {ON|OFF|CLEAR}
001F17r 1               
001F17r 1               LAB_NMI
001F17r 1  A2 DC        	LDX	#NmiBase		; set pointer to NMI values
001F19r 1  C9 93        	CMP	#TK_ON		; compare with token for ON
001F1Br 1  F0 11        	BEQ	LAB_INON		; go turn on interrupt
001F1Dr 1               
001F1Dr 1  C9 B6        	CMP	#TK_OFF		; compare with token for OFF
001F1Fr 1  F0 07        	BEQ	LAB_IOFF		; go turn off interrupt
001F21r 1               
001F21r 1  49 A2        	EOR	#TK_CLEAR		; compare with token for CLEAR, A = $00 if = TK_CLEAR
001F23r 1  F0 0E        	BEQ	LAB_INEX		; go clear interrupt flags and return
001F25r 1               
001F25r 1  4C rr rr     	JMP	LAB_SNER		; do syntax error then warm start
001F28r 1               
001F28r 1               LAB_IOFF
001F28r 1  A9 7F        	LDA	#$7F			; clear A
001F2Ar 1  35 00        	AND	PLUS_0,X		; AND with interrupt setup flag
001F2Cr 1  10 05        	BPL	LAB_INEX		; go clear interrupt enabled flag and return
001F2Er 1               
001F2Er 1               LAB_INON
001F2Er 1  B5 00        	LDA	PLUS_0,X		; get interrupt setup flag
001F30r 1  0A           	ASL				; Shift bit to enabled flag
001F31r 1  15 00        	ORA	PLUS_0,X		; OR with flag byte
001F33r 1               LAB_INEX
001F33r 1  95 00        	STA	PLUS_0,X		; save interrupt flag byte
001F35r 1  4C BC 00     	JMP	LAB_IGBY		; update BASIC execute pointer and return
001F38r 1               
001F38r 1               ; these routines set up the pointers and flags for the interrupt routines
001F38r 1               ; note that the interrupts are also enabled by these commands
001F38r 1               
001F38r 1               ; perform ON IRQ
001F38r 1               
001F38r 1               LAB_SIRQ
001F38r 1  58           	CLI				; enable interrupts
001F39r 1  A2 DF        	LDX	#IrqBase		; set pointer to IRQ values
001F3Br 1  2C           	.byte	$2C			; make next line BIT abs.
001F3Cr 1               
001F3Cr 1               ; perform ON NMI
001F3Cr 1               
001F3Cr 1               LAB_SNMI
001F3Cr 1  A2 DC        	LDX	#NmiBase		; set pointer to NMI values
001F3Er 1               
001F3Er 1  86 78        	STX	TempB			; save interrupt pointer
001F40r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory (past token)
001F43r 1  20 rr rr     	JSR	LAB_GFPN		; get fixed-point number into temp integer
001F46r 1  A5 79        	LDA	Smeml			; get start of mem low byte
001F48r 1  A6 7A        	LDX	Smemh			; get start of mem high byte
001F4Ar 1  20 rr rr     	JSR	LAB_SHLN		; search Basic for temp integer line number from AX
001F4Dr 1  B0 03        	BCS	LAB_LFND		; if carry set go set-up interrupt
001F4Fr 1               
001F4Fr 1  4C rr rr     	JMP	LAB_16F7		; else go do "Undefined statement" error and warm start
001F52r 1               
001F52r 1               LAB_LFND
001F52r 1  A6 78        	LDX	TempB			; get interrupt pointer
001F54r 1  A5 AA        	LDA	Baslnl		; get pointer low byte
001F56r 1  E9 01        	SBC	#$01			; -1 (carry already set for subtract)
001F58r 1  95 01        	STA	PLUS_1,X		; save as interrupt pointer low byte
001F5Ar 1  A5 AB        	LDA	Baslnh		; get pointer high byte
001F5Cr 1  E9 00        	SBC	#$00			; subtract carry
001F5Er 1  95 02        	STA	PLUS_2,X		; save as interrupt pointer high byte
001F60r 1               
001F60r 1  A9 C0        	LDA	#$C0			; set interrupt enabled/setup bits
001F62r 1  95 00        	STA	PLUS_0,X		; set interrupt flags
001F64r 1               LAB_IRTS
001F64r 1  60           	RTS
001F65r 1               
001F65r 1               ; return from IRQ service, restores the enabled flag.
001F65r 1               
001F65r 1               ; perform RETIRQ
001F65r 1               
001F65r 1               LAB_RETIRQ
001F65r 1  D0 FD        	BNE	LAB_IRTS		; exit if following token (to allow syntax error)
001F67r 1               
001F67r 1  A5 DF        	LDA	IrqBase		; get interrupt flags
001F69r 1  0A           	ASL				; copy setup to enabled (b7)
001F6Ar 1  05 DF        	ORA	IrqBase		; OR in setup flag
001F6Cr 1  85 DF        	STA	IrqBase		; save enabled flag
001F6Er 1  4C rr rr     	JMP	LAB_16E8		; go do rest of RETURN
001F71r 1               
001F71r 1               ; return from NMI service, restores the enabled flag.
001F71r 1               
001F71r 1               ; perform RETNMI
001F71r 1               
001F71r 1               LAB_RETNMI
001F71r 1  D0 F1        	BNE	LAB_IRTS		; exit if following token (to allow syntax error)
001F73r 1               
001F73r 1  A5 DC        	LDA	NmiBase		; get set-up flag
001F75r 1  0A           	ASL				; copy setup to enabled (b7)
001F76r 1  05 DC        	ORA	NmiBase		; OR in setup flag
001F78r 1  85 DC        	STA	NmiBase		; save enabled flag
001F7Ar 1  4C rr rr     	JMP	LAB_16E8		; go do rest of RETURN
001F7Dr 1               
001F7Dr 1               ; MAX() MIN() pre process
001F7Dr 1               
001F7Dr 1               LAB_MMPP
001F7Dr 1  20 rr rr     	JSR	LAB_EVEZ		; process expression
001F80r 1  4C rr rr     	JMP	LAB_CTNM		; check if source is numeric, else do type mismatch
001F83r 1               
001F83r 1               ; perform MAX()
001F83r 1               
001F83r 1               LAB_MAX
001F83r 1  20 rr rr     	JSR	LAB_PHFA		; push FAC1, evaluate expression,
001F86r 1               					; pull FAC2 and compare with FAC1
001F86r 1  10 FB        	BPL	LAB_MAX		; branch if no swap to do
001F88r 1               
001F88r 1  A5 B4        	LDA	FAC2_1		; get FAC2 mantissa1
001F8Ar 1  09 80        	ORA	#$80			; set top bit (clear sign from compare)
001F8Cr 1  85 B4        	STA	FAC2_1		; save FAC2 mantissa1
001F8Er 1  20 rr rr     	JSR	LAB_279B		; copy FAC2 to FAC1
001F91r 1  F0 F0        	BEQ	LAB_MAX		; go do next (branch always)
001F93r 1               
001F93r 1               ; perform MIN()
001F93r 1               
001F93r 1               LAB_MIN
001F93r 1  20 rr rr     	JSR	LAB_PHFA		; push FAC1, evaluate expression,
001F96r 1               					; pull FAC2 and compare with FAC1
001F96r 1  30 FB        	BMI	LAB_MIN		; branch if no swap to do
001F98r 1               
001F98r 1  F0 F9        	BEQ	LAB_MIN		; branch if no swap to do
001F9Ar 1               
001F9Ar 1  A5 B4        	LDA	FAC2_1		; get FAC2 mantissa1
001F9Cr 1  09 80        	ORA	#$80			; set top bit (clear sign from compare)
001F9Er 1  85 B4        	STA	FAC2_1		; save FAC2 mantissa1
001FA0r 1  20 rr rr     	JSR	LAB_279B		; copy FAC2 to FAC1
001FA3r 1  F0 EE        	BEQ	LAB_MIN		; go do next (branch always)
001FA5r 1               
001FA5r 1               ; exit routine. don't bother returning to the loop code
001FA5r 1               ; check for correct exit, else so syntax error
001FA5r 1               
001FA5r 1               LAB_MMEC
001FA5r 1  C9 29        	CMP	#')'			; is it end of function?
001FA7r 1  D0 05        	BNE	LAB_MMSE		; if not do MAX MIN syntax error
001FA9r 1               
001FA9r 1  68           	PLA				; dump return address low byte
001FAAr 1  68           	PLA				; dump return address high byte
001FABr 1  4C BC 00     	JMP	LAB_IGBY		; update BASIC execute pointer (to chr past ")")
001FAEr 1               
001FAEr 1               LAB_MMSE
001FAEr 1  4C rr rr     	JMP	LAB_SNER		; do syntax error then warm start
001FB1r 1               
001FB1r 1               ; check for next, evaluate and return or exit
001FB1r 1               ; this is the routine that does most of the work
001FB1r 1               
001FB1r 1               LAB_PHFA
001FB1r 1  20 C2 00     	JSR	LAB_GBYT		; get next BASIC byte
001FB4r 1  C9 2C        	CMP	#','			; is there more ?
001FB6r 1  D0 ED        	BNE	LAB_MMEC		; if not go do end check
001FB8r 1               
001FB8r 1               					; push FAC1
001FB8r 1  20 rr rr     	JSR	LAB_27BA		; round FAC1
001FBBr 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign
001FBDr 1  09 7F        	ORA	#$7F			; set all non sign bits
001FBFr 1  25 AD        	AND	FAC1_1		; AND FAC1 mantissa1 (AND in sign bit)
001FC1r 1  48           	PHA				; push on stack
001FC2r 1  A5 AE        	LDA	FAC1_2		; get FAC1 mantissa2
001FC4r 1  48           	PHA				; push on stack
001FC5r 1  A5 AF        	LDA	FAC1_3		; get FAC1 mantissa3
001FC7r 1  48           	PHA				; push on stack
001FC8r 1  A5 AC        	LDA	FAC1_e		; get FAC1 exponent
001FCAr 1  48           	PHA				; push on stack
001FCBr 1               
001FCBr 1  20 BC 00     	JSR	LAB_IGBY		; scan and get next BASIC byte (after ",")
001FCEr 1  20 rr rr     	JSR	LAB_EVNM		; evaluate expression and check is numeric,
001FD1r 1               					; else do type mismatch
001FD1r 1               
001FD1r 1               					; pop FAC2 (MAX/MIN expression so far)
001FD1r 1  68           	PLA				; pop exponent
001FD2r 1  85 B3        	STA	FAC2_e		; save FAC2 exponent
001FD4r 1  68           	PLA				; pop mantissa3
001FD5r 1  85 B6        	STA	FAC2_3		; save FAC2 mantissa3
001FD7r 1  68           	PLA				; pop mantissa1
001FD8r 1  85 B5        	STA	FAC2_2		; save FAC2 mantissa2
001FDAr 1  68           	PLA				; pop sign/mantissa1
001FDBr 1  85 B4        	STA	FAC2_1		; save FAC2 sign/mantissa1
001FDDr 1  85 B7        	STA	FAC2_s		; save FAC2 sign
001FDFr 1               
001FDFr 1               					; compare FAC1 with (packed) FAC2
001FDFr 1  A9 B3        	LDA	#<FAC2_e		; set pointer low byte to FAC2
001FE1r 1  A0 00        	LDY	#>FAC2_e		; set pointer high byte to FAC2
001FE3r 1  4C rr rr     	JMP	LAB_27F8		; compare FAC1 with FAC2 (AY) and return
001FE6r 1               					; returns A=$00 if FAC1 = (AY)
001FE6r 1               					; returns A=$01 if FAC1 > (AY)
001FE6r 1               					; returns A=$FF if FAC1 < (AY)
001FE6r 1               
001FE6r 1               ; perform WIDTH
001FE6r 1               
001FE6r 1               LAB_WDTH
001FE6r 1  C9 2C        	CMP	#','			; is next byte ","
001FE8r 1  F0 1B        	BEQ	LAB_TBSZ		; if so do tab size
001FEAr 1               
001FEAr 1  20 rr rr     	JSR	LAB_GTBY		; get byte parameter
001FEDr 1  8A           	TXA				; copy width to A
001FEEr 1  F0 0A        	BEQ	LAB_NSTT		; branch if set for infinite line
001FF0r 1               
001FF0r 1  E0 10        	CPX	#$10			; else make min width = 16d
001FF2r 1  90 45        	BCC	TabErr		; if less do function call error and exit
001FF4r 1               
001FF4r 1               ; this next compare ensures that we can't exit WIDTH via an error leaving the
001FF4r 1               ; tab size greater than the line length.
001FF4r 1               
001FF4r 1  E4 64        	CPX	TabSiz		; compare with tab size
001FF6r 1  B0 02        	BCS	LAB_NSTT		; branch if >= tab size
001FF8r 1               
001FF8r 1  86 64        	STX	TabSiz		; else make tab size = terminal width
001FFAr 1               LAB_NSTT
001FFAr 1  86 0F        	STX	TWidth		; set the terminal width
001FFCr 1  20 C2 00     	JSR	LAB_GBYT		; get BASIC byte back
001FFFr 1  F0 1A        	BEQ	WExit			; exit if no following
002001r 1               
002001r 1  C9 2C        	CMP	#','			; else is it ","
002003r 1  D0 A9        	BNE	LAB_MMSE		; if not do syntax error
002005r 1               
002005r 1               LAB_TBSZ
002005r 1  20 rr rr     	JSR	LAB_SGBY		; scan and get byte parameter
002008r 1  8A           	TXA				; copy TAB size
002009r 1  30 2E        	BMI	TabErr		; if >127 do function call error and exit
00200Br 1               
00200Br 1  E0 01        	CPX	#$01			; compare with min-1
00200Dr 1  90 2A        	BCC	TabErr		; if <=1 do function call error and exit
00200Fr 1               
00200Fr 1  A5 0F        	LDA	TWidth		; set flags for width
002011r 1  F0 06        	BEQ	LAB_SVTB		; skip check if infinite line
002013r 1               
002013r 1  E4 0F        	CPX	TWidth		; compare TAB with width
002015r 1  F0 02        	BEQ	LAB_SVTB		; ok if =
002017r 1               
002017r 1  B0 20        	BCS	TabErr		; branch if too big
002019r 1               
002019r 1               LAB_SVTB
002019r 1  86 64        	STX	TabSiz		; save TAB size
00201Br 1               
00201Br 1               ; calculate tab column limit from TAB size. The Iclim is set to the last tab
00201Br 1               ; position on a line that still has at least one whole tab width between it
00201Br 1               ; and the end of the line.
00201Br 1               
00201Br 1               WExit
00201Br 1  A5 0F        	LDA	TWidth		; get width
00201Dr 1  F0 06        	BEQ	LAB_SULP		; branch if infinite line
00201Fr 1               
00201Fr 1  C5 64        	CMP	TabSiz		; compare with tab size
002021r 1  B0 03        	BCS	LAB_WDLP		; branch if >= tab size
002023r 1               
002023r 1  85 64        	STA	TabSiz		; else make tab size = terminal width
002025r 1               LAB_SULP
002025r 1  38           	SEC				; set carry for subtract
002026r 1               LAB_WDLP
002026r 1  E5 64        	SBC	TabSiz		; subtract tab size
002028r 1  B0 FC        	BCS	LAB_WDLP		; loop while no borrow
00202Ar 1               
00202Ar 1  65 64        	ADC	TabSiz		; add tab size back
00202Cr 1  18           	CLC				; clear carry for add
00202Dr 1  65 64        	ADC	TabSiz		; add tab size back again
00202Fr 1  85 10        	STA	Iclim			; save for now
002031r 1  A5 0F        	LDA	TWidth		; get width back
002033r 1  38           	SEC				; set carry for subtract
002034r 1  E5 10        	SBC	Iclim			; subtract remainder
002036r 1  85 10        	STA	Iclim			; save tab column limit
002038r 1               LAB_NOSQ
002038r 1  60           	RTS
002039r 1               
002039r 1               TabErr
002039r 1  4C rr rr     	JMP	LAB_FCER		; do function call error then warm start
00203Cr 1               
00203Cr 1               ; perform SQR()
00203Cr 1               
00203Cr 1               LAB_SQR
00203Cr 1  A5 B0        	LDA	FAC1_s		; get FAC1 sign
00203Er 1  30 F9        	BMI	TabErr		; if -ve do function call error
002040r 1               
002040r 1  A5 AC        	LDA	FAC1_e		; get exponent
002042r 1  F0 F4        	BEQ	LAB_NOSQ		; if zero just return
002044r 1               
002044r 1               					; else do root
002044r 1  20 rr rr     	JSR	LAB_27AB		; round and copy FAC1 to FAC2
002047r 1  A9 00        	LDA	#$00			; clear A
002049r 1               
002049r 1  85 77        	STA	FACt_3		; clear remainder
00204Br 1  85 76        	STA	FACt_2		; ..
00204Dr 1  85 75        	STA	FACt_1		; ..
00204Fr 1  85 78        	STA	TempB			; ..
002051r 1               
002051r 1  85 AF        	STA	FAC1_3		; clear root
002053r 1  85 AE        	STA	FAC1_2		; ..
002055r 1  85 AD        	STA	FAC1_1		; ..
002057r 1               
002057r 1  A2 18        	LDX	#$18			; 24 pairs of bits to do
002059r 1  A5 B3        	LDA	FAC2_e		; get exponent
00205Br 1  4A           	LSR				; check odd/even
00205Cr 1  B0 0E        	BCS	LAB_SQE2		; if odd only 1 shift first time
00205Er 1               
00205Er 1               LAB_SQE1
00205Er 1  06 B6        	ASL	FAC2_3		; shift highest bit of number ..
002060r 1  26 B5        	ROL	FAC2_2		; ..
002062r 1  26 B4        	ROL	FAC2_1		; ..
002064r 1  26 77        	ROL	FACt_3		; .. into remainder
002066r 1  26 76        	ROL	FACt_2		; ..
002068r 1  26 75        	ROL	FACt_1		; ..
00206Ar 1  26 78        	ROL	TempB			; .. never overflows
00206Cr 1               LAB_SQE2
00206Cr 1  06 B6        	ASL	FAC2_3		; shift highest bit of number ..
00206Er 1  26 B5        	ROL	FAC2_2		; ..
002070r 1  26 B4        	ROL	FAC2_1		; ..
002072r 1  26 77        	ROL	FACt_3		; .. into remainder
002074r 1  26 76        	ROL	FACt_2		; ..
002076r 1  26 75        	ROL	FACt_1		; ..
002078r 1  26 78        	ROL	TempB			; .. never overflows
00207Ar 1               
00207Ar 1  06 AF        	ASL	FAC1_3		; root = root * 2
00207Cr 1  26 AE        	ROL	FAC1_2		; ..
00207Er 1  26 AD        	ROL	FAC1_1		; .. never overflows
002080r 1               
002080r 1  A5 AF        	LDA	FAC1_3		; get root low byte
002082r 1  2A           	ROL				; *2
002083r 1  85 5B        	STA	Temp3			; save partial low byte
002085r 1  A5 AE        	LDA	FAC1_2		; get root low mid byte
002087r 1  2A           	ROL				; *2
002088r 1  85 5C        	STA	Temp3+1		; save partial low mid byte
00208Ar 1  A5 AD        	LDA	FAC1_1		; get root high mid byte
00208Cr 1  2A           	ROL				; *2
00208Dr 1  85 5D        	STA	Temp3+2		; save partial high mid byte
00208Fr 1  A9 00        	LDA	#$00			; get root high byte (always $00)
002091r 1  2A           	ROL				; *2
002092r 1  85 5E        	STA	Temp3+3		; save partial high byte
002094r 1               
002094r 1               					; carry clear for subtract +1
002094r 1  A5 77        	LDA	FACt_3		; get remainder low byte
002096r 1  E5 5B        	SBC	Temp3			; subtract partial low byte
002098r 1  85 5B        	STA	Temp3			; save partial low byte
00209Ar 1               
00209Ar 1  A5 76        	LDA	FACt_2		; get remainder low mid byte
00209Cr 1  E5 5C        	SBC	Temp3+1		; subtract partial low mid byte
00209Er 1  85 5C        	STA	Temp3+1		; save partial low mid byte
0020A0r 1               
0020A0r 1  A5 75        	LDA	FACt_1		; get remainder high mid byte
0020A2r 1  E5 5D        	SBC	Temp3+2		; subtract partial high mid byte
0020A4r 1  A8           	TAY				; copy partial high mid byte
0020A5r 1               
0020A5r 1  A5 78        	LDA	TempB			; get remainder high byte
0020A7r 1  E5 5E        	SBC	Temp3+3		; subtract partial high byte
0020A9r 1  90 0E        	BCC	LAB_SQNS		; skip sub if remainder smaller
0020ABr 1               
0020ABr 1  85 78        	STA	TempB			; save remainder high byte
0020ADr 1               
0020ADr 1  84 75        	STY	FACt_1		; save remainder high mid byte
0020AFr 1               
0020AFr 1  A5 5C        	LDA	Temp3+1		; get remainder low mid byte
0020B1r 1  85 76        	STA	FACt_2		; save remainder low mid byte
0020B3r 1               
0020B3r 1  A5 5B        	LDA	Temp3			; get partial low byte
0020B5r 1  85 77        	STA	FACt_3		; save remainder low byte
0020B7r 1               
0020B7r 1  E6 AF        	INC	FAC1_3		; increment root low byte (never any rollover)
0020B9r 1               LAB_SQNS
0020B9r 1  CA           	DEX				; decrement bit pair count
0020BAr 1  D0 A2        	BNE	LAB_SQE1		; loop if not all done
0020BCr 1               
0020BCr 1  38           	SEC				; set carry for subtract
0020BDr 1  A5 B3        	LDA	FAC2_e		; get exponent
0020BFr 1  E9 80        	SBC	#$80			; normalise
0020C1r 1  6A           	ROR				; /2 and re-bias to $80
0020C2r 1  69 00        	ADC	#$00			; add bit zero back in (allow for half shift)
0020C4r 1  85 AC        	STA	FAC1_e		; save it
0020C6r 1  4C rr rr     	JMP	LAB_24D5		; normalise FAC1 and return
0020C9r 1               
0020C9r 1               ; perform VARPTR()
0020C9r 1               
0020C9r 1               LAB_VARPTR
0020C9r 1  20 BC 00     	JSR	LAB_IGBY		; increment and scan memory
0020CCr 1  20 rr rr     	JSR	LAB_GVAR		; get var address
0020CFr 1  20 rr rr     	JSR	LAB_1BFB		; scan for ")" , else do syntax error then warm start
0020D2r 1  A4 95        	LDY	Cvaral		; get var address low byte
0020D4r 1  A5 96        	LDA	Cvarah		; get var address high byte
0020D6r 1  4C rr rr     	JMP	LAB_AYFC		; save and convert integer AY to FAC1 and return
0020D9r 1               
0020D9r 1               ; perform PI
0020D9r 1               
0020D9r 1               LAB_PI
0020D9r 1  A9 rr        	LDA	#<LAB_2C7C		; set (2*pi) pointer low byte
0020DBr 1  A0 rr        	LDY	#>LAB_2C7C		; set (2*pi) pointer high byte
0020DDr 1  20 rr rr     	JSR	LAB_UFAC		; unpack memory (AY) into FAC1
0020E0r 1  C6 AC        	DEC	FAC1_e		; make result = PI
0020E2r 1  60           	RTS
0020E3r 1               
0020E3r 1               ; perform TWOPI
0020E3r 1               
0020E3r 1               LAB_TWOPI
0020E3r 1  A9 rr        	LDA	#<LAB_2C7C		; set (2*pi) pointer low byte
0020E5r 1  A0 rr        	LDY	#>LAB_2C7C		; set (2*pi) pointer high byte
0020E7r 1  4C rr rr     	JMP	LAB_UFAC		; unpack memory (AY) into FAC1 and return
0020EAr 1               
0020EAr 1               ; system dependant i/o vectors
0020EAr 1               ; these are in RAM and are set by the monitor at start-up
0020EAr 1               
0020EAr 1               V_INPT
0020EAr 1  6C 05 02     	JMP	(VEC_IN)		; non halting scan input device
0020EDr 1               V_OUTP
0020EDr 1  6C 07 02     	JMP	(VEC_OUT)		; send byte to output device
0020F0r 1               V_LOAD
0020F0r 1  6C 09 02     	JMP	(VEC_LD)		; load BASIC program
0020F3r 1               V_SAVE
0020F3r 1  6C 0B 02     	JMP	(VEC_SV)		; save BASIC program
0020F6r 1               
0020F6r 1               ; The rest are tables messages and code for RAM
0020F6r 1               
0020F6r 1               ; the rest of the code is tables and BASIC start-up code
0020F6r 1               
0020F6r 1               PG2_TABS
0020F6r 1  00           	.byte	$00			; ctrl-c flag		-	$00 = enabled
0020F7r 1  00           	.byte	$00			; ctrl-c byte		-	GET needs this
0020F8r 1  00           	.byte	$00			; ctrl-c byte timeout	-	GET needs this
0020F9r 1  rr rr        	.word	CTRLC			; ctrl c check vector
0020FBr 1               ;	.word	xxxx			; non halting key input	-	monitor to set this
0020FBr 1               ;	.word	xxxx			; output vector		-	monitor to set this
0020FBr 1               ;	.word	xxxx			; load vector		-	monitor to set this
0020FBr 1               ;	.word	xxxx			; save vector		-	monitor to set this
0020FBr 1               PG2_TABE
0020FBr 1               
0020FBr 1               ; character get subroutine for zero page
0020FBr 1               
0020FBr 1               ; For a 1.8432MHz 6502 including the JSR and RTS
0020FBr 1               ; fastest (>=":")	=  29 cycles =  15.7uS
0020FBr 1               ; slowest (<":")	=  40 cycles =  21.7uS
0020FBr 1               ; space skip	= +21 cycles = +11.4uS
0020FBr 1               ; inc across page	=  +4 cycles =  +2.2uS
0020FBr 1               
0020FBr 1               ; the target address for the LDA at LAB_2CF4 becomes the BASIC execute pointer once the
0020FBr 1               ; block is copied to it's destination, any non zero page address will do at assembly
0020FBr 1               ; time, to assemble a three byte instruction.
0020FBr 1               
0020FBr 1               ; page 0 initialisation table from $BC
0020FBr 1               ; increment and scan memory
0020FBr 1               
0020FBr 1               LAB_2CEE
0020FBr 1  E6 C3        	INC	Bpntrl		; increment BASIC execute pointer low byte
0020FDr 1  D0 02        	BNE	LAB_2CF4		; branch if no carry
0020FFr 1               					; else
0020FFr 1  E6 C4        	INC	Bpntrh		; increment BASIC execute pointer high byte
002101r 1               
002101r 1               ; page 0 initialisation table from $C2
002101r 1               ; scan memory
002101r 1               
002101r 1               LAB_2CF4
002101r 1  AD FF FF     	LDA	$FFFF			; get byte to scan (addr set by call routine)
002104r 1  C9 AD        	CMP	#TK_ELSE		; compare with the token for ELSE
002106r 1  F0 0E        	BEQ	LAB_2D05		; exit if ELSE, not numeric, carry set
002108r 1               
002108r 1  C9 3A        	CMP	#':'			; compare with ":"
00210Ar 1  B0 0A        	BCS	LAB_2D05		; exit if >= ":", not numeric, carry set
00210Cr 1               
00210Cr 1  C9 20        	CMP	#' '			; compare with " "
00210Er 1  F0 EB        	BEQ	LAB_2CEE		; if " " go do next
002110r 1               
002110r 1  38           	SEC				; set carry for SBC
002111r 1  E9 30        	SBC	#'0'			; subtract "0"
002113r 1  38           	SEC				; set carry for SBC
002114r 1  E9 D0        	SBC	#$D0			; subtract -"0"
002116r 1               					; clear carry if byte = "0"-"9"
002116r 1               LAB_2D05
002116r 1  60           	RTS
002117r 1               
002117r 1               ; page zero initialisation table $00-$12 inclusive
002117r 1               
002117r 1               StrTab
002117r 1  4C           	.byte	$4C			; JMP opcode
002118r 1  rr rr        	.word LAB_COLD		; initial warm start vector (cold start)
00211Ar 1               
00211Ar 1  00           	.byte	$00			; these bytes are not used by BASIC
00211Br 1  00 00        	.word	$0000			;
00211Dr 1  00 00        	.word	$0000			;
00211Fr 1  00 00        	.word	$0000			;
002121r 1               
002121r 1  4C           	.byte	$4C			; JMP opcode
002122r 1  rr rr        	.word	LAB_FCER		; initial user function vector ("Function call" error)
002124r 1  00           	.byte	$00			; default NULL count
002125r 1  00           	.byte	$00			; clear terminal position
002126r 1  00           	.byte	$00			; default terminal width byte
002127r 1  F2           	.byte	$F2			; default limit for TAB = 14
002128r 1  00 04        	.word	Ram_base		; start of user RAM
00212Ar 1               EndTab
00212Ar 1               
00212Ar 1               LAB_MSZM
00212Ar 1  0D 0A 4D 65  	.byte	$0D,$0A,"Memory size ",$00
00212Er 1  6D 6F 72 79  
002132r 1  20 73 69 7A  
002139r 1               
002139r 1               LAB_SMSG
002139r 1  20 42 79 74  	.byte	" Bytes free",$0D,$0A,$0A
00213Dr 1  65 73 20 66  
002141r 1  72 65 65 0D  
002147r 1  45 6E 68 61  	.byte	"Enhanced BASIC 2.22",$0A,$00
00214Br 1  6E 63 65 64  
00214Fr 1  20 42 41 53  
00215Cr 1               
00215Cr 1               ; numeric constants and series
00215Cr 1               
00215Cr 1               					; constants and series for LOG(n)
00215Cr 1               LAB_25A0
00215Cr 1  02           	.byte	$02			; counter
00215Dr 1  80 19 56 62  	.byte	$80,$19,$56,$62	; 0.59898
002161r 1  80 76 22 F3  	.byte	$80,$76,$22,$F3	; 0.96147
002165r 1               ;##	.byte	$80,$76,$22,$F1	; 0.96147
002165r 1  82 38 AA 40  	.byte	$82,$38,$AA,$40	; 2.88539
002169r 1               ;##	.byte	$82,$38,$AA,$45	; 2.88539
002169r 1               
002169r 1               LAB_25AD
002169r 1  80 35 04 F3  	.byte	$80,$35,$04,$F3	; 0.70711	1/root 2
00216Dr 1               LAB_25B1
00216Dr 1  81 35 04 F3  	.byte	$81,$35,$04,$F3	; 1.41421	root 2
002171r 1               LAB_25B5
002171r 1  80 80 00 00  	.byte	$80,$80,$00,$00	; -0.5
002175r 1               LAB_25B9
002175r 1  80 31 72 18  	.byte	$80,$31,$72,$18	; 0.69315	LOG(2)
002179r 1               
002179r 1               					; numeric PRINT constants
002179r 1               LAB_2947
002179r 1  91 43 4F F8  	.byte	$91,$43,$4F,$F8	; 99999.9375 (max value with at least one decimal)
00217Dr 1               LAB_294B
00217Dr 1  94 74 23 F7  	.byte	$94,$74,$23,$F7	; 999999.4375 (max value before scientific notation)
002181r 1               LAB_294F
002181r 1  94 74 24 00  	.byte	$94,$74,$24,$00	; 1000000
002185r 1               
002185r 1               					; EXP(n) constants and series
002185r 1               LAB_2AFA
002185r 1  81 38 AA 3B  	.byte	$81,$38,$AA,$3B	; 1.4427	(1/LOG base 2 e)
002189r 1               LAB_2AFE
002189r 1  06           	.byte	$06			; counter
00218Ar 1  74 63 90 8C  	.byte	$74,$63,$90,$8C	; 2.17023e-4
00218Er 1  77 23 0C AB  	.byte	$77,$23,$0C,$AB	; 0.00124
002192r 1  7A 1E 94 00  	.byte	$7A,$1E,$94,$00	; 0.00968
002196r 1  7C 63 42 80  	.byte	$7C,$63,$42,$80	; 0.05548
00219Ar 1  7E 75 FE D0  	.byte	$7E,$75,$FE,$D0	; 0.24023
00219Er 1  80 31 72 15  	.byte	$80,$31,$72,$15	; 0.69315
0021A2r 1  81 00 00 00  	.byte	$81,$00,$00,$00	; 1.00000
0021A6r 1               
0021A6r 1               ;##	.byte	$07			; counter
0021A6r 1               ;##	.byte	$74,$94,$2E,$40	; -1/7! (-1/5040)
0021A6r 1               ;##	.byte	$77,$2E,$4F,$70	;  1/6! ( 1/720)
0021A6r 1               ;##	.byte	$7A,$88,$02,$6E	; -1/5! (-1/120)
0021A6r 1               ;##	.byte	$7C,$2A,$A0,$E6	;  1/4! ( 1/24)
0021A6r 1               ;##	.byte	$7E,$AA,$AA,$50	; -1/3! (-1/6)
0021A6r 1               ;##	.byte	$7F,$7F,$FF,$FF	;  1/2! ( 1/2)
0021A6r 1               ;##	.byte	$81,$80,$00,$00	; -1/1! (-1/1)
0021A6r 1               ;##	.byte	$81,$00,$00,$00	;  1/0! ( 1/1)
0021A6r 1               
0021A6r 1               					; trigonometric constants and series
0021A6r 1               LAB_2C78
0021A6r 1  81 49 0F DB  	.byte	$81,$49,$0F,$DB	; 1.570796371 (pi/2) as floating #
0021AAr 1               LAB_2C84
0021AAr 1  04           	.byte	$04			; counter
0021ABr 1  86 1E D7 FB  	.byte	$86,$1E,$D7,$FB	; 39.7109
0021AFr 1               ;##	.byte	$86,$1E,$D7,$BA	; 39.7109
0021AFr 1  87 99 26 65  	.byte	$87,$99,$26,$65	;-76.575
0021B3r 1               ;##	.byte	$87,$99,$26,$64	;-76.575
0021B3r 1  87 23 34 58  	.byte	$87,$23,$34,$58	; 81.6022
0021B7r 1  86 A5 5D E1  	.byte	$86,$A5,$5D,$E1	;-41.3417
0021BBr 1               ;##	.byte	$86,$A5,$5D,$E0	;-41.3417
0021BBr 1               LAB_2C7C
0021BBr 1  83 49 0F DB  	.byte	$83,$49,$0F,$DB	; 6.28319 (2*pi) as floating #
0021BFr 1               ;##	.byte	$83,$49,$0F,$DA	; 6.28319 (2*pi) as floating #
0021BFr 1               
0021BFr 1               LAB_2CC9
0021BFr 1  08           	.byte	$08			; counter
0021C0r 1  78 3A C5 37  	.byte	$78,$3A,$C5,$37	; 0.00285
0021C4r 1  7B 83 A2 5C  	.byte	$7B,$83,$A2,$5C	;-0.0160686
0021C8r 1  7C 2E DD 4D  	.byte	$7C,$2E,$DD,$4D	; 0.0426915
0021CCr 1  7D 99 B0 1E  	.byte	$7D,$99,$B0,$1E	;-0.0750429
0021D0r 1  7D 59 ED 24  	.byte	$7D,$59,$ED,$24	; 0.106409
0021D4r 1  7E 91 72 00  	.byte	$7E,$91,$72,$00	;-0.142036
0021D8r 1  7E 4C B9 73  	.byte	$7E,$4C,$B9,$73	; 0.199926
0021DCr 1  7F AA AA 53  	.byte	$7F,$AA,$AA,$53	;-0.333331
0021E0r 1               
0021E0r 1               ;##	.byte	$08			; counter
0021E0r 1               ;##	.byte	$78,$3B,$D7,$4A	; 1/17
0021E0r 1               ;##	.byte	$7B,$84,$6E,$02	;-1/15
0021E0r 1               ;##	.byte	$7C,$2F,$C1,$FE	; 1/13
0021E0r 1               ;##	.byte	$7D,$9A,$31,$74	;-1/11
0021E0r 1               ;##	.byte	$7D,$5A,$3D,$84	; 1/9
0021E0r 1               ;##	.byte	$7E,$91,$7F,$C8	;-1/7
0021E0r 1               ;##	.byte	$7E,$4C,$BB,$E4	; 1/5
0021E0r 1               ;##	.byte	$7F,$AA,$AA,$6C	;-1/3
0021E0r 1               
0021E0r 1               LAB_1D96	= *+1			; $00,$00 used for undefined variables
0021E0r 1               LAB_259C
0021E0r 1  81 00 00 00  	.byte	$81,$00,$00,$00	; 1.000000, used for INC
0021E4r 1               LAB_2AFD
0021E4r 1  81 80 00 00  	.byte	$81,$80,$00,$00	; -1.00000, used for DEC. must be on the same page as +1.00
0021E8r 1               
0021E8r 1               					; misc constants
0021E8r 1               LAB_1DF7
0021E8r 1  90           	.byte	$90			;-32768 (uses first three bytes from 0.5)
0021E9r 1               LAB_2A96
0021E9r 1  80 00 00 00  	.byte	$80,$00,$00,$00	; 0.5
0021EDr 1               LAB_2C80
0021EDr 1  7F 00 00 00  	.byte	$7F,$00,$00,$00	; 0.25
0021F1r 1               LAB_26B5
0021F1r 1  84 20 00 00  	.byte	$84,$20,$00,$00	; 10.0000 divide by 10 constant
0021F5r 1               
0021F5r 1               ; This table is used in converting numbers to ASCII.
0021F5r 1               
0021F5r 1               LAB_2A9A
0021F5r 1               LAB_2A9B = LAB_2A9A+1
0021F5r 1               LAB_2A9C = LAB_2A9B+1
0021F5r 1  FE 79 60     	.byte	$FE,$79,$60		; -100000
0021F8r 1  00 27 10     	.byte	$00,$27,$10		; 10000
0021FBr 1  FF FC 18     	.byte	$FF,$FC,$18		; -1000
0021FEr 1  00 00 64     	.byte	$00,$00,$64		; 100
002201r 1  FF FF F6     	.byte	$FF,$FF,$F6		; -10
002204r 1  00 00 01     	.byte	$00,$00,$01		; 1
002207r 1               
002207r 1               LAB_CTBL
002207r 1  rr rr        	.word	LAB_END-1		; END
002209r 1  rr rr        	.word	LAB_FOR-1		; FOR
00220Br 1  rr rr        	.word	LAB_NEXT-1		; NEXT
00220Dr 1  rr rr        	.word	LAB_DATA-1		; DATA
00220Fr 1  rr rr        	.word	LAB_INPUT-1		; INPUT
002211r 1  rr rr        	.word	LAB_DIM-1		; DIM
002213r 1  rr rr        	.word	LAB_READ-1		; READ
002215r 1  rr rr        	.word	LAB_LET-1		; LET
002217r 1  rr rr        	.word	LAB_DEC-1		; DEC			new command
002219r 1  rr rr        	.word	LAB_GOTO-1		; GOTO
00221Br 1  rr rr        	.word	LAB_RUN-1		; RUN
00221Dr 1  rr rr        	.word	LAB_IF-1		; IF
00221Fr 1  rr rr        	.word	LAB_RESTORE-1	; RESTORE		modified command
002221r 1  rr rr        	.word	LAB_GOSUB-1		; GOSUB
002223r 1  rr rr        	.word	LAB_RETIRQ-1	; RETIRQ		new command
002225r 1  rr rr        	.word	LAB_RETNMI-1	; RETNMI		new command
002227r 1  rr rr        	.word	LAB_RETURN-1	; RETURN
002229r 1  rr rr        	.word	LAB_REM-1		; REM
00222Br 1  rr rr        	.word	LAB_STOP-1		; STOP
00222Dr 1  rr rr        	.word	LAB_ON-1		; ON			modified command
00222Fr 1  rr rr        	.word	LAB_NULL-1		; NULL		modified command
002231r 1  rr rr        	.word	LAB_INC-1		; INC			new command
002233r 1  rr rr        	.word	LAB_WAIT-1		; WAIT
002235r 1  rr rr        	.word	V_LOAD-1		; LOAD
002237r 1  rr rr        	.word	V_SAVE-1		; SAVE
002239r 1  rr rr        	.word	LAB_DEF-1		; DEF
00223Br 1  rr rr        	.word	LAB_POKE-1		; POKE
00223Dr 1  rr rr        	.word	LAB_DOKE-1		; DOKE		new command
00223Fr 1  rr rr        	.word	LAB_CALL-1		; CALL		new command
002241r 1  rr rr        	.word	LAB_DO-1		; DO			new command
002243r 1  rr rr        	.word	LAB_LOOP-1		; LOOP		new command
002245r 1  rr rr        	.word	LAB_PRINT-1		; PRINT
002247r 1  rr rr        	.word	LAB_CONT-1		; CONT
002249r 1  rr rr        	.word	LAB_LIST-1		; LIST
00224Br 1  rr rr        	.word	LAB_CLEAR-1		; CLEAR
00224Dr 1  rr rr        	.word	LAB_NEW-1		; NEW
00224Fr 1  rr rr        	.word	LAB_WDTH-1		; WIDTH		new command
002251r 1  rr rr        	.word	LAB_GET-1		; GET			new command
002253r 1  rr rr        	.word	LAB_SWAP-1		; SWAP		new command
002255r 1  rr rr        	.word	LAB_BITSET-1	; BITSET		new command
002257r 1  rr rr        	.word	LAB_BITCLR-1	; BITCLR		new command
002259r 1  rr rr        	.word	LAB_IRQ-1		; IRQ			new command
00225Br 1  rr rr        	.word	LAB_NMI-1		; NMI			new command
00225Dr 1               	;.word   SYSjmp-1                ; SYS         *** added for SBC-2
00225Dr 1               
00225Dr 1               ; function pre process routine table
00225Dr 1               
00225Dr 1               LAB_FTPL
00225Dr 1               LAB_FTPM	= LAB_FTPL+$01
00225Dr 1  rr rr        	.word	LAB_PPFN-1		; SGN(n)	process numeric expression in ()
00225Fr 1  rr rr        	.word	LAB_PPFN-1		; INT(n)		"
002261r 1  rr rr        	.word	LAB_PPFN-1		; ABS(n)		"
002263r 1  rr rr        	.word	LAB_EVEZ-1		; USR(x)	process any expression
002265r 1  rr rr        	.word	LAB_1BF7-1		; FRE(x)		"
002267r 1  rr rr        	.word	LAB_1BF7-1		; POS(x)		"
002269r 1  rr rr        	.word	LAB_PPFN-1		; SQR(n)	process numeric expression in ()
00226Br 1  rr rr        	.word	LAB_PPFN-1		; RND(n)		"
00226Dr 1  rr rr        	.word	LAB_PPFN-1		; LOG(n)		"
00226Fr 1  rr rr        	.word	LAB_PPFN-1		; EXP(n)		"
002271r 1  rr rr        	.word	LAB_PPFN-1		; COS(n)		"
002273r 1  rr rr        	.word	LAB_PPFN-1		; SIN(n)		"
002275r 1  rr rr        	.word	LAB_PPFN-1		; TAN(n)		"
002277r 1  rr rr        	.word	LAB_PPFN-1		; ATN(n)		"
002279r 1  rr rr        	.word	LAB_PPFN-1		; PEEK(n)		"
00227Br 1  rr rr        	.word	LAB_PPFN-1		; DEEK(n)		"
00227Dr 1  00 00        	.word	$0000			; SADD()	none
00227Fr 1  rr rr        	.word	LAB_PPFS-1		; LEN($)	process string expression in ()
002281r 1  rr rr        	.word	LAB_PPFN-1		; STR$(n)	process numeric expression in ()
002283r 1  rr rr        	.word	LAB_PPFS-1		; VAL($)	process string expression in ()
002285r 1  rr rr        	.word	LAB_PPFS-1		; ASC($)		"
002287r 1  rr rr        	.word	LAB_PPFS-1		; UCASE$($)		"
002289r 1  rr rr        	.word	LAB_PPFS-1		; LCASE$($)		"
00228Br 1  rr rr        	.word	LAB_PPFN-1		; CHR$(n)	process numeric expression in ()
00228Dr 1  rr rr        	.word	LAB_BHSS-1		; HEX$(n)		"
00228Fr 1  rr rr        	.word	LAB_BHSS-1		; BIN$(n)		"
002291r 1  00 00        	.word	$0000			; BITTST()	none
002293r 1  rr rr        	.word	LAB_MMPP-1		; MAX()	process numeric expression
002295r 1  rr rr        	.word	LAB_MMPP-1		; MIN()		"
002297r 1  rr rr        	.word	LAB_PPBI-1		; PI		advance pointer
002299r 1  rr rr        	.word	LAB_PPBI-1		; TWOPI		"
00229Br 1  00 00        	.word	$0000			; VARPTR()	none
00229Dr 1  rr rr        	.word	LAB_LRMS-1		; LEFT$()	process string expression
00229Fr 1  rr rr        	.word	LAB_LRMS-1		; RIGHT$()		"
0022A1r 1  rr rr        	.word	LAB_LRMS-1		; MID$()		"
0022A3r 1               
0022A3r 1               ; action addresses for functions
0022A3r 1               
0022A3r 1               LAB_FTBL
0022A3r 1               LAB_FTBM	= LAB_FTBL+$01
0022A3r 1  rr rr        	.word	LAB_SGN-1		; SGN()
0022A5r 1  rr rr        	.word	LAB_INT-1		; INT()
0022A7r 1  rr rr        	.word	LAB_ABS-1		; ABS()
0022A9r 1  rr rr        	.word	LAB_USR-1		; USR()
0022ABr 1  rr rr        	.word	LAB_FRE-1		; FRE()
0022ADr 1  rr rr        	.word	LAB_POS-1		; POS()
0022AFr 1  rr rr        	.word	LAB_SQR-1		; SQR()
0022B1r 1  rr rr        	.word	LAB_RND-1		; RND()		modified function
0022B3r 1  rr rr        	.word	LAB_LOG-1		; LOG()
0022B5r 1  rr rr        	.word	LAB_EXP-1		; EXP()
0022B7r 1  rr rr        	.word	LAB_COS-1		; COS()
0022B9r 1  rr rr        	.word	LAB_SIN-1		; SIN()
0022BBr 1  rr rr        	.word	LAB_TAN-1		; TAN()
0022BDr 1  rr rr        	.word	LAB_ATN-1		; ATN()
0022BFr 1  rr rr        	.word	LAB_PEEK-1		; PEEK()
0022C1r 1  rr rr        	.word	LAB_DEEK-1		; DEEK()		new function
0022C3r 1  rr rr        	.word	LAB_SADD-1		; SADD()		new function
0022C5r 1  rr rr        	.word	LAB_LENS-1		; LEN()
0022C7r 1  rr rr        	.word	LAB_STRS-1		; STR$()
0022C9r 1  rr rr        	.word	LAB_VAL-1		; VAL()
0022CBr 1  rr rr        	.word	LAB_ASC-1		; ASC()
0022CDr 1  rr rr        	.word	LAB_UCASE-1		; UCASE$()		new function
0022CFr 1  rr rr        	.word	LAB_LCASE-1		; LCASE$()		new function
0022D1r 1  rr rr        	.word	LAB_CHRS-1		; CHR$()
0022D3r 1  rr rr        	.word	LAB_HEXS-1		; HEX$()		new function
0022D5r 1  rr rr        	.word	LAB_BINS-1		; BIN$()		new function
0022D7r 1  rr rr        	.word	LAB_BTST-1		; BITTST()		new function
0022D9r 1  rr rr        	.word	LAB_MAX-1		; MAX()		new function
0022DBr 1  rr rr        	.word	LAB_MIN-1		; MIN()		new function
0022DDr 1  rr rr        	.word	LAB_PI-1		; PI			new function
0022DFr 1  rr rr        	.word	LAB_TWOPI-1		; TWOPI		new function
0022E1r 1  rr rr        	.word	LAB_VARPTR-1	; VARPTR()		new function
0022E3r 1  rr rr        	.word	LAB_LEFT-1		; LEFT$()
0022E5r 1  rr rr        	.word	LAB_RIGHT-1		; RIGHT$()
0022E7r 1  rr rr        	.word	LAB_MIDS-1		; MID$()
0022E9r 1               
0022E9r 1               ; hierarchy and action addresses for operator
0022E9r 1               
0022E9r 1               LAB_OPPT
0022E9r 1  79           	.byte	$79			; +
0022EAr 1  rr rr        	.word	LAB_ADD-1
0022ECr 1  79           	.byte	$79			; -
0022EDr 1  rr rr        	.word	LAB_SUBTRACT-1
0022EFr 1  7B           	.byte	$7B			; *
0022F0r 1  rr rr        	.word	LAB_MULTIPLY-1
0022F2r 1  7B           	.byte	$7B			; /
0022F3r 1  rr rr        	.word	LAB_DIVIDE-1
0022F5r 1  7F           	.byte	$7F			; ^
0022F6r 1  rr rr        	.word	LAB_POWER-1
0022F8r 1  50           	.byte	$50			; AND
0022F9r 1  rr rr        	.word	LAB_AND-1
0022FBr 1  46           	.byte	$46			; EOR			new operator
0022FCr 1  rr rr        	.word	LAB_EOR-1
0022FEr 1  46           	.byte	$46			; OR
0022FFr 1  rr rr        	.word	LAB_OR-1
002301r 1  56           	.byte	$56			; >>			new operator
002302r 1  rr rr        	.word	LAB_RSHIFT-1
002304r 1  56           	.byte	$56			; <<			new operator
002305r 1  rr rr        	.word	LAB_LSHIFT-1
002307r 1  7D           	.byte	$7D			; >
002308r 1  rr rr        	.word	LAB_GTHAN-1
00230Ar 1  5A           	.byte	$5A			; =
00230Br 1  rr rr        	.word	LAB_EQUAL-1
00230Dr 1  64           	.byte	$64			; <
00230Er 1  rr rr        	.word	LAB_LTHAN-1
002310r 1               
002310r 1               ; keywords start with ..
002310r 1               ; this is the first character table and must be in alphabetic order
002310r 1               
002310r 1               TAB_1STC
002310r 1  2A           	.byte	"*"
002311r 1  2B           	.byte	"+"
002312r 1  2D           	.byte	"-"
002313r 1  2F           	.byte	"/"
002314r 1  3C           	.byte	"<"
002315r 1  3D           	.byte	"="
002316r 1  3E           	.byte	">"
002317r 1  3F           	.byte	"?"
002318r 1  41           	.byte	"A"
002319r 1  42           	.byte	"B"
00231Ar 1  43           	.byte	"C"
00231Br 1  44           	.byte	"D"
00231Cr 1  45           	.byte	"E"
00231Dr 1  46           	.byte	"F"
00231Er 1  47           	.byte	"G"
00231Fr 1  48           	.byte	"H"
002320r 1  49           	.byte	"I"
002321r 1  4C           	.byte	"L"
002322r 1  4D           	.byte	"M"
002323r 1  4E           	.byte	"N"
002324r 1  4F           	.byte	"O"
002325r 1  50           	.byte	"P"
002326r 1  52           	.byte	"R"
002327r 1  53           	.byte	"S"
002328r 1  54           	.byte	"T"
002329r 1  55           	.byte	"U"
00232Ar 1  56           	.byte	"V"
00232Br 1  57           	.byte	"W"
00232Cr 1  5E           	.byte	"^"
00232Dr 1  00           	.byte	$00			; table terminator
00232Er 1               
00232Er 1               ; pointers to keyword tables
00232Er 1               
00232Er 1               TAB_CHRT
00232Er 1  rr rr        	.word	TAB_STAR		; table for "*"
002330r 1  rr rr        	.word	TAB_PLUS		; table for "+"
002332r 1  rr rr        	.word	TAB_MNUS		; table for "-"
002334r 1  rr rr        	.word	TAB_SLAS		; table for "/"
002336r 1  rr rr        	.word	TAB_LESS		; table for "<"
002338r 1  rr rr        	.word	TAB_EQUL		; table for "="
00233Ar 1  rr rr        	.word	TAB_MORE		; table for ">"
00233Cr 1  rr rr        	.word	TAB_QEST		; table for "?"
00233Er 1  rr rr        	.word	TAB_ASCA		; table for "A"
002340r 1  rr rr        	.word	TAB_ASCB		; table for "B"
002342r 1  rr rr        	.word	TAB_ASCC		; table for "C"
002344r 1  rr rr        	.word	TAB_ASCD		; table for "D"
002346r 1  rr rr        	.word	TAB_ASCE		; table for "E"
002348r 1  rr rr        	.word	TAB_ASCF		; table for "F"
00234Ar 1  rr rr        	.word	TAB_ASCG		; table for "G"
00234Cr 1  rr rr        	.word	TAB_ASCH		; table for "H"
00234Er 1  rr rr        	.word	TAB_ASCI		; table for "I"
002350r 1  rr rr        	.word	TAB_ASCL		; table for "L"
002352r 1  rr rr        	.word	TAB_ASCM		; table for "M"
002354r 1  rr rr        	.word	TAB_ASCN		; table for "N"
002356r 1  rr rr        	.word	TAB_ASCO		; table for "O"
002358r 1  rr rr        	.word	TAB_ASCP		; table for "P"
00235Ar 1  rr rr        	.word	TAB_ASCR		; table for "R"
00235Cr 1  rr rr        	.word	TAB_ASCS		; table for "S"
00235Er 1  rr rr        	.word	TAB_ASCT		; table for "T"
002360r 1  rr rr        	.word	TAB_ASCU		; table for "U"
002362r 1  rr rr        	.word	TAB_ASCV		; table for "V"
002364r 1  rr rr        	.word	TAB_ASCW		; table for "W"
002366r 1  rr rr        	.word	TAB_POWR		; table for "^"
002368r 1               
002368r 1               ; tables for each start character, note if a longer keyword with the same start
002368r 1               ; letters as a shorter one exists then it must come first, else the list is in
002368r 1               ; alphabetical order as follows ..
002368r 1               
002368r 1               ; [keyword,token
002368r 1               ; [keyword,token]]
002368r 1               ; end marker (#$00)
002368r 1               
002368r 1               TAB_STAR
002368r 1  B9 00        	.byte TK_MUL,$00		; *
00236Ar 1               TAB_PLUS
00236Ar 1  B7 00        	.byte TK_PLUS,$00		; +
00236Cr 1               TAB_MNUS
00236Cr 1  B8 00        	.byte TK_MINUS,$00	; -
00236Er 1               TAB_SLAS
00236Er 1  BA 00        	.byte TK_DIV,$00		; /
002370r 1               TAB_LESS
002370r 1               LBB_LSHIFT
002370r 1  3C C0        	.byte	"<",TK_LSHIFT	; <<	note - "<<" must come before "<"
002372r 1  C3           	.byte TK_LT			; <
002373r 1  00           	.byte	$00
002374r 1               TAB_EQUL
002374r 1  C2 00        	.byte TK_EQUAL,$00	; =
002376r 1               TAB_MORE
002376r 1               LBB_RSHIFT
002376r 1  3E BF        	.byte	">",TK_RSHIFT	; >>	note - ">>" must come before ">"
002378r 1  C1           	.byte TK_GT			; >
002379r 1  00           	.byte	$00
00237Ar 1               TAB_QEST
00237Ar 1  9F 00        	.byte TK_PRINT,$00	; ?
00237Cr 1               TAB_ASCA
00237Cr 1               LBB_ABS
00237Cr 1  42 53 28 C6  	.byte	"BS(",TK_ABS	; ABS(
002380r 1               LBB_AND
002380r 1  4E 44 BC     	.byte	"ND",TK_AND		; AND
002383r 1               LBB_ASC
002383r 1  53 43 28 D8  	.byte	"SC(",TK_ASC	; ASC(
002387r 1               LBB_ATN
002387r 1  54 4E 28 D1  	.byte	"TN(",TK_ATN	; ATN(
00238Br 1  00           	.byte	$00
00238Cr 1               TAB_ASCB
00238Cr 1               LBB_BINS
00238Cr 1  49 4E 24 28  	.byte	"IN$(",TK_BINS	; BIN$(
002390r 1  DD           
002391r 1               LBB_BITCLR
002391r 1  49 54 43 4C  	.byte	"ITCLR",TK_BITCLR	; BITCLR
002395r 1  52 A8        
002397r 1               LBB_BITSET
002397r 1  49 54 53 45  	.byte	"ITSET",TK_BITSET	; BITSET
00239Br 1  54 A7        
00239Dr 1               LBB_BITTST
00239Dr 1  49 54 54 53  	.byte	"ITTST(",TK_BITTST
0023A1r 1  54 28 DE     
0023A4r 1               					; BITTST(
0023A4r 1  00           	.byte	$00
0023A5r 1               TAB_ASCC
0023A5r 1               LBB_CALL
0023A5r 1  41 4C 4C 9C  	.byte	"ALL",TK_CALL	; CALL
0023A9r 1               LBB_CHRS
0023A9r 1  48 52 24 28  	.byte	"HR$(",TK_CHRS	; CHR$(
0023ADr 1  DB           
0023AEr 1               LBB_CLEAR
0023AEr 1  4C 45 41 52  	.byte	"LEAR",TK_CLEAR	; CLEAR
0023B2r 1  A2           
0023B3r 1               LBB_CONT
0023B3r 1  4F 4E 54 A0  	.byte	"ONT",TK_CONT	; CONT
0023B7r 1               LBB_COS
0023B7r 1  4F 53 28 CE  	.byte	"OS(",TK_COS	; COS(
0023BBr 1  00           	.byte	$00
0023BCr 1               TAB_ASCD
0023BCr 1               LBB_DATA
0023BCr 1  41 54 41 83  	.byte	"ATA",TK_DATA	; DATA
0023C0r 1               LBB_DEC
0023C0r 1  45 43 88     	.byte	"EC",TK_DEC		; DEC
0023C3r 1               LBB_DEEK
0023C3r 1  45 45 4B 28  	.byte	"EEK(",TK_DEEK	; DEEK(
0023C7r 1  D3           
0023C8r 1               LBB_DEF
0023C8r 1  45 46 99     	.byte	"EF",TK_DEF		; DEF
0023CBr 1               LBB_DIM
0023CBr 1  49 4D 85     	.byte	"IM",TK_DIM		; DIM
0023CEr 1               LBB_DOKE
0023CEr 1  4F 4B 45 9B  	.byte	"OKE",TK_DOKE	; DOKE note - "DOKE" must come before "DO"
0023D2r 1               LBB_DO
0023D2r 1  4F 9D        	.byte	"O",TK_DO		; DO
0023D4r 1  00           	.byte	$00
0023D5r 1               TAB_ASCE
0023D5r 1               LBB_ELSE
0023D5r 1  4C 53 45 AD  	.byte	"LSE",TK_ELSE	; ELSE
0023D9r 1               LBB_END
0023D9r 1  4E 44 80     	.byte	"ND",TK_END		; END
0023DCr 1               LBB_EOR
0023DCr 1  4F 52 BD     	.byte	"OR",TK_EOR		; EOR
0023DFr 1               LBB_EXP
0023DFr 1  58 50 28 CD  	.byte	"XP(",TK_EXP	; EXP(
0023E3r 1  00           	.byte	$00
0023E4r 1               TAB_ASCF
0023E4r 1               LBB_FN
0023E4r 1  4E AF        	.byte	"N",TK_FN		; FN
0023E6r 1               LBB_FOR
0023E6r 1  4F 52 81     	.byte	"OR",TK_FOR		; FOR
0023E9r 1               LBB_FRE
0023E9r 1  52 45 28 C8  	.byte	"RE(",TK_FRE	; FRE(
0023EDr 1  00           	.byte	$00
0023EEr 1               TAB_ASCG
0023EEr 1               LBB_GET
0023EEr 1  45 54 A5     	.byte	"ET",TK_GET		; GET
0023F1r 1               LBB_GOSUB
0023F1r 1  4F 53 55 42  	.byte	"OSUB",TK_GOSUB	; GOSUB
0023F5r 1  8D           
0023F6r 1               LBB_GOTO
0023F6r 1  4F 54 4F 89  	.byte	"OTO",TK_GOTO	; GOTO
0023FAr 1  00           	.byte	$00
0023FBr 1               TAB_ASCH
0023FBr 1               LBB_HEXS
0023FBr 1  45 58 24 28  	.byte	"EX$(",TK_HEXS	; HEX$(
0023FFr 1  DC           
002400r 1  00           	.byte	$00
002401r 1               TAB_ASCI
002401r 1               LBB_IF
002401r 1  46 8B        	.byte	"F",TK_IF		; IF
002403r 1               LBB_INC
002403r 1  4E 43 95     	.byte	"NC",TK_INC		; INC
002406r 1               LBB_INPUT
002406r 1  4E 50 55 54  	.byte	"NPUT",TK_INPUT	; INPUT
00240Ar 1  84           
00240Br 1               LBB_INT
00240Br 1  4E 54 28 C5  	.byte	"NT(",TK_INT	; INT(
00240Fr 1               LBB_IRQ
00240Fr 1  52 51 A9     	.byte	"RQ",TK_IRQ		; IRQ
002412r 1  00           	.byte	$00
002413r 1               TAB_ASCL
002413r 1               LBB_LCASES
002413r 1  43 41 53 45  	.byte	"CASE$(",TK_LCASES
002417r 1  24 28 DA     
00241Ar 1               					; LCASE$(
00241Ar 1               LBB_LEFTS
00241Ar 1  45 46 54 24  	.byte	"EFT$(",TK_LEFTS	; LEFT$(
00241Er 1  28 E4        
002420r 1               LBB_LEN
002420r 1  45 4E 28 D5  	.byte	"EN(",TK_LEN	; LEN(
002424r 1               LBB_LET
002424r 1  45 54 87     	.byte	"ET",TK_LET		; LET
002427r 1               LBB_LIST
002427r 1  49 53 54 A1  	.byte	"IST",TK_LIST	; LIST
00242Br 1               LBB_LOAD
00242Br 1  4F 41 44 97  	.byte	"OAD",TK_LOAD	; LOAD
00242Fr 1               LBB_LOG
00242Fr 1  4F 47 28 CC  	.byte	"OG(",TK_LOG	; LOG(
002433r 1               LBB_LOOP
002433r 1  4F 4F 50 9E  	.byte	"OOP",TK_LOOP	; LOOP
002437r 1  00           	.byte	$00
002438r 1               TAB_ASCM
002438r 1               LBB_MAX
002438r 1  41 58 28 DF  	.byte	"AX(",TK_MAX	; MAX(
00243Cr 1               LBB_MIDS
00243Cr 1  49 44 24 28  	.byte	"ID$(",TK_MIDS	; MID$(
002440r 1  E6           
002441r 1               LBB_MIN
002441r 1  49 4E 28 E0  	.byte	"IN(",TK_MIN	; MIN(
002445r 1  00           	.byte	$00
002446r 1               TAB_ASCN
002446r 1               LBB_NEW
002446r 1  45 57 A3     	.byte	"EW",TK_NEW		; NEW
002449r 1               LBB_NEXT
002449r 1  45 58 54 82  	.byte	"EXT",TK_NEXT	; NEXT
00244Dr 1               LBB_NMI
00244Dr 1  4D 49 AA     	.byte	"MI",TK_NMI		; NMI
002450r 1               LBB_NOT
002450r 1  4F 54 B2     	.byte	"OT",TK_NOT		; NOT
002453r 1               LBB_NULL
002453r 1  55 4C 4C 94  	.byte	"ULL",TK_NULL	; NULL
002457r 1  00           	.byte	$00
002458r 1               TAB_ASCO
002458r 1               LBB_OFF
002458r 1  46 46 B6     	.byte	"FF",TK_OFF		; OFF
00245Br 1               LBB_ON
00245Br 1  4E 93        	.byte	"N",TK_ON		; ON
00245Dr 1               LBB_OR
00245Dr 1  52 BE        	.byte	"R",TK_OR		; OR
00245Fr 1  00           	.byte	$00
002460r 1               TAB_ASCP
002460r 1               LBB_PEEK
002460r 1  45 45 4B 28  	.byte	"EEK(",TK_PEEK	; PEEK(
002464r 1  D2           
002465r 1               LBB_PI
002465r 1  49 E1        	.byte	"I",TK_PI		; PI
002467r 1               LBB_POKE
002467r 1  4F 4B 45 9A  	.byte	"OKE",TK_POKE	; POKE
00246Br 1               LBB_POS
00246Br 1  4F 53 28 C9  	.byte	"OS(",TK_POS	; POS(
00246Fr 1               LBB_PRINT
00246Fr 1  52 49 4E 54  	.byte	"RINT",TK_PRINT	; PRINT
002473r 1  9F           
002474r 1  00           	.byte	$00
002475r 1               TAB_ASCR
002475r 1               LBB_READ
002475r 1  45 41 44 86  	.byte	"EAD",TK_READ	; READ
002479r 1               LBB_REM
002479r 1  45 4D 91     	.byte	"EM",TK_REM		; REM
00247Cr 1               LBB_RESTORE
00247Cr 1  45 53 54 4F  	.byte	"ESTORE",TK_RESTORE
002480r 1  52 45 8C     
002483r 1               					; RESTORE
002483r 1               LBB_RETIRQ
002483r 1  45 54 49 52  	.byte	"ETIRQ",TK_RETIRQ	; RETIRQ
002487r 1  51 8E        
002489r 1               LBB_RETNMI
002489r 1  45 54 4E 4D  	.byte	"ETNMI",TK_RETNMI	; RETNMI
00248Dr 1  49 8F        
00248Fr 1               LBB_RETURN
00248Fr 1  45 54 55 52  	.byte	"ETURN",TK_RETURN	; RETURN
002493r 1  4E 90        
002495r 1               LBB_RIGHTS
002495r 1  49 47 48 54  	.byte	"IGHT$(",TK_RIGHTS
002499r 1  24 28 E5     
00249Cr 1               					; RIGHT$(
00249Cr 1               LBB_RND
00249Cr 1  4E 44 28 CB  	.byte	"ND(",TK_RND	; RND(
0024A0r 1               LBB_RUN
0024A0r 1  55 4E 8A     	.byte	"UN",TK_RUN		; RUN
0024A3r 1  00           	.byte	$00
0024A4r 1               TAB_ASCS
0024A4r 1               LBB_SADD
0024A4r 1  41 44 44 28  	.byte	"ADD(",TK_SADD	; SADD(
0024A8r 1  D4           
0024A9r 1               LBB_SAVE
0024A9r 1  41 56 45 98  	.byte	"AVE",TK_SAVE	; SAVE
0024ADr 1               LBB_SGN
0024ADr 1  47 4E 28 C4  	.byte	"GN(",TK_SGN	; SGN(
0024B1r 1               LBB_SIN
0024B1r 1  49 4E 28 CF  	.byte	"IN(",TK_SIN	; SIN(
0024B5r 1               LBB_SPC
0024B5r 1  50 43 28 B0  	.byte	"PC(",TK_SPC	; SPC(
0024B9r 1               LBB_SQR
0024B9r 1  51 52 28 CA  	.byte	"QR(",TK_SQR	; SQR(
0024BDr 1               LBB_STEP
0024BDr 1  54 45 50 B3  	.byte	"TEP",TK_STEP	; STEP
0024C1r 1               LBB_STOP
0024C1r 1  54 4F 50 92  	.byte	"TOP",TK_STOP	; STOP
0024C5r 1               LBB_STRS
0024C5r 1  54 52 24 28  	.byte	"TR$(",TK_STRS	; STR$(
0024C9r 1  D6           
0024CAr 1               LBB_SWAP
0024CAr 1  57 41 50 A6  	.byte	"WAP",TK_SWAP	; SWAP
0024CEr 1               LBB_SYS
0024CEr 1  59 53 AB     	.byte   "YS", TK_SYS    ; SYS    *** added for SBC-2
0024D1r 1  00           	.byte	$00
0024D2r 1               TAB_ASCT
0024D2r 1               LBB_TAB
0024D2r 1  41 42 28 AC  	.byte	"AB(",TK_TAB	; TAB(
0024D6r 1               LBB_TAN
0024D6r 1  41 4E 28 D0  	.byte	"AN(",TK_TAN	; TAN(
0024DAr 1               LBB_THEN
0024DAr 1  48 45 4E B1  	.byte	"HEN",TK_THEN	; THEN
0024DEr 1               LBB_TO
0024DEr 1  4F AE        	.byte	"O",TK_TO		; TO
0024E0r 1               LBB_TWOPI
0024E0r 1  57 4F 50 49  	.byte	"WOPI",TK_TWOPI	; TWOPI
0024E4r 1  E2           
0024E5r 1  00           	.byte	$00
0024E6r 1               TAB_ASCU
0024E6r 1               LBB_UCASES
0024E6r 1  43 41 53 45  	.byte	"CASE$(",TK_UCASES
0024EAr 1  24 28 D9     
0024EDr 1               					; UCASE$(
0024EDr 1               LBB_UNTIL
0024EDr 1  4E 54 49 4C  	.byte	"NTIL",TK_UNTIL	; UNTIL
0024F1r 1  B4           
0024F2r 1               LBB_USR
0024F2r 1  53 52 28 C7  	.byte	"SR(",TK_USR	; USR(
0024F6r 1  00           	.byte	$00
0024F7r 1               TAB_ASCV
0024F7r 1               LBB_VAL
0024F7r 1  41 4C 28 D7  	.byte	"AL(",TK_VAL	; VAL(
0024FBr 1               LBB_VPTR
0024FBr 1  41 52 50 54  	.byte	"ARPTR(",TK_VPTR	; VARPTR(
0024FFr 1  52 28 E3     
002502r 1  00           	.byte	$00
002503r 1               TAB_ASCW
002503r 1               LBB_WAIT
002503r 1  41 49 54 96  	.byte	"AIT",TK_WAIT	; WAIT
002507r 1               LBB_WHILE
002507r 1  48 49 4C 45  	.byte	"HILE",TK_WHILE	; WHILE
00250Br 1  B5           
00250Cr 1               LBB_WIDTH
00250Cr 1  49 44 54 48  	.byte	"IDTH",TK_WIDTH	; WIDTH
002510r 1  A4           
002511r 1  00           	.byte	$00
002512r 1               TAB_POWR
002512r 1  BB 00        	.byte	TK_POWER,$00	; ^
002514r 1               
002514r 1               ; new decode table for LIST
002514r 1               ; Table is ..
002514r 1               ; byte - keyword length, keyword first character
002514r 1               ; word - pointer to rest of keyword from dictionary
002514r 1               
002514r 1               ; note if length is 1 then the pointer is ignored
002514r 1               
002514r 1               LAB_KEYT
002514r 1  03 45        	.byte	3,"E"
002516r 1  rr rr        	.word	LBB_END		; END
002518r 1  03 46        	.byte	3,"F"
00251Ar 1  rr rr        	.word	LBB_FOR		; FOR
00251Cr 1  04 4E        	.byte	4,"N"
00251Er 1  rr rr        	.word	LBB_NEXT		; NEXT
002520r 1  04 44        	.byte	4,"D"
002522r 1  rr rr        	.word	LBB_DATA		; DATA
002524r 1  05 49        	.byte	5,"I"
002526r 1  rr rr        	.word	LBB_INPUT		; INPUT
002528r 1  03 44        	.byte	3,"D"
00252Ar 1  rr rr        	.word	LBB_DIM		; DIM
00252Cr 1  04 52        	.byte	4,"R"
00252Er 1  rr rr        	.word	LBB_READ		; READ
002530r 1  03 4C        	.byte	3,"L"
002532r 1  rr rr        	.word	LBB_LET		; LET
002534r 1  03 44        	.byte	3,"D"
002536r 1  rr rr        	.word	LBB_DEC		; DEC
002538r 1  04 47        	.byte	4,"G"
00253Ar 1  rr rr        	.word	LBB_GOTO		; GOTO
00253Cr 1  03 52        	.byte	3,"R"
00253Er 1  rr rr        	.word	LBB_RUN		; RUN
002540r 1  02 49        	.byte	2,"I"
002542r 1  rr rr        	.word	LBB_IF		; IF
002544r 1  07 52        	.byte	7,"R"
002546r 1  rr rr        	.word	LBB_RESTORE		; RESTORE
002548r 1  05 47        	.byte	5,"G"
00254Ar 1  rr rr        	.word	LBB_GOSUB		; GOSUB
00254Cr 1  06 52        	.byte	6,"R"
00254Er 1  rr rr        	.word	LBB_RETIRQ		; RETIRQ
002550r 1  06 52        	.byte	6,"R"
002552r 1  rr rr        	.word	LBB_RETNMI		; RETNMI
002554r 1  06 52        	.byte	6,"R"
002556r 1  rr rr        	.word	LBB_RETURN		; RETURN
002558r 1  03 52        	.byte	3,"R"
00255Ar 1  rr rr        	.word	LBB_REM		; REM
00255Cr 1  04 53        	.byte	4,"S"
00255Er 1  rr rr        	.word	LBB_STOP		; STOP
002560r 1  02 4F        	.byte	2,"O"
002562r 1  rr rr        	.word	LBB_ON		; ON
002564r 1  04 4E        	.byte	4,"N"
002566r 1  rr rr        	.word	LBB_NULL		; NULL
002568r 1  03 49        	.byte	3,"I"
00256Ar 1  rr rr        	.word	LBB_INC		; INC
00256Cr 1  04 57        	.byte	4,"W"
00256Er 1  rr rr        	.word	LBB_WAIT		; WAIT
002570r 1  04 4C        	.byte	4,"L"
002572r 1  rr rr        	.word	LBB_LOAD		; LOAD
002574r 1  04 53        	.byte	4,"S"
002576r 1  rr rr        	.word	LBB_SAVE		; SAVE
002578r 1  03 44        	.byte	3,"D"
00257Ar 1  rr rr        	.word	LBB_DEF		; DEF
00257Cr 1  04 50        	.byte	4,"P"
00257Er 1  rr rr        	.word	LBB_POKE		; POKE
002580r 1  04 44        	.byte	4,"D"
002582r 1  rr rr        	.word	LBB_DOKE		; DOKE
002584r 1  04 43        	.byte	4,"C"
002586r 1  rr rr        	.word	LBB_CALL		; CALL
002588r 1  02 44        	.byte	2,"D"
00258Ar 1  rr rr        	.word	LBB_DO		; DO
00258Cr 1  04 4C        	.byte	4,"L"
00258Er 1  rr rr        	.word	LBB_LOOP		; LOOP
002590r 1  05 50        	.byte	5,"P"
002592r 1  rr rr        	.word	LBB_PRINT		; PRINT
002594r 1  04 43        	.byte	4,"C"
002596r 1  rr rr        	.word	LBB_CONT		; CONT
002598r 1  04 4C        	.byte	4,"L"
00259Ar 1  rr rr        	.word	LBB_LIST		; LIST
00259Cr 1  05 43        	.byte	5,"C"
00259Er 1  rr rr        	.word	LBB_CLEAR		; CLEAR
0025A0r 1  03 4E        	.byte	3,"N"
0025A2r 1  rr rr        	.word	LBB_NEW		; NEW
0025A4r 1  05 57        	.byte	5,"W"
0025A6r 1  rr rr        	.word	LBB_WIDTH		; WIDTH
0025A8r 1  03 47        	.byte	3,"G"
0025AAr 1  rr rr        	.word	LBB_GET		; GET
0025ACr 1  04 53        	.byte	4,"S"
0025AEr 1  rr rr        	.word	LBB_SWAP		; SWAP
0025B0r 1  06 42        	.byte	6,"B"
0025B2r 1  rr rr        	.word	LBB_BITSET		; BITSET
0025B4r 1  06 42        	.byte	6,"B"
0025B6r 1  rr rr        	.word	LBB_BITCLR		; BITCLR
0025B8r 1  03 49        	.byte	3,"I"
0025BAr 1  rr rr        	.word	LBB_IRQ		; IRQ
0025BCr 1  03 4E        	.byte	3,"N"
0025BEr 1  rr rr        	.word	LBB_NMI		; NMI
0025C0r 1  03 53        	.byte	3,"S"			;
0025C2r 1  rr rr        	.word	LBB_SYS			; SYS   *** Added for SBC-2
0025C4r 1               
0025C4r 1               
0025C4r 1               ; secondary commands (can't start a statement)
0025C4r 1               
0025C4r 1  04 54        	.byte	4,"T"
0025C6r 1  rr rr        	.word	LBB_TAB		; TAB
0025C8r 1  04 45        	.byte	4,"E"
0025CAr 1  rr rr        	.word	LBB_ELSE		; ELSE
0025CCr 1  02 54        	.byte	2,"T"
0025CEr 1  rr rr        	.word	LBB_TO		; TO
0025D0r 1  02 46        	.byte	2,"F"
0025D2r 1  rr rr        	.word	LBB_FN		; FN
0025D4r 1  04 53        	.byte	4,"S"
0025D6r 1  rr rr        	.word	LBB_SPC		; SPC
0025D8r 1  04 54        	.byte	4,"T"
0025DAr 1  rr rr        	.word	LBB_THEN		; THEN
0025DCr 1  03 4E        	.byte	3,"N"
0025DEr 1  rr rr        	.word	LBB_NOT		; NOT
0025E0r 1  04 53        	.byte	4,"S"
0025E2r 1  rr rr        	.word	LBB_STEP		; STEP
0025E4r 1  05 55        	.byte	5,"U"
0025E6r 1  rr rr        	.word	LBB_UNTIL		; UNTIL
0025E8r 1  05 57        	.byte	5,"W"
0025EAr 1  rr rr        	.word	LBB_WHILE		; WHILE
0025ECr 1  03 4F        	.byte	3,"O"
0025EEr 1  rr rr        	.word	LBB_OFF		; OFF
0025F0r 1               
0025F0r 1               ; opperators
0025F0r 1               
0025F0r 1  01 2B        	.byte	1,"+"
0025F2r 1  00 00        	.word	$0000			; +
0025F4r 1  01 2D        	.byte	1,"-"
0025F6r 1  00 00        	.word	$0000			; -
0025F8r 1  01 2A        	.byte	1,"*"
0025FAr 1  00 00        	.word	$0000			; *
0025FCr 1  01 2F        	.byte	1,"/"
0025FEr 1  00 00        	.word	$0000			; /
002600r 1  01 5E        	.byte	1,"^"
002602r 1  00 00        	.word	$0000			; ^
002604r 1  03 41        	.byte	3,"A"
002606r 1  rr rr        	.word	LBB_AND		; AND
002608r 1  03 45        	.byte	3,"E"
00260Ar 1  rr rr        	.word	LBB_EOR		; EOR
00260Cr 1  02 4F        	.byte	2,"O"
00260Er 1  rr rr        	.word	LBB_OR		; OR
002610r 1  02 3E        	.byte	2,">"
002612r 1  rr rr        	.word	LBB_RSHIFT		; >>
002614r 1  02 3C        	.byte	2,"<"
002616r 1  rr rr        	.word	LBB_LSHIFT		; <<
002618r 1  01 3E        	.byte	1,">"
00261Ar 1  00 00        	.word	$0000			; >
00261Cr 1  01 3D        	.byte	1,"="
00261Er 1  00 00        	.word	$0000			; =
002620r 1  01 3C        	.byte	1,"<"
002622r 1  00 00        	.word	$0000			; <
002624r 1               
002624r 1               ; functions
002624r 1               
002624r 1  04 53        	.byte	4,"S"			;
002626r 1  rr rr        	.word	LBB_SGN		; SGN
002628r 1  04 49        	.byte	4,"I"			;
00262Ar 1  rr rr        	.word	LBB_INT		; INT
00262Cr 1  04 41        	.byte	4,"A"			;
00262Er 1  rr rr        	.word	LBB_ABS		; ABS
002630r 1  04 55        	.byte	4,"U"			;
002632r 1  rr rr        	.word	LBB_USR		; USR
002634r 1  04 46        	.byte	4,"F"			;
002636r 1  rr rr        	.word	LBB_FRE		; FRE
002638r 1  04 50        	.byte	4,"P"			;
00263Ar 1  rr rr        	.word	LBB_POS		; POS
00263Cr 1  04 53        	.byte	4,"S"			;
00263Er 1  rr rr        	.word	LBB_SQR		; SQR
002640r 1  04 52        	.byte	4,"R"			;
002642r 1  rr rr        	.word	LBB_RND		; RND
002644r 1  04 4C        	.byte	4,"L"			;
002646r 1  rr rr        	.word	LBB_LOG		; LOG
002648r 1  04 45        	.byte	4,"E"			;
00264Ar 1  rr rr        	.word	LBB_EXP		; EXP
00264Cr 1  04 43        	.byte	4,"C"			;
00264Er 1  rr rr        	.word	LBB_COS		; COS
002650r 1  04 53        	.byte	4,"S"			;
002652r 1  rr rr        	.word	LBB_SIN		; SIN
002654r 1  04 54        	.byte	4,"T"			;
002656r 1  rr rr        	.word	LBB_TAN		; TAN
002658r 1  04 41        	.byte	4,"A"			;
00265Ar 1  rr rr        	.word	LBB_ATN		; ATN
00265Cr 1  05 50        	.byte	5,"P"			;
00265Er 1  rr rr        	.word	LBB_PEEK		; PEEK
002660r 1  05 44        	.byte	5,"D"			;
002662r 1  rr rr        	.word	LBB_DEEK		; DEEK
002664r 1  05 53        	.byte	5,"S"			;
002666r 1  rr rr        	.word	LBB_SADD		; SADD
002668r 1  04 4C        	.byte	4,"L"			;
00266Ar 1  rr rr        	.word	LBB_LEN		; LEN
00266Cr 1  05 53        	.byte	5,"S"			;
00266Er 1  rr rr        	.word	LBB_STRS		; STR$
002670r 1  04 56        	.byte	4,"V"			;
002672r 1  rr rr        	.word	LBB_VAL		; VAL
002674r 1  04 41        	.byte	4,"A"			;
002676r 1  rr rr        	.word	LBB_ASC		; ASC
002678r 1  07 55        	.byte	7,"U"			;
00267Ar 1  rr rr        	.word	LBB_UCASES		; UCASE$
00267Cr 1  07 4C        	.byte	7,"L"			;
00267Er 1  rr rr        	.word	LBB_LCASES		; LCASE$
002680r 1  05 43        	.byte	5,"C"			;
002682r 1  rr rr        	.word	LBB_CHRS		; CHR$
002684r 1  05 48        	.byte	5,"H"			;
002686r 1  rr rr        	.word	LBB_HEXS		; HEX$
002688r 1  05 42        	.byte	5,"B"			;
00268Ar 1  rr rr        	.word	LBB_BINS		; BIN$
00268Cr 1  07 42        	.byte	7,"B"			;
00268Er 1  rr rr        	.word	LBB_BITTST		; BITTST
002690r 1  04 4D        	.byte	4,"M"			;
002692r 1  rr rr        	.word	LBB_MAX		; MAX
002694r 1  04 4D        	.byte	4,"M"			;
002696r 1  rr rr        	.word	LBB_MIN		; MIN
002698r 1  02 50        	.byte	2,"P"			;
00269Ar 1  rr rr        	.word	LBB_PI		; PI
00269Cr 1  05 54        	.byte	5,"T"			;
00269Er 1  rr rr        	.word	LBB_TWOPI		; TWOPI
0026A0r 1  07 56        	.byte	7,"V"			;
0026A2r 1  rr rr        	.word	LBB_VPTR		; VARPTR
0026A4r 1  06 4C        	.byte	6,"L"			;
0026A6r 1  rr rr        	.word	LBB_LEFTS		; LEFT$
0026A8r 1  07 52        	.byte	7,"R"			;
0026AAr 1  rr rr        	.word	LBB_RIGHTS		; RIGHT$
0026ACr 1  05 4D        	.byte	5,"M"			;
0026AEr 1  rr rr        	.word	LBB_MIDS		; MID$
0026B0r 1               
0026B0r 1               ; BASIC messages, mostly error messages
0026B0r 1               
0026B0r 1               LAB_BAER
0026B0r 1  rr rr        	.word	ERR_NF		;$00 NEXT without FOR
0026B2r 1  rr rr        	.word	ERR_SN		;$02 syntax
0026B4r 1  rr rr        	.word	ERR_RG		;$04 RETURN without GOSUB
0026B6r 1  rr rr        	.word	ERR_OD		;$06 out of data
0026B8r 1  rr rr        	.word	ERR_FC		;$08 function call
0026BAr 1  rr rr        	.word	ERR_OV		;$0A overflow
0026BCr 1  rr rr        	.word	ERR_OM		;$0C out of memory
0026BEr 1  rr rr        	.word	ERR_US		;$0E undefined statement
0026C0r 1  rr rr        	.word	ERR_BS		;$10 array bounds
0026C2r 1  rr rr        	.word	ERR_DD		;$12 double dimension array
0026C4r 1  rr rr        	.word	ERR_D0		;$14 divide by 0
0026C6r 1  rr rr        	.word	ERR_ID		;$16 illegal direct
0026C8r 1  rr rr        	.word	ERR_TM		;$18 type mismatch
0026CAr 1  rr rr        	.word	ERR_LS		;$1A long string
0026CCr 1  rr rr        	.word	ERR_ST		;$1C string too complex
0026CEr 1  rr rr        	.word	ERR_CN		;$1E continue error
0026D0r 1  rr rr        	.word	ERR_UF		;$20 undefined function
0026D2r 1  rr rr        	.word ERR_LD		;$22 LOOP without DO
0026D4r 1               
0026D4r 1               ; I may implement these two errors to force definition of variables and
0026D4r 1               ; dimensioning of arrays before use.
0026D4r 1               
0026D4r 1               ;	.word ERR_UV		;$24 undefined variable
0026D4r 1               
0026D4r 1               ; the above error has been tested and works (see code and comments below LAB_1D8B)
0026D4r 1               
0026D4r 1               ;	.word ERR_UA		;$26 undimensioned array
0026D4r 1               
0026D4r 1  4E 45 58 54  ERR_NF	.byte	"NEXT without FOR",$00
0026D8r 1  20 77 69 74  
0026DCr 1  68 6F 75 74  
0026E5r 1  53 79 6E 74  ERR_SN	.byte	"Syntax",$00
0026E9r 1  61 78 00     
0026ECr 1  52 45 54 55  ERR_RG	.byte	"RETURN without GOSUB",$00
0026F0r 1  52 4E 20 77  
0026F4r 1  69 74 68 6F  
002701r 1  4F 75 74 20  ERR_OD	.byte	"Out of DATA",$00
002705r 1  6F 66 20 44  
002709r 1  41 54 41 00  
00270Dr 1  46 75 6E 63  ERR_FC	.byte	"Function call",$00
002711r 1  74 69 6F 6E  
002715r 1  20 63 61 6C  
00271Br 1  4F 76 65 72  ERR_OV	.byte	"Overflow",$00
00271Fr 1  66 6C 6F 77  
002723r 1  00           
002724r 1  4F 75 74 20  ERR_OM	.byte	"Out of memory",$00
002728r 1  6F 66 20 6D  
00272Cr 1  65 6D 6F 72  
002732r 1  55 6E 64 65  ERR_US	.byte	"Undefined statement",$00
002736r 1  66 69 6E 65  
00273Ar 1  64 20 73 74  
002746r 1  41 72 72 61  ERR_BS	.byte	"Array bounds",$00
00274Ar 1  79 20 62 6F  
00274Er 1  75 6E 64 73  
002753r 1  44 6F 75 62  ERR_DD	.byte	"Double dimension",$00
002757r 1  6C 65 20 64  
00275Br 1  69 6D 65 6E  
002764r 1  44 69 76 69  ERR_D0	.byte	"Divide by zero",$00
002768r 1  64 65 20 62  
00276Cr 1  79 20 7A 65  
002773r 1  49 6C 6C 65  ERR_ID	.byte	"Illegal direct",$00
002777r 1  67 61 6C 20  
00277Br 1  64 69 72 65  
002782r 1  54 79 70 65  ERR_TM	.byte	"Type mismatch",$00
002786r 1  20 6D 69 73  
00278Ar 1  6D 61 74 63  
002790r 1  53 74 72 69  ERR_LS	.byte	"String too long",$00
002794r 1  6E 67 20 74  
002798r 1  6F 6F 20 6C  
0027A0r 1  53 74 72 69  ERR_ST	.byte	"String too complex",$00
0027A4r 1  6E 67 20 74  
0027A8r 1  6F 6F 20 63  
0027B3r 1  43 61 6E 27  ERR_CN	.byte	"Can't continue",$00
0027B7r 1  74 20 63 6F  
0027BBr 1  6E 74 69 6E  
0027C2r 1  55 6E 64 65  ERR_UF	.byte	"Undefined function",$00
0027C6r 1  66 69 6E 65  
0027CAr 1  64 20 66 75  
0027D5r 1  4C 4F 4F 50  ERR_LD	.byte	"LOOP without DO",$00
0027D9r 1  20 77 69 74  
0027DDr 1  68 6F 75 74  
0027E5r 1               
0027E5r 1               ;ERR_UV	.byte	"Undefined variable",$00
0027E5r 1               
0027E5r 1               ; the above error has been tested and works (see code and comments below LAB_1D8B)
0027E5r 1               
0027E5r 1               ;ERR_UA	.byte	"Undimensioned array",$00
0027E5r 1               
0027E5r 1  0D 0A 42 72  LAB_BMSG	.byte	$0D,$0A,"Break",$00
0027E9r 1  65 61 6B 00  
0027EDr 1  20 45 72 72  LAB_EMSG	.byte	" Error",$00
0027F1r 1  6F 72 00     
0027F4r 1  20 69 6E 20  LAB_LMSG	.byte	" in line ",$00
0027F8r 1  6C 69 6E 65  
0027FCr 1  20 00        
0027FEr 1  0D 0A 52 65  LAB_RMSG	.byte	$0D,$0A,"Ready",$0D,$0A,$00
002802r 1  61 64 79 0D  
002806r 1  0A 00        
002808r 1               
002808r 1  20 45 78 74  LAB_IMSG	.byte	" Extra ignored",$0D,$0A,$00
00280Cr 1  72 61 20 69  
002810r 1  67 6E 6F 72  
002819r 1  20 52 65 64  LAB_REDO	.byte	" Redo from start",$0D,$0A,$00
00281Dr 1  6F 20 66 72  
002821r 1  6F 6D 20 73  
00282Cr 1               
00282Cr 1               AA_end_basic
00282Cr 1               
