5700H - File Statement Work Area (Header Copy and FCB)
While a file statement runs, 6298H copies the 2DH-byte header of the file area in use to 5700H-572CH and points Index Register IX at 5700H; 634DH copies it back to the file area, and 6357H clears 5700H-572DH when the statement ends. A file opened by LOAD, RUN, MERGE, SAVE or KILL lives here itself (6076H). Only 5700H-570CH is in the file (all 00H); 570DH-572CH, the FCB part, is not.
5700
DEFB 00H 00
Header byte +00H, the file mode: bit 7 random, bit 6 writable, bit 5 readable, bit 4 a PUT is in progress, bits 3-0 the file type. 00H means the area is not open. Read at 5F88H, 5FD4H, 6054H, 6088H, 614CH, 62A8H, 62B8H, 62FFH; stored with 5701H by 60E1H; 607BH and 634EH/635DH use 5700H as the area's address.
5701
DEFB 00H 00
Header byte +01H, the file flags from the open mode (Register B AND F8H at 60DEH): bit 7 the file may be extended past its end, bit 6 the start of the current record is known (set by 6117H, tested by 6129H).
5702
DEFB 00H 00
Header bytes +02H-+03H, the record length (low byte here). Read as a word by 5EE6H (LOF and LOC division), 6041H (next record position), 617BH and 633CH (room left in the record).
5703
DEFB 00H 00
Header byte +03H, the high byte of the record length whose low byte is at 5702H.
5704
DEFB 00H 00
Header bytes +04H-+06H, the 24-bit position where the last GET or PUT ended (low byte here). 6331H reads it to work out the room left in the record; 6122H reads all three bytes.
5705
DEFB 00H 00
Header byte +05H, the middle byte of the position at 5704H-5706H; 6113H stores and 6125H reads the word at 5705H-5706H.
5706
DEFB 00H 00
Header byte +06H, the high byte of the 24-bit position where the last GET or PUT ended (5704H-5706H).
5707
DEFB 00H 00
Header bytes +07H-+09H, the 24-bit position where the current record starts (low byte here). Read by 603EH (next record) and 6334H (room left in the record); stored by 6117H.
5708
DEFB 00H 00
Header byte +08H, the middle byte of the record start at 5707H-5709H; 611AH stores and 612CH reads the word at 5708H-5709H.
5709
DEFB 00H 00
Header byte +09H, the high byte of the 24-bit record start at 5707H-5709H; read by 6046H.
570A
DEFB 00H 00
Header bytes +0AH-+0CH (low byte here): in a sequential file written by PRINT # the print column, counted by 605BH and used for the comma and TAB by 5F1BH; in a random file SYS10/SYS keeps the position where the last GET or PUT began.
570B
DEFB 00H 00
Header byte +0BH, the middle byte of the 24-bit value whose low byte is at 570AH (used by SYS10/SYS for GET and PUT).
570C
DEFB 00H 00
Header byte +0CH, the high byte of the 24-bit value whose low byte is at 570AH (used by SYS10/SYS for GET and PUT).
570D-572C
DEFS 32
Not in the file. Header bytes +0DH-+2CH: the file's 32-byte FCB, passed to the DOS as Register Pair DE = 570DH (609CH, 60F3H, 622EH, 6370H). FCB+5 is NEXT's low byte (5712H), FCB+8 EOF's low byte (5715H), FCB+10-11 NEXT's middle and high bytes (5717H-5718H), FCB+12-13 EOF's (5719H-571AH).
572DH - Busy Byte, LOAD/RUN/MERGE/SAVE Links and the Overlay Loader
572DH holds the statement's own flags; it is cleared with the header at the end of each file statement, and 6442H-6445H test its bit 7 (the file lives in the work area). The Disk BASIC links for MERGE (418BH), SAVE (41A0H), RUN (41C7H) and LOAD (4188H) open the file in the work area and load SYS19/SYS; the links 41B2H and 41AFH load SYS18/SYS. 576CH is the overlay loader: Register A = the RST 28H code, Register Pair BC = the entry to run.
572D
DEFB 00H 00
Byte 572DH (Index Register IX+2DH while 5700H is the work area), 00H in the file, the statement's flags, set to 00H at 62AEH: bit 7 = the file lives in the work area (set at 6081H, tested at 60ADH and 6445H), bit 6 tested at 62C7H, 62D0H and 62F4H (set by SYS10/SYS at its 4FFAH), bit 4 set at 6162H, bit 2 tested at 61DAH and 620AH (set by SYS10/SYS at its 4F7CH); SYS10/SYS also uses bits 5, 3 and 1.
572E
MERGE link (418BH, from the JP 572EH at 67F4H): GOSUB to 6073H, which opens the file named in the statement in the work area at 5700H for reading (Register B = 01H existing file only, Register C = 20H readable) and returns with Register Pair HL past the filespec.
5731
LD BC,5334H 01 34 53
Load Register Pair BC with 5334H, the entry for MERGE in SYS19/SYS (SYS19/SYS loads at 5200H-56E7H), for the overlay loader at 576CH.
5734
JUMP to 5752H, which loads Register A with 35H, the RST 28H code of SYS19/SYS, and runs it at the entry in Register Pair BC (5334H).
5736
LD BC,559CH 01 9C 55
CMD"F" (from the letter dispatch at 57CEH): load Register Pair BC with 559CH, the entry for CMD"F" in SYS19/SYS, for the overlay loader.
5739
JUMP to 5752H to load SYS19/SYS (RST 28H code 35H) and run it at the entry in Register Pair BC (559CH).
573B
LD BC,8440H 01 40 84
SAVE link (41A0H, from the JP 573BH at 6809H): load Register Pair BC with 8440H, the open mode for 6076H: Register B = 84H (bit 2 truncate the file, bit 7 it may be extended), Register C = 40H (writable).
573E
GOSUB to 6076H to open the file named in the statement in the work area at 5700H with the mode in Register Pair BC (8440H); a new file is created, an existing one is emptied.
5741
LD BC,55C5H 01 C5 55
Load Register Pair BC with 55C5H, the entry for SAVE in SYS19/SYS, for the overlay loader.
5744
JUMP to 5752H to load SYS19/SYS (RST 28H code 35H) and run it at the entry in Register Pair BC (55C5H).
5746
RET C D8
RUN link (41C7H, from the JP 5746H at 6830H; the ROM calls 41C7H at 1EA6H). If the CARRY FLAG is set (the ROM found no file name after RUN, a line number or nothing), RETurn so that the ROM runs the program in memory; Register A and Register Pair HL are left as the ROM passed them.
5747
LD A,01H 3E 01
RUN with a file name: load Register A with 01H, the value SYS19/SYS finds on the stack for RUN (LOAD gives 00H).
Overlapping Instructions
Entered at 5747H, the code runs LD A,01H and then LD B,AFH and arrives at 574BH with Register A = 01H. Entered at 574AH (the LOAD link), the byte AFH is XOR A and the code arrives at 574BH with Register A = 00H.
5749
LD B,AFH 06 AF
Load Register B with AFH. Run from 5747H this only changes Register B and keeps Register A = 01H. Its second byte AFH (574AH) is the instruction XOR A, the entry of the LOAD link (4188H, from the JP 574AH at 67F1H): entered there it sets Register A to 00H and clears the CARRY FLAG, and goes on at 574BH.
574B
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer for SYS19/SYS: Register A = 01H for RUN, 00H for LOAD.
574C
GOSUB to 6073H to open the file named in the statement in the work area at 5700H for reading (Register B = 01H, Register C = 20H); Register Pair HL returns past the filespec.
574F
LD BC,5202H 01 02 52
Load Register Pair BC with 5202H, the entry for LOAD and RUN in SYS19/SYS, for the overlay loader.
5752
LD A,35H 3E 35
Load Register A with 35H, the RST 28H code of SYS19/SYS. 5734H, 5739H and 5744H come here with Register Pair BC = their SYS19/SYS entry.
5754
JUMP to the overlay loader at 576CH with Register A = 35H and Register Pair BC = the SYS19/SYS entry.
5756
PUSH AF F5
Link 41B2H (from the JP 5756H at 681BH; the ROM calls 41B2H at 1AA1H, after a typed line has been tokenized): save Register Pair AF onto the stack at the Stack Pointer, so that the ROM's Register A and flags come back after SYS18/SYS.
5757
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer: the ROM's value, restored by SYS18/SYS, since Register Pair BC is used for the entry address.
5758
LD BC,54FAH 01 FA 54
Load Register Pair BC with 54FAH, the SYS18/SYS entry for this link (it starts PUSH HL / LD BC,(57B6H) and works with the work bytes 57B6H-57B7H).
575B
JUMP to 576AH to load SYS18/SYS (RST 28H code 34H) and run it at the entry in Register Pair BC (54FAH).
575D
POP HL E1
Link 41AFH (from the JP 575DH at 6818H), called by the ROM's line input 0361H at 0368H: POP into Register Pair HL the return address 036BH from the stack at the Stack Pointer.
575E
POP HL E1
POP the next word from the stack at the Stack Pointer into Register Pair HL: the return address into the routine that called the line input 0361H.
575F
PUSH HL E5
Push Register Pair HL back onto the stack at the Stack Pointer, so that the stack holds only the line input's own return address; returning now would leave the ROM's line input without reading the line.
5760
LD DE,1A7EH 11 7E 1A
Load Register Pair DE with 1A7EH, the return address of the CALL 0361H at 1A7BH in the ROM's command loop (the path that prints the prompt and reads a command line).
5763
RST 18H DF
RST 18H compares Register Pair HL (the line input's caller) with Register Pair DE (1A7EH): the Z FLAG is set only when the line input was called from the command loop.
5764
JP NZ,036BH C2 6B 03
If the NZ FLAG is set (Register Pair HL is not 1A7EH: a line input for INPUT or LINE INPUT), JUMP to ROM 036BH, the instruction after the CALL 41AFH at 0368H, so that the ROM reads the line as usual (no link: the ROM page has no id at 036BH).
5767
LD BC,5202H 01 02 52
Command loop: load Register Pair BC with 5202H, the SYS18/SYS entry that reads the command line itself.
576A
LD A,34H 3E 34
Load Register A with 34H, the RST 28H code of SYS18/SYS. 575BH comes here with Register Pair BC = 54FAH, and 66C1H with its own entry.
576C
PUSH BC C5
Overlay loader: push Register Pair BC, the entry address in the overlay, onto the stack at the Stack Pointer, so that the RET at 576FH or 577EH jumps to it.
576D
CP 00H FE 00
Self-Modifying Code
Compare Register A (the RST 28H code wanted) against the operand at 576EH, the code of the overlay loaded last (00H in the file; stored by 577CH, cleared by 5774H before each load, and also stored by SYS21/SYS at its 4DBEH). The Z FLAG is set when it is the same.
576F
RET Z C8
If the Z FLAG is set (the overlay is still in 5200H-56FFH), RETurn: the RET pops the entry address pushed from Register Pair BC and jumps straight to it.
5770
PUSH HL E5
Save Register Pair HL, the caller's value (usually the BASIC text pointer), onto the stack at the Stack Pointer.
5771
LD HL,576EH 21 6E 57
Point Register Pair HL to 576EH, the operand that records which overlay is in memory.
5774
LD (HL),00H 36 00
Store 00H at Register Pair HL (576EH) before the load: if the load fails, no overlay is recorded as present.
5776
GOSUB to 57B5H, an RST 28H with the code in Register A: SYS0/SYS loads the overlay, whose entry for these codes returns at once (SYS18/SYS-SYS20/SYS start with CP A / RET at 5200H), with the Z FLAG or with the NZ FLAG and a DOS error in Register A.
5779
If the NZ FLAG is set (the load failed; Register A = the DOS error code), JUMP to 5DEFH to turn the DOS error into a BASIC error.
577C
LD (HL),A 77
Store Register A (the RST 28H code, still in Register A after the load) at Register Pair HL (576EH): this overlay is now the one in memory.
577D
POP HL E1
Restore Register Pair HL (the caller's value, saved at 5770H) from the stack at the Stack Pointer.
577E
RET C9
RETurn: the RET pops the entry address pushed from Register Pair BC at 576CH and runs the overlay there.
577FH - Links That Load SYS20/SYS (FN, INSTR, MID$=, &, OPEN, an INPUT # Item, LINE INPUT, a CMD String)
Each entry loads Register Pair BC with a SYS20/SYS entry and joins 5782H, which loads Register A with 36H (SYS20/SYS) and goes to the overlay loader.
577F
LD BC,534AH 01 4A 53
FN link (4155H, from the JP 577FH at 67BEH; the ROM calls 4155H at 2524H): load Register Pair BC with 534AH, the FN entry in SYS20/SYS (it calls 5824H for the name).
5782
LD A,36H 3E 36
Load Register A with 36H, the RST 28H code of SYS20/SYS. 5789H, 578EH, 5793H, 5798H, 579DH, 57A2H and 57A8H come here with Register Pair BC = their entry.
5784
JUMP to the overlay loader at 576CH with Register A = 36H and Register Pair BC = the SYS20/SYS entry.
5786
LD BC,53F2H 01 F2 53
INSTR link (419DH, from the JP 5786H at 6806H; the ROM calls 419DH at 2506H): load Register Pair BC with 53F2H, the INSTR entry in SYS20/SYS.
5789
JUMP to 5782H to load SYS20/SYS and run it at the INSTR entry in Register Pair BC (53F2H).
578B
LD BC,5462H 01 62 54
MID$= link (41D9H, from the JP 578BH at 6842H; the ROM calls 41D9H at 2AECH): load Register Pair BC with 5462H, the entry for MID$ on the left of an assignment in SYS20/SYS.
578E
JUMP to 5782H to load SYS20/SYS and run it at the MID$= entry in Register Pair BC (5462H).
5790
LD BC,54C5H 01 C5 54
& link (4194H, from the JP 5790H at 67FDH; the ROM calls 4194H at 24C8H for &H and &O constants): load Register Pair BC with 54C5H, the entry in SYS20/SYS.
5793
JUMP to 5782H to load SYS20/SYS and run it at the &H and &O entry in Register Pair BC (54C5H).
5795
LD BC,5504H 01 04 55
OPEN link (4179H, from the JP 5795H at 67E2H): load Register Pair BC with 5504H, the OPEN entry in SYS20/SYS.
5798
JUMP to 5782H to load SYS20/SYS and run it at the OPEN entry in Register Pair BC (5504H).
579A
LD BC,55D4H 01 D4 55
Link 41DCH (from the JP 579AH at 6845H; the ROM calls 41DCH at 222DH for each item of INPUT # and READ): load Register Pair BC with 55D4H, the item entry in SYS20/SYS.
579D
JUMP to 5782H to load SYS20/SYS and run it at the item entry in Register Pair BC (55D4H).
579F
LD BC,55E8H 01 E8 55
LINE link (41A3H, from the JP 579FH at 680CH), LINE INPUT: load Register Pair BC with 55E8H, the LINE INPUT entry in SYS20/SYS.
57A2
JUMP to 5782H to load SYS20/SYS and run it at the LINE INPUT entry in Register Pair BC (55E8H).
57A4
PUSH BC C5
CMD with a command of more than one character that does not end in $ (from 581CH): save Register Pair BC onto the stack at the Stack Pointer (Register C = the length minus 1).
57A5
LD BC,5202H 01 02 52
Load Register Pair BC with 5202H, the SYS20/SYS entry that runs the command copied to SYS0/SYS's command buffer at 4225H.
57A8
JUMP to 5782H to load SYS20/SYS and run it at the command entry in Register Pair BC (5202H).
57AAH - ERASE and KEEP for SYS20/SYS, CMD"O", the RST 28H, Work Bytes and Upper Case
57AAH and 57AEH are reached from SYS20/SYS's search of the function table at 592BH (CMD"F=ERASE" and CMD"F=KEEP"); they and CMD"O" run SYS21/SYS. 57B5H is the RST 28H used by the overlay loader. 57B6H-57B9H are work bytes. 57BAH converts a lower case letter to upper case.
57AA
LD B,28H 06 28
ERASE: load Register B with 28H, the opcode JR Z, which SYS21/SYS stores at its 4D8DH (its 4D0EH-4D0FH) for ERASE.
57AC
JUMP to 57B0H with Register B = 28H to run SYS21/SYS's ERASE and KEEP code.
57AE
LD B,20H 06 20
KEEP: load Register B with 20H, the opcode JR NZ, which SYS21/SYS stores at its 4D8DH for KEEP.
57B0
LD A,57H 3E 57
Load Register A with 57H, the RST 28H code of SYS21/SYS function 2, its ERASE and KEEP code at 4D0EH.
57B2
RST 28H EF
RST 28H with Register A = 57H: SYS0/SYS loads SYS21/SYS into 4D00H-51E7H and runs it with Register B = the opcode and Register Pair HL = the text pointer; it does not come back here.
57B3
LD A,37H 3E 37
CMD"O" (from 57DDH): load Register A with 37H, the RST 28H code of SYS21/SYS function 1 (its 4DBAH, the array sort).
57B5
RST 28H EF
RST 28H with the code in Register A (37H from 57B3H, or the overlay code from 5776H): SYS0/SYS loads the overlay and runs its entry.
57B6
DEFB 00H 00
Work byte 57B6H (00H in the file), stored with 57B7H as a word by SYS18/SYS at its 5404H and read back by it at 54FBH.
57B7
DEFB 00H 00
Work byte 57B7H (00H in the file), the high byte of the word SYS18/SYS reads at 57B6H-57B7H.
57B8
DEFB 00H 00
Work bytes 57B8H-57B9H, a line number (low byte here): stored by 5D86H (the line after a trailing comma, for SYS19/SYS and SYS21/SYS); SYS19/SYS reads it at its 5322H.
57B9
DEFB 00H 00
Work byte 57B9H, the high byte of the line number at 57B8H-57B9H (00H in the file).
57BA
CP 61H FE 61
Upper case routine (called by 5806H): compare Register A, the character, against 61H (a). The CARRY FLAG is set below a.
57BC
RET C D8
If the CARRY FLAG is set (Register A is below a), RETurn with the character in Register A unchanged.
57BD
CP 7BH FE 7B
Compare Register A, the character, against 7BH, the code after z. The NO CARRY FLAG is set above z.
57BF
RET NC D0
If the NO CARRY FLAG is set (Register A is above z), RETurn with the character in Register A unchanged.
57C0
SUB 20H D6 20
Register A holds a lower case letter a-z: SUBtract 20H to make it the upper case letter A-Z.
57C2
RET C9
RETurn to the caller with the upper case letter in Register A.
57C3H - One-Letter CMD Commands
Reached from 5817H when the command copied to 4225H is one character. Register Pair HL points to 4225H; the BASIC text pointer is on the stack. S returns to the DOS, F runs CMD"F" in SYS19/SYS, C compresses the program, J converts a date, O sorts arrays (SYS21/SYS), E shows the last DOS error; any other letter is ILLEGAL FUNCTION CALL.
57C3
LD A,(HL) 7E
Load Register A with the command letter at Register Pair HL (4225H, the first byte of SYS0/SYS's command buffer).
57C4
CP 53H FE 53
Compare Register A, the command letter, against 53H (S). The Z FLAG is set for CMD"S".
57C6
POP HL E1
Restore Register Pair HL from the stack at the Stack Pointer: the BASIC text pointer saved at 57EFH. POP does not change the flags.
57C7
If the NZ FLAG is set (the letter in Register A is not S), JUMP to 57CCH to test the other letters.
57C9
CMD"S": JUMP to 402DH, the DOS READY exit (JP 4400H): BASIC is left. 64B6H, 64BEH, 6530H and 673DH jump here too when BASIC cannot start.
57CC
CP 46H FE 46
Compare Register A, the command letter, against 46H (F). The Z FLAG is set for CMD"F".
57CE
If the Z FLAG is set (CMD"F"), JUMP to 5736H, which runs CMD"F" in SYS19/SYS at 559CH with Register Pair HL = the text pointer.
57D1
CP 43H FE 43
Compare Register A, the command letter, against 43H (C). The Z FLAG is set for CMD"C".
57D3
If the Z FLAG is set (CMD"C"), JUMP to 5986H, the program compression.
57D6
CP 4AH FE 4A
Compare Register A, the command letter, against 4AH (J). The Z FLAG is set for CMD"J".
57D8
If the Z FLAG is set (CMD"J"), JUMP to 5A76H, the date conversion.
57DB
CP 4FH FE 4F
Compare Register A, the command letter, against 4FH (O). The Z FLAG is set for CMD"O".
57DD
If the Z FLAG is set (CMD"O"), JUMP to 57B3H to run the array sort in SYS21/SYS.
57E0
CP 45H FE 45
Compare Register A, the command letter, against 45H (E). The Z FLAG is set for CMD"E".
57E2
If the NZ FLAG is set (the letter in Register A is not E either), JUMP to 57E9H: ILLEGAL FUNCTION CALL.
57E4
LD A,C0H 3E C0
Self-Modifying Code
CMD"E" (and 5E0AH, a DOS error with no ON ERROR): load Register A with the operand at 57E5H, the last DOS error code OR C0H, stored by 5DF2H (C0H in the file).
57E6
JUMP to the SYS0/SYS error exit 4409H with Register A = the code OR C0H: bit 7 makes SYS4/SYS display the DOS error message and return to the caller instead of DOS READY.
57E9
Any other letter in Register A: JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL (Register E = 08H, then the ROM's error handler at 19A2H).
57ECH - CMD Statement
CMD link (4173H, from the JP 57ECH at 67DCH). The string after CMD (1 to 79 characters) is copied in upper case to SYS0/SYS's command buffer 4225H, ended by 0DH. One character: the letter commands at 57C3H. Ending in $: the text names a string variable whose contents are the command. Otherwise SYS20/SYS runs the command (5202H).
57EC
GOSUB to ROM 2337H to evaluate the expression after CMD at Register Pair HL into the ROM's accumulator (a string gives its descriptor address at 4121H); Register Pair HL returns past it.
57EF
PUSH HL E5
Save Register Pair HL, the BASIC text pointer after the expression, onto the stack at the Stack Pointer.
57F0
LD DE,(4121H) ED 5B 21 41
Load Register Pair DE with the word at 4121H, the ROM accumulator's address of the string's descriptor.
57F4
GOSUB to 5CA4H: the value must be a string (else TYPE MISMATCH); it returns Register A = the string's length and Register Pair DE = the address of its text. 5822H comes back here with a string variable's descriptor in Register Pair DE.
57F7
DEC A 3D
DECrement Register A, the length, by 1, so that a length of 0 becomes FFH.
57F8
CP 4FH FE 4F
Compare Register A, the length minus 1, against 4FH. The CARRY FLAG is set for lengths 1 to 79.
57FA
If the NO CARRY FLAG is set (an empty string or more than 79 characters), JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
57FD
INC A 3C
INCrement Register A back to the string's length (1-79).
57FE
LD HL,4225H 21 25 42
Point Register Pair HL to 4225H, SYS0/SYS's command buffer, where the command goes.
5801
LD B,A 47
Copy Register A (the length) into Register B, the counter of the copy loop.
5802
LD C,A 4F
Copy Register A (the length) into Register C as well, for the one-character test at 5816H.
5803
PUSH HL E5
Save Register Pair HL (4225H, the start of the command buffer) onto the stack at the Stack Pointer.
Loop: copy the command in upper case.
5804
LD A,(DE) 1A
Fetch the next character of the string at Register Pair DE into Register A.
5805
INC DE 13
INCrement Register Pair DE to the following character of the string.
5806
GOSUB to 57BAH to turn the character in Register A into upper case if it is a lower case letter.
5809
LD (HL),A 77
Store Register A (the character) at Register Pair HL in the command buffer.
580A
INC HL 23
INCrement Register Pair HL to the next byte of the command buffer.
580B
DECrement Register B (the characters left) and LOOP BACK to 5804H until all characters are copied.
580D
LD (HL),0DH 36 0D
Store 0DH at Register Pair HL, after the last character, to end the command in the buffer.
Loop: find the last character that is not a space.
580F
DEC HL 2B
DECrement Register Pair HL back by one character in the command buffer.
5810
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5811
CP 20H FE 20
Compare Register A, the character, against 20H, a space. The Z FLAG is set for a space.
5813
If the Z FLAG is set (a trailing space), LOOP BACK to 580FH to step back over it. Register A ends as the last character that is not a space.
5815
POP HL E1
Restore Register Pair HL from the stack at the Stack Pointer: 4225H, the start of the command buffer.
5816
DEC C 0D
DECrement Register C, the length. The Z FLAG is set when the command is one character.
5817
If the Z FLAG is set (one character), JUMP to 57C3H for the letter commands, with Register Pair HL = 4225H and the BASIC text pointer on the stack.
581A
CP 24H FE 24
Compare Register A, the last character that is not a space, against 24H ($). The Z FLAG is set when the command ends in $.
581C
If the NZ FLAG is set (it does not end in $), JUMP to 57A4H to let SYS20/SYS run the command in the buffer at 4225H.
581F
The command ends in $: GOSUB to ROM 2611H (PTRGET after its first instruction) with Register Pair HL = 4225H, which finds the string variable named there; Register Pair DE returns the address of its descriptor.
5822
JUMP to 57F4H to take the variable's string as the command, with Register Pair DE = its descriptor and the text pointer still on the stack.
5824H - Function Name for DEF FN and FN
Reads a function name after FN: 40DCH = 80H tells PTRGET that a function name is wanted (bit 7 set on the first character). Returns Register Pair DE = the function's entry and the Z FLAG set when it is a string function (value type 03H). 5831H is a second entry, used by SYS20/SYS (its 5362H).
5824
RST 10H D7
RST 10H: INCrement Register Pair HL past the FN token and load the next character that is not a space (the first letter of the name) into Register A. Called from 5843H (DEF FN) and by SYS20/SYS's FN at its 534AH.
5825
LD A,80H 3E 80
Load Register A with 80H, the value that marks a function name.
5827
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that PTRGET tests: a nonzero value means a function name is being looked up.
582A
OR (HL) B6
OR the first letter of the name at Register Pair HL into Register A (80H): Register A = the letter with bit 7 set, which keeps function names apart from variables.
582B
LD B,A 47
Copy Register A (the first letter with bit 7 set) into Register B, where PTRGET keeps the first character of a name.
582C
GOSUB to ROM 2612H, PTRGET past its fetch of the first character (2611H is LD B,(HL)), with Register B = the letter with bit 7: Register Pair DE returns the address of the function's entry, Register Pair HL points past the name and 40AFH holds its value type.
582F
JUMP to 5839H to read the value type with Register Pair DE = the entry.
5831
LD A,80H 3E 80
Second entry, called by SYS20/SYS at its 5362H: load Register A with 80H, the value that marks a function name.
5833
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that makes PTRGET look up a function name.
5836
GOSUB to ROM 260DH, PTRGET: Register Pair DE returns the address of the entry named at Register Pair HL and 40AFH its value type.
5839
LD A,(40AFH) 3A AF 40
Fetch the value type at 40AFH into Register A (02H integer, 03H string, 04H single precision, 08H double precision). 582FH and 5890H come here.
583C
CP 03H FE 03
Compare Register A, the value type, against 03H. The Z FLAG is set for a string.
583E
RET C9
RETurn with Register Pair DE = the entry, Register A = the value type and the Z FLAG set for a string.
583FH - DEF Statement (DEF FN and DEF USR)
DEF link (415BH, from the JP 583FH at 67C4H) with Register A = the token after DEF. DEF FN name stores the text pointer (the start of the parameter list) in the function's entry and checks the parameter list; the rest of the statement is passed over like DATA. DEF USRn goes to 585CH.
583F
CP BEH FE BE
Compare Register A, the token after DEF, against BEH, the FN token. The Z FLAG is set for DEF FN.
5841
If the NZ FLAG is set (not FN), JUMP to 585CH for DEF USR.
5843
GOSUB to 5824H to find or create the function's entry: Register Pair DE returns its address and Register Pair HL points past the name.
5846
GOSUB to ROM 2828H, which gives ILLEGAL DIRECT when the statement is typed without a line number; Register Pair HL comes back unchanged.
5849
LD A,L 7D
Copy Register L, the low byte of the text pointer (at the parameter list), into Register A.
584A
LD (DE),A 12
Store Register A (the low byte of the text pointer) in the function's entry at Register Pair DE.
584B
INC DE 13
INCrement Register Pair DE to the next byte of the entry.
584C
LD A,H 7C
Copy Register H, the high byte of the text pointer, into Register A.
584D
LD (DE),A 12
Store Register A (the high byte) at Register Pair DE: the entry now points to the definition in the program text, which FN evaluates.
584E
LD A,28H 3E 28
Load Register A with 28H, the ( that must start the parameter list.
Loop: step through ( name , name ... to check the parameter names.
5850
CP (HL) BE
Compare Register A, the character expected (( first, then a comma), against the character at Register Pair HL. 585AH comes back here.
5851
JP NZ,1F05H C2 05 1F
If the NZ FLAG is set (not the character expected: the parameter list is over), JUMP to ROM 1F05H, the DATA statement's code, which passes over the rest of the statement (no link: the ROM page has no id at 1F05H).
5854
RST 10H D7
RST 10H: INCrement Register Pair HL past the ( or comma and load the next character that is not a space into Register A.
5855
GOSUB to ROM 260DH, PTRGET, to read the parameter name at Register Pair HL (Register Pair DE returns its address, which is not used); Register Pair HL moves past the name.
5858
LD A,2CH 3E 2C
Load Register A with 2CH, the comma that must come before the next parameter.
585A
LOOP BACK to 5850H to compare Register A (2CH) against the next character at Register Pair HL.
585CH - DEF USRn Statement
DEF USRn = address stores the address in the USR table at 589DH. Any other token after DEF is a syntax error.
585C
CP C1H FE C1
Compare Register A, the token after DEF, against C1H, the USR token. The Z FLAG is set for DEF USR.
585E
If the NZ FLAG is set (neither FN nor USR), JUMP to ROM 1997H, SYNTAX ERROR (Register E = 02H).
5861
GOSUB to 5870H: Register Pair DE returns the slot of USR0-USR9 in the table at 589DH and Register Pair HL points past the digit.
5864
PUSH DE D5
Save Register Pair DE (the slot address) onto the stack at the Stack Pointer.
5865
RST 08H CF
RST 08H: the byte after it (D5H, the = token) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it and Register A holds the next character.
5866
DEFB D5H D5
The byte the RST 08H at 5865H compares against: D5H, the = token. RST 08H returns past it, so it is never executed.
5867
GOSUB to ROM 2B02H to evaluate the address at Register Pair HL as an integer: Register Pair DE returns it and Register Pair HL points past it.
586A
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the slot address on the stack at the Stack Pointer: Register Pair HL = the slot.
586B
LD (HL),E 73
Store Register E, the low byte of the address, in the slot at Register Pair HL.
586C
INC HL 23
INCrement Register Pair HL to the high byte of the slot.
586D
LD (HL),D 72
Store Register D, the high byte of the address, in the slot at Register Pair HL.
586E
POP HL E1
Restore Register Pair HL from the stack at the Stack Pointer: the text pointer. A USR routine also returns here (588BH pushes 586EH), and then the text pointer pushed at 5887H is restored.
586F
RET C9
RETurn with Register Pair HL = the text pointer, to the ROM's statement loop (DEF) or to the expression evaluator (USR).
5870H - USR Digit to Table Slot
Returns Register Pair DE = 589DH + 2 x n for USRn (n = 0-9, 0 when no digit follows). Register Pair HL is the text pointer.
5870
LD DE,589DH 11 9D 58
Point Register Pair DE to 589DH, the slot of USR0. 5861H and 5880H call here.
5873
RST 10H D7
RST 10H: INCrement Register Pair HL past the USR token and load the next character that is not a space into Register A; the CARRY FLAG is set for a digit.
5874
RET NC D0
If the NO CARRY FLAG is set (no digit: USR alone), RETurn with Register Pair DE = 589DH, USR0's slot.
5875
SUB 30H D6 30
SUBtract 30H from Register A, turning the digit 0-9 into its value.
5877
ADD A,A 87
ADD Register A to itself: the value times 2, since each slot is two bytes.
5878
ADD A,E 83
ADD Register E, the low byte of 589DH, to Register A.
5879
LD E,A 5F
Copy Register A into Register E, the low byte of the slot address in Register Pair DE.
587A
If the NO CARRY FLAG is set (no carry out of the low byte), JUMP to 587DH.
587C
INC D 14
INCrement Register D to carry into the high byte of Register Pair DE.
587D
RST 10H D7
RST 10H: INCrement Register Pair HL past the digit and load the next character that is not a space into Register A.
587E
RET C9
RETurn with Register Pair DE = the slot of USRn and Register Pair HL past the digit.
587FH - USR Function
Link 41A9H (from the JP 587FH at 6812H; the ROM calls 41A9H at 27FEH for USR). The routine at the address in the slot for USRn is called with Register Pair HL = 4121H (the argument in the ROM's accumulator) and Register A = the value type; it returns to 586EH, which restores the text pointer.
587F
POP AF F1
POP the ROM's return address from its CALL 41A9H at 27FEH off the stack at the Stack Pointer into Register Pair AF, dropping it: the result is returned through 586EH instead.
5880
GOSUB to 5870H: Register Pair DE returns the slot for USRn in the table at 589DH and Register Pair HL points past the digit.
5883
PUSH DE D5
Save Register Pair DE (the slot address) onto the stack at the Stack Pointer.
5884
GOSUB to ROM 252CH to evaluate the argument in parentheses at Register Pair HL into the ROM's accumulator at 4121H (value type at 40AFH); Register Pair HL returns past the ).
5887
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the slot address on the stack at the Stack Pointer: Register Pair HL = the slot, the text pointer is kept on the stack.
5888
LD C,(HL) 4E
Load Register C with the low byte of the routine's address from the slot at Register Pair HL.
5889
INC HL 23
INCrement Register Pair HL to the high byte of the slot.
588A
LD B,(HL) 46
Load Register B with the high byte of the routine's address from the slot at Register Pair HL. Register Pair BC = the USR routine.
588B
LD HL,586EH 21 6E 58
Point Register Pair HL to 586EH, where the routine is to return.
588E
PUSH HL E5
Push Register Pair HL (586EH) onto the stack at the Stack Pointer as the USR routine's return address.
588F
PUSH BC C5
Push Register Pair BC (the routine's address) onto the stack at the Stack Pointer, so that the RET at 589CH jumps to it.
5890
GOSUB to 5839H: Register A returns the value type from 40AFH and the Z FLAG is set for a string.
5893
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the value type, the Z FLAG for a string.
5894
If the Z FLAG is set (a string argument), GOSUB to ROM 29DAH, which frees the string's temporary descriptor (its address at 4121H) and returns Register Pair HL = the descriptor.
5897
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the string's descriptor (for a string argument).
5898
LD HL,4121H 21 21 41
Point Register Pair HL to 4121H, the ROM's accumulator holding the argument (for a string, its descriptor address).
589B
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the value type, the Z FLAG for a string.
589C
RET C9
RETurn: the RET pops the routine's address pushed from Register Pair BC and jumps to the USR routine with Register Pair HL = 4121H and Register A = the value type; it returns to 586EH.
589DH - USR Address Table (USR0-USR9)
Ten addresses set by DEF USRn (586BH-586DH). Each starts as 1E4AH, so a USR that was never defined gives ILLEGAL FUNCTION CALL.
589D-589E
DEFW 1E4AH 4A 1E
The slot of USR0 (5870H returns 589DH): 1E4AH, ROM ILLEGAL FUNCTION CALL, until DEF USR0 stores an address.
589F-58A0
DEFW 1E4AH 4A 1E
The slot of USR1: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR1 stores an address.
58A1-58A2
DEFW 1E4AH 4A 1E
The slot of USR2: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR2 stores an address.
58A3-58A4
DEFW 1E4AH 4A 1E
The slot of USR3: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR3 stores an address.
58A5-58A6
DEFW 1E4AH 4A 1E
The slot of USR4: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR4 stores an address.
58A7-58A8
DEFW 1E4AH 4A 1E
The slot of USR5: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR5 stores an address.
58A9-58AA
DEFW 1E4AH 4A 1E
The slot of USR6: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR6 stores an address.
58AB-58AC
DEFW 1E4AH 4A 1E
The slot of USR7: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR7 stores an address.
58AD-58AE
DEFW 1E4AH 4A 1E
The slot of USR8: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR8 stores an address.
58AF-58B0
DEFW 1E4AH 4A 1E
The slot of USR9: 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR9 stores an address.
58B1H - MKD$, MKS$ and MKI$ Functions
The links for MKD$ (4170H, from the JP 58B1H at 67D9H), MKS$ (416DH, JP 58B4H at 67D6H) and MKI$ (416AH, JP 58B7H at 67D3H) enter with the number in the ROM's accumulator. Register A is set to the length of the result, which is also the ROM's value type code: 08H double, 04H single, 02H integer. The number is converted to that type and a string of that many bytes holding it is returned.
Overlapping Instructions
MKD$ enters at 58B1H (Register A = 08H); the LD BC instructions at 58B3H and 58B6H then only load Register Pair BC. MKS$ enters at 58B4H, where the bytes 3EH 04H are LD A,04H. MKI$ enters at 58B7H, where 3EH 02H are LD A,02H.
58B1
LD A,08H 3E 08
MKD$ entry (4170H): load Register A with 08H, the length of a double precision number and its value type code.
58B3
LD BC,043EH 01 3E 04
Run from 58B1H: load Register Pair BC with 043EH, which only steps over the bytes 3EH 04H, so Register A stays 08H. The MKS$ link (416DH) enters at 58B4H, where 3EH 04H is LD A,04H: Register A = 04H, the length of a single precision number and its value type code.
58B6
LD BC,023EH 01 3E 02
Run from 58B1H or 58B4H: load Register Pair BC with 023EH, which only steps over the bytes 3EH 02H, so Register A keeps 08H or 04H. The MKI$ link (416AH) enters at 58B7H, where 3EH 02H is LD A,02H: Register A = 02H, the length of an integer and its value type code.
58B9
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the length and value type (08H, 04H or 02H).
58BA
GOSUB to ROM 2819H, which converts the number in the ROM's accumulator (4121H, value type at 40AFH) to the value type in Register A.
58BD
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the length (08H, 04H or 02H).
58BE
GOSUB to ROM 2857H to reserve Register A bytes of string space and build a temporary descriptor for them at 40D3H: Register Pair DE returns the address of the space.
58C1
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the address of the new string space (Register Pair DE keeps the text pointer).
58C2
GOSUB to ROM 09FFH (LD DE,09D3H, then the move at 0A02H), which copies the number in the ROM's accumulator (as many bytes as its value type at 40AFH) to the address in Register Pair HL.
58C5
JUMP to ROM 2A2BH (POP BC / JP 2884H): the word on top of the stack at the Stack Pointer is dropped, and 2884H returns the descriptor built at 40D3H as the function's string result.
58C8H - CVD, CVS and CVI Functions
The links for CVD (415EH, from the JP 58C8H at 67C7H), CVS (4158H, JP 58CBH at 67C1H) and CVI (4152H, JP 58CEH at 67BBH) enter with the string argument in the ROM's accumulator. Register A = 08H, 04H or 02H is the number of bytes needed and the value type of the result. A shorter string gives ILLEGAL FUNCTION CALL; otherwise its first bytes are copied into the accumulator as the number.
Overlapping Instructions
CVD enters at 58C8H (Register A = 08H); the LD BC instructions at 58CAH and 58CDH then only load Register Pair BC. CVS enters at 58CBH, where 3EH 04H is LD A,04H. CVI enters at 58CEH, where 3EH 02H is LD A,02H.
58C8
LD A,08H 3E 08
CVD entry (415EH): load Register A with 08H, the size of a double precision number and its value type code.
58CA
LD BC,043EH 01 3E 04
Run from 58C8H: load Register Pair BC with 043EH, which only steps over the bytes 3EH 04H, so Register A stays 08H. The CVS link (4158H) enters at 58CBH, where 3EH 04H is LD A,04H: Register A = 04H, the size of a single precision number.
58CD
LD BC,023EH 01 3E 02
Run from 58C8H or 58CBH: load Register Pair BC with 023EH, which only steps over the bytes 3EH 02H, so Register A keeps its value. The CVI link (4152H) enters at 58CEH, where 3EH 02H is LD A,02H: Register A = 02H, the size of an integer.
58D0
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the size and value type (08H, 04H or 02H).
58D1
GOSUB to 5C99H to take the string from the ROM's accumulator: Register A returns its length, Register Pair DE the address of its text and Register Pair HL its descriptor.
58D4
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the size and value type.
58D5
LD (40AFH),A 32 AF 40
Store Register A at 40AFH, the ROM's value type: the result is of that type.
58D8
DEC A 3D
DECrement Register A, the size, by 1 for the compare with the string's length.
58D9
CP (HL) BE
Compare Register A (the size minus 1) against the string's length, the first byte of the descriptor at Register Pair HL. The NO CARRY FLAG is set when the string is shorter than the size.
58DA
If the NO CARRY FLAG is set (the string is too short), JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
58DD
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the address of the string's text.
58DE
JUMP to ROM 09F7H (LD DE,09D2H, then the move at 0A02H), which copies as many bytes as the value type at 40AFH from the text at Register Pair HL into the ROM's accumulator (4121H, or 411DH for double precision) and returns the number.
58E1H - LSET and RSET Statements
The links for LSET (4197H, from the JP 58E1H at 6800H) and RSET (419AH, JP 58E2H at 6803H). LSET var$ = x$ copies x$ into the existing text of var$ from the left and pads it with spaces; RSET pads first, so that x$ ends at the right; a longer x$ is cut to the length of var$. A var$ whose text is a literal in the program is first copied to string space, so that the program is not changed.
Overlapping Instructions
LSET enters at 58E1H, where F6H AFH is OR AFH. RSET enters at 58E2H, where the byte AFH is XOR A.
58E1
OR AFH F6 AF
LSET entry (4197H): OR Register A with AFH, so that Register A is not 0 and the Z FLAG is clear, the mark of LSET. The RSET link (419AH) enters at 58E2H, where the byte AFH is XOR A: Register A = 00H with the Z FLAG set, the mark of RSET.
58E3
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: the Z FLAG is clear for LSET and set for RSET.
58E4
GOSUB to 5E7BH to read the variable name at Register Pair HL (ROM PTRGET) and require a string: Register Pair DE returns the address of the variable's descriptor (length, text address).
58E7
PUSH HL E5
Save Register Pair HL, the text pointer after the name, onto the stack at the Stack Pointer.
58E8
PUSH DE D5
Save Register Pair DE, the address of the variable's descriptor, onto the stack at the Stack Pointer.
58E9
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the descriptor of the variable.
58EA
INC HL 23
INCrement Register Pair HL past the length byte of the descriptor to its text address.
58EB
LD E,(HL) 5E
Load Register E with the low byte of the text address from the descriptor at Register Pair HL.
58EC
INC HL 23
INCrement Register Pair HL to the high byte of the text address.
58ED
LD D,(HL) 56
Load Register D with the high byte from Register Pair HL: Register Pair DE = the address of the variable's text.
58EE
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the word at 40F9H, the ROM's pointer to the end of the program text (the start of the simple variables).
58F1
RST 18H DF
RST 18H compares Register Pair HL (the end of the program) with Register Pair DE (the text): the CARRY FLAG is set when the text lies above the program.
58F2
If the CARRY FLAG is set (the text is in string space), JUMP to 58FDH: it can be changed in place.
58F4
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the ROM's pointer to the start of the program.
58F7
RST 18H DF
RST 18H compares Register Pair HL (the start of the program) with Register Pair DE (the text): the CARRY FLAG is set when the text lies inside the program, a literal.
58F8
POP HL E1
POP into Register Pair HL the descriptor's address from the stack at the Stack Pointer. POP does not change the flags.
58F9
PUSH HL E5
Push Register Pair HL (the descriptor's address) back onto the stack at the Stack Pointer.
58FA
If the CARRY FLAG is set (the text is a literal in the program), GOSUB to 5CC4H with Register Pair HL = the descriptor, which copies the text into string space and points the descriptor at the copy.
58FD
POP HL E1
POP the descriptor's address from the stack at the Stack Pointer into Register Pair HL.
58FE
EX (SP),HL E3
Exchange Register Pair HL (the descriptor's address) with the text pointer on the stack at the Stack Pointer: Register Pair HL = the text pointer, the descriptor is kept on the stack.
58FF
RST 08H CF
RST 08H: the byte after it (D5H, the = token) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it and Register A holds the next character.
5900
DEFB D5H D5
The byte the RST 08H at 58FFH compares against: D5H, the = token. RST 08H returns past it, so it is never executed.
5901
GOSUB to ROM 2337H to evaluate the expression after the = at Register Pair HL (the string to store) into the ROM's accumulator; Register Pair HL returns past it.
5904
POP BC C1
POP into Register Pair BC the variable's descriptor address from the stack at the Stack Pointer.
5905
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the saved Register Pair AF (the LSET or RSET mark) on the stack at the Stack Pointer: Register Pair HL = the mark, the text pointer is kept on the stack.
5906
PUSH HL E5
Push Register Pair HL (the mark word) back onto the stack at the Stack Pointer, for the POP AF at 591FH.
5907
PUSH BC C5
Push Register Pair BC (the variable's descriptor address) onto the stack at the Stack Pointer.
5908
GOSUB to 5C99H to take the string from the ROM's accumulator: Register A returns its length and Register Pair DE the address of its text.
590B
LD C,A 4F
Copy Register A, the source string's length, into Register C.
590C
POP HL E1
POP into Register Pair HL the variable's descriptor address from the stack at the Stack Pointer.
590D
PUSH DE D5
Save Register Pair DE, the address of the source text, onto the stack at the Stack Pointer.
590E
LD B,(HL) 46
Load Register B with the variable's length, the first byte of its descriptor at Register Pair HL.
590F
INC HL 23
INCrement Register Pair HL to the low byte of the variable's text address.
5910
LD E,(HL) 5E
Load Register E with the low byte of the variable's text address from Register Pair HL.
5911
INC HL 23
INCrement Register Pair HL to the high byte of the text address.
5912
LD D,(HL) 56
Load Register D with the high byte from Register Pair HL: Register Pair DE = the variable's text.
5913
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the variable's text, the destination.
5914
POP DE D1
POP into Register Pair DE the address of the source text from the stack at the Stack Pointer.
5915
LD A,B 78
Copy Register B, the variable's length, into Register A.
5916
SUB C 91
SUBtract Register C, the source's length, from Register A, the variable's length. The CARRY FLAG is set when the source is longer.
5917
If the CARRY FLAG is set (the source is longer), JUMP to 591DH: Register B (the variable's length) is already the number of bytes to copy.
5919
LD B,C 41
Copy Register C (the source's length) into Register B: the number of bytes to copy.
591A
LD C,A 4F
Copy Register A (the variable's length minus the source's) into Register C: the number of spaces to pad.
591B
JUMP to 591FH with Register B = the bytes to copy and Register C = the spaces.
591D
LD C,00H 0E 00
Load Register C with 00H: no spaces when the source is at least as long as the variable.
591F
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: the Z FLAG is set for RSET.
5920
If the Z FLAG is set (RSET), GOSUB to 5CBCH to store Register C spaces at Register Pair HL first; it returns with Register C = 00H.
5923
GOSUB to 5CB6H to copy Register B bytes from the source at Register Pair DE to the variable's text at Register Pair HL.
5926
GOSUB to 5CBCH to store the remaining Register C spaces at Register Pair HL (none left after RSET).
5929
POP HL E1
Restore Register Pair HL, the text pointer, from the stack at the Stack Pointer.
592A
RET C9
RETurn to the ROM's statement loop with Register Pair HL = the text pointer.
592BH - CMD"F=" Function Table
Searched by SYS20/SYS for CMD"F=name": each entry is a length byte, the name and the address of the routine; 00H ends the table. POPS (5316H), POPR (5324H) and POPN (5334H) are in SYS20/SYS itself; ERASE (57AAH), KEEP (57AEH), SASZ (5C34H), SWAP (5963H) and SS (5B8FH) are in this file.
592B-592F
DEFB 04H / DEFM "POPS" 04 50 4F 50 53
Entry 1 of the CMD"F=" table: the length byte 04H and the name POPS.
5930-5931
DEFW 5316H 16 53
The address of CMD"F=POPS": 5316H in SYS20/SYS, which is in memory when SYS20/SYS searches this table (the manual: drop all GOSUB returns and FOR-NEXT loops).
5932-5936
DEFB 04H / DEFM "POPR" 04 50 4F 50 52
Entry 2 of the CMD"F=" table: the length byte 04H and the name POPR.
5937-5938
DEFW 5324H 24 53
The address of CMD"F=POPR": 5324H in SYS20/SYS (the manual: drop the latest GOSUB return).
5939-593D
DEFB 04H / DEFM "POPN" 04 50 4F 50 4E
Entry 3 of the CMD"F=" table: the length byte 04H and the name POPN.
593E-593F
DEFW 5334H 34 53
The address of CMD"F=POPN": 5334H in SYS20/SYS (the manual: drop a FOR-NEXT loop).
5940-5945
DEFB 05H / DEFM "ERASE" 05 45 52 41 53 45
Entry 4 of the CMD"F=" table: the length byte 05H and the name ERASE.
5946-5947
DEFW 57AAH AA 57
The address of CMD"F=ERASE": 57AAH, which runs SYS21/SYS with Register B = 28H.
5948-594C
DEFB 04H / DEFM "KEEP" 04 4B 45 45 50
Entry 5 of the CMD"F=" table: the length byte 04H and the name KEEP.
594D-594E
DEFW 57AEH AE 57
The address of CMD"F=KEEP": 57AEH, which runs SYS21/SYS with Register B = 20H.
594F-5953
DEFB 04H / DEFM "SASZ" 04 53 41 53 5A
Entry 6 of the CMD"F=" table: the length byte 04H and the name SASZ.
5954-5955
DEFW 5C34H 34 5C
The address of CMD"F=SASZ": 5C34H, which changes the size of the string area.
5956-595A
DEFB 04H / DEFM "SWAP" 04 53 57 41 50
Entry 7 of the CMD"F=" table: the length byte 04H and the name SWAP.
595B-595C
DEFW 5963H 63 59
The address of CMD"F=SWAP": 5963H, which exchanges the values of two variables.
595D-595F
DEFB 02H / DEFM "SS" 02 53 53
Entry 8 of the CMD"F=" table: the length byte 02H and the name SS.
5960-5961
DEFW 5B8FH 8F 5B
The address of CMD"F=SS": 5B8FH, single stepping.
5962
DEFB 00H 00
00H in place of a length byte: the end of the CMD"F=" table.
5963H - CMD"F=SWAP",var1,var2
Exchanges the values of two variables of the same type; the number of bytes exchanged is the value type code (2 integer, 3 a string's descriptor, 4 single, 8 double precision). Different types give ILLEGAL FUNCTION CALL.
5963
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL after SWAP, else SYNTAX ERROR; Register Pair HL is moved past it and Register A holds the next character.
5964
DEFB 2CH 2C
The byte the RST 08H at 5963H compares against: 2CH, a comma. It is never executed.
5965
GOSUB to ROM 260DH, PTRGET: Register Pair DE returns the address of the first variable's value and 40AFH its value type; Register Pair HL moves past the name.
5968
PUSH DE D5
Save Register Pair DE (the address of the first variable) onto the stack at the Stack Pointer.
5969
LD A,(40AFH) 3A AF 40
Fetch the first variable's value type from 40AFH into Register A.
596C
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the first variable's value type.
596D
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the next character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it.
596E
DEFB 2CH 2C
The byte the RST 08H at 596DH compares against: 2CH, a comma. It is never executed.
596F
GOSUB to ROM 260DH, PTRGET: Register Pair DE returns the address of the second variable's value and 40AFH its value type.
5972
POP BC C1
POP into Register Pair BC the word pushed from Register Pair AF: Register B = the first variable's value type.
5973
LD A,(40AFH) 3A AF 40
Fetch the second variable's value type from 40AFH into Register A.
5976
CP B B8
Compare Register A (the second value type) against Register B (the first). The Z FLAG is set when they are the same.
5977
If the NZ FLAG is set (different types), JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
597A
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the first variable's address on the stack at the Stack Pointer: Register Pair HL = the first variable, the text pointer is kept on the stack.
Loop: exchange Register B bytes.
597B
LD C,(HL) 4E
Load Register C with a byte of the first variable at Register Pair HL. 5982H loops back here.
597C
LD A,(DE) 1A
Fetch the matching byte of the second variable at Register Pair DE into Register A.
597D
LD (HL),A 77
Store Register A (the second variable's byte) into the first variable at Register Pair HL.
597E
LD A,C 79
Copy Register C (the first variable's byte) into Register A.
597F
LD (DE),A 12
Store Register A (the first variable's byte) into the second variable at Register Pair DE.
5980
INC HL 23
INCrement Register Pair HL to the next byte of the first variable.
5981
INC DE 13
INCrement Register Pair DE to the next byte of the second variable.
5982
DECrement Register B (the bytes left, starting from the value type code) and LOOP BACK to 597BH until every byte is exchanged.
5984
POP HL E1
Restore Register Pair HL, the text pointer, from the stack at the Stack Pointer.
5985
RET C9
RETurn to the caller in SYS20/SYS with Register Pair HL = the text pointer and the two values exchanged.
5986H - CMD"C" Program Compression: Options
CMD"C" removes spaces (outside strings) and remarks; CMD"C",S only spaces; CMD"C",R only remarks. It is allowed only as a direct command. The options set two code bytes: 5A4BH (28H JR Z removes spaces, FEH makes it a CP that keeps them) and 5A6EH (00H NOP drops a remark, 13H INC DE keeps it). The overlay area at 4D00H is used as a line buffer, so the overlay byte 4288H is cleared.
5986
LD DE,(40A2H) ED 5B A2 40
Load Register Pair DE with the word at 40A2H, the ROM's current line number (FFFFH for a direct command).
598A
LD A,D 7A
Copy Register D, the high byte of the line number, into Register A.
598B
AND E A3
AND Register A with Register E, the low byte: FFH only when both bytes are FFH, line FFFFH.
598C
INC A 3C
INCrement Register A: 00H with the Z FLAG for a direct command.
598D
If the NZ FLAG is set (CMD"C" inside a program), JUMP to ROM 1997H, SYNTAX ERROR.
5990
LD BC,2800H 01 00 28
Load Register Pair BC with 2800H, the values when no option is given: Register B = 28H (JR Z, remove spaces), Register C = 00H (NOP, remove remarks).
5993
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H reads the current character again.
5994
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A; the Z FLAG is set at the end of the statement (00H or a colon).
5995
If the Z FLAG is set (no option), JUMP to 59ACH with Register Pair BC = 2800H.
5997
LD BC,FE13H 01 13 FE
Options given: load Register Pair BC with FE13H, Register B = FEH (keep spaces) and Register C = 13H (INC DE, keep remarks), until an option says otherwise.
Loop: one option per comma.
599A
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it and Register A holds the option letter. 59AAH loops back here.
599B
DEFB 2CH 2C
The byte the RST 08H at 599AH compares against: 2CH, a comma. It is never executed.
599C
CP 52H FE 52
Compare Register A, the option letter, against 52H (R). The Z FLAG is set for the option R.
599E
If the NZ FLAG is set (not R), JUMP to 59A4H, which requires S.
59A0
LD C,00H 0E 00
Option R: load Register C with 00H, the NOP that removes remarks.
59A2
JUMP to 59A9H to look for another option after the R.
59A4
LD B,28H 06 28
Option S: load Register B with 28H, the JR Z that removes spaces.
59A6
RST 08H CF
RST 08H: the byte after it (53H, the letter S) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it.
59A7
DEFB 53H 53
The byte the RST 08H at 59A6H compares against: 53H, the letter S. It is never executed.
59A8
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H reads the current character again.
59A9
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A; the Z FLAG is set at the end of the statement. 59A2H comes here.
59AA
If the NZ FLAG is set (more text: another option), LOOP BACK to 599AH.
59AC
LD A,B 78
Copy Register B, the space option (28H or FEH), into Register A. 5995H comes here.
59AD
LD (5A4BH),A 32 4B 5A
Store Register A as the opcode at 5A4BH: 28H (JR Z, a space is not copied) or FEH (CP 1EH, the space is copied).
59B0
LD A,C 79
Copy Register C, the remark option (00H or 13H), into Register A.
59B1
LD (5A6EH),A 32 6E 5A
Store Register A as the opcode at 5A6EH: 00H (NOP, the remark is dropped) or 13H (INC DE, the remark is kept).
59B4
LD HL,4289H 21 89 42
Point Register Pair HL to 4289H, SYS0/SYS's system flags.
59B7
SET 6,(HL) CB F6
Set bit 6 of the system flags at Register Pair HL (4289H): the same mark the RST 28H dispatcher sets while an overlay function runs, which blocks the key combinations (SYS0/SYS 45A1H) while 4D00H is used as a buffer.
59B9
XOR A AF
Set Register A to 00H with XOR A, the value for the overlay byte 4288H below.
59BA
LD (4288H),A 32 88 42
Store Register A (00H) at 4288H, the slot of the overlay in 4D00H-51FFH: none, because the line buffer at 4D00H overwrites it, so the next RST 28H reloads its overlay.
59BD
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the word at 40A4H, the ROM's pointer to the start of the program: the source pointer.
59C0
LD D,H 54
Copy Register H (the high byte of the program start) into Register D.
59C1
LD E,L 5D
Copy Register L into Register E: Register Pair DE = the destination pointer, the same address as the source.
59C2
JUMP to 5A0AH to start with the first line's link.
59C4H - CMD"C": Line Loop
Each line is copied to 4D00H (kept as the original) and compressed in place. A line that became empty (only a remark) is dropped. Otherwise the line is listed and tokenized again: if the result differs from the compressed line (spaces between words can be needed, as in IF A THEN), the original is put back and its line number is displayed. At the end the line links are rebuilt.
59C4
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the destination pointer at the end of the compressed line, Register Pair DE = the source. 5A45H comes here after each line.
59C5
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
59C6
SBC HL,BC ED 42
SUBtract Register Pair BC (the start of the compressed line's text) from Register Pair HL (its end). The Z FLAG is set when the compressed line is empty.
59C8
ADD HL,BC 09
ADD Register Pair BC back to Register Pair HL. ADD HL,BC does not change the Z FLAG of the SBC.
59C9
EX DE,HL EB
Exchange Register Pairs DE and HL back: Register Pair DE = the destination, Register Pair HL = the source.
59CA
INC DE 13
INCrement Register Pair DE past the compressed line's 00H. INC DE does not change the flags.
59CB
INC HL 23
INCrement Register Pair HL, the source, past its 00H.
59CC
If the NZ FLAG is set (the compressed line is not empty), JUMP to 59D5H to check it.
59CE
DEC DE 1B
The line was only a remark: DECrement Register Pair DE (1 of 5) to move back over its 00H, line number and link, so that the line is dropped.
59CF
DEC DE 1B
DECrement Register Pair DE (2 of 5) back over the dropped line.
59D0
DEC DE 1B
DECrement Register Pair DE (3 of 5) back over the dropped line.
59D1
DEC DE 1B
DECrement Register Pair DE (4 of 5) back over the dropped line.
59D2
DEC DE 1B
DECrement Register Pair DE (5 of 5): Register Pair DE is back at the dropped line's link, where the next line goes.
59D3
JUMP to 5A0AH to copy the next line's link with Register Pair DE = the destination and Register Pair HL = the source.
59D5
PUSH HL E5
Save Register Pair HL (the source of the next line) onto the stack at the Stack Pointer.
59D6
LD H,B 60
Copy Register B (the high byte of the compressed line's text) into Register H.
59D7
LD L,C 69
Copy Register C into Register L: Register Pair HL = the start of the compressed line's text.
59D8
PUSH HL E5
Save Register Pair HL (the compressed line's text) onto the stack at the Stack Pointer.
59D9
GOSUB to ROM 2B7EH (BUFLIN), which lists the line at Register Pair HL as text into the input buffer (its address at 40A7H); Register Pair BC returns the address after the text.
59DC
XOR A AF
Set Register A to 00H for the end of the listed text.
59DD
LD (BC),A 02
Store Register A (00H) at Register Pair BC, the end of the listed text.
59DE
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the word at 40A7H, the ROM's pointer to the input buffer.
59E1
GOSUB to ROM 1BC0H (CRUNCH), which tokenizes the text at Register Pair HL in the input buffer again; Register Pair HL returns one byte before the tokenized text.
59E4
POP BC C1
POP into Register Pair BC the compressed line's text address from the stack at the Stack Pointer.
59E5
LD D,B 50
Copy Register B (the high byte of the compressed line's text) into Register D.
59E6
LD E,C 59
Copy Register C into Register E: Register Pair DE = the compressed line's text.
Loop: compare the tokenized buffer with the compressed line.
59E7
INC HL 23
INCrement Register Pair HL to the next byte of the tokenized buffer. 5A07H loops back here.
59E8
LD A,(DE) 1A
Fetch a byte of the compressed line at Register Pair DE into Register A.
59E9
CP (HL) BE
Compare Register A (the compressed line's byte) against the tokenized buffer's byte at Register Pair HL. The Z FLAG is set when they are the same.
59EA
INC DE 13
INCrement Register Pair DE to the next byte of the compressed line. INC DE does not change the flags.
59EB
If the Z FLAG is set (the bytes agree), JUMP to 5A06H to test for the line's end.
59ED
LD HL,4D00H 21 00 4D
The bytes differ: point Register Pair HL to 4D00H, where the original line was kept.
Loop: put the original line back.
59F0
LD A,(HL) 7E
Fetch a byte of the original line at Register Pair HL into Register A. 59F5H loops back here.
59F1
OR A B7
OR Register A with itself: the Z FLAG is set at the line's 00H.
59F2
LD (BC),A 02
Store Register A in the line at Register Pair BC, putting the original back. LD does not change the flags.
59F3
INC HL 23
INCrement Register Pair HL to the next byte of the original line.
59F4
INC BC 03
INCrement Register Pair BC to the next byte of the line in the program.
59F5
If the NZ FLAG is set (the byte was not the 00H), LOOP BACK to 59F0H.
59F7
PUSH BC C5
Save Register Pair BC (the address after the restored line) onto the stack at the Stack Pointer.
59F8
LD DE,0000H 11 00 00
Self-Modifying Code
Load Register Pair DE with the line's number, the operand at 59F9H-59FAH stored by 5A2CH (0000H in the file).
59FB
GOSUB to 5D67H to display the line number in Register Pair DE in decimal; Register E returns the number of digits.
59FE
LD A,08H 3E 08
Load Register A with 08H, the width of the line number column.
5A00
SUB E 93
SUBtract Register E (the number of digits) from Register A: the spaces that fill the column.
5A01
GOSUB to 5D30H to display Register A spaces after the line number.
5A04
XOR A AF
Set Register A to 00H, so that the test at 5A06H ends the compare.
5A05
POP DE D1
POP into Register Pair DE the address after the restored line from the stack at the Stack Pointer.
5A06
OR A B7
OR Register A with itself: the Z FLAG is set when the byte compared (or the 00H from 5A04H) ends the line. 59EBH comes here.
5A07
If the NZ FLAG is set (not the end of the line), LOOP BACK to 59E7H to compare the next byte.
5A09
POP HL E1
Restore Register Pair HL (the source of the next line, saved at 59D5H) from the stack at the Stack Pointer.
5A0A
LD C,(HL) 4E
Load Register C with the low byte of the next line's link at Register Pair HL (the source). 59C2H and 59D3H come here.
5A0B
INC HL 23
INCrement Register Pair HL to the high byte of the link.
5A0C
LD B,(HL) 46
Load Register B with the high byte of the link from Register Pair HL: Register Pair BC = the link.
5A0D
LD A,C 79
Copy Register C (the low byte of the link) into Register A.
5A0E
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A0F
INC DE 13
INCrement Register Pair DE to the next destination byte.
5A10
LD A,B 78
Copy Register B (the high byte of the link) into Register A.
5A11
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A12
INC DE 13
INCrement Register Pair DE to the next destination byte.
5A13
INC HL 23
INCrement Register Pair HL to the source line's number.
5A14
LD A,B 78
Copy Register B (the high byte of the link) into Register A.
5A15
OR C B1
OR Register A with Register C: the Z FLAG is set for a link of 0000H, the end of the program.
5A16
If the NZ FLAG is set (another line follows), JUMP to 5A24H.
5A18
End of the program: GOSUB to ROM 1AF8H, which rebuilds the link of every line, since the lines moved.
5A1B
GOSUB to ROM 1B59H, the part of NEW after the start of the program is set, which stores the end of the program at 40F9H and clears the variables.
5A1E
GOSUB to 5D52H to display a carriage return after the list of line numbers.
5A21
JUMP to ROM 1A19H, READY: the command is over.
5A24
LD C,(HL) 4E
Load Register C with the low byte of the line number at Register Pair HL (the source). 5A16H comes here.
5A25
INC HL 23
INCrement Register Pair HL to the high byte of the line number.
5A26
LD B,(HL) 46
Load Register B with the high byte of the line number from Register Pair HL: Register Pair BC = the line number.
5A27
LD A,C 79
Copy Register C (the low byte of the line number) into Register A.
5A28
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A29
INC DE 13
INCrement Register Pair DE to the next destination byte.
5A2A
LD A,B 78
Copy Register B (the high byte of the line number) into Register A.
5A2B
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A2C
LD (59F9H),BC ED 43 F9 59
Store Register Pair BC (the line number) at 59F9H-59FAH, the operand of the LD DE at 59F8H, for the display when the line is put back.
5A30
INC DE 13
INCrement Register Pair DE to where the destination line's text starts.
5A31
INC HL 23
INCrement Register Pair HL to the source line's text.
5A32
PUSH HL E5
Save Register Pair HL (the source text) onto the stack at the Stack Pointer.
5A33
LD B,D 42
Copy Register D (the high byte of the destination text) into Register B.
5A34
LD C,E 4B
Copy Register E into Register C: Register Pair BC = the start of the destination text, used at 59C6H and 59D6H.
5A35
PUSH DE D5
Save Register Pair DE (the destination text) onto the stack at the Stack Pointer.
5A36
LD DE,4D00H 11 00 4D
Point Register Pair DE to 4D00H, where the original line is kept.
5A39
GOSUB to 5A4DH to copy one item of the source at Register Pair HL to Register Pair DE (4D00H on), without the space rule; the remark rule at 5A6EH still applies. 5A3CH loops back here.
5A3C
If the NZ FLAG is set (the line's 00H has not been copied yet), LOOP BACK to 5A39H.
5A3E
POP DE D1
Restore Register Pair DE (the destination text) from the stack at the Stack Pointer.
5A3F
POP HL E1
Restore Register Pair HL (the source text) from the stack at the Stack Pointer.
5A40
GOSUB to 5A48H to copy one item of the source at Register Pair HL to the destination at Register Pair DE with both rules. 5A43H loops back here.
5A43
If the NZ FLAG is set (the line's 00H has not been copied yet), LOOP BACK to 5A40H.
5A45
JUMP to 59C4H to finish the line with Register Pair DE = the end of the compressed line and Register Pair HL = the source.
5A48H - CMD"C": Copy One Item
Copies from Register Pair HL to Register Pair DE: a space (passed over when 5A4BH is JR Z), a whole quoted string, or one character. After a colon or at a REM token (93H) the opcode at 5A6EH decides whether the remark is copied (INC DE) or dropped (NOP: the destination stops moving, so the remark is written over itself and the line ends there). Returns the Z FLAG at the line's 00H.
5A48
LD A,(HL) 7E
Fetch the source character at Register Pair HL into Register A.
5A49
CP 20H FE 20
Compare Register A against 20H, a space. The Z FLAG is set for a space.
5A4B
Self-Modifying Code
Opcode stored by 59ADH: 28H makes this JR Z,5A6BH, so that a space is passed over without being copied; FEH makes the two bytes CP 1EH, which only changes the flags, and the space is copied.
5A4D
LD A,(HL) 7E
Fetch the source character at Register Pair HL into Register A. 5A39H calls here directly (no space rule).
5A4E
OR A B7
OR Register A with itself: the Z FLAG is set for the line's 00H.
5A4F
LD (DE),A 12
Store Register A at the destination Register Pair DE. LD does not change the flags.
5A50
RET Z C8
If the Z FLAG is set (the line's 00H has been copied), RETurn with the Z FLAG.
5A51
CP 22H FE 22
Compare Register A against 22H, a quote. The Z FLAG is set at the start of a quoted string.
5A53
If the NZ FLAG is set (not a quote), JUMP to 5A5FH.
Loop: copy a quoted string unchanged.
5A55
INC HL 23
INCrement Register Pair HL to the next source character inside the string. 5A5DH loops back here.
5A56
INC DE 13
INCrement Register Pair DE to the next destination byte.
5A57
LD A,(HL) 7E
Fetch the source character at Register Pair HL into Register A.
5A58
OR A B7
OR Register A with itself: the Z FLAG is set for the line's 00H (a string without a closing quote).
5A59
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A5A
RET Z C8
If the Z FLAG is set (the line's 00H), RETurn with the Z FLAG.
5A5B
CP 22H FE 22
Compare Register A against 22H, the closing quote. The Z FLAG is set at the end of the string.
5A5D
If the NZ FLAG is set (still inside the string), LOOP BACK to 5A55H.
5A5F
CP 3AH FE 3A
Compare Register A, the character, against 3AH, a colon. The Z FLAG is set for a colon. 5A53H comes here.
5A61
If the NZ FLAG is set (not a colon), JUMP to 5A66H.
5A63
PUSH HL E5
Save Register Pair HL (the source pointer at the colon) onto the stack at the Stack Pointer.
5A64
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A, to see what follows the colon.
5A65
POP HL E1
Restore Register Pair HL (the source pointer at the colon) from the stack at the Stack Pointer.
5A66
CP 93H FE 93
Compare Register A (the character, or what follows a colon) against 93H, the REM token. The Z FLAG is set for a remark. 5A61H comes here.
5A68
If the Z FLAG is set (a remark starts here), JUMP to 5A6EH.
5A6A
INC DE 13
Keep the character: INCrement Register Pair DE past it in the destination.
5A6B
INC HL 23
INCrement Register Pair HL to the next source character. 5A4BH comes here for a space when spaces are removed.
5A6C
OR D B2
OR Register D (the high byte of the destination, never 00H) into Register A: the NZ FLAG, the line goes on.
5A6D
RET C9
RETurn to 5A39H or 5A40H with the NZ FLAG set: the line goes on.
5A6E
NOP 00
Self-Modifying Code
Opcode stored by 59B1H: 13H (INC DE) moves the destination on, so the remark is copied; 00H (NOP) leaves Register Pair DE where it is, so each character of the remark is written over the previous one and only the line's 00H stays. 5A68H and 5A73H come here.
5A6F
INC HL 23
INCrement Register Pair HL to the next character of the remark.
5A70
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5A71
OR A B7
OR Register A with itself: the Z FLAG is set for the line's 00H.
5A72
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A73
If the NZ FLAG is set (not the line's end), LOOP BACK to 5A6EH.
5A75
RET C9
RETurn with the Z FLAG: the remark runs to the end of the line, which is over.
5A76H - CMD"J",date1,date2: mm/dd/yy to Day of the Year
date1 in the form mm/dd/yy is converted to the three digit day of the year ddd; a date1 that starts with - (-yy/ddd) goes to 5AE9H. The result is assigned to the string variable date2. Bad values give ILLEGAL FUNCTION CALL. The year only decides February: 00 and years not divisible by 4 give 28 days.
5A76
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL after CMD"J", else SYNTAX ERROR; Register Pair HL is moved past it.
5A77
DEFB 2CH 2C
The byte the RST 08H at 5A76H compares against: 2CH, a comma. It is never executed.
5A78
GOSUB to 6190H to evaluate date1: it returns the Z FLAG for a string, with Register B = its length and Register Pair HL = its text, and leaves the BASIC text pointer on the stack.
5A7B
If the NZ FLAG is set (date1 is not a string), JUMP to 5AE7H, ILLEGAL FUNCTION CALL.
5A7D
LD A,(HL) 7E
Fetch the first character of date1 at Register Pair HL into Register A.
5A7E
CP 2DH FE 2D
Compare Register A, the first character, against 2DH (-). The Z FLAG is set for the form -yy/ddd.
5A80
LD A,B 78
Copy Register B (the length of date1) into Register A. LD does not change the flags.
5A81
If the Z FLAG is set (date1 starts with -), JUMP to 5AE9H with Register A = the length.
5A83
CP 08H FE 08
Compare Register A, the length of date1, against 08H, the length of mm/dd/yy. The CARRY FLAG is set when it is shorter.
5A85
If the CARRY FLAG is set (date1 is too short), JUMP to 5AE7H, ILLEGAL FUNCTION CALL.
5A87
LD BC,010CH 01 0C 01
Load Register Pair BC with 010CH: Register B = 01H, the lowest month, and Register C = 0CH, the number of months allowed (1-12).
5A8A
GOSUB to 5B47H to read the two digit month at Register Pair HL into Register A, checked against the range in Register Pair BC.
5A8D
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the month.
5A8E
GOSUB to 5B3FH: a / must follow at Register Pair HL; Register Pair HL is moved past it.
5A91
LD BC,011FH 01 1F 01
Load Register Pair BC with 011FH: Register B = 01H, the lowest day, and Register C = 1FH, the number of days allowed (1-31).
5A94
GOSUB to 5B47H to read the two digit day at Register Pair HL into Register A, checked against the range.
5A97
POP BC C1
POP into Register Pair BC the word pushed from Register Pair AF: Register B = the month.
5A98
DEC A 3D
DECrement Register A, the day of the month, by 1.
5A99
LD C,A 4F
Copy Register A (the day minus 1) into Register C.
5A9A
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer: Register B = the month, Register C = the day minus 1.
5A9B
GOSUB to 5B3FH: a / must follow at Register Pair HL.
5A9E
GOSUB to 5B59H to read the two digit year (0-99) and store February's length, 28 or 29, at 5B7CH.
5AA1
LD HL,5B7AH 21 7A 5B
Point Register Pair HL to 5B7AH, the month length table (5B7AH = 0, then January to December).
5AA4
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the count of the days in the months before this one.
5AA7
POP BC C1
POP into Register Pair BC from the stack at the Stack Pointer: Register B = the month, Register C = the day minus 1.
Loop: add the lengths of the months before this one.
5AA8
LD A,(HL) 7E
Fetch the month length at Register Pair HL from the table into Register A. 5AAFH loops back here.
5AA9
ADD A,E 83
ADD Register E, the low byte of the day count, to Register A.
5AAA
LD E,A 5F
Copy Register A into Register E, the low byte of the day count in Register Pair DE.
5AAB
INC HL 23
INCrement Register Pair HL to the next month's entry.
5AAC
If the NO CARRY FLAG is set (no carry out of the low byte), JUMP to 5AAFH.
5AAE
INC D 14
INCrement Register D to carry into the high byte of the day count in Register Pair DE.
5AAF
DECrement Register B (the months left) and LOOP BACK to 5AA8H. The first pass adds the entry 0 at 5B7AH, so the months before this one are added and Register Pair HL ends at this month's own entry.
5AB1
LD A,C 79
Copy Register C (the day minus 1) into Register A.
5AB2
CP (HL) BE
Compare Register A against the month's length at Register Pair HL. The NO CARRY FLAG is set when the day is past the end of the month.
5AB3
If the NO CARRY FLAG is set (no such day in that month), JUMP to 5AE7H, ILLEGAL FUNCTION CALL.
5AB5
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the days in the months before.
5AB6
INC BC 03
INCrement Register Pair BC: Register B is 00H after the loop, so Register Pair BC = the day of the month.
5AB7
ADD HL,BC 09
ADD Register Pair BC (the day) to Register Pair HL: the day of the year.
5AB8
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the day of the year.
5AB9
GOSUB to 5D0BH to convert Register Pair DE to five decimal digits at 5D2AH-5D2EH.
5ABC
LD HL,5D2CH 21 2C 5D
Point Register Pair HL to 5D2CH, the last three of the five digits.
5ABF
LD DE,5B87H 11 87 5B
Point Register Pair DE to 5B87H, the result buffer.
5AC2
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three digits to copy.
5AC5
LDIR ED B0
Copy Register Pair BC (3) bytes from Register Pair HL (5D2CH) to Register Pair DE (5B87H), counting Register Pair BC down to 0: the result ddd.
5AC7
LD A,03H 3E 03
Load Register A with 03H, the length of the result.
5AC9
POP HL E1
POP into Register Pair HL the BASIC text pointer from the stack at the Stack Pointer (left there by 6190H). 5B3DH comes here with Register A = 08H.
5ACA
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the length of the result.
5ACB
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it.
5ACC
DEFB 2CH 2C
The byte the RST 08H at 5ACBH compares against: 2CH, a comma. It is never executed.
5ACD
GOSUB to ROM 260DH, PTRGET: Register Pair DE returns the address of the variable date2 (its descriptor) and 40AFH its value type.
5AD0
GOSUB to ROM 0AF4H, which gives TYPE MISMATCH unless the value type at 40AFH is a string (date2 must be a string variable); Register Pairs BC, DE and HL are kept.
5AD3
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the length of the result.
5AD4
PUSH HL E5
Save Register Pair HL, the text pointer, onto the stack at the Stack Pointer.
5AD5
PUSH DE D5
Save Register Pair DE, the address of date2's descriptor, onto the stack at the Stack Pointer.
5AD6
GOSUB to ROM 28BFH (GETSPA) to reserve Register A bytes of string space: Register Pair DE returns their address.
5AD9
POP HL E1
POP into Register Pair HL the address of date2's descriptor from the stack at the Stack Pointer.
5ADA
GOSUB to ROM 285DH, which stores Register A (the length) and Register Pair DE (the address) into the descriptor at Register Pair HL; Register Pair DE still points to the new space.
5ADD
LD HL,5B87H 21 87 5B
Point Register Pair HL to 5B87H, the start of the result to copy.
5AE0
LD C,A 4F
Copy Register A (the length of the result) into Register C.
5AE1
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the length of the result.
5AE3
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (5B87H) to Register Pair DE (the new string), counting Register Pair BC down to 0.
5AE5
POP HL E1
Restore Register Pair HL, the text pointer, from the stack at the Stack Pointer.
5AE6
RET C9
RETurn to the ROM's statement loop with date2 assigned and Register Pair HL = the text pointer.
5AE7
JUMP to 5B44H, ILLEGAL FUNCTION CALL: the exit of CMD"J" for a bad date1 (5A7BH, 5A85H, 5AB3H, 5AEBH, 5B0AH).
5AE9H - CMD"J": -yy/ddd to mm/dd/yy
The day of the year is turned into a month and a day by taking away month lengths; the result mm/dd/yy (8 characters) is built at 5B87H and assigned to date2 through 5AC9H.
5AE9
CP 07H FE 07
Compare Register A, the length of date1, against 07H, the length of -yy/ddd. The CARRY FLAG is set when it is shorter.
5AEB
If the CARRY FLAG is set (date1 is too short), JUMP to 5AE7H, ILLEGAL FUNCTION CALL.
5AED
INC HL 23
INCrement Register Pair HL past the - to the first digit of the year.
5AEE
LD E,(HL) 5E
Load Register E with the first year digit at Register Pair HL.
5AEF
INC HL 23
INCrement Register Pair HL to the second year digit.
5AF0
LD D,(HL) 56
Load Register D with the second year digit at Register Pair HL.
5AF1
LD (5B8DH),DE ED 53 8D 5B
Store Register Pair DE (the two year characters) at 5B8DH-5B8EH, the yy of the result.
5AF5
DEC HL 2B
DECrement Register Pair HL back to the first year digit.
5AF6
GOSUB to 5B59H to read the two digit year at Register Pair HL and store February's length at 5B7CH.
5AF9
GOSUB to 5B3FH: a / must follow at Register Pair HL.
5AFC
LD B,03H 06 03
Load Register B with 03H: ddd must be exactly three digits.
5AFE
GOSUB to 5B6EH to read exactly Register B (3) digits at Register Pair HL into Register Pair DE.
5B01
LD HL,5B7BH 21 7B 5B
Point Register Pair HL to 5B7BH, January's entry in the month length table.
5B04
LD B,00H 06 00
Load Register B with 00H, so that Register Pair BC = a month's length once Register C holds it.
5B06
DEC DE 1B
DECrement Register Pair DE, the day of the year, to the day minus 1.
Loop: take away month lengths until the day falls inside a month.
5B07
LD A,L 7D
Copy Register L, the low byte of the table pointer, into Register A. 5B13H loops back here.
5B08
CP 87H FE 87
Compare Register A against 87H, the low byte of 5B87H, the address after December's entry at 5B86H. The Z FLAG is set when every month has been taken away.
5B0A
If the Z FLAG is set (the day is past the end of the year), JUMP to 5AE7H, ILLEGAL FUNCTION CALL.
5B0C
LD C,(HL) 4E
Load Register C with the month's length at Register Pair HL.
5B0D
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the days left.
5B0E
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
5B0F
SBC HL,BC ED 42
SUBtract Register Pair BC (the month's length) from Register Pair HL (the days left). The CARRY FLAG is set when the day lies in this month.
5B11
EX DE,HL EB
Exchange Register Pairs DE and HL back: Register Pair HL = the table pointer, Register Pair DE = the days left.
5B12
INC HL 23
INCrement Register Pair HL to the next month's entry. INC HL does not change the flags.
5B13
If the NO CARRY FLAG is set (the day is beyond this month), LOOP BACK to 5B07H.
5B15
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the days left (below 0), Register Pair DE = the table pointer, one past the month's entry.
5B16
ADD HL,BC 09
ADD Register Pair BC (the month's length) back to Register Pair HL: the day of the month minus 1.
5B17
PUSH HL E5
Save Register Pair HL (the day of the month minus 1) onto the stack at the Stack Pointer.
5B18
LD A,E 7B
Copy Register E, the low byte of the table pointer (7BH plus the month number), into Register A.
5B19
SUB 7BH D6 7B
SUBtract 7BH from Register A: the month number 1-12.
5B1B
LD E,A 5F
Copy Register A (the month number, 1-12) into Register E for the conversion.
5B1C
LD D,H 54
Copy Register H (00H, the high byte of the day value) into Register D: Register Pair DE = the month.
5B1D
GOSUB to 5D0BH to convert Register Pair DE (the month) to five decimal digits at 5D2AH-5D2EH.
5B20
LD HL,(5D2DH) 2A 2D 5D
Load Register Pair HL with the last two digits from 5D2DH-5D2EH.
5B23
LD (5B87H),HL 22 87 5B
Store Register Pair HL (the two month digits) at 5B87H-5B88H: mm.
5B26
POP DE D1
POP into Register Pair DE the day of the month minus 1 from the stack at the Stack Pointer.
5B27
INC DE 13
INCrement Register Pair DE to the day of the month.
5B28
GOSUB to 5D0BH to convert Register Pair DE (the day) to five decimal digits at 5D2AH-5D2EH.
5B2B
LD HL,5B89H 21 89 5B
Point Register Pair HL to 5B89H, after mm in the result.
5B2E
LD A,2FH 3E 2F
Load Register A with 2FH (/), the separator of mm/dd/yy.
5B30
LD (HL),A 77
Store Register A (/) at Register Pair HL (5B89H).
5B31
INC HL 23
INCrement Register Pair HL to 5B8AH, the first digit of the day.
5B32
LD DE,(5D2DH) ED 5B 2D 5D
Load Register Pair DE with the day's last two digits from 5D2DH-5D2EH.
5B36
LD (HL),E 73
Store Register E (the first digit of the day) at Register Pair HL (5B8AH).
5B37
INC HL 23
INCrement Register Pair HL from 5B8AH to 5B8BH, the second digit of the day.
5B38
LD (HL),D 72
Store Register D (the second digit of the day) at Register Pair HL (5B8BH): dd.
5B39
INC HL 23
INCrement Register Pair HL from 5B8BH to 5B8CH, the place of the second /.
5B3A
LD (HL),A 77
Store Register A (/) at Register Pair HL (5B8CH); yy follows at 5B8DH-5B8EH.
5B3B
LD A,08H 3E 08
Load Register A with 08H, the length of mm/dd/yy.
5B3D
JUMP to 5AC9H to assign the result to date2 with Register A = 08H.
5B3FH - CMD"J" Helpers
5B3FH requires a /; 5B47H reads a two digit number in the range Register B to Register B + Register C - 1; 5B59H reads the year and puts 28 or 29 into February's entry; 5B6EH reads exactly Register B digits. Every error goes to ILLEGAL FUNCTION CALL.
5B3F
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5B40
CP 2FH FE 2F
Compare Register A against 2FH (/). The Z FLAG is set for a /.
5B42
INC HL 23
INCrement Register Pair HL past the character tested. INC HL does not change the flags.
5B43
RET Z C8
If the Z FLAG is set (it was a /), RETurn with Register Pair HL past it.
5B44
JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL. 5AE7H, 5B4FH, 5B55H, 5B74H and 5B77H come here.
5B47
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer: the range, Register B = the lowest value and Register C = the number of values allowed.
5B48
LD B,02H 06 02
Load Register B with 02H, the number of digits to read.
5B4A
GOSUB to 5B6EH to read exactly Register B (2) digits at Register Pair HL into Register Pair DE.
5B4D
LD A,D 7A
Copy Register D, the high byte of the value, into Register A.
5B4E
OR A B7
OR Register A with itself: the NZ FLAG is set for a value above 255.
5B4F
If the NZ FLAG is set, JUMP to 5B44H, ILLEGAL FUNCTION CALL.
5B51
POP BC C1
POP into Register Pair BC the range from the stack at the Stack Pointer.
5B52
LD A,E 7B
Copy Register E, the value read (0-255), into Register A for the range check.
5B53
SUB B 90
SUBtract Register B, the lowest value, from Register A.
5B54
CP C B9
Compare Register A against Register C, the number of values allowed. The NO CARRY FLAG is set when the value is out of range.
5B55
If the NO CARRY FLAG is set (out of range), JUMP to 5B44H, ILLEGAL FUNCTION CALL.
5B57
LD A,E 7B
Copy Register E, the value read, into Register A for the caller.
5B58
RET C9
RETurn with Register A = the value, which lies in the range.
5B59
LD BC,0064H 01 64 00
Load Register Pair BC with 0064H: Register B = 00H, the lowest year, and Register C = 64H (100), so the year must be 0-99.
5B5C
GOSUB to 5B47H to read the two digit year at Register Pair HL into Register A.
5B5F
LD B,1CH 06 1C
Load Register B with 1CH (28), February's length in most years.
5B61
OR A B7
OR Register A (the year) with itself: the Z FLAG is set for year 00.
5B62
If the Z FLAG is set (year 00), JUMP to 5B69H with 28 days.
5B64
AND 03H E6 03
AND Register A (the year) with 03H, keeping the two low bits. The Z FLAG is set when the year is divisible by 4.
5B66
If the NZ FLAG is set (the year is not divisible by 4), JUMP to 5B69H with 28 days.
5B68
INC B 04
INCrement Register B from 28 to 29: a leap year.
5B69
LD A,B 78
Copy Register B (February's length, 28 or 29) into Register A. 5B62H and 5B66H come here.
5B6A
LD (5B7CH),A 32 7C 5B
Store Register A at 5B7CH, February's entry in the month length table.
5B6D
RET C9
RETurn with February's length set for the year read.
5B6E
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer: Register B = the number of digits wanted.
5B6F
GOSUB to 5CD7H to read decimal digits at Register Pair HL into Register Pair DE: Register C returns the number of digits read and the CARRY FLAG is set on an overflow.
5B72
LD A,C 79
Copy Register C (the number of digits read) into Register A. LD does not change the flags.
5B73
POP BC C1
POP into Register Pair BC from the stack at the Stack Pointer: Register B = the number of digits wanted.
5B74
If the CARRY FLAG is set (the number overflowed), JUMP to 5B44H, ILLEGAL FUNCTION CALL.
5B76
CP B B8
Compare Register A (the number of digits read) against Register B (the number wanted). The Z FLAG is set when they are equal.
5B77
If the NZ FLAG is set (too few or too many digits), JUMP to 5B44H, ILLEGAL FUNCTION CALL.
5B79
RET C9
RETurn with Register Pair DE = the value read and Register Pair HL past it.
5B7AH - CMD"J" Month Lengths
5B7AH is 0, so that the sum at 5AA8H starts with nothing; 5B7BH-5B86H are January to December. February (5B7CH) is set to 28 or 29 by 5B6AH.
5B7A
DEFB 00H 00
00H, the entry before January: 5AA1H starts the sum here, so January adds nothing for the months before it.
5B7B
DEFB 1FH 1F
January: 1FH, 31 days. 5B01H starts the subtraction here.
5B7C
DEFB 1CH 1C
February: 1CH (28 days) in the file; 5B6AH stores 28 or 29 for the year of the date.
5B7D
DEFB 1FH 1F
March: 1FH, 31 days, in the month length table at 5B7AH.
5B7E
DEFB 1EH 1E
April: 1EH, 30 days, in the month length table at 5B7AH.
5B7F
DEFB 1FH 1F
May: 1FH, 31 days, in the month length table at 5B7AH.
5B80
DEFB 1EH 1E
June: 1EH, 30 days, in the month length table at 5B7AH.
5B81
DEFB 1FH 1F
July: 1FH, 31 days, in the month length table at 5B7AH.
5B82
DEFB 1FH 1F
August: 1FH, 31 days, in the month length table at 5B7AH.
5B83
DEFB 1EH 1E
September: 1EH, 30 days, in the month length table at 5B7AH.
5B84
DEFB 1FH 1F
October: 1FH, 31 days, in the month length table at 5B7AH.
5B85
DEFB 1EH 1E
November: 1EH, 30 days, in the month length table at 5B7AH.
5B86
DEFB 1FH 1F
December: 1FH, 31 days, the last entry; 5B08H stops at 5B87H after it.
5B87H - CMD"J" Result Buffer
The result is built here: ddd in 5B87H-5B89H, or mm/dd/ in 5B87H-5B8CH followed by yy in 5B8DH-5B8EH.
5B87-5B8C
DEFB 00H, 00H, 00H, 00H, 00H, 00H 00 00 00 00 00 00
The result buffer, 00H in the file: ddd at 5B87H-5B89H (5AC5H), or mm at 5B87H-5B88H (5B23H) and /dd/ at 5B89H-5B8CH (5B30H-5B3AH); 5ADDH copies it into date2.
5B8D-5B8E
DEFB 00H, 00H 00 00
The yy of an mm/dd/yy result, copied from date1 by 5AF1H (00H in the file).
5B8FH - CMD"F=SS" Single Stepping
CMD"F=SS" turns single stepping on, CMD"F=SS",line from that line, CMD"F=SS",N off. The line number goes into the operand at 63C4H; the opcode at 63B4H becomes 20H (JR NZ, stepping on) or 18H (JR, off).
5B8F
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the start line when none is given.
5B92
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H reads the current character again.
5B93
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A; the Z FLAG is set at the end of the statement.
5B94
If the Z FLAG is set (CMD"F=SS" alone), JUMP to 5BA4H to turn stepping on with Register Pair DE = 0000H.
5B96
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it and Register A holds the next character.
5B97
DEFB 2CH 2C
The byte the RST 08H at 5B96H compares against: 2CH, a comma. It is never executed.
5B98
CP 4EH FE 4E
Compare Register A, the character after the comma, against 4EH (N). The Z FLAG is set for N.
5B9A
If the Z FLAG is set (CMD"F=SS",N), JUMP to 5BADH to turn stepping off.
5B9C
GOSUB to 5CD5H to read the decimal line number at Register Pair HL into Register Pair DE; Register C returns the number of digits read.
5B9F
LD A,C 79
Copy Register C, the number of digits read, into Register A.
5BA0
OR A B7
OR Register A with itself: the Z FLAG is set when no digit was read.
5BA1
If the Z FLAG is set (neither N nor a number), JUMP to ROM 1997H, SYNTAX ERROR.
5BA4
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H at 5BB2H reads the current character again. 5B94H comes here.
5BA5
LD (63C4H),DE ED 53 C4 63
Store Register Pair DE, the start line number, at 63C4H-63C5H, the operand that the single step test at 63C3H compares the line number with.
5BA9
LD A,20H 3E 20
Load Register A with 20H, the opcode JR NZ, which turns stepping on at 63B4H.
5BAB
JUMP to 5BAFH to store the opcode in Register A.
5BAD
LD A,18H 3E 18
Load Register A with 18H, the opcode JR, which turns stepping off at 63B4H.
5BAF
LD (63B4H),A 32 B4 63
Store Register A, the opcode 20H or 18H, at 63B4H. 5BABH comes here.
5BB2
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A, for the caller.
5BB3
RET C9
RETurn to the caller in SYS20/SYS with single stepping set and Register Pair HL = the text pointer.
5BB4H - Variable Name Reader (for SYS21/SYS)
Used by SYS21/SYS's ERASE, KEEP and CMD"O". Reads a variable name: the first letter goes into Register B, the second character (a letter or a digit, 00H when there is none) into Register C, and the value type (from the suffix %, $, ! or #, else the DEF type of the first letter from the ROM's table at 4101H) into Register D. They are stored as the compare operands at 5BFEH, 5C03H and 5C09H.
5BB4
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H reads the current character again.
5BB5
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A, the first character of the name.
5BB6
LD B,A 47
Copy Register A (the first character of the name) into Register B.
5BB7
GOSUB to ROM 1E3DH, which tests the character at Register Pair HL: the CARRY FLAG is set when it is not a letter.
5BBA
If the CARRY FLAG is set (a name must start with a letter), JUMP to ROM 1997H, SYNTAX ERROR.
5BBD
XOR A AF
Set Register A to 00H for the second character.
5BBE
LD C,A 4F
Copy Register A (00H) into Register C: no second character yet.
Loop: pass over the rest of the name, keeping its second character.
5BBF
INC C 0C
INCrement Register C, the second character, to test it for 00H. 5BC5H and 5BCAH loop back here.
5BC0
DEC C 0D
DECrement Register C back to its value: the Z FLAG is set when it is 00H (no second character kept yet).
5BC1
If the NZ FLAG is set (the second character is already kept), JUMP to 5BC4H.
5BC3
LD C,A 4F
Copy Register A into Register C: the character just read becomes the second character (on the first pass Register A is 00H, which keeps Register C at 00H).
5BC4
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character into Register A; the CARRY FLAG is set for a digit. 5BC1H comes here.
5BC5
If the CARRY FLAG is set (a digit, part of the name), LOOP BACK to 5BBFH.
5BC7
GOSUB to ROM 1E3DH: the CARRY FLAG is set when the character at Register Pair HL is not a letter.
5BCA
If the NO CARRY FLAG is set (a letter, part of the name), LOOP BACK to 5BBFH.
5BCC
LD D,02H 16 02
Load Register D with 02H, the integer value type, for a % suffix.
5BCE
SUB 25H D6 25
SUBtract 25H (%) from Register A, the character after the name. The Z FLAG is set for %.
5BD0
If the Z FLAG is set (a % suffix), JUMP to 5BEAH with Register D = 02H.
5BD2
INC D 14
INCrement Register D to 03H, the string value type.
5BD3
INC A 3C
INCrement Register A (the character minus 25H): 00H with the Z FLAG for $ (24H).
5BD4
If the Z FLAG is set (a $ suffix), JUMP to 5BEAH with Register D = 03H.
5BD6
INC D 14
INCrement Register D to 04H, the single precision value type.
5BD7
CP FDH FE FD
Compare Register A (the character minus 24H) against FDH, the value ! (21H) gives. The Z FLAG is set for !.
5BD9
If the Z FLAG is set (a ! suffix), JUMP to 5BEAH with Register D = 04H.
5BDB
LD D,08H 16 08
Load Register D with 08H, the double precision value type.
5BDD
INC A 3C
INCrement Register A (the character minus 24H): 00H with the Z FLAG for # (23H).
5BDE
If the Z FLAG is set (a # suffix), JUMP to 5BEAH with Register D = 08H.
5BE0
LD A,B 78
No suffix: copy Register B (the first letter) into Register A.
5BE1
SUB 41H D6 41
SUBtract 41H (A) from Register A: the letter's place 0-25 in the alphabet.
5BE3
LD E,A 5F
Copy Register A (the letter's place) into Register E.
5BE4
INC E 1C
INCrement Register E: the low byte of the letter's entry in the ROM's DEF type table, which starts at 4101H for A.
5BE5
LD D,41H 16 41
Load Register D with 41H: Register Pair DE = 4101H plus the letter's place, the letter's entry in the ROM's DEF type table (4101H-411AH).
5BE7
LD A,(DE) 1A
Fetch the default value type for that first letter at Register Pair DE into Register A (set by DEFINT, DEFSNG, DEFDBL and DEFSTR).
5BE8
LD D,A 57
Copy Register A (the default value type) into Register D.
5BE9
DEC HL 2B
DECrement Register Pair HL back by one character: the character after the name was not a suffix and is read again at 5BF6H.
5BEA
LD A,D 7A
Copy Register D, the variable's value type, into Register A. 5BD0H, 5BD4H, 5BD9H and 5BDEH come here.
5BEB
LD (5BFEH),A 32 FE 5B
Store Register A (the value type) at 5BFEH, the operand of the CP at 5BFDH.
5BEE
LD A,C 79
Copy Register C, the second character, into Register A.
5BEF
LD (5C03H),A 32 03 5C
Store Register A (the second character) at 5C03H, the operand of the CP at 5C02H.
5BF2
LD A,B 78
Copy Register B, the first letter, into Register A.
5BF3
LD (5C09H),A 32 09 5C
Store Register A (the first letter) at 5C09H, the operand of the CP at 5C08H.
5BF6
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A.
5BF7
CP 28H FE 28
Compare Register A against 28H, the ( of an array element. The Z FLAG is set for an array.
5BF9
RET C9
RETurn to SYS21/SYS with the Z FLAG set for an array name and the name stored in the operands at 5BFEH, 5C03H and 5C09H.
5BFAH - Variable Table Helpers (for SYS21/SYS)
5BFAH compares the variable entry at Register Pair HL with the name stored by 5BEBH-5BF3H (the Z FLAG on a match, Register Pair HL back at the entry). 5C0DH steps to the next simple variable, 5C18H to the next array. 5C21H passes over a subscript in parentheses (the CARRY FLAG if the statement ends first).
5BFA
LD A,(HL) 7E
Fetch the entry's first byte, its value type, at Register Pair HL into Register A.
5BFB
AND 0FH E6 0F
AND Register A with 0FH, keeping the value type in bits 3-0 (SYS21/SYS uses the bits above it as marks).
5BFD
CP 00H FE 00
Self-Modifying Code
Compare Register A (the entry's value type) against the operand at 5BFEH, the wanted value type stored by 5BEBH (00H in the file). The Z FLAG is set when they agree.
5BFF
RET NZ C0
If the NZ FLAG is set (another value type), RETurn with the NZ FLAG and Register Pair HL at the entry.
5C00
INC HL 23
INCrement Register Pair HL to the entry's second name byte.
5C01
LD A,(HL) 7E
Fetch the entry's second name byte at Register Pair HL into Register A.
5C02
CP 00H FE 00
Self-Modifying Code
Compare Register A against the operand at 5C03H, the wanted second character stored by 5BEFH (00H in the file). The Z FLAG is set when they agree.
5C04
If the NZ FLAG is set (another second character), JUMP to 5C0BH with the NZ FLAG.
5C06
INC HL 23
INCrement Register Pair HL to the entry's third byte, its first letter.
5C07
LD A,(HL) 7E
Fetch the entry's first letter at Register Pair HL into Register A.
5C08
CP 00H FE 00
Self-Modifying Code
Compare Register A against the operand at 5C09H, the wanted first letter stored by 5BF3H (00H in the file). The Z FLAG is set on a match.
5C0A
DEC HL 2B
DECrement Register Pair HL back to the entry's second name byte. DEC HL does not change the flags.
5C0B
DEC HL 2B
DECrement Register Pair HL back to the entry's value type byte. 5C04H comes here.
5C0C
RET C9
RETurn with Register Pair HL at the entry's first byte and the Z FLAG set when the entry has the name wanted.
5C0D
LD A,(HL) 7E
Next simple variable: fetch the entry's value type byte at Register Pair HL into Register A.
5C0E
AND 0FH E6 0F
AND Register A with 0FH, keeping the value type, which is also the size of the value in bytes.
5C10
ADD A,03H C6 03
ADD 03H to Register A for the value type byte and the two name bytes: the size of the entry.
5C12
LD C,A 4F
Copy Register A (the entry's size) into Register C.
5C13
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the entry's size.
5C15
ADD HL,BC 09
ADD Register Pair BC (the size) to Register Pair HL: Register Pair HL = the next entry. 5C1FH comes here.
5C16
OR H B4
OR Register H (never 00H) into Register A: the NZ FLAG.
5C17
RET C9
RETurn with Register Pair HL at the next entry and the NZ FLAG.
5C18
INC HL 23
Next array: INCrement Register Pair HL past the entry's value type byte.
5C19
INC HL 23
INCrement Register Pair HL past the second name byte.
5C1A
INC HL 23
INCrement Register Pair HL past the first letter, to the array's length word.
5C1B
LD C,(HL) 4E
Load Register C with the low byte of the array's length at Register Pair HL.
5C1C
INC HL 23
INCrement Register Pair HL to the high byte of the length.
5C1D
LD B,(HL) 46
Load Register B with the high byte of the length from Register Pair HL: Register Pair BC = the bytes after the length word.
5C1E
INC HL 23
INCrement Register Pair HL past the length word.
5C1F
JUMP to 5C15H to ADD Register Pair BC to Register Pair HL: the next array.
5C21
LD B,00H 06 00
Pass over a subscript: load Register B with 00H, the parenthesis depth (5C23H makes it 1 for the ( already read).
5C23
INC B 04
INCrement Register B, the parenthesis depth: one level deeper. 5C29H comes here.
5C24
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A; the Z FLAG is set at the end of the statement. 5C2DH and 5C2FH come here.
5C25
SCF 37
Set the CARRY FLAG, the mark of a statement that ends inside the parentheses. SCF does not change the Z FLAG.
5C26
RET Z C8
If the Z FLAG is set (the statement ended), RETurn with the CARRY FLAG set.
5C27
CP 28H FE 28
Compare Register A against 28H, an opening parenthesis. The Z FLAG is set for (.
5C29
If the Z FLAG is set (a nested parenthesis), JUMP to 5C23H to go one level deeper.
5C2B
CP 29H FE 29
Compare Register A against 29H, a closing parenthesis. The Z FLAG is set for ).
5C2D
If the NZ FLAG is set (any other character), JUMP to 5C24H for the next character.
5C2F
DECrement Register B, the depth, and LOOP BACK to 5C24H until the outermost ) is reached.
5C31
RST 10H D7
RST 10H: INCrement Register Pair HL and load the character after the subscript into Register A; the Z FLAG is set at the end of the statement.
5C32
OR A B7
OR Register A with itself, which clears the CARRY FLAG (the Z FLAG is set when Register A is 00H).
5C33
RET C9
RETurn with the CARRY FLAG clear and Register A = the character after the subscript.
5C34H - CMD"F=SASZ",size
Changes the size of the string area without clearing the variables. The strings are collected at the top of memory; the new bottom (the top of memory minus size) must be below the lowest string (else OUT OF STRING SPACE) and the stack, which lies just below the string area, must stay at least 256 bytes above the arrays (else OUT OF MEMORY). The stack is moved with the bottom of the string area.
5C34
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL after SASZ, else SYNTAX ERROR; Register Pair HL is moved past it.
5C35
DEFB 2CH 2C
The byte the RST 08H at 5C34H compares against: 2CH, a comma. It is never executed.
5C36
GOSUB to ROM 2B02H to evaluate the size at Register Pair HL as an integer into Register Pair DE.
5C39
PUSH HL E5
Save Register Pair HL, the text pointer, onto the stack at the Stack Pointer.
5C3A
LD HL,(40B1H) 2A B1 40
Load Register Pair HL with the word at 40B1H, the ROM's top of memory (MEMSIZ).
5C3D
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
5C3E
SBC HL,DE ED 52
SUBtract Register Pair DE (the size) from Register Pair HL (the top of memory): Register Pair HL = the new bottom of the string area.
5C40
LD (5C77H),HL 22 77 5C
Store Register Pair HL (the new bottom) at 5C77H-5C78H, the operand of the LD DE at 5C76H.
5C43
PUSH HL E5
Save Register Pair HL (the new bottom) onto the stack at the Stack Pointer.
5C44
GOSUB to ROM 28E6H (GARBA2), the string garbage collection: every string in use is moved to the top of the string area and 40D6H gets the lowest one.
5C47
POP DE D1
POP into Register Pair DE the new bottom from the stack at the Stack Pointer.
5C48
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with the word at 40D6H, the lowest string in use after the collection.
5C4B
RST 18H DF
RST 18H compares Register Pair HL (the lowest string) with Register Pair DE (the new bottom): the CARRY FLAG is set when the strings reach below the new bottom.
5C4C
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the new bottom. EX does not change the flags.
5C4D
LD E,1AH 1E 1A
Load Register E with 1AH, the ROM's error number for OUT OF STRING SPACE.
5C4F
If the CARRY FLAG is set (the strings do not fit), JUMP to ROM 19A2H, the error handler, with Register E = 1AH.
5C52
LD DE,(40A0H) ED 5B A0 40
Load Register Pair DE with the word at 40A0H, the old bottom of the string area (the ROM's STKTOP).
5C56
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
5C57
SBC HL,DE ED 52
SUBtract Register Pair DE (the old bottom) from Register Pair HL (the new bottom): the distance the bottom moves.
5C59
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: Register Pair HL = where the Stack Pointer goes after the move.
5C5A
LD (5C8DH),HL 22 8D 5C
Store Register Pair HL (the new Stack Pointer) at 5C8DH-5C8EH, the operand of the LD SP at 5C8CH.
5C5D
DEC H 25
DECrement Register H: Register Pair HL = the new Stack Pointer minus 256, the room the stack needs.
5C5E
LD DE,(40FDH) ED 5B FD 40
Load Register Pair DE with the word at 40FDH, the ROM's pointer to the end of the arrays (the start of free memory).
5C62
RST 18H DF
RST 18H compares Register Pair HL (the new stack less 256) with Register Pair DE (the end of the arrays): the CARRY FLAG is set when the stack would come too close.
5C63
If the CARRY FLAG is set, JUMP to ROM 197AH, OUT OF MEMORY.
5C66
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, to read the Stack Pointer.
5C69
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: Register Pair HL = the current Stack Pointer.
5C6A
PUSH HL E5
Save Register Pair HL (the current Stack Pointer) onto the stack at the Stack Pointer.
5C6B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the Stack Pointer as it was before that push.
5C6C
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the word at 40A0H, the old bottom of the string area, which is the top end of the stack.
5C6F
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
5C70
SBC HL,DE ED 52
SUBtract Register Pair DE (the Stack Pointer) from Register Pair HL (the top end of the stack): the stack's size less 1.
5C72
LD B,H 44
Copy Register H (the high byte of the stack's size less 1) into Register B.
5C73
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the stack's size less 1.
5C74
INC BC 03
INCrement Register Pair BC: the number of bytes to move.
5C75
ADD HL,DE 19
ADD Register Pair DE (the Stack Pointer) back to Register Pair HL: Register Pair HL = the old bottom, the last byte to move when moving up.
5C76
LD DE,0000H 11 00 00
Self-Modifying Code
Load Register Pair DE with the new bottom of the string area, the operand at 5C77H-5C78H stored by 5C40H (0000H in the file).
5C79
LD (40A0H),DE ED 53 A0 40
Store Register Pair DE (the new bottom) at 40A0H: the string area now starts there.
5C7D
RST 18H DF
RST 18H compares Register Pair HL (the old bottom) with Register Pair DE (the new bottom): the CARRY FLAG is set when the bottom moves up (a smaller string area).
5C7E
DI F3
Disable interrupts while the stack is moved, so that no interrupt pushes onto it.
5C7F
If the NO CARRY FLAG is set (the bottom moves down), JUMP to 5C85H.
5C81
LDDR ED B8
The bottom moves up: copy Register Pair BC bytes from Register Pair HL (the old top end of the stack) to Register Pair DE (the new one), downward, counting Register Pair BC down to 0. The word pushed at 5C6AH lies below the part moved and is left behind.
5C83
JUMP to 5C8CH to load the new Stack Pointer from the operand at 5C8DH.
5C85
POP HL E1
The bottom moves down: POP into Register Pair HL the Stack Pointer saved at 5C6AH, the lowest byte of the stack.
5C86
LD DE,(5C8DH) ED 5B 8D 5C
Load Register Pair DE with the new Stack Pointer from 5C8DH-5C8EH.
5C8A
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (the old stack) to Register Pair DE (the new stack), upward, counting Register Pair BC down to 0.
5C8C
LD SP,0000H 31 00 00
Self-Modifying Code
Load the Stack Pointer with the new value, the operand at 5C8DH-5C8EH stored by 5C5AH (0000H in the file). 5C83H comes here.
5C8F
EI FB
Enable interrupts again: the stack is in its new place.
5C90
POP HL E1
POP into Register Pair HL the text pointer (saved at 5C39H) from the moved stack at the Stack Pointer.
5C91
RET C9
RETurn through the moved stack to the caller in SYS20/SYS with the string area resized.
5C92H - String Helpers
5C92H evaluates a string after a comma and leaves the text pointer on the stack (no caller in this file). 5C99H and 5CA4H take a string result: Register A = its length, Register Pair DE = its text, Register Pair HL = its descriptor. 5CACH gives the descriptor at Register Pair HL new string space of Register A bytes. 5CB6H copies Register B bytes from Register Pair DE to Register Pair HL; 5CBCH stores Register C spaces at Register Pair HL; 5CC4H copies a variable's text into string space; 5CCCH steps over a program line.
5C92
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it.
5C93
DEFB 2CH 2C
The byte the RST 08H at 5C92H compares against: 2CH, a comma. It is never executed.
5C94
GOSUB to ROM 2337H to evaluate the expression at Register Pair HL into the ROM's accumulator; Register Pair HL returns past it.
5C97
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the return address on the stack at the Stack Pointer: Register Pair HL = the return address.
5C98
PUSH HL E5
Push Register Pair HL (the return address) back onto the stack at the Stack Pointer, so that the text pointer stays on the stack below it, and fall into 5C99H.
5C99
GOSUB to ROM 29D7H (FRESTR): the value must be a string (else TYPE MISMATCH); its temporary descriptor is freed and Register Pair HL returns the descriptor's address. 58D1H, 5908H and 6094H call here.
5C9C
LD A,(HL) 7E
Fetch the string's length, the first byte of the descriptor at Register Pair HL, into Register A. 5CAAH comes here.
5C9D
INC HL 23
INCrement Register Pair HL to the low byte of the text address in the descriptor.
5C9E
LD E,(HL) 5E
Load Register E with the low byte of the text address from Register Pair HL.
5C9F
INC HL 23
INCrement Register Pair HL to the high byte of the text address.
5CA0
LD D,(HL) 56
Load Register D with the high byte from Register Pair HL: Register Pair DE = the string's text.
5CA1
DEC HL 2B
DECrement Register Pair HL back to the low byte of the text address.
5CA2
DEC HL 2B
DECrement Register Pair HL back to the descriptor's first byte.
5CA3
RET C9
RETurn with Register A = the length, Register Pair DE = the text and Register Pair HL = the descriptor.
5CA4
GOSUB to ROM 0AF4H: the value type at 40AFH must be a string, else TYPE MISMATCH; Register Pairs BC, DE and HL are kept. 57F4H calls here with Register Pair DE = a descriptor.
5CA7
GOSUB to ROM 29DEH, which frees the temporary descriptor at Register Pair DE if it is the latest one and returns Register Pair HL = the descriptor.
5CAA
JUMP to 5C9CH to read the length and the text address from the descriptor at Register Pair HL.
5CAC
LD (HL),00H 36 00
Store 00H at Register Pair HL, the length byte of the descriptor, until the new space is reserved (called by SYS10/SYS at its 5045H and 50B5H).
5CAE
PUSH HL E5
Save Register Pair HL (the descriptor) onto the stack at the Stack Pointer.
5CAF
GOSUB to ROM 28BFH (GETSPA) to reserve Register A bytes of string space: Register Pair DE returns their address.
5CB2
POP HL E1
Restore Register Pair HL (the descriptor) from the stack at the Stack Pointer.
5CB3
JUMP to ROM 285DH, which stores Register A (the length) and Register Pair DE (the address) into the descriptor at Register Pair HL and returns.
5CB6
LD A,B 78
Copy Register B, the number of bytes to copy, into Register A. 5923H calls here.
5CB7
OR A B7
OR Register A with itself: the Z FLAG is set when there is nothing to copy. 60A0H calls here with the count in Register A.
5CB8
If the NZ FLAG is set, JUMP to ROM 09D6H (LD B,A, then the copy loop at 09D7H), which copies Register A bytes from Register Pair DE to Register Pair HL and returns with both past the bytes.
5CBB
RET C9
RETurn: the count in Register A was 0, so nothing is copied.
5CBC
INC C 0C
INCrement Register C, the number of spaces, to test it. 5920H and 5926H call here.
5CBD
DEC C 0D
DECrement Register C: the Z FLAG is set when no spaces are left. 5CC2H loops back here.
5CBE
RET Z C8
If the Z FLAG is set (no spaces left), RETurn with Register C = 00H.
5CBF
LD (HL),20H 36 20
Store a space (20H) at Register Pair HL, in the variable's text.
5CC1
INC HL 23
INCrement Register Pair HL to the next byte of the variable's text.
5CC2
LOOP BACK to 5CBDH to count down Register C, the spaces left.
5CC4
PUSH HL E5
Save Register Pair HL (the variable's descriptor) onto the stack at the Stack Pointer. 58FAH calls here for a variable whose text is a literal in the program.
5CC5
GOSUB to ROM 2843H, which copies the string of the descriptor at Register Pair HL into new string space and builds a descriptor for the copy at 40D3H; Register Pair DE returns 40D3H.
5CC8
POP HL E1
Restore Register Pair HL (the variable's descriptor) from the stack at the Stack Pointer.
5CC9
JUMP to ROM 09D3H, which copies as many bytes as the value type at 40AFH (3, a string) from Register Pair DE (40D3H) to Register Pair HL: the variable now describes the copy.
5CCC
INC HL 23
Step over a program line (called by SYS11/SYS at its 4D16H and SYS13/SYS at its 51A9H): INCrement Register Pair HL (1 of 3) past the line's link and number.
5CCD
INC HL 23
INCrement Register Pair HL (2 of 3) past the line's link and number.
5CCE
INC HL 23
INCrement Register Pair HL (3 of 3) to the first byte of the line's text.
5CCF
LD A,(HL) 7E
Fetch the byte at Register Pair HL into Register A. 5CD2H loops back here.
5CD0
OR A B7
OR Register A with itself: the Z FLAG is set at the line's 00H.
5CD1
INC HL 23
INCrement Register Pair HL to the next byte. INC HL does not change the flags.
5CD2
If the NZ FLAG is set (not the end of the line), LOOP BACK to 5CCFH.
5CD4
RET C9
RETurn with Register Pair HL past the line's 00H, at the next line's link.
5CD5H - Read a Decimal Number
Reads decimal digits at Register Pair HL into Register Pair DE; Register C returns the number of digits read. 5CD5H allows any number of digits, 5CD7H at most Register B. Returns the NO CARRY FLAG at the first character that is not a digit (or the Z FLAG when the limit is reached), and the CARRY FLAG when the value passes 65535.
5CD5
LD B,FFH 06 FF
Load Register B with FFH: in effect no limit on the number of digits. 5B9CH and 6718H call here.
5CD7
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value being built. 5B6FH calls here with Register B = the most digits allowed.
5CDA
LD C,E 4B
Copy Register E (00H) into Register C, the count of the digits read.
5CDB
LD A,B 78
Copy Register B, the digits still allowed, into Register A. 5CFCH loops back here.
5CDC
OR A B7
OR Register A with itself: the Z FLAG is set when the limit is reached.
5CDD
RET Z C8
If the Z FLAG is set, RETurn with Register Pair DE = the value and Register C = the digits read.
5CDE
DEC B 05
DECrement Register B: one digit fewer allowed.
5CDF
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5CE0
SUB 30H D6 30
SUBtract 30H (0) from Register A, the character.
5CE2
CP 0AH FE 0A
Compare Register A against 0AH. The CARRY FLAG is set for a digit 0-9.
5CE4
RET NC D0
If the NO CARRY FLAG is set (not a digit), RETurn with the NO CARRY FLAG and Register Pair HL at that character.
5CE5
INC HL 23
INCrement Register Pair HL to the next character of the number.
5CE6
INC BC 03
INCrement Register Pair BC, which counts the digit in Register C.
5CE7
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack at the Stack Pointer.
5CE8
PUSH BC C5
Save Register Pair BC (Register B = the digits allowed, Register C = the count) onto the stack at the Stack Pointer.
5CE9
LD C,A 4F
Copy Register A (the digit's value) into Register C.
5CEA
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the digit's value.
5CEC
LD H,D 62
Copy Register D, the high byte of the value, into Register H.
5CED
LD L,E 6B
Copy Register E, the low byte of the value, into Register L: Register Pair HL = the value so far.
5CEE
XOR A AF
Set Register A to 00H; it collects every carry out of the multiplication.
5CEF
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
5CF0
ADC A,A 8F
ADD Register A to itself with the CARRY FLAG, keeping any carry out of Register Pair HL.
5CF1
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
5CF2
ADC A,A 8F
ADD Register A to itself with the CARRY FLAG, keeping any carry.
5CF3
ADD HL,DE 19
ADD Register Pair DE (the old value) to Register Pair HL: the value times 5.
5CF4
ADC A,A 8F
ADD Register A to itself with the CARRY FLAG, keeping any carry.
5CF5
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 10.
5CF6
ADC A,A 8F
ADD Register A to itself with the CARRY FLAG, keeping any carry.
5CF7
ADD HL,BC 09
ADD Register Pair BC (the digit) to Register Pair HL: the new value.
5CF8
POP BC C1
Restore Register Pair BC (the digits allowed and the count) from the stack at the Stack Pointer.
5CF9
ADC A,A 8F
ADD Register A to itself with the CARRY FLAG: Register A stays 00H (the Z FLAG) unless the value passed 65535.
5CFA
POP DE D1
POP into Register Pair DE the text pointer from the stack at the Stack Pointer.
5CFB
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the new value, Register Pair HL = the text pointer.
5CFC
If the Z FLAG is set (no overflow), LOOP BACK to 5CDBH for the next digit.
5CFE
SCF 37
Set the CARRY FLAG: the value in Register Pair DE passed 65535.
5CFF
RET C9
RETurn with the CARRY FLAG, an overflow, and Register Pair HL at the digit.
5D00H - Number to Decimal Text
5D0BH converts Register Pair DE (0-65535) to five digits at 5D2AH-5D2EH with ROM 132FH and returns Register Pair HL at the first digit that is not a leading zero and Registers D and E = the number of digits from there (at least 1). 5D00H also copies those digits to Register Pair BC.
5D00
GOSUB to 5D0BH to convert Register Pair DE to digits: Register Pair HL returns the first digit to use and Register D the count. 5D6BH and 63DAH call here with Register Pair BC = the destination.
5D03
LD A,(HL) 7E
Fetch a digit at Register Pair HL into Register A. 5D08H loops back here.
5D04
LD (BC),A 02
Store Register A (the digit) at Register Pair BC.
5D05
INC BC 03
INCrement Register Pair BC to the next destination byte.
5D06
INC HL 23
INCrement Register Pair HL to the next digit in the buffer.
5D07
DEC D 15
DECrement Register D, the digits left to copy.
5D08
If the NZ FLAG is set (digits left), LOOP BACK to 5D03H.
5D0A
RET C9
RETurn with the digits copied and Register Pair BC after them.
5D0B
PUSH BC C5
Save Register Pair BC (the caller's value) onto the stack at the Stack Pointer. 5AB9H, 5B1DH, 5B28H and 5D00H call here.
5D0C
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value ROM 132FH expects in Register Pair BC.
5D0F
LD (4121H),DE ED 53 21 41
Store Register Pair DE (the number) at 4121H-4122H, the ROM's accumulator as an integer.
5D13
LD HL,5D2AH 21 2A 5D
Point Register Pair HL to 5D2AH, the digit buffer.
5D16
PUSH HL E5
Save Register Pair HL (5D2AH) onto the stack at the Stack Pointer.
5D17
GOSUB to ROM 132FH, which writes the integer in the ROM's accumulator as five decimal digits at Register Pair HL (5D2AH-5D2EH).
5D1A
POP HL E1
Restore Register Pair HL (5D2AH, the first digit) from the stack at the Stack Pointer.
5D1B
POP BC C1
Restore Register Pair BC (the caller's value) from the stack at the Stack Pointer.
5D1C
LD D,04H 16 04
Load Register D with 04H: at most four leading zeros are passed over, so one digit always remains.
5D1E
LD A,(HL) 7E
Fetch a digit at Register Pair HL into Register A. 5D25H loops back here.
5D1F
CP 30H FE 30
Compare Register A, the digit, against 30H (0). The Z FLAG is set for a leading zero.
5D21
If the NZ FLAG is set (not a zero), JUMP to 5D27H.
5D23
INC HL 23
INCrement Register Pair HL past the leading zero.
5D24
DEC D 15
DECrement Register D: one zero fewer may be passed over.
5D25
If the NZ FLAG is set (more zeros may be passed over), LOOP BACK to 5D1EH.
5D27
INC D 14
INCrement Register D: Register D = the number of digits from Register Pair HL on (1-5). 5D21H comes here.
5D28
LD E,D 5A
Copy Register D (the number of digits) into Register E.
5D29
RET C9
RETurn with Register Pair HL at the first digit to use and Registers D and E = the number of digits.
5D2AH - Digit Buffer
5D2AH-5D2EH receive the five digits from 5D0BH; 5D2FH follows them.
5D2A-5D2F
DEFB 00H, 00H, 00H, 00H, 00H, 00H 00 00 00 00 00 00
The digit buffer (00H in the file): ROM 132FH writes five ASCII digits at 5D2AH-5D2EH for 5D0BH; 5AC5H and 5B20H/5B32H copy from 5D2CH and 5D2DH, 5D67H displays from it. 5D2FH is not written in this file.
5D30H - Display Output (Screen and Printer)
5D3FH displays the character in Register A (ROM 0033H) and also prints it (ROM 003BH) when the operand at 5D45H is 24H (it is cleared at 6430H; SYS12/SYS stores it at its 4D04H). 5D30H displays Register A spaces, 5D3DH one space, 5D4FH a space and a carriage return, 5D52H a carriage return, 5D37H and 5D67H a number in decimal; 5D56H divides Register Pair HL by Register A.
5D30
LD B,A 47
Copy Register A, the number of spaces, into Register B. 5A01H calls here.
5D31
GOSUB to 5D3DH to display a space (and print it when the printer is on). 5D34H loops back here.
5D34
DECrement Register B (the spaces left) and LOOP BACK to 5D31H.
5D36
RET C9
RETurn with Register B = 00H after all the spaces.
5D37
LD DE,0000H 11 00 00
Self-Modifying Code
Load Register Pair DE with the number in the operand at 5D38H-5D39H (0000H in the file; SYS10/SYS stores it at its 4F95H and reads it at 5193H). SYS13/SYS calls 5D37H at its 4D17H.
5D3A
GOSUB to 5D67H to display Register Pair DE in decimal, then fall into 5D3DH for a space.
5D3D
LD A,20H 3E 20
Load Register A with 20H, a space. 5D31H and 5D4FH call here.
5D3F
PUSH DE D5
Save Register Pair DE (the caller's value) onto the stack at the Stack Pointer. 5D54H and 5D72H come here with the character in Register A.
5D40
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the character.
5D41
GOSUB to ROM 0033H to display the character in Register A at the cursor (the ROM uses Register Pair DE = 401DH, the display's control block).
5D44
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the operand at 5D45H, the printer switch: 00H in the file and after every file statement (6430H); SYS12/SYS stores Register A there at its 4D04H, and 24H means the output is to be printed as well.
5D46
CP 24H FE 24
Compare Register A, the printer switch, against 24H. The Z FLAG is set when the output is to be printed.
5D48
POP DE D1
POP into Register Pair DE the word pushed from Register Pair AF: Register D = the character. POP does not change the flags.
5D49
LD A,D 7A
Copy Register D (the character) into Register A.
5D4A
If the Z FLAG is set (printing is on), GOSUB to ROM 003BH to print the character in Register A.
5D4D
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer.
5D4E
RET C9
RETurn with the character in Register A displayed (and printed).
5D4F
GOSUB to 5D3DH to display a space, then fall into 5D52H for a carriage return (called by SYS12/SYS at its 4D00H).
5D52
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, to end the line. 5A1EH calls here.
5D54
JUMP to 5D3FH to display (and print) the carriage return in Register A.
5D56
LD C,A 4F
Divide Register Pair HL by Register A (called by SYS21/SYS at its 4E5BH, 4E8CH and 4F06H): copy Register A, the divisor, into Register C.
5D57
LD B,10H 06 10
Load Register B with 10H, the 16 steps of the division, one per bit of Register Pair HL.
5D59
XOR A AF
Set Register A, the remainder of the division, to 00H.
5D5A
ADD HL,HL 29
ADD Register Pair HL to itself: the dividend moves left one bit, its top bit into the CARRY FLAG. 5D63H loops back here.
5D5B
RLA 17
Rotate Register A (the remainder) left through the CARRY FLAG: the dividend's top bit enters the remainder.
5D5C
If the CARRY FLAG is set (the remainder passed 255), JUMP to 5D61H: the divisor certainly goes into it.
5D5E
CP C B9
Compare Register A (the remainder) against Register C (the divisor). The CARRY FLAG is set when the remainder is smaller.
5D5F
If the CARRY FLAG is set (the divisor does not go in), JUMP to 5D63H.
5D61
SUB C 91
SUBtract Register C (the divisor) from Register A (the remainder). 5D5CH comes here.
5D62
INC L 2C
INCrement Register L: the quotient bit 1 goes into the low bit of Register Pair HL.
5D63
DECrement Register B (the steps left) and LOOP BACK to 5D5AH. 5D5FH comes here.
5D65
OR A B7
OR Register A with itself, which clears the CARRY FLAG.
5D66
RET C9
RETurn with the quotient in Register Pair HL and the remainder in Register A.
5D67
LD BC,5D2AH 01 2A 5D
Point Register Pair BC to 5D2AH, the digit buffer, as the destination of the digits. 59FBH and 5D3AH call here with the number in Register Pair DE.
5D6A
PUSH BC C5
Save Register Pair BC (5D2AH) onto the stack at the Stack Pointer.
5D6B
GOSUB to 5D00H to convert Register Pair DE to digits and copy the ones to show to 5D2AH on; Register E returns their number.
5D6E
POP HL E1
POP into Register Pair HL from the stack at the Stack Pointer: 5D2AH, the first digit.
5D6F
LD B,E 43
Copy Register E (the number of digits) into Register B, the loop counter.
5D70
LD A,(HL) 7E
Fetch a digit at Register Pair HL into Register A. 5D75H loops back here.
5D71
INC HL 23
INCrement Register Pair HL to the next digit.
5D72
GOSUB to 5D3FH to display (and print) the digit in Register A.
5D75
DECrement Register B (the digits left) and LOOP BACK to 5D70H.
5D77
RET C9
RETurn with Register E = the number of digits displayed.
5D78H - Continue a Statement on the Next Line (SYS19/SYS, SYS21/SYS)
Called by SYS19/SYS (its 533DH, 55B7H) and SYS21/SYS (its 4D21H) after a trailing comma: the rest of the line must be empty, colons or a remark (5D8BH); the next line's number goes to 57B8H-57B9H. With no next line: SYNTAX ERROR.
5D78
GOSUB to 5D8BH to check that the rest of the line at Register Pair HL is empty, colons or a remark; it returns with Register Pair HL at the line's 00H.
5D7B
INC HL 23
INCrement Register Pair HL past the 00H to the next line's link.
5D7C
LD A,(HL) 7E
Fetch the low byte of the next line's link at Register Pair HL into Register A.
5D7D
INC HL 23
INCrement Register Pair HL to the high byte of the link.
5D7E
OR (HL) B6
OR the high byte of the link at Register Pair HL into Register A: the Z FLAG is set for a link of 0000H, the end of the program.
5D7F
INC HL 23
INCrement Register Pair HL to the next line's number. INC HL does not change the flags.
5D80
If the Z FLAG is set (no next line), JUMP to ROM 1997H, SYNTAX ERROR.
5D83
LD E,(HL) 5E
Load Register E with the low byte of the next line's number at Register Pair HL.
5D84
INC HL 23
INCrement Register Pair HL to the high byte of the line number.
5D85
LD D,(HL) 56
Load Register D with the high byte from Register Pair HL: Register Pair DE = the next line's number.
5D86
LD (57B8H),DE ED 53 B8 57
Store Register Pair DE (the next line's number) at 57B8H-57B9H, for the overlay.
5D8A
RET C9
RETurn with Register Pair HL at the high byte of the next line's number.
5D8BH - Pass Over an Empty Rest of Line or a Remark
Returns with the Z FLAG at the line's 00H. Colons are passed over; anything else must be the REM token, and the remark is passed over to the end of the line; any other character is a syntax error.
5D8B
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H reads the current character again.
5D8C
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A.
5D8D
OR A B7
OR Register A with itself: the Z FLAG is set at the line's 00H.
5D8E
RET Z C8
If the Z FLAG is set (the line is over), RETurn with Register Pair HL at its 00H.
5D8F
CP 3AH FE 3A
Compare Register A against 3AH, a colon. The Z FLAG is set for a colon. 5D94H comes back here.
5D91
If the NZ FLAG is set (not a colon), JUMP to 5D96H, which requires a remark.
5D93
RST 10H D7
RST 10H: INCrement Register Pair HL and load the character after the colon into Register A.
5D94
JUMP to 5D8FH to test the character in Register A.
5D96
RST 08H CF
RST 08H: the byte after it (93H, the REM token) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it and Register A holds the next character.
5D97
DEFB 93H 93
The byte the RST 08H at 5D96H compares against: 93H, the REM token. It is never executed.
5D98
OR A B7
OR Register A with itself: the Z FLAG is set at the line's 00H. 5D9BH loops back here.
5D99
RET Z C8
If the Z FLAG is set (the end of the line), RETurn with Register Pair HL at its 00H.
5D9A
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character of the remark into Register A.
5D9B
LOOP BACK to 5D98H to test the character in Register A.
5D9DH - Disk BASIC Error Entries
One entry per Disk BASIC error: each loads Register A with the error number the ROM keeps in Register E (two times the message number less 1, as the ROM's own errors); the LD BC instructions only step over the next entry's LD A,n, so every entry runs on to 5DDEH with its own number. SYS13/SYS holds the messages. The overlays enter many of these directly.
5D9D
LD A,2AH 3E 2A
Error 2AH, BAD FILE DATA (6288H and SYS10/SYS come here): load Register A with 2AH.
Overlapping Instructions
Each LD BC,nn3EH below only loads Register Pair BC when the code runs into it, so Register A keeps the number already loaded. Entered one byte later, its bytes 3EH nn are LD A,nn: that entry's own error number.
5D9F
LD BC,2E3EH 01 3E 2E
Run into from the entry before: load Register Pair BC with 2E3EH, which only steps over the bytes 3EH 2EH and leaves Register A unchanged. Entered at 5DA0H, those two bytes are LD A,2EH: Register A = 2EH, error UNDEFINED USER FUNCTION.
5DA2
LD BC,643EH 01 3E 64
Run into from the entry before: load Register Pair BC with 643EH, which only steps over the bytes 3EH 64H and leaves Register A unchanged. Entered at 5DA3H, those two bytes are LD A,64H: Register A = 64H, error FIELD OVERFLOW.
5DA5
LD BC,683EH 01 3E 68
Run into from the entry before: load Register Pair BC with 683EH, which only steps over the bytes 3EH 68H and leaves Register A unchanged. Entered at 5DA6H, those two bytes are LD A,68H: Register A = 68H, error BAD FILE #.
5DA8
LD BC,6C3EH 01 3E 6C
Run into from the entry before: load Register Pair BC with 6C3EH, which only steps over the bytes 3EH 6CH and leaves Register A unchanged. Entered at 5DA9H, those two bytes are LD A,6CH: Register A = 6CH, error BAD FILE MODE.
5DAB
LD BC,6E3EH 01 3E 6E
Run into from the entry before: load Register Pair BC with 6E3EH, which only steps over the bytes 3EH 6EH and leaves Register A unchanged. Entered at 5DACH, those two bytes are LD A,6EH: Register A = 6EH, error FILE ALREADY OPEN.
5DAE
LD BC,7C3EH 01 3E 7C
Run into from the entry before: load Register Pair BC with 7C3EH, which only steps over the bytes 3EH 7CH and leaves Register A unchanged. Entered at 5DAFH, those two bytes are LD A,7CH: Register A = 7CH, error INPUT PAST END.
5DB1
LD BC,7E3EH 01 3E 7E
Run into from the entry before: load Register Pair BC with 7E3EH, which only steps over the bytes 3EH 7EH and leaves Register A unchanged. Entered at 5DB2H, those two bytes are LD A,7EH: Register A = 7EH, error BAD RECORD #.
5DB4
LD BC,803EH 01 3E 80
Run into from the entry before: load Register Pair BC with 803EH, which only steps over the bytes 3EH 80H and leaves Register A unchanged. Entered at 5DB5H, those two bytes are LD A,80H: Register A = 80H, error BAD FILE NAME.
5DB7
LD BC,843EH 01 3E 84
Run into from the entry before: load Register Pair BC with 843EH, which only steps over the bytes 3EH 84H and leaves Register A unchanged. Entered at 5DB8H, those two bytes are LD A,84H: Register A = 84H, error DIRECT STATEMENT IN FILE.
5DBA
LD BC,8C3EH 01 3E 8C
Run into from the entry before: load Register Pair BC with 8C3EH, which only steps over the bytes 3EH 8CH and leaves Register A unchanged. Entered at 5DBBH, those two bytes are LD A,8CH: Register A = 8CH, error SEQ # OVERFLOW.
5DBD
LD BC,8E3EH 01 3E 8E
Run into from the entry before: load Register Pair BC with 8E3EH, which only steps over the bytes 3EH 8EH and leaves Register A unchanged. Entered at 5DBEH, those two bytes are LD A,8EH: Register A = 8EH, error RECORD OVERFLOW.
5DC0
LD BC,903EH 01 3E 90
Run into from the entry before: load Register Pair BC with 903EH, which only steps over the bytes 3EH 90H and leaves Register A unchanged. Entered at 5DC1H, those two bytes are LD A,90H: Register A = 90H, error ILLEGAL TO EXTEND FILE.
5DC3
LD BC,923EH 01 3E 92
Run into from the entry before: load Register Pair BC with 923EH, which only steps over the bytes 3EH 92H and leaves Register A unchanged. Entered at 5DC4H, those two bytes are LD A,92H: Register A = 92H, error 92H, for which SYS13/SYS has no message of its own.
5DC6
LD BC,943EH 01 3E 94
Run into from the entry before: load Register Pair BC with 943EH, which only steps over the bytes 3EH 94H and leaves Register A unchanged. Entered at 5DC7H, those two bytes are LD A,94H: Register A = 94H, error PREVIOUSLY DISPLAYED ERROR.
5DC9
LD BC,983EH 01 3E 98
Run into from the entry before: load Register Pair BC with 983EH, which only steps over the bytes 3EH 98H and leaves Register A unchanged. Entered at 5DCAH, those two bytes are LD A,98H: Register A = 98H, error BAD FILE TYPE.
5DCC
LD BC,9A3EH 01 3E 9A
Run into from the entry before: load Register Pair BC with 9A3EH, which only steps over the bytes 3EH 9AH and leaves Register A unchanged. Entered at 5DCDH, those two bytes are LD A,9AH: Register A = 9AH, error IGEL SYNTAX ERROR.
5DCF
LD BC,9C3EH 01 3E 9C
Run into from the entry before: load Register Pair BC with 9C3EH, which only steps over the bytes 3EH 9CH and leaves Register A unchanged. Entered at 5DD0H, those two bytes are LD A,9CH: Register A = 9CH, error IGEL ITEM SYNTAX ERROR.
5DD2
LD BC,9E3EH 01 3E 9E
Run into from the entry before: load Register Pair BC with 9E3EH, which only steps over the bytes 3EH 9EH and leaves Register A unchanged. Entered at 5DD3H, those two bytes are LD A,9EH: Register A = 9EH, error BAD/ILLEGAL/MISSING IGEL ITEM PREFIX.
5DD5
LD BC,A23EH 01 3E A2
Run into from the entry before: load Register Pair BC with A23EH, which only steps over the bytes 3EH A2H and leaves Register A unchanged. Entered at 5DD6H, those two bytes are LD A,A2H: Register A = A2H, error BAD RECORD LENGTH.
5DD8
LD BC,A43EH 01 3E A4
Run into from the entry before: load Register Pair BC with A43EH, which only steps over the bytes 3EH A4H and leaves Register A unchanged. Entered at 5DD9H, those two bytes are LD A,A4H: Register A = A4H, error STMT USES 2 FILE AREAS.
5DDB
LD BC,A63EH 01 3E A6
Run into from the entry before: load Register Pair BC with A63EH, which only steps over the bytes 3EH A6H and leaves Register A unchanged. Entered at 5DDCH, those two bytes are LD A,A6H: Register A = A6H, error BAD FILE POSITIONING PARAM.
5DDEH - Report a BASIC Error
Register A = the error number; ROM 19A2H reports it (to an ON ERROR GOTO line, or with the message, which SYS13/SYS displays for the Disk BASIC numbers).
5DDE
LD E,A 5F
Copy Register A, the error number, into Register E, where the ROM's error handler expects it. 5DEDH comes here.
5DDF
JUMP to ROM 19A2H, the error handler, with Register E = the error number (it keeps the line number for ERL and goes to ON ERROR GOTO or reports the error). 5E0DH comes here.
5DE2H - Report an Error After Relinking (SYS11/SYS, SYS13/SYS)
Entered by SYS11/SYS (its 50E1H) and SYS13/SYS (its 517AH, 5198H, 51B2H) after they have changed the program: the line links are rebuilt and the variables cleared before the error in Register A is reported.
5DE2
LD (5DECH),A 32 EC 5D
Store Register A, the error number, at 5DECH, the operand of the LD A at 5DEBH, since the ROM routines below change Register A.
5DE5
GOSUB to ROM 1AF8H (LINKER), which rebuilds the link of every program line.
5DE8
GOSUB to ROM 1B59H, the part of NEW that stores the end of the program at 40F9H and clears the variables.
5DEB
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the error number, the operand at 5DECH stored by 5DE2H (00H in the file).
5DED
JUMP to 5DDEH to report the error in Register A.
5DEFH - DOS Error to BASIC Error
Register A = a DOS error code. The code OR C0H is kept at 57E5H (for CMD"E"); the table at 5E0FH gives the BASIC error number, 72H DOS ERROR when the code is not listed. Without ON ERROR GOTO the DOS message is displayed first (57E4H).
5DEF
LD C,A 4F
Copy Register A, the DOS error code, into Register C. 5779H, 5FC2H, 60C6H, 6221H, 6255H, 637DH, 641BH and the overlays come here.
5DF0
OR C0H F6 C0
OR Register A with C0H, setting bits 7 and 6, the form SYS0/SYS's error exit 4409H takes to display the message and return to the caller.
5DF2
LD (57E5H),A 32 E5 57
Store Register A (the DOS code OR C0H) at 57E5H, the operand of the LD A at 57E4H, for CMD"E" and for 5E0AH below.
5DF5
LD HL,5E0FH 21 0F 5E
Point Register Pair HL to 5E0FH, the table of DOS code and BASIC number pairs.
5DF8
LD E,72H 1E 72
Load Register E with 72H, DOS ERROR, the BASIC number for a DOS code not in the table.
Loop: look up the DOS code.
5DFA
LD A,(HL) 7E
Fetch an entry's DOS code at Register Pair HL into Register A. 5E03H loops back here.
5DFB
CP C B9
Compare Register A (the entry's DOS code) against Register C (the DOS error). The Z FLAG is set on a match.
5DFC
INC HL 23
INCrement Register Pair HL to the entry's BASIC number. INC HL does not change the flags.
5DFD
If the NZ FLAG is set (another code), JUMP to 5E00H.
5DFF
LD E,(HL) 5E
Found: load Register E with the BASIC number at Register Pair HL.
5E00
INC HL 23
INCrement Register Pair HL to the next entry. 5DFDH comes here.
5E01
LD A,(HL) 7E
Fetch the next entry's DOS code at Register Pair HL into Register A.
5E02
OR A B7
OR Register A with itself: the Z FLAG is set at the 00H that ends the table.
5E03
If the NZ FLAG is set (more entries), LOOP BACK to 5DFAH.
5E05
LD HL,(40F0H) 2A F0 40
Load Register Pair HL with the word at 40F0H, the ROM's ON ERROR GOTO line (0000H when none is set).
5E08
LD A,H 7C
Copy Register H, the high byte of the ON ERROR line, into Register A.
5E09
OR L B5
OR Register L, the low byte, into Register A: the Z FLAG is set when no ON ERROR GOTO is active.
5E0A
If the Z FLAG is set (no ON ERROR GOTO), GOSUB to 57E4H, which loads Register A with the DOS code OR C0H and goes to SYS0/SYS 4409H to display the DOS error message and come back.
5E0D
JUMP to 5DDFH to report the BASIC error number in Register E.
5E0FH - DOS to BASIC Error Table
Pairs of DOS error code and BASIC error number, ended by 00H. DOS codes not listed become 72H, DOS ERROR.
5E0F-5E10
DEFB 0FH, 88H 0F 88
DOS error 0FH (WRITE PROTECTED DISKETTE) becomes BASIC error 88H, DISK WRITE PROTECTED. 5DF5H starts the search here.
5E11-5E12
DEFB 13H, 80H 13 80
DOS error 13H (ILLEGAL FILE NAME) becomes BASIC error 80H, BAD FILE NAME.
5E13-5E14
DEFB 18H, 6AH 18 6A
DOS error 18H (FILE NOT IN DIRECTORY) becomes BASIC error 6AH, FILE NOT FOUND.
5E15-5E16
DEFB 19H, 8AH 19 8A
DOS error 19H (FILE ACCESS DENIED) becomes BASIC error 8AH, FILE ACCESS DENIED.
5E17-5E18
DEFB 1AH, 86H 1A 86
DOS error 1AH (DIRECTORY SPACE FULL) becomes BASIC error 86H, TOO MANY FILES.
5E19-5E1A
DEFB 1BH, 7AH 1B 7A
DOS error 1BH (DISKETTE SPACE FULL) becomes BASIC error 7AH, DISK FULL.
5E1B-5E1C
DEFB 1CH, 7CH 1C 7C
DOS error 1CH (END OF FILE ENCOUNTERED) becomes BASIC error 7CH, INPUT PAST END.
5E1D-5E1E
DEFB 1DH, 7CH 1D 7C
DOS error 1DH (PAST END OF FILE) becomes BASIC error 7CH, INPUT PAST END.
5E1F-5E20
DEFB 1EH, 7AH 1E 7A
DOS error 1EH (DIRECTORY FULL, CAN'T EXTEND FILE) becomes BASIC error 7AH, DISK FULL.
5E21-5E22
DEFB 1FH, 66H 1F 66
DOS error 1FH (PROGRAM NOT FOUND) becomes BASIC error 66H, INTERNAL ERROR.
5E23-5E24
DEFB 20H, 80H 20 80
DOS error 20H (ILLEGAL OR MISSING DRIVE #) becomes BASIC error 80H, BAD FILE NAME.
5E25-5E26
DEFB 21H, 66H 21 66
DOS error 21H (NO DEVICE SPACE AVAILABLE) becomes BASIC error 66H, INTERNAL ERROR.
5E27-5E28
DEFB 22H, 66H 22 66
DOS error 22H (LOAD FILE FORMAT ERROR) becomes BASIC error 66H, INTERNAL ERROR.
5E29-5E2A
DEFB 23H, 66H 23 66
DOS error 23H (MEMORY FAULT) becomes BASIC error 66H, INTERNAL ERROR.
5E2B-5E2C
DEFB 24H, 66H 24 66
DOS error 24H (TRIED TO LOAD READ ONLY MEMORY) becomes BASIC error 66H, INTERNAL ERROR.
5E2D-5E2E
DEFB 25H, 8AH 25 8A
DOS error 25H (ILLEGAL ACCESS TRIED TO PROTECTED FILE) becomes BASIC error 8AH, FILE ACCESS DENIED.
5E2F-5E30
DEFB 26H, 66H 26 66
DOS error 26H (FILE NOT OPEN) becomes BASIC error 66H, INTERNAL ERROR.
5E31-5E32
DEFB 30H, 80H 30 80
DOS error 30H (BAD FILESPEC) becomes BASIC error 80H, BAD FILE NAME.
5E33
DEFB 00H 00
00H in place of a DOS code: the end of the table, tested at 5E02H.
5E34-5E3B
DEFB 00H x 8 00 x 8
Eight bytes of 00H after the table. No instruction of BASIC/CMD or of the overlays SYS10/SYS-SYS21/SYS reads, writes or runs them.
5E3CH - FIELD Statement
FIELD link (417CH, from the JP 5E3CH at 67E5H). FIELD [#]n, w AS var$, ... points each string variable at the next w bytes of the file area's 256-byte buffer (the area + 2DH). The file must be closed, or random with type bits 1 and 0 clear; the widths may add up to 256 at most (else FIELD OVERFLOW).
5E3C
GOSUB to 5F53H to read the file number at Register Pair HL: Register Pair BC returns the file area's address and Register A its mode byte, with the Z FLAG when the file is not open.
5E3F
If the Z FLAG is set (the file is not open), JUMP to 5E48H: the fields can be set up before the OPEN.
5E41
XOR 80H EE 80
Exclusive OR Register A (the mode byte) with 80H, turning bit 7 (random) around.
5E43
AND 83H E6 83
AND Register A with 83H, keeping bits 7, 1 and 0: 00H with the Z FLAG only for a random file whose type bits 1 and 0 are clear.
5E45
If the NZ FLAG is set (any other file), JUMP to 5DA9H, BAD FILE MODE.
5E48
LD DE,002DH 11 2D 00
Load Register Pair DE with 002DH, the offset of the buffer in the file area. 5E3FH comes here; Register A is 00H for a closed file, else 00H after the AND, the bytes used so far.
Loop: one field per pass.
5E4B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the offset (the width of the previous field after the first pass). 5E72H loops back here.
5E4C
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the address of this field (the area + 2DH the first time, then the previous field + its width).
5E4D
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the field's address, Register Pair HL = the text pointer.
5E4E
LD B,A 47
Copy Register A, the bytes used so far, into Register B.
5E4F
LD A,2CH 3E 2C
Load Register A with 2CH, the comma that comes before each field.
5E51
CP (HL) BE
Compare Register A (a comma) against the character at Register Pair HL. The Z FLAG is set when another field follows.
5E52
RET NZ C0
If the NZ FLAG is set (no comma), RETurn: FIELD is done.
5E53
PUSH DE D5
Save Register Pair DE (the field's address) onto the stack at the Stack Pointer.
5E54
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer: Register B = the bytes used before this field.
5E55
GOSUB to ROM 2B1BH, which steps past the comma and evaluates the width as a byte into Register A (0-255).
5E58
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the width.
5E59
RST 08H CF
RST 08H: the byte after it (41H, the letter A of AS) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it.
5E5A
DEFB 41H 41
The byte the RST 08H at 5E59H compares against: 41H, the letter A. It is never executed.
5E5B
RST 08H CF
RST 08H: the byte after it (53H, the letter S of AS) must be the next character, else SYNTAX ERROR; Register Pair HL is moved past it.
5E5C
DEFB 53H 53
The byte the RST 08H at 5E5BH compares against: 53H, the letter S. It is never executed.
5E5D
GOSUB to 5E7BH to find the variable named at Register Pair HL, which must be a string: Register Pair DE returns the address of its descriptor.
5E60
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the width.
5E61
POP BC C1
Restore Register Pair BC from the stack at the Stack Pointer: Register B = the bytes used before this field.
5E62
LD C,A 4F
Copy Register A (the width of this field) into Register C for the descriptor.
5E63
ADD A,B 80
ADD Register B (the bytes used) to Register A: the bytes used with this field. The CARRY FLAG is set past 255.
5E64
If the NO CARRY FLAG is set (below 256), JUMP to 5E68H.
5E66
If the NZ FLAG is set (more than 256), JUMP to 5E78H, FIELD OVERFLOW. Exactly 256 (Register A = 00H with the CARRY FLAG) goes on.
5E68
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the field's address on the stack at the Stack Pointer. 5E64H comes here.
5E69
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the variable's descriptor, Register Pair DE = the field's address.
5E6A
LD (HL),C 71
Store Register C (the width) at Register Pair HL as the string's length.
5E6B
INC HL 23
INCrement Register Pair HL to the low byte of the text address in the descriptor.
5E6C
LD (HL),E 73
Store Register E (the low byte of the field's address) at Register Pair HL.
5E6D
INC HL 23
INCrement Register Pair HL to the high byte of the text address.
5E6E
LD (HL),D 72
Store Register D (the high byte of the field's address) at Register Pair HL: the variable now names the field in the buffer.
5E6F
POP HL E1
POP into Register Pair HL the text pointer from the stack at the Stack Pointer.
5E70
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the width, which 5E4CH adds to reach the next field. LD does not change the flags.
5E72
If the NO CARRY FLAG is set (the total is below 256), LOOP BACK to 5E4BH with Register A = the total.
5E74
LD A,(HL) 7E
Exactly 256 bytes are used: fetch the character at Register Pair HL into Register A.
5E75
CP 2CH FE 2C
Compare Register A against 2CH, a comma. The Z FLAG is set when another field follows.
5E77
RET NZ C0
If the NZ FLAG is set (no more fields), RETurn: FIELD is done.
5E78
JUMP to 5DA3H, FIELD OVERFLOW (5DA3H loads Register A with 64H). 5E66H comes here.
5E7BH - Find a String Variable
ROM PTRGET finds the variable named at Register Pair HL (Register Pair DE = its address); ROM 0AF4H then requires it to be a string.
5E7B
GOSUB to ROM 260DH, PTRGET: Register Pair DE returns the address of the variable named at Register Pair HL and 40AFH its value type. 58E4H and 5E5DH call here.
5E7E
JUMP to ROM 0AF4H, which gives TYPE MISMATCH unless the value type at 40AFH is a string, and returns with Register Pairs BC, DE and HL kept.
5E81H - INPUT # Link
Link 41D6H (from the JP 5E81H at 683FH; the ROM calls 41D6H at 219EH) with Register A = the character after INPUT. INPUT # from a file (not #-1, the cassette) needs a readable file area and continues at the ROM's INPUT code for a device.
5E81
CP 23H FE 23
Compare Register A, the character after INPUT, against 23H (#). The Z FLAG is set for INPUT #.
5E83
RET NZ C0
If the NZ FLAG is set (INPUT from the keyboard), RETurn to the ROM's INPUT at 21A1H.
5E84
PUSH HL E5
Save Register Pair HL (the text pointer at the #) onto the stack at the Stack Pointer.
5E85
RST 10H D7
RST 10H: INCrement Register Pair HL and load the character after the # into Register A.
5E86
CP CEH FE CE
Compare Register A against CEH, the minus token: INPUT #-1 is the cassette. The Z FLAG is set for it.
5E88
POP HL E1
Restore Register Pair HL (the text pointer at the #) from the stack at the Stack Pointer.
5E89
LD A,(HL) 7E
Fetch the # at Register Pair HL into Register A again for the ROM. LD does not change the flags.
5E8A
RET Z C8
If the Z FLAG is set (the cassette), RETurn to the ROM's INPUT at 21A1H.
5E8B
GOSUB to 5F36H: the file must be readable; the file statement is set up with the file area's header at 5700H and Register Pair HL past the file number and comma.
5E8E
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the ROM's return address on the stack at the Stack Pointer, which is dropped: the text pointer stays on the stack for the ROM's INPUT code.
5E8F
JUMP to ROM 21C3H, the part of INPUT that reads a line from a device (the bytes come through the file statement's links).
5E92H - Link 41DFH (After INPUT and in LIST)
Link 41DFH (from the JP 5E92H at 6848H), called by the ROM after INPUT has assigned its variables (2278H) and in LIST (2B44H). Nothing is done unless a file statement is running (6382H); then LIST goes on at 2B4AH (passing over its CALL 1D9BH, the BREAK test) and INPUT # ends at ROM 2282H.
5E92
GOSUB to 6382H: when no file statement is running, its INC SP / INC SP / RET drops this call and returns straight to the ROM; otherwise it returns here.
5E95
POP AF F1
POP the ROM's return address of its CALL 41DFH from the stack at the Stack Pointer into Register Pair AF: Register A = its high byte (2BH from LIST at 2B44H, 22H from INPUT at 2278H).
5E96
CP 2BH FE 2B
Compare Register A against 2BH. The Z FLAG is set when LIST called.
5E98
If the Z FLAG is set (LIST), JUMP to ROM 2B4AH, after LIST's CALL 1D9BH.
5E9B
JUMP to ROM 2282H (FINPRG), the end of INPUT, which restores the text pointer and resets the output device.
5E9EH - EOF Function Entry
Reached through the EOF link at 4161H (the JP 5E9EH at 67CAH). Register B = 01H selects EOF for the common routine at 5EBFH.
5E9E
LD B,01H 06 01
Load Register B with 01H, the EOF selector for 5EBFH and 5FC9H.
5EA0
JUMP to 5EBFH, the code shared by EOF, LOF and LOC, with Register B = 01H.
5EA2H - LOF Function Entry
Reached through the LOF link at 4167H (the JP 5EA2H at 67D0H). Register B = 02H selects LOF: 5FC9H returns the file's end and 5EC8H divides it by the record length, so that LOF returns a number of records.
5EA2
LD B,02H 06 02
Load Register B with 02H, the LOF selector for 5EBFH and 5FC9H.
5EA4
JUMP to 5EBFH, the code shared by EOF, LOF and LOC, with Register B = 02H.
5EA6H - LOC Suffix Characters
The four characters that may follow LOC(n): $, %, ! and #. The loop at 5EB2H compares the character at the text pointer with them in this order. They are data: nothing runs 5EA6H-5EA9H (5EA4H jumps away and the LOC link enters at 5EAAH).
5EA6-5EA9
DEFM "$%!#" 24 25 21 23
The suffix table read by 5EB7H from Register Pair DE (5EACH points to it): $ gives the selector 40H, % 20H, ! 10H and # 08H; LOC with no suffix gives 04H.
5EAAH - LOC Function Entry
Reached through the LOC link at 4164H (the JP 5EAAH at 67CDH), after the ROM has evaluated the file number. A suffix $, %, ! or # after the ) chooses the selector in Register B: 40H, 20H, 10H, 08H, or 04H without one.
5EAA
POP HL E1
POP the top word from the stack at the Stack Pointer into Register Pair HL (the ROM's return address).
5EAB
EX (SP),HL E3
Exchange Register Pair HL with the next word on the stack at the Stack Pointer: Register Pair HL = the text pointer, and the return address goes in its place.
5EAC
LD DE,5EA6H 11 A6 5E
Point Register Pair DE to 5EA6H, the table of suffix characters.
5EAF
LD BC,8005H 01 05 80
Load Register Pair BC with 8005H: Register B = 80H, the selector, rotated right before each compare; Register C = 05H, four compares and the exit.
Loop: try the four suffix characters in turn.
5EB2
RRC B CB 08
Rotate Register B right: 80H becomes 40H, then 20H, 10H, 08H and at last 04H. 5EBAH loops back here.
5EB4
DEC C 0D
DECrement Register C, the compares left. The Z FLAG is set when all four were tried.
5EB5
If the Z FLAG is set (no suffix: Register B = 04H, plain LOC), JUMP to 5EBDH.
5EB7
LD A,(DE) 1A
Fetch the next suffix character from the table at Register Pair DE into Register A.
5EB8
CP (HL) BE
Compare Register A against the character at Register Pair HL. The Z FLAG is set on a match.
5EB9
INC DE 13
INCrement Register Pair DE to the next suffix character. INC DE does not change the flags.
5EBA
If the NZ FLAG is set (not this suffix), LOOP BACK to 5EB2H.
5EBC
RST 10H D7
The suffix matched: RST 10H INCrements Register Pair HL past it and loads the next character into Register A. Register B holds 40H, 20H, 10H or 08H.
5EBD
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the return address on the stack at the Stack Pointer. 5EB5H comes here.
5EBE
PUSH HL E5
Push Register Pair HL (the return address) onto the stack at the Stack Pointer: the two words are in their first order again.
5EBFH - Common EOF, LOF and LOC Code
Register B is the selector from 5E9EH, 5EA2H or 5EAAH. 5FC9H reads the file number and returns a 24-bit value in Registers H, L and C (for EOF and LOC$ it returns the answer itself through 6357H). For LOF (02H) and plain LOC (04H) the file must have fixed-length records (mode bit 2, 6634H) and the value is divided by the record length (5EE1H). The value goes back to BASIC as a single precision number.
5EBF
GOSUB to 5FC9H with Register B = the selector: it returns the value in Registers H (high), L and C (low).
5EC2
LD A,B 78
Copy Register B, the selector (01H EOF, 02H LOF, 04H LOC, 08H LOC#, 10H LOC!, 20H LOC%, 40H LOC$), into Register A.
5EC3
AND 06H E6 06
AND Register A with 06H: not 00H only for LOF (02H) and plain LOC (04H).
5EC5
If the NZ FLAG is set (LOF or plain LOC), GOSUB to 6634H, which gives BAD FILE MODE unless bit 2 of the mode byte at 5700H is set; it returns with the NZ FLAG.
5EC8
If the NZ FLAG is set (LOF or plain LOC), GOSUB to 5EE1H to divide Registers H, L and C by the record length at 5702H-5703H, rounding up: the number of records.
5ECB
GOSUB to ROM 0AEFH (VALSNG), which stores 04H, single precision, as the value type at 40AFH.
5ECE
LD E,C 59
Copy Register C, the low byte of the value, into Register E.
5ECF
LD C,H 4C
Copy Register H, the high byte, into Register C.
5ED0
LD D,L 55
Copy Register L, the middle byte, into Register D: Registers C, D and E now hold the value as a 24-bit mantissa.
5ED1
LD B,00H 06 00
Load Register B with 00H, the extra low byte of the mantissa that ROM 0765H rounds with.
5ED3
LD HL,4124H 21 24 41
Point Register Pair HL to 4124H, the exponent byte of the ROM's accumulator.
5ED6
LD (HL),98H 36 98
Store 98H at Register Pair HL (4124H): an exponent of 24 bits, so the mantissa in Registers C, D and E is a whole number.
5ED8
INC HL 23
INCrement Register Pair HL to 4125H, the sign byte the ROM uses while it normalizes.
5ED9
LD (HL),80H 36 80
Store 80H at Register Pair HL (4125H): the value is positive.
5EDB
GOSUB to ROM 0765H (NORMAL), which shifts Registers C, D, E and B left until the top bit is set, lowering the exponent at 4124H, and stores the single precision result in the ROM's accumulator.
5EDE
JUMP to 6357H to end the file function (header copied back, work area cleared) and return the number to BASIC.
5EE1H - Divide H, L and C by the Record Length (LOF, LOC)
Called from 5EC8H. Divides the 24-bit value in Registers H, L and C by the 16-bit record length at 5702H-5703H in 24 shift and subtract steps (the step count in the alternate Register A', the quotient bits collected in Register A and shifted up through Register Pair DE). The quotient is rounded up when there is a remainder; a quotient past 24 bits is BAD RECORD #.
5EE1
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the high and middle bytes of the dividend (from Registers H and L).
5EE2
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the remainder so far.
5EE5
LD A,C 79
Copy Register C, the low byte of the dividend, into Register A: the dividend is in Registers D, E and A.
5EE6
LD BC,(5702H) ED 4B 02 57
Load Register Pair BC with the divisor, the record length at 5702H-5703H.
5EEA
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': the dividend's low byte waits in Register A' and Register A is free for the step count.
5EEB
LD A,18H 3E 18
Load Register A with 18H (24), one step per bit of the dividend.
Loop: 24 division steps.
5EED
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': Register A = the dividend's low byte and the quotient bits, Register A' = the step count. 5F03H loops back here.
5EEE
ADD A,A 87
ADD Register A to itself: its top bit goes into the CARRY FLAG and bit 0 is free for the next quotient bit.
5EEF
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the upper bytes of the dividend.
5EF0
ADC HL,HL ED 6A
ADD Register Pair HL to itself with the CARRY FLAG: the upper dividend bytes move left and take in the bit from Register A; their top bit goes into the CARRY FLAG.
5EF2
EX DE,HL EB
Exchange Register Pairs DE and HL back: Register Pair DE = the upper dividend bytes, Register Pair HL = the remainder.
5EF3
ADC HL,HL ED 6A
ADD Register Pair HL (the remainder) to itself with the CARRY FLAG: it moves left and takes in the dividend's top bit.
5EF5
If the CARRY FLAG is set (a bit left Register Pair HL, so the remainder is above any divisor), JUMP to 5EFDH to subtract.
5EF7
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the trial SBC.
5EF8
SBC HL,BC ED 42
SUBtract Register Pair BC (the divisor) from Register Pair HL (the remainder) as a test. The CARRY FLAG is set when the remainder is smaller.
5EFA
ADD HL,BC 09
ADD Register Pair BC back to Register Pair HL; the CARRY FLAG of the SBC stays (the ADD's own carry is set exactly then).
5EFB
If the CARRY FLAG is set (the remainder is smaller than the divisor), JUMP to 5F01H: this quotient bit is 0.
5EFD
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC. 5EF5H comes here.
5EFE
SBC HL,BC ED 42
SUBtract Register Pair BC (the divisor) from Register Pair HL (the remainder).
5F00
INC A 3C
INCrement Register A: bit 0, the new quotient bit, is 1.
5F01
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': Register A = the step count. 5EFBH comes here.
5F02
DEC A 3D
DECrement Register A, the division steps left (24 at the start).
5F03
If the NZ FLAG is set (steps left), LOOP BACK to 5EEDH.
5F05
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': Register A = the low byte of the quotient.
5F06
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the high and middle bytes of the quotient, Register Pair DE = the remainder.
5F07
LD C,A 4F
Copy Register A (the low byte of the quotient) into Register C: the quotient is in Registers H, L and C.
5F08
LD A,D 7A
Copy Register D, the high byte of the remainder, into Register A.
5F09
OR E B3
OR Register E into Register A: the Z FLAG is set when the remainder is 0.
5F0A
RET Z C8
If the Z FLAG is set (it divided exactly), RETurn with the quotient in Registers H, L and C.
5F0B
INC C 0C
A remainder is left: INCrement Register C to round the quotient up.
5F0C
RET NZ C0
If the NZ FLAG is set (Register C did not wrap to 00H), RETurn with the rounded quotient.
5F0D
INC HL 23
INCrement Register Pair HL to carry into the middle and high bytes.
5F0E
LD A,H 7C
Copy Register H, the high byte of the quotient, into Register A.
5F0F
OR L B5
OR Register L into Register A: the Z FLAG is set only when Register Pair HL wrapped to 0000H.
5F10
RET NZ C0
If the NZ FLAG is set (no wrap), RETurn with the rounded quotient in Registers H, L and C.
5F11
The quotient passed 24 bits: JUMP to 5DB2H, BAD RECORD #.
5F14H - Link 41D3H (PRINT Comma and TAB to a File)
Link 41D3H (from the JP 5F14H at 683CH), called by the ROM's PRINT for a comma (2108H) and for TAB (2141H). During a file statement the file's print column at 570AH is used instead of the screen's.
5F14
GOSUB to 6382H: when no file statement is running it drops this call and returns straight to the ROM; otherwise it returns here.
5F17
POP HL E1
POP the ROM's return address from the stack at the Stack Pointer into Register Pair HL: 210BH (after the comma's CALL 41D3H) or 2144H (after TAB's).
5F18
LD A,L 7D
Copy Register L, the low byte of the return address (0BH or 44H), into Register A.
5F19
CP 30H FE 30
Compare Register A against 30H. The CARRY FLAG is set for 0BH, the comma.
5F1B
LD A,(570AH) 3A 0A 57
Fetch the file's print column at 570AH into Register A. LD does not change the flags.
5F1E
If the CARRY FLAG is set (a comma), JUMP to ROM 2130H, the comma's code, with Register A = the file's column.
5F21
TAB: JUMP to ROM 2156H, the rest of TAB, with Register A = the file's column.
5F24H - Link 41CDH (PRINT a Number to a File)
Link 41CDH (from the JP 5F24H at 6836H), called by the ROM's PRINT after a number has been made into text (20C6H). During a file statement the test of whether the item fits on the screen line is passed over.
5F24
GOSUB to 6382H: when no file statement is running it drops this call and returns straight to the ROM; otherwise it returns here.
5F27
POP HL E1
POP the ROM's return address from the stack at the Stack Pointer into Register Pair HL, dropping it.
5F28
JUMP to ROM 20E9H, which outputs the item without the screen line test.
5F2BH - Link 41CAH (PRINT #)
Link 41CAH (from the JP 5F2BH at 6833H), called by the ROM's PRINT at 206FH with Register A = the character after PRINT. PRINT # to a file (not #-1, the cassette) needs a writable file that is not random. 5F36H is the entry for INPUT # (readable).
5F2B
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack at the Stack Pointer.
5F2C
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character into Register A, the one after the #.
5F2D
CP CEH FE CE
Compare Register A against CEH, the minus token: PRINT #-1 is the cassette. The Z FLAG is set for it.
5F2F
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
5F30
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A again for the ROM. LD does not change the flags.
5F31
RET Z C8
If the Z FLAG is set (the cassette), RETurn to the ROM's PRINT.
5F32
LD C,40H 0E 40
Load Register C with 40H, the mode bit (writable) the file must have.
5F34
JUMP to 5F38H with Register C = 40H, the writable bit.
5F36H - Entry for INPUT # (Readable File)
Called from 5E8BH: the file must be readable.
5F36
LD C,20H 0E 20
Load Register C with 20H, the mode bit (readable) the file must have, and go on at 5F38H.
5F38H - Check the File for PRINT # and INPUT #
Register C = the mode bit that must be set (40H writable, 20H readable). Random files are not allowed. The current position becomes the record start.
5F38
CP 23H FE 23
Compare Register A, the character at the text pointer, against 23H (#). The Z FLAG is set for #. 5F34H comes here.
5F3A
RET NZ C0
If the NZ FLAG is set (no #: the screen or the keyboard), RETurn to the ROM.
5F3B
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer: Register C = the mode bit wanted.
5F3C
GOSUB to 62C0H to read the file number and the comma and set up the file statement: Register A returns the mode byte (5700H) and Register Pair HL the text pointer after the comma.
5F3F
BIT 7,A CB 7F
Test bit 7 of Register A, the mode byte: random. The NZ FLAG is set for a random file.
5F41
POP BC C1
Restore Register Pair BC from the stack at the Stack Pointer: Register C = the mode bit wanted. POP does not change the flags.
5F42
If the NZ FLAG is set (a random file), JUMP to 5DA9H, BAD FILE MODE.
5F45
AND C A1
AND Register A (the mode byte) with Register C (the bit wanted): the Z FLAG is set when the file cannot be used this way (or is not open).
5F46
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack at the Stack Pointer.
5F47
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A for the ROM. LD does not change the flags.
5F48
If the Z FLAG is set (not allowed), JUMP to 5DA9H, BAD FILE MODE.
5F4B
GOSUB to 61ACH: Registers C, L and H return the current position NEXT.
5F4E
GOSUB to 6117H to store Registers C, L and H as the record start at 5707H-5709H and set bit 6 of 5701H.
5F51
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
5F52
RET C9
RETurn to the ROM's PRINT or INPUT, whose characters now go through the file's links.
5F53H - Read a File Number
Reads [#]n at Register Pair HL. Register Pair BC returns the address of file area n (66BEH + (n - 1) x the area size at 649EH-649FH) and Register A its mode byte, with the Z FLAG when the file is not open. An n of 0 or above the number of areas (the operand at 5F62H) is BAD FILE #. 5F5DH starts with the number already evaluated, 5F61H with the area number already in Register A.
5F53
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H reads the current character again. 5E3CH, 5F7CH and 6295H call here.
5F54
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A.
5F55
CP 23H FE 23
Compare Register A against 23H (#). The Z FLAG is set when a # comes before the number.
5F57
If the Z FLAG is set (a #), GOSUB to ROM 1D78H, the RST 10H code, to step past it.
5F5A
GOSUB to ROM 2337H to evaluate the file number at Register Pair HL into the ROM's accumulator; Register Pair HL returns past it.
5F5D
GOSUB to ROM 2B1FH, which turns the value in the ROM's accumulator into a byte in Register A (ILLEGAL FUNCTION CALL past 255). 5FCAH calls here.
5F60
DEC A 3D
DECrement Register A, the file number: the areas are counted from 0 (a file number of 0 becomes FFH).
5F61
CP 00H FE 00
Self-Modifying Code
Compare Register A (the area number) against the operand at 5F62H, the number of file areas, stored at 6503H when BASIC starts (00H in the file). The NO CARRY FLAG is set when the area does not exist. 5FABH calls here.
5F63
If the NO CARRY FLAG is set (a file number of 0 or too high), JUMP to 5DA6H, BAD FILE #.
5F66
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack at the Stack Pointer.
5F67
LD HL,66BEH 21 BE 66
Point Register Pair HL to 66BEH, the first file area.
5F6A
LD BC,(649EH) ED 4B 9E 64
Load Register Pair BC with the size of one file area from 649EH-649FH.
5F6E
OR A B7
OR Register A (the area number) with itself: the Z FLAG is set for area 0.
5F6F
If the Z FLAG is set (area 0), JUMP to 5F75H with Register Pair HL = 66BEH.
5F71
ADD HL,BC 09
ADD Register Pair BC (the size of one area) to Register Pair HL: the next area. 5F73H loops back here.
5F72
DEC A 3D
DECrement Register A, the areas still to step over.
5F73
If the NZ FLAG is set (areas left), LOOP BACK to 5F71H.
5F75
OR (HL) B6
OR the area's mode byte at Register Pair HL into Register A (00H): the Z FLAG is set when the file is not open. 5F6FH comes here.
5F76
LD B,H 44
Copy Register H (the high byte of the area's address) into Register B.
5F77
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the file area.
5F78
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
5F79
RET C9
RETurn with Register Pair BC = the area and Register A = its mode byte. The links 41D0H and 41E2H (the JP 5F79H at 6839H and 684BH) come here too and only return.
5F7AH - CLOSE Statement
CLOSE link (4185H, from the JP 5F7AH at 67EEH). CLOSE alone closes all files (5F8FH); CLOSE n, m, ... closes the ones named.
5F7A
If the Z FLAG is set (nothing follows CLOSE), JUMP to 5F8FH to close every file.
5F7C
GOSUB to 5F53H to read a file number at Register Pair HL: Register Pair BC returns the area. 5F85H loops back here.
5F7F
GOSUB to 5F8BH to close the file area at Register Pair BC.
5F82
GOSUB to 6368H: the Z FLAG when the statement ends, else a comma must follow (NZ, Register Pair HL past it).
5F85
If the NZ FLAG is set (another number follows), LOOP BACK to 5F7CH.
5F87
RET C9
RETurn to the ROM's statement loop with the files named closed.
5F88H - Close the Work Area File
Called at 6449H for a file that LOAD, RUN, MERGE, SAVE or KILL opened in the work area at 5700H.
5F88
LD BC,5700H 01 00 57
Load Register Pair BC with 5700H, the work area, and fall into 5F8BH.
5F8BH - Close One File Area
Register Pair BC = the file area. The close at 5FAEH is followed by the loop at 5FA7H, which returns at once because the count pushed here is 0.
5F8B
XOR A AF
Set Register A to 00H: no further areas after this one.
5F8C
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A (00H) is the count that 5FC6H takes back.
5F8D
JUMP to 5FAEH to close the area at Register Pair BC.
5F8FH - Close All Files
Link 41BBH (from the JP 5F8FH at 6824H), called by the ROM for NEW and END (1B8CH, 1DB0H), and by CLOSE without numbers. Nothing is done when no area is open. SYS19/SYS can store a RET (C9H) at 5FA8H (its 5224H), so that no file is closed; 644FH puts back the RET Z.
5F8F
LD A,(5F62H) 3A 62 5F
Fetch the number of file areas from 5F62H (the operand stored at 6503H) into Register A.
5F92
OR A B7
OR Register A with itself: the Z FLAG is set when there are no file areas.
5F93
RET Z C8
If the Z FLAG is set, RETurn: there is nothing to close.
5F94
PUSH HL E5
Save Register Pair HL (the caller's value) onto the stack at the Stack Pointer.
5F95
LD B,A 47
Copy Register A (the number of areas) into Register B, the counter of the search.
5F96
LD C,A 4F
Copy Register A (the number of areas) into Register C, the counter of the closing loop.
5F97
LD HL,66BEH 21 BE 66
Point Register Pair HL to 66BEH, the first file area.
5F9A
GOSUB to 65AFH: Register Pair DE returns the size of one file area from 649EH-649FH.
Loop: look for an open area.
5F9D
LD A,(HL) 7E
Fetch the area's mode byte at Register Pair HL into Register A. 5FA2H loops back here.
5F9E
OR A B7
OR Register A with itself: the NZ FLAG is set for an open area.
5F9F
If the NZ FLAG is set (an open area), JUMP to 5FA4H.
5FA1
ADD HL,DE 19
ADD Register Pair DE (the size of one area) to Register Pair HL: the next area.
5FA2
DECrement Register B (the areas left) and LOOP BACK to 5F9DH. When it ends Register A is 00H with the Z FLAG.
5FA4
POP HL E1
Restore Register Pair HL (the caller's value) from the stack at the Stack Pointer. 5F9FH comes here.
5FA5
RET Z C8
If the Z FLAG is set (no area is open), RETurn.
5FA6
LD A,C 79
Copy Register C (the number of areas) into Register A, the counter of the closing loop.
Loop: close the areas from the last to the first.
5FA7
OR A B7
OR Register A (the areas left) with itself: the Z FLAG is set when all are done. 5FC7H loops back here.
5FA8
RET Z C8
If the Z FLAG is set, RETurn. SYS19/SYS stores another opcode here at its 5224H (C9H, RET, when no file is to be closed); 644FH stores C8H again.
5FA9
DEC A 3D
DECrement Register A: the number of the next area to close, counted from 0.
5FAA
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the area number, the count for the loop.
5FAB
GOSUB to 5F61H with Register A = the area number: Register Pair BC returns the area's address.
5FAEH - Close the Area in Register Pair BC
A writable file is closed through SYS0/SYS 4428H; the 2DH-byte header is cleared either way. Then the loop at 5FA7H goes on with the next area.
5FAE
PUSH HL E5
Save Register Pair HL (the caller's value) onto the stack at the Stack Pointer. 5F8DH comes here.
5FAF
LD HL,000DH 21 0D 00
Load Register Pair HL with 000DH, the offset of the FCB in a file area.
5FB2
ADD HL,BC 09
ADD Register Pair BC (the area) to Register Pair HL: the area's FCB at the area + 0DH.
5FB3
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the FCB.
5FB4
LD H,B 60
Copy Register B (the high byte of the area's address) into Register H.
5FB5
LD L,C 69
Copy Register C into Register L: Register Pair HL = the area.
5FB6
BIT 6,(HL) CB 76
Test bit 6 of the mode byte at Register Pair HL: the NZ FLAG is set for a writable file.
5FB8
If the NZ FLAG is set (writable), GOSUB to SYS0/SYS 4428H to close the file of the FCB at Register Pair DE (the last sector and the directory are written); it returns the Z FLAG or the NZ FLAG with a DOS error in Register A.
5FBB
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: the result of the close and its flags.
5FBC
LD B,2DH 06 2D
Load Register B with 2DH, the 45 bytes of the area's header.
5FBE
GOSUB to 6362H to clear Register B bytes at Register Pair HL: the area's header is 00H, so the area is free.
5FC1
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: the result of the close.
5FC2
If the NZ FLAG is set (the close failed), JUMP to 5DEFH with the DOS error code in Register A.
5FC5
POP HL E1
Restore Register Pair HL (the caller's value) from the stack at the Stack Pointer.
5FC6
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the areas still to close (00H after 5F8BH).
5FC7
LOOP BACK to 5FA7H to close the next area, if any is left.
5FC9H - EOF, LOF and LOC: Read the File's Position
Called from 5EBFH with Register B = the selector (01H EOF, 02H LOF, 04H LOC, 08H LOC#, 10H LOC!, 20H LOC%, 40H LOC$). Returns a 24-bit value in Registers H (high), L and C (low); for EOF and LOC$ it finishes the function itself with -1 or 0 (600DH).
5FC9
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer: Register B = the selector.
5FCA
GOSUB to 5F5DH: the file number was already evaluated by the ROM into its accumulator; Register Pair BC returns the file area and Register A its mode byte.
5FCD
GOSUB to 6298H to set up a file statement on the area at Register Pair BC (its header copied to 5700H, Index Register IX = 5700H); Register A returns the mode byte with the Z FLAG when the file is not open.
5FD0
If the Z FLAG is set (the file is not open), JUMP to 5DA9H, BAD FILE MODE.
5FD3
POP BC C1
Restore Register Pair BC from the stack at the Stack Pointer: Register B = the selector.
5FD4
LD DE,(5700H) ED 5B 00 57
Load Register Pair DE from 5700H-5701H: Register E = the mode byte, Register D = the flags byte.
5FD8
GOSUB to 61B3H: Register A returns the low byte of the end of file and Register Pair HL its middle and high bytes.
5FDB
LD C,A 4F
Copy Register A (the low byte of EOF) into Register C: Registers H, L and C = the end of file.
5FDC
LD A,B 78
Copy Register B, the selector, into Register A.
5FDD
AND 22H E6 22
AND Register A with 22H, keeping LOF (02H) and LOC% (20H). The NZ FLAG is set for them.
5FDF
RET NZ C0
If the NZ FLAG is set (LOF or LOC%), RETurn with the end of file in Registers H, L and C.
5FE0
BIT 3,B CB 58
Test bit 3 of Register B, the selector: LOC# (08H).
5FE2
If the NZ FLAG is set (LOC#), JUMP to 6129H, which returns the start of the current record from 5707H-5709H.
5FE5
GOSUB to 61ACH: Registers C, L and H return the current position NEXT.
5FE8
BIT 6,D CB 72
Test bit 6 of Register D, the flags byte (5701H): the start of the current record is known.
5FEA
If the Z FLAG is set (no record yet), JUMP to 6028H.
5FEC
BIT 7,E CB 7B
Test bit 7 of Register E, the mode byte: a random file.
5FEE
If the Z FLAG is set (not random), JUMP to 600DH with the current position.
5FF0
GOSUB to 6122H: Registers C, L and H return the position where the last GET or PUT ended (5704H-5706H).
5FF3
BIT 3,E CB 5B
Test bit 3 of Register E, the mode byte (record segmented file types).
5FF5
If the Z FLAG is set (not record segmented), JUMP to 600DH with that position.
5FF7
BIT 2,E CB 53
Test bit 2 of Register E, the mode byte: fixed-length records.
5FF9
If the NZ FLAG is set (fixed-length records), JUMP to 600AH.
5FFB
Records of varying length: GOSUB to 61A6H to position the file at Registers C, L and H.
Loop: pass over items until the next record starts or the end of file is reached.
5FFE
GOSUB to 6031H to compare the current position with the end of file: the CARRY FLAG is set while it is below. 6006H loops back here.
6001
If the NO CARRY FLAG is set (at or past the end of file), JUMP to 600DH.
6003
GOSUB to 6258H to read an item marker and pass over the item; the NZ FLAG is set for anything but a record start.
6006
If the NZ FLAG is set (not a record start), LOOP BACK to 5FFEH.
6008
JUMP to 600DH with the position of the record start in Registers H, L and C.
600A
GOSUB to 603EH: Registers H, L and C return the next record's position, the record start plus the record length. 5FF9H comes here.
600DH - EOF and LOC$ Results
EOF is -1 only exactly at the end of file; LOC$ is -1 at or past it. The other selectors return the position in Registers H, L and C.
600D
LD A,B 78
Copy Register B, the selector, into Register A. 5FEEH, 5FF5H, 6001H, 6008H and 602AH come here.
600E
AND 41H E6 41
AND Register A with 41H, keeping EOF (01H) and LOC$ (40H). The Z FLAG is set for the others.
6010
RET Z C8
If the Z FLAG is set, RETurn with the position in Registers H, L and C.
6011
POP DE D1
POP the return address into 5EC2H from the stack at the Stack Pointer into Register Pair DE, dropping it: the result is made here.
6012
GOSUB to 6034H to compare the position in Registers H, L and C with the end of file: the Z FLAG when equal, the CARRY FLAG when below.
6015
LD A,FFH 3E FF
Load Register A with FFH, which becomes the integer -1. LD does not change the flags.
6017
If the Z FLAG is set (exactly at the end of file), JUMP to 6021H with Register A = FFH.
6019
If the CARRY FLAG is set (below the end of file), JUMP to 601FH for 0.
601B
BIT 6,B CB 70
Past the end of file: test bit 6 of Register B, the selector (LOC$).
601D
If the NZ FLAG is set (LOC$), JUMP to 6021H with Register A = FFH.
601F
LD A,00H 3E 00
Load Register A with 00H, which becomes the integer 0 (below the end, or EOF past it). 6019H comes here.
6021
LD HL,6357H 21 57 63
Point Register Pair HL to 6357H, the code that ends the file function. 6017H and 601DH come here.
6024
PUSH HL E5
Push Register Pair HL (6357H) onto the stack at the Stack Pointer as the return address.
6025
JUMP to ROM 098DH, which turns Register A (00H or FFH) into the integer 0 or -1 in the ROM's accumulator and returns to 6357H.
6028H - LOC Without a Known Record
Plain LOC (04H) gives 0 when no record has been read or written yet; the other selectors go on with the current position.
6028
BIT 2,B CB 50
Test bit 2 of Register B, the selector: plain LOC (04H). 5FEAH comes here.
602A
If the Z FLAG is set (not plain LOC), JUMP to 600DH with the current position.
602C
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the high and middle bytes of the value 0.
602F
LD C,L 4D
Copy Register L (00H) into Register C: Registers H, L and C = 0.
6030
RET C9
RETurn with the value 0 in Registers H, L and C.
6031H - Compare a Position With the End of File
6031H compares the current position NEXT, 6034H the position in Registers H, L and C, with the end of file: the Z FLAG when equal, the CARRY FLAG when below.
6031
GOSUB to 61ACH: Registers C, L and H return the current position NEXT. 5FFEH calls here.
6034
GOSUB to 61BDH: Register Pair DE returns the middle and high bytes of the end of file. 6012H and 615EH call here.
6037
RST 18H DF
RST 18H compares Register Pair HL (the position's high and middle bytes) with Register Pair DE (those of the end of file): the Z FLAG when equal, the CARRY FLAG when lower.
6038
RET NZ C0
If the NZ FLAG is set (they differ), RETurn with the CARRY FLAG from the compare.
6039
LD A,C 79
Copy Register C, the low byte of the position, into Register A.
603A
CP (IX+15H) DD BE 15
Compare Register A against the low byte of the end of file at Index Register IX+15H (5715H, FCB+8 of the work area's FCB).
603D
RET C9
RETurn with the Z FLAG when the position is at the end of file and the CARRY FLAG when below.
603EH - Next Record Position
Registers H, L and C = the start of the current record (5707H-5709H) plus the record length (5702H-5703H).
603E
LD HL,(5707H) 2A 07 57
Load Register Pair HL with the low and middle bytes of the record start from 5707H-5708H. 600AH calls here.
6041
LD DE,(5702H) ED 5B 02 57
Load Register Pair DE with the record length from 5702H-5703H.
6045
ADD HL,DE 19
ADD Register Pair DE (the record length) to Register Pair HL. The CARRY FLAG is set on a carry into the high byte.
6046
LD A,(5709H) 3A 09 57
Fetch the high byte of the record start from 5709H into Register A.
6049
ADC A,00H CE 00
ADD the CARRY FLAG to Register A (ADC 00H): the high byte of the sum.
604B
LD C,L 4D
Copy Register L, the low byte of the sum, into Register C.
604C
LD L,H 6C
Copy Register H, the middle byte, into Register L.
604D
LD H,A 67
Copy Register A, the high byte, into Register H.
604E
RET C9
RETurn with the next record's position in Registers H, L and C.
604FH - Link 41C1H (Output a Character to a File)
Link 41C1H (from the JP 604FH at 682AH), called by the ROM's character output at 032CH with the character in Register A. During a file statement the character goes to the file when it is writable, and the print column at 570AH is kept: printable characters count, 0DH sets it to 0.
604F
GOSUB to 6382H: when no file statement is running it drops this call and returns straight to the ROM; otherwise it returns here.
6052
EX (SP),HL E3
Exchange Register Pair HL with the ROM's return address on the stack at the Stack Pointer: the caller's Register Pair HL is kept there and Register Pair HL = the return address, dropped at 6071H.
6053
PUSH DE D5
Save Register Pair DE (the caller's value) onto the stack at the Stack Pointer.
6054
LD HL,5700H 21 00 57
Point Register Pair HL to 5700H, the mode byte of the file statement's area.
6057
BIT 6,(HL) CB 76
Test bit 6 of the mode byte at Register Pair HL (5700H): writable.
6059
If the Z FLAG is set (not writable), JUMP to 606FH: the character is dropped.
605B
LD HL,570AH 21 0A 57
Point Register Pair HL to 570AH, the file's print column.
605E
INC (HL) 34
INCrement the print column at Register Pair HL (570AH): the character is counted.
605F
CP 20H FE 20
Compare Register A, the character, against 20H, the first printable code. The NO CARRY FLAG is set for a printable character.
6061
If the NO CARRY FLAG is set (printable), JUMP to 606AH.
6063
DEC (HL) 35
DECrement the print column at Register Pair HL (570AH): a control character does not count.
6064
CP 0DH FE 0D
Compare Register A, the character, against 0DH, a carriage return. The Z FLAG is set for it.
6066
If the NZ FLAG is set (another control character), JUMP to 606AH.
6068
LD (HL),00H 36 00
Store 00H at Register Pair HL (570AH): a carriage return puts the print column back to 0.
606A
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the character. 6061H and 6066H come here.
606B
GOSUB to 6205H to write the character in Register A to the file (ROM 001BH through the FCB at 570DH).
606E
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the character.
606F
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer. 6059H comes here.
6070
POP HL E1
Restore Register Pair HL (the caller's value) from the stack at the Stack Pointer.
6071
POP BC C1
POP into Register Pair BC the word now on the stack at the Stack Pointer, the ROM's return address put there by 6052H, dropping it.
6072
RET C9
RETurn past the ROM's own output to the caller of 032CH: the character went to the file instead of the screen.
6073H - Open a File in the Work Area
6073H opens for LOAD, RUN, MERGE and KILL with Register B = 01H (existing file only) and Register C = 20H (readable); 6076H takes the mode in Register Pair BC (SAVE: 8440H).
6073
LD BC,0120H 01 20 01
Load Register Pair BC with 0120H: Register B = 01H (an existing file only), Register C = 20H (readable). 572EH, 574CH and 6415H call here.
6076H - Open the File Named in the Statement
The work area 5700H is cleared and becomes the statement's file area; bit 7 of 572DH marks it as a work area file (buffer 4300H, closed at 6449H). The filespec is copied to the FCB at 570DH and opened: Register B bit 0 = an existing file only (SYS0/SYS 4424H), else a new or existing one (4420H); bit 2 empties the file, bit 1 starts at its end. Register C becomes the mode byte, Register B AND F8H the flags.
6076
PUSH BC C5
Save Register Pair BC (the open mode) onto the stack at the Stack Pointer. 573EH calls here with 8440H.
6077
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack at the Stack Pointer.
6078
GOSUB to 635AH to clear the file statement flag at 6382H and the work area 5700H-572DH.
607B
LD BC,5700H 01 00 57
Load Register Pair BC with 5700H, the work area.
607E
GOSUB to 6298H to make the area at Register Pair BC (5700H) the statement's file area: Index Register IX = 5700H and the file statement flag is set.
6081
SET 7,(IX+2DH) DD CB 2D FE
Set bit 7 of 572DH at Index Register IX+2DH: the file lives in the work area.
6085
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
6086
POP BC C1
Restore Register Pair BC (the open mode) from the stack at the Stack Pointer.
6087
PUSH BC C5
Save Register Pair BC (the open mode) onto the stack at the Stack Pointer again.
6088
LD A,(5700H) 3A 00 57
Fetch the mode byte of the work area at 5700H into Register A.
608B
OR A B7
OR Register A with itself: the NZ FLAG is set when the area is already open.
608C
If the NZ FLAG is set, JUMP to 5DACH, FILE ALREADY OPEN.
608F
GOSUB to ROM 2337H to evaluate the filespec expression at Register Pair HL into the ROM's accumulator; Register Pair HL returns past it.
6092
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with the open mode on the stack at the Stack Pointer: Register Pair HL = the mode, the text pointer is kept on the stack.
6093
PUSH HL E5
Push Register Pair HL (the open mode) onto the stack at the Stack Pointer.
6094
GOSUB to 5C99H to take the string from the ROM's accumulator: Register A returns its length and Register Pair DE the address of its text.
6097
CP 20H FE 20
Compare Register A, the filespec's length, against 20H. The NO CARRY FLAG is set for 32 characters or more.
6099
If the NO CARRY FLAG is set (too long for the FCB), JUMP to 5DB5H, BAD FILE NAME.
609C
LD HL,570DH 21 0D 57
Point Register Pair HL to 570DH, the FCB, where the filespec goes.
609F
PUSH HL E5
Save Register Pair HL (570DH) onto the stack at the Stack Pointer.
60A0
GOSUB to 5CB7H to copy Register A bytes of the filespec from Register Pair DE to the FCB at Register Pair HL; Register Pair HL returns after them.
60A3
POP DE D1
POP into Register Pair DE the FCB address 570DH from the stack at the Stack Pointer, for the open.
60A4
LD (HL),00H 36 00
Store 00H at Register Pair HL, after the filespec, to end it.
60A6
LD HL,(6352H) 2A 52 63
Load Register Pair HL with the file area's address from 6352H-6353H, the operand of the LD DE at 6351H stored by 62A2H (5700H here).
60A9
LD BC,002DH 01 2D 00
Load Register Pair BC with 002DH, the offset of the buffer in a file area.
60AC
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the area's own buffer at the area + 2DH.
60AD
BIT 7,(IX+2DH) DD CB 2D 7E
Test bit 7 of 572DH at Index Register IX+2DH: a work area file.
60B1
If the Z FLAG is set (an ordinary file area), JUMP to 60B6H with its own buffer.
60B3
LD HL,4300H 21 00 43
A work area file: point Register Pair HL to 4300H, SYS0/SYS's sector buffer, as the file's buffer (the work area has no buffer of its own).
60B6
POP BC C1
Restore Register Pair BC (the open mode) from the stack at the Stack Pointer. 60B1H comes here.
60B7
BIT 0,B CB 40
Test bit 0 of Register B, the mode's high byte: an existing file only.
60B9
PUSH BC C5
Save Register Pair BC (the open mode) onto the stack at the Stack Pointer.
60BA
LD B,00H 06 00
Load Register B with 00H, the record length for the open: 256 bytes. LD does not change the flags.
60BC
If the NZ FLAG is set (an existing file only), JUMP to 60C3H.
60BE
GOSUB to SYS0/SYS 4420H to open a new or an existing file through the FCB at Register Pair DE with the buffer at Register Pair HL and the record length in Register B.
60C1
JUMP to 60C6H to check the result of the open in the flags and Register A.
60C3
GOSUB to SYS0/SYS 4424H to open an existing file through the FCB at Register Pair DE with the buffer at Register Pair HL; it returns the NZ FLAG with a DOS error when the file is missing. 60BCH comes here.
60C6
If the NZ FLAG is set (the open failed), JUMP to 5DEFH with the DOS error code in Register A. 60C1H comes here.
60C9
XOR A AF
Set Register A to 00H, the low byte of position 0.
60CA
LD H,A 67
Copy Register A (00H) into Register H, the high byte of the position.
60CB
LD L,A 6F
Copy Register A (00H) into Register L: Registers A, H and L = position 0.
60CC
POP BC C1
Restore Register Pair BC (the open mode) from the stack at the Stack Pointer.
60CD
BIT 2,B CB 50
Test bit 2 of Register B, the mode's high byte: empty the file.
60CF
If the NZ FLAG is set, GOSUB to 60EBH to set the end of file to 0 (Registers A, H and L).
60D2
BIT 1,B CB 48
Test bit 1 of Register B: start at the end of the file.
60D4
If the NZ FLAG is set, GOSUB to 61B3H: Register A and Register Pair HL return the end of file.
60D7
LD (5717H),HL 22 17 57
Store Register Pair HL (the middle and high bytes of the starting position) at 5717H-5718H, FCB+10 and FCB+11, NEXT.
60DA
LD (5712H),A 32 12 57
Store Register A (the low byte of the starting position) at 5712H, FCB+5, NEXT's low byte.
60DD
LD A,B 78
Copy Register B, the mode's high byte, into Register A.
60DE
AND F8H E6 F8
AND Register A with F8H, keeping bits 7-3 as the file's flags.
60E0
LD B,A 47
Copy Register A (the file's flags, bits 7-3) into Register B.
60E1
LD (5700H),BC ED 43 00 57
Store Register Pair BC at 5700H-5701H: Register C (the mode, 20H or 40H) at 5700H and Register B (the flags) at 5701H.
60E5
SET 6,(IX+0EH) DD CB 0E F6
Set bit 6 of FCB+1 at Index Register IX+0EH (570EH).
60E9
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
60EA
RET C9
RETurn with the file open in the work area at 5700H and Register Pair DE = 570DH, its FCB.
60EBH - Set the End of File
Stores Register A (the low byte) and Register Pair HL (the middle and high bytes) as the end of file: FCB+8 at 5715H and FCB+12-13 at 5719H-571AH.
60EB
LD (5719H),HL 22 19 57
Store Register Pair HL (the middle and high bytes of the end of file) at 5719H-571AH, FCB+12 and FCB+13. 60CFH calls here.
60EE
LD (5715H),A 32 15 57
Store Register A (the low byte of the end of file) at 5715H, FCB+8.
60F1
RET C9
RETurn with the end of file set from Register A and Register Pair HL.
60F2H - Read a Byte From the Work Area File
Called by SYS19/SYS (its 536CH) and SYS20/SYS (its 5629H, 56A7H) to read text files: ROM 0013H through the FCB at 570DH. Returns the Z FLAG with the byte in Register A; at the end of file (DOS errors 1CH and 1DH) the NZ FLAG with the code in Register A (6379H); other errors go to 5DEFH.
60F2
PUSH DE D5
Save Register Pair DE (the caller's value) onto the stack at the Stack Pointer.
60F3
LD DE,570DH 11 0D 57
Point Register Pair DE to 570DH, the work area's FCB.
60F6
GOSUB to ROM 0013H to read a byte from the device or file whose control block is at Register Pair DE (an FCB goes through 4033H to SYS0/SYS 4A80H): Register A returns the byte with the Z FLAG, or a DOS error code with the NZ FLAG.
60F9
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer.
60FA
RET Z C8
If the Z FLAG is set (a byte was read), RETurn with it in Register A.
60FB
JUMP to 6379H to check the DOS error code in Register A.
60FEH - PUT and GET Statements
The links for PUT (4182H, from the JP 60FEH at 67EBH) and GET (417FH, JP 60FFH at 67E8H). The mark (the NZ FLAG for PUT, the Z FLAG for GET) is pushed, the file statement is set up, SYS10/SYS is loaded and its GET and PUT code at 4D03H does the work.
Overlapping Instructions
PUT enters at 60FEH, where F6H AFH is OR AFH (the NZ FLAG). GET enters at 60FFH, where the byte AFH is XOR A (the Z FLAG).
60FE
OR AFH F6 AF
PUT entry (4182H): OR Register A with AFH, so that Register A is not 0 and the Z FLAG is clear, the mark of PUT. GET (417FH) enters at 60FFH, where AFH is XOR A: Register A = 00H with the Z FLAG, the mark of GET.
6100
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: the Z FLAG tells GET from PUT.
6101
GOSUB to 6295H to read the file number at Register Pair HL and set up the file statement (the area's header at 5700H, Index Register IX = 5700H).
6104
GOSUB to 610AH to load SYS10/SYS and keep the current position at 5704H-5706H.
6107
JUMP to 4D03H, SYS10/SYS's GET and PUT code, with the GET or PUT mark on the stack.
610AH - Load SYS10/SYS and Keep the Position
RST 28H with the code 2CH loads SYS10/SYS (its entry at 4D00H returns at once). Then the current position NEXT is stored at 5704H-5706H. Also called from 6228H to load SYS10/SYS again after a DOS call has used the overlay area.
610A
LD A,2CH 3E 2C
Load Register A with 2CH, the RST 28H code of SYS10/SYS. 6104H and 6228H call here.
610C
RST 28H EF
RST 28H with Register A = 2CH: SYS0/SYS loads SYS10/SYS into 4D00H-51E7H unless it is there already (4288H) and calls its entry, which returns.
610D
GOSUB to 61ACH: Registers C, L and H return the current position NEXT from the FCB.
6110
LD (IX+04H),C DD 71 04
Store Register C (the low byte of the position) at Index Register IX+04H, 5704H.
6113
LD (5705H),HL 22 05 57
Store Register Pair HL (the middle and high bytes) at 5705H-5706H.
6116
RET C9
RETurn with the position stored at 5704H-5706H.
6117H - Store the Record Start
Stores Registers C, L and H at 5707H-5709H and sets bit 6 of 5701H (the start of the record is known). Used by PRINT # and INPUT # (5F4EH) and by SYS10/SYS.
6117
LD (IX+07H),C DD 71 07
Store Register C (the low byte of the position) at Index Register IX+07H, 5707H.
611A
LD (5708H),HL 22 08 57
Store Register Pair HL (the middle and high bytes) at 5708H-5709H.
611D
SET 6,(IX+01H) DD CB 01 F6
Set bit 6 of 5701H at Index Register IX+01H: the record start is known.
6121
RET C9
RETurn with the record start stored at 5707H-5709H.
6122H - Read Where the Last GET or PUT Ended
Registers C, L and H = the position at 5704H-5706H.
6122
LD C,(IX+04H) DD 4E 04
Load Register C with the low byte of the position from Index Register IX+04H, 5704H. 5FF0H and 61A3H come here.
6125
LD HL,(5705H) 2A 05 57
Load Register Pair HL with the middle and high bytes from 5705H-5706H.
6128
RET C9
RETurn with the position in Registers C, L and H.
6129H - Read the Record Start
Registers C, L and H = the record start at 5707H-5709H; BAD FILE MODE when bit 6 of 5701H is clear (no record yet). 612FH only makes the check.
6129
LD C,(IX+07H) DD 4E 07
Load Register C with the low byte of the record start from Index Register IX+07H, 5707H. 5FE2H comes here.
612C
LD HL,(5708H) 2A 08 57
Load Register Pair HL with the middle and high bytes from 5708H-5709H.
612F
BIT 6,(IX+01H) DD CB 01 76
Test bit 6 of 5701H at Index Register IX+01H: the record start is known.
6133
RET NZ C0
If the NZ FLAG is set (it is known), RETurn with it in Registers C, L and H.
6134
JUMP to 615BH, BAD FILE MODE: no record has been read or written.
6136H - String Item Marker (SYS10/SYS)
For SYS10/SYS writing a string item. Register B = the string's length; the value at 5094H (inside SYS10/SYS) limits it. Returns Register B = the length to write and Register A = the marker 80H + the length; for 128 bytes or more the marker 71H is written first (61C8H) and Register A = the length.
6136
LD A,(5094H) 3A 94 50
Fetch the limit from 5094H, a byte inside SYS10/SYS, into Register A.
6139
CP B B8
Compare Register A (the limit) against Register B (the string's length). The CARRY FLAG is set when the limit is smaller.
613A
If the CARRY FLAG is set, JUMP to 613DH with the limit in Register A.
613C
LD A,B 78
Copy Register B (the string's length) into Register A.
613D
LD B,A 47
Copy Register A (the length to write) into Register B. 613AH comes here.
613E
ADD A,80H C6 80
ADD 80H to Register A: the one-byte marker 80H + the length. The CARRY FLAG is set for 128 bytes or more.
6140
RET NC D0
If the NO CARRY FLAG is set (below 128 bytes), RETurn with the marker in Register A and the length in Register B.
6141
LD A,71H 3E 71
128 bytes or more: load Register A with 71H, the marker of a string with a separate length byte.
6143
LD C,B 48
Copy Register B (the length) into Register C to keep it.
6144
LD B,00H 06 00
Load Register B with 00H: no data bytes after the marker.
6146
GOSUB to 61C8H to write the marker in Register A with Register B = 0 data bytes.
6149
LD B,C 41
Copy Register C (the length) back into Register B.
614A
LD A,B 78
Copy Register B (the length) into Register A, the length byte to write next.
614B
RET C9
RETurn with Register A = Register B = the length.
614CH - Check the Mode for GET and PUT (SYS10/SYS)
The file must be random (bit 7 of 5700H), and readable for GET or writable for PUT (bit 4 marks a PUT); otherwise BAD FILE MODE. Returns with the CARRY FLAG when allowed.
614C
LD DE,(5700H) ED 5B 00 57
Load Register Pair DE from 5700H-5701H: Register E = the mode byte, Register D = the flags byte.
6150
LD A,E 7B
Copy Register E, the mode byte, into Register A.
6151
RLCA 07
Rotate Register A left: bit 7 (random) goes into the CARRY FLAG.
6152
If the NO CARRY FLAG is set (not random), JUMP to 615BH, BAD FILE MODE.
6154
BIT 5,A CB 6F
Test bit 5 of Register A, which is bit 4 of the mode byte, the PUT mark.
6156
If the NZ FLAG is set (a PUT), JUMP to 6159H.
6158
RLCA 07
A GET: rotate Register A left once more, so that bit 5 (readable) comes next.
6159
RLCA 07
Rotate Register A left: the CARRY FLAG = bit 6 of the mode (writable) for a PUT, bit 5 (readable) for a GET. 6156H comes here.
615A
RET C D8
If the CARRY FLAG is set (the file allows the GET or PUT), RETurn.
615B
JUMP to 5DA9H, BAD FILE MODE. 6134H and 6152H come here.
615EH - PUT at or Past the End of File (SYS10/SYS)
Registers C, L and H = the position of the PUT. At or past the end of file bit 4 of 572DH is set; past it the file must have fixed-length records (else BAD FILE POSITIONING PARAM), and a file with type bits 1-0 not 00 is filled with records of 00H bytes up to the position.
615E
GOSUB to 6034H to compare the position in Registers H, L and C with the end of file: the Z FLAG when equal, the CARRY FLAG when below. 6183H loops back here.
6161
RET C D8
If the CARRY FLAG is set (below the end of file), RETurn.
6162
SET 4,(IX+2DH) DD CB 2D E6
Set bit 4 of 572DH at Index Register IX+2DH: the PUT is at or past the end of file.
6166
RET Z C8
If the Z FLAG is set (exactly at the end of file), RETurn.
6167
LD A,(IX+00H) DD 7E 00
Fetch the mode byte from Index Register IX+00H (5700H) into Register A.
616A
BIT 2,A CB 57
Test bit 2 of Register A: fixed-length records.
616C
If the Z FLAG is set (not fixed), JUMP to 5DDCH, BAD FILE POSITIONING PARAM.
616F
AND 03H E6 03
AND Register A with 03H, keeping the type bits 1-0.
6171
RET Z C8
If the Z FLAG is set (type bits 00), RETurn: nothing is filled in.
6172
PUSH HL E5
Save Register Pair HL (the middle and high bytes of the position) onto the stack at the Stack Pointer.
6173
PUSH BC C5
Save Register Pair BC (Register C = the low byte of the position) onto the stack at the Stack Pointer.
6174
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the middle and high bytes of the end of file (from 6034H).
6175
LD C,(IX+15H) DD 4E 15
Load Register C with the low byte of the end of file from Index Register IX+15H, 5715H.
6178
GOSUB to 61A6H to position the file at the end of file in Registers C, L and H.
617B
LD HL,(5702H) 2A 02 57
Load Register Pair HL with the record length from 5702H-5703H.
617E
GOSUB to 6188H to write Register Pair HL bytes of 00H: one empty record.
6181
POP BC C1
Restore Register Pair BC (Register C = the low byte of the position) from the stack at the Stack Pointer.
6182
POP HL E1
Restore Register Pair HL (the middle and high bytes of the position) from the stack at the Stack Pointer.
6183
LOOP BACK to 615EH until the end of file reaches the position.
6185H - Write 00H Bytes
Writes Register Pair HL bytes of 00H to the file (6188H writes the first byte without testing the count).
6185
LD A,H 7C
Copy Register H, the high byte of the count, into Register A. 618EH loops back here; 632EH calls here.
6186
OR L B5
OR Register L into Register A: the Z FLAG is set when no bytes are left.
6187
RET Z C8
If the Z FLAG is set (Register Pair HL is 0000H), RETurn.
6188
XOR A AF
Set Register A to 00H, the byte to write. 617EH calls here.
6189
LD B,A 47
Copy Register A (00H) into Register B: no data bytes after it.
618A
GOSUB to 61DFH to write the byte in Register A (and Register B data bytes, none).
618D
DEC HL 2B
DECrement Register Pair HL, the count of 00H bytes still to write.
618E
LOOP BACK to 6185H to test the count in Register Pair HL.
6190H - Evaluate an Expression, Text Pointer on the Stack
Used by CMD"J" (5A78H), 6623H, SYS10/SYS and SYS20/SYS: evaluates the expression and leaves the text pointer on the stack under the return address. Returns the NZ FLAG for a number; for a string the Z FLAG with Register B = its length and Register Pair HL = its text.
6190
GOSUB to ROM 2337H to evaluate the expression at Register Pair HL into the ROM's accumulator; Register Pair HL returns past it.
6193
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with this routine's return address on the stack at the Stack Pointer: the text pointer is now on the stack, Register Pair HL = the return address.
6194
PUSH HL E5
Push Register Pair HL (the return address) back onto the stack at the Stack Pointer, above the text pointer.
6195
RST 20H E7
RST 20H tests the value type at 40AFH: the Z FLAG is set for a string.
6196
RET NZ C0
If the NZ FLAG is set (a number), RETurn with the NZ FLAG.
6197
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: the flags of the string test.
6198
GOSUB to ROM 29D7H (FRESTR), which frees the string's temporary descriptor; Register Pair HL returns the descriptor.
619B
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: the Z FLAG of the string test.
619C
LD B,(HL) 46
Load Register B with the string's length, the first byte of the descriptor at Register Pair HL.
619D
INC HL 23
INCrement Register Pair HL to the low byte of the text address.
619E
LD C,(HL) 4E
Load Register C with the low byte of the text address from Register Pair HL.
619F
INC HL 23
INCrement Register Pair HL to the high byte of the text address.
61A0
LD H,(HL) 66
Load Register H with the high byte of the text address from Register Pair HL.
61A1
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the string's text.
61A2
RET C9
RETurn with the Z FLAG, Register B = the length and Register Pair HL = the text.
61A3H - Position the File
61A3H positions the file to where the last GET or PUT ended (5704H-5706H); 61A6H to Registers C, L and H; both through SYS0/SYS 444EH.
61A3
GOSUB to 6122H: Registers C, L and H return the position at 5704H-5706H (called by SYS10/SYS at its 4F83H).
61A6
LD DE,444EH 11 4E 44
Load Register Pair DE with 444EH, SYS0/SYS's routine that positions a file to the byte given in Registers H, L and C. 5FFBH, 6178H, 6250H and SYS10/SYS call here.
61A9
JUMP to 621EH to call the routine in Register Pair DE with the FCB at 570DH.
61ACH - Read NEXT
Registers C, L and H = the current position NEXT (FCB+5 at 5712H, FCB+10 and FCB+11 at 5717H-5718H).
61AC
LD C,(IX+12H) DD 4E 12
Load Register C with NEXT's low byte from Index Register IX+12H, 5712H (FCB+5).
61AF
LD HL,(5717H) 2A 17 57
Load Register Pair HL with NEXT's middle and high bytes from 5717H-5718H (FCB+10 and FCB+11).
61B2
RET C9
RETurn with NEXT, the current position, in Registers C, L and H.
61B3H - Read the End of File
Register A and Register Pair HL = the end of file (FCB+8 at 5715H, FCB+12 and FCB+13 at 5719H-571AH).
61B3
LD A,(5715H) 3A 15 57
Fetch the low byte of the end of file from 5715H (FCB+8) into Register A.
61B6
LD HL,(5719H) 2A 19 57
Load Register Pair HL with the middle and high bytes of the end of file from 5719H-571AH (FCB+12 and FCB+13).
61B9
RET C9
RETurn with the end of file in Register A (low byte) and Register Pair HL.
61BAH - Read NEXT and the End of File
Registers C, L and H = NEXT; Register Pair DE = the middle and high bytes of the end of file and Register A its low byte. 61BDH reads only the end of file into Register Pair DE and Register A, keeping Register Pair HL.
61BA
GOSUB to 61ACH: Registers C, L and H return NEXT. 631DH and 65A9H call here.
61BD
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE keeps the caller's Register Pair HL (NEXT's middle and high bytes) for a moment. 6034H calls here.
61BE
GOSUB to 61B3H: Register A and Register Pair HL return the end of file.
61C1
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the value it had before, Register Pair DE = the middle and high bytes of the end of file.
61C2
RET C9
RETurn with the end of file in Register Pair DE and Register A, and Register Pair HL as it was.
61C3H - Read a Byte From the File
ROM 0013H through the FCB at 570DH (621EH).
61C3
LD DE,0013H 11 13 00
Load Register Pair DE with 0013H, the ROM's routine that reads a byte from the device or file at Register Pair DE. 626CH and 628DH call here.
61C6
JUMP to 621EH to call the routine in Register Pair DE with Register Pair DE = the FCB at 570DH.
61C8H - Write an Item Marker and Its Data (SYS10/SYS)
Register A = the marker, Register B = the number of data bytes at Register Pair HL. The room left in the record (the operand at 61CAH, stored by SYS10/SYS at its 4F8EH) is lowered by Register B + 1; when it goes below 0, RECORD OVERFLOW. With bit 2 of 572DH set nothing is written.
61C8
PUSH HL E5
Save Register Pair HL (the address of the data) onto the stack at the Stack Pointer. 6146H and SYS10/SYS call here.
61C9
LD HL,0000H 21 00 00
Self-Modifying Code
Load Register Pair HL with the room left in the record, the operand at 61CAH-61CBH stored by SYS10/SYS and by 61D6H (0000H in the file).
61CC
LD E,B 58
Copy Register B, the number of data bytes, into Register E.
61CD
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the number of data bytes.
61CF
INC DE 13
INCrement Register Pair DE by 1 for the marker byte.
61D0
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
61D1
SBC HL,DE ED 52
SUBtract Register Pair DE (the bytes to write) from Register Pair HL (the room left). The CARRY FLAG is set when they do not fit.
61D3
If the CARRY FLAG is set, JUMP to 5DBEH, RECORD OVERFLOW.
61D6
LD (61CAH),HL 22 CA 61
Store Register Pair HL (the room left now) at 61CAH-61CBH, the operand of the LD HL at 61C9H.
61D9
POP HL E1
Restore Register Pair HL (the address of the data) from the stack at the Stack Pointer.
61DA
BIT 2,(IX+2DH) DD CB 2D 56
Test bit 2 of 572DH at Index Register IX+2DH (set by SYS10/SYS at its 4F7CH): the NZ FLAG when nothing is to be written.
61DE
RET NZ C0
If the NZ FLAG is set, RETurn without writing: only the room was counted.
61DFH - Write a Byte and Data Bytes
Writes the byte in Register A and then Register B bytes from Register Pair HL (620AH). Writing at or past the end of file needs bit 7 of 5701H (the file may be extended), else ILLEGAL TO EXTEND FILE.
61DF
PUSH HL E5
Save Register Pair HL (the address of the data) onto the stack at the Stack Pointer. 618AH and SYS10/SYS call here.
61E0
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the byte to write.
61E1
GOSUB to 65A8H: Register A returns NEXT's low byte, Register Pair HL NEXT's middle and high bytes and Register Pair DE those of the end of file; Register Pair BC is kept.
61E4
NOP 00
No operation: a byte left between the CALL and the SUB.
61E5
SUB (IX+15H) DD 96 15
SUBtract the end of file's low byte at Index Register IX+15H (5715H) from Register A (NEXT's low byte).
61E8
SBC HL,DE ED 52
SUBtract Register Pair DE (the end of file's middle and high bytes) from Register Pair HL with the borrow: the NO CARRY FLAG when NEXT is at or past the end of file.
61EA
If the NO CARRY FLAG is set (at or past the end of file), JUMP to 61F4H.
61EC
ADD A,B 80
ADD Register B (the data bytes) to Register A, the low byte of NEXT minus the end of file.
61ED
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, for the carry.
61F0
ADC HL,DE ED 5A
ADD Register Pair DE (0000H) and the CARRY FLAG to Register Pair HL: the CARRY FLAG is set when the write reaches the end of file.
61F2
If the NO CARRY FLAG is set (the write stays below the end of file), JUMP to 61FBH.
61F4
BIT 7,(IX+01H) DD CB 01 7E
Test bit 7 of 5701H at Index Register IX+01H: the file may be extended. 61EAH comes here.
61F8
If the Z FLAG is set (it may not), JUMP to 5DC1H, ILLEGAL TO EXTEND FILE.
61FB
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = the byte to write. 61F2H comes here.
61FC
POP HL E1
Restore Register Pair HL (the address of the data) from the stack at the Stack Pointer.
61FD
GOSUB to 6205H to write the byte in Register A to the file.
6200
LD A,B 78
Copy Register B, the number of data bytes, into Register A.
6201
OR A B7
OR Register A with itself: the Z FLAG is set when there is no data.
6202
RET Z C8
If the Z FLAG is set, RETurn: only the byte was written.
6203
JUMP to 620AH to write Register A data bytes from Register Pair HL.
6205H - Write a Byte to the File
ROM 001BH through the FCB at 570DH (621EH).
6205
LD DE,001BH 11 1B 00
Load Register Pair DE with 001BH, the ROM's routine that writes Register A to the device or file at Register Pair DE. 606BH and 61FDH call here.
6208
JUMP to 621EH to call the routine in Register Pair DE with Register Pair DE = the FCB at 570DH.
620AH - Write or Read a Block in Record Mode
620AH writes Register A bytes from Register Pair HL unless bit 2 of 572DH is set; 620FH writes them (SYS0/SYS 443CH, write with verify), 6214H reads them (SYS0/SYS 4436H). FCB+1 bit 7 (record mode) is set and Register A becomes the record length FCB+9 (5716H), so that one call moves the whole block.
620A
BIT 2,(IX+2DH) DD CB 2D 56
Test bit 2 of 572DH at Index Register IX+2DH. 6203H comes here.
620E
RET NZ C0
If the NZ FLAG is set, RETurn without writing.
620F
LD DE,443CH 11 3C 44
Load Register Pair DE with 443CH, SYS0/SYS's write with verify.
6212
JUMP to 6217H to set record mode and call the routine in Register Pair DE.
6214H - Read a Block in Record Mode (SYS10/SYS)
Register Pair DE = 4436H, SYS0/SYS's read, then as 6217H.
6214
LD DE,4436H 11 36 44
Load Register Pair DE with 4436H, SYS0/SYS's read (called by SYS10/SYS at its 4EF9H and 50DEH).
6217
SET 7,(IX+0EH) DD CB 0E FE
Set bit 7 of FCB+1 at Index Register IX+0EH (570EH): record mode, so that the read or write moves FCB+9 bytes between the buffer and Register Pair HL. 6212H comes here.
621B
LD (5716H),A 32 16 57
Store Register A (the number of bytes) at 5716H, FCB+9, the record length.
621E
GOSUB to 622DH, which jumps to the routine in Register Pair DE with Register Pair DE = the FCB at 570DH. 61A9H, 61C6H, 6208H, 623EH and 6243H come here.
6221
If the NZ FLAG is set (the DOS gave an error in Register A), GOSUB to 5DEFH to report it.
6224
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: the result of the call.
6225
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the operand at 6226H, the mark that SYS10/SYS must be loaded again after a DOS call (stored by SYS10/SYS at its 4D05H, cleared at 642DH; 00H in the file).
6227
OR A B7
OR Register A with itself: the NZ FLAG is set when SYS10/SYS must be loaded again.
6228
If the NZ FLAG is set, GOSUB to 610AH to load SYS10/SYS again (the DOS call may have loaded another overlay into 4D00H) and keep the position.
622B
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: the result of the call.
622C
RET C9
RETurn with the result of the call in Register A and the flags.
622DH - Call a DOS Routine With the FCB
Pushes the routine's address in Register Pair DE as the return address and loads Register Pair DE with the FCB at 570DH, so that the RET jumps to the routine.
622D
PUSH DE D5
Push Register Pair DE (the routine's address) onto the stack at the Stack Pointer as the return address.
622E
LD DE,570DH 11 0D 57
Load Register Pair DE with 570DH, the FCB of the statement's file.
6231
RET C9
RETurn: the RET jumps to the routine with Register Pair DE = 570DH; the routine returns to 6221H.
6232H - Read a Sector
SYS0/SYS 4436H with FCB+1 bit 7 clear (sector mode). Called by SYS10/SYS at its 4F05H.
6232
LD DE,4436H 11 36 44
Load Register Pair DE with 4436H, SYS0/SYS's read.
6235
JUMP to 623AH to set sector mode and call the routine in Register Pair DE.
6237H - Write a Sector
SYS0/SYS 443CH (write with verify) with FCB+1 bit 7 clear. Called by SYS10/SYS at its 4DAAH and 4F08H.
6237
LD DE,443CH 11 3C 44
Load Register Pair DE with 443CH, SYS0/SYS's write with verify.
623A
RES 7,(IX+0EH) DD CB 0E BE
Clear bit 7 of FCB+1 at Index Register IX+0EH (570EH): sector mode. 6235H comes here.
623E
JUMP to 621EH to call the routine in Register Pair DE with the FCB.
6240H - Rewind
SYS0/SYS 443FH through the FCB. Called by SYS19/SYS at its 5610H.
6240
LD DE,443FH 11 3F 44
Load Register Pair DE with 443FH, SYS0/SYS's rewind (NEXT set to 0).
6243
JUMP to 621EH to call the routine in Register Pair DE with the FCB.
6245H - Move Forward in the File
Moves NEXT forward by Register B (6245H) or Register A (6246H) bytes; past 24 bits it is DOS error 1DH.
6245
LD A,B 78
Copy Register B, the number of bytes, into Register A.
6246
GOSUB to 61ACH: Registers C, L and H return NEXT; Register A is kept. 6266H and SYS10/SYS come here.
6249
ADD A,C 81
ADD Register C (NEXT's low byte) to Register A (the number of bytes).
624A
LD C,A 4F
Copy Register A (the new low byte) into Register C.
624B
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, for the carry.
624E
ADC HL,DE ED 5A
ADD Register Pair DE (0000H) and the CARRY FLAG to Register Pair HL, NEXT's middle and high bytes. The CARRY FLAG is set past 24 bits.
6250
If the NO CARRY FLAG is set, JUMP to 61A6H to position the file at Registers C, L and H.
6253
LD A,1DH 3E 1D
Load Register A with 1DH, the DOS error PAST END OF FILE.
6255
JUMP to 5DEFH to report the DOS error in Register A.
6258H - Pass Over One Item (SYS10/SYS)
Checks that the position is still inside the record (6334H), reads an item marker (626CH) and passes over the item's data. Returns the Z FLAG and the CARRY FLAG at a record start (70H), the NZ FLAG otherwise. Called by 6003H and SYS10/SYS (its 4E55H, 4F69H).
6258
PUSH HL E5
Save Register Pair HL (the middle and high bytes of the position) onto the stack at the Stack Pointer.
6259
PUSH BC C5
Save Register Pair BC (Register C = the low byte of the position) onto the stack at the Stack Pointer.
625A
LD H,L 65
Copy Register L, the middle byte of the position, into Register H.
625B
LD L,C 69
Copy Register C, the low byte, into Register L: Register Pair HL = the low and middle bytes of the position.
625C
GOSUB to 6334H to work out the room left between the position in Register Pair HL and the end of the record: RECORD OVERFLOW when the position is past the record.
625F
GOSUB to 626CH to read the item marker: Register B returns the item's length, with the CARRY FLAG for a record start.
6262
LD A,B 78
Copy Register B (the item's length) into Register A.
6263
POP BC C1
Restore Register Pair BC (Register C = the low byte of the position) from the stack at the Stack Pointer.
6264
POP HL E1
Restore Register Pair HL (the middle and high bytes) from the stack at the Stack Pointer.
6265
RET C D8
If the CARRY FLAG is set (a record start, marker 70H), RETurn with the Z FLAG and the CARRY FLAG.
6266
If the NZ FLAG is set (a data item), GOSUB to 6246H to move forward Register A bytes, past the item's data.
6269
OR FFH F6 FF
OR Register A with FFH: Register A = FFH with the NZ FLAG and the CARRY FLAG clear.
626B
RET C9
RETurn with the NZ FLAG: an item was passed over (or a filler byte 00H).
626CH - Read an Item Marker
Returns the Z FLAG and the NO CARRY FLAG for 00H (a filler byte), the Z FLAG and the CARRY FLAG for 70H (a record start); otherwise the NZ FLAG with Register A = the value type and Register B = the length: 71H n and 80H + n strings (type 03H, length n), 72H an integer (2 bytes), 73H single precision (4), 74H double precision (8); any other marker is BAD FILE DATA.
626C
GOSUB to 61C3H to read the marker byte from the file into Register A. 625FH and SYS10/SYS call here.
626F
OR A B7
OR Register A (the marker) with itself: the Z FLAG is set for 00H.
6270
RET Z C8
If the Z FLAG is set (00H, a filler byte), RETurn with the Z FLAG and the NO CARRY FLAG.
6271
ADD A,80H C6 80
ADD 80H to Register A: the CARRY FLAG is set for a marker of 80H or more, and Register A = the length n.
6273
If the CARRY FLAG is set (80H + n, a short string), JUMP to 6290H with Register A = n.
6275
ADD A,10H C6 10
ADD 10H to Register A (the marker + 90H): 00H with the CARRY FLAG for 70H.
6277
RET Z C8
If the Z FLAG is set (70H, a record start), RETurn with the Z FLAG and the CARRY FLAG.
6278
DEC A 3D
DECrement Register A (the marker minus 70H): 00H with the Z FLAG for 71H.
6279
If the Z FLAG is set (71H, a string with a length byte), JUMP to 628DH.
627B
LD B,02H 06 02
Load Register B with 02H, the length of an integer.
627D
DEC A 3D
DECrement Register A (the marker minus 71H): 00H with the Z FLAG for 72H.
627E
If the Z FLAG is set (72H, an integer), JUMP to 628BH with Register B = 02H.
6280
LD B,04H 06 04
Load Register B with 04H, the length of a single precision number.
6282
DEC A 3D
DECrement Register A (the marker minus 72H): 00H with the Z FLAG for 73H.
6283
If the Z FLAG is set (73H, single precision), JUMP to 628BH with Register B = 04H.
6285
LD B,08H 06 08
Load Register B with 08H, the length of a double precision number.
6287
DEC A 3D
DECrement Register A (the marker minus 73H): 00H with the Z FLAG for 74H.
6288
If the NZ FLAG is set (not 74H either), JUMP to 5D9DH, BAD FILE DATA.
628B
OR B B0
OR Register B into Register A (00H): Register A = the length, which is also the value type, with the NZ FLAG. 627EH and 6283H come here.
628C
RET C9
RETurn with the NZ FLAG and Register A = Register B = the length and value type.
628D
Marker 71H: GOSUB to 61C3H to read the length byte from the file into Register A. 6279H comes here.
6290
LD B,A 47
Copy Register A (the string's length) into Register B. 6273H comes here.
6291
LD A,03H 3E 03
Load Register A with 03H, the value type of a string.
6293
OR A B7
OR Register A with itself, which sets the NZ FLAG (and clears the CARRY FLAG).
6294
RET C9
RETurn with the NZ FLAG, Register A = 03H and Register B = the string's length.
6295H - Set Up a File Statement
6295H reads the file number first (5F53H); 6298H starts with the area in Register Pair BC. Only one file area per statement: the flag at 6382H must be 00H, else STMT USES 2 FILE AREAS. The area's address is kept in the operand at 6352H, 6382H becomes C9H, Index Register IX = 5700H, 572DH is cleared and the area's 2DH-byte header is copied to 5700H.
6295
GOSUB to 5F53H to read the file number at Register Pair HL: Register Pair BC returns the area. 6101H and 62C0H call here.
6298
LD A,(6382H) 3A 82 63
Fetch the file statement flag at 6382H into Register A (00H none, C9H one is running). 5FCDH and 607EH call here.
629B
OR A B7
OR Register A with itself: the NZ FLAG is set when a file statement is already running.
629C
If the NZ FLAG is set, JUMP to 5DD9H, STMT USES 2 FILE AREAS.
629F
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack at the Stack Pointer.
62A0
LD H,B 60
Copy Register B (the high byte of the area's address) into Register H.
62A1
LD L,C 69
Copy Register C into Register L: Register Pair HL = the file area.
62A2
LD (6352H),HL 22 52 63
Store Register Pair HL (the file area) at 6352H-6353H, the operand of the LD DE at 6351H, for copying the header back.
62A5
GOSUB to 6386H, which stores C9H at 6382H: a file statement is running.
62A8
LD DE,5700H 11 00 57
Load Register Pair DE with 5700H, the place of the header copy. 62BEH comes here.
62AB
PUSH DE D5
Push Register Pair DE (5700H) onto the stack at the Stack Pointer, for the POP IX.
62AC
POP IX DD E1
POP the word from the stack at the Stack Pointer into Index Register IX: Index Register IX = 5700H.
62AE
LD (IX+2DH),00H DD 36 2D 00
Store 00H at Index Register IX+2DH (572DH): the statement's flags start clear.
62B2
LD BC,002DH 01 2D 00
Load Register Pair BC with 002DH, the 45 bytes of a header. 6354H comes here.
62B5
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (the area) to Register Pair DE (5700H), counting Register Pair BC down to 0: the header copy (or, from 6354H, back to the area).
62B7
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
62B8
LD A,(5700H) 3A 00 57
Fetch the mode byte at 5700H into Register A. 62C5H comes here.
62BB
OR A B7
OR Register A with itself: the Z FLAG is set when the file is not open.
62BC
RET C9
RETurn with Register A = the mode byte and Index Register IX = 5700H.
62BDH - Copy an Area's Header to 5700H
Register Pair HL = the area (called at 646DH).
62BD
PUSH HL E5
Save Register Pair HL (the area) onto the stack at the Stack Pointer, as 62A8H-62B7H expect.
62BE
JUMP to 62A8H to copy the header from Register Pair HL to 5700H.
62C0H - Set Up a File Statement and Require a Comma
For PRINT # and INPUT # (5F3CH).
62C0
GOSUB to 6295H to read the file number at Register Pair HL and set up the file statement.
62C3
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it.
62C4
DEFB 2CH 2C
The byte the RST 08H at 62C3H compares against: 2CH, a comma. It is never executed.
62C5
JUMP to 62B8H to return the mode byte in Register A.
62C7H - Item Prefix Checks (SYS10/SYS)
Bit 6 of 572DH means a length prefix was given. 62C7H: an item without one is fine, one given for a number is an error; 62CEH and 62D0H: the item needs one. The error is BAD/ILLEGAL/MISSING IGEL ITEM PREFIX.
62C7
BIT 6,(IX+2DH) DD CB 2D 76
Test bit 6 of 572DH at Index Register IX+2DH: a length prefix was given (called by SYS10/SYS at its 50D9H and 517BH).
62CB
RET Z C8
If the Z FLAG is set (no prefix was given with the item), RETurn.
62CC
A prefix was given where it is not allowed: JUMP to 62D5H to report the error.
62CE
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the text pointer. 62E4H and 62E8H come here; SYS10/SYS calls here at its 5149H.
62CF
INC DE 13
INCrement Register Pair DE past the # or $ at the text pointer.
62D0
BIT 6,(IX+2DH) DD CB 2D 76
Test bit 6 of 572DH at Index Register IX+2DH: a length prefix was given (SYS10/SYS calls here at its 5070H).
62D4
RET NZ C0
If the NZ FLAG is set (a prefix was given, as needed), RETurn.
62D5
JUMP to 5DD3H, BAD/ILLEGAL/MISSING IGEL ITEM PREFIX. 62CCH comes here.
62D8H - Item Variable for a File With Type Bit 1 (SYS10/SYS)
With mode bit 1 clear it returns the Z FLAG. With bit 1 set it returns the NZ FLAG with Register C = the prefix limit at 5094H and either Register A = # or $ (Register Pair DE past it), or Register A = 00H with Register Pair HL = the variable's address (PTRGET). A string variable needs a prefix.
62D8
BIT 1,(IX+00H) DD CB 00 4E
Test bit 1 of the mode byte at Index Register IX+00H (5700H) (called by SYS10/SYS at its 5017H and 50F7H).
62DC
RET Z C8
If the Z FLAG is set (bit 1 clear), RETurn with the Z FLAG.
62DD
LD A,(5094H) 3A 94 50
Fetch the prefix limit from 5094H, a byte inside SYS10/SYS, into Register A.
62E0
LD C,A 4F
Copy Register A (the prefix limit from 5094H) into Register C.
62E1
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
62E2
CP 23H FE 23
Compare Register A against 23H (#). The Z FLAG is set for #.
62E4
If the Z FLAG is set (#), JUMP to 62CEH, which needs a prefix.
62E6
CP 24H FE 24
Compare Register A against 24H ($). The Z FLAG is set for $.
62E8
If the Z FLAG is set ($), JUMP to 62CEH, which needs a prefix.
62EA
PUSH BC C5
Save Register Pair BC (Register C = the limit) onto the stack at the Stack Pointer.
62EB
GOSUB to ROM 260DH, PTRGET: Register Pair DE returns the address of the variable named at Register Pair HL and 40AFH its value type.
62EE
POP BC C1
Restore Register Pair BC (Register C = the limit) from the stack at the Stack Pointer.
62EF
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the variable's address, Register Pair DE = the text pointer.
62F0
LD B,(HL) 46
Load Register B with the variable's first byte at Register Pair HL (a string's length).
62F1
RST 20H E7
RST 20H tests the value type at 40AFH: the Z FLAG is set for a string.
62F2
If the NZ FLAG is set (a number), JUMP to 62FBH.
62F4
BIT 6,(IX+2DH) DD CB 2D 76
Test bit 6 of 572DH at Index Register IX+2DH: a prefix was given.
62F8
If the Z FLAG is set (a string without a prefix), JUMP to 5DD3H, BAD/ILLEGAL/MISSING IGEL ITEM PREFIX.
62FB
OR D B2
OR Register D (the high byte of the text pointer, never 00H) into Register A: the NZ FLAG. 62F2H comes here.
62FC
LD A,00H 3E 00
Load Register A with 00H: the item is a variable. LD does not change the flags.
62FE
RET C9
RETurn with the NZ FLAG, Register A = 00H, Register Pair HL = the variable and Register C = the limit.
62FFH - Fill the Rest of a Record After a PUT (SYS10/SYS)
After a PUT (mode bit 4) to a file with mode bit 3 set, the rest of the record is filled with 00H bytes where the file's mode asks for it: the room left at 61CAH, or, when 572DH bit 3 is set and the PUT was not at the end, up to the end of file. Called by SYS10/SYS at its 51BAH.
62FF
LD A,(5700H) 3A 00 57
Fetch the mode byte at 5700H into Register A.
6302
BIT 4,A CB 67
Test bit 4 of Register A: a PUT is in progress.
6304
RET Z C8
If the Z FLAG is set (the statement was not a PUT), RETurn.
6305
BIT 3,A CB 5F
Test bit 3 of Register A, the mode byte from 5700H.
6307
RET Z C8
If the Z FLAG is set (bit 3 clear), RETurn: nothing to fill.
6308
LD B,(IX+2DH) DD 46 2D
Load Register B with the statement's flags from Index Register IX+2DH (572DH).
630B
BIT 1,A CB 4F
Test bit 1 of Register A, the mode byte from 5700H.
630D
If the NZ FLAG is set (bit 1), JUMP to 6328H.
630F
BIT 0,A CB 47
Test bit 0 of Register A, the mode byte from 5700H.
6311
RET Z C8
If the Z FLAG is set (bits 1 and 0 clear), RETurn.
6312
BIT 2,A CB 57
Test bit 2 of Register A, the mode byte: fixed-length records.
6314
If the NZ FLAG is set, JUMP to 632BH to fill the room left in the record.
6316
BIT 4,B CB 60
Test bit 4 of Register B, the flags from 572DH: the PUT was at or past the end of file (6162H).
6318
RET NZ C0
If the NZ FLAG is set (the PUT was at or past the end of file), RETurn.
6319
BIT 3,B CB 58
Test bit 3 of Register B, the flags from 572DH (set by SYS10/SYS at its 4F5DH).
631B
If the Z FLAG is set (bit 3 clear), JUMP to 632BH to fill the room left in the record.
631D
GOSUB to 61BAH: Registers C, L and H return NEXT; Register A and Register Pair DE the end of file.
6320
SUB C 91
SUBtract Register C (NEXT's low byte) from Register A (the end of file's low byte).
6321
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the end of file's middle and high bytes, Register Pair DE = NEXT's.
6322
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL with the borrow: the bytes from NEXT to the end of file (middle in Register L).
6324
LD H,L 65
Copy Register L (the middle byte of the difference) into Register H.
6325
LD L,A 6F
Copy Register A (the low byte of the difference) into Register L: Register Pair HL = the bytes up to the end of file.
6326
JUMP to 632EH to write Register Pair HL bytes of 00H.
6328
BIT 4,B CB 60
Mode bit 1: test bit 4 of Register B, the flags from 572DH (at or past the end of file). 630DH comes here.
632A
RET Z C8
If the Z FLAG is set (not at the end), RETurn.
632B
LD HL,(61CAH) 2A CA 61
Load Register Pair HL with the room left in the record from 61CAH-61CBH. 6314H and 631BH come here.
632E
JUMP to 6185H to write Register Pair HL bytes of 00H. 6326H comes here.
6331H - Room Left in the Record (SYS10/SYS)
6331H: the record length minus the bytes from the record start (5707H) to where the last GET or PUT ended (5704H); 6334H takes the position in Register Pair HL. RECORD OVERFLOW when it is below 0; returns Register Pair HL = the room.
6331
LD HL,(5704H) 2A 04 57
Load Register Pair HL with the low and middle bytes of where the last GET or PUT ended, 5704H-5705H (called by SYS10/SYS at its 4F18H).
6334
LD DE,(5707H) ED 5B 07 57
Load Register Pair DE with the low and middle bytes of the record start, 5707H-5708H. 625CH and 634BH come here.
6338
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
6339
SBC HL,DE ED 52
SUBtract Register Pair DE (the record start) from Register Pair HL (the position): the bytes of the record used.
633B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the bytes used.
633C
LD HL,(5702H) 2A 02 57
Load Register Pair HL with the record length from 5702H-5703H.
633F
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
6340
SBC HL,DE ED 52
SUBtract Register Pair DE (the bytes used) from Register Pair HL (the record length): the room left. The CARRY FLAG is set when it is below 0.
6342
RET NC D0
If the NO CARRY FLAG is set, RETurn with the room left in Register Pair HL.
6343
The room in Register Pair HL is below 0: JUMP to 5DBEH, RECORD OVERFLOW.
6346H - Room Left From NEXT (SYS10/SYS)
As 6331H with the current position NEXT. Called by SYS10/SYS at its 505DH and 50E6H.
6346
GOSUB to 61ACH: Registers C, L and H return NEXT.
6349
LD H,L 65
Copy Register L (NEXT's middle byte) into Register H.
634A
LD L,C 69
Copy Register C (NEXT's low byte) into Register L: Register Pair HL = NEXT's low and middle bytes.
634B
JUMP to 6334H with Register Pair HL = the position.
634DH - Copy the Header Back to the File Area
5700H-572CH is copied to the area whose address is the operand at 6352H.
634D
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack at the Stack Pointer, for the POP HL at 62B7H. 6357H and 648CH call here.
634E
LD HL,5700H 21 00 57
Point Register Pair HL to 5700H, the header copy.
6351
LD DE,0000H 11 00 00
Self-Modifying Code
Load Register Pair DE with the file area's address, the operand at 6352H-6353H stored by 62A2H (0000H in the file).
6354
JUMP to 62B2H to copy 2DH bytes from Register Pair HL (5700H) to Register Pair DE (the area) and return the mode byte.
6357H - End a File Function
Pushed as the return for EOF, LOF and LOC (5EDEH, 6021H): the header is copied back, the file statement flag cleared and the work area 5700H-572DH cleared. 635AH only clears; 6362H clears Register B bytes at Register Pair HL.
6357
GOSUB to 634DH to copy the header at 5700H back to the file area.
635A
GOSUB to 6392H, which stores 00H at 6382H: no file statement is running. 6078H and 648FH call here.
635D
LD HL,5700H 21 00 57
Point Register Pair HL to 5700H, the work area.
6360
LD B,2EH 06 2E
Load Register B with 2EH, the 46 bytes 5700H-572DH.
6362
LD (HL),00H 36 00
Store 00H at Register Pair HL. 5FBEH calls here with Register B = 2DH; 6365H loops back here.
6364
INC HL 23
INCrement Register Pair HL to the next byte to clear.
6365
DECrement Register B (the bytes left) and LOOP BACK to 6362H.
6367
RET C9
RETurn with the Register B bytes at Register Pair HL cleared to 00H.
6368H - End of Statement or a Comma
Returns the Z FLAG when the statement ends; otherwise a comma must follow, and the NZ FLAG is returned with Register A = the character after it.
6368
DEC HL 2B
DECrement Register Pair HL by one character, so that the RST 10H reads the current character again. 5F82H calls here.
6369
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A; the Z FLAG is set at the end of the statement.
636A
RET Z C8
If the Z FLAG is set (the statement ends), RETurn with the Z FLAG.
636B
RST 08H CF
RST 08H: the byte after it (2CH, a comma) must be the character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is moved past it and Register A holds the next character.
636C
DEFB 2CH 2C
The byte the RST 08H at 636BH compares against: 2CH, a comma. It is never executed.
636D
CP FFH FE FF
Compare Register A against FFH: the NZ FLAG is set for any character but FFH.
636F
RET C9
RETurn with the NZ FLAG and Register A = the character after the comma.
6370H - Read the Next Sector (SYS19/SYS)
SYS0/SYS 4436H through the FCB at 570DH (called by SYS19/SYS at its 5617H). Returns the Z FLAG on success; at the end of file (DOS errors 1CH and 1DH; 6379H is also used by 60FBH) the NZ FLAG with the code in Register A; other errors go to 5DEFH.
6370
LD DE,570DH 11 0D 57
Point Register Pair DE to 570DH, the work area's FCB.
6373
GOSUB to SYS0/SYS 4436H to read the next sector of the file at Register Pair DE into its buffer: the Z FLAG on success, else the NZ FLAG with a DOS error in Register A.
6376
RET Z C8
If the Z FLAG is set (the sector was read), RETurn.
6377
CP 1DH FE 1D
Compare Register A (the DOS error) against 1DH, PAST END OF FILE. The Z FLAG is set for it.
6379
If the Z FLAG is set, JUMP to 6380H. 60FBH comes here with a DOS error in Register A.
637B
CP 1CH FE 1C
Compare Register A against 1CH, END OF FILE ENCOUNTERED. The Z FLAG is set for it.
637D
If the NZ FLAG is set (another error), JUMP to 5DEFH to report it.
6380
OR A B7
OR Register A (1CH or 1DH) with itself: the NZ FLAG. 6379H comes here.
6381
RET C9
RETurn with the NZ FLAG and the end of file code in Register A.
6382H - File Statement Flag
The byte at 6382H is 00H (NOP) when no file statement is running and C9H (RET) while one is. The links call 6382H first: with 00H the INC SP / INC SP / RET drops the call and returns straight to the ROM; with C9H the call just returns. 6386H sets it (also for SYS19/SYS, its 5271H), 638CH and 6395H save and restore it for the ROM.
6382
NOP 00
The flag byte: 00H (NOP) in the file and when no file statement runs, C9H (RET) during one (6386H). Called by 5E92H, 5F14H, 5F24H, 604FH, SYS18/SYS (its 550BH) and SYS20/SYS (its 55D4H); read by 6298H, 638CH and 643CH.
6383
INC SP 33
No file statement: INCrement the Stack Pointer (1 of 2), dropping the return address of the CALL 6382H.
6384
INC SP 33
INCrement the Stack Pointer again (2 of 2): the return address of the CALL 6382H is dropped.
6385
RET C9
RETurn to the caller's caller (the ROM, for a link): the link does nothing.
6386H - Mark a File Statement Running
6382H = C9H (called from 62A5H and by SYS19/SYS at its 5271H).
6386
LD A,C9H 3E C9
Load Register A with C9H, the opcode RET, for the flag at 6382H.
6388
LD (6382H),A 32 82 63
Store Register A at 6382H: C9H means a file statement is running, 00H none. 6393H and 6397H come here.
638B
RET C9
RETurn with the file statement flag at 6382H set from Register A.
638CH - Link 41B5H: Keep and Clear the Flag
Link 41B5H (from the JP 638CH at 681EH), called by the ROM at 1AECH; the flag is kept in the operand at 6396H and cleared, until link 41B8H (1AF2H) puts it back.
638C
LD A,(6382H) 3A 82 63
Fetch the file statement flag at 6382H into Register A.
638F
LD (6396H),A 32 96 63
Store Register A (the flag) at 6396H, the operand of the LD A at 6395H.
6392
XOR A AF
Set Register A to 00H, the value for no file statement. 635AH calls here.
6393
JUMP to 6388H to store Register A (00H) at 6382H and return.
6395H - Link 41B8H: Put the Flag Back
Link 41B8H (from the JP 6395H at 6821H), called by the ROM at 1AF2H.
6395
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the flag kept at 6396H by 638FH (00H in the file).
6397
JUMP to 6388H to store Register A at 6382H and return.
6399H - Link 41C4H (Keyboard Scan): End of a File Statement and Single Stepping
Link 41C4H (from the JP 6399H at 682DH), called by the ROM's keyboard scan at 0358H. When the scan is made by the ROM's BREAK test 1D9BH (return address 1D9EH) the ordinary key handling at 63F8H follows. When it is made from 1D21H, as BASIC goes to the next statement, any file statement is ended (641EH) and, at the end of a line, single stepping can run (63B4H). Other callers go on at ROM 035BH.
6399
POP AF F1
POP the return address of the ROM's CALL 41C4H at 0358H from the stack at the Stack Pointer into Register Pair AF, dropping it.
639A
EX (SP),HL E3
Exchange Register Pair HL with the next word on the stack at the Stack Pointer: Register Pair HL = the return address into the scan's caller, and the caller's Register Pair HL waits on the stack.
639B
PUSH DE D5
Save Register Pair DE (the caller's value) onto the stack at the Stack Pointer.
639C
LD DE,1D9EH 11 9E 1D
Load Register Pair DE with 1D9EH, the return address of the CALL 0358H at 1D9BH, the ROM's BREAK test.
639F
RST 18H DF
RST 18H compares Register Pair HL (the return address) with Register Pair DE (1D9EH): the Z FLAG when the scan was made by the BREAK test.
63A0
If the NZ FLAG is set (another caller), JUMP to 63A6H.
63A2
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer.
63A3
EX (SP),HL E3
Exchange Register Pair HL (the return address) with the word on the stack at the Stack Pointer: the return address goes back and Register Pair HL is the caller's again.
63A4
JUMP to 63F8H for the key handling during RUN ONLY and chaining.
63A6
LD DE,1D21H 11 21 1D
Load Register Pair DE with 1D21H, the return address of the scan made as BASIC goes to the next statement. 63A0H comes here.
63A9
RST 18H DF
RST 18H compares Register Pair HL (the return address) with Register Pair DE (1D21H): the Z FLAG for that caller.
63AA
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer. POP does not change the flags.
63AB
EX (SP),HL E3
Exchange Register Pair HL with the word on the stack at the Stack Pointer: the return address goes back, Register Pair HL is the caller's (the text pointer for 1D21H).
63AC
JP NZ,035BH C2 5B 03
If the NZ FLAG is set (another caller), JUMP to ROM 035BH, the rest of the keyboard scan (no link: the ROM page has no id at 035BH).
63AF
A new statement: GOSUB to 641EH to end any file statement.
63B2
LD A,(HL) 7E
Fetch the character at Register Pair HL, the text pointer, into Register A: 00H at the end of a line.
63B3
OR A B7
OR Register A with itself: the Z FLAG is set at the end of a line.
63B4
Self-Modifying Code
Opcode stored by CMD"F=SS" at 5BAFH: 18H (JR, stepping off, as in the file) always jumps to 63F8H; 20H (JR NZ, stepping on) jumps there inside a line and falls into 63B6H at the end of one.
63B6H - Single Step
Before the next line runs, its number is shown as @nnnnn at the top right of the screen (3C39H) and the program waits for ENTER (step) or BREAK. With a start line (the operand at 63C4H) nothing happens until that line comes up.
63B6
PUSH HL E5
Save Register Pair HL (the text pointer at the line's 00H) onto the stack at the Stack Pointer.
63B7
PUSH DE D5
Save Register Pair DE (the caller's value) onto the stack at the Stack Pointer.
63B8
PUSH BC C5
Save Register Pair BC (the caller's value) onto the stack at the Stack Pointer.
63B9
INC HL 23
INCrement Register Pair HL past the line's 00H to the next line's link.
63BA
LD A,(HL) 7E
Fetch the low byte of the next line's link at Register Pair HL into Register A.
63BB
INC HL 23
INCrement Register Pair HL to the high byte of the link.
63BC
OR (HL) B6
OR the high byte at Register Pair HL into Register A: the Z FLAG is set for 0000H, the end of the program.
63BD
If the Z FLAG is set (no next line), JUMP to 63F5H.
63BF
INC HL 23
INCrement Register Pair HL to the next line's number.
63C0
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL.
63C1
INC HL 23
INCrement Register Pair HL to the high byte of the line number.
63C2
LD D,(HL) 56
Load Register D with the high byte from Register Pair HL: Register Pair DE = the next line's number.
63C3
LD HL,0000H 21 00 00
Self-Modifying Code
Load Register Pair HL with the start line, the operand at 63C4H-63C5H stored by 5BA5H (0000H in the file: step every line).
63C6
LD A,H 7C
Copy Register H, the high byte of the start line, into Register A.
63C7
OR L B5
OR Register L into Register A: the Z FLAG is set when there is no start line.
63C8
If the Z FLAG is set, JUMP to 63CFH: step now.
63CA
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
63CB
SBC HL,DE ED 52
SUBtract Register Pair DE (the next line) from Register Pair HL (the start line): the Z FLAG when they are the same.
63CD
If the NZ FLAG is set (not the start line yet), JUMP to 63F5H.
63CF
LD (63C4H),HL 22 C4 63
Store Register Pair HL (0000H) at 63C4H-63C5H: from now on every line is stepped. 63C8H comes here.
63D2
LD BC,3C39H 01 39 3C
Load Register Pair BC with 3C39H, a place near the right end of the first screen line (the screen is 3C00H-3FFFH, 64 characters a line).
63D5
LD A,40H 3E 40
Load Register A with 40H (@), shown before the line number.
63D7
LD (BC),A 02
Store Register A (@) on the screen at Register Pair BC (3C39H).
63D8
PUSH BC C5
Save Register Pair BC (3C39H) onto the stack at the Stack Pointer.
63D9
INC BC 03
INCrement Register Pair BC to the next screen position, 3C3AH.
63DA
GOSUB to 5D00H to put the digits of the line number in Register Pair DE on the screen from Register Pair BC on.
63DD
GOSUB to 6407H to blank the rest of the screen line from Register Pair BC.
Loop: wait for ENTER or BREAK.
63E0
GOSUB to ROM 0049H, which waits for a key and returns it in Register A. 63E9H loops back here.
63E3
CP 01H FE 01
Compare Register A, the key, against 01H, BREAK. The Z FLAG is set for BREAK.
63E5
If the Z FLAG is set (BREAK), JUMP to 63EBH with Register A = 01H.
63E7
SUB 0DH D6 0D
SUBtract 0DH from Register A: 00H with the Z FLAG for ENTER.
63E9
If the NZ FLAG is set (another key), LOOP BACK to 63E0H.
63EB
POP BC C1
POP into Register Pair BC from the stack at the Stack Pointer: 3C39H, the start of the display. 63E5H comes here.
63EC
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = 00H (ENTER) or 01H (BREAK).
63ED
GOSUB to 6407H to blank the @nnnnn display from Register Pair BC (3C39H) to the end of the screen line.
63F0
POP AF F1
Restore Register Pair AF from the stack at the Stack Pointer: Register A = 00H for ENTER, 01H for BREAK.
63F1
POP BC C1
Restore Register Pair BC (the caller's value) from the stack at the Stack Pointer.
63F2
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer.
63F3
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
63F4
RET C9
RETurn to the ROM as the key scan's result: Register A = 01H (BREAK) stops the program, 00H lets it run.
63F5
POP BC C1
Restore Register Pair BC (the caller's value) from the stack at the Stack Pointer. 63BDH and 63CDH come here.
63F6
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer.
63F7
POP HL E1
Restore Register Pair HL (the text pointer) from the stack at the Stack Pointer.
63F8
XOR A AF
Set Register A to 00H for the test below. 63A4H and 63B4H come here.
63F9
OR 00H F6 00
Self-Modifying Code
OR Register A with the operand at 63FAH: 00H in the file; SYS19/SYS stores another value there at its 524EH and SYS18/SYS reads it at its 521EH. The NZ FLAG is set when it is not 00H.
63FB
If the NZ FLAG is set, JUMP to 6405H: no key is scanned, so BREAK does nothing.
63FD
LD A,(4289H) 3A 89 42
Fetch SYS0/SYS's system flags at 4289H into Register A.
6400
AND 20H E6 20
AND Register A with 20H, keeping bit 5: a chain file is supplying the keys.
6402
JP Z,035BH CA 5B 03
If the Z FLAG is set (no chaining), JUMP to ROM 035BH, the rest of the keyboard scan (no link: the ROM page has no id at 035BH).
6405
XOR A AF
Set Register A to 00H: no key. 63FBH comes here.
6406
RET C9
RETurn to the ROM with Register A = 00H, as if no key were pressed.
6407H - Blank to the End of the Screen Line
Stores spaces from Register Pair BC up to the next 64-byte line boundary.
6407
LD A,20H 3E 20
Load Register A with 20H, a space. 63DDH and 63EDH call here; 640EH loops back here.
6409
LD (BC),A 02
Store Register A (a space) on the screen at Register Pair BC.
640A
INC BC 03
INCrement Register Pair BC to the next screen position.
640B
LD A,C 79
Copy Register C, the low byte of the screen address, into Register A.
640C
AND 3FH E6 3F
AND Register A with 3FH, keeping the column (0-63): the Z FLAG is set at the start of the next line.
640E
If the NZ FLAG is set (still on the line), LOOP BACK to 6407H.
6410
RET C9
RETurn with Register Pair BC at the start of the next screen line.
6411H - Link 41BEH (After PRINT)
Link 41BEH (from the JP 6411H at 6827H), called by the ROM when a PRINT ends (2174H): the file statement is ended through 6420H with 645BH = JR NZ, so that when the end comes through the ROM's error handling (Register Pair BC = 19B4H) the file area's data is put back as it was before the statement.
6411
LD A,20H 3E 20
Load Register A with 20H, the opcode JR NZ, for 645BH.
6413
JUMP to 6420H to store Register A (20H) at 645BH and end the statement.
6415H - KILL Statement and the End of a File Statement
KILL link (4191H, from the JP 6415H at 67FAH): the file is opened in the work area and killed with SYS0/SYS 442CH, then the statement ends. 641EH ends a file statement (called at each new statement from 63AFH): 645BH becomes JR.
6415
GOSUB to 6073H to open the file named in the statement in the work area: Register Pair DE returns 570DH, its FCB.
6418
GOSUB to SYS0/SYS 442CH to kill the file of the FCB at Register Pair DE: the Z FLAG on success, else the NZ FLAG with a DOS error in Register A.
641B
If the NZ FLAG is set, JUMP to 5DEFH to report the DOS error in Register A.
641E
LD A,18H 3E 18
Load Register A with 18H, the opcode JR, for 645BH. 63AFH calls here.
6420
LD (645BH),A 32 5B 64
Store Register A (18H, or 20H from 6413H) at 645BH. 6413H comes here.
6423H - End the File Statement
Calls the cleanup routine whose address is at 6427H (6496H, a RET, or one of SYS19/SYS's or SYS21/SYS's while they run), clears 65A2H, the SYS10/SYS reload mark (6226H), the printer switch (5D45H) and bit 6 of 4289H, and sets 40A9H to 1. If a file statement ran: a work area file (572DH bit 7) is closed; otherwise the header is copied back, or after an error the area's own data is put back. Then the flag and the work area are cleared.
6423
PUSH HL E5
Save Register Pair HL (the caller's value) onto the stack at the Stack Pointer.
6424
PUSH DE D5
Save Register Pair DE (the caller's value) onto the stack at the Stack Pointer.
6425
PUSH BC C5
Save Register Pair BC (the caller's value) onto the stack at the Stack Pointer.
6426
Self-Modifying Code
GOSUB to the cleanup routine whose address is the operand at 6427H-6428H: 6496H (a RET) in the file and after 6497H; SYS19/SYS stores its own at its 52DAH and SYS21/SYS at its 4D15H (4D67H).
6429
XOR A AF
Set Register A to 00H for the bytes cleared below.
642A
LD (65A2H),A 32 A2 65
Store Register A (00H) at 65A2H, a byte that nothing else in the file reads.
642D
LD (6226H),A 32 26 62
Store Register A (00H) at 6226H, the operand at 6225H: SYS10/SYS need not be loaded again after a DOS call.
6430
LD (5D45H),A 32 45 5D
Store Register A (00H) at 5D45H, the operand at 5D44H: the output is no longer printed.
6433
INC A 3C
INCrement Register A from 00H to 01H for 40A9H.
6434
LD (40A9H),A 32 A9 40
Store Register A (01H) at 40A9H, the ROM's byte that tells the cassette from the other devices.
6437
LD HL,4289H 21 89 42
Point Register Pair HL to 4289H, SYS0/SYS's system flags.
643A
RES 6,(HL) CB B6
Clear bit 6 of the system flags at Register Pair HL (4289H), the mark set at 59B7H (and by the RST 28H dispatcher) that blocks the key combinations.
643C
LD A,(6382H) 3A 82 63
Fetch the file statement flag at 6382H into Register A.
643F
OR A B7
OR Register A with itself: the Z FLAG is set when no file statement is running.
6440
If the Z FLAG is set, JUMP to 6492H to return.
6442
LD HL,572DH 21 2D 57
Point Register Pair HL to 572DH, the statement's flags.
6445
BIT 7,(HL) CB 7E
Test bit 7 of the byte at Register Pair HL (572DH): the file lives in the work area.
6447
If the Z FLAG is set (an ordinary file area), JUMP to 6453H.
6449
GOSUB to 5F88H to close the work area file at 5700H.
644C
LD HL,5FA8H 21 A8 5F
Point Register Pair HL to 5FA8H, the RET Z of the close-all loop.
644F
LD (HL),C8H 36 C8
Store C8H (RET Z) at Register Pair HL (5FA8H), in case SYS19/SYS made it RET.
6451
JUMP to 648FH to clear the flag and the work area.
6453
POP BC C1
POP into Register Pair BC the caller's Register Pair BC, saved at 6425H, from the stack at the Stack Pointer. 6447H comes here.
6454
LD HL,19B4H 21 B4 19
Load Register Pair HL with 19B4H, the value the ROM's error handler (19A2H) holds in Register Pair BC, its continuation address.
6457
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC.
6458
SBC HL,BC ED 42
SUBtract Register Pair BC (the caller's value) from Register Pair HL (19B4H): the Z FLAG when the statement is being ended by the ROM's error handling.
645A
PUSH BC C5
Push Register Pair BC (the caller's value) back onto the stack at the Stack Pointer for 6492H.
645B
Self-Modifying Code
Opcode stored by 6420H: 18H (JR, from 641EH) always jumps to 648CH; 20H (JR NZ, from the link at 6411H) jumps there unless Register Pair BC was 19B4H, the ROM's error handling.
645D
LD HL,(6352H) 2A 52 63
The error path: load Register Pair HL with the file area's address from 6352H-6353H.
6460
LD A,(HL) 7E
Fetch the area's mode byte at Register Pair HL into Register A.
6461
OR A B7
OR Register A with itself: the Z FLAG is set when the area is not open.
6462
If the Z FLAG is set (the area is not open), JUMP to 648FH.
6464
PUSH HL E5
Save Register Pair HL (the area) onto the stack at the Stack Pointer.
6465
GOSUB to 61ACH: Registers C, L and H return the statement's NEXT.
6468
EX (SP),HL E3
Exchange Register Pair HL (NEXT's middle and high bytes) with the area on the stack at the Stack Pointer: Register Pair HL = the area.
6469
LD A,(570EH) 3A 0E 57
Fetch the statement's FCB+1 from 570EH into Register A.
646C
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer: Register A = the statement's FCB+1.
646D
GOSUB to 62BDH to copy the area's own header (as it was before the statement) to 5700H.
6470
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte after the 2DH bytes copied: the area's byte +2DH.
6472
POP BC C1
POP into Register Pair BC the word pushed from Register Pair AF: Register B = the statement's FCB+1.
6473
POP DE D1
POP into Register Pair DE the statement's NEXT middle and high bytes from the stack at the Stack Pointer.
6474
LD C,(IX+0EH) DD 4E 0E
Load Register C with the area's FCB+1 from Index Register IX+0EH (570EH).
6477
LD HL,(5717H) 2A 17 57
Load Register Pair HL with the area's NEXT middle and high bytes from 5717H-5718H.
647A
RST 18H DF
RST 18H compares Register Pair HL (the area's NEXT) with Register Pair DE (the statement's): the Z FLAG when they are in the same 256-byte block.
647B
If the NZ FLAG is set (the NEXT values differ), JUMP to 6485H.
647D
BIT 4,C CB 61
Test bit 4 of Register C, the area's own FCB+1 byte from 570EH.
647F
If the Z FLAG is set (bit 4 of the area's FCB+1 is clear), JUMP to 6485H.
6481
BIT 4,B CB 60
Test bit 4 of Register B, the statement's FCB+1.
6483
If the NZ FLAG is set, JUMP to 6485H: the offset is 00H, so either way the next instruction is 6485H and the three tests change nothing.
6485
RES 4,C CB A1
Clear bit 4 of Register C, the area's FCB+1. 647BH, 647FH and 6483H come here.
6487
SET 5,C CB E9
Set bit 5 of Register C: the buffer does not hold the sector at NEXT and is read again.
6489
LD (IX+0EH),C DD 71 0E
Store Register C (the new FCB+1) at Index Register IX+0EH (570EH).
648C
GOSUB to 634DH to copy the header at 5700H back to the file area. 645BH comes here.
648F
GOSUB to 635AH to clear the file statement flag and the work area. 6451H and 6462H come here.
6492
POP BC C1
Restore Register Pair BC (the caller's value) from the stack at the Stack Pointer. 6440H comes here.
6493
POP DE D1
Restore Register Pair DE (the caller's value) from the stack at the Stack Pointer.
6494
POP HL E1
Restore Register Pair HL (the caller's value) from the stack at the Stack Pointer.
6495
XOR A AF
Set Register A to 00H with the Z FLAG for the caller.
6496
RET C9
RETurn. This RET is also the cleanup routine called at 6426H when no overlay has put its own there.
6497H - Put Back the Cleanup Routine
Stores 6496H (a RET) in the operand at 6427H again. SYS19/SYS (its 5475H) and SYS21/SYS (its 4DB7H) jump here when they finish.
6497
LD HL,6496H 21 96 64
Load Register Pair HL with 6496H, the RET that serves as the cleanup routine when none is set.
649A
LD (6427H),HL 22 27 64
Store Register Pair HL (6496H) at 6427H-6428H, the operand of the CALL at 6426H.
649D
RET C9
RETurn with the cleanup routine back to 6496H.
649EH - File Area Size
Two bytes, not in the file, that hold the size of one file area: 012DH (301 bytes) stored by 6711H, or 022DH when 6730H sets the high byte to 02H.
649E-649F
DEFS 2
Not in the file (the load block before ends at 649DH, the next starts at 64A0H): the size of one file area, read by 5F6AH, 6511H, 65AFH and SYS20/SYS (its 5573H); 6711H stores 012DH (301 bytes) and 6730H makes the high byte 02H (022DH, 557 bytes).
64A0H - Three Bytes Before the Initialization
The load block 64A0H-6588H starts with three bytes that nothing runs or reads: 649DH is a RET and the entry code jumps to 64A3H.
64A0
LD A,(2C00H) 3A 00 2C
The bytes 3AH 00H 2CH decode as LD A,(2C00H), a load of Register A from 2C00H in the ROM, but no instruction jumps to 64A0H, so they are never run; 64A3H-65B9H are later BASIC's input buffer.
64A3H - Initialization: Check the Top of BASIC Memory
Reached from the JP 64A3H at 6759H, the end of the entry code at 66BEH, which has read the parameters after BASIC on the DOS command line and stored its results in the operands below: the memory size at 64A4H, the number of file areas at 6502H and the startup command pointer at 6537H. From 64D8H on, 64A3H-65B9H become BASIC's input buffer.
64A3
LD HL,0000H 21 00 00
Self-Modifying Code
Load Register Pair HL with the top of memory asked for, the operand at 64A4H-64A5H: 0000H in the file (none asked for), the memory size less 1 stored by 6741H, or the previous MEMSIZ stored by 66CEH for a start with an asterisk.
64A6
LD A,H 7C
Copy Register H, the high byte of the address asked for, into Register A.
64A7
OR L B5
OR Register L into Register A: the Z FLAG is set when no address was asked for (0000H).
64A8
LD DE,(4411H) ED 5B 11 44
Load Register Pair DE with HIMEM from 4411H-4412H, the highest address the DOS leaves to programs. LD does not change the flags.
64AC
If the NZ FLAG is set (an address was asked for), JUMP to 64B0H to check it against HIMEM in Register Pair DE.
64AE
LD H,D 62
None was asked for: copy Register D (the high byte of HIMEM) into Register H.
64AF
LD L,E 6B
Copy Register E (the low byte of HIMEM) into Register L: Register Pair HL = HIMEM, which passes the check below.
Limit Check
Register Pair HL = the top of memory BASIC is to use, Register Pair DE = HIMEM from 4411H. BASIC must not go above HIMEM.
64B0
LD A,D 7A
Copy Register D (the high byte of HIMEM) into Register A. 64ACH comes here.
64B1
CP H BC
Compare Register A (HIMEM's high byte) against Register H (the high byte of the top of memory). The CARRY FLAG is set when HIMEM is lower, the Z FLAG when they are equal.
64B2
If the NZ FLAG is set (the high bytes differ), JUMP to 64B6H: the CARRY FLAG decides.
64B4
LD A,E 7B
The high bytes are equal: copy Register E (HIMEM's low byte) into Register A.
64B5
CP L BD
Compare Register A (HIMEM's low byte) against Register L (the low byte of the top of memory). The CARRY FLAG is set when HIMEM is lower.
64B6
If the CARRY FLAG is set (the top of memory asked for is above HIMEM), JUMP to 57C9H, JP 402DH: BASIC is not started and the DOS returns to DOS READY. 64B2H comes here.
RAM Test
The top of memory in Register Pair HL is not above HIMEM; there must also be RAM at it.
64B9
LD B,(HL) 46
Fetch the byte at the top of memory, at Register Pair HL, into Register B, to put it back after the test.
64BA
LD A,D9H 3E D9
Load Register A with D9H, the test pattern written to the top of memory.
64BC
LD (HL),A 77
Store Register A (D9H) at Register Pair HL, the top of memory to test.
64BD
CP (HL) BE
Compare Register A (D9H) against the byte read back at Register Pair HL. The Z FLAG is set when RAM kept it.
64BE
If the NZ FLAG is set (no RAM there), JUMP to 57C9H, JP 402DH: back to DOS READY.
64C1
LD (HL),B 70
Store Register B (the original byte) back at Register Pair HL.
The ROM's Memory Pointers
Register Pair HL = the top of memory, checked.
64C2
LD (40B1H),HL 22 B1 40
Store Register Pair HL (the top of memory) at 40B1H-40B2H, the ROM's MEMSIZ, the highest address BASIC uses.
64C5
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, -50: BASIC starts with 50 bytes of string space, as after the ROM's own power-up.
64C8
ADD HL,DE 19
ADD Register Pair DE (-50) to Register Pair HL: the top of memory less 50.
64C9
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the ROM's STKTOP: the bottom of the string space, under which BASIC's stack lies.
64CCH - Initialization: Sign-On, Line Number, Input Buffer and BREAK
The message at 675CH is displayed, the current line number and the input buffer are set, bit 7 of 4289H is cleared, and with option AB (RUN-ONLY, bit 6 of 428CH) the BREAK hook at 4478H becomes JP and the keyboard scan of 63F8H is turned off (63FAH = 42H); otherwise 4478H becomes RET (BREAK gives the key 01H).
64CC
LD HL,675CH 21 5C 67
Point Register Pair HL to 675CH, the sign-on message (1CH 1FH, two lines of text, ended by 0DH).
64CF
GOSUB to SYS0/SYS 4467H, which sends the message at Register Pair HL to the display up to its 0DH (the end of the message at 67BAH).
64D2
LD HL,FFFEH 21 FE FF
Load Register Pair HL with FFFEH, a line number that is neither a program line (0-65529) nor FFFFH, the ROM's mark of a direct command.
64D5
LD (40A2H),HL 22 A2 40
Store Register Pair HL (FFFEH) at 40A2H-40A3H, the ROM's current line number, until the command loop stores FFFFH.
64D8
LD HL,64A3H 21 A3 64
Point Register Pair HL to 64A3H, the start of this initialization code, which becomes BASIC's input buffer from here on.
64DB
LD (40A7H),HL 22 A7 40
Store Register Pair HL (64A3H) at 40A7H-40A8H, the ROM's input buffer pointer: the ROM's line input stores typed lines from 64A3H on (at most 240 characters and a 00H, up to 6593H).
64DE
LD HL,4289H 21 89 42
Point Register Pair HL to 4289H, SYS0/SYS's system flags.
64E1
RES 7,(HL) CB BE
Clear bit 7 of the system flags at Register Pair HL (4289H), the bit SYS3/SYS sets and clears.
64E3
LD A,(428CH) 3A 8C 42
Fetch the option byte at 428CH (SYS0/SYS's copy of the system data byte F0H) into Register A.
64E6
BIT 6,A CB 77
Test bit 6 of Register A: option AB, RUN-ONLY. The NZ FLAG is set for it.
64E8
LD A,C9H 3E C9
Load Register A with C9H, the opcode RET, for the BREAK hook at 4478H. LD does not change the flags.
64EA
If the Z FLAG is set (not RUN-ONLY), JUMP to 64F2H to store C9H at 4478H.
64EC
LD A,H 7C
RUN-ONLY: copy Register H (42H, the high byte of 4289H) into Register A.
64ED
LD (63FAH),A 32 FA 63
Store Register A (42H) at 63FAH, the operand of the OR at 63F9H: not 00H, so the keyboard scan through link 41C4H gives no key and BREAK cannot stop the program.
64F0
LD A,C3H 3E C3
Load Register A with C3H, the opcode JP, for the BREAK hook at 4478H.
64F2
LD (4478H),A 32 78 44
Store Register A at 4478H, the opcode of SYS0/SYS's BREAK hook (JP 4546H in SYS0/SYS): C3H keeps the jump, so BREAK is not passed on as a key; C9H (RET) makes BREAK the key 01H for BASIC. 64EAH comes here.
64F5H - Initialization: Install the Disk BASIC Links
Copies the 147-byte link table 67BBH-684DH over the ROM's link area 4152H-41E4H (49 entries of 3 bytes). After this each link jumps into BASIC/CMD (or to the ROM for the links it leaves alone).
64F5
LD HL,67BBH 21 BB 67
Point Register Pair HL to 67BBH, the link table in this file.
64F8
LD DE,4152H 11 52 41
Point Register Pair DE to 4152H, the first link (CVI).
64FB
LD BC,0093H 01 93 00
Load Register Pair BC with 0093H (147), the length of the table: 49 links of 3 bytes, 4152H-41E4H.
64FE
DI F3
Disable interrupts while the links are being written and the Stack Pointer is moved at 6509H.
64FF
LDIR ED B0
Copy Register Pair BC (147) bytes from Register Pair HL (67BBH-684DH) to Register Pair DE (4152H-41E4H), counting Register Pair BC down to 0.
6501
LD A,03H 3E 03
Self-Modifying Code
Load Register A with the number of file areas, the operand at 6502H: 03H in the file, the number typed after BASIC (0-15) stored by 6726H, or the number worked out by 6747H for a start with an asterisk.
6503
LD (5F62H),A 32 62 5F
Store Register A (the number of file areas) at 5F62H, the operand of the CP at 5F61H that rejects higher file numbers and the count read by 5F8FH.
6506H - Initialization: Clear the File Areas
One file area per file, from 66BEH on, is cleared to 00H. The entry code at 66BEH is no longer needed, so the areas lie over it. Each area is the size at 649EH-649FH: 012DH (301 bytes), or 022DH (557 bytes) with V.
6506
LD HL,66BEH 21 BE 66
Point Register Pair HL to 66BEH, the first file area.
6509
LD SP,650DH 31 0D 65
Load the Stack Pointer with 650DH: the stack now grows down over the initialization code that has already run (6501H-650CH), inside BASIC/CMD.
650C
EI FB
Enable interrupts: the links are in place and the stack is set.
650D
OR A B7
OR Register A (the number of file areas) with itself: the Z FLAG is set for none.
650E
If the Z FLAG is set (no file areas), JUMP to 6521H with Register Pair HL = 66BEH.
Loop: one file area per pass.
6510
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': the number of areas left waits in Register A'. 651FH loops back here.
6511
LD BC,(649EH) ED 4B 9E 64
Load Register Pair BC with the size of one file area from 649EH-649FH.
Loop: one byte per pass.
6515
LD (HL),00H 36 00
Store 00H at Register Pair HL. 651BH loops back here.
6517
DEC BC 0B
DECrement Register Pair BC, the bytes of this area left.
6518
INC HL 23
INCrement Register Pair HL to the next byte of the file area.
6519
LD A,B 78
Copy Register B, the high byte of the count, into Register A.
651A
OR C B1
OR Register C into Register A: the Z FLAG is set when Register Pair BC is 0000H.
651B
If the NZ FLAG is set (bytes left), LOOP BACK to 6515H.
651D
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': Register A = the number of areas left.
651E
DEC A 3D
DECrement Register A, the number of file areas still to clear.
651F
If the NZ FLAG is set (areas left), LOOP BACK to 6510H; Register Pair HL is at the next area.
6521H - Initialization: Program Start, Room Check and NEW
Register Pair HL is after the last file area (66BEH when there are none). A 00H byte must come before the first program line, so it goes here and the program starts at the next byte. At least 300 bytes must be left up to the top of memory.
6521
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte before the first line of the program. 650EH comes here.
6523
INC HL 23
INCrement Register Pair HL to where the program starts.
6524
LD (40A4H),HL 22 A4 40
Store Register Pair HL at 40A4H-40A5H, the ROM's TXTTAB, the start of the program.
6527
LD DE,012CH 11 2C 01
Load Register Pair DE with 012CH (300), the least room BASIC needs above the start of the program.
652A
ADD HL,DE 19
ADD Register Pair DE (300) to Register Pair HL: the lowest top of memory allowed.
652B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the program start plus 300.
652C
LD HL,(40B1H) 2A B1 40
Load Register Pair HL with MEMSIZ from 40B1H-40B2H, the top of memory stored at 64C2H.
652F
RST 18H DF
RST 18H compares Register Pair HL (MEMSIZ) with Register Pair DE (the program start plus 300): the CARRY FLAG is set when MEMSIZ is lower.
6530
If the CARRY FLAG is set (too little memory for the file areas), JUMP to 57C9H, JP 402DH: back to DOS READY.
6533
GOSUB to ROM 1B4DH (SCRTCH, the work of NEW): TRACE and AUTO off, 00H 00H at the start of the program, VARTAB (40F9H) after them, the variables cleared and the stack set up again.
6536H - Startup Command
What BASIC does first, from the text after BASIC and its numbers on the DOS command line. When it starts with an asterisk, the program of the previous session is still in memory: its first link and its end, saved by the entry code before NEW, are put back and the command LIST is queued. Otherwise a command typed there is queued, or BASIC simply shows READY.
6536
LD HL,0000H 21 00 00
Self-Modifying Code
Load Register Pair HL with the startup command pointer, the operand at 6537H-6538H stored by 674BH (0000H in the file): the asterisk, the first character after the numbers, or the 0DH at the end of the command line.
6539
LD A,(HL) 7E
Fetch the first character of the startup text at Register Pair HL into Register A.
653A
CP 2AH FE 2A
Compare Register A against 2AH (an asterisk). The Z FLAG is set for it.
653C
If the NZ FLAG is set (no asterisk), JUMP to 6555H.
A Start With an Asterisk
SCRTCH at 6533H wrote 00H 00H over the first line's link and moved VARTAB; the entry code kept both.
653E
LD BC,0000H 01 00 00
Self-Modifying Code
Load Register Pair BC with the first line's link of the program in memory, the operand at 653FH-6540H stored by 66DDH (0000H in the file, kept for an empty program).
6541
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with TXTTAB from 40A4H-40A5H, the start of the program, where SCRTCH wrote 00H 00H.
6544
LD (HL),C 71
Store Register C, the low byte of the link, at Register Pair HL.
6545
INC HL 23
INCrement Register Pair HL to the high byte of the link.
6546
LD (HL),B 70
Store Register B, the high byte of the link, at Register Pair HL: the program's chain of lines is whole again.
6547
LD HL,0000H 21 00 00
Self-Modifying Code
Load Register Pair HL with the program's end, the VARTAB value at 6548H-6549H stored by 66E7H (0000H in the file).
654A
GOSUB to ROM 1B5AH, the LD (40F9H),HL inside SCRTCH: VARTAB = the program's end, then the variables are cleared and the stack set up again above the program.
654D
LD HL,54E4H 21 E4 54
Point Register Pair HL to 54E4H, the text LIST ended by 0DH in SYS18/SYS (in memory at 5200H-56E7H since the entry code at 66C1H).
6550
LD (6537H),HL 22 37 65
Store Register Pair HL (54E4H) at 6537H-6538H, the startup command pointer, for the copy at 6570H.
6553
JUMP to 6559H to set the startup hook at 5205H for the LIST command.
No Asterisk
Register A = the first character of the startup text.
6555
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line. The Z FLAG is set when no command was typed. 653CH comes here.
6557
If the Z FLAG is set, JUMP to 655FH to show READY without a startup command.
Queue the Startup Command
The operand at 6537H-6538H points to the command text.
6559
LD HL,6562H 21 62 65
Point Register Pair HL to 6562H, the startup hook. 6553H comes here.
655C
LD (5205H),HL 22 05 52
Store Register Pair HL (6562H) at 5205H-5206H, the operand of the CALL 0033H at 5204H in SYS18/SYS's line input code (its 5202H): the first command line input calls 6562H instead.
655F
JUMP to ROM 1A19H, READY, which shows READY and goes to the command loop, which reads a line through the line input 0361H and link 41AFH (575DH, then SYS18/SYS at 5202H). 6557H comes here.
6562H - Startup Hook
Called once through the CALL at 5204H in SYS18/SYS (patched at 655CH) when the command loop reads its first line: the queued command is copied into the input buffer and handed back through the ROM's line input exit at 0379H as if it had been typed. The CALL is put back to 0033H.
6562
POP HL E1
POP the return address of the CALL at 5204H (5207H in SYS18/SYS) from the stack at the Stack Pointer into Register Pair HL, dropping it: the line is not read from the keyboard.
6563
LD HL,0033H 21 33 00
Load Register Pair HL with 0033H, the address the CALL at 5204H normally has (the ROM's display routine).
6566
LD (5205H),HL 22 05 52
Store Register Pair HL (0033H) at 5205H-5206H: the hook is used only once.
6569
PUSH BC C5
Save Register Pair BC onto the stack at the Stack Pointer, for the POP BC at 037FH in the ROM's line input exit (which stands for its PUSH BC at 036BH).
656A
LD HL,6585H 21 85 65
Point Register Pair HL to 6585H, the string 1DH 1BH 1FH 03H.
656D
GOSUB to SYS0/SYS 4467H to send the string at Register Pair HL to the display: the cursor goes to the start of the line, up one line (to READY) and the screen is erased from there.
6570
LD DE,(6537H) ED 5B 37 65
Load Register Pair DE with the startup command pointer from 6537H-6538H, the source.
6574
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer address from 40A7H-40A8H (64A3H), the destination.
Loop: copy the command and its 0DH into the input buffer.
6577
LD A,(DE) 1A
Fetch the next character of the command at Register Pair DE into Register A. 657DH loops back here.
6578
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command. The Z FLAG is set at the end.
657A
LD (HL),A 77
Store Register A at Register Pair HL in the input buffer (the 0DH too). LD does not change the flags.
657B
INC DE 13
INCrement Register Pair DE to the next character of the command.
657C
INC HL 23
INCrement Register Pair HL to the next byte of the buffer.
657D
If the NZ FLAG is set (not the 0DH yet), LOOP BACK to 6577H.
657F
XOR A AF
Set Register A to 00H, which also clears the CARRY FLAG.
6580
PUSH AF F5
Save Register Pair AF onto the stack at the Stack Pointer (Register A = 00H, the CARRY FLAG clear: the line ended with ENTER, not BREAK), for the POP AF at 037EH.
6581
DEC HL 2B
DECrement Register Pair HL back to the 0DH in the buffer.
6582
JUMP to ROM 0379H, the end of the line input: it stores 00H over the 0DH at Register Pair HL, loads Register Pair HL with the buffer from 40A7H, takes back Register Pairs AF and BC, and returns to the command loop at 1A7EH, which runs the command.
6585H - Screen Control String (Data)
The four bytes displayed at 656DH through SYS0/SYS 4467H; the last bytes of the load block that started at 64A0H (6589H-65A1H are not in the file).
6585-6588
DEFB 1DH, 1BH, 1FH, 03H 1D 1B 1F 03
1DH moves the cursor to the start of its line, 1BH moves it up one line, 1FH erases to the end of the screen, and 03H ends the string for 4467H without a new line.
6589-65A1
DEFS 25
Not in the file: the load block ends at 6588H and the next one starts at 65A2H. The input buffer from 64A3H can reach into these bytes.
65A2H - Work Byte and Unused Bytes (Data)
The first six bytes of the load block 65A2H-669FH.
65A2
DEFB 00H 00
A byte that 642AH sets to 00H at the end of every file statement (00H in the file); no instruction of BASIC/CMD or of the overlays reads it.
65A3-65A5
DEFB 00H, 00H, 00H 00 00 00
Three 00H bytes that nothing reads or writes. SYS11/SYS uses 65A3H only as an address to compare with (LD DE,65A3H at its 4D5CH).
65A6-65A7
DEFB 2AH, 2AH 2A 2A
Two asterisks (2AH 2AH) that nothing reads, writes or runs; 65A8H is entered by its CALL from 61E1H.
65A8H - Read NEXT and the End of File, Register Pair BC Kept
Called from 61E1H. 61BAH returns NEXT in Registers C, L and H and the end of file in Register A and Register Pair DE; this routine hands back NEXT's low byte in Register A instead and keeps the caller's Register Pair BC.
65A8
PUSH BC C5
Save Register Pair BC (the caller's value: Register B = the number of data bytes) onto the stack at the Stack Pointer, since 61BAH returns NEXT's low byte in Register C.
65A9
GOSUB to 61BAH: Registers C, L and H return NEXT (from 5712H and 5717H-5718H), Register Pair DE the middle and high bytes of the end of file (5719H-571AH) and Register A its low byte.
65AC
LD A,C 79
Copy Register C (NEXT's low byte) into Register A.
65AD
POP BC C1
Restore Register Pair BC (the caller's value) from the stack at the Stack Pointer.
65AE
RET C9
RETurn to 61E4H with Register A = NEXT's low byte, Register Pair HL = NEXT's middle and high bytes and Register Pair DE = the end of file's.
65AFH - Size of One File Area
Called from 5F9AH by the close-all loop, which steps from one file area to the next.
65AF
LD DE,(649EH) ED 5B 9E 64
Load Register Pair DE with the size of one file area from 649EH-649FH: 012DH (301 bytes), or 022DH (557 bytes) with V, or the size kept from the previous session after a start with an asterisk.
65B3
RET C9
RETurn to 5F9DH with the size of one file area in Register Pair DE.
65B4H - Helpers for SYS21/SYS
The routines 65B4H-661BH are called only by SYS21/SYS (65B4H at its 4E0DH, 65B9H at 4E78H, 65EBH at 4E87H, 65F4H at 50DFH, 65FFH at 5119H, 6608H at 51A9H). They work on the block at Index Register IX that SYS21/SYS sets up, and on SYS21/SYS's own bytes at 4F02H and 5102H.
65B4
SET 7,(IX+04H) DD CB 04 FE
Set bit 7 of the byte at Index Register IX+04H, in the block that SYS21/SYS points to.
65B8
RET C9
RETurn to SYS21/SYS (its 4E10H) with bit 7 of the byte at Index Register IX+04H set.
65B9H - Look Through the Entries at 4300H (SYS21/SYS)
With the NZ FLAG from the caller it is ILLEGAL FUNCTION CALL. Otherwise the word at Index Register IX+05H-+06H is compared with the word at +05H-+06H of each 17H-byte entry from 4300H (from 4317H when SYS21/SYS's byte at 5102H is not 00H), while each entry's first byte is below Register C; every match sets bit 6 of the byte at Index Register IX+04H.
65B9
If the NZ FLAG is set (from SYS21/SYS's RST 18H at its 4E77H), JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
65BC
LD A,(5102H) 3A 02 51
Fetch the byte at 5102H, in SYS21/SYS (stored by it at its 4E04H), into Register A.
65BF
OR A B7
OR Register A with itself: the Z FLAG is set when the byte at 5102H is 00H.
65C0
LD IY,4300H FD 21 00 43
Point Index Register IY to 4300H, the first 17H-byte entry, in SYS0/SYS's sector buffer. LD does not change the flags.
65C4
If the Z FLAG is set (5102H holds 00H), JUMP to 65CAH and start at 4300H.
65C6
LD IY,4317H FD 21 17 43
Point Index Register IY to 4317H, the second entry, so that the first one is left out.
65CA
PUSH HL E5
Save Register Pair HL (the caller's value) onto the stack at the Stack Pointer. 65C4H comes here.
65CB
LD L,(IX+05H) DD 6E 05
Load Register L with the byte at Index Register IX+05H, the low byte of the word to look for.
65CE
LD H,(IX+06H) DD 66 06
Load Register H with the byte at Index Register IX+06H: Register Pair HL = the word to look for.
Loop: one entry per pass; Index Register IY points to it.
65D1
LD E,(IY+05H) FD 5E 05
Load Register E with the byte at Index Register IY+05H, the low byte of the entry's word. 65E7H loops back here.
65D4
LD D,(IY+06H) FD 56 06
Load Register D with the byte at Index Register IY+06H: Register Pair DE = the entry's word.
65D7
RST 18H DF
RST 18H compares Register Pair HL (the word looked for) with Register Pair DE (the entry's word): the Z FLAG when they are equal.
65D8
If the NZ FLAG is set (no match), JUMP to 65DEH.
65DA
SET 6,(IX+04H) DD CB 04 F6
A match: set bit 6 of the byte at Index Register IX+04H.
65DE
LD DE,0017H 11 17 00
Load Register Pair DE with 0017H (23), the length of an entry. 65D8H comes here.
65E1
ADD IY,DE FD 19
ADD Register Pair DE (23) to Index Register IY: the next entry.
65E3
LD A,(IY+00H) FD 7E 00
Fetch the next entry's first byte at Index Register IY+00H into Register A.
65E6
CP C B9
Compare Register A against Register C, the limit from SYS21/SYS (its 4E70H). The CARRY FLAG is set when the byte is below it.
65E7
If the CARRY FLAG is set, LOOP BACK to 65D1H to compare this entry.
65E9
POP HL E1
Restore Register Pair HL (the caller's value) from the stack at the Stack Pointer.
65EA
RET C9
RETurn to SYS21/SYS with bit 6 of the byte at Index Register IX+04H set if any entry matched.
65EBH - Store at 4F02H Unless Bit 6 Is Set (SYS21/SYS)
When bit 6 of the byte at Index Register IX+04H (set at 65DAH) is clear, Register A is stored at 4F02H, a byte in SYS21/SYS.
65EB
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of the byte at Index Register IX+04H. The NZ FLAG is set when it is 1.
65EF
RET NZ C0
If the NZ FLAG is set, RETurn to SYS21/SYS without storing.
65F0
LD (4F02H),A 32 02 4F
Store Register A (from SYS21/SYS, its 4E81H-4E84H) at 4F02H, the byte in SYS21/SYS it was taken from.
65F3
RET C9
RETurn to SYS21/SYS (its 4E8AH) with Register A stored at 4F02H.
65F4H - Load the Byte at IX+13H and, When Bit 6 Is Set, Add BC to HL (SYS21/SYS)
Register E = the byte at Index Register IX+13H. With bit 6 of the byte at Index Register IX+04H set, the return address is dropped, Register Pair BC is added to Register Pair HL and the RET goes to the caller's caller.
65F4
LD E,(IX+13H) DD 5E 13
Load Register E with the byte at Index Register IX+13H.
65F7
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of the byte at Index Register IX+04H. The Z FLAG is set when it is 0.
65FB
RET Z C8
If the Z FLAG is set, RETurn to SYS21/SYS (its 50E2H) with Register E loaded.
65FC
POP AF F1
Bit 6 is 1: POP the return address from the stack at the Stack Pointer into Register Pair AF, dropping it.
65FD
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL, both as SYS21/SYS passed them.
65FE
RET C9
RETurn to the word under the dropped return address (the caller's caller) with Register Pair HL increased by Register Pair BC.
65FFH - Add DE to HL Register B Times Unless Bit 6 Is Set (SYS21/SYS)
Reached by SYS21/SYS's JP at its 5119H. With bit 6 of the byte at Index Register IX+04H clear, Register Pair DE is added to Register Pair HL Register B times (256 times for 00H).
65FF
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of the byte at Index Register IX+04H. The NZ FLAG is set when it is 1.
6603
RET NZ C0
If the NZ FLAG is set, RETurn with Register Pair HL unchanged.
Loop: Register B times.
6604
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL. 6605H loops back here.
6605
DECrement Register B and LOOP BACK to 6604H until it is 0.
6607
RET C9
RETurn with Register Pair HL increased by Register Pair DE times the Register B it came with, and Register B = 00H.
6608H - Store H at IX+0AH and Move a Block Down (SYS21/SYS)
Called by SYS21/SYS at its 51A9H. Register H is stored at Index Register IX+0AH. Unless bit 6 of the byte at Index Register IX+04H is set, the Register Pair BC bytes that end just before Register Pair DE are moved so that they end just before Register Pair HL + Register Pair BC, from the top byte down.
6608
LD (IX+0AH),H DD 74 0A
Store Register H (the high byte of the destination) at Index Register IX+0AH.
660B
ADD HL,BC 09
ADD Register Pair BC (the number of bytes) to Register Pair HL: the address just after the destination.
660C
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the address after the destination, Register Pair HL = the address after the source.
660D
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of the byte at Index Register IX+04H. The NZ FLAG is set when it is 1.
6611
RET NZ C0
If the NZ FLAG is set, RETurn without moving anything.
6612
LD A,B 78
Copy Register B, the high byte of the count, into Register A.
6613
OR C B1
OR Register C into Register A: the Z FLAG is set when the count is 0000H.
6614
If the Z FLAG is set, JUMP to 661AH: nothing to move.
6616
DEC HL 2B
DECrement Register Pair HL to the last byte of the source.
6617
DEC DE 1B
DECrement Register Pair DE to the last byte of the destination.
6618
LDDR ED B8
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE, downward, counting Register Pair BC down to 0, so that a destination above the source is filled correctly.
661A
XOR A AF
Set Register A to 00H with the Z FLAG. 6614H comes here.
661B
RET C9
RETurn to SYS21/SYS with Register A = 00H and the Z FLAG.
661CH - Helpers for SYS10/SYS
661CH (reached by SYS10/SYS's JP at its 4DE1H) and 6623H (called at its 4E60H) evaluate an expression through 6190H and go on in SYS10/SYS at 4DE4H and 4E17H; 662CH (called at its 4E64H) tests Registers A, L and C for 0.
661C
GOSUB to 6623H, which evaluates the expression at Register Pair HL and jumps to 4DE4H in SYS10/SYS with this CALL's return address (661FH) on top of the stack.
661F
PUSH HL E5
Save Register Pair HL (as 4DE4H returned it) onto the stack at the Stack Pointer. 4DE4H returns here.
6620
JUMP to 4E17H in SYS10/SYS with Register Pair HL on the stack.
6623
GOSUB to 6190H to evaluate the expression at Register Pair HL: it leaves the text pointer on the stack, and returns the Z FLAG with Register B = the length and Register Pair HL = the text for a string, the NZ FLAG for a number.
6626
POP HL E1
POP into Register Pair HL the text pointer that 6190H left on the stack at the Stack Pointer.
6627
EX (SP),HL E3
Exchange Register Pair HL (the text pointer) with this routine's return address on the stack at the Stack Pointer: the text pointer goes in its place.
6628
PUSH HL E5
Push Register Pair HL (the return address) back onto the stack at the Stack Pointer, above the text pointer. The flags and Register B from 6190H are kept.
6629
JUMP to 4DE4H in SYS10/SYS with the return address on top of the stack and the text pointer under it.
662C
OR L B5
OR Register L into Register A (the caller's value).
662D
OR C B1
OR Register C into Register A: the Z FLAG is set when Registers A, L and C were all 00H.
662E
If the Z FLAG is set, JUMP to 5DB2H, BAD RECORD #.
6631
LD A,C 79
Copy Register C (the value from SYS10/SYS) into Register A.
6632
OR A B7
OR Register A with itself: the flags from Register C.
6633
RET C9
RETurn to SYS10/SYS with Register A = Register C and the flags set from it.
6634H - Require Fixed-Length Records
Called from 5EC5H for LOF and plain LOC: bit 2 of the mode byte at Index Register IX+00H (5700H) must be set, else BAD FILE MODE.
6634
BIT 2,(IX+00H) DD CB 00 56
Test bit 2 of the mode byte at Index Register IX+00H (5700H): fixed-length records. The Z FLAG is set when it is 0.
6638
If the Z FLAG is set, JUMP to 5DA9H, BAD FILE MODE.
663B
RET C9
RETurn to 5EC8H with the NZ FLAG still set from the BIT test.
663CH - Unused Bytes
128 bytes of 00H: 663CH-669FH end the load block from 65A2H, and 66A0H-66BBH begin the block 66A0H-66C7H.
663C-669F
DEFB 00H x 100 00 x 100
100 bytes of 00H at the end of the load block 65A2H-669FH. No instruction of BASIC/CMD or of the overlays reads, writes or runs them; the file areas cleared by 6506H can lie over them.
66A0-66BB
DEFB 00H x 28 00 x 28
The first 28 bytes of the load block 66A0H-66C7H, all 00H. Its last 12 bytes (66BCH-66C7H, also 00H in that block) are loaded again by the next block, which puts the entry code there; the bytes shown from 66BCH on are those of the later block.
66BC-66BD
DEFB 2AH, 2AH 2A 2A
Two asterisks (2AH 2AH), from the load block that starts at 66BCH; nothing reads them, and the DOS enters BASIC/CMD at its transfer address 66BEH just after them.
66BEH - Program Entry
The DOS runs BASIC/CMD here, its transfer address, with Register Pair HL pointing into the DOS command line just after the name BASIC. SYS18/SYS is loaded first through the overlay loader. Then the rest of the command line is read: BASIC followed by an asterisk restarts with the previous session's program still in memory, otherwise numbers give the file areas (0-15, V for 557-byte areas) and the memory size (256 or more), and any further text is the startup command. A bad parameter returns to DOS READY. The code ends at 6759H with JP 64A3H; from 6506H on the file areas lie over it.
66BE
LD BC,66C4H 01 C4 66
Load Register Pair BC with 66C4H, where the overlay loader is to go on after loading SYS18/SYS.
66C1
JUMP to 576AH, which loads Register A with 34H (SYS18/SYS), pushes Register Pair BC (66C4H), loads SYS18/SYS through RST 28H (its entry at 5200H returns at once), records 34H at 576EH and RETurns to 66C4H with Register Pair HL kept.
66C4
DEC HL 2B
DECrement Register Pair HL, the command line pointer, so that the RST 10H reads the first character after BASIC.
66C5
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A; the CARRY FLAG is set for a digit.
66C6
CP 2AH FE 2A
Compare Register A against 2AH (an asterisk). The Z FLAG is set when an asterisk follows BASIC.
66C8
If the NZ FLAG is set (no asterisk), JUMP to 670DH to read the numbers.
A Start With an Asterisk
The previous session's program, its pointers and the file area size are still in memory. The program must be whole; the two values NEW will destroy are kept, and the number of file areas is worked out from where the program starts: TXTTAB = 66BFH + the number of areas x the area size.
66CA
PUSH HL E5
Save Register Pair HL (the address of the asterisk) onto the stack at the Stack Pointer; it becomes the startup command pointer at 674BH.
66CB
LD HL,(40B1H) 2A B1 40
Load Register Pair HL with MEMSIZ from 40B1H-40B2H, the previous session's top of memory.
66CE
LD (64A4H),HL 22 A4 64
Store Register Pair HL (the previous MEMSIZ) at 64A4H-64A5H, the operand of the LD HL at 64A3H, so that the top of memory stays the same.
66D1
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with TXTTAB from 40A4H-40A5H, the start of the program in memory.
66D4
PUSH HL E5
Save Register Pair HL (TXTTAB) onto the stack at the Stack Pointer for 66F5H.
66D5
LD E,(HL) 5E
Load Register E with the low byte of the first line's link at Register Pair HL (TXTTAB): the address of the second line, or 0000H for an empty program.
66D6
INC HL 23
INCrement Register Pair HL to TXTTAB+1, the high byte of the link.
66D7
LD D,(HL) 56
Load Register D with the high byte of the link from Register Pair HL: Register Pair DE = the first line's link.
66D8
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the link, Register Pair DE = TXTTAB+1.
66D9
LD A,H 7C
Copy Register H, the high byte of the link, into Register A.
66DA
OR L B5
OR Register L into Register A: the Z FLAG is set for a link of 0000H, an empty program.
66DB
If the Z FLAG is set (an empty program), JUMP to 66E4H; the operand at 653FH keeps 0000H.
66DD
LD (653FH),HL 22 3F 65
Store Register Pair HL (the first line's link) at 653FH-6540H, the operand of the LD BC at 653EH, which puts it back after NEW.
66E0
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = TXTTAB+1, Register Pair DE = the link.
66E1
RST 18H DF
RST 18H compares Register Pair HL (TXTTAB+1) with Register Pair DE (the link): the CARRY FLAG is set when the link lies above the start of the program, as it must.
66E2
If the NO CARRY FLAG is set (not a valid program), JUMP to 673DH: back to DOS READY.
66E4
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the address after the program in memory. 66DBH comes here.
66E7
LD (6548H),HL 22 48 65
Store Register Pair HL (VARTAB) at 6548H-6549H, the operand of the LD HL at 6547H, which gives it back to ROM 1B5AH after NEW.
66EA
DEC HL 2B
DECrement Register Pair HL to VARTAB-1, the second byte of the program's 00H 00H end mark.
66EB
LD A,(HL) 7E
Fetch the byte at Register Pair HL (VARTAB-1) into Register A.
66EC
DEC HL 2B
DECrement Register Pair HL to VARTAB-2, the first byte of the end mark.
66ED
OR (HL) B6
OR the byte at Register Pair HL (VARTAB-2) into Register A: the Z FLAG is set when both bytes are 00H.
66EE
If the NZ FLAG is set (no end mark below VARTAB), JUMP to 673DH: back to DOS READY.
66F0
RST 18H DF
RST 18H compares Register Pair HL (VARTAB-2, the end mark) with Register Pair DE (the first line's link, or TXTTAB+1 for an empty program): the CARRY FLAG is set when the end mark lies below it.
66F1
If the CARRY FLAG is set, JUMP to 673DH: back to DOS READY (an empty program ends here too).
66F3
OR FFH F6 FF
OR Register A with FFH: Register A = FFH, which the loop at 6700H makes 00H on its first pass, and the CARRY FLAG is clear for the SBC.
66F5
POP HL E1
POP into Register Pair HL the TXTTAB saved at 66D4H from the stack at the Stack Pointer.
66F6
LD DE,66BFH 11 BF 66
Load Register Pair DE with 66BFH, the start of the program when there are no file areas (66BEH holds its 00H).
66F9
SBC HL,DE ED 52
SUBtract Register Pair DE (66BFH) from Register Pair HL (TXTTAB): the room the file areas took, the number of areas x the area size.
66FB
LD DE,(649EH) ED 5B 9E 64
Load Register Pair DE with the area size from 649EH-649FH, still the previous session's (670EH-6711H do not run on this path).
66FF
ADD HL,DE 19
ADD Register Pair DE (one area size) to Register Pair HL, so that the first pass takes it off again.
Loop: Register A counts the areas; each pass takes one area size off Register Pair HL until it is 0.
6700
INC A 3C
INCrement Register A, the number of areas (00H on the first pass). 6709H loops back here.
6701
OR A B7
OR Register A with itself, which clears the CARRY FLAG for the SBC; Register A is unchanged.
6702
SBC HL,DE ED 52
SUBtract Register Pair DE (the area size) from Register Pair HL. The Z FLAG is set when it reaches 0000H: exactly Register A areas.
6704
If the Z FLAG is set, JUMP to 6747H with the number of file areas in Register A.
6707
CP 0FH FE 0F
Compare Register A against 0FH (15). The CARRY FLAG is set while it is below 15.
6709
If the CARRY FLAG is set, LOOP BACK to 6700H to try one area more.
670B
No number from 0 to 15 fits the program's start: JUMP to 673DH, back to DOS READY.
670DH - Read the Numbers
No asterisk: the area size is set to 301 bytes, then numbers separated by commas are read. A value of 0-15 is the number of file areas and may be followed by V for 557-byte areas; a value of 256 or more is the memory size; 16-255 is an error. The first character that is not a digit starts the startup command.
670D
DEC HL 2B
DECrement Register Pair HL back to the character before the one tested, so that the RST 10H at 6715H reads it again. 66C8H comes here.
670E
LD BC,012DH 01 2D 01
Load Register Pair BC with 012DH (301), the size of one file area.
6711
LD (649EH),BC ED 43 9E 64
Store Register Pair BC (012DH) at 649EH-649FH, the area size read by 6511H, 5F6AH and 65AFH.
Loop: one number per pass.
6715
RST 10H D7
RST 10H: INCrement Register Pair HL and load the next character that is not a space into Register A; the CARRY FLAG is set for a digit. 6737H loops back here.
6716
If the NO CARRY FLAG is set (not a digit), JUMP to 674BH: Register Pair HL points to the startup command or to the 0DH at the end of the line.
6718
GOSUB to 5CD5H to read the decimal number at Register Pair HL into Register Pair DE; Register Pair HL returns at the first character that is not a digit and the CARRY FLAG is set past 65535.
671B
If the CARRY FLAG is set (above 65535), JUMP to 673DH: back to DOS READY.
671D
LD A,D 7A
Copy Register D, the high byte of the value, into Register A.
671E
OR A B7
OR Register A with itself: the NZ FLAG is set for 256 or more.
671F
If the NZ FLAG is set, JUMP to 6740H: the memory size.
6721
LD A,E 7B
Copy Register E, the value (0-255), into Register A.
6722
CP 10H FE 10
Compare Register A against 10H (16). The CARRY FLAG is set below 16.
6724
If the NO CARRY FLAG is set (16-255), JUMP to 673DH: back to DOS READY.
6726
LD (6502H),A 32 02 65
Store Register A (the number of file areas, 0-15) at 6502H, the operand of the LD A at 6501H.
6729
LD A,(HL) 7E
Fetch the character after the number at Register Pair HL into Register A.
672A
CP 56H FE 56
Compare Register A against 56H (V). The Z FLAG is set for V.
672C
If the NZ FLAG is set (no V after the number), JUMP to 6734H.
672E
LD A,02H 3E 02
Load Register A with 02H, the high byte of the larger area size.
6730
LD (649FH),A 32 9F 64
Store Register A (02H) at 649FH, the high byte of the area size: 022DH (557 bytes) instead of 012DH.
6733
RST 10H D7
RST 10H: INCrement Register Pair HL past the V and load the next character that is not a space into Register A.
6734
LD A,(HL) 7E
Fetch the character after the number at Register Pair HL into Register A. 672CH and 6745H come here.
6735
CP 2CH FE 2C
Compare Register A against 2CH, a comma. The Z FLAG is set when another number follows.
6737
If the Z FLAG is set (a comma), LOOP BACK to 6715H for the next number.
6739
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line. The Z FLAG is set for it.
673B
If the Z FLAG is set, JUMP to 674BH with Register Pair HL at the 0DH: no startup command.
673D
A bad parameter, or a program in memory that does not fit, after BASIC: JUMP to 57C9H, JP 402DH, back to DOS READY without starting BASIC. 66E2H, 66EEH, 66F1H, 670BH, 671BH and 6724H come here too.
6740
DEC DE 1B
The value in Register Pair DE is the memory size: DECrement Register Pair DE to the highest address BASIC is to use. 671FH comes here.
6741
LD (64A4H),DE ED 53 A4 64
Store Register Pair DE at 64A4H-64A5H, the operand of the LD HL at 64A3H, which checks it against HIMEM and for RAM.
6745
JUMP to 6734H to look at the character after the memory size (a V is not taken here).
6747H - Store the Results and Go On
6747H is reached from 6704H with the number of file areas of a start with an asterisk in Register A; 674BH from the number reader with Register Pair HL at the startup command or at the 0DH. The ROM's division table is copied to RAM as at power-up, and initialization goes on at 64A3H.
6747
LD (6502H),A 32 02 65
Store Register A (the number of file areas worked out at 6700H) at 6502H, the operand of the LD A at 6501H.
674A
POP HL E1
POP into Register Pair HL the address of the asterisk saved at 66CAH from the stack at the Stack Pointer.
674B
LD (6537H),HL 22 37 65
Store Register Pair HL at 6537H-6538H, the operand of the LD HL at 6536H: the asterisk, the first character of the startup command, or the 0DH at the end of the line. 6716H and 673BH come here.
674E
LD HL,18F7H 21 F7 18
Point Register Pair HL to ROM 18F7H, the 39 bytes the ROM copies to RAM at power-up for its division code.
6751
LD DE,4080H 11 80 40
Point Register Pair DE to 4080H, where those bytes go (4080H-40A6H).
6754
LD BC,0027H 01 27 00
Load Register Pair BC with 0027H (39), the number of bytes.
6757
LDIR ED B0
Copy Register Pair BC (39) bytes from Register Pair HL (ROM 18F7H-191DH) to Register Pair DE (4080H-40A6H), counting Register Pair BC down to 0.
6759
JUMP to 64A3H to set up BASIC with the values stored in the operands.
675CH - Sign-On Message (Data)
Displayed at 64CFH through SYS0/SYS 4467H, which stops at the 0DH at 67BAH: a cleared screen, then two lines of mixed case text.
675C-675D
DEFB 1CH, 1FH 1C 1F
1CH moves the cursor to the top left and 1FH erases to the end of the screen: the screen is cleared before the message. 64CCH points here.
675E-6789
DEFM "Disk Basic. Radio Shack's ROM Enhanced With" 44 69 73 6B 20 42 61 73 69 63 2E 20 20 52 61 64 69 6F 20 53 68 61 63 6B 27 73 20 52 4F 4D 20 45 6E 68 61 6E 63 65 64 20 57 69 74 68
The first line of the sign-on message, 44 characters.
678A
DEFB 0AH 0A
0AH, a line feed: the text goes on at the start of the next line.
678B-67B8
DEFM "Apparat's NewDos80 Extended and Disk Features." 41 70 70 61 72 61 74 27 73 20 4E 65 77 44 6F 73 38 30 20 45 78 74 65 6E 64 65 64 20 61 6E 64 20 44 69 73 6B 20 46 65 61 74 75 72 65 73 2E
The second line of the sign-on message, 46 characters.
67B9-67BA
DEFB 0AH, 0DH 0A 0D
0AH, a line feed, then 0DH, which ends the message for 4467H (and is sent as a carriage return).
67BBH - Disk BASIC Link Table (Copied to 4152H-41E4H)
49 entries of three bytes, 67BBH-684DH, copied by the LDIR at 64FFH over the ROM's link area 4152H-41E4H. They run there, not here: each row names the link it becomes. 4152H-41A5H are the ROM's links for the Disk BASIC words; 41A6H-41E4H are the links the ROM calls from its own routines.
67BB
Copied to 4152H, the link for the CVI function: JUMP to 58CEH. 58CEH is its code in BASIC/CMD.
67BE
Copied to 4155H, the link for FN (called by the ROM at 2524H): JUMP to 577FH. 577FH is its code in BASIC/CMD.
67C1
Copied to 4158H, the link for the CVS function: JUMP to 58CBH. 58CBH is its code in BASIC/CMD.
67C4
Copied to 415BH, the link for the DEF statement: JUMP to 583FH. 583FH is its code in BASIC/CMD.
67C7
Copied to 415EH, the link for the CVD function: JUMP to 58C8H. 58C8H is its code in BASIC/CMD.
67CA
Copied to 4161H, the link for the EOF function: JUMP to 5E9EH. 5E9EH is its code in BASIC/CMD.
67CD
Copied to 4164H, the link for the LOC function: JUMP to 5EAAH. 5EAAH is its code in BASIC/CMD.
67D0
Copied to 4167H, the link for the LOF function: JUMP to 5EA2H. 5EA2H is its code in BASIC/CMD.
67D3
Copied to 416AH, the link for the MKI$ function: JUMP to 58B7H. 58B7H is its code in BASIC/CMD.
67D6
Copied to 416DH, the link for the MKS$ function: JUMP to 58B4H. 58B4H is its code in BASIC/CMD.
67D9
Copied to 4170H, the link for the MKD$ function: JUMP to 58B1H. 58B1H is its code in BASIC/CMD.
67DC
Copied to 4173H, the link for the CMD statement: JUMP to 57ECH. 57ECH is its code in BASIC/CMD.
67DF
Copied to 4176H, the link for TIME$ (the ROM jumps to 4176H at 2510H): JUMP to 3030H. 3030H is a JP 3799H in the ROM, the ROM's own TIME$ code (the 17-character date and time through 35BBH and 35A0H), so BASIC/CMD has no TIME$ code of its own.
67E2
Copied to 4179H, the link for the OPEN statement: JUMP to 5795H. 5795H is its code in BASIC/CMD.
67E5
Copied to 417CH, the link for the FIELD statement: JUMP to 5E3CH. 5E3CH is its code in BASIC/CMD.
67E8
Copied to 417FH, the link for the GET statement: JUMP to 60FFH. 60FFH is its code in BASIC/CMD.
67EB
Copied to 4182H, the link for the PUT statement: JUMP to 60FEH. 60FEH is its code in BASIC/CMD.
67EE
Copied to 4185H, the link for the CLOSE statement: JUMP to 5F7AH. 5F7AH is its code in BASIC/CMD.
67F1
Copied to 4188H, the link for the LOAD statement: JUMP to 574AH. 574AH is its code in BASIC/CMD.
67F4
Copied to 418BH, the link for the MERGE statement: JUMP to 572EH. 572EH is its code in BASIC/CMD.
67F7
Copied to 418EH, the link for the NAME statement: JUMP to 1E4AH. 1E4AH is the ROM's ILLEGAL FUNCTION CALL: NAME is not available.
67FA
Copied to 4191H, the link for the KILL statement: JUMP to 6415H. 6415H is its code in BASIC/CMD.
67FD
Copied to 4194H, the link for &H and &O constants (called by the ROM at 24C8H): JUMP to 5790H. 5790H is its code in BASIC/CMD.
6800
Copied to 4197H, the link for the LSET statement: JUMP to 58E1H. 58E1H is its code in BASIC/CMD.
6803
Copied to 419AH, the link for the RSET statement: JUMP to 58E2H. 58E2H is its code in BASIC/CMD.
6806
Copied to 419DH, the link for INSTR (called by the ROM at 2506H): JUMP to 5786H. 5786H is its code in BASIC/CMD.
6809
Copied to 41A0H, the link for the SAVE statement: JUMP to 573BH. 573BH is its code in BASIC/CMD.
680C
Copied to 41A3H, the link for LINE INPUT: JUMP to 579FH. 579FH is its code in BASIC/CMD.
680F
LD A,2FH 3E 2F
Copied to 41A6H, the link the ROM's error handler calls at 19ECH: load Register A with 2FH, the RST 28H code of SYS13/SYS function 1 (slot 0FH), which shows the error message.
6811
RST 28H EF
At 41A8H: RST 28H with Register A = 2FH, so that SYS0/SYS loads SYS13/SYS and runs it.
6812
Copied to 41A9H, the USR link called by the ROM at 27FEH: JUMP to 587FH, the USR function.
6815
Copied to 41ACH, the link called by READY at 1A1CH: JUMP to ROM 2169H, which sets the output back to the display and turns the cassette off.
6818
Copied to 41AFH, the line input link called by the ROM at 0368H: JUMP to 575DH, which lets SYS18/SYS read the command line.
681B
Copied to 41B2H, the link called by the ROM at 1AA1H after a typed line has been tokenized: JUMP to 5756H, which runs SYS18/SYS.
681E
Copied to 41B5H, the link called by the ROM at 1AECH: JUMP to 638CH, which keeps and clears the file statement flag.
6821
Copied to 41B8H, the link called by the ROM at 1AF2H: JUMP to 6395H, which puts the file statement flag back.
6824
Copied to 41BBH, the link called by the ROM for NEW and END (1B8CH, 1DB0H): JUMP to 5F8FH, which closes all files.
6827
Copied to 41BEH, the link called by the ROM at 2174H when a PRINT ends: JUMP to 6411H, which ends the file statement.
682A
Copied to 41C1H, the link called by the ROM's character output at 032CH: JUMP to 604FH, which sends the character to the file during a file statement.
682D
Copied to 41C4H, the link called by the ROM's keyboard scan at 0358H: JUMP to 6399H (end of a file statement, single stepping, RUN-ONLY and chaining).
6830
Copied to 41C7H, the RUN link called by the ROM at 1EA6H: JUMP to 5746H, RUN with a file name.
6833
Copied to 41CAH, the PRINT link called by the ROM at 206FH: JUMP to 5F2BH, PRINT #.
6836
Copied to 41CDH, the link called by the ROM's PRINT at 20C6H after a number has been made into text: JUMP to 5F24H.
6839
Copied to 41D0H, the link called by the ROM at 2103H: JUMP to 5F79H, a RET, so the link does nothing.
683C
Copied to 41D3H, the link called by the ROM's PRINT for a comma (2108H) and TAB (2141H): JUMP to 5F14H.
683F
Copied to 41D6H, the INPUT link called by the ROM at 219EH: JUMP to 5E81H, INPUT #.
6842
Copied to 41D9H, the link the ROM jumps to at 2AECH for MID$ on the left of an assignment: JUMP to 578BH, which runs SYS20/SYS.
6845
Copied to 41DCH, the link called by the ROM at 222DH for each item of INPUT and READ: JUMP to 579AH, which runs SYS20/SYS.
6848
Copied to 41DFH, the link called by the ROM at 2278H (after INPUT) and 2B44H (in LIST): JUMP to 5E92H.
684B
Copied to 41E2H, the link called by the SYSTEM command at 02B2H: JUMP to 5F79H, a RET, so the link does nothing.