;***************************************************************************************L:
;
;       R O M A B L E   T I N Y   S C E L B A L 
;
;
;   adapted from original SCELBAL by Mark G. Arnold (MGA)  March 2013
;
;
;  In its 40-year history, no "pure" the 8008-based Scelbi-8H *ever* ran a 
;  high-level language since the 8H has a 4K memory limit, and SCELBAL takes>=8K. 
;  It seems (integer only) Tiny BASIC was created after the 8080 era was under way,  
;  and (I may be wrong but) no one seems to have ever ported it to the 8008. 
;
;  This is a *very* limited, *very* stripped-down ("tiny") version of SCELBAL 
;  that just barely squeezes into 4K, leaving ~350 bytes for user programs. 
;  The key idea is to replace the Floating-Point arithmetic with integer 
;  (fixed-point) arithmetic. It was also necessary to remove most features 
;  (arrays, functions, gosubs, etc), leaving just enough to allow 
;  the user to edit and run a tiny program.  The parser used is the original
;  "slow" one which allows user programs without blanks, not the "fast" parser
;  used in SCELBAL II.  ("5IFI<JGOTO 2" is legal; the only blank needed separates 
;  GOTO from the line number). The development of this version began by
;  removing and simplifying as many features of floating-point SCELBAL as possible
;  while keeping the float arithmetic underneath.  The features removed include:
; 
;   replace RST for SWITCH,ADV,CLESYM,ECHO,LOOP,ADBDE,INDEXC,GETCHR
;   eliminate arrays (DIM), GOSUB, RETURN, FOR, NEXT
;   eliminate PFPOUT eliminated so zero and fractions(assuming float) not printed right
;   eliminate functions altogether
;
;  The only float routines used by this stripped-down version are FPADD, FPSUB, FPMULT,
;  FPDIV, FPOUT and DINPUT.  During development, the original float routines were 
;  relocated to be above 017.  In 2013, MGA developed a tiny fixed-point package 
;  that fits within the available space for a 4K system.
;  Although SCELBAL reserves 32 bits for each variable, this package only uses low 16,
;  (one exception is the use of 24 bit sign extension in FPADD and FPSUB so 
;  that 16-bit signed comparision works correctly on the 8008, which lacks an overflow 
;  flag and therefore makes signed comparison very difficult).
;  LLI \LB\L127 and LLI 126 in the SCELBAL interpreter need to be changed.
;  Such changes are noted in lines taken from original SCELBAL by "++fxp"
;
;  limitations of this fixed-point package:
;   the multiply and divide algorithms are Peano (very very very ... slow)
;   the output does not suppress leading zeros
; 
;  
;  after substituting the fixed point package, the constant data from OLDPG1, OLDPG26
;  and OLDPG27 was relocated to the end of the code (allowing it to be ROMable)
;  the variable storage and fixed-point data now share the start of the page for 
;  the user program .  All the other volatile data now resides on what was OLDPG26
;  Earlier versions of Tiny SCELBAL kept the page addresses on the
;  original three SCELBAL data pages.
;
;  as this is a derivative work from the original SCELBAL, the following 
;  comment must be preserved:
;
	
;;; This is the Scelbi Basic Program from 1974 known as
;;; SCELBAL by Mark G. Arnold (MGA) and Nat Wadsworth  
;;;
;;;  Copyright 1975 Scelbi Computer Consulting, Inc.
;;;  All rights reserved
;;;
;;; MGA gives permission to use SCELBAL for 
;;; educational, historical, non-commercial purposes.
;;; Versions of this have been circulating on the web since
;;; about 2000; this version is authorized by MGA (Mar 2012)
;;; with the understanding no warranty is expressed or implied.
;;; As stated in the original, "no responsibility is assumed for
;;; for inaccuracies or for the success or failure of
;;; various applications to which the information herein
;;; may be applied."
;;; 
;;; SCELBAL is the only open-source, floating-point 
;;; high-level language ever implemented on Intel's first
;;; general-purpose microprocessor, the 8008.  It was
;;; published in book form:
;;;
;;;  SCELBAL: A Higher-Level Language for 8008/8080 Systems
;;;
;;; (Tiny BASIC only used 16-bit integers; the MCM\70
;;; was a closed system; calculators implemented with 8008
;;; were floating-point, but not high-level.)
;;;
;;; This version is modified to assemble with the
;;; as8 assembler (using the -octal option) 
;;; for the Intel 8008 by Thomas E. Jones.
;;; This current form is made up non-relocatable so that
;;; locations of all code and data is identical to the
;;; original SCELBAL documents and patches.  It should be
;;; reasonable after debugging code to convert this to a
;;; relocatable and ROMable code with variables in RAM.
;;; This code originates from a version made by 
;;;
;;;    Steve Loboyko in 2001.
;;;
;;; This version has all 3 patches for SCELBAL (the two
;;; pasted in the original manual, and a third which was
;;; written in SCELBAL UPDATE publication, as well as
;;; a couple changes to constants which didn't actually
;;; require a patch, just changes to bytes of data or
;;; arguments to an instruction--one of these (Tucker) was 
;;; incorrect and restored to original by MGA March 2012).
;;; 
;;; This comment must be incorporated with any version of SCELBAL
;;; downloaded, distributed, posted or disemenated.
	


ENDPGRAM:  EQU 020       
;CHANGED TO LABEL BGNPGRAM:  EQU 016;033       
	
;;; Here are labels originally attempting to make the code
;;; relocatable.  These 4 pages contain variable data
;;; which needs to be relocated from ROM to RAM.
;;; I can't vouch for ALL references to these pages in
;;; the code being switched to these labels, but they
;;; seem to be.
	

OLDPG1:		EQU	016#000; shares pg1;vars from pg27;usrpgm 
OLDPG26:	EQU	015#000

INPORT:	EQU 5
OUTPORT: EQU 016

;;; Page zero will contain the I/O Routines.  These are actually
;;; just as suggested by Scelbal Manual for Serial I/O.


; Here are the RSTs of the most frequent routines to allow shortening the code:

RST_SWITCH: EQU 005
           ORG 000#000
                                  ;Subroutine to exchange the contents of H & L with
                                  ;D & E.
SWITCH:    LCH                    ;Transfer register H to C temporarily
           LHD                    ;Place value of D into H
           LDC                    ;Now put former H from C into D
           LCL                    ;Transfer register L to C temporarily
           LLE                    ;Place value of E into L
           LEC                    ;Now put former L from C into E
           RET                    ;Exit to calling routine




RST_ADV: EQU 015
           ORG 000#010
                                  ;Subroutine to advance the two byte
                                  ;value in CPU registers H and L.
ADV:       INL                    ;Advance value in register L.
           RFZ                    ;If new value not zero, return to caller.
           INH                    ;Else must increment value in H
           RET                    ;Before retuming to caller


RST_CLESYM: EQU 025
           ORG 000#020

CLESYM:    LLI \LB\L120                ;Set L to start of SYMBOL BUFFER.
           LHI \HB\OLDPG26        ;** Set H to page of SYMBOL BUFFER.
           LMI 000                ;Place a zero byte at start of SYMBOL BUFFER.
           RET                    ;To effectively clear the buffer. Then exit to caller.


RST_LOOP: EQU 035
           ORG 000#030

LOOP:      LBM                    ;Fetch memory location pointed to by H & L into B.
           INB                    ;Increment the value.
           LMB                    ;Restore it back to memory.
           LLI \LB\L000                ;Change pointer to start of INPUT LINE BUFFER
           JMP LOOP2  ;  to fit in 8 bytes


RST_GETCHR: EQU 045
           ORG 000#040
GETCHR:    LAM                    ;Get pointer from memory location pointed to by H&L
           CPI 120                ;See if within range of line input buffer.
           LHI \HB\OLDPG26        ;** LINE INPUT BUFFER by setting up H too.
           JMP GETCHR2  ;to fit in 8 bytes


RST_ADBDE: EQU 055
           ORG 000#050
ADBDE:     LAE                    ;Subroutine to add the contents of CPU register B (single
           ADB                    ;Byte value) to the double byte value in registers D & E.
           LEA                    ;First add B to E to form new least significant byte
           RFC                    ;Restore new value to E and exit if no carry resulted
           IND                    ;If had a carry then must increment most significant byte
           RET                    ;In register D before returning to calling routine



RST_INDEXC: EQU 065
           ORG 000#060
                                  ;Following subroutine causes register C to be used as an
                                  ;indexing register. Value in C is added to address in H
                                  ;and L to form new address.

INDEXC:    LAL                    ;Place value from register L into accumulator
           ADC                    ;Add quantity in register C
           LLA                    ;Restore updated value back to L
           RFC                    ;Exit to caller if no carry from addition
           INH                    ;But, if have carry then must increment register H
           RET

RST_ECHO: EQU 075
           ORG 000#070
   JMP ECHO




;if the simulator didn't need this, could save 11 bytes

	ORG 000#100		; save a bit of space before this
	JMP EXEC		



                                  ;The following subroutine is used to
                                  ;display the ASCII encoded character in the ACC on the
                                  ;system's display device. This routine calls a routine
                                  ;labeled CINPUT which must be provided by the user to
                                  ;actually drive the system's output device. The subroutine
                                  ;below also increments an output column counter each time
                                  ;it is used.

ECHO:
           LDH                    ;Save entry value of H in register D
           LEL                    ;And save entry value of L in register E
           LLI \LB\L043                ;Set L to point to COLUMN COUNTER storage location
           LHI \HB\L043         ;** Set H to page of COLUMN COUNTER
           LBM                    ;Fetch the value in the COLUMN COUNTER
           INB                    ;And increment it for each character displayed
           LMB                    ;Restore the updated count in memory

        LHD                    ;Restore entry value of H from D
        LLE                    ;Restore entry value of L from E

;ECHO called CPRINT< substituting 2400 BAUD VERSION OF DRIVER here	MJW
ECHO2:
	NDI   177
	RAL
	OUT OUTPORT
	RAR
	
	LAA			; delay to make timing work
	LAA
	LBI	2		; delay counter
	CAL 	MORE2		
	CAL 	BITOUT		; LSB
	CAL 	BITOUT		; 1
	CAL 	BITOUT		; 2
	CAL 	BITOUT		; 3
	CAL 	BITOUT		; 4
	CAL 	BITOUT		; 5
	CAL 	BITOUT		; 6
	CAL 	BITOUT		; MSB
	LBA			; timing delay
	LAI 	001
	OUT 	OUTPORT		; stop bit
	LBI 	5
	JMP 	MORE2

BITOUT:	
	OUT 	OUTPORT
	RRC			; shift to get next bit
	LBI 	3
MORE2:
	LAA			; nop to delay 5 states to make timing work
	DCB
	JFZ 	MORE2
	LBI	0		; delay 8 states
	RET

;finish LOOP from above RST
LOOP2:     LAM                    ;Fetch buffer length (cc) value into the accumulator
           DCB                    ;Make value in B original value
           CPB                    ;See if buffer length same as that in B
           RET                    ;Return with flags yielding results of the comparison

;finish GETCHR from above RST
GETCHR2:
           JFS BIGERR             ;If not then have an overflow condition = error.
           LLA                    ;Else can use it as addr of character to fetch from the
           LAM                    ;Fetch the character from the line input buffer.
           CPI 240                ;See if it is ASCII code for space.
           RET                    ;Return to caller with flags set according to comparison.

;;; HERE IS THE USER DEFINED CHARACTER INPUT TO READ FROM SERIAL PORT
;;; 2400 BAUD VERSION MJW
; Returns Character in A,  destroys B and D - needs to conserve C
; WAIT for start bit
CINPUT:
	INP INPORT
	NDA			; 5
	JTS CINPUT		; 9/11

        LAA                   ; 5  delay to make timing better
; found - delay 1 1/2 bit times
	LBI 	7		; 8
TIMER:				; 
	DCB			; 5
	JFZ TIMER		; 9/11

;grab 8 bits
	LDI	8		; 8

; get 1 bit
; MSB of port contains input stream
; read and move to carry
; shift into MS bit position
; and maintain in B register
DATAIN:
	LBA			; 5
	INP INPORT		; 8
	RAL			; 5
	LAB			; 5
	RAR			; 5

; delay 1 bit time
	LBI 	3		; 8 
BITTIMER:			; 
	DCB			; 5
	JFZ BITTIMER		; 9/11
        LAA                   ; 5  delay to make timing better
	DCD			; 5
	JFZ	DATAIN		; 9/11
;
; result is in a, save in D, echo, then return
;
	LDA                   ; 
	CAL	ECHO2
	LAD
	ORI	200
	RET

;;; no user defined functions yet, stop here if we see one.



SYNTAX:    DATA RST_CLESYM             ;Clear the SYMBOL BUFFER area
           LLI \LB\L340                ;Set L to start of LINE NUMBER BUFFER
           LHI \HB\OLDPG26        ;** Set H to page of LINE NUMBER BUFFER
           LMI 000                ;Initialize line number buff by placing zero as (cc)
           LLI \LB\L201                ;Change pointer to syntax counter/pointer storage loc.
           LMI 001                ;Set pointer to first character (after cc) in line buffer
SYNTX1:    LLI \LB\L201                ;Set pointer to syntax cntr/pntr storage location
           DATA RST_GETCHR             ;Fetch the character pointed to by contents of syntax
           JTZ SYNTX2             ;Cntr/pntr from the line input buffer. If character was
           CPI 260                ;A space, ignore. Else, test to see if character was ASCII
           JTS SYNTX3             ;Code for a decimal digit. If not a decimal digit, consider
           CPI 272                ;Line number to have been processed by jumping
           JFS SYNTX3             ;Over the remainder of this SYNTX1 section.
           LLI \LB\L340                ;If have decimal digit, set pointer to start of LINE
           CAL CONCT1             ;NUMBER BUFFER and append incoming digit there.
SYNTX2:    LLI \LB\L201                ;Reset L to syntax cntr/pntr storage location. Call sub-
           DATA RST_LOOP               ;Routine to advance pntr and test for end of inr)ut buffer
           JFZ SYNTX1             ;If not end of input buffer, go back for next digit
           LLI \LB\L203                ;If end of buffer, only had a line number in the line.
           LMI 000                ;Set pntr to TOKEN storage location. Set TOKEN = 000.
           RET                    ;Return to caller.
SYNTX3:    LLI \LB\L201                ;Reset pointer to syntax cntr/pntr and fetch
           LBM                    ;Position of next character after the line number
           LLI \LB\L202                ;Change pntr to SCAN pntr storage location
           LMB                    ;Store address when SCAN takes up after line number
SYNTX4:    LLI \LB\L202                ;Set pntr to SCAN pntr stomge location
           DATA RST_GETCHR             ;Fetch the character pointed to by contents of the SCAN
           JTZ SYNTX6             ;Pointer storage location. If character was ASCII code
           CPI 275                ;For space, ignore. Else, compare character with "=" sign
           JTZ SYNTX7             ;If is an equal sign, go set TOKEN for IMPLIED LET.
           CPI 250                ;Else, compare character with left parenthesis " ( "
           JTZ SYNTX8             ;If left parenthesis, go set TOKEN for implied array LET
           CAL CONCTS             ;Otherwise, concatenate the character onto the string
           LLI \LB\L203                ;Being constructed in the SYMBOL BUFFER. Now set
           LMI 001                ;Up TOKEN storage location to an initial value of 001.
           LHI \HB\L000_27        ;** Set H to point to start of KEYWORD TABLE.
           LLI \LB\L000_27	 ;Set L to point to start of KEYWORD TABLE.
SYNTX5:    LDI \HB\OLDPG26        ;** Set D to page of SYMBOL BUFFER
           LEI \LB\L120                ;Set E to start of SYMBOL BUFFER
           CAL STRCP              ;Compare char string presently in SYMBOL BUFFER
           RTZ                    ;With entry in KEYWORD TABLE. Exit if match.
           DATA RST_SWITCH             ;TOKEN will be set to keyword found. Else, switch
SYNTXL:    INL                    ;Pointers to get table address back and advance pntr to
           LAM                    ;KEYWORD TABLE. Now look for start of next entry
           NDI 300                ;In KEYWORD TABLE by looking for (cc) byte which
           JFZ SYNTXL             ;Will NOT have a one in the two most sig. bits. Advance
           DATA RST_SWITCH             ;Pntr til next entry found. Then switch pointers apin so
           LLI \LB\L203                ;Table pointer is in D&E. Put addr of TOKEN in L.
           LHI \HB\OLDPG26        ;** And page of TOKEN in H. Fetch the value currently
           LBM                    ;In TOKEN and advance it to account for going on to
           INB                    ;The next entry in the KEYWORD TABLE.
           LMB                    ;Restore the updated TOKEN value back to storage.
           DATA RST_SWITCH             ;Restore the keyword table pointer back to H&L.
           LAB                    ;Put TOKEN count in ACC.
           CPI 015                ;See if have tested all entries in the keyword table.
           JFZ SYNTX5             ;If not, continue checking the keyword table.
SYNTX6:    LLI \LB\L202                ;Set L to SCAN pointer storage location
           LHI \HB\OLDPG26        ;** Set H to page of SCAN pointer stomge location
           DATA RST_LOOP               ;Call routine to advance pntr & test for end of In buffer
           JFZ SYNTX4             ;Go back and add another character to SYMBOL BUFF
           LLI \LB\L203                ;And search table for KEYWORD again. Unless reach
           LMI 377                ;End of line input buffer. In which case set TOKEN=377
           RET                    ;As an error indicator and exit to calling routine.
SYNTX7:    LLI \LB\L203                ;Set pointer to TOKEN storage register. Set TOKEN
           LMI 015                ;Equal to 015 when "=" sign found for IMPLIED LET.
           RET                    ;Exit to calling routine.
SYNTX8:    LLI \LB\L203                ;Set pointer to TOKEN storage register. Set TOKEN
           LMI 016                ;Equal to 016 when "(" found for IMPLIED array LET.
           RET                    ;Exit to calling routine.

                                  ;The following are subroutines used by SYNTAX and
                                  ;other routines in SCELBAL.

BIGERR:    LAI 302                ;Load ASCII code for letters B and G to indicate BIG
           LCI 307                ;ERROR (for when buffer, stack,etc., overflows).
ERROR:     DATA RST_ECHO               ;Call user provided display routine to print ASCII code
           LAC                    ;In accumulator. Transfer ASCII code from C to ACC
           DATA RST_ECHO               ;And repeat to display error codes.
           JMP FINERR             ;Go cpmplete error message (AT LINE) as required.



                                  ;Subroutine to concatenate (append) a character to the
                                  ;SYMBOL BUFFER. Character must be alphanumeric.

CONCTA:    CPI 301                ;See if character code less than that for letter A.
           JTS CONCTN             ;If so, go see if it is numeric.
           CPI 333                ;See if character code greater than that for letter Z.
           JTS CONCTS             ;If not, have valid alphabetical character.
CONCTN:    CPI 260                ;Else, see if character in valid numeric range.
           JTS CONCTE             ;If not, have an error condition.
           CPI 272                ;Continue to check for valid number.
           JFS CONCTE             ;If not, have an error condition.
