5200H - The Error Codes
Data: TBASIC's table of two letter error codes, two bytes for each offset after the mapping at 5259H: 00H-2EH the ROM's 23 codes (NF to L3, in the ROM's order) and UF, Undefined user function; 30H-56H the codes of the disk error offsets 64H-8AH (error codes 51-70). It takes the place of the ROM's table at 18C9H, which has no codes for the disk errors. The error codes 57, 60 and 61, which no error of TBASIC gives, show UE. The texts named in each row are those of ERROR/OVL and of the manual's table.
5200-5201
DEFM "NF" 4E 46
The code NF of the offset 00H, error code 1: NEXT without FOR, as in the ROM's table.
5202-5203
DEFM "SN" 53 4E
The code SN of the offset 02H, error code 2: Syntax error, as in the ROM's table.
5204-5205
DEFM "RG" 52 47
The code RG of the offset 04H, error code 3: RETURN without GOSUB, as in the ROM's table.
5206-5207
DEFM "OD" 4F 44
The code OD of the offset 06H, error code 4: Out of DATA, as in the ROM's table.
5208-5209
DEFM "FC" 46 43
The code FC of the offset 08H, error code 5: Illegal function call, as in the ROM's table.
520A-520B
DEFM "OV" 4F 56
The code OV of the offset 0AH, error code 6: Overflow, as in the ROM's table.
520C-520D
DEFM "OM" 4F 4D
The code OM of the offset 0CH, error code 7: Out of memory, as in the ROM's table.
520E-520F
DEFM "UL" 55 4C
The code UL of the offset 0EH, error code 8: Undefined line number, as in the ROM's table.
5210-5211
DEFM "BS" 42 53
The code BS of the offset 10H, error code 9: Subscript out of range, as in the ROM's table.
5212-5213
DEFM "DD" 44 44
The code DD of the offset 12H, error code 10: Redimensioned array, as in the ROM's table.
5214-5215
DEFM "/0" 2F 30
The code /0 of the offset 14H, error code 11: Division by zero, as in the ROM's table.
5216-5217
DEFM "ID" 49 44
The code ID of the offset 16H, error code 12: Illegal direct, as in the ROM's table.
5218-5219
DEFM "TM" 54 4D
The code TM of the offset 18H, error code 13: Type mismatch, as in the ROM's table.
521A-521B
DEFM "OS" 4F 53
The code OS of the offset 1AH, error code 14: Out of string space, as in the ROM's table.
521C-521D
DEFM "LS" 4C 53
The code LS of the offset 1CH, error code 15: String too long, as in the ROM's table.
521E-521F
DEFM "ST" 53 54
The code ST of the offset 1EH, error code 16: String formula too complex, as in the ROM's table.
5220-5221
DEFM "CN" 43 4E
The code CN of the offset 20H, error code 17: Can't continue, as in the ROM's table.
5222-5223
DEFM "NR" 4E 52
The code NR of the offset 22H, error code 18: No RESUME, as in the ROM's table.
5224-5225
DEFM "RW" 52 57
The code RW of the offset 24H, error code 19: RESUME without error, as in the ROM's table.
5226-5227
DEFM "UE" 55 45
The code UE of the offset 26H, error code 20: Unprintable error, as in the ROM's table.
5228-5229
DEFM "MO" 4D 4F
The code MO of the offset 28H, error code 21: Missing operand, as in the ROM's table.
522A-522B
DEFM "FD" 46 44
The code FD of the offset 2AH, error code 22: Bad file data, as in the ROM's table.
522C-522D
DEFM "L3" 4C 33
The code L3 of the offset 2CH, error code 23: DISK BASIC feature, as in the ROM's table.
522E-522F
DEFM "UF" 55 46
The code UF of the offset 2EH, error code 24: Undefined user function.
5230-5231
DEFM "FO" 46 4F
The code FO of the offset 64H, error code 51: FIELD overflow.
5232-5233
DEFM "IE" 49 45
The code IE of the offset 66H, error code 52: Internal error.
5234-5235
DEFM "BN" 42 4E
The code BN of the offset 68H, error code 53: Bad file number.
5236-5237
DEFM "FF" 46 46
The code FF of the offset 6AH, error code 54: File not found.
5238-5239
DEFM "BM" 42 4D
The code BM of the offset 6CH, error code 55: Bad file mode.
523A-523B
DEFM "AO" 41 4F
The code AO of the offset 6EH, error code 56: File already open.
523C-523D
DEFM "UE" 55 45
The code UE (as for Unprintable error) of the offset 70H, error code 57, which no error of TBASIC gives.
523E-523F
DEFM "IO" 49 4F
The code IO of the offset 72H, error code 58: Disk I/O error.
5240-5241
DEFM "FE" 46 45
The code FE of the offset 74H, error code 59: File already exists.
5242-5243
DEFM "UE" 55 45
The code UE (as for Unprintable error) of the offset 76H, error code 60, which no error of TBASIC gives.
5244-5245
DEFM "UE" 55 45
The code UE (as for Unprintable error) of the offset 78H, error code 61, which no error of TBASIC gives.
5246-5247
DEFM "DF" 44 46
The code DF of the offset 7AH, error code 62: Disk full.
5248-5249
DEFM "EF" 45 46
The code EF of the offset 7CH, error code 63: Input past end.
524A-524B
DEFM "RN" 52 4E
The code RN of the offset 7EH, error code 64: Bad record number.
524C-524D
DEFM "NM" 4E 4D
The code NM of the offset 80H, error code 65: Bad file name.
524E-524F
DEFM "MM" 4D 4D
The code MM of the offset 82H, error code 66: Mode-mismatch.
5250-5251
DEFM "DS" 44 53
The code DS of the offset 84H, error code 67: Direct statement in file.
5252-5253
DEFM "FL" 46 4C
The code FL of the offset 86H, error code 68: Too many files.
5254-5255
DEFM "WP" 57 50
The code WP of the offset 88H, error code 69: Disk write protected.
5256-5257
DEFM "AD" 41 44
The code AD of the offset 8AH, error code 70: File access DENIED.
5258H - The Error Hook
Link 41A6H (the jump at 58AEH), called by the ROM's error routine at 19ECH with Register E = the offset of the error, once no ON ERROR GOTO handler has taken it. TBASIC has no long messages: ERROR/OVL would load at 5200H, over TBASIC itself. It shows a question mark and the two letter code of its own table at 5200H, which also has codes for the disk errors, and the ROM's text Error. During the start-up (line FFFEH) it goes back to the DOS; otherwise it lets 601DH wipe a run only program and goes on in the ROM's error display at 1A11H: in and the line number unless in direct mode, then READY.
5258
POP HL E1
Discard the top of the stack into Register Pair HL: the return address 19EFH of the ROM's CALL 41A6H, so that the ROM's own display, whose table has no disk errors, is not used.
5259
LD A,E 7B
Load Register A with Register E, the offset of the error (00H, 02H, 04H and so on, the ERR value), as the ROM's error routine passes it.
525A
CP 8BH FE 8B
Compare Register A against 8BH: the NC FLAG for an offset of 8BH or more, beyond 8AH, the last disk error (File access DENIED).
525C
If the NC FLAG is set (no code for the offset), JUMP to 5266H to show UE, the code of Unprintable error.
525E
CP 63H FE 63
Compare Register A against 63H: the NC FLAG for the offsets 63H-8AH, the disk errors of TBASIC (64H FIELD overflow on).
5260
If the NC FLAG is set (a disk error), JUMP to 5268H to subtract 34H: the disk codes follow the first 24 codes in the table.
5262
CP 2FH FE 2F
Compare Register A against 2FH: the C FLAG for the offsets 00H-2EH, the 23 errors of the ROM and 2EH, Undefined user function.
5264
If the C FLAG is set (00H-2EH), JUMP to 526AH with the offset unchanged: these codes are in the order of the offsets.
5266
LD A,5AH 3E 5A
Load Register A with 5AH, which the SUB 34H below turns into 26H, the offset of UE: for the offsets 2FH-62H and 8BH-FFH.
5268
SUB 34H D6 34
SUBtract 34H from Register A: a disk error offset 64H-8AH becomes 30H-56H, its place in the table after the 24 codes of 00H-2EH.
526A
LD E,A 5F
Load Register E with Register A, the offset of the code in the table (00H-56H, two bytes for each code).
526B
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the offset of the code in the table.
526D
LD HL,5200H 21 00 52
Point Register Pair HL to 5200H, TBASIC's table of the two letter error codes.
5270
LD A,3FH 3E 3F
Load Register A with 3FH, the question mark shown before the code, as the ROM shows it.
5272
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device: the question mark.
5275
ADD HL,DE 19
ADD Register Pair DE, the offset, to Register Pair HL: Register Pair HL = the code of the error in the table.
5276
LD A,(HL) 7E
Load Register A with the first letter of the code at Register Pair HL.
5277
GOSUB to 032AH, the ROM's output of the character in Register A: the first letter of the code.
527A
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the second character of the code (no code has a space there), as the ROM does at 19FAH.
527B
GOSUB to 032AH, the ROM's output of the character in Register A: the second character of the code.
527E
LD HL,191DH 21 1D 19
Point Register Pair HL to 191DH, the ROM's text Error after a space, ended by 00H, which the ROM's own display uses.
5281
GOSUB to 28A7H, the ROM's output of the text at Register Pair HL up to its 00H: the word Error.
5284
LD HL,(40A2H) 2A A2 40
Load Register Pair HL with the current line number from 40A2H-40A3H: FFFFH in direct mode, FFFEH during the start-up of TBASIC.
5287
LD DE,FFFEH 11 FE FF
Load Register Pair DE with FFFEH, the line number that TBASIC's start-up copies from the ROM's table (1919H) to 40A2H.
528A
RST 18H DF
RST 18H: compare Register Pair HL, the line number, with Register Pair DE (FFFEH): the Z FLAG when they are equal.
528B
If the NZ FLAG is set (not the start-up), JUMP to 5293H.
528D
GOSUB to 20FEH, the ROM's output of a carriage return, to end the line of the error code.
5290
JUMP to 402DH, EXIT@, back to the DOS: an error before any program line ran (such as a program named after TBASIC that cannot be loaded) ends TBASIC. The ROM goes to 0674H here.
5293
GOSUB to 601DH to wipe a program loaded with access level 6 or 7, which then shows RUN access only and goes to READY without coming back.
5296
JP 1A11H C3 11 1A
JUMP to 1A11H, the ROM's error display after its message, with Register Pair HL = the line number: in and the number unless it is FFFFH, then READY.
5299H - CMD
Link 4173H, the statement CMD, with Register Pair HL at the text after it and the Z FLAG at the end of the statement. CMD alone goes back to the DOS through EXIT@. Otherwise the expression must be a string whose first character, upper or lower case, is the option: D (DEBUG@), E (the last DOS error with ERROR@), T (interrupts off), R (interrupts on) or S (the DOS, as CMD alone); any other character, and an empty string, is Illegal function call. Unlike BASIC/CMD, TBASIC runs no DOS command from CMD: it lives at 5200H-61B7H, where a library command would load its overlay over it.
5299
If the Z FLAG is set (CMD alone), JUMP to 402DH, EXIT@, back to the DOS.
529C
GOSUB to 2337H, the ROM's expression evaluator, for the string after CMD at Register Pair HL.
529F
PUSH HL E5
Save Register Pair HL, the text pointer after the expression, to the top of the stack.
52A0
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns the descriptor.
52A3
LD C,(HL) 4E
Load Register C with the length of the string from the descriptor at Register Pair HL.
52A4
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
52A5
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
52A6
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
52A7
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the string.
52A8
LD A,C 79
Load Register A with Register C, the length of the string.
52A9
OR A B7
OR Register A against itself: the Z FLAG for an empty string.
52AA
If the Z FLAG is set (an empty string), JUMP to 1E4AH, the ROM's Illegal function call error.
52AD
LD A,(DE) 1A
Load Register A with the character of the option at Register Pair DE.
52AE
RES 5,A CB AF
RESET bit 5 of Register A, which makes a lower case letter upper case.
52B0
CP 44H FE 44
Compare Register A against 44H, the letter D: enter the DOS's debugger.
52B2
If the Z FLAG is set (D), JUMP to 52E3H to enter the debugger.
52B4
CP 45H FE 45
Compare Register A against 45H, the letter E: show the last DOS error.
52B6
If the Z FLAG is set (E), JUMP to 52D9H to show the last DOS error.
52B8
CP 54H FE 54
Compare Register A against 54H, the letter T: the interrupts off.
52BA
If the Z FLAG is set (T), JUMP to 52D1H to turn the interrupts off.
52BC
CP 52H FE 52
Compare Register A against 52H, the letter R: the interrupts on.
52BE
If the Z FLAG is set (R), JUMP to 52CEH to turn the interrupts on.
52C0
CP 53H FE 53
Compare Register A against 53H, the letter S: back to the DOS, as CMD alone.
52C2
If the Z FLAG is set (S), JUMP to 402DH, EXIT@, back to the DOS.
52C5
JUMP to 1E4AH, the ROM's Illegal function call error: TBASIC's CMD takes no other option and no DOS command.
52C8H - Back to READY
The vector at 4203H-4205H (set at 5740H) and SYSTEM's BREAK (56B6H) come here. The ROM's 19AEH resets the stack and the BASIC pointers and goes on at 1A18H, which falls into READY. TBASIC does not point ABORT@ here: it runs no DOS commands.
52C8
LD BC,1A18H 01 18 1A
Load Register Pair BC with 1A18H, where the ROM's 19AEH goes on: the POP BC before the ROM's READY at 1A19H.
52CB
JUMP to 19AEH, the ROM's routine that resets the stack and continues at Register Pair BC.
52CE
LD A,C3H 3E C3
CMD"R": load Register A with C3H, the opcode JP, for the interrupt vector at 4012H.
52D0
LD BC,C93EH 01 3E C9
52D1H (CMD"T") enters inside this LD BC,C93EH: its bytes 3EH C9H read as LD A,C9H, the opcode RET; from above it only loads Register Pair BC.
52D3
LD (4012H),A 32 12 40
Store Register A to 4012H, the opcode of the RST 38H vector: C3H (JP) lets the interrupts be served; C9H (RET) returns from the first one without EI, so they stay off.
52D6
POP HL E1
Restore Register Pair HL, the text pointer after the expression, from the top of the stack.
52D7
EI FB
Enable the interrupts (EI), so that CMD"R" turns them on again at once.
52D8
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
52D9
LD A,(570AH) 3A 0A 57
Load Register A with the last DOS error code from 570AH, kept by the error mapping at 607CH.
52DC
OR C0H F6 C0
OR Register A with C0H: bit 7 return to the caller, bit 6 no frame around the message.
52DE
GOSUB to 4409H, ERROR@, to show the DOS's message for the error code in Register A.
52E1
POP HL E1
Restore Register Pair HL, the text pointer after the expression, from the top of the stack.
52E2
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
52E3
GOSUB to 440DH, DEBUG@, to enter the DOS's debugger, which returns here when it ends.
52E6
POP HL E1
Restore Register Pair HL, the text pointer after the expression, from the top of the stack.
52E7
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text, after DEBUG@ has ended.
52E8H - TIME$
Link 4176H, the function TIME$: a new string of 17 characters, the date MM/DD/YY from GTDATE@, a space, and the time HH:MM:SS from GTTIME@.
52E8
RST 10H D7
RST 10H: increment Register Pair HL past the token of TIME$ and load Register A with the next character.
52E9
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack for the end of the function.
52EA
LD A,11H 3E 11
Load Register A with 11H, the length of the new string: 17 characters.
52EC
GOSUB to 2857H, the ROM's STRINI, to make room for a string of Register A characters and build its descriptor at 40D3H.
52EF
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the address of the new string from 40D4H-40D5H, the descriptor's address bytes.
52F2
GOSUB to 4470H, GTDATE@, which writes the date MM/DD/YY at Register Pair HL and leaves Register Pair HL after it.
52F5
LD (HL),20H 36 20
Store 20H, a space, at Register Pair HL between the date and the time.
52F7
INC HL 23
INCrement Register Pair HL by 1, to the place of the time in the new string.
52F8
GOSUB to 446DH, GTTIME@, which writes the time HH:MM:SS at Register Pair HL.
52FB
JUMP to 2884H, the ROM's PUTNEW, which makes the new string the result and returns to the expression evaluator.
52FEH - DEF
Link 415BH, the statement DEF, with Register A = the token after it. DEFUSRn=address (C1H, the token of USR) stores the address into the table 5330H. DEF FN stores the address of the definition's text into the value of the function's entry, a variable whose name has bit 7 set; a definition is allowed only in a program line (the ROM's 2828H), and its parameter list is only checked here, then the rest of the line is passed over as DATA is.
52FE
CP C1H FE C1
Compare Register A, the token after DEF, against C1H, the token of USR.
5300
If the Z FLAG is set (DEFUSR), JUMP to 5321H.
5302
GOSUB to 536DH to check the token of FN and find the function's entry: Register Pair DE returns the address of its value.
5305
GOSUB to 2828H, the ROM's test of the direct mode, which gives Illegal direct when DEF FN is not in a program line.
5308
LD A,L 7D
Load Register A with Register L, the low byte of the text pointer: the definition's parameters or its =.
5309
LD (DE),A 12
Store Register A to the function's value at Register Pair DE, the low byte of the definition's address.
530A
INC DE 13
INCrement Register Pair DE by 1, to the high byte of the function's value.
530B
LD A,H 7C
Load Register A with Register H, the high byte of the text pointer.
530C
LD (DE),A 12
Store Register A to the function's value at Register Pair DE, the high byte of the definition's address.
530D
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, after the function's name.
530E
CP 28H FE 28
Compare Register A against 28H, the ( of a parameter list.
5310
If the NZ FLAG is set (no parameters), JUMP to 1F05H, the ROM's DATA, which passes over the rest of the statement.
5313
RST 10H D7
RST 10H: increment Register Pair HL past the ( and load Register A with the next character.
5314
GOSUB to 260DH, the ROM's variable search, to check the name of a parameter at Register Pair HL.
5317
LD A,(HL) 7E
Load Register A with the character at Register Pair HL after the parameter.
5318
CP 29H FE 29
Compare Register A against 29H, the ) that ends the parameter list.
531A
If the Z FLAG is set (the end of the list), JUMP to 1F05H, the ROM's DATA, which passes over the rest of the statement.
531D
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma between parameters, or the ROM shows a Syntax error.
531F
LOOP back to 5314H for the next parameter of the definition.
5321
GOSUB to 545EH to take the digit after USR: Register Pair DE returns the address of its entry in the table 5330H.
5324
PUSH DE D5
Save Register Pair DE, the table entry, to the top of the stack.
5325
RST 08H => D5H CF D5
RST 08H: the next character of the text at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
5327
GOSUB to 2B02H, the ROM's routine that evaluates the expression at Register Pair HL as an integer into Register Pair DE.
532A
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the table entry, the text pointer is saved.
532B
LD (HL),E 73
Store Register E, the low byte of the routine's address, at Register Pair HL in the table.
532C
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the table entry.
532D
LD (HL),D 72
Store Register D, the high byte of the routine's address, at Register Pair HL in the table.
532E
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
532F
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
5330H - The USR Table
Data: the addresses of USR0-USR9, set by DEFUSRn. Each starts as 1E4AH, the ROM's Illegal function call error, so a USR that was not defined gives that error.
5330-5331
DEFW 1E4AH 4A 1E
USR0 and USR without a digit: 1E4AH, Illegal function call, until DEFUSR0 sets it.
5332-5333
DEFW 1E4AH 4A 1E
USR1: 1E4AH, Illegal function call, until DEFUSR1 sets it.
5334-5335
DEFW 1E4AH 4A 1E
USR2: 1E4AH, Illegal function call, until DEFUSR2 sets it.
5336-5337
DEFW 1E4AH 4A 1E
USR3: 1E4AH, Illegal function call, until DEFUSR3 sets it.
5338-5339
DEFW 1E4AH 4A 1E
USR4: 1E4AH, Illegal function call, until DEFUSR4 sets it.
533A-533B
DEFW 1E4AH 4A 1E
USR5: 1E4AH, Illegal function call, until DEFUSR5 sets it.
533C-533D
DEFW 1E4AH 4A 1E
USR6: 1E4AH, Illegal function call, until DEFUSR6 sets it.
533E-533F
DEFW 1E4AH 4A 1E
USR7: 1E4AH, Illegal function call, until DEFUSR7 sets it.
5340-5341
DEFW 1E4AH 4A 1E
USR8: 1E4AH, Illegal function call, until DEFUSR8 sets it.
5342-5343
DEFW 1E4AH 4A 1E
USR9: 1E4AH, Illegal function call, until DEFUSR9 sets it.
5344H - Save a Parameter
Part of FN (53A9H): saves the value of a parameter variable before FN gives it the argument. Register Pair HL is the variable's value, 40AFH its type. A string's descriptor is copied into the ROM's pool of temporary strings (2888H); a number's value is pushed, one word for an integer, two for single and four for double precision. Then the variable's address and Register Pair AF (Register A = the type less 3, with its flags and the C FLAG set; 00H and the Z FLAG for a string) are pushed for the restore at 53EDH. FN always comes here with the C FLAG set, so 535FH and the jump to 2423H are not reached.
5344
LD A,(40AFH) 3A AF 40
Load Register A with the type of the parameter variable from 40AFH: 02H, 03H, 04H or 08H.
5347
SUB 03H D6 03
SUBtract 03H from Register A: FFH integer, 00H string, 01H single, 05H double precision.
5349
OR A B7
OR Register A against itself: the Z FLAG for a string, the M FLAG for an integer, the PO FLAG for single precision.
534A
SCF 37
Set the C FLAG, the mark of a parameter's saved value.
534B
If the Z FLAG is set (a string), JUMP to 53ABH.
534D
LD C,(HL) 4E
Load Register C with the low byte of the value's first word at Register Pair HL.
534E
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the first word.
534F
LD B,(HL) 46
Load Register B with the high byte of the value's first word at Register Pair HL.
5350
PUSH BC C5
Save Register Pair BC, the first word of the value, to the top of the stack.
5351
If the M FLAG is set (an integer, one word), JUMP to 536BH.
5354
INC HL 23
INCrement Register Pair HL by 1, to the second word of the value.
5355
LD C,(HL) 4E
Load Register C with the low byte of the value's second word at Register Pair HL.
5356
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the second word.
5357
LD B,(HL) 46
Load Register B with the high byte of the value's second word at Register Pair HL.
5358
PUSH BC C5
Save Register Pair BC, the second word of the value, to the top of the stack.
5359
If the PO FLAG is set (single precision, two words), JUMP to 536BH.
535C
INC HL 23
INCrement Register Pair HL by 1, to the third word of a double precision value.
535D
If the C FLAG is set (always, from FN), JUMP to 5362H.
535F
LD HL,411DH 21 1D 41
Point Register Pair HL to 411DH, the low bytes of the accumulator's double precision value (not reached from FN).
5362
LD C,(HL) 4E
Load Register C with the low byte of the third word at Register Pair HL.
5363
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the third word.
5364
LD B,(HL) 46
Load Register B with the high byte of the third word at Register Pair HL.
5365
INC HL 23
INCrement Register Pair HL by 1, to the fourth word.
5366
PUSH BC C5
Save Register Pair BC, the third word of the value, to the top of the stack.
5367
LD C,(HL) 4E
Load Register C with the low byte of the fourth word at Register Pair HL.
5368
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the fourth word.
5369
LD B,(HL) 46
Load Register B with the high byte of the fourth word at Register Pair HL.
536A
PUSH BC C5
Save Register Pair BC, the fourth word of the value, to the top of the stack.
536B
If the C FLAG is set (always, from FN), JUMP to 53B5H to save the variable's address and its type.
536DH - Find a Function
Checks the token of FN at Register Pair HL and finds the function's entry with the ROM's variable search, its name's first character with bit 7 set (so it is apart from the variable of that name) and no subscripts (40DCH = 80H): Register Pair DE returns the address of its value.
536D
RST 08H => BEH CF BE
RST 08H: the next character of the text at Register Pair HL must be BEH, the token of FN, or the ROM shows a Syntax error.
536F
LD A,80H 3E 80
Load Register A with 80H, the flag that the name may have no subscripts.
5371
LD (40DCH),A 32 DC 40
Store Register A (80H) to 40DCH, the ROM's subscript flag for its variable search.
5374
OR (HL) B6
OR Register A (80H) with the first character of the name at Register Pair HL: the character with bit 7 set.
5375
LD B,A 47
Load Register B with Register A, the first character of the function's name with bit 7 set.
5376
JUMP to 2612H, the ROM's variable search after it has taken the first character into Register B: Register Pair DE returns the value's address.
5379H - FN
Link 4155H, a call of a function defined by DEF FN. The function's entry gives the address of its definition (none: Undefined user function, 5470H). With parameters, each parameter variable's value is saved (5344H) and the arguments are assigned to them one by one (the ROM's 1F2BH, as LET); the definition's expression is evaluated, and the saved values are put back (53EDH). A string result is moved to 40D3H first, so it survives the restore. The result is converted to the function's own type (the ROM's 281AH), which returns with Register Pair HL at the text after the call.
5379
GOSUB to 536DH to check the token of FN and find the function's entry: Register Pair DE returns the address of its value.
537C
LD A,(40AFH) 3A AF 40
Load Register A with the type of the function from 40AFH, set by the variable search.
537F
OR A B7
OR Register A against itself: the NZ FLAG and the NC FLAG, the mark of the end of the saved values.
5380
PUSH AF F5
Save Register Pair AF, the function's type, to the top of the stack.
5381
LD (40F3H),HL 22 F3 40
Store Register Pair HL, the text pointer after the function's name, into 40F3H-40F4H.
5384
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the function's value, Register Pair DE = the text pointer.
5385
LD A,(HL) 7E
Load Register A with the low byte of the definition's address at Register Pair HL.
5386
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the definition's address.
5387
LD H,(HL) 66
Load Register H with the high byte of the definition's address at Register Pair HL.
5388
LD L,A 6F
Load Register L with Register A: Register Pair HL = the text of the definition after the function's name.
5389
OR H B4
OR Register A with Register H: the Z FLAG when the address is 0000H, a function never defined.
538A
If the Z FLAG is set (not defined), JUMP to 5470H, the error Undefined user function.
538D
LD A,(HL) 7E
Load Register A with the character of the definition at Register Pair HL.
538E
CP 28H FE 28
Compare Register A against 28H, the ( of the definition's parameter list.
5390
If the NZ FLAG is set (no parameters), JUMP to 53DEH.
5392
RST 10H D7
RST 10H: increment Register Pair HL past the ( and load Register A with the next character.
5393
LD (40D8H),HL 22 D8 40
Store Register Pair HL, the definition's first parameter, into 40D8H-40D9H for the assignment of the arguments.
5396
JUMP to 539AH to save the value of the first parameter variable.
5398
RST 08H => 2CH CF 2C
RST 08H: the next character of the definition at Register Pair HL must be 2CH, the comma between parameters, or the ROM shows a Syntax error.
539A
LD C,04H 0E 04
Load Register C with 04H, the room to check: eight bytes, the most a saved value needs.
539C
GOSUB to 1963H, the ROM's check that twice Register C bytes are free, else Out of memory.
539F
LD A,80H 3E 80
Load Register A with 80H, the flag that the name may have no subscripts.
53A1
LD (40DCH),A 32 DC 40
Store Register A (80H) to 40DCH, the ROM's subscript flag for its variable search.
53A4
GOSUB to 260DH, the ROM's variable search, for the parameter at Register Pair HL: Register Pair DE returns its value's address.
53A7
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the parameter's value, Register Pair DE = the definition's text.
53A8
SCF 37
Set the C FLAG for the saving of a parameter's value.
53A9
JUMP to 5344H to save the value of the parameter variable.
53AB
JP NC,2423H D2 23 24
If the NC FLAG is set (not reached: FN sets the C FLAG), JUMP to 2423H.
53AE
PUSH DE D5
Save Register Pair DE, the variable's address, to the top of the stack.
53AF
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the variable's descriptor, Register Pair HL = the definition's text.
53B0
GOSUB to 2888H, the ROM's routine that copies the descriptor at Register Pair DE into its pool of temporary strings: Register Pair HL returns the variable's address.
53B3
POP DE D1
Restore Register Pair DE, the definition's text, from the top of the stack.
53B4
XOR A AF
Set Register A to 00H by XORing it with itself: the Z FLAG marks a saved string.
53B5
PUSH HL E5
Save Register Pair HL, the address for the restore of the parameter, to the top of the stack.
53B6
PUSH AF F5
Save Register Pair AF, the parameter's type in Register A and its flags, to the top of the stack.
53B7
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the definition's text.
53B8
LD A,(HL) 7E
Load Register A with the character of the definition at Register Pair HL after the parameter.
53B9
CP 29H FE 29
Compare Register A against 29H, the ) that ends the parameter list.
53BB
If the NZ FLAG is set (more parameters), LOOP back to 5398H for the next one.
53BD
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the text pointer after the function's name in the call, from 40F3H-40F4H.
53C0
RST 08H => 28H CF 28
RST 08H: the next character of the call at Register Pair HL must be 28H, the ( of the arguments, or the ROM shows a Syntax error.
53C2
PUSH HL E5
Save Register Pair HL, the call's first argument, to the top of the stack.
53C3
LD HL,(40D8H) 2A D8 40
Load Register Pair HL with the definition's first parameter from 40D8H-40D9H.
53C6
GOSUB to 260DH, the ROM's variable search, for the parameter at Register Pair HL: Register Pair DE returns its value's address.
53C9
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the argument, the definition's text saved.
53CA
GOSUB to 1F2BH, the ROM's assignment of LET: evaluate the argument at Register Pair HL and store it in the variable at Register Pair DE.
53CD
LD A,(HL) 7E
Load Register A with the character of the call at Register Pair HL after the argument.
53CE
CP 29H FE 29
Compare Register A against 29H, the ) that ends the arguments.
53D0
If the Z FLAG is set (the last argument), JUMP to 53D9H.
53D2
RST 08H => 2CH CF 2C
RST 08H: the next character of the call at Register Pair HL must be 2CH, the comma between arguments, or the ROM shows a Syntax error.
53D4
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the definition's text, the call saved.
53D5
RST 08H => 2CH CF 2C
RST 08H: the next character of the definition at Register Pair HL must be 2CH, the comma between parameters, or the ROM shows a Syntax error.
53D7
LOOP back to 53C6H for the next parameter and its argument.
53D9
RST 10H D7
RST 10H: increment Register Pair HL past the ) of the call and load Register A with the next character.
53DA
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the definition's text, the call's text pointer saved.
53DB
RST 08H => 29H CF 29
RST 08H: the next character of the definition at Register Pair HL must be 29H, the ) of its parameters, or the ROM shows a Syntax error.
53DD
LD A,D5H 3E D5
Load Register A with D5H, a byte with no use here. 53DEH (a definition without parameters) enters inside it at its operand D5H, which reads as PUSH DE and saves the call's text pointer.
53DF
RST 08H => D5H CF D5
RST 08H: the next character of the definition at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
53E1
GOSUB to 2337H, the ROM's expression evaluator, for the definition's expression at Register Pair HL.
53E4
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the expression again.
53E5
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
53E6
If the NZ FLAG is set (more text in the definition), JUMP to 1997H, the ROM's Syntax error.
53E9
RST 20H E7
RST 20H: test the type of the result in the accumulator: the Z FLAG for a string.
53EA
If the Z FLAG is set (a string), JUMP to 541BH to move the result out of the temporary pool.
53EC
POP DE D1
Restore Register Pair DE, the call's text pointer, from the top of the stack.
53ED
POP AF F1
Restore Register Pair AF, the type and flags of the next saved value, from the top of the stack.
53EE
If the Z FLAG is set (a saved string), JUMP to 542FH to put the string back.
53F0
If the NC FLAG is set (the mark of the function's own type), JUMP to 540EH: every parameter is restored.
53F2
POP HL E1
Restore Register Pair HL, the address of the last byte of the parameter's value, from the top of the stack.
53F3
POP BC C1
Restore Register Pair BC, the last word of the saved value, from the top of the stack.
53F4
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
53F5
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
53F6
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
53F7
If the M FLAG is set (an integer, one word), LOOP back to 53EDH for the next saved value.
53FA
DEC HL 2B
DECrement Register Pair HL by 1, to the high byte of the word before.
53FB
POP BC C1
Restore Register Pair BC, the next word of the saved value, from the top of the stack.
53FC
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
53FD
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
53FE
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
53FF
If the PO FLAG is set (single precision, two words), LOOP back to 53EDH for the next saved value.
5402
DEC HL 2B
DECrement Register Pair HL by 1, to the high byte of the word before.
5403
POP BC C1
Restore Register Pair BC, the second word of a double precision value, from the top of the stack.
5404
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
5405
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
5406
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
5407
DEC HL 2B
DECrement Register Pair HL by 1, to the high byte of the first word.
5408
POP BC C1
Restore Register Pair BC, the first word of the double precision value, from the top of the stack.
5409
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
540A
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
540B
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
540C
LOOP back to 53EDH for the next saved value on the stack.
540E
PUSH DE D5
Save Register Pair DE, the call's text pointer, to the top of the stack for the ROM's 281AH to restore into Register Pair HL.
540F
PUSH AF F5
Save Register Pair AF, the function's type, to the top of the stack.
5410
RST 20H E7
RST 20H: test the type of the result in the accumulator: the Z FLAG for a string.
5411
LD DE,40D3H 11 D3 40
Point Register Pair DE to 40D3H, the descriptor where a string result was put.
5414
If the Z FLAG is set (a string), GOSUB to 2888H to make the descriptor at Register Pair DE the result, a temporary string.
5417
POP AF F1
Restore Register Pair AF, the function's type in Register A, from the top of the stack.
5418
JUMP to 281AH, the ROM's conversion of the result to the type in Register A, which returns with Register Pair HL at the call's text.
541B
LD DE,(40B3H) ED 5B B3 40
Load Register Pair DE with 40B3H-40B4H, the ROM's pointer to the next free temporary string descriptor.
541F
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the address of the result's descriptor from 4121H-4122H in the accumulator.
5422
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG when the result is a temporary string.
5423
If the C FLAG is set (a temporary), JUMP to 542AH to move it to 40D3H.
5425
GOSUB to 2843H, the ROM's routine that copies the string of the descriptor at Register Pair HL into new string space, with its descriptor at 40D3H.
5428
JUMP to 53ECH to restore the parameters with the result at 40D3H.
542A
POP DE D1
Restore Register Pair DE, the call's text pointer, from the top of the stack.
542B
LD HL,40D3H 21 D3 40
Point Register Pair HL to 40D3H, where the result's descriptor is put.
542E
PUSH HL E5
Save Register Pair HL (40D3H), the place for the descriptor, to the top of the stack.
542F
GOSUB to 29F5H, the ROM's routine that backs Register Pair HL up to the last temporary descriptor (Register Pair BC its string's address).
5432
LD A,(HL) 7E
Load Register A with the length of the string from the descriptor at Register Pair HL.
5433
LD (40B3H),HL 22 B3 40
Store Register Pair HL into 40B3H-40B4H, the ROM's pointer to the next free descriptor: the last temporary is freed.
5436
POP HL E1
Restore Register Pair HL, the place for the descriptor (40D3H or the parameter variable), from the top of the stack.
5437
LD (HL),A 77
Store Register A, the length, at Register Pair HL, the first byte of the descriptor.
5438
INC HL 23
INCrement Register Pair HL by 1, to the low byte of the string's address.
5439
LD (HL),C 71
Store Register C, the low byte of the string's address, at Register Pair HL.
543A
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
543B
LD (HL),B 70
Store Register B, the high byte of the string's address, at Register Pair HL.
543C
LOOP back to 53EDH for the next saved value on the stack.
543EH - USR
Link 41A9H, the function USR. The ROM's return is dropped and the argument in parentheses is evaluated. The routine of the USR table (5330H) is entered by RET with Register A = the argument's type (02H, 03H, 04H or 08H), Register Pair HL = 4121H (the accumulator) and Register Pair DE = the string's descriptor for a string; it returns to the ROM's 26E7H, which restores the text pointer.
543E
POP AF F1
Restore Register Pair AF with the ROM's return address, which USR does not use: the routine returns through 26E7H.
543F
GOSUB to 545EH to take the digit after USR: Register Pair DE returns the address of its entry in the table 5330H.
5442
PUSH DE D5
Save Register Pair DE, the table entry, to the top of the stack.
5443
GOSUB to 252CH, the ROM's evaluation of the argument in parentheses at Register Pair HL into the accumulator.
5446
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the table entry, the text pointer saved.
5447
LD C,(HL) 4E
Load Register C with the low byte of the routine's address at Register Pair HL.
5448
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the routine's address.
5449
LD B,(HL) 46
Load Register B with the high byte of the routine's address at Register Pair HL.
544A
LD HL,26E7H 21 E7 26
Point Register Pair HL to 26E7H, the ROM's code that restores the text pointer and goes on with the expression.
544D
PUSH HL E5
Save Register Pair HL (26E7H) to the top of the stack, the return address of the user's routine.
544E
PUSH BC C5
Save Register Pair BC, the routine's address, to the top of the stack, so that the RET below enters it.
544F
LD A,(40AFH) 3A AF 40
Load Register A with the type of the argument from 40AFH.
5452
PUSH AF F5
Save Register Pair AF, the type in Register A, to the top of the stack.
5453
CP 03H FE 03
Compare Register A against 03H, the type of a string.
5455
If the Z FLAG is set (a string), GOSUB to 29DAH, the ROM's FREFAC, which frees the string's temporary: Register Pair HL returns its descriptor.
5458
POP AF F1
Restore Register Pair AF, the type in Register A, from the top of the stack.
5459
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the string's descriptor.
545A
LD HL,4121H 21 21 41
Point Register Pair HL to 4121H, the accumulator with the argument's value.
545D
RET C9
RETurn into the user's routine with Register A, Register Pair HL and Register Pair DE set.
545EH - The USR Number
Takes the digit after USR (none is USR0): Register Pair DE returns the address of its entry in the table 5330H, Register Pair HL the text after it.
545E
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after USR: the C FLAG for a digit.
545F
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the offset of USR0.
5462
If the NC FLAG is set (no digit), JUMP to 5469H with USR0.
5464
SUB 30H D6 30
SUBtract 30H from Register A, the ASCII digit, giving its value 0-9 (and the NC FLAG).
5466
RLA 17
Rotate Register A left through the C FLAG: twice the digit, the offset of its word in the table.
5467
LD C,A 4F
Load Register C with Register A, the offset of the entry in Register Pair BC.
5468
RST 10H D7
RST 10H: increment Register Pair HL past the digit and load Register A with the next character.
5469
EX DE,HL EB
EXchange Register Pairs DE and HL, to keep the text pointer in Register Pair DE.
546A
LD HL,5330H 21 30 53
Point Register Pair HL to 5330H, the USR table.
546D
ADD HL,BC 09
ADD Register Pair BC, the offset, to Register Pair HL: the entry of the USR number.
546E
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the entry, Register Pair HL = the text pointer.
546F
RET C9
RETurn with Register Pair DE at the USR table's entry.
5470
LD E,2EH 1E 2E
Load Register E with 2EH, the offset of the error Undefined user function.
5472
JUMP to 19A2H, the ROM's error routine, with the offset in Register E.
5475H - INSTR
Link 419DH, the function INSTR([n,]a$,b$): the position of b$ in a$, searched from character n (1 when n is not given; n = 0 is Illegal function call). The result is 0 when n is past the end of a$, when a$ is empty or when b$ is not found; an empty b$ gives n. The routine returns Register A to the ROM's 27F8H, which makes it the integer result, and then to 26E7H, which restores the text pointer.
5475
RST 10H D7
RST 10H: increment Register Pair HL past the token of INSTR and load Register A with the next character.
5476
GOSUB to 2335H, the ROM's check of the ( and evaluation of the first expression at Register Pair HL.
5479
RST 20H E7
RST 20H: test the type of the first expression: the Z FLAG for a string (a$, so n is 1).
547A
LD A,01H 3E 01
Load Register A with 01H, the position to start from when n is not given.
547C
PUSH AF F5
Save Register Pair AF, the start in Register A, to the top of the stack.
547D
If the Z FLAG is set (the first expression is a$), JUMP to 5490H.
547F
POP AF F1
Restore Register Pair AF from the top of the stack: the first expression is n.
5480
GOSUB to 2B1FH, the ROM's CONINT, to make the value of n a byte in Register A.
5483
OR A B7
OR Register A against itself: the Z FLAG for n = 0.
5484
If the Z FLAG is set (n = 0), JUMP to 1E4AH, the ROM's Illegal function call error.
5487
PUSH AF F5
Save Register Pair AF, the start n in Register A, to the top of the stack.
5488
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after n, or the ROM shows a Syntax error.
548A
GOSUB to 2337H, the ROM's expression evaluator, for a$ at Register Pair HL.
548D
GOSUB to 0AF4H, the ROM's test that the value is a string, else Type mismatch.
5490
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after a$, or the ROM shows a Syntax error.
5492
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5493
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the descriptor of a$ from 4121H-4122H in the accumulator.
5496
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): a$ saved, Register Pair HL = the text pointer.
5497
GOSUB to 2337H, the ROM's expression evaluator, for b$ at Register Pair HL.
549A
RST 08H => 29H CF 29
RST 08H: the next character of the text at Register Pair HL must be 29H, the ) that ends INSTR, or the ROM shows a Syntax error.
549C
PUSH HL E5
Save Register Pair HL, the text pointer after INSTR, to the top of the stack.
549D
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns b$'s descriptor.
54A0
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the descriptor of b$.
54A1
POP BC C1
Restore Register Pair BC, the text pointer after INSTR, from the top of the stack.
54A2
POP HL E1
Restore Register Pair HL, the descriptor of a$, from the top of the stack.
54A3
POP AF F1
Restore Register Pair AF, the start n in Register A, from the top of the stack.
54A4
PUSH BC C5
Save Register Pair BC, the text pointer, to the top of the stack for the ROM's 26E7H.
54A5
LD BC,26E7H 01 E7 26
Load Register Pair BC with 26E7H, the ROM's code that restores the text pointer.
54A8
PUSH BC C5
Save Register Pair BC (26E7H) to the top of the stack, the second return address.
54A9
LD BC,27F8H 01 F8 27
Load Register Pair BC with 27F8H, the ROM's routine that makes Register A the integer result.
54AC
PUSH BC C5
Save Register Pair BC (27F8H) to the top of the stack, the first return address of the search.
54AD
PUSH AF F5
Save Register Pair AF, the start n, to the top of the stack.
54AE
PUSH DE D5
Save Register Pair DE, the descriptor of b$, to the top of the stack.
54AF
GOSUB to 29DDH, the ROM's routine that frees the temporary of the descriptor at Register Pair HL (a$) when it is the last one.
54B2
POP DE D1
Restore Register Pair DE, the descriptor of b$, from the top of the stack.
54B3
POP AF F1
Restore Register Pair AF, the start n, from the top of the stack.
54B4
LD B,A 47
Load Register B with Register A, the start n.
54B5
DEC A 3D
DECrement Register A by 1: the characters of a$ before the start.
54B6
LD C,A 4F
Load Register C with Register A, the characters before the start (n less 1).
54B7
CP (HL) BE
Compare Register A against the length of a$ at Register Pair HL: the NC FLAG when n is past the end.
54B8
LD A,00H 3E 00
Load Register A with 00H, the result when b$ is not found (the flags are kept).
54BA
RET NC D0
If the NC FLAG is set (n past the end of a$), RETurn with the result 0.
54BB
LD A,(HL) 7E
Load Register A with the length of a$ at Register Pair HL.
54BC
OR A B7
OR Register A against itself: the Z FLAG for an empty a$.
54BD
RET Z C8
If the Z FLAG is set (a$ empty), RETurn with the result 0 in Register A.
54BE
LD A,(DE) 1A
Load Register A with the length of b$ at Register Pair DE.
54BF
OR A B7
OR Register A against itself: the Z FLAG for an empty b$.
54C0
LD A,B 78
Load Register A with Register B, the start n (the flags are kept).
54C1
RET Z C8
If the Z FLAG is set (b$ empty), RETurn with the result n in Register A.
54C2
LD A,(HL) 7E
Load Register A with the length of a$ at Register Pair HL.
54C3
INC HL 23
INCrement Register Pair HL by 1, to the address of a$ in the descriptor.
54C4
LD B,(HL) 46
Load Register B with the low byte of a$'s address at Register Pair HL.
54C5
INC HL 23
INCrement Register Pair HL by 1, to the high byte of a$'s address.
54C6
LD H,(HL) 66
Load Register H with the high byte of a$'s address at Register Pair HL.
54C7
LD L,B 68
Load Register L with Register B: Register Pair HL = the characters of a$.
54C8
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
54CA
ADD HL,BC 09
ADD Register Pair BC (n less 1) to Register Pair HL: the start of the search in a$.
54CB
SUB C 91
SUBtract Register C (n less 1) from Register A, the length of a$: the characters left from the start.
54CC
LD B,A 47
Load Register B with Register A, the characters of a$ left from the start.
54CD
PUSH BC C5
Save Register Pair BC (Register B the characters left, Register C n less 1) to the top of the stack for the result.
54CE
PUSH DE D5
Save Register Pair DE, the descriptor of b$, to the top of the stack.
54CF
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = b$'s descriptor, the place in a$ saved.
54D0
LD C,(HL) 4E
Load Register C with the length of b$ at Register Pair HL.
54D1
INC HL 23
INCrement Register Pair HL by 1, to the address of b$ in the descriptor.
54D2
LD E,(HL) 5E
Load Register E with the low byte of b$'s address at Register Pair HL.
54D3
INC HL 23
INCrement Register Pair HL by 1, to the high byte of b$'s address.
54D4
LD D,(HL) 56
Load Register D with the high byte of b$'s address at Register Pair HL: Register Pair DE = the characters of b$.
54D5
POP HL E1
Restore Register Pair HL, the place in a$, from the top of the stack.
54D6
PUSH HL E5
Save Register Pair HL, the place in a$ where this try starts, to the top of the stack.
54D7
PUSH DE D5
Save Register Pair DE, the first character of b$, to the top of the stack.
54D8
PUSH BC C5
Save Register Pair BC (Register B the characters left in a$, Register C the length of b$) to the top of the stack.
54D9
LD A,(DE) 1A
Load Register A with the character of b$ at Register Pair DE.
54DA
CP (HL) BE
Compare Register A with the character of a$ at Register Pair HL.
54DB
If the NZ FLAG is set (they differ), JUMP to 54F4H to try from the next place in a$.
54DD
INC DE 13
INCrement Register Pair DE by 1, to the next character of b$.
54DE
DEC C 0D
DECrement Register C by 1, the characters of b$ still to compare.
54DF
If the Z FLAG is set (all of b$ matched), JUMP to 54EBH to compute the position.
54E1
INC HL 23
INCrement Register Pair HL by 1, to the next character of a$.
54E2
DEC B 05
DECrement Register B by 1, the characters left in a$.
54E3
If the NZ FLAG is set (a$ has more), LOOP back to 54D9H for the next character.
54E5
POP DE D1
Restore Register Pair DE from the top of the stack: the counts of this try are dropped.
54E6
POP DE D1
Restore Register Pair DE from the top of the stack: the start of b$ is dropped.
54E7
POP BC C1
Restore Register Pair BC from the top of the stack: the place in a$ is dropped.
54E8
POP DE D1
Restore Register Pair DE from the top of the stack: the counts of the start are dropped.
54E9
XOR A AF
Set Register A to 00H by XORing it with itself: b$ is not found, the result 0.
54EA
RET C9
RETurn with the result in Register A to the ROM's 27F8H.
54EB
POP HL E1
Restore Register Pair HL, the counts of this try: Register H the characters of a$ left where it started.
54EC
POP DE D1
Restore Register Pair DE from the top of the stack: the start of b$ is dropped.
54ED
POP DE D1
Restore Register Pair DE from the top of the stack: the place in a$ is dropped.
54EE
POP BC C1
Restore Register Pair BC, the counts of the start: Register B the characters left, Register C n less 1.
54EF
LD A,B 78
Load Register A with Register B, the characters of a$ left from n.
54F0
SUB H 94
SUBtract Register H, the characters left where the match starts, from Register A: the match's distance from n.
54F1
ADD A,C 81
ADD Register C (n less 1) to Register A, the distance of the match from n.
54F2
INC A 3C
INCrement Register A by 1: the position of b$ in a$, counted from 1.
54F3
RET C9
RETurn with the result in Register A to the ROM's 27F8H.
54F4
POP BC C1
Restore Register Pair BC, the counts of this try, from the top of the stack.
54F5
POP DE D1
Restore Register Pair DE, the first character of b$, from the top of the stack.
54F6
POP HL E1
Restore Register Pair HL, the place in a$ where this try started, from the top of the stack.
54F7
INC HL 23
INCrement Register Pair HL by 1, to the next place in a$.
54F8
DEC B 05
DECrement Register B by 1, the characters left in a$.
54F9
If the Z FLAG is set (no place left), JUMP to 54E8H with the result 0.
54FB
LOOP back to 54D6H to try b$ from the next place in a$.
54FDH - MID$ =
Link 41D9H, MID$(v$,n[,m])=x$ on the left of an assignment, entered by the ROM's jump at 2AECH. A string whose characters are still in the program text is first copied into the string space, so that the program is not changed. Characters of x$ replace those of v$ from n, at most m (255 when m is not given), at most the rest of v$ and at most the length of x$; the length of v$ never changes. n = 0 or past the end of v$ is Illegal function call.
54FD
INC HL 23
INCrement Register Pair HL by 1, past the token of MID$ to the (.
54FE
RST 08H => 28H CF 28
RST 08H: the next character of the text at Register Pair HL must be 28H, the ( after MID$, or the ROM shows a Syntax error.
5500
GOSUB to 260DH, the ROM's variable search, for v$ at Register Pair HL: Register Pair DE returns its descriptor.
5503
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
5506
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5507
PUSH DE D5
Save Register Pair DE, the descriptor of v$, to the top of the stack.
5508
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the descriptor of v$.
5509
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
550A
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
550B
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
550C
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the characters of v$.
550D
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of the string space from 40A0H-40A1H.
5510
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG when the characters are in the string space.
5511
If the C FLAG is set (in the string space), JUMP to 551DH: they may be changed in place.
5513
POP HL E1
Restore Register Pair HL, the descriptor of v$, from the top of the stack.
5514
PUSH HL E5
Save Register Pair HL, the descriptor of v$, to the top of the stack again.
5515
GOSUB to 2843H, the ROM's routine that copies the string of the descriptor at Register Pair HL into the string space, with its descriptor at 40D3H.
5518
POP HL E1
Restore Register Pair HL, the descriptor of v$, from the top of the stack.
5519
PUSH HL E5
Save Register Pair HL, the descriptor of v$, to the top of the stack again.
551A
GOSUB to 09D3H, the ROM's copy of the value at Register Pair DE (the new descriptor) into the variable at Register Pair HL.
551D
POP HL E1
Restore Register Pair HL, the descriptor of v$, from the top of the stack.
551E
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the text pointer, the descriptor saved.
551F
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before n, or the ROM shows a Syntax error.
5521
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate n as a byte into Register A.
5524
OR A B7
OR Register A against itself: the Z FLAG for n = 0.
5525
If the Z FLAG is set (n = 0), JUMP to 1E4AH, the ROM's Illegal function call error.
5528
PUSH AF F5
Save Register Pair AF, n in Register A, to the top of the stack.
5529
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL after n.
552A
GOSUB to 556EH to take ,m and the ): Register E returns m, FFH when it is not given.
552D
PUSH DE D5
Save Register Pair DE, m in Register E, to the top of the stack.
552E
RST 08H => D5H CF D5
RST 08H: the next character of the text at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
5530
GOSUB to 2337H, the ROM's expression evaluator, for x$ at Register Pair HL.
5533
PUSH HL E5
Save Register Pair HL, the text pointer after the statement, to the top of the stack.
5534
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns x$'s descriptor.
5537
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the descriptor of x$.
5538
POP HL E1
Restore Register Pair HL, the text pointer after the statement, from the top of the stack.
5539
POP BC C1
Restore Register Pair BC, m in Register C, from the top of the stack.
553A
POP AF F1
Restore Register Pair AF, n in Register A, from the top of the stack.
553B
LD B,A 47
Load Register B with Register A, n, the first character of v$ to replace.
553C
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the descriptor of v$, the text pointer saved.
553D
PUSH HL E5
Save Register Pair HL, the descriptor of v$, to the top of the stack.
553E
LD HL,26E7H 21 E7 26
Point Register Pair HL to 26E7H, the ROM's code that restores the text pointer.
5541
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): 26E7H becomes the return address, Register Pair HL = the descriptor of v$.
5542
LD A,C 79
Load Register A with Register C, m, the most characters to replace.
5543
OR A B7
OR Register A against itself: the Z FLAG for m = 0.
5544
RET Z C8
If the Z FLAG is set (m = 0), RETurn through 26E7H: nothing is replaced.
5545
LD A,(HL) 7E
Load Register A with the length of v$ at Register Pair HL.
5546
SUB B 90
SUBtract Register B, n, from Register A: the C FLAG when n is past the end of v$.
5547
If the C FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call error.
554A
INC A 3C
INCrement Register A by 1: the characters of v$ from n to its end.
554B
CP C B9
Compare Register A against Register C, m: the C FLAG when fewer characters than m are left.
554C
If the C FLAG is set, JUMP to 554FH with the characters left as the count.
554E
LD A,C 79
Load Register A with Register C, m, as the count.
554F
LD C,B 48
Load Register C with Register B, n, the first character of v$ to replace.
5550
DEC C 0D
DECrement Register C by 1, n less 1, the offset of the first character replaced.
5551
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
5553
PUSH DE D5
Save Register Pair DE, the descriptor of x$, to the top of the stack.
5554
INC HL 23
INCrement Register Pair HL by 1, to the address of v$ in its descriptor.
5555
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
5556
INC HL 23
INCrement Register Pair HL by 1, to the high byte of v$'s address.
5557
LD H,(HL) 66
Load Register H with the high byte of v$'s address at Register Pair HL.
5558
LD L,E 6B
Load Register L with Register E: Register Pair HL = the characters of v$.
5559
ADD HL,BC 09
ADD Register Pair BC, the offset, to Register Pair HL: the first character to replace.
555A
LD B,A 47
Load Register B with Register A, the most characters to replace.
555B
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = x$'s descriptor, the place in v$ saved.
555C
LD A,(HL) 7E
Load Register A with the length of x$ at Register Pair HL.
555D
INC HL 23
INCrement Register Pair HL by 1, to the address of x$ in its descriptor.
555E
LD E,(HL) 5E
Load Register E with the low byte of x$'s address at Register Pair HL.
555F
INC HL 23
INCrement Register Pair HL by 1, to the high byte of x$'s address.
5560
LD D,(HL) 56
Load Register D with the high byte of x$'s address at Register Pair HL: Register Pair DE = the characters of x$.
5561
POP HL E1
Restore Register Pair HL, the place in v$, from the top of the stack.
5562
LD C,A 4F
Load Register C with Register A, the length of x$.
5563
OR A B7
OR Register A against itself: the Z FLAG for an empty x$.
5564
RET Z C8
If the Z FLAG is set (x$ empty), RETurn through 26E7H: nothing is replaced.
5565
LD A,(DE) 1A
Load Register A with the next character of x$ at Register Pair DE.
5566
LD (HL),A 77
Store Register A, the character, at Register Pair HL in v$.
5567
INC DE 13
INCrement Register Pair DE by 1, to the next character of x$.
5568
INC HL 23
INCrement Register Pair HL by 1, to the next character of v$.
5569
DEC C 0D
DECrement Register C by 1, the characters of x$ left.
556A
RET Z C8
If the Z FLAG is set (x$ used up), RETurn through 26E7H.
556B
DECrement Register B and LOOP back to 5565H while characters may still be replaced.
556D
RET C9
RETurn through 26E7H, the ROM's code that restores the text pointer.
556EH - The Length of MID$ =
Takes the optional ,m and the ) of MID$(v$,n,m): Register E returns m, or FFH when the ) follows n.
556E
LD E,FFH 1E FF
Load Register E with FFH, the most characters to replace when m is not given.
5570
CP 29H FE 29
Compare Register A, the character after n, against 29H, the ) that ends the arguments.
5572
If the Z FLAG is set (no m), JUMP to 5579H to check the ) after n.
5574
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before m, or the ROM shows a Syntax error.
5576
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate m as a byte into Register E.
5579
RST 08H => 29H CF 29
RST 08H: the next character of the text at Register Pair HL must be 29H, the ) of MID$, or the ROM shows a Syntax error.
557B
RET C9
RETurn with m in Register E and Register Pair HL after the ).
557CH - &H
Link 4194H, a constant &Hnnnn (the H may be left out): up to four hexadecimal digits 0-9 and A-F, upper case, form an integer in the accumulator. A fifth digit is Overflow; the first other character ends the number.
557C
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value before the first digit.
557F
LD B,05H 06 05
Load Register B with 05H: the fifth digit is too many.
5581
RST 10H D7
RST 10H: increment Register Pair HL past the & and load Register A with the next character.
5582
CP 48H FE 48
Compare Register A against 48H, the letter H of &H.
5584
If the Z FLAG is set (H), JUMP to 5587H, to the first digit after it.
5586
DEC HL 2B
DECrement Register Pair HL by 1, so that the character after the & is read again as the first digit.
5587
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the C FLAG for a digit 0-9.
5588
GOSUB to 1E3EH, the ROM's letter test of Register A: the NC FLAG for a letter A-Z.
558B
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the value, Register Pair DE = the text pointer.
558C
If the NC FLAG is set (a letter), JUMP to 5598H.
558E
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9: the NC FLAG for anything above 9.
5590
If the NC FLAG is set (not a digit), JUMP to 55ABH, the end of the number.
5592
SUB 30H D6 30
SUBtract 30H from Register A, the ASCII digit, giving its value.
5594
If the C FLAG is set (below 0), JUMP to 55ABH, the end of the number.
5596
JUMP to 559EH to add the value of the digit to the number.
5598
CP 47H FE 47
Compare Register A against 47H, the letter G: the NC FLAG for a letter G-Z.
559A
If the NC FLAG is set (not a hexadecimal digit), JUMP to 55ABH, the end of the number.
559C
SUB 37H D6 37
SUBtract 37H from Register A, the letter A-F, giving its value 0AH-0FH.
559E
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
559F
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
55A0
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 8.
55A1
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 16, one hexadecimal digit up.
55A2
ADD A,L 85
ADD Register L to Register A, the value of the new digit.
55A3
LD L,A 6F
Load Register L with Register A: the digit is in the low four bits of Register Pair HL.
55A4
DEC B 05
DECrement Register B by 1, the digits still allowed.
55A5
If the Z FLAG is set (a fifth digit), JUMP to 07B2H, the ROM's Overflow error.
55A8
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the value, Register Pair HL = the text pointer.
55A9
LOOP back to 5587H for the next digit of the number.
55AB
GOSUB to 0A9AH, the ROM's routine that makes Register Pair HL the integer in the accumulator.
55AE
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the text pointer at the character after the number.
55AF
RET C9
RETurn to the expression evaluator with the integer in the accumulator.
55B0H - PRINT #
Link 41CAH, called by the ROM's PRINT (206FH) with Register Pair HL at the #. PRINT #-1 is the ROM's cassette and is left to it. Otherwise the file number is evaluated (5948H): the file must be open for output (mode 02H, else Bad file mode), a comma must follow, and the file's area becomes the current one (570EH), to which the output link 41C1H sends PRINT's characters.
55B0
PUSH HL E5
Save Register Pair HL, the text pointer at the #, to the top of the stack.
55B1
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after the #.
55B2
CP CEH FE CE
Compare Register A against CEH, the token of the minus sign: PRINT #-1, the cassette.
55B4
POP HL E1
Restore Register Pair HL, the text pointer at the #, from the top of the stack.
55B5
LD A,(HL) 7E
Load Register A with the # at Register Pair HL, as the ROM expects it (the flags are kept).
55B6
RET Z C8
If the Z FLAG is set (#-1), RETurn: the ROM writes to the cassette.
55B7
LD C,02H 0E 02
Load Register C with 02H, the mode of a file open for output.
55B9
JUMP to 5948H to take the file number and make its area the current one.
55BCH - INPUT #
Link 41D6H, called by the ROM's INPUT (219EH) with Register A = the character after INPUT. INPUT # (not #-1, which the ROM reads from the cassette) takes the file number (5946H, open for input, mode 01H), makes its area the current one, and goes on in the ROM's INPUT at 21EBH, the items coming from the file through the link 41DCH (59C2H). TBASIC has no INPUT @.
55BC
CP 23H FE 23
Compare Register A against 23H, the character # of INPUT #.
55BE
RET NZ C0
If the NZ FLAG is set (not #), RETurn to the ROM's INPUT from the keyboard.
55BF
PUSH HL E5
Save Register Pair HL, the text pointer at the #, to the top of the stack.
55C0
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after the #.
55C1
CP CEH FE CE
Compare Register A against CEH, the token of the minus sign: INPUT #-1, the cassette.
55C3
POP HL E1
Restore Register Pair HL, the text pointer at the #, from the top of the stack.
55C4
LD A,(HL) 7E
Load Register A with the # at Register Pair HL, as the ROM expects it (the flags are kept).
55C5
RET Z C8
If the Z FLAG is set (#-1), RETurn: the ROM reads from the cassette.
55C6
POP BC C1
Restore Register Pair BC with the ROM's return address, which INPUT # does not use.
55C7
GOSUB to 5946H to take the file number (open for input, mode 01H) and make its area the current one.
55CA
PUSH HL E5
Save Register Pair HL, the text pointer at the first item, to the top of the stack.
55CB
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
55CE
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the buffer, as the ROM's INPUT expects.
55CF
JUMP to 21EBH, the ROM's INPUT after the line has been taken: the items come from the file through the link 41DCH.
55D2H - LINE INPUT
Link 41A3H, the statement LINE, which must be LINE INPUT (the token 89H). It is not allowed in the direct mode. LINE INPUT # goes to 59D6H. Otherwise the ROM's 21CDH shows a quoted prompt, the string variable is found, the ROM's 0361H takes a line from the keyboard (BREAK goes to the ROM's 1DBEH), and the line becomes the variable's value through the ROM's assignment of LET (1F32H).
55D2
RST 08H => 89H CF 89
RST 08H: the next character of the text at Register Pair HL must be 89H, the token of INPUT after LINE, or the ROM shows a Syntax error.
55D4
GOSUB to 2828H, the ROM's test of the direct mode, which gives Illegal direct outside a program.
55D7
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
55D8
CP 23H FE 23
Compare Register A against 23H, the character # of LINE INPUT #.
55DA
If the Z FLAG is set (LINE INPUT #), JUMP to 59D6H to read the line from the file.
55DD
GOSUB to 21CDH, the ROM's routine that shows a quoted prompt at Register Pair HL and checks the semicolon after it.
55E0
GOSUB to 260DH, the ROM's variable search, for the variable at Register Pair HL: Register Pair DE returns its descriptor.
55E3
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
55E6
PUSH DE D5
Save Register Pair DE, the variable's descriptor, to the top of the stack.
55E7
PUSH HL E5
Save Register Pair HL, the text pointer after the variable, to the top of the stack.
55E8
GOSUB to 0361H, the ROM's line input from the keyboard into the input buffer: Register Pair HL the buffer, the C FLAG for BREAK.
55EB
POP DE D1
Restore Register Pair DE, the text pointer after the variable, from the top of the stack.
55EC
POP BC C1
Restore Register Pair BC, the variable's descriptor, from the top of the stack.
55ED
If the C FLAG is set (BREAK), JUMP to 1DBEH, the ROM's handling of BREAK during an input.
55F0
PUSH BC C5
Save Register Pair BC, the variable's descriptor, to the top of the stack for the ROM's assignment.
55F1
PUSH DE D5
Save Register Pair DE, the text pointer after the variable, to the top of the stack.
55F2
LD B,00H 06 00
Load Register B with 00H, the character that ends the line in the input buffer.
55F4
GOSUB to 2868H, the ROM's routine that makes the text at Register Pair HL, up to the 00H in Register B, a temporary string.
55F7
POP HL E1
Restore Register Pair HL, the text pointer after the variable, from the top of the stack.
55F8
XOR A AF
Set Register A to 00H by XORing it with itself: the type of the value less 3, a string, for the ROM's 1F32H.
55F9
JUMP to 1F32H, the ROM's assignment of LET, which stores the string into the variable whose descriptor is on the stack.
55FCH - The End of INPUT and of a Listed Line
Link 41DFH, called by the ROM at 2278H (the end of INPUT) and at 2B44H (each line of LIST). With no current file it returns. With a file the ROM's return is dropped: INPUT # goes to 2282H, past the ROM's Extra ignored test; LIST to a file (SAVE ,A) goes to 2B4AH, past the ROM's BREAK and SHIFT @ test.
55FC
PUSH HL E5
Save Register Pair HL to the top of the stack.
55FD
LD HL,(570EH) 2A 0E 57
Load Register Pair HL with the current file area from 570EH-570FH (0000H: none).
5600
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
5601
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
5602
POP HL E1
Restore Register Pair HL from the top of the stack.
5603
RET Z C8
If the Z FLAG is set (no file), RETurn to the ROM.
5604
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the ROM's return address.
5605
PUSH DE D5
Save Register Pair DE to the top of the stack.
5606
LD DE,2B2EH 11 2E 2B
Load Register Pair DE with 2B2EH, the ROM's LIST: returns above it come from LIST.
5609
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the NC FLAG for a call from LIST (2B44H).
560A
POP DE D1
Restore Register Pair DE from the top of the stack.
560B
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
560C
If the NC FLAG is set (LIST), JUMP to 2B4AH, the ROM's LIST of the line without the keyboard test.
560F
JUMP to 2282H, the ROM's end of INPUT without the Extra ignored test.
5612H - The Line Input Link
Link 41AFH, the ROM's line input at 0368H. With no current file it returns, and the ROM takes the line from the keyboard with its own editing (TBASIC has no editing keys of its own). With a file (LOAD and MERGE of a program saved in ASCII) the ROM's return is dropped and a line of up to 255 characters is read into the input buffer through the ROM's 0384H, which gets the bytes from the file through the keyboard link (5652H); a line feed at the start of a line is passed over, the carriage return ends the line and 00H is put after it.
5612
PUSH HL E5
Save Register Pair HL to the top of the stack.
5613
LD HL,(570EH) 2A 0E 57
Load Register Pair HL with the current file area from 570EH-570FH (0000H: none).
5616
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
5617
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
5618
POP HL E1
Restore Register Pair HL from the top of the stack.
5619
RET Z C8
If the Z FLAG is set (no file), RETurn to the ROM's own line input from the keyboard.
561A
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used: the line is read here.
561B
PUSH BC C5
Save Register Pair BC to the top of the stack.
561C
PUSH DE D5
Save Register Pair DE to the top of the stack.
561D
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
5620
LD B,FFH 06 FF
Load Register B with FFH, the most characters of a line: 255.
5622
PUSH HL E5
Save Register Pair HL, the input buffer, to the top of the stack.
5623
GOSUB to 0384H, the ROM's wait for a key, which takes the next byte of the file through the keyboard link: Register A.
5626
LD (HL),A 77
Store Register A, the byte, at Register Pair HL in the input buffer.
5627
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return that ends a line.
5629
If the Z FLAG is set (the end of the line), JUMP to 5637H.
562B
CP 0AH FE 0A
Compare Register A against 0AH, the line feed.
562D
If the NZ FLAG is set (another character), JUMP to 5634H to keep it.
562F
LD A,B 78
Load Register A with Register B, the room left in the line.
5630
CP FFH FE FF
Compare Register A against FFH: the Z FLAG when the line feed is the first byte of the line.
5632
If the Z FLAG is set (a line feed at the start), LOOP back to 5623H: it is passed over.
5634
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the input buffer.
5635
DECrement Register B and LOOP back to 5623H while the line has room.
5637
LD (HL),00H 36 00
Store 00H at Register Pair HL over the carriage return: the end of the line.
5639
POP HL E1
Restore Register Pair HL, the input buffer, from the top of the stack.
563A
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the buffer, as the ROM's line input returns it.
563B
POP DE D1
Restore Register Pair DE from the top of the stack.
563C
POP BC C1
Restore Register Pair BC from the top of the stack.
563D
XOR A AF
Set Register A to 00H by XORing it with itself, and clear the C FLAG: the line is not ended by BREAK.
563E
RET C9
RETurn to the caller of the ROM's line input with the line in the buffer.
563FH - The Output Link
Link 41C1H, the ROM's output of a byte (032CH) with the byte in Register C. With no current file it returns and the ROM sends the byte to its device. With a file (PRINT # or SAVE ,A) the ROM's return is dropped, Register Pair BC (saved by the ROM's 032AH) is restored, and 5F7AH writes the byte to the file, returning to the ROM's caller.
563F
PUSH HL E5
Save Register Pair HL to the top of the stack.
5640
LD HL,(570EH) 2A 0E 57
Load Register Pair HL with the current file area from 570EH-570FH (0000H: none).
5643
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
5644
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
5645
POP HL E1
Restore Register Pair HL from the top of the stack.
5646
LD A,C 79
Load Register A with Register C, the byte to output (the flags are kept).
5647
RET Z C8
If the Z FLAG is set (no file), RETurn to the ROM's output.
5648
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used: the byte goes to the file.
5649
LD A,C 79
Load Register A with Register C, the byte to output.
564A
POP BC C1
Restore Register Pair BC, which the ROM's 032AH saved, from the top of the stack.
564B
LD IX,(570EH) DD 2A 0E 57
Load Index Register IX with the current file area from 570EH-570FH.
564F
JUMP to 5F7AH to write the byte in Register A to the file of Index Register IX.
5652H - The Keyboard Link
Link 41C4H, the ROM's keyboard scan at 0358H. The ROM's return is dropped and the caller is told by its return address. For INKEY$ (01A8H) the keyboard is scanned. For the ROM's wait for a key (0387H) with a current file, the next byte of the file is returned (5F68H); at the end of the file (an ASCII program loaded) file area 0 is closed, and BASIC either RUNs the program (the run flag 570BH) or shows READY and returns a carriage return. Any other scan (the ROM's BREAK tests) gives no key while a DO file runs (bit 5 of SFLAG1$), so the DO file's bytes are not taken by them.
5652
POP AF F1
Restore Register Pair AF with the return address into the ROM's 035BH, which is not used.
5653
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the address the scan returns to.
5654
PUSH DE D5
Save Register Pair DE to the top of the stack.
5655
LD DE,0387H 11 87 03
Load Register Pair DE with 0387H, the return address of the scan in the ROM's wait for a key.
5658
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for the wait for a key.
5659
If the Z FLAG is set (the wait for a key), JUMP to 566EH.
565B
LD DE,01A8H 11 A8 01
Load Register Pair DE with 01A8H, the return address of the scan in the ROM's INKEY$.
565E
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for INKEY$.
565F
POP DE D1
Restore Register Pair DE from the top of the stack.
5660
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): the return address is put back.
5661
If the Z FLAG is set (INKEY$), JUMP to 035BH, the ROM's scan of the keyboard.
5664
LD A,(4297H) 3A 97 42
Load Register A with SFLAG1$ from 4297H, whose bit 5 is set while a DO file runs.
5667
CPL 2F
Complement Register A (CPL): bit 5 is now set when no DO file runs.
5668
AND 20H E6 20
AND Register A with 20H, bit 5: the NZ FLAG when no DO file runs.
566A
If the NZ FLAG is set (no DO file), JUMP to 035BH, the ROM's scan of the keyboard.
566D
RET C9
RETurn with Register A = 00H: no key, while a DO file runs.
566E
LD DE,(570EH) ED 5B 0E 57
Load Register Pair DE with the current file area from 570EH-570FH (0000H: none).
5672
LD A,D 7A
Load Register A with Register D, the high byte of the file area.
5673
OR E B3
OR Register A with Register E: the Z FLAG when there is no current file.
5674
POP DE D1
Restore Register Pair DE from the top of the stack.
5675
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): the return address is put back.
5676
If the Z FLAG is set (no file), JUMP to 035BH, the ROM's scan of the keyboard.
5679
PUSH HL E5
Save Register Pair HL to the top of the stack.
567A
LD IX,(570EH) DD 2A 0E 57
Load Index Register IX with the current file area from 570EH-570FH.
567E
GOSUB to 5F68H to read the next byte of the file into Register A: the C FLAG at the end of the file.
5681
If the NC FLAG is set (a byte), JUMP to 26E7H, the ROM's POP HL and RET, which returns the byte in Register A.
5684
PUSH BC C5
Save Register Pair BC to the top of the stack.
5685
PUSH DE D5
Save Register Pair DE to the top of the stack.
5686
GOSUB to 5BFFH to close file area 0, the file that was loaded.
5689
POP DE D1
Restore Register Pair DE from the top of the stack.
568A
POP BC C1
Restore Register Pair BC from the top of the stack.
568B
LD A,(570BH) 3A 0B 57
Load Register A with the run flag from 570BH: not 00H when the program is to be run.
568E
OR A B7
OR Register A against itself: the NZ FLAG for a run.
568F
LD HL,1D1EH 21 1E 1D
Point Register Pair HL to 1D1EH, the ROM's loop that runs the statements.
5692
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): 1D1EH becomes the return address.
5693
If the NZ FLAG is set (the run flag), JUMP to 1B5DH, the ROM's RUN, which returns into 1D1EH.
5696
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL is put back.
5697
PUSH BC C5
Save Register Pair BC to the top of the stack.
5698
PUSH DE D5
Save Register Pair DE to the top of the stack.
5699
LD HL,1929H 21 29 19
Point Register Pair HL to 1929H, the ROM's text READY.
569C
GOSUB to 28A7H, the ROM's routine that shows the text at Register Pair HL up to its 00H.
569F
POP DE D1
Restore Register Pair DE from the top of the stack.
56A0
POP BC C1
Restore Register Pair BC from the top of the stack.
56A1
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return returned as the key.
56A3
POP HL E1
Restore Register Pair HL from the top of the stack.
56A4
RET C9
RETurn with the carriage return in Register A.
56A5H - SYSTEM
Link 41E2H, called by the ROM's SYSTEM (02B2H) before its prompt. The stack is put back to 4288H, the prompt (an asterisk and the ROM's question mark) is shown and a line is taken by the ROM's 1BB3H. A line goes to the ROM's SYSTEM at 02C6H; BREAK goes back to BASIC's READY (52C8H).
56A5
LD SP,4288H 31 88 42
Load the Stack Pointer with 4288H, the stack of the ROM's SYSTEM.
56A8
GOSUB to 20FEH, the ROM's routine that starts a new line on the display when the cursor is not at its start.
56AB
LD A,2AH 3E 2A
Load Register A with 2AH, the asterisk of the prompt of SYSTEM.
56AD
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device.
56B0
GOSUB to 1BB3H, the ROM's input of a line after a question mark: the C FLAG for BREAK.
56B3
JP NC,02C6H D2 C6 02
If the NC FLAG is set (a line), JUMP to 02C6H, the ROM's SYSTEM, to take the name or the address.
56B6
JUMP to 52C8H, BASIC's return to READY: BREAK at the prompt leaves SYSTEM.
56B9H - Comma and TAB
Link 41D3H, called by the ROM's PRINT for a comma (2108H) and for TAB (2141H). With a current file the file area's column byte (+01H) takes the place of the device's position: the comma goes on at the ROM's 2130H and TAB at 2156H. Without a file the comma goes back to 210BH; TAB to the printer (409CH = 01H) evaluates its argument again from the TAB( token, so that the ROM's AND 7FH is left out and the printer can be tabbed up to 255; TAB elsewhere goes back to 2144H.
56B9
LD HL,(570EH) 2A 0E 57
Load Register Pair HL with the current file area from 570EH-570FH (0000H: none).
56BC
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
56BD
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
56BE
INC HL 23
INCrement Register Pair HL by 1, to the column byte of the file area (the flags are kept).
56BF
LD A,(HL) 7E
Load Register A with the file's column at Register Pair HL, the characters on its line.
56C0
POP HL E1
Restore Register Pair HL with the ROM's return address, which tells comma and TAB apart.
56C1
PUSH AF F5
Save Register Pair AF, the column and the Z FLAG of no file, to the top of the stack.
56C2
PUSH DE D5
Save Register Pair DE to the top of the stack.
56C3
LD DE,2130H 11 30 21
Load Register Pair DE with 2130H, between the ROM's two calls: the C FLAG below for the comma.
56C6
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG for the comma (210BH), the NC FLAG for TAB (2144H).
56C7
POP DE D1
Restore Register Pair DE from the top of the stack.
56C8
If the NC FLAG is set (TAB), JUMP to 56D1H for the TAB of a file or the printer.
56CA
POP AF F1
Restore Register Pair AF, the column and the flags, from the top of the stack.
56CB
If the NZ FLAG is set (a file), JUMP to 2130H, the ROM's comma, with the file's column in Register A.
56CE
JUMP to 210BH, the ROM's comma for its own devices.
56D1
POP AF F1
Restore Register Pair AF, the column and the flags, from the top of the stack.
56D2
If the NZ FLAG is set (a file), JUMP to 2156H, the ROM's TAB, with the file's column in Register A.
56D5
LD A,(409CH) 3A 9C 40
Load Register A with the ROM's output device from 409CH: 01H for the printer.
56D8
DEC A 3D
DECrement Register A by 1: the Z FLAG for the printer.
56D9
If the NZ FLAG is set (not the printer), JUMP to 2144H, the ROM's TAB.
56DC
POP HL E1
Restore Register Pair HL, the text pointer the ROM saved at 2140H, from the top of the stack.
56DD
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack again for the ROM.
56DE
DEC HL 2B
DECrement Register Pair HL by 1, one character back in the text.
56DF
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
56E0
CP BCH FE BC
Compare Register A against BCH, the token of TAB(.
56E2
If the NZ FLAG is set (not yet the token), LOOP back to 56DEH.
56E4
GOSUB to 2B1BH, the ROM's evaluation of the byte in the parentheses after the token: Register E the whole value.
56E7
JUMP to 2144H, the ROM's TAB, with the value in Register E.
56EAH - The Current File
Four links that keep the current file area (570EH-570FH): 41BEH (the end of PRINT, the ROM's 2174H after it set Register A to 00H) ends it; 41B5H (1AECH) saves it into 40F3H-40F4H over the ROM's 1B5DH when a program line is entered, and 41B8H (1AF2H) restores it; 41CDH (20C6H) sends a number to a file without the ROM's test of the line's room (20E9H).
56EA
LD (570EH),A 32 0E 57
Store Register A (00H from the ROM's 2170H) to 570EH, the low byte of the current file area.
56ED
LD (570FH),A 32 0F 57
Store Register A (00H) to 570FH, the high byte: no current file.
56F0
RET C9
RETurn to the ROM's PRINT with no current file.
56F1
LD HL,(570EH) 2A 0E 57
Load Register Pair HL with the current file area from 570EH-570FH.
56F4
LD (40F3H),HL 22 F3 40
Store Register Pair HL, the current file area, into 40F3H-40F4H while the ROM's 1B5DH runs.
56F7
RET C9
RETurn to the ROM's entry of a program line, which goes on to 1B5DH.
56F8
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the saved file area from 40F3H-40F4H.
56FB
LD (570EH),HL 22 0E 57
Store Register Pair HL into 570EH-570FH, the current file area again.
56FE
RET C9
RETurn to the ROM's entry of a program line with the file area back.
56FF
LD HL,(570EH) 2A 0E 57
Load Register Pair HL with the current file area from 570EH-570FH (0000H: none).
5702
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
5703
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
5704
RET Z C8
If the Z FLAG is set (no file), RETurn to the ROM's PRINT of the number.
5705
POP HL E1
Restore Register Pair HL with the ROM's return address, which is not used.
5706
JUMP to 20E9H, the ROM's output of the number's string, without the test of the room on the line.
5709H - The Variables
Link 41D0H (the ROM's 2103H, after PRINT's carriage return) is a RET. Then TBASIC's variables: 570AH-570BH are loaded, 570CH-572FH are not.
5709
RET C9
RETurn: BASIC has nothing to do after PRINT's carriage return (the link 41D0H).
570A
DEFB 00H 00
The last DOS error code (607CH), shown again by CMD"E".
570B
DEFB 00H 00
The run flag: not 00H when LOAD ,R or RUN is to run the program once it is loaded (5A8FH, 5C25H).
570C
DEFS 1
The number of files the program may open, 0-15 (-F:nn; 01H by default).
570D
DEFS 1
The protection level of a program loaded and run with an access level of 6 or 7 (5F22H); 601DH wipes such a program at READY.
570E-570F
DEFS 2
The current file area (Index Register IX) of PRINT #, INPUT #, LOAD and SAVE ,A; 0000H when there is none.
5710-572F
DEFS 32
The addresses of the file areas 0-15, one word each (5825H).
5730H - Start-up
TBASIC/CMD's transfer address. Entered from the DOS with Register Pair HL at the rest of the command line after TBASIC. It puts the stack at 4288H, sets RST 10H to the ROM's own 1D78H, puts 52C8H into the vector at 4203H-4205H and copies the 49 Disk BASIC links (585AH) to 4152H-41E4H. A command line starting with * is the re-entry TBASIC * (581BH). Otherwise it copies the ROM's RAM table to 4080H, takes the file specification and the options -F:nn (files, 0-15) and -M:nnnnn (top of memory), sets up the file areas (5825H), the program start and the top of memory, clears the program (NEW), and either shows the heading and goes to READY, or loads and runs the program named. The start-up is the code of BASIC/CMD's at new addresses, except the RST 10H vector.
5730
LD SP,4288H 31 88 42
Load the Stack Pointer with 4288H, the ROM's stack area in the input buffer region, for the start-up of BASIC.
5733
LD A,(HL) 7E
Load Register A with the first character of the command line at Register Pair HL, tested for the asterisk at 574EH.
5734
LD (5777H),HL 22 77 57
Store Register Pair HL, the command line pointer, into 5777H-5778H, the operand of LD HL,0000H at 5776H.
5737
LD HL,1D78H 21 78 1D
Point Register Pair HL to 1D78H, the ROM's own RST 10H code (the next character of the text): TBASIC has no RST 10H hook of its own.
573A
LD (4004H),HL 22 04 40
Store Register Pair HL (1D78H) into 4004H-4005H, the operand of the JP at 4003H, the RST 10H vector.
573D
LD HL,52C8H 21 C8 52
Point Register Pair HL to 52C8H, BASIC's return to READY with a new stack.
5740
LD (4204H),HL 22 04 42
Store Register Pair HL (52C8H) into 4204H-4205H: on the Model III the operand of the BREAK vector JP at 4203H; on the Model I these bytes are in DOSPLUS's buffer 4200H-42FFH and are not a vector.
5743
LD DE,4152H 11 52 41
Point Register Pair DE to 4152H, the first of the Disk BASIC links (4152H-41E4H) that the ROM calls or jumps to.
5746
LD HL,585AH 21 5A 58
Point Register Pair HL to 585AH, BASIC's table of the 49 links, three bytes each (JP nnnnH).
5749
LD BC,0093H 01 93 00
Load Register Pair BC with 0093H, the length of the 49 links: 147 bytes.
574C
LDIR ED B0
Copy the 147 bytes from Register Pair HL (585AH) to Register Pair DE (4152H) by LDIR, counted by Register Pair BC.
574E
CP 2AH FE 2A
Compare Register A, the first character of the command line, against 2AH, the asterisk of BASIC followed by an asterisk (re-entry).
5750
If the Z FLAG is set (the re-entry), JUMP to 581BH to go back to the program in memory.
5753
LD DE,4080H 11 80 40
Point Register Pair DE to 4080H, the ROM's RAM area of the division routine and the BASIC variables.
5756
LD HL,18F7H 21 F7 18
Point Register Pair HL to 18F7H, the ROM's table that its power up copies to 4080H.
5759
LD C,27H 0E 27
Load Register C with 27H, the 39 bytes of the table (Register B is 00H after the LDIR above).
575B
LDIR ED B0
Copy the 39 bytes from Register Pair HL (18F7H) to Register Pair DE (4080H) by LDIR, counted by Register Pair BC.
575D
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HMEM$ from 4411H-4412H, the highest address the DOS lets a program use.
5760
LD (57CAH),HL 22 CA 57
Store Register Pair HL (HMEM$) into 57CAH-57CBH, the operand of LD DE,0000H at 57C9H: the top of memory when no -M option is given.
5763
LD HL,60B6H 21 B6 60
Point Register Pair HL to 60B6H, BASIC's input buffer of 256 bytes (60B6H-61B5H, not loaded).
5766
LD (40A7H),HL 22 A7 40
Store Register Pair HL (60B6H) into 40A7H-40A8H, the ROM's pointer to the input buffer.
5769
XOR A AF
Set Register A to 00H by XORing it with itself, for the counter and the flag below.
576A
LD B,A 47
Load Register B with Register A (00H): the length of the file specification, counted at 5789H.
576B
LD (570DH),A 32 0D 57
Store Register A (00H) to 570DH, the protection flag of the program in memory (5F22H): none.
576E
LD A,01H 3E 01
Load Register A with 01H, the number of files when no -F option is given.
5770
LD (570CH),A 32 0C 57
Store Register A (01H) to 570CH, the number of files BASIC may open.
5773
LD DE,60B6H 11 B6 60
Point Register Pair DE to 60B6H, the input buffer, where the file specification is collected.
5776
LD HL,0000H 21 00 00
Load Register Pair HL with the command line pointer, the operand 5777H-5778H (0000H in the file) stored at 5734H.
5779
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below takes the first character of the command line.
577A
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character that is not a space (the ROM's 1D78H).
577B
CP 20H FE 20
Compare Register A against 20H, the space: the C FLAG for a control character, the end of the command line.
577D
If the C FLAG is set (the end of the line), JUMP to 57BFH to set up the memory.
577F
CP 3BH FE 3B
Compare Register A against 3BH, the character ; that also ends a command.
5781
If the Z FLAG is set (;), JUMP to 57BFH to set up the memory.
5783
CP 2DH FE 2D
Compare Register A against 2DH, the character - that starts an option.
5785
If the Z FLAG is set (-), JUMP to 5795H to take the option.
5787
LD (DE),A 12
Store Register A, a character of the file specification, at Register Pair DE in the input buffer.
5788
INC DE 13
INCrement Register Pair DE by 1, to the next byte of the input buffer.
5789
INC B 04
INCrement Register B by 1, the length of the file specification.
578A
LD A,B 78
Load Register A with Register B, the length of the file specification so far.
578B
CP 18H FE 18
Compare Register A against 18H: the NC FLAG when the file specification reaches 24 characters.
578D
If the NC FLAG is set (24 characters or more), JUMP to 6068H, the error Bad file name.
5790
LD (57FBH),A 32 FB 57
Store Register A, the length, to 57FBH, the operand of LD C,00H at 57FAH.
5793
LOOP back to 577AH for the next character of the command line.
5795
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the letter of the option after the -.
5796
RES 5,A CB AF
RESET bit 5 of Register A, which makes a lower case letter upper case.
5798
CP 4DH FE 4D
Compare Register A against 4DH, the letter M of -M:nnnnn, the top of memory.
579A
If the Z FLAG is set (M), JUMP to 57B6H to take the top of memory.
579C
CP 46H FE 46
Compare Register A against 46H, the letter F of -F:nn, the number of files.
579E
If the NZ FLAG is set (neither F nor M), JUMP to 1E4AH, the ROM's Illegal function call error.
57A1
GOSUB to 5844H to take :nnnnn into Register Pair DE: the Z FLAG when another - follows.
57A4
PUSH AF F5
Save Register Pair AF, the flags of the end of the option, to the top of the stack.
57A5
LD A,D 7A
Load Register A with Register D, the high byte of the number of files.
57A6
OR A B7
OR Register A against itself: the NZ FLAG when the number is 256 or more.
57A7
If the NZ FLAG is set, JUMP to 6074H, the error Too many files.
57AA
LD A,E 7B
Load Register A with Register E, the low byte of the number of files.
57AB
CP 10H FE 10
Compare Register A against 10H: the NC FLAG for 16 files or more.
57AD
If the NC FLAG is set (16 or more), JUMP to 6074H, the error Too many files.
57B0
LD (570CH),A 32 0C 57
Store Register A, the number of files (0-15), to 570CH.
57B3
POP AF F1
Restore Register Pair AF, the flags of the end of the option, from the top of the stack.
57B4
JUMP to 57BDH, the test for another option after this one.
57B6
GOSUB to 5844H to take :nnnnn into Register Pair DE: the Z FLAG when another - follows.
57B9
LD (57CAH),DE ED 53 CA 57
Store Register Pair DE, the top of memory of -M, into 57CAH-57CBH, the operand of LD DE,0000H at 57C9H.
57BD
If the Z FLAG is set (another - follows), LOOP back to 5795H to take that option.
57BF
XOR A AF
Set Register A to 00H by XORing it with itself, and clear the C FLAG: every file area is marked closed.
57C0
GOSUB to 5825H to build the table of the file areas from 61B7H: Register Pair HL returns the end of the last area.
57C3
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte before the first line of the program.
57C5
INC HL 23
INCrement Register Pair HL by 1, to the start of the program.
57C6
LD (40A4H),HL 22 A4 40
Store Register Pair HL into 40A4H-40A5H, the ROM's pointer to the start of the program text.
57C9
LD DE,0000H 11 00 00
Load Register Pair DE with the top of memory, the operand 57CAH-57CBH (0000H in the file): HMEM$ or the value of -M.
57CC
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HMEM$ from 4411H-4412H, the highest address the DOS allows.
57CF
RST 18H DF
RST 18H: compare Register Pair HL (HMEM$) with Register Pair DE (the top asked for): the C FLAG when the top is above HMEM$.
57D0
If the C FLAG is set (-M above HMEM$), JUMP to 197AH, the ROM's Out of memory error.
57D3
DEC DE 1B
DECrement Register Pair DE by 1: the last byte BASIC may use is the one below the top.
57D4
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
57D7
LD BC,012CH 01 2C 01
Load Register Pair BC with 012CH, 300 bytes, the least room BASIC needs above the start of the program.
57DA
ADD HL,BC 09
ADD Register Pair BC (300) to Register Pair HL, the start of the program.
57DB
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the last byte, Register Pair DE = the start plus 300.
57DC
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG when the memory is less than 300 bytes.
57DD
If the C FLAG is set (too little memory), JUMP to 197AH, the ROM's Out of memory error.
57E0
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, minus 50: the string space starts 50 bytes below the top.
57E3
LD (40B1H),HL 22 B1 40
Store Register Pair HL, the last byte BASIC may use, into 40B1H-40B2H, the ROM's top of memory.
57E6
ADD HL,DE 19
ADD Register Pair DE (minus 50) to Register Pair HL, the top of memory.
57E7
LD (40A0H),HL 22 A0 40
Store Register Pair HL into 40A0H-40A1H, the ROM's start of the string space: 50 bytes, as the ROM's own CLEAR 50.
57EA
GOSUB to 1B4DH, the ROM's NEW: an empty program and no variables.
57ED
LD A,(57FBH) 3A FB 57
Load Register A with the length of the file specification from 57FBH, the operand of LD C,00H at 57FAH.
57F0
OR A B7
OR Register A against itself: the Z FLAG when no program was named.
57F1
If the Z FLAG is set (no program), JUMP to 5812H to show the heading.
57F3
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
57F4
GOSUB to 596CH for file area 0: Index Register IX the area, Register Pair DE its file control block.
57F7
LD HL,60B6H 21 B6 60
Point Register Pair HL to 60B6H, the file specification collected in the input buffer.
57FA
LD C,00H 0E 00
Load Register C with the length of the file specification: the operand 57FBH (00H in the file) stored at 5790H.
57FC
GOSUB to 5E82H to copy the file specification at Register Pair HL into the file control block at Register Pair DE, with 03H after it.
57FF
LD A,FFH 3E FF
Load Register A with FFH, the flag that the program is to be run after it is loaded.
5801
LD (570BH),A 32 0B 57
Store Register A (FFH) to 570BH, the run flag of LOAD (5A8FH).
5804
LD A,01H 3E 01
Load Register A with 01H, the mode of a file opened for input.
5806
GOSUB to 5EE5H to open file area 0 for input with OPEN@.
5809
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the line to start at: the first line.
580C
LD (40F3H),HL 22 F3 40
Store Register Pair HL (0000H) into 40F3H-40F4H, the line number that LOAD's run starts at (5B9DH).
580F
JUMP to 5AE8H to load the program from file area 0 and run it.
5812
LD HL,58EDH 21 ED 58
Point Register Pair HL to 58EDH, the heading of BASIC with its copyright line.
5815
GOSUB to 28A7H, the ROM's routine that shows the text at Register Pair HL up to its 00H.
5818
JUMP to 1A19H, the ROM's READY, with the empty program.
581B
SCF 37
Set the C FLAG: the file areas keep their contents, so the open files of the program stay open.
581C
GOSUB to 5825H to build the table of the file areas again (the number of files is still in 570CH).
581F
LD BC,2B2EH 01 2E 2B
Load Register Pair BC with 2B2EH, the ROM's LIST, where the reset of the stack goes on.
5822
JUMP to 19AEH, the ROM's routine that resets the stack and the BASIC pointers and continues at Register Pair BC: LIST shows the program.
5825H - The File Areas
Builds the table 5710H of the addresses of the file areas: one area for each file (570CH) and one more, area 0, that LOAD, RUN, SAVE, MERGE and KILL use. The areas are 0222H bytes each from 61B7H: the mode byte, the column byte, the file control block (32 bytes) and two buffers of 256 bytes. With the C FLAG clear the first byte of each area is set to 00H (closed). Register Pair HL returns the end of the last area, where the program starts.
5825
LD HL,570CH 21 0C 57
Point Register Pair HL to 570CH, the number of files.
5828
LD B,(HL) 46
Load Register B with the number of files at Register Pair HL.
5829
INC B 04
INCrement Register B by 1, for file area 0, which is always there.
582A
LD HL,61B7H 21 B7 61
Point Register Pair HL to 61B7H, the first file area.
582D
LD DE,5710H 11 10 57
Point Register Pair DE to 5710H, the table of the addresses of the file areas.
5830
If the C FLAG is set (the re-entry), JUMP to 5834H: the area keeps its mode byte.
5832
LD (HL),00H 36 00
Store 00H at Register Pair HL, the mode byte of the area: closed.
5834
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the table entry, Register Pair DE = the area.
5835
LD (HL),E 73
Store Register E, the low byte of the area's address, at Register Pair HL in the table.
5836
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the table entry.
5837
LD (HL),D 72
Store Register D, the high byte of the area's address, at Register Pair HL in the table.
5838
INC HL 23
INCrement Register Pair HL by 1, to the next table entry.
5839
PUSH AF F5
Save Register Pair AF, the C FLAG, to the top of the stack.
583A
PUSH HL E5
Save Register Pair HL, the next table entry, to the top of the stack.
583B
LD HL,0222H 21 22 02
Load Register Pair HL with 0222H, the length of a file area: 546 bytes.
583E
ADD HL,DE 19
ADD Register Pair DE, the area, to Register Pair HL: Register Pair HL = the next area.
583F
POP DE D1
Restore Register Pair DE, the next table entry, from the top of the stack.
5840
POP AF F1
Restore Register Pair AF, the C FLAG, from the top of the stack.
5841
DECrement Register B and LOOP back to 5830H for the next file area.
5843
RET C9
RETurn with Register Pair HL = the end of the last file area.
5844H - The Value of an Option
Takes :nnnnn after the letter of an option: the number goes to Register Pair DE. Returns the Z FLAG when a - follows (another option), the NZ FLAG at the end of the command line or at ;. Anything else is a syntax error.
5844
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character, which must be the colon.
5845
CP 3AH FE 3A
Compare Register A against 3AH, the colon between the letter of the option and its value.
5847
If the NZ FLAG is set (no colon), JUMP to 1997H, the ROM's Syntax error.
584A
GOSUB to 1E5BH, the ROM's decimal number scan: the number into Register Pair DE, Register A the character after it.
584D
CP 2DH FE 2D
Compare Register A against 2DH, the character - of another option.
584F
RET Z C8
If the Z FLAG is set (-), RETurn with the Z FLAG.
5850
CP 20H FE 20
Compare Register A against 20H, the space: the C FLAG for a control character, the end of the line.
5852
RET C D8
If the C FLAG is set (the end of the line), RETurn with the NZ FLAG.
5853
CP 3BH FE 3B
Compare Register A against 3BH, the character ; that ends a command.
5855
If the NZ FLAG is set (anything else), JUMP to 1997H, the ROM's Syntax error.
5858
OR A B7
OR Register A against itself (3BH): the NZ FLAG for the end of the options.
5859
RET C9
RETurn with the NZ FLAG: no other option follows this one.
585AH - The Disk BASIC Links
Data: the 49 jumps that the start-up copies to 4152H-41E4H, where the ROM calls or jumps to the Disk BASIC functions, statements and hooks. Each row names the link it becomes.
585A
JUMP to 59A5H: becomes the link 4152H, CVI, which the ROM reaches through that link.
585D
JUMP to 5379H: becomes the link 4155H, FN (a user function defined by DEF FN).
5860
JUMP to 59A8H: becomes the link 4158H, CVS, which the ROM reaches through that link.
5863
JUMP to 52FEH: becomes the link 415BH, DEF (DEF FN and DEFUSR), which the ROM reaches through that link.
5866
JUMP to 59ABH: becomes the link 415EH, CVD, which the ROM reaches through that link.
5869
JUMP to 5DD1H: becomes the link 4161H, EOF, which the ROM reaches through that link.
586C
JUMP to 5DE6H: becomes the link 4164H, LOC, which the ROM reaches through that link.
586F
JUMP to 5DF3H: becomes the link 4167H, LOF, which the ROM reaches through that link.
5872
JUMP to 598CH: becomes the link 416AH, MKI$, which the ROM reaches through that link.
5875
JUMP to 598FH: becomes the link 416DH, MKS$, which the ROM reaches through that link.
5878
JUMP to 5992H: becomes the link 4170H, MKD$, which the ROM reaches through that link.
587B
JUMP to 5299H: becomes the link 4173H, CMD, which the ROM reaches through that link.
587E
JUMP to 52E8H: becomes the link 4176H, TIME$, which the ROM reaches through that link.
5881
JUMP to 5E92H: becomes the link 4179H, OPEN, which the ROM reaches through that link.
5884
JUMP to 5CDFH: becomes the link 417CH, FIELD, which the ROM reaches through that link.
5887
JUMP to 5E00H: becomes the link 417FH, GET, which the ROM reaches through that link.
588A
JUMP to 5DFFH: becomes the link 4182H, PUT, which the ROM reaches through that link.
588D
JUMP to 5CAFH: becomes the link 4185H, CLOSE, which the ROM reaches through that link.
5890
JUMP to 5A8EH: becomes the link 4188H, LOAD, which the ROM reaches through that link.
5893
JUMP to 5C23H: becomes the link 418BH, MERGE, which the ROM reaches through that link.
5896
JUMP to 1E4AH, the ROM's Illegal function call error: becomes the link 418EH, NAME, which TBASIC does not have (labels are BASIC/CMD's).
5899
JUMP to 5F50H: becomes the link 4191H, KILL, which the ROM reaches through that link.
589C
JUMP to 557CH: becomes the link 4194H, the & of &H hexadecimal constants.
589F
JUMP to 5D30H: becomes the link 4197H, LSET, which the ROM reaches through that link.
58A2
JUMP to 5D2FH: becomes the link 419AH, RSET, which the ROM reaches through that link.
58A5
JUMP to 5475H: becomes the link 419DH, INSTR, which the ROM reaches through that link.
58A8
JUMP to 5C61H: becomes the link 41A0H, SAVE, which the ROM reaches through that link.
58AB
JUMP to 55D2H: becomes the link 41A3H, LINE (LINE INPUT), which the ROM reaches through that link.
58AE
JUMP to 5258H: becomes the link 41A6H, the error hook of the ROM's error routine (TBASIC's two letter codes).
58B1
JUMP to 543EH: becomes the link 41A9H, USR, which the ROM reaches through that link.
58B4
JUMP to 5BFFH: becomes the link 41ACH, READY (file area 0 closed), which the ROM reaches through that link.
58B7
JUMP to 5612H: becomes the link 41AFH, the keyboard line input (a program line from a file during LOAD and MERGE).
58BA
JUMP to 5C50H: becomes the link 41B2H, after a line has been tokenized (direct statements in a file).
58BD
JUMP to 56F1H: becomes the link 41B5H, after the program's line pointers are fixed.
58C0
JUMP to 56F8H: becomes the link 41B8H, after a line has been entered and CLEAR done.
58C3
JUMP to 5CD5H: becomes the link 41BBH, NEW and END: close every file, which the ROM reaches through that link.
58C6
JUMP to 56EAH: becomes the link 41BEH, the end of PRINT: no file for the output.
58C9
JUMP to 563FH: becomes the link 41C1H, the output of a byte: to the file of PRINT # when one is selected.
58CC
JUMP to 5652H: becomes the link 41C4H, the keyboard scan: the file of INPUT # or of LOAD when one is selected.
58CF
JUMP to 5A8BH: becomes the link 41C7H, RUN with a file name, which the ROM reaches through that link.
58D2
JUMP to 55B0H: becomes the link 41CAH, PRINT: the # of PRINT #, which the ROM reaches through that link.
58D5
JUMP to 56FFH: becomes the link 41CDH, PRINT of a number to a file, which the ROM reaches through that link.
58D8
JUMP to 5709H: becomes the link 41D0H, after PRINT's carriage return (a RET).
58DB
JUMP to 56B9H: becomes the link 41D3H, the comma and TAB of PRINT with a file.
58DE
JUMP to 55BCH: becomes the link 41D6H, INPUT: the # of INPUT #.
58E1
JUMP to 54FDH: becomes the link 41D9H, MID$ on the left of an assignment.
58E4
JUMP to 59C2H: becomes the link 41DCH, the items of INPUT # from a file.
58E7
JUMP to 55FCH: becomes the link 41DFH, the end of INPUT and the end of a listed line.
58EA
JUMP to 56A5H: becomes the link 41E2H, SYSTEM: the ROM's prompt of SYSTEM.
58EDH - The Heading
Data: the heading that the start-up shows when no program is named (5812H).
58ED-5912
DEFM "TBASIC - DOSPLUS Tiny disk BASIC - 1.7" 54 42 41 53 49 43 20 2D 20 44 4F 53 50 4C 55 53 20 54 69 6E 79 20 64 69 73 6B 20 42 41 53 49 43 20 2D 20 31 2E 37
The first line of the heading: the name and the version of TBASIC/CMD.
5913
DEFB 0DH 0D
The carriage return that ends the first line of the heading.
5914-5942
DEFM "(c) Copyright 1983, Micro-Systems Software Inc." 28 63 29 20 43 6F 70 79 72 69 67 68 74 20 31 39 38 33 2C 20 4D 69 63 72 6F 2D 53 79 73 74 65 6D 73 20 53 6F 66 74 77 61 72 65 20 49 6E 63 2E
The second line of the heading: the copyright notice.
5943-5945
DEFB 0DH,0DH,00H 0D 0D 00
Two carriage returns (the end of the copyright line and an empty line before READY) and the 00H that ends the heading for the ROM's 28A7H.
5946H - The File Number
5946H (mode 01H, input) and 5948H (mode in Register C) take #n, followed by a comma, at Register Pair HL: the file must be open in that mode (else Bad file mode), and its area becomes the current file (570EH). Without # they return at once. 595BH evaluates the file number: 0 is Bad record number (606BH), above the number of files Bad file number (596CH). 596CH: Register A = a file number; returns Index Register IX = its area, Register Pair DE = the area's file control block (+02H), Register A = the mode byte and the Z FLAG when the file is closed.
5946
LD C,01H 0E 01
Load Register C with 01H, the mode of a file open for input.
5948
CP 23H FE 23
Compare Register A, the character at the text, against 23H, the # of a file number.
594A
RET NZ C0
If the NZ FLAG is set (no #), RETurn: the statement has no file number.
594B
PUSH BC C5
Save Register Pair BC, the mode wanted in Register C, to the top of the stack.
594C
GOSUB to 595BH to evaluate the file number and find its area: Register A returns its mode.
594F
POP BC C1
Restore Register Pair BC, the mode wanted in Register C, from the top of the stack.
5950
CP C B9
Compare Register A, the file's mode, against Register C, the mode wanted.
5951
If the NZ FLAG is set (another mode, or closed), JUMP to 6059H, the error Bad file mode.
5954
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the file number, or the ROM shows a Syntax error.
5956
LD (570EH),IX DD 22 0E 57
Store Index Register IX, the file's area, into 570EH-570FH: the current file.
595A
RET C9
RETurn with the file's area current in 570EH-570FH.
595B
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character again.
595C
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character.
595D
CP 23H FE 23
Compare Register A against 23H, the # before the file number.
595F
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code, to pass over it.
5962
GOSUB to 2337H, the ROM's expression evaluator, for the file number at Register Pair HL.
5965
GOSUB to 2B1FH, the ROM's CONINT, to make the file number a byte in Register A.
5968
OR A B7
OR Register A against itself: the Z FLAG for file number 0.
5969
If the Z FLAG is set (file 0), JUMP to 606BH, the error Bad record number.
596C
LD E,A 5F
Load Register E with Register A, the file number.
596D
LD A,(570CH) 3A 0C 57
Load Register A with the number of files from 570CH.
5970
CP E BB
Compare Register A against Register E, the file number: the C FLAG when it is above the number of files.
5971
If the C FLAG is set, JUMP to 605CH, the error Bad file number.
5974
SLA E CB 23
Shift Register E left (SLA): twice the file number, the offset of its word in the table.
5976
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the offset.
5978
LD IX,5710H DD 21 10 57
Point Index Register IX to 5710H, the table of the file areas.
597C
ADD IX,DE DD 19
ADD Register Pair DE, the offset, to Index Register IX: the file's entry in the table.
597E
LD E,(IX+00H) DD 5E 00
Load Register E with the low byte of the area's address from Index Register IX+00H.
5981
LD D,(IX+01H) DD 56 01
Load Register D with the high byte of the area's address from Index Register IX+01H.
5984
LD A,(DE) 1A
Load Register A with the mode byte of the area at Register Pair DE: 00H closed.
5985
PUSH DE D5
Save Register Pair DE, the area, to the top of the stack.
5986
POP IX DD E1
Restore Index Register IX with the area from the top of the stack.
5988
INC DE 13
INCrement Register Pair DE by 1, to the column byte of the area.
5989
INC DE 13
INCrement Register Pair DE by 1, to the file control block of the area.
598A
OR A B7
OR Register A against itself: the Z FLAG when the file is closed.
598B
RET C9
RETurn with Index Register IX the area and Register Pair DE its file control block.
598CH - MKI$, MKS$ and MKD$
Links 416AH (598CH, MKI$: 2 bytes), 416DH (598FH, MKS$: 4 bytes) and 4170H (5992H, MKD$: 8 bytes). The number is converted to that type (the ROM's 2819H) and its bytes become a new string.
598C
LD A,02H 3E 02
MKI$: load Register A with 02H, the type and length of an integer.
598E
LD BC,043EH 01 3E 04
598FH (MKS$) enters inside this LD BC,043EH: its bytes 3EH 04H read as LD A,04H, single precision; from above it only loads Register Pair BC.
5991
LD BC,083EH 01 3E 08
5992H (MKD$) enters inside this LD BC,083EH: its bytes 3EH 08H read as LD A,08H, double precision; from above it only loads Register Pair BC.
5994
PUSH AF F5
Save Register Pair AF, the type in Register A, to the top of the stack.
5995
GOSUB to 2819H, the ROM's conversion of the accumulator to the type in Register A.
5998
POP AF F1
Restore Register Pair AF, the type in Register A, from the top of the stack.
5999
GOSUB to 2857H, the ROM's STRINI, to make room for a string of Register A bytes with its descriptor at 40D3H.
599C
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the address of the new string from 40D4H-40D5H.
599F
GOSUB to 09FFH, the ROM's copy of the accumulator's value to Register Pair HL by its type.
59A2
JUMP to 2A2BH, the ROM's end of a string function, which makes the new string the result.
59A5H - CVI, CVS and CVD
Links 4152H (59A5H, CVI), 4158H (59A8H, CVS) and 415EH (59ABH, CVD): the first 2, 4 or 8 bytes of the string become the value of that type. A shorter string is Illegal function call.
59A5
LD A,01H 3E 01
CVI: load Register A with 01H, the length of an integer less 1.
59A7
LD BC,033EH 01 3E 03
59A8H (CVS) enters inside this LD BC,033EH: its bytes 3EH 03H read as LD A,03H, single precision; from above it only loads Register Pair BC.
59AA
LD BC,073EH 01 3E 07
59ABH (CVD) enters inside this LD BC,073EH: its bytes 3EH 07H read as LD A,07H, double precision; from above it only loads Register Pair BC.
59AD
PUSH AF F5
Save Register Pair AF, the length less 1 in Register A, to the top of the stack.
59AE
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns the descriptor.
59B1
POP AF F1
Restore Register Pair AF, the length less 1 in Register A, from the top of the stack.
59B2
CP (HL) BE
Compare Register A against the length of the string at Register Pair HL: the NC FLAG when the string is too short.
59B3
If the NC FLAG is set (too short), JUMP to 1E4AH, the ROM's Illegal function call error.
59B6
INC A 3C
INCrement Register A by 1: the type, 02H, 04H or 08H.
59B7
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
59B8
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
59B9
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
59BA
LD H,(HL) 66
Load Register H with the high byte of the string's address at Register Pair HL.
59BB
LD L,C 69
Load Register L with Register C: Register Pair HL = the bytes of the string.
59BC
LD (40AFH),A 32 AF 40
Store Register A, the type, to 40AFH, the ROM's type of the value in the accumulator.
59BF
JUMP to 09F7H, the ROM's copy of the value at Register Pair HL into the accumulator by its type.
59C2H - INPUT # Items and LINE INPUT #
59C2H is the link 41DCH, called by the ROM's INPUT for each item (222DH). With no current file it returns. With a file the ROM's return is dropped and the item is read from the file into the input buffer (59E9H) with the flags in Register D: bit 0 pass over leading spaces, bit 1 a number (a space or a comma ends it), bit 2 a string may be quoted, bit 3 inside the quotes. A number is converted by the ROM's 0E6CH, a string becomes a temporary string (2868H). The item then goes back into the ROM's INPUT at 2243H. LINE INPUT # (59D6H) reads everything up to the carriage return (Register D = 00H) and assigns it through the ROM's 1F31H. A carriage return or the end of the file ends an item; an item of 255 characters ends there. Reading the first byte past the end of the file is Input past end.
59C2
LD DE,(570EH) ED 5B 0E 57
Load Register Pair DE with the current file area from 570EH-570FH (0000H: none).
59C6
LD A,D 7A
Load Register A with Register D, the high byte of the file area.
59C7
OR E B3
OR Register A with Register E: the Z FLAG when there is no current file.
59C8
RET Z C8
If the Z FLAG is set (no file), RETurn: the ROM takes the item from its input buffer.
59C9
POP DE D1
Restore Register Pair DE with the ROM's return address (2230H), which is not used.
59CA
RST 20H E7
RST 20H: test the type of the variable: Register A the type less 3, the Z FLAG for a string.
59CB
LD BC,2243H 01 43 22
Load Register Pair BC with 2243H, where the ROM's INPUT goes on with the item.
59CE
LD D,03H 16 03
Load Register D with 03H, the flags of a number: pass over leading spaces, a space ends it.
59D0
If the NZ FLAG is set (a number), JUMP to 59E9H to read it.
59D2
LD D,05H 16 05
Load Register D with 05H, the flags of a string: pass over leading spaces, it may be quoted.
59D4
JUMP to 59E9H to read the string item from the file.
59D6
GOSUB to 5946H to take #n, open for input, and make its area the current one.
59D9
GOSUB to 260DH, the ROM's variable search, for the variable at Register Pair HL: Register Pair DE returns its descriptor.
59DC
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
59DF
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's reset of the output, where LINE INPUT # ends.
59E2
PUSH BC C5
Save Register Pair BC (2169H) to the top of the stack, the last return address.
59E3
PUSH DE D5
Save Register Pair DE, the variable's descriptor, to the top of the stack for the ROM's assignment.
59E4
LD BC,1F31H 01 31 1F
Load Register Pair BC with 1F31H, the ROM's assignment of LET after its expression.
59E7
XOR A AF
Set Register A to 00H by XORing it with itself: the type less 3 of a string.
59E8
LD D,A 57
Load Register D with Register A (00H): no flags, the whole line up to its carriage return.
59E9
PUSH AF F5
Save Register Pair AF, the type less 3 and its flags, to the top of the stack for the ROM.
59EA
PUSH BC C5
Save Register Pair BC, the address where the ROM goes on, to the top of the stack.
59EB
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
59EC
LD B,FFH 06 FF
Load Register B with FFH, the most characters of an item: 255.
59EE
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
59F1
PUSH HL E5
Save Register Pair HL, the input buffer, to the top of the stack.
59F2
GOSUB to 5F68H to read the next byte of the file into Register A: the C FLAG at the end of the file.
59F5
If the C FLAG is set (nothing left), JUMP to 6062H, the error Input past end.
59F8
CP 20H FE 20
Compare Register A against 20H, the space before or in an item.
59FA
If the NZ FLAG is set (not a space), JUMP to 5A02H.
59FC
BIT 0,D CB 42
Test bit 0 of Register D: the NZ FLAG when leading spaces are passed over.
59FE
If the NZ FLAG is set, LOOP back to 59F2H for the next byte.
5A00
JUMP to 5A11H to keep the space as part of the item.
5A02
CP 22H FE 22
Compare Register A against 22H, the quotation mark.
5A04
If the NZ FLAG is set (not a quotation mark), JUMP to 5A11H.
5A06
BIT 2,D CB 52
Test bit 2 of Register D: the NZ FLAG when the item may be quoted.
5A08
If the Z FLAG is set (no quotes), JUMP to 5A11H to keep the quotation mark.
5A0A
GOSUB to 5F68H to read the byte after the quotation mark into Register A: the C FLAG at the end of the file.
5A0D
If the C FLAG is set (the end of the file), JUMP to 5A6FH to end the item.
5A0F
SET 3,D CB DA
SET bit 3 of Register D: the bytes are now inside the quotes.
5A11
BIT 3,D CB 5A
Test bit 3 of Register D: the NZ FLAG inside the quotes.
5A13
If the NZ FLAG is set (quoted), JUMP to 5A32H.
5A15
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return.
5A17
If the Z FLAG is set (the end of the line), JUMP to 5A6FH to end the item.
5A19
CP 0AH FE 0A
Compare Register A against 0AH, the line feed.
5A1B
If the NZ FLAG is set (not a line feed), JUMP to 5A32H.
5A1D
BIT 2,D CB 52
Test bit 2 of Register D: the Z FLAG for a number or LINE INPUT #.
5A1F
If the Z FLAG is set, GOSUB to 5A84H to keep the line feed in the item.
5A22
GOSUB to 5F68H to read the next byte of the file into Register A: the C FLAG at the end of the file.
5A25
If the C FLAG is set (the end of the file), JUMP to 5A6FH to end the item.
5A27
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return after the line feed.
5A29
If the NZ FLAG is set (another byte), JUMP to 5A32H.
5A2B
BIT 0,D CB 42
Test bit 0 of Register D: the Z FLAG for LINE INPUT #.
5A2D
If the Z FLAG is set, GOSUB to 5A84H to keep the carriage return in the line.
5A30
JUMP to 5A52H: a carriage return after a line feed does not end the item.
5A32
OR A B7
OR Register A against itself: the Z FLAG for a byte 00H.
5A33
If the Z FLAG is set (00H), JUMP to 5A52H: the byte is passed over.
5A35
BIT 0,D CB 42
Test bit 0 of Register D: the Z FLAG for LINE INPUT #.
5A37
If the Z FLAG is set (LINE INPUT #), JUMP to 5A4FH to keep the byte.
5A39
BIT 3,D CB 5A
Test bit 3 of Register D: the NZ FLAG inside the quotes.
5A3B
If the Z FLAG is set (not quoted), JUMP to 5A43H.
5A3D
CP 22H FE 22
Compare Register A against 22H, the closing quotation mark.
5A3F
If the Z FLAG is set (the string ends), JUMP to 5A59H.
5A41
JUMP to 5A4FH to keep the byte of the quoted string.
5A43
CP 2CH FE 2C
Compare Register A against 2CH, the comma between items.
5A45
If the Z FLAG is set (a comma), JUMP to 5A6FH to end the item.
5A47
BIT 1,D CB 4A
Test bit 1 of Register D: the NZ FLAG for a number.
5A49
If the Z FLAG is set (a string), JUMP to 5A4FH to keep the byte.
5A4B
CP 20H FE 20
Compare Register A against 20H, the space that ends a number.
5A4D
If the Z FLAG is set (a space), JUMP to 5A59H.
5A4F
GOSUB to 5A84H to keep the byte in Register A in the item.
5A52
GOSUB to 5F68H to read the next byte of the file into Register A: the C FLAG at the end of the file.
5A55
If the C FLAG is set (the end of the file), JUMP to 5A6FH to end the item.
5A57
LOOP back to 5A11H to look at the byte just read from the file.
5A59
GOSUB to 5F68H to read the next byte of the file into Register A: the C FLAG at the end of the file.
5A5C
If the C FLAG is set (the end of the file), JUMP to 5A6FH to end the item.
5A5E
CP 20H FE 20
Compare Register A against 20H, a space after the item.
5A60
If the Z FLAG is set (a space), LOOP back to 5A59H.
5A62
CP 2CH FE 2C
Compare Register A against 2CH, the comma after the item.
5A64
If the Z FLAG is set (a comma), JUMP to 5A6FH to end the item.
5A66
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return after the item.
5A68
If the Z FLAG is set (the end of the line), JUMP to 5A6FH to end the item.
5A6A
PUSH DE D5
Save Register Pair DE, the flags in Register D, to the top of the stack.
5A6B
GOSUB to 5FAFH to step the file back one byte: the byte is left for the next item.
5A6E
POP DE D1
Restore Register Pair DE, the flags in Register D, from the top of the stack.
5A6F
LD (HL),00H 36 00
Store 00H at Register Pair HL, the end of the item in the buffer.
5A71
POP HL E1
Restore Register Pair HL, the input buffer, from the top of the stack.
5A72
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the buffer.
5A73
BIT 1,D CB 4A
Test bit 1 of Register D: the NZ FLAG for a number.
5A75
If the NZ FLAG is set (a number), JUMP to 5A7EH.
5A77
LD B,00H 06 00
Load Register B with 00H, the byte that ends the item in the buffer.
5A79
GOSUB to 2868H, the ROM's routine that makes the text at Register Pair HL, up to the 00H in Register B, a temporary string.
5A7C
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5A7D
RET C9
RETurn into the ROM at the address in Register Pair BC (2243H or 1F31H) with the string.
5A7E
RST 10H D7
RST 10H: increment Register Pair HL to the first character of the item and load Register A with it.
5A7F
GOSUB to 0E6CH, the ROM's conversion of the text at Register Pair HL to a number in the accumulator.
5A82
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5A83
RET C9
RETurn into the ROM's INPUT at 2243H with the number.
5A84
LD (HL),A 77
Store Register A, the byte, at Register Pair HL in the item.
5A85
INC HL 23
INCrement Register Pair HL by 1, to the next place in the buffer.
5A86
DEC B 05
DECrement Register B by 1, the room left in the item.
5A87
RET NZ C0
If the NZ FLAG is set (room left), RETurn to the reading of the item.
5A88
POP BC C1
Restore Register Pair BC with the return address, which is dropped: the item is full.
5A89
JUMP to 5A6FH to end the item of 255 characters.
5A8BH - RUN and LOAD
Link 41C7H (5A8BH, RUN with a file name or a line number, from the ROM's 1EA6H) and link 4188H (5A8EH, LOAD). RUN of a line number returns to the ROM. Otherwise the file is opened as area 0 for input; ,R sets the run flag and ,V the verify flag (570BH, 5ACAH), or a line number after a comma becomes the line RUN starts at (40F3H). Unless verify, the program is cleared (the ROM's NEW) first. A file whose first byte is not FFH is an ASCII program: it is left open and the command level reads it line by line through the line input link. A compressed program (first byte FFH) is loaded by 5AFCH. Then, for RUN, the program is run from the line in 40F3H.
5A8B
RET C D8
If the C FLAG is set (RUN of a line number, not a string), RETurn to the ROM's RUN.
5A8C
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used.
5A8D
OR AFH F6 AF
RUN: OR Register A with AFH, Register A not 00H, the run flag. LOAD enters at 5A8EH, the AFH operand, which reads as XOR A and sets Register A to 00H, LOAD's run flag.
5A8F
LD (570BH),A 32 0B 57
Store Register A (not 00H for RUN, 00H for LOAD) to 570BH, the run flag.
5A92
XOR A AF
Set Register A to 00H by XORing it with itself.
5A93
LD (5ACAH),A 32 CA 5A
Store Register A (00H) to 5ACAH, the operand of LD A,00H at 5AC9H, the verify flag: not set yet.
5A96
LD D,01H 16 01
Load Register D with 01H, the mode of a file open for input.
5A98
GOSUB to 5EDAH to take the file specification and open it as file area 0 for input: Register Pair HL at the text after it.
5A9B
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the line RUN starts at when none is given.
5A9E
LD (40F3H),DE ED 53 F3 40
Store Register Pair DE into 40F3H-40F4H, the line RUN starts at.
5AA2
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the file again.
5AA3
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
5AA4
If the Z FLAG is set (the end of the statement), JUMP to 5AC2H to load the program.
5AA6
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before an option, or the ROM shows a Syntax error.
5AA8
If the NC FLAG is set (not a digit), JUMP to 5AAFH to test for R or V.
5AAA
GOSUB to 1E5AH, the ROM's scan of a line number at Register Pair HL into Register Pair DE.
5AAD
JUMP back to 5A9EH to store the line number as the line RUN starts at.
5AAF
CP 52H FE 52
Compare Register A against 52H, the letter R, which makes LOAD run the program.
5AB1
If the NZ FLAG is set (not R), JUMP to 5AB8H.
5AB3
LD (570BH),A 32 0B 57
Store Register A (52H) to 570BH, the run flag: the program is run after it is loaded.
5AB6
JUMP back to 5AA3H for the next character after the R option.
5AB8
CP 56H FE 56
Compare Register A against 56H, the letter V, which verifies the load.
5ABA
If the NZ FLAG is set (neither R nor V), JUMP to 1997H, the ROM's Syntax error.
5ABD
LD (5ACAH),A 32 CA 5A
Store Register A (56H) to 5ACAH, the operand of LD A,00H at 5AC9H, the verify flag.
5AC0
JUMP back to 5AA3H for the next character after the V option.
5AC2
LD A,(570BH) 3A 0B 57
Load Register A with the run flag from 570BH: 00H for a plain LOAD.
5AC5
OR A B7
OR Register A against itself: the Z FLAG for a plain LOAD.
5AC6
If the Z FLAG is set (LOAD), GOSUB to 5CD5H to close every open file.
5AC9
LD A,00H 3E 00
Load Register A with the verify flag, the operand 5ACAH: 00H or 56H.
5ACB
OR A B7
OR Register A against itself: the Z FLAG when the load is not a verify.
5ACC
If the NZ FLAG is set (a verify), JUMP to 5AE0H: the program in memory is kept.
5ACE
LD A,(570CH) 3A 0C 57
Load Register A with the number of files from 570CH.
5AD1
LD (5ADCH),A 32 DC 5A
Store Register A to 5ADCH, the operand of LD A,00H at 5ADBH, the number of files saved.
5AD4
XOR A AF
Set Register A to 00H by XORing it with itself.
5AD5
LD (570CH),A 32 0C 57
Store Register A (00H) to 570CH, the number of files, so that the ROM's NEW closes none.
5AD8
GOSUB to 1B4DH, the ROM's NEW, which clears the program and the variables.
5ADB
LD A,00H 3E 00
Load Register A with the number of files saved, the operand 5ADCH (00H in the file).
5ADD
LD (570CH),A 32 0C 57
Store Register A to 570CH, the number of files restored.
5AE0
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
5AE1
GOSUB to 596CH for file area 0: Index Register IX the area, Register Pair DE its file control block.
5AE4
LD (570EH),IX DD 22 0E 57
Store Index Register IX, file area 0, into 570EH-570FH: the current file.
5AE8
GOSUB to 5FC3H to read the first record of the file into its buffer: Register Pair HL at the first byte.
5AEB
LD A,(HL) 7E
Load Register A with the first byte of the file at Register Pair HL.
5AEC
INC A 3C
INCrement Register A by 1: the Z FLAG when the first byte is FFH, a compressed program.
5AED
If the Z FLAG is set (FFH), JUMP to 5AFCH to load the compressed program.
5AEF
GOSUB to 5FA3H to rewind the file to its first record (an ASCII program is read from the start).
5AF2
LD A,(5ACAH) 3A CA 5A
Load Register A with the verify flag from 5ACAH: 56H for ,V.
5AF5
OR A B7
OR Register A against itself: the NZ FLAG for a verify.
5AF6
If the NZ FLAG is set (verify of an ASCII file), JUMP to 6059H, the error Bad file mode.
5AF9
JUMP to 1A33H, the ROM's command level, which reads the ASCII program line by line from the file.
5AFCH - The Compressed Loader
A compressed program's records hold the program text. The program's length is the file's size (the sector count in the file control block and the bytes in the last sector); it must fit below the start of the string space and below the top of memory (else Out of memory). The variable tables (VARTAB, ARYTAB, STREND) are moved up or down by that length to make room, their string pointers adjusted (5BAAH), then the program bytes are read record by record into the text area. The links are rebuilt (the ROM's 1AF8H), the pointers reset and the stack reinitialized.
5AFC
GOSUB to 5BAAH to adjust the string pointers of the variables for the move of the variable tables.
5AFF
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
5B02
LD C,(IX+0AH) DD 4E 0A
Load Register C with the bytes in the last sector from Index Register IX+0AH, the file control block's end of file byte.
5B05
LD B,(IX+0EH) DD 46 0E
Load Register B with the low byte of the sector count from Index Register IX+0EH.
5B08
LD A,(IX+0FH) DD 7E 0F
Load Register A with the high byte of the sector count from Index Register IX+0FH.
5B0B
OR A B7
OR Register A against itself: the NZ FLAG when the program is 256 sectors or more.
5B0C
If the NZ FLAG is set (too long), JUMP to 197AH, the ROM's Out of memory error.
5B0F
DEC BC 0B
DECrement Register Pair BC by 1, toward the program's length in Register Pair BC.
5B10
ADD HL,BC 09
ADD Register Pair BC, the length, to Register Pair HL, the start of the program: the end of the program.
5B11
If the C FLAG is set (past FFFFH), JUMP to 197AH, the ROM's Out of memory error.
5B14
PUSH BC C5
Save Register Pair BC, the program's length, to the top of the stack.
5B15
PUSH HL E5
Save Register Pair HL, the end of the program, to the top of the stack.
5B16
LD DE,(40F9H) ED 5B F9 40
Load Register Pair DE with VARTAB from 40F9H-40FAH, the start of the variables.
5B1A
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with STREND from 40FDH-40FEH, the end of the variables.
5B1D
SBC HL,DE ED 52
SUBtract Register Pair DE, VARTAB, from Register Pair HL: Register Pair HL = the length of the variable tables.
5B1F
LD C,L 4D
Load Register C with Register L, the low byte of the variable length.
5B20
LD B,H 44
Load Register B with Register H: Register Pair BC = the length of the variable tables.
5B21
POP HL E1
Restore Register Pair HL, the end of the program, from the top of the stack.
5B22
SBC HL,DE ED 52
SUBtract Register Pair DE, VARTAB, from Register Pair HL: how far the variable tables move.
5B24
PUSH HL E5
Save Register Pair HL, the distance of the move, to the top of the stack.
5B25
If the C FLAG is set (the program ends below VARTAB), JUMP to 5B43H to move the tables down.
5B27
ADD HL,DE 19
ADD Register Pair DE, VARTAB, back to Register Pair HL: the end of the program again.
5B28
ADD HL,BC 09
ADD Register Pair BC, the variable length, to Register Pair HL: the new end of the variable tables.
5B29
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the new end of the tables.
5B2A
If the C FLAG is set (past FFFFH), JUMP to 197AH, the ROM's Out of memory error.
5B2D
PUSH BC C5
Save Register Pair BC, the variable length, to the top of the stack.
5B2E
LD BC,FFAAH 01 AA FF
Load Register Pair BC with FFAAH, minus 86, the room kept below the top of memory.
5B31
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the top of the string space from 40A0H-40A1H.
5B34
ADD HL,BC 09
ADD Register Pair BC (minus 86) to Register Pair HL, the top of the string space.
5B35
SBC HL,DE ED 52
SUBtract Register Pair DE, the new end of the tables, from Register Pair HL: the C FLAG when there is not room.
5B37
POP BC C1
Restore Register Pair BC, the variable length, from the top of the stack.
5B38
If the C FLAG is set (no room), JUMP to 197AH, the ROM's Out of memory error.
5B3B
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with STREND from 40FDH-40FEH, the last byte to move.
5B3E
INC BC 03
INCrement Register Pair BC by 1, the bytes of the variable tables to move.
5B3F
LDDR ED B8
Copy the variable tables up by Register Pair BC bytes, from Register Pair HL down to Register Pair DE, by LDDR.
5B41
JUMP to 5B48H past the downward move of the tables.
5B43
ADD HL,DE 19
ADD Register Pair DE, VARTAB, to Register Pair HL: the new start of the variable tables.
5B44
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the new start, Register Pair HL = VARTAB.
5B45
INC BC 03
INCrement Register Pair BC by 1, the bytes of the variable tables to move.
5B46
LDIR ED B0
Copy the variable tables down by Register Pair BC bytes, from Register Pair HL to Register Pair DE, by LDIR.
5B48
POP BC C1
Restore Register Pair BC, the distance of the move, from the top of the stack.
5B49
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH.
5B4C
ADD HL,BC 09
ADD Register Pair BC, the distance, to Register Pair HL: the new VARTAB.
5B4D
LD (40F9H),HL 22 F9 40
Store Register Pair HL into 40F9H-40FAH, VARTAB moved.
5B50
LD HL,(40FBH) 2A FB 40
Load Register Pair HL with ARYTAB from 40FBH-40FCH.
5B53
ADD HL,BC 09
ADD Register Pair BC, the distance, to Register Pair HL: the new ARYTAB.
5B54
LD (40FBH),HL 22 FB 40
Store Register Pair HL into 40FBH-40FCH, ARYTAB moved.
5B57
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with STREND from 40FDH-40FEH.
5B5A
ADD HL,BC 09
ADD Register Pair BC, the distance, to Register Pair HL: the new STREND.
5B5B
LD (40FDH),HL 22 FD 40
Store Register Pair HL into 40FDH-40FEH, STREND moved.
5B5E
POP BC C1
Restore Register Pair BC, the program's length, from the top of the stack.
5B5F
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
5B63
GOSUB to 5FCEH to load Register Pair HL with the file's buffer pointer from Index Register IX+05H-06H.
5B66
INC HL 23
INCrement Register Pair HL by 1, past the FFH that marks a compressed file.
5B67
LDI ED A0
Copy one byte of the program from Register Pair HL to Register Pair DE by LDI, counting Register Pair BC down.
5B69
If the PO FLAG is set (the whole program is loaded), JUMP to 5B77H.
5B6C
LD A,(IX+0AH) DD 7E 0A
Load Register A with the bytes in the last sector from Index Register IX+0AH, the record length.
5B6F
CP C B9
Compare Register A against Register C, the low byte of the count left: the Z FLAG at a record boundary.
5B70
PUSH DE D5
Save Register Pair DE, the place in the text area, to the top of the stack.
5B71
If the Z FLAG is set (a record boundary), GOSUB to 5FC3H to read the next record into Register Pair HL.
5B74
POP DE D1
Restore Register Pair DE, the place in the text area, from the top of the stack.
5B75
LOOP back to 5B67H for the next byte of the program.
5B77
GOSUB to 1AF8H, the ROM's routine that rebuilds the links of the program's lines.
5B7A
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
5B7D
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the program.
5B7E
LD (40DFH),HL 22 DF 40
Store Register Pair HL into 40DFH-40E0H, the ROM's text pointer.
5B81
LD (40FFH),HL 22 FF 40
Store Register Pair HL into 40FFH-4100H, the ROM's READ/DATA pointer.
5B84
XOR A AF
Set Register A to 00H by XORing it with itself.
5B85
LD (40F2H),A 32 F2 40
Store Register A (00H) to 40F2H, the ROM's ON ERROR active flag: off.
5B88
LD L,A 6F
Load Register L with Register A (00H), the low byte of 0000H.
5B89
LD H,A 67
Load Register H with Register A (00H): Register Pair HL = 0000H.
5B8A
LD (40F0H),HL 22 F0 40
Store Register Pair HL (0000H) into 40F0H-40F1H, the ROM's ON ERROR line: none.
5B8D
LD (40F7H),HL 22 F7 40
Store Register Pair HL (0000H) into 40F7H-40F8H, the ROM's saved text pointer for CONT: none.
5B90
GOSUB to 1B8FH, the ROM's STKINI, which resets the stack and clears GOSUB and FOR.
5B93
GOSUB to 5BFFH to close file area 0, the program file.
5B96
LD A,(570BH) 3A 0B 57
Load Register A with the run flag from 570BH: 00H for LOAD.
5B99
OR A B7
OR Register A against itself: the Z FLAG for LOAD.
5B9A
If the Z FLAG is set (LOAD), JUMP to 1A19H, the ROM's READY.
5B9D
LD DE,(40F3H) ED 5B F3 40
Load Register Pair DE with the line RUN starts at from 40F3H-40F4H.
5BA1
GOSUB to 1B2CH, the ROM's search for line Register Pair DE: Register Pair BC the line.
5BA4
DEC BC 0B
DECrement Register Pair BC by 1, to the byte before the line's text, for the dispatcher.
5BA5
LD H,B 60
Load Register H with Register B, the high byte of the line.
5BA6
LD L,C 69
Load Register L with Register C: Register Pair HL = the byte before the line.
5BA7
JUMP to 1D1EH, the ROM's run of the program from line Register Pair HL.
5BAAH - Move the String Pointers
Walks the simple variables and then the arrays; for each string whose characters are in the program text (below the start of the variables and above the top of the string space), the ROM's 2843H copies the string into the string space, so it survives the move of the program. Used before the compressed loader moves the variable tables.
5BAA
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the first simple variable.
5BAD
LD DE,(40FDH) ED 5B FD 40
Load Register Pair DE with STREND from 40FDH-40FEH, the end of the variables.
5BB1
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG at the end of the variables.
5BB2
RET Z C8
If the Z FLAG is set (all variables done), RETurn to the loader.
5BB3
LD DE,(40FBH) ED 5B FB 40
Load Register Pair DE with ARYTAB from 40FBH-40FCH, the start of the arrays.
5BB7
LD C,(HL) 4E
Load Register C with the type of the variable at Register Pair HL.
5BB8
INC HL 23
INCrement Register Pair HL by 1, past the type byte.
5BB9
INC HL 23
INCrement Register Pair HL by 1, past the first name byte.
5BBA
INC HL 23
INCrement Register Pair HL by 1, past the second name byte, to the value.
5BBB
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE (ARYTAB): the C FLAG for a simple variable.
5BBC
LD B,00H 06 00
Load Register B with 00H, the high byte of the length in Register Pair BC.
5BBE
LD A,C 79
Load Register A with Register C, the type of the variable.
5BBF
If the C FLAG is set (a simple variable), JUMP to 5BC5H.
5BC1
LD C,(HL) 4E
Load Register C with the low byte of the array's length at Register Pair HL.
5BC2
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the array's length.
5BC3
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL.
5BC4
INC HL 23
INCrement Register Pair HL by 1, past the length word.
5BC5
PUSH HL E5
Save Register Pair HL, the value or the array, to the top of the stack.
5BC6
ADD HL,BC 09
ADD Register Pair BC, the length, to Register Pair HL: the variable or array after this one.
5BC7
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the value, the next one saved.
5BC8
CP 03H FE 03
Compare Register A, the type, against 03H, a string.
5BCA
If the NZ FLAG is set (not a string), JUMP to 5BFCH to the next variable.
5BCC
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE (ARYTAB): the C FLAG for a simple string.
5BCD
If the C FLAG is set (a simple string), JUMP to 5BD7H.
5BCF
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the array of strings.
5BD0
LD A,(DE) 1A
Load Register A with the low byte of the array's dimension count at Register Pair DE.
5BD1
INC DE 13
INCrement Register Pair DE by 1, past the dimension count byte.
5BD2
LD L,A 6F
Load Register L with Register A, the dimension count.
5BD3
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the dimension count.
5BD5
ADD HL,HL 29
ADD Register Pair HL to itself: twice the count, the bytes of the dimensions.
5BD6
ADD HL,DE 19
ADD Register Pair DE, the array, to Register Pair HL: the first string of the array.
5BD7
PUSH HL E5
Save Register Pair HL, the string's descriptor, to the top of the stack.
5BD8
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
5BD9
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
5BDA
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
5BDB
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL.
5BDC
INC HL 23
INCrement Register Pair HL by 1, past the descriptor.
5BDD
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the descriptor, the place after it saved.
5BDE
PUSH HL E5
Save Register Pair HL, the descriptor, to the top of the stack.
5BDF
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
5BE2
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the program's start.
5BE3
POP HL E1
Restore Register Pair HL, the descriptor, from the top of the stack.
5BE4
If the NC FLAG is set (below the program), JUMP to 5BF6H: the string is not moved.
5BE6
PUSH HL E5
Save Register Pair HL, the descriptor, to the top of the stack.
5BE7
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the top of the string space from 40A0H-40A1H.
5BEA
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the string space.
5BEB
POP HL E1
Restore Register Pair HL, the descriptor, from the top of the stack.
5BEC
If the C FLAG is set (in the string space), JUMP to 5BF6H: the string is not moved.
5BEE
PUSH HL E5
Save Register Pair HL, the descriptor, to the top of the stack.
5BEF
GOSUB to 2843H, the ROM's routine that copies the string of the descriptor at Register Pair HL into the string space, with its descriptor at 40D3H.
5BF2
POP HL E1
Restore Register Pair HL, the descriptor, from the top of the stack.
5BF3
GOSUB to 09D3H, the ROM's copy of the new descriptor at 40D3H into the descriptor at Register Pair HL.
5BF6
POP HL E1
Restore Register Pair HL, the place after the descriptor, from the top of the stack.
5BF7
POP DE D1
Restore Register Pair DE, the next variable or array, from the top of the stack.
5BF8
PUSH DE D5
Save Register Pair DE, the next variable or array, to the top of the stack again.
5BF9
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG at the end of this array.
5BFA
If the NZ FLAG is set (more strings in the array), LOOP back to 5BD7H.
5BFC
POP HL E1
Restore Register Pair HL, the next variable or array, from the top of the stack.
5BFD
JUMP back to 5BADH for the next variable of the program.
5BFFH - The READY Link
Link 41ACH, called by the ROM's 1A1CH just before the READY prompt. File area 0 is closed (5C13H), the output is reset (the ROM's 2169H), and when the call is the ROM's READY (its 1A1FH follows) a protected program (570DH) is wiped (601DH), then the ROM's 1BAFH restores its text pointer and goes on.
5BFF
GOSUB to 2169H, the ROM's routine that resets the output to the display and turns the cassette off.
5C02
GOSUB to 5C13H to close file area 0 if it is open.
5C05
POP HL E1
Restore Register Pair HL with the ROM's return address.
5C06
PUSH DE D5
Save Register Pair DE to the top of the stack.
5C07
LD DE,1A1FH 11 1F 1A
Load Register Pair DE with 1A1FH, the address after the ROM's call of this link.
5C0A
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for the call from READY.
5C0B
POP DE D1
Restore Register Pair DE from the top of the stack.
5C0C
PUSH HL E5
Save Register Pair HL, the return address, to the top of the stack.
5C0D
If the Z FLAG is set (from READY), GOSUB to 601DH to wipe a program protected against listing.
5C10
JUMP to 1BAFH, the ROM's code that restores its text pointer and goes on to READY.
5C13H - Close a File Area
Closes the file area whose number is in Register A (0 for area 0). CLOSE@ is called only for a file open for output; the area's mode byte is then set to 00H. An error from CLOSE@ is posted.
5C13
GOSUB to 596CH for the file number in Register A: Register Pair DE the file control block, Register A the area's mode byte, the Z FLAG when it is closed.
5C16
RET Z C8
If the Z FLAG is set (the file is already closed), RETurn.
5C17
DEC A 3D
DECrement Register A by 1: the Z FLAG when the mode is 01H, a file open for input, which needs no CLOSE@.
5C18
If the NZ FLAG is set (a file open for output), GOSUB to 4428H, CLOSE@, to close the file at Register Pair DE.
5C1B
LD (IX+00H),00H DD 36 00 00
Store 00H at Index Register IX+00H, the area's mode byte: the file is closed.
5C1F
If the NZ FLAG is set (an error from CLOSE@), JUMP to 6079H to post the error in Register A.
5C22
RET C9
RETurn with the file area closed and its mode byte 00H.
5C23H - MERGE
Link 418BH, the statement MERGE. The file is opened as area 0 for input; ,R sets the run flag. The file must be an ASCII program (first byte not FFH, else Bad file mode); it is rewound and the command level reads its lines, which are added to the program in memory.
5C23
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used.
5C24
XOR A AF
Set Register A to 00H by XORing it with itself, the run flag of MERGE.
5C25
LD (570BH),A 32 0B 57
Store Register A (00H) to 570BH, the run flag.
5C28
LD D,01H 16 01
Load Register D with 01H, the mode of a file open for input.
5C2A
GOSUB to 5EDAH to take the file specification and open it as area 0 for input: Register Pair HL at the text after it.
5C2D
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the file again.
5C2E
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
5C2F
If the Z FLAG is set (the end of the statement), JUMP to 5C42H.
5C31
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before R, or the ROM shows a Syntax error.
5C33
CP 52H FE 52
Compare Register A against 52H, the letter R, which runs the merged program.
5C35
If the NZ FLAG is set (not R), JUMP to 5C3CH, a syntax error.
5C37
LD (570BH),A 32 0B 57
Store Register A (52H) to 570BH, the run flag.
5C3A
JUMP back to 5C2EH for the next character after the file name.
5C3C
GOSUB to 5BFFH to close file area 0 after the syntax error.
5C3F
JUMP to 1997H, the ROM's Syntax error, for a bad MERGE option.
5C42
GOSUB to 5FC3H to read the first record of the file into its buffer: Register Pair HL at the first byte.
5C45
LD A,(HL) 7E
Load Register A with the first byte of the file at Register Pair HL.
5C46
INC A 3C
INCrement Register A by 1: the Z FLAG when the first byte is FFH, a compressed program.
5C47
If the Z FLAG is set (compressed), JUMP to 6059H, the error Bad file mode: MERGE needs an ASCII file.
5C4A
GOSUB to 5FA3H to rewind the file to its first record.
5C4D
JUMP to 1A33H, the ROM's command level, which reads the ASCII program line by line into memory.
5C50H - Direct Statement in a File
Link 41B2H, called by the ROM at 1AA1H after a line typed or read from a file was tokenized, with the C FLAG set when the line starts with a line number (the ROM's RST 10H at 1A81H). A program line is kept. A direct statement from a file is the error Direct statement in file; one typed at the keyboard first lets 601DH wipe a run only program and then runs at the ROM's dispatcher (1D5AH).
5C50
RET C D8
If the C FLAG is set (a program line), RETurn: the line is kept in the program.
5C51
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used.
5C52
LD DE,(570EH) ED 5B 0E 57
Load Register Pair DE with the current file area from 570EH-570FH (0000H: none).
5C56
LD A,D 7A
Load Register A with Register D, the high byte of the file area.
5C57
OR E B3
OR Register A with Register E: the Z FLAG when there is no current file.
5C58
If the NZ FLAG is set (a current file), JUMP to 6071H, the error Direct statement in file.
5C5B
GOSUB to 601DH to wipe a program protected against listing before the direct statement runs.
5C5E
JUMP to 1D5AH, the ROM's dispatcher, to run the direct statement.
5C61H - SAVE
Link 41A0H, the statement SAVE. The file is opened as area 0 for output; ,A saves the program as ASCII, else it is saved compressed. For a compressed save the program text (TXTTAB to VARTAB) is written as records headed by FFH and ended by three 00H; the file control block's sector count is set from the length. For an ASCII save the program is listed to the file through the output link (the ROM's LIST).
5C61
XOR A AF
Set Register A to 00H by XORing it with itself, the run flag (SAVE does not run).
5C62
LD D,02H 16 02
Load Register D with 02H, the mode of a file open for output.
5C64
GOSUB to 5EDAH to take the file specification and open it as area 0 for output: Register Pair HL at the text after it.
5C67
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the file again.
5C68
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
5C69
If the Z FLAG is set (no ,A), JUMP to 5C72H to save the program compressed.
5C6B
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before A, or the ROM shows a Syntax error.
5C6D
RST 08H => 41H CF 41
RST 08H: the next character of the text at Register Pair HL must be 41H, the letter A, or the ROM shows a Syntax error.
5C6F
JUMP to 2B2EH, the ROM's LIST, which lists the program to the current file (the output link writes it).
5C72
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the end of the program text.
5C75
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
5C79
SBC HL,DE ED 52
SUBtract Register Pair DE, the start, from Register Pair HL: Register Pair HL = the length of the program text.
5C7B
LD C,L 4D
Load Register C with Register L, the low byte of the length.
5C7C
LD B,H 44
Load Register B with Register H: Register Pair BC = the length of the program text.
5C7D
INC BC 03
INCrement Register Pair BC by 1, for the FFH written before the text.
5C7E
LD (IX+07H),C DD 71 07
Store Register C, the low byte of the length, into Index Register IX+07H, the count of the bytes in the current record.
5C81
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the start of the program.
5C82
GOSUB to 5FE0H to load Register Pair DE with the file's buffer pointer from Index Register IX+05H-06H.
5C85
LD A,FFH 3E FF
Load Register A with FFH, the byte that marks a compressed file.
5C87
LD (DE),A 12
Store Register A (FFH) at Register Pair DE in the buffer.
5C88
INC DE 13
INCrement Register Pair DE by 1, to the next byte of the buffer.
5C89
DEC BC 0B
DECrement Register Pair BC by 1, the count written (the FFH is counted in).
5C8A
LDI ED A0
Copy one byte of the program from Register Pair HL to Register Pair DE by LDI, counting Register Pair BC down.
5C8C
If the PO FLAG is set (the whole program is written), JUMP to 5C98H.
5C8F
LD A,(IX+07H) DD 7E 07
Load Register A with the count of the record from Index Register IX+07H.
5C92
CP C B9
Compare Register A against Register C, the low byte of the count left: the Z FLAG at a record boundary.
5C93
If the Z FLAG is set (a record boundary), GOSUB to 5FD5H to write the record and start the next.
5C96
LOOP back to 5C8AH for the next byte of the program.
5C98
GOSUB to 5FD5H to write the last record of the program.
5C9B
LD A,(IX+07H) DD 7E 07
Load Register A with the count of the last record from Index Register IX+07H.
5C9E
OR A B7
OR Register A against itself: the Z FLAG when the last record is full.
5C9F
If the NZ FLAG is set (a part record), GOSUB to 5FB7H to write the part record.
5CA2
LD A,(IX+0CH) DD 7E 0C
Load Register A with the bytes in the last sector from Index Register IX+0CH, the file control block's end of file byte.
5CA5
LD (IX+0EH),A DD 77 0E
Store Register A into Index Register IX+0EH, the sector count's low byte of the file control block.
5CA8
LD (IX+0FH),00H DD 36 0F 00
Store 00H into Index Register IX+0FH, the sector count's high byte.
5CAC
JUMP to 5BFFH to close file area 0, the saved file.
5CAFH - CLOSE
Link 4185H, the statement CLOSE. CLOSE alone closes every file (5C13H for each). CLOSE #n closes those files: the file number is evaluated, its area closed, and more follow after a comma.
5CAF
LD A,(570CH) 3A 0C 57
Load Register A with the number of files from 570CH.
5CB2
If the NZ FLAG is set (CLOSE #n follows), JUMP to 5CBEH.
5CB4
OR A B7
OR Register A against itself: the Z FLAG when there are no files.
5CB5
RET Z C8
If the Z FLAG is set (no files at all), RETurn: nothing to close.
5CB6
PUSH AF F5
Save Register Pair AF, the file number, to the top of the stack.
5CB7
GOSUB to 5C13H to close the file of that number if it is open.
5CBA
POP AF F1
Restore Register Pair AF, the file number, from the top of the stack.
5CBB
DEC A 3D
DECrement Register A by 1, to the next file number.
5CBC
LOOP back to 5CB4H for the next file number to close.
5CBE
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
5CBF
CP 23H FE 23
Compare Register A against 23H, the # before a file number.
5CC1
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code, to pass over it.
5CC4
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate the file number into Register A.
5CC7
OR A B7
OR Register A against itself: the Z FLAG for file number 0.
5CC8
If the Z FLAG is set (file 0), JUMP to 606BH, the error Bad record number.
5CCB
GOSUB to 5C13H to close the file of that number.
5CCE
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
5CCF
CP 2CH FE 2C
Compare Register A against 2CH, the comma before another file number.
5CD1
RET NZ C0
If the NZ FLAG is set (no comma), RETurn: CLOSE is done.
5CD2
RST 10H D7
RST 10H: increment Register Pair HL past the comma and load Register A with the next character.
5CD3
JUMP back to 5CBEH for the next file number after the comma.
5CD5H - Close All Files
Link 41BBH, called by the ROM's NEW and END. Every file is closed (5CAFH with no #n) and Register A returns 00H.
5CD5
PUSH DE D5
Save Register Pair DE to the top of the stack.
5CD6
PUSH BC C5
Save Register Pair BC to the top of the stack.
5CD7
XOR A AF
Set Register A to 00H by XORing it with itself, so that 5CAFH closes every file.
5CD8
GOSUB to 5CAFH to close every open file of the program.
5CDB
POP BC C1
Restore Register Pair BC from the top of the stack.
5CDC
POP DE D1
Restore Register Pair DE from the top of the stack.
5CDD
XOR A AF
Set Register A to 00H by XORing it with itself, for the ROM's NEW.
5CDE
RET C9
RETurn to the ROM's NEW or END with Register A = 00H.
5CDFH - FIELD
Link 417CH, the statement FIELD n,w AS v$,... Each width w names a part of the file's buffer: the string variable v$ is given a descriptor whose length is w and whose address is the next free place in the buffer. The widths must not run past the buffer (256 bytes), else Field overflow. The file must be open (Bad file mode when closed).
5CDF
GOSUB to 595BH to evaluate the file number: Index Register IX returns its area, Register A its mode byte.
5CE2
If the Z FLAG is set (the file is closed), JUMP to 6059H, the error Bad file mode.
5CE5
SUB 03H D6 03
SUBtract 03H from Register A, the mode byte: 00H and the Z FLAG for a random file.
5CE7
If the NZ FLAG is set (not a random file), JUMP to 6059H, the error Bad file mode.
5CEA
LD B,00H 06 00
Load Register B with 00H, the places of the buffer used so far.
5CEC
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
5CED
CP 2CH FE 2C
Compare Register A against 2CH, the comma before a width.
5CEF
RET NZ C0
If the NZ FLAG is set (no more fields), RETurn.
5CF0
PUSH BC C5
Save Register Pair BC, the places used in Register B, to the top of the stack.
5CF1
GOSUB to 2B1BH, the ROM's evaluation of the width into Register A.
5CF4
PUSH AF F5
Save Register Pair AF, the width in Register A, to the top of the stack.
5CF5
RST 08H => 41H CF 41
RST 08H: the next character of the text at Register Pair HL must be 41H, the letter A of AS, or the ROM shows a Syntax error.
5CF7
RST 08H => 53H CF 53
RST 08H: the next character of the text at Register Pair HL must be 53H, the letter S of AS, or the ROM shows a Syntax error.
5CF9
GOSUB to 260DH, the ROM's variable search, for v$ at Register Pair HL: Register Pair DE returns its descriptor.
5CFC
GOSUB to 0AF4H, the ROM's test that v$ is a string, else Type mismatch.
5CFF
POP AF F1
Restore Register Pair AF, the width in Register A, from the top of the stack.
5D00
POP BC C1
Restore Register Pair BC, the places used in Register B, from the top of the stack.
5D01
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5D02
LD L,A 6F
Load Register L with Register A, the width of this field.
5D03
ADD A,B 80
ADD Register B, the places used, to Register A: the places used after this field.
5D04
LD H,A 67
Load Register H with Register A: Register Pair HL holds the width (Register L) and the new total (Register H).
5D05
If the NC FLAG is set (the total did not pass 255), JUMP to 5D0AH.
5D07
If the NZ FLAG is set (the total is above 255), JUMP to 606EH, the error Field overflow.
5D0A
LD A,(IX+0BH) DD 7E 0B
Load Register A with the record length from Index Register IX+0BH, the file control block's logical record length.
5D0D
CP H BC
Compare Register A against Register H, the places used after this field: the NC FLAG when the field fits.
5D0E
If the NC FLAG is set (within the record), JUMP to 5D14H.
5D10
OR A B7
OR Register A against itself: the NZ FLAG when the record length is not 256 (00H).
5D11
If the NZ FLAG is set (the field runs past the record), JUMP to 606EH, the error Field overflow.
5D14
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
5D16
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the area, the width and total saved.
5D17
LD C,B 48
Load Register C with Register B, the places used before this field.
5D18
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
5D1A
ADD HL,BC 09
ADD Register Pair BC, the places used, to Register Pair HL: the place in the area past its header.
5D1B
LD C,22H 0E 22
Load Register C with 22H, the offset of the file's buffer in its area.
5D1D
ADD HL,BC 09
ADD Register Pair BC (22H) to Register Pair HL: the field's place in the buffer.
5D1E
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the field's place in the buffer, Register Pair HL = v$'s descriptor.
5D1F
POP BC C1
Restore Register Pair BC, the width (Register C) and the total (Register B), from the top of the stack.
5D20
LD (HL),C 71
Store Register C, the width, at Register Pair HL, the length byte of v$'s descriptor.
5D21
INC HL 23
INCrement Register Pair HL by 1, to the address of v$ in the descriptor.
5D22
LD (HL),E 73
Store Register E, the low byte of the field's place, at Register Pair HL.
5D23
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the address.
5D24
LD (HL),D 72
Store Register D, the high byte of the field's place, at Register Pair HL.
5D25
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5D26
INC B 04
INCrement Register B by 1, to test the total.
5D27
DEC B 05
DECrement Register B by 1: the total of the places used.
5D28
If the NZ FLAG is set (the buffer is not full), LOOP back to 5CECH for the next field.
5D2A
INC C 0C
INCrement Register C by 1, to test the width.
5D2B
DEC C 0D
DECrement Register C by 1: the width of the last field.
5D2C
RET NZ C0
If the NZ FLAG is set (the last field had a width), RETurn.
5D2D
JUMP back to 5CECH for the next field of the FIELD statement.
5D2FH - LSET and RSET
Links 4197H (5D30H, LSET) and 419AH (5D2FH, RSET). The string value is placed into the buffer field named by the variable: LSET at its left, RSET at its right, the rest filled with spaces, cut to the field's width. A value still in the program text is copied into the string space first. The C FLAG tells RSET (5D2FH sets it clear through OR 37H, then 5D30H, LSET, sets it with SCF) from LSET.
5D2F
OR 37H F6 37
RSET: OR Register A with 37H, so Register A is not 00H and the C FLAG is clear, the mark of RSET. LSET enters at 5D30H, the 37H operand, which reads as SCF and sets the C FLAG, the mark of LSET.
5D31
PUSH AF F5
Save Register Pair AF, the C FLAG of LSET or RSET, to the top of the stack.
5D32
GOSUB to 260DH, the ROM's variable search, for the field variable at Register Pair HL: Register Pair DE returns its descriptor.
5D35
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
5D38
PUSH DE D5
Save Register Pair DE, the field's descriptor, to the top of the stack.
5D39
RST 08H => D5H CF D5
RST 08H: the next character of the text at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
5D3B
GOSUB to 2337H, the ROM's expression evaluator, for the string at Register Pair HL.
5D3E
POP BC C1
Restore Register Pair BC, the field's descriptor, from the top of the stack.
5D3F
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the C FLAG saved, the text pointer saved.
5D40
PUSH HL E5
Save Register Pair HL, the LSET or RSET flag, to the top of the stack.
5D41
PUSH BC C5
Save Register Pair BC, the field's descriptor, to the top of the stack.
5D42
GOSUB to 29D7H, the ROM's routine that frees the string's temporary: Register Pair HL returns its descriptor.
5D45
LD B,(HL) 46
Load Register B with the length of the string at Register Pair HL.
5D46
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the field's descriptor.
5D47
LD A,(HL) 7E
Load Register A with the length of the field at Register Pair HL.
5D48
LD C,A 4F
Load Register C with Register A, the length of the field.
5D49
PUSH BC C5
Save Register Pair BC, the string length (Register B) and the field length (Register C), to the top of the stack.
5D4A
PUSH HL E5
Save Register Pair HL, the field's descriptor, to the top of the stack.
5D4B
PUSH AF F5
Save Register Pair AF, the field length in Register A, to the top of the stack.
5D4C
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
5D4D
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
5D4E
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
5D4F
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the string.
5D50
OR A B7
OR Register A against itself: the Z FLAG for an empty string.
5D51
If the Z FLAG is set (empty), JUMP to 5DA8H to fill the field with spaces.
5D53
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
5D56
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the program's start.
5D57
If the NC FLAG is set (below the program), JUMP to 5D86H: the string is in the string space already.
5D59
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the end of the program text.
5D5C
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the program text.
5D5D
If the C FLAG is set (above the program text), JUMP to 5D86H: the string is not in the program.
5D5F
LD E,C 59
Load Register E with Register C, the field length as the room to allocate.
5D60
LD D,00H 16 00
Load Register D with 00H, the high byte in Register Pair DE.
5D62
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the top of the string space from 40A0H-40A1H.
5D65
ADD HL,DE 19
ADD Register Pair DE, the room, to Register Pair HL.
5D66
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the top of the string space plus the room.
5D67
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with FRETOP from 40D6H-40D7H, the top of the free string area.
5D6A
GOSUB to 1C90H, the ROM's RST 18H compare of Register Pair HL and Register Pair DE: the C FLAG when the string space is full.
5D6D
If the C FLAG is set (the string space is full), JUMP to 5DBBH to make room.
5D6F
POP AF F1
Restore Register Pair AF, the field length in Register A, from the top of the stack.
5D70
LD A,C 79
Load Register A with Register C, the field length.
5D71
GOSUB to 28BFH, the ROM's routine that allocates Register A bytes of string space: Register Pair DE the space.
5D74
POP HL E1
Restore Register Pair HL, the field's descriptor, from the top of the stack.
5D75
POP BC C1
Restore Register Pair BC, the string length (Register B) and the field length (Register C), from the top of the stack.
5D76
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the value's string descriptor, the field's descriptor saved.
5D77
PUSH DE D5
Save Register Pair DE, the allocated space, to the top of the stack.
5D78
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
5D79
GOSUB to 29D7H, the ROM's routine that frees the temporary: Register Pair HL returns the value's descriptor.
5D7C
POP BC C1
Restore Register Pair BC, the lengths, from the top of the stack.
5D7D
POP DE D1
Restore Register Pair DE, the allocated space, from the top of the stack.
5D7E
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the field's descriptor.
5D7F
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
5D80
PUSH HL E5
Save Register Pair HL, the field's descriptor, to the top of the stack.
5D81
INC HL 23
INCrement Register Pair HL by 1, to the address of the value's string in the descriptor.
5D82
LD (HL),E 73
Store Register E, the low byte of the allocated space, at Register Pair HL (not the field).
5D83
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
5D84
LD (HL),D 72
Store Register D, the high byte of the allocated space, at Register Pair HL.
5D85
PUSH AF F5
Save Register Pair AF, the field length, to the top of the stack.
5D86
POP AF F1
Restore Register Pair AF, the field length in Register A, from the top of the stack.
5D87
POP HL E1
Restore Register Pair HL, the field's descriptor, from the top of the stack.
5D88
INC HL 23
INCrement Register Pair HL by 1, to the address of the field in the buffer.
5D89
LD E,(HL) 5E
Load Register E with the low byte of the field's address at Register Pair HL.
5D8A
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the field's address.
5D8B
LD D,(HL) 56
Load Register D with the high byte of the field's address at Register Pair HL: Register Pair DE = the field in the buffer.
5D8C
POP BC C1
Restore Register Pair BC, the string length (Register B) and the field length (Register C), from the top of the stack.
5D8D
POP HL E1
Restore Register Pair HL, the value's string descriptor, from the top of the stack.
5D8E
INC HL 23
INCrement Register Pair HL by 1, to the address of the value's string.
5D8F
LD A,(HL) 7E
Load Register A with the low byte of the value's address at Register Pair HL.
5D90
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
5D91
LD H,(HL) 66
Load Register H with the high byte of the value's address at Register Pair HL.
5D92
LD L,A 6F
Load Register L with Register A: Register Pair HL = the characters of the value.
5D93
LD A,C 79
Load Register A with Register C, the field length.
5D94
CP B B8
Compare Register A against Register B, the string length: the NC FLAG when the field is as long as the string.
5D95
If the NC FLAG is set (the field holds the string), JUMP to 5D98H.
5D97
LD B,A 47
Load Register B with Register A, the field length: the string is cut to the field.
5D98
SUB B 90
SUBtract Register B, the characters to copy, from Register A, the field length: the spaces to fill.
5D99
LD C,A 4F
Load Register C with Register A, the spaces to fill.
5D9A
POP AF F1
Restore Register Pair AF, the LSET or RSET flag, from the top of the stack.
5D9B
If the NC FLAG is set (RSET), GOSUB to 5DB2H to put the spaces at the left first.
5D9E
INC B 04
INCrement Register B by 1, to test the count.
5D9F
DEC B 05
DECrement Register B by 1: the Z FLAG when the string has no characters to copy.
5DA0
If the Z FLAG is set (no characters), JUMP to 5DADH to fill the rest with spaces.
5DA2
LD A,(HL) 7E
Load Register A with the character of the value at Register Pair HL.
5DA3
LD (DE),A 12
Store Register A, the character, at Register Pair DE in the field.
5DA4
INC HL 23
INCrement Register Pair HL by 1, to the next character of the value.
5DA5
INC DE 13
INCrement Register Pair DE by 1, to the next place of the field.
5DA6
LOOP back to 5D9FH for the next character of the value.
5DA8
POP BC C1
Restore Register Pair BC from the top of the stack: the saved lengths are dropped.
5DA9
POP BC C1
Restore Register Pair BC from the top of the stack: the descriptor is dropped.
5DAA
POP BC C1
Restore Register Pair BC from the top of the stack: the value's descriptor is dropped.
5DAB
POP BC C1
Restore Register Pair BC from the top of the stack: the field length is dropped.
5DAC
POP BC C1
Restore Register Pair BC, the field length (Register C), from the top of the stack for the fill.
5DAD
If the C FLAG is set (LSET), GOSUB to 5DB2H to put the spaces at the right.
5DB0
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5DB1
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
5DB2
LD A,20H 3E 20
Load Register A with 20H, a space to fill the field with.
5DB4
INC C 0C
INCrement Register C by 1, to test the count.
5DB5
DEC C 0D
DECrement Register C by 1: the Z FLAG when no spaces are left.
5DB6
RET Z C8
If the Z FLAG is set (no spaces left), RETurn to the caller.
5DB7
LD (DE),A 12
Store Register A (20H), a space, at Register Pair DE in the field.
5DB8
INC DE 13
INCrement Register Pair DE by 1, to the next place of the field.
5DB9
LOOP back to 5DB5H for the next space of the fill.
5DBB
POP AF F1
Restore Register Pair AF from the top of the stack: the field length is dropped.
5DBC
POP HL E1
Restore Register Pair HL, the field's descriptor, from the top of the stack.
5DBD
POP BC C1
Restore Register Pair BC, the lengths, from the top of the stack.
5DBE
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the value's descriptor.
5DBF
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the value's descriptor.
5DC0
If the NZ FLAG is set (the string space holds the value), JUMP to 5DCBH.
5DC2
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
5DC3
LD A,B 78
Load Register A with Register B, the string length.
5DC4
GOSUB to 2857H, the ROM's STRINI, to make room for the value with its descriptor at 40D3H.
5DC7
GOSUB to 2884H, the ROM's PUTNEW, which makes the new string the current temporary.
5DCA
POP BC C1
Restore Register Pair BC, the lengths, from the top of the stack.
5DCB
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the field's descriptor, the value saved.
5DCC
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
5DCD
PUSH HL E5
Save Register Pair HL, the field's descriptor, to the top of the stack.
5DCE
PUSH AF F5
Save Register Pair AF, the flags, to the top of the stack.
5DCF
JUMP back to 5D6FH to allocate the field after the string space has been tidied.
5DD1H - EOF
Link 4161H, the function EOF(n): true (-1) at the end of the file, false (0) before it. The file must be open and not for output (Bad file mode). CKEOF@ (4457H) gives the answer.
5DD1
GOSUB to 5965H to evaluate the file number: Index Register IX returns its area, the Z FLAG when it is closed.
5DD4
If the Z FLAG is set (the file is closed), JUMP to 6059H, the error Bad file mode.
5DD7
CP 02H FE 02
Compare Register A, the mode byte, against 02H: the Z FLAG for a file open for output.
5DD9
If the Z FLAG is set (output), JUMP to 6059H, the error Bad file mode.
5DDC
GOSUB to 4457H, CKEOF@, to test the file for its end: the Z FLAG before the end, the NZ FLAG at or past it.
5DDF
If the Z FLAG is set (not at the end), JUMP to 5DE3H with Register A = 00H, false.
5DE1
LD A,FFH 3E FF
Load Register A with FFH, the value true, at the end of the file.
5DE3
JUMP to 098DH, the ROM's routine that makes the signed byte in Register A the integer result.
5DE6H - LOC
Link 4164H, the function LOC(n): the number of the record last read or written. The file's position (file control block) gives it (5FE7H).
5DE6
GOSUB to 5965H to evaluate the file number: Index Register IX returns its area, the Z FLAG when it is closed.
5DE9
If the Z FLAG is set (the file is closed), JUMP to 6059H, the error Bad file mode.
5DEC
GOSUB to 5FE7H to work out the record last accessed into Register Pair HL from the file control block.
5DEF
DEC HL 2B
DECrement Register Pair HL by 1, so that the record is counted as LOC gives it.
5DF0
JUMP to 0A9AH, the ROM's routine that makes the integer in Register Pair HL the result.
5DF3H - LOF
Link 4167H, the function LOF(n): the number of records in the file. The file control block's sector count gives it (5FF5H).
5DF3
GOSUB to 5965H to evaluate the file number: Index Register IX returns its area, the Z FLAG when it is closed.
5DF6
If the Z FLAG is set (the file is closed), JUMP to 6059H, the error Bad file mode.
5DF9
GOSUB to 5FF5H to work out the number of records into Register Pair HL from the file control block.
5DFC
JUMP to 0A9AH, the ROM's routine that makes the integer in Register Pair HL the result.
5DFFH - GET and PUT
Links 417FH (5E00H, GET) and 4182H (5DFFH, PUT). The record is read into the buffer (GET) or the buffer is written (PUT); with an optional record number the file is positioned there first (POSN@). Only a random file (mode 03H) is allowed. PUT of a record past the end fills the new records with 00H.
5DFF
LD A,AFH 3E AF
PUT: load Register A with AFH, the PUT flag. GET enters at 5E00H, the AFH operand, which reads as XOR A and sets Register A to 00H, the GET flag.
5E01
LD (5E4EH),A 32 4E 5E
Store Register A (AFH for PUT, 00H for GET) to 5E4EH, the operand of LD A,00H at 5E4DH.
5E04
GOSUB to 595BH to evaluate the file number: Index Register IX returns its area, Register A its mode byte.
5E07
CP 03H FE 03
Compare Register A against 03H, the mode of a random file.
5E09
If the NZ FLAG is set (not random), JUMP to 6059H, the error Bad file mode.
5E0C
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
5E0D
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5E0E
GOSUB to 5FE7H to work out the file's next record number into Register Pair HL.
5E11
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the next record number.
5E12
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5E13
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
5E14
CP 2CH FE 2C
Compare Register A against 2CH, the comma before a record number.
5E16
If the Z FLAG is set (a record number follows), GOSUB to 1E45H, the ROM's scan of the record number at Register Pair HL into Register Pair DE.
5E19
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the record number again.
5E1A
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
5E1B
If the NZ FLAG is set (more text), JUMP to 1997H, the ROM's Syntax error.
5E1E
LD A,E 7B
Load Register A with Register E, the low byte of the record number.
5E1F
OR D B2
OR Register A with Register D: the Z FLAG for record 0.
5E20
If the Z FLAG is set (record 0), JUMP to 606BH, the error Bad record number.
5E23
LD B,D 42
Load Register B with Register D, the high byte of the record number.
5E24
LD C,E 4B
Load Register C with Register E: Register Pair BC = the record number.
5E25
DEC BC 0B
DECrement Register Pair BC by 1, to the record number POSN@ counts from 0.
5E26
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
5E27
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5E28
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, the position POSN@ gives a blocked random file.
5E2B
ADD HL,DE 19
ADD Register Pair DE, the file control block, to Register Pair HL (not used further here).
5E2C
GOSUB to 4442H, POSN@, to position the file at record Register Pair BC: the error code in Register A.
5E2F
If the Z FLAG is set (positioned within the file), JUMP to 5E4DH.
5E31
CP 1CH FE 1C
Compare Register A against 1CH, the error Attempted to read past eof.
5E33
If the Z FLAG is set (past the end), JUMP to 5E3AH.
5E35
CP 1DH FE 1D
Compare Register A against 1DH, the error Attempted to read outside of file limits.
5E37
If the NZ FLAG is set (another error), JUMP to 6079H to post it.
5E3A
LD A,(5E4EH) 3A 4E 5E
Load Register A with the GET or PUT flag from 5E4EH: 00H for GET.
5E3D
OR A B7
OR Register A against itself: the Z FLAG for GET.
5E3E
If the NZ FLAG is set (PUT), JUMP to 5E5AH to write the record, which extends the file.
5E40
INC BC 03
INCrement Register Pair BC by 1, back to the record number asked for.
5E41
GOSUB to 4442H, POSN@, to position the file at record Register Pair BC again.
5E44
XOR A AF
Set Register A to 00H by XORing it with itself, the byte that fills the buffer.
5E45
LD (HL),00H 36 00
Store Register A (00H) at Register Pair HL in the buffer.
5E47
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the buffer.
5E48
DEC A 3D
DECrement Register A by 1 (to FFH and back round): the Z FLAG after 256 bytes.
5E49
If the NZ FLAG is set (more of the buffer), LOOP back to 5E45H.
5E4B
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5E4C
RET C9
RETurn to the statement loop of the ROM with the buffer cleared (GET past the end).
5E4D
LD A,00H 3E 00
Load Register A with the GET or PUT flag, the operand 5E4EH (00H in the file).
5E4F
OR A B7
OR Register A against itself: the Z FLAG for GET.
5E50
If the NZ FLAG is set (PUT), JUMP to 5E5AH to write the record.
5E52
GOSUB to 4436H, READ@, to read the record into the file's buffer.
5E55
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5E58
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5E59
RET C9
RETurn to the statement loop of the ROM with the record read.
5E5A
GOSUB to 4439H, WRITE@, to write the file's buffer as the record.
5E5D
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5E60
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5E61
RET C9
RETurn to the statement loop of the ROM with the record written.
5E62H - Take a File Field
Evaluates the next string at Register Pair HL as a file specification (empty: Bad file name; over 24 characters: Bad file name) and copies it into the file control block at Register Pair DE with 03H after it.
5E62
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
5E63
GOSUB to 2337H, the ROM's expression evaluator, for the file specification at Register Pair HL.
5E66
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5E67
GOSUB to 29D7H, the ROM's routine that frees the string's temporary: Register Pair HL returns its descriptor.
5E6A
LD C,(HL) 4E
Load Register C with the length of the file specification at Register Pair HL.
5E6B
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
5E6C
INC C 0C
INCrement Register C by 1, to test the length.
5E6D
DEC C 0D
DECrement Register C by 1: the Z FLAG for an empty file specification.
5E6E
If the Z FLAG is set (empty), JUMP to 6068H, the error Bad file name.
5E71
LD A,18H 3E 18
Load Register A with 18H, the longest file specification: 24 characters.
5E73
CP C B9
Compare Register A against Register C, the length: the C FLAG when it is above 24.
5E74
If the C FLAG is set (too long), JUMP to 6068H, the error Bad file name.
5E77
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
5E78
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
5E79
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the file specification.
5E7A
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5E7B
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the file control block, the text pointer saved.
5E7C
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the file control block, Register Pair HL = the file specification.
5E7D
GOSUB to 5E82H to copy the file specification at Register Pair HL into the file control block at Register Pair DE.
5E80
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5E81
RET C9
RETurn with the file specification in the file control block.
5E82H - Copy a File Specification
Copies the file specification at Register Pair HL (length in Register C) into the file control block at Register Pair DE, with 03H after it, so CMNDI@ and the file routines can read it. A device name (@ first) is Bad file name.
5E82
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
5E83
LD A,(HL) 7E
Load Register A with the first character of the file specification at Register Pair HL.
5E84
CP 40H FE 40
Compare Register A against 40H, the character @ of a device name.
5E86
If the Z FLAG is set (a device name), JUMP to 6068H, the error Bad file name.
5E89
LD B,00H 06 00
Load Register B with 00H, the high byte of the length in Register Pair BC.
5E8B
LDIR ED B0
Copy the file specification from Register Pair HL to Register Pair DE by LDIR, counted by Register Pair BC.
5E8D
LD A,03H 3E 03
Load Register A with 03H, the byte that ends the file specification for CMNDI@.
5E8F
LD (DE),A 12
Store Register A (03H) at Register Pair DE after the file specification.
5E90
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
5E91
RET C9
RETurn with the file specification copied into the block.
5E92H - OPEN
Link 4179H, the statement OPEN "mode",n,"file"[,reclen]. The mode letter is I (input, 01H), O (output, 02H), E (append/extend, 04H), R or D (random, 03H); any other is Bad file mode. The file is opened as area n: input by OPEN@, output and random by INIT@ (open or create); E then positions at the end (PEOF@). A random file may give a record length. A file already open in area n is File already open.
5E92
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's reset of the output, where OPEN ends.
5E95
PUSH BC C5
Save Register Pair BC (2169H) to the top of the stack, the return address of OPEN.
5E96
GOSUB to 2337H, the ROM's expression evaluator, for the mode string at Register Pair HL.
5E99
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5E9A
GOSUB to 29D7H, the ROM's routine that frees the string's temporary: Register Pair HL returns the mode's descriptor.
5E9D
LD A,(HL) 7E
Load Register A with the length of the mode string at Register Pair HL.
5E9E
INC HL 23
INCrement Register Pair HL by 1, to the address of the mode string in the descriptor.
5E9F
OR A B7
OR Register A against itself: the Z FLAG for an empty mode string.
5EA0
If the Z FLAG is set (empty), JUMP to 6059H, the error Bad file mode.
5EA3
LD C,(HL) 4E
Load Register C with the low byte of the mode's address at Register Pair HL.
5EA4
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the mode's address.
5EA5
LD B,(HL) 46
Load Register B with the high byte of the mode's address at Register Pair HL: Register Pair BC = the mode string.
5EA6
LD A,(BC) 0A
Load Register A with the first character of the mode string at Register Pair BC.
5EA7
RES 5,A CB AF
RESET bit 5 of Register A, which makes a lower case letter upper case.
5EA9
LD D,04H 16 04
Load Register D with 04H, the mode code of E (append).
5EAB
CP 45H FE 45
Compare Register A against 45H, the letter E.
5EAD
If the Z FLAG is set (E), JUMP to 5EC6H with the mode code 04H.
5EAF
LD D,02H 16 02
Load Register D with 02H, the mode code of O (output).
5EB1
CP 4FH FE 4F
Compare Register A against 4FH, the letter O.
5EB3
If the Z FLAG is set (O), JUMP to 5EC6H with the mode code 02H.
5EB5
LD D,01H 16 01
Load Register D with 01H, the mode code of I (input).
5EB7
CP 49H FE 49
Compare Register A against 49H, the letter I.
5EB9
If the Z FLAG is set (I), JUMP to 5EC6H with the mode code 01H.
5EBB
LD D,03H 16 03
Load Register D with 03H, the mode code of R (random).
5EBD
CP 52H FE 52
Compare Register A against 52H, the letter R.
5EBF
If the Z FLAG is set (R), JUMP to 5EC6H with the mode code 03H.
5EC1
CP 44H FE 44
Compare Register A against 44H, the letter D, also a random file.
5EC3
If the NZ FLAG is set (no mode letter matched), JUMP to 6059H, the error Bad file mode.
5EC6
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5EC7
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the mode, or the ROM shows a Syntax error.
5EC9
PUSH DE D5
Save Register Pair DE, the mode code in Register D, to the top of the stack.
5ECA
CP 23H FE 23
Compare Register A against 23H, the # before the file number.
5ECC
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code, to pass over it.
5ECF
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate the file number into Register E.
5ED2
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the file number, or the ROM shows a Syntax error.
5ED4
LD A,E 7B
Load Register A with Register E, the file number.
5ED5
OR A B7
OR Register A against itself: the Z FLAG for file number 0.
5ED6
If the Z FLAG is set (file 0), JUMP to 606BH, the error Bad record number.
5ED9
POP DE D1
Restore Register Pair DE, the mode code in Register D, from the top of the stack.
5EDA
PUSH DE D5
Save Register Pair DE, the mode code in Register D, to the top of the stack.
5EDB
GOSUB to 596CH for the file number in Register A: Index Register IX the area, Register Pair DE its file control block, the Z FLAG when it is closed.
5EDE
If the NZ FLAG is set (already open), JUMP to 6065H, the error File already open.
5EE1
GOSUB to 5E62H to take the file specification into the file control block at Register Pair DE.
5EE4
POP AF F1
Restore Register Pair AF, the mode code in Register A, from the top of the stack.
5EE5
PUSH AF F5
Save Register Pair AF, the mode code in Register A, to the top of the stack.
5EE6
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
5EE7
LD B,00H 06 00
Load Register B with 00H, the record length when none is given.
5EE9
CP 03H FE 03
Compare Register A against 03H, the mode of a random file.
5EEB
If the NZ FLAG is set (not random), JUMP to 5EF7H: no record length is taken.
5EED
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character again.
5EEE
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
5EEF
If the Z FLAG is set (no record length), JUMP to 5EF7H.
5EF1
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before the record length, or the ROM shows a Syntax error.
5EF3
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate the record length into Register E.
5EF6
LD B,E 43
Load Register B with Register E, the record length.
5EF7
LD (40DFH),HL 22 DF 40
Store Register Pair HL into 40DFH-40E0H, the ROM's text pointer, kept over the open.
5EFA
LD (570EH),IX DD 22 0E 57
Store Index Register IX, the file's area, into 570EH-570FH: the current file.
5EFE
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
5EFF
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, the offset past the file control block to its buffer.
5F02
ADD HL,DE 19
ADD Register Pair DE, the file control block, to Register Pair HL (the record length is not written to the block here).
5F03
INC B 04
INCrement Register B by 1, to test the record length.
5F04
DEC B 05
DECrement Register B by 1: the Z FLAG when no record length was given.
5F05
If the Z FLAG is set (no record length), JUMP to 5F08H.
5F07
INC H 24
INCrement Register H by 1 (a side effect of the length test; the result is not stored).
5F08
POP AF F1
Restore Register Pair AF, the mode code in Register A, from the top of the stack.
5F09
LD C,A 4F
Load Register C with Register A, the mode code, to become the area's mode byte.
5F0A
CP 01H FE 01
Compare Register A against 01H, the mode of input.
5F0C
If the NZ FLAG is set (not input), JUMP to 5F2BH.
5F0E
GOSUB to 4424H, OPEN@, to open the existing file at Register Pair DE for input.
5F11
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5F14
LD A,(570BH) 3A 0B 57
Load Register A with the run flag from 570BH: not 00H when RUN opened the program file.
5F17
OR A B7
OR Register A against itself: the Z FLAG for an OPEN statement.
5F18
If the Z FLAG is set (an OPEN statement), JUMP to 5F45H.
5F1A
INC DE 13
INCrement Register Pair DE by 1, to the access level byte of the file control block.
5F1B
LD A,(DE) 1A
Load Register A with the access level at Register Pair DE.
5F1C
AND 07H E6 07
AND Register A with 07H, the protection level in the low three bits.
5F1E
CP 06H FE 06
Compare Register A against 06H: the C FLAG for a level below 6.
5F20
If the C FLAG is set (below execute only), JUMP to 5F45H.
5F22
LD (570DH),A 32 0D 57
Store Register A to 570DH, the protection level 6 or 7 of a program that may not be listed.
5F25
LD A,(DE) 1A
Load Register A with the access level at Register Pair DE.
5F26
AND F8H E6 F8
AND Register A with F8H, to clear the protection level in the low three bits.
5F28
LD (DE),A 12
Store Register A back at Register Pair DE, the access level without its protection bits.
5F29
JUMP to 5F45H to set the area's mode byte for the input file.
5F2B
CP 03H FE 03
Compare Register A against 03H, the mode of a random file.
5F2D
If the NZ FLAG is set (output or append), JUMP to 5F37H.
5F2F
GOSUB to 4420H, INIT@, to open the random file at Register Pair DE, creating it when it does not exist.
5F32
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5F35
JUMP to 5F45H to set the area's mode byte for the random file.
5F37
GOSUB to 4420H, INIT@, to open the file at Register Pair DE for output, creating it when it does not exist.
5F3A
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5F3D
LD A,C 79
Load Register A with Register C, the mode code: 04H for append.
5F3E
LD C,02H 0E 02
Load Register C with 02H, the area's mode byte for an output file.
5F40
CP 04H FE 04
Compare Register A against 04H, the mode of append.
5F42
If the Z FLAG is set (append), GOSUB to 4448H, PEOF@, to position the file at its end.
5F45
LD (IX+00H),C DD 71 00
Store Register C, the area's mode byte (01H input, 02H output, 03H random), into Index Register IX+00H.
5F48
LD (IX+01H),00H DD 36 01 00
Store 00H into Index Register IX+01H, the area's column byte.
5F4C
LD HL,(40DFH) 2A DF 40
Load Register Pair HL with the ROM's text pointer from 40DFH-40E0H, kept over the open.
5F4F
RET C9
RETurn to the ROM's reset of the output at 2169H.
5F50H - KILL
Link 4191H, the statement KILL "file": the file is opened as area 0, then deleted by KILL@, and the area is marked closed.
5F50
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
5F51
GOSUB to 596CH for file area 0: Index Register IX the area, Register Pair DE its file control block.
5F54
GOSUB to 5E62H to take the file specification into the file control block at Register Pair DE.
5F57
GOSUB to 4424H, OPEN@, to open the file at Register Pair DE so that it can be deleted.
5F5A
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5F5D
GOSUB to 442CH, KILL@, to delete the file at Register Pair DE.
5F60
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5F63
LD (IX+00H),00H DD 36 00 00
Store 00H into Index Register IX+00H, the area's mode byte: closed.
5F67
RET C9
RETurn with the file deleted and the area closed.
5F68H - Read a Byte from the File
Reads the next byte of the file of Index Register IX into Register A through the ROM's GET@ (0013H): the Z FLAG for a byte, the C FLAG at the end of the file (error 1CH), any other error posted.
5F68
PUSH DE D5
Save Register Pair DE to the top of the stack.
5F69
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
5F6B
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
5F6C
INC DE 13
INCrement Register Pair DE by 1, past the mode byte of the area.
5F6D
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
5F6E
GOSUB to 0013H, the ROM's GET@, which reads a byte of the file at Register Pair DE into Register A: the Z FLAG for a byte.
5F71
POP DE D1
Restore Register Pair DE from the top of the stack.
5F72
RET Z C8
If the Z FLAG is set (a byte was read), RETurn with the byte in Register A.
5F73
CP 1CH FE 1C
Compare Register A against 1CH, the error Attempted to read past eof.
5F75
If the NZ FLAG is set (another error), JUMP to 6079H to post it.
5F78
SCF 37
Set the C FLAG, the mark of the end of the file.
5F79
RET C9
RETurn with the C FLAG set at the end of the file.
5F7AH - Write a Byte to the File
Writes the byte in Register A to the file of Index Register IX through the ROM's PUT@ (001BH). The column (Index Register IX+01H) counts the characters on the line: it is cleared by a carriage return and otherwise increased so that it stays below 256.
5F7A
PUSH DE D5
Save Register Pair DE to the top of the stack.
5F7B
LD E,(IX+00H) DD 5E 00
Load Register E with the mode byte of the area from Index Register IX+00H.
5F7E
DEC E 1D
DECrement Register E by 1: the Z FLAG when the mode is 01H, a file open for input.
5F7F
If the Z FLAG is set (an input file), JUMP to 5FA1H: nothing is written.
5F81
LD E,(IX+01H) DD 5E 01
Load Register E with the column from Index Register IX+01H, the characters on the line.
5F84
LD (IX+01H),00H DD 36 01 00
Store 00H into Index Register IX+01H, the column, cleared before it is set again.
5F88
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return.
5F8A
If the Z FLAG is set (a carriage return), JUMP to 5F96H with the column 00H.
5F8C
PUSH AF F5
Save Register Pair AF, the byte, to the top of the stack.
5F8D
ADD A,E0H C6 E0
ADD E0H to Register A: the C FLAG when the byte is 20H or more, a character on the line.
5F8F
LD A,E 7B
Load Register A with Register E, the old column.
5F90
ADC A,00H CE 00
ADD 00H to Register A with the carry: the column plus 1 for a character, or unchanged.
5F92
LD (IX+01H),A DD 77 01
Store Register A into Index Register IX+01H, the new column (it stays below 256).
5F95
POP AF F1
Restore Register Pair AF, the byte, from the top of the stack.
5F96
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
5F98
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
5F99
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
5F9A
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
5F9B
GOSUB to 001BH, the ROM's PUT@, which writes the byte in Register A to the file at Register Pair DE.
5F9E
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5FA1
POP DE D1
Restore Register Pair DE from the top of the stack.
5FA2
RET C9
RETurn with the byte written to the file of Index Register IX.
5FA3H - Rewind the File
Rewinds the file of Index Register IX to its first record through REW@ (443FH).
5FA3
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
5FA5
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
5FA6
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
5FA7
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
5FA8
GOSUB to 443FH, REW@, to rewind the file at Register Pair DE.
5FAB
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5FAE
RET C9
RETurn with the file of Index Register IX rewound.
5FAFH - Back Up a Record
Decrements the record count of the write (Index Register IX+07H) and, when it reaches zero, backs the file up one record through BKSP@ (4445H): used while reading the items of INPUT # from a file.
5FAF
LD A,(IX+07H) DD 7E 07
Load Register A with the record count from Index Register IX+07H.
5FB2
DEC (IX+07H) DD 35 07
DECrement the record count at Index Register IX+07H.
5FB5
OR A B7
OR Register A against itself: the Z FLAG when the count was 1, now 0.
5FB6
RET NZ C0
If the NZ FLAG is set (the count is not yet 0), RETurn.
5FB7
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
5FB9
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
5FBA
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
5FBB
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
5FBC
GOSUB to 4445H, BKSP@, to back the file up one record.
5FBF
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5FC2
RET C9
RETurn with the file of Index Register IX backed up one record.
5FC3H - Read a Record
Reads the next record (sector) of the file of Index Register IX into its buffer through READ@ (4436H): Register Pair HL returns the buffer (5FCEH).
5FC3
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
5FC5
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
5FC6
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
5FC7
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
5FC8
GOSUB to 4436H, READ@, to read the next record into the file's buffer.
5FCB
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5FCE
LD L,(IX+05H) DD 6E 05
Load Register L with the low byte of the buffer address from Index Register IX+05H, the file control block's buffer pointer.
5FD1
LD H,(IX+06H) DD 66 06
Load Register H with the high byte of the buffer address from Index Register IX+06H.
5FD4
RET C9
RETurn with Register Pair HL at the file's buffer.
5FD5H - Write a Record
Writes the file's buffer as the next record through WRITE@ (4439H): Register Pair DE returns the buffer (5FE0H).
5FD5
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
5FD7
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
5FD8
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
5FD9
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
5FDA
GOSUB to 4439H, WRITE@, to write the file's buffer as the next record.
5FDD
If the NZ FLAG is set (an error), JUMP to 6079H to post it.
5FE0
LD E,(IX+05H) DD 5E 05
Load Register E with the low byte of the buffer address from Index Register IX+05H, the file control block's buffer pointer.
5FE3
LD D,(IX+06H) DD 56 06
Load Register D with the high byte of the buffer address from Index Register IX+06H.
5FE6
RET C9
RETurn with Register Pair DE at the file's buffer.
5FE7H - The Record Last Accessed
Works out the number of the record last read or written, for LOC: the record is the position's sector times the record length plus the byte offset in it, plus 1. The position is at Index Register IX+0CH-0DH (the file control block's current sector) and the record length at Index Register IX+07H.
5FE7
LD D,(IX+07H) DD 56 07
Load Register D with the record length from Index Register IX+07H.
5FEA
LD L,(IX+0CH) DD 6E 0C
Load Register L with the low byte of the current sector from Index Register IX+0CH.
5FED
LD H,(IX+0DH) DD 66 0D
Load Register H with the high byte of the current sector from Index Register IX+0DH.
5FF0
GOSUB to 5FFEH to work out the sector times the record length plus the offset into Register Pair HL.
5FF3
INC HL 23
INCrement Register Pair HL by 1, so that LOC counts the records from 1.
5FF4
RET C9
RETurn with the record number in Register Pair HL.
5FF5H - The Number of Records
Works out the number of records in the file, for LOF: the file's last sector (Index Register IX+0EH-0FH) times the record length plus the bytes in the last sector (Index Register IX+0AH).
5FF5
LD D,(IX+0AH) DD 56 0A
Load Register D with the bytes in the last sector from Index Register IX+0AH, the file control block's end of file byte.
5FF8
LD L,(IX+0EH) DD 6E 0E
Load Register L with the low byte of the sector count from Index Register IX+0EH.
5FFB
LD H,(IX+0FH) DD 66 0F
Load Register H with the high byte of the sector count from Index Register IX+0FH.
5FFE
LD E,(IX+0BH) DD 5E 0B
Load Register E with the record length from Index Register IX+0BH, the file control block's logical record length.
6001
LD A,E 7B
Load Register A with Register E, the record length.
6002
ADD A,FFH C6 FF
ADD FFH to Register A, minus 1: the NC FLAG when the record length is 00H, meaning 256.
6004
If the NC FLAG is set (a record length of 256), JUMP to 6018H.
6006
ADD A,D 82
ADD Register D, the bytes in the last sector, to Register A (the record length less 1).
6007
If the NC FLAG is set (no carry), JUMP to 600BH.
6009
LD D,A 57
Load Register D with Register A, the sum's low byte.
600A
INC HL 23
INCrement Register Pair HL by 1, for the carry into the sector count.
600B
LD A,E 7B
Load Register A with Register E, the record length.
600C
GOSUB to 4451H, DIVD@, to divide the sector count in Register Pair HL by the record length in Register A: the quotient in Register Pair HL, the remainder in Register A.
600F
LD B,L 45
Load Register B with Register L, the low byte of the quotient.
6010
LD H,A 67
Load Register H with Register A, the remainder, as the high byte.
6011
LD L,D 6A
Load Register L with Register D, the bytes in the last sector, as the low byte.
6012
LD A,E 7B
Load Register A with Register E, the record length.
6013
GOSUB to 4451H, DIVD@, to divide Register Pair HL by the record length in Register A.
6016
LD H,B 60
Load Register H with Register B, the low byte of the first quotient.
6017
RET C9
RETurn with the number of records in Register Pair HL.
6018
INC D 14
INCrement Register D by 1, to test the bytes in the last sector.
6019
DEC D 15
DECrement Register D by 1: the Z FLAG when the last sector is full.
601A
RET Z C8
If the Z FLAG is set (the last sector is full), RETurn.
601B
INC HL 23
INCrement Register Pair HL by 1, for the part record in the last sector.
601C
RET C9
RETurn with the number of records in Register Pair HL.
601DH - Wipe a Protected Program
When a program was loaded with an access level of 6 or 7 (570DH), it may not be listed or saved: at READY, or before a direct statement, the program text is overwritten with 00H, cleared by the ROM's NEW, and the text RUN access only is shown. Otherwise the routine returns at once.
601D
PUSH AF F5
Save Register Pair AF to the top of the stack.
601E
PUSH HL E5
Save Register Pair HL to the top of the stack.
601F
LD HL,570DH 21 0D 57
Point Register Pair HL to 570DH, the protection level of the program.
6022
XOR A AF
Set Register A to 00H by XORing it with itself.
6023
LD (570BH),A 32 0B 57
Store Register A (00H) to 570BH, the run flag, cleared.
6026
CP (HL) BE
Compare Register A (00H) with the protection level at Register Pair HL: the Z FLAG when the program is not protected.
6027
LD (HL),A 77
Store Register A (00H) at Register Pair HL (570DH), the protection level cleared.
6028
If the Z FLAG is set (not protected), JUMP to 6044H: nothing is wiped.
602A
LD HL,044CH 21 4C 04
Load Register Pair HL with 044CH, the bytes of the text area to clear: 1100 bytes.
602D
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
6031
ADD HL,DE 19
ADD Register Pair DE, the start, to Register Pair HL: the end of the area to clear.
6032
LD (HL),00H 36 00
Store 00H at Register Pair HL in the program text.
6034
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before.
6035
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the start: the Z FLAG when the whole area is cleared.
6036
If the NZ FLAG is set (more to clear), LOOP back to 6032H.
6038
GOSUB to 1B4DH, the ROM's NEW, which clears the program and the variables.
603B
LD HL,6047H 21 47 60
Point Register Pair HL to 6047H, the text RUN access only.
603E
GOSUB to 28A7H, the ROM's routine that shows the text at Register Pair HL up to its 00H.
6041
JUMP to 1A19H, the ROM's READY, after the protected program is wiped.
6044
POP HL E1
Restore Register Pair HL from the top of the stack.
6045
POP AF F1
Restore Register Pair AF from the top of the stack.
6046
RET C9
RETurn to the caller: the program was not protected, so nothing was wiped.
6047-6058
DEFB 0DH / DEFM "RUN access only" / DEFB 0DH,00H 0D 52 55 4E 20 61 63 63 65 73 73 20 6F 6E 6C 79 0D 00
The text shown when a program protected against listing is wiped: a carriage return, the words, a carriage return and the 00H that ends it.
6059H - The Error Exits
Ten entries, each loading a BASIC error offset into Register E, then the ROM's error routine. The entries after the first are each entered inside a LD BC,xx1EH instruction, at its 1EH xxH bytes, which read as LD E,xxH; from above they only load Register Pair BC.
6059
LD E,6CH 1E 6C
Load Register E with 6CH, the offset of the error Bad file mode, and fall into the LD BC below.
605B
LD BC,681EH 01 1E 68
605CH enters inside this LD BC,681EH: its bytes 1EH 68H read as LD E,68H, the offset Bad file number; from above it only loads Register Pair BC.
605E
LD BC,661EH 01 1E 66
605FH enters inside this LD BC,661EH: its bytes 1EH 66H read as LD E,66H, the offset Internal error; from above it only loads Register Pair BC.
6061
LD BC,7C1EH 01 1E 7C
6062H enters inside this LD BC,7C1EH: its bytes 1EH 7CH read as LD E,7CH, the offset Input past end; from above it only loads Register Pair BC.
6064
LD BC,6E1EH 01 1E 6E
6065H enters inside this LD BC,6E1EH: its bytes 1EH 6EH read as LD E,6EH, the offset File already open; from above it only loads Register Pair BC.
6067
LD BC,801EH 01 1E 80
6068H enters inside this LD BC,801EH: its bytes 1EH 80H read as LD E,80H, the offset Bad file name; from above it only loads Register Pair BC.
606A
LD BC,7E1EH 01 1E 7E
606BH enters inside this LD BC,7E1EH: its bytes 1EH 7EH read as LD E,7EH, the offset Bad record number; from above it only loads Register Pair BC.
606D
LD BC,641EH 01 1E 64
606EH enters inside this LD BC,641EH: its bytes 1EH 64H read as LD E,64H, the offset Field overflow; from above it only loads Register Pair BC.
6070
LD BC,841EH 01 1E 84
6071H enters inside this LD BC,841EH: its bytes 1EH 84H read as LD E,84H, the offset Direct statement in file; from above it only loads Register Pair BC.
6073
LD BC,861EH 01 1E 86
6074H enters inside this LD BC,861EH: its bytes 1EH 86H read as LD E,86H, the offset Too many files; from above it only loads Register Pair BC.
6076
JUMP to 19A2H, the ROM's error routine, with the BASIC error offset in Register E.
6079H - Post a DOS Error
Takes a DOS error code in Register A, saves it for CMD"E" (570AH), maps it to a BASIC error offset through the table 608CH (a code of 27H or more maps to the second entry, Internal error), and jumps to the ROM's error routine.
6079
LD HL,608CH 21 8C 60
Point Register Pair HL to 608CH, the start of the map of DOS error codes to BASIC error offsets.
607C
LD (570AH),A 32 0A 57
Store Register A, the DOS error code, to 570AH, shown again by CMD"E".
607F
CP 27H FE 27
Compare Register A against 27H: the C FLAG for a code below 27H.
6081
If the C FLAG is set (a known code), JUMP to 6085H.
6083
LD A,01H 3E 01
Load Register A with 01H, so that an unknown code maps to the second entry, Internal error.
6085
LD C,A 4F
Load Register C with Register A, the code, as the offset into the table.
6086
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
6088
ADD HL,BC 09
ADD Register Pair BC, the code, to Register Pair HL: the table entry of the code.
6089
LD E,(HL) 5E
Load Register E with the BASIC error offset at Register Pair HL.
608A
JUMP to 19A2H, the ROM's error routine, with the BASIC error offset in Register E.
608D-60B5
DEFB 72H,72H,72H,72H,72H,72H,72H,80H,72H,72H,72H,72H,72H,72H,88H,66H,72H,72H,80H,72H,72H,72H,72H,6AH,8AH,86H,7AH,66H,66H,7AH,66H,80H,66H,66H,66H,66H,8AH,66H,3AH,00H,2CH 72 72 72 72 72 72 72 80 72 72 72 72 72 72 88 66 72 72 80 72 72 72 72 6A 8A 86 7A 66 66 7A 66 80 66 66 66 66 8A 66 3A 00 2C
The map of DOS error codes to BASIC error offsets, from code 01H: the code indexes the table at 608CH (whose first byte is the 19H high byte of the JUMP above, for the unused code 00H) and the byte is the offset the ROM's error routine is given (72H Disk I/O error, 6AH File not found, 66H Internal error and so on). The last three bytes are not used by codes up to 26H.
60B6-61B5
DEFS 256
The keyboard input buffer, pointed to by the ROM's 40A7H and used by the line input and the file reads.
61B6-61B7
DEFB 00H,00H 00 00
The two bytes before the file areas; the first file area begins at 61B7H (its mode byte, loaded as 00H, closed).
61B8-7FFF
DEFS 7752
The file areas (each 0222H bytes from 61B7H: the mode byte, the column byte, the file control block and two 256 byte buffers) and, above them, the BASIC program, its variables and the string space, up to the top of memory. None of this is in the file.