0020H - RST 20H Routine - This routine will compare HL and DE. NZ means no match, Z means match.
This routine will skip forward from DE until the first non-space character, with Register A holding that character.
This routine will continue execution.
This routine will check a variable to make sure it exists. If it doesn't, CARRY will be set. If it does, HL will point to the variable and NC will be set. Note that only variables A-Z and A(n) are valid in Level 1.
This would be triggered on hitting the RESET BUTTON.
At this point, HL has the current pointer to the line being examined is at the top of the stack, DE has the pointer to the variable, Z/NZ is set based on whether the location of the array variable is in or out of bounds, and if Register A is greater than Register E, the CARRY FLAG is set.
Jumped to if the variable is "A" and no "(" was found after it. This routine will set HL to point to the RAM address which holds the variables "A" - "Z"
Register A will contain 0-25, representing variables "A"-"Z".
If a digit is found, will return with Register A containing the digit and NC set, or the CARRY FLAG set otherwise.
Jumped here if we have a non-digit that isn't a "." or an "E".
Jumped here if we have started processing an exponent and then hit a non-digit.
Clear out H', L', C', and Bit 6 of Register B' in anticipation of starting to parse.
This basically multiplies the 24 bit digit represented by C'H'L' by 10 and then adds in A' with overflow going to B' thus leaving a 32 bit result of B'C'H'L'.. Specifically it accumulates the digit by multiplying the accumulator by 10 and then adding in A to the newly vacant one's spot. Routine will return a NZ SET if an overflow occurs from the accumulation. On entry, the REGULAR REGISTER SET is active.
018EH - Determine How Much RAM is in the System by fetching, complementing, storing, and testing each byte from FFFFH downwards. HL = 00FFH on entry.
TRS-80 - Level 1 ROM Disassembled
Entry point for the ON x GOTO Command.
050FH
POP HL
Put the value held at the top of the STACK into Register Pair HL.
0510H
GOSUB to 0526H to turn the value passed after the ON (i.e., the ON x expression) into a line number.
0513H
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
0514H
JUMP to 03BCH which is inside the GOTO routine.
Entry point for the ON x GOSUB Command.
0517H
POP HL
Put the value held at the top of the STACK into Register Pair HL.
0518H
GOSUB to 0526H to turn the value passed after the ON (i.e., the ON x expression) into a line number.
051BH
LD (409BH),HL
Store the value held in Register Pair HL into the pointer to the FOR LOOP's NEXT variable (held in memory location 409BH).
051EH
GOSUB to 0A9FH to move the BASIC language stack to make room for a new stack entry (like the return address of a GOSUB or the value of a FOR loop).
0521H
LD HL,(409BH)
Fetch the pointer to the FOR LOOP's NEXT variable (held in memory location 409BH) and store it into Register Pair HL.
0524H
JUMP to 04CAH which is inside the GOSUB routine.
Part of the ON Command; turns the value/expression passed after the ON into a line number.
0526H
DEC L
DECrement the value stored in Register L by 1.
0527H
If the Z FLAG (Zero) has been set, JUMP to 0539H to parse the referenced line number.
0529H
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
052AH
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
052CH
If the character is a CARRIAGE RETURN, then we don't have a good value and the Z FLAG (Zero) has been set, so JUMP BACK to 050BH to continue processing (i.e., looking for a : or CARRIAGE RETURN) as if the index passed was zero.
052EH
CP 3AH
If we are here, then we got either the CARRIAGE RETURN or the :, so compare the value held in Register A against 3AH (ASCII: :). If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG will be set.
0530H
If the character is a :, then we don't have a good value and the Z FLAG (Zero) has been set, so JUMP BACK to 050BH to continue processing as if the index passed was zero.
0532H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
0533H
CP 2CH
CP ","
Compare the value held in Register A against 2CH (ASCII: ,). Results: If Register A equals ,, the Z FLAG is set; otherwise the NZ FLAG will be set.
0535H
If the character was a , then we have to process the list, so continue the routine by JUMPing to 0526H.
0537H
JUMP to 0529H to continue parsing the command line.
Part of the ON Command; parse the line number of an ON x LINE NUMBER command, and then read (and discard) characters on the BASIC line until we hit a CARRIAGE RETURN or a :.
0539H
GOSUB to 0EBDH to parse an integer into HL or set NZ for an error. RETURN if NZ, or JUMP to 08C9H to display the "WHAT" error otherwise.
053CH
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
053DH
CP 3AH
Compare the value held in Register A against 3AH (ASCII: :). Results: If Register A equals :, the Z FLAG is set; otherwise the NZ FLAG is set.
053FH
RET Z
If the character was a :, then the Z FLAG will have been set, so RETurn to the caller.
0540H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
0542H
RET Z
If the character was a CARRIAGE RETURN, then the Z FLAG will have been set, so RETurn to the caller.
0543H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
0544H
LOOP BACK to the top of this routine at 053CH to keep checking characters until we hit a CARRIAGE RETURN) or a :).
Entry point for the FOR Command.
0546H
GOSUB to 0A9FH to move the BASIC language stack to make room for a new stack entry (like the return address of a GOSUB or the value of a FOR loop).
0549H
GOSUB to 08A8H to parse for a variable which is then followed by an equal and an expression.
054CH
LD (40A5H),HL
Store the value held in Register Pair HL into memory location 40A5H (which is the pointer to the current FOR LOOP variable).
054FH
LD HL,030BH
Let Register Pair HL equal 030BH, which will be the location in ROM where the command lookup table is, starting with the TO command.
0552H
JUMP to 0343H in the READY COMMAND LOOP to try to match reserved words, starting at the TO command.
Entry point for the TO Command.
0555H
Determine the TO value which is present on the command line via a GOSUB to 0807H to calculate an integer expression with the results into Register Pair HL.
0558H
LD (406EH),HL
Store the "TO" value, held in Register Pair ,HL into memory location 406EH (which holds current FOR LOOP END (i.e., the TO) value).
055BH
LD HL,0311H
Let Register Pair HL equal 0311H, which will be the location in ROM where the command lookup table is, starting with the STEP command.
055EH
JUMP to 0343H in the READY COMMAND LOOP to try to match reserved words, starting at the STEP command.
Entry point for the STEP Command.
0560H
Determine the STEP value which is present on the command line via a GOSUB to 0807H to calculate an integer expression with the results into Register Pair HL.
0563H
Skip over the next instruction via a JUMP to 0568H.
0565H
LD HL,0001H
Set a default STEP value as 1 by setting Register Pair HL equal to 0001H.
0568H
LD (4091H),HL
Store the STEP value (held in Register Pair HL) into the of the FOR LOOP STEP (held in memory location 4091H).
056BH
LD HL,(409FH)
Fetch the pointer to the current line being executed (held in memory location 409FH) and store it into Register Pair HL.
056EH
LD (4093H),HL
Store the value held in Register Pair HL into memory location 4093H (which holds address of the top of the current FOR LOOP).
0571H
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
0572H
LD (4095H),HL
Store the value held in Register Pair HL into memory location 4095H (which holds address of the current FOR statement).
0575H
LD BC,000AH
Let Register Pair BC equal 000AH (Decimal: 10).
0578H
LD HL,(40A5H)
Fetch the value held in memory location 40A5H (which is the pointer to the current FOR LOOP variable) and store it into Register Pair HL.
057BH
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
057CH
LD H,B
Copy the contents of Register B (which is a 00H) into Register H.
057DH
LD L,B
Copy the contents of Register B (which is a 00H) into Register L.
057EH
ADD HL,SP
LET Register Pair HL = Register Pair HL + Register SP.
057FH
LD A,09H
Let Register A equal 09H. So on first pass, perhaps this sets Register A to 09, just to be overwritten by a LD A,xx. Since there is a jump point to 0580H, I assume that this some cleverness to also have a LD HL,BC on future passes.
0580H
ADD HL,BC
Let HL = HL + BC.
0581H
LD A,(HL)
Fetch the value held in the memory location pointed to by Register Pair HL and store it into Register A.
0582H
INC HL
INCrement the value stored in Register Pair HL by 1.
0583H
OR (HL)
OR the value stored at (HL+1) against the value stored at (HL) which is now in Register A. The results are stored in Register A.
0584H
If (HL+1) = (HL) then the Z FLAG will have been set, JUMP to 059EH to clean up and exit the routine.
0586H
LD A,(HL)
If they differ, then fetch the value held in the memory location pointed to by Register Pair HL and store it into Register A.
0587H
DEC HL
DECrement the value stored in Register Pair HL by 1.
0588H
CP D
Compare the value held in Register A against the value held in Register D. Results:
- If Register A equals the value held in Register D, the Z FLAG is set.
- If A < D, the CARRY FLAG will be set.
- If A >= D, the NO CARRY FLAG will be set.
0589H
If the NZ FLAG (Not Zero) has been set, LOOP BACK to 0580H.
058BH
LD A,(HL)
Fetch the value held in the memory location pointed to by Register Pair (HL) and store it into Register A.
058CH
CP E
Compare the value held in Register A against the value held in Register E. Results:
- If Register A equals the value held in Register E, the Z FLAG is set.
- If A < E, the CARRY FLAG will be set.
- If A >= E, the NO CARRY FLAG will be set.
058DH
If the NZ FLAG (Not Zero) has been set, LOOP BACK to 0580H.
058FH
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
0590H
LD HL,0000H
Let Register Pair HL equal 0000H.
0593H
ADD HL,SP
LET Register Pair HL = Register Pair HL + Register SP.
0594H
LD B,H
Copy the contents of Register H into Register B.
0595H
LD C,L
Copy the contents of Register L into Register C.
0596H
LD HL,000AH
Let Register Pair HL equal 000AH (Decimal: 10).
0599H
ADD HL,DE
LET Register Pair HL = Register Pair HL + Register DE.
059AH
GOSUB to 0A77H to copy the bytes, backwards, from BC through DE to HL.
059DH
LD SP,HL
Copy the contents of Register Pair HL into Register Pair SP.
059EH
LD HL,(4095H)
Fetch the value held in memory location (4095H) and store it into Register Pair HL.
05A1H
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
05A2H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
Entry point for the NEXT Command.
05A3H
RST 38H
RST 38H checks the command line to see if the next non-space character is an existing variable; HL to point to the variable if it exists and CARRY set if it doesn't.
05A4H
If the C FLAG (Carry) has been set, then we didn't get a variable after the NEXT command so JUMP to 08C9H to display the "WHAT" error.
05A7H
LD (409BH),HL
Store the value held in Register Pair HL into the pointer to the FOR LOOP's NEXT variable (held in memory location 409BH).
05AAH
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
05ABH
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
05ACH
LD HL,(40A5H)
Fetch the value held in memory location 40A5H (which is the pointer to the current FOR LOOP variable) and store it into Register Pair HL.
05AFH
LD A,H
OR L
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
05B1H
If HL=0 then there is no active FOR command so JUMP to 08CAH to display the "WHAT" error message.
05B4H
RST 20H
Compare the NEXT variable with the FOR variable (i.e., HL and DE) via a call to RST 20H. Results: NZ means no match, Z means match, and if H=D but L < E, then the C flag will be set.
05B5H
If they match, jump away to 05C0H.
05B7H
POP DE
Put the value held at the top of the STACK into Register Pair DE.
05B8H
GOSUB to 0A84H to move the various items held in the BASIC stack to their corresponding RAM location values. Essentially a group POP from the BASIC stack.
05BBH
LD HL,(409BH)
Fetch the pointer to the FOR LOOP's NEXT variable (held in memory location 409BH) and store it into Register Pair HL.
05BEH
JUMP to 05AAH to see if the NEXT command now matches the proper variable.
Continuation of the NEXT Command; jumped here if the FOR and NEXT variables match the current BASIC stack frame.
05C0H
GOSUB to 0BC3H to push the variable held in Register Pair HL into the FLOATING POINT STACK.
05C3H
GOSUB to 0C0BH to convert the number in the FLOATING POINT STACK into an INTEGER to be stored in Register Pair HL.
05C6H
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
05C7H
LD HL,(4091H)
Fetch the FOR LOOP STEP (held in memory location 4091H) and store it into Register Pair HL.
05CAH
PUSH HL
Save the FOR LOOP STEP value (held in Register Pair HL) to the top of the stack.
05CBH
ADD HL,DE
Calculate the new step value by adding that value with Register Pair DE; results in Register Pair HL.
05CCH
PUSH HL
Save the new STEP value (held in Register Pair HL) to the top of the stack.
05CDH
GOSUB to 0C59H to convert the value stored in Register Pair HL to a floating point number in the Floating Point Stack.
05D0H
LD HL,(40A5H)
Fetch the value held in memory location 40A5H (which is the pointer to the current FOR LOOP variable) and store it into Register Pair HL.
05D3H
GOSUB to 0BE9H to update the FOR variable to a new value.
05D6H
POP DE
Put the value held at the top of the STACK into Register Pair DE.
05D7H
LD HL,(406EH)
Fetch the current FOR LOOP END (i.e., the TO) value (held in memory location 406EH) and store it into Register Pair HL.
05DAH
POP AF
Put the value held at the top of the STACK into Register Pair AF.
05DBH
OR A
Set FLAGS based on the contents of Register A, most notedly in this case, the SIGN bit of the STEP value.
05DCH
If the S FLAG has been RESET, skip the next instruction and JUMP to 05E0H.
05DFH
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
05E0H
LD A,H
Copy the MSB of Register Pair HL (i.e., the contents of Register H) into Register A.
05E1H
XOR D
eXclusive OR Register D against Register A. The results are stored in Register A.
05E2H
If the S FLAG has been RESET, skip the next instruction and JUMP to 05E6H.
05E5H
EX DE,HL
EXchange the value stored in Register Pair HL with the value stored in Register Pair DE.
05E6H
RST 20H
Compare HL and DE via a call to RST 20H. Results: NZ means no match, Z means match, and if H=D but L < E, then the C flag will be set.
05E7H
POP DE
Put the value held at the top of the STACK into Register Pair DE.
05E8H
If the C FLAG (Carry) has been set then the loop is done, so JUMP to 05F2H to restore the values from the BASIC stack into their RAM locations, clear the RETurn address, and continue processing the current BASIC line.
05EAH
LD HL,(4093H)
If we are here then the loop is not done, so fetch the address of the top of the current FOR LOOP (held in memory location 4093H) and store it into Register Pair HL.
05EDH
LD (409FH),HL
Store the value held in Register Pair HL into memory location 409FH (which is the pointer to the current line being executed).
05F0H
JUMP to 059EH to continue processing the LOOP.
Jump point to exit out of BASIC stack operations -- routine restores the values from the BASIC stack into their RAM locations, clears the RETurn address, and continues processing the current BASIC line.
05F2H
GOSUB to 0A84H to move the various items held in the BASIC stack to their corresponding RAM location values. Essentially a group POP from the BASIC stack.
05F5H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
05F6H - Entry point for the REM and DATA Commands.
05F6H
LD HL,0000H
Let Register Pair HL equal 0000H.
05F9H
Skip the next intruction via a JUMP to 05FEH.
05FBH - Entry point for the IF Command.
05FBH
GOSUB to 0807H to calculate an integer expression with the results into Register Pair HL.
05FEH
05FFH
LD A,H
OR L
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
0600H
If the NZ FLAG (Not Zero) has been set, then we have IF followed by a valid entry, so JUMP to 060BH to look for the THEN.
0602H
GOSUB to 0947H to look for the next line.
0605H
If the next line was found then the NC FLAG will have been set, so JUMP to 039CH to execute that line.
0608H
Otherwise, enter they READY command line routine via a JUMP to 01C9H.
060BH - Look for the THEN Command.
060BH
LD HL,0337H
Let Register Pair HL equal 0337H, which is in the RESERVED WORD LOOKUP TABLE just before the THEN command.
060EH
JUMP to 0343H in the READY COMMAND LOOP to try to match reserved words, starting at the THEN command.
0611H - Entry point for the THEN Command.
0611H
GOSUB to 0EC4H to parse an integer into Register Pair HL to see if we have a number or a command.
0614H
If the NZ FLAG (Not Zero) has been set, then we have a non-Zero integer line number after the THEN (i.e., IF A=10 THEN 30), so we need to GO TO that line number via a JUMP to 0513H which will PUSH DE and then JUMP to 03BCH in the GOTO routine.
0617H
If we're here, then we didn't get a line number after the THEN, so we need to see if it's a reserved word instead. JUMP to 03A2H in the middle of the EXECUTE NEXT LINE, which will check for BREAK (and if found, STOP) or else reset the cassette motor, set IX to the bottom of the floating point stack, set HL to point to the middle of the reserved word list, and parse for matching reserved words.
061AH - Restore SP from a temporary storage space of 409BH and restore the current line being executed back into Register Pair HL and the associated memory location; this is jumped to at 08DCH.
061AH
LD SP,(409BH)
Fetch the pointer to the FOR LOOP's NEXT variable (held in memory location 409BH) and store it into Register Pair SP.
061EH
POP HL
Put the value held at the top of the STACK into Register Pair HL.
061FH
LD (409FH),HL
Store the value held in Register Pair HL into memory location 409FH (which is the pointer to the current line being executed).
0622H
POP DE
Put the value held at the top of the STACK into Register Pair DE.
0623H - Entry point for the INPUT Command.
0623H
RST 08H
23H
0AH
Check for a "#" via a call to RST 08H with parameters of 23H and an offset of 0AH. RST 08H will move to the next non-space character and check it against 23H (which is a "#"). If there is no match, jump to the return (of the next instruction, i.e. 0626H) + 0A instructions (which would be 0630H).
0626H
If we are here, then there was a "#", meaning this INPUT is from cassette, so GOSUB to 0EF4H which turns on the cassette motor, reads the data header and then read the number of bytes needed to fill RAM based on the block addresses. Routine exits with Register A holding the CRC and flags set based on Register A; DE is preserved.
0629H
PUSH DE
Save the contents of Register Pair DE (i.e., the current character of the line being interpreted) to the top of the stack.
062AH
LD HL,(409FH)
Fetch the pointer to the current line being executed (held in memory location 409FH) and store it into Register Pair HL.
062DH
PUSH HL
Save the pointer to the current line being executed (held in Register Pair HL) to the top of the stack.
062EH
JUMP to 064EH which JUMPs to 06D4H which continues the INPUT routine by parsing the line (DE must point to the current character to be parsed).
0630H - Continuation of the INPUT Command; jumped here if the INPUT was not followed by a "#", meaning that we are inputting from the keyboard.
0630H
PUSH DE
Save the contents of Register Pair DE (i.e., the current character of the line being interpreted) to the top of the stack.
0631H
GOSUB to 095BH to display a quoted expression pointed to by Register Pair DE and JUMP to the command line parsing routine if a CR is found, otherwise JUMP to the return address + 2 bytes, which will check for a ;.
0634H
Skip the next instruction and JUMP to 0639H.
0636H - Continuation of the INPUT Command.
0636H
Check for a
; via a call to RST 08H with parameters of 3BH and an offset of 18H. RST 08H will move to the next non-space character and check it against 3BH (which is a
;). If there is no match, jump to the return (of the next instruction, i.e. 0639H) + 18H instructions (which would be
0651H).
0639H
LD HL,(409FH)
Fetch the pointer to the current line being executed (held in memory location 409FH) and store it into Register Pair HL.
063CH
PUSH HL
Save the pointer to the current line being executed (held in Register Pair HL) to the top of the stack.
063DH
LD HL,0630H
Let Register Pair HL equal 0630H / (Decimal: 1584).
0640H
LD (409FH),HL
Store the value held in Register Pair HL into memory location 409FH (which is the pointer to the current line being executed).
0643H
LD (409BH),SP
Store the value held in Register Pair SP into the pointer to the FOR LOOP's NEXT variable (held in memory location 409BH).
0647H
PUSH DE
Save the contents of Register Pair DE (i.e., the current character of the line being interpreted) to the top of the stack.
0648H
LD A,3FH
Let Register A equal 3FH (ASCII: ?).
064AH
GOSUB to 08FCH to display a prompt of the character held in Register A then then fetch a line of input into a 53 character buffer between 40ACH and 40F3H pointed to by Register Pair DE.
064DH
POP DE
Restore the current character of the line being interpreted from the top of the stack back into Register Pair DE.
064EH
JUMP to 06D4H which continues the INPUT routine by parsing the line (DE must point to the current character to be parsed).
0651H - Continuation of the INPUT Command; jumped here if there was no ; when one was expected.
0651H
POP AF
Clear the return address from the stack.
0652H
JUMP to 06CAH which JUMPs to 08C9H to display the "WHAT" error.
0654H - Multi-Command Routine. Used by LET, INPUT, and READ to parse the characters pointed to by Register Pair DE.
0654H
If the Z FLAG (Zero) has been set, JUMP to 08AEH to parse a numeric value.
0657H
RST 28H
Call RST 28H to move DE to point to the next non-space character, with Register A holding that character.
0658H
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
0659H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise, the NZ FLAG is set.
065BH
If the character at the BASIC line being processed is a CARRIAGE RETURN, then the Z FLAG will have been set, so JUMP to 066FH to fill the rest of the 15 character buffer pointed to by Register Pair HL with 00H's and RETurn.
065DH
CP 22H
Compare the value held in Register A against 22H (ASCII: "). Results: If Register A equals ", the Z FLAG is set; otherwise, the NZ FLAG is set.
065FH
If the character at the BASIC line being processed is a ", then the Z FLAG will have been set, so JUMP to 0678H to parse a quoted string into a 15 character buffer pointed to by Register Pair HL.
0661H
CP 2CH
Compare the value held in Register A against 2CH (ASCII: ,). Results: If Register A equals ,, the Z FLAG is set; otherwise, the NZ FLAG is set.
0663H
If the character at the BASIC line being processed is a ,, then the Z FLAG will have been set, so JUMP to fill the rest of the 15 character buffer pointed to by Register Pair HL with 00H's and RETurn.
If we're here then we didn't get a CARRIAGE RETURN, , or " so we are just going to copy the data to the buffer pointed to by Register Pair HL.
0665H
LD (HL),A
Store the character held in Register A into the memory location pointed to by Register Pair HL.
0666H
INC HL
Bump HL to point to the next open space in the 15 character buffer.
0667H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
0668H
LD A,L
Copy the contents of Register L (i.e., the LSB of HL) into Register A.
0669H
AND 0FH
MASK the value of Register A against 0FH (0000 1111), thus setting a maximum value of Register A at 15.
066BH
If masked value of L is zero then we have run out of space in the 15 character buffer and the Z FLAG will have been set, so JUMP to 068AH.
066DH
If we are here, then we still have room in the 15 character buffer pointed to by Register Pair HL so LOOP BACK to 0658H in this routine.
066FH - Routine to fill the rest of the 15 character buffer pointed to by Register Pair HL with 00H's; jumped here if the next character is a CARRIAGE RETURN.
066FH - Routine to fill the rest of the 15 character buffer pointed to by Register Pair HL with 00H's; jumped here if the next character is a CARRIAGE RETURN.
066FH
LD (HL),00H
Store the value 00H into the memory location pointed to by Register Pair HL.
0671H
INC HL
INCrement the value stored in Register Pair HL by 1.
0672H
LD A,L
Copy the contents of Register L (i.e., the LSB of HL) into Register A.
0673H
AND 0FH
MASK the value of Register A against 0FH (0000 1111), thus setting a maximum value of Register A at 15.
0675H
If masked value of L is NOT zero, then the NZ FLAG will have been set, JUMP to 066FH.
0677H
RET
Otherwise, if the masked value of L is a zero then RETurn to the caller.
0678H - Parse a quoted string into a 15 character buffer pointed to by Register Pair HL.
0678H - Parse a quoted string into a 15 character buffer pointed to by Register Pair HL.
0678H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
0679H
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
067AH
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise, the NZ FLAG is set.
067CH
If the character on the BASIC line being processed (currently pointed to by DE) is a CARRIAGE RETURN, then the Z FLAG will have been set, so JUMP to 066FH to fill the rest of the 15 character buffer pointed to by Register Pair HL with 00H's and RETurn.
067EH
INC DE
Bump DE to point to the next character on the BASIC line being processed.
067FH
CP 22H
CP 22H
Compare the value held in Register A against 22H (ASCII: "). Results: If Register A equals ", the Z FLAG is set; otherwise, the NZ FLAG is set.
0681H
If the character on the BASIC line being processed (currently pointed to by DE) is a ", then the Z FLAG will have been set, so JUMP 066FH to fill the rest of the 15 character buffer pointed to by Register Pair HL with 00H's and RETurn.
0683H
LD (HL),A
Store the character held in Register A into the memory location pointed to by Register Pair HL.
0684H
INC HL
Bump HL to point to the next open space.
0685H
LD A,L
Copy the contents of Register L (i.e., the LSB of HL) into Register A.
0686H
AND 0FH
MASK the value of Register A against 0FH (0000 1111), thus setting a maximum value of Register A at 15.
0688H
If masked value of L is NOT zero, then the NZ FLAG will have been set, JUMP to 0679H.
068AH
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
068BH
CP 2CH
Compare the value held in Register A against 2CH (ASCII: ,). Results: If Register A equals ,, the Z FLAG is set; otherwise, the NZ FLAG is set.
068DH
RET Z
If the character on the BASIC line being processed (currently pointed to by DE) is a ,, then the Z FLAG will have been set, so RETurn to the caller.
068EH
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise, the NZ FLAG is set.
0690H
RET Z
If the character on the BASIC line being processed (currently pointed to by DE) is a CARRIAGE RETURN, then the Z FLAG will have been set, so RETurn to the caller.
0691H
INC DE
If we are here then we are out of space in the buffer, so we loop to fewtch and discard the characters until we hit a CARRIAGE RETURN or ,. First, bump DE to point to the next character on the BASIC line being processed.
0692H
JUMP 5 instructions to 068AH to keep fetching command characters from DE and checking them against a , and a CARRIAGE RETURN.
0694H - Multi Command Subroutine; parse the next characters of a variable. Used in the LET command and the INPUT command for the characters after the ;. If the variable does not exist, the C FLAG is set; a close array returns with the Z FLAG set; and a $ returns with register L holding either 70H (for A$) or 80H (for B$) and the Z FLAG set.
0694H - Multi Command Subroutine; parse the next characters of a variable. Used in the LET command and the INPUT command for the characters after the ";". If the variable does not exist, the C FLAG is set; a close array returns with the Z FLAG set; and a $ returns with register L holding either 70H (for A$) or 80H (for B$) and the Z FLAG set.
0694H
RST 38H
RST 38H checks the command line to see if the next non-space character is an existing variable; HL to point to the variable if it exists and CARRY set if it doesn't.
0695H
RET C
If the C FLAG (Carry) has been set then the next non-space character is NOT an existing variable, RETurn to the caller.
0696H
DEC DE
Otherwise, since the next non-space character IS an existing variable, back up 1 space on the instruction line by DECrementing the value stored in Register Pair DE by 1 to we can see how the variable ended ... was it an array? was it a string?.
0697H
LD A,(DE)
Fetch the character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
0698H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
0699H
CP 29H
Compare the value held in Register A against 29H (ASCII: )). Results: If Register A equals ), the Z FLAG is set; otherwise the NZ FLAG is set.
069BH
RET Z
If the character on the BASIC line being processed (currently pointed to by DE) is a ), then the Z FLAG will have has been set, so we RETurn to the caller.
069CH
LD A,(DE)
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
069DH
CP 24H
Compare the value held in Register A against 24H (ASCII:
$). Results:
- If Register A equals $, the Z FLAG is set; otherwise the NZ FLAG is set.
069FH
If the character on the BASIC line being processed (currently pointed to by DE) is a $, then the Z FLAG will have been set, so JUMP to 06A3H to validate to A$ or B$ only (results in Register L being 70H or 80H respectively), or throw a WHAT error otherwise.
06A1H
XOR A
Set Register A to ZERO and clear all Flags.
06A2H
RET
RETurn to the caller.
06A3H - Continuation of the above routine; jumped here if the variable found on the BASIC line being processed ended in a "$". On exit, Register L will be either 70H if the variable is A$ or 80H if the variable is B$. DE will point to the next character on the BASIC line being processed.
06A3H
LD A,L
Copy the contents of Register L (i.e., the LSB of HL) into Register A. Register L will be a 00H if the variable is A$ and will be 04H if the variable is a B$; C$ is 08H.
06A4H
CP 07H
Compare the value held in Register A against 07H since that is 1 less than the first invalid string value of C$. Results:
- If Register A equals 07H, the Z FLAG is set.
- If A < 07H, the CARRY FLAG will be set.
- if A >= 07H, the NO CARRY FLAG will be set.
06A6H
If A >= 07H (meaning we received a C$ or higher) then the NC FLAG will have been set, so JUMP to 08C9H to display the "WHAT" error.
06A9H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
06AAH
06AAH
SLA A
SLA A
If the variable was B$ then this will rotate Register A from 04 to 08 to 10. If the variable was A$ then 00H remains 00H.
06AEH
ADD 70H
LET Register A = Register A + 70H. If the variable was A$ then Register A = 70H and if the variable was B$ then Register A will be 80H
06B0H
LD L,A
Copy the contents of Register A (70H if the variable was A$ and 80H if the variable was B$) into Register L.
06B1H
AND A
Reset the CARRY FLAG and set the Z/NZ FLAGS based on Register A via an AND A (which masks the value of Register A against itself).
06B2H
RET
RETurn to the caller.
06B3H - This routine is JUMPed to from the RESERVED WORD LOOKUP list, if the main commands are not found. The reserved words after this are functions, math symbols, and the like.
06B3H
LD A,(DE)
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
06B4H
CP 0DH
Compare the value held in Register A against 0DH (ASCII:
CARRIAGE RETURN). Results:
- If Register A equals CARRIAGE RETURN, the Z FLAG is set.
- If A < CARRIAGE RETURN, the CARRY FLAG will be set.
- if A >= CARRIAGE RETURN, the NO CARRY FLAG will be set.
06B6H
If the character pointed to by Register Pair DE is a CARRIAGE RETURN then the Z FLAG will have been set, so JUMP to 06C5H which will execute a RST 30H, clear the RET, and continue processing the BASIC instruction line.
06B8H - Entry point for the LET Command. This is also a pass through from the exhausted RESERVE WORD LOOKUP list jump; meaning that if the ROM cannot find a command where it expected one, it is willing to assume that the line is actually a variable assignment.
06B8H
GOSUB to 0694H to parse the next characters of a variable. If the variable does not exist, the C FLAG is set; a close array returns with the Z FLAG set; and a $ returns with register L holding either 70H (for A$) or 80H (for B$) and the Z FLAG set.
06BBH
If the variable does not exist then the C FLAG will have been set, JUMP to 06CAH which JUMPs to 08C9H to display the "WHAT" error.
06BDH
PUSH AF
Preserve Register Pair AF to the top of the stack due to the next RST call.
06BEH
RST 08H
3DH
09H
Check for a "=" via a call to RST 08H with parameters of 3DH and an offset of 09H. RST 08H will move to the next non-space character and check it against 3DH (which is a "="). If there is no match, jump to the return (of the next instruction, i.e. 06C1H) + 09H instructions (which would be 06CAH) to display the "WHAT" error.
06C1H
POP AF
Restore AF from the stack.
06C2H
GOSUB to 0654H to parse the characters pointed to by Register Pair DE (i.e., everthing after "LET variable =").
06C5H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
06C6H - Continuation of the INPUT Command; jumped to by 06D7H and 06EBH.
06C6H
POP HL
Restore the value of the current line being executed from the top of the stack into Register Pair HL.
06C7H
LD (409FH),HL
Store the value held in Register Pair HL into memory location 409FH (which is the pointer to the current line being executed).
06CAH
JUMP to 08C9H to display the "WHAT" error.
06CDH - Entry point for the RESTORE Command.
06CDH
LD HL,0000H
Let Register Pair HL equal 0000H so as to represent the beginning of the READ list when put into 401AH.
06D0H
LD (40A1H),HL
Store the value held in Register Pair HL into memory location 40A1H (which is the pointer for the READ command).
06D3H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
06D4H - Continuation of the INPUT Command; this will parse the line. On entry, DE must point to the current character in the BASIC line being parsed.
06D4H - Continuation of the INPUT Command; this will parse the line. On entry, DE must point to the current character in the BASIC line being parsed.
06D4H
GOSUB to 0694H to parse the next characters of a variable. If the variable does not exist, the C FLAG is set; a close array returns with the Z FLAG set; and a $ returns with register L holding either 70H (for A$) or 80H (for B$) and the Z FLAG set.
06D7H
If the variable doesn't exist then the C FLAG will have been set, so JUMP to 06C6H to restore the pointer to the current line being executed to its place in RAM and to HL and then abort with a "WHAT" error.
06D9H
PUSH DE
Save the contents of Register Pair DE (i.e., the current character of the line being interpreted) to the top of the stack.
06DAH
LD DE,40ACH
Let Register Pair DE equal 40ACH which is a dual purpose location: Buffer for command input AND output to cassette.
06DDH
GOSUB to 0654H to parse the characters in the input buffer (pointed to by Register Pair DE).
06E0H
LD (4099H),DE
Store the value held in Register Pair DE into memory location 4099H (which is the address of a buffer in RAM).
06E4H
POP DE
Restore the pointer to the current character of the line being interpreted into Register Pair DE.
06E5H
Check for a "
," via a call to RST 08H with parameters of 2CH and an offset of 53H. RST 08H will move to the next non-space character and check it against 2CH (which is a "
,"). If there is no match, jump to the return (of the next instruction, i.e. 06E8H) + 53H instructions (which would be
073BH).
06E8H
GOSUB to 0694H to parse the next characters of a variable. If the variable does not exist, the C FLAG is set; a close array returns with the Z FLAG set; and a $ returns with register L holding either 70H (for A$) or 80H (for B$) and the Z FLAG set.
06EBH
If the C FLAG (Carry) has been set, JUMP to 06C6H to restore the pointer to the current line being executed to its place in RAM and to HL and then abort with a "WHAT" error.
06EDH
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
06EEH
PUSH AF
Temporarily save the contents of Register Pair AF to the top of the stack so that the RST 08H doesn't destroy them.
06EFH
LD DE,(4099H)
Fetch the address of the buffer in RAM (held in memory location 4099H) and store it into Register Pair DE.
06F3H
RST 08H
2CH
4BH
Check for a "," via a call to RST 08H with parameters of 2CH and an offset of 4BH. RST 08H will move to the next non-space character and check it against 2CH (which is a ","). If there is no match, jump to the return (of the next instruction, i.e. 06F6H) + 4BH instructions (which would be 0741H).
06F6H
POP AF
Restore AF from the stack.
06F7H
JUMP to 06DDH to parse the next value.
06F9H - Entry point for the READ Command.
06F9H - Entry point for the READ Command.
06F9H
GOSUB to 0694H to parse the next characters of a variable. If the variable does not exist, the C FLAG is set; a close array returns with the Z FLAG set; and a $ returns with register L holding either 70H (for A$) or 80H (for B$) and the Z FLAG set.
06FCH
PUSH DE
>Save the contents of Register Pair DE (i.e., the current character of the line being interpreted) to the top of the stack.
06FDH
If the variable doesn't exist then the C FLAG will have been set, so JUMP to 0742H to handle the situation where a "," was needed but not found.
06FFH
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
0700H
LD DE,(40A1H)
Fetch the pointer for the READ command (held in memory location 40A1H) and store it into Register Pair DE.
0704H
0705H
LD A,D
OR E
Since the Z-80 cannot test Register Pair DE against zero, the common trick is to set Register A to equal to Register D, and then OR A against Register E. Only if both Register D and Register E were zero can the Z FLAG be set.
0706H
If the READ POINTER is not zero, then JUMP to 0731H.
0708H
LD DE,4200H
Since the READ POINTER was zero, we need to start from scratch. Let Register Pair DE equal 4200H.
NOTE: 4200H is the top of system stack pointer.
070BH
PUSH HL
Temporarily preserve contents of Register Pair HL to the top of the stack.
070CH
GOSUB to 0751H to examine the current BASIC instruction line for DATA statements. If we hit the end of the program with no DATA statements, the C FLAG will be set.
070FH
POP HL
Restore Register Pair HL from the stack.
0710H
If the C FLAG (Carry) has been set then no DATA statements were found; making the triggered READ command a problem, so JUMP to 0745H to display the "HOW" error.
0712H
POP AF
Restore Register Pair HL from the stack.
0713H
LD BC,(409FH)
Fetch the pointer to the current line being executed (held in memory location 409FH) and store it into Register Pair BC.
0717H
PUSH BC
Temporarily save the contents of Register Pair BC to the top of the stack for the next 3 instructions.
0718H
LD BC,0000H
Let Register Pair BC equal 0000H.
071BH
LD (409FH),BC
Store the value held in Register Pair BC into memory location 409FH (which is the pointer to the current line being executed).
071FH
GOSUB to 0654H to parse the characters in the input buffer (pointed to by Register Pair DE).
0722H
POP BC
Restore the current line being executed to Register Pair BC from the stack.
0723H
LD (409FH),BC
Store the current line being executed (held in Register Pair BC) into memory location 409FH (which is the pointer to the current line being executed).
0727H
LD (40A1H),DE
Store the value held in Register Pair DE into memory location 40A1H (which is the pointer for the READ command).
072BH
POP DE
Restore the pointer to the current character of the BASIC instruction line being interpreted back into Register Pair DE.
072CH
Check for a "
," via a call to RST 08H with parameters of 2CH and an offset of 11H. RST 08H will move to the next non-space character and check it against 2CH (which is a "
,"). If there is no match, jump to the return (of the next instruction, i.e. 072FH) + 11H instructions (which would be
0740H).
072FH
If the next character is a "," then JUMP to 06F9H to the top of this READ routine.
0731H
RST 08H
2CH
02H
Check for a "," via a call to RST 08H with parameters of 2CH and an offset of 02H. RST 08H will move to the next non-space character and check it against 2CH (which is a ","). If there is no match, jump to the return (of the next instruction, i.e. 0734H) + 02H instructions (which would be 0736H).
0736H
Check for a "CARRIAGE RETURN" via a call to RST 08H with parameters of 0DH and an offset of 08H. RST 08H will move to the next non-space character and check it against 0DH (which is a "CARRIAGE RETURN"). If there is no match, jump to the return (of the next instruction, i.e. 0739H) + 08H instructions (which would be
07F1H).
073BH - Continuation of the INPUT Command; JUMPed here if a "," wasn't found at 06E5H.
073BH - Continuation of the INPUT Command; JUMPed here if a "," wasn't found at 06E5H.
073BH
POP HL
Restore the pointer to the current line being executed into Register Pair HL.
073CH
LD (409FH),HL
Store the value held in Register Pair HL into memory location 409FH (which is the pointer to the current line being executed).
073FH
POP AF
Discard the next stack entry.
0740H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
0741H - Continuation of the INPUT Command; JUMPed here if a "," wasn't found at 06F3H.
0741H - Continuation of the INPUT Command; JUMPed here if a "," wasn't found at 06F3H.
0741H
POP AF
Clear the RETurn address from the stack.
0742H
JUMP to 08CAH to display the "WHAT" error message.
0745H - Continuation of the READ Command; jumped here from 0710H when no DATA statements were found.
0745H - Continuation of the READ Command; jumped here from 0710H when no DATA statements were found.
0745H
POP AF
Clear the RETurn address from the stack.
0746H
JUMP to 01A3H to display the "HOW?" error.
0749H - JUMPed here from the DATA PARSE TABLE (at 0BBFH) if the DATA statement is located, and DE now points to the first entry of that DATA statement.
0749H - JUMPed here from the DATA PARSE TABLE (at 0BBFH) if the DATA statement is located, and DE now points to the first entry of that DATA statement.
0749H
XOR A
Set Register A to ZERO and clear all Flags.
074AH
RET
RETurn to the caller.
074BH - This is JUMPed to by the JP (HL) in 0377H and in the DATA PARSE TABLE if DATA statement was not found. This routine loops through the characters on the BASIC line being processed until it hits a CARRIAGE RETURN.
074BH - This is JUMPed to by the JP (HL) in 0377H and in the DATA PARSE TABLE if DATA statement was not found. This routine loops through the characters on the BASIC line being processed until it hits a CARRIAGE RETURN.
074BH
LD A,(DE)
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
074CH
INC DE
Bump DE to point to the next character on the BASIC line being processed.
074DH
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
074FH
If the CARRIAGE RETURN has still not been found, the NZ FLAG will have been set, so LOOP to back to the top of this routine at 074BH.
0751H - Examine the current BASIC instruction line for DATA statements. If we hit the end of the program with no DATA statements, the C FLAG will be set.
0751H - Examine the current BASIC instruction line for DATA statements. If we hit the end of the program with no DATA statements, the C FLAG will be set.
0751H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
0752H
INC DE
Bump DE to point to the next character on the BASIC line being processed.
0753H
LD HL,(406CH)
Fetch the pointer to the top of used RAM (held in memory location 406CH) and store it into Register Pair HL.
0756H
RST 20H
Compare HL and DE via a call to RST 20H. Results: NZ means no match, Z means match, and if H=D but L < E, then the C flag will be set.
0757H
RET C
If HL < DE then the C FLAG (Carry) will have been set, RETurn to the caller.
0758H
LD HL,0BBAH
Let Register Pair HL equal 0BBAH.
075BH
JUMP to 07AAH which JUMPs to 0343H in the READY COMMAND LOOP, with HL pointing to 0BBAH as the RESERVED WORD LOOKUP/VECTOR TABLE starting point.
075DH - Parse an optional relational expression ">" "<" or "=".
075DH - Parse an optional relational expression ">" "<" or "=".
075DH
GOSUB to 07A7H to look for ">" "<" or "=" on the command line.
0760H
GOSUB to 0C59H to convert the value stored in Register Pair HL to a floating point number in the Floating Point Stack.
0763H - Entry point for a > Command.
0763H - Entry point for a ">" Command.
0763H
RST 08H
3DH
06H
Check for a "=" via a call to RST 08H with parameters of 3DH and an offset of 06H. RST 08H will move to the next non-space character and check it against 3DH (which is a "="). If there is no match, jump to the return (of the next instruction, i.e. 0766H) + 06H instructions (which would be 076CH) to process a straight >.
0766H
If we are here, then the "=" was found after the ">" so GOSUB to 0799H to compare two numbers on a ">=" basis.
0768H
RLCA
Rotate the bits of Register left (i.e., lower bit moves higher) one bit position. The contents of bit 7 are copied to the CARRY FLAG and to bit 0.
0769H
RET C
If the C FLAG (Carry) has been set, RETurn to the caller.
076AH
Otherwise, JUMP to 07A3H in the NUMERIC COMPARISON routine to set HL to 0001H (meaning TRUE) and RETurn to the routine caller.
076CH - Part of the > Command; JUMPed here if the "=" was not found in 0763H, to process a straight >.
076CH - Part of the > Command; JUMPed here if the "=" was not found in 0763H, to process a straight >.
076CH
GOSUB to 0799H to compare two numbers.
076FH
RET Z
If the Z FLAG (Zero) has been set, RETurn to the caller.
0770H
RET C
If the C FLAG (Carry) has been set, RETurn to the caller.
0771H
JUMP to 07A3H in the NUMERIC COMPARISON routine to set HL to 0001H (meaning TRUE) and RETurn to the routine caller.
0773H - Entry point for a "<" Command.
0773H - Entry point for a "<" Command.
0773H
Check for a "=" via a call to RST 08H with parameters of 3DH and an offset of 0CH. RST 08H will move to the next non-space character and check it against 3DH (which is a "="). If there is no match, jump to the return (of the next instruction, i.e. 0776H) + 0CH instructions (which would be
0782H) to check for
<>.
0776H
If an "=" was found, GOSUB to 0799H to compare two numbers on a "<=" basis.
0779H
LD HL,0001H
Let Register Pair HL equal 0001H to indicate TRUE.
077CH
RET Z
If the Z FLAG (Zero) has been set, RETurn to the caller.
077DH
RET C
If the C FLAG (Carry) has been set, RETurn to the caller.
077EH
LD HL,0000H
Let Register Pair HL equal 0000H to indicate FALSE.
0781H
RET
RETurn to the caller.
0782H - Part of the "<" Command; JUMPed here if an "=" was NOT found (so no <=), to next check for <>.
0782H - Part of the "<" Command; JUMPed here if an "=" was NOT found (so no <=), to next check for <>.
0782H
Check for a "
>" via a call to RST 08H with parameters of 3EH and an offset of 0CH. RST 08H will move to the next non-space character and check it against 3EH (which is a "
>"). If there is no match, jump to the return (of the next instruction, i.e. 0785H) + 0CH instructions (which would be
0791H) to handle a straight "
<".
0785H
If the ">" was found, GOSUB to 0799H to compare two numbers on a "<>" basis.
0788H
RET Z
If the Z FLAG (Zero) has been set, RETurn to the caller.
0789H
JUMP to 07A3H in the NUMERIC COMPARISON routine to set HL to 0001H (meaning TRUE) and RETurn to the routine caller.
078BH - Entry point for a = Command.
078BH - Entry point for a = Command.
078BH
GOSUB to 0799H to compare two numbers on an "=" basis.
078EH
RET NZ
If the NZ FLAG (Not Zero) has been set, RETurn to the caller.
078FH
JUMP to 07A3H in the NUMERIC COMPARISON routine to set HL to 0001H (meaning TRUE) and RETurn to the routine caller.
0791H - Part of the "<" Command; JUMPed here to test a straight "<" math operation.
0791H - Part of the "<" Command; JUMPed here to test a straight "<" math operation.
0791H
GOSUB to 0799H to compare two numbers on a "<" basis.
0794H
RET NC
If the NC FLAG (No Carry) has been set, RETurn to the caller.
0795H
JUMP to 07A3H in the NUMERIC COMPARISON routine to set HL to 0001H (meaning TRUE) and RETurn to the routine caller.
0797H - This is the jump point in the RESERVED WORD LOOKUP TABLE for where ">", "<" and "=" pass through. This is where we go if the relational expression was not found.
0797H - This is the jump point in the RESERVED WORD LOOKUP TABLE for where ">", "<" and "=" pass through. This is where we go if the relational expression was not found.
0797H
POP AF
Put the value held at the top of the STACK into Register Pair AF.
0798H
RET
RETurn to the caller.
0799H - Subroutine to compare two numbers.
0799H - Subroutine to compare two numbers.
0799H
GOSUB to 07ADH to parse an expression.
079CH
GOSUB to 0CB1H to fetch the top 2 entries from the Floating Point Stack into their register sets, remove them from the Floating Point Stack, and do a bunch of comparisons between the two.
079FH
LD HL,0000H
Let Register Pair HL equal 0000H.
07A2H
RET
RETurn to the caller.
07A3H - Part of the NUMERIC COMPARISON routines. In these routines HL=0 means TRUE and HL=1 means FALSE. This routine sets HL to FALSE and RETurns to caller.
07A3H - Part of the NUMERIC COMPARISON routines. In these routines HL=0 means TRUE and HL=1 means FALSE. This routine sets HL to FALSE and RETurns to caller.
07A3H
LD HL,0001H
Let Register Pair HL equal 0001H.
07A6H
RET
RETurn to the caller.
07A7H - Check the current BASIC program line against relational operators.
07A7H - Check the current BASIC program line against relational operators.
07A7H
LD HL,032CH
Let Register Pair HL equal 032CH, which is in the middle of the RESERVED WORD LOOKUP/VECTOR TABLE.
07AAH
JUMP to 0343H to look for keyword matches but starting with the keywords at 0319H (i.e., ">", "=", "<").
07ADH - Parse an expression. This is part of the RST 18H routine as well as other locations and is the main expression parsing routine.
07ADH - Parse an expression. This is part of the RST 18H routine as well as other locations and is the main expression parsing routine.
07ADH
Check for a "-" via a call to RST 08H with parameters of 2DH and an offset of 08H. RST 08H will move to the next non-space character and check it against 2DH (which is a "-"). If there is no match, jump to the return (of the next instruction, i.e. 07B0H) + 08H instructions (which would be
07B8H).
07B0H
LD HL,0000H
If we are here, then a "-" was found, so prepare for math by setting Register Pair HL equal 0000H.
07B3H
GOSUB to 0C59H to convert the value stored in Register Pair HL to a floating point number in the Floating Point Stack.
07B6H
JUMP to 07CCH to continue the math by resulting from having found a "-".
07B8H - Parse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if a "-" wasn't found, to now check for a "+".
07B8H - Parse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if a "-" wasn't found, to now check for a "+".
07B8H
RST 08H
2BH
00H
Check for a "+" via a call to RST 08H with parameters of 2BH and an offset of 00H. RST 08H will move to the next non-space character and check it against 2BH (which is a "+"). If there is no match, jump to the return (of the next instruction, i.e. 00H) + 07BBH instructions (which would be 07BBH).
07BBH
If we are here, then a "+" was found, so GOSUB to 07D4H to keep looking for other possible operators and functions in the expression.
07BEH
Check for a "+" via a call to RST 08H with parameters of 2BH and an offset of 08H. RST 08H will move to the next non-space character and check it against 2BH (which is a "+"). If there is no match, jump to the return (of the next instruction, i.e. 08H) + 07C1H instructions (which would be
07C9H).
07C1H
If we are here, then a "+" was found, so GOSUB to 07D4H to keep looking for other possible operators and functions in the expression.
07C4H
GOSUB to 0CD3H to handle floating point addition.
07C7H
LOOP BACK 2 instructions (to 07BEH) to keep parsing.
07C9H - Parse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if a "-" and "+" wasn't found, to now check for a "-".
07C9H - Parse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if a "-" and "+" wasn't found, to now check for a "-".
07C9H
RST 08H
2DH
37H
Check for a "-" via a call to RST 08H with parameters of 2DH and an offset of 37H. RST 08H will move to the next non-space character and check it against 2DH (which is a "-"). If there is no match, jump to the return (of the next instruction, i.e. 07CCH) + 37H instructions (which would be 0803H).
07CCH
If we are here, then a "-" was found, so GOSUB to 07D4H to keep processing.
07CFH
GOSUB to 0CBFH to handle Floating Point Subtraction.
07D2H
JUMP BACK to 07BEH in the prior routine to keep parsing.
07D4H - Parse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if a "+" was found.
07D4H - Parse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if a "+" was found.
07D4H
GOSUB to 07EDH which will which JUMPs to 0343H in the READY COMMAND LOOP, with HL pointing to 02EEH (RND) as the RESERVED WORD LOOKUP/VECTOR TABLE starting point. This would be the list of RESERVED WORDS that could be part of math expression: RND, ABS, MEM, INT, and POINT.
07D7H
Check for a "
*" via a call to RST 08H with parameters of 2AH and an offset of 08H. RST 08H will move to the next non-space character and check it against 2AH (which is a "*"). If there is no match, jump to the return (of the next instruction, i.e. 08H) + 07DAH instructions (which would be
07E2H).
07DAH
If we are here, then the "*" was found, so GOSUB to 07EDH which will which JUMPs to 0343H in the READY COMMAND LOOP, with HL pointing to 02EEH (RND) as the RESERVED WORD LOOKUP/VECTOR TABLE starting point. This would be the list of RESERVED WORDS that could be part of math expression: RND, ABS, MEM, INT, and POINT.
07DDH
GOSUB to 0C87H to do Floating Point Multiplication.
07E0H
LOOP BACK 2 instructions (to 07D7H) to keep parsing.
07E2H - arse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if the check at 07D7H didn't find a "*".
07E2H - arse an expression. This is part of the RST 18H routine as well as other locations; JUMPed here if the check at 07D7H didn't find a "*".
07E2H
RST 08H
2FH
1EH
Check for a "/" via a call to RST 08H with parameters of 2FH and an offset of 1EH. RST 08H will move to the next non-space character and check it against 2FH (which is a "/"). If there is no match, jump to the return (of the next instruction, i.e. 07E5H) + 1EH instructions (which would be 0803H).
07E5H
GOSUB to 07EDH which JUMPs to 0343H in the READY COMMAND LOOP, with HL pointing to 02EEH (RND) as the RESERVED WORD LOOKUP/VECTOR TABLE starting point. This would be the list of RESERVED WORDS that could be part of math expression: RND, ABS, MEM, INT, and POINT.
07E7H
RLCA
Rotate the bits of Register left (i.e., lower bit moves higher) one bit position. The contents of bit 7 are copied to the CARRY FLAG and to bit 0.
07E8H
GOSUB to 0C98H to do a FLOATING POINT DIVIDE of the numbers at the top of the FLOATING POINT STACK.
07EBH
JUMP BACK to 07D7H to keep parsing.
07EDH - Parse an expression. This is part of the RST 18H routine as well as other locations. This will parse a primary expression.
07EDH - Parse an expression. This is part of the RST 18H routine as well as other locations. This will parse a primary expression.
07EDH
LD HL,02EEH
Let Register Pair HL equal 02EEH (RND) as the RESERVED WORD LOOKUP/VECTOR TABLE starting point. This would be the list of RESERVED WORDS that could be part of math expression: RND, ABS, MEM, INT, and POINT.
07F0H
JUMP to 07AAH which JUMPs to 0343H in the READY COMMAND LOOP, with HL pointing to 02EEH as the RESERVED WORD LOOKUP/VECTOR TABLE starting point.
07F2H - ???? Don't see how we get here. Part of the PARSE AN EXPRESSION routine. Supposedly jumps here if "intrinsic function not found" to parse a regular expression.
07F2H - ???? Don't see how we get here. Part of the PARSE AN EXPRESSION routine. Supposedly jumps here if "intrinsic function not found" to parse a regular expression.
07F2H
RST 38H
RST 38H checks the command line to see if the next non-space character is an existing variable; HL to point to the variable if it exists and CARRY set if it doesn't.
07F3H
If the C FLAG (Carry) has been set, then the variable doesn't exist, so JUMP to 07F8H to see if it is a constant instead.
07F5H
JUMP to 0BC3H to put the number pointed to by Register Pair HL onto the FLOATING POINT STACK.
07F8H - Part of the PARSE AN EXPRESSION routine. If we need to parse a regular expression, but the variable was not found, we need to assume that we have a constant; so we wind up here.
07F8H - Part of the PARSE AN EXPRESSION routine. If we need to parse a regular expression, but the variable was not found, we need to assume that we have a constant; so we wind up here.
07F8H
GOSUB to 00A6H to analyze a Floating Point Constant.
07FBH
RET NZ
If the NZ FLAG (Not Zero) has been set, RETurn to the caller.
07FCH - Subroutine to verify that an integer is inside parenthesis, and parse it via a RST 18H call.
07FCH - Subroutine to verify that an integer is inside parenthesis, and parse it via a RST 18H call.
07FCH
We need to see if the number is surrounded by parenthesis. We do this a call to RST 08H with parameters of "(" and an offset of 05H. RST 08H will move to the next non-space character and check it against 28H (which is a "("). If there is no match, jump to the return (of the next instruction, i.e. 07FFH) + 05H instructions (which would be
0804H - which will give a WHAT error).
07FFH
RST 18H
We expect a number to be here, so we call RST 18 to parse an expression (and an optional expression, if any).
0800H
RST 08H
29
01H
We had an open parenthesis so we need to find the close. We do this a call to RST 08H with parameters of ")" and an offset of 01H. RST 08H will move to the next non-space character and check it against 29H (which is a ")"). If there is no match, jump to the return (of the next instruction, i.e. 0803H) + 01H instructions (which would be
0804H - which will give a WHAT error).
0803H
RET
RETurn to the caller.
0804H
JP 08C9H
JUMP to 08C9H to display the "WHAT" error.
0806H - ??? I don't see what jumps to this instruction. Whatever it is, its trying to get to 0807H but AF and AF' are backwards.
0806H - ??? I don't see what jumps to this instruction. Whatever it is, its trying to get to 0807H but AF and AF' are backwards.
0806H
EX AF,AF'
EXchange the value stored in Register Pair AF' with the value stored in Register Pair AF.
0807H - Calculate an integer expression with the results into Register Pair HL.
0807H - Calculate an integer expression with the results into Register Pair HL.
0807H
RST 18H
RST 18 to parse an expression (and an optional expression, if any).
0808H
JUMP to 0C0BH to convert a FLOATING number to an INTEGER; results stored in Register Pair HL.
080BH - Compute the number held in Regster Pair HL as a non-negative integer.
080BH - Compute the number held in Regster Pair HL as a non-negative integer.
080BH
GOSUB to 0807H to calculate an integer expression with the results into Register Pair HL.
080EH
BIT 7,H
Test Bit Number 7 of Register H, which is the bit which tracks the SIGN of the number. Z FLAG will be set if that bit is 0 (positive), and NZ FLAG will be set if that bit is 1 (negative).
0810H
If the NZ FLAG (Not Zero) has been set, meaning the number which needed to be positive is actually negative, so display the "HOW?" error via a JUMP to 01A2H.
0813H
RET
RETurn to the caller.
0814H - Verify that an integer is within parenthesis, and calculate the integer expression with the result in Register Pair HL.
0814H - Verify that an integer is within parenthesis, and calculate the integer expression with the result in Register Pair HL.
0814H
GOSUB to 07FCH to verify that an integer is inside parenthesis, and parse it via a RST 18H call.
0817H
JUMP to 0808H to JUMP to 0C0BH to convert the number in the FLOATING POINT STACK into an INTEGER to be stored in Register Pair HL.
0819H - Entry point for the ABS() command.
0819H - Entry point for the ABS() command.
0819H
Since the ABS() instruction has a number in parenthesis, we first need to GOSUB to 07FCH to verify that an integer is inside parenthesis, and parse it via a RST 18H call.
081CH
RES 7,(IX+FFH)
In a nutshell, remove the negative sign. IX+FFH is the same as IX-01H, which is the SIGN of NUMBER 1 in the FLOATING POINT STACK. RESET (i.e., set as 0) BIT 7 of the SIGN of NUMBER 1 stored at the memory location pointed to by Register (IX-01H). Bit 7 is the bit which contains the sign, so by resetting it, the value in Register A is then positive.
0820H
RET
RETurn to the caller.
0821H - Entry point for the "MEM" command.
0821H - Entry point for the MEM command.
0821H
PUSH DE
Save the contents of Register Pair DE (i.e., the current character of the line being interpreted) to the top of the stack.
0822H
LD DE,(406CH)
Fetch the pointer to the top of used RAM (held in memory location 406CH) and store it into Register Pair DE.
0826H
LD HL,(406AH)
Fetch the value of the top of physical memory (held in memory location 406AH) and store it into Register Pair HL.
0829H
XOR A
Set Register A to ZERO and clear all Flags.
082AH
SBC HL,DE
Subtracts the amount of used RAM (held stored in Register Pair DE) and the carry flag from the amount of total physical RAM (stored in Register Pair HL).
082CH
POP DE
Restore the pointer to the current character of the line being interpreted into Register Pair DE.
082DH
JUMP to 0835H which Jumps to 0C59H which converts the value stored in Register Pair HL (i.e., the amount of free RAM available) to a floating point number in the Floating Point Stack.
082FH - Entry point for the INT() command.
082FH - Entry point for the INT() command.
082FH
Since the INT() instruction has a number in parenthesis, we first need to GOSUB to 07FCH to verify that an integer is inside parenthesis, and parse it via a RST 18H call.
0832H
GOSUB to 0808H which JUMPs to 0C0BH to convert a FLOATING number to an INTEGER; results stored in Register Pair HL.
0835H
JUMP to 0C59H to convert the value stored in Register Pair HL to a floating point number in the Floating Point Stack.
0838H - Entry point for the RESET Command.
0838H - Entry point for the RESET Command.
0838H
LD A,80H
Let Register A equal (Decimal: 128).
083AH
JUMP to 0842H in the POINT with A set to 128.
083CH - Entry point for the SET Command.
083CH - Entry point for the SET Command.
083CH
LD A,01H
Let Register A equal 01H (Decimal: 1).
083EH
JUMP to 0842H in the POINT with A set to 1.
0840H - Entry point for the POINT Command.
0840H - Entry point for the POINT Command.
0840H
LD A,00H
Let Register A equal 00H. This will differentiate from other routines entering this routine, whereby A is 1 for a SET and 128 for a RESET.
0842H - This is the main routine for graphics. On Entry A=128 for SET, 1 for RESET, and 0 for POINT.
0842H - This is the main routine for graphics. On Entry A=128 for SET, 1 for RESET, and 0 for POINT.
0842H
AND A
Reset the CARRY FLAG and set the Z/NZ FLAGS based on Register A via an AND A (which masks the value of Register A against itself).
0843H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
0844H
RST 08H
28H
52H
Check for a "(" via a call to RST 08H with parameters of 28H and an offset of 52H. RST 08H will move to the next non-space character and check it against 28H (which is a "("). If there is no match, jump to the return (of the next instruction, i.e. 0847H) + 52H instructions (which would be 0899H - which JUMPs to 08C9H to display the "WHAT" error).
0847H
GOSUB to 080BH to convert the number held in Register Pair HL into a non-negative integer. This will be the X coordinate in SET (x,y).
084AH
PUSH HL
Save the X coordinate (held in Register Pair HL) to the top of the stack.
084BH
RST 08H
2CH
4BH
Check for a "," via a call to RST 08H with parameters of 2CH and an offset of 4BH. RST 08H will move to the next non-space character and check it against 2CH (which is a ","). If there is no match, jump to the return (of the next instruction, i.e. 084EH) + 4BH instructions (which would be 0899H - which JUMPs to 08C9H to display the "WHAT" error).
084EH
GOSUB to 080BH to convert the number held in Register Pair HL into a non-negative integer. This will be the Y coordinate in SET (x,y).
0851H
RST 08H
29H
45H
Check for a ")" via a call to RST 08H with parameters of 29H and an offset of 45H. RST 08H will move to the next non-space character and check it against 29H (which is a ")"). If there is no match, jump to the return (of the next instruction, i.e. 0851H) + 45H instructions (which would be 0899H - which JUMPs to 08C9H to display the "WHAT" error).
0854H
LD BC,0030H
Let Register Pair BC equal 0030H (Decimal: 48), which is the highest vertical number.
0857H
AND A
Reset the CARRY FLAG and set the Z/NZ FLAGS based on Register A via an AND A (which masks the value of Register A against itself).
0842H - This is the main routine for graphics. On Entry A=128 for SET, 1 for RESET, and 0 for POINT.
0842H
AND A
Reset the CARRY FLAG and set the Z/NZ FLAGS based on Register A via an AND A (which masks the value of Register A against itself).
0843H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
0844H
RST 08H
28H
52H
Check for a "(" via a call to RST 08H with parameters of 28H and an offset of 52H. RST 08H will move to the next non-space character and check it against 28H (which is a "("). If there is no match, jump to the return (of the next instruction, i.e. 0847H) + 52H instructions (which would be 0899H - which JUMPs to 08C9H to display the "WHAT" error).
0847H
GOSUB to 080BH to convert the number held in Register Pair HL into a non-negative integer. This will be the X coordinate in SET (x,y).
084AH
PUSH HL
Save the X coordinate (held in Register Pair HL) to the top of the stack.
084BH
RST 08H
2CH
4BH
Check for a "," via a call to RST 08H with parameters of 2CH and an offset of 4BH. RST 08H will move to the next non-space character and check it against 2CH (which is a ","). If there is no match, jump to the return (of the next instruction, i.e. 084EH) + 4BH instructions (which would be 0899H - which JUMPs to 08C9H to display the "WHAT" error).
084EH
GOSUB to 080BH to convert the number held in Register Pair HL into a non-negative integer. This will be the Y coordinate in SET (x,y).
0851H
RST 08H
29H
45H
Check for a ")" via a call to RST 08H with parameters of 29H and an offset of 45H. RST 08H will move to the next non-space character and check it against 29H (which is a ")"). If there is no match, jump to the return (of the next instruction, i.e. 0851H) + 45H instructions (which would be 0899H - which JUMPs to 08C9H to display the "WHAT" error).
0854H
LD BC,0030H
Let Register Pair BC equal 0030H (Decimal: 48), which is the highest vertical number.
0857H
AND A
Reset the CARRY FLAG and set the Z/NZ FLAGS based on Register A via an AND A (which masks the value of Register A against itself).
Do some division ... first let's divide out the Y value by subtracting until it goes negative
0858H
SBC HL,BC
Subtract the value stored in Register Pair BC and the carry flag from the value stored in Register Pair HL.
085AH
If there is still NO CARRY (meaning it did not yet go negative), JUMP BACK to the prior instruction.
085CH
ADD HL,BC
Once we have a carry, we bust out of that loop, and make the remainder positive by adding BC back into HL. With this, HL will be the "Y" value, between (and including) 0 and 47.
085DH
LD A,L
Copy the Y-Value (held in Register L) into Register A.
Next, let's get Y MOD 3 into Register H.
085EH
LD H,FFH
Load register H with the starting quotient.
0860H
INC H
INCrement the value stored in Register H by 1.
0861H
SUB 03H
Divide by subtraction ... SUBtract the value 03H from Register A.
0863H
If the NC FLAG (No Carry) has been set, LOOP BACK 2 instructions to increment H and then subtract another 3 from Register A.
0865H
ADD 03H
We have gone negative, so now add back 03H so that Register H = the Y-Value MOD 3.
0867H
POP BC
Put the X-value (held at the top of the STACK) into Register Pair BC.
0868H
LD B,H
Copy the contents of Register H into Register B.
0869H
SLA C
Shift the bits in Register C left one position, with the contents of bit 7 being copied to the CARRY FLAG and Bit 0 being set as ZERO.
086BH
RR B
Divide Register B by 2 via a RRB which rotates the Bits in Register B to the right one bit position, with Bit 0 being copied to the CARRY FLAG and CARRY FLAG being copied to Bit 7.
086DH
RR C
Divide Register C by 2 via a RRB which rotates the Bits in Register C to the right one bit position, with Bit 0 being copied to the CARRY FLAG and CARRY FLAG being copied to Bit 7.
086FH
RR B
Divide Register B by 2 via a RRB which rotates the Bits in Register B to the right one bit position, with Bit 0 being copied to the CARRY FLAG and CARRY FLAG being copied to Bit 7.
0871H
RR C
Divide Register C by 2 via a RRB which rotates the Bits in Register C to the right one bit position, with Bit 0 being copied to the CARRY FLAG and CARRY FLAG being copied to Bit 7.
0873H
RLA
Rotate the bits of Register left (i.e., lower bit moves higher) one bit position. The contents of bit 7 are copied to the CARRY FLAG and the previous contents of the carry flag are copied to bit 0.
0874H
INC A
INCrement the value stored in Register A by 1.
0875H
SCF
Since the CARRY FLAG is going to be important, turn the CARRY FLAG on.
At this point, Register A is the number of iterations that we have to rotate the graphic mask, Register H, to the left.
0876H
LD H,00H
Let Register H equal 00H. Register H will be the graphic mask.
0878H
RL H
Top of a loop. Rotate the bits in Register H left one bit position, with the contents of Bit 7 copied to the CARRY FLAG and CARRY FLAG copied to Bit 0.
087AH
DEC A
DECrement the value stored in Register A by 1.
087BH
Keep rotating H until A = 0 via a JUMP to 0878H.
Next, we need to calculate the screen location by masking B with an OR for FCH and AND for 3FH to get a value between 0 and 63 (the screen width).
087DH
LD A,B
Copy the contents of Register B into Register A.
087EH
OR FCH
OR Register A against FCH, which turns on all bits other than bits 0 and 1.
0880H
AND 3FH
MASK the value of Register A against 3FH (0011 1111). This has the effect of turning off bits 7, 6, leaving only bits 5, 4, 3, 2, 1, 0 active, for a maximum value of 63, which is the number of characters a screen line can handle.
0882H
LD B,A
Copy the contents of Register A into Register B.
0883H
LD A,(BC)
Fetch the character at the screen location pointed to by Register Pair BC.
0884H
BIT 7,A
Test Bit Number 7 of Register A to see if the screen location had a graphic character or not. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
0886H
If the NZ FLAG (Not Zero) has been set, JUMP to 088BH to test the graphic character.
If we didn't jump away, the Bit 7 of Register A was a 0, meaning that it was not a graphic character, so we need to put one there!
0888H
LD A,80H
Let Register A equal 80H (Decimal: 128), which is the lowest graphic character (which is also empty).
088AH
LD (BC),A
Store the dummy graphic character held in Register A into the memory location pointed to by Register Pair BC.
At this point, Register Pair BC points to the screen location at which the revised graphic character will be placed, and Register H has the graphic mask to apply to the character.
088BH
POP AF
Restore the routine entry flags (0=Point, 1=Set, 128=Reset).
088CH
LD A,(BC)
Load Register A with the graphic character at the location of the video memory pointer in register pair BC.
088DH
If the Z FLAG (Zero) has been set, meaning we entered the routine with a 00H or POINT instruction, JUMP to 089BH.
088FH
If the S FLAG has been RESET, JUMP to 08A5H to finish the SET command.
0892H
LD A,H
If we are here, then we have a RESET command ... copy the graphic mask in Register H into Register A.
0893H
CPL
Reverse each bit in Register A (which is the same as NOT).
0894H
LD H,A
Copy the contents of Register A into Register H.
0895H
LD A,(BC)
Fetch the graphic character at the location of the video memory pointer in register pair BC and put into into Register A.
0896H
AND H
RESET the graphic bit by combining the graphic mask in register H with the graphic character in Register A.
0897H
LD (BC),A
Save the adjusted graphic character in Register A at the location of the video memory pointer in register pair BC.
0898H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
0899H
JUMP to 08C9H to display the "WHAT" error.
089BH - Part of the Generic Graphics Routine; final processing of POINT command.
089BH
AND H
POINT the graphic bit by combining the graphic mask in register H with the graphic character in Register A.
089CH
LD HL,0000H
Let Register Pair HL equal 0000H.
089FH
If the Z FLAG (Zero) has been set, skip the next instruction.
08A1H
INC L
INCrement the value stored in Register L by 1.
At this point, HL will be 0 if the SQUOT being tested if OFF and HL = 1 if the SQUOT being tested if ON.
08A2H
JUMP to 0C59H to convert the value stored in Register Pair HL to a floating point number in the Floating Point Stack.
08A5H - Part of the Generic Graphics Routine; final processing of SET command.
08A5H
OR H
SET the graphic bit by combining the graphic mask in register H with the graphic character in Register A.
08A6H
LD (BC),A
Save the adjusted graphic character in Register A at the location of the video memory pointer in register pair BC.
08A7H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
08A8H - Parse a variable name followed by an "=" and an expression (such as "FOR X = 4").
08A8H
RST 38H
RST 38H checks the command line to see if the next non-space character is an existing variable; HL to point to the variable if it exists and CARRY set if it doesn't.
08A9H
If the C FLAG (Carry) has been set, JUMP to 08C9H to display the "WHAT" error.
08ABH
RST 08H
3DH
1BH
Check for a "=" via a call to RST 08H with parameters of 3DH and an offset of 1BH. RST 08H will move to the next non-space character and check it against 3DH (which is a "="). If there is no match, jump to the return (of the next instruction, i.e. 08AEH) + 1BH instructions (which would be 08C9H).
08AEH
PUSH HL
Save the location of the variable at issue (held in Register Pair HL) to the top of the stack, which is necessary for the JUMP to 0BE8H.
08AFH
RST 18H
RST 18 to parse an expression (and an optional expression, if any).
08B0H
JUMP to 0BE8H to take the value held in the FLOATING POINT STACK and put it in the VARIABLE pointed to by HL (and then remove it from the FLOATING POINT STACK). Since this is a JUMP, that routine will RETurn out of this one.
08B3H - Check if the next character is a ":" and if yes, JUMP to 08BAH to check for a CARRIAGE RETURN and if not then jump to the MIDDLE of the EXECUTE NEXT LINE routine.
08BAH
RST 08H
3AH
04H
Check for a ":" by calling to RST 08H with parameters of 3AH and an offset of 04H. RST 08H will move to the next non-space character and check it against 3AH (which is a ":"). If there is no match, jump to the return (of the next instruction, i.e. 08B6H) + 04H instructions (which would be 08BAH).
08B6H
POP AF
Clear the RETurn location from the stack
08B7H
JUMP to 03A2H in the middle of the EXECUTE NEXT LINE, which will check for BREAK (and if found, STOP) or else reset the cassette motor, set IX to the bottom of the floating point stack, set HL to point to the middle of the reserved word list, and parse for matching reserved words.
08BAH - Check if the next character is a CARRIAGE RETURN and if YES, keep processing the next line and if NO then RETurn.
08BAH
RST 08H
0DH
04H
Check for a CARRIAGE RETURN by calling to RST 08H with parameters of 0DH and an offset of 04H. RST 08H will move to the next non-space character and check it against 3AH (which is a CARRIAGE RETURN). If there is no match, jump to the return (of the next instruction, i.e. 08BDH) + 04H instructions (which would be 08C1H).
08BDH
POP AF
Clear the RETurn location from the stack
08BEH
JUMP to the top of EXECUTE NEXT LINE routine at 0394H.
08C1H
RET
RETurn to the caller.
08C2H - Very common routine to parse an integer.
08C2H
GOSUB to 0EC4H to parse an integer into Register Pair HL.
08C5H - Very common jump point. This is jumped to when a command is executed that has no further parameters and, therefore, REQUIRES a CARRIAGE RETURN as the next character. It will return out of the main routine if the next character is a a CARRIAGE RETURN, and display a WHAT error otherwise.
08C5H
RST 28H
Call RST 28H to move DE to point to the next non-space character, with Register A holding that character.
08C6H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set.
08C8H
RET Z
If the Z FLAG (Zero) has been set, RETurn to the caller. Otherwise will pass through to the "WHAT" error routine which follows.
08C9H - Display the "WHAT" error.
08C9H
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
08CAH
LD DE,01B4H
Let Register Pair DE equal 01B4H, which points to the "WHAT" error message in the ROM.
08CDH
GOSUB to 094FH to display the message pointed to by Register Pair DE, returning once a 00H is found
08D0H
LD DE,(409FH)
Fetch the pointer to the current line being executed (held in memory location 409FH) and store it into Register Pair DE.
08D4H
08D4H
LD A,D
OR E
Since the Z-80 cannot test Register Pair DE against zero, the common trick is to set Register A to equal to Register D, and then OR A against Register E. Only if both Register D and Register E were zero can the Z FLAG be set.
08D6H
If the Z FLAG (Zero) has been set, meaning that we are not at a line number, JUMP to 08F1H to return to the READY PROMPT.
08D8H
INC DE
If we are here, then DE holds the pointer to the line number being executed. Bump DE to point to the next character on the BASIC line being processed.
08D9H
LD A,(DE)
LD A,(DE)
Fetch the next character on the BASIC line being processed (held in the memory location pointed to by Register Pair DE) and store it into Register A.
08DAH
DEC DE
DECrement the value stored in Register Pair DE by 1 so that it once again holds the pointer to the line number being executed.
08DBH
OR A
Set FLAGS based on the contents of Register A (and, in all events, clear the CARRY FLAG).
08DCH
If the S FLAG has been SET, JUMP to 061AH to restore SP from a temporary storage space of 409BH and restore the current line being executed back into Register Pair HL and the associated memory location.
08DFH
POP HL
Put the value held at the top of the STACK into Register Pair HL.
08E0H
LD A,(HL)
Fetch the value held in the memory location pointed to by Register Pair (HL) and store it into Register A.
08E1H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
08E2H
SUB A
LET Register A = 0.
08E3H
LD (HL),A
Store a ZERO (i.e., the value held in Register A) into the memory location pointed to by Register Pair HL.
08E4H
GOSUB to 0A63H to display the line number pointed to by Register Pair DE on screen.
08E7H
DEC DE
DECrement the value stored in Register Pair DE by 1.
08E8H
POP AF
Put the value held at the top of the STACK into Register Pair AF.
08E9H
LD (DE),A
Store the value held in Register A into the memory location pointed to by Register Pair DE.
08EAH
LD A,3FH
Let Register A equal 3FH (ASCII: ?).
08ECH
RST 10H
Send the character held in Register A (i.e., 0CH) to the cassette or screen via a RST 10 call.
08EDH
SUB A
LET Register A = 0.
08EEH
GOSUB to 094FH to display the message pointed to by Register Pair DE, returning once a 00H is found
08F1H
Enter they READY command line routine via a JUMP to 01C9H.
08F4H - Display the "SORRY" error. This is the error used by Level 1 when we are OUT OF MEMORY.
08F4H
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
08F5H
LD DE,01BAH
Let Register Pair DE equal 01BAH, which points to the "SORRY" error message in the ROM.
08F8H
JUMP to 08CDH which GOSUBs to 094FH to display the message pointed to by Register Pair DE, returning once a 00H is found
08FAH - If entry is 08FAH, display a prompt of the character held in Register A then then fetch a line of input into a 53 character buffer between 40ACH and 40F3H pointed to by Register Pair DE.
08FAH
LD A,3EH
Let Register A equal 3EH (ASCII: >), which is the standard TRS-80 prompt.
08FCH
RST 10H
Send the character held in Register A to the screen via a RST 10 call.
08FDH
LD DE,40ACH
Let Register Pair DE equal 40ACH which is a dual purpose location: Buffer for command input AND output to cassette.
0900H
GOSUB to 0B40H to fetch a keystroke from the keyboard (note: does not wait for a keypress).
0903H
If the Z FLAG (Zero) has been set, loop back to the prior instruction to fetch a keystroke.
0905H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
0907H
If the keystroke was a CARRIAGE RETURN, then the Z FLAG will have been set, so JUMP to 0915H to add that CARRIAGE RETURN to the buffer.
0909H
CP 1DH
Compare the value held in Register A against 1DH (Decimal: 29) to check for a control code. Results: If Register A equals 1DH, the Z FLAG is set; otherwise the NZ FLAG is set.
090BH
If the Z FLAG (Zero) has been set, JUMP to 0922H.
090DH
CP 03H
Compare the value held in Register A against 03H (Keyboard: BREAK). Results: If Register A equals BREAK, the Z FLAG is set; otherwise the NZ FLAG is set.
090FH
If the keystroke was a BREAK, then the Z FLAG will have been set, so JUMP to 08F1H which JUMPs to JP 01C9H to return to the READY command line routine.
0911H
CP 20H
Compare the value held in Register A against 20H (Decimal: 32). Results:
- If Register A equals 20H, the Z FLAG is set.
- If A < 20H, the CARRY FLAG will be set.
- if A >= 20H, the NO CARRY FLAG will be set.
0913H
If the keystroke was a character < 20H, meaning a control code, the C FLAG (Carry) will have been set, so JUMP to 0900H to ignore the character and keep polling the keyboard.
0915H
LD (DE),A
If we are here, then we want to keep the character, so store the keystroke (held in Register A) into the buffer memory location pointed to by Register Pair DE.
0916H
INC DE
Bump DE to point to the next character in the input buffer.
0917H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
0919H
RET Z
If the character is a CARRIAGE RETURN, then the Z FLAG will have been set, meaning we are done with this line of INPUT, so RETurn to the caller.
If we are here, then we had a character we wanted to keep, and it wasn't a CARRIAGE RETURN, so we need to keep getting more characters.
091AH
LD A,E
Copy the LSB of the pointer to the buffer (i.e., the contents of Register E) into Register A so we can test to see how much buffer we have left.
091BH
CP F3H
Compare the value held in Register A against F3H (meaning, to check it see if we hit 40F3H in filling the buffer). Results: If Register A equals F3H, the Z FLAG is set; otherwise the NZ FLAG will be set.
091DH
If the NZ FLAG was set, then we still have room in the buffer pointed to by DE, so JUMP back to 0900H to get more keystrokes.
If we are here, then we have run out of buffer space for INPUT.
091FH
LD A,1DH
Let Register A equal 1DH to delete the new character.
0921H
RST 10H
Send the character held in Register A (i.e., 1DH) to the cassette or screen via a RST 10 call.
0922H
LD A,E
Copy the LSB of the pointer to the buffer (i.e., the contents of Register E) into Register A.
0923H
CP ACH
Compare the value held in Register A against ACH (meaning, to check it see if we hit 40ACH in filling the buffer, which is the start of the buffer). Results: If Register A equals ACH, the Z FLAG is set; otherwise the NZ FLAG will be set.
0925H
If the Z FLAG (Zero) has been set, then we are at the start of the buffer, so discard everything and start again via a JUMP to 08FAH to fetch a line of input from the user.
0927H
DEC DE
If we weren't at the start of the buffer, then back up the pointer to the buffer by 1 by DECrementing the value stored in Register Pair DE by 1.
0928H
JUMP to 0900H to keep fetching keystrokes.
092AH - Find the line in RAM which matches the line number pointed to by Register Pair HL starting at the address held in Register Pair DE. If jumped HERE it starts at the beginning of BASIC RAM. Will set the CARRY FLAG if nothing was found.
092AH
LD DE,4200H
Let Register Pair DE equal 4200H, to point to the start of BASIC RAM. So if the jump was to 092AH, it scans all of RAM. if the call was to 092DH, then it starts where DE was set before the CALL.
092DH - Find the line in RAM which matches the line number pointed to by Register Pair HL starting at the address held in Register Pair DE. If no line is found, it will point to the line BEFORE where the line contained in HL should have been AND will set the CARRY and NZ FLAGs.
092DH
PUSH HL
Save the contents of Register Pair HL (i.e., the line number being looked for) to the top of the stack.
First we need to verify that the RAM we are searching (held in DE) isn't less than 4200H or higher than the top of RAM (held in 406CH). First, check for too low ...
092EH
LD A,D
Copy the MSB of the RAM address being examined (held in Register D) into Register A.
092FH
CP 42H
Compare the value held in Register A against 42H, below which would be an improper search location. Results: If Register A < 42H, the CARRY FLAG will be set.
0931H
If the C FLAG (Carry) has been set, then we are trying to search starting too low, so exit via a JUMP to 08F1H which will JUMP to 01C9H to return to the READY command line routine.
.. and now, check for too high. Involves a temporary repurpose of HL.
0933H
LD HL,(406CH)
Fetch the pointer to the top of used RAM (held in memory location 406CH) and store it into Register Pair HL.
0936H
DEC HL
Step back one byte from the highest RAM location.
0937H
RST 20H
Compare the top of RAM (held in HL) and the starting point for the line number search (held in DE) via a call to RST 20H. Results: NZ means no match, Z means match, and if H=D but L < E, then the C flag will be set.
0938H
POP HL
Restore the the line number being looked for back into HL from the STACK.
0939H
RET C
If the C FLAG (Carry) has been set, then we are trying to search starting too high and nothing can be found, so RETurn to the caller with the C FLAG set to indicate NOTHING WAS FOUND.
093AH - Continuation of the FIND THE LINE NUMBER IN RAM routine, to actually do the search. Register Pair DE holds the RAM location to examine, and Register Pair HL holds the line number being looked for.
093AH
LD A,(DE)
Fetch character in RAM to examine for the line number.
093BH
SUB L
LET Register A = Register A - the LSB of the line number being looked for (held in Register L).
093CH
LD B,A
Put the results of that subtraction into Register B.
093DH
INC DE
Bump DE to point to the next character in RAM to examine.
093EH
LD A,(DE)
Fetch that character and put it into Register A.
093FH
SBC A,H
LET Register A = Register A - the MSB of the line number being looked for (held in Register H), with the carry flag being used as well.
0940H
If the C FLAG (Carry) has been set, JUMP to 0946H which will advance DE 1 places and then search for the next line in RAM.
0942H
DEC DE
If there was no carry, then back up DE to the prior character in RAM.
0943H
OR B
OR Register B against Register A. The results are stored in Register A.
0944H
RET
RETurn to the caller with the CARRY FLAG reset (as OR resets) to indicate FOUND.
0945H - Continuation of the FIND THE LINE NUMBER IN RAM routine. Jumped here to skip to the end of the line and then to jump back to continue searching.
0945H
INC DE
Advance DE one character.
0946H
INC DE
Advance DE one character.
0947H
LD A,(DE)
Fetch character in RAM to examine for the line number.
0948H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A DOES NOT equal CARRIAGE RETURN, the NZ FLAG is set.
094AH
If the current character in RAM, pointed to by DE, is not a CARRIAGE RETURN, then the NZ FLAG will have been set, so JUMP to 0946H to advance DE and check again.
094CH
INC DE
Advance DE one character.
094DH
JUMP to 092DH to continue parsing RAM (from the new DE) for the line number pointed to by Register Pair HL.
094FH - Display the message pointed to by Register Pair DE until a either a CARRIAGE RETURN or the contents of REGISTER A is found.
094FH
XOR A
Set Register A to ZERO and clear all Flags.
0950H
LD B,A
Top of a loop. Set Register B to the delimeter character we are looking for.
0951H
LD A,(DE)
Fetch the current character to display (held in the memory location pointed to by Register Pair DE) and store it into Register A.
0952H
INC DE
Bump DE to point to the next character to display.
0953H
CP B
Compare the character at DE - 1 against the delimeter character (held in Register B). If they match, the Z FLAG will be set.
0954H
RET Z
If the Z FLAG (Zero) has been set, meaning a delimeter was hit, RETurn to the caller.
0955H
RST 10H
If we did not get the delimeter, then send the character held in Register A (i.e., a character in the message to display) to the cassette or screen via a RST 10 call.
0956H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set; otherwise the NZ FLAG is set.
0958H
If the NZ FLAG (Not Zero) has been set, JUMP to 0951H to fetch the next character and continue the loop.
095AH
RET
RETurn to the caller.
095BH - Part of the PRINT routine. Display a quoted expression pointed to by Register Pair DE and JUMP to the command line parsing routine if a CR is found, otherwise JUMP to the return address + 2 bytes.
095BH
RST 08H
22H
0EH
Call to RST 08H with parameters of 22H and an offset of 0EH. RST 08H will move to the next non-space character and check it against 22H (which is a "). If there is no match, jump to the return (of the next instruction, i.e. 095EH) + 0EH instructions (which would be 096CH, which is just a RET).
095EH
LD A,22H
Store a " into Register A, as that will act as the END OF ROUTINE delimeter in the CALL to 0950H.
0960H
CALL 0950H
GOSUB to 0950H in the prior routine to display the message pointed to by Register Pair DE until a " is found.
0963H
CP 0DH
Compare the value held in Register A against 0DH (ASCII: CARRIAGE RETURN). Results: If Register A equals CARRIAGE RETURN, the Z FLAG is set.
0965H
POP HL
Put the ROUTINE RETURN ADDRESS (held at the top of the STACK) into Register Pair HL.
0966H
If we had a CARRIAGE RETURN, then the Z FLAG (Zero) will have been set, JUMP to the top of EXECUTE NEXT LINE routine at 0394H.
0969H
096AH
INC HL
INC HL
Advance HL 2 bytes to point 2 bytes after the prior routine return address.
096BH
JP (HL)
JUMP to (HL).
096CH - Exit out of the prior routine based on the RST 08H call not matching a ".
096CH
RET
RETurn to the caller.
096DH - Display the contents of Register Pair HL as a decimal number.
096DH
GOSUB to 0C59H to convert the value stored in Register Pair HL to a floating point number in the Floating Point Stack.
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
0971H
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
0972H
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
0973H
LD A,(IX+FEH)
IX+FEH is the same as IX-02H, which is the EXPONENT of NUMBER 1 in the FLOATING POINT STACK. Fetch the EXPONENT of the number in the FLOATING POINT STACK (held at IX-2) into Register A.
0976H
CP 80H
Compare the EXPONENT (held in Register A) against 80H (Decimal: 128), which is to test if the negative sign is set. If Register A is NOT 128, the NZ FLAG will be set.
0978H
If the NZ FLAG (Not Zero) has been set, meaning the number is NOT ZERO, JUMP to the next routine at 0983H.
If we are here, then we need to print a zero value.
097AH
LD A,20H
Let Register A equal 20H (ASCII: SPACE).
097CH
RST 10H
Send the character held in Register A (i.e., 0CH) to the cassette or screen via a RST 10 call.
097DH
LD A,30H
Let Register A equal 30H (ASCII: 0).
097FH
RST 10H
Send the character held in Register A (i.e., 0CH) to the cassette or screen via a RST 10 call.
0980H
JUMP to 0A41H to exit by first displaying a SPACE, POPing HL/BC/DE from the STACK, POPing the FLOATING POINT STACK, and then RETurning to the caller of this routine.
0983H - Continuation of the routine to display the contents of Register Pair HL as a decimal number; jumped here to print a NEGATIVE number.
0983H
LD A,(IX+FFH)
IX+FFH is the same as IX-01H, which is the SIGN of NUMBER 1 in the FLOATING POINT STACK.Fetch the SIGN of the number in the FLOATING POINT STACK (held at IX-1) into Register A.
0986H
AND A
Reset the CARRY FLAG and set the Z/NZ FLAGS based on Register A via an AND A (which masks the value of Register A against itself).
0987H
LD A,20H
Let Register A equal 20H (ASCII: SPACE).
0989H
If the Z FLAG (Zero) has been set, meaning a POSITIVE NUMBER, skip the next instruction and JUMP to 098DH to display the leading SPACE.
098BH
LD A,2DH
If we are here, then NZ was set, meaning a NEGATIVE number, so replace the character we are about to display with a -.
098DH
RST 10H
Send the character held in Register A (i.e., either a SPACE if the sign is POSITIVE or a "-" if the sign is NEGATIVE) to the cassette or screen via a RST 10 call.
098EH
XOR A
Set Register A to ZERO and clear all Flags.
098FH
LD (IX+FFH),A
IX+FFH is the same as IX-01H, which is the SIGN of NUMBER 1 in the FLOATING POINT STACK. Store a ZERO over the SIGN BIT of the number in the FLOATING POINT STACK (held at IX-1).
0992H
LD A,FFH
Let Register A equal FFH (Decimal: -1).
0994H
PUSH AF
Top of a loop. Save the contents of Register Pair AF to the top of the stack.
0995H
LD HL,0EB9H
Let Register Pair HL equal 0EB9H, which is a pointer to a constant in ROM holding CCH CCH CCH 7EH
0998H
GOSUB to 0CA6H which is part of the FLOATING POINT DIVIDE routine. This routine pushes that constant to the FLOATING POINT STACK, converts the top two numbers in the FLOATING POINT STACK to to B/D/B'/D'/E' and C/L/C'/H'/L', and then replaces BC with -5 before JUMPing to 0CB7H.
099BH
If the NC FLAG (No Carry) has been set, JUMP to 09A4H to continue, skipping the multiplication of the FLOATING POINT STACK number by 10.
099DH
GOSUB to 0C84H to multiply the floating point stack by 10.
09A0H
POP AF
Put the value held at the top of the STACK into Register Pair AF.
09A1H
DEC A
DECrement the value stored in Register A by 1.
09A4H - Continuation of the routine to display the contents of Register Pair HL as a decimal number.
09A4H
LD HL,0EB5H
Let Register Pair HL equal 0EB5H, which is a location in ROM holding 00H 00H 80H 80H.
09A7H
GOSUB to 0CA6H which is part of the FLOATING POINT DIVIDE routine. This routine pushes HL to the FLOATING POINT STACK, converts the top two numbers in the FLOATING POINT STACK to to B/D/B'/D'/E' and C/L/C'/H'/L', and then replaces BC with -5 before JUMPing to 0CB7H.
09AAH
If the C FLAG (Carry) has been set, JUMP to 09B4H to continue, skipping the division of the FLOATING POINT STACK number by 10.
09ACH
GOSUB to 0C95H to divide the floating point stack by 10.
09AFH
POP AF
Put the value held at the top of the STACK into Register Pair AF.
09B0H
INC A
INCrement the value stored in Register A by 1.
09B1H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
09B2H
LOOP BACK to the top of this routine at 09A4H.
09B4H - Continuation of the routine to display the contents of Register Pair HL as a decimal number.
09B4H
LD A,(IX+FEH)
IX+FEH is the same as IX-02H, which is the EXPONENT of NUMBER 1 in the FLOATING POINT STACK. Fetch the EXPONENT of the number in the FLOATING POINT STACK (held at IX-2) into Register A.
09B7H
NEG
Negate the contents of Register A (which is the same as -A). This will now be a counter to the number of times we are going to rotate the bits NUMBER 2.
09B9H
Top of a loop. If the Z FLAG (Zero) has been set, stop rotating and JUMP to the next routine at 09C6H.
09BBH
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL' so we can access the value of NUMBER 2. Note: AF is not handled via EXX.
09BCH
SRL C
Shift the bits of the MSB of NUMBER 2 (held in Register C') right one bit position, with Bit 0 being copied to the CARRY FLAG and Bit 7 set to zero.
09BEH
RR H
Rotate the bits of the NMSB of NUMBER 2 (held in Register H') right one bit position, with bit 0 copied to the CARRY FLAG and the previous contents of the CARRY FLAG copied to bit 7.
09C0H
RR L
Rotate the bits of the LSB of NUMBER 2 (held in Register L') right one bit position, with bit 0 copied to the CARRY FLAG and the previous contents of the CARRY FLAG copied to bit 7.
09C2H
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
09C3H
DEC A
DECrement the value stored in Register A by 1.
09C6H - Continuation of the routine to display the contents of Register Pair HL as a decimal number. I will not make believe I know what is going on.
09C6H
LD B,07H
Let Register B equal 07H, for a DJNZ loop of 7.
09C8H
09CAH
PUSH IX
POP HL
Let Register Pair HL = Special Index Register IX (i.e., the pointer to the FLOATING POINT STACK).
09CBH
LD (HL),00H
IX+00H is the LSB of NUMBER 2 in the FLOATING POINT STACK. Store the value 00H as the LSB of NUMBER 2.
09CDH
INC HL
INCrement the value stored in Register Pair HL by 1 to now point to IX+01H.
09CEH
LD A,00H
Top of a DJNZ loop of 7. Let Register A equal 00H.
09D0H
GOSUB to 015EH to to accumulate the digit by multiplying the accumulator by 10 and then adding in A to the newly vacant one's spot. Routine will return a NZ SET if an overflow occurs from the accumulation.
09D3H
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
09D4H
LD A,B
Copy the contents of Register B' into Register A.
09D5H
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
09D6H
LD (HL),A
Store the value held in Register A into the memory location pointed to by Register Pair HL (which will be a number between IX+01H and IX+08H).
09D7H
INC HL
INCrement the value stored in Register Pair HL by 1.
09D8H
LOOP back to 09CEH, 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.
09DAH
LD B,06H
Let Register B equal 06H in preparation for a 6 interation DJNZ LOOP of 09E2H-09F7H.
09DCH
LD C,00H
Let Register C equal 00H.
09DEH
DEC HL
DECrement the value stored in Register Pair HL by 1. HL is pointing to the FLOATING POINT STACK.
09DFH
LD A,(HL)
Fetch the value held in the memory location pointed to by Register Pair (HL) and store it into Register A.
09E0H
CP 05H
Compare the value held in Register A against 05H (Decimal: 5). Results:
- If Register A equals 05H, the Z FLAG is set.
- If A < 05H, the CARRY FLAG will be set.
- if A >= 05H, the NO CARRY FLAG will be set.
09E2H
CCF
Top of a 6 iteration DJNZ loop if passing down, or a 1 iteration if this routine was about to end. Invert the state of the CARRY FLAG so that A < 05H will produce a NO CARRY, and A >= 05H will produce a CARRY.
09E3H
LD A,00H
Let Register A equal 00H as an accumulator.
09E5H
DEC HL
DECrement the value stored in Register Pair HL by 1. HL is pointing to the FLOATING POINT STACK.
09E6H
ADC A,(HL)
Add, with CARRY, A and the value stored in the FLOATING POINT STACK pointed to by HL.
09E7H
SLA C
Shift the bits of Register C left one position, with the contents of bit 7 copied to the CARRY FLAG and a zero is put into bit 0.
09E9H
CP 0AH
Compare the value held in Register A against 0AH (Decimal: 10). If A < 10, the CARRY FLAG will be set.
09EBH
If the C FLAG (Carry) has been set, SKIP the next instruction and then continue at 09EFH.
09EDH
LD A,00H
If A was => 10, the reset Register A back to 0.
09EFH
LD (HL),A
Store the value held in Register A into the FLOATING POINT STACK location pointed to by Register Pair HL.
09F0H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
09F1H
AND A
Reset the CARRY FLAG and set the Z/NZ FLAGS based on Register A via an AND A (which masks the value of Register A against itself).
09F2H
If the Z FLAG (Zero) has been set, SKIP the next instruction and then continue at 09F6H.
09F4H
SET 0,C
If the Z flag wasn't set, SET (i.e., set as 1) BIT 0 of Register C.
09F6H
POP AF
Put the value held at the top of the STACK into Register Pair AF.
09F7H
LOOP back to 09E2H, 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.
09F9H
LD A,C
Copy the contents of Register C into Register A.
09FAH
POP BC
Put the value held at the top of the STACK into Register Pair BC.
09FBH
If the C FLAG (Carry) has been set, JUMP to 0A03H.
09FDH
INC B
INCrement the value stored in Register B by 1.
09FEH
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
09FFH
LD B,01H
Let Register B equal 01H for a 1-iteration DJNZ Loop.
0A01H
JUMP to 09E2H for that loop.
0A03H - Continuation of the routine to display the contents of Register Pair HL as a decimal number. I will not make believe I know what is going on.
0A03H
LD C,A
Copy the contents of Register A into Register C.
0A04H
LD A,B
Copy the contents of Register B into Register A.
0A05H
INC A
INCrement the value stored in Register A by 1.
0A06H
If the S FLAG has been SET, JUMP to the next routine at 0A13H.
0A09H
CP 07H
Compare the value held in Register A against 07H. If A >= 07H, the NO CARRY FLAG will be set.
0A0BH
If A >= 07H, then the NC FLAG will have been set, JUMP to the next routine at 0A13H.
0A0DH
LD B,A
Copy the contents of Register A into Register B.
0A0EH
GOSUB to 0A4DH to decrement B, displays a "." if B didn't hit zero, and then display a number. Then, if a shifted C isn't zero, loops back to the top and if it is zero, Decrements B twice, exiting if the sign changes, or redoing the routine otherwise.
0A11H
JUMP to 0A41H to exit by first displaying a SPACE, POPing HL/BC/DE from the STACK, POPing the FLOATING POINT STACK, and then RETurning to the caller of this routine.
0A13H - Continuation of the routine to display the contents of Register Pair HL as a decimal number. This will process the exponent display by first displaying the "E" if needed, set up to display the sign after the "E", and load Register A with the number (negated if it was negative).
0A13H
PUSH BC
Temporarily save the contents of Register Pair BC to the top of the stack so that Register B can be used over the next 4 instructions.
0A14H
LD B,01H
Let Register B equal 01H, which will be the parameter passed in the next CALL.
0A16H
GOSUB to 0A4DH with B=01H. This will display a "." and then more numbers.
0A19H
LD A,45H
Let Register A equal 45H (ASCII: E).
0A1BH
RST 10H
Send the character held in Register A (i.e., E) to the cassette or screen via a RST 10 call.
0A1CH
POP BC
Restore Registers B and C from the stack.
0A1DH
BIT 7,B
Test Bit Number 7 of Register B. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
0A1FH
LD A,2BH
Set up Register A so that it will display a +.
0A21H
If the Z FLAG (Zero) has been set, then the SIGN was positive, so JUMP to the next routine at 0A2BH (which starts by displaying the + held in Register A).
0A23H
LD A,2DH
If Bit 7 of Register B was 1, then the number is negative, so set Register A to a -.
0A25H
RST 10H
Send the character held in Register A (i.e., -) to the cassette or screen via a RST 10 call.
0A26H
LD A,B
Since you can't negate Register B, copy the contents of Register B into Register A.
0A27H
NEG
Negate the contents of Register A (which is the same as -A) so that the number is represented as a negative number.
0A29H
Skip over the next 2 instructions (which would have applied if the number was positive - showing the "+" and then setting A = B instead of A=-B) via a JUMP to 0A2DH.
<------------- BAD BEFORE THIS -------------->
If we are here, then a negative number was passed. Will give some examples.
As a reminder, NUMBER 1 is stored in B' (MSB), D' (NMSB), and E' (LSB), with the SIGN in D and the EXPONENT in E,. NUMBER 2 is stored in C' (MSB), H' (NMSB), and L' (LSB), with the SIGN in H and the EXPONENT in L.