CONCTS:    LLI \LB\L120                ;If character alphanumeric, can concatenate. Set pointer
           LHI \HB\OLDPG26        ;** To starting address of SYMBOL BUFFER.
CONCT1:    LCM                    ;Fetch old character count in SYMBOL BUFFER.
           INC                    ;Increment the value to account for adding new
           LMC                    ;Character to the buffer. Restore updated (cc).
           LBA                    ;Save character to be appended in register B.
           DATA RST_INDEXC        ;Add (cc) to address in H & L to get new end of buffer
           LMB                    ;Address and append the new character to buffer
           LAI 000                ;Clear the accumulator
           RET                    ;Exit to caller
CONCTE:    JMP SYNERR             ;If character to be appended not alphanumeric, ERROR!

                                  ;Subroutine to compare
                                  ;character strings pointed to by
                                  ;register pairs D & E and H & L.

STRCP:     LAM                    ;Fetch (cc) of first string.
           DATA RST_SWITCH             ;Switch pointers and fetch length of second string (cc)
           LBM                    ;Into register B. Compare the lengths of the two strings.
           CPB                    ;If they are not the same
           RFZ                    ;Return to caller with flags set to non-zero condition
           DATA RST_SWITCH             ;Else, exchange the pointers back to first string.
STRCPL:    DATA RST_ADV                ;Advance the pointer to string number 1 and fetch a
           LAM                    ;Character from that string into the accumulator.
           DATA RST_SWITCH             ;Now switch the pointers to string number 2.
           DATA RST_ADV                ;Advance the pointer in line number 2.
STRCPE:    CPM                    ;Compare char in stxing 1 (ACC) to string 2 (memory)
           RFZ                    ;If not equal, return to cauer with flags set to non-zero
           DATA RST_SWITCH             ;Else, exchange pointers to restore pntr to string 1
           DCB                    ;Decrement the string length counter in register B
           JFZ STRCPL             ;If not finiahed, continue testing entire string
           RET                    ;If complete match, return with flag in zero condition
STRCPC:    LAM                    ;Fetch character pointed to by pointer to string 1
           DATA RST_SWITCH             ;Exchange pointer to examine string 2
           JMP STRCPE             ;Continue the string comparison loop

                                  ;and test to see if the end of the buffer
                                  ;has been reached.


                                  ;The following subroutine is used to
                                  ;input characters from the system's
                                  ;input device (such as a keyboard)
                                  ;into the LINE INPUT BUFFER. Routine has limited
                                  ;editing capability included.
                                  ;(Rubout = delete previous character(s) entered.)
;;; This label, STRIN:	should be location 03 014
STRIN:     LCI 000                ;Initialize register C to zero.
STRIN1:    CAL CINPUT             ;Call user provided device input subroutine to fetch one
           CPI 377                ;Character from the input device. Is it ASCII code for
           JFZ NOTDEL             ;Rubout? Skip to next section if not rubout.
           LAI 334                ;Else, load ASCII code for backslash into ACC.
           DATA RST_ECHO               ;Call user display driver to present backslash as a delete
           DCC                    ;Indicator. Now decrement the input character counter.
           JTS STRIN              ;If at beginning of line do NOT decrement H and L.
           CAL DEC                ;Else, decrement H & L line pointer to erase previous
           JMP STRIN1             ;Entry, then go back for a new input.
NOTDEL:    
//           CPI 203                ;See if character inputted was'CONTROL C'
//           JTZ CTRLC              ;If so, stop inputting and go back to the EXECutive
           CPI 215                ;If not, see if character was carriage-return
           JTZ STRINF             ;If so, have end of line of input
           CPI 212                ;If not, see if character was line-feed
           JTZ STRIN1             ;If so, ignore the input, get another character
           DATA RST_ADV                ;If none of the above, advance contents of H & L
           INC                    ;Increment the character counter
           LMA                    ;Store the new character in the line input buffer
           LAC                    ;Put new character count in the accumulator
           CPI 120                ;Make sure maximum buffer size not exceeded
           JFS BIGERR             ;If buffer size exceeded, go display BG error message
           JMP STRIN1             ;Else can go back to look for next input
STRINF:    LBC                    ;Transfer character count from C to B
           CAL SUBHL              ;Subtract B from H & L to get starting address of
           LMC                    ;The string and place the character count (cc) there
           CAL CRLF               ;Provide a line ending CR & LF combination on the
           RET                    ;Display device. Then exit to caller.

                                  ;Subroutine to subtract contents of CPU register B from
                                  ;the two byte value in CPU registers H & L.

SUBHL:     LAL                    ;Load contents of register L into the accumulator
           SUB                    ;Subtract the contents of register B
           LLA                    ;Restore the new value back to L
           RFC                    ;If no carry, then no underflow. Exit to caller.
           DCH                    ;Else must also decrement contents of H.
           RET                    ;Before retuming to caller.

                                  ;Subroutine to display a character string on the system's
                                  ;display device.

TEXTC:     LCM                    ;Fetch (cc) from the first location in the buffer (H & L
           LAM                    ;Pointing there upon entry) into register B and ACC.
           NDA                    ;Test the character count value.
           RTZ                    ;No display if (cc) is zero.
TEXTCL:    DATA RST_ADV                ;Advance pointer to next location in buffer
           LAM                    ;Fetch a character from the buffer into ACC
           DATA RST_ECHO               ;Call the user's display driver subroutine
           DCC                    ;Decrement the (cc)
           JFZ TEXTCL             ;If character counter not zero, continue display
           RET                    ;Exit to caller when (cc) is zero.

                                  ;Subroutine to provide carriage-return and line-feed
                                  ;combination to system's display device. Routine also
                                  ;initializes a column counter to zero. Column counter
                                  ;is used by selected output routines to count the num-
                                  ;ber of characters that have been displayed on a line.

CRLF:      LAI 215                ;Load ASCII code for carriage-return into ACC
           DATA RST_ECHO               ;Call user provided display driver subroutine
           LAI 212                ;Load ASCII code for line-feed into ACC
           DATA RST_ECHO               ;Call user provided display driver subroutine
           LLI \LB\L043                ;Set L to point to COLUMN COUNTER storage location
           LHI \HB\L043         ;** Set H to page of COLUMN COUNTER
           LMI 001                ;Initialize COLUMN COUNTER to a value of one
           LHD                    ;Restore H from D (saved by ECHO subroutine)
           LLE                    ;Restore L from E (saved by ECHO subroutine)
           RET                    ;Then exit to calling routine

                                  ;Subroutine to decrement double-byte value in CPU
                                  ;registers H and L.

DEC:       DCL                    ;Decrement contents of L
           INL                    ;Now increment to exercise CPU flags
           JFZ DECNO              ;If L not presently zero, skip decrementing H
           DCH                    ;Else decrement H
DECNO:     DCL                    ;Do the actual decrement of L
           RET                    ;Return to caller


                                  ;Subroutine to index the value in CPU registers H and L
                                  ;by the contents of CPU register B.

INDEXB:    LAL                    ;Load L into the accumulator
           ADB                    ;Add B to that value
           LLA                    ;Restore the new value to L
           RFC                    ;If no carry,  return to caller
           INH                    ;Else, increment value in H
           RET                    ;Before returning to caller


EVAL:      LLI \LB\L227                ;Load L with address of ARITHMETIC STACK pointer
           LHI \HB\L227         ;** Set H to page of ARITHMETIC STACK pointer
           LMI \LB\L230_0-4                ;Initialize ARITH STACK pointer value to addr minus 4
           ;INL                    ;Advance memory pointer to FUN/ARRAY STACK pntr
           LLI \LB\L230                    ;different page FUN/ARRAY STACK pntr
           LHI \HB\OLDPG26        ;** Set H to page of FUN/ARRAY STACK pointer
           LMI 000                ;Initialize FUNIARRAY STACK pointer to start of stack
           DATA RST_CLESYM             ;Initialize the SYMBOL BUFFER to empty condition
           LLI \LB\L210                ;Load L with address of OPERATOR STACK pointer
           LMI 000                ;Initialize OPERATOR STACK pointer value
           LLI \LB\L276                ;Set L to address of EVAL pointer (start of expression)
           LBM                    ;Fetch the EVAL pointer value into register B
           LLI \LB\L200                ;Set up a working pointer register in this location
           LMB                    ;And initialize EVAL CURRENT pointer
SCAN1:     LLI \LB\L200                ;Load L with address of EVAL CURRENT pointer
           DATA RST_GETCHR             ;Fetch a character in the expression being evaluated
           JTZ SCAN10             ;If character is a space, jump out of this section
           CPI 253                ;See if character is a "+" sign
           JFZ SCAN2              ;If not, continue checking for an operator
           LLI \LB\L176                ;If yes, set pointer to PARSER TOKEN storage location
           LMI 001                ;Place TOKEN value for "+" sign in PARSER TOKEN
           JMP SCANFN             ;Go to PARSER subroutine entry point
SCAN2:     CPI 255                ;See if character is a minus ("-") sign
           JFZ SCAN4              ;If not, continue checking for an operator
           LLI \LB\L120                ;If yes, check the length of the symbol stored in the
           LAM                    ;SYMBOL BUFFER by fetching the (cc) byte
           NDA                    ;And testing to see if (cc) is zero
           JFZ SCAN3              ;If length not zero, then not a unary minus indicator
           LLI \LB\L176                ;Else, check to see if last operator was a right parenthesi
           LAM                    ;By fetching the value in the PARSER TOKEN storage
           CPI 007                ;Location and seeing if it is token value for ")"
           JTZ SCAN3              ;If last operator was I')" then do not have a unary minus
           CPI 003                ;Check to see if last operator was C4*~2
           JTZ SYNERR             ;If yes, then have a syntax error
           CPI 005                ;Check to see if last operator was exponentiation
           JTZ SYNERR             ;If yes, then have a syntax error
           LLI \LB\L120                ;If none of the above, then minus sign is unary, put
           LMI 001                ;Character string representing the
           INL                    ;Value zero in the SYMBOL BUFFER in string format
           LMI 260                ;(Character count (cc) followed by ASCII code for zero)
SCAN3:     LLI \LB\L176                ;Set L to address of PARSER TOKEN storage location
           LMI 002                ;Set PARSER TOKEN value for minus operator
SCANFN:    CAL PARSER             ;Call the PARSER subroutine to process current symbol
           JMP SCAN10             ;And operator. Then jump to continue processing.
SCAN4:     CPI 252                ;See if character fetched from expression is
           JFZ SCAN5              ;If not, continue checking for an operator
           LLI \LB\L176                ;If yes, set pointer to PARSER TOKEN storage location
           LMI 003                ;Place TOKEN value for "*" (multiplication) operator in
           JMP SCANFN             ;PARSER TOKEN and go to PARSER subroutine entry
SCAN5:     CPI 257                ;See if character fetched from expression is
           JFZ SCAN6              ;If not, continue checking for an operator
           LLI \LB\L176                ;If yes, set pointer to PARSER TOKEN storage location
           LMI 004                ;Place TOKEN value for "/" (division) operator in
           JMP SCANFN             ;PARSER TOKEN and go to PARSER subroutine entry
SCAN6:     CPI 250                ;See if character fetched from expression is
           JFZ SCAN7              ;If not, continue checking for an operator
           LLI \LB\L230                ;If yes, load L with address of FUN/ARRAY STACK
           LBM                    ;Pointer. Fetch the value in the stack pointer. Increment
           INB                    ;It to indicate number of "(" operators encountered.
           LMB                    ;Restore the updated stack pointer back to memory
           ;CAL FUNARR             ;Call subroutine to process possible FUNCTION or
           LLI \LB\L176                ;ARRAY variable subscript. Ihen set pointer to
           LMI 006                ;PARSER TOKEN storage and set value for operator
           JMP SCANFN             ;Go to PARSER subroutine entry point.
SCAN7:     CPI 251                ;See if character fetched from expression is
           JFZ SCAN8              ;If not, continue checking for an operator
           LLI \LB\L176                ;If yes, load L with address of PARSER TOKEN
           LMI 007                ;Set PARSER TOKEN value to reflect ")"
           CAL PARSER             ;Call the  PARSER subroutine to process current symbol
	
           ;CAL PRIGHT             ;Call subroutine to handle FUNCTION or ARRAY
           LLI \LB\L230                ;Load L with address of FUN/ARRAY STACK pointer
           LHI \HB\OLDPG26        ;** Set H to page of FUN/ARRAY STACK pointer
           LBM                    ;Fetch the value in the stack pointer. Decrement it
           DCB                    ;To account for left parenthesis just processed.
           LMB                    ;Restore the updated value back to memory.
           JMP SCAN10             ;Jump to continue processing expression.
SCAN8:     CPI 336                ;See if character fetched from expression is " t
           JFZ SCAN9              ;If not, continue checking for an operator
           LLI \LB\L176                ;If yes, load L with address of PARSER TOKEN
           LMI 005                ;Put in value for exponentiation
           JMP SCANFN             ;Go to PARSER subroutine entry point.
SCAN9:     CPI 274                ;See if character fetched is the "less than" sign
           JFZ SCAN11             ;If not, continue checking for an operator
           LLI \LB\L200                ;If yes, set L to the EVAL CURRENT pointer
           LBM                    ;Fetch the pointer
           INB                    ;Increment it to point to the next character
           LMB                    ;Restore the updated pointer value
           DATA RST_GETCHR             ;Fetch the next character in the expression
           CPI 275                ;Is the character the "= 9 $ sign?
           JTZ SCAN13             ;If so, have 'less than or equal" combination
           CPI 276                ;Is the character the "greater than" sign?
           JTZ SCAN15             ;If so, have "less than or greater than" combination
           LLI \LB\L200                ;Else character is not part of the operator. Set L back
           LBM                    ;To the EVAL CURRENT pointer. Fetch the pointer
           DCB                    ;Value and decriment it back one character in the
           LMB                    ;Expression. Restore the original pointer value.
           LLI \LB\L176                ;Have just the 'less than" operator. Set L to the
           LMI 011                ;PARSER TOKEN storage location and set the value for
           JMP SCANFN             ;The 'less than" sign then go to PARSER entry point.
SCAN11:    CPI 275                ;See if character fetched is the "= " sign
           JFZ SCAN12             ;If not, continue checking for an operator
           LLI \LB\L200                ;If yes, set L to the EVAL CURRENT pointer
           LBM                    ;Fetch the pointer
           INB                    ;Increment it to point to the next character
           LMB                    ;Restore the updated pointer value
           DATA RST_GETCHR             ;Fetch the next character in the expression
           CPI 274                ;Is the character the "less than" sign?
           JTZ SCAN13             ;If so, have "less than or equal" combination
           CPI 276                ;Is the character the "greater than" sign?
           JTZ SCAN14             ;If so, have "equal or greater than" combination
           LLI \LB\L200                ;Else character is not part of the operator. Set L back
           LBM                    ;To the EVAL CURRENT pointer. Fetch the pointer
           DCB                    ;Value and decrement it back one character in the
           LMB                    ;Expression. Restore the original pointer value.
           LLI \LB\L176                ;Just have '~-- " operator. Set L to the PARSER TOKEN
           LMI 012                ;Storage location and set the value for the sign.
           JMP SCANFN             ;Go to the PARSER entry point.
SCAN12:    CPI 276                ;See if character fetched is the "greater than" sign
           JFZ SCAN16             ;If not, go append the character to the SYMBOL BUFF
           LLI \LB\L200                ;If so, set L to the EVAL CURRENT pointer
           LBM                    ;Fetch the pointer
           INB                    ;Increment it to point to the next character
           LMB                    ;Restore the updated pointer value
           DATA RST_GETCHR             ;Fetch the next character in the expression
           CPI 274                ;Is the character the "less than" sign?
           JTZ SCAN15             ;If so, have "less than or greater than" combination
           CPI 275                ;Is the character the "= " sign?
           JTZ SCAN14             ;If so, have the "equal to or greater than " combination
           LLI \LB\L200                ;Else character is not part of the operator. Set L back
           LBM                    ;To the EVAL CURRENT pointer. Fetch the pointer
           DCB                    ;Value and decrement it back one character in the
           LMB                    ;Expression. Restore the original pointer value.
           LLI \LB\L176                ;Have just the "greater than" operator. Set L to the
           LMI 013                ;PARSER TOKEN storage location and set the value for
           JMP SCANFN             ;The "greater than" sign then go to PARSER entry
SCAN13:    LLI \LB\L176                ;When have 'less than or equal" combination set L to
           LMI 014                ;PARSER TOKEN storage location and set the value.
           JMP SCANFN             ;Then go to the PARSER entry point.
SCAN14:    LLI \LB\L176                ;When have "equal to or greater than" combination set L
           LMI 015                ;To PARSER TOKEN storage location and set the value.
           JMP SCANFN             ;Then go to the PARSER entry point.
SCAN15:    LLI \LB\L176                ;When have 'less than or greater than" combination set
           LMI 016                ;L to PARSER TOKEN storage location and set value.
           JMP SCANFN             ;Then go to the PARSER entry point.
SCAN16:    CAL CONCTS             ;Concatenate the character to the SYMBOL BUFFER
SCAN10:    LLI \LB\L200                ;Set L to the EVAL CURRENT pointer storage location
           LHI \HB\OLDPG26        ;** Set H to page of EVAL CURRENT pointer
           LBM                    ;Fetch the EVAL CURRENT pointer value into B
           INB                    ;Increment the pointer value to point to next character
           LMB                    ;In the expression and restore the updated value.
           LLI \LB\L277                ;Set L to EVAL FINISH storage location.
           LAM                    ;Fetch the EVAL FINISH value into the accumulator.
           DCB                    ;Set B to last character processed in the expression.
           CPB                    ;See if last character was at EVAL FINISH location.
           JFZ SCAN1              ;If not, continue processing the expression. Else, jump
           JMP PARSEP             ;To final evaluation procedure and test.  (Directs routine
           HLT                    ;To a dislocated section.) Safety Halt in unused byte.
PARSER:    LLI \LB\L120                ;Load L with starting address of SYMBOL BUFFER
           LHI \HB\OLDPG26        ;** Load H with page of SYMBOL BUFFER
           LAM                    ;Fetch the (cc) for  contents of SYMBOL BUFFER
           NDA                    ;Into the ACC and see if buffer is  empty
           JTZ PARSE              ;If empty then no need to convert contents
           INL                    ;If not empty, advance buffer pointer
           LAM                    ;Fetch the first character in the buffer
           ;CPI 256                ;See if it is ASCII code for decimal sign
           ;JTZ PARNUM             ;If yes, consider contents of buffer to be a number
           CPI 260                ;If not decimal sign, see if first character represents
           JTS LOOKUP             ;A deciinal digit, if not, should have a variable
           CPI 272                ;Continue to test for a decimal digit
           JFS LOOKUP             ;If not, go look up the variable nwne
