0000H
DI
Disable Interrupts.
0001H
LD HL,00FFH
Let Register Pair HL equal 00FFH, which, when the very next instruction hits, will turn HL into FFFFH.
0004H
JUMP to 018EH to determine How Much RAM is in the System and then continue with startup.
0007H
NOP
No Operation (Do Nothing).
0008H - RST 08H Routine - This routine requires TWO parameters ... a value as the next bit and a byte offset. DE is advanced to the next non-space and tests it against the value. If there is no match, jumps to the return value PLUS the offset. If there is match, jumps to the byte after the offset.
0008H
EX (SP),HL
Since this routine ultimately changes the place to which it returns, we need to get that address so EXchange the value stored in Register Pair HL with the value stored in Register Pair SP.
0009H
RST 28H
Call RST 28H to move DE to point to the next non-space character, with Register A holding that character.
000AH
CP (HL)
Compare the next non-space character (held in Register A) against the value held at the top of the stack (i..e, in the memory location pointed to by the value held in Register Pair HL). Results:
- If Register A equals the value held in Register (HL), the Z FLAG is set.
- If A < (HL), the CARRY FLAG will be set.
- if A >= (HL), the NO CARRY FLAG will be set.
000BH
Continue on with a JUMP to 0098H.
000EH - Display a CARRIAGE RETURN.
000EH
LD A,0DH
Let Register A equal 0DH (ASCII: ENTER). Routine then falls through to RST 10H which displays the character.
0010H - RST 10H Routine - This routine will send a character to the screen or to the cassette.
0010H
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
0011H
EX AF,AF'
EXchange the value stored in Register Pair AF' with the value stored in Register Pair AF.
0012H
GOSUB to 0FF0H to check to see if the cassette motor is running.
0015H
JUMP to 0ACBH to send the byte held in Register A either to the screen or the cassette.
0018H - RST 18H Routine - This routine will parse an expression.
0018H
GOSUB to 07ADH to parse an expressions.
001BH
NOP
No Operation (Do Nothing).
001CH
JUMP to 075DH to parse an optional relational expression (">" "<" or "=").
001FH
NOP
No Operation (Do Nothing).
0020H - RST 20H Routine - This routine will compare HL and DE. NZ means no match, Z means match.
0020H - RST 20H Routine - This routine will compare HL and DE. NZ means no match, Z means match.
0020H
LD A,H
Copy the contents of Register H into Register A.
0021H
CP D
Compare Register H (held in Register A) against 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.
0022H
RET NZ
If the NZ FLAG (Not Zero) has been set, RETurn to the caller.
0023H
LD A,L
If we're here, then H matched D so let's keep going. Copy the contents of Register L into Register A.
0024H
CP E
Compare Register L (held in Register A) against 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.
0025H
RET
Return to the caller.
0026H
NOP
No Operation (Do Nothing).
0027H
NOP
No Operation (Do Nothing).
0028H - RST 28H Routine
This routine will skip forward from DE until the first non-space character, with Register A holding that character.
0028H
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.
0029H
CP 20H
Since the purpose of this routine is to skip over SPACE, we compare the value held in Register A against 20H (ASCII: SPACE). Results: If Register A equals SPACE, the Z FLAG is set.
002BH
RET NZ
If the NZ FLAG (Not Zero) has been set, then we have a non-space held in A, so return to the caller.
002CH
INC DE
Otherwise, we still have a space so increment the value stored in Register Pair DE by 1.
002DH
Jump to 0028H to test that character.
0030H - RST 30H Routine
This routine will continue execution.
0030H
POP AF
Put the return address (which should be held at the top of the STACK) into Register Pair AF.
0031H
GOSUB to 08B3H to check if the next character is a ":" and if yes, jump to 08BAH to check for a ENTER and if not then jump to the middle of the execute next line routine.
0034H
Jump to 08C9H to display the "WHAT" error (Level 1 equivalent of a SYNTAX ERROR).
0037H
NOP
No Operation (Do Nothing).
0038H - RST 38H Routine.
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.
0038H
RST 28H
First, move to where the variable should be via a call to RST 28H to search DE until a non-space character is found, with Register A holding that character.
0039H
SUB 41H
Subtract the value 41H (ASCII: A) from Register A to test to see if the character is less than a capital "A".
003BH
RET C
If the CARRY FLAG has been set then the variable (i.e., the non-space character) was less than A, meaning an invalid variable. Return to the caller with the CARRY FLAG set.
003CH
CP 1AH
Compare the value held in Register A against 1AH (Decimal: 26) to see if the character is greater than a Control Character. Results:
- If Register A equals 26, the Z FLAG is set.
- If A < 26, the CARRY FLAG will be set.
- If A >= 26, the NO CARRY FLAG will be set.
003EH
CCF
So at this point, a good variable will be less than 26 (with the CARRY FLAG set) and a bad variable will be greater than or equal to 26 (with the NC set). This is backwards from an error, so invert the state of the CARRY FLAG, so that a bad variable has the CARRY set and a good variable has the NC set.
003FH
RET C
If the CARRY FLAG has been set, meaning we have a bad variable, return to the caller.
0040H
INC DE
If we're here then we have a good variable at DE. Increment the value stored in Register Pair DE by 1.
0041H
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). This tests to see if the variable at DE is an "A" or not, as "A" is the only variable that can be an array in Level 1.
0042H
If the NZ FLAG (Not Zero) has been set (meaning that the variable is not "A"), jump to 0082H to continue processing the single valid non-array variable.
0044H
Next we need to check for the array, which means a parenthesis. We do this a call to RST 08H with parameters of "(" and an offset of 3AH. 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. 0047H) + 3AH instructions (which would be 0081H).
0047H
If we are here then the next character pointed to by DE is the subscript of an A() variable. GOSUB to 080BH to determine that subscript as a non-negative integer.
004AH
INC HL
Now we need to position HL to point to the variable. Increment the value stored in Register Pair HL by 1.
004CH
ADD HL,HL
Double HL again!
004DH
If the C FLAG (Carry) has been set because of all that math, then HL doesn't have a valid value anymore so display the "HOW?" error via a jump to 01A2H.
0050H
PUSH HL
If the CARRY FLAG didn't trip, then we have a valid pointer value in HL so save it to the top of the stack.
0051H
Next we need to check for close parenthesis. We do this a call to RST 08H with parameters of ")" and an offset of 35H. 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. 0054H) + 35H instructions (which would be 0089H).
0054H
POP HL
Restore HL from the top of the stack.
0055H
PUSH DE
Save the current pointer on the line being analyzed (held in Register Pair DE) to the top of the stack.
0056H
PUSH HL
Save the pointer to the variable (held in Register Pair HL) to the top of the stack.
0057H
LD HL,(406AH)
Fetch the value of the top of physical memory (held in memory location 406AH) and store it into Register Pair HL.
005AH
LD DE,(406CH)
Fetch the pointer to the top of user RAM (held in memory location 406CH) and store it into Register Pair DE.
005EH
XOR A
Set Register A to ZERO and clear all Flags.
005FH
SBC HL,DE
Subtract the top of user RAM and the CARRY FLAG from the top of physical memory, with the results into Register Pair HL.
0061H
POP DE
Restore the pointer to the variable (formerly held in Register Pair HL) from the top of the stack into Register Pair DE.
0062H
RST 20H
Compare HL and DE via a call to RST 20H - NZ means no match, Z means match. If H=D but L < E, then the C flag will be set.
0063H
Skip over the NMI handler routine and continue on via a jump to 0076H.
0066H - Non-Maskable Interrupt Routine.
This would be triggered on hitting the RESET BUTTON.
0066H
DI
Disable Interrupts.
0067H
LD SP,4200H
Set the Stack Pointer to 4200H.
006AH
XOR A
Set Register A to ZERO and clear all Flags.
006BH
LD (4090H),A
Store the ZERO held in Register A into the cassette port status cache (held in memory location 4090H).
006EH
OUT (FFH),A
Send the ZERO held in Register A into the cassette port.
0070H
LD A,0CH
Let Register A equal 0CH (ASCII: Form Feed), which is essentially a CLS.
0072H
RST 10H
Send the character held in Register A (i.e., 0CH) to the cassette or screen via a RST 10 call.
0073H
Show the READY prompt via a JUMP to 01C9H.
0076H - Continuation point for the RST 38H routine.
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.
0076H
If the C FLAG (Carry) has been set (meaning that DE > HL) then we have a problem, so JUMP to 08F5H to display the "SORRY" error.
0079H
LD HL,(406AH)
Fetch the value of the top of physical memory (held in memory location 406AH) and store it into Register Pair HL.
007CH
SBC HL,DE
Subtracts the value stored in Register Pair DE (the pointer to the variable) and the carry flag from the value stored in Register Pair HL (the top of physical memory).
007EH
POP DE
Put the current pointer to the line being examined (held at the top of the STACK) back into Register Pair DE.
007FH
XOR A
Set Register A to ZERO and clear all Flags.
0080H
RET
Return to the caller.
0081H - Continuation point for the RST 38H routine"
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"
0081H
XOR A
Set Register A to ZERO and clear all Flags.
0082H - Continuation point for the RST 38H routine".
Register A will contain 0-25, representing variables "A"-"Z".
0082H
LD H,40H
Let Register H equal 40H to set the MSB to the variable list of 4000H (Variable A) through 4064H (Variable Z)
0084H
0085H
RLA
RLA
Rotate the bits of Register left (i.e., lower bit moves higher) two bit positions so that A will correspond to 00H (Variable A) to 64H (Variable Z)
0086H
LD L,A
Set the LSB of the Register Pair HL variable pointer to the offset calculated and held in Register A.
0087H
XOR A
Set Register A to ZERO and clear all Flags.
0088H
RET
Return to the caller.
0089H - Jump to the routine to Display the "WHAT" error.
0089H
Jump to 08C9H to display the "WHAT" error.
008CH - Subroutine to check to see if the character pointed to by Register Pair DE is, or is not, a digit (i.e., 0-9).
If a digit is found, will return with Register A containing the digit and NC set, or the CARRY FLAG set otherwise.
008CH
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.
008DH
CP 30H
Compare the value held in Register A against 30H (ASCII:
0). Results:
- If Register A equals 0, the Z FLAG is set.
- If A < 0, the CARRY FLAG will be set.
- If A >= 0, the NO CARRY FLAG will be set.
008FH
RET C
If the C FLAG (Carry) has been set then it's not a digit because it's below 0, so return to the caller with the CARRY FLAG set.
0090H
CP 3AH
Compare the value held in Register A against 3AH (ASCII:
:), which is 1 character higher than a
9. Results:
- If Register A equals :, the Z FLAG is set.
- If A < :, the CARRY FLAG will be set.
- If A >= :, the NO CARRY FLAG will be set.
0092H
CCF
If we have a good character, the CARRY FLAG will have been set by the CP instruction. Since the CARRY FLAG being set is supposed to signal a bad character, we need to invert the state of the CARRY FLAG.
0093H
RET C
If the C FLAG (Carry) has been set then it's not a digit because it's above9, so return to the caller with the CARRY FLAG set.
0094H
INC DE
If we are here then we have a good digit stored in Register A. Now a bit of cleanup. First advance the pointer on the line being examined (held in Register Pair DE) by 1 to point to the next character instead of the one we just examined.
0095H
AND 0FH
Cap the number at 15 by masking the value of Register A against 0FH (00001111). This has the effect of turning off bits 7,6,5,4, leaving only bits 3,2,1,0 active.
0097H
RET
Return to the caller.
0098H — RST 08H Resolution — Match/No-Match branching logic
0098H
INC HL
Increment Register Pair HL to point to the offset byte.
0099H
If the Z FLAG was set (match found), JUMP to 00A2H to advance DE past the matched character.
009BH
PUSH BC
Save Register Pair BC to the stack to take the alternate (no-match) branch.
009CH
LD C,(HL)
Load Register C from the memory location pointed to by HL (the branch offset byte).
009DH
LD B,00H
Let Register B equal 00H to form a 16-bit offset in BC.
009FH
ADD HL,BC
Add the offset in BC to HL to compute the branch address.
00A0H
POP BC
Restore Register Pair BC from the stack.
00A1H
DEC DE
Decrement Register Pair DE so that the character at DE is NOT consumed (no-match case).
00A2H
INC DE
Advance Register Pair DE past the matched character (match case entry point).
00A3H
INC HL
Advance HL past the offset byte.
00A4H
EX (SP),HL
Substitute the return address on the stack with the computed branch address in HL.
00A5H
RET
Return, which actually jumps to the substituted branch address.
010AH - Continuation of the FLOATING POINT CONSTANT routine at 00A6H.
Jumped here if we have a non-digit that isn't a ".", "E", or +, or -.
010AH
GOSUB to 0157H to zero out the integer accumulator.
010DH
We need to verify that the character is a digit, so GOSUB to 008CH to check to see if the character pointed to by Register Pair DE is, or is not, a digit. Returns Register A containing the digit, or the CARRY FLAG set otherwise.
0110H
If the CARRY FLAG has been set, and we do not have a digit, JUMP to 0120H.
0112H
SET 5,B
SET (i.e., set as 1) BIT 5 of Register B to indicate that we have found a digit in an exponent position.
0114H
GOSUB to 015EH to accumulate the exponent's 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.
0117H
If the NZ FLAG (Not Zero) has been set, meaning we have an overflow, display the "HOW?" error via a JUMP to 01A2H.
011AH
JUMP to 010DH to parse the next character.
011CH - Continuation of the FLOATING POINT CONSTANT routine at 00A6H.
Jumped here if we have a non-digit that isn't a "." or an "E".
011CH
POP DE
Restore the current position on the line being evaluated from the top of the stack into Register Pair DE.
011DH
XOR A
Set Register A to ZERO and clear all Flags.
0120H - Continuation of the FLOATING POINT CONSTANT routine at 00A6H.
Jumped here if we have started processing an exponent and then hit a non-digit.
0120H
BIT 5,B
Test Bit Number 5 of Register B to determine if we already have exponent digits. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
0122H
If the Z FLAG (Zero) has been set and we have no exponent digits, JUMP to 011CH.
0124H
POP AF
Put the value held at the top of the STACK into Register Pair AF.
0125H
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
0126H
LD A,C
Copy the contents of Register C into Register A.
0127H
OR H
OR Register H against Register A. The results are stored in Register A.
0128H
The NZ will be set if either Register C or Register H is not zero. If that's the case, then we have a problem (most likely an overflow) and the NZ FLAG (Not Zero) will have been set, JUMP to 0151H to swap the registers back and give a "HOW" error.
012AH
LD A,L
Copy the exponent (held in Register L) into Register A.
012BH
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
012CH
BIT 7,A
Test Bit Number 7 of Register A to see if we have a large number of digits (meaning, over 128). Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
012EH
If the NZ FLAG (Not Zero) has been set, display the "HOW?" error via a JUMP to 01A2H.
0131H
BIT 1,B
Test Bit Number 1 of Register B to see if we have found a exponent minus sign. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
0133H
If the Z FLAG (Zero) has been set, JUMP to 0137H.
0135H
NEG
At this point, we have a valid exponent ... but its sign is wrong. Negate the contents of Register A (which is the same as -A).
0137H
ADD A,C
LET Register A = Register A + Register C.
0138H
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).
0139H
If the Z FLAG (Zero) has been set, then Register A, after all that, is still zero -- so we were given an E00. Since that's not relevant, JUMP away to 014EH to exit the routine.
013BH
BIT 7,A
Test Bit Number 7 of Register A to see if we have a large number of digits (meaning, over 128). Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
013DH
If the Z FLAG (Zero) has been set then we have a POSITIVE exponent to process ... JUMP to 0146H.
013FH
INC A
INCrement the value stored in Register A by 1.
0140H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
0141H
GOSUB to 0C95H to divide the floating point stack by 10.
0146H - Continuation of the FLOATING POINT CONSTANT routine at 00A6H; jumped here if to process a POSITIVE exponent.
0146H
DEC A
DECrement the value stored in Register A by 1.
0147H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
0148H
GOSUB to 0C84H to multiply the floating point stack by 10.
014BH
POP AF
Put the value held at the top of the stack into Register Pair AF.
014EH - Continuation of the FLOATING POINT ROUTINE at 00A6H; exit the floating point routine.
014EH
BIT 6,B
Test Bit Number 6 of Register B to see if we had found any digits. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
0150H
RET
RETurn to the caller - If Z is set, then we had a bad value.
0151H - Exit routine with HOW error.
0151H
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
0152H
Display the "HOW?" error via a JUMP to 01A2H.
0155H - Routine to clear parse flags and prepare for next parsing.
0155H
RES 6,B
RESet (i.e., set as 0) BIT 6 of Register B to zero out the flag as to whether we have found a digit yet or not.
0157H
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
0158H
LD L,00H
Let Register L equal 00H.
015AH
LD H,L
Copy a 0 (i.e., the contents of Register L) into Register H.
015BH
LD C,L
Copy a 0 (i.e., the contents of Register L) into Register C.
015CH
EXX
EXchanges the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
015DH
RET
RETurn to the caller.
015EH - Continuation of the FLOATING POINT CONSTANT routine at 00A6H.
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.
015EH
EX AF,AF'
EXchange the value stored in Register Pair AF' with the value stored in Register Pair AF.
015FH
EXX
Set the ALTERNATE REGISTER SET as active and EXchange the 16-bit contents of BC, DE, and HL with BC', DE', and HL'. Note: AF is not handled via EXX.
0160H
0161H
LD D,H
LD E,L
Let Register Pair DE' = Register Pair HL'.
0162H
LD A,C
Copy the contents of Register C' into Register A'.
0163H
LD B,00H
Let Register B' equal 00H. Register B' tracks a whole lot of status bits for the floating point routine. Bit 0=Decimal point has been found, Bit 1 = Exponent with a Minus Sign has been Found, Bit 5 = Digits in an exponent have been found, Bit 6 = A digit has been found, and Bit 7 = A large number of digits (more than 127) have been found.
0165H
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
0166H
ADD HL,HL
LET Register Pair HL = Register Pair HL + Register HL.
0167H
RL C
Rotate the bits of Register C left 1 position, with bit 7 going to CARRY and CARRY going to bit 0. This effectively multiplies Register C by 2.
0169H
RL B
Rotate the bits of Register B left 1 position, with bit 7 going to CARRY and CARRY going to bit 0. This effectively multiplies Register B by 2.
So at this point HL, C, and B have all been multiplied by 2.
016BH
ADD HL,HL
LET Register Pair HL = Register Pair HL + Register HL.
016CH
RL C
Rotate the bits of Register C left 1 position similar to above multiplication.
016EH
RL B
Rotate the bits of Register B left 1 position similar to above multiplication.
So at this point HL, C, and B have all been multiplied by 4 total.
0170H
ADD HL,DE
LET Register Pair HL = Register Pair HL + Register DE.
0171H
ADC A,C
LET Register A = Register A + Register C with carry. Now Register A = Register C * 5.
0172H
LD C,A
Save Register C * 5 to Register C.
0173H
LD A,00H
Set Register A to 00H.
0175H
ADC A,B
LET Register A = Register A + Register B with carry. Now Register A = Register B * 5.
0176H
LD B,A
Save Register B * 5 to Register B.
So at this point HL, C, and B have all been multiplied by 5 total.
0177H
POP AF
Restore the original value of C into A from the stack.
0178H
ADD HL,HL
Double Register Pair HL.
0179H
RL C
Rotate bits of Register C left once more.
017BH
RL B
Rotate bits of Register B left once more.
So at this point HL, C, and B have all been multiplied by 10 total.
017DH
EX AF,AF'
Exchange value stored in Register Pair AF' with AF.
The rest of the routine adds Register A to Register Pairs HL and BC.
017EH
ADD A,L
LET Register A = Register A + Register L.
017FH
LD L,A
Copy result to Register L.
0180H
LD A,00H
Set Register A to 00H.
0182H
ADC A,H
LET Register A = Register A + Register H with carry.
0183H
LD H,A
Copy result to Register H.
0184H
LD A,00H
Set Register A to 00H.
0186H
ADC A,C
LET Register A = Register A + Register C with carry.
0187H
LD C,A
Copy result to Register C.
0188H
LD A,00H
Set Register A to 00H.
018AH
ADC A,B
LET Register A = Register A + Register B with carry.
018BH
LD B,A
Copy result to Register B.
018CH
EXX
Exchange BC, DE, HL with BC', DE', HL'. AF is not handled via EXX.
018DH
RET
Return to the caller.
018EH - Determine How Much RAM is in the System by fetching, complementing, storing, and testing each byte from FFFFH downwards. HL = 00FFH on entry.
018EH - Determine How Much RAM is in the System by fetching, complementing, storing, and testing each byte from FFFFH downwards. HL = 00FFH on entry.
018EH
DEC H
DECrement the value stored in Register H by 1. On the first run this turns HL's 00FFH into FFFFH.
018FH
LD A,(HL)
Fetch the value held in the memory location pointed to by Register Pair (HL) and store it into Register A.
0190H
CPL
Reverse each bit in Register A (which is the same as NOT).
0191H
LD (HL),A
Store the value held in Register A into the memory location pointed to by Register Pair HL.
0192H
XOR (HL)
eXclusive OR the value stored at (HL) against Register A. Why XOR the value against itself (since the value at HL was just set as A) when XORing a value against itself produces a Zero? Well, the RAM location might not exist, which is the only way that XOR would produce a NZ result.
0193H
If the NZ FLAG (Not Zero) has been set then the RAM location pointed to by HL didn't accept the value, so LOOP back to 018EH to keep reducing the page of RAM to test (so FFFF to FEFF to FDFF ...).
0195H
LD (406AH),HL
If we are here, then we hit the first tested address that stored a value. Store THAT address (held in Register Pair HL) into memory location 406AH (which is the top of physical memory).
0198H
XOR A
Set Register A to ZERO and clear all Flags.
0199H
LD (4090H),A
Store a 0 (held in Register A) into the cassette port status cache (held at memory location 4090H).
019CH
LD SP,4200H
Set the stack pointer to 4200H / (Decimal: 16896).
019FH
JUMP to 037BH to clear the screen and continue with the startup process.
01A2H - Display the "HOW?" error.
01A2H
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
01A3H
LD DE,01A9H
Let Register Pair DE equal 01A9H to point to the HOW? message.
01A9H - MESSAGE STORAGE AREA.
01C9H - BASIC's READY Entry Point. If JUMPed here, the BASIC RUN STATE is cleared.
01C9H
LD SP,4200H
Set the stack pointer to 4200H.
01CCH
GOSUB to 0FE4H to turn off the cassette motor.
01CFH - BASIC's READY Alternate Entry Point. If JUMPed here, the BASIC RUN STATE is not affected.
01CFH
GOSUB to 000EH to display a CARRIAGE RETURN.
01D2H
LD DE,01AEH
Let Register Pair DE equal 01AEH, which is the message storage area for the READY prompt.
01D5H
GOSUB to 094FH to display the message pointed to by Register Pair DE, returning once a 00H is found.
01D8H - Process a line of code in a READY loop
01D8H
LD SP,4200H
Set the stack pointer to 4200H.
01DBH
GOSUB to 0239H to clear the 10 bytes starting at 409DH and set Register Pair DE to 4200. 409D is the pointer to the line where a STOP statement was activated, 409F is the pointer to the current line being executed, 40A1 is the pointer for the READ statement, 40A3 is the BASIC Stack Pointer location, and 40A5 is the pointer for the current FOR variable.
01DEH
LD IX,40F4H
Let Special Index Register Pair IX, which is used in the floating point math routines, equal 40F4H, which is the bottom of floating point stack. Each entry is 5 bytes consisting of LSB, Middle, MSB (with Bit 7 set), Exponent and Sign (in Bit 7)
01E2H
GOSUB to 08FAH to fetch a line of input.
01E5H
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
01E6H
LD DE,40ACH
Let Register Pair DE equal 40ACH.
NOTE: 40ACH is the storage location for buffer for command input AND the print output to cassette.
01E9H
The first thing we should find is a line number, so GOSUB to 0EC4H to parse an integer into Register Pair HL. Note, this moves DE forward to point to the first non-blank character.
01ECH
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.
01EEH
POP BC
Restore the prior contents of Register Pair DE into Register Pair BC.
01EFH
The flag is currently set by the OR above. If the value is 0, then we are on the command line instead of being inside a program. So ... if the Z FLAG (Zero) has been set, JUMP to 0340H.
01F2H
DEC DE
If we are here, then we are parsing a line in a program. DECrement the value stored in Register Pair DE by 1 to go back to the second number in the 2 byte line number (as DE was moved forward in the call to 0EC4H).
01F3H
LD A,H
Copy the second byte of the line number (held in Register H) into Register A.
01F4H
LD (DE),A
Store the value held in Register A into the memory location pointed to by Register Pair DE.
01F5H
DEC DE
DECrement the value stored in Register Pair DE by 1 to point DE to the first number in the 2 byte line number.
01F6H
LD A,L
Copy the first byte of the line number (held in Register L) into Register A.
01F7H
LD (DE),A
Store the value held in Register A into the memory location pointed to by Register Pair DE.
01F8H
PUSH BC
Save the contents of Register Pair BC to the top of the stack.
01F9H
PUSH DE
Save the contents of Register Pair DE (currently pointing to the line number of the line to be parsed) to the top of the stack.
01FAH
LD A,C
Copy the contents of Register C into Register A.
01FBH
SUB E
LET Register A = Register C - Register E.
01FCH
PUSH AF
Save the contents of Register Pair AF to the top of the stack.
01FDH
GOSUB to 092AH to find the line in RAM which matches the line number pointed to by Register Pair HL. Note: A jump to 092AH resets DE. To do the routine while preserving DE, jump instead to 092DH.
The line number has been found, so we will overwrite/delete the old line.
0200H
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
0201H
If the NZ FLAG (Not Zero) has been set, JUMP to 0213H.
0203H
PUSH DE
Save the contents of Register Pair DE to the top of the stack.
0204H
GOSUB to 0945H to scan the entire line.
0207H
POP BC
Put the value held at the top of the STACK into Register Pair BC.
0208H
LD HL,(406CH)
Fetch the pointer to the top of used RAM (held in memory location 406CH) and store it into Register Pair HL.
020BH
GOSUB to 0A6FH to copy the bytes held at (DE) to (BC), backwards, until DE = HL.
020EH
LD H,B
LD L,C
Copy the contents of Register Pair BC into Register Pair HL because there is no LD (xxxx),BC command in the Z-80!
0210H
LD (406CH),HL
Now that we used up some RAM, set the NEW top of used RAM to HL by putting HL into 406CH (which points to the top of used RAM).
If we are here we will add a new line to the program UNLESS it was just a line number, in which case we delete the line.
0213H
POP BC
Put the value held at the top of the STACK into Register Pair BC.
0214H
LD HL,(406CH)
Fetch the pointer to the top of used RAM (held in memory location 406CH) and store it into Register Pair HL.
0217H
POP AF
Put the value held at the top of the STACK into Register Pair AF.
0218H
PUSH HL
Save the contents of Register Pair HL (which should be holding the pointer to the end of the line to be moved) to the top of the stack. This will be POPed into DE at 022EH.
0219H
CP 03H
Compare the value held in Register A against the end-of-line terminator 03H. Results: If Register A equals 03H, the Z FLAG is set.
021BH
If the Z FLAG (Zero) has been set then we are at EOL delimiter, so JUMP to the top of the READY LOOP (minus the READY prompt) at 01D8H to infinitely process another line of code.
If we are here then we did not hit the EOL delimiter. The next bunch of calls and math is first designed to make sure there is enough RAM to store the whole line, so HL is set up to be the highest RAM location needed to store the line.
021DH
ADD A,L
LET Register A = Register A + Register L.
021EH
LD L,A
Copy the contents of Register A into Register L. These 2 commands are basically HL = HL + A.
021FH
LD A,00H
Let Register A equal 00H.
0221H
ADC A,H
LET Register A = Register A + Register H.
0222H
LD H,A
Copy the contents of Register A into Register H.
0223H
LD DE,(406AH)
Fetch the value of the top of physical memory (held in memory location 406AH) and store it into Register Pair DE.
0227H
RST 20H
Call the routine at RST 20H to compare HL (the highest RAM address needed to store the line) and DE (the highest possible RAM location). Results: NZ means no match, Z means match. If H=D but L < E, then the C flag will be set.
0228H
Since the RST 20H in the prior instruction was testing to see if the byte we need to store in RAM exceeds the amount of free RAM or not, a NC means we are out of RAM. If the NC FLAG (No Carry) has been set, JUMP to 08F4H to display the "WHAT" error.
022BH
LD (406CH),HL
If we are here, then we still had enough RAM left and BC remains untouched so that it still points to the starting location of the text to move via the call at 0A77H. We still need to set up DE and HL for that call, so store the value held in Register Pair HL into memory location 406CH (which points to the top of used RAM), as HL is where the bytes from (BC) to (DE) will be moved to.
022EH
POP DE
Put the value held at the top of the STACK into Register Pair DE.
022FH
GOSUB to 0A77H to copy the bytes, backwards, from BC through DE to HL.
0232H
POP DE
Put the value held at the top of the STACK into Register Pair DE.
0233H
POP HL
Put the value held at the top of the STACK into Register Pair HL.
0234H
GOSUB to 0A6FH to copy the bytes held at (DE) to (BC), backwards, until DE = HL.
0237H
Jump to the top of the READY LOOP (minus the READY prompt) at 01D8H to infinitely process another line of code.
0239H - Clear the 10 bytes from 409DH to 40A6H and set Register Pair DE to 4200H.
0239H
LD B,0AH
Let Register B equal 0AH (Decimal: 10) for a DJNZ loop of 10 iterations.
023BH
PUSH HL
Save the contents of Register Pair HL to the top of the stack.
023CH
LD HL,409DH
Let Register Pair HL equal 409DH, which is the parse pointer saved when a STOP command is executed (current line being executed).
023FH
LD (HL),00H
Store 00H at the memory location pointed to by HL, setting current line number to 0000.
0241H
INC HL
Increment Register Pair HL by 1.
0242H
Loop back to 023FH, decrementing B each time, until B reaches zero.
0244H
LD DE,4200H
Set Register Pair DE to 4200H.
0247H
POP HL
Restore previous value of Register Pair HL from the stack.
0248H
RET
Return to the caller.
0249H - RESERVED WORD LOOKUP/VECTOR TABLE.
024DH
The entry point for the LIST command is 0401H
0252H
The entry point for the RUN command is 038CH
0257H
The entry point for the NEW command is 0378H
025DH
The entry point for the CONT command is 03EBH
0264H
The entry point for the CLOAD command is 0EE9H
026BH
The entry point for the CSAVE command is 0F3BH
0271H
The entry point for the NEXT command is 05A3H
0276H
The entry point for the LET command is 06B8H
027DH
The entry point for the INPUT command is 0623H
0281H
The entry point for the IF command is 05FBH
0285H
The entry point for the ON command is 04FEH
028BH
The entry point for the GOTO command is 03B5H
0292H
The entry point for the GOSUB command is 04C4H
0299H
The entry point for the RESET command is 0838H
02A1H
The entry point for the RETURN command is 04E6H
02A7H
The entry point for the READ command is 06F9H
02B0H
The entry point for the RESTORE command is 06CDH
02B5H
The entry point for the REM command is 05F6H
02BBH
The entry point for the DATA command is 05F6H
02C0H
The entry point for the FOR command is 0546H
02C7H
The entry point for the PRINT command is 042FH
02CCH
The entry point for the SET command is 083CH
02D2H
The entry point for the STOP command is 03C5H
02D7H
The entry point for the END command is 0387H
02DCH
The entry point for the CLS command is 04B5H
02DEH
That's the end of the single command reserved words. If none of the above reserved words were found, JUMP to 06B3H, which will process a variable assignment.
02E4H
The entry point for the ON x GOTO command is 050FH
02EBH
The entry point for the ON x GOSUB command is 0517H
02EDH
DEFW 88C9H
If we were looking for a GOTO or GOSUB, and they weren't found, the JUMP here to 08C9H will display the "WHAT" error.
02F2H
The entry point for the RND command is 0E47H
02F7H
The entry point for the ABS command is 0819H
02FCH
The entry point for the MEM command is 0821H
0301H
The entry point for the INT command is 082FH
0308H
The entry point for the POINT command is 0840H
030EH
The entry point for the TO command is 0555H
0316H
The entry point for the STEP command is 0560H
031DH
The entry point for the TAB command is 049FH
0321H
The entry point for the AT command is 0473H
0325H
The entry point for the A$ command is 0459H
0329H
The entry point for the B$ command is 045EH
032BH
DEFB 84H, 52H
Entry vector byte pair (omitted in the original disassembly).
032EH
The entry point for the > operator is 0763H
0331H
The entry point for the = operator is 078BH
0334H
The entry point for the "<" operator is 0773H
0336H
DEFW 8797H
This is the jump point for when a relational expression is not found.
033CH
The entry point for the THEN command is 0611H
0340H - Routine to look for a BASIC keyword. Jumped to when the instruction line being interpreted is on the command line instead of being part of a program.
0340H
LD HL,0248H
Let Register Pair HL equal 0248H, which is the top of the RESERVED WORD LOOKUP LIST, in preparation to check if the next character(s) pointed to by DE is/are a reserved word.
The next batch of code is to try to match the instruction to a reserved word.
0343H
RST 28H
Call RST 28H to move DE (pointer to current character in instruction line) to next non-space character, with Register A holding that character.
0344H
PUSH DE
Save the contents of Register Pair DE (current character pointer) to the top of the stack.
0345H
LD A,(DE)
Fetch the non-space character pointed to by DE from instruction line into Register A.
0346H
INC DE
Increment DE to point to next character in BASIC line.
0347H
INC HL
Increment HL to point to next entry in RESERVED WORD LOOKUP/VECTOR TABLE.
0348H
CP (HL)
Compare Register A (current instruction character) against the reserved word character pointed to by HL. If equal, Z FLAG is set.
0349H
If Z FLAG set, potential match between instruction character and reserved word; jump to 0351H.
034BH
BIT 7,(HL)
Test bit 7 of (HL); Z FLAG if 0 (next item not starting with 8), NZ FLAG if 1 (next item starting with 8, a branch address).
034DH
If NZ FLAG set, at a branch address instead of reserved word, jump to 035BH.
034FH
No first letter match or branch instruction; jump to 0362H.
0351H - Continuation of the routine to parse an instruction line; jumped from 0349H if first character match from line vs reserved word.
0351H
LD A,(DE)
Fetch next character on BASIC line (pointed to by DE) into Register A.
0352H
INC DE
Increment DE to point to next character.
0353H
INC HL
Increment HL for next entry in RESERVED WORD LOOKUP/VECTOR TABLE.
0354H
CP (HL)
Compare Register A against reserved word char pointed to by HL; Z FLAG set if equal.
0355H
If Z FLAG set, have another match; loop back to 0351H.
0357H
BIT 7,(HL)
Test bit 7 of (HL) to distinguish branch addresses from reserved words.
0359H
If Z FLAG set, matched entire keyword but did not hit address; jump to 035EH.
035BH
DEC DE
Back up 1 character on instruction line, so DE points to start of address instead of second char.
035CH
Jump to 0370H to process matched address.
035EH - Continuation to parse instruction line; jumped here if might have abbreviation match.
035EH
CP 2EH
Compare Register A against 2EH (ASCII .); Z FLAG set if equal.
0360H
If Z FLAG set, abbreviation match; jump to 036BH.
0362H
INC HL
Increment HL to skip the address in LOOKUP/VECTOR TABLE.
0363H
BIT 7,(HL)
Test bit 7 of (HL) to check for second address; Z FLAG set if 0, NZ if 1.
0365H
If Z FLAG set, more addresses exist; loop back to 0362H.
0367H
INC HL
Increment HL to next character in LOOKUP/VECTOR TABLE.
0368H
POP DE
Restore current character pointer of line from stack (saved at 0344H).
0369H
Loop back to 0343H to continue keyword matching.
036BH - Continue parsing instruction line; loops to skip chars until an address found.
036BH
INC HL
Increment HL to next entry in LOOKUP/VECTOR TABLE.
036CH
BIT 7,(HL)
Test bit 7 of (HL) to see if it's an '8' (address present); Z FLAG set if 0, NZ if 1.
036EH
If Z FLAG set, not found address yet; loop back to 036BH.
0370H
LD A,(HL)
Fetch MSB of address pointed to by HL into Register A.
0371H
INC HL
Increment HL to next character in LOOKUP/VECTOR TABLE.
0372H
LD L,(HL)
Fetch LSB of address pointed to by HL into Register L.
0373H
AND 7FH
Mask Register A with 7FH to clear bit 7, as it is not part of the address.
0375H
LD H,A
Copy masked MSB into Register H.
0376H
POP AF
Clear return address from stack.
0377H
JP (HL)
Jump to address held in (HL).
0378H - Entry point for the NEW command.
0378H
GOSUB to 08C5H to check if next character pointed by DE is a carriage return. Returns here if yes; otherwise shows "WHAT" error.
037BH - Continuation of start-up process after RAM determination.
037BH
LD A,0CH
Set Register A to 0CH (form feed) to clear the screen.
037DH
RST 10H
Send Register A to cassette or screen via RST 10.
037EH
LD HL,4200H
Set Register Pair HL to 4200H.
0381H
LD (406CH),HL
Store HL into memory 406CH, marking top of used RAM.
0384H
Jump to READY command line routine at 01C9H.
0387H - Entry point for the END command.
0387H
GOSUB to 08C5H to check next character pointed by DE for carriage return. Returns here if yes; otherwise shows "WHAT" error.
038AH
Jump to READY routine at 0384H.
038CH - Entry point for the RUN command.
038CH
GOSUB to 08C2H to parse an integer into HL.
038FH
GOSUB to 0239H to clear 10-byte buffer starting at 409DH and set DE to 4200.
0392H
Preserve HL (line number to RUN) by skipping the next instruction and jumping to 0397H.
0394H - Common routine continuation point. Execute the next line.
0394H
LD HL,0000H
Set HL to 0000H.
0397H
GOSUB to 092DH to find line in RAM matching HL, preserving DE.
039AH
If C flag set, jump to READY routine at 01C9H.
039CH
LD (409FH),DE
Store DE (current line to execute) into memory 409FH.
03A0H
03A1H
INC DE
INC DE
Increment DE by 2 to skip line number.
03A2H
GOSUB to 0B40H to fetch keyboard keystroke (non-blocking).
03A5H
CP 03H
Compare Register A to 03H (BREAK); set Z if equal.
03A7H
If BREAK detected (Z set), jump to STOP command at 03C5H.
03A9H
GOSUB to 0FE4H to turn off cassette motor.
03ACH
LD IX,40F4H
Set IX to 40F4H, bottom of floating point stack.
03B0H
LD HL,026CH
Set HL to 026CH, pointing to middle of RESERVED WORD LOOKUP table before NEXT command.
03B3H
Jump to 0343H to continue READY COMMAND loop with adjusted lookup table pointer.
03B5H - Entry point for the "GOTO" command.
03B5H
GOSUB to 0EBDH to parse integer into HL or set NZ for error. Return if NZ; otherwise jump to 08C9H to display "WHAT" error.
03B8H
PUSH DE
Save DE on stack.
03B9H
GOSUB to 08C5H to check next character pointed by DE for carriage return; returns here if yes, else shows "WHAT" error.
03BCH
GOSUB to 092AH to find line in RAM matching HL; jump to 092DH to preserve DE.
03BFH
If NZ set, jump to 01A3H to display "HOW?" error.
03C2H
POP AF
Restore AF from stack.
03C3H
Jump to 039CH to continue processing instructions on identified line.
03C5H - Entry point for the "STOP" command.
03C5H
LD (409DH),DE
Store DE as parse pointer saved when a STOP command is executed at memory location 409DH.
03C9H
LD A,0DH
Set Register A to 0DH (ASCII carriage return).
03CBH
RST 10H
Send Register A to cassette or screen via RST 10 call.
03CCH
LD DE,01C0H
Set DE to 01C0H, pointer to "BREAK AT" message in ROM.
03CFH
GOSUB to 094FH to display the message pointed to by DE, returning once 00H found; message followed by line number.
03D2H
LD HL,(409FH)
Fetch current execution line pointer from 409FH into HL.
03D5H
LD (4097H),HL
Store HL into 4097H, which points to current line address.
03D8H
LD E,(HL)
Load byte pointed by HL into Register E.
03DAH
LD D,(HL)
Load byte pointed by HL into Register D.
03DBH
LD HL,0000H
Set HL to 0000H.
03DEH
LD (409FH),HL
Store 0000 into 409FH, resetting pointer to current line.
03E1H
EX DE,HL
Exchange HL and DE registers.
At this point HL contains the line number to display.
03E2H
GOSUB to 096DH to display the decimal contents of HL.
03E5H
LD A,0DH
Set Register A to 0DH (carriage return).
03E7H
RST 10H
Send Register A to cassette or screen via RST 10.
03E8H
Jump to the middle of the READY COMMAND LINE LOOP at 01DEH.
03EBH - Entry point for the "CONT" command.
03EBH
CONT takes no parameters; calls 08C5H to check for carriage return. Otherwise shows "WHAT" error.
03EEH
LD HL,(409DH)
Set HL to the parse pointer saved when STOP command was executed (409DH).
03F1H
03F2H
LD A,H
OR L
Z80 cannot directly test HL zero; common trick sets A = H OR L; Z flag set if both zero.
03F3H
If Z flag set, no address to continue; jump to READY routine at 01C9H.
03F5H
EX DE,HL
Exchange HL and DE.
03F6H
LD HL,(4097H)
Restore current execution line from 4097H into HL.
03F9H
LD (409FH),HL
Store current execution line into 409FH.
03FCH
GOSUB to 08B3H to check next character for ":"; if yes checks for carriage return, else jump to execute next line.
03FFH
Jump to code that checks for BREAK and processes reserved words.
0401H - Entry point for the "LIST" command.
0401H
Check for a line number parameter by parsing integer into HL.
0404H
Find line in RAM matching HL while preserving DE.
0407H
LD C,0CH
Set Register C to 0CH (12) for line display loop.
0409H
If C flag set, no line found; jump to 042DH to READY loop.
040BH
DEC C
Decrement Register C.
040CH
If Z flag set, jump to 0418H.
040EH
PUSH BC
Preserve BC on stack.
040FH
Display line number pointed to by DE.
0412H
POP BC
Restore BC from stack.
0413H
Find next line in RAM matching HL.
0418H - Continuation of LIST command after 12 lines displayed.
0418H
Display line number pointed to by DE.
041BH
Find line in RAM matching HL.
041EH
If C flag set, jump to 042DH (READY loop).
0420H
Fetch a keystroke (non-blocking) from keyboard.
0423H
If no key found (Z flag), loop back to 0420H and keep polling.
0425H
CP 1BH
Compare Register A to 1BH (ASCII escape). Z flag set if equal.
0427H
If escape detected (Z flag), jump back to 0418H to redisplay LIST line and wait for key.
0429H
CP 0DH
Compare Register A to 0DH (carriage return). NZ flag set if not equal.
042BH
If key other than carriage return pressed, loop back to 0420H.
042DH
If carriage return received (STOP LISTING), jump to middle of READY loop at 03E8H.
042FH - Entry point for the PRINT command.
042FH
RST 08H
23H
09H
Check for a "#" via RST 08H with parameters 23H and offset 09H. Moves to next non-space character and checks if it is "#". If no match, jump 9 instructions past current.
0432H
LD HL,40ACH
Set HL to 40ACH, buffer for command input and cassette output.
0435H
LD (4099H),HL
Store HL into printer buffer address at 4099H.
0438H
Turn on cassette motor.
043BH - If PRINT was not followed by a #, jump here.
043BH
Check for a ":" via RST 08H with parameters 3AH and offset 05H. Moves to next non-space char and checks. If no match, jump to 0443H.
043EH
CALL 000EH
Display carriage return.
0441H
Jump to continue EXECUTE NEXT LINE routine.
0443H - If PRINT was not followed by a :, jump here.
0443H
RST 08H
0DH
06H
Check for carriage return via RST 08H with parameters 0DH and offset 06H. If no match, jump to 044CH.
0446H
CALL 000EH
Display carriage return.
0449H
Jump to top of EXECUTE NEXT LINE routine.
044CH - If PRINT was not followed by a carriage return, jump here.
044CH
LD HL,0319H
Set Register Pair HL equal 0319H, in the middle of the RESERVED WORD LOOKUP/VECTOR TABLE.
044FH
Jump to 0343H to look for keyword matches starting at 0319H (e.g., TAB, AT, A$, B$ ...).
0452H - If PRINT had a QUOTE, jump here.
0452H
Display quoted expression pointed to by DE; jump to command line parse if carriage return found, else jump to return address + 2 bytes.
0455H
Jump to concluding code of PRINT AT routine.
0457H - If PRINT expression did not end with carriage return, jump here.
0457H
Jump to process the display of a COMMA or TAB STOP if needed.
0459H - Entry point for the PRINT A$ command.
0459H
LD HL,4070H
Set Register Pair HL to 4070H, which holds variable A$.
045CH
Jump to 0461H to print variable pointed by HL.
045EH - Entry point for the PRINT B$ command.
045EH
LD HL,4080H
Set Register Pair HL to 4080H, which holds variable B$.
Routine to print a string variable.
0461H
GOSUB to 04B9H to display the contents of a string variable pointed to by Register Pair HL until either 00H is reached OR 16 bytes have been displayed.
0464H
Check for a
, by calling to RST 08H with parameters of 2CH and an offset of 26H. 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. 0467H) + 26H instructions (which would be
0467H).
If we are here, then we got a comma, so we need to handle the display of a TAB.
0467H
LD A,(4068H)
Copy the CURSOR POSITION (held in 4068H) into Register A.
046AH
AND 0FH
MASK the value of Register A against 0FH (0000 1111). This has the effect of turning off bits 7, 6, 5, 4, leaving A to be 00H-0FH only.
046CH
If that is a 0, then we are already at a TAB STOP, so JUMP to 0490H.
046EH
LD A,20H
Otherwise, let Register A equal 20H (ASCII: SPACE).
0470H
RST 10H
Send the character held in Register A (i.e., ASCII: SPACE) to the cassette or screen via a RST 10 call.
0471H
LOOP BACK to 0467H until we are at a "0" location (a tab stop).
Entry point for the PRINT AT Command.
0473H
Determine the location on the screen being asked for via a GOSUB to 0807H to calculate an integer expression with the results into Register Pair HL.
0476H
LD BC,(4068H)
Fetch the cursor position on screen (held in memory location 4068H) and store it into Register Pair BC.
047AH
LD A,20H
LD A," "
Let Register A equal 20H (ASCII: SPACE).
047CH
LD (BC),A
Erase the cursor by putting the SPACE held in Register A onto the cursor position.
047DH
LD A,H
Copy the contents of Register H (from the integer) into Register A.
047EH
OR FCH
1111 1100
OR Register A against FCH (1111 1100). This has the effect of turning on bits 7-3, leaving the only possible values to be 252-255.
0480H
AND 3FH
AND 0011 1111
MASK the value of Register A against 3FH (0011 1111). This has the effect of turning off bits 7 and 6, leaving the only possible values to be 63 and lower, which are the number of columns on a TRS-80 screen.
0482H
LD H,A
Copy the modified contents of Register A into Register H.
0483H
LD (HL),5FH
LD (HL),"_ "
Store the value 5FH (ASCII: _) onto the screen at the pointed to by Register Pair HL.
0485H
LD (4068H),HL
Store the value held in Register Pair HL into memory location 4068H (which holds the cursor position on screen).
0488H
RST 08H
2CH
02H
Check for a "," by calling 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. 048BH) + 02H instructions (which would be 048DH).
If a , is found, then we are here.
048BH
JUMP to 0490H to GOSUB to 08B3H to check if the next character is a ":" and if yes, JUMP to 08BAH to check for a ENTER and if not then jump to the MIDDLE of the EXECUTE NEXT LINE routine.
Middle of the PRINT AT Routine.
048DH
Check for a "
;" by calling to RST 08H with parameters of 3BH and an offset of 05H. 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. 0490H) + 05H instructions (which would be
0495H).
If a ; is found, then we are here.
0490H
GOSUB to 08B3H to check if the next character is a ":" and if yes, JUMP to 08BAH to check for a ENTER and if not then jump to the MIDDLE of the EXECUTE NEXT LINE routine.
0493H
JUMP to 044CH to look for keyword matches but starting with the keywords at 0319H (i.e., TAB, AT, A$, B$ ...).
Middle of the PRINT AT Routine where a ";" was not found, so process the end of the line
0495H
GOSUB to 000EH to display a CARRIAGE RETURN since we are not trying to continue displaying characters on that line.
0498H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
0499H
RST 18H
RST 18 to parse an expression (and an optional expression, if any).
049AH
GOSUB to 0970H to display the contents of Register Pair HL as a decimal number.
049DH
JUMP to 0464H to process the display of a COMMA or TAB STOP if needed.
Entry point for the PRINT TAB Command.
049FH
GOSUB to 0814H to verify that an integer is within parenthesis, and calculate the integer expression with the result in Register Pair HL.
04A2H
LD A,L
We only care about the 8 bit value of Register L, so copy the contents of Register L into Register A.
04A3H
AND 3FH
AND 0011 1111
MASK the value of Register A against 3FH (Decimal: 63) to set the possible values to be between 0 and 63, which are the possible column numbers for a Model I screen. This is the column we want to go to.
04A5H
LD L,A
Copy the masked contents back into Register L.
04A6H
LD A,(4068H)
Fetch the cursor position on screen (held in memory location 4068H) and store it into Register A.
04A9H
AND 3FH
AND 0011 1111
MASK the value of Register A against 3FH (Decimal: 63) to set the possible values to be between 0 and 63, which are the possible column numbers for a Model I screen. This is the column that the cursor is currently in.
04ABH
CP L
Compare the current column on the screen line (held in Register A) against the column held in Register L. Results:
- If Register A equals the value held in Register L, the Z FLAG is set.
- If Register A < Register L, the CARRY FLAG will be set.
- if Register A > Register L, the NO CARRY FLAG will be set.
04ACH
If the Z FLAG (Zero) has been set, then the GOAL column is the same as the CURRENT column, so we will do nothing here and JUMP to 0488H to keep processing whatever else might be on the PRINT TAB line.
04AEH
If the NC FLAG (No Carry) has been set, then the GOAL column is PAST the CURRENT column, so we will do nothing here and JUMP to 0488H to keep processing whatever else might be on the PRINT TAB line.
If we are here, then we are not yet on screen where we want to be, so we need to space over until we get there.
04B0H
LD A,20H
Let Register A equal 20H (ASCII: SPACE).
04B2H
RST 10H
Send the character held in Register A (i.e., SPACE) to the screen via a RST 10 call.
04B3H
Loop back to 04A6H to check to see if we have hit the GOAL column yet. This is a far more time consuming way to do this than if the number of spaces had just been calculated and filled.
Entry point for the CLS Command.
04B5H
LD A,0CH
Let Register A equal 0CH (ASCII: FORM FEED. This will act as a clear screen command.
04B7H
RST 10H
Send the character held in Register A (i.e., 0CH) to the cassette or screen via a RST 10 call.
04B8H
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
Subroutine to display the contents of a string variable pointed to by Register Pair HL until either a 00H is reached OR 16 bytes have been displayed.
04B9H
LD A,(HL)
Fetch the value held in the memory location pointed to by Register Pair (HL) and store it into Register A.
04BAH
INC HL
INCrement Register Pair HL by 1 to point to the next character in the string.
04BBH
AND A
Test to see if the character there is empty. 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).
04BCH
RET Z
If the Z FLAG (Zero) has been set, then we have a 00H delimiter, so we are done! RETurn to the caller.
04BDH
RST 10H
Send the character held in Register A to the cassette or screen via a RST 10 call.
04BEH
LD A,L
Copy the contents of the LSB of string pointer (held in Register L) into Register A.
04BFH
AND 0FH
AND 0000 1111
MASK the LSB against 0FH (0000 1111). This has the effect of turning off bits 7, 6, 5, 4, leaving a value 15 or lower.
04C1H
RET Z
If the Z FLAG (Zero) has been set, RETurn to the caller.
04C2H
Get the next character by LOOPing back to the top of the routine at 04B9H.
Entry point for the GOSUB Command.
04C4H
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).
04C7H
Fetch the line number associated with the GOSUB command by GOSUBing 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.
04CAH
PUSH DE
Save the contents of Register Pair DE to the top of the stack because the next instruction will reset DE.
04CBH
GOSUB to 092AH to find the line in RAM which matches the line number pointed to by Register Pair HL. Note: A jump to 092AH resets DE. To do the routine while preserving DE, jump instead to 092DH.
04CEH
If the number after the GOSUB command does not correspond to a line number in RAM the NZ FLAG (Not Zero) will have been set, so JUMP to 01A3H to display the "HOW?" error.
04D1H
LD HL,(409FH)
Fetch the pointer to the current line being executed (held in memory location 409FH) and store it into Register Pair HL. This would be the RETURN point.
04D4H
PUSH HL
Save the line number to RETURN to (held in Register Pair HL) to the top of the stack.
04D5H
LD HL,(40A3H)
Fetch the line number location to return to from the saved stack pointer (held in memory location 40A3H) and store it into Register Pair HL.
04D8H
PUSH HL
Save the saved BASIC stack pointer (held in Register Pair HL) to the top of the stack.
04D9H
LD HL,0000H
Let Register Pair HL equal 0000H.
04DCH
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).
04DFH
ADD HL,SP
Put the stack pointer into HL via a LET Register Pair HL = Register Pair HL + Register SP.
04E0H
LD (40A3H),HL
Store the return to line location into 40A3H (which is the saved stack pointer).
04E3H
JUMP to 039CH to execute the BASIC instructions at the RAM location pointed to by Register Pair DE.
Entry point for the RETURN Command.
04E6H
GOSUB to 08C5H which will check the next character on the instruction line (pointed to by DE) for a CARRIAGE RETURN. If that's what it finds, it returns here. If it finds anything else (meaning, an unwanted character), it will display the "WHAT" error message.
04E9H
LD HL,(40A3H)
Fetch the saved return to line num location / BASIC stack pointer (held in memory location 40A3H) and store it into Register Pair HL.
04ECH
LD A,H
Copy the contents of Register H into Register A, as part of testing Register Pair HL for zero.
04EDH
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.
04EEH
If the BASIC stack pointer is 0000H, then the RETURN TO LINE number was 0000 which is a bad thing, the Z FLAG (Zero) will have been set, so JUMP to 08C9H to display the "WHAT" error.
04F1H
LD SP,HL
Copy the contents of Register Pair HL into Register Pair SP so that the system's stack pointer now points to the BASIC stack pointer.
04F2H
POP HL
Put the value held at the top of the STACK into Register Pair HL.
04F3H
LD (40A3H),HL
Store the value held in Register Pair HL into memory location 40A3H (which is the saved stack pointer).
04F6H
POP HL
Put the value held at the top of the STACK into Register Pair HL.
04F7H
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).
04FAH
POP DE
Put the value held at the top of the STACK into Register Pair DE.
04FBH
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.
Entry point for the ON Command.
04FEH
GOSUB to 080BH to calculate a non-negative integer into Register Pair HL.
0501H
LD A,H
Copy the contents of Register H into Register A, as part of testing Register Pair HL for zero.
0502H
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.
0503H
If HL was zero then the Z FLAG (Zero) will have been set, so JUMP to 050BH.
0505H
PUSH HL
Save the non-negative integer expression held Register Pair HL to the top of the stack.
0506H
LD HL,02DFH
Let Register Pair HL equal 02DFH, which will be the location in ROM where the command lookup table is, starting with the PRINT command.
0509H
JUMP to 0552H which JUMPs to 0343H in the READY COMMAND LOOP to try to match reserved words, starting with the PRINT command.
Part of the ON Command; jumped here if the index passed to ON was a ZERO.
050BH
GOSUB to 053CH to read (and discard) characters on the BASIC line until we hit a ENTER or a :
050EH
RST 30H
RST 30H will clear the RETurn address from the stack, and continue processing the current instruction line.
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: ENTER). If Register A equals ENTER, the Z FLAG is set; otherwise the NZ FLAG is set.
052CH
If the character is a ENTER, 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 ENTER) as if the index passed was zero.
052EH
CP 3AH
If we are here, then we got either the ENTER 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 ENTER 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: ENTER). Results: If Register A equals ENTER, the Z FLAG is set; otherwise the NZ FLAG is set.
0542H
RET Z
If the character was a ENTER, 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 ENTER) 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: ENTER). Results: If Register A equals ENTER, the Z FLAG is set; otherwise, the NZ FLAG is set.
065BH
If the character at the BASIC line being processed is a ENTER, 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 ENTER.
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: ENTER). 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
SLA A
Shift Register A Left Arithmetically one bit position (bit 7 moves to CARRY, 0 fills bit 0).
06ACH
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:
ENTER). 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 ENTER.
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 ENTER.
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: ENTER). Results: If Register A equals ENTER, the Z FLAG is set; otherwise the NZ FLAG is set.
074FH
If the ENTER 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.
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.
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.
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).
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 ENTER and if not then jump to the MIDDLE of the EXECUTE NEXT LINE routine.
08B3H
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 ENTER and if YES, keep processing the next line and if NO then RETurn.
08BAH
RST 08H
0DH
04H
Check for a ENTER 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 ENTER). 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 ENTER 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: ENTER). Results: If Register A equals ENTER, 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
LD A,D
Copy the contents of Register D into Register A, as part of testing Register Pair DE for zero.
08D5H
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: ENTER). Results: If Register A equals ENTER, the Z FLAG is set; otherwise the NZ FLAG is set.
0907H
If the keystroke was a ENTER, then the Z FLAG will have been set, so JUMP to 0915H to add that ENTER 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: ENTER). Results: If Register A equals ENTER, the Z FLAG is set; otherwise the NZ FLAG is set.
0919H
RET Z
If the character is a ENTER, 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 ENTER, 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: ENTER). Results: If Register A DOES NOT equal ENTER, the NZ FLAG is set.
094AH
If the current character in RAM, pointed to by DE, is not a ENTER, 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: ENTER). Results: If Register A equals ENTER, 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: ENTER). Results: If Register A equals ENTER, 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 ENTER, 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.
0970H
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.