4FFDLINFL1
DEC HL
Back up the pointer in the BASIC program (stored in Register Pair HL) by 1 in preparation for the RST 10H command which advances HL.
4FFELINFOL
RST 10H
We are still looking for a line number. Call the EXAMINE NEXT SYMBOL routine at RST 10H.
NOTE:- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY FLAG if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Original Source Code Comment: GET CANDIDATE FOR LINE NUMBER
4FFF
PUSH HL
Save the pointer in the BASIC Program (stored in Register Pair HL) to the top of the stack.
5000
OR A
Set FLAGS based on the contents of Register A to see if we are at end of line (00H) or not. If we are at the end of the line ...
5001
... JUMP to 500CH since we don't need to check for a LINE FEED.
The LOKLF routine looks for a LINE FEED character.
5003LOKLF
INC HL
INCrement the pointer in the BASIC program (stored in Register Pair HL) by 1.
Original Source Code Comment: GO LOOK FOR A LINE FEED
5004
LD A,(HL)
Fetch a byte of the BASIC program (held in the memory location pointed to by Register Pair HL) and store it into Register A.
Original Source Code Comment: GET THE CHAR
5005
CP 0AH
Compare the value held in Register A against 0AH (ASCII: LINE FEED). If the current character in the BASIC program is a LINE FEED ...
Original Source Code Comment: CHECK FOR LINE FEED
5007
... replace it with a "*" and continue via a JUMP to 500FH.
5009
OR A
Set FLAGS based on the contents of Register A. If it is not end of line (i.e., 00H) ....
500A
LOOP back to the top of the LOKLF routine and keep looking for the LINE FEED.
Next we are going to put a "*" wherever there was a LINE FEED. If (HL) is not a line feed, then a dummy HL of 4121H is offered as the sacrificial location to put the "*".
500CNOLF
LD HL,4121HLD HL,FACLO
If (HL) wasn't pointing to a LINE FEED we don't want the next line to overwrite that character with a *, so let Register Pair HL equal 4121H as a dummy location to put the *.
500FCLRLF
LD (HL),2AH
Store a * into the memory location pointed to by Register Pair HL (which is either the dummy location if there wasn't a LINE FEED there, or to overwrite a LINE FEED if it was there).
5011
EX DE,HL
Put the value stored in Register Pair HL (which could be either 4121H or the position in the BASIC program AFTER searching for the LINE FEED) into DE. HL is discarded so it doesn't matter what was in DE.
5012
POP HL
Restore the pointer in the BASIC Program (before searching for the LF) held at the top of the STACK into Register Pair HL, and then remove the entry from the stack.
5013
PUSH HL
Save the pointer in the BASIC Program (before searching for the LF) to the top of the stack.
Original Source Code Comment: GET BACK START (HL)
5014
PUSH DE
Save the contents of Register Pair DE (which could be either 4121H or the position in the BASIC program AFTER searching for the LINE FEED) to the top of the stack.
5015
Convert the ASCII string pointed to by HL to an integer deposited into DE via a GOSUB to the Model III ROM routine at 1E5AH. After execution HL points to the delimiter and the A register contains the delimiter value. The Z flag is set if the delimiter equals 00 or 3A. Z is reset if any other delimiter is used. If the routine finds a non-numerical character, the conversion is stopped
5018
LD A,0AH
Let Register A equal 0AH (ASCII: LINE FEED.
501A
POP BC
Put the value held at the top of the STACK which could be either 4121H or the position in the BASIC program AFTER searching for the LINE FEED) into Register Pair BC, and then remove the entry from the stack.
501B
LD (BC),A
Restore the LINE FEED into the memory location pointed to by Register Pair BC.
Original Source Code Comment: RESTORE LINE FEED
Next we need to check to see if we advanced in the BASIC program.
501C
POP BC
Restore the pointer in the BASIC Program (before searching for the LF) held at the top of the STACK into Register Pair BC, and then remove the entry from the stack.
Original Source Code Comment: SEE IF ADVANCED
501D
LD A,L
Copy the contents of Register L (i.e., the current location in the program) into Register A.
Original Source Code Comment: CURRENT
501E
SUB C
Subtract the LSB from the program before searching for the LF from the LSB of the current location of the program, to see if we have moved. If this is NZ, there was a Line Feed.
Original Source Code Comment: MINUS PREVIOUS
501F
If the Z FLAG (Zero) has been set, go back to whence we came and continue processing characters via a JUMP to 5045H.
Original Source Code Comment: IF NON ZERO THERE WAS A LINE
5021
PUSH DE
Otherwise, save the LINE NUMBER (held in Register Pair DE) to the top of the stack.
Original Source Code Comment: SAVE THE LINE NUMBER
The next steps calculate the number of SPACES we need to add.
5022
LD E,A
Copy the contents of Register A into Register E.
Original Source Code Comment: CALCULATE SIZE LINE# - 5
5023
LD A,02H
Assume we want TWO spaces, so set Register A to 02H.
Original Source Code Comment: ASSUME PUT IN 2 SPACES
5025
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
5026
LD A,05H
Let Register A equal 05H.
5028
SUB E
LET Register A = Register A - Register E. Register A now holds the number of spaces we need to insert to make room for a hard line number.
Original Source Code Comment: INTO (A)
5029
If the number spaces is still positive, JUMP to 5032H to move the program to make room for the line number.
502B
CPL
If, however, the number of spaces went negative because the line number was more than 5 characters including zeros and spaces, we need to make even more room. First, reverse each bit in Register A (which is the same as NOT) to become positive.
Original Source Code Comment: SINCE LINE # CAN BE
502C
INC A
INCrement the value stored in Register A by 1.
Original Source Code Comment: GREATER THAN FIVE CHARS. WITH LEADING ZEROS
502D
POP DE
Put the value held at the top of the STACK (which should be 02H) into Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: AND TRAILING SPACES WE MAY NEED EXTRA SPACES
502E
ADD A,02H
Add two assumed spaces by letting Register A = Register A + 02H.
Original Source Code Comment: PLUS THE ASSUMED 2
5030
PUSH AF
Save the space count (held in Register Pair AF) to the top of the stack.
Original Source Code Comment: SAVE SPACE COUNT
5031
XOR A
Set Register A to ZERO and clear all Flags.
Next we make room for the hard line number, put in the hard line number indicator byte, the line number, and then spaces to fill the remainder.
5032MOVPR2
PUSH BC
Save the location that the LINE VALUE CONSTANT is going to be placed (held in Register Pair BC) to the top of the stack.
Original Source Code Comment: SAVE START OF PUT PLACE
5033
If the NZ FLAG (Not Zero) has been set, ??? move (HL) for (A) bytes via a GOSUB to 5071H.
Original Source Code Comment: MOVE AT (HL) FOR (A) BYTES
5036
POP HL
Restore the pointer to the to the BASIC program (held at the top of the Stack) into Register Pair HL). This should be the 5 bytes that need to be replaced with an actual hard line number.
Original Source Code Comment: GET START OF 5 BYTES
5037
LD (HL),0EHLD (HL),LINCON
Store the flag for a LINE VALUE CONSTANT into the memory location pointed to by Register Pair HL.
5039
INC HL
INCrement the pointer to the BASIC program (held in Register Pair HL) by 1.
503A
POP BC
Restore the space count into Register B from the top of the STACK, as B acts as the counter of a DJNZ loop.
Original Source Code Comment: GET SPACE COUNT INTO (B)
503B
POP DE
Restore the LINE VALUE CONSTANT (held at the top of the STACK) into Register Pair DE, and then remove the entry from the stack.
Original Source Code Comment: GET BACK THE LINE NUMBER
503C
LD (HL),E
Store the LSB of LINE VALUE CONSTANT (held in Register E) into the BASIC Program at the memory location pointed to by Register Pair HL.
503D
INC HL
INCrement the pointer to the BASIC program (held in Register Pair HL) by 1.
503E
LD (HL),D
Store the MSB of LINE VALUE CONSTANT (held in Register D) into the BASIC Program at the memory location pointed to by Register Pair HL.
503FSPCPUR
INC HL
Top of a DJNZ loop. INCrement the pointer to the BASIC program (held in Register Pair HL) by 1.
5040
LD (HL),20H
Store a SPACE into the BASIC Program at the memory location pointed to by Register Pair HL.
5042
LOOP back to 503FH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
The line number and spaces are now present. If passing through, we need to bump HL because the routine starts off by reducing it because the RST 10H needs it to be HL-1.
5044SNOLIN
INC HL
INCrement the value stored in Register Pair HL by 1.
5045NOLIN
DEC HL
DECrement the value stored in Register Pair HL by 1.
5046
RST 10H
Call the EXAMINE NEXT SYMBOL routine at RST 10H.
NOTE:- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY FLAG if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
5047
5048
INC A
DEC A
Set the Z or NZ flag based on the character in Register A.
5049
If the C FLAG (Carry) has been set then the character is alphabetic (and not alphanumeric), so JUMP to 4FFDH.
504B
INC HL
INCrement the pointer to the BASIC program (held in Register Pair HL) by 1.
504C
If the Z FLAG (Zero) has been set then the RST 10H returned a 0, which is end of line. With this, we need to move to process the next line via a JUMP to 4F9AH.
If we are here, we know that the character held in Register A is alphanumeric and not a 00H EOL marker.
504F
DEC HL
In preparation for the next set of tests which would need such thing, we do a one time DECrement the pointer to the BASIC program (held in Register Pair HL) by 1.
5050
CP 20H
Compare the value held in Register A against 20H (ASCII: SPACE) since we want to skip any between line separators. If there is a SPACE there ...
Original Source Code Comment: SKIP SEPERATORS OK BETWEEN LINES
5052
... push HL to point to the next character in the BASIC Program via a JUMP to 5044H.
5054
CP 2CH
Compare the value held in Register A against 2CH (ASCII: ,). If it is a , ...
5056
... push HL to point to the next character in the BASIC Program via a JUMP to 5044H.
5058
CP 0CEHCP MINUTK
Compare the value held in Register A against CEH (Decimal: 206). Results: If Register A equals 0CEH ...
505A
... push HL to point to the next character in the BASIC Program via a JUMP to 5044H.
505C
CP 0D4HCP GREATK
Compare the value held in Register A against D4H (Decimal: 212). If A < D4H, the CARRY FLAG will be set ...
505E
If the C FLAG (Carry) has been set, JUMP to 5064H to zero out the array variable table and RETurn.
5060
CP 0D7HCP LESSTK+1
Compare the value held in Register A against 0D7H (Decimal: 215). If A < 0D7H ...
5062
... push HL to point to the next character in the BASIC Program via a JUMP to 5044H.
5064GOPNXT
JUMP to 4FA2H to process the next character in the BASIC program.