;PARNUM:    DCL                    ;If SYMBOL BUFFER contains number, decrement
;           LAM                    ;Buffer pointer back to (cc) and fetch it to ACC
;           CPI 001                ;See if length of string in buffer is just one
;           JTZ NOEXPO             ;If so, cannot have number with scientific notation
;           ADL                    ;If not, add length to buffer pointer to
;           LLA                    ;Point to last character in the buffer
;           LAM                    ;Fetch the last character in buffer and see if it
;           CPI 305                ;Represents letter E for Exponent
;           JFZ NOEXPO             ;If not, cannot have number with scientific notation
;           LLI \LB\L200                ;If yes, have part of a scientific number, set pointer to
;           DATA RST_GETCHR             ;Get the operator that follows the E and append it to
;           JMP CONCTS             ;The SYMBOL BUFFER and return to EVAL routine
NOEXPO:    LLI \LB\L227                ;Load L with address of ARITHMETIC STACK pointer
           LHI \HB\L227         ;** Load H with page of ARITHMETIC STACK pointer
           LAM                    ;Fetch AS pointer value to ACC and add four to account
           ADI 004                ;For the number of bytes required to store a number in
           LMA                    ;Floating point format. Restore pointer to mernory.
           LLA                    ;Then, change L to point to entry position in the AS
           CAL FSTORE             ;Place contents of the FPACC onto top of the AS
           LLI \LB\L120                ;Change L to point to start of the SYMBOL BUFFER
           LHI \HB\OLDPG26        ;** Set H to page of the SYMBOL BUFFER
           CAL DINPUT             ;Convert number in the buffer to floating point format
           JMP PARSE              ;In the FPACC then jump to check operator sign.
LOOKUP:    LLI \LB\L370                ;Load L with address of LOOK-UP COUNTER
           LHI \HB\OLDPG26        ;** Load H with page of the counter
           LMI 000                ;Initialize the counter to zero
           LLI \LB\L120                ;Load L with starting address of the SYMBOL BUFFER
           LDI \HB\L210_27        ;** Load D with page of the VARIABLES TABLE
           LEI \LB\L210_27	 ;Load E with start of the VARL433LES TABLE
           LAM                    ;Fetch the (cc) for the string in the SYMBOL BUFFER
           CPI 001                ;See if the name length is just one character. If not,
           JFZ LOOKU1             ;Should be two so proceed to look-up routine. Else,
           LLI \LB\L122                ;Change L to second character byte in the buffer and set
           LMI 000                ;It to zero to provide compatibility with entries in table
LOOKU1:    LLI \LB\L121                ;Load L with addr of first character in the SYMBOL
           LHI \HB\OLDPG26        ;** BUFFER. Set H to page of the SYMBOL BUFFER.
           DATA RST_SWITCH             ;Exchange contents of D&E with H&L so that can
           LAM                    ;Fetch the first character of a name in the VARIABLES
           INL                    ;TABLE. Advance the table pointer and save the
           LBM                    ;Second byte of name in B. Then advance the pointer
           INL                    ;Again to reach first bvte of floating point forrnatted
           DATA RST_SWITCH             ;Number in table. Now exchange D&E with H&L and
           CPM                    ;Compare first byte in table against first char in buffer
           JFZ LOOKU2             ;If not the same, go try next entry in table. If same,
           INL                    ;Advance pointer to next char in buffer. Transfer the
           LAB                    ;Character in B (second byte in table entry) to the ACC
           CPM                    ;Compare it against second character in the buffer.
           JTZ LOOKU4             ;If match, have found the name in the VARIABLES tbl.
LOOKU2:    CAL AD4DE              ;Call subroutine to add four to the pointer in D&E to
           LLI \LB\L370                ;Advance the table pointer over value bytes. Then set
           LHI \HB\OLDPG26        ;** Up H and L to point to LOOK-UP COUNTER.
           LBM                    ;Fetch counter value (counts number of entries tested
           INB                    ;In the VARIABLES TABLE), increment it
           LMB                    ;And restore it back to meynory
           LLI \LB\L077_27                ;Load L with address of SYMBOL VARIABLES counter
           LHI \HB\L077_27        ;** Do same for H. (Counts number of names in table.)
           LAB                    ;Place LOOK-UP COUNTER value in the accumulator.
           CPM                    ;Compare it with number of entries in the table.
           JFZ LOOKU1             ;If have not reached end of table, keep looking for name.
           LLI \LB\L077_27                ;If reach end of table without match, need to add name
           LHI \HB\L077_27        ;** To table. First set H & L to the SYMBOL
           LBM                    ;VARIABLES counter. Fetch the counter value and
           INB                    ;Increment to account for new name being added to the
           LMB                    ;Table. Restore the updated count to meinory. Also,
           LAB                    ;Move the new counter value to the accumulator and
           CPI 025                ;Check to see that table size is not exceeded. If try to
           JFS BIGERR             ;Go over 20 (decirnal) entries then have BIG error.
           LLI \LB\L121                ;Else, set L to point to first character in the SYMBOL
           LHI \HB\OLDPG26        ;** BUFFER and set H to proper page. Set the number
           LBI 002                ;Of bytes to be transferred into register B as a counter.
           CAL MOVEIT             ;Move the symbol name from the buffer to the
           LLE                    ;VARIABLES TABLE. Now set up H & L with value
           LHD                    ;Contained in D & E after moving ops (points to first
           XRA                    ;Byte of the value to be associated with the symbol
           LMA                    ;Name.) Clear the accumulator and place zero in all four
           INL                    ;Bytes associated with the variable name entered
           LMA                    ;In the VARIABLES TABLE
           INL                    ;In order to
           LMA                    ;Assign an
           INL                    ;Initial value
           LMA                    ;To the variable narne
           LAL                    ;Then transfer the address in L to the acc'umulator
           SUI 004                ;Subtract four to reset the pointer to start of zeroing ops
           LEA                    ;Restore the address in D & E to be in same state as if
           LDH                    ;Name was found in the table in the LOOKUP routine
LOOKU4:    CAL SAVEHL             ;Save current address to VARIABLES TABLE
           LLI \LB\L227                ;Load L with address of ARITHMETIC STACK pointer
           LHI \HB\L227 	;** Load H with page of the pointer
           LAM                    ;Fetch the AS pointer value to the accumulator
           ADI 004                ;Add four to account for next floating point forrnatted
           LMA                    ;Number to be stored in the stack. Restore the stack
           LLA                    ;Pointer to memory and set it up in register L too.
           CAL FSTORE             ;Place the value in the FPACC on the top of the
           CAL RESTHL             ;ARITHMETIC STACK. Restore the VARIABLES
           DATA RST_SWITCH             ;TABLE pointer to H&L and move it to D&E. Now load
           CAL FLOAD              ;The VARIABLE value from the table to the FPACC.
PARSE:     DATA RST_CLESYM             ;Clear the SYMBOL BUFFER
           LLI \LB\L176                ;Load L with address of PARSER TOKEN VALUE
           LAM                    ;And fetch the token value into the accumulator
           CPI 007                ;Is it token value for right parenthesis ")" ? If so, have
           JTZ PARSE2             ;Special case where must perforin ops til find a "(" !
           ADI \LB\L240                ;Else, fon-n address to HEIRARCHY IN table and
           LHI \HB\L240           ;romable page
           LLA                    ;Set L to point to HEIRARCHY IN VALUE in the table
           LBM                    ;Fetch the heirarchy value from the table to register B
           LLI \LB\L210                ;Set L to OPERATOR STACK pointer storage location
           LHI \HB\OLDPG26         ;put back to oldpg26
           LCM                    ;Fetch the OS pointer into CPU register C
           DATA RST_INDEXC         ;Add OS pointer to address of OS pointer storage loc
           LAM                    ;Fetch the token value for the operator at top of the OS
           ADI \LB\L257                ;And form address to HEIRARCHY OUT table
           LHI \HB\L257           ; ROMable page
           LLA                    ;Set L to point to HEIRARCHY OUT VALUE in the
           LAB                    ;Table. Move the HEIRARCHY IN value to the ACC.
           CPM                    ;Compare the HEIRARCHY IN with the HEIRARCHY
           LHI \HB\OLDPG26        ; put back to oldpg26
           JTZ PARSE1             ;OUT value. If heirarchy of current operator equal to or
           JTS PARSE1             ;Less than operator on top of OS stack, perfo
           LLI \LB\L176                ;Operation indicated in top of OS stack. Else, fetch the
           LBM                    ;Current operator token value into register B.
           LLI \LB\L210                ;Load L with address of the OPERATOR STACK pntr
           LCM                    ;Fetch the stack pointer value
           INC                    ;Increment it to account for new entry on the stack
           LMC                    ;Restore the stack pointer value to memory
           DATA RST_INDEXC             ;For in pointer to next entry in OPERATOR STACK
           LMB                    ;Place the current operator token value on top of the OS
           RET                    ;Exit back to the EVAL routine.
PARSE1:    LLI \LB\L210                ;Load L with address of the OPERATOR STACK pntr
           LAM                    ;Fetch the stack pointer value to the accumulator
           ADL                    ;Add in the value of the stack pointer address to form
           LLA                    ;Address that points to top entry in the OS
           LAM                    ;Fetch the token value at the top of the OS to the ACC
           NDA                    ;Check to see if the token value is zero for end of stack
           RTZ                    ;Exit back to the EVAL routine if stack empty
           LLI \LB\L210                ;Else, reset L to the OS pointer storage location
           LCM                    ;Fetch the pointer value
           DCC                    ;Decrement it to account for operator rernoved from
           LMC                    ;The OPERATOR STACK and restore the pointer value
           CAL FPOPER             ;Perform the operation obtained from the top of the OS
           JMP PARSE              ;Continue to compare current operator against top of OS
PARSE2:    LLI \LB\L210                ;Load L with address of the OPERATOR STACK pntr
           LHI \HB\OLDPG26        ;** Load H with page of the pointer
           LAM                    ;Fetch the stack pointer value to the accumulator
           ADL                    ;Add in the value of the stack pointer address to form
           LLA                    ;Address that points to top entry in the OS
           LAM                    ;Fetch the token value at the top of the 0 S to the ACC
           NDA                    ;Check to see if the token value is zero for end of stack
           JTZ PARNER             ;If end of stack, then have a parenthesis error condx
           LLI \LB\L210                ;Else, reset L to the OS pointer storage location
           LCM                    ;Fetch the pointer value
           DCC                    ;Decrement it to account for operator removed from
           LMC                    ;The OPERATOR STACK and restore the pointer value
           CPI 006                ;Check to see if token value is "(" to close parenthesis
           RTZ                    ;If so, exit back to EVAL routine.
           CAL FPOPER             ;Else, perforin the op obtained from the top of the OS
           JMP PARSE2             ;Continue to process data in parenthesis
FPOPER:    LLI \LB\L371                ;Load L with address of TEMP OP storage location
           LHI \HB\OLDPG26        ;** Load H with page of TEMP OP storage location
           LMA                    ;Store OP (from top of OPERATOR STACK)
           LLI \LB\L227                ;Change L to address of ARff HMETIC STACK pointer
           LHI \HB\L227         ;** Load H with page of AS pointer
           LAM                    ;Fetch AS pointer value into ACC
           LLA                    ;Set L to top of ARITHMETIC STACK
           CAL OPLOAD             ;Transfer number from ARffHMETIC STACK to FPOP
           LLI \LB\L227                ;Restore pointer to AS pointer
           LAM                    ;Fetch the pointer value to the ACC and subtract four
           SUI 004                ;To remove top value from the ARITHMETIC STACK
           LMA                    ;Restore the updated AS pointer to memory
           LLI \LB\L371                ;Set L to address of TEMP OP storage location
           LHI \HB\OLDPG26        ;** Set H to page of TEMP OP storage location
           LAM                    ;Fetch the operator token value to the ACC
           CPI 001                ;Find out which kind of operation indicated
           JTZ FPADD              ;Perforn addition if have plus operator
           CPI 002                ;If not plus, see if minus
           JTZ FPSUB              ;Perform subtraction if have minus operator
           CPI 003                ;If not minus, see if multiplication
           JTZ FPMULT             ;Perform multiplication if have multiplication operator
           CPI 004                ;If not multiplication, see if division
           JTZ FPDIV              ;Perform division if have division operator
           CPI 011                ;If not exponentiation, see if "less than" operator
           JTZ LT                 ;Perform compaison for "less than" op if indicated
           CPI 012                ;If not 'less than" see if have "equal" operator
           JTZ EQ                 ;Perforin comparison for "equal" op if indicated
           CPI 013                ;If not "equal" see if have "greater than" operator
           JTZ GT                 ;Perform comparison for "greater than" op if indicated
           CPI 014                ;If not "'greater than" see if have 'less than or equal" op
           JTZ LE                 ;Perform comparison for the combination op if indicated
           CPI 015                ;See if have "equal to or greater than" operator
           JTZ GE                 ;Perform comparison for the combination op if indicated
           CPI 016                ;See if have "less than or greater than" operator
           JTZ NE                 ;Perform comparison for the combination op if indicated
PARNER:    LLI \LB\L230                ;If cannot find operator, expression is not balanced
           LHI \HB\OLDPG26        ;** Set H and L to address of F/A STACK pointer
           LMI 000                ;Clear the F/A STACK pointer to re-initialize
           LAI 311                ;Load ASCII code for letter I into the accumulator
           LCI 250                ;And code for "(" character into register C
           JMP ERROR              ;Go display 1( for "Imbalanced Parenthesis") error msg
LT:        CAL FPSUB              ;Subtract contents of FPACC from FPOP to compare
           LLI \LB\L126                ;++fxp: Set L to point to the MSW of the FPACC (Contains
           LAM                    ;Result of the subtraction.) Fetch the MSW of the
           NDA                    ;FPACC to the accumulator and test to see if result is
           JTS CTRUE              ;Positive or negative. Set up the FPACC as a function
           JMP CFALSE             ;Of the result obtained.
EQ:        CAL FPSUB              ;Subtract contents of FPACC from FPOP to compare
           LLI \LB\L126                ;++fxp: Set L to signext MSW of the FPACC (Contains
           LAM                    ;Result of the subtraction.) Fetch the MSW of the
           ;NDA                    ;FPACC to the accumulator and test to see if result is
EQFXP:     DCL                    ;++fxp: MSW of 16-bit fixed point
           ORM                    ;++fxp: or together to test for zero
           DCL                    ;++fxp: LSW of 16-bit fixed point
           ORM                    ;++fxp: or together to test for zero
           JTZ CTRUE              ;Equal. Set up the FPACC as a function
           JMP CFALSE             ;Of the result obtained.
GT:        CAL FPSUB              ;Subtract contents of FPACC from FPOP to compare
           LLI \LB\L126                ;++fxp: Set L to point to the MSW of the FPACC (Contains
           LAM                    ;Result of the subtraction.) Fetch the MSW of the
           NDA                    ;FPACC to the accumulator and test to see if result is
           JTZ NEFXP              ;++fxp: Positive, Negative, or Equal. Set up the FPACC
           JFS CTRUE              ;As a function
           JMP CFALSE             ;Of the result obtained.
LE:        CAL FPSUB              ;Subtract contents of FPACC from FPOP to compare
           LLI \LB\L126                ;++fxp: Set L to point to the MSW of the FPACC (Contains
           LAM                    ;Result of the subtraction.) Fetch the MSW of the
           NDA                    ;FPACC to the accumulator and test to see if result is
           JTZ EQFXP              ;Positive, Negative, or Equal. Set up the FPACC
           JTS CTRUE              ;As a function
           JMP CFALSE             ;Of the result obtained
GE:        CAL FPSUB              ;Submit contents of FPACC from FPOP to compare
           LLI \LB\L126                ;++fxp: Set L to point to the MSW of the FPACC (Contains
           LAM                    ;Result of the subtraction.) Fetch the MSW of the
           NDA                    ;FPACC to the accumulator and test to see if result is
           JFS CTRUE              ;Positive or Negative. Set up the FPACC
           JMP CFALSE             ;As a function of the result obtained
NE:        CAL FPSUB              ;Subtract contents of FPACC from FPOP to compare
           LLI \LB\L126                ;++fxp: Set L to sign ext MSW of the FPACC (Contains
           LAM                    ;Result of the subtraction.) Fetch the MSW of the
NEFXP:     DCL                    ;++fxp: MSW of 16-bit fixed point
           ORM                    ;++fxp: or together to test for zero
           DCL                    ;++fxp: LSW of 16-bit fixed point
           ORM                    ;++fxp: or together to test for zero
           JTZ CFALSE             ;Equal. Set up the FPACC as a function of the result.
CTRUE:
FPONE:     LLI \LB\L004                ;Load L with address of floating point value +1.0
           LHI \HB\L004
           JMP FLOAD              ;Load FPACC with value +1.0 and exit to caller
FP0:       LHI \HB\OLDPG1         ;** Load H with floating point working registers page
CFALSE:    LLI \LB\L127                ;Load L with address of FPACC Exponent register
           LMI 000                ;Set the FPACC Exponent to zero and then set the
                                  ;Following subroutine clears the FPACC to the zero
                                  ;condition.

FPZERO:    LLI \LB\L127                ;++fxp: no extension for fxp Set L point to MSW of FPACC
           XRA                    ;Clear the accumulator
           LMA                    ;Set the MSW of FPACC to zero
           DCL                    ;Decrement the pointer
           LMA                    ;Set the next significant word of FPACC to zero
           DCL                    ;Decrement the pointer
           LMA                    ;Set the LSW of FPACC to zero
           DCL                    ;Decrement the pointer
           LMA                    ;Set the auxiliary FPACC byte to zero
           RET                    ;Exit to calling routine
AD4DE:     LAE                    ;Subroutine to add four to the value in register E.
           ADI 004                ;Move contents of E to the ACC and add four.
           LEA                    ;Restore the updated value back to register E.
           RET                    ;Return to the calling routine.

;;; The label PRIGHT: SHOULD BE UP TO 07 003

;PRIGHT:    
;           LLI \LB\L230                ;Load L with address of F/A STACK pointer
;           LHI \HB\OLDPG26        ;** Load H with page of F/A STACK pointer
;           LAM                    ;Fetch the pointer value into the ACC
;           ADL                    ;Form pointer to top of the F/A STACK
;           LLA                    ;Set L to point to top of the F/A STACK
;           LAM                    ;Fetch the contents of the top of the F/A STACK into
;           LMI 000                ;The ACC then clear the top of the F/A STACK
;           LLI \LB\L203                ;Load L with address of F /A STACK TEMP storage
;           LHI \HB\OLDPG27        ;** Location. Set H to page of F/A STACK TEMP
;           LMA                    ;Store value from top of F/A STACK into temp loc.
;           NDA                    ;Test to see if token value in top of stack was zero
;           RTZ                    ;If so, just had simple grouping parenthesis!
;           JTS PRIGH1             ;@@ If token value minus, indicates array subscript
;           CPI 001                ;For positive token value, look for appropriate function
;           RTZ               ;If token value for INTeger function, go do it.
;           CPI 002                ;Else, see if token value for SIGN function.
;           JTZ SGNX               ;If so, go do it.
;           CPI 003                ;Else, see if token value for ABSolute function
;           JTZ ABSX               ;If so, go do it.
;           CPI 004                ;If not, see if token value for SQuare Root function
;           JTZ SQRX               ;If so, go do it.
;           CPI 005                ;If not, see if token value for TAB function
;           JTZ TABX               ;If so, go do it.
;           CPI 006                ;If not, see if token value for RaNDom function
;           JTZ RNDX               ;If so, go find a random number.
;           CPI 007                ;If not, see if token value for CHaRacter function
;           JTZ CHRX               ;If so, go perform the function.
           ;CPI 010                ;Else, see if token for user defined machine language
           ;JTZ UDEFX              ;# Function. If so, perform the User DEfined Function
