5700H - File Statement Work Area (Header Copy and FCB)
While a file statement runs, 62BCH copies the 2DH-byte header of the file area in use to 5700H-572CH and points Index Register IX at 5700H; 6445H copies it back and clears 5700H-572DH when the statement ends. 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 0-3 the file type (MI 1, FI 2, MU 9, MF 0DH, FF 0EH). Read at 5FAFH, 5FFBH, 607BH, 60A2H, 60AFH; set by 6108H.
5701
DEFB 00H 00
Header byte +01H: bit 7 the file may be extended, bit 6 the start of the current record is known.
5702
DEFB 00H 00
Header bytes +02H/+03H, low byte of the record length (5F0DH, 6068H, 61A2H, 6363H read the word).
5703
DEFB 00H 00
High byte of the record length (header byte +03H).
5704
DEFB 00H 00
Header bytes +04H-+06H: 24-bit position where the last statement ended (low byte; read at 6358H).
5705
DEFB 00H 00
Middle byte of that position (the word at 5705H is read at 613AH and 614CH).
5706
DEFB 00H 00
High byte of the 24-bit position where the last statement ended (header byte +06H).
5707
DEFB 00H 00
Header bytes +07H-+09H: 24-bit position of the start of the last record (low byte; read at 6065H and 635BH).
5708
DEFB 00H 00
Middle byte (the word at 5708H is read at 6141H and 6153H).
5709
DEFB 00H 00
High byte of the 24-bit position of the start of the last record (header byte +09H, read at 606DH).
570A
DEFB 00H 00
Header bytes +0AH-+0CH: 24-bit position where the last GET or PUT statement started (low byte; SYS10 stores and reads it). In a PRINT # file 570AH is the print column instead (counted at 6082H, used for commas and TAB at 5F42H).
570B
DEFB 00H 00
Middle byte of the 24-bit position where the last GET or PUT statement started (header byte +0BH).
570C
DEFB 00H 00
High byte of the 24-bit position where the last GET or PUT statement started (header byte +0CH).
570D-572C
DEFS 32
Not in the file. Header bytes +0DH-+2CH: the file's FCB, passed to the DOS as Register Pair DE = 570DH (60C3H, 611AH, 6255H, 6397H).
572DH - Busy Byte, LOAD/RUN/MERGE/SAVE Links and the Overlay Loader
572DH is cleared with the header at the end of each file statement and its bit 7 is tested at 646CH. The Disk BASIC links for MERGE (418BH), SAVE (41A0H), RUN (41C7H) and LOAD (4188H) open the file in the work area and load SYS19; the links 41B2H and 41AFH load SYS18. 576CH is the overlay loader: Register A = the RST 28H code, Register Pair BC = the entry to run.
572D
DEFB 00H 00
Byte 572DH, 00H in the file. Cleared with the header area at the end of each file statement; 646CH tests its bit 7.
572E
MERGE link (418BH, JP 572EH at 67F4H): CALL 609AH to open the file named in the statement in the work area at 5700H for reading.
5731
LD BC,5334H 01 34 53
Load Register Pair BC with 5334H, the MERGE entry in SYS19.
5734
JUMP to 5752H to load SYS19 and run it at 5334H.
5736
LD BC,559CH 01 9C 55
CMD"F" (from the letter dispatch at 57CEH): load Register Pair BC with 559CH, the CMD"F"/DELETE entry in SYS19.
5739
JUMP to 5752H to load SYS19 and run it at 559CH.
573B
LD BC,8440H 01 40 84
SAVE link (41A0H, JP 573BH at 6809H): load Register Pair BC with 8440H, the mode for 609DH (B = 84H, C = 40H: output, create or replace).
573E
CALL 609DH to open the file named in the statement with the mode in Register Pair BC.
5741
LD BC,55C5H 01 C5 55
Load Register Pair BC with 55C5H, the SAVE entry in SYS19.
5744
JUMP to 5752H to load SYS19 and run it at 55C5H.
5746
RET C D8
RUN link (41C7H, JP 5746H at 6830H). If the ROM arrives with the Carry FLAG set (RUN without a file name), RETURN to let the ROM run the program in memory.
5747
LD A,01H 3E 01
RUN with a file name: load Register A with 01H, the RUN mode for SYS19.
5749
LD B,AFH 06 AF
Load Register B with AFH. Run from 5747H this only loads Register B and keeps Register A = 01H. Its second byte AFH (574AH) is the instruction XOR A, the entry of the Disk BASIC link for LOAD (4188H, JP 574AH at 67F1H): entered there, it clears Register A to 00H and the CARRY FLAG and continues at 574BH.
Overlapping Instructions
Entered at 5747H, the code runs LD A,01H then LD B,0AFH 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.
574B
PUSH AF F5
Save Register Pair AF on the stack for SYS19: Register A = 01H for RUN, 00H for LOAD.
574C
CALL 609AH to open the file named in the statement in the work area for reading.
574F
LD BC,5202H 01 02 52
Load Register Pair BC with 5202H, the LOAD/RUN entry in SYS19.
5752
LD A,35H 3E 35
Load Register A with 35H, the RST 28H code of SYS19.
5754
JUMP to the overlay loader at 576CH with Register A = 35H and Register Pair BC = the SYS19 entry.
5756
PUSH AF F5
Link 41B2H (JP 5756H at 681BH), called by the ROM after a typed line has been tokenized: save Register Pair AF.
5757
PUSH BC C5
Save Register Pair BC, the caller's value, on the stack before it is used for the SYS18 entry.
5758
LD BC,54FFH 01 FF 54
Load Register Pair BC with 54FFH, the SYS18 entry that checks the tokenized line.
575B
JUMP to 576AH to load SYS18 (RST 28H code 34H) and run it at the entry in Register Pair BC.
575D
POP HL E1
Link 41AFH (JP 575DH at 6818H), called by the ROM's line input at 0368H: take the return address 036BH off the stack into Register Pair HL.
575E
POP HL E1
Take the next word, the address that called the line input routine, into Register Pair HL.
575F
PUSH HL E5
Push Register Pair HL back on the stack, so the stack again holds only the caller's return address (036BH has been removed).
5760
LD DE,1A7EH 11 7E 1A
Load Register Pair DE with 1A7EH, the return address inside the ROM's command loop.
5763
RST 18H DF
RST 18H compares Register Pair HL (the caller) with Register Pair DE (1A7EH): Z only when the line input was called from the command loop.
5764
JP NZ,036BH C2 6B 03
If the word in Register Pair HL is not 1A7EH (NZ from the RST 18H compare with DE), JUMP to ROM 036BH, the instruction after the CALL 41AFH in the ROM's keyboard line input routine at 0361H (not linked: the ROM page has no id at 036BH).
5767
LD BC,5202H 01 02 52
Command loop line input: load Register Pair BC with 5202H, the SYS18 entry that reads the command line.
576A
LD A,34H 3E 34
Load Register A with 34H, the RST 28H code of SYS18.
576C
PUSH BC C5
Overlay loader: push Register Pair BC, the entry address, so the RET at 576FH or 577EH goes there.
576D
CP 00H FE 00
Self-Modifying Code
Compare Register A (the wanted RST 28H code) with the operand at 576EH, the code of the overlay loaded last (00H in the file; stored at 577CH, cleared at 5774H and by SYS21).
576F
RET Z C8
If that overlay is still in memory (Z), RETURN, which jumps straight to the entry in Register Pair BC.
5770
PUSH HL E5
Save Register Pair HL, the caller's value, on the stack.
5771
LD HL,576EH 21 6E 57
Point Register Pair HL at 576EH, the operand that records the overlay in memory.
5774
LD (HL),00H 36 00
Store 00H into the operand at Register Pair HL (576EH): if the load fails nothing is recorded as loaded.
5776
CALL 57B5H, which executes RST 28H with the code in Register A: SYS0 loads the overlay and returns here.
5779
If the DOS reported an error (NZ, code in Register A), JUMP to 5E16H to turn it into a BASIC error.
577C
LD (HL),A 77
Store Register A, the RST 28H code, 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, from the stack.
577E
RET C9
RETURN, which jumps to the entry in Register Pair BC.
577FH - Links That Load SYS20 (FN, INSTR, MID$=, &, OPEN, INPUT# Item, LINE INPUT, CMD String)
Each entry loads Register Pair BC with a SYS20 entry and joins 5782H, which loads Register A with 36H (SYS20) and goes to the overlay loader.
577F
LD BC,534AH 01 4A 53
FN link (4155H, JP 577FH at 67BEH): load Register Pair BC with 534AH, the FN entry in SYS20.
5782
LD A,36H 3E 36
Load Register A with 36H, the RST 28H code of SYS20.
5784
JUMP to the overlay loader at 576CH with Register A = 36H and Register Pair BC = the SYS20 entry.
5786
LD BC,53F2H 01 F2 53
INSTR link (419DH, JP 5786H at 6806H): load Register Pair BC with 53F2H, the INSTR entry in SYS20.
5789
JUMP to 5782H to load SYS20 and run it at the INSTR entry in Register Pair BC.
578B
LD BC,5462H 01 62 54
MID$= link (41D9H, JP 578BH at 6842H): load Register Pair BC with 5462H, the MID$ assignment entry in SYS20.
578E
JUMP to 5782H to load SYS20 and run it at the MID$ assignment entry in Register Pair BC.
5790
LD BC,54C5H 01 C5 54
& link (4194H, JP 5790H at 67FDH; &H and &O constants): load Register Pair BC with 54C5H, the entry in SYS20.
5793
JUMP to 5782H to load SYS20 and run it at the &H and &O entry in Register Pair BC.
5795
LD BC,5504H 01 04 55
OPEN link (4179H, JP 5795H at 67E2H): load Register Pair BC with 5504H, the OPEN entry in SYS20.
5798
JUMP to 5782H to load SYS20 and run it at the OPEN entry in Register Pair BC.
579A
LD BC,55D4H 01 D4 55
Link 41DCH (JP 579AH at 6845H), an INPUT# or READ item: load Register Pair BC with 55D4H, the item entry in SYS20.
579D
JUMP to 5782H to load SYS20 and run it at the INPUT# item entry in Register Pair BC.
579F
LD BC,55E8H 01 E8 55
LINE link (41A3H, JP 579FH at 680CH), LINE INPUT: load Register Pair BC with 55E8H, the LINE INPUT entry in SYS20.
57A2
JUMP to 5782H to load SYS20 and run it at the LINE INPUT entry in Register Pair BC.
57A4
PUSH BC C5
CMD with a command longer than one character (from 582FH): save Register Pair BC.
57A5
LD BC,5202H 01 02 52
Load Register Pair BC with 5202H, the SYS20 entry that runs the command copied to 4318H.
57A8
JUMP to 5782H to load SYS20 and run it at the command entry in Register Pair BC (5202H).
57AAH - CMD"F=ERASE", CMD"F=KEEP", CMD"O", RST 28H, Upper Case
57AAH and 57AEH are reached from SYS20's search of the function table at 5952H; they and CMD"O" run SYS21. 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 SYS21 stores at 4D8DH (JR Z: erase the variables not named).
57AC
JUMP to 57B0H with Register B = 28H to run SYS21's ERASE/KEEP code.
57AE
LD B,20H 06 20
KEEP: load Register B with 20H (JR NZ: keep only the variables named).
57B0
LD A,57H 3E 57
Load Register A with 57H, the RST 28H code for SYS21's ERASE/KEEP part.
57B2
RST 28H EF
RST 28H: SYS0 loads SYS21 and runs ERASE/KEEP at 4D0EH with Register B as the mode.
57B3
LD A,37H 3E 37
CMD"O" (from 57DDH): load Register A with 37H, the RST 28H code for SYS21's array sort.
57B5
RST 28H EF
RST 28H with the code in Register A: SYS0 loads the overlay and starts it (for SYS18-SYS20 the start just returns to the caller of 57B5H).
57B6
DEFB 00H 00
Work byte 57B6H (00H in the file): SYS18 stores the RST 28H code of RENEW, RENUM or REF here.
57B7
DEFB 00H 00
Work byte 57B7H: SYS18 stores the flag of that command here.
57B8
DEFB 00H 00
Work bytes 57B8H-57B9H: a line number, stored by 5DADH (next line after a trailing comma) and used by SYS19's MERGE.
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: compare Register A, the character, with 61H (a).
57BC
RET C D8
If Register A is below a (the CARRY FLAG is set), RETurn with the character unchanged.
57BD
CP 7BH FE 7B
Compare Register A with 7BH, the character after z.
57BF
RET NC D0
If Register A is above z (the NC FLAG is set), RETurn with the character unchanged.
57C0
SUB 20H D6 20
Register A is a lower case letter: subtract 20H to make it upper case.
57C2
RET C9
RETurn with the upper case character in Register A.
57C3H - One-Letter CMD Commands
Reached from 582AH when the CMD string (copied to 4318H) is one character. Register Pair HL points at 4318H; the BASIC text pointer is on the stack. S returns to the DOS, F runs SYS19's CMD"F", C compresses the program, J converts a date, O sorts arrays (SYS21), E shows the last DOS error, D does nothing, R and T switch the RST 38H interrupt vector.
57C3
LD A,(HL) 7E
Load Register A with the command letter at 4318H (Register Pair HL).
57C4
CP 53H FE 53
Compare Register A, the command letter, with 53H (S).
57C6
POP HL E1
Restore Register Pair HL, the BASIC text pointer.
57C7
If the letter in Register A is not S (the NZ FLAG is set), JUMP to 57CCH.
57C9
CMD"S": JUMP to 402DH, DOS READY; BASIC is left. (64DDH, 64E5H, 6557H and 673DH jump here too.)
57CC
CP 46H FE 46
Compare the letter in Register A with 46H (F).
57CE
If the letter in Register A is F (the Z FLAG is set), JUMP to 5736H to run CMD"F" in SYS19 at 559CH.
57D1
CP 43H FE 43
Compare Register A, the command letter, with 43H (C).
57D3
CMD"C": JUMP to 59ADH, the program compression.
57D6
CP 4AH FE 4A
Compare Register A, the command letter, with 4AH (J).
57D8
If the letter in Register A is J (the Z FLAG is set), JUMP to 5A9DH, the date conversion.
57DB
CP 4FH FE 4F
Compare Register A, the command letter, with 4FH (O).
57DD
If the letter in Register A is O (the Z FLAG is set), JUMP to 57B3H to run the array sort in SYS21.
57E0
CP 45H FE 45
Compare Register A, the command letter, with 45H (E).
57E2
If the letter in Register A is not E (the NZ FLAG is set), JUMP to 57E9H.
57E4
LD A,C0H 3E C0
Self-Modifying Code
CMD"E" (and 5E31H when no ON ERROR is active): load Register A with the operand at 57E5H, the last DOS error code OR C0H, stored by 5E19H (C0H in the file).
57E6
JUMP to the SYS0 error exit 4409H: bit 7 of Register A makes it display the DOS error message and return.
57E9
CP 44H FE 44
Compare the letter in Register A with 44H (D).
57EB
RET Z C8
If the letter in Register A is D (the Z FLAG is set), RETurn: CMD"D" has nothing to do here.
57EC
LD B,C3H 06 C3
Load Register B with C3H, the opcode JP (CMD"R").
57EE
CP 52H FE 52
Compare Register A, the command letter, with 52H (R).
57F0
If the letter in Register A is R (the Z FLAG is set), JUMP to 57F9H with Register B = C3H.
57F2
CP 54H FE 54
Compare Register A, the command letter, with 54H (T).
57F4
JP NZ,1E4AH C2 4A 1E
Any other letter: JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
57F7
LD B,C9H 06 C9
CMD"T": load Register B with C9H, the opcode RET.
57F9
LD A,B 78
Load Register A with the opcode in Register B.
57FA
LD (4012H),A 32 12 40
Store Register A, the opcode, at 4012H, the first byte of the RST 38H interrupt vector: JP (C3H, R) lets interrupts reach SYS0, RET (C9H, T) ignores them.
57FD
EI FB
Enable interrupts again, now that the interrupt vector at 4012H is set.
57FE
RET C9
RETurn to the caller with the interrupt vector at 4012H set for CMD"R" or CMD"T".
57FFH - CMD Statement
CMD link (4173H, JP 57FFH at 67DCH). The string after CMD (1 to 79 characters) is copied in upper case to SYS0's command buffer 4318H with a 0DH. One character: the letter commands at 57C3H. Ending in $: the text is the name of a string variable whose contents are the command. Otherwise SYS20 runs the command (5202H).
57FF
CALL 2337H CD 37 23
CALL ROM 2337H to evaluate the expression after CMD into the floating accumulator.
5802
PUSH HL E5
Save Register Pair HL, the BASIC text pointer.
5803
LD DE,(4121H) ED 5B 21 41
Load Register Pair DE with the word at 4121H, the address of the string's descriptor.
5807
CALL 5CCBH: the value must be a string; it returns Register A = the length and Register Pair DE = the address of the text.
580A
DEC A 3D
DECrement Register A, the string length, by 1, so a length of 0 becomes FFH.
580B
CP 4FH FE 4F
Compare Register A, the length minus 1, with 4FH: the CARRY FLAG is set for lengths 1 to 79.
580D
JP NC,1E4AH D2 4A 1E
Length 0 or above 79 (No Carry): JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
5810
INC A 3C
INCrement Register A back to the string length.
5811
LD HL,4318H 21 18 43
Point Register Pair HL at 4318H, SYS0's command buffer.
5814
LD B,A 47
Copy Register A, the length, into Register B as the copy counter.
5815
LD C,A 4F
Copy Register A, the length, into Register C as well, for the one-character test at 5829H.
5816
PUSH HL E5
Save Register Pair HL (4318H, the command buffer) on the stack.
Loop: copy the command in upper case.
5817
LD A,(DE) 1A
Load Register A with the next character from Register Pair DE.
5818
INC DE 13
Bump Register Pair DE to the next character of the string.
5819
GOSUB to 57BAH to make the character in Register A upper case.
581C
LD (HL),A 77
Store Register A, the upper case character, at Register Pair HL in the command buffer.
581D
INC HL 23
Bump Register Pair HL to the next byte of the command buffer.
581E
Decrement Register B and LOOP to 5817H until all characters are copied.
5820
LD (HL),0DH 36 0D
Store 0DH at Register Pair HL to end the command in the buffer.
Loop: find the last character that is not a space.
5822
DEC HL 2B
DECrement Register Pair HL back one character from the end of the command.
5823
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5824
CP 20H FE 20
Compare Register A, the last character of the command, with 20H, a space.
5826
If Register A is a space (the Z FLAG is set), LOOP back to 5822H to step back over trailing spaces.
5828
POP HL E1
Restore Register Pair HL (4318H, the command buffer) from the stack.
5829
DEC C 0D
DECrement Register C, the length: the Z FLAG is set when the command is one character.
582A
One character (Z): JUMP to 57C3H for the letter commands.
582D
CP 24H FE 24
Compare the last non-space character in Register A with 24H ($).
582F
Not $: JUMP to 57A4H to let SYS20 run the command.
5832
CALL 2611H CD 11 26
Ends in $: CALL ROM 2611H (PTRGET after its first instruction) with Register Pair HL = 4318H, which finds the string variable named there; Register Pair DE returns its address.
5835
JUMP to 5807H to use that variable's contents as the command.
5837H - Function Name for DEF FN and FN
Reads a function name after FN: 40DCH = 80H tells PTRGET that a function name is being looked up (bit 7 set on the first character). Returns Register Pair DE = the entry and the Z FLAG set when it is a string function (value type 03H). 5844H is a second entry, used by SYS20's FN.
5837
RST 10H D7
RST 10H: step Register Pair HL to the next non-space character after the FN token and load it into Register A.
5838
LD A,80H 3E 80
Load Register A with 80H, the flag for a function name.
583A
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that makes PTRGET look up a function name.
583D
OR (HL) B6
OR the first character of the name at Register Pair HL into Register A (bit 7 set).
583E
LD B,A 47
Copy Register A, the first name character with bit 7 set, into Register B as PTRGET expects it.
583F
CALL 2612H CD 12 26
CALL ROM 2612H, PTRGET after its first-character fetch: the entry's address comes back in Register Pair DE.
5842
JUMP to 584CH to fetch the value type with Register Pair DE = the entry.
5844
LD A,80H 3E 80
Second entry (not called in this file): load Register A with 80H.
5846
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that makes PTRGET look up a function name.
5849
CALL 260DH CD 0D 26
CALL ROM 260DH, PTRGET: Register Pair DE returns the entry's address.
584C
LD A,(40AFH) 3A AF 40
Load Register A with the value type at 40AFH (02H integer, 03H string, 04H single, 08H double).
584F
CP 03H FE 03
Compare Register A, the value type, with 03H: the Z FLAG is set for a string.
5851
RET C9
RETurn with Register Pair DE = the entry, Register A = the value type and the Z FLAG set for a string.
5852H - DEF Statement (DEF FN and DEF USR)
DEF link (415BH, JP 5852H at 67C4H) with Register A = the token after DEF. DEF FN name stores the text pointer (the start of the definition) in the function's entry and checks the parameter list; the rest of the statement is skipped like DATA. DEF USRn goes to 586FH.
5852
CP BEH FE BE
Compare Register A, the token after DEF, with BEH, the FN token.
5854
If Register A is not FN (the NZ FLAG is set), JUMP to 586FH for DEF USR.
5856
CALL 5837H to find or create the function's entry; Register Pair DE returns its address.
5859
CALL 2828H CD 28 28
CALL ROM 2828H: DEF is not allowed as a direct statement.
585C
LD A,L 7D
Load Register A with Register L, the low byte of the text pointer.
585D
LD (DE),A 12
Store Register A, the low byte of the text pointer, into the function's entry at Register Pair DE.
585E
INC DE 13
Bump Register Pair DE to the high byte of the entry.
585F
LD A,H 7C
Copy Register H, the high byte of the text pointer, into Register A.
5860
LD (DE),A 12
Store Register A, the high byte, at Register Pair DE: the entry now points at the definition in the program text.
5861
LD A,28H 3E 28
Load Register A with 28H, the ( that starts the parameter list.
Loop: step through ( name , name ... to check the parameter names.
5863
CP (HL) BE
Compare Register A with the character at Register Pair HL.
5864
JP NZ,1F05H C2 05 1F
Not the expected character: JUMP to ROM 1F05H (DATA), which skips the rest of the statement.
5867
RST 10H D7
RST 10H: step Register Pair HL past the character and load the next non-space character into Register A.
5868
CALL 260DH CD 0D 26
CALL ROM 260DH, PTRGET, to read a parameter name.
586B
LD A,2CH 3E 2C
Load Register A with 2CH, the comma before the next parameter.
586D
LOOP back to 5863H to compare Register A (now a comma) with the next character at Register Pair HL.
586FH - DEF USRn Statement
DEF USRn = address stores the address in the USR table at 58B0H. Any other token after DEF is a syntax error.
586F
CP C1H FE C1
Compare Register A, the token after DEF, with C1H, the USR token.
5871
JP NZ,1997H C2 97 19
Neither FN nor USR: JUMP to ROM 1997H, SYNTAX ERROR.
5874
CALL 5883H: Register Pair DE returns the table slot for USR0-USR9.
5877
PUSH DE D5
Save Register Pair DE, the table slot address, on the stack.
5878
RST 08H CF
RST 08H: the byte after it, D5H (the = token), must be the next character at Register Pair HL, else SYNTAX ERROR; Register Pair HL is stepped past it.
5879
DEFB 0D5H D5
Inline byte for the RST 08H at 5878H: D5H, the = token (not executed).
587A
CALL 2B02H CD 02 2B
CALL ROM 2B02H to evaluate the address as an integer into Register Pair DE.
587D
EX (SP),HL E3
Exchange Register Pair HL, the text pointer, with the slot address at the Stack Pointer: Register Pair HL = the slot.
587E
LD (HL),E 73
Store Register E, the low byte of the address, into the slot at Register Pair HL.
587F
INC HL 23
Bump Register Pair HL to the high byte of the slot.
5880
LD (HL),D 72
Store Register D, the high byte of the address, into the slot at Register Pair HL.
5881
POP HL E1
Restore Register Pair HL, the text pointer (also the return point of a USR call, pushed at 58A1H).
5882
RET C9
RETurn to the statement loop with Register Pair HL = the text pointer.
5883H - USR Digit to Table Slot
Register Pair DE = 58B0H + 2 x n for USRn (n 0-9, 0 when no digit follows). Register Pair HL is the text pointer.
5883
LD DE,58B0H 11 B0 58
Point Register Pair DE at the USR table 58B0H.
5886
RST 10H D7
RST 10H: step Register Pair HL to the next character and load it into Register A; the CARRY FLAG is set for a digit.
5887
RET NC D0
No digit (No Carry): RETURN with USR0's slot.
5888
SUB 30H D6 30
Convert the digit in Register A to its value 0-9.
588A
ADD A,A 87
Add Register A to itself, doubling the digit: two bytes per slot.
588B
ADD A,E 83
Add Register E, the low byte of 58B0H, to Register A.
588C
LD E,A 5F
Copy Register A into Register E, the low byte of the slot address in Register Pair DE.
588D
If there was no carry out (the NC FLAG is set), JUMP to 5890H.
588F
INC D 14
INCrement Register D to take the carry into the high byte of Register Pair DE.
5890
RST 10H D7
RST 10H: step Register Pair HL past the digit and load the next character into Register A.
5891
RET C9
RETURN with the slot address in Register Pair DE.
5892H - USR Function
Link 41A9H (JP 5892H at 6812H), called by the ROM for USR. The routine at the address in the slot for USRn is called with Register Pair HL = 4121H (the argument in the floating accumulator) and Register A = the value type; it returns to 5881H, which restores the text pointer.
5892
POP AF F1
Pop the return address of the ROM's CALL to the 41A9H link into Register Pair AF, dropping it.
5893
CALL 5883H: Register Pair DE = the slot for USRn.
5896
PUSH DE D5
Save Register Pair DE, the slot address, on the stack.
5897
CALL 252CH CD 2C 25
CALL ROM 252CH to evaluate the argument in parentheses into the floating accumulator.
589A
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL = the slot, the text pointer goes on the stack.
589B
LD C,(HL) 4E
Load Register C with the low byte of the routine's address at Register Pair HL.
589C
INC HL 23
Bump Register Pair HL to the high byte of the slot.
589D
LD B,(HL) 46
Load Register B with the high byte of the routine's address at Register Pair HL.
589E
LD HL,5881H 21 81 58
Load Register Pair HL with 5881H, where the routine will return.
58A1
PUSH HL E5
Push Register Pair HL (5881H) on the stack as the routine's return address.
58A2
PUSH BC C5
Push Register Pair BC, the routine's address, so the RET at 58AFH jumps to it.
58A3
CALL 584CH: Register A = the value type, Z for a string.
58A6
PUSH AF F5
Save Register Pair AF: Register A = the value type, the Z FLAG set for a string.
58A7
CALL Z,29DAH CC DA 29
A string argument (Z): CALL ROM 29DAH to free its temporary descriptor.
58AA
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL.
58AB
LD HL,4121H 21 21 41
Point Register Pair HL at 4121H, the argument.
58AE
POP AF F1
Restore Register Pair AF: Register A = the value type and the flags.
58AF
RET C9
RETurn, which pops Register Pair BC's routine address and jumps to the USR routine.
58B0H - USR Address Table (USR0-USR9) and the TIME$ Entry
Ten addresses set by DEF USRn. Each starts as 1E4AH, so an undefined USR gives ILLEGAL FUNCTION CALL. 58C4H is the entry of the TIME$ link.
58B0-58B1
DEFW 1E4AH 4A 1E
USR0 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR0 sets it.
58B2-58B3
DEFW 1E4AH 4A 1E
USR1 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR1 sets it.
58B4-58B5
DEFW 1E4AH 4A 1E
USR2 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR2 sets it.
58B6-58B7
DEFW 1E4AH 4A 1E
USR3 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR3 sets it.
58B8-58B9
DEFW 1E4AH 4A 1E
USR4 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR4 sets it.
58BA-58BB
DEFW 1E4AH 4A 1E
USR5 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR5 sets it.
58BC-58BD
DEFW 1E4AH 4A 1E
USR6 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR6 sets it.
58BE-58BF
DEFW 1E4AH 4A 1E
USR7 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR7 sets it.
58C0-58C1
DEFW 1E4AH 4A 1E
USR8 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR8 sets it.
58C2-58C3
DEFW 1E4AH 4A 1E
USR9 address, 1E4AH (ILLEGAL FUNCTION CALL) until DEF USR9 sets it.
58C4
RST 10H D7
Entry of the Disk BASIC link for TIME$ (4176H; the JP 58C4H at 67DFH is copied there): RST 10H steps Register Pair HL past the TIME$ token and loads the next character into Register A.
58C5H - TIME$ Function
Returns the 17-character string MM/DD/YY HH:MM:SS built by the SYS0 date and time routines.
58C5
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
58C6
LD A,11H 3E 11
Load Register A with 11H, the length of the string (17 characters).
58C8
CALL 2857H CD 57 28
CALL ROM 2857H to reserve 17 bytes of string space; Register Pair DE returns its address.
58CB
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL points at the new string.
58CC
CALL SYS0 4470H: the date as MM/DD/YY at Register Pair HL, which is advanced past it.
58CF
LD (HL),20H 36 20
Store a space (20H) at Register Pair HL, between the date and the time.
58D1
INC HL 23
Bump Register Pair HL past the space to where the time goes.
58D2
GOSUB to the SYS0 routine at 446DH to put the time as HH:MM:SS at Register Pair HL.
58D5
JP 2884H C3 84 28
JUMP to ROM 2884H to register the new string as the function result.
58D8H - MKD$, MKS$ and MKI$ Functions
The Disk BASIC links for MKD$ (4170H, JP 58D8H at 67D9H), MKS$ (416DH, JP 58DBH at 67D6H) and MKI$ (416AH, JP 58DEH at 67D3H) enter here with the number in the floating 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, a string of that length is reserved and the number's bytes are copied into it.
Overlapping Instructions
MKD$ enters at 58D8H (Register A = 08H); the LD BC instructions at 58DAH and 58DDH then only load Register Pair BC. MKS$ enters at 58DBH, where the bytes 3EH 04H are LD A,04H. MKI$ enters at 58DEH, where 3EH 02H are LD A,02H.
58D8
LD A,08H 3E 08
MKD$ entry: load Register A with 08H, the length of a double-precision number and its value type code.
58DA
LD BC,043EH 01 3E 04
Fall-through from 58D8H: load Register Pair BC with 043EH, which only skips the LD A,04H hidden in bytes 58DBH-58DCH, so Register A stays 08H. The MKS$ link (416DH) enters at 58DBH, where 3EH 04H is LD A,04H: Register A = 04H, the length of a single-precision number and its value type code.
58DD
LD BC,023EH 01 3E 02
Fall-through from 58D8H or 58DBH: load Register Pair BC with 023EH, which only skips the LD A,02H hidden in bytes 58DEH-58DFH, so Register A keeps 08H or 04H. The MKI$ link (416AH) enters at 58DEH, where 3EH 02H is LD A,02H: Register A = 02H, the length of an integer and its value type code.
58E0
PUSH AF F5
Save Register Pair AF on the stack: Register A = the length and type code 08H, 04H or 02H.
58E1
CALL 2819H CD 19 28
CALL the ROM routine at 2819H to convert the number in the floating accumulator to the type in Register A.
58E4
POP AF F1
Restore Register Pair AF: Register A = the length 08H, 04H or 02H.
58E5
CALL 2857H CD 57 28
CALL the ROM routine at 2857H to reserve Register A bytes of string space and build a temporary string descriptor; Register Pair DE returns the address of the space.
58E8
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL now holds the address of the new string space.
58E9
CALL 09FFH CD FF 09
CALL the ROM at 09FFH, which copies the value in the floating accumulator (as many bytes as its type) to the address in Register Pair HL.
58EC
JP 2A2BH C3 2B 2A
JUMP to the ROM at 2A2BH, which drops a stack word and returns the new string to BASIC through 2884H.
58EFH - CVD, CVS and CVI Functions
The Disk BASIC links for CVD (415EH, JP 58EFH at 67C7H), CVS (4158H, JP 58F2H at 67C1H) and CVI (4152H, JP 58F5H at 67BBH) enter with the string argument in the floating 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 floating accumulator.
Overlapping Instructions
CVD enters at 58EFH (Register A = 08H); the LD BC instructions at 58F1H and 58F4H then only load Register Pair BC. CVS enters at 58F2H, where 3EH 04H is LD A,04H. CVI enters at 58F5H, where 3EH 02H is LD A,02H.
58EF
LD A,08H 3E 08
CVD entry: load Register A with 08H, the size of a double-precision number.
58F1
LD BC,043EH 01 3E 04
Fall-through from 58EFH: load Register Pair BC with 043EH, which hides LD A,04H at 58F2H (the CVS entry). Register A stays 08H.
58F4
LD BC,023EH 01 3E 02
Fall-through: load Register Pair BC with 023EH, which hides LD A,02H at 58F5H (the CVI entry).
58F7
PUSH AF F5
Save Register Pair AF on the stack: Register A = the size and value type 08H, 04H or 02H.
58F8
CALL 5CC0H to take the string from the floating accumulator: Register A = its length, Register Pair DE = its text, Register Pair HL = its descriptor.
58FB
POP AF F1
Restore Register Pair AF: Register A = the size and value type.
58FC
LD (40AFH),A 32 AF 40
Store Register A at 40AFH: the result has that value type.
58FF
DEC A 3D
DECrement Register A, the size, by 1 for the compare with the string's length.
5900
CP (HL) BE
Compare Register A, the size minus 1, with the string's length, the first byte of the descriptor at Register Pair HL.
5901
JP NC,1E4AH D2 4A 1E
If the string is shorter than the size (No Carry), JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
5904
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL points at the string's text.
5905
JP 09F7H C3 F7 09
JUMP to ROM 09F7H, which copies the bytes at Register Pair HL into the floating accumulator (as many as the value type) and returns the number.
5908H - LSET and RSET Statements
The Disk BASIC links for LSET (4197H, JP 5908H at 6800H) and RSET (419AH, JP 5909H at 6803H). LSET var$ = x$ copies x$ into the existing text of var$ from the left and pads with spaces; RSET pads first, so 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 the program is not changed.
Overlapping Instructions
LSET enters at 5908H, where F6H AFH is OR 0AFH. RSET enters at 5909H, where the byte AFH is XOR A.
5908
OR AFH F6 AF
LSET entry (4197H): OR Register A with AFH, so Register A is not zero and the Z FLAG is clear (the LSET flag). The RSET link (419AH) enters at 5909H, where the byte AFH is XOR A: Register A = 00H and the Z FLAG is set (the RSET flag).
590A
PUSH AF F5
Save Register Pair AF on the stack: Register A and the Z FLAG say NZ for LSET, Z for RSET.
590B
CALL 5EA2H to read the variable name (ROM PTRGET) and require a string: Register Pair DE returns the address of its descriptor.
590E
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
590F
PUSH DE D5
Save Register Pair DE, the descriptor's address.
5910
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL points at the variable's descriptor.
5911
INC HL 23
Bump Register Pair HL past the length byte of the descriptor.
5912
LD E,(HL) 5E
Load Register E with the low byte of the text address at Register Pair HL.
5913
INC HL 23
Bump Register Pair HL to the high byte of the text address.
5914
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the address of the variable's text.
5915
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with 40F9H, the end of the program text.
5918
RST 18H DF
RST 18H compares Register Pair HL with Register Pair DE: Carry when the text lies above the program.
5919
Above the program (Carry): the text is in string space; JUMP to 5924H.
591B
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with 40A4H, the start of the program.
591E
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).
591F
POP HL E1
Load Register Pair HL with the descriptor's address from the stack.
5920
PUSH HL E5
Push Register Pair HL, the descriptor's address, back on the stack.
5921
A literal in the program (Carry): CALL 5CEBH to copy the text to string space and point the descriptor at the copy.
5924
POP HL E1
Take the descriptor's address off the stack into Register Pair HL.
5925
EX (SP),HL E3
Exchange Register Pair HL, the descriptor's address, with the text pointer at the Stack Pointer: Register Pair HL = the text pointer.
5926
RST 08H CF
RST 08H: the next BASIC text character must be the token in the byte after this instruction (D5H, the = token); RST 08H steps past it or reports a syntax error, and returns to 5928H.
5927
DEFB 0D5H D5
Inline byte for the RST 08H at 5926H: D5H, the = token (not executed).
5928
CALL 2337H CD 37 23
CALL ROM 2337H to evaluate the expression after the = (the source string).
592B
POP BC C1
Load Register Pair BC with the variable's descriptor address from the stack.
592C
EX (SP),HL E3
Exchange Register Pair HL, the text pointer, with the saved LSET/RSET flag word at the Stack Pointer.
592D
PUSH HL E5
Push Register Pair HL, the LSET/RSET flag word, on the stack again.
592E
PUSH BC C5
Push Register Pair BC, the variable's descriptor address, on the stack.
592F
CALL 5CC0H: Register A = the source's length, Register Pair DE = its text.
5932
LD C,A 4F
Copy Register A, the source's length, into Register C.
5933
POP HL E1
Load Register Pair HL with the variable's descriptor address.
5934
PUSH DE D5
Save Register Pair DE, the source text address, on the stack.
5935
LD B,(HL) 46
Load Register B with the variable's length, the first byte of its descriptor at Register Pair HL.
5936
INC HL 23
Bump Register Pair HL to the low byte of the variable's text address.
5937
LD E,(HL) 5E
Load Register E with the low byte of the variable's text address at Register Pair HL.
5938
INC HL 23
Bump Register Pair HL to the high byte of the variable's text address.
5939
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the variable's text.
593A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the variable's text (the destination).
593B
POP DE D1
Restore Register Pair DE = the source's text.
593C
LD A,B 78
Load Register A with the variable's length in Register B.
593D
SUB C 91
Subtract Register C, the source's length, from Register A, the variable's length.
593E
Source longer (Carry): JUMP to 5944H; Register B (the variable's length) is the number of bytes to copy.
5940
LD B,C 41
Copy Register C (the source's length) to Register B: the number of bytes to copy.
5941
LD C,A 4F
Copy Register A, the difference, into Register C: the number of spaces to pad.
5942
JUMP to 5946H with Register B = the bytes to copy and Register C = the spaces to pad.
5944
LD C,00H 0E 00
Load Register C with 00H: no padding when the source is longer.
5946
POP AF F1
Restore Register Pair AF: the Z FLAG is set for RSET.
5947
RSET (Z): CALL 5CE3H to store Register C spaces first; it returns with Register C = 00H.
594A
CALL 5CDDH to copy Register B bytes from Register Pair DE (source) to Register Pair HL (variable).
594D
CALL 5CE3H to store the remaining Register C spaces (none for RSET).
5950
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5951
RET C9
RETurn to the statement loop with Register Pair HL = the text pointer.
5952H - CMD"F=" Function Table
Searched by SYS20 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 itself; ERASE 57AAH, KEEP 57AEH, SASZ 5C5BH, SWAP 598AH and SS 5BB6H are here.
5952-5956
DEFB 04H,50H,4FH,50H,53H 04 50 4F 50 53
CMD"F=" table entry 1: the length byte 04H and the name POPS.
5957-5958
DEFB 16H,53H 16 53
Address 5316H (in SYS20): CMD"F=POPS" purges all GOSUB returns and FOR-NEXT loops.
5959-595D
DEFB 04H,50H,4FH,50H,52H 04 50 4F 50 52
CMD"F=" table entry 2: the length byte 04H and the name POPR.
595E-595F
DEFB 24H,53H 24 53
Address 5324H (in SYS20): CMD"F=POPR" purges the current GOSUB level.
5960-5964
DEFB 04H,50H,4FH,50H,4EH 04 50 4F 50 4E
CMD"F=" table entry 3: the length byte 04H and the name POPN.
5965-5966
DEFB 34H,53H 34 53
Address 5334H (in SYS20): CMD"F=POPN" purges a FOR-NEXT loop.
5967-596C
DEFB 05H,45H,52H,41H,53H,45H 05 45 52 41 53 45
CMD"F=" table entry 4: the length byte 05H and the name ERASE.
596D-596E
DEFB 0AAH,57H AA 57
Address 57AAH: CMD"F=ERASE" clears the variables named (SYS21).
596F-5973
DEFB 04H,4BH,45H,45H,50H 04 4B 45 45 50
CMD"F=" table entry 5: the length byte 04H and the name KEEP.
5974-5975
DEFB 0AEH,57H AE 57
Address 57AEH: CMD"F=KEEP" clears all variables except those named (SYS21).
5976-597A
DEFB 04H,53H,41H,53H,5AH 04 53 41 53 5A
CMD"F=" table entry 6: the length byte 04H and the name SASZ.
597B-597D
DEFB 5BH,5CH,04H 5B 5C 04
Address 5C5BH (CMD"F=SASZ", change the string area size), then the length 04H of entry 7.
597E-5981
DEFB 53H,57H,41H,50H 53 57 41 50
CMD"F=" table entry 7: the name SWAP (its length byte 04H is at 597DH).
5982-5983
DEFB 8AH,59H 8A 59
Address 598AH: CMD"F=SWAP" exchanges two variables.
5984-5986
DEFB 02H,53H,53H 02 53 53
CMD"F=" table entry 8: the length byte 02H and the name SS.
5987-5989
DEFB 0B6H,5BH,00H B6 5B 00
Address 5BB6H (CMD"F=SS", single stepping), then 00H, the end of the table.
598AH - CMD"F=SWAP",var1,var2
Exchanges the values of two variables of the same type; the number of bytes exchanged is the type code (2 integer, 3 string descriptor, 4 single, 8 double). Different types give ILLEGAL FUNCTION CALL.
598A
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
598B
DEFB 2CH 2C
Inline byte for the RST 08H at 598AH: 2CH, a comma (not executed).
598C
CALL 260DH CD 0D 26
CALL ROM 260DH, PTRGET: Register Pair DE = the address of the first variable.
598F
PUSH DE D5
Save Register Pair DE, the address of the first variable, on the stack.
5990
LD A,(40AFH) 3A AF 40
Load Register A with the first variable's value type from 40AFH.
5993
PUSH AF F5
Save Register Pair AF on the stack: Register A = the first variable's type.
5994
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5995
DEFB 2CH 2C
Inline byte for the RST 08H at 5994H: 2CH, a comma (not executed).
5996
CALL 260DH CD 0D 26
CALL ROM 260DH: Register Pair DE = the address of the second variable.
5999
POP BC C1
Restore the first variable's type into Register B (Register Pair BC from the pushed Register Pair AF).
599A
LD A,(40AFH) 3A AF 40
Load Register A with the second variable's type from 40AFH.
599D
CP B B8
Compare Register A, the second variable's type, with Register B, the first type.
599E
JP NZ,1E4AH C2 4A 1E
Different types: JUMP to ROM 1E4AH, ILLEGAL FUNCTION CALL.
59A1
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL = the first variable, the text pointer goes on the stack.
Loop: exchange Register B bytes.
59A2
LD C,(HL) 4E
Load Register C with a byte of the first variable at Register Pair HL.
59A3
LD A,(DE) 1A
Load Register A with the byte of the second variable at Register Pair DE.
59A4
LD (HL),A 77
Store Register A, the second variable's byte, into the first variable at Register Pair HL.
59A5
LD A,C 79
Load Register A with the saved byte in Register C.
59A6
LD (DE),A 12
Store Register A, the first variable's byte, into the second variable at Register Pair DE.
59A7
INC HL 23
Bump Register Pair HL to the next byte of the first variable.
59A8
INC DE 13
Bump Register Pair DE to the next byte of the second variable.
59A9
DECrement Register B, the bytes left (the type code), and LOOP back to 59A2H until all bytes are exchanged.
59AB
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
59AC
RET C9
RETurn to the statement loop with the two variables exchanged.
59ADH - CMD"C" Program Compression: Options
CMD"C" removes spaces (outside strings) and remarks; CMD"C",S only spaces; CMD"C",R only remarks (manual 7.13). Allowed only as a direct command. The options set two bytes of code: 5A72H (28H JR Z removes spaces, FEH makes it CP 1EH) and 5A95H (00H NOP drops a remark, 13H INC DE keeps it). SYS0's overlay area 4D00H is used as a line buffer, so 4317H is cleared.
59AD
LD DE,(40A2H) ED 5B A2 40
Load Register Pair DE with the current line number from 40A2H.
59B1
LD A,D 7A
Copy Register D, the high byte of the line number, into Register A.
59B2
AND E A3
AND Register A with Register E: FFH only for line FFFFH (a direct command).
59B3
INC A 3C
INCrement Register A: zero (the Z FLAG set) for a direct command.
59B4
JP NZ,1997H C2 97 19
In a program (NZ): JUMP to ROM 1997H, SYNTAX ERROR.
59B7
LD BC,2800H 01 00 28
Load Register Pair BC with 2800H for no options: Register B = 28H (remove spaces), Register C = 00H (remove remarks).
59BA
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H rereads it.
59BB
RST 10H D7
RST 10H: load the next character at Register Pair HL into Register A; the Z FLAG is set at the end of the statement.
59BC
If there are no options (the Z FLAG is set), JUMP to 59D3H.
59BE
LD BC,FE13H 01 13 FE
Options present: load Register Pair BC with FE13H, Register B = FEH (keep spaces) and Register C = 13H (keep remarks).
Loop: one option per comma.
59C1
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
59C2
DEFB 2CH 2C
Inline byte for the RST 08H at 59C1H: 2CH, a comma (not executed).
59C3
CP 52H FE 52
Compare the option letter in Register A with 52H (R).
59C5
If Register A, the option letter, is not R (the NZ FLAG is set), JUMP to 59CBH.
59C7
LD C,00H 0E 00
Option R: load Register C with 00H, remove remarks.
59C9
JUMP to 59D0H to look for another option after the R.
59CB
LD B,28H 06 28
Option S: load Register B with 28H, remove spaces.
59CD
RST 08H CF
RST 08H: the character at Register Pair HL must be the letter S (53H, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
59CE
DEFB 53H 53
Inline byte for the RST 08H at 59CDH: 53H, the letter S (not executed).
59CF
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H rereads it.
59D0
RST 10H D7
RST 10H: load the next character at Register Pair HL into Register A; the Z FLAG is set at the end of the statement.
59D1
Not the end of the statement: LOOP to 59C1H for another option.
59D3
LD A,B 78
Copy Register B, the space option (28H or FEH), into Register A.
59D4
LD (5A72H),A 32 72 5A
Store Register A as the opcode at 5A72H: 28H (JR Z, remove spaces) or FEH (CP, keep spaces).
59D7
LD A,C 79
Copy Register C, the remark option (00H or 13H), into Register A.
59D8
LD (5A95H),A 32 95 5A
Store Register A as the opcode at 5A95H: 00H (NOP, remove remarks) or 13H (INC DE, keep remarks).
59DB
LD HL,4369H 21 69 43
Point Register Pair HL at 4369H, the DOS flags.
59DE
SET 6,(HL) CB F6
Set bit 6 of the DOS flags at Register Pair HL (4369H): an overlay function is running, which blocks the key combinations while 4D00H is used as a buffer.
59E0
XOR A AF
Set Register A to 00H for the overlay byte at 4317H.
59E1
LD (4317H),A 32 17 43
Store Register A (00H) at 4317H: no overlay is in 4D00H-51FFH any more.
59E4
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H (source).
59E7
LD D,H 54
Copy Register H into Register D, the high byte of the destination pointer.
59E8
LD E,L 5D
Copy Register L to Register E: Register Pair DE = the destination, the same address.
59E9
JUMP to 5A31H to start with the first line's link.
59EBH - CMD"C": Line Loop
Each line is copied to 4D00H (kept as the original), then 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 (for example IFFORDTHEN), the original is put back and the line number is displayed. At the end the line links are rebuilt and BASIC returns to READY.
59EB
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the destination pointer after the line.
59EC
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
59ED
SBC HL,BC ED 42
Subtract Register Pair BC, the start of the compressed line's text, from Register Pair HL.
59EF
ADD HL,BC 09
Add Register Pair BC back to Register Pair HL; the Z FLAG from the SBC stays: Z when the compressed line is empty.
59F0
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL back: Register Pair DE = the destination, Register Pair HL = the source.
59F1
INC DE 13
Advance Register Pair DE past the line's 00H.
59F2
INC HL 23
Advance Register Pair HL, the source, past its 00H.
59F3
If the line is not empty (the NZ FLAG is set), JUMP to 59FCH.
59F5
DEC DE 1B
The line was only a remark: step Register Pair DE back 5 bytes (00H, line number and link) so it is dropped.
59F6
DEC DE 1B
DECrement Register Pair DE (2 of 5 steps back over the dropped line).
59F7
DEC DE 1B
DECrement Register Pair DE (3 of 5 steps back over the dropped line).
59F8
DEC DE 1B
DECrement Register Pair DE (4 of 5 steps back over the dropped line).
59F9
DEC DE 1B
DECrement Register Pair DE (5 of 5): Register Pair DE is back at the dropped line's link.
59FA
JUMP to 5A31H to copy the next line with Register Pair DE = the destination.
59FC
PUSH HL E5
Save Register Pair HL, the source of the next line.
59FD
LD H,B 60
Copy Register B into Register H, the high byte of the compressed line's text address.
59FE
LD L,C 69
Copy Register C to Register L: Register Pair HL = the compressed line's text.
59FF
PUSH HL E5
Save Register Pair HL, the compressed line's text, on the stack.
5A00
CALL 2B7EH CD 7E 2B
CALL ROM 2B7EH (BUFLIN) to list the line as text into the input buffer; Register Pair BC returns the end.
5A03
XOR A AF
Set Register A to 00H for the end of the listed text.
5A04
LD (BC),A 02
Store Register A (00H) at Register Pair BC to end the listed text.
5A05
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer address from 40A7H.
5A08
CALL 1BC0H CD C0 1B
CALL ROM 1BC0H to tokenize the text again in the buffer.
5A0B
POP BC C1
Restore Register Pair BC, the compressed line's text.
5A0C
LD D,B 50
Copy Register B into Register D, the high byte of the compressed line's address.
5A0D
LD E,C 59
Copy Register C to Register E: Register Pair DE = the compressed line.
Loop: compare the tokenized buffer with the compressed line.
5A0E
INC HL 23
Bump Register Pair HL to the next byte of the tokenized buffer.
5A0F
LD A,(DE) 1A
Load Register A with a byte of the compressed line at Register Pair DE.
5A10
CP (HL) BE
Compare Register A, the compressed line's byte, with the buffer byte at Register Pair HL.
5A11
INC DE 13
Bump Register Pair DE to the next byte of the compressed line.
5A12
If the bytes are equal (the Z FLAG is set), JUMP to 5A2DH to test for the end of the line.
5A14
LD HL,4D00H 21 00 4D
Different: point Register Pair HL at 4D00H, the saved original line.
Loop: put the original line back.
5A17
LD A,(HL) 7E
Load Register A with a byte of the original line at Register Pair HL.
5A18
OR A B7
OR Register A with itself to set the flags: Z at the line's 00H.
5A19
LD (BC),A 02
Store Register A into the line at Register Pair BC, restoring the original.
5A1A
INC HL 23
Bump Register Pair HL to the next byte of the original line.
5A1B
INC BC 03
Bump Register Pair BC to the next byte of the restored line.
5A1C
If the byte was not the 00H (the NZ FLAG is set), LOOP back to 5A17H.
5A1E
PUSH BC C5
Save Register Pair BC, the end of the restored line.
5A1F
LD DE,0000H 11 00 00
Load Register Pair DE with the line number; the operand 0000H at 5A20H is filled in by 5A53H.
5A22
CALL 5D8EH to display it in decimal; Register E returns the number of digits.
5A25
LD A,08H 3E 08
Load Register A with 08H, the width of the line number column.
5A27
SUB E 93
Subtract the digit count in Register E: Register A = the spaces needed for an 8-character column.
5A28
GOSUB to 5D57H to display Register A spaces after the line number.
5A2B
XOR A AF
Clear Register A so the test at 5A2DH ends the compare.
5A2C
POP DE D1
Restore Register Pair DE, the end of the line.
5A2D
OR A B7
Set the flags from Register A: Z at the line's 00H.
5A2E
If Register A is not the line's 00H (the NZ FLAG is set), LOOP back to 5A0EH.
5A30
POP HL E1
Restore Register Pair HL, the source of the next line.
5A31
LD C,(HL) 4E
Load Register C with the low byte of the next line's link at Register Pair HL, the source.
5A32
INC HL 23
Bump Register Pair HL to the high byte of the link.
5A33
LD B,(HL) 46
Load Register B with the high byte of the link at Register Pair HL.
5A34
LD A,C 79
Copy Register C, the low byte of the link, into Register A.
5A35
LD (DE),A 12
Store Register A, the low byte of the link, at the destination Register Pair DE.
5A36
INC DE 13
Bump Register Pair DE to the next destination byte.
5A37
LD A,B 78
Copy Register B, the high byte of the link, into Register A.
5A38
LD (DE),A 12
Store Register A, the high byte of the link, at the destination Register Pair DE.
5A39
INC DE 13
Bump Register Pair DE to the next destination byte.
5A3A
INC HL 23
Bump Register Pair HL to the source's line number.
5A3B
LD A,B 78
Copy Register B, the high byte of the link, into Register A.
5A3C
OR C B1
OR Register A with Register C: a zero link (the Z FLAG set) is the end of the program.
5A3D
If there is another line (the NZ FLAG is set), JUMP to 5A4BH.
5A3F
CALL 1AF8H CD F8 1A
End of the program: CALL ROM 1AF8H to rebuild the line links.
5A42
CALL 1B59H CD 59 1B
CALL ROM 1B59H, inside NEW: store the end of the program at 40F9H and clear the variables.
5A45
GOSUB to 5D79H to display a carriage return after the list of changed lines.
5A48
JP 1A19H C3 19 1A
JUMP to ROM 1A19H, READY, which ends the command.
5A4B
LD C,(HL) 4E
Load Register C with the low byte of the line number at Register Pair HL.
5A4C
INC HL 23
Bump Register Pair HL to the high byte of the line number.
5A4D
LD B,(HL) 46
Load Register B with the high byte of the line number at Register Pair HL.
5A4E
LD A,C 79
Copy Register C, the low byte of the line number, into Register A.
5A4F
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A50
INC DE 13
Bump Register Pair DE to the next destination byte.
5A51
LD A,B 78
Copy Register B, the high byte of the line number, into Register A.
5A52
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A53
LD (5A20H),BC ED 43 20 5A
Store Register Pair BC, the line number, in the operand at 5A20H for the display at 5A1FH.
5A57
INC DE 13
Advance Register Pair DE to the destination text.
5A58
INC HL 23
Bump Register Pair HL to the source line's text.
5A59
PUSH HL E5
Save Register Pair HL, the source text address, on the stack.
5A5A
LD B,D 42
Copy Register D into Register B, the high byte of the destination text.
5A5B
LD C,E 4B
Copy Register E to Register C: Register Pair BC = the start of the destination text.
5A5C
PUSH DE D5
Save Register Pair DE, the destination, on the stack.
5A5D
LD DE,4D00H 11 00 4D
Point Register Pair DE at 4D00H, where the original line is kept.
5A60
CALL 5A74H to copy one item of the line to 4D00H; remarks are handled as set by the options.
5A63
If the line's 00H has not been copied (the NZ FLAG is set), LOOP back to 5A60H.
5A65
POP DE D1
Restore Register Pair DE, the destination, from the stack.
5A66
POP HL E1
Restore Register Pair HL, the source text, from the stack.
5A67
CALL 5A6FH to copy one item of the line with the space rule as well.
5A6A
If the line's 00H has not been copied (the NZ FLAG is set), LOOP back to 5A67H.
5A6C
JUMP to 59EBH to finish the line with Register Pair DE = the end of the compressed line.
5A6FH - CMD"C": Copy One Item
Copies from Register Pair HL to Register Pair DE: a space (removed when 5A72H is JR Z), a whole quoted string, or one character. After a colon or at a REM token (93H) the opcode at 5A95H decides whether the remark is copied (INC DE) or dropped (NOP, the destination stops advancing). Returns Z at the line's 00H.
5A6F
LD A,(HL) 7E
Load Register A with the source character at Register Pair HL.
5A70
CP 20H FE 20
Compare Register A, the source character, with 20H (space).
5A72
Self-Modifying Code
Opcode set by 59D4H: 28H (JR Z) sends a space to 5A92H, which skips it; FEH turns the two bytes into CP 1EH, which changes nothing.
5A74
LD A,(HL) 7E
Load Register A with the source character at Register Pair HL (entry from 5A60H, no space rule).
5A75
OR A B7
OR Register A with itself to set the flags: Z for the line's 00H.
5A76
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A77
RET Z C8
If it is the line's 00H (the Z FLAG is set), RETurn with Z.
5A78
CP 22H FE 22
Compare Register A, the source character, with 22H, a quote.
5A7A
If Register A is not a quote (the NZ FLAG is set), JUMP to 5A86H.
Loop: copy a quoted string unchanged.
5A7C
INC HL 23
Bump Register Pair HL to the next source character inside the string.
5A7D
INC DE 13
Bump Register Pair DE to the next destination byte.
5A7E
LD A,(HL) 7E
Load Register A with the next source character at Register Pair HL.
5A7F
OR A B7
OR Register A with itself to set the flags: Z for the line's 00H.
5A80
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A81
RET Z C8
If it is the line's 00H (the Z FLAG is set), RETurn with Z.
5A82
CP 22H FE 22
Compare Register A with 22H, the closing quote.
5A84
If Register A is not the closing quote (the NZ FLAG is set), LOOP back to 5A7CH.
5A86
CP 3AH FE 3A
Compare Register A, the character, with 3AH (colon).
5A88
If Register A is not a colon (the NZ FLAG is set), JUMP to 5A8DH.
5A8A
PUSH HL E5
Save Register Pair HL, the source pointer, on the stack.
5A8B
RST 10H D7
RST 10H: step Register Pair HL and load Register A with the next non-space character after the colon.
5A8C
POP HL E1
Restore Register Pair HL, the source pointer at the colon, from the stack.
5A8D
CP 93H FE 93
Compare Register A, the next character, with 93H, the REM token.
5A8F
If Register A is the REM token (the Z FLAG is set), JUMP to 5A95H.
5A91
INC DE 13
Keep the character: advance Register Pair DE.
5A92
INC HL 23
Bump Register Pair HL to the next source character.
5A93
OR D B2
OR Register D (not zero) into Register A: NZ, the line goes on.
5A94
RET C9
RETurn with the NZ FLAG set: the line goes on.
5A95
NOP 00
Self-Modifying Code
Opcode set by 59D8H: 13H (INC DE) copies the remark; 00H (NOP) leaves Register Pair DE in place, so the colon and the remark are overwritten and the line ends there.
5A96
INC HL 23
Bump Register Pair HL to the next character of the remark.
5A97
LD A,(HL) 7E
Load Register A with the next character of the remark at Register Pair HL.
5A98
OR A B7
OR Register A with itself to set the flags: Z for the line's 00H.
5A99
LD (DE),A 12
Store Register A at the destination Register Pair DE.
5A9A
If it is not the line's 00H (the NZ FLAG is set), LOOP back to 5A95H.
5A9C
RET C9
RETurn with the Z FLAG set: the line has ended.
5A9DH - CMD"J",date1,date2: mm/dd/yy to Day of the Year
date1 in mm/dd/yy form is converted to the 3-digit day of the year ddd; date1 starting with - (-yy/ddd) goes to 5B10H. The result string is assigned to the string variable date2 (manual CMD"J"). Bad values give ILLEGAL FUNCTION CALL. The year only decides February: 00 and years not divisible by 4 have 28 days.
5A9D
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5A9E
DEFB 2CH 2C
Inline byte for the RST 08H at 5A9DH: 2CH, a comma (not executed).
5A9F
CALL 61B7H to evaluate date1: Z for a string, with Register B = its length and Register Pair HL = its text; the BASIC text pointer is left on the stack.
5AA2
Not a string: JUMP to 5B0EH (ILLEGAL FUNCTION CALL).
5AA4
LD A,(HL) 7E
Load Register A with the first character of date1 at Register Pair HL.
5AA5
CP 2DH FE 2D
Compare Register A, the first character, with 2DH (-).
5AA7
LD A,B 78
Load Register A with the length from Register B.
5AA8
If date1 starts with - (the Z FLAG is set), JUMP to 5B10H with Register A = the length.
5AAA
CP 08H FE 08
Compare Register A, the length of date1, with 08H.
5AAC
If Register A is below 08H (the CARRY FLAG is set), date1 is shorter than mm/dd/yy: JUMP to 5B0EH.
5AAE
LD BC,010CH 01 0C 01
Load Register Pair BC with 010CH: Register B = 01H, Register C = 0CH, so the month must be 1-12.
5AB1
CALL 5B6EH to read the 2-digit month into Register A.
5AB4
PUSH AF F5
Save Register Pair AF on the stack: Register A = the month.
5AB5
GOSUB to 5B66H: a / must follow at Register Pair HL.
5AB8
LD BC,011FH 01 1F 01
Load Register Pair BC with 011FH: Register B = 01H, Register C = 1FH, so the day must be 1-31.
5ABB
CALL 5B6EH to read the 2-digit day into Register A.
5ABE
POP BC C1
Restore the month into Register B (Register Pair BC from the pushed Register Pair AF).
5ABF
DEC A 3D
DECrement Register A, the day of the month, by 1.
5AC0
LD C,A 4F
Copy Register A, the day minus 1, into Register C.
5AC1
PUSH BC C5
Save Register Pair BC on the stack: Register B = the month, Register C = the day minus 1.
5AC2
GOSUB to 5B66H: a / must follow at Register Pair HL.
5AC5
CALL 5B80H to read the 2-digit year and set February's length at 5BA3H.
5AC8
LD HL,5BA1H 21 A1 5B
Point Register Pair HL at 5BA1H, the table of month lengths (5BA1H = 0, then January).
5ACB
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the day count of the months before.
5ACE
POP BC C1
Restore Register Pair BC: Register B = the month, Register C = the day minus 1.
Loop: add the lengths of the months before this one.
5ACF
LD A,(HL) 7E
Load Register A with the month length at Register Pair HL in the table.
5AD0
ADD A,E 83
Add Register E, the low byte of the day count, to Register A.
5AD1
LD E,A 5F
Copy Register A into Register E, the low byte of the day count.
5AD2
INC HL 23
Bump Register Pair HL to the next month's entry.
5AD3
If there was no carry (the NC FLAG is set), JUMP to 5AD6H.
5AD5
INC D 14
INCrement Register D to take the carry into the high byte of the day count in Register Pair DE.
5AD6
DECrement Register B, the month, and LOOP back to 5ACFH; Register Pair HL ends at the month's own entry.
5AD8
LD A,C 79
Copy Register C, the day minus 1, into Register A.
5AD9
CP (HL) BE
Compare Register A with the month's length at Register Pair HL.
5ADA
If the day is past the month's length (the NC FLAG is set), JUMP to 5B0EH.
5ADC
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the days before the month.
5ADD
INC BC 03
Register Pair BC = the day (Register B is 00H after the loop).
5ADE
ADD HL,BC 09
Add Register Pair BC, the day, to Register Pair HL: Register Pair HL = the day of the year.
5ADF
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the day of the year.
5AE0
CALL 5D32H to convert Register Pair DE to five decimal digits at 5D51H-5D55H.
5AE3
LD HL,5D53H 21 53 5D
Point Register Pair HL at 5D53H, the last three digits.
5AE6
LD DE,5BAEH 11 AE 5B
Point Register Pair DE at 5BAEH, the result buffer.
5AE9
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the three digits to copy.
5AEC
LDIR ED B0
Copy Register Pair BC (3) bytes from Register Pair HL (5D53H) to Register Pair DE (5BAEH): the digits ddd.
5AEE
LD A,03H 3E 03
Load Register A with 03H, the length of the result.
5AF0
POP HL E1
Restore Register Pair HL, the BASIC text pointer.
5AF1
PUSH AF F5
Save Register Pair AF on the stack: Register A = the result length.
5AF2
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5AF3
DEFB 2CH 2C
Inline byte for the RST 08H at 5AF2H: 2CH, a comma (not executed).
5AF4
CALL 260DH CD 0D 26
CALL ROM 260DH, PTRGET: Register Pair DE = the address of date2.
5AF7
CALL AF4H CD F4 0A
CALL ROM 0AF4H: date2 must be a string variable.
5AFA
POP AF F1
Restore Register Pair AF: Register A = the result length.
5AFB
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5AFC
PUSH DE D5
Save Register Pair DE, the address of date2, on the stack.
5AFD
CALL 28BFH CD BF 28
CALL ROM 28BFH to reserve Register A bytes of string space; Register Pair DE returns the address.
5B00
POP HL E1
Restore Register Pair HL, the variable's address.
5B01
CALL 285DH CD 5D 28
CALL ROM 285DH to store the length and address into the variable's descriptor.
5B04
LD HL,5BAEH 21 AE 5B
Point Register Pair HL at the result in 5BAEH.
5B07
LD C,A 4F
Copy Register A, the result length, into Register C.
5B08
LD B,00H 06 00
Load Register B with 00H, so Register Pair BC = the result length.
5B0A
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (5BAEH) to Register Pair DE, the new string.
5B0C
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5B0D
RET C9
RETurn to the statement loop with date2 assigned.
5B0E
JUMP to 5B6BH, ILLEGAL FUNCTION CALL (the bad-value exit of CMD"J").
5B10H - CMD"J": -yy/ddd to mm/dd/yy
The day of the year is turned into a month and day by subtracting month lengths; the result mm/dd/yy (8 characters) is built at 5BAEH and assigned to date2 through 5AF0H.
5B10
CP 07H FE 07
Compare Register A, the length of date1, with 07H.
5B12
If Register A is below 07H (the CARRY FLAG is set), date1 is shorter than -yy/ddd: JUMP to 5B0EH.
5B14
INC HL 23
Bump Register Pair HL past the - to the first year digit.
5B15
LD E,(HL) 5E
Load Register E with the first year digit at Register Pair HL.
5B16
INC HL 23
Bump Register Pair HL to the second year digit.
5B17
LD D,(HL) 56
Load Register D with the second year digit at Register Pair HL.
5B18
LD (5BB4H),DE ED 53 B4 5B
Store Register Pair DE, the two year characters, at 5BB4H, the yy of the result.
5B1C
DEC HL 2B
Step Register Pair HL back to the first year digit.
5B1D
CALL 5B80H to read the year and set February's length.
5B20
GOSUB to 5B66H: a / must follow at Register Pair HL.
5B23
LD B,03H 06 03
Load Register B with 03H: exactly three digits for ddd.
5B25
CALL 5B95H to read ddd into Register Pair DE.
5B28
LD HL,5BA2H 21 A2 5B
Point Register Pair HL at 5BA2H, January's length.
5B2B
LD B,00H 06 00
Load Register B with 00H, so Register Pair BC = a month's length in Register C.
5B2D
DEC DE 1B
DECrement Register Pair DE, the day of the year, to the day minus 1.
Loop: subtract month lengths until the day falls inside a month.
5B2E
LD A,L 7D
Copy Register L, the low byte of the table pointer, into Register A.
5B2F
CP AEH FE AE
Compare Register A with AEH, the low byte of 5BAEH, one past December's entry at 5BADH.
5B31
If Register A is AEH (the Z FLAG is set), the day is past the end of the year: JUMP to 5B0EH.
5B33
LD C,(HL) 4E
Load Register C with the month's length at Register Pair HL.
5B34
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the remaining days.
5B35
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
5B36
SBC HL,BC ED 42
Subtract Register Pair BC, the month's length, from Register Pair HL, the remaining days.
5B38
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL back: Register Pair HL = the table pointer.
5B39
INC HL 23
Bump Register Pair HL to the next month's entry.
5B3A
If there was no borrow (the NC FLAG is set), LOOP back to 5B2EH.
5B3C
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the negative remainder.
5B3D
ADD HL,BC 09
Add Register Pair BC, the month's length, back to Register Pair HL: the day minus 1 within the month.
5B3E
PUSH HL E5
Save Register Pair HL, the day minus 1, on the stack.
5B3F
LD A,E 7B
Copy Register E, the low byte of the table pointer (one past the month's entry), into Register A.
5B40
SUB A2H D6 A2
Subtract A2H from Register A: the month number 1-12.
5B42
LD E,A 5F
Copy Register A, the month number, into Register E.
5B43
LD D,H 54
Copy Register H (00H, the high byte of the day value) into Register D, so Register Pair DE = the month.
5B44
CALL 5D32H to convert the month to decimal digits at 5D51H.
5B47
LD HL,(5D54H) 2A 54 5D
Load Register Pair HL with the last two digits at 5D54H.
5B4A
LD (5BAEH),HL 22 AE 5B
Store Register Pair HL, the two month digits, at 5BAEH: mm.
5B4D
POP DE D1
Restore Register Pair DE, the day minus 1, from the stack.
5B4E
INC DE 13
INCrement Register Pair DE to the day of the month.
5B4F
GOSUB to 5D32H to convert Register Pair DE, the day, to decimal digits at 5D51H.
5B52
LD HL,5BB0H 21 B0 5B
Point Register Pair HL at 5BB0H, after mm in the result.
5B55
LD A,2FH 3E 2F
Load Register A with 2FH (/), the separator of mm/dd/yy.
5B57
LD (HL),A 77
Store Register A, the first /, at Register Pair HL.
5B58
INC HL 23
Bump Register Pair HL to the day's first digit.
5B59
LD DE,(5D54H) ED 5B 54 5D
Load Register Pair DE with the day's last two digits from 5D54H.
5B5D
LD (HL),E 73
Store Register E, the first digit of the day, at Register Pair HL.
5B5E
INC HL 23
Bump Register Pair HL to the next result byte.
5B5F
LD (HL),D 72
Store Register D, the second digit of the day, at Register Pair HL: dd.
5B60
INC HL 23
Bump Register Pair HL to the next result byte.
5B61
LD (HL),A 77
Store Register A, the second /, at Register Pair HL (yy follows at 5BB4H).
5B62
LD A,08H 3E 08
Load Register A with 08H, the length of mm/dd/yy.
5B64
JUMP to 5AF0H to assign the result to date2 with Register A = 08H.
5B66H - CMD"J" Helpers
5B66H requires a /; 5B6EH reads a 2-digit number within Register B to Register B + Register C - 1; 5B80H reads the year and puts 28 or 29 into February's entry; 5B95H reads exactly Register B digits. All errors go to ILLEGAL FUNCTION CALL.
5B66
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
5B67
CP 2FH FE 2F
Compare Register A, the character, with 2FH (/).
5B69
INC HL 23
Bump Register Pair HL past the character just tested.
5B6A
RET Z C8
If Register A was a / (the Z FLAG is set), RETurn.
5B6B
JP 1E4AH C3 4A 1E
JUMP to ROM 1E4AH to report ILLEGAL FUNCTION CALL.
5B6E
PUSH BC C5
Save Register Pair BC, the range (Register B = the lowest value, Register C = the count), on the stack.
5B6F
LD B,02H 06 02
Load Register B with 02H, the number of digits to read.
5B71
CALL 5B95H to read them into Register Pair DE.
5B74
LD A,D 7A
Copy Register D, the high byte of the value, into Register A.
5B75
OR A B7
OR Register A with itself to set the flags: NZ for a value above 255.
5B76
If the value is above 255 (the NZ FLAG is set), JUMP to 5B6BH.
5B78
POP BC C1
Restore Register Pair BC, the range, from the stack.
5B79
LD A,E 7B
Load Register A with the value in Register E.
5B7A
SUB B 90
Subtract Register B, the lowest value, from Register A.
5B7B
CP C B9
Compare Register A with Register C, the number of allowed values.
5B7C
If the value is out of range (the NC FLAG is set), JUMP to 5B6BH.
5B7E
LD A,E 7B
Copy Register E, the value read, into Register A for the caller.
5B7F
RET C9
RETurn with Register A = the value, checked against the range.
5B80
LD BC,0064H 01 64 00
Register Pair BC = 0064H: the year must be 0-99.
5B83
GOSUB to 5B6EH to read the year into Register A.
5B86
LD B,1CH 06 1C
Load Register B with 1CH, 28 days for February.
5B88
OR A B7
OR Register A, the year, with itself to set the flags.
5B89
If the year is 00 (the Z FLAG is set), keep 28: JUMP to 5B90H.
5B8B
AND 03H E6 03
AND Register A, the year, with 03H, keeping the low two bits.
5B8D
If the year is not divisible by 4 (the NZ FLAG is set), JUMP to 5B90H.
5B8F
INC B 04
INCrement Register B from 28 to 29 days: a leap year.
5B90
LD A,B 78
Copy Register B, February's length (28 or 29), into Register A.
5B91
LD (5BA3H),A 32 A3 5B
Store Register A, February's length, at 5BA3H in the month table.
5B94
RET C9
RETurn with February's length set for the year read.
5B95
PUSH BC C5
Save Register Pair BC on the stack: Register B = the number of digits wanted.
5B96
CALL 5CFEH to read decimal digits into Register Pair DE; Register C returns the number of digits, Carry on overflow.
5B99
LD A,C 79
Copy Register C, the digit count, into Register A.
5B9A
POP BC C1
Restore Register Pair BC: Register B = the number of digits wanted.
5B9B
If the number overflowed (the CARRY FLAG is set), JUMP to 5B6BH.
5B9D
CP B B8
Compare Register A, the digit count, with Register B, the number wanted.
5B9E
If the counts differ (the NZ FLAG is set), JUMP to 5B6BH.
5BA0
RET C9
RETurn with Register Pair DE = the value read.
5BA1H - CMD"J" Month Lengths
5BA1H is 0 (so the sum at 5ACFH starts from nothing); 5BA2H-5BADH are January to December. February (5BA3H) is set to 28 or 29 by 5B91H.
5BA1
DEFB 00H 00
Month length table entry. 00H, the entry before January, so the sum at 5ACFH for January adds nothing.
5BA2
DEFB 1FH 1F
Month length table entry. January: 1FH, 31 days.
5BA3
DEFB 1CH 1C
Month length table entry. February: 1CH (28 days) in the file, set to 28 or 29 by 5B91H.
5BA4
DEFB 1FH 1F
Month length table entry. March: 1FH, 31 days.
5BA5
DEFB 1EH 1E
Month length table entry. April: 1EH, 30 days.
5BA6
DEFB 1FH 1F
Month length table entry for May: 1FH, 31 days.
5BA7
DEFB 1EH 1E
Month length table entry. June: 1EH, 30 days.
5BA8
DEFB 1FH 1F
Month length table entry. July: 1FH, 31 days.
5BA9
DEFB 1FH 1F
Month length table entry. August: 1FH, 31 days.
5BAA
DEFB 1EH 1E
Month length table entry. September: 1EH, 30 days.
5BAB
DEFB 1FH 1F
Month length table entry. October: 1FH, 31 days.
5BAC
DEFB 1EH 1E
Month length table entry. November: 1EH, 30 days.
5BAD
DEFB 1FH 1F
Month length table entry. December: 1FH, 31 days.
5BAEH - CMD"J" Result Buffer
The result is built here: ddd in 5BAEH-5BB0H, or mm/dd/ in 5BAEH-5BB3H followed by yy in 5BB4H-5BB5H.
5BAE-5BB3
DEFB 00H,00H,00H,00H,00H,00H 00 00 00 00 00 00
5BAEH-5BB3H: the result mm/dd/ (for -yy/ddd) or ddd in the first three bytes.
5BB4-5BB5
DEFB 00H,00H 00 00
5BB4H-5BB5H: the year yy of the result, copied from date1 at 5B18H.
5BB6H - CMD"F=SS" Single Stepping
CMD"F=SS" turns single stepping on, CMD"F=SS",line from that line, CMD"F=SS",N off (manual 7.20). The line number goes into the operand at 63EBH; the opcode at 63DBH becomes 20H (JR NZ, stepping on) or 18H (JR, off).
5BB6
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: no start line yet.
5BB9
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H rereads it.
5BBA
RST 10H D7
RST 10H: load the next character at Register Pair HL into Register A; the Z FLAG is set at the end of the statement.
5BBB
End of the statement: JUMP to 5BCBH (on, from the next line).
5BBD
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5BBE
DEFB 2CH 2C
Inline byte for the RST 08H at 5BBDH: 2CH, a comma (not executed).
5BBF
CP 4EH FE 4E
Compare Register A, the character after the comma, with 4EH (N).
5BC1
If Register A is N (the Z FLAG is set), JUMP to 5BD4H to turn stepping off.
5BC3
CALL 5CFCH to read the start line number into Register Pair DE; Register C = the number of digits.
5BC6
LD A,C 79
Copy Register C, the digit count, into Register A.
5BC7
OR A B7
OR Register A with itself to set the flags: Z when no digits were read.
5BC8
JP Z,1997H CA 97 19
If no digits were read (the Z FLAG is set), JUMP to ROM 1997H, SYNTAX ERROR.
5BCB
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H at 5BD9H rereads it.
5BCC
LD (63EBH),DE ED 53 EB 63
Store Register Pair DE, the start line number, in the operand at 63EBH.
5BD0
LD A,20H 3E 20
Register A = 20H, the opcode JR NZ (stepping on).
5BD2
JUMP to 5BD6H to store the opcode in Register A.
5BD4
LD A,18H 3E 18
Register A = 18H, the opcode JR (stepping off).
5BD6
LD (63DBH),A 32 DB 63
Store Register A, the opcode 20H or 18H, at 63DBH.
5BD9
RST 10H D7
RST 10H: load the next character at Register Pair HL into Register A for the statement loop.
5BDA
RET C9
RETurn to the statement loop with single stepping set.
5BDBH - Variable Name Parser (for SYS21)
Used by SYS21's ERASE/KEEP and CMD"O". Reads a variable name: the first letter goes into Register B, the second character (letter or digit, 00H if none) into Register C, and the type (suffix %, $, ! or #, else the DEF type of the first letter from the ROM table at 4101H) into Register D. They are stored as the compare operands at 5C25H (type), 5C2AH (second character) and 5C30H (first character). Returns Z when a ( follows (an array). 5BDBH steps back first; 5BDDH starts with the character in Register A.
5BDB
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H rereads it.
5BDC
RST 10H D7
RST 10H: load Register A with the next non-space character at Register Pair HL.
5BDD
LD B,A 47
Copy Register A, the first character of the name, into Register B.
5BDE
CALL 1E3DH CD 3D 1E
GOSUB to ROM 1E3DH: the CARRY FLAG is set if Register A is not a letter.
5BE1
JP C,1997H DA 97 19
Not a letter: JUMP to ROM 1997H, SYNTAX ERROR.
5BE4
XOR A AF
Set Register A to 00H for the second character.
5BE5
LD C,A 4F
Copy Register A (00H) into Register C: no second character yet.
Loop: skip the rest of the name, keeping its second character.
5BE6
INC C 0C
INCrement Register C, the second character, to test it.
5BE7
DEC C 0D
DECrement Register C back again: the Z FLAG is set if it is 00H.
5BE8
If Register C is already set (the NZ FLAG is set), JUMP to 5BEBH.
5BEA
LD C,A 4F
Store the character in Register A as the second character in Register C (00H on the first pass).
5BEB
RST 10H D7
RST 10H: load the next character at Register Pair HL into Register A; the CARRY FLAG is set for a digit.
5BEC
If Register A is a digit (the CARRY FLAG is set), LOOP back to 5BE6H.
5BEE
CALL 1E3DH CD 3D 1E
GOSUB to ROM 1E3DH: the CARRY FLAG is set if Register A is not a letter.
5BF1
If Register A is a letter (the NC FLAG is set), LOOP back to 5BE6H.
5BF3
LD D,02H 16 02
Load Register D with 02H, the integer type, for a % suffix.
5BF5
SUB 25H D6 25
Subtract 25H from Register A, the suffix character: zero for %.
5BF7
If the suffix is % (the Z FLAG is set), JUMP to 5C11H with Register D = 02H.
5BF9
INC D 14
INCrement Register D to 03H, the string type.
5BFA
INC A 3C
INCrement Register A, the suffix character minus 25H: zero for $ (24H).
5BFB
If the suffix is $ (the Z FLAG is set), JUMP to 5C11H with Register D = 03H.
5BFD
INC D 14
INCrement Register D to 04H, the single-precision type.
5BFE
CP FDH FE FD
Compare Register A with FDH, the value left by ! (21H).
5C00
If the suffix is ! (the Z FLAG is set), JUMP to 5C11H with Register D = 04H.
5C02
LD D,08H 16 08
Load Register D with 08H, the double-precision type.
5C04
INC A 3C
INCrement Register A, the suffix character minus 22H: zero for # (23H).
5C05
If the suffix is # (the Z FLAG is set), JUMP to 5C11H with Register D = 08H.
5C07
LD A,B 78
No suffix: load Register A with the first character from Register B.
5C08
SUB 41H D6 41
Subtract 41H (A) from Register A, the first character.
5C0A
LD E,A 5F
Copy Register A, the letter's offset, into Register E.
5C0B
INC E 1C
Add 1: Register E = the letter's offset in the ROM's DEF type table.
5C0C
LD D,41H 16 41
Register D = 41H: Register Pair DE = 4101H + the letter's position.
5C0E
LD A,(DE) 1A
Load Register A with the letter's default type from the ROM's DEF type table at Register Pair DE.
5C0F
LD D,A 57
Copy Register A, the default type, into Register D.
5C10
DEC HL 2B
Step Register Pair HL back: the character read was not a suffix.
5C11
LD A,D 7A
Copy Register D, the type of the variable, into Register A.
5C12
LD (5C25H),A 32 25 5C
Store Register A, the type, as the operand at 5C25H.
5C15
LD A,C 79
Load Register A with the second character from Register C.
5C16
LD (5C2AH),A 32 2A 5C
Store Register A, the second character, as the operand at 5C2AH.
5C19
LD A,B 78
Load Register A with the first character from Register B.
5C1A
LD (5C30H),A 32 30 5C
Store Register A, the first character, as the operand at 5C30H.
5C1D
RST 10H D7
RST 10H: load the next character at Register Pair HL into Register A.
5C1E
CP 28H FE 28
Compare Register A with 28H, the ( of an array.
5C20
RET C9
RETurn with the Z FLAG set for an array and the name stored in the operands.
5C21H - Variable Table Helpers (for SYS21)
5C21H compares the variable entry at Register Pair HL with the name stored by 5BDDH (Z = match, Register Pair HL unchanged). 5C34H steps to the next simple variable, 5C3FH to the next array. 5C48H skips a subscript in parentheses (Carry if the statement ends first).
5C21
LD A,(HL) 7E
Load Register A with the entry's type byte at Register Pair HL.
5C22
AND 0FH E6 0F
AND Register A with 0FH, keeping bits 0-3, the type (SYS21 uses bit 4 as a mark).
5C24
CP 00H FE 00
Compare Register A with the wanted type, the operand at 5C25H (00H in the file) stored by 5C12H.
5C26
RET NZ C0
If the type differs (the NZ FLAG is set), RETurn with NZ.
5C27
INC HL 23
Advance Register Pair HL to the entry's second name character.
5C28
LD A,(HL) 7E
Load Register A with the entry's second name character at Register Pair HL.
5C29
CP 00H FE 00
Compare Register A with the wanted second character, the operand at 5C2AH (00H in the file) stored by 5C16H.
5C2B
If it differs (the NZ FLAG is set), JUMP to 5C32H with NZ.
5C2D
INC HL 23
Bump Register Pair HL to the entry's first name character.
5C2E
LD A,(HL) 7E
Load Register A with the entry's first name character at Register Pair HL.
5C2F
CP 00H FE 00
Compare Register A with the wanted first character, the operand at 5C30H (00H in the file) stored by 5C1AH: Z on a match.
5C31
DEC HL 2B
DECrement Register Pair HL back to the second name character.
5C32
DEC HL 2B
Step back again: Register Pair HL points at the entry's type byte (DEC does not change the flags).
5C33
RET C9
RETurn with Register Pair HL at the entry's type byte and the Z FLAG set on a match.
5C34
LD A,(HL) 7E
Next simple variable: load Register A with the type byte at Register Pair HL.
5C35
AND 0FH E6 0F
AND Register A with 0FH, keeping the type, which is its length in bytes.
5C37
ADD A,03H C6 03
Add 03H to Register A for the type byte and the two name characters.
5C39
LD C,A 4F
Copy Register A, the entry's size, into Register C.
5C3A
LD B,00H 06 00
Load Register B with 00H, so Register Pair BC = the entry's size.
5C3C
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL points at the next entry.
5C3D
OR H B4
OR Register H into Register A: the NZ FLAG is set.
5C3E
RET C9
RETurn with Register Pair HL at the next entry and the NZ FLAG set.
5C3F
INC HL 23
Next array: bump Register Pair HL past the type byte.
5C40
INC HL 23
Bump Register Pair HL past the second name character.
5C41
INC HL 23
Bump Register Pair HL past the first name character.
5C42
LD C,(HL) 4E
Load Register C with the low byte of the array's length at Register Pair HL.
5C43
INC HL 23
Bump Register Pair HL to the high byte of the length.
5C44
LD B,(HL) 46
Load Register B with the high byte of the array's length at Register Pair HL.
5C45
INC HL 23
Advance Register Pair HL past the length word.
5C46
JUMP to 5C3CH to add the length in Register Pair BC to Register Pair HL.
5C48
LD B,00H 06 00
Skip a subscript: Register B = 00H, the parenthesis depth.
5C4A
INC B 04
INCrement Register B, the parenthesis depth: one level deeper.
5C4B
RST 10H D7
RST 10H: load the next character at Register Pair HL into Register A; Z at the end of the statement.
5C4C
SCF 37
Set the CARRY FLAG for an early end of the statement.
5C4D
RET Z C8
If the statement ended (the Z FLAG is set), RETurn with the CARRY FLAG set.
5C4E
CP 28H FE 28
Compare Register A, the character, with 28H, an opening parenthesis.
5C50
If Register A is ( (the Z FLAG is set), JUMP to 5C4AH.
5C52
CP 29H FE 29
Compare Register A, the character, with 29H, a closing parenthesis.
5C54
If Register A is not ) (the NZ FLAG is set), JUMP to 5C4BH.
5C56
DECrement Register B, the depth, and LOOP back to 5C4BH until level 0.
5C58
RST 10H D7
RST 10H: load the character after the subscript at Register Pair HL into Register A.
5C59
OR A B7
OR Register A with itself to clear the CARRY FLAG (Z if the statement ends).
5C5A
RET C9
RETurn with the CARRY FLAG clear and Register A = the character after the subscript.
5C5BH - CMD"F=SASZ",size
Changes the size of the string area without clearing variables (manual 7.16). The strings are compacted to the top of memory; the new bottom (top of memory minus size) must be below the lowest string (else OUT OF STRING SPACE) and at least 256 bytes above the arrays (else OUT OF MEMORY). The stack, which lies just below the string area, is moved with it.
5C5B
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5C5C
DEFB 2CH 2C
Inline byte for the RST 08H at 5C5BH: 2CH, a comma (not executed).
5C5D
CALL 2B02H CD 02 2B
CALL ROM 2B02H to evaluate the size into Register Pair DE.
5C60
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5C61
LD HL,(40B1H) 2A B1 40
Load Register Pair HL with the top of memory from 40B1H.
5C64
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
5C65
SBC HL,DE ED 52
Subtract Register Pair DE, the size, from Register Pair HL: Register Pair HL = the new bottom of the string area.
5C67
LD (5C9EH),HL 22 9E 5C
Store Register Pair HL, the new bottom, as the operand at 5C9EH.
5C6A
PUSH HL E5
Save Register Pair HL, the new bottom, on the stack.
5C6B
CALL 28E6H CD E6 28
CALL ROM 28E6H to collect garbage: all strings in use are moved to the top.
5C6E
POP DE D1
Restore Register Pair DE = the new bottom of the string area.
5C6F
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with 40D6H, the lowest string in use.
5C72
RST 18H DF
RST 18H compares Register Pair HL with Register Pair DE: Carry when the strings reach below the new bottom.
5C73
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the new bottom.
5C74
LD E,1AH 1E 1A
Register E = 1AH, the error code OUT OF STRING SPACE.
5C76
JP C,19A2H DA A2 19
Strings do not fit: JUMP to the ROM error routine 19A2H.
5C79
LD DE,(40A0H) ED 5B A0 40
Load Register Pair DE with the old bottom of the string area from 40A0H.
5C7D
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
5C7E
SBC HL,DE ED 52
Subtract Register Pair DE, the old bottom, from Register Pair HL: the distance the area moves.
5C80
ADD HL,SP 39
Add the Stack Pointer to Register Pair HL: Register Pair HL = the new Stack Pointer.
5C81
LD (5CB4H),HL 22 B4 5C
Store Register Pair HL, the new Stack Pointer, as the operand at 5CB4H.
5C84
DEC H 25
DECrement Register H, subtracting 256 from Register Pair HL as a safety margin.
5C85
LD DE,(40FDH) ED 5B FD 40
Load Register Pair DE with 40FDH, the end of the arrays.
5C89
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 if the stack would come too close.
5C8A
JP C,197AH DA 7A 19
If the new stack is too close (the CARRY FLAG is set), JUMP to ROM 197AH, OUT OF MEMORY.
5C8D
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H for the Stack Pointer read.
5C90
ADD HL,SP 39
Add the Stack Pointer: Register Pair HL = the current Stack Pointer.
5C91
PUSH HL E5
Save Register Pair HL, the current Stack Pointer, on the stack.
5C92
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the Stack Pointer.
5C93
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the old bottom from 40A0H.
5C96
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
5C97
SBC HL,DE ED 52
Subtract Register Pair DE, the Stack Pointer, from Register Pair HL: the size of the stack.
5C99
LD B,H 44
Copy Register H into Register B, the high byte of the stack size.
5C9A
LD C,L 4D
Copy Register L into Register C, the low byte of the stack size.
5C9B
INC BC 03
Add 1: Register Pair BC = the number of bytes to move.
5C9C
ADD HL,DE 19
Add Register Pair DE, the Stack Pointer, back to Register Pair HL: the old bottom (the stack's top end).
5C9D
LD DE,0000H 11 00 00
Load Register Pair DE with the new bottom; the operand 0000H at 5C9EH is stored by 5C67H.
5CA0
LD (40A0H),DE ED 53 A0 40
Store Register Pair DE, the new bottom, at 40A0H: the string area now starts there.
5CA4
RST 18H DF
RST 18H compares Register Pair HL (the old bottom) with Register Pair DE (the new bottom): the CARRY FLAG is set if the area moves up.
5CA5
DI F3
Disable interrupts while the stack is moved, so no interrupt uses it.
5CA6
If the area moves down (the NC FLAG is set), JUMP to 5CACH.
5CA8
LDDR ED B8
Moving up: copy Register Pair BC bytes from Register Pair HL (the old top end) to Register Pair DE (the new top end), downward (LDDR).
5CAA
JUMP to 5CB3H to load the new Stack Pointer after the move.
5CAC
POP HL E1
Restore Register Pair HL = the old Stack Pointer.
5CAD
LD DE,(5CB4H) ED 5B B4 5C
Load Register Pair DE with the new Stack Pointer from 5CB4H.
5CB1
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (the old Stack Pointer) to Register Pair DE (the new Stack Pointer), upward (LDIR).
5CB3
LD SP,0000H 31 00 00
Load the Stack Pointer with the new value; the operand 0000H at 5CB4H is stored by 5C81H.
5CB6
EI FB
Enable interrupts again now that the stack is in place.
5CB7
POP HL E1
Restore Register Pair HL, the text pointer, from the moved stack.
5CB8
RET C9
RETurn to the statement loop with the string area resized.
5CB9H - String Helpers
5CB9H evaluates a string after a comma and leaves the text pointer on the stack (no caller in this file). 5CC0H/5CCBH take a string result: Register A = length, Register Pair DE = text, Register Pair HL = descriptor. 5CD3H creates a string of length A in the descriptor at Register Pair HL (used by SYS10). 5CDDH copies Register B bytes from Register Pair DE to Register Pair HL; 5CE3H stores Register C spaces. 5CEBH copies a string that lies in the program text to string space. 5CF3H steps to the end of a program line (SYS11, SYS13).
5CB9
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5CBA
DEFB 2CH 2C
Inline byte for the RST 08H at 5CB9H: 2CH, a comma (not executed).
5CBB
CALL 2337H CD 37 23
GOSUB to ROM 2337H to evaluate the string expression at Register Pair HL into the floating accumulator; Register Pair HL returns the text pointer after it.
5CBE
EX (SP),HL E3
Exchange Register Pair HL, the text pointer, with the return address at the Stack Pointer.
5CBF
PUSH HL E5
Push Register Pair HL, the return address, again: the text pointer stays on the stack below it.
5CC0
CALL 29D7H CD D7 29
CALL ROM 29D7H to free the string result's temporary descriptor; Register Pair HL returns the descriptor's address.
5CC3
LD A,(HL) 7E
Load Register A with the string's length, the first byte of the descriptor at Register Pair HL.
5CC4
INC HL 23
Bump Register Pair HL to the low byte of the text address.
5CC5
LD E,(HL) 5E
Load Register E with the low byte of the text address at Register Pair HL.
5CC6
INC HL 23
Bump Register Pair HL to the high byte of the text address.
5CC7
LD D,(HL) 56
Load Register D with the high byte of the text address at Register Pair HL, so Register Pair DE = the text.
5CC8
DEC HL 2B
DECrement Register Pair HL back to the low byte of the text address.
5CC9
DEC HL 2B
Step back again: Register Pair HL = the descriptor.
5CCA
RET C9
RETurn with Register A = the length, Register Pair DE = the text and Register Pair HL = the descriptor.
5CCB
CALL AF4H CD F4 0A
CALL ROM 0AF4H: the value must be a string (else TYPE MISMATCH).
5CCE
CALL 29DEH CD DE 29
CALL ROM 29DEH to free the temporary descriptor at Register Pair DE; Register Pair HL returns it.
5CD1
JUMP to 5CC3H to read the length and address.
5CD3
LD (HL),00H 36 00
Store 00H at Register Pair HL (the descriptor's length, until the space is reserved).
5CD5
PUSH HL E5
Save Register Pair HL, the descriptor's address, on the stack.
5CD6
CALL 28BFH CD BF 28
CALL ROM 28BFH to reserve Register A bytes of string space; Register Pair DE returns the address.
5CD9
POP HL E1
Restore Register Pair HL, the descriptor's address, from the stack.
5CDA
JP 285DH C3 5D 28
JUMP to ROM 285DH to store the length in Register A and the address in Register Pair DE into the descriptor.
5CDD
LD A,B 78
Load Register A with the byte count in Register B.
5CDE
OR A B7
OR Register A, the byte count, with itself to set the flags.
5CDF
JP NZ,09D6H C2 D6 09
Not zero: JUMP to ROM 09D6H, which copies Register B bytes from Register Pair DE to Register Pair HL.
5CE2
RET C9
RETurn at once: Register B is zero, so there is nothing to copy.
5CE3
INC C 0C
INCrement Register C, the spaces left, to test it.
5CE4
DEC C 0D
DECrement Register C: the Z FLAG is set when no spaces are left.
5CE5
RET Z C8
No more spaces: RETURN with Register C = 00H.
5CE6
LD (HL),20H 36 20
Store a space (20H) at Register Pair HL in the variable's text.
5CE8
INC HL 23
Bump Register Pair HL to the next byte of the variable's text.
5CE9
LOOP back to 5CE4H to count down Register C, the spaces left.
5CEB
PUSH HL E5
Save Register Pair HL, the variable's descriptor address, on the stack.
5CEC
CALL 2843H CD 43 28
CALL ROM 2843H, which copies the string at the descriptor in Register Pair HL to string space and makes a temporary descriptor for the copy.
5CEF
POP HL E1
Restore Register Pair HL, the variable's descriptor.
5CF0
JP 09D3H C3 D3 09
JUMP to ROM 09D3H to copy the new descriptor into the variable.
5CF3
INC HL 23
Bump Register Pair HL forward (1 of 3) past the line's link and number.
5CF4
INC HL 23
Bump Register Pair HL forward (2 of 3) past the line's link and number.
5CF5
INC HL 23
Bump Register Pair HL forward (3 of 3) to the first byte of the line's text.
5CF6
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL.
5CF7
OR A B7
OR Register A with itself to set the flags: Z at the line's 00H.
5CF8
INC HL 23
Bump Register Pair HL to the next byte of the line.
5CF9
Not the 00H at the end of the line: LOOP to 5CF6H.
5CFB
RET C9
RETURN with Register Pair HL at the next line.
5CFCH - Read a Decimal Number
Reads decimal digits at Register Pair HL into Register Pair DE; Register C returns the number of digits read. 5CFCH allows any number of digits, 5CFEH at most Register B. Returns No Carry at the first non-digit, Carry if the value passes 65535.
5CFC
LD B,FFH 06 FF
Load Register B with FFH: no limit on the number of digits.
5CFE
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value being built.
5D01
LD C,E 4B
Copy Register E (00H) into Register C, the digit count.
5D02
LD A,B 78
Load Register A with the digits still allowed in Register B.
5D03
OR A B7
OR Register A, the digits still allowed, with itself to set the flags.
5D04
RET Z C8
If the limit is reached (the Z FLAG is set), RETurn.
5D05
DEC B 05
DECrement Register B: one digit fewer allowed.
5D06
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
5D07
SUB 30H D6 30
Subtract 30H (0) from Register A, the character.
5D09
CP 0AH FE 0A
Compare Register A with 0AH: the CARRY FLAG is set for a digit.
5D0B
RET NC D0
If Register A is not a digit (the NC FLAG is set), RETurn with the NC FLAG.
5D0C
INC HL 23
Bump Register Pair HL to the next character of the number.
5D0D
INC BC 03
INCrement Register Pair BC, counting the digit in Register C.
5D0E
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5D0F
PUSH BC C5
Save Register Pair BC, the limit and count, on the stack.
5D10
LD C,A 4F
Copy Register A, the digit's value, into Register C.
5D11
LD B,00H 06 00
Load Register B with 00H, so Register Pair BC = the digit's value.
5D13
LD H,D 62
Copy Register D into Register H, the high byte of the value.
5D14
LD L,E 6B
Copy Register E into Register L, so Register Pair HL = the value.
5D15
XOR A AF
Set Register A to 00H, the overflow collector.
5D16
ADD HL,HL 29
Add Register Pair HL to itself: the value times 2.
5D17
ADC A,A 8F
Add Register A to itself with the CARRY FLAG, collecting any overflow.
5D18
ADD HL,HL 29
Add Register Pair HL to itself: the value times 4.
5D19
ADC A,A 8F
Add Register A to itself with the CARRY FLAG, collecting any overflow.
5D1A
ADD HL,DE 19
Add Register Pair DE, the old value, to Register Pair HL: the value times 5.
5D1B
ADC A,A 8F
Add Register A to itself with the CARRY FLAG, collecting any overflow.
5D1C
ADD HL,HL 29
Add Register Pair HL to itself: the value times 10.
5D1D
ADC A,A 8F
Add Register A to itself with the CARRY FLAG, collecting any overflow.
5D1E
ADD HL,BC 09
Add Register Pair BC, the digit, to Register Pair HL.
5D1F
POP BC C1
Restore Register Pair BC, the limit and count, from the stack.
5D20
ADC A,A 8F
Collect the last carry: Register A is zero unless the value passed 65535.
5D21
POP DE D1
Restore the text pointer from the stack into Register Pair DE.
5D22
EX DE,HL EB
Exchange: Register Pair DE = the new value, Register Pair HL = the text pointer.
5D23
If there was no overflow (the Z FLAG is set), LOOP back to 5D02H.
5D25
SCF 37
Overflow: set the CARRY FLAG for the caller, the value passed 65535.
5D26
RET C9
RETurn with the CARRY FLAG set for an overflow.
5D27H - Number to Decimal Text
5D32H converts Register Pair DE (0-65535) to five digits at 5D51H-5D55H with ROM 132FH and returns Register Pair HL at the first digit that is not a leading zero and Register E (and D) = the number of digits left (at least 1). 5D27H also copies those digits to Register Pair BC.
5D27
GOSUB to 5D32H to convert Register Pair DE to digits; Register Pair HL = the first digit, Register D = the count.
5D2A
LD A,(HL) 7E
Load Register A with a digit at Register Pair HL.
5D2B
LD (BC),A 02
Store Register A, the digit, at Register Pair BC.
5D2C
INC BC 03
Bump Register Pair BC to the next output byte.
5D2D
INC HL 23
Bump Register Pair HL to the next digit in the digit buffer.
5D2E
DEC D 15
DECrement Register D, the digits left to copy.
5D2F
If more digits are left (the NZ FLAG is set), LOOP back to 5D2AH.
5D31
RET C9
Register D reached 0: all digits have been copied. RETURN.
5D32
PUSH BC C5
Save Register Pair BC, the caller's output pointer, on the stack.
5D33
LD BC,0000H 01 00 00
Register Pair BC = 0000H for the ROM routine.
5D36
LD (4121H),DE ED 53 21 41
Store Register Pair DE, the number, at 4121H, the integer accumulator.
5D3A
LD HL,5D51H 21 51 5D
Point Register Pair HL at 5D51H, the digit buffer.
5D3D
PUSH HL E5
Save Register Pair HL (5D51H, the digit buffer) on the stack.
5D3E
CALL 132FH CD 2F 13
CALL ROM 132FH to write the value as five decimal digits at Register Pair HL.
5D41
POP HL E1
Restore Register Pair HL = 5D51H, the first digit.
5D42
POP BC C1
Restore Register Pair BC, the caller's value, from the stack.
5D43
LD D,04H 16 04
Register D = 04H: at most four leading zeros are skipped.
5D45
LD A,(HL) 7E
Load Register A with a digit at Register Pair HL.
5D46
CP 30H FE 30
Compare Register A, the digit, with 30H, the character 0.
5D48
If Register A is not a zero (the NZ FLAG is set), JUMP to 5D4EH.
5D4A
INC HL 23
Bump Register Pair HL past the leading zero in the digit buffer.
5D4B
DEC D 15
DECrement Register D: one fewer zero may be skipped.
5D4C
If more zeros may be skipped (the NZ FLAG is set), LOOP back to 5D45H.
5D4E
INC D 14
INCrement Register D: Register D = the number of digits left.
5D4F
LD E,D 5A
Copy Register D, the digit count, into Register E.
5D50
RET C9
RETurn with Register Pair HL at the first significant digit and Register D = Register E = the digit count.
5D51H - Digit Buffer
Six bytes: 5D51H-5D55H receive the five digits from 5D32H.
5D51-5D56
DEFB 00H,00H,00H,00H,00H,00H 00 00 00 00 00 00
5D51H-5D56H, the digit buffer (00H in the file).
5D57H - Display Output (Screen and Printer)
5D66H displays the character in Register A (ROM 0033H) and also prints it when the operand at 5D6CH is 24H ($; set by SYS12 for REF$, cleared at 6457H). 5D57H outputs Register A spaces, 5D64H one space, 5D79H a carriage return, 5D5EH and 5D8EH a number in decimal, 5D7DH divides Register Pair HL by Register A.
5D57
LD B,A 47
Load Register B with the number of spaces in Register A.
5D58
GOSUB to 5D64H to output a space; Register B is kept.
5D5B
DECrement Register B, the spaces left, and LOOP back to 5D58H.
5D5D
RET C9
RETurn with Register B = 00H after all the spaces.
5D5E
LD DE,0000H 11 00 00
Load Register Pair DE with the number; the operand 0000H at 5D5FH is stored and read by SYS10.
5D61
CALL 5D8EH to output it in decimal, then fall into 5D64H.
5D64
LD A,20H 3E 20
Load Register A with 20H, a space, and fall into 5D66H to output it.
5D66
PUSH DE D5
Save Register Pair DE, the caller's value, on the stack.
5D67
PUSH AF F5
Save Register Pair AF, holding the character in Register A, on the stack.
5D68
GOSUB to ROM 0033H to display the character in Register A.
5D6B
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the operand at 5D6CH: 00H, or 24H when the output is also to go to the printer.
5D6D
CP 24H FE 24
Compare Register A, the printer flag, with 24H.
5D6F
POP DE D1
Pop the saved Register Pair AF into Register Pair DE: Register D = the character.
5D70
LD A,D 7A
Copy Register D, the character, into Register A.
5D71
If the printer is on (the Z FLAG is set), GOSUB to ROM 003BH to print the character in Register A.
5D74
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
5D75
RET C9
RETurn with the character output in Register A.
5D76
CALL 5D64H to output a space, then fall into 5D79H.
5D79
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, to end the line.
5D7B
JUMP to 5D66H to output the carriage return in Register A.
5D7D
LD C,A 4F
Divide Register Pair HL by Register A: load Register C with the divisor.
5D7E
LD B,10H 06 10
Load Register B with 10H, the 16 steps of the division.
5D80
XOR A AF
Set Register A, the remainder of the division, to 00H.
5D81
ADD HL,HL 29
Add Register Pair HL to itself, shifting the dividend left one bit.
5D82
RLA 17
Rotate Register A left through the CARRY FLAG, shifting the top bit into the remainder.
5D83
If the remainder overflowed (the CARRY FLAG is set), JUMP to 5D88H.
5D85
CP C B9
Compare Register A, the remainder, with Register C, the divisor.
5D86
If the remainder is smaller (the CARRY FLAG is set), JUMP to 5D8AH.
5D88
SUB C 91
Subtract Register C, the divisor, from Register A, the remainder.
5D89
INC L 2C
INCrement Register L, setting the quotient bit in Register Pair HL.
5D8A
DECrement Register B, the steps left, and LOOP back to 5D81H.
5D8C
OR A B7
OR Register A with itself to clear the CARRY FLAG.
5D8D
RET C9
RETURN with the quotient in Register Pair HL and the remainder in Register A.
5D8E
LD BC,5D51H 01 51 5D
Point Register Pair BC at 5D51H, the digit buffer.
5D91
PUSH BC C5
Save Register Pair BC (5D51H, the digit buffer) on the stack.
5D92
CALL 5D27H to convert Register Pair DE to digits.
5D95
POP HL E1
Restore Register Pair HL = 5D51H, the digits.
5D96
LD B,E 43
Load Register B with the number of digits in Register E.
5D97
LD A,(HL) 7E
Load Register A with a digit at Register Pair HL.
5D98
INC HL 23
Bump Register Pair HL to the next digit in the digit buffer.
5D99
GOSUB to 5D66H to output the digit in Register A.
5D9C
DECrement Register B, the digits left, and LOOP back to 5D97H.
5D9E
RET C9
RETURN with Register E = the number of digits.
5D9FH - Continue a Statement on the Next Line (SYS19, SYS21)
Called by SYS19 (MERGE) and SYS21 (ERASE/KEEP) after a trailing comma: the rest of the line must be empty, colons or a remark (5DB2H); the next line's number goes to 57B8H. No next line: SYNTAX ERROR.
5D9F
CALL 5DB2H to check the rest of the line and step to its 00H.
5DA2
INC HL 23
Advance Register Pair HL to the next line's link.
5DA3
LD A,(HL) 7E
Load Register A with the low byte of the next line's link at Register Pair HL.
5DA4
INC HL 23
Bump Register Pair HL to the high byte of the link.
5DA5
OR (HL) B6
OR Register A with the high byte of the link at Register Pair HL: zero at the end of the program.
5DA6
INC HL 23
Bump Register Pair HL to the next line's number.
5DA7
JP Z,1997H CA 97 19
No next line: JUMP to ROM 1997H, SYNTAX ERROR.
5DAA
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL.
5DAB
INC HL 23
Bump Register Pair HL to the high byte of the line number.
5DAC
LD D,(HL) 56
Load Register D with the high byte of the line number at Register Pair HL.
5DAD
LD (57B8H),DE ED 53 B8 57
Store Register Pair DE, the next line's number, at 57B8H.
5DB1
RET C9
RETurn with the next line number at 57B8H-57B9H.
5DB2H - Skip an Empty Rest of Line or a Remark
Returns at the line's 00H (Z). Colons are skipped; anything else must be the REM token, and the remark is skipped.
5DB2
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H rereads it.
5DB3
RST 10H D7
RST 10H: load Register A with the next non-space character at Register Pair HL.
5DB4
OR A B7
OR Register A with itself to set the flags: Z for the line's 00H.
5DB5
RET Z C8
If it is the line's 00H (the Z FLAG is set), RETurn.
5DB6
CP 3AH FE 3A
Compare Register A, the character, with 3AH (colon).
5DB8
If Register A is not a colon (the NZ FLAG is set), JUMP to 5DBDH.
5DBA
RST 10H D7
RST 10H: load Register A with the character after the colon at Register Pair HL.
5DBB
JUMP back to 5DB6H to test the character in Register A.
5DBD
RST 08H CF
RST 08H: the character at Register Pair HL must be the REM token (93H, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5DBE
DEFB 93H 93
Inline byte for the RST 08H at 5DBDH: 93H, the REM token (not executed).
5DBF
OR A B7
Set the flags from the character in Register A.
5DC0
RET Z C8
If it is the line's 00H (the Z FLAG is set), RETurn.
5DC1
RST 10H D7
RST 10H: load Register A with the next character of the remark at Register Pair HL.
5DC2
LOOP back to 5DBFH to test the character in Register A.
5DC4H - Disk BASIC Error Entries
One entry per Disk BASIC error: each loads Register A with the error code; the LD BC instructions only hide the next entry's LD A,n, so every entry falls through to 5E05H with its own code. The code in Register E selects the message (SYS13: codes 64H and up are Disk BASIC messages).
5DC4
LD A,2AH 3E 2A
Error 2AH, BAD FILE DATA: load Register A with 2AH.
Overlapping Instructions
Fall-through executes LD BC,2E3EH, which only loads Register Pair BC; entered at 5DC7H the bytes 3EH 2EH are LD A,2EH.
5DC6
LD BC,2E3EH 01 3E 2E
Fall-through: load Register Pair BC with 2E3EH, which leaves Register A unchanged. Entered at 5DC7H (the bytes 3EH 2EH): load Register A with 2EH, error UNDEFINED USER FUNCTION.
5DC9
LD BC,643EH 01 3E 64
Fall-through: load Register Pair BC with 643EH, which leaves Register A unchanged. Entered at 5DCAH (the bytes 3EH 64H): load Register A with 64H, error FIELD OVERFLOW.
5DCC
LD BC,683EH 01 3E 68
Fall-through: load Register Pair BC with 683EH, which leaves Register A unchanged. Entered at 5DCDH (the bytes 3EH 68H): load Register A with 68H, error BAD FILE #.
5DCF
LD BC,6C3EH 01 3E 6C
Fall-through: load Register Pair BC with 6C3EH, which leaves Register A unchanged. Entered at 5DD0H (the bytes 3EH 6CH): load Register A with 6CH, error BAD FILE MODE.
5DD2
LD BC,6E3EH 01 3E 6E
Fall-through: load Register Pair BC with 6E3EH, which leaves Register A unchanged. Entered at 5DD3H (the bytes 3EH 6EH): load Register A with 6EH, error FILE ALREADY OPEN.
5DD5
LD BC,7C3EH 01 3E 7C
Fall-through: load Register Pair BC with 7C3EH, which leaves Register A unchanged. Entered at 5DD6H (the bytes 3EH 7CH): load Register A with 7CH, error INPUT PAST END.
5DD8
LD BC,7E3EH 01 3E 7E
Fall-through: load Register Pair BC with 7E3EH, which leaves Register A unchanged. Entered at 5DD9H (the bytes 3EH 7EH): load Register A with 7EH, error BAD RECORD #.
5DDB
LD BC,803EH 01 3E 80
Fall-through: load Register Pair BC with 803EH, which leaves Register A unchanged. Entered at 5DDCH (the bytes 3EH 80H): load Register A with 80H, error BAD FILE NAME.
5DDE
LD BC,843EH 01 3E 84
Fall-through: load Register Pair BC with 843EH, which leaves Register A unchanged. Entered at 5DDFH (the bytes 3EH 84H): load Register A with 84H, error DIRECT STATEMENT IN FILE.
5DE1
LD BC,8C3EH 01 3E 8C
Fall-through: load Register Pair BC with 8C3EH, which leaves Register A unchanged. Entered at 5DE2H (the bytes 3EH 8CH): load Register A with 8CH, error SEQ # OVERFLOW.
5DE4
LD BC,8E3EH 01 3E 8E
Fall-through: load Register Pair BC with 8E3EH, which leaves Register A unchanged. Entered at 5DE5H (the bytes 3EH 8EH): load Register A with 8EH, error RECORD OVERFLOW.
5DE7
LD BC,903EH 01 3E 90
Fall-through: load Register Pair BC with 903EH, which leaves Register A unchanged. Entered at 5DE8H (the bytes 3EH 90H): load Register A with 90H, error ILLEGAL TO EXTEND FILE.
5DEA
LD BC,923EH 01 3E 92
Fall-through: load Register Pair BC with 923EH, which leaves Register A unchanged. Entered at 5DEBH (the bytes 3EH 92H): load Register A with 92H, error "?" (no message).
5DED
LD BC,943EH 01 3E 94
Fall-through: load Register Pair BC with 943EH, which leaves Register A unchanged. Entered at 5DEEH (the bytes 3EH 94H): load Register A with 94H, error PREVIOUSLY DISPLAYED ERROR.
5DF0
LD BC,983EH 01 3E 98
Fall-through: load Register Pair BC with 983EH, which leaves Register A unchanged. Entered at 5DF1H (the bytes 3EH 98H): load Register A with 98H, error BAD FILE TYPE.
5DF3
LD BC,9A3EH 01 3E 9A
Fall-through: load Register Pair BC with 9A3EH, which leaves Register A unchanged. Entered at 5DF4H (the bytes 3EH 9AH): load Register A with 9AH, error IGEL SYNTAX ERROR.
5DF6
LD BC,9C3EH 01 3E 9C
Fall-through: load Register Pair BC with 9C3EH, which leaves Register A unchanged. Entered at 5DF7H (the bytes 3EH 9CH): load Register A with 9CH, error IGEL ITEM SYNTAX ERROR.
5DF9
LD BC,9E3EH 01 3E 9E
Fall-through: load Register Pair BC with 9E3EH, which leaves Register A unchanged. Entered at 5DFAH (the bytes 3EH 9EH): load Register A with 9EH, error BAD/ILLEGAL/MISSING IGEL ITEM PREFIX.
5DFC
LD BC,A23EH 01 3E A2
Fall-through: load Register Pair BC with 0A23EH, which leaves Register A unchanged. Entered at 5DFDH (the bytes 3EH A2H): load Register A with A2H, error BAD RECORD LENGTH.
5DFF
LD BC,A43EH 01 3E A4
Fall-through: load Register Pair BC with 0A43EH, which leaves Register A unchanged. Entered at 5E00H (the bytes 3EH A4H): load Register A with A4H, error STMT USES 2 FILE AREAS.
5E02
LD BC,A63EH 01 3E A6
Fall-through: load Register Pair BC with 0A63EH, which leaves Register A unchanged. Entered at 5E03H (the bytes 3EH A6H): load Register A with A6H, error BAD FILE POSITIONING PARAM.
5E05H - Report a BASIC Error
Register A = the error code; ROM 19A2H reports it (ON ERROR GOTO, or the message through SYS13).
5E05
LD E,A 5F
Load Register E with the error code in Register A.
5E06
JP 19A2H C3 A2 19
JUMP to the ROM error routine 19A2H with Register E = the error code.
5E09H - Report an Error After Relinking (SYS11, SYS13)
Used by RENUM in SYS11 and SYS13: the program's line links are rebuilt before the error in Register A is reported.
5E09
LD (5E13H),A 32 13 5E
Store the error code in Register A as the operand at 5E13H.
5E0C
CALL 1AF8H CD F8 1A
GOSUB to ROM 1AF8H to rebuild the program's line links.
5E0F
CALL 1B59H CD 59 1B
CALL ROM 1B59H, inside NEW: store the end of the program at 40F9H and clear the variables.
5E12
LD A,00H 3E 00
Load Register A with the error code; the operand 00H at 5E13H is stored by 5E09H.
5E14
JUMP to 5E05H to report the error in Register A.
5E16H - 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 5E36H gives the BASIC error, 72H DOS ERROR when the code is not listed. Without ON ERROR GOTO the DOS message is displayed first (57E4H).
5E16
LD C,A 4F
Copy Register A, the DOS error code, into Register C.
5E17
OR C0H F6 C0
OR Register A with C0H, setting bits 7 and 6: display the message and return, for SYS0 4409H.
5E19
LD (57E5H),A 32 E5 57
Store Register A as the operand at 57E5H, used by CMD"E" and below.
5E1C
LD HL,5E36H 21 36 5E
Point Register Pair HL at the translation table 5E36H.
5E1F
LD E,72H 1E 72
Register E = 72H, DOS ERROR, for codes not in the table.
Loop: look up the DOS code.
5E21
LD A,(HL) 7E
Load Register A with a table entry's DOS code at Register Pair HL.
5E22
CP C B9
Compare Register A with Register C, the DOS code.
5E23
INC HL 23
Bump Register Pair HL to the entry's BASIC code.
5E24
If the codes differ (the NZ FLAG is set), JUMP to 5E27H.
5E26
LD E,(HL) 5E
Found: load Register E with the BASIC code at Register Pair HL.
5E27
INC HL 23
Bump Register Pair HL to the next entry of the translation table.
5E28
LD A,(HL) 7E
Load Register A with the next entry's DOS code at Register Pair HL.
5E29
OR A B7
OR Register A with itself to set the flags: 00H ends the table.
5E2A
If there are more entries (the NZ FLAG is set), LOOP back to 5E21H.
5E2C
LD HL,(40F0H) 2A F0 40
Load Register Pair HL with the ON ERROR GOTO line from 40F0H.
5E2F
LD A,H 7C
Copy Register H, the high byte of the ON ERROR line, into Register A.
5E30
OR L B5
OR Register A with Register L: zero when no ON ERROR GOTO is active.
5E31
No ON ERROR (Z): CALL 57E4H to display the DOS error message.
5E34
JUMP to 5E06H to report the BASIC error in Register E.
5E36H - DOS to BASIC Error Table
Pairs of DOS error code and BASIC error code, ended by 00H. DOS codes not listed become 72H DOS ERROR.
5E36-5E37
DEFB 0FH,88H 0F 88
DOS 0FH WRITE PROTECTED DISKETTE becomes BASIC 88H DISK WRITE PROTECTED.
5E38-5E39
DEFB 13H,80H 13 80
DOS 13H ILLEGAL FILE NAME becomes BASIC 80H BAD FILE NAME.
5E3A-5E3B
DEFB 18H,6AH 18 6A
DOS 18H FILE NOT IN DIRECTORY becomes BASIC 6AH FILE NOT FOUND.
5E3C-5E3D
DEFB 19H,8AH 19 8A
DOS 19H FILE ACCESS DENIED becomes BASIC 8AH FILE ACCESS DENIED.
5E3E-5E3F
DEFB 1AH,86H 1A 86
DOS 1AH DIRECTORY SPACE FULL becomes BASIC 86H TOO MANY FILES.
5E40-5E41
DEFB 1BH,7AH 1B 7A
DOS 1BH DISKETTE SPACE FULL becomes BASIC 7AH DISK FULL.
5E42-5E43
DEFB 1CH,7CH 1C 7C
DOS 1CH END OF FILE ENCOUNTERED becomes BASIC 7CH INPUT PAST END.
5E44-5E45
DEFB 1DH,7CH 1D 7C
DOS 1DH PAST END OF FILE becomes BASIC 7CH INPUT PAST END.
5E46-5E47
DEFB 1EH,7AH 1E 7A
DOS 1EH DIRECTORY FULL. CAN'T EXTEND FILE becomes BASIC 7AH DISK FULL.
5E48-5E49
DEFB 1FH,66H 1F 66
DOS 1FH PROGRAM NOT FOUND becomes BASIC 66H INTERNAL ERROR.
5E4A-5E4B
DEFB 20H,80H 20 80
DOS 20H ILLEGAL OR MISSING DRIVE # becomes BASIC 80H BAD FILE NAME.
5E4C-5E4D
DEFB 21H,66H 21 66
DOS 21H NO DEVICE SPACE AVAILABLE becomes BASIC 66H INTERNAL ERROR.
5E4E-5E4F
DEFB 22H,66H 22 66
DOS 22H LOAD FILE FORMAT ERROR becomes BASIC 66H INTERNAL ERROR.
5E50-5E51
DEFB 23H,66H 23 66
DOS 23H MEMORY FAULT becomes BASIC 66H INTERNAL ERROR.
5E52-5E53
DEFB 24H,66H 24 66
DOS 24H TRIED TO LOAD READ ONLY MEMORY becomes BASIC 66H INTERNAL ERROR.
5E54-5E55
DEFB 25H,8AH 25 8A
DOS 25H ILLEGAL ACCESS TRIED TO PROTECTED FILE becomes BASIC 8AH FILE ACCESS DENIED.
5E56-5E57
DEFB 26H,66H 26 66
DOS 26H FILE NOT OPEN becomes BASIC 66H INTERNAL ERROR.
5E58-5E59
DEFB 30H,80H 30 80
DOS 30H BAD FILESPEC becomes BASIC 80H BAD FILE NAME.
5E5A
DEFB 00H 00
00H: the end of the DOS to BASIC error table.
5E5B-5E62
DEFB 00H,00H,00H,00H,00H,00H,00H,00H 00 00 00 00 00 00 00 00
5E5BH-5E62H: eight 00H bytes that nothing in BASIC/CMD or the overlays uses.
5E63H - FIELD Statement
FIELD link (417CH, JP 5E63H at 67E5H). FIELD [#]n, w AS var$, ... points each string variable at the next w bytes of the file area's 256-byte buffer (area + 2DH). The file must be closed or a random file whose type bits 0-1 are 0; the widths may add up to 256 (else FIELD OVERFLOW).
5E63
CALL 5F7AH to read the file number: Register Pair BC = the file area, Register A = its mode byte (Z if it is not open).
5E66
If the file is not open (the Z FLAG is set), JUMP to 5E6FH.
5E68
XOR 80H EE 80
Exclusive OR Register A, the mode byte, with 80H, flipping bit 7 (random).
5E6A
AND 83H E6 83
AND Register A with 83H, keeping bits 7, 1 and 0: zero only for a random file with type bits 0-1 clear.
5E6C
Any other file: JUMP to 5DD0H, BAD FILE MODE.
5E6F
LD DE,002DH 11 2D 00
Register Pair DE = 002DH, the buffer's offset in the file area.
Loop: one field per pass.
5E72
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the offset.
5E73
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: the address of the field (the area + 2DH first, then the previous field + its width).
5E74
EX DE,HL EB
Exchange: Register Pair DE = the field's address, Register Pair HL = the text pointer.
5E75
LD B,A 47
Load Register B with the bytes used so far (Register A).
5E76
LD A,2CH 3E 2C
Load Register A with 2CH, a comma, the separator between fields.
5E78
CP (HL) BE
Compare Register A with the next BASIC character at Register Pair HL.
5E79
RET NZ C0
If there is no comma (the NZ FLAG is set), RETurn: FIELD is done.
5E7A
PUSH DE D5
Save Register Pair DE, the field's address, on the stack.
5E7B
PUSH BC C5
Save Register Pair BC on the stack: Register B = the bytes used.
5E7C
CALL 2B1BH CD 1B 2B
CALL ROM 2B1BH to evaluate the width into Register A.
5E7F
PUSH AF F5
Save Register Pair AF on the stack: Register A = the width.
5E80
RST 08H CF
RST 08H: the character at Register Pair HL must be the letter A (41H, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5E81
DEFB 41H 41
Inline byte for the RST 08H at 5E80H: 41H, the letter A (not executed).
5E82
RST 08H CF
RST 08H: the character at Register Pair HL must be the letter S (53H, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
5E83
DEFB 53H 53
Inline byte for the RST 08H at 5E82H: 53H, the letter S (not executed).
5E84
CALL 5EA2H to find the string variable: Register Pair DE = the address of its descriptor.
5E87
POP AF F1
Restore Register Pair AF: Register A = the width.
5E88
POP BC C1
Restore Register Pair BC: Register B = the bytes used before this field.
5E89
LD C,A 4F
Copy Register A, the width of the field, into Register C.
5E8A
ADD A,B 80
Add Register B, the bytes used, to Register A: the total so far.
5E8B
If there was no carry (the total is below 256), JUMP to 5E8FH.
5E8D
Above 256: JUMP to 5E9FH, FIELD OVERFLOW (exactly 256 falls through).
5E8F
EX (SP),HL E3
Exchange Register Pair HL, the text pointer, with the field's address at the Stack Pointer.
5E90
EX DE,HL EB
Exchange: Register Pair HL = the descriptor, Register Pair DE = the field's address.
5E91
LD (HL),C 71
Store Register C, the width, at Register Pair HL as the string's length.
5E92
INC HL 23
Bump Register Pair HL to the low byte of the text address.
5E93
LD (HL),E 73
Store Register E, the low byte of the field's address, at Register Pair HL.
5E94
INC HL 23
Bump Register Pair HL to the high byte of the text address.
5E95
LD (HL),D 72
Store Register D, the high byte of the field's address, at Register Pair HL: the variable now points into the buffer.
5E96
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5E97
LD B,00H 06 00
Register B = 00H: Register Pair BC = the width, added at 5E73H to reach the next field.
5E99
If the total is below 256 (the NC FLAG is set), LOOP back to 5E72H.
5E9B
LD A,(HL) 7E
Exactly 256: load Register A with the next BASIC character at Register Pair HL.
5E9C
CP 2CH FE 2C
Compare Register A, the next BASIC character, with 2CH, a comma.
5E9E
RET NZ C0
If there are no more fields (the NZ FLAG is set), RETurn.
5E9F
JUMP to 5DCAH, error 64H FIELD OVERFLOW, with Register A to be loaded there.
5EA2H - Find a String Variable
ROM PTRGET finds the variable at Register Pair HL (Register Pair DE = its address); ROM 0AF4H then requires it to be a string.
5EA2
CALL 260DH CD 0D 26
CALL ROM 260DH, PTRGET: Register Pair DE = the variable's address.
5EA5
JP AF4H C3 F4 0A
JUMP to ROM 0AF4H: TYPE MISMATCH unless it is a string.
5EA8H - INPUT # Link
Link 41D6H (JP 5EA8H at 683FH), called by the ROM's INPUT with Register A = the next character. INPUT # to a file (not #-, the cassette) checks the file area (readable) and continues at the ROM's INPUT code for a device.
5EA8
CP 23H FE 23
Compare Register A, the next character, with 23H (#).
5EAA
RET NZ C0
If Register A is not # (the NZ FLAG is set), RETurn to the ROM's INPUT.
5EAB
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5EAC
RST 10H D7
RST 10H: load Register A with the character after the # at Register Pair HL.
5EAD
CP CEH FE CE
Compare Register A with CEH, the minus token (INPUT #-1 is the cassette).
5EAF
POP HL E1
Restore Register Pair HL, the text pointer at the #, from the stack.
5EB0
LD A,(HL) 7E
Load Register A with the # at Register Pair HL again.
5EB1
RET Z C8
If it is the cassette (the Z FLAG is set), RETurn to the ROM.
5EB2
CALL 5F5DH: the file must be readable; the file statement is set up.
5EB5
EX (SP),HL E3
Exchange Register Pair HL with the return address at the Stack Pointer, which is dropped.
5EB6
JP 21C3H C3 C3 21
JUMP to ROM 21C3H, the INPUT code that reads from a device.
5EB9H - Link 41DFH (After INPUT and LIST)
Link 41DFH (JP 5EB9H at 6848H), called by the ROM after INPUT assigns its variables (2278H) and in LIST (2B44H). Nothing to do unless a file statement is running (63A9H); then LIST continues at 2B4AH and INPUT # ends at ROM 2282H.
5EB9
CALL 63A9H: if no file statement is running, this returns straight to the ROM.
5EBC
POP AF F1
POP Register Pair AF: Register A = the high byte of the return address (Register F gets the low byte).
5EBD
CP 2BH FE 2B
Compare Register A with 2BH: the call came from LIST (2B44H).
5EBF
JP Z,2B4AH CA 4A 2B
If the call came from LIST (the Z FLAG is set), JUMP to ROM 2B4AH.
5EC2
JP 2282H C3 82 22
JUMP to ROM 2282H (FINPRG), the end of INPUT, with Register Pair HL = the text pointer.
5EC5H - EOF Function Entry
Reached through the Disk BASIC link at 4161H (the JP 5EC5H at 67CAH is copied there). Register B = 01H selects EOF for the common routine at 5EE6H.
5EC5
LD B,01H 06 01
Load Register B with 01H, the EOF selector that 5EE6H passes to 5FF0H.
5EC7
JUMP to 5EE6H, the routine shared by EOF, LOF and LOC, with Register B = 01H.
5EC9H - LOF Function Entry
Reached through the Disk BASIC link at 4167H (the JP 5EC9H at 67D0H). Register B = 02H selects LOF: 5FF0H returns the file's end position and 5EE6H divides it by the record length (5F08H), rounding up, so LOF returns a number of records.
5EC9
LD B,02H 06 02
Load Register B with 02H, the LOF selector that 5EE6H passes to 5FF0H.
5ECB
JUMP to 5EE6H, the routine shared by EOF, LOF and LOC, with Register B = 02H.
5ECDH - LOC Suffix Characters
The four characters that may follow LOC(fan): $, %, ! and #. The loop at 5ED9H compares the character at the BASIC text pointer with them in this order. They are data: nothing executes 5ECDH-5ED0H (5ECBH jumps away and the LOC link enters at 5ED1H).
5ECD-5ED0
DEFM "$%!#" 24 25 21 23
Suffix table: 24H $ (B = 40H), 25H % (B = 20H), 21H ! (B = 10H), 23H # (B = 08H). No suffix leaves B = 04H.
5ED1H - LOC Function Entry
Reached through the Disk BASIC link at 4164H (the JP 5ED1H at 67CDH). Looks for one of the suffixes $, %, ! or # (manual section 8.12) and sets Register B to the selector: 40H LOC(fan)$ (next record at or past EOF), 20H LOC(fan)% (EOF as a byte address), 10H LOC(fan)! (next record or current position), 08H LOC(fan)# (REMRA), 04H plain LOC(fan) (the previous record number).
5ED1
POP HL E1
Remove the top word of the stack into Register Pair HL.
5ED2
EX (SP),HL E3
Exchange Register Pair HL with the next word at the Stack Pointer, so Register Pair HL now holds the BASIC text pointer and that word goes on the stack.
5ED3
LD DE,5ECDH 11 CD 5E
Point Register Pair DE at the suffix table at 5ECDH ("$%!#").
5ED6
LD BC,8005H 01 05 80
Load Register Pair BC with 8005H: Register B = 80H (the selector, rotated right once before each compare) and Register C = 05H (four compares plus the exit test).
Loop: try the four suffix characters in turn.
5ED9
RRC B CB 08
Rotate Register B right: 80H becomes 40H, then 20H, 10H, 08H and finally 04H.
5EDB
DEC C 0D
DECrement Register C, counting down from 05H.
5EDC
If Register C reached 00H, no suffix matched and Register B = 04H (plain LOC): JUMP to 5EE4H.
5EDE
LD A,(DE) 1A
Load Register A with the next suffix character from the table at Register Pair DE.
5EDF
CP (HL) BE
Compare Register A with the BASIC text character at Register Pair HL.
5EE0
INC DE 13
Point Register Pair DE at the next suffix character.
5EE1
If the characters differ (NZ), LOOP back to 5ED9H for the next suffix.
5EE3
RST 10H D7
The suffix matched: RST 10H steps Register Pair HL past it in the BASIC text and loads Register A with the next character. Register B holds 40H, 20H, 10H or 08H.
5EE4
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the BASIC text pointer goes back on the stack.
5EE5
PUSH HL E5
Push Register Pair HL, the other word, back, so the two stack words are in their original order again.
5EE6H - Common EOF/LOF/LOC Routine
Register B is the selector from 5EC5H, 5EC9H or 5ED1H. 5FF0H reads the file number and returns a 24-bit value in Registers H:L:C (for LOF and LOC% it returns early at 6006H). For LOF (02H) and plain LOC (04H) the file area must have bit 2 of its byte +00H set (6660H) and the value is divided by the record length, rounded up (5F08H). The result is then converted to a single-precision number and returned through 637EH.
5EE6
CALL 5FF0H with Register B = the selector. It returns the value in Registers H:L:C.
5EE9
LD A,B 78
Load Register A with the selector in Register B (01H EOF, 02H LOF, 04H LOC, 08H LOC#, 10H LOC!, 20H LOC%, 40H LOC$).
5EEA
AND 06H E6 06
Keep bits 1 and 2 of Register A: the result is not zero only for LOF (02H) and plain LOC (04H).
5EEC
For LOF or plain LOC (NZ), CALL 6660H, which reports BASIC error 55 unless bit 2 of byte +00H of the file area at Index Register IX is set. It returns with the NZ FLAG still set.
5EEF
For LOF or plain LOC (NZ), CALL 5F08H to divide Registers H:L:C by the record length at 5702H-5703H, rounding up. The quotient comes back in Registers H:L:C.
5EF2
CALL AEFH CD EF 0A
CALL the ROM routine at 0AEFH, which sets the value type at 40AFH to single precision (Register A is changed).
5EF5
LD E,C 59
Load Register E with Register C, the low byte of the 24-bit value.
5EF6
LD C,H 4C
Load Register C with Register H, the high byte.
5EF7
LD D,L 55
Load Register D with Register L, the middle byte. Registers C:D:E now hold the 24-bit value as a mantissa.
5EF8
LD B,00H 06 00
Load Register B with 00H, the extra low mantissa byte used for rounding by 0765H.
5EFA
LD HL,4124H 21 24 41
Point Register Pair HL at 4124H, the exponent byte of the ROM's floating accumulator.
5EFD
LD (HL),98H 36 98
Store exponent 98H at Register Pair HL (4124H): the mantissa in Registers C:D:E counts as a 24-bit whole number.
5EFF
INC HL 23
Point Register Pair HL at 4125H, the sign byte the ROM uses while normalising.
5F00
LD (HL),80H 36 80
Store 80H at Register Pair HL (4125H), the sign byte: the value is positive.
5F02
CALL 0765H CD 65 07
CALL the ROM normalise routine at 0765H: it shifts Registers C:D:E:B left until the top bit is set, lowering the exponent at 4124H, and stores the single-precision result in the floating accumulator.
5F05
JUMP to 637EH to end the file statement and return the number to BASIC.
5F08H - Divide H:L:C by the Record Length (LOF, LOC)
Called from 5EEFH. Divides the 24-bit value in Registers H:L:C by the 16-bit record length at 5702H-5703H with 24 shift-and-subtract steps (counter in Register A', 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 above FFFFFFH after rounding gives BASIC error 64 (5DD9H).
5F08
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE now holds the high and middle bytes of the dividend (from Registers H and L).
5F09
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the running remainder.
5F0C
LD A,C 79
Load Register A with Register C, the low byte of the dividend. The dividend is D:E:A.
5F0D
LD BC,(5702H) ED 4B 02 57
Load Register Pair BC with the divisor, the record length word at 5702H-5703H.
5F11
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF' to set the step counter in Register A'.
5F12
LD A,18H 3E 18
Load Register A' with 18H (24): one step per dividend bit.
Loop: 24 division steps.
5F14
EX AF,AF' 08
Exchange the alternate Register Pair AF' back with Register Pair AF: Register A holds the low dividend byte and quotient collector.
5F15
ADD A,A 87
Shift Register A left; its top bit goes into the Carry FLAG and bit 0 is freed for the next quotient bit.
5F16
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL, so Register Pair HL holds the upper dividend bytes (Registers D and E).
5F17
ADC HL,HL ED 6A
Add Register Pair HL to itself with the CARRY FLAG, shifting the upper dividend bytes left and taking in the bit from Register A.
5F19
EX DE,HL EB
Exchange back: Register Pair DE holds the upper dividend bytes, Register Pair HL the remainder.
5F1A
ADC HL,HL ED 6A
Shift the remainder in Register Pair HL left, taking in the dividend bit from the Carry.
5F1C
If a bit was shifted out of Register Pair HL (the remainder is at least 10000H, larger than any divisor), JUMP to 5F24H to subtract.
5F1E
OR A B7
OR Register A with itself to clear the CARRY FLAG for the trial subtraction.
5F1F
SBC HL,BC ED 42
Subtract the divisor in Register Pair BC from the remainder in Register Pair HL to compare them.
5F21
ADD HL,BC 09
Add Register Pair BC, the divisor, back to Register Pair HL; the CARRY FLAG from 5F1FH is kept only if the remainder was smaller.
5F22
If the remainder is smaller than the divisor, this quotient bit is 0: JUMP to 5F28H.
5F24
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
5F25
SBC HL,BC ED 42
Subtract the divisor in Register Pair BC from the remainder in Register Pair HL.
5F27
INC A 3C
Set bit 0 of Register A: this quotient bit is 1.
5F28
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF': Register A' is the step counter.
5F29
DEC A 3D
DECrement Register A, the step counter, by one step.
5F2A
If steps remain (the NZ FLAG is set), LOOP back to 5F14H.
5F2C
EX AF,AF' 08
Exchange the alternate Register Pair AF' back: Register A holds the low byte of the quotient.
5F2D
EX DE,HL EB
Exchange: Register Pair HL now holds the high and middle bytes of the quotient, Register Pair DE the remainder.
5F2E
LD C,A 4F
Copy Register A, the low quotient byte, into Register C. The quotient is in Registers H:L:C.
5F2F
LD A,D 7A
Load Register A with the high byte of the remainder in Register D.
5F30
OR E B3
OR Register A, the high byte of the remainder, with Register E: the Z FLAG is set if the remainder is 0.
5F31
RET Z C8
If there is no remainder, RETURN with the quotient in Registers H:L:C.
5F32
INC C 0C
There is a remainder: round up by adding 1 to Register C.
5F33
RET NZ C0
If Register C did not wrap to 00H (the NZ FLAG is set), RETurn with the rounded quotient.
5F34
INC HL 23
INCrement Register Pair HL, carrying the 1 into the high and middle bytes.
5F35
LD A,H 7C
Copy Register H, the high byte of the quotient, into Register A.
5F36
OR L B5
OR Register A with Register L: the Z FLAG is set only if Register Pair HL wrapped to 0000H.
5F37
RET NZ C0
If it did not wrap, RETURN with the rounded quotient in Registers H:L:C.
5F38
The quotient overflowed 24 bits: JUMP to 5DD9H, which reports BASIC error 64 (7EH / 2 + 1).
5F3BH - Link 41D3H (PRINT Comma and TAB to a File)
Link 41D3H (JP 5F3BH at 683CH), called by the ROM's PRINT comma (2108H) and TAB (2141H). During a file statement the file's print column (570AH) is used instead of the screen's.
5F3B
CALL 63A9H: if no file statement is running, this returns straight to the ROM.
5F3E
POP HL E1
Take the return address into Register Pair HL: 210BH for a comma, 2144H for TAB.
5F3F
LD A,L 7D
Copy Register L, the low byte of the return address, into Register A.
5F40
CP 30H FE 30
Compare Register A with 30H: the CARRY FLAG is set for the comma (210BH).
5F42
LD A,(570AH) 3A 0A 57
Load Register A with the file's print column from 570AH.
5F45
JP C,2130H DA 30 21
Comma: JUMP to ROM 2130H (MORCOM) with the file's column.
5F48
JP 2156H C3 56 21
TAB: JUMP to ROM 2156H with the file's column.
5F4BH - Link 41CDH (PRINT a Number to a File)
Link 41CDH (JP 5F4BH at 6836H), called by the ROM after a number is converted for PRINT (20C6H). During a file statement the check whether the item fits on the screen line is skipped.
5F4B
CALL 63A9H: if no file statement is running, this returns straight to the ROM.
5F4E
POP HL E1
POP the ROM's return address into Register Pair HL, dropping it.
5F4F
JP 20E9H C3 E9 20
JUMP to ROM 20E9H (LINCH2) to output the item.
5F52H - Link 41CAH (PRINT #)
Link 41CAH (JP 5F52H at 6833H), called by the ROM's PRINT (206FH). PRINT # to a file (not #-, the cassette) needs a writable file. 5F5DH is the entry for INPUT # (readable).
5F52
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5F53
RST 10H D7
RST 10H: load Register A with the character after the one in Register A at Register Pair HL.
5F54
CP CEH FE CE
Compare Register A with CEH, the minus token (PRINT #-1 is the cassette).
5F56
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5F57
LD A,(HL) 7E
Load Register A with the current character at Register Pair HL (the flags are kept).
5F58
RET Z C8
If it is the cassette (the Z FLAG is set), RETurn to the ROM.
5F59
LD C,40H 0E 40
Register C = 40H: the file must be writable (mode bit 6).
5F5B
JUMP to 5F5FH with Register C = 40H, the writable bit.
5F5DH - Entry for INPUT # (Readable File)
Called from 5EB2H: the file must be readable.
5F5D
LD C,20H 0E 20
Register C = 20H: the file must be readable (mode bit 5).
5F5FH - 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.
5F5F
CP 23H FE 23
Compare Register A, the next character, with 23H (#).
5F61
RET NZ C0
If there is no # (the NZ FLAG is set), RETurn to the ROM for screen output.
5F62
PUSH BC C5
Save Register Pair BC on the stack: Register C = the mode bit wanted.
5F63
CALL 62E7H to read the file number and the comma and set up the file statement; Register A = the mode byte.
5F66
BIT 7,A CB 7F
Test bit 7 of Register A, the mode byte: a random file.
5F68
POP BC C1
Restore Register Pair BC: Register C = the mode bit wanted.
5F69
If the file is random (the NZ FLAG is set), JUMP to 5DD0H, BAD FILE MODE.
5F6C
AND C A1
AND Register A, the mode, with Register C: zero if the file cannot be used this way.
5F6D
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5F6E
LD A,(HL) 7E
Load Register A with the next character at Register Pair HL (the flags are not changed).
5F6F
Not allowed (or not open): JUMP to 5DD0H, BAD FILE MODE.
5F72
CALL 61D3H: Register C and Register Pair HL = the current position NEXT.
5F75
CALL 613EH to store it as the record start (5707H-5709H) and set bit 6 of 5701H.
5F78
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5F79
RET C9
RETURN to the ROM, which prints or inputs through the file.
5F7AH - 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 64C5H), Register A its mode byte (Z if the file is not open). n above the file count (5F89H) is BAD FILE #. 5F84H starts with the number already evaluated.
5F7A
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H rereads it.
5F7B
RST 10H D7
RST 10H: load Register A with the next non-space character at Register Pair HL.
5F7C
CP 23H FE 23
Compare Register A, the character before the file number, with 23H (#).
5F7E
CALL Z,1D78H CC 78 1D
A #: CALL ROM 1D78H (RST 10H) to step past it.
5F81
CALL 2337H CD 37 23
GOSUB to ROM 2337H to evaluate the file number at Register Pair HL.
5F84
CALL 2B1FH CD 1F 2B
CALL ROM 2B1FH to make it a byte in Register A.
5F87
DEC A 3D
DECrement Register A, the file number, by 1: areas are counted from 0.
5F88
CP 00H FE 00
Compare Register A with the number of file areas, the operand at 5F89H (00H in the file, stored at 652AH during initialization).
5F8A
Too high (or 0): JUMP to 5DCDH, error 68H BAD FILE #.
5F8D
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
5F8E
LD HL,66BEH 21 BE 66
Point Register Pair HL at 66BEH, the first file area.
5F91
LD BC,(64C5H) ED 4B C5 64
Load Register Pair BC with the size of one area from 64C5H.
5F95
OR A B7
Set the flags from the area number in Register A.
5F96
If the area number is 0 (the Z FLAG is set), JUMP to 5F9CH.
5F98
ADD HL,BC 09
Add Register Pair BC, the size of one area, to Register Pair HL.
5F99
DEC A 3D
DECrement Register A, the areas left to step over.
5F9A
If areas are left (the NZ FLAG is set), LOOP back to 5F98H.
5F9C
OR (HL) B6
OR the area's mode byte at Register Pair HL into Register A (00H): the Z FLAG is set if it is not open.
5F9D
LD B,H 44
Copy Register H into Register B, the high byte of the area address.
5F9E
LD C,L 4D
Copy Register L to Register C: Register Pair BC = the area.
5F9F
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
5FA0
RET C9
RETURN. (The links 41D0H and 41E2H also jump here, a plain RETURN.)
5FA1H - CLOSE Statement
CLOSE link (4185H, JP 5FA1H at 67EEH). CLOSE alone closes all files (5FB6H); CLOSE n, m, ... closes the ones listed.
5FA1
Nothing after CLOSE (Z): JUMP to 5FB6H to close every file.
5FA3
CALL 5F7AH to read a file number: Register Pair BC = the area.
5FA6
GOSUB to 5FB2H to close the file area at Register Pair BC.
5FA9
CALL 638FH: Z if the statement ends, otherwise a comma must follow.
5FAC
If another number follows (the NZ FLAG is set), LOOP back to 5FA3H.
5FAE
RET C9
RETurn to the statement loop with the files closed.
5FAFH - Close the Work Area File
Called at 6470H for a file that LOAD, RUN, MERGE, SAVE or KILL opened in the work area at 5700H.
5FAF
LD BC,5700H 01 00 57
Register Pair BC = 5700H, then fall into 5FB2H.
5FB2H - Close One File Area
Register Pair BC = the file area.
5FB2
XOR A AF
Register A = 00H: no more areas after this one.
5FB3
PUSH AF F5
Save Register Pair AF on the stack: Register A (00H) is the loop counter for 5FEDH.
5FB4
JUMP to 5FD5H to close the area at Register Pair BC.
5FB6H - Close All Files
Link 41BBH (JP 5FB6H at 6824H), called by the ROM for NEW and END, and by CLOSE without numbers. Nothing is done if no area is open. SYS19's RUN with the R option makes 5FCFH a RET so no file is closed; 6476H puts back the RET Z.
5FB6
LD A,(5F89H) 3A 89 5F
Load Register A with the number of file areas from 5F89H.
5FB9
OR A B7
OR Register A, the number of file areas, with itself to set the flags.
5FBA
RET Z C8
If there are no file areas (the Z FLAG is set), RETurn.
5FBB
PUSH HL E5
Save Register Pair HL, the caller's value, on the stack.
5FBC
LD B,A 47
Copy Register A, the count, into Register B for the search.
5FBD
LD C,A 4F
Copy Register A, the count, into Register C for the closing loop.
5FBE
LD HL,66BEH 21 BE 66
Point Register Pair HL at the first area, 66BEH.
5FC1
CALL 65DBH: Register Pair DE = the size of one area.
Loop: look for an open area.
5FC4
LD A,(HL) 7E
Load Register A with the area's mode byte at Register Pair HL.
5FC5
OR A B7
OR Register A with itself to set the flags: NZ for an open area.
5FC6
If the area is open (the NZ FLAG is set), JUMP to 5FCBH.
5FC8
ADD HL,DE 19
Add Register Pair DE, the size of one area, to Register Pair HL: the next area.
5FC9
DECrement Register B, the areas left, and LOOP back to 5FC4H.
5FCB
POP HL E1
Restore Register Pair HL, the caller's value, from the stack.
5FCC
RET Z C8
If no area is open (the Z FLAG is set), RETurn.
5FCD
LD A,C 79
Load Register A with the count in Register C.
Loop: close the areas from the last to the first.
5FCE
OR A B7
OR Register A, the areas left, with itself to set the flags.
5FCF
RET Z C8
All done: RETURN. (C9H here during a RUN with the R option.)
5FD0
DEC A 3D
DECrement Register A: the next area number, counting from 0.
5FD1
PUSH AF F5
Save Register Pair AF on the stack: Register A = the area number.
5FD2
GOSUB to 5F88H with Register A = the area number: Register Pair BC = the area.
5FD5H - Close the Area in Register Pair BC
Writable files are closed through SYS0 4428H; the 2DH-byte header is cleared either way. Then the loop at 5FCEH goes on with the next area.
5FD5
PUSH HL E5
Save Register Pair HL, the caller's value, on the stack.
5FD6
LD HL,000DH 21 0D 00
Load Register Pair HL with 000DH, the FCB's offset in the area.
5FD9
ADD HL,BC 09
Add Register Pair BC, the area, to Register Pair HL: the area's FCB (area + 0DH).
5FDA
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the FCB.
5FDB
LD H,B 60
Copy Register B into Register H, the high byte of the area address.
5FDC
LD L,C 69
Copy Register C to Register L: Register Pair HL = the area.
5FDD
BIT 6,(HL) CB 76
Test bit 6 of the mode byte at Register Pair HL: a writable file.
5FDF
Writable: CALL SYS0 4428H to close the file (writes the buffer and the directory).
5FE2
PUSH AF F5
Save Register Pair AF on the stack: the result of the close and the flags.
5FE3
LD B,2DH 06 2D
Load Register B with 2DH, the bytes of the area's header.
5FE5
CALL 6389H to clear the area's header: the area is free.
5FE8
POP AF F1
Restore Register Pair AF: the result of the close and the flags.
5FE9
If the DOS reported an error (the NZ FLAG is set), JUMP to 5E16H with the code in Register A.
5FEC
POP HL E1
Restore Register Pair HL, the caller's value, from the stack.
5FED
POP AF F1
Restore Register Pair AF: Register A = the area counter.
5FEE
LOOP back to 5FCEH to close the next file area, if any is left.
5FF0H - EOF, LOF and LOC: Read the File's Position
Called from 5EE6H with Register B = the selector (01H EOF, 02H LOF, 04H LOC, 08H LOC#, 10H LOC!, 20H LOC%, 40H LOC$). Returns the value as a 24-bit number in Registers H (high), L and C (low), or, for EOF and LOC$, finishes the function itself with -1 or 0.
5FF0
PUSH BC C5
Save Register Pair BC on the stack: Register B = the selector.
5FF1
CALL 5F84H: the file number was already evaluated; Register Pair BC = the area.
5FF4
CALL 62BFH to set up the file statement (copy the header to 5700H); Register A = the mode byte.
5FF7
If the file is not open (the Z FLAG is set), JUMP to 5DD0H, BAD FILE MODE.
5FFA
POP BC C1
Restore Register Pair BC: Register B = the selector.
5FFB
LD DE,(5700H) ED 5B 00 57
Load Register Pair DE from 5700H: Register E = the mode (5700H), Register D = the flags (5701H).
5FFF
CALL 61DAH: Register A and Register Pair HL = the end of file.
6002
LD C,A 4F
Copy Register A, the low byte of EOF, into Register C: Registers H, L and C = EOF.
6003
LD A,B 78
Copy Register B, the selector, into Register A.
6004
AND 22H E6 22
AND Register A with 22H, keeping LOF (02H) and LOC% (20H).
6006
RET NZ C0
If the selector is LOF or LOC% (the NZ FLAG is set), RETurn with EOF in Registers H, L and C.
6007
BIT 3,B CB 58
Test bit 3 of Register B, the selector: LOC#.
6009
LOC#: JUMP to 6150H for the last record start (REMRA).
600C
CALL 61D3H: Registers C, L and H = the current position NEXT.
600F
BIT 6,D CB 72
Test bit 6 of Register D, the flags: the record start is known.
6011
If the record start is not known (the Z FLAG is set), JUMP to 604FH.
6013
BIT 7,E CB 7B
Test bit 7 of Register E, the mode: a random file.
6015
Not random: JUMP to 6034H with the current position.
6017
CALL 6149H: the position where the last GET or PUT ended.
601A
BIT 3,E CB 5B
Test bit 3 of Register E, the mode (record segmented types).
601C
If the file is not record segmented (the Z FLAG is set), JUMP to 6034H.
601E
BIT 2,E CB 53
Test bit 2 of Register E, the mode byte: fixed-length records.
6020
If bit 2 is set (the NZ FLAG is set), JUMP to 6031H for fixed-length records.
6022
Variable records: CALL 61CDH to position the file there.
Loop: skip items until the next record starts or EOF is reached.
6025
CALL 6058H: the current position, Carry if below the end of file.
6028
If the position is at or past EOF (the NC FLAG is set), JUMP to 6034H.
602A
CALL 627FH to read an item marker and skip the item; NZ for anything but a record start.
602D
If it is not a record start (the NZ FLAG is set), LOOP back to 6025H.
602F
JUMP to 6034H with the position of the record start in Registers H, L and C.
6031
CALL 6065H: the next record = the last record start + the record length.
6034H - EOF and LOC$ Results
EOF is -1 only exactly at the end of file; LOC$ is -1 at or past it (manual 8.12). Other selectors return the position.
6034
LD A,B 78
Copy Register B, the selector, into Register A.
6035
AND 41H E6 41
AND Register A with 41H, keeping EOF (01H) and LOC$ (40H).
6037
RET Z C8
Others: RETURN with the position in Registers H, L and C.
6038
POP DE D1
POP the return address to 5EE9H into Register Pair DE, dropping it: this routine finishes the function.
6039
CALL 605BH to compare the position with EOF: Z equal, Carry below.
603C
LD A,FFH 3E FF
Load Register A with FFH, true, the value for -1.
603E
If the position is at EOF (the Z FLAG is set), JUMP to 6048H with Register A = FFH (-1).
6040
If the position is below EOF (the CARRY FLAG is set), JUMP to 6046H for 0.
6042
BIT 6,B CB 70
Past EOF: test bit 6 of Register B, the selector (LOC$).
6044
If the selector is LOC$ (the NZ FLAG is set), JUMP to 6048H with -1.
6046
LD A,00H 3E 00
EOF past the end, or below it: Register A = 00H (false).
6048
LD HL,637EH 21 7E 63
Load Register Pair HL with 637EH, the return that ends the file statement.
604B
PUSH HL E5
Push Register Pair HL (637EH) on the stack as the return address.
604C
JP 098DH C3 8D 09
JUMP to ROM 098DH to return Register A (00H or FFH) as the integer 0 or -1.
604FH - LOC Without a Known Record
Plain LOC (04H) returns 0 when no record has been read or written; the others go on with the current position.
604F
BIT 2,B CB 50
Test bit 2 of Register B, the selector: plain LOC.
6051
If it is not plain LOC (the Z FLAG is set), JUMP to 6034H.
6053
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the high and middle bytes of the value 0.
6056
LD C,L 4D
Copy Register L (00H) into Register C: Registers H, L and C = 0.
6057
RET C9
RETurn with the value 0 in Registers H, L and C.
6058H - Compare a Position With EOF
6058H compares the current position NEXT, 605BH the position in Registers H, L and C, with the end of file: Z equal, Carry below.
6058
GOSUB to 61D3H: Registers C, L and H = NEXT, the current position.
605B
CALL 61E4H: Register Pair DE = the middle and high bytes of EOF.
605E
RST 18H DF
RST 18H compares Register Pair HL with Register Pair DE.
605F
RET NZ C0
If the high and middle bytes differ (the NZ FLAG is set), RETurn.
6060
LD A,C 79
Copy Register C, the low byte of the position, into Register A.
6061
CP (IX+15H) DD BE 15
Compare Register A with the low byte of EOF at Index Register IX+15H (FCB+8 at 5715H).
6064
RET C9
RETurn with the Z FLAG set if equal and the CARRY FLAG set if below.
6065H - Next Record Position
Registers H, L and C = the last record start (5707H-5709H) plus the record length (5702H-5703H).
6065
LD HL,(5707H) 2A 07 57
Load Register Pair HL with the low and middle bytes of the record start (5707H-5708H).
6068
LD DE,(5702H) ED 5B 02 57
Load Register Pair DE with the record length at 5702H.
606C
ADD HL,DE 19
Add Register Pair DE, the record length, to Register Pair HL.
606D
LD A,(5709H) 3A 09 57
Load Register A with the high byte of the record start at 5709H.
6070
ADC A,00H CE 00
Add the CARRY FLAG to Register A, the high byte of the record start.
6072
LD C,L 4D
Copy Register L, the low byte, into Register C.
6073
LD L,H 6C
Copy Register H, the middle byte, into Register L.
6074
LD H,A 67
Copy Register A, the high byte, into Register H.
6075
RET C9
RETurn with the next record position in Registers H, L and C.
6076H - Link 41C1H (Output a Character to a File)
Link 41C1H (JP 6076H at 682AH), called by the ROM's character output (032CH). During a file statement to a writable file the character in Register A goes to the file, and the print column (570AH) is kept: printable characters count, 0DH resets it.
6076
CALL 63A9H: if no file statement is running, this returns straight to the ROM.
6079
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer.
607A
PUSH DE D5
Save Register Pair DE, the caller's value, on the stack.
607B
LD HL,5700H 21 00 57
Point Register Pair HL at the mode byte 5700H.
607E
BIT 6,(HL) CB 76
Test bit 6 of the mode byte at Register Pair HL (5700H): writable.
6080
If the file is not writable (the Z FLAG is set), JUMP to 6096H.
6082
LD HL,570AH 21 0A 57
Point Register Pair HL at the print column 570AH.
6085
INC (HL) 34
INCrement the print column at Register Pair HL (570AH), counting the character.
6086
CP 20H FE 20
Compare Register A, the character, with 20H, the first printable character.
6088
If the character is printable (the NC FLAG is set), JUMP to 6091H.
608A
DEC (HL) 35
DECrement the print column at Register Pair HL: a control character does not count.
608B
CP 0DH FE 0D
Compare Register A, the character, with 0DH, a carriage return.
608D
If it is not a carriage return (the NZ FLAG is set), JUMP to 6091H.
608F
LD (HL),00H 36 00
Store 00H at Register Pair HL (570AH): a carriage return resets the column.
6091
PUSH AF F5
Save Register Pair AF on the stack: Register A = the character.
6092
CALL 622CH to write it to the file (ROM 001BH through the FCB).
6095
POP AF F1
Restore Register Pair AF: Register A = the character.
6096
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
6097
POP HL E1
Restore Register Pair HL, the caller's value, from the stack.
6098
POP BC C1
POP the ROM's return address into Register Pair BC, dropping it.
6099
RET C9
RETURN past the ROM's own output: the character went to the file.
609AH - Open a File in the Work Area
609AH opens for LOAD, RUN, MERGE and KILL with Register B = 01H (existing file only) and Register C = 20H (readable); 609DH takes the mode in Register Pair BC (SAVE: 8440H).
609A
LD BC,0120H 01 20 01
Load Register Pair BC with 0120H: Register B = 01H (existing file only), Register C = 20H (readable).
609DH - 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 4200H, closed at 6470H). The filespec is copied to the FCB at 570DH and opened: Register B bit 0 set = existing file only (SYS0 4424H), else 4420H. Bit 2 of Register B sets EOF to 0, bit 1 starts at EOF. 5700H gets Register C (the mode), 5701H Register B AND F8H.
609D
PUSH BC C5
Save Register Pair BC, the mode, on the stack.
609E
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
609F
CALL 6381H to clear the file statement flag and the work area.
60A2
LD BC,5700H 01 00 57
Load Register Pair BC with 5700H, the work area.
60A5
CALL 62BFH to use 5700H as the statement's file area (Index Register IX = 5700H).
60A8
SET 7,(IX+2DH) DD CB 2D FE
Set bit 7 of 572DH at Index Register IX+2DH: a work-area file.
60AC
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
60AD
POP BC C1
Restore Register Pair BC, the mode, from the stack.
60AE
PUSH BC C5
Save Register Pair BC, the mode, on the stack again.
60AF
LD A,(5700H) 3A 00 57
Load Register A with the mode byte of the work area at 5700H.
60B2
OR A B7
OR Register A with itself to set the flags: NZ if the area is already open.
60B3
Already open: JUMP to 5DD3H, error 6EH FILE ALREADY OPEN.
60B6
CALL 2337H CD 37 23
GOSUB to ROM 2337H to evaluate the filespec at Register Pair HL.
60B9
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: Register Pair HL = the mode, the text pointer goes on the stack.
60BA
PUSH HL E5
Push Register Pair HL, the mode, on the stack.
60BB
CALL 5CC0H: Register A = the length, Register Pair DE = the text.
60BE
CP 20H FE 20
Compare Register A, the filespec length, with 20H.
60C0
32 characters or more: JUMP to 5DDCH, error 80H BAD FILE NAME.
60C3
LD HL,570DH 21 0D 57
Point Register Pair HL at the FCB at 570DH, where the filespec goes.
60C6
PUSH HL E5
Save Register Pair HL (570DH, the FCB) on the stack.
60C7
CALL 5CDEH to copy the filespec (Register A bytes) to the FCB.
60CA
POP DE D1
Restore Register Pair DE = 570DH, the FCB for the open.
60CB
LD (HL),00H 36 00
Store 00H at Register Pair HL to end the filespec.
60CD
LD HL,(6379H) 2A 79 63
Self-Modifying Code
Load Register Pair HL with the file area's address, the operand at 6379H (stored at 62C9H).
60D0
LD BC,002DH 01 2D 00
Load Register Pair BC with 002DH, the buffer's offset in the area.
60D3
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: the area's buffer.
60D4
BIT 7,(IX+2DH) DD CB 2D 7E
Test bit 7 of 572DH at Index Register IX+2DH: a work-area file.
60D8
If it is not a work-area file (the Z FLAG is set), JUMP to 60DDH.
60DA
LD HL,4200H 21 00 42
Work-area file: point Register Pair HL at the buffer at 4200H.
60DD
POP BC C1
Restore Register Pair BC, the mode, from the stack.
60DE
BIT 0,B CB 40
Test bit 0 of Register B: existing file only.
60E0
PUSH BC C5
Save Register Pair BC, the mode, on the stack.
60E1
LD B,00H 06 00
Load Register B with 00H: the record length is 256.
60E3
If only an existing file is allowed (the NZ FLAG is set), JUMP to 60EAH.
60E5
CALL SYS0 4420H to open a new or existing file.
60E8
JUMP to 60EDH to check the result of the open.
60EA
GOSUB to the SYS0 routine at 4424H to open the existing file (FCB at Register Pair DE, buffer at Register Pair HL).
60ED
If the DOS reported an error (the NZ FLAG is set), JUMP to 5E16H with the code in Register A.
60F0
XOR A AF
Set Register A to 00H, the low byte of position 0.
60F1
LD H,A 67
Copy Register A (00H) into Register H, the high byte of the position.
60F2
LD L,A 6F
Copy Register A (00H) into Register L: Registers A, H and L = position 0.
60F3
POP BC C1
Restore Register Pair BC, the mode, from the stack.
60F4
BIT 2,B CB 50
Test bit 2 of Register B, the mode: truncate the file.
60F6
If truncating (the NZ FLAG is set), GOSUB to 6112H to set EOF to 0.
60F9
BIT 1,B CB 48
Test bit 1 of Register B, the mode: start at the end of the file.
60FB
Start at the end: CALL 61DAH, Register A and Register Pair HL = EOF.
60FE
LD (5717H),HL 22 17 57
Store Register Pair HL, the middle and high bytes of the position, as NEXT (FCB+10/11 at 5717H).
6101
LD (5712H),A 32 12 57
Store Register A, the low byte of the position, as NEXT's low byte (FCB+5 at 5712H).
6104
LD A,B 78
Copy Register B, the mode's high byte, into Register A.
6105
AND F8H E6 F8
AND Register A with F8H, keeping bits 3-7 as the flags.
6107
LD B,A 47
Copy Register A, the flags, back into Register B.
6108
LD (5700H),BC ED 43 00 57
Store Register Pair BC at 5700H: the mode (Register C) at 5700H and the flags (Register B) at 5701H.
610C
SET 6,(IX+0EH) DD CB 0E F6
Set bit 6 of FCB+1 at Index Register IX+0EH (570EH).
6110
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
6111
RET C9
RETurn with the file open in the work area at 5700H.
6112H - Set EOF
Stores Register A (low) and Register Pair HL (middle, high) as the end of file (FCB+8 at 5715H, FCB+12/13 at 5719H).
6112
LD (5719H),HL 22 19 57
Store Register Pair HL, the middle and high bytes of EOF, at 5719H.
6115
LD (5715H),A 32 15 57
Store Register A, the low byte of EOF, at 5715H.
6118
RET C9
RETurn with the end of file set from Register A and Register Pair HL.
6119H - Read a Byte From the Work Area File
Used by SYS19 and SYS20 to read text files: ROM 0013H through the FCB at 570DH. Returns Z with the byte in Register A; at the end of file (DOS 1CH/1DH) NZ with Register A = the code (63A0H); other errors go to 5E16H.
6119
PUSH DE D5
Save Register Pair DE, the caller's value, on the stack.
611A
LD DE,570DH 11 0D 57
Point Register Pair DE at the FCB at 570DH for the ROM read.
611D
GOSUB to ROM 0013H to read a byte through the FCB at Register Pair DE into Register A.
6120
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
6121
RET Z C8
If the read succeeded (the Z FLAG is set), RETurn with the byte in Register A.
6122
JUMP to 63A0H to check the error code in Register A.
6125H - PUT and GET Statements
The Disk BASIC links for PUT (4182H, JP 6125H at 67EBH) and GET (417FH, JP 6126H at 67E8H). The flag (NZ for PUT, Z for GET) is pushed, the file statement is set up, SYS10 is loaded and its GET/PUT code at 4D03H does the work.
Overlapping Instructions
PUT enters at 6125H, where F6H AFH is OR 0AFH (NZ). GET enters at 6126H, where the byte AFH is XOR A (Z).
6125
OR AFH F6 AF
PUT entry (4182H): OR Register A with AFH: NZ, the PUT flag. GET enters at 6126H, the second byte, as XOR A: Z, the GET flag.
6127
PUSH AF F5
Save Register Pair AF on the stack: the Z FLAG is the GET/PUT flag.
6128
CALL 62BCH to read the file number and set up the file statement (Index Register IX = 5700H).
612B
CALL 6131H to load SYS10 and note the current position.
612E
JP 4D03H C3 03 4D
JUMP to SYS10's GET/PUT entry at 4D03H with the PUT/GET flag on the stack.
6131H - Load SYS10 and Note the Position
RST 28H with code 2CH loads SYS10 (its 4D00H entry returns at once). 6134H stores the current position NEXT, 6137H the position in Registers C, L and H, at 5704H-5706H (where the last GET or PUT ended). Also called from 624FH to reload SYS10 after a DOS call.
6131
LD A,2CH 3E 2C
Load Register A with 2CH, the RST 28H code of SYS10.
6133
RST 28H EF
RST 28H: SYS0 loads SYS10 (if it is not in memory) and returns.
6134
GOSUB to 61D3H: Registers C, L and H = NEXT, the current position.
6137
LD (IX+04H),C DD 71 04
Store Register C, the low byte of the position, at Index Register IX+04H (5704H, byte +04H of the header).
613A
LD (5705H),HL 22 05 57
Store Register Pair HL, the middle and high bytes of the position, at 5705H-5706H.
613D
RET C9
RETurn with the position stored at 5704H-5706H.
613EH - Store the Record Start
Stores Registers C, L and H at 5707H-5709H and sets bit 6 of 5701H (the record start is known). Used by PRINT #/INPUT # (5F75H) and SYS10.
613E
LD (IX+07H),C DD 71 07
Store Register C, the low byte of the position, at Index Register IX+07H (5707H).
6141
LD (5708H),HL 22 08 57
Store Register Pair HL, the middle and high bytes of the position, at 5708H-5709H.
6144
SET 6,(IX+01H) DD CB 01 F6
Set bit 6 of 5701H at Index Register IX+01H: the record start is known.
6148
RET C9
RETurn with the record start stored at 5707H-5709H.
6149H - Read the Last GET/PUT End
Registers C, L and H = the position at 5704H-5706H.
6149
LD C,(IX+04H) DD 4E 04
Load Register C with the low byte at Index Register IX+04H (5704H).
614C
LD HL,(5705H) 2A 05 57
Load Register Pair HL with the middle and high bytes from 5705H.
614F
RET C9
RETurn with the last GET/PUT end in Registers C, L and H.
6150H - Read the Record Start
Registers C, L and H = the record start at 5707H-5709H; BAD FILE MODE if bit 6 of 5701H is clear (no record yet). 6156H only makes the check (SYS10).
6150
LD C,(IX+07H) DD 4E 07
Load Register C with the low byte at Index Register IX+07H (5707H).
6153
LD HL,(5708H) 2A 08 57
Load Register Pair HL with the middle and high bytes from 5708H.
6156
BIT 6,(IX+01H) DD CB 01 76
Test bit 6 of 5701H at Index Register IX+01H: the record start is known.
615A
RET NZ C0
If the record start is known (the NZ FLAG is set), RETurn.
615B
JUMP to 6182H to report BAD FILE MODE: no record has been read or written.
615DH - String Item Marker (SYS10)
Called from SYS10 when writing a string item with a length prefix. Register B = the string's length; the prefix n at 5094H (inside SYS10) limits it. Returns Register B = the length to write and Register A = the marker 80H + n; for 128 bytes or more the marker 71H is written first and Register A = n, the length byte.
615D
LD A,(5094H) 3A 94 50
Load Register A with the prefix length from 5094H (inside SYS10).
6160
CP B B8
Compare Register A, the prefix length, with Register B, the string's length.
6161
The prefix is shorter: JUMP to 6164H with it.
6163
LD A,B 78
Copy Register B, the string's length, into Register A.
6164
LD B,A 47
Copy Register A, the length to write, into Register B.
6165
ADD A,80H C6 80
Add 80H to Register A: the one-byte marker for a short string.
6167
RET NC D0
Below 128 bytes (No Carry): RETURN with the marker in Register A.
6168
LD A,71H 3E 71
128 bytes or more: Register A = 71H, the marker for a string with a length byte.
616A
LD C,B 48
Copy Register B, the length, into Register C to keep it.
616B
LD B,00H 06 00
Load Register B with 00H: no data bytes after the marker.
616D
GOSUB to 61EFH to write the 71H marker in Register A.
6170
LD B,C 41
Copy Register C, the length, back into Register B.
6171
LD A,B 78
Copy Register B, the length, into Register A, the length byte to write next.
6172
RET C9
RETurn with Register A = Register B = the length.
6173H - Check the Mode for GET and PUT (SYS10)
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 set when allowed.
6173
LD DE,(5700H) ED 5B 00 57
Load Register Pair DE from 5700H: Register E = the mode (5700H), Register D = the flags (5701H).
6177
LD A,E 7B
Copy Register E, the mode byte of the file, into Register A.
6178
RLCA 07
Rotate Register A left: bit 7 (random) goes into the CARRY FLAG.
6179
If the file is not random (the NC FLAG is set), JUMP to 6182H.
617B
BIT 5,A CB 6F
Test bit 5 of Register A, the rotated mode: bit 4 of the mode, the PUT bit.
617D
If it is a PUT (the NZ FLAG is set), JUMP to 6180H.
617F
RLCA 07
A GET: rotate Register A left once more, so bit 5 comes next.
6180
RLCA 07
Rotate Register A left again: the CARRY FLAG = bit 5 (readable) for GET or bit 6 (writable) for PUT.
6181
RET C D8
If the operation is allowed (the CARRY FLAG is set), RETurn.
6182
JUMP to 5DD0H, error 6CH BAD FILE MODE, with Register A to be loaded there.
6185H - PUT at or Past the End of File (SYS10)
Registers C, L and H = the position of the PUT. At or past EOF bit 4 of 572DH is set; past it the file must have fixed-length records (else BAD FILE POSITIONING PARAM), and an item file is filled with records of 00H bytes up to the position.
6185
GOSUB to 605BH to compare the position in Registers H, L and C with EOF.
6188
RET C D8
If the position is below EOF (the CARRY FLAG is set), RETurn.
6189
SET 4,(IX+2DH) DD CB 2D E6
Set bit 4 of 572DH at Index Register IX+2DH: at or past the end.
618D
RET Z C8
If the position is exactly at EOF (the Z FLAG is set), RETurn.
618E
LD A,(IX+00H) DD 7E 00
Load Register A with the mode byte at Index Register IX+00H (5700H).
6191
BIT 2,A CB 57
Test bit 2 of Register A, the mode: fixed-length records.
6193
Not fixed: JUMP to 5E03H, error A6H BAD FILE POSITIONING PARAM.
6196
AND 03H E6 03
AND Register A with 03H, keeping the type bits 0-1.
6198
RET Z C8
If it is not an item file (the Z FLAG is set), RETurn.
6199
PUSH HL E5
Save Register Pair HL, the middle and high bytes of the position, on the stack.
619A
PUSH BC C5
Save Register Pair BC, holding the low byte in Register C, on the stack.
619B
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the middle and high bytes of EOF.
619C
LD C,(IX+15H) DD 4E 15
Load Register C with the low byte of EOF at Index Register IX+15H (5715H).
619F
GOSUB to 61CDH to position the file at EOF in Registers C, L and H.
61A2
LD HL,(5702H) 2A 02 57
Load Register Pair HL with the record length at 5702H.
61A5
GOSUB to 61AFH to write Register Pair HL bytes of 00H.
61A8
POP BC C1
Restore Register Pair BC: Register C = the low byte of the position.
61A9
POP HL E1
Restore Register Pair HL, the middle and high bytes of the position.
61AA
LOOP back to 6185H until the position is reached.
61ACH - Write 00H Bytes
Writes Register Pair HL bytes of 00H to the file (61AFH skips the zero test for the first byte).
61AC
LD A,H 7C
Copy Register H, the high byte of the count, into Register A.
61AD
OR L B5
OR Register A with Register L: zero when no bytes are left.
61AE
RET Z C8
If no bytes are left (the Z FLAG is set), RETurn.
61AF
XOR A AF
Set Register A to 00H, the filler byte to write to the file.
61B0
LD B,A 47
Copy Register A (00H) into Register B: no data bytes after it.
61B1
GOSUB to 6206H to write the byte in Register A.
61B4
DEC HL 2B
DECrement Register Pair HL, the count of bytes left to write.
61B5
LOOP back to 61ACH to test Register Pair HL, the bytes left.
61B7H - Evaluate an Expression, Text Pointer on the Stack
Used by CMD"J" and SYS10: evaluates the expression and leaves the text pointer on the stack under the return address. Returns NZ for a number; for a string Z with Register B = its length and Register Pair HL = its text.
61B7
CALL 2337H CD 37 23
GOSUB to ROM 2337H to evaluate the expression at Register Pair HL.
61BA
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the text pointer goes on the stack, Register Pair HL = the return address.
61BB
PUSH HL E5
Push Register Pair HL, the return address, again.
61BC
RST 20H E7
RST 20H: test the value type; the Z FLAG is set for a string.
61BD
RET NZ C0
If it is a number (the NZ FLAG is set), RETurn with NZ.
61BE
PUSH AF F5
Save Register Pair AF on the stack: the flags for a string.
61BF
CALL 29D7H CD D7 29
CALL ROM 29D7H to free the string's temporary descriptor; Register Pair HL = the descriptor.
61C2
POP AF F1
Restore Register Pair AF: the flags for a string.
61C3
LD B,(HL) 46
Load Register B with the string's length at Register Pair HL.
61C4
INC HL 23
Bump Register Pair HL to the low byte of the text address.
61C5
LD C,(HL) 4E
Load Register C with the low byte of the text address at Register Pair HL.
61C6
INC HL 23
Bump Register Pair HL to the high byte of the text address.
61C7
LD H,(HL) 66
Load Register H with the high byte of the text address at Register Pair HL.
61C8
LD L,C 69
Copy Register C into Register L: Register Pair HL = the text.
61C9
RET C9
RETurn with the Z FLAG set, Register B = the length and Register Pair HL = the text.
61CAH - Position the File
61CAH positions the file to where the last GET or PUT ended (5704H-5706H); 61CDH to Registers C, L and H, through SYS0 444EH.
61CA
CALL 6149H: Registers C, L and H = 5704H-5706H.
61CD
LD DE,444EH 11 4E 44
Register Pair DE = 444EH, SYS0's position-to-byte vector.
61D0
JUMP to 6245H to call it with the FCB at 570DH.
61D3H - Read NEXT
Registers C, L and H = the current position NEXT (FCB+5 at 5712H, FCB+10/11 at 5717H-5718H).
61D3
LD C,(IX+12H) DD 4E 12
Load Register C with the low byte (Index Register IX+12H = 5712H).
61D6
LD HL,(5717H) 2A 17 57
Load Register Pair HL with the middle and high bytes from 5717H.
61D9
RET C9
RETurn with NEXT, the current position, in Registers C, L and H.
61DAH - Read EOF
Register A and Register Pair HL = the end of file (FCB+8 at 5715H, FCB+12/13 at 5719H-571AH).
61DA
LD A,(5715H) 3A 15 57
Load Register A with the low byte from 5715H.
61DD
LD HL,(5719H) 2A 19 57
Load Register Pair HL with the middle and high bytes from 5719H.
61E0
RET C9
RETurn with EOF in Register A and Register Pair HL.
61E1H - Read NEXT and EOF
Registers C, L and H = NEXT; Register Pair DE = the middle and high bytes of EOF and Register A its low byte. 61E4H reads only EOF into Register Pair DE and Register A.
61E1
GOSUB to 61D3H: Registers C, L and H = NEXT, the current position.
61E4
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE holds NEXT's middle and high bytes for a moment.
61E5
CALL 61DAH: Register A and Register Pair HL = EOF.
61E8
EX DE,HL EB
Exchange: Register Pair HL = NEXT again, Register Pair DE = EOF.
61E9
RET C9
RETurn with NEXT in Registers C, L and H and EOF in Register Pair DE and Register A.
61EAH - Read a Byte From the File
ROM 0013H through the FCB at 570DH (6245H).
61EA
LD DE,0013H 11 13 00
Register Pair DE = 0013H, the ROM's input routine.
61ED
JUMP to 6245H to call the ROM routine in Register Pair DE with the FCB.
61EFH - Write an Item Marker and Its Data (SYS10)
Register A = the marker, Register B = the number of data bytes at Register Pair HL. The room left in the record (operand 61F1H, set by SYS10) is reduced by B + 1; none left is RECORD OVERFLOW. With bit 2 of 572DH (the % format-only mode) nothing is written.
61EF
PUSH HL E5
Save Register Pair HL, the data address, on the stack.
61F0
LD HL,0000H 21 00 00
Load Register Pair HL with the room left in the record; the operand 0000H at 61F1H is stored by SYS10 and at 61FDH.
61F3
LD E,B 58
Copy Register B, the data length, into Register E.
61F4
LD D,00H 16 00
Load Register D with 00H, so Register Pair DE = the data length.
61F6
INC DE 13
INCrement Register Pair DE by 1 for the marker.
61F7
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
61F8
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the room left.
61FA
Not enough room: JUMP to 5DE5H, error 8EH RECORD OVERFLOW.
61FD
LD (61F1H),HL 22 F1 61
Store Register Pair HL, the new room left, at 61F1H.
6200
POP HL E1
Restore Register Pair HL, the data address, from the stack.
6201
BIT 2,(IX+2DH) DD CB 2D 56
Test bit 2 of 572DH at Index Register IX+2DH: format only.
6205
RET NZ C0
If format only (the NZ FLAG is set), RETurn without writing.
6206H - Write a Byte and Data Bytes
Writes the byte in Register A and then Register B bytes from Register Pair HL (6231H). Writing past EOF needs bit 7 of 5701H (the file may be extended), else ILLEGAL TO EXTEND FILE.
6206
PUSH HL E5
Save Register Pair HL, the data address, on the stack.
6207
PUSH AF F5
Save Register Pair AF on the stack: Register A = the byte to write.
6208
CALL 65D4H: Register A and Register Pair HL = NEXT, Register Pair DE = EOF's middle and high bytes.
620B
NOP 00
NOP: no operation, a spare byte between the call and the compare.
620C
SUB (IX+15H) DD 96 15
Subtract EOF's low byte at Index Register IX+15H (5715H) from Register A, NEXT's low byte.
620F
SBC HL,DE ED 52
Subtract Register Pair DE, EOF's middle and high bytes, from Register Pair HL with the borrow: the NC FLAG when NEXT is at or past EOF.
6211
If NEXT is at or past EOF (the NC FLAG is set), JUMP to 621BH.
6213
ADD A,B 80
Add Register B, the data length, to Register A.
6214
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H for the carry.
6217
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 crosses EOF.
6219
If the write stays below EOF (the NC FLAG is set), JUMP to 6222H.
621B
BIT 7,(IX+01H) DD CB 01 7E
Test bit 7 of 5701H at Index Register IX+01H: the file may be extended.
621F
May not: JUMP to 5DE8H, error 90H ILLEGAL TO EXTEND FILE.
6222
POP AF F1
Restore Register Pair AF: Register A = the byte to write.
6223
POP HL E1
Restore Register Pair HL, the data address, from the stack.
6224
GOSUB to 622CH to write the byte in Register A.
6227
LD A,B 78
Copy Register B, the data length, into Register A.
6228
OR A B7
OR Register A with itself to set the flags: Z for no data.
6229
RET Z C8
If there is no data (the Z FLAG is set), RETurn.
622A
JUMP to 6231H to write Register A data bytes from Register Pair HL.
622CH - Write a Byte to the File
ROM 001BH through the FCB at 570DH (6245H).
622C
LD DE,001BH 11 1B 00
Register Pair DE = 001BH, the ROM's output routine.
622F
JUMP to 6245H to call the ROM routine in Register Pair DE with the FCB.
6231H - Write or Read a Block in Record Mode
6231H writes Register A bytes from Register Pair HL unless 572DH bit 2 (format only) is set; 6236H writes them (SYS0 443CH, write with verify), 623BH reads them (SYS0 4436H). FCB+1 bit 7 (record mode) is set and the record length FCB+9 (5716H) is Register A.
6231
BIT 2,(IX+2DH) DD CB 2D 56
Test bit 2 of 572DH at Index Register IX+2DH: format only.
6235
RET NZ C0
If format only (the NZ FLAG is set), RETurn without writing.
6236
LD DE,443CH 11 3C 44
Load Register Pair DE with 443CH, SYS0's write with verify.
6239
JUMP to 623EH to set record mode and call the vector in Register Pair DE.
623BH - Read a Block in Record Mode (SYS10)
Register Pair DE = 4436H (read).
623B
LD DE,4436H 11 36 44
Load Register Pair DE with 4436H, SYS0's read.
623E
SET 7,(IX+0EH) DD CB 0E FE
Set bit 7 of FCB+1 at Index Register IX+0EH (570EH): record mode.
6242
LD (5716H),A 32 16 57
Store the byte count in Register A as the record length FCB+9 (5716H).
6245
CALL 6254H, which jumps to the DOS vector in Register Pair DE with Register Pair DE = the FCB 570DH.
6248
If the DOS reported an error (the NZ FLAG is set), GOSUB to 5E16H with the code in Register A.
624B
PUSH AF F5
Save Register Pair AF on the stack: the result of the DOS call.
624C
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the operand at 624DH: set by SYS10 when it must be reloaded after a DOS call, cleared at 6454H.
624E
OR A B7
OR Register A, the reload flag, with itself to set the flags.
624F
If the flag is set (the NZ FLAG is set), GOSUB to 6131H to load SYS10 again.
6252
POP AF F1
Restore Register Pair AF: the result of the DOS call.
6253
RET C9
RETurn with the result of the DOS call in Register A and the flags.
6254H - Call a DOS Vector With the FCB
Pushes the vector in Register Pair DE as the return address and loads Register Pair DE with the FCB 570DH, so the RET jumps to the vector.
6254
PUSH DE D5
Push Register Pair DE, the vector address, on the stack as the return address.
6255
LD DE,570DH 11 0D 57
Load Register Pair DE with 570DH, the FCB of the work area.
6258
RET C9
RETurn, which jumps into the vector with Register Pair DE = the FCB.
6259H - Read a Sector
SYS0 4436H with FCB+1 bit 7 cleared (sector mode). Used by SYS10.
6259
LD DE,4436H 11 36 44
Load Register Pair DE with 4436H, SYS0's read.
625C
JUMP to 6261H to set sector mode and call the vector in Register Pair DE.
625EH - Write a Sector
SYS0 443CH (write with verify) with FCB+1 bit 7 cleared. Used by SYS10.
625E
LD DE,443CH 11 3C 44
Load Register Pair DE with 443CH, SYS0's write with verify.
6261
RES 7,(IX+0EH) DD CB 0E BE
Clear bit 7 of FCB+1 at Index Register IX+0EH (570EH): sector mode.
6265
JUMP to 6245H to call the vector in Register Pair DE with the FCB.
6267H - Rewind
SYS0 443FH through the FCB. Used by SYS19.
6267
LD DE,443FH 11 3F 44
Load Register Pair DE with 443FH, SYS0's rewind.
626A
JUMP to 6245H to call the vector in Register Pair DE with the FCB.
626CH - Skip Bytes in the File
Moves NEXT forward by Register B (626CH) or Register A (626DH) bytes; past 24 bits is DOS error 1DH.
626C
LD A,B 78
Copy Register B, the byte count, into Register A.
626D
GOSUB to 61D3H: Registers C, L and H = NEXT; Register A is kept.
6270
ADD A,C 81
Add Register C, NEXT's low byte, to Register A, the byte count.
6271
LD C,A 4F
Copy Register A, the new low byte, into Register C.
6272
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H for the carry.
6275
ADC HL,DE ED 5A
Add Register Pair DE (0000H) and the CARRY FLAG to Register Pair HL, the middle and high bytes.
6277
No overflow: JUMP to 61CDH to position there.
627A
LD A,1DH 3E 1D
Overflow: Register A = 1DH, PAST END OF FILE.
627C
JUMP to 5E16H to report the DOS error in Register A.
627FH - Skip One Item (SYS10)
Checks that the position is still inside the record (635BH), reads an item marker (6293H) and skips the item's data. Returns Z and Carry at a record start (70H), NZ otherwise.
627F
PUSH HL E5
Save Register Pair HL (position middle and high).
6280
PUSH BC C5
Save Register Pair BC, holding the low byte of the position in Register C, on the stack.
6281
LD H,L 65
Copy Register L, the middle byte, into Register H.
6282
LD L,C 69
Copy Register C, the low byte, into Register L.
6283
CALL 635BH: RECORD OVERFLOW if the position is past the record.
6286
CALL 6293H to read the item marker: Register B = the item's length.
6289
LD A,B 78
Copy Register B, the item's length, into Register A.
628A
POP BC C1
Restore Register Pair BC: Register C = the low byte of the position.
628B
POP HL E1
Restore Register Pair HL, the middle and high bytes of the position.
628C
RET C D8
If it is a record start (the CARRY FLAG is set), RETurn.
628D
A data item (NZ): CALL 626DH to skip its bytes.
6290
OR FFH F6 FF
OR Register A with FFH: Register A = FFH and the NZ FLAG is set.
6292
RET C9
RETurn with the NZ FLAG set: an item was skipped.
6293H - Read an Item Marker
Returns Z and No Carry for 00H (a filler byte), Z and Carry for 70H (a record start); otherwise NZ with Register A = the type and Register B = the length: 71H n and 80H + n strings (type 3, length n), 72H integer (2), 73H single (4), 74H double (8). Any other byte is BAD FILE DATA.
6293
GOSUB to 61EAH to read the marker byte into Register A.
6296
OR A B7
OR Register A, the marker, with itself to set the flags.
6297
RET Z C8
If the marker is 00H (the Z FLAG is set), RETurn: a filler byte.
6298
ADD A,80H C6 80
Add 80H to Register A, the marker: the CARRY FLAG is set for 80H and above.
629A
80H or above (Carry): a short string, JUMP to 62B7H.
629C
ADD A,10H C6 10
Add 10H to Register A: zero (with the CARRY FLAG) for 70H.
629E
RET Z C8
If the marker is 70H (the Z FLAG is set), RETurn with Z and the CARRY FLAG: a record start.
629F
DEC A 3D
DECrement Register A, the marker minus 70H: zero for 71H.
62A0
If the marker is 71H (the Z FLAG is set), JUMP to 62B4H.
62A2
LD B,02H 06 02
Load Register B with 02H, the length of an integer.
62A4
DEC A 3D
DECrement Register A, the marker minus 71H: zero for 72H.
62A5
If the marker is 72H (the Z FLAG is set), JUMP to 62B2H: an integer.
62A7
LD B,04H 06 04
Load Register B with 04H, the length of a single-precision number.
62A9
DEC A 3D
DECrement Register A, the marker minus 72H: zero for 73H.
62AA
If the marker is 73H (the Z FLAG is set), JUMP to 62B2H: a single-precision number.
62AC
LD B,08H 06 08
Load Register B with 08H, the length of a double-precision number.
62AE
DEC A 3D
DECrement Register A, the marker minus 73H: zero for 74H.
62AF
Not 74H: JUMP to 5DC4H, error 2AH BAD FILE DATA.
62B2
OR B B0
Register A = the length and type in Register B: NZ.
62B3
RET C9
RETurn with the NZ FLAG set, Register A = Register B = the type and length.
62B4
71H: GOSUB to 61EAH to read the length byte into Register A.
62B7
LD B,A 47
Copy Register A, the string's length, into Register B.
62B8
LD A,03H 3E 03
Load Register A with 03H, the value type of a string.
62BA
OR A B7
OR Register A with itself, setting the NZ FLAG.
62BB
RET C9
RETurn with the NZ FLAG set, Register A = 03H and Register B = the length.
62BCH - Set Up a File Statement
62BCH reads the file number first (5F7AH); 62BFH starts with the area in Register Pair BC. Only one file area per statement (63A9H must be 00H, else error A4H STMT USES 2 FILE AREAS). The area's address is kept at 6379H, 63A9H is set to C9H, Index Register IX = 5700H and the area's 2DH-byte header is copied to 5700H (572DH cleared). Returns Register A = the mode byte, Z if the file is not open.
62BC
CALL 5F7AH to read the file number: Register Pair BC = the area.
62BF
LD A,(63A9H) 3A A9 63
Load Register A with the statement flag at 63A9H.
62C2
OR A B7
OR Register A, the statement flag, with itself to set the flags.
62C3
A file statement is already running: JUMP to 5E00H, error A4H.
62C6
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
62C7
LD H,B 60
Copy Register B into Register H, the high byte of the area address.
62C8
LD L,C 69
Copy Register C to Register L: Register Pair HL = the area.
62C9
LD (6379H),HL 22 79 63
Store Register Pair HL, the area, as the operand at 6379H, for copying back.
62CC
CALL 63ADH: 63A9H = C9H, a file statement is running.
62CF
LD DE,5700H 11 00 57
Load Register Pair DE with 5700H, the work header.
62D2
PUSH DE D5
Push Register Pair DE (5700H) on the stack for the POP IX.
62D3
POP IX DD E1
Pop it into Index Register IX: Index Register IX = 5700H.
62D5
LD (IX+2DH),00H DD 36 2D 00
Store 00H at Index Register IX+2DH (572DH), the busy byte.
62D9
LD BC,002DH 01 2D 00
Load Register Pair BC with 002DH, the bytes of the header.
62DC
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL, the area, to Register Pair DE (5700H): the header.
62DE
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
62DF
LD A,(5700H) 3A 00 57
Load Register A with the mode byte of the file area at 5700H.
62E2
OR A B7
OR Register A with itself to set the flags: Z if the file is not open.
62E3
RET C9
RETurn with Register A = the mode byte and Index Register IX = 5700H.
62E4H - Copy an Area's Header to 5700H
Register Pair HL = the area (used at 6494H).
62E4
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
62E5
JUMP to 62CFH to copy the header from Register Pair HL to 5700H.
62E7H - Set Up a File Statement and Require a Comma
For PRINT # and INPUT # (and SYS20).
62E7
GOSUB to 62BCH to read the file number and set up the file statement at Register Pair HL.
62EA
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
62EB
DEFB 2CH 2C
Inline byte for the RST 08H at 62EAH: 2CH, a comma (not executed).
62EC
JUMP to 62DFH to return the mode byte in Register A.
62EEH - Item Prefix Checks (SYS10)
Bit 6 of 572DH means a length prefix was given. 62EEH: a numeric item may not have one; 62F5H/62F7H: the item needs one (error 9EH BAD/ILLEGAL/MISSING IGEL ITEM PREFIX).
62EE
BIT 6,(IX+2DH) DD CB 2D 76
Test bit 6 of 572DH at Index Register IX+2DH: a length prefix was given.
62F2
RET Z C8
If there is no prefix (the Z FLAG is set), RETurn.
62F3
A prefix was given for a number: JUMP to 62FCH to report the error.
62F5
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the text pointer.
62F6
INC DE 13
Bump Register Pair DE past the # or $ to the prefix value.
62F7
BIT 6,(IX+2DH) DD CB 2D 76
Test bit 6 of 572DH at Index Register IX+2DH: a length prefix was given.
62FB
RET NZ C0
If a prefix was given (the NZ FLAG is set), RETurn.
62FC
JUMP to 5DFAH, error 9EH BAD/ILLEGAL/MISSING IGEL ITEM PREFIX, with Register A to be loaded there.
62FFH - Item Variable for a Type F File (SYS10)
Type M files return Z. Type F (mode bit 1) returns NZ with Register C = the prefix length (5094H) and either Register A = # or $ (Register Pair DE after it) or Register A = 00H with Register Pair HL = the variable's address (PTRGET); a string variable needs a prefix.
62FF
BIT 1,(IX+00H) DD CB 00 4E
Test bit 1 of the mode at Index Register IX+00H: a type F file.
6303
RET Z C8
If the file is type M (the Z FLAG is set), RETurn with Z.
6304
LD A,(5094H) 3A 94 50
Load Register A with the prefix length from 5094H (inside SYS10).
6307
LD C,A 4F
Copy Register A, the prefix length, into Register C.
6308
LD A,(HL) 7E
Load Register A with the next BASIC character at Register Pair HL.
6309
CP 23H FE 23
Compare Register A, the next character, with 23H (#).
630B
If Register A is # (the Z FLAG is set), JUMP to 62F5H.
630D
CP 24H FE 24
Compare Register A, the next character, with 24H ($).
630F
If Register A is $ (the Z FLAG is set), JUMP to 62F5H.
6311
PUSH BC C5
Save Register Pair BC on the stack: Register C = the prefix length.
6312
CALL 260DH CD 0D 26
CALL ROM 260DH, PTRGET: Register Pair DE = the variable's address.
6315
POP BC C1
Restore Register Pair BC: Register C = the prefix length.
6316
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the variable.
6317
LD B,(HL) 46
Load Register B with the variable's first byte at Register Pair HL (a string's length).
6318
RST 20H E7
RST 20H: test the value type; the Z FLAG is set for a string.
6319
If the variable is not a string (the NZ FLAG is set), JUMP to 6322H.
631B
BIT 6,(IX+2DH) DD CB 2D 76
Test bit 6 of 572DH at Index Register IX+2DH: a prefix was given.
631F
If no prefix was given (the Z FLAG is set), JUMP to 5DFAH, error 9EH.
6322
OR D B2
OR Register A with Register D (not zero), setting the NZ FLAG.
6323
LD A,00H 3E 00
Load Register A with 00H: the item is a variable.
6325
RET C9
RETurn with the NZ FLAG set, Register A = 00H and Register C = the prefix length.
6326H - Fill the Rest of a Record After PUT (SYS10)
After a PUT (mode bit 4) to a record-segmented file (mode bit 3) the rest of the record is filled with 00H bytes where the type needs it: the room left (61F1H), or, for a type MU file not at EOF with 572DH bit 3, up to EOF.
6326
LD A,(5700H) 3A 00 57
Load Register A with the mode byte of the file at 5700H.
6329
BIT 4,A CB 67
Test bit 4 of Register A, the mode byte: a PUT is in progress.
632B
RET Z C8
If it is not a PUT (the Z FLAG is set), RETurn.
632C
BIT 3,A CB 5F
Test bit 3 of Register A, the mode: record segmented.
632E
RET Z C8
If the file is not record segmented (the Z FLAG is set), RETurn.
632F
LD B,(IX+2DH) DD 46 2D
Load Register B with the flags at Index Register IX+2DH (572DH).
6332
BIT 1,A CB 4F
Test bit 1 of Register A, the mode: a type F file.
6334
If the file is type F (the NZ FLAG is set), JUMP to 634FH.
6336
BIT 0,A CB 47
Test bit 0 of Register A, the mode byte: the file type bit 0.
6338
RET Z C8
If bit 0 is clear (the Z FLAG is set), RETurn.
6339
BIT 2,A CB 57
Test bit 2 of Register A, the mode (type MF).
633B
If the file is type MF (the NZ FLAG is set), JUMP to 6352H.
633D
BIT 4,B CB 60
Test bit 4 of Register B, the flags from 572DH: the PUT was at or past EOF.
633F
RET NZ C0
If the PUT was at the end (the NZ FLAG is set), RETurn.
6340
BIT 3,B CB 58
Test bit 3 of Register B, the flags from 572DH.
6342
If bit 3 is clear (the Z FLAG is set), JUMP to 6352H.
6344
CALL 61E1H: NEXT in Registers C, L and H, EOF in Register A and Register Pair DE.
6347
SUB C 91
Subtract Register C, NEXT's low byte, from Register A, EOF's low byte.
6348
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = EOF's middle and high bytes.
6349
SBC HL,DE ED 52
Subtract Register Pair DE, NEXT's middle and high bytes, from Register Pair HL with the borrow.
634B
LD H,L 65
Copy Register L, the middle byte, into Register H.
634C
LD L,A 6F
Copy Register A, the low byte, into Register L: Register Pair HL = the bytes up to EOF.
634D
JUMP to 6355H to write Register Pair HL bytes of 00H.
634F
BIT 4,B CB 60
Type F: test bit 4 of Register B, the flags from 572DH.
6351
RET Z C8
If the PUT was not at the end (the Z FLAG is set), RETurn.
6352
LD HL,(61F1H) 2A F1 61
Load Register Pair HL with the room left in the record (61F1H).
6355
JUMP to 61ACH to write Register Pair HL bytes of 00H.
6358H - Room Left in the Record (SYS10)
6358H: the record length minus the bytes from the record start (5707H) to the end of the last GET/PUT (5704H); 636DH: to NEXT. RECORD OVERFLOW if negative; returns Register Pair HL = the room.
6358
LD HL,(5704H) 2A 04 57
Load Register Pair HL with the low and middle bytes of the last GET/PUT end (5704H).
635B
LD DE,(5707H) ED 5B 07 57
Load Register Pair DE with the low and middle bytes of the record start (5707H).
635F
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
6360
SBC HL,DE ED 52
Subtract Register Pair DE, the record start, from Register Pair HL: the bytes used.
6362
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the bytes used.
6363
LD HL,(5702H) 2A 02 57
Load Register Pair HL with the record length at 5702H.
6366
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
6367
SBC HL,DE ED 52
Subtract Register Pair DE, the bytes used, from Register Pair HL: the room left.
6369
RET NC D0
If the room left is not negative (the NC FLAG is set), RETurn with it in Register Pair HL.
636A
JUMP to 5DE5H, error 8EH RECORD OVERFLOW, with Register A to be loaded there.
636DH - Room Left, From NEXT (SYS10)
Uses the current position instead of 5704H.
636D
GOSUB to 61D3H: Registers C, L and H = NEXT, the current position.
6370
LD H,L 65
Copy Register L, the middle byte, into Register H.
6371
LD L,C 69
Copy Register C, the low byte, into Register L.
6372
JUMP to 635BH with Register Pair HL = NEXT's low and middle bytes.
6374H - Copy the Header Back to the File Area
5700H-572CH is copied to the area whose address is the operand at 6379H.
6374
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
6375
LD HL,5700H 21 00 57
Point Register Pair HL at the work header at 5700H.
6378
LD DE,0000H 11 00 00
Load Register Pair DE with the file area's address; the operand 0000H at 6379H is stored by 62C9H.
637B
JUMP to 62D9H to copy 2DH bytes from Register Pair HL to Register Pair DE.
637EH - End a File Function
Pushed as the return for EOF, LOF and LOC: the header is copied back, the statement flag cleared and the work area 5700H-572DH cleared. 6381H only clears; 6389H clears Register B bytes at Register Pair HL.
637E
GOSUB to 6374H to copy the header at 5700H back to the file area.
6381
GOSUB to 63B9H to store 00H at 63A9H: no file statement.
6384
LD HL,5700H 21 00 57
Point Register Pair HL at the work area at 5700H.
6387
LD B,2EH 06 2E
Load Register B with 2EH, the bytes 5700H-572DH.
6389
LD (HL),00H 36 00
Store 00H at Register Pair HL in the work area at 5700H-572DH.
638B
INC HL 23
Bump Register Pair HL to the next byte of the work area.
638C
DECrement Register B and LOOP back to 6389H until all the bytes are cleared.
638E
RET C9
RETurn with the work area at 5700H-572DH cleared to 00H.
638FH - End of Statement or a Comma
Z if the statement ends; otherwise a comma must follow and NZ is returned with Register A = the next character.
638F
DEC HL 2B
DECrement Register Pair HL back one character, so RST 10H rereads it.
6390
RST 10H D7
RST 10H: load Register A with the next character at Register Pair HL; the Z FLAG is set at the end of the statement.
6391
RET Z C8
If the statement ends (the Z FLAG is set), RETurn with Z.
6392
RST 08H CF
RST 08H: the character at Register Pair HL must be a comma (2CH, the inline byte after this instruction), else SYNTAX ERROR; Register Pair HL steps past it and Register A holds the next character.
6393
DEFB 2CH 2C
Inline byte for the RST 08H at 6392H: 2CH, a comma (not executed).
6394
CP FFH FE FF
Compare Register A with FFH, setting the NZ FLAG.
6396
RET C9
RETurn with the NZ FLAG set and Register A = the next character.
6397H - Read the Next Sector (SYS19)
SYS0 4436H through the FCB 570DH. Returns Z on success; at the end of file (DOS 1CH or 1DH, 63A0H is also used by 6119H) NZ with Register A = the code; other errors go to 5E16H.
6397
LD DE,570DH 11 0D 57
Point Register Pair DE at the FCB of the work area at 570DH.
639A
GOSUB to the SYS0 routine at 4436H to read the next sector through the FCB at Register Pair DE.
639D
RET Z C8
If the read succeeded (the Z FLAG is set), RETurn.
639E
CP 1DH FE 1D
Compare Register A, the error code, with 1DH, PAST END OF FILE.
63A0
If Register A is 1DH (the Z FLAG is set), JUMP to 63A7H.
63A2
CP 1CH FE 1C
Compare Register A, the error code, with 1CH, END OF FILE ENCOUNTERED.
63A4
If it is another error (the NZ FLAG is set), JUMP to 5E16H with the code in Register A.
63A7
OR A B7
OR Register A with itself, setting the NZ FLAG with the code in Register A.
63A8
RET C9
RETurn with the NZ FLAG set and the end-of-file code in Register A.
63A9H - File Statement Flag
The byte at 63A9H is 00H (NOP) when no file statement is running and C9H (RET) while one is. The links call 63A9H first: with 00H the INC SP / INC SP / RET drops the call and returns straight to the ROM; with C9H the call just returns. 63ADH sets it, 63B3H (link 41B5H) saves it at 63BDH and clears it, 63BCH (link 41B8H) puts it back.
63A9
NOP 00
The flag: 00H (NOP) in the file, C9H (RET) during a file statement.
63AA
INC SP 33
No file statement: INCrement the Stack Pointer, dropping the return address (1 of 2).
63AB
INC SP 33
INCrement the Stack Pointer again, dropping the return address (2 of 2).
63AC
RET C9
RETURN to the caller's caller: the hook does nothing.
63ADH - Mark a File Statement Running
63A9H = C9H (called from 62CCH and SYS19).
63AD
LD A,C9H 3E C9
Load Register A with C9H, the opcode RET, for the flag at 63A9H.
63AF
LD (63A9H),A 32 A9 63
Store Register A at 63A9H: C9H marks a file statement running, 00H none.
63B2
RET C9
RETurn with the file statement flag at 63A9H set.
63B3H - Link 41B5H: Save and Clear the Flag
Called by the ROM after the program's line table is rebuilt (1AECH).
63B3
LD A,(63A9H) 3A A9 63
Link 41B5H (JP 63B3H at 681EH), called by the ROM after the program's line table is rebuilt: load Register A with the flag at 63A9H.
63B6
LD (63BDH),A 32 BD 63
Store Register A, the flag, as the operand at 63BDH.
63B9
XOR A AF
Set Register A to 00H, the flag value for no file statement.
63BA
JUMP to 63AFH to store Register A (00H) at 63A9H and return.
63BCH - Link 41B8H: Restore the Flag
Called by the ROM after the line table and CLEAR (1AF2H).
63BC
LD A,00H 3E 00
Link 41B8H (JP 63BCH at 6821H), called after that and CLEAR: load Register A with the flag saved at 63BDH (operand 00H in the file).
63BE
JUMP to 63AFH to put Register A back at 63A9H.
63C0H - Link 41C4H (Keyboard Scan), File Statement End and Single Stepping
Link 41C4H (JP 63C0H at 682DH), called by the ROM's keyboard scan (0358H). When BASIC starts a new statement (the scan called from 1D21H) the file statement is ended (6445H); at the start of a line single stepping runs when 63DBH is JR NZ. During RUN ONLY (6421H) or chaining (4369H bit 5) the scan is skipped and no key is returned.
63C0
POP AF F1
Pop the return address of the ROM's CALL to the link into Register Pair AF, dropping it.
63C1
EX (SP),HL E3
Exchange Register Pair HL with the next word at the Stack Pointer: the return address of the keyboard scan's caller.
63C2
PUSH DE D5
Save Register Pair DE, the caller's value, on the stack.
63C3
LD DE,1D9EH 11 9E 1D
Load Register Pair DE with 1D9EH, a return address inside the ROM.
63C6
RST 18H DF
RST 18H compares Register Pair HL with Register Pair DE.
63C7
If the caller is not 1D9EH (the NZ FLAG is set), JUMP to 63CDH.
63C9
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
63CA
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the return address goes back and Register Pair HL is restored.
63CB
JUMP to 641FH for the normal key handling of the keyboard scan.
63CD
LD DE,1D21H 11 21 1D
Register Pair DE = 1D21H, BASIC's next-statement code.
63D0
RST 18H DF
RST 18H compares Register Pair HL, the caller, with Register Pair DE (1D21H).
63D1
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
63D2
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: the return address goes back.
63D3
JP NZ,035BH C2 5B 03
Called from elsewhere: JUMP to ROM 035BH, the rest of the keyboard scan.
63D6
A new statement: CALL 6445H to end any file statement.
63D9
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the text pointer: 00H at the end of a line.
63DA
OR A B7
OR Register A with itself to set the flags: Z at the end of a line.
63DB
Self-Modifying Code
Opcode set by CMD"F=SS" (5BD6H): 18H (JR, stepping off) always jumps to 641FH; 20H (JR NZ, stepping on) falls into 63DDH at the end of a line.
63DDH - 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 (63EBH) nothing happens until that line comes up.
63DD
PUSH HL E5
Save Register Pair HL, the text pointer, on the stack.
63DE
PUSH DE D5
Save Register Pair DE, the caller's value, on the stack.
63DF
PUSH BC C5
Save Register Pair BC, the caller's value, on the stack.
63E0
INC HL 23
Advance Register Pair HL to the next line's link.
63E1
LD A,(HL) 7E
Load Register A with the low byte of the next line's link at Register Pair HL.
63E2
INC HL 23
Bump Register Pair HL to the high byte of the link.
63E3
OR (HL) B6
OR Register A with the high byte of the link at Register Pair HL: zero at the end of the program.
63E4
If it is the end of the program (the Z FLAG is set), JUMP to 641CH.
63E6
INC HL 23
Bump Register Pair HL to the next line's number.
63E7
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL.
63E8
INC HL 23
Bump Register Pair HL to the high byte of the line number.
63E9
LD D,(HL) 56
Load Register D with the high byte of the line number at Register Pair HL.
63EA
LD HL,0000H 21 00 00
Load Register Pair HL with the start line; the operand 0000H at 63EBH is stored by 5BCCH (0000H = step every line).
63ED
LD A,H 7C
Copy Register H, the high byte of the start line, into Register A.
63EE
OR L B5
OR Register A with Register L: zero when there is no start line.
63EF
If there is no start line (the Z FLAG is set), JUMP to 63F6H.
63F1
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
63F2
SBC HL,DE ED 52
Subtract Register Pair DE, the next line, from Register Pair HL, the start line.
63F4
If the start line is not reached (the NZ FLAG is set), JUMP to 641CH.
63F6
LD (63EBH),HL 22 EB 63
Store 0000H (Register Pair HL) at 63EBH: from now on every line steps.
63F9
LD BC,3C39H 01 39 3C
Register Pair BC = 3C39H, the top right of the screen.
63FC
LD A,40H 3E 40
Load Register A with 40H (@), shown before the line number.
63FE
LD (BC),A 02
Store Register A (@) on the screen at Register Pair BC.
63FF
PUSH BC C5
Save Register Pair BC, the screen address, on the stack.
6400
INC BC 03
Bump Register Pair BC to the next screen position.
6401
CALL 5D27H to put the line number's digits on the screen at Register Pair BC.
6404
CALL 642EH to blank the rest of the screen line.
Loop: wait for ENTER or BREAK.
6407
GOSUB to ROM 0049H to wait for a key; Register A = the key.
640A
CP 01H FE 01
Compare Register A, the key, with 01H, BREAK.
640C
If the key is BREAK (the Z FLAG is set), JUMP to 6412H.
640E
SUB 0DH D6 0D
Subtract 0DH from Register A: zero for ENTER.
6410
If it is any other key (the NZ FLAG is set), LOOP back to 6407H.
6412
POP BC C1
Restore Register Pair BC = 3C39H, the screen address.
6413
PUSH AF F5
Save Register Pair AF on the stack: Register A = the key result.
6414
GOSUB to 642EH to blank the @nnnnn display at Register Pair BC.
6417
POP AF F1
Restore Register Pair AF: Register A = 00H for ENTER, 01H for BREAK.
6418
POP BC C1
Restore Register Pair BC, the caller's value, from the stack.
6419
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
641A
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
641B
RET C9
RETURN to the ROM with Register A as the key (01H is BREAK).
641C
POP BC C1
Restore Register Pair BC, the caller's value, from the stack.
641D
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
641E
POP HL E1
Restore Register Pair HL, the text pointer, from the stack.
641F
XOR A AF
Set Register A to 00H before the RUN ONLY test below.
6420
OR 00H F6 00
OR Register A with the operand at 6421H: 43H during RUN ONLY (set by SYS19), else 00H as in the file.
6422
RUN ONLY: JUMP to 642CH (no key, BREAK is ignored).
6424
LD A,(4369H) 3A 69 43
Load Register A with the DOS flags at 4369H to test for chaining.
6427
AND 20H E6 20
AND Register A with 20H, keeping bit 5 (chaining).
6429
JP Z,035BH CA 5B 03
Not chaining: JUMP to ROM 035BH for the normal keyboard scan.
642C
XOR A AF
Set Register A to 00H: no key is returned to the ROM.
642D
RET C9
RETurn to the ROM with Register A = 00H, no key pressed.
642EH - Blank to the End of the Screen Line
Stores spaces from Register Pair BC up to the next 64-byte line boundary.
642E
LD A,20H 3E 20
Load Register A with 20H, a space, to blank the screen line.
6430
LD (BC),A 02
Store Register A, the space, on the screen at Register Pair BC.
6431
INC BC 03
Bump Register Pair BC to the next screen position.
6432
LD A,C 79
Copy Register C, the low byte of the screen address, into Register A.
6433
AND 3FH E6 3F
AND Register A with 3FH, keeping the column bits.
6435
If it is not the end of the line (the NZ FLAG is set), LOOP back to 642EH.
6437
RET C9
RETurn with Register Pair BC at the start of the next screen line.
6438H - Link 41BEH (After PRINT)
Link 41BEH (JP 6438H at 6827H), called by the ROM when a PRINT ends (and from its error handling): the file statement is ended through 6447H with 6482H = JR NZ, so that on an error (called from 19B4H) the file area's control data is put back as it was (manual 8.13).
6438
LD A,20H 3E 20
Register A = 20H, the opcode JR NZ for 6482H.
643A
JUMP to 6447H to store Register A (20H) at 6482H.
643CH - KILL Statement and the End of a File Statement
KILL link (4191H, JP 643CH at 67FAH): the file is opened in the work area and killed with SYS0 442CH, then the statement ends. 6445H ends a file statement (called at each new statement from 63D6H, by SYS10 and SYS18): 6482H becomes JR (always write the header back).
643C
CALL 609AH to open the file named in the statement.
643F
GOSUB to the SYS0 routine at 442CH to kill the file in the FCB at Register Pair DE.
6442
If the DOS reported an error (the NZ FLAG is set), JUMP to 5E16H with the code in Register A.
6445
LD A,18H 3E 18
Load Register A with 18H, the opcode JR, for 6482H.
6447
LD (6482H),A 32 82 64
Store Register A, the opcode 18H or 20H, at 6482H.
644AH - End the File Statement
Calls the cleanup hook at 644EH (a RET, or SYS19's/SYS21's while they run), clears the SYS10 reload flag (624DH), the printer echo (5D6CH), 65C9H and 4369H bit 6, sets 40A9H to 1. If a file statement ran: a work-area file (572DH bit 7) is closed; otherwise the header is copied back to the file area, except that after an error (called from ROM 19B4H with 6482H = JR NZ) the area's position and FCB+1 are put back as they were before the statement. Then 5700H-572DH is cleared.
644A
PUSH HL E5
Save Register Pair HL, the caller's value, on the stack.
644B
PUSH DE D5
Save Register Pair DE, the caller's value, on the stack.
644C
PUSH BC C5
Save Register Pair BC, the caller's value, on the stack.
644D
Self-Modifying Code
CALL the cleanup routine whose address is the operand at 644EH: 64BDH (a RET) normally; SYS19 (543EH) and SYS21 (4D67H) put their own there, 64BEH puts back 64BDH.
6450
XOR A AF
Set Register A to 00H for the flags cleared below.
6451
LD (65C9H),A 32 C9 65
Store Register A (00H) at 65C9H, clearing that flag.
6454
LD (624DH),A 32 4D 62
Store Register A (00H) at 624DH: SYS10 need not be reloaded.
6457
LD (5D6CH),A 32 6C 5D
Store Register A (00H) at 5D6CH: no output to the printer.
645A
INC A 3C
INCrement Register A from 00H to 01H for the cassette flag.
645B
LD (40A9H),A 32 A9 40
Store Register A (01H) at 40A9H, the ROM's cassette flag: not the cassette.
645E
LD HL,4369H 21 69 43
Point Register Pair HL at the DOS flags at 4369H.
6461
RES 6,(HL) CB B6
Clear bit 6 of the DOS flags at Register Pair HL: no overlay function running.
6463
LD A,(63A9H) 3A A9 63
Load Register A with the file statement flag 63A9H.
6466
OR A B7
OR Register A, the statement flag, with itself to set the flags.
6467
If no file statement is running (the Z FLAG is set), JUMP to 64B9H.
6469
LD HL,572DH 21 2D 57
Point Register Pair HL at the busy byte at 572DH.
646C
BIT 7,(HL) CB 7E
Test bit 7 of the byte at Register Pair HL (572DH): a work-area file.
646E
If it is not a work-area file (the Z FLAG is set), JUMP to 647AH.
6470
GOSUB to 5FAFH to close the work-area file at 5700H.
6473
LD HL,5FCFH 21 CF 5F
Point Register Pair HL at 5FCFH, the RET Z of the close-all routine.
6476
LD (HL),C8H 36 C8
Store C8H (RET Z) at Register Pair HL (5FCFH): the close-all routine works again (RUN with R had made it RET).
6478
JUMP to 64B6H to clear the flag and the work area.
647A
POP BC C1
Take the caller's return address into Register Pair BC.
647B
LD HL,19B4H 21 B4 19
Register Pair HL = 19B4H, the return address inside the ROM's error handling.
647E
OR A B7
OR Register A with itself to clear the CARRY FLAG before the subtraction.
647F
SBC HL,BC ED 42
Subtract Register Pair BC, the return address, from Register Pair HL (19B4H): Z when called from there.
6481
PUSH BC C5
Push Register Pair BC, the return address, back on the stack.
6482
Self-Modifying Code
Opcode set at 6447H: 18H (JR) always goes to 64B3H; 20H (JR NZ, from the 41BEH link at 6438H) goes there unless this is the error path.
6484
LD HL,(6379H) 2A 79 63
Error path: load Register Pair HL with the file area's address from 6379H.
6487
LD A,(HL) 7E
Load Register A with the area's mode byte at Register Pair HL.
6488
OR A B7
OR Register A with itself to set the flags: Z if the area is not open.
6489
If the area is not open (the Z FLAG is set), JUMP to 64B6H.
648B
PUSH HL E5
Save Register Pair HL, the area address, on the stack.
648C
CALL 61D3H: Registers C, L and H = the statement's NEXT.
648F
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer: NEXT's middle/high word goes on the stack, Register Pair HL = the area.
6490
LD A,(570EH) 3A 0E 57
Load Register A with the statement's FCB+1 (570EH).
6493
PUSH AF F5
Save Register Pair AF on the stack: Register A = the statement's FCB+1.
6494
CALL 62E4H to copy the area's header back to 5700H: the control data as it was before the statement.
6497
LD (HL),00H 36 00
Store 00H at Register Pair HL, the first byte of the area's header.
6499
POP BC C1
Pop the saved Register Pair AF into Register Pair BC: Register B = the statement's FCB+1.
649A
POP DE D1
Restore Register Pair DE = the statement's NEXT middle and high bytes.
649B
LD C,(IX+0EH) DD 4E 0E
Load Register C with the original FCB+1 at Index Register IX+0EH (570EH).
649E
LD HL,(5717H) 2A 17 57
Load Register Pair HL with the original NEXT middle and high bytes at 5717H.
64A1
RST 18H DF
RST 18H compares Register Pair HL, the original NEXT, with Register Pair DE, the statement's NEXT.
64A2
If they are in different sectors (the NZ FLAG is set), JUMP to 64ACH.
64A4
BIT 4,C CB 61
Test bit 4 of Register C, the original FCB+1.
64A6
If bit 4 is clear (the Z FLAG is set), JUMP to 64ACH.
64A8
BIT 4,B CB 60
Test bit 4 of Register B, the statement's FCB+1.
64AA
JUMP to 64ACH, the next instruction, so the three tests have no effect.
64AC
RES 4,C CB A1
Clear bit 4 of Register C, the FCB+1 (buffer changed).
64AE
SET 5,C CB E9
Set bit 5 of Register C, the FCB+1: the buffer does not hold NEXT, so it is read again.
64B0
LD (IX+0EH),C DD 71 0E
Store Register C, the new FCB+1, at Index Register IX+0EH (570EH).
64B3
CALL 6374H to copy the header back to the file area.
64B6
CALL 6381H to clear the flag and the work area.
64B9
POP BC C1
Restore Register Pair BC, the caller's value, from the stack.
64BA
POP DE D1
Restore Register Pair DE, the caller's value, from the stack.
64BB
POP HL E1
Restore Register Pair HL, the caller's value, from the stack.
64BC
XOR A AF
Set Register A to 00H and the Z FLAG for the caller.
64BD
RET C9
RETURN (also the default cleanup routine called at 644DH).
64BEH - Restore the Cleanup Hook
Puts 64BDH (a RET) back into the operand at 644EH. Used by SYS19 and SYS21 when they finish.
64BE
LD HL,64BDH 21 BD 64
Load Register Pair HL with 64BDH, the default cleanup routine (a RET).
64C1
LD (644EH),HL 22 4E 64
Store Register Pair HL (64BDH) as the operand at 644EH.
64C4
RET C9
RETurn with the cleanup hook at 644EH back to 64BDH.
64C5H - FCB Size Storage
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.
64C5-64C6
DEFS 2
Not in the file (the load block before ends at 64C4H, the next starts at 64C7H). File control block size: 6711H stores 012DH (301 bytes) here, 6730H sets the high byte to 02H (022DH) when the file count is followed by V.
64C7
LD A,(2C00H) 3A 00 2C
Load Register A with the byte at 2C00H. Unreferenced: nothing jumps to 64C7H (64C4H is a RET and the entry code jumps to 64CAH), so these three bytes are never executed.
64CAH - Initialization: Establish and Verify the Top of BASIC Memory
Execution arrives here from the JP 64CAH at 6759H, the last instruction of the program entry code at 66BEH. By this point the entry code has parsed the parameters typed after BASIC on the DOS command line and stored its results inside the code below: the number of file buffers in the operand at 6529H, the size of one file control block in 64C5H-64C6H, any requested top of memory in the operand at 64CBH-64CCH, and the address of the startup command text in the operand at 655EH-655FH. It has also copied the ROM's 39-byte division support table from 18F7H-191DH to 4080H-40A6H, as the ROM's own power-up code does. This routine decides where BASIC's memory ends, proves that RAM exists at that address, and sets MEMSIZ and STKTOP.
Everything from 64CAH through 65AFH runs only once. At 6502H this address becomes BASIC's keyboard input buffer, and every line BASIC reads afterward is stored over this code. The ROM line-input routine accepts up to 240 characters plus a 00H terminator, so the buffer occupies 64CAH-65BAH at most. The three bytes 3AH, 00H, 2CH at 64C7H-64C9H, immediately in front of it, are the same three bytes the ROM's power-up code places at 41E5H-41E7H in front of its own default buffer at 41E8H.
64CA
LD HL,0000H 21 00 00
Load Register Pair HL with the requested top of BASIC memory, the operand at 64CBH-64CCH. The file holds 0000H, meaning no top of memory was requested; the entry code overwrites it at 66CEH with the parsed value.
64CD
LD A,H 7C
Load Register A with Register H, the high byte of the requested top of memory, so that the next instruction can test all of Register Pair HL for zero.
64CE
OR L B5
OR Register L (the low byte of the requested top of memory) into Register A. If Register Pair HL is 0000H because no top of memory was requested, the Z FLAG is set; otherwise the NZ FLAG is set.
64CF
LD DE,(4049H) ED 5B 49 40
Fetch the DOS top-of-memory address from 4049H-404AH into Register Pair DE. This is the highest RAM address the DOS makes available to programs, and BASIC is not allowed to go above it. LD does not change the flags, so the Z/NZ result of the OR is still in effect.
64D3
If the NZ FLAG (Not Zero) has been set because a top of memory was requested, JUMP to 64D7H to check the requested address in Register Pair HL against the DOS top of memory in Register Pair DE.
64D5
LD H,D 62
No top of memory was requested, so BASIC uses the DOS limit. Load Register H with Register D, the high byte of the DOS top-of-memory address from 4049H.
64D6
LD L,E 6B
Load Register L with Register E, the low byte of the DOS top-of-memory address. Register Pair HL now holds the same address as Register Pair DE, so the comparison that follows finds them equal.
Limit Check
Register Pair HL holds the top of memory BASIC will use and Register Pair DE holds the DOS top of memory from 4049H. The top of memory BASIC uses must not be higher than the DOS limit.
64D7
LD A,D 7A
Load Register A with Register D, the high byte of the DOS top-of-memory address.
64D8
CP H BC
Compare Register A (high byte of the DOS top of memory) against Register H (high byte of the top of memory BASIC will use). If Register A is lower, the CARRY FLAG is set. If they are equal, the Z FLAG is set.
64D9
If the NZ FLAG (Not Zero) has been set because the high bytes differ, the CARRY FLAG from this comparison already decides the result, so JUMP to 64DDH to act on it.
64DB
LD A,E 7B
The high bytes are equal. Load Register A with Register E, the low byte of the DOS top-of-memory address.
64DC
CP L BD
Compare Register A (low byte of the DOS top of memory) against Register L (low byte of the top of memory BASIC will use). If Register A is lower, the CARRY FLAG is set.
64DD
If the CARRY FLAG has been set, the requested top of memory is above the DOS top of memory at 4049H, so JUMP to 57C9H. 57C9H holds JP 402DH, the NEWDOS/80 No-Error Exit, which abandons BASIC and returns to DOS READY.
RAM Test
The top-of-memory address in Register Pair HL is within the DOS limit. Now confirm that a writable RAM byte exists at that address.
64E0
LD B,(HL) 46
Fetch the byte currently stored at the top-of-memory address in Register Pair HL into Register B, so it can be put back after the write test.
64E1
LD A,D9H 3E D9
Load Register A with the test pattern D9H for the RAM test.
64E3
LD (HL),A 77
Store the test pattern D9H (Register A) to the top-of-memory address in Register Pair HL.
64E4
CP (HL) BE
Compare Register A (the D9H pattern) with the byte read back at Register Pair HL. If RAM exists there and kept the pattern, the Z FLAG is set.
64E5
If the NZ FLAG (Not Zero) has been set because the pattern did not read back, there is no RAM at the top-of-memory address, so JUMP to 57C9H (JP 402DH, the NEWDOS/80 No-Error Exit) to return to DOS READY.
64E8
LD (HL),B 70
Store the original byte (Register B, saved at 64E0H) back to the top-of-memory address in Register Pair HL, undoing the test.
Set The BASIC Memory Pointers
Register Pair HL holds the verified top of memory.
64E9
LD (40B1H),HL 22 B1 40
Store the verified top of memory (Register Pair HL) to MEMSIZ at 40B1H-40B2H, the highest RAM address BASIC may use.
64EC
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, which is -50 in 16-bit two's complement. BASIC starts with 50 bytes of string space, the same default the ROM's power-up routine uses.
64EF
ADD HL,DE 19
Add Register Pair DE (-50) to Register Pair HL (the top of memory), giving the top of memory minus 50.
64F0
LD (40A0H),HL 22 A0 40
Store Register Pair HL (the top of memory minus 50) to STKTOP at 40A0H-40A1H. String space runs from MEMSIZ down to this address, and BASIC's stack is built immediately below it.
64F3H - Initialization: Sign-On Message, Line Number, Input Buffer and BREAK Vectors
With the memory pointers set, display the NEWDOS/80 Disk BASIC sign-on message, set the current line number, make 64CAH BASIC's keyboard input buffer, and set the vector at 4312H and the operand at 6421H according to bit 6 of the NEWDOS/80 flag byte at 436CH.
64F3
LD HL,675CH 21 5C 67
Point Register Pair HL to the sign-on message at 675CH: 1CH (home cursor) and 1FH (clear to end of frame), which together clear the screen, then DISK BASIC. RADIO SHACK'S ROM ENHANCED WITH, a line feed (0AH), APPARAT'S NEWDOS80 EXTENDED AND DISK FEATURES., a line feed, and the carriage return (0DH) at 67BAH that ends the message.
64F6
GOSUB to the NEWDOS/80 SYS0 routine at 4467H: Send message to the display. It sends each byte of the string at Register Pair HL (the sign-on message at 675CH) to the display until it reaches a 0DH or 03H; the 0DH at 67BAH ends this message.
64F9
LD HL,FFFEH 21 FE FF
Load Register Pair HL with FFFEH. This is neither a program line number (0-65529) nor FFFFH, the direct-mode value that the ROM command loop at 1A33H stores when BASIC reaches command level.
64FC
LD (40A2H),HL 22 A2 40
Store FFFEH (Register Pair HL) to CURLIN at 40A2H-40A3H, the currently executing line number. It keeps this value until the ROM command loop sets FFFFH.
64FF
LD HL,64CAH 21 CA 64
Point Register Pair HL to 64CAH, the start of this initialization code, which becomes BASIC's keyboard input buffer from here on.
6502
LD (40A7H),HL 22 A7 40
Store 64CAH (Register Pair HL) to BUFPNT at 40A7H-40A8H, the pointer to the keyboard input buffer. The ROM line-input routine INLIN (0361H) stores each typed line starting at this address, up to 240 characters plus a 00H terminator (64CAH-65BAH at most).
6505
LD HL,4369H 21 69 43
Point Register Pair HL to 4369H, a NEWDOS/80 system flag byte whose bit 6 is the operation-in-progress flag shared with the interrupt handler.
6508
RES 7,(HL) CB BE
Clear bit 7 of the NEWDOS/80 system flag byte at 4369H (Register Pair HL). Register Pair HL still holds 4369H.
650A
LD A,(436CH) 3A 6C 43
Fetch the NEWDOS/80 system flag byte at 436CH into Register A. Bit 7 of this byte indicates whether disk I/O is allowed; bit 6 is tested next.
650D
BIT 6,A CB 77
Test bit 6 of the 436CH flag byte in Register A. If the bit is 0, the Z FLAG is set; if it is 1, the NZ FLAG is set.
650F
LD A,C9H 3E C9
Load Register A with C9H, the RET opcode, as the value for 4312H. LD does not change the flags, so the result of the BIT test is still in effect.
6511
If the Z FLAG (Zero) has been set because bit 6 of 436CH is 0, JUMP to 6519H to store the RET opcode (C9H) at 4312H, leaving the operand at 6421H at its file value of 00H.
6513
LD A,H 7C
Bit 6 of 436CH is 1. Load Register A with Register H, which still holds 43H, the high byte of the 4369H pointer loaded at 6505H.
6514
LD (6421H),A 32 21 64
Self-Modifying Code
Store 43H (Register A) to 6421H, the operand of the OR 00H instruction at 6420H. With the file value 00H, the code at 6420H-6429H tests bit 5 of 4369H and, when that bit is 0, jumps to ROM 035BH (the keyboard scan entry that bypasses the Disk BASIC link at 41C4H). With 43H there, the OR always gives a non-zero result, so the JR NZ,642CH at 6422H is always taken and that test and jump are skipped.
6517
LD A,C3H 3E C3
Load Register A with C3H, the JP opcode, as the value for 4312H.
6519
LD (4312H),A 32 12 43
Store Register A to 4312H, the opcode byte of the NEWDOS/80 SYS0 vector at 4312H-4314H: C9H (RET) when bit 6 of 436CH is 0, so that a transfer to 4312H returns at once, or C3H (JP) when bit 6 is 1, so that it continues to the address held at 4313H-4314H.
651CH - Initialization: Install the Disk BASIC Link Table
Copy BASIC/CMD's 147-byte link table from 67BBH-684DH over the link area at 4152H-41E4H. The ROM's power-up code fills the 28 Disk BASIC statement links at 4152H-41A5H with JP 012DH (?L3 ERROR) and the 21 DOS links at 41A6H-41E4H with RET. After this copy each slot holds a JP into BASIC/CMD or the ROM, except 41A6H, the error message link, which receives LD A,2FH / RST 28H. Two of the links matter later in this code: 41AFH, the keyboard line-input link called from 0368H inside INLIN, becomes JP 575DH, and 41BBH, the NEW/END close-files link, becomes JP 5FB6H. Interrupts stay disabled from here until the stack has been moved at 6530H.
651C
LD HL,67BBH 21 BB 67
Point Register Pair HL to 67BBH, the source: BASIC/CMD's link table, 49 three-byte entries occupying 67BBH-684DH.
651F
LD DE,4152H 11 52 41
Point Register Pair DE to 4152H, the destination: the first Disk BASIC statement link.
6522
LD BC,0093H 01 93 00
Load Register Pair BC with 0093H (147), the byte count: 49 slots of 3 bytes, 4152H-41E4H.
6525
DI F3
Disable interrupts, so no interrupt-driven code runs while the link vectors are only partly written or while the Stack Pointer is being moved at 6530H.
6526
LDIR ED B0
Block move 147 bytes from 67BBH-684DH (source Register Pair HL) to 4152H-41E4H (destination DE), incrementing, until Register Pair BC reaches zero. On exit Register Pair HL = 684EH, Register Pair DE = 41E5H and Register Pair BC = 0000H.
6528
LD A,03H 3E 03
Self-Modifying Code
The operand at 6529H is the number of file buffers. The file holds 03H. The entry code overwrites it at 6726H with the file count (0-15) typed on the command line, or at 6747H with the count recovered from the resident program's position when BASIC is started with an asterisk. Load Register A with the number of file buffers.
652A
LD (5F89H),A 32 89 5F
Store the number of file buffers (Register A) to 5F89H. 5F89H is the operand of the CP 00H at 5F88H, which rejects file numbers higher than this count, and is the count fetched at 5FB6H by the close-all-files routine. Register A keeps the count for the test at 6534H.
652DH - Initialization: Clear the File Control Block Table
Zero one file control block per file buffer, starting at 66BEH. The program entry code at 66BEH has finished, so the table is written over it. Each block is the size held at 64C5H-64C6H: 012DH (301 bytes) as set by the entry code at 6711H, 022DH (557 bytes) when the file count on the command line was followed by V (set at 6730H), or the previous session's size, left unchanged, when BASIC is started with an asterisk. Register A holds the number of file buffers from 6528H.
652D
LD HL,66BEH 21 BE 66
Point Register Pair HL to 66BEH, the start of the file control block table (file 1's block).
6530
LD SP,6534H 31 34 65
Load the Stack Pointer with 6534H. The stack now grows downward from 6534H over the bytes of this initialization code that have already executed, so no RAM outside BASIC/CMD is disturbed while the table and the program area are set up.
6533
EI FB
Enable interrupts. The link table is complete and the stack is in place.
6534
OR A B7
Set the flags from Register A, the number of file buffers stored at 652AH. If it is zero, the Z FLAG is set.
6535
If the Z FLAG (Zero) has been set because BASIC was started with no file buffers, JUMP to 6548H. There is no table to clear, and Register Pair HL (66BEH) is already the address for the zero byte that precedes the program.
Loop Start
Outer loop: once per file buffer. Register Pair HL points to the first byte of the block to clear.
6537
EX AF,AF' 08
Exchange AF with the alternate AF, saving the remaining file count in A' while Register A is used by the byte loop.
6538
LD BC,(64C5H) ED 4B C5 64
Fetch the file control block size from 64C5H-64C6H into Register Pair BC as the byte count for this block.
Loop Start
Inner loop: once per byte of the block.
653C
LD (HL),00H 36 00
Store 00H to the current byte of the file control block at Register Pair HL.
653E
DEC BC 0B
DECrement the remaining byte count in Register Pair BC by 1.
653F
INC HL 23
INCrement Register Pair HL to the next byte of the table.
6540
LD A,B 78
Load Register A with Register B, the high byte of the remaining byte count.
6541
OR C B1
OR Register C (the low byte of the remaining byte count) into Register A. If Register Pair BC is 0000H, this block is finished and the Z FLAG is set.
6542
If the NZ FLAG (Not Zero) has been set because bytes remain in this block, LOOP BACK to 653CH to clear the next byte.
Loop End
Inner loop.
6544
EX AF,AF' 08
Exchange AF with the alternate AF, bringing the remaining file count back into Register A.
6545
DEC A 3D
DECrement the remaining file count in Register A by 1. If it reaches zero, the Z FLAG is set.
6546
If the NZ FLAG (Not Zero) has been set because more blocks remain, LOOP BACK to 6537H to clear the next one. Register Pair HL already points to its first byte.
Loop End
Outer loop. Register Pair HL points one byte past the last file control block.
6548H - Initialization: Set the Program Start, Check Workspace, and Perform NEW
Register Pair HL points one byte past the file control block table (66BEH when there are no file buffers). BASIC requires a 00H byte immediately in front of the first program line, so that byte goes here and the program text area begins at the next address. BASIC then requires at least 300 bytes between the program start and the top of memory, and calls the ROM's NEW code to set up an empty program and clear the variables.
6548
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte after the file control block table. This is the zero byte that must come immediately before the first line of program text.
654A
INC HL 23
INCrement Register Pair HL to the first byte of the BASIC program area.
654B
LD (40A4H),HL 22 A4 40
Store Register Pair HL to TXTTAB at 40A4H-40A5H, the pointer to the start of BASIC program text.
654E
LD DE,012CH 11 2C 01
Load Register Pair DE with 012CH (300), the minimum workspace BASIC requires above the program start.
6551
ADD HL,DE 19
Add Register Pair DE (300) to Register Pair HL (the program start), giving the lowest acceptable top of memory.
6552
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL. Register Pair DE now holds the program start plus 300.
6553
LD HL,(40B1H) 2A B1 40
Fetch MEMSIZ, the top of memory stored at 64E9H, from 40B1H-40B2H into Register Pair HL.
6556
RST 18H DF
RST 18H compares Register Pair HL (MEMSIZ) with Register Pair DE (the program start plus 300). If MEMSIZ is lower, the CARRY FLAG is set.
6557
If the CARRY FLAG has been set because fewer than 300 bytes lie between the program start and the top of memory (too many or too large file buffers for the memory available), JUMP to 57C9H (JP 402DH, the NEWDOS/80 No-Error Exit) to return to DOS READY.
655A
CALL 1B4DH CD 4D 1B
GOSUB to ROM routine SCRTCH at 1B4DH, the working part of NEW. It turns TRACE off, clears the AUTO flag, writes 00H 00H at the program start held in 40A4H, sets VARTAB (40F9H) two bytes above it, then runs CLEARC: variable types default to single precision, FRETOP is set to MEMSIZ, the DATA pointer is reset, ARYTAB and STREND are set to VARTAB, and the close-files link at 41BBH (now JP 5FB6H) is called. It finishes in STKINI, which rebuilds the stack below STKTOP (40A0H) and returns here on the new stack.
655DH - Startup Command Dispatch
Decide what BASIC does first, from the text that followed BASIC and its numeric parameters on the DOS command line. If that text begins with an asterisk, BASIC was restarted with the previous session's program still in memory: the program's first link word and its end address, both saved by the entry code before NEW erased them, are put back, and the command text at 54E9H is queued. If there is any other text, it is queued as the first direct command. If the command line ended there (0DH), BASIC goes straight to READY. A queued command is delivered by placing 6589H in the vector at 5205H-5206H.
655D
LD HL,0000H 21 00 00
Self-Modifying Code
The operand at 655EH-655FH is the startup command pointer. The file holds 0000H; the entry code stores the real value at 674BH: the address of the asterisk when BASIC is started with an asterisk, otherwise the address of the first non-blank character after the numeric parameters, which is the 0DH at the end of the command line when nothing else was typed. Load Register Pair HL with the startup command pointer.
6560
LD A,(HL) 7E
Fetch the first character of the startup command text, at Register Pair HL, into Register A.
6561
CP 2AH FE 2A
Compare Register A against 2AH (an asterisk). If Register A equals 2AH, the Z FLAG is set; otherwise the NZ FLAG is set.
6563
If the NZ FLAG (Not Zero) has been set because the startup text does not begin with an asterisk, JUMP to 657CH to test for an empty command.
Restart With Program Intact
BASIC was started with an asterisk. SCRTCH, called at 655AH, zeroed the first line's link word and moved VARTAB. The entry code saved both values before that call.
6565
LD BC,0000H 01 00 00
Self-Modifying Code
The operand at 6566H-6567H is written at 66DDH with the resident program's first link word (the address of its second line), read from the program start before NEW. It stays 0000H when the resident program is empty. Load Register Pair BC with the saved link word.
6568
LD HL,(40A4H) 2A A4 40
Fetch TXTTAB, the program start stored at 654BH, from 40A4H-40A5H into Register Pair HL. This is where SCRTCH wrote 00H 00H.
656B
LD (HL),C 71
Store Register C, the low byte of the saved link word, at Register Pair HL, the program start, replacing the 00H written by SCRTCH.
656C
INC HL 23
INCrement Register Pair HL to the second byte of the first line's link word.
656D
LD (HL),B 70
Store Register B, the high byte of the saved link word, at Register Pair HL. The resident program's line chain is intact again.
656E
LD HL,0000H 21 00 00
Self-Modifying Code
Load Register Pair HL with the resident program's VARTAB; the operand 0000H at 656FH-6570H is written at 66E7H with VARTAB read from 40F9H before NEW.
6571
CALL 1B5AH CD 5A 1B
GOSUB to ROM 1B5AH, the instruction inside SCRTCH that stores Register Pair HL into VARTAB (40F9H). VARTAB becomes the resident program's end address, and the code continues through RUNC and CLEARC, clearing the variables above the restored program, and through STKINI, which rebuilds the stack below STKTOP and returns here.
6574
LD HL,54E9H 21 E9 54
Point Register Pair HL to 54E9H, the command text queued for an asterisk start. 54E9H lies in 5200H-56FFH, outside BASIC/CMD. The code at 6597H-65A5H copies this text, up to and including its 0DH, into the input buffer.
6577
LD (655EH),HL 22 5E 65
Store 54E9H (Register Pair HL) to 655EH-655FH, the startup command pointer (the operand of the LD HL at 655DH), which the code at 6597H reads.
657A
JUMP to 6580H to install the hook and enter BASIC's command level.
No Asterisk Prefix
Register A holds the first character of the startup command text.
657C
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If the startup text is only the 0DH that ends the command line, the Z FLAG is set.
657E
If the Z FLAG (Zero) has been set because no startup command was typed, JUMP to 6586H to enter BASIC's command level without installing the hook.
Queue The Startup Command
The operand at 655EH-655FH points to the command text.
6580
LD HL,6589H 21 89 65
Point Register Pair HL to 6589H, the startup command hook.
6583
LD (5205H),HL 22 05 52
Store 6589H (Register Pair HL) to 5205H-5206H, replacing the vector's normal content, 0033H, which the hook puts back at 658DH. The hook at 6589H runs when BASIC's direct-mode line input passes through this vector: the ROM command loop calls INLIN (0361H), INLIN calls its DOS link at 41AFH (JP 575DH), and 575DH, finding the command loop's return address 1A7EH on the stack, dispatches SVC 34H with a return to 5202H.
6586
JP 1A19H C3 19 1A
JUMP to ROM READY at 1A19H, which displays READY and enters the command loop at 1A33H. The command loop sets CURLIN (40A2H) to FFFFH and calls INLIN (0361H) for a line of input.
6589H - Startup Command Hook
Reached through the vector at 5205H-5206H installed at 6583H, on BASIC's direct-mode line-input path: the ROM command loop has called INLIN (0361H), INLIN has called its DOS link at 41AFH, and 575DH has verified the command loop's return address 1A7EH and dispatched SVC 34H to continue at 5202H. This code runs once. It restores the vector to 0033H, erases the READY message from the screen, copies the startup command into the input buffer at 64CAH, and leaves through INLIN's own exit code at 0379H, so the command loop receives the command exactly as if it had been typed and ENTER pressed.
6589
POP HL E1
Restore Register Pair HL from the stack, removing the word left there by the transfer through 5205H. The word beneath it is 1A7EH, the return address into the ROM command loop that 575DH verified, which INLIN's exit code will return to.
658A
LD HL,0033H 21 33 00
Load Register Pair HL with 0033H, the vector's normal content (the address of the ROM display-character routine).
658D
LD (5205H),HL 22 05 52
Store 0033H (Register Pair HL) to 5205H-5206H, removing the hook so that it runs only once.
6590
PUSH BC C5
Save Register Pair BC onto the stack. INLIN pushes Register Pair BC at its start and its exit code at 0379H pops it, so this PUSH stands in for INLIN's.
6591
LD HL,65ACH 21 AC 65
Point Register Pair HL to the screen control string at 65ACH: 1DH, 1BH, 1FH, ended by 03H.
6594
GOSUB to the NEWDOS/80 SYS0 routine at 4467H: Send message to the display. 1DH moves the cursor to the beginning of the input line, 1BH moves it up one line to where READY was displayed, and 1FH clears from there to the end of the screen. The 03H ends the string.
6597
LD DE,(655EH) ED 5B 5E 65
Fetch the startup command pointer from 655EH-655FH (stored at 674BH, or at 6577H for an asterisk start) into Register Pair DE as the copy source.
659B
LD HL,(40A7H) 2A A7 40
Fetch BUFPNT, the input buffer address 64CAH stored at 6502H, from 40A7H-40A8H into Register Pair HL as the copy destination.
Loop Start
Copy the command text, including its terminating 0DH, into the input buffer.
659E
LD A,(DE) 1A
Fetch the next character of the startup command text, at Register Pair DE, into Register A.
659F
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If this is the end of the command text, the Z FLAG is set.
65A1
LD (HL),A 77
Store the character in Register A to the input buffer at Register Pair HL. The final 0DH is stored as well. LD does not change the flags.
65A2
INC DE 13
INCrement Register Pair DE to the next source character. INC of a register pair does not change the flags.
65A3
INC HL 23
INCrement Register Pair HL to the next input buffer position.
65A4
If the NZ FLAG (Not Zero) has been set because the character copied was not 0DH, LOOP BACK to 659EH to copy the next one.
Loop End
Register Pair HL points one byte past the 0DH stored in the buffer.
65A6
XOR A AF
Set Register A to ZERO and clear all flags, including the CARRY FLAG.
65A7
PUSH AF F5
Save Register Pair AF (Register A = 00H, the CARRY FLAG clear) on the stack. INLIN's exit code pops this as the result of its keyboard input; the CARRY FLAG clear means the line was ended with ENTER, not BREAK.
65A8
DEC HL 2B
DECrement Register Pair HL to the 0DH stored at the end of the command in the input buffer.
65A9
JP 0379H C3 79 03
JUMP into ROM INLIN at 0379H, its exit code. It stores 00H over the 0DH at Register Pair HL to end the line, reloads Register Pair HL with the buffer start from 40A7H, pops AF (A = 00H, CARRY clear) and Register Pair BC, backs Register Pair HL up one byte for RST 10H, and returns to the ROM command loop at 1A7EH, which tokenizes and executes the command.
65ACH - Screen Control String (Data)
The four-byte string displayed at 6594H through SYS0 routine 4467H. It is data, not code, and is the last part of the load block that begins at 64C7H. The load file contains nothing for 65B0H-65C8H.
65AC-65AF
DEFB 1DH, 1BH, 1FH, 03H 1D 1B 1F 03
1DH moves the cursor to the beginning of the current line, 1BH moves it up one line, 1FH clears to the end of the frame, and 03H ends the string for 4467H.
65C9H - Flag Byte and Unreferenced Bytes (Data)
The first six bytes of the load block that begins at 65C9H. They are data, not code.
65C9
DEFB 00H 00
Flag byte, 00H in the file. The code at 6451H stores 00H here; no instruction in BASIC/CMD reads it.
65CA-65CC
DEFB 00H, 00H, 00H 00 00 00
Three 00H bytes. No instruction in BASIC/CMD reads or writes 65CAH-65CCH.
65CD-65CE
DEFB 2AH,2AH 2A 2A
Two ASCII asterisks (2AH 2AH). No instruction in BASIC/CMD reads or writes 65CDH-65CEH, and they are not executed; the routine that follows begins at 65CFH.
65CFH - Advance the Text Pointer and Test for an Equals Sign
Advances Register Pair HL by one byte and tests the character there for =. Entry: HL points one byte before the character to test. Exit: HL points to the character, Register A holds it, and the Z FLAG is set if it is =. No instruction in BASIC/CMD calls this routine.
65CF
INC HL 23
INCrement Register Pair HL, the caller's text pointer, to the next character.
65D0
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
65D1
CP 3DH FE 3D
Compare Register A against 3DH (ASCII: =). If Register A equals 3DH, the Z FLAG is set; otherwise the NZ FLAG is set.
65D3
RET C9
Return to the caller with Register Pair HL pointing to the character, the character in Register A, and the Z FLAG set if it is =.
65D4H - Fetch File Block Byte +12H With BC Preserved
Called from 6208H with Index Register IX pointing to a file's block. Calls 61E1H, which returns byte +12H of the block in Register C, the word at 5717H-5718H in HL, the word at 5719H-571AH in DE and the byte at 5715H in A, then moves byte +12H into Register A and restores Register Pair BC, which 61E1H would otherwise change.
65D4
PUSH BC C5
Save Register Pair BC (the caller's value) onto the stack, because 61E1H returns a value in Register C.
65D5
GOSUB to 61E1H. It returns Register C = byte +12H of the block at Index Register IX, Register Pair HL = the word at 5717H-5718H and Register Pair DE = the word at 5719H-571AH (stored at 60FEH and 6112H), and Register A = the byte at 5715H.
65D8
LD A,C 79
Load Register A with Register C, byte +12H of the block at Index Register IX, replacing the 5715H byte that 61E1H left in A.
65D9
POP BC C1
Restore Register Pair BC with the caller's value.
65DA
RET C9
Return to 6208H with A = byte +12H of the block, Register Pair HL = the word from 5717H, Register Pair DE = the word from 5719H and Register Pair BC unchanged. The caller subtracts byte +15H of the block from A and then Register Pair DE from Register Pair HL with the borrow, one 24-bit comparison.
65DBH - Get the File Control Block Size
Called from 5FC1H in the close-all-files routine at 5FB6H, which steps through the file control block table at 66BEH one block at a time.
65DB
LD DE,(64C5H) ED 5B C5 64
Fetch the file control block size from 64C5H-64C6H into Register Pair DE: 012DH (301), 022DH (557) when BASIC was started with V after the file count, or the previous session's size after an asterisk start.
65DF
RET C9
Return to 5FC4H with the block size in Register Pair DE. The caller adds Register Pair DE to Register Pair HL to step from one file's block to the next.
65E0H - Set Bit 7 of File Block Byte +04H
Sets bit 7 of byte +04H of the block that Index Register IX points to. No instruction in BASIC/CMD calls this routine.
65E0
SET 7,(IX+04H) DD CB 04 FE
Set bit 7 of byte +04H of the block at Index Register IX.
65E4
RET C9
RETurn to the caller with bit 7 of byte +04H set at Index Register IX+04H.
65E5H - Scan the 4200H Table for a Matching Word
If the caller's flags are NZ, report ?FC ERROR. Otherwise compare the word at +05H-+06H of the block that Index Register IX points to with the word at +05H-+06H of each 17H-byte (23-byte) entry of the table at 4200H, starting with the first entry when the byte at 5102H is 00H and with the second entry (4217H) otherwise, and set bit 6 of the block's byte +04H for each match. The scan continues while byte +00H of the next entry is less than Register C. No instruction in BASIC/CMD calls this routine.
65E5
JP NZ,1E4AH C2 4A 1E
If the NZ FLAG (Not Zero) has been set by the caller, JUMP to ROM FCERR at 1E4AH, which reports ?FC ERROR (Illegal Function Call).
65E8
LD A,(5102H) 3A 02 51
Load Register A with the byte at 5102H, in the overlay area.
65EB
OR A B7
Set the flags from Register A. If the byte at 5102H is 00H, the Z FLAG is set.
65EC
LD IY,4200H FD 21 00 42
Point Index Register IY to 4200H, the first entry of the table. LD does not change the flags.
65F0
If the Z FLAG (Zero) has been set because the byte at 5102H is 00H, JUMP to 65F6H to start the scan at 4200H.
65F2
LD IY,4217H FD 21 17 42
Point Index Register IY to 4217H, the second entry of the table, so the scan starts there.
65F6
PUSH HL E5
Save Register Pair HL (the caller's value) onto the stack.
65F7
LD L,(IX+05H) DD 6E 05
Load Register L with byte +05H of the block at Index Register IX, the low byte of the word to match.
65FA
LD H,(IX+06H) DD 66 06
Load Register H with byte +06H of the block at Index Register IX. Register Pair HL now holds the block's word at +05H-+06H.
Loop Start
One pass per table entry. Index Register IY points to the entry.
65FD
LD E,(IY+05H) FD 5E 05
Load Register E with byte +05H of the table entry at Index Register IY.
6600
LD D,(IY+06H) FD 56 06
Load Register D with byte +06H of the table entry at Index Register IY+06H. Register Pair DE now holds the entry's word at +05H-+06H.
6603
RST 18H DF
RST 18H compares Register Pair HL (the block's word) with Register Pair DE (the entry's word). If they are equal, the Z FLAG is set.
6604
If the NZ FLAG (Not Zero) has been set because the words differ, JUMP to 660AH to advance to the next entry.
6606
SET 6,(IX+04H) DD CB 04 F6
The words match. Set bit 6 of byte +04H of the block at Index Register IX.
660A
LD DE,0017H 11 17 00
Load Register Pair DE with 0017H (23), the length of one table entry.
660D
ADD IY,DE FD 19
Add Register Pair DE (23) to Index Register IY, advancing to the next table entry.
660F
LD A,(IY+00H) FD 7E 00
Load Register A with byte +00H of the next table entry at Index Register IY+00H.
6612
CP C B9
Compare Register A against Register C, the limit supplied by the caller. If byte +00H of the entry is less than Register C, the CARRY FLAG is set.
6613
If the CARRY FLAG has been set, LOOP BACK to 65FDH to compare this entry.
Loop End
6615
POP HL E1
Restore Register Pair HL with the caller's value.
6616
RET C9
Return to the caller. Bit 6 of byte +04H of the block at Index Register IX is set if any scanned entry matched.
6617H - Store Register A at 4F02H Unless File Block Byte +04H Bit 6 Is Set
Tests bit 6 of byte +04H of the block that Index Register IX points to (the bit set at 6606H). When it is clear, Register A is stored at 4F02H. No instruction in BASIC/CMD calls this routine.
6617
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of byte +04H of the block at Index Register IX. If it is 1, the NZ FLAG is set.
661B
RET NZ C0
If the NZ FLAG (Not Zero) has been set because bit 6 is 1, return to the caller without storing.
661C
LD (4F02H),A 32 02 4F
Store Register A at 4F02H, in the overlay area.
661F
RET C9
RETurn to the caller with Register A stored at 4F02H.
6620H - Load File Block Byte +13H and, When Byte +04H Bit 6 Is Set, Add BC to HL
Loads Register E with byte +13H of the block that Index Register IX points to. If bit 6 of the block's byte +04H is set, it also discards the top word of the stack and adds Register Pair BC to HL before returning, so that when it was entered by CALL it returns to the caller's caller. No instruction in BASIC/CMD calls this routine.
6620
LD E,(IX+13H) DD 5E 13
Load Register E with byte +13H of the block at Index Register IX.
6623
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of byte +04H of the block at Index Register IX. If it is 0, the Z FLAG is set.
6627
RET Z C8
If the Z FLAG (Zero) has been set because bit 6 is 0, return to the caller with Register E loaded.
6628
POP AF F1
Bit 6 is 1. POP the top word of the stack into Register Pair AF, removing it. When this routine is entered by CALL, that word is its return address, and the RET below goes to the address beneath it.
6629
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, then return to the caller's caller.
662A
RET C9
Return to the caller's caller with Register Pair HL increased by Register Pair BC.
662BH - Add DE to HL B Times Unless File Block Byte +04H Bit 6 Is Set
If bit 6 of byte +04H of the block that Index Register IX points to is clear, adds Register Pair DE to HL, Register B times (256 times when B is 00H), leaving B at 00H. No instruction in BASIC/CMD calls this routine.
662B
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of byte +04H of the block at Index Register IX. If it is 1, the NZ FLAG is set.
662F
RET NZ C0
If the NZ FLAG (Not Zero) has been set because bit 6 is 1, return to the caller with Register Pair HL unchanged.
Loop Start
6630
ADD HL,DE 19
Add Register Pair DE to Register Pair HL, once for each count in Register B.
6631
DECrement Register B and LOOP BACK to 6630H if it is not zero.
Loop End
6633
RET C9
Return to the caller with Register Pair HL increased by Register Pair DE times the entry value of B.
6634H - Store H at File Block +0AH and Move a Block Downward in Memory
Stores Register H at byte +0AH of the block that Index Register IX points to. Then, unless bit 6 of the block's byte +04H is set, moves the BC bytes that end just below the entry value of DE so that they end just below the entry value of HL plus BC, working from the highest byte down. Entry: HL = destination start, DE = address just past the source, BC = byte count. Exit: A = 00H with the Z FLAG set, unless bit 6 was set. No instruction in BASIC/CMD calls this routine.
6634
LD (IX+0AH),H DD 74 0A
Store Register H (the high byte of the destination start) to byte +0AH of the block at Index Register IX.
6637
ADD HL,BC 09
Add Register Pair BC (the byte count) to Register Pair HL, giving the address just past the destination.
6638
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL. Register Pair DE now holds the address just past the destination, and Register Pair HL holds the address just past the source.
6639
BIT 6,(IX+04H) DD CB 04 76
Test bit 6 of byte +04H of the block at Index Register IX. If it is 1, the NZ FLAG is set.
663D
RET NZ C0
If the NZ FLAG (Not Zero) has been set because bit 6 is 1, return to the caller without moving anything.
663E
LD A,B 78
Load Register A with Register B, the high byte of the byte count.
663F
OR C B1
OR Register C (the low byte of the byte count) into Register A. If the count is 0000H, the Z FLAG is set.
6640
If the Z FLAG (Zero) has been set because the byte count is zero, JUMP to 6646H; there is nothing to move.
6642
DEC HL 2B
DECrement Register Pair HL to the last byte of the source.
6643
DEC DE 1B
DECrement Register Pair DE to the last byte of the destination.
6644
LDDR ED B8
Block move Register Pair BC bytes from the source (HL) to the destination (DE), decrementing, from the highest byte down, so that an overlapping destination above the source is filled correctly.
6646
XOR A AF
Set Register A to ZERO and clear all flags (the Z FLAG is set).
6647
RET C9
RETurn to the caller with Register A = 00H and the Z FLAG set.
6648H - Evaluate a String Argument, Then Continue at 4DE4H and 4E17H
Evaluates the expression at the BASIC text pointer through 664FH, which passes control to 4DE4H; when 4DE4H returns, execution resumes at 664BH, which pushes HL and continues at 4E17H. 4DE4H and 4E17H are in the overlay area at 4D00H-51FFH. No instruction in BASIC/CMD calls 6648H.
6648
GOSUB to 664FH to evaluate the expression at the text pointer (Register Pair HL). 664FH leaves this CALL's return address, 664BH, on top of the stack when it passes control to 4DE4H, so 4DE4H's RET comes back to 664BH.
664B
PUSH HL E5
Save Register Pair HL, as returned from 4DE4H, onto the stack.
664C
JP 4E17H C3 17 4E
JUMP to 4E17H in the overlay area with Register Pair HL on the stack.
664FH - Evaluate a String Argument and Continue at 4DE4H
Called from 6648H. Calls 61B7H, which evaluates the expression at the text pointer and, when the result is a string, returns with the Z FLAG set, the string length in Register B and the updated text pointer on the stack. This routine then moves the text pointer beneath its own return address and passes control to 4DE4H in the overlay area.
664F
GOSUB to 61B7H. It calls ROM FRMEVL (2337H) to evaluate the expression at Register Pair HL, places the updated text pointer on the stack beneath its return address, and tests the result type with RST 20H. For a string it calls ROM FRESTR (29D7H) and returns with the Z FLAG set, the string length in Register B and the string address in Register Pair HL; for any other type it returns with the NZ FLAG set.
6652
POP HL E1
Restore Register Pair HL from the stack: the updated text pointer that 61B7H left there.
6653
EX (SP),HL E3
Exchange Register Pair HL with the word at the Stack Pointer. The text pointer goes onto the stack in place of this routine's return address (664BH when called from 6648H), which comes into Register Pair HL.
6654
PUSH HL E5
Save the return address (Register Pair HL) back onto the stack, above the text pointer. The flags and Register B from 61B7H are unchanged.
6655
JP 4DE4H C3 E4 4D
JUMP to 4DE4H in the overlay area, with the return address on top of the stack and the text pointer beneath it.
6658H - Test A, L and C for Zero
ORs Register L and Register C into Register A. If all three are zero, BASIC error 64 is reported through 5DD9H; otherwise the routine returns with Register A holding the value of C and the flags set from it. No instruction in BASIC/CMD calls this routine.
6658
OR L B5
OR Register L into Register A (the caller's value).
6659
OR C B1
OR Register C into Register A. If Registers A, L and C were all zero, the Z FLAG is set.
665A
If the Z FLAG (Zero) has been set, JUMP to 5DD9H, which loads Register A with 7EH and passes it through 5E05H to the ROM error handler at 19A2H as the error offset in Register E: BASIC error 64 (7EH / 2 + 1).
665D
LD A,C 79
Copy Register C, the value checked, into Register A.
665E
OR A B7
Set the flags from Register A (the value of C). If C is zero, the Z FLAG is set.
665F
RET C9
RETurn to the caller with Register A = Register C and the flags set from it.
6660H - Require File Block Byte +00H Bit 2
Called from 5EECH when Register B has bit 1 or bit 2 set (tested at 5EEAH, after the CALL to 5FF0H). Reports BASIC error 55 unless bit 2 of byte +00H of the block that Index Register IX points to is set.
6660
BIT 2,(IX+00H) DD CB 00 56
Test bit 2 of byte +00H of the block at Index Register IX. If it is 0, the Z FLAG is set.
6664
If the Z FLAG (Zero) has been set because bit 2 is 0, JUMP to 5DD0H, which loads Register A with 6CH and passes it through 5E05H to the ROM error handler at 19A2H as the error offset in Register E: BASIC error 55 (6CH / 2 + 1).
6667
RET C9
Bit 2 is set. RETurn to 5EEFH with the NZ FLAG still set.
6668H - Unused Space
84 bytes of 00H between the last routine and the program entry area. No instruction in BASIC/CMD reads, writes or executes them.
6668-66BB
NOP x 84 00 x 84
Unused: 84 bytes of 00H that nothing reads, writes or executes.
66BCH - Unreferenced Bytes Before the Program Entry Point (Data)
The two bytes immediately below the program entry point at 66BEH. They are data, not code.
66BC-66BD
DEFB 2AH,2AH 2A 2A
Two ASCII asterisks (2AH 2AH). No instruction in BASIC/CMD reads or writes 66BCH-66BDH, and they are not executed: the DOS starts BASIC/CMD at its transfer address 66BEH, where LD BC,66C4H (01 C4 66) begins. The file control block table cleared at 653CH starts at 66BEH, so these two bytes are left as they are.
66BEH - Program Entry Point
The DOS transfers control here after loading BASIC/CMD; 66BEH is the load file's transfer address. Register Pair HL, as passed by the DOS, points into the DOS command line just past the program name BASIC. The code from here through 675BH reads the rest of that line, stores what it finds into the initialization code at 64CAH-6589H, and jumps to 64CAH. It runs only once: the file control block table that 653CH clears begins at 66BEH and is written over it.
Two forms of the command line are handled. BASIC followed by an asterisk restarts BASIC with the previous session's program and memory layout still in place. Otherwise BASIC may be followed by numbers separated by commas: 0-15 is the number of file buffers (optionally followed by V for 557-byte blocks), and 256 or more is the memory size. Text that does not begin with a digit, either directly after BASIC or after a comma, ends the parameters and becomes the first command BASIC executes.
66BE
LD BC,66C4H 01 C4 66
Load Register Pair BC with 66C4H, the address at which the dispatcher at 576AH continues when it finishes.
66C1
JUMP to 576AH, which loads Register A with 34H, pushes Register Pair BC (66C4H) as its return address, and, because the CP 00H at 576DH does not match 34H, issues NEWDOS/80 SVC 34H (SYS18, function 1, by the RST 28H encoding) through the RST 28H at 57B5H. It saves and restores Register Pair HL around the SVC and returns to 66C4H. If the SVC reports an error it goes to 5E16H instead.
66C4
DEC HL 2B
DECrement Register Pair HL, the command line pointer passed by the DOS, so that RST 10H, which advances Register Pair HL before reading, examines the first character after the program name.
66C5
RST 10H D7
RST 10H advances Register Pair HL and fetches the next non-blank character of the command line into Register A, skipping spaces. Register Pair HL points to that character. If it is a digit, the CARRY FLAG is set.
66C6
CP 2AH FE 2A
Compare Register A against 2AH (an asterisk). If Register A equals 2AH, the Z FLAG is set; otherwise the NZ FLAG is set.
66C8
If the NZ FLAG (Not Zero) has been set because the first character is not an asterisk, JUMP to 670DH to read the numeric parameters.
Restart With Program Intact
BASIC was started as BASIC with an asterisk. The previous session's program, pointers and file control block size are still in memory. Check that the program is intact, save the two values the NEW at 655AH will destroy, and work out how many file buffers the previous session had from where its program starts: TXTTAB is 66BFH plus the number of buffers times the block size. Any inconsistency sends BASIC back to DOS through 673DH.
66CA
PUSH HL E5
Save Register Pair HL, the address of the asterisk in the command line, onto the stack. It becomes the startup command pointer at 674BH.
66CB
LD HL,(40B1H) 2A B1 40
Fetch MEMSIZ, the previous session's top of BASIC memory, from 40B1H-40B2H into Register Pair HL.
66CE
LD (64CBH),HL 22 CB 64
Self-Modifying Code
Store the previous top of memory (Register Pair HL) to 64CBH-64CCH, the operand of the LD HL at 64CAH, so that initialization keeps the same top of memory.
66D1
LD HL,(40A4H) 2A A4 40
Fetch TXTTAB, the start of the resident program's text, from 40A4H-40A5H into Register Pair HL.
66D4
PUSH HL E5
Save Register Pair HL, TXTTAB, on the stack for the file buffer calculation at 66F5H.
66D5
LD E,(HL) 5E
Load Register E with the low byte of the first line's link word at Register Pair HL (TXTTAB). The link word is the address of the next line, or 0000H when the program is empty.
66D6
INC HL 23
INCrement Register Pair HL to TXTTAB+1, the high byte of the link word.
66D7
LD D,(HL) 56
Load Register D with the high byte of the link word at Register Pair HL. Register Pair DE holds the first line's link word.
66D8
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL. Register Pair HL holds the link word and Register Pair DE holds TXTTAB+1.
66D9
LD A,H 7C
Load Register A with Register H, the high byte of the link word.
66DA
OR L B5
OR Register L (the low byte of the link word) into Register A. If the link word is 0000H because the program is empty, the Z FLAG is set.
66DB
If the Z FLAG (Zero) has been set because the program is empty, JUMP to 66E4H, leaving the operand at 6566H-6567H at its file value of 0000H.
66DD
LD (6566H),HL 22 66 65
Self-Modifying Code
Store the first line's link word (Register Pair HL) to 6566H-6567H, the operand of the LD BC at 6565H, which writes it back over the 00H 00H that NEW leaves at the program start.
66E0
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL. Register Pair HL holds TXTTAB+1 and Register Pair DE holds the link word.
66E1
RST 18H DF
RST 18H compares Register Pair HL (TXTTAB+1) with Register Pair DE (the link word). If TXTTAB+1 is lower, the CARRY FLAG is set.
66E2
If the NO CARRY FLAG has been set because the link word does not point above the program start, the text at TXTTAB is not a valid program, so JUMP to 673DH to return to DOS.
66E4
LD HL,(40F9H) 2A F9 40
Fetch VARTAB, the address just past the end of the resident program, from 40F9H-40FAH into Register Pair HL.
66E7
LD (656FH),HL 22 6F 65
Self-Modifying Code
Store VARTAB (Register Pair HL) to 656FH-6570H, the operand of the LD HL at 656EH, which hands it 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 marker.
66EB
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, VARTAB-1.
66EC
DEC HL 2B
DECrement Register Pair HL to VARTAB-2, the first byte of the end marker.
66ED
OR (HL) B6
OR the byte at Register Pair HL, VARTAB-2, into Register A. If both bytes are 00H, the Z FLAG is set.
66EE
If the NZ FLAG (Not Zero) has been set because the two bytes below VARTAB are not the 00H 00H end marker, JUMP to 673DH to return to DOS.
66F0
RST 18H DF
RST 18H compares Register Pair HL (VARTAB-2, the address of the end marker) with Register Pair DE (the first line's link word, or TXTTAB+1 for an empty program). If Register Pair HL is lower, the CARRY FLAG is set. For an empty program the end marker is at TXTTAB, which is lower than TXTTAB+1.
66F1
If the CARRY FLAG has been set because the end marker lies below the first link target, JUMP to 673DH to return to DOS. An empty program is rejected here.
66F3
OR FFH F6 FF
Set Register A to FFH, so that the loop at 6700H increments it to 00H on its first pass, and clear the CARRY FLAG for the SBC below.
66F5
POP HL E1
Restore TXTTAB (saved at 66D4H) into Register Pair HL.
66F6
LD DE,66BFH 11 BF 66
Load Register Pair DE with 66BFH, the program start when there are no file buffers (66BEH holds the zero byte that precedes the program).
66F9
SBC HL,DE ED 52
Subtract Register Pair DE (66BFH) from Register Pair HL (TXTTAB), with the CARRY FLAG clear, giving the size of the previous session's file control block table: number of buffers times block size.
66FB
LD DE,(64C5H) ED 5B C5 64
Fetch the file control block size from 64C5H-64C6H into Register Pair DE. After BASIC with an asterisk it still holds the previous session's value, because 670EH-6711H are not executed on this path.
66FF
ADD HL,DE 19
Add one block size (Register Pair DE) to Register Pair HL, so that the first pass of the loop subtracts it back off.
Loop Start
Register A counts blocks; each pass subtracts one block size from HL until it reaches zero.
6700
INC A 3C
INCrement the block count in Register A by 1 (to 00H on the first pass).
6701
OR A B7
OR Register A with itself to clear the CARRY FLAG for the SBC below. Register A is unchanged.
6702
SBC HL,DE ED 52
Subtract one block size (Register Pair DE) from Register Pair HL. If Register Pair HL reaches 0000H, the table held exactly Register A blocks and the Z FLAG is set.
6704
If the Z FLAG (Zero) has been set, JUMP to 6747H with the number of file buffers in Register A.
6707
CP 0FH FE 0F
Compare Register A against 0FH (15). If Register A is less than 15, the CARRY FLAG is set.
6709
If the CARRY FLAG has been set, LOOP BACK to 6700H to try one more block.
Loop End
670B
No count from 0 to 15 fits the program start exactly, so the resident memory layout is inconsistent. JUMP to 673DH to return to DOS.
670DH - Read the Numeric Parameters
BASIC was not started with an asterisk. Set the default file control block size, then read numbers separated by commas. A value of 0-15 is the number of file buffers and may be followed by V for 557-byte blocks; a value of 256 or more is the memory size; a value of 16-255 is rejected. A character that is not a digit, where a number could begin, ends the parameters; HL then points to the startup command, or to the 0DH at the end of the line. After a number, only a comma or the ending 0DH may follow; anything else sends BASIC back to DOS. Register Pair HL points to the first non-blank character after BASIC.
670D
DEC HL 2B
DECrement Register Pair HL to the character before the one just tested, so that the RST 10H at 6715H reads it again.
670E
LD BC,012DH 01 2D 01
Load Register Pair BC with 012DH (301), the default size of one file control block.
6711
LD (64C5H),BC ED 43 C5 64
Store 012DH (Register Pair BC) to 64C5H-64C6H, the block size used by the table-clearing loop at 6538H and by 65DBH.
Loop Start
One parameter per pass.
6715
RST 10H D7
RST 10H advances Register Pair HL and fetches the next non-blank character into Register A. If it is a digit, the CARRY FLAG is set.
6716
If the NO CARRY FLAG has been set because the character is not a digit, the parameters are finished and Register Pair HL points to the startup command or to the 0DH at the end of the line, so JUMP to 674BH.
6718
GOSUB to 5CFCH to convert the decimal digits at Register Pair HL into a 16-bit value in Register Pair DE. It returns with Register Pair HL pointing to the first non-digit and the CARRY FLAG set if the value exceeded 65535.
671B
If the CARRY FLAG has been set because the number is larger than 65535, JUMP to 673DH to return to DOS.
671D
LD A,D 7A
Load Register A with Register D, the high byte of the value.
671E
OR A B7
Set the flags from Register A. If the value is 256 or more, the NZ FLAG is set.
671F
If the NZ FLAG (Not Zero) has been set because the value is 256 or more, it is the memory size, so JUMP to 6740H.
6721
LD A,E 7B
Load Register A with Register E, the value (0-255).
6722
CP 10H FE 10
Compare Register A against 10H (16). If Register A is less than 16, the CARRY FLAG is set.
6724
If the NO CARRY FLAG has been set because the value is 16-255 (neither a file count nor a memory size), JUMP to 673DH to return to DOS.
6726
LD (6529H),A 32 29 65
Self-Modifying Code
Store the number of file buffers (0-15, Register A) to 6529H, the operand of the LD A at 6528H.
6729
LD A,(HL) 7E
Fetch the character following the number, at Register Pair HL, into Register A.
672A
CP 56H FE 56
Compare Register A against 56H (ASCII: V). If Register A equals 56H, the Z FLAG is set.
672C
If the NZ FLAG (Not Zero) has been set because the character is not V, JUMP to 6734H.
672E
LD A,02H 3E 02
Load Register A with 02H, the high byte of the larger block size.
6730
LD (64C6H),A 32 C6 64
Store 02H (Register A) to 64C6H, the high byte of the block size, changing it from 012DH (301 bytes) to 022DH (557 bytes).
6733
RST 10H D7
RST 10H advances Register Pair HL past the V and fetches the next non-blank character into Register A.
6734
LD A,(HL) 7E
Fetch the character that follows the parameter, at Register Pair HL, into Register A.
6735
CP 2CH FE 2C
Compare Register A against 2CH (ASCII: ,). If Register A equals 2CH, the Z FLAG is set.
6737
If the Z FLAG (Zero) has been set because a comma follows, LOOP BACK to 6715H for the next parameter.
Loop End
6739
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If this is the end of the command line, the Z FLAG is set.
673B
If the Z FLAG (Zero) has been set, JUMP to 674BH with Register Pair HL pointing to the 0DH, so that no startup command is queued.
673D
Error Path
Reached for an invalid parameter or an inconsistent resident program. JUMP to 57C9H, which holds JP 402DH, the NEWDOS/80 No-Error Exit, returning to DOS READY without starting BASIC.
6740
DEC DE 1B
The value in Register Pair DE is 256 or more: the memory size. DECrement it by 1 to get the highest address BASIC may use.
6741
LD (64CBH),DE ED 53 CB 64
Self-Modifying Code
Store that address (Register Pair DE) to 64CBH-64CCH, the operand of the LD HL at 64CAH, which checks it against the DOS top of memory at 4049H and tests for RAM there.
6745
JUMP to 6734H to check the character that follows the memory size. A V is not accepted after a memory size.
6747H - Store the Results and Enter Initialization
Reached from 6704H with the number of file buffers of a BASIC with an asterisk restart in Register A, or at 674BH from the parameter reader with Register Pair HL pointing to the startup command or to the 0DH at the end of the line.
6747
LD (6529H),A 32 29 65
Self-Modifying Code
Store the number of file buffers worked out at 6700H (Register A) to 6529H, the operand of the LD A at 6528H.
674A
POP HL E1
Restore Register Pair HL with the address of the asterisk in the command line (saved at 66CAH).
674B
LD (655EH),HL 22 5E 65
Self-Modifying Code
Store Register Pair HL to 655EH-655FH, the operand of the LD HL at 655DH: the address of the asterisk, the first character of the startup command, or the 0DH at the end of the command line.
674E
LD HL,18F7H 21 F7 18
Point Register Pair HL to ROM 18F7H, the source: the ROM's 39-byte division support table (CONSTR, 18F7H-191DH).
6751
LD DE,4080H 11 80 40
Point Register Pair DE to 4080H, the destination: the RAM area 4080H-40A6H.
6754
LD BC,0027H 01 27 00
Load Register Pair BC with 0027H (39), the byte count.
6757
LDIR ED B0
Copy Register Pair BC (39) bytes from ROM 18F7H-191DH (Register Pair HL) to 4080H-40A6H (Register Pair DE), incrementing, as the ROM's own power-up routine does, so that the ROM's division routines have their table.
6759
JUMP to the initialization code at 64CAH to set up BASIC.
675CH - Sign-On Message Text (Data)
The sign-on message displayed at 64F6H through the NEWDOS/80 SYS0 routine at 4467H, which stops at the 0DH at 67BAH. It reads: DISK BASIC. RADIO SHACK'S ROM ENHANCED WITH on one line and APPARAT'S NEWDOS80 EXTENDED AND DISK FEATURES. on the next.
675C-675D
DEFB 1CH, 1FH 1C 1F
1CH homes the cursor and 1FH clears to the end of the frame, clearing the screen before the message.
675E-6769
DEFM "DISK BASIC. " 44 49 53 4B 20 42 41 53 49 43 2E 20
Sign-on message text: DISK BASIC. and the first of two spaces.
676A-6777
DEFM " RADIO SHACK'S" 20 52 41 44 49 4F 20 53 48 41 43 4B 27 53
Sign-on message text. The leading space follows the space that ends 675EH-6769H, giving two spaces after the period.
6778-6789
DEFM " ROM ENHANCED WITH" 20 52 4F 4D 20 45 4E 48 41 4E 43 45 44 20 57 49 54 48
Sign-on message text, the end of the first line.
678A
DEFB 0AH 0A
Line feed: the rest of the message goes on the next line.
678B-679D
DEFM "APPARAT'S NEWDOS80 " 41 50 50 41 52 41 54 27 53 20 4E 45 57 44 4F 53 38 30 20
Sign-on message text, the start of the second line.
679E-67B8
DEFM "EXTENDED AND DISK FEATURES." 45 58 54 45 4E 44 45 44 20 41 4E 44 20 44 49 53 4B 20 46 45 41 54 55 52 45 53 2E
Sign-on message text, the end of the second line.
67B9-67BA
DEFB 0AH, 0DH 0A 0D
Line feed, then the carriage return that both ends the display line and ends the message for 4467H.
67BBH - Disk BASIC Link Table (Copied to 4152H-41E4H)
Forty-nine three-byte entries, 67BBH-684DH, copied by the LDIR at 6526H over the ROM's link area at 4152H-41E4H. They execute there, not here: the name at the start of each description is the RAM slot the entry occupies at run time. The first 28 slots, 4152H-41A5H, are where the ROM sends each Disk BASIC statement and function; the other 21, 41A6H-41E4H, are the DOS links the ROM calls at fixed points. No entry jumps into this table, so each link below goes to the target's own address.
67BB
4152H CVI
Runs at 4152H, the Disk BASIC link for CVI. JUMP to 58F5H.
67BE
4155H FN
Runs at 4155H, the Disk BASIC link for FN. JUMP to 577FH.
67C1
4158H CVS
Runs at 4158H, the Disk BASIC link for CVS. JUMP to 58F2H.
67C4
415BH DEF
Runs at 415BH, the Disk BASIC link for DEF. JUMP to 5852H.
67C7
415EH CVD
Runs at 415EH, the Disk BASIC link for CVD. JUMP to 58EFH.
67CA
4161H EOF
Runs at 4161H, the Disk BASIC link for EOF. JUMP to 5EC5H.
67CD
4164H LOC
Runs at 4164H, the Disk BASIC link for LOC. JUMP to 5ED1H.
67D0
4167H LOF
Runs at 4167H, the Disk BASIC link for LOF. JUMP to 5EC9H.
67D3
416AH MKI$
Runs at 416AH, the Disk BASIC link for MKI$. JUMP to 58DEH.
67D6
416DH MKS$
Runs at 416DH, the Disk BASIC link for MKS$. JUMP to 58DBH.
67D9
4170H MKD$
Runs at 4170H, the Disk BASIC link for MKD$. JUMP to 58D8H.
67DC
4173H CMD
Runs at 4173H, the Disk BASIC link for CMD. JUMP to 57FFH.
67DF
4176H TIME$
Runs at 4176H, the Disk BASIC link for TIME$. JUMP to 58C4H.
67E2
4179H OPEN
Runs at 4179H, the Disk BASIC link for OPEN. JUMP to 5795H.
67E5
417CH FIELD
Runs at 417CH, the Disk BASIC link for FIELD. JUMP to 5E63H.
67E8
417FH GET
Runs at 417FH, the Disk BASIC link for GET. JUMP to 6126H.
67EB
4182H PUT
Runs at 4182H, the Disk BASIC link for PUT. JUMP to 6125H.
67EE
4185H CLOSE
Runs at 4185H, the Disk BASIC link for CLOSE. JUMP to 5FA1H.
67F1
4188H LOAD
Runs at 4188H, the Disk BASIC link for LOAD. JUMP to 574AH.
67F4
418BH MERGE
Runs at 418BH, the Disk BASIC link for MERGE. JUMP to 572EH.
67F7
JP 1E4AH C3 4A 1E
418EH NAME
Runs at 418EH, the Disk BASIC link for NAME. JUMP to 1E4AH. 1E4AH is ROM FCERR, so NAME reports ?FC ERROR.
67FA
4191H KILL
Runs at 4191H, the Disk BASIC link for KILL. JUMP to 643CH.
67FD
4194H &
Runs at 4194H, the Disk BASIC link for &. JUMP to 5790H.
6800
4197H LSET
Runs at 4197H, the Disk BASIC link for LSET. JUMP to 5908H.
6803
419AH RSET
Runs at 419AH, the Disk BASIC link for RSET. JUMP to 5909H.
6806
419DH INSTR
Runs at 419DH, the Disk BASIC link for INSTR. JUMP to 5786H.
6809
41A0H SAVE
Runs at 41A0H, the Disk BASIC link for SAVE. JUMP to 573BH.
680C
41A3H LINE
Runs at 41A3H, the Disk BASIC link for LINE. JUMP to 579FH.
680F
LD A,2FH 3E 2F
41A6H Error Message Link
Runs at 41A6H. Load Register A with 2FH, the SVC code for the long error messages: SYS13, function 1, by the RST 28H encoding.
6811
RST 28H EF
Runs at 41A8H, the last byte of the 41A6H slot. Issue the NEWDOS/80 SVC in Register A (2FH) through RST 28H.
6812
41A9H
Runs at 41A9H: USR link, called at 27FEH. JUMP to 5892H.
6815
JP 2169H C3 69 21
41ACH
Runs at 41ACH: READY link, called at 1A1CH. JUMP to 2169H. 2169H is ROM FINPRT, which resets the output device to the video display.
6818
41AFH
Runs at 41AFH: Keyboard line-input link, called from 0368H inside INLIN. JUMP to 575DH.
681B
41B2H
Runs at 41B2H: Link called at 1AA1H, after a BASIC line is tokenized. JUMP to 5756H.
681E
41B5H
Runs at 41B5H: Link called at 1AECH, after the program line chain is updated. JUMP to 63B3H.
6821
41B8H
Runs at 41B8H: Link called at 1AF2H, after the line chain update and CLEAR. JUMP to 63BCH.
6824
41BBH
Runs at 41BBH: NEW and END link (close all files), called at 1B8CH and 1DB0H. JUMP to 5FB6H.
6827
41BEH
Runs at 41BEH: Output-reset link, called at 2174H inside FINPRT. JUMP to 6438H.
682A
41C1H
Runs at 41C1H: Byte output link, called at 032CH. JUMP to 6076H.
682D
41C4H
Runs at 41C4H: Keyboard scan link, called at 0358H. JUMP to 63C0H.
6830
41C7H
Runs at 41C7H: RUN link, called at 1EA6H. JUMP to 5746H.
6833
41CAH
Runs at 41CAH: PRINT link, called at 206FH. JUMP to 5F52H.
6836
41CDH
Runs at 41CDH: Link called at 20C6H, after a number is converted to ASCII for PRINT. JUMP to 5F4BH.
6839
41D0H
Runs at 41D0H: Link called at 2103H, after PRINT sends a carriage return. JUMP to 5FA0H. 5FA0H is a RET, so this link does nothing.
683C
41D3H
Runs at 41D3H: PRINT comma and TAB link, called at 2108H and 2141H. JUMP to 5F3BH.
683F
41D6H
Runs at 41D6H: INPUT# link, called at 219EH. JUMP to 5EA8H.
6842
41D9H
Runs at 41D9H: Left-side MID$ link, reached by JP at 2AECH. JUMP to 578BH.
6845
41DCH
Runs at 41DCH: READ/INPUT variable assignment link, called at 222DH. JUMP to 579AH.
6848
41DFH
Runs at 41DFH: Link called at 2278H and 2B44H, after INPUT assignment and in LIST. JUMP to 5EB9H.
684B
41E2H
Runs at 41E2H: SYSTEM command link, called at 02B2H. JUMP to 5FA0H. 5FA0H is a RET, so this link does nothing.