;           HLT                    ;Safety halt. Program should not reach this location!

;;; The label FUNARR SHOULD BE AT 07 100
;FUNARR:    LLI \LB\L120                ;Load L with starting address of SYMBOL BUFFER
;           LHI \HB\OLDPG26        ;** Load H with page of SYMBOL BUFFER
;           LAM                    ;Fetch the (cc) for contents of buffer to the ACC
;           NDA                    ;See if (cc) is zero, if so buffer is empty, return to
;           RTZ                    ;Caller as have simple grouping parenthesis sign
;           LLI \LB\L202_27                ;Else set L to TEMP COUNTER location
;           LHI \HB\OLDPG27        ;** Set H to TEMP COUNTER page
;           LMI 000                ;Initialize TEMP COUNTER to zero
;FUNAR1:    LLI \LB\L202_27                ;Load L with address of TEMP COUNTER
;           LHI \HB\OLDPG27        ;** Load H with page of TEMP COUNTER
;           LBM                    ;Fetch the counter value to register B
;           INB                    ;Increment the counter
;           LMB                    ;Restore the updated value to memory
;           LCI 002                ;Initialize C to a value of two for future ops
;           LLI \LB\L274                ;Load L with starting address (less four) of FUNCTION
;           LHI \HB\OLDPG26        ;** LOOK-UP TABLE. Set H to table page.
;           CAL TABADR             ;Find address of next entry in the table
;           LDI \HB\OLDPG26        ;** Load D with page of SYMBOL BUFFER
;           LEI \LB\L120                ;Load E with starting address of SYMBOL BUFFER
;           CAL STRCP              ;Compare entry in FUNCTION LOOK-UP TABLE with
;           JTZ FUNAR4             ;Contents of SYMBOL BUFFER. If find match, go set
;           LLI \LB\L202_27                ;Up the function token value. Else, set L to the TEMP
;           LHI \HB\OLDPG27        ;** COUNTER and set H to the proper page. Fetch the
;           LAM                    ;Current counter value and see if have tried all eight
;           CPI 010                ;Possible functions in the table.
;           JFZ FUNAR1             ;If not, go back and check the next entry.
;           LLI \LB\L202_27                ;If have tried all of the entries in the table, set L
;           LHI \HB\OLDPG27        ;** As well as H to the address of the TEMP COUI,.7ER
;           LMI 000                ;And reset it to zero. Now go see if have subscripted
;;           JMP FUNAR2             ;@@ Array (unless array capability not in program).
;FAERR:     LLI \LB\L230                ;Load L with address of F/A STACK pointer
;           LHI \HB\OLDPG26        ;** Load H with page of F/A STACK pointer
;           LMI 000                ;Clear the F/A STACK pointer to reset on an error
;           LAI 306                ;Load the ASCII code for letter F into the ACC
;           LCI 301                ;Load the ASCII code for letter A into register C
;           JMP ERROR              ;Go display the FA error message
;FUNAR4:    LLI \LB\L202_27                ;Load L with address of TEMP COUNTER
;           LHI \HB\OLDPG27        ;** Set H to page of TEMP COUNTER
;           LBM                    ;Load value in counter to register B. This is FUNCTION
;           LLI \LB\L230                ;TOKEN VALUE. Cbange- L to F/A STACK pointer.
;           LHI \HB\OLDPG26        ;** Load H with page of F/A STACK pointer.
;           LCM                    ;Fetch the F/A STACK pointer value into register C.
;           CAL INDEXC             ;Form the address to the top of the F/A STACK.
;           LMB                    ;Store the FUNCTION TOKEN VALUE in the F/A
;           DATA RST_CLESYM             ;STACK. Then exit by clearing the SYMBOL BUFFER.
;           RET
;TABADR:    LAB                    ;Move the TEMP COUNTER value from B to ACC
;TABAD1:    RLC                    ;Multiply by four using this loop to form value equal
;           DCC                    ;To number of bytes per entry (4) times current entry
;           JFZ TABAD1             ;In the FUNCTION LOOK-UP TABLE.
;           ADL                    ;Add this value to the starting address of the table.
;           LLA                    ;Form pointer to next entry in table
;           RFC                    ;If no carry return to caller
;           INH                    ;Else, increment H before
;           RET                    ;Returning to caller

;ABSX:      LLI \LB\L126                ;Load L with address of MSW of the FPACC
;           LHI \HB\OLDPG1         ;** Set H to page of the FPACC
;           LAM                    ;Fetch the MSW of the FPACC into the accumulator
;           NDA                    ;Test the sign of the number to see if it is positive.
;           JTS FPCOMP             ;If negative, complement the number before returning.
;           RET                    ;Else, just return with absolute value in the FPACC.
;SGNX:      LLI \LB\L126                ;Load L with address of MSW of the FPACC
;           LHI \HB\OLDPG1         ;** Load H with the page of the FPACC
;           LAM                    ;Fetch the MSW of the FPACC into the accumulator
;           NDA                    ;Test to see if the FPACC is zero
;           RTZ                    ;Return to caller if FPACC is zero
;           JFS FPONE              ;If FPACC is positive, load +1.0 into FPACC and exit
;           LLI \LB\L024                ;If FPACC is negative, set up to load -1.0 into the
;           JMP FLOAD              ;FPACC and exit to caller
;CHRX:      CAL FPFIX              ;Convert contents of FPACC from floating point to
;           LLI \LB\L124                ;Fixed point. Load L with address of LSW of fixed
;           LAM                    ;Value. Fetch this byte into the accumulator.
;           DATA RST_ECHO               ;Display the value.
;           LLI \LB\L177                ;Set L to address of the TAB FLAG
;           LHI \HB\OLDPG26        ;** Set H to page of the TAB FLAG
;           LMI 377                ;Set TAB FLAG (to inhibit display of FP value)
;           RET                    ;Exit to caller.
;TABX:      CAL FPFIX              ;Convert contents of FPACC from floating point to
;TAB1:      LLI \LB\L124                ;Fixed point. Load L with address of 1,SW of fixed
;           LAM                    ;Value. Fetch this byte into the accumulator.
;           LLI \LB\L043L043                ;Load L with address of COLUMN COUNTER
;           SUM                    ;Subtract value in C-OLUMN COUNTER from desired
;           LLI \LB\L177                ;TAB position. Load L with address of the TAB FLAG.
;           LHI \HB\OLDPG26        ;** Set H to page of the TAB FLAG.
;           LMI 377                ;Set TAB FLAG (to inhibit display of FP value)
;           JTS BACKSP             ;If beyond TAB point desired, simulate back spacing
;           RTZ                    ;Return to caller if at desired TAB location
;TABC:      LCA                    ;Else, put difference count in register C
;           LAI 240                ;Place ASCII code for space in ACC
;TABLOP:    DATA RST_ECHO               ;Display space on output device
;           DCC                    ;Decrement displacement counter
;           JFZ TABLOP             ;If have not reached TAB position, continue to space
;           RET                    ;Else, return to calling routine.
;BACKSP:    LAI 215                ;Load ASCII code for carriage-return into the ACC
;           DATA RST_ECHO               ;Display the carriage-return
;           DATA RST_ECHO               ;Repeat to provide extra time if TTY
;           LLI \LB\L043                ;Load L with address of COLUMN COUNTER
;           LHI \HB\OLDPG1         ;** Set H to page of COLUMN COUNTER
;           LMI 001                ;Set COLUMN COUNTER to first column
;           LLI \LB\L124                ;Set L to address containing desired TAB position
;           LAM                    ;Fetch the desired TAB position value
;           NDA                    ;Test to see if it is
;           RTS                    ;Negative or zero
;           RTZ                    ;In which case return to caller
;           JMP TAB1               ;Else, proceed to perform the TAB operation.

;;; The label STOSYM should be AT 10 055
STOSYM:    
           ;LLI \LB\L201                ;Load L with address of ARRAY FLAG
           ;LHI \HB\OLDPG27        ;** Load H with page of ARRAY FLAG
           ;LAM                    ;Fetch the value of the ARRAY FLAG into the ACC
           ;NDA                    ;Check to see if the flag is set indicating processing an
           ;JTZ STOSY1             ;Array variable value. Jump ahead if flag not set.
           ;LMI 000                ;If ARRAY FLAG was set, clear it for next time.
           ;LLI \LB\L204                ;Then load L with address of array address storage loc
           ;LLM                    ;Fetch the array storage address as new pointer
           ;LHI \HB\OLDPG57        ;tt Set H to ARRAY VALUES page   ****************
           ;JMP FSTORE             ;Store the array variable value and exit to caller.
STOSY1:    LLI \LB\L370                ;Load L with address of TEMP CNTR
           LHI \HB\OLDPG26        ;** Load H with page of TEMP CNTR
           LMI 000                ;Initialize the TEMP CNTR by clearing it
           LLI \LB\L120                ;Load L with starting address of SYMBOL BUFFER
           LDI \HB\L210_27        ;** Load D with page of VARIABLES LOOK-UP table
           LEI \LB\L210_27                ;Load E with starting addr of VARIABLES LOOK-UP
           LAM                    ;Table. Fetch the (cc) for the SYMBOL BUFFER into
           CPI 001                ;The ACC and see if length of variable name is just one
           JFZ STOSY2             ;Character. If not, skip next couple of instructions.
           LLI \LB\L122                ;Else, set pointer to second character location in the
           LMI 000                ;SYMBOL BUFFER and set it to zero
STOSY2:    LLI \LB\L121                ;load L with address of first character in the SYMBOL
           LHI \HB\OLDPG26        ;** BUFFER. Load H with page of the buffer.
           DATA RST_SWITCH             ;Exchange pointer to buffer for pointer to VARIABLES
           LAM                    ;LOOK-UP table. Fetch first char in a name from the
           INL                    ;Table. Advance the pointer to second char in a name.
           LBM                    ;Fetch the second character into register B.
           INL                    ;Advance the pointer to first byte of a value in the table.
           DATA RST_SWITCH             ;Exchange table pointer for pointer to SYMBOL BUFF
           CPM                    ;Compare first character in buffer against first character
           JFZ STOSY3             ;In table entry. If no match, try next entry in the table.
           INL                    ;If match, advance pointer to second character in buffer.
           LAB                    ;Move second character obtained from table into ACC.
           CPM                    ;Compare second characters in table and buffer.
           JTZ STOSY5             ;If same, have found the variable name in the table.
STOSY3:    CAL AD4DE              ;Add four to pointer in registers D&E to skip over value
           LLI \LB\L370                ;Portion of entry in table. Load L with address of TEMP
           LHI \HB\OLDPG26        ;** CNTR. Load H with page of TEMP CNTR.
           LBM                    ;Fetch the counter
           INB                    ;Increment the counter
           LMB                    ;Restore it to storage
           LLI \LB\L077_27                ;Set L to address of VARIABLES CNTR (indicates
           LHI \HB\L077_27        ;** Number of variables currently in table.) Set H too
           LAB                    ;Move the TEMP CNTR value into the ACC. (Number of
           CPM                    ;Entries checked.) Compare with number of entries in
           JFZ STOSY2             ;The table. If have not checked all entries, try next one.
           LLI \LB\L077_27                ;If have checked all entries, load L with address of the
           LHI \HB\L077_27        ;** VARIABLES CNTR. Set H too. Fetch the counter
           LBM                    ;Value and incrernent it to account for
           INB                    ;New variable nwne that will now be
           LMB                    ;Added to the table. Save the new value.
           LAB                    ;Place the new counter value into the accumulator
           CPI 025                ;And check to see that adding new variable name to the
           JFS BIGERR             ;Table will not cause table overflow. Big Error if it does!
           LLI \LB\L121                ;If room available in table, set L to address of first
           LHI \HB\OLDPG26        ;** Caracter in the SYMBOL BUFFER. Set H too.
           LBI 002                ;Set a counter for number of characters to transfer.
           CAL MOVEIT             ;Move the variable name from buffer to table.
STOSY5:    DATA RST_SWITCH             ;Exchange buffer pointer for table pointer.
           CAL FSTORE             ;Transfer new mathematical value into the table.
           DATA RST_CLESYM             ;Clear the SYMBOL BUFFER and exit to calling routine.
           RET
                                  ;The subroutines below are used by some of the routines
                                  ;in this chapter as well as other parts of the program.

SAVESY:    LLI \LB\L120                ;Load L with the address of the start of the SYMBOL
           LHI \HB\OLDPG26        ;** BUFFER. Load H with the page of the buffer.
           LDH                    ;Load register D with the page of the AUX SYMBOL
           LEI \LB\L144                ;BUFFER and set register E to start of that buffer.
           JMP MOVECP             ;Transfer SYMBOL BF contents to AUX SYMBOL BF

RESTSY:    LLI \LB\L144                ;Load L with address of start of AUX SYMBOL BUFF
           LHI \HB\OLDPG26        ;** Load H with page of AUX SYMBOL BUFFER
           LDH                    ;Set D to page of SYMBOL BUFFER (same as H)
           LEI \LB\L120                ;Load E with start of SYMBOL BUFFER
MOVECP:    LBM                    ;Load (cc) for source string (first byte in source buffer)
           INB                    ;Add one to (cc) to include (cc) byte itself
           JMP MOVEIT             ;Move the source string to destination buffer


EXEC:      LLI \LB\L352                ;Load L with address of READY message
           LHI \HB\L352         ;** Load H with page of READY message
           CAL TEXTC              ;Call subroutine to display the READY message

EXEC1:     LLI \LB\L000                ;Load L with starting address of INPUT LINE BUFFER
           LHI \HB\OLDPG26        ;** Load H with page of INPUT LINE BUFFER
           CAL STRIN              ;Call subroutine to input a line into the buffer
           LAM                    ;The STRIN subroutine will exit with pointer set to the
           NDA                    ;CHARACTER COUNT for the line inputted. Fetch the
           JTZ EXEC1              ;Value of the counter, if it is zero then line was blank.
           LLI \LB\L335                ;Load L with address of LIST in look up table
           LHI \HB\L335		 ;Load H with address of LIST in look up table
           LDI \HB\OLDPG26        ;Load D with page of line input buffer
           LEI \LB\L000                ;Load E with start of line input buffer
           CAL STRCP              ;Call string compare subroutine to see if first word in
           JFZ NOLIST             ;Input buffer is LIST. Jump 3 ahead if not LIST.
           LLI \LB\BGNPGRAM       ;If LIST, set up pointers to start of USER PROGRAM
           LHI \HB\BGNPGRAM      ;BUFFER. (Note user could alter this starting addr)   *****

                                  ;Next portion of program will LIST the contents of the
                                  ;USER PROGRAM BUFFER until an end of buffer
                                  ;(zero byte) indicator is detected.

LIST:      LAM                    ;Fetch the first byte of a line in the USER PROGRAM
           NDA                    ;BUFFER and see if it is zero. If so, have finished LIST
           JTZ EXEC               ;So go back to start of Executive and display READY.
           CAL TEXTC              ;Else call subroutine to display a line of information
           DATA RST_ADV                ;Now call subroutine to advance buffer pointer to
           CAL CRLF               ;Character count in next line. Also display a CR & LF.
           JMP LIST               ;Continue LISTing process

                                  ;If line inputted by operator did not contain a LIST comman
                                  ;continue program to see if RUN or SCRatch command.

NOLIST:    LLI \LB\L342                ;Load L with address of RUN in look up table
           LHI \HB\L342         ;** Load H with address of RUN in look up table
           LEI \LB\L000                ;Load E with start of line input buffer
           LDI \HB\OLDPG26        ;** Load D with page of line input buffer
           ;LEI 000                ;(Reserve 2 locs in case of patching by duplicating above)
           CAL STRCP              ;Call string compare subroutine to see if first word in
           JTZ RUN                ;Input buffer is RUN. Go to RUN routine if match.
           LDI \HB\OLDPG26        ;** If not RUN command, reset address pointers back
           LEI \LB\L000                ;To the start of the line input buffer
           LLI \LB\L346                ;Load L with address of SCR in look up table
           LHI \HB\L346         ;** Load H with page of SCR in look up table
           CAL STRCP              ;Call string compare subroutine to see if first word in
           JFZ NOSCR              ;Input buffer is SCR. If not then jump ahead.
           LHI \HB\OLDPG26        ;** If found SCR command then load memory pointer
           LLI \LB\L364                ;With address of a pointer storage location. Set that
           LMI \HB\BGNPGRAM    ;tt Storage location to page of start of USER PRO-  *******
           INL                    ;GRAM BUFFER. (Buffer start loc may be altered).
           LMI \LB\BGNPGRAM    ;Then adv pntr and do same for low addr portion of pntr
           LLI \LB\L077_27                ;Now set pointer to address of VARIABLES counter
           LHI \HB\L077_27        ;** Storage location. Initialize this counter by placing
           LMI 001                ;The count of one into it. Now change the memory pntr
;MGA 3/31/12 put it back to 001; solves nested FOR/NEXT, but limits vars to 19
           LLI \LB\L210_27        ;Set pointer to storage location for the first byte of the
           LMI 000                ;VARIABLES symbol table. Initialize it to zero too.
           INL                    ;Advance the pointer and zero the second location
           LMI 000                ;In the Variables table also.
           LHI \HB\BGNPGRAM   ;tt Load H with page of start of USER PROGRAM    **********
           LLI \LB\BGNPGRAM   ;BUFFER. (Buffer start location could be altered.now=0)
           LMI 000                ;Clear first location to indicate end of user program.
           JMP EXEC               ;SCRatch operations completed, go back to EXEC.

                                  ;If line inputted did not contain RUN or SCRatch com-
                                  ;mand, program continues by testing for SAVE or LOAD
                                  ;commands. If it does not find either of these com-
                                  ;mands, then operator did not input an executive com-
                                  ;mand. Program then sets up to see if the first entry in
                                  ;the line inputted is a LINE NUMBER.

NOSCR:     
           LLI \LB\L360                ;If not LOAD then set pointer to address of storage loc
           LHI \HB\OLDPG26        ;** For USER PROGRAM BUFFER pointer. Initialize this
           LMI \HB\BGNPGRAM     ;tt Pointer to the starting address of the program buffer.
           INL                    ;Advance memory pntr. Since pointer storage requires
           LMI \LB\BGNPGRAM        ;Two locations, initialize the low addr portion also.
           CAL SYNTAX             ;Call the SYNTAX subroutine to obtain a TOKEN indi-
           LLI \LB\L203                ;Cator which will be stored in this location. Upon return
           LHI \HB\OLDPG26        ;** From SYNTAX subroutine set memory pointer to
           LAM                    ;The TOKEN indicator storage location and fetch the
           NDA                    ;Value of the TOKEN. If the value of the syntax TOKEN
           JFS SYNTOK             ;Is positive then have a valid entry.
SYNERR:    LAI 323                ;However, if SYNTAX returns a negative value TOKEN
           LCI 331                ;Then have an error condition. Set up the letters SY in
           JMP ERROR              ;ASCII code and go to display error message to operator.
SYNTOK:    LLI \LB\L340                ;Set pointer to start of LINE NUMBER storage area
           LAM                    ;First byte there will contain the length of the line
           NDA                    ;Number character string. Fetch that value (cc).
           JTZ DIRECT             ;DIRECT If line number blank, have a DIRECT statement!
           LLI \LB\L360                ;If have a line number must get line in input buffer into
           LMI \HB\BGNPGRAM       ;tt User program buffer. Initialize pointer to user buffer.
           INL                    ;This is a two byte pointer so after initializing page addr
           LMI \LB\BGNPGRAM       ;Advance pointer and initialize location on page address

                                  ;If the line in the LINE INPUT BUFFER has a line num-
                                  ;ber then the line is to be placed in the USER PRO-
                                  ;GRAM BUFFER. It is now necessary to determine
                                  ;where the new line is to be placed in the USER PRO-
                                  ;GRAM BUFFER. This is dictated by the value of the
                                  ;new line number in relation to the line numbers cur-
                                  ;rently in the program buffer. The next portion of the
                                  ;program goes through the contents of the USER PRO-
                                  ;GRAM BUFFER comparing the values of the line num-
                                  ;bers already stored against the value of the line number
                                  ;currently being held in the LINE INPUT BUFFER.
                                  ;Appropriate action is then taken to Insert or Append,
                                  ;Change, or Delete a line in the program buffer.

GETAUX:    LLI \LB\L201                ;Set memory pointer to line character pointer storage
           LHI \HB\OLDPG26        ;** Location and then initialize that storage location
           LMI 001                ;To point to the 1'st character in a line
           LLI \LB\L350                ;Set memory pointer to addr of start of auxiliary line
           LMI 000                ;Number storage area and initialize first byte to zero
GETAU0:    LLI \LB\L201                ;Set memory pointer to line character pointer storage loc
           CAL GETCHP             ;Fetch a char in line pointed to by line pointer
           JTZ GETAU1             ;If character is a space, skip it by going to advance pntrs
           CPI 260                ;If not a space check to see if character represents a
           JTS GETAU2             ;Valid decimal digit in the range 0 to 9 by testing the
           CPI 272                ;ASCII code value obtained. If not a deciznal digit then
           JFS GETAU2             ;Assume have obtained the line number. Go process.
           LLI \LB\L350                ;If valid decimal digit want to append the digit to the
           LHI \HB\OLDPG26        ;** Current string being built up in the auxiliary line
           CAL CONCT1             ;Number storage area so call sub to concat a character.
GETAU1:    LLI \LB\L201                ;Reset memory pointer to line character pntr storage loc
           LHI \HB\OLDPG26        ;On the appropriate page.
           LBM
           INB                    ;Fetch the pointer, increment it, and restore new value
           LMB
           LLI \LB\L360                ;Set memory pointer to pgm buff line pntr storage loc
           LHI \HB\OLDPG26
           LCM                    ;Bring the high order byte of this double byte pointer
           INL                    ;Into CPU register C. Then advance the memory pntr
           LLM                    ;And bring the low order byte into register L. Now trans-
           LHC                    ;Fer the higher order portion into memory pointer H.
           LAM                    ;Obtain the char cntr (cc) which indicates the length of
           DCB                    ;The line being pointed to by the user program line pntr
           CPB                    ;Compare this with the value of the chars processed so
           JFZ GETAU0             ;Far in current line. If not equal, continue getting line n
GETAU2:    LLI \LB\L360                ;Reset mem pntr to pgm buffer line pntr storage
           LHI \HB\OLDPG26        ;** On this page and place the high order byte
           LDM                    ;Of this pointer into CPU register D
           INL                    ;Advance the memory pointer, fetch the second
           LLM                    ;Byte of the pgm buffer line pointer into register L
           LHD                    ;Now make the memory pointer equal to this value
           LAM                    ;Fetch the first byte of a line in the program buffer
           NDA                    ;Test to see if end of contents of pgm buff (zero byte)
           JFZ NOTEND             ;If not zero continue processing. If zero have reached
           JMP NOSAME             ;End of buffer contents so go APPEND line to buffer.

NOTEND:    LLI \LB\L350                ;Load L with addr of auxiliary line number storage loc
           LHI \HB\OLDPG26        ;Load H with addr of aux line number storage loc
           LDI \HB\OLDPG26        ;Load D with addr of line number buffer location
           LEI \LB\L340                ;Load E with address of line number buffer location
           CAL STRCP              ;Compare line nr in input buffer with line number in
           JTS CONTIN             ;User program buffer. If lesser in value keep looking.
           JFZ NOSAME             ;If greater in value then go to Insert line in pgm buffer
           LLI \LB\L360                ;If same values then must remove the line with the same
           LHI \HB\OLDPG26        ;** Line number from the user program buffer. Set up
           LCM                    ;The CPU memory pointer to point to the current
           INL                    ;Position in the user program buffer by retrieving that
           LLM                    ;Pointer from its storage location. Then obtain the first
           LHC                    ;Byte of data pointed to which will be the character
           LBM                    ;Count for that line (cc). Add one to the cc value to take
           INB                    ;Account of the (cc) byte itself and then remove that
           CAL REMOVE             ;Many bytes to effectively delete the line fm the user
           LLI \LB\L203                ;Program buffer. Now see if line in input buffer consists
           LHI \HB\OLDPG26        ;** Only of a line number by checking SYNTAX
           LAM                    ;TOKEN value. Fetch the TOKEN value from its
           NDA                    ;Storage location. If it is zero then input buffer only
           JTZ EXEC               ;Contains a line number. Action is a pure Delete.
NOSAME:    LLI \LB\L360                ;Reset memory pointer to program buffer
           LHI \HB\OLDPG26        ;Line pointer storage location
           LDM                    ;Load high order byte into CPU register D
           INL                    ;Advance memory pointer
           LEM                    ;Load low order byte into CPU register E
           LLI \LB\L000                ;Load L with address of start of line input buffer
           LHI \HB\OLDPG26        ;** Do same for CPU register H
           LBM                    ;Get length of line input buffer
           INB                    ;Advance length by one to include (cc) byte
           CAL INSERT             ;Go make room to insert line into user program buffer
           LLI \LB\L360                ;Reset memory pointer to program buffer
           LHI \HB\OLDPG26        ;** Line pointer storage location
           LDM                    ;Load higher byte into CPU register D
           INL                    ;Advance memory pointer
           LEM                    ;Load low order byte into CPU register E
           LLI \LB\L000                ;Load L with address of start of line input buffer
           LHI \HB\OLDPG26        ;** Do same for CPU register H
           CAL MOVEC              ;Call subroutine to Insert line in input buffer into the
           JMP EXEC1              ;User program buffer then go back to start of EXEC.
MOVEC:     LBM                    ;Fetch length of string in line input buffer
           INB                    ;Increment that value to provide for (cc)
MOVEPG:    LAM                    ;Fetch character from line input buffer
           DATA RST_ADV                ;Advance pointer for line input buffer
           DATA RST_SWITCH             ;Switch memory pointer to point to user pgm buffer
           LMA                    ;Deposit character fm input buff into user pgm buff
           DATA RST_ADV                ;Advance pointer for user program buffer
           DATA RST_SWITCH             ;Switch memory pntr back to point to input buffer
           DCB                    ;Decrement character counter stored in CPU register B
           JFZ MOVEPG             ;If counter does not go to zero continue transfer ops
           RET                    ;When counter equals zero return to calling routine
CONTIN:    LLI \LB\L360                ;Reset memory pointer to program buffer
           LHI \HB\OLDPG26        ;** Line pointer storage location
           LDM                    ;Load high order byte into CPU register D
           INL                    ;Advance memory pointer
           LEM                    ;Load low order byte into CPU register E
           LHD                    ;Now set CPU register H to high part of address
           LLE                    ;And set CPU register L to low part of address
           LBM                    ;Fetch the character counter (cc) byte fm line in
           INB                    ;Program buffer and add one to compensate for (cc)
           DATA RST_ADBDE              ;Add length of line value to old value to get new pointer
           LLI \LB\L360                ;Reset memory pointer to program buffer
           LHI \HB\OLDPG26        ;** Line pointer storage location
           LMD                    ;Restore new high portion
           INL                    ;Advance memory pointer
           LME                    ;And restore new low portion
           JMP GETAUX             ;Continue til find point at which to enter new line
GETCHP:    LHI \HB\OLDPG26        ;** Load H with pointer page (low portion set upon
           LBM                    ;Entry). Now fetch pointer into CPU register B.
           LLI \LB\L360                ;Reset pntr to pgm buffer line pointer storage location
           LDM                    ;Load high order byte into CPU register D
           INL                    ;Advance memory pointer
           LEM                    ;Load low order byte into CPU register E
           DATA RST_ADBDE              ;Add pointer to pgm buffer pointer to obtain address of
           LHD                    ;Desired character. Place high part of new addr in H.
           LLE                    ;And low part of new address in E.
           LAM                    ;Fetch character from position in line in user pgm buffer
           CPI 240                ;See if it is the ASCII code for space
           RET                    ;Return to caller with flags set to indicate result
REMOVE:    CAL INDEXB             ;Add (cc) plus one to addr of start of line
           LCM                    ;Obtain byte from indexed location and
           CAL SUBHL              ;Subtract character count to obtain old location
           LMC                    ;Put new byte in old location
           LAC                    ;As well as in the Accumulator
           NDA                    ;Test to see if zero byte to indicate end of user pgm buff
           JTZ REMOV1             ;If it is end of user pgm buffer, go complete process
           DATA RST_ADV                ;Otherwise add one to the present pointer value
           JMP REMOVE             ;And continue removing chamcters from the user pgm bf
REMOV1:    LLI \LB\L364                ;Load L with end of user pgm buffer pointer storage loc
           LHI \HB\OLDPG26        ;** Load H with page of that pointer storage location
           LDM                    ;Get page portion of end of pgm buffer address
           INL                    ;Advance memory pointer
           LAM                    ;And get low portion of end of pgm buffer address into
           SUB                    ;Accumulator then subtract displacement value in B
           LMA                    ;Restore new low portion of end of pgm buffer address
           RFC                    ;If subtract did not cause carry can return now
           DCL                    ;Otherwise decrement memory pointer back to page
           DCD                    ;Storage location, decrement page value to give new page
           LMD                    ;And store new page value back in buffer pntr storage loc
           RET                    ;Then return to calling routine
INSERT:    LLI \LB\L364                ;Load L with end of user pgm buffer pointer storage loc
           LHI \HB\OLDPG26        ;** Load H with page of that pointer storage location
           LAM                    ; Get page portion of end of program buffer address
           INL                    ;Advance memory pointer
           LLM                    ;Load low portion of end of program buffer address
           LHA                    ;Into L and finish setting up memory pointer
           CAL INDEXB             ;Add (cc) of line in input buffer to form new end of
           LAH                    ;Program buffer address. Fetch new end of buffer page
           CPI ENDPGRAM           ;tt Address and see if this value would exceed user's
           JFS BIGERR             ;System capabilit'y. Go display error message if so!
           CAL SUBHL              ;Else restore original value of end of buffer address
INSER1:    LCM                    ;Bring byte pointed to by H & L into CPU register C
           CAL INDEXB             ;Add displacement value to current memory pointer
           LMC                    ;Store the byte in the new location
           CAL SUBHL              ;Now subtract displacement value from H & L
           CAL CPHLDE             ;Compare this with the address stored in D & E
           JTZ INSER3             ;If same then go finish up Insert operation
           CAL DEC                ;Else set pointer to the byte before the byte just
           JMP INSER1             ;Processed and continue the Insert operation
INSER3:
INCLIN:    LLI \LB\L000                ;Load L with start of line input buffer
           LHI \HB\OLDPG26        ;** Load H with page of start of line input buffer
           LBM                    ;Fetch length of the line in line input buffer
           INB                    ;Increment value by one to include (cc) byte
           LLI \LB\L364                ;Set memory pointer to end of user pgrn buffer pointer
           LDM                    ;Storage location on same page and fetch page address
           INL                    ;Of this pointer into D. Then advance memory pointer
           LEM                    ;And get low part of this pointer into CPU register E.
           DATA RST_ADBDE              ;Now add displacement (cc) of line in input buffer to
           LME                    ;The end of program buffer pointer. Replace the updated
           DCL                    ;Low portion of the new pointer value back in stomge
           LMD                    ;And restore the new page value back into storage
           RET                    ;Then return to calling routine
CPHLDE:    LAH                    ;Subroutine to compare if the contents of CPU registers
           CPD                    ;H & L are equal to registers D & E. First compare
           RFZ                    ;Register H to D. Return with flags set if not equal. If
           LAL                    ;Equal continue by comparing register L to E.
           CPE                    ;IF L equals E then H & L equal to D & E so return to
           RET                    ;Calling routines with flags set to equality status
FINERR:    LLI \LB\L340                ;Load L with starting address of line number storage area
           LHI \HB\OLDPG26        ;** Load H with page of line number storage area
           LAM                    ;Get (cc) for line number string. If length is zero meaning
           NDA                    ;There is no line number stored in the buffer then jump
           JTZ FINER1             ;Ahead to avoid displaying "AT LINE" message
           LLI \LB\L366                ;Else load L with address of start of "AT LINE" message
           LHI \HB\OLDPG1         ;** Stored on this page
           CAL TEXTC              ;Call subroutine to display the "AT LINE" message
           LLI \LB\L340                ;Now reset L to starting address of line number storage
           LHI \HB\OLDPG26        ;** Area and do same for CPU register H
           CAL TEXTC              ;Call subroutine to display the line number
FINER1:    CAL CRLF               ;Call subroutine to provide a carriage-return and line-feed
	   JMP EXEC
DVERR:     LAI 304                ;Set up ASCII code for letter 'D' in Accumulator
           LCI 332                ;Set up ASCII code for letter 'Z' in CPU register C
           JMP ERROR              ;Go display the 'DZ' (divide by zero) error message
FIXERR:    LAI 306                ;Set up ASCII code for letter 'F' in Accumulator
           LCI 330                ;Set up ASCII code for letter 'X' in CPU register C
           JMP ERROR              ;Go display the 'FX' (FiX) error message
NUMERR:    LAI 311                ;Set up ASCII code for letter 'I' in Accumulator
           LCI 316                ;Set up ASCII code for letter 'N' in CPU register C
           LLI \LB\L220                ;Load L with address of pointer used by DINPUT
           LHI \HB\L220         ;** Routine. Do same for register H.
           LMI 000                ;Clear the location
           JMP ERROR              ;Go display the'IN'(Illegal Number) error message

                                  ;The following subroutine, used by various sections of
                                  ;SCELBAL, will search the LINE INPUT BUGGER for
                                  ;a character string which is contained in a buffer starting
                                  ;at the address pointed to by CPU registers H & L when
                                  ;the subroutine is entered.

INSTR:     LDI \HB\OLDPG26        ;**Set D to starting page of LINE INPUT BUFFER
           LEI \LB\L000                ;Load E with starting location of LINE INPUT BUFFER
INSTR1:    CAL ADVDE              ;Advancer D & E pointer to the next location (input
           CAL SAVEHL             ;Buffer). Now save contents of d, E, H & L vefore the
           LBM                    ;Compare operations. Get length of TEST buffer in B.
           DATA RST_ADV                ;Advance H & L buffer to first char in TEST buffer.
           CAL STRCPC             ;Compare contents of TEST buffer against input buffer
           JTZ RESTHL             ;For length B. If match, restore pntrs and exit to caller.
           CAL RESTHL             ;If no match, restore pointers for loop test.
           LLI \LB\L000                ;Load L with start of input buffer (to get the char cntr).
           LHI \HB\OLDPG26        ;**Load H with page of input buffer.
           LAM                    ;Get length of buffer (cc) into the accumulator.
           CPE                    ;Compare with current input buffer pointer value.
           JTZ INSTR2             ;If at end of buffer, jump ahead.
           CAL RESTHL             ;Else restore test string address (H&L) and input buffer
           JMP INSTR1             ;Address (D&E). Look gor occurrence of test string in ln.
           HLT                    ;Safety halt. If program reaches here have system failure.
INSTR2:    LEI 000                ;If reach end of input buffer without finding a match
           RET                    ;Load E with 000 as an indicator and return to caller.
ADVDE:     INE                    ;Subroutine to advance the pointer in the register
           RFZ                    ;Pair D & E. Advance contents of E. Return if not zero.
           IND                    ;If register E goes to 0 when advanced, then advance
           RET                    ;Register D too. Exit to calling routine.

;;; The label RUN should start at 13-170
RUN:       ;LLI \LB\L073                ;Load L with addr of GOSUB/RETURN stack pointer
           ;LHI \HB\OLDPG27        ;** Load H with page of same pointer
           ;LMI 000                ;Initialize the GOSUB/RETURN stack pointer to zero
           ;LLI \LB\L205                ;Load L with addr of FOR/NEXT stack pointer
           ;LMI 000                ;Initialize the FOR/NEXT stack pointer to zero
           LLI \LB\L360                ;Load L with addr of user pgm buffer line pointer
           LHI \HB\OLDPG26        ;** Load H with page of user pgm buffer line pointer
           LMI \HB\BGNPGRAM   ;tt Initialize pointer (may be altered by user)   *******
           INL                    ;Advance memory pointer to low portion of user pgm
           LMI \LB\BGNPGRAM         ;Buffer pointer and initialize to start of buffer
           JMP SAMLIN             ;Start executing user program with first line in buffer
NXTLIN:    LLI \LB\L360            ;Load L with addr of user program buffer line pointer
           LHI \HB\OLDPG26        ;** Load H with page of user pgm buffer line pointer
           LDM                    ;Place page addr of pgm buffer line pointer in D
           INL                    ;Advance the memory pointer
           LEM                    ;Place low addr of pgm buffer line pointer in E
           LHD                    ;Also put page addr of pgm buffer line pointer in H
           LLE                    ;And low addr of pgm buffer line pointer in L
           LBM                    ;Now fetch the (cc) of current line into register B
           INB                    ;Add one to account for (cc) byte itself
           DATA RST_ADBDE              ;Add value in B to D&E to point to next line in
           LLI \LB\L360                ;User program buffer. Reset L to addr of user logrn
           LHI \HB\OLDPG26        ;** Buffer pointer storage location. Store the new
           LMD                    ;Updated user pgm line pointer in pointer storage
           INL                    ;Location. Store both the high portion
           LME                    ;And low portion. (Now points to next line to be
           LLI \LB\L340                ;Processed from user program buffer.) Change pointer
           LHI \HB\OLDPG26        ;** To address of line number buffer. Fetch the last
           LAM                    ;Line number (length) processed. Test to see if it was
           NDA                    ;Blank. If it was blank
           JTZ EXEC               ;Then stop processing and return to the Executive
           LAA                    ;Insert two effective NOPs here
           LAA                    ;In case of patching
SAMLIN:    LLI \LB\L360                ;Load L with addr of user program buffer line pointer
           LHI \HB\OLDPG26        ;** Load H with page of same pointer
           LCM                    ;Fetch the high portion of the pointer into register C
           INL                    ;Advance the memory pointer
           LLM                    ;Fetch the low portion of the pointer into register L
           LHC                    ;Now move the high portion into register H
           LDI \HB\OLDPG26        ;** Set D to page of line input buffer
           LEI \LB\L000                ;Set E to address of start of line input buffer
           CAL MOVEC              ;Move the line ftom the user program buffer into the
           LLI \LB\L000                ;Line input buffer. Now reset the pointer to the start
           LHI \HB\OLDPG26        ;** Of the line input buffer.
           LAM                    ;Fetch the first byte of the line input buffer (cc)
           NDA                    ;Test (cc) value to see if fetched a blank line
           JTZ EXEC               ;If fetched a blank line, return to the Executive
           CAL SYNTAX             ;Else call subrtn to strip off line nr & set statement toke

DIRECT:    LLI \LB\L203                ;Load L with address of syntax TOKEN storage location
           LHI \HB\OLDPG26        ;** Load H with page of syntax TOKEN location
           LAM                    ;Fetch the TOKEN value into the accumulator
           CPI 001                ;Is it token value for REM statement? If so, ignore the
           JTZ NXTLIN             ;Current line and go on to the next line in pgm buffer.
           CPI 002                ;Is it token value for IF statement?
           JTZ IF                 ;If yes, then go to the IF statement routine.
           CPI 003                ;Is it token value for LET statement? (Using keyword)
           JTZ LET                ;If yes, then go to the LET statement routine.
           CPI 004                ;Is it token value for GOTO statement?
           JTZ GOTO               ;If yes, then go to the GOTO statement routine.
           CPI 005                ;Is it token value for PRINT statement?
           JTZ PRINT              ;If yes, then go to the PRINT statement routine.
           CPI 006                ;Is it token value for INPUT statement?
           JTZ INPUT              ;If yes, then go to the INPUT statement routine.
           CPI 007                ;new token Is it token value for END statement?
           JTZ EXEC               ;If yes, then go back to the Executive, user pgm finished!
           CPI 015                ;Is it token value for IMPLIED LET statement?
           JTZ LET0               ;If yes, then go to special LET entry point.
;           CPI 016                ;@@ Is it token value for ARRAY IMPLIED LET?
           JMP SYNERR             ;If not, then assume a syntax error condition.
;           CAL ARRAY1             ;@@ Else, perform array storage set up subroutine.
;           LLI \LB\L206                ;@@ Set L to array pointer storage location.
;           LHI \HB\OLDPG26        ;@@ * * Set H to array pointer storage location.
;           LBM                    ;@@ Fetch array pointer to register B.
;           LLI \LB\L202                ;@@ Change memory pointer to syntax pntr storage loc.
;           LMB                    ;@@ Save array pointer value there.
;           CAL SAVESY             ;@@ Save array name in auxiliary symbol buffer
;           JMP LET1
PRINT:     LLI \LB\L202                ;Load L with address of SCAN pointer storage location
           LHI \HB\OLDPG26        ;** Load H with page of SCAN pointer
           LAM                    ;Fetch the pointer value (last character scanned by the
           LLI \LB\L000                ;SYNTAX routine). Change pointer to line buffer (cc).
           CPM                    ;Compare pointer value to buffer length. If not equal
           JTS PRINT1             ;Then line contains more than stand alone PRINT state-
           CAL CRLF               ;Ment. However, if just have PRINT statement then issue
           JMP NXTLIN             ;A carriage-return & line-feed combination, then exit.
PRINT1:    DATA RST_CLESYM             ;Initialize the SYMBOL buffer for new entry.
           LLI \LB\L202                ;Load L with address of SCAN buffer pointer
           LHI \HB\OLDPG26        ;** Load H with page of SCAN pointer
           LBM                    ;Pointer points to last char scanned by SYNTAX. Need
           INB                    ;To increment it to point to next char in statement line.
           LLI \LB\L203                ;Load L with address of former TOKEN value. Use it as
           LMB                    ;Storage location for a PRINT statement pointer.
PRINT2:    LLI \LB\L203                ;Set memory pointer to PRINT pointer storage location
           DATA RST_GETCHR             ;Fetch character in input buffer pointed to by PRINT
           CPI 247                ;Pointer. See if it is ASCII code for single quote mark.
           JTZ QUOTE              ;If so, go to QUOTE section to process text string.
           CPI 242                ;If not, see if it is ASCII code for double quote mark.
           JTZ QUOTE              ;If so, go to QUOTE section to process text string.
           CPI 254                ;If not, see if it is ASCII code for comma sign.
           JTZ PRINT3             ;If so, go evaluate expression.
           CPI 273                ;If not, see if it is ASCII code for semi-colon sign.
           JTZ PRINT3             ;If so, go evaluate expression.
           LLI \LB\L203                ;Load L with address of PRINT pointer storage location.
           DATA RST_LOOP               ;Increment pointer and test for end of line.
           JFZ PRINT2             ;If not end of line, fetch the next character.
PRINT3:    LLI \LB\L202                ;Load L with address of SCAN pointer storage location
           LBM                    ;Fetch value of the pointer (last letter of KEYWORD)
           INB                    ;Add one to point to first character of expression
           LLI \LB\L276                ;Load L with addr of EVAL pointer storage location
           LMB                    ;Store addr at which EVAL should start scanning
           LLI \LB\L203                ;Load L with address of PRINT pointer
           LBM                    ;Which points to field terminator
           DCB                    ;Decrement pointer value to last character of expression
           LLI \LB\L277                ;Load L with address of EVAL FINISH pntr storage loc.
           LMB                    ;Place address value of last char in PRINT field there
           LLI \LB\L367                ;Load L with address of QUOTE flag
           LAM                    ;Fetch the value of the QUOTE flag into the ACC
           NDA                    ;Test the QUOTE flag status
           JTZ PRINT4             ;If field not quoted, proceed to evaluate expression
           LMI 000                ;If field quoted, then clear the QUOTE flag for next field
           JMP PRINT6             ;And skip the evaluation procedure
PRINT4:    CAL EVAL               ;Evaluate the current PRINT field
           LLI \LB\L177                ;Then load L,with address of the TAB flag
           LHI \HB\OLDPG26        ;** Load H with the page of the TAB flag
           LAM                    ;Fetch the value of the TAB flag into the accumulator
           NDA                    ;Test the TAB flag
           ;LLI \LB\L110                ;Change L to the FIXED/FLOAT flag location
           ;LHI \HB\OLDPG1         ;** Change H to the FIXED/FLOAT flag page
           ;LMI 377                ;Set FIXED/FLOAT flag to fixed point
PRINT5:    CTZ FPOUT             ;If TAB flag not set, display value of expression
           LLI \LB\L177                ;Load L with address of TAB flag
           LHI \HB\OLDPG26        ;** Load H with page of TAB flag
           LMI 000                ;Reset TAB flag for next PRINT field
PRINT6:    LLI \LB\L203                ;Load L with address of PRINT pointer stomge location
           DATA RST_GETCHR             ;Fetch the character pointed to by the PRINT pointer
           CPI 254                ;See if the last character scanned was a comma sign
           CTZ PCOMMA             ;If so, then display spaces to next TA.B location
           LLI \LB\L203                ;Reset L to address of PRINT pointer storage location
           LHI \HB\OLDPG26        ;** Reset H to page of PRINT pointer stomge location
           LBM                    ;Fetch the value of the pointer into register B
           LLI \LB\L202                ;Change L to SCAN pointer storage location
           LMB                    ;Place end of last field processed into SCAN pointer
           LLI \LB\L000                ;Change pointer to start of line input buffer
           LAB                    ;Place pntr to last char scanned into the accumulator
           CPM                    ;Compare this value to the (cc) for the line buffer
           JTS PRINT1             ;If not end of line, continue to process next field
           LLI \LB\L000                ;If end of line, fetch the last character in the line
           DATA RST_GETCHR             ;And check to see if it
           CPI 254                ;Was a comma. If it was, go on to the next line in the
           JTZ NXTLIN             ;User program buffer without displaying a CR & LF.
           CPI 273                ;If not a comma, check to see if it was a semi-colon.
           JTZ NXTLIN             ;If so, do not provide a CR & LF combination.
           CAL CRLF               ;If not comma or semi-colon, provide CR & LF at end
           JMP NXTLIN             ;Of a PRINT statement. Go process next line of pgrm.
QUOTE:     LLI \LB\L367                ;Load L with address of QUOTE flag
           LMA                    ;Store type of quote in flag storage location
           DATA RST_CLESYM             ;Initialize the SYMBOL buffer for new entry
           LLI \LB\L203                ;Load L with address of PRINT pointer
           LBM                    ;Fetch the PRINT pointer into register B
           INB                    ;Add one to advance over quote character
           LLI \LB\L204                ;Load L with address of QUOTE pointer
           LMB                    ;Store the beginning of the QUOTE field pointer
QUOTE1:    LLI \LB\L204                ;Load L with address of QUOTE pointer
           DATA RST_GETCHR             ;Fetch the next character in the TEXT field
           LLI \LB\L367                ;Load L with the QUOTE flag (type of quote)
           CPM                    ;Compare to see if latest character this quote mark
           JTZ QUOTE2             ;If so, finish up this quote field
           DATA RST_ECHO               ;If not, display the character as part of TEXT
           LLI \LB\L204                ;Reset L to QUOTE pointer storage location
           DATA RST_LOOP               ;Increment QUOTE pointer and test for end of line
           JFZ QUOTE1             ;If not end of line, continue processing TEXT field
QUOTER:    LAI 311                ;If end of line before closing quote mark have an error
           LCI 321                ;So load ACC with I and register C with Q
           LLI \LB\L367                ;Load L with the address of the QUOTE flag
           LHI \HB\OLDPG26        ;** Load H with the page of the QUOTE flag
           LMI 000                ;Clear the QUOTE flag for future use
           JMP ERROR              ;Go display the IQ (Illegal Quote) error message
QUOTE2:    LLI \LB\L204                ;Load L with address of QUOTE pointer
           LBM                    ;Fetch the QUOTE pointer into register B
           LLI \LB\L202                ;Load L with address of SCAN pointer storage location
           LMB                    ;Store former QUOTE vointer as start of next field
           LAB                    ;Place QUOTE pointer into the accumulator
           LLI \LB\L000                ;Change L to point to start of the input line buffer
           CPM                    ;Compare QUOTE pointer value with (cc) value
           JFZ PRINT1             ;If not end of line, process next PRINT field
           CAL CRLF               ;Else display a CR & LF combination at the end of line
           LLI \LB\L367                ;Load L with the address of the TAB flag
           LHI \HB\OLDPG26        ;** Load H with the page of the TAB flag
           LMI 000                ;Clear the TAB flag for future use
           JMP NXTLIN             ;Go process next line of the program.

PCOMMA:    LLI \LB\L000                ;Load L with address of (cc) in line input buffer
           LAM                    ;Fetch the (cc) for the line into the ACC
           LLI \LB\L203                ;Change pointer to PRINT pointer storage location
           SUM                    ;Subtract value of PRINT pointer from line (cc)
           RTS                    ;If at end of buffer, do not TAB
           LLI \LB\L043                ;If not end, load L with address of COLUMN COUNTER
           LHI \HB\L043         ;** Set H to page of COLUMN COUNTER
           LAM                    ;Fetch COLUMN COUNTER into the accumulator
           NDI 360                ;Find the last TAB position (multiple of 16 decimal)
           ADI 020                ;Add 16 (decimal) to get new TAB position
           SUM                    ;Subtract current position from next TAB position
           LCA                    ;Store this value in register C as a counter
           LAI 240                ;Load the ACC with the ASCII code for space
PCOM1:     DATA RST_ECHO               ;Display the space
           DCC                    ;Decrement the loop counter
           JFZ PCOM1              ;Continue displaying spaces until loop counter is zero
           RET                    ;Then return to calling routine

LET0:      CAL SAVESY             ;Entry point for IMPLIED LET statement. Save the
           LLI \LB\L202                ;Variable (to left of the equal sign). Set L to the SCAN
           LHI \HB\OLDPG26        ;** Pointer. Set H to the page of the SCAN pointer.
           LBM                    ;Fetch value of SCAN pointer. (Points to = sign in In bf)
           LLI \LB\L203                ;Change pointer to LET pointer (was TOKEN value)
           LMB                    ;Place the SCAN pointer value into the LET pointer
           JMP LET5               ;Continue processing the LET statement line
LET:       DATA RST_CLESYM             ;Initialize the SYMBOL BUFFER for new entry
           LLI \LB\L144                ;Load L with address of start of AUX SYMBOL BUFF
           LHI \HB\OLDPG26        ;** Load H with page of AUX SYMBOL BUFFER
           LMI 000                ;Initialize AUX SYMBOL BUFFER
LET1:      LLI \LB\L202                ;Entry point for ARRAY IMPLIED LET statement.
           LHI \HB\OLDPG26        ;** Set pointer to SCAN pointer storage location
           LBM                    ;Fetch the SCAN pointer value (last letter scanned by
           INB                    ;SYNTAX subroutine) and add one to next character
           LLI \LB\L203                ;Change L to LET pointer storage location
           LMB                    ;Store former SCAN value (updated) in LET pointer
LET2:      LLI \LB\L203                ;Set L to gtorage location of LET pointer
           DATA RST_GETCHR             ;Fetch the character pointed to by the LET pointer
           JTZ LET4               ;If character is a space, ignore it
           CPI 275                ;See if character is the equal (=) sign
           JTZ LET5               ;If so, go process other side of the statement (after
;           CPI 250                ;@@ If not, see if character is a right parenthesis
;           JFZ LET3               ;If not, continue looking for equal sign
;           CAL ARRAY              ;@@ If so, have subscript. Call array set up subroutine.
;           LLI \LB\L206                ;@@ Load L with address of ARRAY pointer
;           LHI \HB\OLDPG26        ;@@ ** Load H with page of ARRAY pointer
;           LBM                    ;@@ Fetch value (points to ")" character of subscript)
;           LLI \LB\L203                ;@@ Load L with address of LET pointer
;           LMB                    ;@@ Place ARRAY pointer value as new LET pointer
;           JMP LET4               ;@@ Continue to look for = sign in statement line
LET3:      LLI \LB\L144                ;Reset L to start of AUX SYMBOL BUFFER
           LHI \HB\OLDPG26        ;** Load H with page of AUX SYMBOL BUFFER
           CAL CONCT1             ;Concatenate character to the AUX SYMBOL BUFFER
LET4:      LLI \LB\L203                ;Load L with address of LET pointer storage location
           DATA RST_LOOP               ;Add one to pointer and test for end of line input buffer
           JFZ LET2               ;If not end of line, continue looking for the equal sign
LETERR:    LAI 314                ;If do not find an equal sign in the LET statement line
           LCI 305                ;Then have a LE (Let Error). Load the code for L and E
           JMP ERROR              ;Into registers ACC and C and go display the error msg.
LET5:      LLI \LB\L203                ;When find the equal sign, reset L to point to the LET
           LHI \HB\OLDPG26        ;** Pointer and H to the proper page. Fetch the pointer
           LBM                    ;Value into register B and add one to advance pointer
           INB                    ;Over the equal sign to first char in the expression.
           LLI \LB\L276                ;Set L to point to the address of the EVAL pointer
           LMB                    ;Set EVAL pointer to start evaluating right after the
           LLI \LB\L000                ;Equal sign. Now change L to start of line input buffer.
           LBM                    ;Fetch the (cc) value into register B. (Length of line.)
           LLI \LB\L277                ;Load L with EVAL FINISH pointer storage location.
           LMB                    ;Set it to stop evaluating at end of the line.
           CAL EVAL               ;Call the subroutine to evaluate the expression.
           CAL RESTSY             ;Restore the name of the variable to receive new value.
           CAL STOSYM             ;Store the new value for the variable in variables table.
           JMP NXTLIN             ;Go process next line of the program.
GOTO:      LLI \LB\L350                ;Load L with start of AUX LINE NR BUFFER
           LHI \HB\OLDPG26        ;** Load H with page of AUX LINE NR BUFFER
           LMI 000                ;Initialize the AUX LINE NR BUFFER to zero
           LLI \LB\L202                ;Load L with address of SCAN pointer storage location
           LBM                    ;Fetch pointer value (last char scanned by SYNTAX)
           INB                    ;Add one to skip over the last 0 in GOTO keyword
           LLI \LB\L203                ;Change pointer to GOTO pointer (formerly TOKEN)
           LMB                    ;Store the updated SCAN pointer as the GOTO pointer
GOTO1:     LLI \LB\L203                ;Load L with address of GOTO pointer
           DATA RST_GETCHR             ;Fetch the character pointed to by the GOTO pointer
           JTZ GOTO2              ;If character was a space, ignore it
           CPI 260                ;See if character is in the range of a decimal digit
           JTS GOTO3              ;If not, must have end of the line number digit string
           CPI 272                ;Continue to test for decitnal digit
           JFS GOTO3              ;If not, mugt have end of the line number digit string
           LLI \LB\L350                ;If valid decimal digit, load L with addr of AUX LINE
           CAL CONCT1             ;NR BUFFER and concatenate digit to the buffer.
GOTO2:     LLI \LB\L203                ;Reset pointer to GOTO pointer storage location
           DATA RST_LOOP               ;Advance the pointer value and test for end of line
           JFZ GOTO1              ;If not end of line, fetch next digit in GOTO line number
GOTO3:	   LLI \LB\L360                ;Set L to user program buffer pointer storage location
           LHI \HB\OLDPG26        ;** Set H to page of program buffer pointer
           LMI \HB\BGNPGRAM       ;Initialize high part of pointer to start of pgm buffer
           INL                    ;Advance the memory point
           LMI \LB\BGNPGRAM      ;Initialize the low part of pointer to start of pgm buffer
GOTO4:     DATA RST_CLESYM             ;Clear the SYMBOL BUFFER
           LLI \LB\L204                ;Load L with address of GOTO SEARCH pointer
           LMI 001                ;Initialize to one for first char of line
GOTO5:     LLI \LB\L204                ;Load L with address of GOTO SEARCH pointer
           CAL GETCHP             ;Fetch character pointed to by GOTO SEARCH pointer
           JTZ GOTO6              ;From line pointed to in user program buffer. Ignore
           CPI 260                ;Spaces. Check to see if character is a decirnal digit.
           JTS GOTO7              ;If not, then have processed line number at the start of
           CPI 272                ;The current line. Continue the check for a valid decimal
           JFS GOTO7              ;Digit. If have a decirnal digit then concatenate the digit
           CAL CONCTS             ;Onto the current string in the SYMBOL BUFFER,
GOTO6:     LLI \LB\L204                ;Change L to the address of the GOTO SEARCH pointer
           LHI \HB\OLDPG26        ;** And H to the proper page of the pointer
           LBM                    ;Fetch the GOTO SEARCH pointer value
           INB                    ;Increment the GOTO SEARCH pointer
           LMB                    ;And restore it back to memory
           LLI \LB\L360                ;Change L to address of user program buffer pointer
           LCM                    ;Save the high part of this pointer value in register C
           INL                    ;Advance L to the low part of the pgrn buffer pointer
           LLM                    ;Now load it into L
           LHC                    ;And transfer C into H to point to start of the line
           LAM                    ;Fetch the (cc) of the current line being pointed to in the
           DCB                    ;User pgm buff. Decrernent B to previous value. Compare
           CPB                    ;GOTO SEARCH pointer value to length of current line.
           JFZ GOTO5              ;If not end of line then continue getting current line nr.
GOTO7:     LLI \LB\L120                ;Load L with address of start of the SYMBOL BUFFER
           LHI \HB\OLDPG26        ;Set H to the page of the SYMBOL BUFFER
           LDI \HB\OLDPG26        ;Set D to the page of the AUX LINE NR BUFFER
           LEI \LB\L350                ;Set E to the start of the AUX LINE NR BUFFER
           CAL STRCP              ;Compare GOTO line number against current line nr.
           JTZ SAMLIN             ;If they match, found GOTO line. Pick up ops there!
           LLI \LB\L360                ;Else, set L to user program buffer pntr storage location
           LHI \HB\OLDPG26        ;** Set H to page of user program buffer pointer
           LDM                    ;Fetch the high part of this pointer into register D
           INL                    ;Advance the memory pointer
           LEM                    ;Fetch the low part into register E
           LHD                    ;Transfer the pointer to H
           LLE                    ;And L. Fetch the (cc) of the current line into register
           LBM                    ;B and then add one to account for the (cc) byte to get
           INB                    ;Total length of the current line in the user pgm buffer
           DATA RST_ADBDE              ;Add the total length to the pointer value in D & E
           LLI \LB\L360                ;To get the starting address of the next line in the user
           LHI \HB\OLDPG26        ;** User program buffer. Place the new value for the user
           LMD                    ;Program buffer pointer back into the user program
           INL                    ;Buffer pointer storage locations so that it points to the
           LME                    ;Next line to be processed in the user program buffer.
           LLI \LB\L364                ;Load L with address of end of user pgm buffer storage
           LAD                    ;Location (page address) and fetch end of buffer page.
           CPM                    ;Compare this with next line pointer (updated).
           JFZ GOTO4              ;If not end of buffer, keep looking for the specified line
           INL                    ;If have same page addresses, check the low address
           LAE                    ;Portions to see if
           CPM                    ;Have reached end of user program buffer
           JFZ GOTO4              ;If not, continue looking. If end of buffer without
GOTOER:    LAI 325                ;Finding specified line, then have an error condition.
           LCI 316                ;Load ACC and register C with code for "UN" and go
           JMP ERROR              ;Display "Undefined Line" error message.
IF:        LLI \LB\L202                ;Set L to SCAN pointer storage location.
           LHI \HB\OLDPG26        ;** Load H to page of SCAN pointer storage location.
           LBM                    ;Fetch the SCAN pointer value to register B.
           INB                    ;Add one to advance pointer over last char scanned.
           LLI \LB\L276                ;Change L to address of EVAL pointer. Set up EVAL
           LMB                    ;Pointer to begin evaluation with next char in the line.
           DATA RST_CLESYM             ;Clear the SYMBOL BUFFER.
           LLI \LB\L320                ;Set L to starting address of THEN in look-up table.
           LHI \HB\L320         ;** Set H to page of the look-up table.
           CAL INSTR              ;Search for occurrence of THEN in the line input buffer.
           LAE                    ;Transfer register E to ACC. If THEN not found
           NDA                    ;The value in E will be zero.
           JFZ IF1                ;If THEN found, can evaluate the IF expression.
           LLI \LB\L013_27                ;If THEN not found, set L to Auting address of GOTO
           LHI \HB\L013_27        ;** In the KEYWORD look-up table. Set H to table
           CAL INSTR              ;Search for occurrence of GOTO in the line input buffer.
           LAE                    ;Transfer E to ACC. If GOTO not found
           NDA                    ;The value in E will be zero.
           JFZ IF1                ;If GOTO found, can evaluate the IF expression.
IFERR:     LAI 311                ;Set ASCII code for letter I in ACC
           LCI 306                ;And code for letter F in register C
           JMP ERROR              ;Go display the IF error message
IF1:       LLI \LB\L277                ;Load L with addr of EVAL FINISH pointer storage loc
           LHI \HB\OLDPG26        ;** Load H with page of storage location
           DCE                    ;Subtract one from pointer in E and set the EVAL
           LME                    ;FINISH pointer so that it will evaluate up to the THEN
           CAL EVAL               ;Or GOTO directive. Evaluate the expression.
           LLI \LB\L125                ;++fxp: Load L with address of FPACC Most Significant Word
           LHI \HB\OLDPG1         ;** Load H with page of FPACC MSW
           LAM                    ;Fetch the FPACC MSW into the accumulator
           ;NDA                    ;Test the value of the FPACC MSW
           DCL                    ;++fxp: also need to check LSW of fixed point
           ORM                    ;++fxp: OR is zero only if MSW and LSW are both zero 
           JTZ NXTLIN             ;If it is zero, IF condition failed, ignore rest of line.
           LLI \LB\L277                ;If not, load L with addr of EVAL FINISH pointer
           LHI \HB\OLDPG26        ;** Set H to the appmpriate page
           LAM                    ;Fetch the value in the EVAL FINISH pointer
           ADI 005                ;Add five to skip over THEN or GOTO directive
           LLI \LB\L202                ;Change L to SCAN pointer stomge location
           LMA                    ;Set up the SCAN pointer to location after THEN or
           LBA                    ;GOTO directive. Also put this value in register B.
           INB                    ;Add one to the value in B to point to next character
           LLI \LB\L204                ;After THEN or GOTO. Change L to addr of THEN pntr
           LMB                    ;Storage location and store the pointer value.
IF2:       LLI \LB\L204                ;Load L with the address of the THEN pointer
           DATA RST_GETCHR             ;Fetch the character pointed to by the THEN pointer
           JFZ IF3                ;If character is not a space, exit this loop
           LLI \LB\L204                ;If fetch a space, ignore. Reset L to the THEN pointer
           DATA RST_LOOP               ;Add one to the THEN pointer and test for end of line
           JFZ IF2                ;If not end of line, keep looking for a character other
           JMP IFERR              ;Than a space. If reach end of line first, then error
IF3:       CPI 260                ;When find a character see if it is numeric.
           JTS IF4                ;If not numeric, then should have a new type of
           CPI 272                ;Statement. If numeric, then should have a line number.
           JTS GOTO               ;So process as though have a GOTO statement!
IF4:       LLI \LB\L000                ;Load L with addr of start of line input buffer.
           LAM                    ;Fetch the (cc) byte to get length of line value.
           LLI \LB\L204                ;Change L to current value of THEN pointer (where first
           SUM                    ;Non-space char. found after THEN or GOTO). Subtract
           LBA                    ;This value from length of line to get remainder. Now
           INB                    ;Have length of second statement portion. Add one for
           LCM                    ;(cc) count. Save THEN pointer value in register C.
           LLI \LB\L000                ;Reset L to start of line input buffer. Now put length of
           LMB                    ;Second statement into (cc) position of input buffer.
           LLC                    ;Set L to where second statement starts.
           LDI \HB\OLDPG26        ;** Set D to page of line input buffer.
           LEI \LB\L001                ;Set E to first character position of line input buffer.
           CAL MOVEIT             ;Move the second statement up in line to become first!
           LLI \LB\L202                ;Load L with address of new SCAN pointer. Load
           LMI 001                ;It with starting position for SYNTAX scan.
           CAL SYNTX4             ;Use special entry to SYNTAX to get new TOKEN value.
           JMP DIRECT             ;Process the second statement in the original line.



PARSEP:    LLI \LB\L176                ;Load L with PARSER TOKEN storage location. Set
           LMI 000                ;The value indicating end of expression. Call the
           CAL PARSER             ;PARSER subroutine for final time for the expression.
           LLI \LB\L227                ;Change L to point to the ARITH STACK pointer.
           LHI \HB\L227         ;** Set H to the page of the ARITH STACK pointer.
           LAM                    ;Fetch the ARITH STACK pointer value.
           CPI \LB\L230_0                ;Should indicate only one value (answer) in stack.
           RTZ                    ;Exit with answer in FPACC if ARITH STACK is O.K.
           JMP SYNERR             ;Else have a syntax error!

                                  ;The following subroutine moves the contents of a string
                                  ;of memory locations from the address pointed to by
                                  ;CPU registers H & L to the address specified by the con-
                                  ;tents of registers D & E when the routine is entered. The
                                  ;process continues until the counter in register B is zero.

MOVEIT:    LAM                    ;Fetch a word from memory string A
           INL                    ;Advance A string pointer
           DATA RST_SWITCH             ;Switch pointer to string B
           LMA                    ;Put word from string A into string B
           INL                    ;Advance B string pointer
           DATA RST_SWITCH             ;Switch pointer back to string A
           DCB                    ;Decrement loop counter
           RTZ                    ;Return to calling routine when counter reaches zero
           JMP MOVEIT             ;Else continue transfer operations


                                  ;The next several subroutines are used to perform
                                  ;floating pojnt register loading and transfer operations.

FSTORE:    LEL                    ;Transfer contents of register L to E
           LDH                    ;Transfer contents of register H to D
           LLI \LB\L124                ;Set L to least significant byte of FPACC mantissa
           LHI \HB\OLDPG1         ;** Set page to FPACC storage area
           JMP SETIT              ;Go transfer FPACC contents to area pointed to by D&E
OPLOAD:    LDI \HB\OLDPG1         ;** Set page to FPOP storage area
           LEI \LB\L134                ;Set pointer to least significant byte of FPOP
SETIT:     LBI 004                ;Set precision counter. Transfer from H & L area to
           JMP MOVEIT             ;Locations pointed to by D & E

                                  ;The next subroutine perforins a double transfer opera-
                                  ;tion. It first transfers the contents of the FPACC into
                                  ;the FPOP. It then transfers new data (as pointed to by
                                  ;H & L upon entry to the subroutine) into the FPACC.

FACXOP:    CAL SAVEHL             ;Save contents of H & L upon entry to subroutine
           LLI \LB\L124                ;Set pointer to FPACC LSW
           LHI \HB\OLDPG1         ;** Set pointer to page of FPACC
           CAL OPLOAD             ;Transfer FPACC to FPOP
           CAL RESTHL             ;Recover original subroutine entry values for H & L
           JMP FLOAD              ;Transfer registers pointed to by H & L into the FPACC

                                  ;Subroutine to save the contents of CPU registers D, E, H
                                  ;and L in a temporary storage area in memory.

SAVEHL:    LAH                    ;Transfer value in H to ACC
           LBL                    ;And value in L to B
           LLI \LB\L200                ;Now set L to start of tempomry storage locations
           LHI \HB\OLDPG1         ;** And set H to storage area page
           LMA                    ;Save A (entry value of H) in memory
           INL                    ;Advance pointer
           LMB                    ;Save B (entry value of L) in memory
           INL                    ;Advance pointer
           LMD                    ;Save D in memory
           INL                    ;Advance pointer
           LME                    ;Save E in memory
           LHA                    ;Restore entry value of H
           LLB                    ;Restore entry value of L
           RET                    ;Exit to calling routine

                                  ;Subroutine to restore the contents of CPU registers D,
                                  ;E, H and L from temporary storage in memory.

RESTHL:    LLI \LB\L200                ;Set L to start of temporary storage locations
           LHI \HB\OLDPG1         ;** Set H to storage area page
           LAM                    ;Fetch stored value for li iii ACC
           INL                    ;Advance pointer
           LBM                    ;Fetch stored value for L into B
           INL                    ;Advance pointer
           LDM                    ;Fetch stored value for T.)
           INL                    ;Advance pointer
           LEM                    ;Fetch stored value for
           LHA                    ;Restore  saved value for H
           LLB                    ;Restore saved value for L
           LAM                    ;Leave stored value for E in ACC
           RET                    ;Exit to calling routine




;***************************************************************************************
; the following fixed-point mini-package replaces the floating-point routines
; of original SCELBAL
;
;   written by Mark Arnold March 2013
;
; although SCELBAL reserves 32 bits for each value, this package only uses the low 16
;   LLI \LB\L127 and LLI 126 in SCELBAL need to be changed to be compatible 
;   (except 24 bits used in FPADD and FPSUB) to avoid weirdness of 16-bit signed integer 
;   compare on 8008 this is needed because 8008 has no overflow flag
;
; limitations:
;   the multiply and divide algorithms are very very very ... slow
;   the output does not suppress leading zeros
;   input does not accept negative numbers;but SCELBAL does not use this
;     instead SCELBAL computes (-9) as unary minus (0-9) 
;***************************************************************************************






                                   ;multiply FPOP*FPACC mod 65536
                                  ;this is a very slow algorithm, but it is short
FPMULT:    
           CAL CKSIGNS            ;DE=|FPOP|; BC=|FPACC|, SIGNS=sign of result
           LHD                    ;move FPOP MSW into H. 
           LLE                    ;move FPOP LSW into L.    HL=FPOP
           LDI 000                ;DE=0
           LED
FPMULT1:   LAH                    ;exit loop if HL==0
           ORL
           JTZ EXMLDV             ;exit via routine that deals with SIGNS 
           CAL DEC                ;decrement HL
           LAC                    ;DE = DE + BC
           ADE
           LEA
           LAB
           ACD
           LDA
           JMP FPMULT1
   

                                  ;this is the "childish division algorithm"
                                  ;from my book Verilog Digital Computer Design
                                  ;it is also really slow, but short 

FPDIV0:    LLI 377                ;HL= -1
           LHL 
FPDIV1:    DATA RST_ADV           ;HL=HL+1
           LAE                    ;DE = DE - BC
           SUC
           LEA
           LAD
           SBB
           LDA
           JFC FPDIV1 
           LAC                    ;DE = DE + BC
           ADE
           LEA
           LAB
           ACD
           LDA
           LCL                    ;BC=HL
           LBH
           RET

FPDIV: 
           CAL CKSIGNS            ;DE=|FPOP|; BC=|FPACC|, SIGNS=sign of result
           LAB
           ORC
           JTZ DVERR
           CAL FPDIV0             ;DE=remainder, BC=quotient
           LEC                    ;SCELBAL routine expects quot in FPACC
           LDB
                                  ;finish as in multiply
EXMLDV:    
           LHI \HB\OLDPG1         ;page where FPACC,FPOP are located
           LLI \LB\L100                ;get SIGNS indicator
           LAM                    ;into A
           NDA                    ;check sign bit
           JFS EXMLDV1            ;if positive, skip ahead
           XRA                    ;clear A and flags
           SUE                    ;subtract LSW of FPOP from zero
           LEA                    ;put back into E
           LAI 000                ;clear A w/o effecting carry
           SBD                    ;subtract MSW of FPOP from zero with borrow
           LDA                    ;put back into D
EXMLDV1:
           LLI \LB\L124                ;Set L to point to LSW of FPACC
           LME                    ;store LSW byte of product from E
           INL                    ;advance L to next word of 16 bit
           LMD                    ;store MSW byte of product from D
           RET	
 
FPDIVREM:
           CAL CKSIGNS            ;DE=|FPOP|; BC=|FPACC|, SIGNS=sign of result
           CAL FPDIV0             ;DE=remainder, BC=quotient
           LHI \HB\OLDPG1         ;page where FPOP is located
           LLI \LB\L134                ;Set L to point to LSW of FPOP
           LME                    ;store LSW byte from E
           INL                    ;advance L to next word of 16 bit
           LMD                    ;store MSW from D.  
           JMP EXMLDV1            ;store unsigned quotient in FPACC


CKSIGNS:
           LHI \HB\OLDPG1         ;page where FPACC,FPOP are located
           LLI \LB\L124                ;Set L to point to LSW of FPACC
           LCM                    ;get LSW byte into C
           INL                    ;advance L to next word of 16 bit
           LBM                    ;get MSW into B.  BC=FPACC
           LLI \LB\L134                ;Set L to point to LSW of FPOP
           LEM                    ;get FPOP LSW byte into E
           INL                    ;advance L to next word of 16 bit
           LDM                    ;get FPOP MSW into D.  DE=FPOP 

           LAD                    ;xor MSWs of FPOP
           XRB                    ;with FPACC
           LLI \LB\L100                ;store this (sign bit of product)
           LMA                    ;into "SIGNS" indicator
           LAB                    ;get MSW of FPACC
           NDA                    ;test if sign set
           JFS CKSIGNS1           ;if not skip ahead
           XRA                    ;clear A and flags
           SUC                    ;subtract LSW of FPACC from zero
           LCA                    ;put back into C
           LAI 000                ;clear A w/o effecting carry
           SBB                    ;subtract MSW of FPACC from zero with borrow
           LBA                    ;put back into B
CKSIGNS1:
           LAD                    ;get MSW of FPOP 
           NDA                    ;test if sign set
           RFS                    ;if not skip ahead
           XRA                    ;clear A and flags
           SUE                    ;subtract LSW of FPOP from zero
           LEA                    ;put back into E
           LAI 000                ;clear A w/o effecting carry
           SBD                    ;subtract MSW of FPOP from zero with borrow
           LDA                    ;put back into D
           RET                    ;return


FPOUT:     LHI \HB\OLDPG1
           LLI \LB\L125               ;MSW of 16-bit FPACC
           LAM
           NDA
           LAI 240               ;" " for positive numbers
           JFS FPOUTPOS          ;if sign bit not set, don't print "-"
           CAL FPCOMP            ;if sign bit set, form -FPACC
           LAI 255               ; and print "-"
FPOUTPOS: 
           DATA RST_ECHO         ;print either " " or "-"
           LLI \LB\L124
           CAL OPLOAD            ;FPOP=FPACC
           LBI 047               ;BC=10000
           LCI 020
           CAL FPOUTDIG
           LBI 003               ;BC=1000
           LCI 350
           CAL FPOUTDIG
           LBI 000               ;BC=100
           LCI 144
           CAL FPOUTDIG
           LBI 000               ;BC=10
           LCI 012
           CAL FPOUTDIG
           LLI \LB\L134
           LHI \HB\OLDPG1
           LAI 260
           ADM
           JMP ECHO 
FPOUTDIG:
           LHI \HB\OLDPG1         ;page of FPACC
           LLI \LB\L124                ;FPACC=BC (10^i argument set by imm loads above)
           LMC
           INL
           LMB
           CAL FPDIVREM           ;FPACC=remainder, FPOP (and BC)=quotient
           LAI 260                ;print '0'+quotient
           ADC
           DATA RST_ECHO
           RET                    ;return where called above

                                  ;following INPUT routines are taken from SCELBAL with float
                                  ;but reduced to deal with fixed point and use FPMULT above
                                  ;as in the SCELBAL interpreter itself, changes noted "++fxp"

GETINP:    LHI \HB\L220         ;** Set H to page of GETINP character counter
           LLI \LB\L220                ;Set L to address of GETINP character counter
           LCM                    ;Load counter value into CPU register C
           INC                    ;Exercise the counter in order
           DCC                    ;To set CPU flags. If counter is non-zero, then indexing
           JFZ NOT0               ;Register (GETINP counter) is all set so jump ahead.
           LLE                    ;But, if counter zero, then starting to process a new
           LHD                    ;Character string. Transfer char string buffer pointer into
           LCM                    ;H & L and fetch the string's character count value (cc)
           INC                    ;Increment the (cc) by one to take account of (cc) byte
           DATA RST_INDEXC             ;Add contents of regis C to H & L to point to end of the
           LMI 000                ;Character string in buffer and place a zero byte marker
NOT0:      LLI \LB\L220                ;Set L back to address of GETINP counter which is used
           LHI \HB\L220         ;** As an indexing value. Set H to correct page.
           LCM                    ;Fetch the value of GETINP counter into register C
           INC                    ;Increment the value in C
           LMC                    ;Restore the updated value for future use
           LLE                    ;Bring the base address of the character string buffer into
           LHD                    ;CPU registers H & L
           DATA RST_INDEXC          ;Add contents of register C to form indexed address of
           LAM                    ;Next character to be fetched as input. Fetch the next
           NDA                    ;Character. Exercise the CPU flags.
           LHI \HB\OLDPG1         ;** Restore page pointer to floating point working area
           RFZ                    ;If character is non-zero, not end of string, exit to calle
           LLI \LB\L220                ;If zero character, must reset GETINP counter for next
           LHI \HB\L220         ;** As an indexing value. Set H to correct page.
           LMI 000                ;String. Reset pointer and clear GETINP counter to zero
           LHI \HB\OLDPG1         ;** Restore page pointer to floating point working area
           RET                    ;Then exit to calling routine

                                  ;Main Decimal INPUT subroutine to convert strings of
                                  ;ASCII characters representing decimal fixed or floating
                                  ;point numbers to binary floating point numbers.

DINPUT:    LEL                    ;Save entry value of register L in E. (Pointer to buffer
           LDH                    ;Containing ASCII character string.) Do same for H to D.
           LHI \HB\OLDPG1         ;** Set H to page of floating point working registers
           CAL FPZERO             ;++fxp: clear FPACC
           CAL GETINP             ;Fetch a character from the ASCII chax string buffer
           LLI \LB\L103                ;Minus sign, set pointer to MINUS flag storage location.
           LMA                    ;Set the MINUS flag to indicate a minus number
           CPI 253                ;(Typically the SYMBOL/TOKEN buffer). See if it is
           JTZ NINPUT             ;Code for + sign. Jump ahead if code for + sign.
           CPI 255                ;See if code for minus (-) sign.
           JFZ NOTPLM             ;Jump ahead if not code for minus sign. If code for
NINPUT:    CAL GETINP             ;Fetch another character from the ASCII char string
NOTPLM:    CPI 240                ;Else see if code for space.
           JTZ NINPUT             ;Ignore space character, go fetch another character.
           NDA                    ;If none of the above see if zero byte
           JTZ DINEXIT        ;++fxp: Indicating end of input char string. If yes, done.
           ;RTZ                    ;++fxp: Indicating end of input char string. If yes, done.
           CPI 260                ;If not end of string, check to see
           JTS NUMERR             ;If character represents
           CPI 272                ;A valid decimal number (0 to 9)
           JFS NUMERR             ;Display error message if not a valid digit at this point!
           LLI \LB\L221                ;++fxp: documentation claims 221-223 unused 
           LMA                    ;++fxp: put char and string address here
           INL                    ;++fxp
           LME                    ;++fxp
           INL                    ;++fxp
           LMD                    ;++fxp
           LLI \LB\L134                ;++fxp: FPOP becomes ten
           LMI 012                ;++fxp
           INL                    ;++fxp
           LMI 000                ;++fxp
           CAL FPMULT             ;++fxp: FPACC=FPACC*10
           LLI \LB\L221                ;++fxp: address of saved character
           LAM                    ;++fxp: get char
           SUI 260                ;++fxp: form `char-'0'
           LLI \LB\L134                ;++fxp: FPOP becomes char-'0' 
           LMA                    ;++fxp
           INL                    ;++fxp
           LMI 000                ;++fxp
           CAL FPADD              ;++fxp: FPACC=FPACC+char-'0' 
           LLI \LB\L222                ;++fxp: address of old string pointer
           LEM                    ;++fxp: restore string pointer into DE 
           INL                    ;++fxp
           LDM                    ;++fxp
           JMP NINPUT             ;In the new digit in holding registers. Continue inputting.
DINEXIT:   LLI \LB\L103                ;Minus sign, set pointer to MINUS flag storage location.
           LAM                    ;get the MINUS flag 
           CPI 255                ;See if code for minus (-) sign.
           RFZ                    ;if not -, exit
           JMP FPCOMP

                                  ;The next subroutine will transfer the four byte
                                  ;register string (generally a number in floating point
                                  ;format) from the starting address pointed to by CPU
                                  ;registers H & L when the subroutine is entered to
                                  ;the FPACC (floating point accumulator registers).

FLOAD:     LDI \HB\OLDPG1         ;** Set page address of FPACC
           LEI \LB\L124                ;Set address of least signficant byte of FPACC
           LBI 004                ;Set precision counter to four bytes (mantissa bytes
           JMP MOVEIT             ;Plus Exponent) and exit via the transfer routine

FPCOMP:    XRA                    ;clear A
           LLI \LB\L124                ;Set L to point to LSW of FPACC
           LHI \HB\OLDPG1         ;page where FPACC,FPOP are located
           SUM                    ;subtract LSW from 0 without carry
           LMA                    ;replace negated byte into FPACC
           INL                    ;point to next byte
           LAI 000                ;clear a without disturbing carry
           SBM                    ;subtract byte from 0 with carry
           LMA                    ;replace negated byte into FPACC
           ;for the moment only 16 of 32 bits 
           ;INL                    ;point to next byte
           ;LAI 000                ;clear a without disturbing carry
           ;SBM                    ;subtract byte from 0 with carry
           ;LMA                    ;replace negated byte into FPACC
           ;INL                    ;point to next byte
           ;LAI 000                ;clear a without disturbing carry
           ;SBM                    ;subtract byte from 0 with carry
           ;LMA                    ;replace negated byte into FPACC
           RET
                                  ;The following subroutine SUBTRACTS the
                                  ;contents of the FPOP and
                                  ;leaves the result in the FPACC. 
                                  ;by negating the FPACC first, and doing FPADD

FPSUB:     CAL FPCOMP             ;form negative of FPACC and fall thru to addition

                                  ;Fixed point ADDITION. Adds contents of FPACC to
                                  ;FPOP and leaves result in FPACC. 

FPADD:     
           LHI \HB\OLDPG1         ;page where FPACC,FPOP are located
           LLI \LB\L125                ;sign extension of FPACC
           LAM                    ;get 16-bit MSW
           RAL                    ;put sign bit in carry
           SBA                    ;000 in A if pos; 377 if neg
           LLI \LB\L126                ;make this the 24-bit sign extended byte
           LMA                    ;in what is otherwise unused loc of FPACC
           LLI \LB\L135                ;sign extension of FPOP
           LAM                    ;get 16-bit MSW
           RAL                    ;put sign bit in carry
           SBA                    ;000 in A if pos; 377 if neg
           LLI \LB\L136                ;make this the 24-bit sign extended byte
           LMA                    ;in what is otherwise unused loc of FPOP

           LLI \LB\L134                ;Set L to point to LSW of FPOP
           LAM                    ;get LSW byte
           LLI \LB\L124                ;Set L to point to LSW of FPACC
           ADM                    ;add without carry
           LMA                    ;replace sum byte into FPACC
           LLI \LB\L135                ;Set L to point to next byte of FPOP
           LAM                    ;get next byte
           LLI \LB\L125                ;Set L to point to next byte of FPACC
           ACM                    ;add with carry
           LMA                    ;replace next sum byte into FPACC
           ;for the moment only 16 of 32 bits 
           LLI \LB\L136                ;Set L to point to next byte of FPOP
           LAM                    ;get next byte
           LLI \LB\L126                ;Set L to point to next byte of FPACC
           ACM                    ;add with carry
           LMA                    ;replace next sum byte into FPACC
           ;LLI \LB\L137                ;Set L to point to MSW of FPOP
           ;LAM                    ;get next byte
           ;LLI \LB\L127                ;Set L to point to MSW of FPACC
           ;ACM                    ;add with carry
           ;LMA                    ;replace MSW into FPACC
           RET
;***************************************************************************************
;   end of 2013 fixed-point package
;***************************************************************************************

INPUT:     DATA RST_CLESYM             ;Clear the SYMBOL BUFFER
           LLI \LB\L202                ;Load L with address of SCAN pointer storage location
           LBM                    ;Fetch value of SCAN pointer to register B
           INB                    ;Increment value to point to next chamcter
           LLI \LB\L203                ;Change L to point to INPUT pointer (formerly TOKEN)
           LMB                    ;Updated SCAN pointer becomes INPUT pointer
INPUT1:    LLI \LB\203                ;Load L with address of INPUT pointer
           DATA RST_GETCHR             ;Fetch a character from the line input buffer
           JTZ INPUT3             ;If character is a space, ignore it. Else,
           CPI 254                ;See if character is a comma. If so, process the
           JTZ INPUT4             ;Variable that preceeds the comma.
INPUT2:    CAL CONCTS             ;Concatenate character to SYMBOL BUFFER
INPUT3:    LLI \LB\L203                ;Load L with address of INPUT pointer
           DATA RST_LOOP               ;Increment INPUT pointer and test for end of line
           JFZ INPUT1             ;If not end of line, go get next character
           CAL INPUTX             ;If end of buffer, get input for variable in the SYMBOL
           CAL STOSYM             ;BUFFER and store the value in the VARIABLES table
           JMP NXTLIN             ;Then continue to interpret next statement line
INPUT4:    CAL INPUTX             ;Get input from user for variable in SYMBOL BUFFER
           CAL STOSYM             ;Store the inputted value in the VARIABLES table
           LHI \HB\OLDPG26        ;** Set H to page of INPUT pointer
           LLI \LB\L203                ;Set L to location of INPUT pointer
           LBM                    ;Fetch pointer value for last character examined
           LLI \LB\L202                ;Change L to point to SCAN pointer storage location
           LMB                    ;Update the SCAN pointer
           JMP INPUT              ;Continue processing statement line for next variable
INPUTX:    
INPUTN:    LLI \LB\L144                ;Load L with address of start of AUX SYMBOL BUFF
           LHI \HB\OLDPG26        ;** Load H with page of AUX SYMBOL BUFFER
           LAI 277                ;Load accumulator with ASCII code for ? mark
           DATA RST_ECHO               ;Call output subroutine to display the ? mark
           CAL STRIN              ;Input string of characters (number) fm input device
          JMP DINPUT             ;Convert decimal string into binary floating point nr.
L000_27:	DATA 3
	DATA "REM"
	DATA 2
	DATA "IF"
	DATA 3    ;MGA 3/31/12 Loboyko transcription error
	DATA "LET"
L013_27:	DATA 4
	DATA "GOTO"
	DATA 5
	DATA "PRINT"
        DATA 5
        DATA "INPUT"
	DATA 3
	DATA "END"
	DATA 0			; END OF TABLE
L320:	DATA 4
	DATA "THEN"
L335:	DATA 4
	DATA "LIST"
L342:	DATA 3
	DATA "RUN"
L346:	DATA 3
	DATA "SCR
L352:	DATA 013		; CC FOR "READY" MESSAGE
	DATA 224,215,212	; CTRL-T, CARRIAGE RETURN, LINE FEED
	DATA "READY"
	DATA 215,212,212	; CARRIAGE RETURN, LINE FEED, LINE FEED;
	DATA 011
	DATA " AT LINE "
	;; HEIRARCHY TABLE (FOR OUT OF STACK OPS)
	;; USED BY PARSER ROUTINE.
;;; This SHOULD START AT 26 240
L240: 	DATA 000		; EOS
	DATA 003		; PLUS SIGN
	DATA 003		; MINUS SIGN
	DATA 004		; MULTIPLICATION SIGN
	DATA 004		; DIVISION SIGN
	DATA 005		; EXPONENT SIGN
	DATA 006		; LEFT PARENTHESIS
	DATA 001		; RIGHT PARENTHESIS
	DATA 002		; NOT ASSIGNED
	DATA 002		; LESS THAN SIGN
	DATA 002		; Equal sign
	DATA 002		; GREATER THAN SIGN
	DATA 002		; LESS THAN OR EQUAL COMBO
	DATA 002		; EQUAL OR GREATER THAN
	DATA 002		; LESS THAN OR GREATER THAN

	;; HEIRARCHY TABLE (FOR INTO STACK OPS)
	;; USED BY PARSER ROUTINE.
;;; This SHOULD START AT 26 257
L257:	DATA 000		; EOS
	DATA 003		; PLUS SIGN
	DATA 003		; MINUS SIGN
	DATA 004		; MULTIPLICATION SIGN
	DATA 004		; DIVISION SIGN
	DATA 005		; EXPONENTIATION SIGN
	DATA 001		; LEFT PARENTHESIS
	DATA 001		; RIGHT PARENTHESIS
	DATA 002		; NOT ASSIGNED
	DATA 002		; LESS THAN SIGN
	DATA 002		; EQUAL SIGN
	DATA 002		; GREATER THAN SIGN
	DATA 002		; LESS THAN OR EQUAL SIGN
	DATA 002		; EQUAL TO OR GREATER THAN
	DATA 002		; LESS THAN OR GREATER THAN
L004:	DATA 001,000,000,000	;++fxp:fixed point +1


	
; 
; &&&&&&&&& end of non-volatile (ROM) code &&&&&&&&&&&&&&&&&&&&&&&&
;
	
	

	

	


	ORG 015#000
L000:	DATA 000		; CC FOR INPUT LINE BUFFER
L001:	DATA 000		; first char of input line buffer
	DATA *78 		; THE INPUT LINE BUFFER
L120:	DATA 000        	; CC for symvbol buffer
L121:  	DATA 000		; 1st char
L122:   DATA 000		; 2nd char
	DATA 000	; THESE ARE SYMBOL BUFFER STORAGE
	DATA 000,000,000,000
	DATA 000,000,000,000	; SHOULD BE 26-120 TO 26 143
	DATA 000,000,000,000
	DATA 000,000,000,000
L144:	DATA 000,000,000,000	; THESE LOCATIONS ARE AUXILIARY SYMBOL BUFFER
	DATA 000,000,000,000
	DATA 000,000,000,000	; SHOULD BE 26 144 TO 26 175
	DATA 000,000,000,000
	DATA 000,000,000,000
	DATA 000,000,000,000
	DATA 000,000
L176:	DATA 000		; TEMP SCAN STORAGE REGISTER
L177:	DATA 000		; TAB FLAG
L200:	DATA 000		; EVAL CURRENT TEMP REG.
L201:	DATA 000		; SYNTAX LINE NUMBER
L202:	DATA 000		; SCAN TEMPORARY REGISTER
L203:	DATA 000		; STATEMENT TOKEN
L204:	DATA 000,000		; TEMPORARY WORKING REGISTERS
L206:	DATA 000,000		; ARRAY POINTERS
;;; NOW WE SHOULD BE UP TO 26 210
L210:	DATA 000		; OPERATOR STACK POINTER
	DATA *15		; OPERATOR STACK
L230:	DATA 000		; FUN/ARRAY STACK POINTER
	DATA *7			; FUNCTION/ARRAY STACK
;;; THE LAST BYTE SHOULD HAVE BEEN 26 237



L276:	DATA 000		; EVAL START POINTER
L277:	DATA 000		; EVAL FINISH POINTER

L340:	DATA 000,000,000,000	; LINE NUMBER BUFFER STORAGE
	DATA 000,000,000,000	; (SHOULD BE 340-347)
L350:	DATA 000,000,000,000	; AUX LINE NUMBER BUFFER
	DATA 000,000,000,000	; (SHOULD BE 350-357)
;;; The following data is a change in page 3 of Scelbal update issue 4
;;; which apparently makes the "INSERT" command work correctly, the
;;; first time (later SCR commands load 33 into this spot) 
L360:	DATA 000 		; USER PGM LINE PTR (PG)
	DATA 000 		; USER PGM LINE PTR (LOW)
;	DATA 000 		; AUX PGM LINE PTR (PG)
;	DATA 000 		; AUX PGM LINE PTR (LOW)
L364:	DATA 000 		; END OF USER PGM BUFFER PTR (PG)
	DATA 000 		; END OF USER PGM BUFFER PTR (LOW)
L366:	DATA 000		; PARENTHESIS COUNTER (366)
L367:	DATA 000		; QUOTE INDICATOR
L370:	DATA 000		; TABLE COUNTER (370)
L371: 	DATA 000		; temp op

L077_27:	DATA 0

L202_27:	DATA 000  		; STOSYM COUNTER

L227:	DATA 000		; ARITHMETIC STACK POINTER (01 227)
L230_0: DATA 000,000,000,000		; ARITHMETIC STACK (NOT CLEAR HOW LONG)
        DATA 000,000,000,000
        DATA 000,000,000,000
        DATA 000,000,000,000
        DATA 000,000,000,000
        DATA 000,000,000,000
        DATA 000,000,000,000
        DATA 000,000,000,000

L043:	DATA 000 ;column counter
L220:	DATA 000		; GETINP COUNTER



 
; this page is shared by the following data, and the start of usr pgm

       ORG 016#000

L210_27:	DATA 000		; USED AS VARIABLES SYMBOL TABLE
	DATA *119		; (SHOULD BE 211-377 RESERVED)
	DATA 000
	;; THIS SHOULD BE THE END OF PAGE 01
L100:	DATA 000		; SIGN INDICATOR
L103:   DATA 000,000		; SIGN INDICATOR
L124: 	DATA 000
L125:	DATA 000
L126: 	DATA 000
L127:	DATA 000		; FPACC LSW, NSW, MSW, EXPONENT
L134: 	DATA 000
L135:	DATA 000
L136: 	DATA 000
L137:	DATA 000		; FPOP LSW, NSW, MSW, EXPONENT
L221: 	DATA 000		;++fxp: saved char (new DINPUT)
L222: 	DATA 000,000 		;++fxp: saved address of string  (new DINPUT)
BGNPGRAM: DATA 000



