DOSPLUS 3.5 for the Model III - BASIC/CMD Disassembled

Page Customization

Introduction/Summary

DOSPLUS 3.5 BASIC/CMD Disassembly - Extended Disk BASIC 1.7 (Model III)

BASIC/CMD is DOSPLUS 3.5's Extended Disk BASIC, version 1.7: the disk extension of the Model III's Level II ROM BASIC. It loads at 5200H-6DE1H (4821 bytes, transfer address 5200H), in the area the DOS keeps for its command overlays. A DOS library command used from BASIC through CMD"command" loads over part of that area, so the resident high overlay is read again afterwards. BASIC/CMD is a load module whose first block, at 5C00H, loads before the start-up block at 5200H, so the blocks are not in address order.

The Model III and Model IIIII files are the same length and differ in only eleven bytes, all of them ROM entry points that differ between the two machines (the NMI vector read by the start-up, the error vector stored for the BREAK key, SFLAG1$, and the ROM's multiply and divide and CKEOF entry addresses). The DOSPLUS code is identical; the Model IIIII page is this page with those addresses changed.

The Parts of BASIC/CMD

AddressContents
5200H-5418HThe start-up: options, the Disk BASIC links, the file areas, the heading (5200H)
5C00H-5D75HThe error hook, CMD and its options, CMD"M" (5C00H)
5D76H-5F02HTIME$, DEF FN, FN, USR (5D76H)
5F03H-60C9HINSTR, MID$=, &H, the PRINT # and INPUT # hooks, INPUT @ (5F03H)
60CAH-631DHLINE INPUT, the INPUT @ field editor, the I/O links and the variables (60CAH)
631EH-64E1HBASIC's command-line editor, the shorthand, DI and DU, TRON (631EH)
64E2H-66B1HThe RST 10H hook (line numbers and labels), file numbers, MKI$/CVI, INPUT # items (64E2H)
66B2H-6908HRUN, LOAD, the program loader, MERGE, SAVE, CLOSE (66B2H)
6909H-6B91HFIELD, LSET, RSET, EOF, LOC, LOF, GET, PUT, OPEN, KILL (6909H)
6B92H-6CDFHThe file-access helpers, the error exits and the DOS-to-BASIC error map (6B92H)
6CE0H-6DDFHThe keyboard input buffer

The Disk BASIC Links

The start-up (5200H) copies 49 three-byte jumps into the ROM's hook table at 4152H-41E4H, where the Level II ROM calls or jumps to the Disk BASIC functions and statements. Each link row at 532AH names the address it becomes. Through these links the ROM reaches CVI/CVS/CVD, FN, EOF, LOC, LOF, MKI$/MKS$/MKD$, CMD, TIME$, OPEN, FIELD, GET, PUT, CLOSE, LOAD, MERGE, NAME (labels), KILL, &H, LSET, RSET, INSTR, SAVE, LINE INPUT, USR, and the output, keyboard and PRINT/INPUT hooks that redirect I/O to a file.

Files

Every file operation goes through SYS0/SYS's entry points (OPEN@, INIT@, CLOSE@, KILL@, READ@, WRITE@, POSN@, REW@, BKSP@, PEOF@, CKEOF@) by way of the helpers at 6B92H on, which take the file's area as an Index Register. A file area (one per file, 0 to 15, and one more, area 0, for LOAD, RUN, SAVE, MERGE and KILL) is 0222H bytes from 6DE1H: a mode byte, a column byte, a 32-byte file control block and two 256-byte buffers. OPEN's mode letter is I (input), O (output), E (append), or R or D (random). A DOS error from any entry point is mapped to a Disk BASIC error code by the table at 6CB6H.

Program Files

A BASIC program is saved compressed (tokenized, the file beginning with FFH) or as ASCII (SAVE"file",A). The compressed loader (6723H) makes room by moving the variable tables and reads the program in record by record; an ASCII program is read line by line through the line-input link, as though typed. LOAD,V verifies a compressed file. A program loaded under an access level of 6 or 7 may not be listed or saved: at READY it is wiped and the message RUN access only is shown (6C47H).

Differences from the Manual

These are stated from the bytes. CMD"R" and CMD"T" (5C83H) turn the interrupts on and off by storing the opcode JP or RET at the RST 38H vector 4012H. The shorthand (63D1H) expands a letter to a token only when it stands alone as a statement's word with no = in the statement; L followed by a quotation mark becomes LOAD, otherwise LIST. DI and DU (6441H) work only in a direct line. OPEN of a random file (6ABCH) parses a record-length argument but does not store it in the file control block, which keeps the length the file was created with (6B29H). MERGE (684AH) requires an ASCII program and gives Bad file mode for a compressed one. LOAD,V of an ASCII program gives Bad file mode (verify applies only to a compressed file).

Variables

The variables are in BASIC/CMD's own area 62F5H-631DH, which the start-up and the file routines read and write; the program, its variables and the string space lie above the file areas, which start at 6DE1H.

BASIC/CMD Variables

Address
Size
Contents
62F5H
1 byte
ERROR/OVL state
Bit 0: the long error messages of ERROR/OVL are usable. Bit 1: ERROR/OVL is to be loaded before the next error. 03H in the file (5C00H).
62F6H
1 byte
Last DOS error
The DOS error code last posted, shown again by CMD"E" (6CA3H).
62F7H
1 byte
Run flag
Not 00H when RUN, LOAD,R or MERGE,R is to run the program once it is loaded (66B2H).
62F8H-62F9H
2 bytes
ERROR/OVL entry
The transfer address LOAD@ returned for ERROR/OVL (5C10H).
62FAH
1 byte
Number of files
The number of files the program may open, 0 to 15 (the -F: option; 01H by default).
62FBH
1 byte
Protection level
The access level (6 or 7) of a program loaded that may not be listed; 6C47H wipes such a program at READY (6B4CH).
62FCH-62FDH
2 bytes
Current file
The area of the file PRINT #, INPUT #, LOAD and SAVE ,A use; 0000H when there is none.
62FEH-631DH
32 bytes
File area table
The addresses of the file areas 0 to 15, one word each, built by the start-up (52F5H).

Self-Modified Operands

Address
Size
Contents
52CBH
1 byte
File length
The length of the file specification collected by the start-up: the operand of LD C,00H at 52CAH (5260H).
5247H-5248H
2 bytes
Command line
The command line pointer: the operand of LD HL,0000H at 5246H (5204H).
529AH-529BH
2 bytes
Top of memory
HMEM$ or the value of -M: the operand of LD DE,0000H at 5299H (5230H).
66F1H
1 byte
Verify flag
56H ('V') when LOAD,V verifies a compressed file: the operand of LD A,00H at 66F0H (66E4H).
6703H
1 byte
Saved files
The number of files saved across the NEW of LOAD and RUN: the operand of LD A,00H at 6702H (66F8H).
6473H
1 byte
DI/DU flag
49H ('I') for DI, 00H for DU: the operand of LD A,00H at 6472H (6441H).
6A78H
1 byte
GET/PUT flag
AFH for PUT, 00H for GET: the operand of LD A,00H at 6A77H (6A2BH).

Disassembly

5200H - Start-up

BASIC/CMD's transfer address. Entered from the DOS with Register Pair HL at the rest of the command line after BASIC. The start-up runs once in the area 5200H-5418H, which later serves the DOS overlays and ERROR/OVL. It puts the stack at 4288H, sends RST 10H to 64E2H, puts 5CD6H into the vector at 4203H-4205H and copies the 49 Disk BASIC links (532AH) to 4152H-41E4H. A command line starting with * is the re-entry BASIC * (52EBH). Otherwise it copies the ROM's RAM table to 4080H, takes the file specification and the options -F:nn (files, 0-15) and -M:nnnnn (top of memory), sets up the file areas (52F5H), the program start and the top of memory, clears the program (NEW), and either shows the heading and goes to READY, or loads and runs the program named.

5200
LD SP,4288H 31 88 42
Load the Stack Pointer with 4288H, the ROM's stack area in the input buffer region, for the start-up of BASIC.
5203
LD A,(HL) 7E
Load Register A with the first character of the command line at Register Pair HL, tested for the asterisk at 521EH.
5204
LD (5247H),HL 22 47 52
Store Register Pair HL, the command line pointer, into 5247H-5248H, the operand of LD HL,0000H at 5246H.
5207
LD HL,64E2H 21 E2 64
Point Register Pair HL to 64E2H, BASIC's own character fetch, which RST 10H calls from now on.
520A
LD (4004H),HL 22 04 40
Store Register Pair HL (64E2H) into 4004H-4005H, the operand of the JP at 4003H, the RST 10H vector.
520D
LD HL,5CD6H 21 D6 5C
Point Register Pair HL to 5CD6H, BASIC's return to READY with a new stack.
5210
LD (4204H),HL 22 04 42
Store Register Pair HL (5CD6H) into 4204H-4205H: on the Model III the operand of the BREAK vector JP at 4203H; on the Model I these bytes are in DOSPLUS's buffer 4200H-42FFH and are not a vector.
5213
LD DE,4152H 11 52 41
Point Register Pair DE to 4152H, the first of the Disk BASIC links (4152H-41E4H) that the ROM calls or jumps to.
5216
LD HL,532AH 21 2A 53
Point Register Pair HL to 532AH, BASIC's table of the 49 links, three bytes each (JP nnnnH).
5219
LD BC,0093H 01 93 00
Load Register Pair BC with 0093H, the length of the 49 links: 147 bytes.
521C
LDIR ED B0
Copy the 147 bytes from Register Pair HL (532AH) to Register Pair DE (4152H) by LDIR, counted by Register Pair BC.
521E
CP 2AH FE 2A
Compare Register A, the first character of the command line, against 2AH, the asterisk of BASIC followed by an asterisk (re-entry).
5220
If the Z FLAG is set (the re-entry), JUMP to 52EBH to go back to the program in memory.
5223
LD DE,4080H 11 80 40
Point Register Pair DE to 4080H, the ROM's RAM area of the division routine and the BASIC variables.
5226
LD HL,18F7H 21 F7 18
Point Register Pair HL to 18F7H, the ROM's table that its power up copies to 4080H.
5229
LD C,27H 0E 27
Load Register C with 27H, the 39 bytes of the table (Register B is 00H after the LDIR above).
522B
LDIR ED B0
Copy the 39 bytes from Register Pair HL (18F7H) to Register Pair DE (4080H) by LDIR, counted by Register Pair BC.
522D
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HMEM$ from 4411H-4412H, the highest address the DOS lets a program use.
5230
LD (529AH),HL 22 9A 52
Store Register Pair HL (HMEM$) into 529AH-529BH, the operand of LD DE,0000H at 5299H: the top of memory when no -M option is given.
5233
LD HL,6CE0H 21 E0 6C
Point Register Pair HL to 6CE0H, BASIC's input buffer of 256 bytes (6CE0H-6DDFH, not loaded).
5236
LD (40A7H),HL 22 A7 40
Store Register Pair HL (6CE0H) into 40A7H-40A8H, the ROM's pointer to the input buffer.
5239
XOR A AF
Set Register A to 00H by XORing it with itself, for the counter and the flag below.
523A
LD B,A 47
Load Register B with Register A (00H): the length of the file specification, counted at 5259H.
523B
LD (62FBH),A 32 FB 62
Store Register A (00H) to 62FBH, the protection flag of the program in memory (6B4CH): none.
523E
LD A,01H 3E 01
Load Register A with 01H, the number of files when no -F option is given.
5240
LD (62FAH),A 32 FA 62
Store Register A (01H) to 62FAH, the number of files BASIC may open.
5243
LD DE,6CE0H 11 E0 6C
Point Register Pair DE to 6CE0H, the input buffer, where the file specification is collected.
5246
LD HL,0000H 21 00 00
Load Register Pair HL with the command line pointer, the operand 5247H-5248H (0000H in the file) stored at 5204H.
5249
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below takes the first character of the command line.
524A
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character that is not a space (through 64E2H).
524B
CP 20H FE 20
Compare Register A against 20H, the space: the C FLAG for a control character, the end of the command line.
524D
If the C FLAG is set (the end of the line), JUMP to 528FH to set up the memory.
524F
CP 3BH FE 3B
Compare Register A against 3BH, the character ; that also ends a command.
5251
If the Z FLAG is set (;), JUMP to 528FH to set up the memory.
5253
CP 2DH FE 2D
Compare Register A against 2DH, the character - that starts an option.
5255
If the Z FLAG is set (-), JUMP to 5265H to take the option.
5257
LD (DE),A 12
Store Register A, a character of the file specification, at Register Pair DE in the input buffer.
5258
INC DE 13
INCrement Register Pair DE by 1, to the next byte of the input buffer.
5259
INC B 04
INCrement Register B by 1, the length of the file specification.
525A
LD A,B 78
Load Register A with Register B, the length of the file specification so far.
525B
CP 18H FE 18
Compare Register A against 18H: the NC FLAG when the file specification reaches 24 characters.
525D
If the NC FLAG is set (24 characters or more), JUMP to 6C92H, the error Bad file name.
5260
LD (52CBH),A 32 CB 52
Store Register A, the length, to 52CBH, the operand of LD C,00H at 52CAH.
5263
LOOP back to 524AH for the next character of the command line.
5265
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the letter of the option after the -.
5266
RES 5,A CB AF
RESET bit 5 of Register A, which makes a lower case letter upper case.
5268
CP 4DH FE 4D
Compare Register A against 4DH, the letter M of -M:nnnnn, the top of memory.
526A
If the Z FLAG is set (M), JUMP to 5286H to take the top of memory.
526C
CP 46H FE 46
Compare Register A against 46H, the letter F of -F:nn, the number of files.
526E
If the NZ FLAG is set (neither F nor M), JUMP to 1E4AH, the ROM's Illegal function call error.
5271
GOSUB to 5314H to take :nnnnn into Register Pair DE: the Z FLAG when another - follows.
5274
PUSH AF F5
Save Register Pair AF, the flags of the end of the option, to the top of the stack.
5275
LD A,D 7A
Load Register A with Register D, the high byte of the number of files.
5276
OR A B7
OR Register A against itself: the NZ FLAG when the number is 256 or more.
5277
If the NZ FLAG is set, JUMP to 6C9EH, the error Too many files.
527A
LD A,E 7B
Load Register A with Register E, the low byte of the number of files.
527B
CP 10H FE 10
Compare Register A against 10H: the NC FLAG for 16 files or more.
527D
If the NC FLAG is set (16 or more), JUMP to 6C9EH, the error Too many files.
5280
LD (62FAH),A 32 FA 62
Store Register A, the number of files (0-15), to 62FAH.
5283
POP AF F1
Restore Register Pair AF, the flags of the end of the option, from the top of the stack.
5284
JUMP to 528DH, the test for another option after this one.
5286
GOSUB to 5314H to take :nnnnn into Register Pair DE: the Z FLAG when another - follows.
5289
LD (529AH),DE ED 53 9A 52
Store Register Pair DE, the top of memory of -M, into 529AH-529BH, the operand of LD DE,0000H at 5299H.
528D
If the Z FLAG is set (another - follows), LOOP back to 5265H to take that option.
528F
XOR A AF
Set Register A to 00H by XORing it with itself, and clear the C FLAG: every file area is marked closed.
5290
GOSUB to 52F5H to build the table of the file areas from 6DE1H: Register Pair HL returns the end of the last area.
5293
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte before the first line of the program.
5295
INC HL 23
INCrement Register Pair HL by 1, to the start of the program.
5296
LD (40A4H),HL 22 A4 40
Store Register Pair HL into 40A4H-40A5H, the ROM's pointer to the start of the program text.
5299
LD DE,0000H 11 00 00
Load Register Pair DE with the top of memory, the operand 529AH-529BH (0000H in the file): HMEM$ or the value of -M.
529C
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HMEM$ from 4411H-4412H, the highest address the DOS allows.
529F
RST 18H DF
RST 18H: compare Register Pair HL (HMEM$) with Register Pair DE (the top asked for): the C FLAG when the top is above HMEM$.
52A0
If the C FLAG is set (-M above HMEM$), JUMP to 197AH, the ROM's Out of memory error.
52A3
DEC DE 1B
DECrement Register Pair DE by 1: the last byte BASIC may use is the one below the top.
52A4
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
52A7
LD BC,012CH 01 2C 01
Load Register Pair BC with 012CH, 300 bytes, the least room BASIC needs above the start of the program.
52AA
ADD HL,BC 09
ADD Register Pair BC (300) to Register Pair HL, the start of the program.
52AB
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the last byte, Register Pair DE = the start plus 300.
52AC
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG when the memory is less than 300 bytes.
52AD
If the C FLAG is set (too little memory), JUMP to 197AH, the ROM's Out of memory error.
52B0
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, minus 50: the string space starts 50 bytes below the top.
52B3
LD (40B1H),HL 22 B1 40
Store Register Pair HL, the last byte BASIC may use, into 40B1H-40B2H, the ROM's top of memory.
52B6
ADD HL,DE 19
ADD Register Pair DE (minus 50) to Register Pair HL, the top of memory.
52B7
LD (40A0H),HL 22 A0 40
Store Register Pair HL into 40A0H-40A1H, the ROM's start of the string space: 50 bytes, as the ROM's own CLEAR 50.
52BA
GOSUB to 1B4DH, the ROM's NEW: an empty program and no variables.
52BD
LD A,(52CBH) 3A CB 52
Load Register A with the length of the file specification from 52CBH, the operand of LD C,00H at 52CAH.
52C0
OR A B7
OR Register A against itself: the Z FLAG when no program was named.
52C1
If the Z FLAG is set (no program), JUMP to 52E2H to show the heading.
52C3
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
52C4
GOSUB to 6593H for file area 0: Index Register IX the area, Register Pair DE its file control block.
52C7
LD HL,6CE0H 21 E0 6C
Point Register Pair HL to 6CE0H, the file specification collected in the input buffer.
52CA
LD C,00H 0E 00
Load Register C with the length of the file specification: the operand 52CBH (00H in the file) stored at 5260H.
52CC
GOSUB to 6AACH to copy the file specification at Register Pair HL into the file control block at Register Pair DE, with 03H after it.
52CF
LD A,FFH 3E FF
Load Register A with FFH, the flag that the program is to be run after it is loaded.
52D1
LD (62F7H),A 32 F7 62
Store Register A (FFH) to 62F7H, the run flag of LOAD (66B6H).
52D4
LD A,01H 3E 01
Load Register A with 01H, the mode of a file opened for input.
52D6
GOSUB to 6B0FH to open file area 0 for input with OPEN@.
52D9
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the line to start at: the first line.
52DC
LD (40F3H),HL 22 F3 40
Store Register Pair HL (0000H) into 40F3H-40F4H, the line number that LOAD's run starts at (67C4H).
52DF
JUMP to 670FH to load the program from file area 0 and run it.
52E2
LD HL,53BDH 21 BD 53
Point Register Pair HL to 53BDH, the heading of BASIC with its copyright line.
52E5
GOSUB to 28A7H, the ROM's routine that shows the text at Register Pair HL up to its 00H.
52E8
JUMP to 1A19H, the ROM's READY, with the empty program.
52EB
SCF 37
Set the C FLAG: the file areas keep their contents, so the open files of the program stay open.
52EC
GOSUB to 52F5H to build the table of the file areas again (the number of files is still in 62FAH).
52EF
LD BC,2B2EH 01 2E 2B
Load Register Pair BC with 2B2EH, the ROM's LIST, where the reset of the stack goes on.
52F2
JUMP to 19AEH, the ROM's routine that resets the stack and the BASIC pointers and continues at Register Pair BC: LIST shows the program.

52F5H - The File Areas

Builds the table 62FEH of the addresses of the file areas: one area for each file (62FAH) and one more, area 0, that LOAD, RUN, SAVE, MERGE and KILL use. The areas are 0222H bytes each from 6DE1H: the mode byte, the column byte, the file control block (32 bytes) and two buffers of 256 bytes. With the C FLAG clear the first byte of each area is set to 00H (closed). Register Pair HL returns the end of the last area, where the program starts.

52F5
LD HL,62FAH 21 FA 62
Point Register Pair HL to 62FAH, the number of files.
52F8
LD B,(HL) 46
Load Register B with the number of files at Register Pair HL.
52F9
INC B 04
INCrement Register B by 1, for file area 0, which is always there.
52FA
LD HL,6DE1H 21 E1 6D
Point Register Pair HL to 6DE1H, the first file area.
52FD
LD DE,62FEH 11 FE 62
Point Register Pair DE to 62FEH, the table of the addresses of the file areas.
5300
If the C FLAG is set (the re-entry), JUMP to 5304H: the area keeps its mode byte.
5302
LD (HL),00H 36 00
Store 00H at Register Pair HL, the mode byte of the area: closed.
5304
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the table entry, Register Pair DE = the area.
5305
LD (HL),E 73
Store Register E, the low byte of the area's address, at Register Pair HL in the table.
5306
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the table entry.
5307
LD (HL),D 72
Store Register D, the high byte of the area's address, at Register Pair HL in the table.
5308
INC HL 23
INCrement Register Pair HL by 1, to the next table entry.
5309
PUSH AF F5
Save Register Pair AF, the C FLAG, to the top of the stack.
530A
PUSH HL E5
Save Register Pair HL, the next table entry, to the top of the stack.
530B
LD HL,0222H 21 22 02
Load Register Pair HL with 0222H, the length of a file area: 546 bytes.
530E
ADD HL,DE 19
ADD Register Pair DE, the area, to Register Pair HL: Register Pair HL = the next area.
530F
POP DE D1
Restore Register Pair DE, the next table entry, from the top of the stack.
5310
POP AF F1
Restore Register Pair AF, the C FLAG, from the top of the stack.
5311
DECrement Register B and LOOP back to 5300H for the next file area.
5313
RET C9
RETurn with Register Pair HL = the end of the last file area.

5314H - The Value of an Option

Takes :nnnnn after the letter of an option: the number goes to Register Pair DE. Returns the Z FLAG when a - follows (another option), the NZ FLAG at the end of the command line or at ;. Anything else is a syntax error.

5314
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character, which must be the colon.
5315
CP 3AH FE 3A
Compare Register A against 3AH, the colon between the letter of the option and its value.
5317
If the NZ FLAG is set (no colon), JUMP to 1997H, the ROM's Syntax error.
531A
GOSUB to 1E5BH, the ROM's decimal number scan: the number into Register Pair DE, Register A the character after it.
531D
CP 2DH FE 2D
Compare Register A against 2DH, the character - of another option.
531F
RET Z C8
If the Z FLAG is set (-), RETurn with the Z FLAG.
5320
CP 20H FE 20
Compare Register A against 20H, the space: the C FLAG for a control character, the end of the line.
5322
RET C D8
If the C FLAG is set (the end of the line), RETurn with the NZ FLAG.
5323
CP 3BH FE 3B
Compare Register A against 3BH, the character ; that ends a command.
5325
If the NZ FLAG is set (anything else), JUMP to 1997H, the ROM's Syntax error.
5328
OR A B7
OR Register A against itself (3BH): the NZ FLAG for the end of the options.
5329
RET C9
RETurn with the NZ FLAG: no other option follows this one.

532AH - The Disk BASIC Links

Data: the 49 jumps that the start-up copies to 4152H-41E4H, where the ROM calls or jumps to the Disk BASIC functions, statements and hooks. Each row names the link it becomes.

532A
JUMP to 65CCH: becomes the link 4152H, CVI, which the ROM reaches through that link.
532D
JUMP to 5E07H: becomes the link 4155H, FN (a user function defined by DEF FN).
5330
JUMP to 65CFH: becomes the link 4158H, CVS, which the ROM reaches through that link.
5333
JUMP to 5D8CH: becomes the link 415BH, DEF (DEF FN and DEFUSR), which the ROM reaches through that link.
5336
JUMP to 65D2H: becomes the link 415EH, CVD, which the ROM reaches through that link.
5339
JUMP to 69FBH: becomes the link 4161H, EOF, which the ROM reaches through that link.
533C
JUMP to 6A10H: becomes the link 4164H, LOC, which the ROM reaches through that link.
533F
JUMP to 6A1DH: becomes the link 4167H, LOF, which the ROM reaches through that link.
5342
JUMP to 65B3H: becomes the link 416AH, MKI$, which the ROM reaches through that link.
5345
JUMP to 65B6H: becomes the link 416DH, MKS$, which the ROM reaches through that link.
5348
JUMP to 65B9H: becomes the link 4170H, MKD$, which the ROM reaches through that link.
534B
JUMP to 5C48H: becomes the link 4173H, CMD, which the ROM reaches through that link.
534E
JUMP to 5D76H: becomes the link 4176H, TIME$, which the ROM reaches through that link.
5351
JUMP to 6ABCH: becomes the link 4179H, OPEN, which the ROM reaches through that link.
5354
JUMP to 6909H: becomes the link 417CH, FIELD, which the ROM reaches through that link.
5357
JUMP to 6A2AH: becomes the link 417FH, GET, which the ROM reaches through that link.
535A
JUMP to 6A29H: becomes the link 4182H, PUT, which the ROM reaches through that link.
535D
JUMP to 68D9H: becomes the link 4185H, CLOSE, which the ROM reaches through that link.
5360
JUMP to 66B5H: becomes the link 4188H, LOAD, which the ROM reaches through that link.
5363
JUMP to 684AH: becomes the link 418BH, MERGE, which the ROM reaches through that link.
5366
JUMP to 656AH: becomes the link 418EH, NAME (a label line), which the ROM reaches through that link.
5369
JUMP to 6B7AH: becomes the link 4191H, KILL, which the ROM reaches through that link.
536C
JUMP to 600AH: becomes the link 4194H, the & of &H hexadecimal constants.
536F
JUMP to 695AH: becomes the link 4197H, LSET, which the ROM reaches through that link.
5372
JUMP to 6959H: becomes the link 419AH, RSET, which the ROM reaches through that link.
5375
JUMP to 5F03H: becomes the link 419DH, INSTR, which the ROM reaches through that link.
5378
JUMP to 688BH: becomes the link 41A0H, SAVE, which the ROM reaches through that link.
537B
JUMP to 60CAH: becomes the link 41A3H, LINE (LINE INPUT), which the ROM reaches through that link.
537E
JUMP to 5C00H: becomes the link 41A6H, the error hook of the ROM's error routine (the long messages of ERROR/OVL).
5381
JUMP to 5ECCH: becomes the link 41A9H, USR, which the ROM reaches through that link.
5384
JUMP to 6826H: becomes the link 41ACH, READY (file area 0 closed), which the ROM reaches through that link.
5387
JUMP to 61FBH: becomes the link 41AFH, the keyboard line input (a program line from a file during LOAD and MERGE).
538A
JUMP to 6877H: becomes the link 41B2H, after a line has been tokenized (direct statements in a file).
538D
JUMP to 62DCH: becomes the link 41B5H, after the program's line pointers are fixed.
5390
JUMP to 62E3H: becomes the link 41B8H, after a line has been entered and CLEAR done.
5393
JUMP to 68FFH: becomes the link 41BBH, NEW and END: close every file, which the ROM reaches through that link.
5396
JUMP to 62D5H: becomes the link 41BEH, the end of PRINT: no file for the output.
5399
JUMP to 622AH: becomes the link 41C1H, the output of a byte: to the file of PRINT # when one is selected.
539C
JUMP to 623DH: becomes the link 41C4H, the keyboard scan: the file of INPUT # or of LOAD when one is selected.
539F
JUMP to 66B2H: becomes the link 41C7H, RUN with a file name, which the ROM reaches through that link.
53A2
JUMP to 603EH: becomes the link 41CAH, PRINT: the # of PRINT #, which the ROM reaches through that link.
53A5
JUMP to 62EAH: becomes the link 41CDH, PRINT of a number to a file, which the ROM reaches through that link.
53A8
JUMP to 62F4H: becomes the link 41D0H, after PRINT's carriage return (a RET).
53AB
JUMP to 62A4H: becomes the link 41D3H, the comma and TAB of PRINT with a file.
53AE
JUMP to 604AH: becomes the link 41D6H, INPUT: the # of INPUT # and the @ of INPUT @.
53B1
JUMP to 5F8BH: becomes the link 41D9H, MID$ on the left of an assignment.
53B4
JUMP to 65E9H: becomes the link 41DCH, the items of INPUT # from a file.
53B7
JUMP to 61E5H: becomes the link 41DFH, the end of INPUT and the end of a listed line.
53BA
JUMP to 6290H: becomes the link 41E2H, SYSTEM: the ROM's prompt of SYSTEM.

53BDH - The Heading

Data: the heading that the start-up shows when no program is named (52E2H).

53BD-53E5
DEFM "BASIC - DOSPLUS Extended disk BASIC - 1.7" 42 41 53 49 43 20 2D 20 44 4F 53 50 4C 55 53 20 45 78 74 65 6E 64 65 64 20 64 69 73 6B 20 42 41 53 49 43 20 2D 20 31 2E 37
The first line of the heading: the name and the version of BASIC/CMD.
53E6
DEFB 0DH 0D
The carriage return that ends the first line of the heading.
53E7-5415
DEFM "(c) Copyright 1983, Micro-Systems Software Inc." 28 63 29 20 43 6F 70 79 72 69 67 68 74 20 31 39 38 33 2C 20 4D 69 63 72 6F 2D 53 79 73 74 65 6D 73 20 53 6F 66 74 77 61 72 65 20 49 6E 63 2E
The second line of the heading: the copyright notice.
5416-5417
DEFB 0DH,0DH 0D 0D
Two carriage returns: the end of the copyright line and an empty line before READY.
5418
DEFB 00H 00
The 00H that ends the heading for the ROM's 28A7H.
5419-5BFF
DEFS 2023
Not loaded: the rest of the DOS's overlay area 5200H-5BFFH. After the start-up the library commands of CMD" (the high overlays) and ERROR/OVL load there.

5C00H - The Error Hook

Link 41A6H, called by the ROM's error routine with Register E = the error's offset (the ERR value). 62F5H decides: bit 0 clear (no ERROR/OVL) returns with Register A = 00H, and an offset of 63H or more (a disk error) becomes 26H, so that the ROM shows the two letter code UE of its own table. Bit 0 set pushes ERROR/OVL's entry (62F8H-62F9H) and returns into it, which shows the long message; when bit 1 is set too, ERROR/OVL is first loaded into the overlay area 5200H with LOAD@, through the file control block of file area 0, and 62F5H becomes 01H (loaded) or 00H (not on the diskette: the short messages from then on). 62F5H is 03H in the file, and CMD" sets bit 1 again (5CC5H), because a library command loads over ERROR/OVL.

5C00
LD A,(62F5H) 3A F5 62
Load Register A with the state of the long error messages from 62F5H: bit 0 ERROR/OVL usable, bit 1 to be loaded first.
5C03
BIT 0,A CB 47
Test bit 0 of Register A: the NZ FLAG when the long messages of ERROR/OVL are to be used.
5C05
If the NZ FLAG is set (ERROR/OVL), JUMP to 5C10H.
5C07
LD A,E 7B
Load Register A with Register E, the offset of the error in the ROM's table.
5C08
CP 63H FE 63
Compare Register A against 63H: the C FLAG for an error of the ROM (offsets 00H-62H), the NC FLAG for a disk error.
5C0A
LD A,00H 3E 00
Load Register A with 00H for the ROM's error routine (the flags are kept).
5C0C
RET C D8
If the C FLAG is set (an error of the ROM), RETurn: the ROM shows its own two letter code.
5C0D
LD E,26H 1E 26
Load Register E with 26H, the offset of the ROM's Unprintable error (UE): it has no code for the disk errors.
5C0F
RET C9
RETurn to the ROM's error routine with Register E = 26H and Register A = 00H.
5C10
LD BC,(62F8H) ED 4B F8 62
Load Register Pair BC with ERROR/OVL's entry from 62F8H-62F9H, the transfer address LOAD@ returned.
5C14
PUSH BC C5
Save Register Pair BC, ERROR/OVL's entry, to the top of the stack, so that a RET goes into ERROR/OVL.
5C15
BIT 1,A CB 4F
Test bit 1 of Register A: the Z FLAG when ERROR/OVL is in memory already.
5C17
RET Z C8
If the Z FLAG is set (in memory), RETurn into ERROR/OVL with Register E = the offset of the error.
5C18
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL is saved in place of the entry.
5C19
PUSH DE D5
Save Register Pair DE, the error offset in Register E, to the top of the stack.
5C1A
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
5C1B
GOSUB to 6593H for file area 0: Index Register IX the area, Register Pair DE its file control block.
5C1E
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
5C1F
LD HL,5C3EH 21 3E 5C
Point Register Pair HL to 5C3EH, the file specification ERROR/OVL with its 03H.
5C22
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, the ten bytes of the file specification.
5C25
LDIR ED B0
Copy the 10 bytes from Register Pair HL (5C3EH) into the file control block at Register Pair DE by LDIR, counted by Register Pair BC.
5C27
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
5C28
GOSUB to 4430H, LOAD@, to load ERROR/OVL into the overlay area: Register Pair HL returns its transfer address, the Z FLAG for success.
5C2B
LD (62F8H),HL 22 F8 62
Store Register Pair HL, ERROR/OVL's transfer address, into 62F8H-62F9H.
5C2E
POP DE D1
Restore Register Pair DE, the error offset, from the top of the stack.
5C2F
POP HL E1
Restore Register Pair HL, the value it had on entry, from the top of the stack.
5C30
LD A,01H 3E 01
Load Register A with 01H, the state ERROR/OVL loaded (the flags of LOAD@ are kept).
5C32
If the Z FLAG is set (ERROR/OVL loaded), JUMP to 5C35H with Register A = 01H.
5C34
DEC A 3D
DECrement Register A by 1, to 00H: ERROR/OVL could not be loaded, so the short messages are used.
5C35
LD (62F5H),A 32 F5 62
Store Register A (01H or 00H) to 62F5H, the state of the long error messages.
5C38
DEC A 3D
DECrement Register A by 1: 00H after a load, FFH when the load failed.
5C39
LD (429EH),A 32 9E 42
Store Register A to 429EH, OVLYH$: ERROR/OVL fills the high overlay area, so the next library command loads its overlay again.
5C3C
JUMP back to 5C00H to show the error with the new state.
5C3E-5C46
DEFM "ERROR/OVL" 45 52 52 4F 52 2F 4F 56 4C
The file specification of the overlay with the long error messages, copied into file area 0's file control block.
5C47
DEFB 03H 03
The 03H that ends the file specification for LOAD@.

5C48H - CMD

Link 4173H, the statement CMD, with Register Pair HL at the text after it and the Z FLAG at the end of the statement. CMD alone goes back to the DOS through EXIT@. Otherwise the expression must be a string: one character is an option, I (a second string as the command), D (DEBUG@), E (the last DOS error with ERROR@), T (interrupts off), R (interrupts on), M (CMD"M", the simple variables) or S (the DOS); any other single character, and every longer string, is a DOS command. The command (up to 63 characters) is copied into file area 0 with 03H after it, ABORT@ is pointed to 5CD6H so that an error of the command comes back to BASIC, and CMNDI@ runs it; the statement then goes on.

5C48
If the Z FLAG is set (CMD alone), JUMP to 402DH, EXIT@, back to the DOS.
5C4B
GOSUB to 2337H, the ROM's expression evaluator, for the string after CMD at Register Pair HL.
5C4E
PUSH HL E5
Save Register Pair HL, the text pointer after the expression, to the top of the stack.
5C4F
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns the descriptor.
5C52
LD C,(HL) 4E
Load Register C with the length of the string from the descriptor at Register Pair HL.
5C53
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
5C54
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
5C55
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
5C56
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the string.
5C57
LD A,C 79
Load Register A with Register C, the length of the string.
5C58
OR A B7
OR Register A against itself: the Z FLAG for an empty string.
5C59
If the Z FLAG is set (an empty string), JUMP to 1E4AH, the ROM's Illegal function call error.
5C5C
CP 01H FE 01
Compare Register A against 01H: the Z FLAG for a string of one character, an option.
5C5E
If the NZ FLAG is set (longer), JUMP to 5CB0H to run the string as a DOS command.
5C60
LD A,(DE) 1A
Load Register A with the character of the option at Register Pair DE.
5C61
RES 5,A CB AF
RESET bit 5 of Register A, which makes a lower case letter upper case.
5C63
CP 49H FE 49
Compare Register A against 49H, the letter I: a second string holds the DOS command.
5C65
If the Z FLAG is set (I), JUMP to 5C9DH to take the second string.
5C67
CP 44H FE 44
Compare Register A against 44H, the letter D: start DEBUG.
5C69
If the Z FLAG is set (D), JUMP to 5C98H to enter the debugger.
5C6B
CP 45H FE 45
Compare Register A against 45H, the letter E: show the last DOS error.
5C6D
If the Z FLAG is set (E), JUMP to 5C8EH to show the last DOS error.
5C6F
CP 54H FE 54
Compare Register A against 54H, the letter T: the interrupts off.
5C71
If the Z FLAG is set (T), JUMP to 5C86H to turn the interrupts off.
5C73
CP 52H FE 52
Compare Register A against 52H, the letter R: the interrupts on.
5C75
If the Z FLAG is set (R), JUMP to 5C83H to turn the interrupts on.
5C77
CP 4DH FE 4D
Compare Register A against 4DH, the letter M: show the simple variables.
5C79
If the Z FLAG is set (M), JUMP to 5CDCH to show the simple variables.
5C7B
CP 53H FE 53
Compare Register A against 53H, the letter S: back to the DOS, as CMD alone.
5C7D
If the Z FLAG is set (S), JUMP to 402DH, EXIT@, back to the DOS.
5C80
LD A,C 79
Load Register A with Register C, the length 01H: any other character is a DOS command of one character.
5C81
JUMP to 5CB0H to run the string as a DOS command.
5C83
LD A,C3H 3E C3
CMD"R": load Register A with C3H, the opcode JP, for the interrupt vector at 4012H.
5C85
LD BC,C93EH 01 3E C9
5C86H (CMD"T") enters inside this LD BC,C93EH: its bytes 3EH C9H read as LD A,C9H, the opcode RET; from above it only loads Register Pair BC.
5C88
LD (4012H),A 32 12 40
Store Register A to 4012H, the opcode of the RST 38H vector: C3H (JP) lets the interrupts be served; C9H (RET) returns from the first one without EI, so they stay off.
5C8B
POP HL E1
Restore Register Pair HL, the text pointer after the expression, from the top of the stack.
5C8C
EI FB
Enable the interrupts (EI), so that CMD"R" turns them on again at once.
5C8D
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
5C8E
LD A,(62F6H) 3A F6 62
Load Register A with the last DOS error code from 62F6H, kept by the error mapping at 6CA6H.
5C91
OR C0H F6 C0
OR Register A with C0H: bit 7 return to the caller, bit 6 no frame around the message.
5C93
GOSUB to 4409H, ERROR@, to show the DOS's message for the error code in Register A.
5C96
POP HL E1
Restore Register Pair HL, the text pointer after the expression, from the top of the stack.
5C97
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
5C98
GOSUB to 440DH, DEBUG@, to enter the DOS's debugger, which returns here when it ends.
5C9B
POP HL E1
Restore Register Pair HL, the text pointer after the expression, from the top of the stack.
5C9C
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
5C9D
POP HL E1
Restore Register Pair HL, the text pointer after the first string, from the top of the stack.
5C9E
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before the second string, or the ROM shows a Syntax error.
5CA0
GOSUB to 2337H, the ROM's expression evaluator, for the second string at Register Pair HL.
5CA3
PUSH HL E5
Save Register Pair HL, the text pointer after the expression, to the top of the stack.
5CA4
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns the descriptor.
5CA7
LD A,(HL) 7E
Load Register A with the length of the second string from the descriptor at Register Pair HL.
5CA8
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
5CA9
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
5CAA
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
5CAB
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the command.
5CAC
OR A B7
OR Register A against itself: the Z FLAG for an empty string.
5CAD
If the Z FLAG is set (an empty string), JUMP to 1E4AH, the ROM's Illegal function call error.
5CB0
CP 40H FE 40
Compare Register A, the length of the command, against 40H: the NC FLAG for 64 characters or more.
5CB2
If the NC FLAG is set (too long), JUMP to 1E4AH, the ROM's Illegal function call error.
5CB5
PUSH AF F5
Save Register Pair AF, the length in Register A, to the top of the stack.
5CB6
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
5CB7
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the command.
5CB8
GOSUB to 6593H for file area 0: Index Register IX the area, Register Pair DE its file control block, where the command is put.
5CBB
POP AF F1
Restore Register Pair AF, the length in Register A, from the top of the stack.
5CBC
PUSH DE D5
Save Register Pair DE, the start of the copy, to the top of the stack.
5CBD
LD C,A 4F
Load Register C with Register A, the length of the command.
5CBE
LD B,00H 06 00
Load Register B with 00H, the high byte of the length in Register Pair BC.
5CC0
LDIR ED B0
Copy the command from Register Pair HL to Register Pair DE by LDIR, counted by Register Pair BC.
5CC2
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the byte after the command.
5CC3
LD (HL),03H 36 03
Store 03H at Register Pair HL, the end of the command line for CMNDI@.
5CC5
LD HL,62F5H 21 F5 62
Point Register Pair HL to 62F5H, the state of the long error messages.
5CC8
SET 1,(HL) CB CE
SET bit 1 of the byte at Register Pair HL (62F5H): the command may load over ERROR/OVL, so it is loaded again for the next error.
5CCA
LD HL,5CD6H 21 D6 5C
Point Register Pair HL to 5CD6H, BASIC's return to READY with a new stack.
5CCD
LD (4031H),HL 22 31 40
Store Register Pair HL (5CD6H) into 4031H-4032H, the operand of ABORT@'s JP at 4030H: an error of the command comes back to BASIC.
5CD0
POP HL E1
Restore Register Pair HL, the start of the copied command, from the top of the stack.
5CD1
GOSUB to 4405H, CMNDI@, to run the command at Register Pair HL; it returns here when the command is done.
5CD4
POP HL E1
Restore Register Pair HL, the text pointer after the expression, from the top of the stack.
5CD5
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.

5CD6H - Back to READY

ABORT@ (4030H, set at 5CCDH) and the vector at 4203H-4205H (5210H) come here. The ROM's 19AEH resets the stack and the BASIC pointers and goes on at 1A18H, which falls into READY.

5CD6
LD BC,1A18H 01 18 1A
Load Register Pair BC with 1A18H, where the ROM's 19AEH goes on: the POP BC before the ROM's READY at 1A19H.
5CD9
JUMP to 19AEH, the ROM's routine that resets the stack and continues at Register Pair BC.

5CDCH - CMD"M"

Shows every simple variable from VARTAB (40F9H) to ARYTAB (40FBH): the name in four columns with its type character ($, % or #; none for single precision), " = " and the value, one a line; names with bit 7 set (user functions) are passed over. With ,P the output goes to the printer (409CH = 01H). The current line becomes FFFFH (direct mode); the ROM's 1D9BH lets SHIFT @ pause and BREAK stop the list, and the end is READY.

5CDC
POP HL E1
Restore Register Pair HL, the text pointer after the string, from the top of the stack.
5CDD
POP DE D1
Restore Register Pair DE with the statement's return address, which CMD"M" does not use: it ends at READY.
5CDE
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the string again.
5CDF
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character of the text: the Z FLAG at the end of the statement.
5CE0
If the Z FLAG is set (no ,P), JUMP to 5CF0H with the output on the display.
5CE2
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before P, or the ROM shows a Syntax error.
5CE4
RES 5,A CB AF
RESET bit 5 of Register A, which makes a lower case letter upper case.
5CE6
CP 50H FE 50
Compare Register A against 50H, the letter P: the output to the printer.
5CE8
If the NZ FLAG is set (not P), JUMP to 1997H, the ROM's Syntax error.
5CEB
LD A,01H 3E 01
Load Register A with 01H, the ROM's output selection for the printer.
5CED
LD (409CH),A 32 9C 40
Store Register A (01H) to 409CH, the ROM's output device byte: the printer.
5CF0
LD HL,FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the line number of the direct mode.
5CF3
LD (40A2H),HL 22 A2 40
Store Register Pair HL (FFFFH) into 40A2H-40A3H, the ROM's current line number.
5CF6
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the first simple variable.
5CF9
LD DE,(40FBH) ED 5B FB 40
Load Register Pair DE with ARYTAB from 40FBH-40FCH, the end of the simple variables.
5CFD
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG at the end of the simple variables.
5CFE
If the Z FLAG is set (all shown), JUMP to 1A19H, the ROM's READY.
5D01
GOSUB to 1D9BH, the ROM's test of SHIFT @ (pause) and BREAK (stop) on the keyboard.
5D04
PUSH HL E5
Save Register Pair HL, the variable's entry, to the top of the stack.
5D05
LD B,04H 06 04
Load Register B with 04H, the width of the name column.
5D07
LD C,(HL) 4E
Load Register C with the variable's type at Register Pair HL: 02H integer, 03H string, 04H single, 08H double precision.
5D08
INC HL 23
INCrement Register Pair HL by 1, to the second character of the name.
5D09
INC HL 23
INCrement Register Pair HL by 1, to the first character of the name.
5D0A
LD A,(HL) 7E
Load Register A with the first character of the name at Register Pair HL.
5D0B
BIT 7,A CB 7F
Test bit 7 of Register A: the NZ FLAG for an entry that is not a simple variable.
5D0D
If the NZ FLAG is set (bit 7), JUMP to 5D68H to pass over the entry.
5D0F
GOSUB to 5D71H to output the first character of the name in Register A and count it in Register B.
5D12
DEC HL 2B
DECrement Register Pair HL by 1, to the second character of the name.
5D13
LD A,(HL) 7E
Load Register A with the second character of the name at Register Pair HL: 00H for a name of one letter.
5D14
OR A B7
OR Register A against itself: the Z FLAG for no second character.
5D15
If the NZ FLAG is set (a second character), GOSUB to 5D71H to output it from Register A.
5D18
LD A,24H 3E 24
Load Register A with 24H, the character $ of a string variable.
5D1A
BIT 0,C CB 41
Test bit 0 of Register C, the type: the NZ FLAG for a string (03H).
5D1C
If the NZ FLAG is set (a string), JUMP to 5D28H to output the $.
5D1E
LD A,25H 3E 25
Load Register A with 25H, the character % of an integer variable.
5D20
BIT 1,C CB 49
Test bit 1 of Register C, the type: the NZ FLAG for an integer (02H).
5D22
If the NZ FLAG is set (an integer), JUMP to 5D28H to output the %.
5D24
LD A,23H 3E 23
Load Register A with 23H, the character # of a double precision variable.
5D26
BIT 3,C CB 59
Test bit 3 of Register C, the type: the NZ FLAG for double precision (08H), the Z FLAG for single precision.
5D28
If the NZ FLAG is set, GOSUB to 5D71H to output the type character in Register A (single precision has none).
5D2B
LD A,20H 3E 20
Load Register A with 20H, the space that fills the name column.
5D2D
GOSUB to 5D71H to output the space in Register A: Register B counts down the column.
5D30
If the NZ FLAG is set (the column is not full), LOOP back to 5D2DH.
5D32
LD A,3DH 3E 3D
Load Register A with 3DH, the character = between the name and the value.
5D34
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device.
5D37
LD A,20H 3E 20
Load Register A with 20H, the space after the =.
5D39
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device.
5D3C
INC HL 23
INCrement Register Pair HL by 1, to the third byte of the entry.
5D3D
INC HL 23
INCrement Register Pair HL by 1, to the value of the variable.
5D3E
LD A,C 79
Load Register A with Register C, the type of the variable.
5D3F
LD (40AFH),A 32 AF 40
Store Register A, the type, to 40AFH, the ROM's type of the value in the accumulator.
5D42
GOSUB to 09F7H, the ROM's routine that copies the value at Register Pair HL into the accumulator by its type.
5D45
RST 20H E7
RST 20H: test the type of the accumulator: the Z FLAG for a string.
5D46
If the Z FLAG is set (a string), JUMP to 5D52H to output its characters.
5D48
PUSH BC C5
Save Register Pair BC, the type in Register C, to the top of the stack.
5D49
GOSUB to 0FBDH, the ROM's conversion of the number in the accumulator to text: Register Pair HL returns the text.
5D4C
GOSUB to 28A7H, the ROM's routine that outputs the text at Register Pair HL up to its 00H.
5D4F
POP BC C1
Restore Register Pair BC, the type in Register C, from the top of the stack.
5D50
JUMP to 5D63H to end the line of the variable with its carriage return.
5D52
LD A,(4121H) 3A 21 41
Load Register A with the length of the string from 4121H, the first byte of its descriptor in the accumulator.
5D55
OR A B7
OR Register A against itself: the Z FLAG for an empty string.
5D56
If the Z FLAG is set (empty), JUMP to 5D63H to end the line.
5D58
LD B,A 47
Load Register B with Register A, the length of the string, as the count.
5D59
LD HL,(4122H) 2A 22 41
Load Register Pair HL with the address of the string from 4122H-4123H in the accumulator.
5D5C
LD A,(HL) 7E
Load Register A with the character of the string at Register Pair HL.
5D5D
GOSUB to 5D71H to output the character in Register A and count it in Register B.
5D60
INC HL 23
INCrement Register Pair HL by 1, to the next character of the string.
5D61
If the NZ FLAG is set (characters left), LOOP back to 5D5CH.
5D63
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return that ends the variable's line.
5D65
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device.
5D68
POP HL E1
Restore Register Pair HL, the variable's entry, from the top of the stack.
5D69
INC C 0C
INCrement Register C by 1, the type, on the way to the length of the entry.
5D6A
INC C 0C
INCrement Register C by 1 again, the type, on the way to the length of the entry.
5D6B
INC C 0C
INCrement Register C by 1: Register C = the length of the entry (the type byte, the two name bytes and the value).
5D6C
LD B,00H 06 00
Load Register B with 00H, the high byte of the length in Register Pair BC.
5D6E
ADD HL,BC 09
ADD Register Pair BC, the length of the entry, to Register Pair HL: the next variable.
5D6F
LOOP back to 5CF9H for the next variable, until ARYTAB is reached.

5D71H - Output and Count

Outputs the character in Register A to the selected device (the ROM's 032AH) and decrements Register B: the Z FLAG when the count reaches zero.

5D71
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device.
5D74
DEC B 05
DECrement Register B by 1, the count of characters: the Z FLAG at zero.
5D75
RET C9
RETurn to the caller with the flags of the count in Register B.

5D76H - TIME$

Link 4176H, the function TIME$: a new string of 17 characters, the date MM/DD/YY from GTDATE@, a space, and the time HH:MM:SS from GTTIME@.

5D76
RST 10H D7
RST 10H: increment Register Pair HL past the token of TIME$ and load Register A with the next character.
5D77
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack for the end of the function.
5D78
LD A,11H 3E 11
Load Register A with 11H, the length of the new string: 17 characters.
5D7A
GOSUB to 2857H, the ROM's STRINI, to make room for a string of Register A characters and build its descriptor at 40D3H.
5D7D
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the address of the new string from 40D4H-40D5H, the descriptor's address bytes.
5D80
GOSUB to 4470H, GTDATE@, which writes the date MM/DD/YY at Register Pair HL and leaves Register Pair HL after it.
5D83
LD (HL),20H 36 20
Store 20H, a space, at Register Pair HL between the date and the time.
5D85
INC HL 23
INCrement Register Pair HL by 1, to the place of the time in the new string.
5D86
GOSUB to 446DH, GTTIME@, which writes the time HH:MM:SS at Register Pair HL.
5D89
JUMP to 2884H, the ROM's PUTNEW, which makes the new string the result and returns to the expression evaluator.

5D8CH - DEF

Link 415BH, the statement DEF, with Register A = the token after it. DEFUSRn=address (C1H, the token of USR) stores the address into the table 5DBEH. DEF FN stores the address of the definition's text into the value of the function's entry, a variable whose name has bit 7 set; a definition is allowed only in a program line (the ROM's 2828H), and its parameter list is only checked here, then the rest of the line is passed over as DATA is.

5D8C
CP C1H FE C1
Compare Register A, the token after DEF, against C1H, the token of USR.
5D8E
If the Z FLAG is set (DEFUSR), JUMP to 5DAFH.
5D90
GOSUB to 5DFBH to check the token of FN and find the function's entry: Register Pair DE returns the address of its value.
5D93
GOSUB to 2828H, the ROM's test of the direct mode, which gives Illegal direct when DEF FN is not in a program line.
5D96
LD A,L 7D
Load Register A with Register L, the low byte of the text pointer: the definition's parameters or its =.
5D97
LD (DE),A 12
Store Register A to the function's value at Register Pair DE, the low byte of the definition's address.
5D98
INC DE 13
INCrement Register Pair DE by 1, to the high byte of the function's value.
5D99
LD A,H 7C
Load Register A with Register H, the high byte of the text pointer.
5D9A
LD (DE),A 12
Store Register A to the function's value at Register Pair DE, the high byte of the definition's address.
5D9B
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, after the function's name.
5D9C
CP 28H FE 28
Compare Register A against 28H, the ( of a parameter list.
5D9E
If the NZ FLAG is set (no parameters), JUMP to 1F05H, the ROM's DATA, which passes over the rest of the statement.
5DA1
RST 10H D7
RST 10H: increment Register Pair HL past the ( and load Register A with the next character.
5DA2
GOSUB to 260DH, the ROM's variable search, to check the name of a parameter at Register Pair HL.
5DA5
LD A,(HL) 7E
Load Register A with the character at Register Pair HL after the parameter.
5DA6
CP 29H FE 29
Compare Register A against 29H, the ) that ends the parameter list.
5DA8
If the Z FLAG is set (the end of the list), JUMP to 1F05H, the ROM's DATA, which passes over the rest of the statement.
5DAB
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma between parameters, or the ROM shows a Syntax error.
5DAD
LOOP back to 5DA2H for the next parameter of the definition.
5DAF
GOSUB to 5EECH to take the digit after USR: Register Pair DE returns the address of its entry in the table 5DBEH.
5DB2
PUSH DE D5
Save Register Pair DE, the table entry, to the top of the stack.
5DB3
RST 08H => D5H CF D5
RST 08H: the next character of the text at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
5DB5
GOSUB to 2B02H, the ROM's routine that evaluates the expression at Register Pair HL as an integer into Register Pair DE.
5DB8
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the table entry, the text pointer is saved.
5DB9
LD (HL),E 73
Store Register E, the low byte of the routine's address, at Register Pair HL in the table.
5DBA
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the table entry.
5DBB
LD (HL),D 72
Store Register D, the high byte of the routine's address, at Register Pair HL in the table.
5DBC
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
5DBD
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.

5DBEH - The USR Table

Data: the addresses of USR0-USR9, set by DEFUSRn. Each starts as 1E4AH, the ROM's Illegal function call error, so a USR that was not defined gives that error.

5DBE-5DBF
DEFW 1E4AH 4A 1E
USR0 and USR without a digit: 1E4AH, Illegal function call, until DEFUSR0 sets it.
5DC0-5DC1
DEFW 1E4AH 4A 1E
USR1: 1E4AH, Illegal function call, until DEFUSR1 sets it.
5DC2-5DC3
DEFW 1E4AH 4A 1E
USR2: 1E4AH, Illegal function call, until DEFUSR2 sets it.
5DC4-5DC5
DEFW 1E4AH 4A 1E
USR3: 1E4AH, Illegal function call, until DEFUSR3 sets it.
5DC6-5DC7
DEFW 1E4AH 4A 1E
USR4: 1E4AH, Illegal function call, until DEFUSR4 sets it.
5DC8-5DC9
DEFW 1E4AH 4A 1E
USR5: 1E4AH, Illegal function call, until DEFUSR5 sets it.
5DCA-5DCB
DEFW 1E4AH 4A 1E
USR6: 1E4AH, Illegal function call, until DEFUSR6 sets it.
5DCC-5DCD
DEFW 1E4AH 4A 1E
USR7: 1E4AH, Illegal function call, until DEFUSR7 sets it.
5DCE-5DCF
DEFW 1E4AH 4A 1E
USR8: 1E4AH, Illegal function call, until DEFUSR8 sets it.
5DD0-5DD1
DEFW 1E4AH 4A 1E
USR9: 1E4AH, Illegal function call, until DEFUSR9 sets it.

5DD2H - Save a Parameter

Part of FN (5E37H): saves the value of a parameter variable before FN gives it the argument. Register Pair HL is the variable's value, 40AFH its type. A string's descriptor is copied into the ROM's pool of temporary strings (2888H); a number's value is pushed, one word for an integer, two for single and four for double precision. Then the variable's address and Register Pair AF (Register A = the type less 3, with its flags and the C FLAG set; 00H and the Z FLAG for a string) are pushed for the restore at 5E7BH. FN always comes here with the C FLAG set, so 5DEDH and the jump to 2423H are not reached.

5DD2
LD A,(40AFH) 3A AF 40
Load Register A with the type of the parameter variable from 40AFH: 02H, 03H, 04H or 08H.
5DD5
SUB 03H D6 03
SUBtract 03H from Register A: FFH integer, 00H string, 01H single, 05H double precision.
5DD7
OR A B7
OR Register A against itself: the Z FLAG for a string, the M FLAG for an integer, the PO FLAG for single precision.
5DD8
SCF 37
Set the C FLAG, the mark of a parameter's saved value.
5DD9
If the Z FLAG is set (a string), JUMP to 5E39H.
5DDB
LD C,(HL) 4E
Load Register C with the low byte of the value's first word at Register Pair HL.
5DDC
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the first word.
5DDD
LD B,(HL) 46
Load Register B with the high byte of the value's first word at Register Pair HL.
5DDE
PUSH BC C5
Save Register Pair BC, the first word of the value, to the top of the stack.
5DDF
If the M FLAG is set (an integer, one word), JUMP to 5DF9H.
5DE2
INC HL 23
INCrement Register Pair HL by 1, to the second word of the value.
5DE3
LD C,(HL) 4E
Load Register C with the low byte of the value's second word at Register Pair HL.
5DE4
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the second word.
5DE5
LD B,(HL) 46
Load Register B with the high byte of the value's second word at Register Pair HL.
5DE6
PUSH BC C5
Save Register Pair BC, the second word of the value, to the top of the stack.
5DE7
If the PO FLAG is set (single precision, two words), JUMP to 5DF9H.
5DEA
INC HL 23
INCrement Register Pair HL by 1, to the third word of a double precision value.
5DEB
If the C FLAG is set (always, from FN), JUMP to 5DF0H.
5DED
LD HL,411DH 21 1D 41
Point Register Pair HL to 411DH, the low bytes of the accumulator's double precision value (not reached from FN).
5DF0
LD C,(HL) 4E
Load Register C with the low byte of the third word at Register Pair HL.
5DF1
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the third word.
5DF2
LD B,(HL) 46
Load Register B with the high byte of the third word at Register Pair HL.
5DF3
INC HL 23
INCrement Register Pair HL by 1, to the fourth word.
5DF4
PUSH BC C5
Save Register Pair BC, the third word of the value, to the top of the stack.
5DF5
LD C,(HL) 4E
Load Register C with the low byte of the fourth word at Register Pair HL.
5DF6
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the fourth word.
5DF7
LD B,(HL) 46
Load Register B with the high byte of the fourth word at Register Pair HL.
5DF8
PUSH BC C5
Save Register Pair BC, the fourth word of the value, to the top of the stack.
5DF9
If the C FLAG is set (always, from FN), JUMP to 5E43H to save the variable's address and its type.

5DFBH - Find a Function

Checks the token of FN at Register Pair HL and finds the function's entry with the ROM's variable search, its name's first character with bit 7 set (so it is apart from the variable of that name) and no subscripts (40DCH = 80H): Register Pair DE returns the address of its value.

5DFB
RST 08H => BEH CF BE
RST 08H: the next character of the text at Register Pair HL must be BEH, the token of FN, or the ROM shows a Syntax error.
5DFD
LD A,80H 3E 80
Load Register A with 80H, the flag that the name may have no subscripts.
5DFF
LD (40DCH),A 32 DC 40
Store Register A (80H) to 40DCH, the ROM's subscript flag for its variable search.
5E02
OR (HL) B6
OR Register A (80H) with the first character of the name at Register Pair HL: the character with bit 7 set.
5E03
LD B,A 47
Load Register B with Register A, the first character of the function's name with bit 7 set.
5E04
JUMP to 2612H, the ROM's variable search after it has taken the first character into Register B: Register Pair DE returns the value's address.

5E07H - FN

Link 4155H, a call of a function defined by DEF FN. The function's entry gives the address of its definition (none: Undefined user function, 5EFEH). With parameters, each parameter variable's value is saved (5DD2H) and the arguments are assigned to them one by one (the ROM's 1F2BH, as LET); the definition's expression is evaluated, and the saved values are put back (5E7BH). A string result is moved to 40D3H first, so it survives the restore. The result is converted to the function's own type (the ROM's 281AH), which returns with Register Pair HL at the text after the call.

5E07
GOSUB to 5DFBH to check the token of FN and find the function's entry: Register Pair DE returns the address of its value.
5E0A
LD A,(40AFH) 3A AF 40
Load Register A with the type of the function from 40AFH, set by the variable search.
5E0D
OR A B7
OR Register A against itself: the NZ FLAG and the NC FLAG, the mark of the end of the saved values.
5E0E
PUSH AF F5
Save Register Pair AF, the function's type, to the top of the stack.
5E0F
LD (40F3H),HL 22 F3 40
Store Register Pair HL, the text pointer after the function's name, into 40F3H-40F4H.
5E12
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the function's value, Register Pair DE = the text pointer.
5E13
LD A,(HL) 7E
Load Register A with the low byte of the definition's address at Register Pair HL.
5E14
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the definition's address.
5E15
LD H,(HL) 66
Load Register H with the high byte of the definition's address at Register Pair HL.
5E16
LD L,A 6F
Load Register L with Register A: Register Pair HL = the text of the definition after the function's name.
5E17
OR H B4
OR Register A with Register H: the Z FLAG when the address is 0000H, a function never defined.
5E18
If the Z FLAG is set (not defined), JUMP to 5EFEH, the error Undefined user function.
5E1B
LD A,(HL) 7E
Load Register A with the character of the definition at Register Pair HL.
5E1C
CP 28H FE 28
Compare Register A against 28H, the ( of the definition's parameter list.
5E1E
If the NZ FLAG is set (no parameters), JUMP to 5E6CH.
5E20
RST 10H D7
RST 10H: increment Register Pair HL past the ( and load Register A with the next character.
5E21
LD (40D8H),HL 22 D8 40
Store Register Pair HL, the definition's first parameter, into 40D8H-40D9H for the assignment of the arguments.
5E24
JUMP to 5E28H to save the value of the first parameter variable.
5E26
RST 08H => 2CH CF 2C
RST 08H: the next character of the definition at Register Pair HL must be 2CH, the comma between parameters, or the ROM shows a Syntax error.
5E28
LD C,04H 0E 04
Load Register C with 04H, the room to check: eight bytes, the most a saved value needs.
5E2A
GOSUB to 1963H, the ROM's check that twice Register C bytes are free, else Out of memory.
5E2D
LD A,80H 3E 80
Load Register A with 80H, the flag that the name may have no subscripts.
5E2F
LD (40DCH),A 32 DC 40
Store Register A (80H) to 40DCH, the ROM's subscript flag for its variable search.
5E32
GOSUB to 260DH, the ROM's variable search, for the parameter at Register Pair HL: Register Pair DE returns its value's address.
5E35
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the parameter's value, Register Pair DE = the definition's text.
5E36
SCF 37
Set the C FLAG for the saving of a parameter's value.
5E37
JUMP to 5DD2H to save the value of the parameter variable.
5E39
JP NC,2423H D2 23 24
If the NC FLAG is set (not reached: FN sets the C FLAG), JUMP to 2423H.
5E3C
PUSH DE D5
Save Register Pair DE, the variable's address, to the top of the stack.
5E3D
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the variable's descriptor, Register Pair HL = the definition's text.
5E3E
GOSUB to 2888H, the ROM's routine that copies the descriptor at Register Pair DE into its pool of temporary strings: Register Pair HL returns the variable's address.
5E41
POP DE D1
Restore Register Pair DE, the definition's text, from the top of the stack.
5E42
XOR A AF
Set Register A to 00H by XORing it with itself: the Z FLAG marks a saved string.
5E43
PUSH HL E5
Save Register Pair HL, the address for the restore of the parameter, to the top of the stack.
5E44
PUSH AF F5
Save Register Pair AF, the parameter's type in Register A and its flags, to the top of the stack.
5E45
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the definition's text.
5E46
LD A,(HL) 7E
Load Register A with the character of the definition at Register Pair HL after the parameter.
5E47
CP 29H FE 29
Compare Register A against 29H, the ) that ends the parameter list.
5E49
If the NZ FLAG is set (more parameters), LOOP back to 5E26H for the next one.
5E4B
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the text pointer after the function's name in the call, from 40F3H-40F4H.
5E4E
RST 08H => 28H CF 28
RST 08H: the next character of the call at Register Pair HL must be 28H, the ( of the arguments, or the ROM shows a Syntax error.
5E50
PUSH HL E5
Save Register Pair HL, the call's first argument, to the top of the stack.
5E51
LD HL,(40D8H) 2A D8 40
Load Register Pair HL with the definition's first parameter from 40D8H-40D9H.
5E54
GOSUB to 260DH, the ROM's variable search, for the parameter at Register Pair HL: Register Pair DE returns its value's address.
5E57
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the argument, the definition's text saved.
5E58
GOSUB to 1F2BH, the ROM's assignment of LET: evaluate the argument at Register Pair HL and store it in the variable at Register Pair DE.
5E5B
LD A,(HL) 7E
Load Register A with the character of the call at Register Pair HL after the argument.
5E5C
CP 29H FE 29
Compare Register A against 29H, the ) that ends the arguments.
5E5E
If the Z FLAG is set (the last argument), JUMP to 5E67H.
5E60
RST 08H => 2CH CF 2C
RST 08H: the next character of the call at Register Pair HL must be 2CH, the comma between arguments, or the ROM shows a Syntax error.
5E62
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the definition's text, the call saved.
5E63
RST 08H => 2CH CF 2C
RST 08H: the next character of the definition at Register Pair HL must be 2CH, the comma between parameters, or the ROM shows a Syntax error.
5E65
LOOP back to 5E54H for the next parameter and its argument.
5E67
RST 10H D7
RST 10H: increment Register Pair HL past the ) of the call and load Register A with the next character.
5E68
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the definition's text, the call's text pointer saved.
5E69
RST 08H => 29H CF 29
RST 08H: the next character of the definition at Register Pair HL must be 29H, the ) of its parameters, or the ROM shows a Syntax error.
5E6B
LD A,D5H 3E D5
Load Register A with D5H, a byte with no use here. 5E6CH (a definition without parameters) enters inside it at its operand D5H, which reads as PUSH DE and saves the call's text pointer.
5E6D
RST 08H => D5H CF D5
RST 08H: the next character of the definition at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
5E6F
GOSUB to 2337H, the ROM's expression evaluator, for the definition's expression at Register Pair HL.
5E72
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the expression again.
5E73
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
5E74
If the NZ FLAG is set (more text in the definition), JUMP to 1997H, the ROM's Syntax error.
5E77
RST 20H E7
RST 20H: test the type of the result in the accumulator: the Z FLAG for a string.
5E78
If the Z FLAG is set (a string), JUMP to 5EA9H to move the result out of the temporary pool.
5E7A
POP DE D1
Restore Register Pair DE, the call's text pointer, from the top of the stack.
5E7B
POP AF F1
Restore Register Pair AF, the type and flags of the next saved value, from the top of the stack.
5E7C
If the Z FLAG is set (a saved string), JUMP to 5EBDH to put the string back.
5E7E
If the NC FLAG is set (the mark of the function's own type), JUMP to 5E9CH: every parameter is restored.
5E80
POP HL E1
Restore Register Pair HL, the address of the last byte of the parameter's value, from the top of the stack.
5E81
POP BC C1
Restore Register Pair BC, the last word of the saved value, from the top of the stack.
5E82
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
5E83
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
5E84
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
5E85
If the M FLAG is set (an integer, one word), LOOP back to 5E7BH for the next saved value.
5E88
DEC HL 2B
DECrement Register Pair HL by 1, to the high byte of the word before.
5E89
POP BC C1
Restore Register Pair BC, the next word of the saved value, from the top of the stack.
5E8A
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
5E8B
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
5E8C
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
5E8D
If the PO FLAG is set (single precision, two words), LOOP back to 5E7BH for the next saved value.
5E90
DEC HL 2B
DECrement Register Pair HL by 1, to the high byte of the word before.
5E91
POP BC C1
Restore Register Pair BC, the second word of a double precision value, from the top of the stack.
5E92
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
5E93
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
5E94
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
5E95
DEC HL 2B
DECrement Register Pair HL by 1, to the high byte of the first word.
5E96
POP BC C1
Restore Register Pair BC, the first word of the double precision value, from the top of the stack.
5E97
LD (HL),B 70
Store Register B, the high byte of the word, at Register Pair HL in the variable.
5E98
DEC HL 2B
DECrement Register Pair HL by 1, to the low byte of the word.
5E99
LD (HL),C 71
Store Register C, the low byte of the word, at Register Pair HL in the variable.
5E9A
LOOP back to 5E7BH for the next saved value on the stack.
5E9C
PUSH DE D5
Save Register Pair DE, the call's text pointer, to the top of the stack for the ROM's 281AH to restore into Register Pair HL.
5E9D
PUSH AF F5
Save Register Pair AF, the function's type, to the top of the stack.
5E9E
RST 20H E7
RST 20H: test the type of the result in the accumulator: the Z FLAG for a string.
5E9F
LD DE,40D3H 11 D3 40
Point Register Pair DE to 40D3H, the descriptor where a string result was put.
5EA2
If the Z FLAG is set (a string), GOSUB to 2888H to make the descriptor at Register Pair DE the result, a temporary string.
5EA5
POP AF F1
Restore Register Pair AF, the function's type in Register A, from the top of the stack.
5EA6
JUMP to 281AH, the ROM's conversion of the result to the type in Register A, which returns with Register Pair HL at the call's text.
5EA9
LD DE,(40B3H) ED 5B B3 40
Load Register Pair DE with 40B3H-40B4H, the ROM's pointer to the next free temporary string descriptor.
5EAD
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the address of the result's descriptor from 4121H-4122H in the accumulator.
5EB0
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG when the result is a temporary string.
5EB1
If the C FLAG is set (a temporary), JUMP to 5EB8H to move it to 40D3H.
5EB3
GOSUB to 2843H, the ROM's routine that copies the string of the descriptor at Register Pair HL into new string space, with its descriptor at 40D3H.
5EB6
JUMP to 5E7AH to restore the parameters with the result at 40D3H.
5EB8
POP DE D1
Restore Register Pair DE, the call's text pointer, from the top of the stack.
5EB9
LD HL,40D3H 21 D3 40
Point Register Pair HL to 40D3H, where the result's descriptor is put.
5EBC
PUSH HL E5
Save Register Pair HL (40D3H), the place for the descriptor, to the top of the stack.
5EBD
GOSUB to 29F5H, the ROM's routine that backs Register Pair HL up to the last temporary descriptor (Register Pair BC its string's address).
5EC0
LD A,(HL) 7E
Load Register A with the length of the string from the descriptor at Register Pair HL.
5EC1
LD (40B3H),HL 22 B3 40
Store Register Pair HL into 40B3H-40B4H, the ROM's pointer to the next free descriptor: the last temporary is freed.
5EC4
POP HL E1
Restore Register Pair HL, the place for the descriptor (40D3H or the parameter variable), from the top of the stack.
5EC5
LD (HL),A 77
Store Register A, the length, at Register Pair HL, the first byte of the descriptor.
5EC6
INC HL 23
INCrement Register Pair HL by 1, to the low byte of the string's address.
5EC7
LD (HL),C 71
Store Register C, the low byte of the string's address, at Register Pair HL.
5EC8
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
5EC9
LD (HL),B 70
Store Register B, the high byte of the string's address, at Register Pair HL.
5ECA
LOOP back to 5E7BH for the next saved value on the stack.

5ECCH - USR

Link 41A9H, the function USR. The ROM's return is dropped and the argument in parentheses is evaluated. The routine of the USR table (5DBEH) is entered by RET with Register A = the argument's type (02H, 03H, 04H or 08H), Register Pair HL = 4121H (the accumulator) and Register Pair DE = the string's descriptor for a string; it returns to the ROM's 26E7H, which restores the text pointer.

5ECC
POP AF F1
Restore Register Pair AF with the ROM's return address, which USR does not use: the routine returns through 26E7H.
5ECD
GOSUB to 5EECH to take the digit after USR: Register Pair DE returns the address of its entry in the table 5DBEH.
5ED0
PUSH DE D5
Save Register Pair DE, the table entry, to the top of the stack.
5ED1
GOSUB to 252CH, the ROM's evaluation of the argument in parentheses at Register Pair HL into the accumulator.
5ED4
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the table entry, the text pointer saved.
5ED5
LD C,(HL) 4E
Load Register C with the low byte of the routine's address at Register Pair HL.
5ED6
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the routine's address.
5ED7
LD B,(HL) 46
Load Register B with the high byte of the routine's address at Register Pair HL.
5ED8
LD HL,26E7H 21 E7 26
Point Register Pair HL to 26E7H, the ROM's code that restores the text pointer and goes on with the expression.
5EDB
PUSH HL E5
Save Register Pair HL (26E7H) to the top of the stack, the return address of the user's routine.
5EDC
PUSH BC C5
Save Register Pair BC, the routine's address, to the top of the stack, so that the RET below enters it.
5EDD
LD A,(40AFH) 3A AF 40
Load Register A with the type of the argument from 40AFH.
5EE0
PUSH AF F5
Save Register Pair AF, the type in Register A, to the top of the stack.
5EE1
CP 03H FE 03
Compare Register A against 03H, the type of a string.
5EE3
If the Z FLAG is set (a string), GOSUB to 29DAH, the ROM's FREFAC, which frees the string's temporary: Register Pair HL returns its descriptor.
5EE6
POP AF F1
Restore Register Pair AF, the type in Register A, from the top of the stack.
5EE7
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the string's descriptor.
5EE8
LD HL,4121H 21 21 41
Point Register Pair HL to 4121H, the accumulator with the argument's value.
5EEB
RET C9
RETurn into the user's routine with Register A, Register Pair HL and Register Pair DE set.

5EECH - The USR Number

Takes the digit after USR (none is USR0): Register Pair DE returns the address of its entry in the table 5DBEH, Register Pair HL the text after it.

5EEC
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after USR: the C FLAG for a digit.
5EED
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the offset of USR0.
5EF0
If the NC FLAG is set (no digit), JUMP to 5EF7H with USR0.
5EF2
SUB 30H D6 30
SUBtract 30H from Register A, the ASCII digit, giving its value 0-9 (and the NC FLAG).
5EF4
RLA 17
Rotate Register A left through the C FLAG: twice the digit, the offset of its word in the table.
5EF5
LD C,A 4F
Load Register C with Register A, the offset of the entry in Register Pair BC.
5EF6
RST 10H D7
RST 10H: increment Register Pair HL past the digit and load Register A with the next character.
5EF7
EX DE,HL EB
EXchange Register Pairs DE and HL, to keep the text pointer in Register Pair DE.
5EF8
LD HL,5DBEH 21 BE 5D
Point Register Pair HL to 5DBEH, the USR table.
5EFB
ADD HL,BC 09
ADD Register Pair BC, the offset, to Register Pair HL: the entry of the USR number.
5EFC
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the entry, Register Pair HL = the text pointer.
5EFD
RET C9
RETurn with Register Pair DE at the USR table's entry.
5EFE
LD E,2EH 1E 2E
Load Register E with 2EH, the offset of the error Undefined user function.
5F00
JUMP to 19A2H, the ROM's error routine, with the offset in Register E.

5F03H - INSTR

Link 419DH, the function INSTR([n,]a$,b$): the position of b$ in a$, searched from character n (1 when n is not given; n = 0 is Illegal function call). The result is 0 when n is past the end of a$, when a$ is empty or when b$ is not found; an empty b$ gives n. The routine returns Register A to the ROM's 27F8H, which makes it the integer result, and then to 26E7H, which restores the text pointer.

5F03
RST 10H D7
RST 10H: increment Register Pair HL past the token of INSTR and load Register A with the next character.
5F04
GOSUB to 2335H, the ROM's check of the ( and evaluation of the first expression at Register Pair HL.
5F07
RST 20H E7
RST 20H: test the type of the first expression: the Z FLAG for a string (a$, so n is 1).
5F08
LD A,01H 3E 01
Load Register A with 01H, the position to start from when n is not given.
5F0A
PUSH AF F5
Save Register Pair AF, the start in Register A, to the top of the stack.
5F0B
If the Z FLAG is set (the first expression is a$), JUMP to 5F1EH.
5F0D
POP AF F1
Restore Register Pair AF from the top of the stack: the first expression is n.
5F0E
GOSUB to 2B1FH, the ROM's CONINT, to make the value of n a byte in Register A.
5F11
OR A B7
OR Register A against itself: the Z FLAG for n = 0.
5F12
If the Z FLAG is set (n = 0), JUMP to 1E4AH, the ROM's Illegal function call error.
5F15
PUSH AF F5
Save Register Pair AF, the start n in Register A, to the top of the stack.
5F16
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after n, or the ROM shows a Syntax error.
5F18
GOSUB to 2337H, the ROM's expression evaluator, for a$ at Register Pair HL.
5F1B
GOSUB to 0AF4H, the ROM's test that the value is a string, else Type mismatch.
5F1E
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after a$, or the ROM shows a Syntax error.
5F20
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5F21
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the descriptor of a$ from 4121H-4122H in the accumulator.
5F24
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): a$ saved, Register Pair HL = the text pointer.
5F25
GOSUB to 2337H, the ROM's expression evaluator, for b$ at Register Pair HL.
5F28
RST 08H => 29H CF 29
RST 08H: the next character of the text at Register Pair HL must be 29H, the ) that ends INSTR, or the ROM shows a Syntax error.
5F2A
PUSH HL E5
Save Register Pair HL, the text pointer after INSTR, to the top of the stack.
5F2B
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns b$'s descriptor.
5F2E
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the descriptor of b$.
5F2F
POP BC C1
Restore Register Pair BC, the text pointer after INSTR, from the top of the stack.
5F30
POP HL E1
Restore Register Pair HL, the descriptor of a$, from the top of the stack.
5F31
POP AF F1
Restore Register Pair AF, the start n in Register A, from the top of the stack.
5F32
PUSH BC C5
Save Register Pair BC, the text pointer, to the top of the stack for the ROM's 26E7H.
5F33
LD BC,26E7H 01 E7 26
Load Register Pair BC with 26E7H, the ROM's code that restores the text pointer.
5F36
PUSH BC C5
Save Register Pair BC (26E7H) to the top of the stack, the second return address.
5F37
LD BC,27F8H 01 F8 27
Load Register Pair BC with 27F8H, the ROM's routine that makes Register A the integer result.
5F3A
PUSH BC C5
Save Register Pair BC (27F8H) to the top of the stack, the first return address of the search.
5F3B
PUSH AF F5
Save Register Pair AF, the start n, to the top of the stack.
5F3C
PUSH DE D5
Save Register Pair DE, the descriptor of b$, to the top of the stack.
5F3D
GOSUB to 29DDH, the ROM's routine that frees the temporary of the descriptor at Register Pair HL (a$) when it is the last one.
5F40
POP DE D1
Restore Register Pair DE, the descriptor of b$, from the top of the stack.
5F41
POP AF F1
Restore Register Pair AF, the start n, from the top of the stack.
5F42
LD B,A 47
Load Register B with Register A, the start n.
5F43
DEC A 3D
DECrement Register A by 1: the characters of a$ before the start.
5F44
LD C,A 4F
Load Register C with Register A, the characters before the start (n less 1).
5F45
CP (HL) BE
Compare Register A against the length of a$ at Register Pair HL: the NC FLAG when n is past the end.
5F46
LD A,00H 3E 00
Load Register A with 00H, the result when b$ is not found (the flags are kept).
5F48
RET NC D0
If the NC FLAG is set (n past the end of a$), RETurn with the result 0.
5F49
LD A,(HL) 7E
Load Register A with the length of a$ at Register Pair HL.
5F4A
OR A B7
OR Register A against itself: the Z FLAG for an empty a$.
5F4B
RET Z C8
If the Z FLAG is set (a$ empty), RETurn with the result 0 in Register A.
5F4C
LD A,(DE) 1A
Load Register A with the length of b$ at Register Pair DE.
5F4D
OR A B7
OR Register A against itself: the Z FLAG for an empty b$.
5F4E
LD A,B 78
Load Register A with Register B, the start n (the flags are kept).
5F4F
RET Z C8
If the Z FLAG is set (b$ empty), RETurn with the result n in Register A.
5F50
LD A,(HL) 7E
Load Register A with the length of a$ at Register Pair HL.
5F51
INC HL 23
INCrement Register Pair HL by 1, to the address of a$ in the descriptor.
5F52
LD B,(HL) 46
Load Register B with the low byte of a$'s address at Register Pair HL.
5F53
INC HL 23
INCrement Register Pair HL by 1, to the high byte of a$'s address.
5F54
LD H,(HL) 66
Load Register H with the high byte of a$'s address at Register Pair HL.
5F55
LD L,B 68
Load Register L with Register B: Register Pair HL = the characters of a$.
5F56
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
5F58
ADD HL,BC 09
ADD Register Pair BC (n less 1) to Register Pair HL: the start of the search in a$.
5F59
SUB C 91
SUBtract Register C (n less 1) from Register A, the length of a$: the characters left from the start.
5F5A
LD B,A 47
Load Register B with Register A, the characters of a$ left from the start.
5F5B
PUSH BC C5
Save Register Pair BC (Register B the characters left, Register C n less 1) to the top of the stack for the result.
5F5C
PUSH DE D5
Save Register Pair DE, the descriptor of b$, to the top of the stack.
5F5D
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = b$'s descriptor, the place in a$ saved.
5F5E
LD C,(HL) 4E
Load Register C with the length of b$ at Register Pair HL.
5F5F
INC HL 23
INCrement Register Pair HL by 1, to the address of b$ in the descriptor.
5F60
LD E,(HL) 5E
Load Register E with the low byte of b$'s address at Register Pair HL.
5F61
INC HL 23
INCrement Register Pair HL by 1, to the high byte of b$'s address.
5F62
LD D,(HL) 56
Load Register D with the high byte of b$'s address at Register Pair HL: Register Pair DE = the characters of b$.
5F63
POP HL E1
Restore Register Pair HL, the place in a$, from the top of the stack.
5F64
PUSH HL E5
Save Register Pair HL, the place in a$ where this try starts, to the top of the stack.
5F65
PUSH DE D5
Save Register Pair DE, the first character of b$, to the top of the stack.
5F66
PUSH BC C5
Save Register Pair BC (Register B the characters left in a$, Register C the length of b$) to the top of the stack.
5F67
LD A,(DE) 1A
Load Register A with the character of b$ at Register Pair DE.
5F68
CP (HL) BE
Compare Register A with the character of a$ at Register Pair HL.
5F69
If the NZ FLAG is set (they differ), JUMP to 5F82H to try from the next place in a$.
5F6B
INC DE 13
INCrement Register Pair DE by 1, to the next character of b$.
5F6C
DEC C 0D
DECrement Register C by 1, the characters of b$ still to compare.
5F6D
If the Z FLAG is set (all of b$ matched), JUMP to 5F79H to compute the position.
5F6F
INC HL 23
INCrement Register Pair HL by 1, to the next character of a$.
5F70
DEC B 05
DECrement Register B by 1, the characters left in a$.
5F71
If the NZ FLAG is set (a$ has more), LOOP back to 5F67H for the next character.
5F73
POP DE D1
Restore Register Pair DE from the top of the stack: the counts of this try are dropped.
5F74
POP DE D1
Restore Register Pair DE from the top of the stack: the start of b$ is dropped.
5F75
POP BC C1
Restore Register Pair BC from the top of the stack: the place in a$ is dropped.
5F76
POP DE D1
Restore Register Pair DE from the top of the stack: the counts of the start are dropped.
5F77
XOR A AF
Set Register A to 00H by XORing it with itself: b$ is not found, the result 0.
5F78
RET C9
RETurn with the result in Register A to the ROM's 27F8H.
5F79
POP HL E1
Restore Register Pair HL, the counts of this try: Register H the characters of a$ left where it started.
5F7A
POP DE D1
Restore Register Pair DE from the top of the stack: the start of b$ is dropped.
5F7B
POP DE D1
Restore Register Pair DE from the top of the stack: the place in a$ is dropped.
5F7C
POP BC C1
Restore Register Pair BC, the counts of the start: Register B the characters left, Register C n less 1.
5F7D
LD A,B 78
Load Register A with Register B, the characters of a$ left from n.
5F7E
SUB H 94
SUBtract Register H, the characters left where the match starts, from Register A: the match's distance from n.
5F7F
ADD A,C 81
ADD Register C (n less 1) to Register A, the distance of the match from n.
5F80
INC A 3C
INCrement Register A by 1: the position of b$ in a$, counted from 1.
5F81
RET C9
RETurn with the result in Register A to the ROM's 27F8H.
5F82
POP BC C1
Restore Register Pair BC, the counts of this try, from the top of the stack.
5F83
POP DE D1
Restore Register Pair DE, the first character of b$, from the top of the stack.
5F84
POP HL E1
Restore Register Pair HL, the place in a$ where this try started, from the top of the stack.
5F85
INC HL 23
INCrement Register Pair HL by 1, to the next place in a$.
5F86
DEC B 05
DECrement Register B by 1, the characters left in a$.
5F87
If the Z FLAG is set (no place left), JUMP to 5F76H with the result 0.
5F89
LOOP back to 5F64H to try b$ from the next place in a$.

5F8BH - MID$ =

Link 41D9H, MID$(v$,n[,m])=x$ on the left of an assignment, entered by the ROM's jump at 2AECH. A string whose characters are still in the program text is first copied into the string space, so that the program is not changed. Characters of x$ replace those of v$ from n, at most m (255 when m is not given), at most the rest of v$ and at most the length of x$; the length of v$ never changes. n = 0 or past the end of v$ is Illegal function call.

5F8B
INC HL 23
INCrement Register Pair HL by 1, past the token of MID$ to the (.
5F8C
RST 08H => 28H CF 28
RST 08H: the next character of the text at Register Pair HL must be 28H, the ( after MID$, or the ROM shows a Syntax error.
5F8E
GOSUB to 260DH, the ROM's variable search, for v$ at Register Pair HL: Register Pair DE returns its descriptor.
5F91
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
5F94
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
5F95
PUSH DE D5
Save Register Pair DE, the descriptor of v$, to the top of the stack.
5F96
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the descriptor of v$.
5F97
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
5F98
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
5F99
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
5F9A
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the characters of v$.
5F9B
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of the string space from 40A0H-40A1H.
5F9E
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG when the characters are in the string space.
5F9F
If the C FLAG is set (in the string space), JUMP to 5FABH: they may be changed in place.
5FA1
POP HL E1
Restore Register Pair HL, the descriptor of v$, from the top of the stack.
5FA2
PUSH HL E5
Save Register Pair HL, the descriptor of v$, to the top of the stack again.
5FA3
GOSUB to 2843H, the ROM's routine that copies the string of the descriptor at Register Pair HL into the string space, with its descriptor at 40D3H.
5FA6
POP HL E1
Restore Register Pair HL, the descriptor of v$, from the top of the stack.
5FA7
PUSH HL E5
Save Register Pair HL, the descriptor of v$, to the top of the stack again.
5FA8
GOSUB to 09D3H, the ROM's copy of the value at Register Pair DE (the new descriptor) into the variable at Register Pair HL.
5FAB
POP HL E1
Restore Register Pair HL, the descriptor of v$, from the top of the stack.
5FAC
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the text pointer, the descriptor saved.
5FAD
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before n, or the ROM shows a Syntax error.
5FAF
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate n as a byte into Register A.
5FB2
OR A B7
OR Register A against itself: the Z FLAG for n = 0.
5FB3
If the Z FLAG is set (n = 0), JUMP to 1E4AH, the ROM's Illegal function call error.
5FB6
PUSH AF F5
Save Register Pair AF, n in Register A, to the top of the stack.
5FB7
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL after n.
5FB8
GOSUB to 5FFCH to take ,m and the ): Register E returns m, FFH when it is not given.
5FBB
PUSH DE D5
Save Register Pair DE, m in Register E, to the top of the stack.
5FBC
RST 08H => D5H CF D5
RST 08H: the next character of the text at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
5FBE
GOSUB to 2337H, the ROM's expression evaluator, for x$ at Register Pair HL.
5FC1
PUSH HL E5
Save Register Pair HL, the text pointer after the statement, to the top of the stack.
5FC2
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns x$'s descriptor.
5FC5
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the descriptor of x$.
5FC6
POP HL E1
Restore Register Pair HL, the text pointer after the statement, from the top of the stack.
5FC7
POP BC C1
Restore Register Pair BC, m in Register C, from the top of the stack.
5FC8
POP AF F1
Restore Register Pair AF, n in Register A, from the top of the stack.
5FC9
LD B,A 47
Load Register B with Register A, n, the first character of v$ to replace.
5FCA
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the descriptor of v$, the text pointer saved.
5FCB
PUSH HL E5
Save Register Pair HL, the descriptor of v$, to the top of the stack.
5FCC
LD HL,26E7H 21 E7 26
Point Register Pair HL to 26E7H, the ROM's code that restores the text pointer.
5FCF
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): 26E7H becomes the return address, Register Pair HL = the descriptor of v$.
5FD0
LD A,C 79
Load Register A with Register C, m, the most characters to replace.
5FD1
OR A B7
OR Register A against itself: the Z FLAG for m = 0.
5FD2
RET Z C8
If the Z FLAG is set (m = 0), RETurn through 26E7H: nothing is replaced.
5FD3
LD A,(HL) 7E
Load Register A with the length of v$ at Register Pair HL.
5FD4
SUB B 90
SUBtract Register B, n, from Register A: the C FLAG when n is past the end of v$.
5FD5
If the C FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call error.
5FD8
INC A 3C
INCrement Register A by 1: the characters of v$ from n to its end.
5FD9
CP C B9
Compare Register A against Register C, m: the C FLAG when fewer characters than m are left.
5FDA
If the C FLAG is set, JUMP to 5FDDH with the characters left as the count.
5FDC
LD A,C 79
Load Register A with Register C, m, as the count.
5FDD
LD C,B 48
Load Register C with Register B, n, the first character of v$ to replace.
5FDE
DEC C 0D
DECrement Register C by 1, n less 1, the offset of the first character replaced.
5FDF
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
5FE1
PUSH DE D5
Save Register Pair DE, the descriptor of x$, to the top of the stack.
5FE2
INC HL 23
INCrement Register Pair HL by 1, to the address of v$ in its descriptor.
5FE3
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
5FE4
INC HL 23
INCrement Register Pair HL by 1, to the high byte of v$'s address.
5FE5
LD H,(HL) 66
Load Register H with the high byte of v$'s address at Register Pair HL.
5FE6
LD L,E 6B
Load Register L with Register E: Register Pair HL = the characters of v$.
5FE7
ADD HL,BC 09
ADD Register Pair BC, the offset, to Register Pair HL: the first character to replace.
5FE8
LD B,A 47
Load Register B with Register A, the most characters to replace.
5FE9
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = x$'s descriptor, the place in v$ saved.
5FEA
LD A,(HL) 7E
Load Register A with the length of x$ at Register Pair HL.
5FEB
INC HL 23
INCrement Register Pair HL by 1, to the address of x$ in its descriptor.
5FEC
LD E,(HL) 5E
Load Register E with the low byte of x$'s address at Register Pair HL.
5FED
INC HL 23
INCrement Register Pair HL by 1, to the high byte of x$'s address.
5FEE
LD D,(HL) 56
Load Register D with the high byte of x$'s address at Register Pair HL: Register Pair DE = the characters of x$.
5FEF
POP HL E1
Restore Register Pair HL, the place in v$, from the top of the stack.
5FF0
LD C,A 4F
Load Register C with Register A, the length of x$.
5FF1
OR A B7
OR Register A against itself: the Z FLAG for an empty x$.
5FF2
RET Z C8
If the Z FLAG is set (x$ empty), RETurn through 26E7H: nothing is replaced.
5FF3
LD A,(DE) 1A
Load Register A with the next character of x$ at Register Pair DE.
5FF4
LD (HL),A 77
Store Register A, the character, at Register Pair HL in v$.
5FF5
INC DE 13
INCrement Register Pair DE by 1, to the next character of x$.
5FF6
INC HL 23
INCrement Register Pair HL by 1, to the next character of v$.
5FF7
DEC C 0D
DECrement Register C by 1, the characters of x$ left.
5FF8
RET Z C8
If the Z FLAG is set (x$ used up), RETurn through 26E7H.
5FF9
DECrement Register B and LOOP back to 5FF3H while characters may still be replaced.
5FFB
RET C9
RETurn through 26E7H, the ROM's code that restores the text pointer.

5FFCH - The Length of MID$ =

Takes the optional ,m and the ) of MID$(v$,n,m): Register E returns m, or FFH when the ) follows n.

5FFC
LD E,FFH 1E FF
Load Register E with FFH, the most characters to replace when m is not given.
5FFE
CP 29H FE 29
Compare Register A, the character after n, against 29H, the ) that ends the arguments.
6000
If the Z FLAG is set (no m), JUMP to 6007H to check the ) after n.
6002
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before m, or the ROM shows a Syntax error.
6004
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate m as a byte into Register E.
6007
RST 08H => 29H CF 29
RST 08H: the next character of the text at Register Pair HL must be 29H, the ) of MID$, or the ROM shows a Syntax error.
6009
RET C9
RETurn with m in Register E and Register Pair HL after the ).

600AH - &H

Link 4194H, a constant &Hnnnn (the H may be left out): up to four hexadecimal digits 0-9 and A-F, upper case, form an integer in the accumulator. A fifth digit is Overflow; the first other character ends the number.

600A
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value before the first digit.
600D
LD B,05H 06 05
Load Register B with 05H: the fifth digit is too many.
600F
RST 10H D7
RST 10H: increment Register Pair HL past the & and load Register A with the next character.
6010
CP 48H FE 48
Compare Register A against 48H, the letter H of &H.
6012
If the Z FLAG is set (H), JUMP to 6015H, to the first digit after it.
6014
DEC HL 2B
DECrement Register Pair HL by 1, so that the character after the & is read again as the first digit.
6015
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the C FLAG for a digit 0-9.
6016
GOSUB to 1E3EH, the ROM's letter test of Register A: the NC FLAG for a letter A-Z.
6019
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the value, Register Pair DE = the text pointer.
601A
If the NC FLAG is set (a letter), JUMP to 6026H.
601C
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9: the NC FLAG for anything above 9.
601E
If the NC FLAG is set (not a digit), JUMP to 6039H, the end of the number.
6020
SUB 30H D6 30
SUBtract 30H from Register A, the ASCII digit, giving its value.
6022
If the C FLAG is set (below 0), JUMP to 6039H, the end of the number.
6024
JUMP to 602CH to add the value of the digit to the number.
6026
CP 47H FE 47
Compare Register A against 47H, the letter G: the NC FLAG for a letter G-Z.
6028
If the NC FLAG is set (not a hexadecimal digit), JUMP to 6039H, the end of the number.
602A
SUB 37H D6 37
SUBtract 37H from Register A, the letter A-F, giving its value 0AH-0FH.
602C
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
602D
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
602E
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 8.
602F
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 16, one hexadecimal digit up.
6030
ADD A,L 85
ADD Register L to Register A, the value of the new digit.
6031
LD L,A 6F
Load Register L with Register A: the digit is in the low four bits of Register Pair HL.
6032
DEC B 05
DECrement Register B by 1, the digits still allowed.
6033
If the Z FLAG is set (a fifth digit), JUMP to 07B2H, the ROM's Overflow error.
6036
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the value, Register Pair HL = the text pointer.
6037
LOOP back to 6015H for the next digit of the number.
6039
GOSUB to 0A9AH, the ROM's routine that makes Register Pair HL the integer in the accumulator.
603C
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the text pointer at the character after the number.
603D
RET C9
RETurn to the expression evaluator with the integer in the accumulator.

603EH - PRINT #

Link 41CAH, called by the ROM's PRINT (206FH) with Register Pair HL at the #. PRINT #-1 is the ROM's cassette and is left to it. Otherwise the file number is evaluated (656FH): the file must be open for output (mode 02H, else Bad file mode), a comma must follow, and the file's area becomes the current one (62FCH), to which the output link 41C1H sends PRINT's characters.

603E
PUSH HL E5
Save Register Pair HL, the text pointer at the #, to the top of the stack.
603F
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after the #.
6040
CP CEH FE CE
Compare Register A against CEH, the token of the minus sign: PRINT #-1, the cassette.
6042
POP HL E1
Restore Register Pair HL, the text pointer at the #, from the top of the stack.
6043
LD A,(HL) 7E
Load Register A with the # at Register Pair HL, as the ROM expects it (the flags are kept).
6044
RET Z C8
If the Z FLAG is set (#-1), RETurn: the ROM writes to the cassette.
6045
LD C,02H 0E 02
Load Register C with 02H, the mode of a file open for output.
6047
JUMP to 656FH to take the file number and make its area the current one.

604AH - INPUT # and INPUT @

Link 41D6H, called by the ROM's INPUT (219EH) with Register A = the character after INPUT. INPUT @pos,["prompt",]len,"format";v$ (6064H) is the controlled input of a field. INPUT #-1 is the ROM's cassette. INPUT #n reads its line from a file open for input (656DH): the ROM's return is dropped and the items are taken by the ROM's INPUT code from 21EBH on, which gets them through the link 41DCH (65E9H).

604A
CP 40H FE 40
Compare Register A against 40H, the character @ of INPUT @.
604C
If the Z FLAG is set (INPUT @), JUMP to 6064H.
604E
CP 23H FE 23
Compare Register A against 23H, the character # of INPUT #.
6050
RET NZ C0
If the NZ FLAG is set (neither), RETurn to the ROM's INPUT from the keyboard.
6051
PUSH HL E5
Save Register Pair HL, the text pointer at the #, to the top of the stack.
6052
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after the #.
6053
CP CEH FE CE
Compare Register A against CEH, the token of the minus sign: INPUT #-1, the cassette.
6055
POP HL E1
Restore Register Pair HL, the text pointer at the #, from the top of the stack.
6056
LD A,(HL) 7E
Load Register A with the # at Register Pair HL, as the ROM expects it (the flags are kept).
6057
RET Z C8
If the Z FLAG is set (#-1), RETurn: the ROM reads from the cassette.
6058
POP BC C1
Restore Register Pair BC with the ROM's return address, which INPUT # does not use.
6059
GOSUB to 656DH to take the file number (open for input, mode 01H) and make its area the current one.
605C
PUSH HL E5
Save Register Pair HL, the text pointer at the first item, to the top of the stack.
605D
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
6060
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the buffer, as the ROM's INPUT expects.
6061
JUMP to 21EBH, the ROM's INPUT after the line has been taken: the items come from the file through the link 41DCH.
6064
POP BC C1
Restore Register Pair BC with the ROM's return address, which INPUT @ does not use.
6065
GOSUB to 2B01H, the ROM's GETINT, to evaluate the position after the @ into Register Pair DE (Register A its high byte).
6068
CP 04H FE 04
Compare Register A, the high byte of the position, against 04H: the NC FLAG for 1024 or more.
606A
If the NC FLAG is set (not on the display), JUMP to 1E4AH, the ROM's Illegal function call error.
606D
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
606E
LD HL,3C00H 21 00 3C
Point Register Pair HL to 3C00H, the first byte of the display.
6071
ADD HL,DE 19
ADD Register Pair DE, the position, to Register Pair HL: the place of the field on the display.
6072
LD (4020H),HL 22 20 40
Store Register Pair HL into 4020H-4021H, the cursor address of the display driver.
6075
LD A,E 7B
Load Register A with Register E, the low byte of the position.
6076
AND 3FH E6 3F
AND Register A with 3FH: the column of the position on its line, 0-63.
6078
LD (40A6H),A 32 A6 40
Store Register A, the column, to 40A6H, the ROM's cursor column.
607B
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
607C
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the position, or the ROM shows a Syntax error.
607E
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
607F
CP 22H FE 22
Compare Register A against 22H, the quotation mark of a prompt.
6081
If the NZ FLAG is set (no prompt), JUMP to 608DH.
6083
GOSUB to 2866H, the ROM's routine that takes the quoted string at Register Pair HL as a temporary string.
6086
PUSH HL E5
Save Register Pair HL, the text pointer after the prompt, to the top of the stack.
6087
GOSUB to 28AAH, the ROM's routine that shows the string of the descriptor in the accumulator.
608A
POP HL E1
Restore Register Pair HL, the text pointer after the prompt, from the top of the stack.
608B
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the prompt, or the ROM shows a Syntax error.
608D
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate the length of the field into Register E.
6090
LD A,E 7B
Load Register A with Register E, the length of the field.
6091
OR A B7
OR Register A against itself: the Z FLAG for a length of 0.
6092
If the Z FLAG is set (length 0), JUMP to 1E4AH, the ROM's Illegal function call error.
6095
PUSH AF F5
Save Register Pair AF, the length in Register A, to the top of the stack.
6096
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the length, or the ROM shows a Syntax error.
6098
GOSUB to 2337H, the ROM's expression evaluator, for the format string at Register Pair HL.
609B
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
609C
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns the format's descriptor.
609F
LD B,(HL) 46
Load Register B with the length of the format string at Register Pair HL.
60A0
INC HL 23
INCrement Register Pair HL by 1, to the address of the format string.
60A1
LD E,(HL) 5E
Load Register E with the low byte of the format's address at Register Pair HL.
60A2
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the format's address.
60A3
LD D,(HL) 56
Load Register D with the high byte of the format's address at Register Pair HL: Register Pair DE = the format.
60A4
INC B 04
INCrement Register B by 1, to test the length.
60A5
DEC B 05
DECrement Register B by 1: the Z FLAG for an empty format.
60A6
If the Z FLAG is set (an empty format), JUMP to 1E4AH, the ROM's Illegal function call error.
60A9
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
60AA
LD C,80H 0E 80
Load Register C with 80H, the flags of the field: bit 7 INPUT @.
60AC
LD A,(DE) 1A
Load Register A with the first character of the format at Register Pair DE.
60AD
INC DE 13
INCrement Register Pair DE by 1, to the second character of the format.
60AE
CP 24H FE 24
Compare Register A against 24H, the character $ of a field of any characters.
60B0
If the Z FLAG is set ($), JUMP to 60B9H, a field of any characters.
60B2
SET 0,C CB C1
SET bit 0 of Register C, the flag of a numeric field (# in the format).
60B4
CP 23H FE 23
Compare Register A against 23H, the character # of a numeric field.
60B6
If the NZ FLAG is set (neither $ nor #), JUMP to 1997H, the ROM's Syntax error.
60B9
DEC B 05
DECrement Register B by 1, the characters of the format left.
60BA
If the Z FLAG is set (one character), JUMP to 60C4H.
60BC
LD A,(DE) 1A
Load Register A with the second character of the format at Register Pair DE.
60BD
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk: the field ends by itself when it is full.
60BF
If the NZ FLAG is set (anything else), JUMP to 1997H, the ROM's Syntax error.
60C2
SET 1,C CB C9
SET bit 1 of Register C, the flag that a full field ends the input without ENTER.
60C4
POP AF F1
Restore Register Pair AF, the length of the field in Register A, from the top of the stack.
60C5
LD B,A 47
Load Register B with Register A, the length of the field.
60C6
RST 08H => 3BH CF 3B
RST 08H: the next character of the text at Register Pair HL must be 3BH, the semicolon before the variable, or the ROM shows a Syntax error.
60C8
JUMP to 60DAH, the variable and the input of LINE INPUT, with the flags of the field in Register C.

60CAH - LINE INPUT

Link 41A3H, the statement LINE, which must be LINE INPUT (the token 89H). It is not allowed in the direct mode. LINE INPUT # goes to 65FDH. Otherwise the ROM's 21CDH shows a quoted prompt, the line is taken from the keyboard by the ROM's 0361H (INPUT @ takes its field with 6101H instead, 60C8H), and the whole line, without any change, is assigned to the string variable (the ROM's 1F32H). BREAK goes to the ROM's 1DBEH.

60CA
RST 08H => 89H CF 89
RST 08H: the next character of the text at Register Pair HL must be 89H, the token of INPUT after LINE, or the ROM shows a Syntax error.
60CC
GOSUB to 2828H, the ROM's test of the direct mode, which gives Illegal direct outside a program.
60CF
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
60D0
CP 23H FE 23
Compare Register A against 23H, the character # of LINE INPUT #.
60D2
If the Z FLAG is set (LINE INPUT #), JUMP to 65FDH.
60D5
GOSUB to 21CDH, the ROM's routine that shows a quoted prompt at Register Pair HL and checks the semicolon after it.
60D8
LD C,00H 0E 00
Load Register C with 00H, the flags of a plain LINE INPUT (bit 7 clear: from the keyboard).
60DA
PUSH BC C5
Save Register Pair BC, the flags in Register C and the length of an INPUT @ field in Register B, to the top of the stack.
60DB
GOSUB to 260DH, the ROM's variable search, for the variable at Register Pair HL: Register Pair DE returns its descriptor.
60DE
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
60E1
POP BC C1
Restore Register Pair BC, the flags and the length, from the top of the stack.
60E2
PUSH DE D5
Save Register Pair DE, the variable's descriptor, to the top of the stack.
60E3
PUSH HL E5
Save Register Pair HL, the text pointer after the variable, to the top of the stack.
60E4
PUSH BC C5
Save Register Pair BC, the flags and the length, to the top of the stack.
60E5
BIT 7,C CB 79
Test bit 7 of Register C: the Z FLAG for a plain LINE INPUT.
60E7
If the Z FLAG is set, GOSUB to 0361H, the ROM's line input from the keyboard into the input buffer (the C FLAG for BREAK).
60EA
POP BC C1
Restore Register Pair BC, the flags and the length, from the top of the stack.
60EB
BIT 7,C CB 79
Test bit 7 of Register C: the NZ FLAG for INPUT @.
60ED
If the NZ FLAG is set, GOSUB to 6101H to take the INPUT @ field into the input buffer (the C FLAG for BREAK).
60F0
POP DE D1
Restore Register Pair DE, the text pointer after the variable, from the top of the stack.
60F1
POP BC C1
Restore Register Pair BC, the variable's descriptor, from the top of the stack.
60F2
If the C FLAG is set (BREAK), JUMP to 1DBEH, the ROM's handling of BREAK during an input.
60F5
PUSH BC C5
Save Register Pair BC, the variable's descriptor, to the top of the stack for the ROM's assignment.
60F6
PUSH DE D5
Save Register Pair DE, the text pointer, to the top of the stack.
60F7
LD B,00H 06 00
Load Register B with 00H, the character that ends the line in the input buffer.
60F9
GOSUB to 2868H, the ROM's routine that makes the text at Register Pair HL, up to the 00H in Register B, a temporary string.
60FC
POP HL E1
Restore Register Pair HL, the text pointer after the variable, from the top of the stack.
60FD
XOR A AF
Set Register A to 00H by XORing it with itself: the type of the value less 3, a string, for the ROM's 1F32H.
60FE
JUMP to 1F32H, the ROM's assignment of LET, which stores the string into the variable whose descriptor is on the stack.

6101H - The INPUT @ Field

Takes the field of INPUT @ (6128H) into the input buffer, ended by 00H. When nothing was typed, the key that ended the field is put in the buffer before the 00H. The ROM's cursor column (40A6H) is set from the cursor address. Returns Register Pair HL at the byte before the buffer, Register A the key that ended the field and the C FLAG for BREAK.

6101
LD HL,4099H 21 99 40
Point Register Pair HL to 4099H, the ROM's byte of the last key read.
6104
LD (HL),00H 36 00
Store 00H at Register Pair HL (4099H): no key is waiting.
6106
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
6109
GOSUB to 6128H to take the field: Register B returns the characters typed, Register A the key that ended it.
610C
PUSH AF F5
Save Register Pair AF, the ending key and the C FLAG of BREAK, to the top of the stack.
610D
PUSH HL E5
Save Register Pair HL, the input buffer, to the top of the stack.
610E
LD C,B 48
Load Register C with Register B, the characters typed.
610F
LD B,00H 06 00
Load Register B with 00H, the high byte of the count in Register Pair BC.
6111
ADD HL,BC 09
ADD Register Pair BC, the characters typed, to Register Pair HL: the end of the input.
6112
LD (HL),00H 36 00
Store 00H at Register Pair HL, the end of the input in the buffer.
6114
INC C 0C
INCrement Register C by 1, to test the count.
6115
DEC C 0D
DECrement Register C by 1: the Z FLAG when nothing was typed.
6116
If the NZ FLAG is set (characters typed), JUMP to 611CH.
6118
LD (HL),A 77
Store Register A, the key that ended the field, at Register Pair HL, the first byte of the buffer.
6119
INC HL 23
INCrement Register Pair HL by 1, to the byte after it.
611A
LD (HL),00H 36 00
Store 00H at Register Pair HL, the end of the input after the key.
611C
LD A,(4020H) 3A 20 40
Load Register A with the low byte of the cursor address from 4020H.
611F
AND 3FH E6 3F
AND Register A with 3FH: the column of the cursor on its line, 0-63.
6121
LD (40A6H),A 32 A6 40
Store Register A, the column, to 40A6H, the ROM's cursor column.
6124
POP HL E1
Restore Register Pair HL, the input buffer, from the top of the stack.
6125
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the buffer, as the ROM's input routines return it.
6126
POP AF F1
Restore Register Pair AF, the ending key and the C FLAG of BREAK, from the top of the stack.
6127
RET C9
RETurn to LINE INPUT with the field in the input buffer.

6128H - The Field Editor

The field of Register B characters is shown as underscores at the cursor, and the cursor is put back to its start. Keys are taken by the ROM's 0049H with the cursor shown. A printable key is stored and shown while the field has room; in a numeric field (bit 0 of the flags) only the digits and . + - are taken. A full field ends by itself when the format had the asterisk (bit 1), else it waits for a control key. ENTER and CLEAR end the field, BREAK ends it with the C FLAG, the left arrow (08H) takes back one character and SHIFT left arrow (18H) all of them; the other control keys are ignored. At the end a carriage return follows the text in the buffer and the rest of the field is cleared with spaces. Returns Register B = the characters typed and Register A = the key that ended the field.

6128
PUSH HL E5
Save Register Pair HL, the input buffer, to the top of the stack.
6129
PUSH BC C5
Save Register Pair BC, the length of the field in Register B and the flags in Register C, to the top of the stack.
612A
LD C,B 48
Load Register C with Register B, the length of the field.
612B
LD A,5FH 3E 5F
Load Register A with 5FH, the underscore that marks a place of the field.
612D
GOSUB to 0033H, the ROM's routine that shows the character in Register A on the display.
6130
DECrement Register B and LOOP back to 612BH until the whole field is shown.
6132
LD B,C 41
Load Register B with Register C, the length of the field.
6133
GOSUB to 61C2H to move the cursor back one place.
6136
DECrement Register B and LOOP back to 6133H until the cursor is at the start of the field.
6138
LD B,C 41
Load Register B with Register C: the room left in the field, all of it.
6139
LD A,0EH 3E 0E
Load Register A with 0EH, the control code that shows the cursor.
613B
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
613E
GOSUB to 0049H, the ROM's routine that waits for a key and returns it in Register A.
6141
CP 20H FE 20
Compare Register A against 20H, the space: the C FLAG for a control key.
6143
If the C FLAG is set (a control key), JUMP to 618EH.
6145
INC B 04
INCrement Register B by 1, to test the room left.
6146
DEC B 05
DECrement Register B by 1: the Z FLAG when the field is full.
6147
If the Z FLAG is set (no room), LOOP back to 6139H: the key is ignored.
6149
POP DE D1
Restore Register Pair DE from the top of the stack: the flags of the field in Register E.
614A
PUSH DE D5
Save Register Pair DE, the flags, to the top of the stack again.
614B
BIT 0,E CB 43
Test bit 0 of Register E: the Z FLAG for a field of any characters.
614D
If the Z FLAG is set (any characters), JUMP to 6163H to take the key.
614F
CP 2EH FE 2E
Compare Register A against 2EH, the decimal point, allowed in a numeric field.
6151
If the Z FLAG is set (.), JUMP to 6163H to take the key.
6153
CP 2BH FE 2B
Compare Register A against 2BH, the plus sign, allowed in a numeric field.
6155
If the Z FLAG is set (+), JUMP to 6163H to take the key.
6157
CP 2DH FE 2D
Compare Register A against 2DH, the minus sign, allowed in a numeric field.
6159
If the Z FLAG is set (-), JUMP to 6163H to take the key.
615B
CP 30H FE 30
Compare Register A against 30H, the digit 0: the C FLAG for a character below it.
615D
If the C FLAG is set (not a digit), LOOP back to 6139H: the key is ignored.
615F
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9: the NC FLAG for a character above the digits.
6161
If the NC FLAG is set (not a digit), LOOP back to 6139H: the key is ignored.
6163
LD (HL),A 77
Store Register A, the key, at Register Pair HL in the input buffer.
6164
GOSUB to 0033H, the ROM's routine that shows the character in Register A on the display.
6167
INC HL 23
INCrement Register Pair HL by 1, to the next place in the buffer.
6168
DECrement Register B and LOOP back to 6139H while the field has room.
616A
POP DE D1
Restore Register Pair DE from the top of the stack: the flags of the field in Register E.
616B
PUSH DE D5
Save Register Pair DE, the flags, to the top of the stack again.
616C
OR A B7
OR Register A against itself: the NC FLAG, no BREAK.
616D
BIT 1,E CB 4B
Test bit 1 of Register E: the NZ FLAG when a full field ends the input (the asterisk in the format).
616F
If the Z FLAG is set (no asterisk), LOOP back to 6139H to wait for ENTER or another control key.
6171
POP DE D1
Restore Register Pair DE from the top of the stack: the flags are no longer needed.
6172
PUSH AF F5
Save Register Pair AF, the ending key and the C FLAG, to the top of the stack.
6173
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return that ends the text in the buffer.
6175
LD (HL),A 77
Store Register A (0DH) at Register Pair HL, after the characters typed.
6176
PUSH BC C5
Save Register Pair BC, the room left in Register B and the length in Register C, to the top of the stack.
6177
LD A,0FH 3E 0F
Load Register A with 0FH, the control code that hides the cursor.
6179
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
617C
INC B 04
INCrement Register B by 1, for the DEC B below.
617D
DEC B 05
DECrement Register B by 1, the places of the field still to clear: the Z FLAG when none is left.
617E
If the Z FLAG is set (the field is cleared), JUMP to 6187H.
6180
LD A,20H 3E 20
Load Register A with 20H, a space over an underscore of the field.
6182
GOSUB to 0033H, the ROM's routine that shows the character in Register A on the display.
6185
LOOP back to 617DH for the next place of the field.
6187
POP BC C1
Restore Register Pair BC, the room left in Register B and the length in Register C, from the top of the stack.
6188
LD A,C 79
Load Register A with Register C, the length of the field.
6189
SUB B 90
SUBtract Register B, the room left, from Register A: the characters typed.
618A
LD B,A 47
Load Register B with Register A, the characters typed.
618B
POP AF F1
Restore Register Pair AF, the ending key and the C FLAG, from the top of the stack.
618C
POP HL E1
Restore Register Pair HL, the input buffer, from the top of the stack.
618D
RET C9
RETurn with Register B the characters typed and Register A the ending key.
618E
CP 0DH FE 0D
Compare Register A against 0DH, the ENTER key.
6190
If the Z FLAG is set (ENTER), JUMP to 6171H to end the field.
6192
CP 1FH FE 1F
Compare Register A against 1FH, the CLEAR key.
6194
If the Z FLAG is set (CLEAR), JUMP to 6171H to end the field.
6196
CP 01H FE 01
Compare Register A against 01H, the BREAK key.
6198
SCF 37
Set the C FLAG, the mark of BREAK (the Z FLAG of the compare is kept).
6199
If the Z FLAG is set (BREAK), JUMP to 6171H to end the field with the C FLAG.
619B
LD DE,6139H 11 39 61
Point Register Pair DE to 6139H, the wait for the next key.
619E
PUSH DE D5
Save Register Pair DE (6139H) to the top of the stack, so that a RET goes back to the wait for a key.
619F
CP 08H FE 08
Compare Register A against 08H, the left arrow: take back one character.
61A1
If the Z FLAG is set (left arrow), JUMP to 61ACH.
61A3
CP 18H FE 18
Compare Register A against 18H, SHIFT left arrow: take back the whole field.
61A5
RET NZ C0
If the NZ FLAG is set (another control key), RETurn to 6139H: the key is ignored.
61A6
GOSUB to 61ACH to take back one character: the Z FLAG when the field is empty.
61A9
If the NZ FLAG is set (characters left), LOOP back to 61A6H.
61AB
RET C9
RETurn to 6139H, the wait for the next key, with the field emptied.
61AC
LD A,B 78
Load Register A with Register B, the room left in the field.
61AD
CP C B9
Compare Register A against Register C, the length: the Z FLAG when nothing has been typed.
61AE
RET Z C8
If the Z FLAG is set (nothing to take back), RETurn.
61AF
LD A,0FH 3E 0F
Load Register A with 0FH, the control code that hides the cursor.
61B1
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
61B4
GOSUB to 61C2H to move the cursor back one place, onto the last character typed.
61B7
LD A,5FH 3E 5F
Load Register A with 5FH, the underscore of an empty place of the field.
61B9
GOSUB to 0033H, the ROM's routine that shows the character in Register A over the character.
61BC
GOSUB to 61C2H to move the cursor back one place again, onto the underscore.
61BF
DEC HL 2B
DECrement Register Pair HL by 1, back to the place of that character in the buffer.
61C0
INC B 04
INCrement Register B by 1, the room left in the field (the NZ FLAG).
61C1
RET C9
RETurn with the NZ FLAG: a character was taken back.

61C2H - Cursor Left

Sends 18H, the display driver's cursor left. Before it, 61D9H moves the cursor address 4020H up a line when it is at the start of a line; in the 32 character mode (bit 3 of 403DH, which the ROM's display driver also tests) the address one place before is tested the same way.

61C2
PUSH HL E5
Save Register Pair HL to the top of the stack.
61C3
LD HL,(4020H) 2A 20 40
Load Register Pair HL with the cursor address from 4020H-4021H.
61C6
GOSUB to 61D9H to move the cursor address up a line when it is at the start of a line.
61C9
DEC HL 2B
DECrement Register Pair HL by 1, the place before the cursor.
61CA
LD A,(403DH) 3A 3D 40
Load Register A with the byte at 403DH, whose bit 3 is the 32 character mode.
61CD
AND 08H E6 08
AND Register A with 08H, bit 3: the NZ FLAG in the 32 character mode.
61CF
If the NZ FLAG is set (32 characters), GOSUB to 61D9H for the place before the cursor too.
61D2
LD A,18H 3E 18
Load Register A with 18H, the display driver's code for the cursor left.
61D4
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
61D7
POP HL E1
Restore Register Pair HL from the top of the stack.
61D8
RET C9
RETurn to the field editor with the cursor one place back.
61D9
LD A,L 7D
Load Register A with Register L, the low byte of the address.
61DA
AND 3FH E6 3F
AND Register A with 3FH: the column, the Z FLAG at the start of a line.
61DC
RET NZ C0
If the NZ FLAG is set (not at the start), RETurn.
61DD
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 64, one line of the display.
61E0
ADD HL,DE 19
ADD Register Pair DE (minus 64) to Register Pair HL: the address one line up.
61E1
LD (4020H),HL 22 20 40
Store Register Pair HL into 4020H-4021H, the cursor address.
61E4
RET C9
RETurn to 61C2H with the cursor address moved up a line.

61E5H - The End of INPUT and of a Listed Line

Link 41DFH, called by the ROM at 2278H (the end of INPUT) and at 2B44H (each line of LIST). With no current file it returns. With a file the ROM's return is dropped: INPUT # goes to 2282H, past the ROM's Extra ignored test; LIST to a file (SAVE ,A) goes to 2B4AH, past the ROM's BREAK and SHIFT @ test.

61E5
PUSH HL E5
Save Register Pair HL to the top of the stack.
61E6
LD HL,(62FCH) 2A FC 62
Load Register Pair HL with the current file area from 62FCH-62FDH (0000H: none).
61E9
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
61EA
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
61EB
POP HL E1
Restore Register Pair HL from the top of the stack.
61EC
RET Z C8
If the Z FLAG is set (no file), RETurn to the ROM.
61ED
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the ROM's return address.
61EE
PUSH DE D5
Save Register Pair DE to the top of the stack.
61EF
LD DE,2B2EH 11 2E 2B
Load Register Pair DE with 2B2EH, the ROM's LIST: returns above it come from LIST.
61F2
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the NC FLAG for a call from LIST (2B44H).
61F3
POP DE D1
Restore Register Pair DE from the top of the stack.
61F4
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
61F5
If the NC FLAG is set (LIST), JUMP to 2B4AH, the ROM's LIST of the line without the keyboard test.
61F8
JUMP to 2282H, the ROM's end of INPUT without the Extra ignored test.

61FBH - The Line Input Link

Link 41AFH, the ROM's line input at 0368H. With no current file it goes to 631EH, BASIC's own line input with its editing keys. With a file (LOAD and MERGE of a program saved in ASCII) the ROM's return is dropped and a line of up to 255 characters is read into the input buffer through the ROM's 0384H, which gets the bytes from the file through the keyboard link (623DH); a line feed at the start of a line is passed over, the carriage return ends the line and 00H is put after it.

61FB
PUSH HL E5
Save Register Pair HL to the top of the stack.
61FC
LD HL,(62FCH) 2A FC 62
Load Register Pair HL with the current file area from 62FCH-62FDH (0000H: none).
61FF
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
6200
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
6201
POP HL E1
Restore Register Pair HL from the top of the stack.
6202
If the Z FLAG is set (no file), JUMP to 631EH, BASIC's line input from the keyboard.
6205
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used: the line is read here.
6206
PUSH BC C5
Save Register Pair BC to the top of the stack.
6207
PUSH DE D5
Save Register Pair DE to the top of the stack.
6208
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
620B
LD B,FFH 06 FF
Load Register B with FFH, the most characters of a line: 255.
620D
PUSH HL E5
Save Register Pair HL, the input buffer, to the top of the stack.
620E
GOSUB to 0384H, the ROM's wait for a key, which takes the next byte of the file through the keyboard link: Register A.
6211
LD (HL),A 77
Store Register A, the byte, at Register Pair HL in the input buffer.
6212
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return that ends a line.
6214
If the Z FLAG is set (the end of the line), JUMP to 6222H.
6216
CP 0AH FE 0A
Compare Register A against 0AH, the line feed.
6218
If the NZ FLAG is set (another character), JUMP to 621FH to keep it.
621A
LD A,B 78
Load Register A with Register B, the room left in the line.
621B
CP FFH FE FF
Compare Register A against FFH: the Z FLAG when the line feed is the first byte of the line.
621D
If the Z FLAG is set (a line feed at the start), LOOP back to 620EH: it is passed over.
621F
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the input buffer.
6220
DECrement Register B and LOOP back to 620EH while the line has room.
6222
LD (HL),00H 36 00
Store 00H at Register Pair HL over the carriage return: the end of the line.
6224
POP HL E1
Restore Register Pair HL, the input buffer, from the top of the stack.
6225
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the buffer, as the ROM's line input returns it.
6226
POP DE D1
Restore Register Pair DE from the top of the stack.
6227
POP BC C1
Restore Register Pair BC from the top of the stack.
6228
XOR A AF
Set Register A to 00H by XORing it with itself, and clear the C FLAG: the line is not ended by BREAK.
6229
RET C9
RETurn to the caller of the ROM's line input with the line in the buffer.

622AH - The Output Link

Link 41C1H, the ROM's output of a byte (032CH) with the byte in Register C. With no current file it returns and the ROM sends the byte to its device. With a file (PRINT # or SAVE ,A) the ROM's return is dropped, Register Pair BC (saved by the ROM's 032AH) is restored, and 6BA4H writes the byte to the file, returning to the ROM's caller.

622A
PUSH HL E5
Save Register Pair HL to the top of the stack.
622B
LD HL,(62FCH) 2A FC 62
Load Register Pair HL with the current file area from 62FCH-62FDH (0000H: none).
622E
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
622F
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
6230
POP HL E1
Restore Register Pair HL from the top of the stack.
6231
LD A,C 79
Load Register A with Register C, the byte to output (the flags are kept).
6232
RET Z C8
If the Z FLAG is set (no file), RETurn to the ROM's output.
6233
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used: the byte goes to the file.
6234
LD A,C 79
Load Register A with Register C, the byte to output.
6235
POP BC C1
Restore Register Pair BC, which the ROM's 032AH saved, from the top of the stack.
6236
LD IX,(62FCH) DD 2A FC 62
Load Index Register IX with the current file area from 62FCH-62FDH.
623A
JUMP to 6BA4H to write the byte in Register A to the file of Index Register IX.

623DH - The Keyboard Link

Link 41C4H, the ROM's keyboard scan at 0358H. The ROM's return is dropped and the caller is told by its return address. For INKEY$ (01A8H) the keyboard is scanned. For the ROM's wait for a key (0387H) with a current file, the next byte of the file is returned (6B92H); at the end of the file (an ASCII program loaded) file area 0 is closed, and BASIC either RUNs the program (the run flag 62F7H) or shows READY and returns a carriage return. Any other scan (the ROM's BREAK tests) gives no key while a DO file runs (bit 5 of SFLAG1$), so the DO file's bytes are not taken by them.

623D
POP AF F1
Restore Register Pair AF with the return address into the ROM's 035BH, which is not used.
623E
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the address the scan returns to.
623F
PUSH DE D5
Save Register Pair DE to the top of the stack.
6240
LD DE,0387H 11 87 03
Load Register Pair DE with 0387H, the return address of the scan in the ROM's wait for a key.
6243
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for the wait for a key.
6244
If the Z FLAG is set (the wait for a key), JUMP to 6259H.
6246
LD DE,01A8H 11 A8 01
Load Register Pair DE with 01A8H, the return address of the scan in the ROM's INKEY$.
6249
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for INKEY$.
624A
POP DE D1
Restore Register Pair DE from the top of the stack.
624B
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): the return address is put back.
624C
If the Z FLAG is set (INKEY$), JUMP to 035BH, the ROM's scan of the keyboard.
624F
LD A,(4297H) 3A 97 42
Load Register A with SFLAG1$ from 4297H, whose bit 5 is set while a DO file runs.
6252
CPL 2F
Complement Register A (CPL): bit 5 is now set when no DO file runs.
6253
AND 20H E6 20
AND Register A with 20H, bit 5: the NZ FLAG when no DO file runs.
6255
If the NZ FLAG is set (no DO file), JUMP to 035BH, the ROM's scan of the keyboard.
6258
RET C9
RETurn with Register A = 00H: no key, while a DO file runs.
6259
LD DE,(62FCH) ED 5B FC 62
Load Register Pair DE with the current file area from 62FCH-62FDH (0000H: none).
625D
LD A,D 7A
Load Register A with Register D, the high byte of the file area.
625E
OR E B3
OR Register A with Register E: the Z FLAG when there is no current file.
625F
POP DE D1
Restore Register Pair DE from the top of the stack.
6260
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): the return address is put back.
6261
If the Z FLAG is set (no file), JUMP to 035BH, the ROM's scan of the keyboard.
6264
PUSH HL E5
Save Register Pair HL to the top of the stack.
6265
LD IX,(62FCH) DD 2A FC 62
Load Index Register IX with the current file area from 62FCH-62FDH.
6269
GOSUB to 6B92H to read the next byte of the file into Register A: the C FLAG at the end of the file.
626C
If the NC FLAG is set (a byte), JUMP to 26E7H, the ROM's POP HL and RET, which returns the byte in Register A.
626F
PUSH BC C5
Save Register Pair BC to the top of the stack.
6270
PUSH DE D5
Save Register Pair DE to the top of the stack.
6271
GOSUB to 6826H to close file area 0, the file that was loaded.
6274
POP DE D1
Restore Register Pair DE from the top of the stack.
6275
POP BC C1
Restore Register Pair BC from the top of the stack.
6276
LD A,(62F7H) 3A F7 62
Load Register A with the run flag from 62F7H: not 00H when the program is to be run.
6279
OR A B7
OR Register A against itself: the NZ FLAG for a run.
627A
LD HL,1D1EH 21 1E 1D
Point Register Pair HL to 1D1EH, the ROM's loop that runs the statements.
627D
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): 1D1EH becomes the return address.
627E
If the NZ FLAG is set (the run flag), JUMP to 1B5DH, the ROM's RUN, which returns into 1D1EH.
6281
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL is put back.
6282
PUSH BC C5
Save Register Pair BC to the top of the stack.
6283
PUSH DE D5
Save Register Pair DE to the top of the stack.
6284
LD HL,1929H 21 29 19
Point Register Pair HL to 1929H, the ROM's text READY.
6287
GOSUB to 28A7H, the ROM's routine that shows the text at Register Pair HL up to its 00H.
628A
POP DE D1
Restore Register Pair DE from the top of the stack.
628B
POP BC C1
Restore Register Pair BC from the top of the stack.
628C
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return returned as the key.
628E
POP HL E1
Restore Register Pair HL from the top of the stack.
628F
RET C9
RETurn with the carriage return in Register A.

6290H - SYSTEM

Link 41E2H, called by the ROM's SYSTEM (02B2H) before its prompt. The stack is put back to 4288H, the prompt (an asterisk and the ROM's question mark) is shown and a line is taken by the ROM's 1BB3H. A line goes to the ROM's SYSTEM at 02C6H; BREAK goes back to BASIC's READY (5CD6H).

6290
LD SP,4288H 31 88 42
Load the Stack Pointer with 4288H, the stack of the ROM's SYSTEM.
6293
GOSUB to 20FEH, the ROM's routine that starts a new line on the display when the cursor is not at its start.
6296
LD A,2AH 3E 2A
Load Register A with 2AH, the asterisk of the prompt of SYSTEM.
6298
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device.
629B
GOSUB to 1BB3H, the ROM's input of a line after a question mark: the C FLAG for BREAK.
629E
JP NC,02C6H D2 C6 02
If the NC FLAG is set (a line), JUMP to 02C6H, the ROM's SYSTEM, to take the name or the address.
62A1
JUMP to 5CD6H, BASIC's return to READY: BREAK at the prompt leaves SYSTEM.

62A4H - Comma and TAB

Link 41D3H, called by the ROM's PRINT for a comma (2108H) and for TAB (2141H). With a current file the file area's column byte (+01H) takes the place of the device's position: the comma goes on at the ROM's 2130H and TAB at 2156H. Without a file the comma goes back to 210BH; TAB to the printer (409CH = 01H) evaluates its argument again from the TAB( token, so that the ROM's AND 7FH is left out and the printer can be tabbed up to 255; TAB elsewhere goes back to 2144H.

62A4
LD HL,(62FCH) 2A FC 62
Load Register Pair HL with the current file area from 62FCH-62FDH (0000H: none).
62A7
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
62A8
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
62A9
INC HL 23
INCrement Register Pair HL by 1, to the column byte of the file area (the flags are kept).
62AA
LD A,(HL) 7E
Load Register A with the file's column at Register Pair HL, the characters on its line.
62AB
POP HL E1
Restore Register Pair HL with the ROM's return address, which tells comma and TAB apart.
62AC
PUSH AF F5
Save Register Pair AF, the column and the Z FLAG of no file, to the top of the stack.
62AD
PUSH DE D5
Save Register Pair DE to the top of the stack.
62AE
LD DE,2130H 11 30 21
Load Register Pair DE with 2130H, between the ROM's two calls: the C FLAG below for the comma.
62B1
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG for the comma (210BH), the NC FLAG for TAB (2144H).
62B2
POP DE D1
Restore Register Pair DE from the top of the stack.
62B3
If the NC FLAG is set (TAB), JUMP to 62BCH for the TAB of a file or the printer.
62B5
POP AF F1
Restore Register Pair AF, the column and the flags, from the top of the stack.
62B6
If the NZ FLAG is set (a file), JUMP to 2130H, the ROM's comma, with the file's column in Register A.
62B9
JUMP to 210BH, the ROM's comma for its own devices.
62BC
POP AF F1
Restore Register Pair AF, the column and the flags, from the top of the stack.
62BD
If the NZ FLAG is set (a file), JUMP to 2156H, the ROM's TAB, with the file's column in Register A.
62C0
LD A,(409CH) 3A 9C 40
Load Register A with the ROM's output device from 409CH: 01H for the printer.
62C3
DEC A 3D
DECrement Register A by 1: the Z FLAG for the printer.
62C4
If the NZ FLAG is set (not the printer), JUMP to 2144H, the ROM's TAB.
62C7
POP HL E1
Restore Register Pair HL, the text pointer the ROM saved at 2140H, from the top of the stack.
62C8
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack again for the ROM.
62C9
DEC HL 2B
DECrement Register Pair HL by 1, one character back in the text.
62CA
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
62CB
CP BCH FE BC
Compare Register A against BCH, the token of TAB(.
62CD
If the NZ FLAG is set (not yet the token), LOOP back to 62C9H.
62CF
GOSUB to 2B1BH, the ROM's evaluation of the byte in the parentheses after the token: Register E the whole value.
62D2
JUMP to 2144H, the ROM's TAB, with the value in Register E.

62D5H - The Current File

Four links that keep the current file area (62FCH-62FDH): 41BEH (the end of PRINT, the ROM's 2174H after it set Register A to 00H) ends it; 41B5H (1AECH) saves it into 40F3H-40F4H over the ROM's 1B5DH when a program line is entered, and 41B8H (1AF2H) restores it; 41CDH (20C6H) sends a number to a file without the ROM's test of the line's room (20E9H).

62D5
LD (62FCH),A 32 FC 62
Store Register A (00H from the ROM's 2170H) to 62FCH, the low byte of the current file area.
62D8
LD (62FDH),A 32 FD 62
Store Register A (00H) to 62FDH, the high byte: no current file.
62DB
RET C9
RETurn to the ROM's PRINT with no current file.
62DC
LD HL,(62FCH) 2A FC 62
Load Register Pair HL with the current file area from 62FCH-62FDH.
62DF
LD (40F3H),HL 22 F3 40
Store Register Pair HL, the current file area, into 40F3H-40F4H while the ROM's 1B5DH runs.
62E2
RET C9
RETurn to the ROM's entry of a program line, which goes on to 1B5DH.
62E3
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the saved file area from 40F3H-40F4H.
62E6
LD (62FCH),HL 22 FC 62
Store Register Pair HL into 62FCH-62FDH, the current file area again.
62E9
RET C9
RETurn to the ROM's entry of a program line with the file area back.
62EA
LD HL,(62FCH) 2A FC 62
Load Register Pair HL with the current file area from 62FCH-62FDH (0000H: none).
62ED
LD A,H 7C
Load Register A with Register H, the high byte of the file area.
62EE
OR L B5
OR Register A with Register L: the Z FLAG when there is no current file.
62EF
RET Z C8
If the Z FLAG is set (no file), RETurn to the ROM's PRINT of the number.
62F0
POP HL E1
Restore Register Pair HL with the ROM's return address, which is not used.
62F1
JUMP to 20E9H, the ROM's output of the number's string, without the test of the room on the line.

62F4H - The Variables

Link 41D0H (the ROM's 2103H, after PRINT's carriage return) is a RET. Then BASIC's variables: 62F5H-62F7H are loaded, 62F8H-631DH are not.

62F4
RET C9
RETurn: BASIC has nothing to do after PRINT's carriage return (the link 41D0H).
62F5
DEFB 03H 03
The state of the long error messages: bit 0 ERROR/OVL is used, bit 1 it must be loaded first (5C00H); 03H at the start.
62F6
DEFB 00H 00
The last DOS error code (6CA6H), shown again by CMD"E".
62F7
DEFB 00H 00
The run flag: not 00H when LOAD ,R or RUN is to run the program once it is loaded (66B6H, 684CH).
62F8-62F9
DEFS 2
ERROR/OVL's entry, the transfer address LOAD@ returned (5C2BH).
62FA
DEFS 1
The number of files the program may open, 0-15 (-F:nn; 01H by default).
62FB
DEFS 1
The protection level of a program loaded and run with an access level of 6 or 7 (6B4CH); 6C47H wipes such a program at READY.
62FC-62FD
DEFS 2
The current file area (Index Register IX) of PRINT #, INPUT #, LOAD and SAVE ,A; 0000H when there is none.
62FE-631D
DEFS 32
The addresses of the file areas 0-15, one word each (52F5H).

631EH - BASIC's Line Input

Reached from the line input link (6202H) when no file is current. The ROM's return into its own line input (036BH) is dropped; when the caller is not BASIC's command level (its return address 1A7EH) the ROM's line input is entered at 036BH. At the command level the first key is read here: a key that lists or edits a line acts at once (the current line is 40ECH), any other key goes into the ROM's line input at 05E3H as its first character.

631E
POP AF F1
Restore Register Pair AF with the ROM's return address into 036BH, which is not used here.
631F
POP HL E1
Restore Register Pair HL with the return address of the caller of the ROM's line input.
6320
LD DE,1A7EH 11 7E 1A
Load Register Pair DE with 1A7EH, the return address of the line input of BASIC's command level.
6323
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for the command level.
6324
PUSH HL E5
Save Register Pair HL, the caller's return address, to the top of the stack again.
6325
JP NZ,036BH C2 6B 03
If the NZ FLAG is set (another caller), JUMP to 036BH, the ROM's line input.
6328
LD A,0EH 3E 0E
Load Register A with 0EH, the control code that shows the cursor.
632A
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
632D
GOSUB to 0049H, the ROM's routine that waits for a key and returns it in Register A.
6330
LD DE,(40ECH) ED 5B EC 40
Load Register Pair DE with the current line from 40ECH-40EDH, the line of the ROM's EDIT and of the period.
6334
CP 0AH FE 0A
Compare Register A against 0AH, the down arrow: show the next line.
6336
If the Z FLAG is set (down arrow), JUMP to 636BH.
6338
CP 5BH FE 5B
Compare Register A against 5BH, the up arrow: show the line before.
633A
If the Z FLAG is set (up arrow), JUMP to 636BH.
633C
CP 2EH FE 2E
Compare Register A against 2EH, the period: show the current line.
633E
If the Z FLAG is set (period), JUMP to 636BH.
6340
CP 2CH FE 2C
Compare Register A against 2CH, the comma: edit the current line.
6342
If the Z FLAG is set (comma), JUMP to 636BH to edit the current line.
6344
LD DE,FFFFH 11 FF FF
Load Register Pair DE with FFFFH, a line number above every line, for the last line.
6347
CP 1AH FE 1A
Compare Register A against 1AH, SHIFT down arrow: show the last line.
6349
If the Z FLAG is set (SHIFT down arrow), JUMP to 636BH.
634B
CP 2FH FE 2F
Compare Register A against 2FH, the slash: show the last line.
634D
If the Z FLAG is set (slash), JUMP to 636BH to show the last line.
634F
PUSH AF F5
Save Register Pair AF, the key in Register A, to the top of the stack.
6350
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H, the first line.
6353
CP 1BH FE 1B
Compare Register A against 1BH, SHIFT up arrow: show the first line.
6355
If the Z FLAG is set (SHIFT up arrow), JUMP to 639EH with the first line.
6357
CP 3BH FE 3B
Compare Register A against 3BH, the semicolon: show the first line.
6359
If the Z FLAG is set (semicolon), JUMP to 639EH with the first line.
635B
POP AF F1
Restore Register Pair AF, the key in Register A, from the top of the stack: an ordinary key.
635C
PUSH BC C5
Save Register Pair BC to the top of the stack, as the ROM's line input does at 036BH.
635D
LD HL,0374H 21 74 03
Point Register Pair HL to 0374H, where the ROM's line input goes on after its key loop.
6360
PUSH HL E5
Save Register Pair HL (0374H) to the top of the stack, the return address of the key loop.
6361
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
6364
LD B,F0H 06 F0
Load Register B with F0H, the 240 characters the ROM's line input allows.
6366
PUSH HL E5
Save Register Pair HL, the input buffer, to the top of the stack for the ROM's key loop.
6367
LD C,B 48
Load Register C with Register B, the length of the buffer, as the ROM's key loop keeps it.
6368
JUMP to 05E3H, the ROM's key loop, with the first key already in Register A.
636B
PUSH AF F5
Save Register Pair AF, the key in Register A, to the top of the stack.
636C
GOSUB to 1B2CH, the ROM's search for line Register Pair DE: Register Pair BC the line (or the next one), Register Pair HL the one after it, the C FLAG when it exists.
636F
POP DE D1
Restore Register Pair DE with the key in Register D.
6370
LD A,D 7A
Load Register A with Register D, the key that was pressed.
6371
PUSH AF F5
Save Register Pair AF, the key and the C FLAG of the search, to the top of the stack.
6372
If the NC FLAG is set (the line does not exist), JUMP to 6388H.
6374
CP 2EH FE 2E
Compare Register A against 2EH, the period: the current line itself.
6376
If the Z FLAG is set (period), JUMP to 639CH with the line found.
6378
CP 2CH FE 2C
Compare Register A against 2CH, the comma: the current line itself.
637A
If the Z FLAG is set (comma), JUMP to 639CH with the line found.
637C
CP 0AH FE 0A
Compare Register A against 0AH, the down arrow.
637E
If the NZ FLAG is set (not the down arrow), JUMP to 6388H for the line before.
6380
LD A,(HL) 7E
Load Register A with the low byte of the link of the next line at Register Pair HL.
6381
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the link.
6382
OR (HL) B6
OR Register A with the high byte at Register Pair HL: the Z FLAG when the next line is the end of the program.
6383
DEC HL 2B
DECrement Register Pair HL by 1, back to the start of the next line.
6384
If the NZ FLAG is set (a next line), JUMP to 639EH to show it.
6386
JUMP to 639CH: the current line is the last, so it is shown again.
6388
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
638B
OR A B7
OR Register A against itself, to clear the C FLAG for the SBC below.
638C
SBC HL,BC ED 42
SUBtract Register Pair BC, the line, from Register Pair HL: the Z FLAG when it is the first line.
638E
If the Z FLAG is set (the first line), JUMP to 639CH to show it.
6390
ADD HL,BC 09
ADD Register Pair BC back to Register Pair HL: the start of the program again.
6391
LD E,C 59
Load Register E with Register C, the low byte of the line.
6392
LD D,B 50
Load Register D with Register B: Register Pair DE = the line whose predecessor is wanted.
6393
LD C,L 4D
Load Register C with Register L, the low byte of the line being looked at.
6394
LD B,H 44
Load Register B with Register H: Register Pair BC = the line being looked at.
6395
LD A,(HL) 7E
Load Register A with the low byte of the line's link at Register Pair HL.
6396
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the link.
6397
LD H,(HL) 66
Load Register H with the high byte of the link at Register Pair HL.
6398
LD L,A 6F
Load Register L with Register A: Register Pair HL = the next line.
6399
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG when the next line is the one wanted.
639A
If the NZ FLAG is set, LOOP back to 6393H to the next line.
639C
LD L,C 69
Load Register L with Register C, the low byte of the line to show.
639D
LD H,B 60
Load Register H with Register B: Register Pair HL = the line to show.
639E
POP BC C1
Restore Register Pair BC with the key in Register B.
639F
POP AF F1
Restore Register Pair AF with the return address into the command level, which is not used: the end is the ROM's 1A33H.
63A0
LD A,(HL) 7E
Load Register A with the low byte of the line's link at Register Pair HL.
63A1
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the link.
63A2
OR (HL) B6
OR Register A with the high byte at Register Pair HL: the Z FLAG at the end of the program.
63A3
INC HL 23
INCrement Register Pair HL by 1, to the line number.
63A4
If the NZ FLAG is set (a line), JUMP to 63ACH.
63A6
GOSUB to 20FEH, the ROM's routine that starts a new line when the cursor is not at the start of one.
63A9
JUMP to 1A33H, the ROM's command level, for the next line typed.
63AC
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL.
63AD
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the line number.
63AE
LD D,(HL) 56
Load Register D with the high byte of the line number at Register Pair HL: Register Pair DE = the line number.
63AF
INC HL 23
INCrement Register Pair HL by 1, to the text of the line.
63B0
LD A,2CH 3E 2C
Load Register A with 2CH, the comma that edits the line.
63B2
CP B B8
Compare Register A against Register B, the key: the Z FLAG for the comma.
63B3
If the Z FLAG is set (comma), JUMP to 2E65H, the ROM's EDIT of line Register Pair DE.
63B6
PUSH DE D5
Save Register Pair DE, the line number, to the top of the stack.
63B7
LD A,0FH 3E 0F
Load Register A with 0FH, the control code that hides the cursor.
63B9
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
63BC
LD A,1DH 3E 1D
Load Register A with 1DH, the control code that moves the cursor to the start of its line.
63BE
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
63C1
LD A,1EH 3E 1E
Load Register A with 1EH, the control code that clears the line from the cursor on.
63C3
GOSUB to 0033H, the ROM's routine that sends the code in Register A to the display.
63C6
POP DE D1
Restore Register Pair DE, the line number, from the top of the stack.
63C7
LD (40ECH),DE ED 53 EC 40
Store Register Pair DE, the line shown, into 40ECH-40EDH: it becomes the current line.
63CB
GOSUB to 64C2H to show the line number in Register Pair DE and the text at Register Pair HL.
63CE
JUMP to 1A33H, the ROM's command level, for the next line typed.

63D1H - Shorthand, DI and DU

Called by the link 41B2H (6877H) after a typed line has been tokenized, with the C FLAG for a program line. In each statement a letter that stands alone as the statement's word, with no = in the statement, becomes the token of the table 6484H (L followed by a quotation mark becomes LOAD). D alone in the first statement of a direct line followed by I or U is DI or DU (6441H). Quoted strings are passed over, and nothing after REM is changed.

63D1
PUSH HL E5
Save Register Pair HL, the tokenized line, to the top of the stack.
63D2
PUSH DE D5
Save Register Pair DE to the top of the stack.
63D3
PUSH BC C5
Save Register Pair BC to the top of the stack.
63D4
PUSH AF F5
Save Register Pair AF, the C FLAG of a program line, to the top of the stack.
63D5
LD B,00H 06 00
Load Register B with 00H: the first statement of the line.
63D7
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the first character of the statement: the Z FLAG at the end of the line.
63D8
If the Z FLAG is set (the end of the line), JUMP to 642AH.
63DA
CP 93H FE 93
Compare Register A against 93H, the token of REM.
63DC
If the Z FLAG is set (REM), JUMP to 642EH: the rest of the line is left as it is.
63DE
PUSH HL E5
Save Register Pair HL, the place of the statement's first character, to the top of the stack.
63DF
LD DE,6484H 11 84 64
Point Register Pair DE to 6484H, the table of the shorthand letters and their tokens.
63E2
LD C,A 4F
Load Register C with Register A, the statement's first character.
63E3
LD A,(DE) 1A
Load Register A with the letter of the table entry at Register Pair DE.
63E4
INC DE 13
INCrement Register Pair DE by 1, to the entry's token.
63E5
OR A B7
OR Register A against itself: the Z FLAG at the 00H that ends the table.
63E6
If the Z FLAG is set (not a shorthand letter), JUMP to 6424H.
63E8
CP C B9
Compare Register A against Register C, the statement's first character.
63E9
If the Z FLAG is set (the letter is in the table), JUMP to 63EEH.
63EB
INC DE 13
INCrement Register Pair DE by 1, to the next table entry.
63EC
LOOP back to 63E3H for the next entry of the shorthand table.
63EE
GOSUB to 6433H to take the next character, passing over a quoted string: the Z FLAG at the end of the statement.
63F1
If the Z FLAG is set (the end of the statement), JUMP to 63F9H: it is shorthand.
63F3
CP D5H FE D5
Compare Register A against D5H, the token of =: the letter is then a variable.
63F5
If the Z FLAG is set (an assignment), JUMP to 6424H: it is not shorthand.
63F7
LOOP back to 63EEH for the next character of the statement.
63F9
POP HL E1
Restore Register Pair HL, the place of the letter, from the top of the stack.
63FA
PUSH HL E5
Save Register Pair HL, the place of the letter, to the top of the stack again.
63FB
LD A,C 79
Load Register A with Register C, the shorthand letter found.
63FC
CP 4CH FE 4C
Compare Register A against 4CH, the letter L.
63FE
If the NZ FLAG is set (not L), JUMP to 6409H.
6400
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after the L.
6401
CP 22H FE 22
Compare Register A against 22H, the quotation mark of L followed by a file name.
6403
If the NZ FLAG is set (no quotation mark), JUMP to 6420H: L is LIST.
6405
LD A,A7H 3E A7
Load Register A with A7H, the token of LOAD, for L with a file name.
6407
JUMP to 6421H to put the token of LOAD in place of the L.
6409
CP 44H FE 44
Compare Register A against 44H, the letter D.
640B
If the NZ FLAG is set (not D), JUMP to 6420H to put the letter's token in its place.
640D
INC B 04
INCrement Register B by 1, to test the statement count.
640E
DEC B 05
DECrement Register B by 1: the Z FLAG in the first statement.
640F
If the NZ FLAG is set (a later statement), JUMP to 6420H: D is DELETE.
6411
POP BC C1
Restore Register Pair BC with the place of the letter, to reach the flags below it on the stack.
6412
POP AF F1
Restore Register Pair AF, the flags the caller gave: the C FLAG for a program line.
6413
PUSH AF F5
Save Register Pair AF to the top of the stack again.
6414
PUSH BC C5
Save Register Pair BC, the place of the letter, to the top of the stack again.
6415
If the C FLAG is set (a program line), JUMP to 6420H: D is DELETE.
6417
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the character after the D.
6418
CP 49H FE 49
Compare Register A against 49H, the letter I of DI.
641A
If the Z FLAG is set (DI), JUMP to 6441H with Register A = 49H.
641C
SUB 55H D6 55
SUBtract 55H, the letter U of DU, from Register A: 00H and the Z FLAG for DU.
641E
If the Z FLAG is set (DU), JUMP to 6441H with Register A = 00H.
6420
LD A,(DE) 1A
Load Register A with the token of the table entry at Register Pair DE.
6421
POP HL E1
Restore Register Pair HL, the place of the letter, from the top of the stack.
6422
PUSH HL E5
Save Register Pair HL to the top of the stack again.
6423
LD (HL),A 77
Store Register A, the token, at Register Pair HL in place of the letter.
6424
POP HL E1
Restore Register Pair HL, the place of the statement's first character, from the top of the stack.
6425
GOSUB to 6433H to take the next character, passing over a quoted string: the Z FLAG at the end of the statement.
6428
If the NZ FLAG is set, LOOP back to 6425H until the end of the statement.
642A
LD B,A 47
Load Register B with Register A, the character that ended the statement: not 00H for the colon.
642B
OR A B7
OR Register A against itself: the NZ FLAG when another statement follows.
642C
If the NZ FLAG is set (a colon), LOOP back to 63D7H for the next statement.
642E
POP AF F1
Restore Register Pair AF, the caller's flags, from the top of the stack.
642F
POP BC C1
Restore Register Pair BC from the top of the stack.
6430
POP DE D1
Restore Register Pair DE from the top of the stack.
6431
POP HL E1
Restore Register Pair HL, the tokenized line, from the top of the stack.
6432
RET C9
RETurn to the link 41B2H (6877H) with the caller's flags.

6433H - The Next Character

RST 10H, then a quoted string is passed over to its closing quotation mark: returns the Z FLAG at the end of the statement (or of the line inside a string).

6433
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
6434
RET Z C8
If the Z FLAG is set (the end of the statement), RETurn.
6435
CP 22H FE 22
Compare Register A against 22H, the quotation mark that opens a string.
6437
RET NZ C0
If the NZ FLAG is set (not a string), RETurn with the NZ FLAG.
6438
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character of the string.
6439
OR A B7
OR Register A against itself: the Z FLAG at the 00H that ends the line.
643A
RET Z C8
If the Z FLAG is set (the end of the line), RETurn with the Z FLAG.
643B
CP 22H FE 22
Compare Register A against 22H, the quotation mark that closes the string.
643D
If the NZ FLAG is set (still in the string), LOOP back to 6438H.
643F
OR A B7
OR Register A against itself (22H): the NZ FLAG after the string.
6440
RET C9
RETurn with the NZ FLAG and Register A = the closing quotation mark.

6441H - DI and DU

DI old,new and DU old,new in the direct mode. The text of line old is copied after a line number word in front of the input buffer, as a tokenized line; DI then deletes line old (the ROM's 2BE4H and 1AF8H). The ROM's 1AA7H then puts the copy into the program as line new. Line old must exist (Undefined line number).

6441
LD (6473H),A 32 73 64
Store Register A (49H for DI, 00H for DU) to 6473H, the operand of LD A,00H at 6472H.
6444
RST 10H D7
RST 10H: increment Register Pair HL past the I or U and load Register A with the next character.
6445
GOSUB to 1E4FH, the ROM's scan of a line number (a period is the current line) at Register Pair HL into Register Pair DE.
6448
LD B,D 42
Load Register B with Register D, the high byte of the old line number.
6449
LD C,E 4B
Load Register C with Register E: Register Pair BC = the old line number.
644A
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma between the line numbers, or the ROM shows a Syntax error.
644C
GOSUB to 1E4FH, the ROM's scan of a line number at Register Pair HL into Register Pair DE: the new line.
644F
PUSH DE D5
Save Register Pair DE, the new line number, to the top of the stack.
6450
LD D,B 50
Load Register D with Register B, the high byte of the old line number.
6451
LD E,C 59
Load Register E with Register C: Register Pair DE = the old line number.
6452
GOSUB to 1B2CH, the ROM's search for line Register Pair DE: Register Pair BC the line, the C FLAG when it exists.
6455
If the NC FLAG is set (no such line), JUMP to 1ED9H, the ROM's Undefined line number error.
6458
LD DE,(40A7H) ED 5B A7 40
Load Register Pair DE with the input buffer's address from 40A7H-40A8H.
645C
DEC DE 1B
DECrement Register Pair DE by 1, toward the place of the line number word.
645D
DEC DE 1B
DECrement Register Pair DE by 1: the copy starts two bytes before the input buffer.
645E
PUSH DE D5
Save Register Pair DE, the start of the copy, to the top of the stack.
645F
PUSH BC C5
Save Register Pair BC, the old line, to the top of the stack.
6460
LD H,B 60
Load Register H with Register B, the high byte of the old line.
6461
LD L,C 69
Load Register L with Register C: Register Pair HL = the old line.
6462
LD BC,0004H 01 04 00
Load Register Pair BC with 0004H, the link and the line number before the text, the start of the count.
6465
ADD HL,BC 09
ADD Register Pair BC (4) to Register Pair HL: the text of the old line.
6466
LD A,(HL) 7E
Load Register A with the next byte of the old line at Register Pair HL.
6467
LD (DE),A 12
Store Register A, the byte, at Register Pair DE in the copy.
6468
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the old line.
6469
INC DE 13
INCrement Register Pair DE by 1, to the next byte of the copy.
646A
INC BC 03
INCrement Register Pair BC by 1, the count of the line.
646B
OR A B7
OR Register A against itself: the Z FLAG at the 00H that ends the line.
646C
If the NZ FLAG is set, LOOP back to 6466H for the next byte.
646E
LD D,B 50
Load Register D with Register B, the high byte of the count.
646F
LD E,C 59
Load Register E with Register C: Register Pair DE = the count.
6470
POP BC C1
Restore Register Pair BC, the old line, from the top of the stack.
6471
PUSH DE D5
Save Register Pair DE, the count, to the top of the stack.
6472
LD A,00H 3E 00
Load Register A with 00H, the operand 6473H stored at 6441H: 49H for DI, 00H for DU.
6474
OR A B7
OR Register A against itself: the Z FLAG for DU.
6475
If the Z FLAG is set (DU), JUMP to 647DH: the old line stays.
6477
GOSUB to 2BE4H, the ROM's deletion of the program lines from Register Pair BC up to Register Pair HL: the old line.
647A
GOSUB to 1AF8H, the ROM's routine that fixes the links of the program's lines.
647D
POP BC C1
Restore Register Pair BC, the count, from the top of the stack.
647E
POP HL E1
Restore Register Pair HL, the start of the copy, from the top of the stack.
647F
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the copy.
6480
POP DE D1
Restore Register Pair DE, the new line number, from the top of the stack.
6481
JUMP to 1AA7H, the ROM's insertion of a tokenized line, with the new line number in Register Pair DE and the count in Register Pair BC.

6484H - The Shorthand Table

Data: pairs of a letter and the token it becomes when it stands alone as a statement's word, ended by 00H.

6484-6485
DEFB 41H,B7H 41 B7
The letter A alone becomes B7H, the token of AUTO.
6486-6487
DEFB 44H,B6H 44 B6
The letter D alone becomes B6H, the token of DELETE (DI and DU are taken first in a direct line).
6488-6489
DEFB 45H,9DH 45 9D
The letter E alone becomes 9DH, the token of EDIT.
648A-648B
DEFB 47H,8DH 47 8D
The letter G alone becomes 8DH, the token of GOTO.
648C-648D
DEFB 49H,89H 49 89
The letter I alone becomes 89H, the token of INPUT.
648E-648F
DEFB 4BH,AAH 4B AA
The letter K alone becomes AAH, the token of KILL.
6490-6491
DEFB 4CH,B4H 4C B4
The letter L alone becomes B4H, the token of LIST (L followed by a quotation mark becomes LOAD).
6492-6493
DEFB 4EH,A9H 4E A9
The letter N alone becomes A9H, the token of NAME, which marks a label.
6494-6495
DEFB 52H,8EH 52 8E
The letter R alone becomes 8EH, the token of RUN.
6496-6497
DEFB 53H,ADH 53 AD
The letter S alone becomes ADH, the token of SAVE.
6498
DEFB 00H 00
The 00H that ends the shorthand table of letters and tokens.

6499H - TRON

The RST 10H hook (64E2H) comes here when RST 10H was not called by the ROM's line number scan. Unless the call is the statement dispatcher's (return address 1D5BH) with TRON on (411BH not 00H), the ROM's RST 10H (1D78H) is done. With TRON, the statement about to run is shown (64CDH) and a key is awaited: BREAK stops the program through the ROM's 1DB7H, any other key lets the statement run.

6499
LD DE,1D5BH 11 5B 1D
Load Register Pair DE with 1D5BH, the return address of the RST 10H of the ROM's statement dispatcher.
649C
RST 18H DF
RST 18H: compare Register Pair HL (the return address) with Register Pair DE: the Z FLAG for the dispatcher.
649D
POP DE D1
Restore Register Pair DE from the top of the stack.
649E
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): the return address is put back, Register Pair HL = the text pointer.
649F
If the NZ FLAG is set (another caller), JUMP to 1D78H, the ROM's RST 10H.
64A2
LD A,(411BH) 3A 1B 41
Load Register A with the ROM's TRON flag from 411BH: 00H when the trace is off.
64A5
OR A B7
OR Register A against itself: the Z FLAG for TROFF.
64A6
If the Z FLAG is set (TROFF), JUMP to 1D78H, the ROM's RST 10H.
64A9
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
64AA
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, before the statement.
64AB
CP 3AH FE 3A
Compare Register A against 3AH, the colon between statements.
64AD
If the Z FLAG is set (a colon), JUMP to 64B0H.
64AF
INC HL 23
INCrement Register Pair HL by 1, to the start of the line's text.
64B0
GOSUB to 64CDH to show the text at Register Pair HL as LIST shows it.
64B3
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
64B4
GOSUB to 0384H, the ROM's wait for a key, which returns it in Register A.
64B7
LD (4099H),A 32 99 40
Store Register A, the key, to 4099H, the ROM's byte of the last key read.
64BA
DEC A 3D
DECrement Register A by 1: the Z FLAG for BREAK (01H).
64BB
If the NZ FLAG is set (another key), JUMP to 1D78H, the ROM's RST 10H: the statement runs.
64BE
INC A 3C
INCrement Register A by 1, back to 01H, the code of BREAK.
64BF
JUMP to 1DB7H, the ROM's stop of the program by BREAK.

64C2H - Show a Line

64C2H shows the line number in Register Pair DE and a space, then 64CDH expands the tokenized text at Register Pair HL into file area 0's file control block and buffer (256 bytes, ended by 00H) with the ROM's LIST code (2B85H), shows it (2B75H) and starts a new line.

64C2
PUSH HL E5
Save Register Pair HL, the text of the line, to the top of the stack.
64C3
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the line number.
64C4
GOSUB to 0FAFH, the ROM's output of the integer in Register Pair HL as a number.
64C7
LD A,20H 3E 20
Load Register A with 20H, the space after the line number.
64C9
GOSUB to 032AH, the ROM's output of the character in Register A to the selected device.
64CC
POP HL E1
Restore Register Pair HL, the text of the line, from the top of the stack.
64CD
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
64CE
GOSUB to 6593H for file area 0: Register Pair DE returns its file control block, used here as a buffer.
64D1
PUSH DE D5
Save Register Pair DE, the buffer, to the top of the stack.
64D2
LD C,E 4B
Load Register C with Register E, the low byte of the buffer.
64D3
LD B,D 42
Load Register B with Register D: Register Pair BC = the buffer, where the text is expanded.
64D4
INC D 14
INCrement Register D by 1: Register Pair DE = the buffer plus 256.
64D5
DEC DE 1B
DECrement Register Pair DE by 1, to the last byte of the 256.
64D6
XOR A AF
Set Register A to 00H by XORing it with itself.
64D7
LD (DE),A 12
Store Register A (00H) at Register Pair DE, the end of the buffer.
64D8
GOSUB to 2B85H, the ROM's LIST code that expands the tokenized text at Register Pair HL into the buffer at Register Pair BC.
64DB
POP HL E1
Restore Register Pair HL, the buffer with the expanded text, from the top of the stack.
64DC
GOSUB to 2B75H, the ROM's routine that shows the text at Register Pair HL up to its 00H.
64DF
JUMP to 20FEH, the ROM's routine that starts a new line when the cursor is not at the start of one.

64E2H - The RST 10H Hook

The RST 10H vector (4003H, set at 520AH) comes here. A call from anywhere but the ROM's line number scan (its RST 10H at 1E5EH, return 1E5FH) goes to 6499H (TRON, else the ROM's 1D78H). For the line number scan the ROM's scan is replaced, and its own return is dropped, so this code returns to the scan's caller with Register Pair DE = the line number: callers below 1B0FH take digits only (6515H); the others take digits, or a label: the name of a line that starts with NAME (64FBH, 651BH).

64E2
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the return address of the RST 10H, the text pointer saved.
64E3
PUSH DE D5
Save Register Pair DE to the top of the stack.
64E4
LD DE,1E5FH 11 5F 1E
Load Register Pair DE with 1E5FH, the return address of the RST 10H in the ROM's line number scan.
64E7
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for the line number scan.
64E8
If the NZ FLAG is set (another caller), JUMP to 6499H.
64EB
POP DE D1
Restore Register Pair DE from the top of the stack.
64EC
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack: the return into the ROM's scan is dropped.
64ED
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the return address of the scan's caller.
64EE
PUSH DE D5
Save Register Pair DE to the top of the stack.
64EF
LD DE,1B0FH 11 0F 1B
Load Register Pair DE with 1B0FH: callers below it take only a number.
64F2
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the C FLAG for a caller below 1B0FH.
64F3
POP DE D1
Restore Register Pair DE from the top of the stack.
64F4
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): the caller's return is put back, Register Pair HL = the text pointer.
64F5
If the C FLAG is set (a number only), JUMP to 6515H.
64F7
GOSUB to 1D78H, the ROM's RST 10H code: the next character in Register A, the C FLAG for a digit, the Z FLAG at the end of the statement.
64FA
RET Z C8
If the Z FLAG is set (nothing), RETurn to the scan's caller with Register Pair DE = 0000H.
64FB
If the NC FLAG is set (not a digit), JUMP to 651BH for a label.
64FD
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
64FE
PUSH AF F5
Save Register Pair AF, the digit in Register A, to the top of the stack.
64FF
LD HL,1998H 21 98 19
Load Register Pair HL with 1998H, 6552: a number above it cannot take another digit.
6502
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the number so far: the C FLAG when it is above 6552.
6503
If the C FLAG is set (too big), JUMP to 1997H, the ROM's Syntax error.
6506
LD H,D 62
Load Register H with Register D, the high byte of the number so far.
6507
LD L,E 6B
Load Register L with Register E: Register Pair HL = the number so far.
6508
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 2.
6509
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 4.
650A
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the number times 5.
650B
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 10.
650C
POP AF F1
Restore Register Pair AF, the digit in Register A, from the top of the stack.
650D
SUB 30H D6 30
SUBtract 30H from Register A, the ASCII digit, giving its value.
650F
LD E,A 5F
Load Register E with Register A, the value of the digit.
6510
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the value of the digit.
6512
ADD HL,DE 19
ADD Register Pair DE, the digit, to Register Pair HL, ten times the number.
6513
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the new number.
6514
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6515
GOSUB to 1D78H, the ROM's RST 10H code: the next character in Register A, the C FLAG for a digit.
6518
If the C FLAG is set (a digit), LOOP back to 64FDH to add it to the number.
651A
RET C9
RETurn to the scan's caller with the line number in Register Pair DE.
651B
GOSUB to 1E3DH, the ROM's letter test of the character at Register Pair HL: the C FLAG when it is not a letter.
651E
RET C D8
If the C FLAG is set (not a letter), RETurn with Register Pair DE = 0000H: no line number.
651F
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the label in the text.
6520
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
6523
DEC DE 1B
DECrement Register Pair DE by 1, so that the ROM's RST 10H code reads the label's first letter.
6524
PUSH BC C5
Save Register Pair BC to the top of the stack.
6525
LD C,(HL) 4E
Load Register C with the low byte of the line's link at Register Pair HL.
6526
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the link.
6527
LD B,(HL) 46
Load Register B with the high byte of the link at Register Pair HL: Register Pair BC = the next line.
6528
INC HL 23
INCrement Register Pair HL by 1, to the line number.
6529
LD A,B 78
Load Register A with Register B, the high byte of the link.
652A
OR C B1
OR Register A with Register C: the Z FLAG at the end of the program.
652B
If the Z FLAG is set (no line has the label), JUMP to 1ED9H, the ROM's Undefined line number error.
652E
PUSH HL E5
Save Register Pair HL, the line number of this line, to the top of the stack.
652F
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the line number.
6530
GOSUB to 1D78H, the ROM's RST 10H code: the first character of the line's text in Register A.
6533
CP A9H FE A9
Compare Register A against A9H, the token of NAME, which starts a labelled line.
6535
If the NZ FLAG is set (no label), JUMP to 654CH to the next line.
6537
PUSH DE D5
Save Register Pair DE, the label in the text, to the top of the stack.
6538
GOSUB to 1D78H, the ROM's RST 10H code: the next character of the line's label in Register A, the C FLAG for a digit.
653B
If the Z FLAG is set (the end of the statement), JUMP to 6552H: the line's label ends.
653D
CCF 3F
Complement the C FLAG (CCF): the C FLAG now when the character is not a digit.
653E
If the C FLAG is set (not a digit), GOSUB to 1E3DH, the ROM's letter test: the C FLAG when it is not a letter.
6541
If the C FLAG is set (neither digit nor letter), JUMP to 6552H: the line's label ends.
6543
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the label in the text.
6544
GOSUB to 1D78H, the ROM's RST 10H code: the next character of the label in the text in Register A.
6547
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the line's label again.
6548
CP (HL) BE
Compare Register A, the text's character, with the line's character at Register Pair HL.
6549
If the Z FLAG is set (the same), LOOP back to 6538H for the next character.
654B
POP DE D1
Restore Register Pair DE, the label in the text, from the top of the stack.
654C
POP HL E1
Restore Register Pair HL, the line number of this line, from the top of the stack.
654D
LD H,B 60
Load Register H with Register B, the high byte of the next line.
654E
LD L,C 69
Load Register L with Register C: Register Pair HL = the next line.
654F
JUMP to 6525H to look at the next line of the program for the label.
6552
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the label in the text.
6553
GOSUB to 1D78H, the ROM's RST 10H code: the character after the text's label in Register A, the C FLAG for a digit.
6556
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the label in the text again.
6557
If the Z FLAG is set (the text's label ends too), JUMP to 6561H: the labels are the same.
6559
EX DE,HL EB
EXchange Register Pairs DE and HL, so that the ROM's letter test reads the text's character.
655A
CCF 3F
Complement the C FLAG (CCF): the C FLAG now when the character is not a digit.
655B
If the C FLAG is set (not a digit), GOSUB to 1E3DH, the ROM's letter test: the C FLAG when it is not a letter.
655E
EX DE,HL EB
EXchange Register Pairs DE and HL back: Register Pair DE = the label in the text.
655F
If the NC FLAG is set (the text's label goes on), JUMP to 654BH: the labels differ.
6561
POP HL E1
Restore Register Pair HL from the top of the stack: the start of the text's label is dropped.
6562
POP HL E1
Restore Register Pair HL, the line number of the labelled line, from the top of the stack.
6563
PUSH DE D5
Save Register Pair DE, the text after the label, to the top of the stack.
6564
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL.
6565
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the line number.
6566
LD D,(HL) 56
Load Register D with the high byte of the line number at Register Pair HL: Register Pair DE = the line number.
6567
POP HL E1
Restore Register Pair HL, the text after the label, from the top of the stack.
6568
POP BC C1
Restore Register Pair BC from the top of the stack.
6569
RET C9
RETurn to the scan's caller with the labelled line's number in Register Pair DE.

656AH - NAME

Link 418EH, the statement NAME that puts a label on its line: when it runs, the rest of the statement is passed over as by DATA.

656A
JUMP to 1F05H, the ROM's DATA, which passes over the rest of the statement, the label.

656DH - The File Number

656DH (mode 01H, input) and 656FH (mode in Register C) take #n, followed by a comma, at Register Pair HL: the file must be open in that mode (else Bad file mode), and its area becomes the current file (62FCH). Without # they return at once. 6582H evaluates the file number: 0 is Bad record number (6C95H), above the number of files Bad file number (6593H). 6593H: Register A = a file number; returns Index Register IX = its area, Register Pair DE = the area's file control block (+02H), Register A = the mode byte and the Z FLAG when the file is closed.

656D
LD C,01H 0E 01
Load Register C with 01H, the mode of a file open for input.
656F
CP 23H FE 23
Compare Register A, the character at the text, against 23H, the # of a file number.
6571
RET NZ C0
If the NZ FLAG is set (no #), RETurn: the statement has no file number.
6572
PUSH BC C5
Save Register Pair BC, the mode wanted in Register C, to the top of the stack.
6573
GOSUB to 6582H to evaluate the file number and find its area: Register A returns its mode.
6576
POP BC C1
Restore Register Pair BC, the mode wanted in Register C, from the top of the stack.
6577
CP C B9
Compare Register A, the file's mode, against Register C, the mode wanted.
6578
If the NZ FLAG is set (another mode, or closed), JUMP to 6C83H, the error Bad file mode.
657B
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the file number, or the ROM shows a Syntax error.
657D
LD (62FCH),IX DD 22 FC 62
Store Index Register IX, the file's area, into 62FCH-62FDH: the current file.
6581
RET C9
RETurn with the file's area current in 62FCH-62FDH.
6582
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character again.
6583
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character.
6584
CP 23H FE 23
Compare Register A against 23H, the # before the file number.
6586
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code, to pass over it.
6589
GOSUB to 2337H, the ROM's expression evaluator, for the file number at Register Pair HL.
658C
GOSUB to 2B1FH, the ROM's CONINT, to make the file number a byte in Register A.
658F
OR A B7
OR Register A against itself: the Z FLAG for file number 0.
6590
If the Z FLAG is set (file 0), JUMP to 6C95H, the error Bad record number.
6593
LD E,A 5F
Load Register E with Register A, the file number.
6594
LD A,(62FAH) 3A FA 62
Load Register A with the number of files from 62FAH.
6597
CP E BB
Compare Register A against Register E, the file number: the C FLAG when it is above the number of files.
6598
If the C FLAG is set, JUMP to 6C86H, the error Bad file number.
659B
SLA E CB 23
Shift Register E left (SLA): twice the file number, the offset of its word in the table.
659D
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the offset.
659F
LD IX,62FEH DD 21 FE 62
Point Index Register IX to 62FEH, the table of the file areas.
65A3
ADD IX,DE DD 19
ADD Register Pair DE, the offset, to Index Register IX: the file's entry in the table.
65A5
LD E,(IX+00H) DD 5E 00
Load Register E with the low byte of the area's address from Index Register IX+00H.
65A8
LD D,(IX+01H) DD 56 01
Load Register D with the high byte of the area's address from Index Register IX+01H.
65AB
LD A,(DE) 1A
Load Register A with the mode byte of the area at Register Pair DE: 00H closed.
65AC
PUSH DE D5
Save Register Pair DE, the area, to the top of the stack.
65AD
POP IX DD E1
Restore Index Register IX with the area from the top of the stack.
65AF
INC DE 13
INCrement Register Pair DE by 1, to the column byte of the area.
65B0
INC DE 13
INCrement Register Pair DE by 1, to the file control block of the area.
65B1
OR A B7
OR Register A against itself: the Z FLAG when the file is closed.
65B2
RET C9
RETurn with Index Register IX the area and Register Pair DE its file control block.

65B3H - MKI$, MKS$ and MKD$

Links 416AH (65B3H, MKI$: 2 bytes), 416DH (65B6H, MKS$: 4 bytes) and 4170H (65B9H, MKD$: 8 bytes). The number is converted to that type (the ROM's 2819H) and its bytes become a new string.

65B3
LD A,02H 3E 02
MKI$: load Register A with 02H, the type and length of an integer.
65B5
LD BC,043EH 01 3E 04
65B6H (MKS$) enters inside this LD BC,043EH: its bytes 3EH 04H read as LD A,04H, single precision; from above it only loads Register Pair BC.
65B8
LD BC,083EH 01 3E 08
65B9H (MKD$) enters inside this LD BC,083EH: its bytes 3EH 08H read as LD A,08H, double precision; from above it only loads Register Pair BC.
65BB
PUSH AF F5
Save Register Pair AF, the type in Register A, to the top of the stack.
65BC
GOSUB to 2819H, the ROM's conversion of the accumulator to the type in Register A.
65BF
POP AF F1
Restore Register Pair AF, the type in Register A, from the top of the stack.
65C0
GOSUB to 2857H, the ROM's STRINI, to make room for a string of Register A bytes with its descriptor at 40D3H.
65C3
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the address of the new string from 40D4H-40D5H.
65C6
GOSUB to 09FFH, the ROM's copy of the accumulator's value to Register Pair HL by its type.
65C9
JUMP to 2A2BH, the ROM's end of a string function, which makes the new string the result.

65CCH - CVI, CVS and CVD

Links 4152H (65CCH, CVI), 4158H (65CFH, CVS) and 415EH (65D2H, CVD): the first 2, 4 or 8 bytes of the string become the value of that type. A shorter string is Illegal function call.

65CC
LD A,01H 3E 01
CVI: load Register A with 01H, the length of an integer less 1.
65CE
LD BC,033EH 01 3E 03
65CFH (CVS) enters inside this LD BC,033EH: its bytes 3EH 03H read as LD A,03H, single precision; from above it only loads Register Pair BC.
65D1
LD BC,073EH 01 3E 07
65D2H (CVD) enters inside this LD BC,073EH: its bytes 3EH 07H read as LD A,07H, double precision; from above it only loads Register Pair BC.
65D4
PUSH AF F5
Save Register Pair AF, the length less 1 in Register A, to the top of the stack.
65D5
GOSUB to 29D7H, the ROM's routine that frees the string's temporary descriptor: Register Pair HL returns the descriptor.
65D8
POP AF F1
Restore Register Pair AF, the length less 1 in Register A, from the top of the stack.
65D9
CP (HL) BE
Compare Register A against the length of the string at Register Pair HL: the NC FLAG when the string is too short.
65DA
If the NC FLAG is set (too short), JUMP to 1E4AH, the ROM's Illegal function call error.
65DD
INC A 3C
INCrement Register A by 1: the type, 02H, 04H or 08H.
65DE
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
65DF
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
65E0
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
65E1
LD H,(HL) 66
Load Register H with the high byte of the string's address at Register Pair HL.
65E2
LD L,C 69
Load Register L with Register C: Register Pair HL = the bytes of the string.
65E3
LD (40AFH),A 32 AF 40
Store Register A, the type, to 40AFH, the ROM's type of the value in the accumulator.
65E6
JUMP to 09F7H, the ROM's copy of the value at Register Pair HL into the accumulator by its type.

65E9H - INPUT # Items and LINE INPUT #

65E9H is the link 41DCH, called by the ROM's INPUT for each item (222DH). With no current file it returns. With a file the ROM's return is dropped and the item is read from the file into the input buffer (6610H) with the flags in Register D: bit 0 pass over leading spaces, bit 1 a number (a space or a comma ends it), bit 2 a string may be quoted, bit 3 inside the quotes. A number is converted by the ROM's 0E6CH, a string becomes a temporary string (2868H). The item then goes back into the ROM's INPUT at 2243H. LINE INPUT # (65FDH) reads everything up to the carriage return (Register D = 00H) and assigns it through the ROM's 1F31H. A carriage return or the end of the file ends an item; an item of 255 characters ends there. Reading the first byte past the end of the file is Input past end.

65E9
LD DE,(62FCH) ED 5B FC 62
Load Register Pair DE with the current file area from 62FCH-62FDH (0000H: none).
65ED
LD A,D 7A
Load Register A with Register D, the high byte of the file area.
65EE
OR E B3
OR Register A with Register E: the Z FLAG when there is no current file.
65EF
RET Z C8
If the Z FLAG is set (no file), RETurn: the ROM takes the item from its input buffer.
65F0
POP DE D1
Restore Register Pair DE with the ROM's return address (2230H), which is not used.
65F1
RST 20H E7
RST 20H: test the type of the variable: Register A the type less 3, the Z FLAG for a string.
65F2
LD BC,2243H 01 43 22
Load Register Pair BC with 2243H, where the ROM's INPUT goes on with the item.
65F5
LD D,03H 16 03
Load Register D with 03H, the flags of a number: pass over leading spaces, a space ends it.
65F7
If the NZ FLAG is set (a number), JUMP to 6610H to read it.
65F9
LD D,05H 16 05
Load Register D with 05H, the flags of a string: pass over leading spaces, it may be quoted.
65FB
JUMP to 6610H to read the string item from the file.
65FD
GOSUB to 656DH to take #n, open for input, and make its area the current one.
6600
GOSUB to 260DH, the ROM's variable search, for the variable at Register Pair HL: Register Pair DE returns its descriptor.
6603
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
6606
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's reset of the output, where LINE INPUT # ends.
6609
PUSH BC C5
Save Register Pair BC (2169H) to the top of the stack, the last return address.
660A
PUSH DE D5
Save Register Pair DE, the variable's descriptor, to the top of the stack for the ROM's assignment.
660B
LD BC,1F31H 01 31 1F
Load Register Pair BC with 1F31H, the ROM's assignment of LET after its expression.
660E
XOR A AF
Set Register A to 00H by XORing it with itself: the type less 3 of a string.
660F
LD D,A 57
Load Register D with Register A (00H): no flags, the whole line up to its carriage return.
6610
PUSH AF F5
Save Register Pair AF, the type less 3 and its flags, to the top of the stack for the ROM.
6611
PUSH BC C5
Save Register Pair BC, the address where the ROM goes on, to the top of the stack.
6612
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
6613
LD B,FFH 06 FF
Load Register B with FFH, the most characters of an item: 255.
6615
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the input buffer's address from 40A7H-40A8H.
6618
PUSH HL E5
Save Register Pair HL, the input buffer, to the top of the stack.
6619
GOSUB to 6B92H to read the next byte of the file into Register A: the C FLAG at the end of the file.
661C
If the C FLAG is set (nothing left), JUMP to 6C8CH, the error Input past end.
661F
CP 20H FE 20
Compare Register A against 20H, the space before or in an item.
6621
If the NZ FLAG is set (not a space), JUMP to 6629H.
6623
BIT 0,D CB 42
Test bit 0 of Register D: the NZ FLAG when leading spaces are passed over.
6625
If the NZ FLAG is set, LOOP back to 6619H for the next byte.
6627
JUMP to 6638H to keep the space as part of the item.
6629
CP 22H FE 22
Compare Register A against 22H, the quotation mark.
662B
If the NZ FLAG is set (not a quotation mark), JUMP to 6638H.
662D
BIT 2,D CB 52
Test bit 2 of Register D: the NZ FLAG when the item may be quoted.
662F
If the Z FLAG is set (no quotes), JUMP to 6638H to keep the quotation mark.
6631
GOSUB to 6B92H to read the byte after the quotation mark into Register A: the C FLAG at the end of the file.
6634
If the C FLAG is set (the end of the file), JUMP to 6696H to end the item.
6636
SET 3,D CB DA
SET bit 3 of Register D: the bytes are now inside the quotes.
6638
BIT 3,D CB 5A
Test bit 3 of Register D: the NZ FLAG inside the quotes.
663A
If the NZ FLAG is set (quoted), JUMP to 6659H.
663C
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return.
663E
If the Z FLAG is set (the end of the line), JUMP to 6696H to end the item.
6640
CP 0AH FE 0A
Compare Register A against 0AH, the line feed.
6642
If the NZ FLAG is set (not a line feed), JUMP to 6659H.
6644
BIT 2,D CB 52
Test bit 2 of Register D: the Z FLAG for a number or LINE INPUT #.
6646
If the Z FLAG is set, GOSUB to 66ABH to keep the line feed in the item.
6649
GOSUB to 6B92H to read the next byte of the file into Register A: the C FLAG at the end of the file.
664C
If the C FLAG is set (the end of the file), JUMP to 6696H to end the item.
664E
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return after the line feed.
6650
If the NZ FLAG is set (another byte), JUMP to 6659H.
6652
BIT 0,D CB 42
Test bit 0 of Register D: the Z FLAG for LINE INPUT #.
6654
If the Z FLAG is set, GOSUB to 66ABH to keep the carriage return in the line.
6657
JUMP to 6679H: a carriage return after a line feed does not end the item.
6659
OR A B7
OR Register A against itself: the Z FLAG for a byte 00H.
665A
If the Z FLAG is set (00H), JUMP to 6679H: the byte is passed over.
665C
BIT 0,D CB 42
Test bit 0 of Register D: the Z FLAG for LINE INPUT #.
665E
If the Z FLAG is set (LINE INPUT #), JUMP to 6676H to keep the byte.
6660
BIT 3,D CB 5A
Test bit 3 of Register D: the NZ FLAG inside the quotes.
6662
If the Z FLAG is set (not quoted), JUMP to 666AH.
6664
CP 22H FE 22
Compare Register A against 22H, the closing quotation mark.
6666
If the Z FLAG is set (the string ends), JUMP to 6680H.
6668
JUMP to 6676H to keep the byte of the quoted string.
666A
CP 2CH FE 2C
Compare Register A against 2CH, the comma between items.
666C
If the Z FLAG is set (a comma), JUMP to 6696H to end the item.
666E
BIT 1,D CB 4A
Test bit 1 of Register D: the NZ FLAG for a number.
6670
If the Z FLAG is set (a string), JUMP to 6676H to keep the byte.
6672
CP 20H FE 20
Compare Register A against 20H, the space that ends a number.
6674
If the Z FLAG is set (a space), JUMP to 6680H.
6676
GOSUB to 66ABH to keep the byte in Register A in the item.
6679
GOSUB to 6B92H to read the next byte of the file into Register A: the C FLAG at the end of the file.
667C
If the C FLAG is set (the end of the file), JUMP to 6696H to end the item.
667E
LOOP back to 6638H to look at the byte just read from the file.
6680
GOSUB to 6B92H to read the next byte of the file into Register A: the C FLAG at the end of the file.
6683
If the C FLAG is set (the end of the file), JUMP to 6696H to end the item.
6685
CP 20H FE 20
Compare Register A against 20H, a space after the item.
6687
If the Z FLAG is set (a space), LOOP back to 6680H.
6689
CP 2CH FE 2C
Compare Register A against 2CH, the comma after the item.
668B
If the Z FLAG is set (a comma), JUMP to 6696H to end the item.
668D
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return after the item.
668F
If the Z FLAG is set (the end of the line), JUMP to 6696H to end the item.
6691
PUSH DE D5
Save Register Pair DE, the flags in Register D, to the top of the stack.
6692
GOSUB to 6BD9H to step the file back one byte: the byte is left for the next item.
6695
POP DE D1
Restore Register Pair DE, the flags in Register D, from the top of the stack.
6696
LD (HL),00H 36 00
Store 00H at Register Pair HL, the end of the item in the buffer.
6698
POP HL E1
Restore Register Pair HL, the input buffer, from the top of the stack.
6699
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the buffer.
669A
BIT 1,D CB 4A
Test bit 1 of Register D: the NZ FLAG for a number.
669C
If the NZ FLAG is set (a number), JUMP to 66A5H.
669E
LD B,00H 06 00
Load Register B with 00H, the byte that ends the item in the buffer.
66A0
GOSUB to 2868H, the ROM's routine that makes the text at Register Pair HL, up to the 00H in Register B, a temporary string.
66A3
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
66A4
RET C9
RETurn into the ROM at the address in Register Pair BC (2243H or 1F31H) with the string.
66A5
RST 10H D7
RST 10H: increment Register Pair HL to the first character of the item and load Register A with it.
66A6
GOSUB to 0E6CH, the ROM's conversion of the text at Register Pair HL to a number in the accumulator.
66A9
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
66AA
RET C9
RETurn into the ROM's INPUT at 2243H with the number.
66AB
LD (HL),A 77
Store Register A, the byte, at Register Pair HL in the item.
66AC
INC HL 23
INCrement Register Pair HL by 1, to the next place in the buffer.
66AD
DEC B 05
DECrement Register B by 1, the room left in the item.
66AE
RET NZ C0
If the NZ FLAG is set (room left), RETurn to the reading of the item.
66AF
POP BC C1
Restore Register Pair BC with the return address, which is dropped: the item is full.
66B0
JUMP to 6696H to end the item of 255 characters.

66B2H - RUN and LOAD

Link 41C7H (66B2H, RUN with a file name or a line number, from the ROM's 1EA6H) and link 4188H (66B5H, LOAD). RUN of a line number returns to the ROM. Otherwise the file is opened as area 0 for input; ,R sets the run flag and ,V the verify flag (62F7H, 66F1H), or a line number after a comma becomes the line RUN starts at (40F3H). Unless verify, the program is cleared (the ROM's NEW) first. A file whose first byte is not FFH is an ASCII program: it is left open and the command level reads it line by line through the line input link. A compressed program (first byte FFH) is loaded by 6723H. Then, for RUN, the program is run from the line in 40F3H.

66B2
RET C D8
If the C FLAG is set (RUN of a line number, not a string), RETurn to the ROM's RUN.
66B3
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used.
66B4
OR AFH F6 AF
RUN: OR Register A with AFH, Register A not 00H, the run flag. LOAD enters at 66B5H, the AFH operand, which reads as XOR A and sets Register A to 00H, LOAD's run flag.
66B6
LD (62F7H),A 32 F7 62
Store Register A (not 00H for RUN, 00H for LOAD) to 62F7H, the run flag.
66B9
XOR A AF
Set Register A to 00H by XORing it with itself.
66BA
LD (66F1H),A 32 F1 66
Store Register A (00H) to 66F1H, the operand of LD A,00H at 66F0H, the verify flag: not set yet.
66BD
LD D,01H 16 01
Load Register D with 01H, the mode of a file open for input.
66BF
GOSUB to 6B04H to take the file specification and open it as file area 0 for input: Register Pair HL at the text after it.
66C2
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the line RUN starts at when none is given.
66C5
LD (40F3H),DE ED 53 F3 40
Store Register Pair DE into 40F3H-40F4H, the line RUN starts at.
66C9
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the file again.
66CA
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
66CB
If the Z FLAG is set (the end of the statement), JUMP to 66E9H to load the program.
66CD
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before an option, or the ROM shows a Syntax error.
66CF
If the NC FLAG is set (not a digit), JUMP to 66D6H to test for R or V.
66D1
GOSUB to 1E5AH, the ROM's scan of a line number at Register Pair HL into Register Pair DE.
66D4
JUMP back to 66C5H to store the line number as the line RUN starts at.
66D6
CP 52H FE 52
Compare Register A against 52H, the letter R, which makes LOAD run the program.
66D8
If the NZ FLAG is set (not R), JUMP to 66DFH.
66DA
LD (62F7H),A 32 F7 62
Store Register A (52H) to 62F7H, the run flag: the program is run after it is loaded.
66DD
JUMP back to 66CAH for the next character after the R option.
66DF
CP 56H FE 56
Compare Register A against 56H, the letter V, which verifies the load.
66E1
If the NZ FLAG is set (neither R nor V), JUMP to 1997H, the ROM's Syntax error.
66E4
LD (66F1H),A 32 F1 66
Store Register A (56H) to 66F1H, the operand of LD A,00H at 66F0H, the verify flag.
66E7
JUMP back to 66CAH for the next character after the V option.
66E9
LD A,(62F7H) 3A F7 62
Load Register A with the run flag from 62F7H: 00H for a plain LOAD.
66EC
OR A B7
OR Register A against itself: the Z FLAG for a plain LOAD.
66ED
If the Z FLAG is set (LOAD), GOSUB to 68FFH to close every open file.
66F0
LD A,00H 3E 00
Load Register A with the verify flag, the operand 66F1H: 00H or 56H.
66F2
OR A B7
OR Register A against itself: the Z FLAG when the load is not a verify.
66F3
If the NZ FLAG is set (a verify), JUMP to 6707H: the program in memory is kept.
66F5
LD A,(62FAH) 3A FA 62
Load Register A with the number of files from 62FAH.
66F8
LD (6703H),A 32 03 67
Store Register A to 6703H, the operand of LD A,00H at 6702H, the number of files saved.
66FB
XOR A AF
Set Register A to 00H by XORing it with itself.
66FC
LD (62FAH),A 32 FA 62
Store Register A (00H) to 62FAH, the number of files, so that the ROM's NEW closes none.
66FF
GOSUB to 1B4DH, the ROM's NEW, which clears the program and the variables.
6702
LD A,00H 3E 00
Load Register A with the number of files saved, the operand 6703H (00H in the file).
6704
LD (62FAH),A 32 FA 62
Store Register A to 62FAH, the number of files restored.
6707
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
6708
GOSUB to 6593H for file area 0: Index Register IX the area, Register Pair DE its file control block.
670B
LD (62FCH),IX DD 22 FC 62
Store Index Register IX, file area 0, into 62FCH-62FDH: the current file.
670F
GOSUB to 6BEDH to read the first record of the file into its buffer: Register Pair HL at the first byte.
6712
LD A,(HL) 7E
Load Register A with the first byte of the file at Register Pair HL.
6713
INC A 3C
INCrement Register A by 1: the Z FLAG when the first byte is FFH, a compressed program.
6714
If the Z FLAG is set (FFH), JUMP to 6723H to load the compressed program.
6716
GOSUB to 6BCDH to rewind the file to its first record (an ASCII program is read from the start).
6719
LD A,(66F1H) 3A F1 66
Load Register A with the verify flag from 66F1H: 56H for ,V.
671C
OR A B7
OR Register A against itself: the NZ FLAG for a verify.
671D
If the NZ FLAG is set (verify of an ASCII file), JUMP to 6C83H, the error Bad file mode.
6720
JUMP to 1A33H, the ROM's command level, which reads the ASCII program line by line from the file.

6723H - The Compressed Loader

A compressed program's records hold the program text. The program's length is the file's size (the sector count in the file control block and the bytes in the last sector); it must fit below the start of the string space and below the top of memory (else Out of memory). The variable tables (VARTAB, ARYTAB, STREND) are moved up or down by that length to make room, their string pointers adjusted (67D1H), then the program bytes are read record by record into the text area. The links are rebuilt (the ROM's 1AF8H), the pointers reset and the stack reinitialized.

6723
GOSUB to 67D1H to adjust the string pointers of the variables for the move of the variable tables.
6726
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
6729
LD C,(IX+0AH) DD 4E 0A
Load Register C with the bytes in the last sector from Index Register IX+0AH, the file control block's end of file byte.
672C
LD B,(IX+0EH) DD 46 0E
Load Register B with the low byte of the sector count from Index Register IX+0EH.
672F
LD A,(IX+0FH) DD 7E 0F
Load Register A with the high byte of the sector count from Index Register IX+0FH.
6732
OR A B7
OR Register A against itself: the NZ FLAG when the program is 256 sectors or more.
6733
If the NZ FLAG is set (too long), JUMP to 197AH, the ROM's Out of memory error.
6736
DEC BC 0B
DECrement Register Pair BC by 1, toward the program's length in Register Pair BC.
6737
ADD HL,BC 09
ADD Register Pair BC, the length, to Register Pair HL, the start of the program: the end of the program.
6738
If the C FLAG is set (past FFFFH), JUMP to 197AH, the ROM's Out of memory error.
673B
PUSH BC C5
Save Register Pair BC, the program's length, to the top of the stack.
673C
PUSH HL E5
Save Register Pair HL, the end of the program, to the top of the stack.
673D
LD DE,(40F9H) ED 5B F9 40
Load Register Pair DE with VARTAB from 40F9H-40FAH, the start of the variables.
6741
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with STREND from 40FDH-40FEH, the end of the variables.
6744
SBC HL,DE ED 52
SUBtract Register Pair DE, VARTAB, from Register Pair HL: Register Pair HL = the length of the variable tables.
6746
LD C,L 4D
Load Register C with Register L, the low byte of the variable length.
6747
LD B,H 44
Load Register B with Register H: Register Pair BC = the length of the variable tables.
6748
POP HL E1
Restore Register Pair HL, the end of the program, from the top of the stack.
6749
SBC HL,DE ED 52
SUBtract Register Pair DE, VARTAB, from Register Pair HL: how far the variable tables move.
674B
PUSH HL E5
Save Register Pair HL, the distance of the move, to the top of the stack.
674C
If the C FLAG is set (the program ends below VARTAB), JUMP to 676AH to move the tables down.
674E
ADD HL,DE 19
ADD Register Pair DE, VARTAB, back to Register Pair HL: the end of the program again.
674F
ADD HL,BC 09
ADD Register Pair BC, the variable length, to Register Pair HL: the new end of the variable tables.
6750
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the new end of the tables.
6751
If the C FLAG is set (past FFFFH), JUMP to 197AH, the ROM's Out of memory error.
6754
PUSH BC C5
Save Register Pair BC, the variable length, to the top of the stack.
6755
LD BC,FFAAH 01 AA FF
Load Register Pair BC with FFAAH, minus 86, the room kept below the top of memory.
6758
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the top of the string space from 40A0H-40A1H.
675B
ADD HL,BC 09
ADD Register Pair BC (minus 86) to Register Pair HL, the top of the string space.
675C
SBC HL,DE ED 52
SUBtract Register Pair DE, the new end of the tables, from Register Pair HL: the C FLAG when there is not room.
675E
POP BC C1
Restore Register Pair BC, the variable length, from the top of the stack.
675F
If the C FLAG is set (no room), JUMP to 197AH, the ROM's Out of memory error.
6762
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with STREND from 40FDH-40FEH, the last byte to move.
6765
INC BC 03
INCrement Register Pair BC by 1, the bytes of the variable tables to move.
6766
LDDR ED B8
Copy the variable tables up by Register Pair BC bytes, from Register Pair HL down to Register Pair DE, by LDDR.
6768
JUMP to 676FH past the downward move of the tables.
676A
ADD HL,DE 19
ADD Register Pair DE, VARTAB, to Register Pair HL: the new start of the variable tables.
676B
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the new start, Register Pair HL = VARTAB.
676C
INC BC 03
INCrement Register Pair BC by 1, the bytes of the variable tables to move.
676D
LDIR ED B0
Copy the variable tables down by Register Pair BC bytes, from Register Pair HL to Register Pair DE, by LDIR.
676F
POP BC C1
Restore Register Pair BC, the distance of the move, from the top of the stack.
6770
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH.
6773
ADD HL,BC 09
ADD Register Pair BC, the distance, to Register Pair HL: the new VARTAB.
6774
LD (40F9H),HL 22 F9 40
Store Register Pair HL into 40F9H-40FAH, VARTAB moved.
6777
LD HL,(40FBH) 2A FB 40
Load Register Pair HL with ARYTAB from 40FBH-40FCH.
677A
ADD HL,BC 09
ADD Register Pair BC, the distance, to Register Pair HL: the new ARYTAB.
677B
LD (40FBH),HL 22 FB 40
Store Register Pair HL into 40FBH-40FCH, ARYTAB moved.
677E
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with STREND from 40FDH-40FEH.
6781
ADD HL,BC 09
ADD Register Pair BC, the distance, to Register Pair HL: the new STREND.
6782
LD (40FDH),HL 22 FD 40
Store Register Pair HL into 40FDH-40FEH, STREND moved.
6785
POP BC C1
Restore Register Pair BC, the program's length, from the top of the stack.
6786
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
678A
GOSUB to 6BF8H to load Register Pair HL with the file's buffer pointer from Index Register IX+05H-06H.
678D
INC HL 23
INCrement Register Pair HL by 1, past the FFH that marks a compressed file.
678E
LDI ED A0
Copy one byte of the program from Register Pair HL to Register Pair DE by LDI, counting Register Pair BC down.
6790
If the PO FLAG is set (the whole program is loaded), JUMP to 679EH.
6793
LD A,(IX+0AH) DD 7E 0A
Load Register A with the bytes in the last sector from Index Register IX+0AH, the record length.
6796
CP C B9
Compare Register A against Register C, the low byte of the count left: the Z FLAG at a record boundary.
6797
PUSH DE D5
Save Register Pair DE, the place in the text area, to the top of the stack.
6798
If the Z FLAG is set (a record boundary), GOSUB to 6BEDH to read the next record into Register Pair HL.
679B
POP DE D1
Restore Register Pair DE, the place in the text area, from the top of the stack.
679C
LOOP back to 678EH for the next byte of the program.
679E
GOSUB to 1AF8H, the ROM's routine that rebuilds the links of the program's lines.
67A1
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
67A4
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the program.
67A5
LD (40DFH),HL 22 DF 40
Store Register Pair HL into 40DFH-40E0H, the ROM's text pointer.
67A8
LD (40FFH),HL 22 FF 40
Store Register Pair HL into 40FFH-4100H, the ROM's READ/DATA pointer.
67AB
XOR A AF
Set Register A to 00H by XORing it with itself.
67AC
LD (40F2H),A 32 F2 40
Store Register A (00H) to 40F2H, the ROM's ON ERROR active flag: off.
67AF
LD L,A 6F
Load Register L with Register A (00H), the low byte of 0000H.
67B0
LD H,A 67
Load Register H with Register A (00H): Register Pair HL = 0000H.
67B1
LD (40F0H),HL 22 F0 40
Store Register Pair HL (0000H) into 40F0H-40F1H, the ROM's ON ERROR line: none.
67B4
LD (40F7H),HL 22 F7 40
Store Register Pair HL (0000H) into 40F7H-40F8H, the ROM's saved text pointer for CONT: none.
67B7
GOSUB to 1B8FH, the ROM's STKINI, which resets the stack and clears GOSUB and FOR.
67BA
GOSUB to 6826H to close file area 0, the program file.
67BD
LD A,(62F7H) 3A F7 62
Load Register A with the run flag from 62F7H: 00H for LOAD.
67C0
OR A B7
OR Register A against itself: the Z FLAG for LOAD.
67C1
If the Z FLAG is set (LOAD), JUMP to 1A19H, the ROM's READY.
67C4
LD DE,(40F3H) ED 5B F3 40
Load Register Pair DE with the line RUN starts at from 40F3H-40F4H.
67C8
GOSUB to 1B2CH, the ROM's search for line Register Pair DE: Register Pair BC the line.
67CB
DEC BC 0B
DECrement Register Pair BC by 1, to the byte before the line's text, for the dispatcher.
67CC
LD H,B 60
Load Register H with Register B, the high byte of the line.
67CD
LD L,C 69
Load Register L with Register C: Register Pair HL = the byte before the line.
67CE
JUMP to 1D1EH, the ROM's run of the program from line Register Pair HL.

67D1H - Move the String Pointers

Walks the simple variables and then the arrays; for each string whose characters are in the program text (below the start of the variables and above the top of the string space), the ROM's 2843H copies the string into the string space, so it survives the move of the program. Used before the compressed loader moves the variable tables.

67D1
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the first simple variable.
67D4
LD DE,(40FDH) ED 5B FD 40
Load Register Pair DE with STREND from 40FDH-40FEH, the end of the variables.
67D8
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG at the end of the variables.
67D9
RET Z C8
If the Z FLAG is set (all variables done), RETurn to the loader.
67DA
LD DE,(40FBH) ED 5B FB 40
Load Register Pair DE with ARYTAB from 40FBH-40FCH, the start of the arrays.
67DE
LD C,(HL) 4E
Load Register C with the type of the variable at Register Pair HL.
67DF
INC HL 23
INCrement Register Pair HL by 1, past the type byte.
67E0
INC HL 23
INCrement Register Pair HL by 1, past the first name byte.
67E1
INC HL 23
INCrement Register Pair HL by 1, past the second name byte, to the value.
67E2
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE (ARYTAB): the C FLAG for a simple variable.
67E3
LD B,00H 06 00
Load Register B with 00H, the high byte of the length in Register Pair BC.
67E5
LD A,C 79
Load Register A with Register C, the type of the variable.
67E6
If the C FLAG is set (a simple variable), JUMP to 67ECH.
67E8
LD C,(HL) 4E
Load Register C with the low byte of the array's length at Register Pair HL.
67E9
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the array's length.
67EA
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL.
67EB
INC HL 23
INCrement Register Pair HL by 1, past the length word.
67EC
PUSH HL E5
Save Register Pair HL, the value or the array, to the top of the stack.
67ED
ADD HL,BC 09
ADD Register Pair BC, the length, to Register Pair HL: the variable or array after this one.
67EE
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the value, the next one saved.
67EF
CP 03H FE 03
Compare Register A, the type, against 03H, a string.
67F1
If the NZ FLAG is set (not a string), JUMP to 6823H to the next variable.
67F3
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE (ARYTAB): the C FLAG for a simple string.
67F4
If the C FLAG is set (a simple string), JUMP to 67FEH.
67F6
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the array of strings.
67F7
LD A,(DE) 1A
Load Register A with the low byte of the array's dimension count at Register Pair DE.
67F8
INC DE 13
INCrement Register Pair DE by 1, past the dimension count byte.
67F9
LD L,A 6F
Load Register L with Register A, the dimension count.
67FA
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the dimension count.
67FC
ADD HL,HL 29
ADD Register Pair HL to itself: twice the count, the bytes of the dimensions.
67FD
ADD HL,DE 19
ADD Register Pair DE, the array, to Register Pair HL: the first string of the array.
67FE
PUSH HL E5
Save Register Pair HL, the string's descriptor, to the top of the stack.
67FF
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
6800
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
6801
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
6802
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL.
6803
INC HL 23
INCrement Register Pair HL by 1, past the descriptor.
6804
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the descriptor, the place after it saved.
6805
PUSH HL E5
Save Register Pair HL, the descriptor, to the top of the stack.
6806
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
6809
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the program's start.
680A
POP HL E1
Restore Register Pair HL, the descriptor, from the top of the stack.
680B
If the NC FLAG is set (below the program), JUMP to 681DH: the string is not moved.
680D
PUSH HL E5
Save Register Pair HL, the descriptor, to the top of the stack.
680E
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the top of the string space from 40A0H-40A1H.
6811
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the string space.
6812
POP HL E1
Restore Register Pair HL, the descriptor, from the top of the stack.
6813
If the C FLAG is set (in the string space), JUMP to 681DH: the string is not moved.
6815
PUSH HL E5
Save Register Pair HL, the descriptor, to the top of the stack.
6816
GOSUB to 2843H, the ROM's routine that copies the string of the descriptor at Register Pair HL into the string space, with its descriptor at 40D3H.
6819
POP HL E1
Restore Register Pair HL, the descriptor, from the top of the stack.
681A
GOSUB to 09D3H, the ROM's copy of the new descriptor at 40D3H into the descriptor at Register Pair HL.
681D
POP HL E1
Restore Register Pair HL, the place after the descriptor, from the top of the stack.
681E
POP DE D1
Restore Register Pair DE, the next variable or array, from the top of the stack.
681F
PUSH DE D5
Save Register Pair DE, the next variable or array, to the top of the stack again.
6820
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG at the end of this array.
6821
If the NZ FLAG is set (more strings in the array), LOOP back to 67FEH.
6823
POP HL E1
Restore Register Pair HL, the next variable or array, from the top of the stack.
6824
JUMP back to 67D4H for the next variable of the program.

6826H - The READY Link

Link 41ACH, called by the ROM's 1A1CH just before the READY prompt. File area 0 is closed (683AH), the output is reset (the ROM's 2169H), and when the call is the ROM's READY (its 1A1FH follows) a protected program (62FBH) is wiped (6C47H), then the ROM's 1BAFH restores its text pointer and goes on.

6826
GOSUB to 2169H, the ROM's routine that resets the output to the display and turns the cassette off.
6829
GOSUB to 683AH to close file area 0 if it is open.
682C
POP HL E1
Restore Register Pair HL with the ROM's return address.
682D
PUSH DE D5
Save Register Pair DE to the top of the stack.
682E
LD DE,1A1FH 11 1F 1A
Load Register Pair DE with 1A1FH, the address after the ROM's call of this link.
6831
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE: the Z FLAG for the call from READY.
6832
POP DE D1
Restore Register Pair DE from the top of the stack.
6833
PUSH HL E5
Save Register Pair HL, the return address, to the top of the stack.
6834
If the Z FLAG is set (from READY), GOSUB to 6C47H to wipe a program protected against listing.
6837
JUMP to 1BAFH, the ROM's code that restores its text pointer and goes on to READY.

683AH - Close a File Area

Closes the file area whose number is in Register A (0 for area 0). CLOSE@ is called only for a file open for output; the area's mode byte is then set to 00H. An error from CLOSE@ is posted.

683A
GOSUB to 6593H for the file number in Register A: Register Pair DE the file control block, Register A the area's mode byte, the Z FLAG when it is closed.
683D
RET Z C8
If the Z FLAG is set (the file is already closed), RETurn.
683E
DEC A 3D
DECrement Register A by 1: the Z FLAG when the mode is 01H, a file open for input, which needs no CLOSE@.
683F
If the NZ FLAG is set (a file open for output), GOSUB to 4428H, CLOSE@, to close the file at Register Pair DE.
6842
LD (IX+00H),00H DD 36 00 00
Store 00H at Index Register IX+00H, the area's mode byte: the file is closed.
6846
If the NZ FLAG is set (an error from CLOSE@), JUMP to 6CA3H to post the error in Register A.
6849
RET C9
RETurn with the file area closed and its mode byte 00H.

684AH - MERGE

Link 418BH, the statement MERGE. The file is opened as area 0 for input; ,R sets the run flag. The file must be an ASCII program (first byte not FFH, else Bad file mode); it is rewound and the command level reads its lines, which are added to the program in memory.

684A
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used.
684B
XOR A AF
Set Register A to 00H by XORing it with itself, the run flag of MERGE.
684C
LD (62F7H),A 32 F7 62
Store Register A (00H) to 62F7H, the run flag.
684F
LD D,01H 16 01
Load Register D with 01H, the mode of a file open for input.
6851
GOSUB to 6B04H to take the file specification and open it as area 0 for input: Register Pair HL at the text after it.
6854
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the file again.
6855
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
6856
If the Z FLAG is set (the end of the statement), JUMP to 6869H.
6858
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before R, or the ROM shows a Syntax error.
685A
CP 52H FE 52
Compare Register A against 52H, the letter R, which runs the merged program.
685C
If the NZ FLAG is set (not R), JUMP to 6863H, a syntax error.
685E
LD (62F7H),A 32 F7 62
Store Register A (52H) to 62F7H, the run flag.
6861
JUMP back to 6855H for the next character after the file name.
6863
GOSUB to 6826H to close file area 0 after the syntax error.
6866
JUMP to 1997H, the ROM's Syntax error, for a bad MERGE option.
6869
GOSUB to 6BEDH to read the first record of the file into its buffer: Register Pair HL at the first byte.
686C
LD A,(HL) 7E
Load Register A with the first byte of the file at Register Pair HL.
686D
INC A 3C
INCrement Register A by 1: the Z FLAG when the first byte is FFH, a compressed program.
686E
If the Z FLAG is set (compressed), JUMP to 6C83H, the error Bad file mode: MERGE needs an ASCII file.
6871
GOSUB to 6BCDH to rewind the file to its first record.
6874
JUMP to 1A33H, the ROM's command level, which reads the ASCII program line by line into memory.

6877H - Direct Statement in a File

Link 41B2H, called after a line read from a file was tokenized. The shorthand and DI/DU are expanded (63D1H); a line with a number is a program line, kept. A direct statement from a file (no line number) is run at once by the ROM's dispatcher, unless there is still a current file, when it is Direct statement in file.

6877
GOSUB to 63D1H to expand the shorthand and DI/DU of the tokenized line: the C FLAG for a program line.
687A
RET C D8
If the C FLAG is set (a program line), RETurn: the line is kept in the program.
687B
POP AF F1
Restore Register Pair AF with the ROM's return address, which is not used.
687C
LD DE,(62FCH) ED 5B FC 62
Load Register Pair DE with the current file area from 62FCH-62FDH (0000H: none).
6880
LD A,D 7A
Load Register A with Register D, the high byte of the file area.
6881
OR E B3
OR Register A with Register E: the Z FLAG when there is no current file.
6882
If the NZ FLAG is set (a current file), JUMP to 6C9BH, the error Direct statement in file.
6885
GOSUB to 6C47H to wipe a program protected against listing before the direct statement runs.
6888
JUMP to 1D5AH, the ROM's dispatcher, to run the direct statement.

688BH - SAVE

Link 41A0H, the statement SAVE. The file is opened as area 0 for output; ,A saves the program as ASCII, else it is saved compressed. For a compressed save the program text (TXTTAB to VARTAB) is written as records headed by FFH and ended by three 00H; the file control block's sector count is set from the length. For an ASCII save the program is listed to the file through the output link (the ROM's LIST).

688B
XOR A AF
Set Register A to 00H by XORing it with itself, the run flag (SAVE does not run).
688C
LD D,02H 16 02
Load Register D with 02H, the mode of a file open for output.
688E
GOSUB to 6B04H to take the file specification and open it as area 0 for output: Register Pair HL at the text after it.
6891
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the file again.
6892
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
6893
If the Z FLAG is set (no ,A), JUMP to 689CH to save the program compressed.
6895
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before A, or the ROM shows a Syntax error.
6897
RST 08H => 41H CF 41
RST 08H: the next character of the text at Register Pair HL must be 41H, the letter A, or the ROM shows a Syntax error.
6899
JUMP to 2B2EH, the ROM's LIST, which lists the program to the current file (the output link writes it).
689C
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the end of the program text.
689F
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
68A3
SBC HL,DE ED 52
SUBtract Register Pair DE, the start, from Register Pair HL: Register Pair HL = the length of the program text.
68A5
LD C,L 4D
Load Register C with Register L, the low byte of the length.
68A6
LD B,H 44
Load Register B with Register H: Register Pair BC = the length of the program text.
68A7
INC BC 03
INCrement Register Pair BC by 1, for the FFH written before the text.
68A8
LD (IX+07H),C DD 71 07
Store Register C, the low byte of the length, into Index Register IX+07H, the count of the bytes in the current record.
68AB
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL = the start of the program.
68AC
GOSUB to 6C0AH to load Register Pair DE with the file's buffer pointer from Index Register IX+05H-06H.
68AF
LD A,FFH 3E FF
Load Register A with FFH, the byte that marks a compressed file.
68B1
LD (DE),A 12
Store Register A (FFH) at Register Pair DE in the buffer.
68B2
INC DE 13
INCrement Register Pair DE by 1, to the next byte of the buffer.
68B3
DEC BC 0B
DECrement Register Pair BC by 1, the count written (the FFH is counted in).
68B4
LDI ED A0
Copy one byte of the program from Register Pair HL to Register Pair DE by LDI, counting Register Pair BC down.
68B6
If the PO FLAG is set (the whole program is written), JUMP to 68C2H.
68B9
LD A,(IX+07H) DD 7E 07
Load Register A with the count of the record from Index Register IX+07H.
68BC
CP C B9
Compare Register A against Register C, the low byte of the count left: the Z FLAG at a record boundary.
68BD
If the Z FLAG is set (a record boundary), GOSUB to 6BFFH to write the record and start the next.
68C0
LOOP back to 68B4H for the next byte of the program.
68C2
GOSUB to 6BFFH to write the last record of the program.
68C5
LD A,(IX+07H) DD 7E 07
Load Register A with the count of the last record from Index Register IX+07H.
68C8
OR A B7
OR Register A against itself: the Z FLAG when the last record is full.
68C9
If the NZ FLAG is set (a part record), GOSUB to 6BE1H to write the part record.
68CC
LD A,(IX+0CH) DD 7E 0C
Load Register A with the bytes in the last sector from Index Register IX+0CH, the file control block's end of file byte.
68CF
LD (IX+0EH),A DD 77 0E
Store Register A into Index Register IX+0EH, the sector count's low byte of the file control block.
68D2
LD (IX+0FH),00H DD 36 0F 00
Store 00H into Index Register IX+0FH, the sector count's high byte.
68D6
JUMP to 6826H to close file area 0, the saved file.

68D9H - CLOSE

Link 4185H, the statement CLOSE. CLOSE alone closes every file (683AH for each). CLOSE #n closes those files: the file number is evaluated, its area closed, and more follow after a comma.

68D9
LD A,(62FAH) 3A FA 62
Load Register A with the number of files from 62FAH.
68DC
If the NZ FLAG is set (CLOSE #n follows), JUMP to 68E8H.
68DE
OR A B7
OR Register A against itself: the Z FLAG when there are no files.
68DF
RET Z C8
If the Z FLAG is set (no files at all), RETurn: nothing to close.
68E0
PUSH AF F5
Save Register Pair AF, the file number, to the top of the stack.
68E1
GOSUB to 683AH to close the file of that number if it is open.
68E4
POP AF F1
Restore Register Pair AF, the file number, from the top of the stack.
68E5
DEC A 3D
DECrement Register A by 1, to the next file number.
68E6
LOOP back to 68DEH for the next file number to close.
68E8
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
68E9
CP 23H FE 23
Compare Register A against 23H, the # before a file number.
68EB
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code, to pass over it.
68EE
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate the file number into Register A.
68F1
OR A B7
OR Register A against itself: the Z FLAG for file number 0.
68F2
If the Z FLAG is set (file 0), JUMP to 6C95H, the error Bad record number.
68F5
GOSUB to 683AH to close the file of that number.
68F8
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
68F9
CP 2CH FE 2C
Compare Register A against 2CH, the comma before another file number.
68FB
RET NZ C0
If the NZ FLAG is set (no comma), RETurn: CLOSE is done.
68FC
RST 10H D7
RST 10H: increment Register Pair HL past the comma and load Register A with the next character.
68FD
JUMP back to 68E8H for the next file number after the comma.

68FFH - Close All Files

Link 41BBH, called by the ROM's NEW and END. Every file is closed (68D9H with no #n) and Register A returns 00H.

68FF
PUSH DE D5
Save Register Pair DE to the top of the stack.
6900
PUSH BC C5
Save Register Pair BC to the top of the stack.
6901
XOR A AF
Set Register A to 00H by XORing it with itself, so that 68D9H closes every file.
6902
GOSUB to 68D9H to close every open file of the program.
6905
POP BC C1
Restore Register Pair BC from the top of the stack.
6906
POP DE D1
Restore Register Pair DE from the top of the stack.
6907
XOR A AF
Set Register A to 00H by XORing it with itself, for the ROM's NEW.
6908
RET C9
RETurn to the ROM's NEW or END with Register A = 00H.

6909H - FIELD

Link 417CH, the statement FIELD n,w AS v$,... Each width w names a part of the file's buffer: the string variable v$ is given a descriptor whose length is w and whose address is the next free place in the buffer. The widths must not run past the buffer (256 bytes), else Field overflow. The file must be open (Bad file mode when closed).

6909
GOSUB to 6582H to evaluate the file number: Index Register IX returns its area, Register A its mode byte.
690C
If the Z FLAG is set (the file is closed), JUMP to 6C83H, the error Bad file mode.
690F
SUB 03H D6 03
SUBtract 03H from Register A, the mode byte: 00H and the Z FLAG for a random file.
6911
If the NZ FLAG is set (not a random file), JUMP to 6C83H, the error Bad file mode.
6914
LD B,00H 06 00
Load Register B with 00H, the places of the buffer used so far.
6916
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
6917
CP 2CH FE 2C
Compare Register A against 2CH, the comma before a width.
6919
RET NZ C0
If the NZ FLAG is set (no more fields), RETurn.
691A
PUSH BC C5
Save Register Pair BC, the places used in Register B, to the top of the stack.
691B
GOSUB to 2B1BH, the ROM's evaluation of the width into Register A.
691E
PUSH AF F5
Save Register Pair AF, the width in Register A, to the top of the stack.
691F
RST 08H => 41H CF 41
RST 08H: the next character of the text at Register Pair HL must be 41H, the letter A of AS, or the ROM shows a Syntax error.
6921
RST 08H => 53H CF 53
RST 08H: the next character of the text at Register Pair HL must be 53H, the letter S of AS, or the ROM shows a Syntax error.
6923
GOSUB to 260DH, the ROM's variable search, for v$ at Register Pair HL: Register Pair DE returns its descriptor.
6926
GOSUB to 0AF4H, the ROM's test that v$ is a string, else Type mismatch.
6929
POP AF F1
Restore Register Pair AF, the width in Register A, from the top of the stack.
692A
POP BC C1
Restore Register Pair BC, the places used in Register B, from the top of the stack.
692B
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
692C
LD L,A 6F
Load Register L with Register A, the width of this field.
692D
ADD A,B 80
ADD Register B, the places used, to Register A: the places used after this field.
692E
LD H,A 67
Load Register H with Register A: Register Pair HL holds the width (Register L) and the new total (Register H).
692F
If the NC FLAG is set (the total did not pass 255), JUMP to 6934H.
6931
If the NZ FLAG is set (the total is above 255), JUMP to 6C98H, the error Field overflow.
6934
LD A,(IX+0BH) DD 7E 0B
Load Register A with the record length from Index Register IX+0BH, the file control block's logical record length.
6937
CP H BC
Compare Register A against Register H, the places used after this field: the NC FLAG when the field fits.
6938
If the NC FLAG is set (within the record), JUMP to 693EH.
693A
OR A B7
OR Register A against itself: the NZ FLAG when the record length is not 256 (00H).
693B
If the NZ FLAG is set (the field runs past the record), JUMP to 6C98H, the error Field overflow.
693E
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
6940
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the area, the width and total saved.
6941
LD C,B 48
Load Register C with Register B, the places used before this field.
6942
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
6944
ADD HL,BC 09
ADD Register Pair BC, the places used, to Register Pair HL: the place in the area past its header.
6945
LD C,22H 0E 22
Load Register C with 22H, the offset of the file's buffer in its area.
6947
ADD HL,BC 09
ADD Register Pair BC (22H) to Register Pair HL: the field's place in the buffer.
6948
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the field's place in the buffer, Register Pair HL = v$'s descriptor.
6949
POP BC C1
Restore Register Pair BC, the width (Register C) and the total (Register B), from the top of the stack.
694A
LD (HL),C 71
Store Register C, the width, at Register Pair HL, the length byte of v$'s descriptor.
694B
INC HL 23
INCrement Register Pair HL by 1, to the address of v$ in the descriptor.
694C
LD (HL),E 73
Store Register E, the low byte of the field's place, at Register Pair HL.
694D
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the address.
694E
LD (HL),D 72
Store Register D, the high byte of the field's place, at Register Pair HL.
694F
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6950
INC B 04
INCrement Register B by 1, to test the total.
6951
DEC B 05
DECrement Register B by 1: the total of the places used.
6952
If the NZ FLAG is set (the buffer is not full), LOOP back to 6916H for the next field.
6954
INC C 0C
INCrement Register C by 1, to test the width.
6955
DEC C 0D
DECrement Register C by 1: the width of the last field.
6956
RET NZ C0
If the NZ FLAG is set (the last field had a width), RETurn.
6957
JUMP back to 6916H for the next field of the FIELD statement.

6959H - LSET and RSET

Links 4197H (695AH, LSET) and 419AH (6959H, RSET). The string value is placed into the buffer field named by the variable: LSET at its left, RSET at its right, the rest filled with spaces, cut to the field's width. A value still in the program text is copied into the string space first. The C FLAG tells RSET (6959H sets it clear through OR 37H, then 695AH, LSET, sets it with SCF) from LSET.

6959
OR 37H F6 37
RSET: OR Register A with 37H, so Register A is not 00H and the C FLAG is clear, the mark of RSET. LSET enters at 695AH, the 37H operand, which reads as SCF and sets the C FLAG, the mark of LSET.
695B
PUSH AF F5
Save Register Pair AF, the C FLAG of LSET or RSET, to the top of the stack.
695C
GOSUB to 260DH, the ROM's variable search, for the field variable at Register Pair HL: Register Pair DE returns its descriptor.
695F
GOSUB to 0AF4H, the ROM's test that the variable is a string, else Type mismatch.
6962
PUSH DE D5
Save Register Pair DE, the field's descriptor, to the top of the stack.
6963
RST 08H => D5H CF D5
RST 08H: the next character of the text at Register Pair HL must be D5H, the token of =, or the ROM shows a Syntax error.
6965
GOSUB to 2337H, the ROM's expression evaluator, for the string at Register Pair HL.
6968
POP BC C1
Restore Register Pair BC, the field's descriptor, from the top of the stack.
6969
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the C FLAG saved, the text pointer saved.
696A
PUSH HL E5
Save Register Pair HL, the LSET or RSET flag, to the top of the stack.
696B
PUSH BC C5
Save Register Pair BC, the field's descriptor, to the top of the stack.
696C
GOSUB to 29D7H, the ROM's routine that frees the string's temporary: Register Pair HL returns its descriptor.
696F
LD B,(HL) 46
Load Register B with the length of the string at Register Pair HL.
6970
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the field's descriptor.
6971
LD A,(HL) 7E
Load Register A with the length of the field at Register Pair HL.
6972
LD C,A 4F
Load Register C with Register A, the length of the field.
6973
PUSH BC C5
Save Register Pair BC, the string length (Register B) and the field length (Register C), to the top of the stack.
6974
PUSH HL E5
Save Register Pair HL, the field's descriptor, to the top of the stack.
6975
PUSH AF F5
Save Register Pair AF, the field length in Register A, to the top of the stack.
6976
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
6977
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
6978
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
6979
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the string.
697A
OR A B7
OR Register A against itself: the Z FLAG for an empty string.
697B
If the Z FLAG is set (empty), JUMP to 69D2H to fill the field with spaces.
697D
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
6980
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the program's start.
6981
If the NC FLAG is set (below the program), JUMP to 69B0H: the string is in the string space already.
6983
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with VARTAB from 40F9H-40FAH, the end of the program text.
6986
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the string's address: the C FLAG when the string is above the program text.
6987
If the C FLAG is set (above the program text), JUMP to 69B0H: the string is not in the program.
6989
LD E,C 59
Load Register E with Register C, the field length as the room to allocate.
698A
LD D,00H 16 00
Load Register D with 00H, the high byte in Register Pair DE.
698C
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the top of the string space from 40A0H-40A1H.
698F
ADD HL,DE 19
ADD Register Pair DE, the room, to Register Pair HL.
6990
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the top of the string space plus the room.
6991
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with FRETOP from 40D6H-40D7H, the top of the free string area.
6994
GOSUB to 1C90H, the ROM's RST 18H compare of Register Pair HL and Register Pair DE: the C FLAG when the string space is full.
6997
If the C FLAG is set (the string space is full), JUMP to 69E5H to make room.
6999
POP AF F1
Restore Register Pair AF, the field length in Register A, from the top of the stack.
699A
LD A,C 79
Load Register A with Register C, the field length.
699B
GOSUB to 28BFH, the ROM's routine that allocates Register A bytes of string space: Register Pair DE the space.
699E
POP HL E1
Restore Register Pair HL, the field's descriptor, from the top of the stack.
699F
POP BC C1
Restore Register Pair BC, the string length (Register B) and the field length (Register C), from the top of the stack.
69A0
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the value's string descriptor, the field's descriptor saved.
69A1
PUSH DE D5
Save Register Pair DE, the allocated space, to the top of the stack.
69A2
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
69A3
GOSUB to 29D7H, the ROM's routine that frees the temporary: Register Pair HL returns the value's descriptor.
69A6
POP BC C1
Restore Register Pair BC, the lengths, from the top of the stack.
69A7
POP DE D1
Restore Register Pair DE, the allocated space, from the top of the stack.
69A8
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the field's descriptor.
69A9
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
69AA
PUSH HL E5
Save Register Pair HL, the field's descriptor, to the top of the stack.
69AB
INC HL 23
INCrement Register Pair HL by 1, to the address of the value's string in the descriptor.
69AC
LD (HL),E 73
Store Register E, the low byte of the allocated space, at Register Pair HL (not the field).
69AD
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
69AE
LD (HL),D 72
Store Register D, the high byte of the allocated space, at Register Pair HL.
69AF
PUSH AF F5
Save Register Pair AF, the field length, to the top of the stack.
69B0
POP AF F1
Restore Register Pair AF, the field length in Register A, from the top of the stack.
69B1
POP HL E1
Restore Register Pair HL, the field's descriptor, from the top of the stack.
69B2
INC HL 23
INCrement Register Pair HL by 1, to the address of the field in the buffer.
69B3
LD E,(HL) 5E
Load Register E with the low byte of the field's address at Register Pair HL.
69B4
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the field's address.
69B5
LD D,(HL) 56
Load Register D with the high byte of the field's address at Register Pair HL: Register Pair DE = the field in the buffer.
69B6
POP BC C1
Restore Register Pair BC, the string length (Register B) and the field length (Register C), from the top of the stack.
69B7
POP HL E1
Restore Register Pair HL, the value's string descriptor, from the top of the stack.
69B8
INC HL 23
INCrement Register Pair HL by 1, to the address of the value's string.
69B9
LD A,(HL) 7E
Load Register A with the low byte of the value's address at Register Pair HL.
69BA
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
69BB
LD H,(HL) 66
Load Register H with the high byte of the value's address at Register Pair HL.
69BC
LD L,A 6F
Load Register L with Register A: Register Pair HL = the characters of the value.
69BD
LD A,C 79
Load Register A with Register C, the field length.
69BE
CP B B8
Compare Register A against Register B, the string length: the NC FLAG when the field is as long as the string.
69BF
If the NC FLAG is set (the field holds the string), JUMP to 69C2H.
69C1
LD B,A 47
Load Register B with Register A, the field length: the string is cut to the field.
69C2
SUB B 90
SUBtract Register B, the characters to copy, from Register A, the field length: the spaces to fill.
69C3
LD C,A 4F
Load Register C with Register A, the spaces to fill.
69C4
POP AF F1
Restore Register Pair AF, the LSET or RSET flag, from the top of the stack.
69C5
If the NC FLAG is set (RSET), GOSUB to 69DCH to put the spaces at the left first.
69C8
INC B 04
INCrement Register B by 1, to test the count.
69C9
DEC B 05
DECrement Register B by 1: the Z FLAG when the string has no characters to copy.
69CA
If the Z FLAG is set (no characters), JUMP to 69D7H to fill the rest with spaces.
69CC
LD A,(HL) 7E
Load Register A with the character of the value at Register Pair HL.
69CD
LD (DE),A 12
Store Register A, the character, at Register Pair DE in the field.
69CE
INC HL 23
INCrement Register Pair HL by 1, to the next character of the value.
69CF
INC DE 13
INCrement Register Pair DE by 1, to the next place of the field.
69D0
LOOP back to 69C9H for the next character of the value.
69D2
POP BC C1
Restore Register Pair BC from the top of the stack: the saved lengths are dropped.
69D3
POP BC C1
Restore Register Pair BC from the top of the stack: the descriptor is dropped.
69D4
POP BC C1
Restore Register Pair BC from the top of the stack: the value's descriptor is dropped.
69D5
POP BC C1
Restore Register Pair BC from the top of the stack: the field length is dropped.
69D6
POP BC C1
Restore Register Pair BC, the field length (Register C), from the top of the stack for the fill.
69D7
If the C FLAG is set (LSET), GOSUB to 69DCH to put the spaces at the right.
69DA
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
69DB
RET C9
RETurn to the statement loop of the ROM with Register Pair HL at the text.
69DC
LD A,20H 3E 20
Load Register A with 20H, a space to fill the field with.
69DE
INC C 0C
INCrement Register C by 1, to test the count.
69DF
DEC C 0D
DECrement Register C by 1: the Z FLAG when no spaces are left.
69E0
RET Z C8
If the Z FLAG is set (no spaces left), RETurn to the caller.
69E1
LD (DE),A 12
Store Register A (20H), a space, at Register Pair DE in the field.
69E2
INC DE 13
INCrement Register Pair DE by 1, to the next place of the field.
69E3
LOOP back to 69DFH for the next space of the fill.
69E5
POP AF F1
Restore Register Pair AF from the top of the stack: the field length is dropped.
69E6
POP HL E1
Restore Register Pair HL, the field's descriptor, from the top of the stack.
69E7
POP BC C1
Restore Register Pair BC, the lengths, from the top of the stack.
69E8
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the value's descriptor.
69E9
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the value's descriptor.
69EA
If the NZ FLAG is set (the string space holds the value), JUMP to 69F5H.
69EC
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
69ED
LD A,B 78
Load Register A with Register B, the string length.
69EE
GOSUB to 2857H, the ROM's STRINI, to make room for the value with its descriptor at 40D3H.
69F1
GOSUB to 2884H, the ROM's PUTNEW, which makes the new string the current temporary.
69F4
POP BC C1
Restore Register Pair BC, the lengths, from the top of the stack.
69F5
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the field's descriptor, the value saved.
69F6
PUSH BC C5
Save Register Pair BC, the lengths, to the top of the stack.
69F7
PUSH HL E5
Save Register Pair HL, the field's descriptor, to the top of the stack.
69F8
PUSH AF F5
Save Register Pair AF, the flags, to the top of the stack.
69F9
JUMP back to 6999H to allocate the field after the string space has been tidied.

69FBH - EOF

Link 4161H, the function EOF(n): true (-1) at the end of the file, false (0) before it. The file must be open and not for output (Bad file mode). CKEOF@ (4457H) gives the answer.

69FB
GOSUB to 658CH to evaluate the file number: Index Register IX returns its area, the Z FLAG when it is closed.
69FE
If the Z FLAG is set (the file is closed), JUMP to 6C83H, the error Bad file mode.
6A01
CP 02H FE 02
Compare Register A, the mode byte, against 02H: the Z FLAG for a file open for output.
6A03
If the Z FLAG is set (output), JUMP to 6C83H, the error Bad file mode.
6A06
GOSUB to 4457H, CKEOF@, to test the file for its end: the Z FLAG before the end, the NZ FLAG at or past it.
6A09
If the Z FLAG is set (not at the end), JUMP to 6A0DH with Register A = 00H, false.
6A0B
LD A,FFH 3E FF
Load Register A with FFH, the value true, at the end of the file.
6A0D
JUMP to 098DH, the ROM's routine that makes the signed byte in Register A the integer result.

6A10H - LOC

Link 4164H, the function LOC(n): the number of the record last read or written. The file's position (file control block) gives it (6C11H).

6A10
GOSUB to 658CH to evaluate the file number: Index Register IX returns its area, the Z FLAG when it is closed.
6A13
If the Z FLAG is set (the file is closed), JUMP to 6C83H, the error Bad file mode.
6A16
GOSUB to 6C11H to work out the record last accessed into Register Pair HL from the file control block.
6A19
DEC HL 2B
DECrement Register Pair HL by 1, so that the record is counted as LOC gives it.
6A1A
JUMP to 0A9AH, the ROM's routine that makes the integer in Register Pair HL the result.

6A1DH - LOF

Link 4167H, the function LOF(n): the number of records in the file. The file control block's sector count gives it (6C1FH).

6A1D
GOSUB to 658CH to evaluate the file number: Index Register IX returns its area, the Z FLAG when it is closed.
6A20
If the Z FLAG is set (the file is closed), JUMP to 6C83H, the error Bad file mode.
6A23
GOSUB to 6C1FH to work out the number of records into Register Pair HL from the file control block.
6A26
JUMP to 0A9AH, the ROM's routine that makes the integer in Register Pair HL the result.

6A29H - GET and PUT

Links 417FH (6A2AH, GET) and 4182H (6A29H, PUT). The record is read into the buffer (GET) or the buffer is written (PUT); with an optional record number the file is positioned there first (POSN@). Only a random file (mode 03H) is allowed. PUT of a record past the end fills the new records with 00H.

6A29
LD A,AFH 3E AF
PUT: load Register A with AFH, the PUT flag. GET enters at 6A2AH, the AFH operand, which reads as XOR A and sets Register A to 00H, the GET flag.
6A2B
LD (6A78H),A 32 78 6A
Store Register A (AFH for PUT, 00H for GET) to 6A78H, the operand of LD A,00H at 6A77H.
6A2E
GOSUB to 6582H to evaluate the file number: Index Register IX returns its area, Register A its mode byte.
6A31
CP 03H FE 03
Compare Register A against 03H, the mode of a random file.
6A33
If the NZ FLAG is set (not random), JUMP to 6C83H, the error Bad file mode.
6A36
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
6A37
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
6A38
GOSUB to 6C11H to work out the file's next record number into Register Pair HL.
6A3B
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the next record number.
6A3C
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6A3D
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
6A3E
CP 2CH FE 2C
Compare Register A against 2CH, the comma before a record number.
6A40
If the Z FLAG is set (a record number follows), GOSUB to 1E45H, the ROM's scan of the record number at Register Pair HL into Register Pair DE.
6A43
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character after the record number again.
6A44
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
6A45
If the NZ FLAG is set (more text), JUMP to 1997H, the ROM's Syntax error.
6A48
LD A,E 7B
Load Register A with Register E, the low byte of the record number.
6A49
OR D B2
OR Register A with Register D: the Z FLAG for record 0.
6A4A
If the Z FLAG is set (record 0), JUMP to 6C95H, the error Bad record number.
6A4D
LD B,D 42
Load Register B with Register D, the high byte of the record number.
6A4E
LD C,E 4B
Load Register C with Register E: Register Pair BC = the record number.
6A4F
DEC BC 0B
DECrement Register Pair BC by 1, to the record number POSN@ counts from 0.
6A50
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
6A51
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
6A52
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, the position POSN@ gives a blocked random file.
6A55
ADD HL,DE 19
ADD Register Pair DE, the file control block, to Register Pair HL (not used further here).
6A56
GOSUB to 4442H, POSN@, to position the file at record Register Pair BC: the error code in Register A.
6A59
If the Z FLAG is set (positioned within the file), JUMP to 6A77H.
6A5B
CP 1CH FE 1C
Compare Register A against 1CH, the error Attempted to read past eof.
6A5D
If the Z FLAG is set (past the end), JUMP to 6A64H.
6A5F
CP 1DH FE 1D
Compare Register A against 1DH, the error Attempted to read outside of file limits.
6A61
If the NZ FLAG is set (another error), JUMP to 6CA3H to post it.
6A64
LD A,(6A78H) 3A 78 6A
Load Register A with the GET or PUT flag from 6A78H: 00H for GET.
6A67
OR A B7
OR Register A against itself: the Z FLAG for GET.
6A68
If the NZ FLAG is set (PUT), JUMP to 6A84H to write the record, which extends the file.
6A6A
INC BC 03
INCrement Register Pair BC by 1, back to the record number asked for.
6A6B
GOSUB to 4442H, POSN@, to position the file at record Register Pair BC again.
6A6E
XOR A AF
Set Register A to 00H by XORing it with itself, the byte that fills the buffer.
6A6F
LD (HL),00H 36 00
Store Register A (00H) at Register Pair HL in the buffer.
6A71
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the buffer.
6A72
DEC A 3D
DECrement Register A by 1 (to FFH and back round): the Z FLAG after 256 bytes.
6A73
If the NZ FLAG is set (more of the buffer), LOOP back to 6A6FH.
6A75
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6A76
RET C9
RETurn to the statement loop of the ROM with the buffer cleared (GET past the end).
6A77
LD A,00H 3E 00
Load Register A with the GET or PUT flag, the operand 6A78H (00H in the file).
6A79
OR A B7
OR Register A against itself: the Z FLAG for GET.
6A7A
If the NZ FLAG is set (PUT), JUMP to 6A84H to write the record.
6A7C
GOSUB to 4436H, READ@, to read the record into the file's buffer.
6A7F
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6A82
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6A83
RET C9
RETurn to the statement loop of the ROM with the record read.
6A84
GOSUB to 4439H, WRITE@, to write the file's buffer as the record.
6A87
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6A8A
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6A8B
RET C9
RETurn to the statement loop of the ROM with the record written.

6A8CH - Take a File Field

Evaluates the next string at Register Pair HL as a file specification (empty: Bad file name; over 24 characters: Bad file name) and copies it into the file control block at Register Pair DE with 03H after it.

6A8C
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
6A8D
GOSUB to 2337H, the ROM's expression evaluator, for the file specification at Register Pair HL.
6A90
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
6A91
GOSUB to 29D7H, the ROM's routine that frees the string's temporary: Register Pair HL returns its descriptor.
6A94
LD C,(HL) 4E
Load Register C with the length of the file specification at Register Pair HL.
6A95
INC HL 23
INCrement Register Pair HL by 1, to the address of the string in the descriptor.
6A96
INC C 0C
INCrement Register C by 1, to test the length.
6A97
DEC C 0D
DECrement Register C by 1: the Z FLAG for an empty file specification.
6A98
If the Z FLAG is set (empty), JUMP to 6C92H, the error Bad file name.
6A9B
LD A,18H 3E 18
Load Register A with 18H, the longest file specification: 24 characters.
6A9D
CP C B9
Compare Register A against Register C, the length: the C FLAG when it is above 24.
6A9E
If the C FLAG is set (too long), JUMP to 6C92H, the error Bad file name.
6AA1
LD E,(HL) 5E
Load Register E with the low byte of the string's address at Register Pair HL.
6AA2
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the string's address.
6AA3
LD D,(HL) 56
Load Register D with the high byte of the string's address at Register Pair HL: Register Pair DE = the file specification.
6AA4
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6AA5
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the file control block, the text pointer saved.
6AA6
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE = the file control block, Register Pair HL = the file specification.
6AA7
GOSUB to 6AACH to copy the file specification at Register Pair HL into the file control block at Register Pair DE.
6AAA
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6AAB
RET C9
RETurn with the file specification in the file control block.

6AACH - Copy a File Specification

Copies the file specification at Register Pair HL (length in Register C) into the file control block at Register Pair DE, with 03H after it, so CMNDI@ and the file routines can read it. A device name (@ first) is Bad file name.

6AAC
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
6AAD
LD A,(HL) 7E
Load Register A with the first character of the file specification at Register Pair HL.
6AAE
CP 40H FE 40
Compare Register A against 40H, the character @ of a device name.
6AB0
If the Z FLAG is set (a device name), JUMP to 6C92H, the error Bad file name.
6AB3
LD B,00H 06 00
Load Register B with 00H, the high byte of the length in Register Pair BC.
6AB5
LDIR ED B0
Copy the file specification from Register Pair HL to Register Pair DE by LDIR, counted by Register Pair BC.
6AB7
LD A,03H 3E 03
Load Register A with 03H, the byte that ends the file specification for CMNDI@.
6AB9
LD (DE),A 12
Store Register A (03H) at Register Pair DE after the file specification.
6ABA
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
6ABB
RET C9
RETurn with the file specification copied into the block.

6ABCH - OPEN

Link 4179H, the statement OPEN "mode",n,"file"[,reclen]. The mode letter is I (input, 01H), O (output, 02H), E (append/extend, 04H), R or D (random, 03H); any other is Bad file mode. The file is opened as area n: input by OPEN@, output and random by INIT@ (open or create); E then positions at the end (PEOF@). A random file may give a record length. A file already open in area n is File already open.

6ABC
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's reset of the output, where OPEN ends.
6ABF
PUSH BC C5
Save Register Pair BC (2169H) to the top of the stack, the return address of OPEN.
6AC0
GOSUB to 2337H, the ROM's expression evaluator, for the mode string at Register Pair HL.
6AC3
PUSH HL E5
Save Register Pair HL, the text pointer, to the top of the stack.
6AC4
GOSUB to 29D7H, the ROM's routine that frees the string's temporary: Register Pair HL returns the mode's descriptor.
6AC7
LD A,(HL) 7E
Load Register A with the length of the mode string at Register Pair HL.
6AC8
INC HL 23
INCrement Register Pair HL by 1, to the address of the mode string in the descriptor.
6AC9
OR A B7
OR Register A against itself: the Z FLAG for an empty mode string.
6ACA
If the Z FLAG is set (empty), JUMP to 6C83H, the error Bad file mode.
6ACD
LD C,(HL) 4E
Load Register C with the low byte of the mode's address at Register Pair HL.
6ACE
INC HL 23
INCrement Register Pair HL by 1, to the high byte of the mode's address.
6ACF
LD B,(HL) 46
Load Register B with the high byte of the mode's address at Register Pair HL: Register Pair BC = the mode string.
6AD0
LD A,(BC) 0A
Load Register A with the first character of the mode string at Register Pair BC.
6AD1
RES 5,A CB AF
RESET bit 5 of Register A, which makes a lower case letter upper case.
6AD3
LD D,04H 16 04
Load Register D with 04H, the mode code of E (append).
6AD5
CP 45H FE 45
Compare Register A against 45H, the letter E.
6AD7
If the Z FLAG is set (E), JUMP to 6AF0H with the mode code 04H.
6AD9
LD D,02H 16 02
Load Register D with 02H, the mode code of O (output).
6ADB
CP 4FH FE 4F
Compare Register A against 4FH, the letter O.
6ADD
If the Z FLAG is set (O), JUMP to 6AF0H with the mode code 02H.
6ADF
LD D,01H 16 01
Load Register D with 01H, the mode code of I (input).
6AE1
CP 49H FE 49
Compare Register A against 49H, the letter I.
6AE3
If the Z FLAG is set (I), JUMP to 6AF0H with the mode code 01H.
6AE5
LD D,03H 16 03
Load Register D with 03H, the mode code of R (random).
6AE7
CP 52H FE 52
Compare Register A against 52H, the letter R.
6AE9
If the Z FLAG is set (R), JUMP to 6AF0H with the mode code 03H.
6AEB
CP 44H FE 44
Compare Register A against 44H, the letter D, also a random file.
6AED
If the NZ FLAG is set (no mode letter matched), JUMP to 6C83H, the error Bad file mode.
6AF0
POP HL E1
Restore Register Pair HL, the text pointer, from the top of the stack.
6AF1
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the mode, or the ROM shows a Syntax error.
6AF3
PUSH DE D5
Save Register Pair DE, the mode code in Register D, to the top of the stack.
6AF4
CP 23H FE 23
Compare Register A against 23H, the # before the file number.
6AF6
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code, to pass over it.
6AF9
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate the file number into Register E.
6AFC
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma after the file number, or the ROM shows a Syntax error.
6AFE
LD A,E 7B
Load Register A with Register E, the file number.
6AFF
OR A B7
OR Register A against itself: the Z FLAG for file number 0.
6B00
If the Z FLAG is set (file 0), JUMP to 6C95H, the error Bad record number.
6B03
POP DE D1
Restore Register Pair DE, the mode code in Register D, from the top of the stack.
6B04
PUSH DE D5
Save Register Pair DE, the mode code in Register D, to the top of the stack.
6B05
GOSUB to 6593H for the file number in Register A: Index Register IX the area, Register Pair DE its file control block, the Z FLAG when it is closed.
6B08
If the NZ FLAG is set (already open), JUMP to 6C8FH, the error File already open.
6B0B
GOSUB to 6A8CH to take the file specification into the file control block at Register Pair DE.
6B0E
POP AF F1
Restore Register Pair AF, the mode code in Register A, from the top of the stack.
6B0F
PUSH AF F5
Save Register Pair AF, the mode code in Register A, to the top of the stack.
6B10
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
6B11
LD B,00H 06 00
Load Register B with 00H, the record length when none is given.
6B13
CP 03H FE 03
Compare Register A against 03H, the mode of a random file.
6B15
If the NZ FLAG is set (not random), JUMP to 6B21H: no record length is taken.
6B17
DEC HL 2B
DECrement Register Pair HL by 1, so that the RST 10H below reads the character again.
6B18
RST 10H D7
RST 10H: increment Register Pair HL and load Register A with the next character: the Z FLAG at the end of the statement.
6B19
If the Z FLAG is set (no record length), JUMP to 6B21H.
6B1B
RST 08H => 2CH CF 2C
RST 08H: the next character of the text at Register Pair HL must be 2CH, the comma before the record length, or the ROM shows a Syntax error.
6B1D
GOSUB to 2B1CH, the ROM's GETBYT, to evaluate the record length into Register E.
6B20
LD B,E 43
Load Register B with Register E, the record length.
6B21
LD (40DFH),HL 22 DF 40
Store Register Pair HL into 40DFH-40E0H, the ROM's text pointer, kept over the open.
6B24
LD (62FCH),IX DD 22 FC 62
Store Index Register IX, the file's area, into 62FCH-62FDH: the current file.
6B28
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
6B29
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, the offset past the file control block to its buffer.
6B2C
ADD HL,DE 19
ADD Register Pair DE, the file control block, to Register Pair HL (the record length is not written to the block here).
6B2D
INC B 04
INCrement Register B by 1, to test the record length.
6B2E
DEC B 05
DECrement Register B by 1: the Z FLAG when no record length was given.
6B2F
If the Z FLAG is set (no record length), JUMP to 6B32H.
6B31
INC H 24
INCrement Register H by 1 (a side effect of the length test; the result is not stored).
6B32
POP AF F1
Restore Register Pair AF, the mode code in Register A, from the top of the stack.
6B33
LD C,A 4F
Load Register C with Register A, the mode code, to become the area's mode byte.
6B34
CP 01H FE 01
Compare Register A against 01H, the mode of input.
6B36
If the NZ FLAG is set (not input), JUMP to 6B55H.
6B38
GOSUB to 4424H, OPEN@, to open the existing file at Register Pair DE for input.
6B3B
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6B3E
LD A,(62F7H) 3A F7 62
Load Register A with the run flag from 62F7H: not 00H when RUN opened the program file.
6B41
OR A B7
OR Register A against itself: the Z FLAG for an OPEN statement.
6B42
If the Z FLAG is set (an OPEN statement), JUMP to 6B6FH.
6B44
INC DE 13
INCrement Register Pair DE by 1, to the access level byte of the file control block.
6B45
LD A,(DE) 1A
Load Register A with the access level at Register Pair DE.
6B46
AND 07H E6 07
AND Register A with 07H, the protection level in the low three bits.
6B48
CP 06H FE 06
Compare Register A against 06H: the C FLAG for a level below 6.
6B4A
If the C FLAG is set (below execute only), JUMP to 6B6FH.
6B4C
LD (62FBH),A 32 FB 62
Store Register A to 62FBH, the protection level 6 or 7 of a program that may not be listed.
6B4F
LD A,(DE) 1A
Load Register A with the access level at Register Pair DE.
6B50
AND F8H E6 F8
AND Register A with F8H, to clear the protection level in the low three bits.
6B52
LD (DE),A 12
Store Register A back at Register Pair DE, the access level without its protection bits.
6B53
JUMP to 6B6FH to set the area's mode byte for the input file.
6B55
CP 03H FE 03
Compare Register A against 03H, the mode of a random file.
6B57
If the NZ FLAG is set (output or append), JUMP to 6B61H.
6B59
GOSUB to 4420H, INIT@, to open the random file at Register Pair DE, creating it when it does not exist.
6B5C
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6B5F
JUMP to 6B6FH to set the area's mode byte for the random file.
6B61
GOSUB to 4420H, INIT@, to open the file at Register Pair DE for output, creating it when it does not exist.
6B64
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6B67
LD A,C 79
Load Register A with Register C, the mode code: 04H for append.
6B68
LD C,02H 0E 02
Load Register C with 02H, the area's mode byte for an output file.
6B6A
CP 04H FE 04
Compare Register A against 04H, the mode of append.
6B6C
If the Z FLAG is set (append), GOSUB to 4448H, PEOF@, to position the file at its end.
6B6F
LD (IX+00H),C DD 71 00
Store Register C, the area's mode byte (01H input, 02H output, 03H random), into Index Register IX+00H.
6B72
LD (IX+01H),00H DD 36 01 00
Store 00H into Index Register IX+01H, the area's column byte.
6B76
LD HL,(40DFH) 2A DF 40
Load Register Pair HL with the ROM's text pointer from 40DFH-40E0H, kept over the open.
6B79
RET C9
RETurn to the ROM's reset of the output at 2169H.

6B7AH - KILL

Link 4191H, the statement KILL "file": the file is opened as area 0, then deleted by KILL@, and the area is marked closed.

6B7A
XOR A AF
Set Register A to 00H by XORing it with itself, the number of file area 0.
6B7B
GOSUB to 6593H for file area 0: Index Register IX the area, Register Pair DE its file control block.
6B7E
GOSUB to 6A8CH to take the file specification into the file control block at Register Pair DE.
6B81
GOSUB to 4424H, OPEN@, to open the file at Register Pair DE so that it can be deleted.
6B84
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6B87
GOSUB to 442CH, KILL@, to delete the file at Register Pair DE.
6B8A
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6B8D
LD (IX+00H),00H DD 36 00 00
Store 00H into Index Register IX+00H, the area's mode byte: closed.
6B91
RET C9
RETurn with the file deleted and the area closed.

6B92H - Read a Byte from the File

Reads the next byte of the file of Index Register IX into Register A through the ROM's GET@ (0013H): the Z FLAG for a byte, the C FLAG at the end of the file (error 1CH), any other error posted.

6B92
PUSH DE D5
Save Register Pair DE to the top of the stack.
6B93
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
6B95
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
6B96
INC DE 13
INCrement Register Pair DE by 1, past the mode byte of the area.
6B97
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
6B98
GOSUB to 0013H, the ROM's GET@, which reads a byte of the file at Register Pair DE into Register A: the Z FLAG for a byte.
6B9B
POP DE D1
Restore Register Pair DE from the top of the stack.
6B9C
RET Z C8
If the Z FLAG is set (a byte was read), RETurn with the byte in Register A.
6B9D
CP 1CH FE 1C
Compare Register A against 1CH, the error Attempted to read past eof.
6B9F
If the NZ FLAG is set (another error), JUMP to 6CA3H to post it.
6BA2
SCF 37
Set the C FLAG, the mark of the end of the file.
6BA3
RET C9
RETurn with the C FLAG set at the end of the file.

6BA4H - Write a Byte to the File

Writes the byte in Register A to the file of Index Register IX through the ROM's PUT@ (001BH). The column (Index Register IX+01H) counts the characters on the line: it is cleared by a carriage return and otherwise increased so that it stays below 256.

6BA4
PUSH DE D5
Save Register Pair DE to the top of the stack.
6BA5
LD E,(IX+00H) DD 5E 00
Load Register E with the mode byte of the area from Index Register IX+00H.
6BA8
DEC E 1D
DECrement Register E by 1: the Z FLAG when the mode is 01H, a file open for input.
6BA9
If the Z FLAG is set (an input file), JUMP to 6BCBH: nothing is written.
6BAB
LD E,(IX+01H) DD 5E 01
Load Register E with the column from Index Register IX+01H, the characters on the line.
6BAE
LD (IX+01H),00H DD 36 01 00
Store 00H into Index Register IX+01H, the column, cleared before it is set again.
6BB2
CP 0DH FE 0D
Compare Register A against 0DH, the carriage return.
6BB4
If the Z FLAG is set (a carriage return), JUMP to 6BC0H with the column 00H.
6BB6
PUSH AF F5
Save Register Pair AF, the byte, to the top of the stack.
6BB7
ADD A,E0H C6 E0
ADD E0H to Register A: the C FLAG when the byte is 20H or more, a character on the line.
6BB9
LD A,E 7B
Load Register A with Register E, the old column.
6BBA
ADC A,00H CE 00
ADD 00H to Register A with the carry: the column plus 1 for a character, or unchanged.
6BBC
LD (IX+01H),A DD 77 01
Store Register A into Index Register IX+01H, the new column (it stays below 256).
6BBF
POP AF F1
Restore Register Pair AF, the byte, from the top of the stack.
6BC0
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
6BC2
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
6BC3
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
6BC4
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
6BC5
GOSUB to 001BH, the ROM's PUT@, which writes the byte in Register A to the file at Register Pair DE.
6BC8
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6BCB
POP DE D1
Restore Register Pair DE from the top of the stack.
6BCC
RET C9
RETurn with the byte written to the file of Index Register IX.

6BCDH - Rewind the File

Rewinds the file of Index Register IX to its first record through REW@ (443FH).

6BCD
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
6BCF
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
6BD0
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
6BD1
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
6BD2
GOSUB to 443FH, REW@, to rewind the file at Register Pair DE.
6BD5
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6BD8
RET C9
RETurn with the file of Index Register IX rewound.

6BD9H - Back Up a Record

Decrements the record count of the write (Index Register IX+07H) and, when it reaches zero, backs the file up one record through BKSP@ (4445H): used while reading the items of INPUT # from a file.

6BD9
LD A,(IX+07H) DD 7E 07
Load Register A with the record count from Index Register IX+07H.
6BDC
DEC (IX+07H) DD 35 07
DECrement the record count at Index Register IX+07H.
6BDF
OR A B7
OR Register A against itself: the Z FLAG when the count was 1, now 0.
6BE0
RET NZ C0
If the NZ FLAG is set (the count is not yet 0), RETurn.
6BE1
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
6BE3
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
6BE4
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
6BE5
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
6BE6
GOSUB to 4445H, BKSP@, to back the file up one record.
6BE9
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6BEC
RET C9
RETurn with the file of Index Register IX backed up one record.

6BEDH - Read a Record

Reads the next record (sector) of the file of Index Register IX into its buffer through READ@ (4436H): Register Pair HL returns the buffer (6BF8H).

6BED
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
6BEF
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
6BF0
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
6BF1
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
6BF2
GOSUB to 4436H, READ@, to read the next record into the file's buffer.
6BF5
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6BF8
LD L,(IX+05H) DD 6E 05
Load Register L with the low byte of the buffer address from Index Register IX+05H, the file control block's buffer pointer.
6BFB
LD H,(IX+06H) DD 66 06
Load Register H with the high byte of the buffer address from Index Register IX+06H.
6BFE
RET C9
RETurn with Register Pair HL at the file's buffer.

6BFFH - Write a Record

Writes the file's buffer as the next record through WRITE@ (4439H): Register Pair DE returns the buffer (6C0AH).

6BFF
PUSH IX DD E5
Save Index Register IX, the file's area, to the top of the stack.
6C01
POP DE D1
Restore Register Pair DE with the file's area from the top of the stack.
6C02
INC DE 13
INCrement Register Pair DE by 1, past the mode byte.
6C03
INC DE 13
INCrement Register Pair DE by 1, past the column byte: Register Pair DE = the file control block.
6C04
GOSUB to 4439H, WRITE@, to write the file's buffer as the next record.
6C07
If the NZ FLAG is set (an error), JUMP to 6CA3H to post it.
6C0A
LD E,(IX+05H) DD 5E 05
Load Register E with the low byte of the buffer address from Index Register IX+05H, the file control block's buffer pointer.
6C0D
LD D,(IX+06H) DD 56 06
Load Register D with the high byte of the buffer address from Index Register IX+06H.
6C10
RET C9
RETurn with Register Pair DE at the file's buffer.

6C11H - The Record Last Accessed

Works out the number of the record last read or written, for LOC: the record is the position's sector times the record length plus the byte offset in it, plus 1. The position is at Index Register IX+0CH-0DH (the file control block's current sector) and the record length at Index Register IX+07H.

6C11
LD D,(IX+07H) DD 56 07
Load Register D with the record length from Index Register IX+07H.
6C14
LD L,(IX+0CH) DD 6E 0C
Load Register L with the low byte of the current sector from Index Register IX+0CH.
6C17
LD H,(IX+0DH) DD 66 0D
Load Register H with the high byte of the current sector from Index Register IX+0DH.
6C1A
GOSUB to 6C28H to work out the sector times the record length plus the offset into Register Pair HL.
6C1D
INC HL 23
INCrement Register Pair HL by 1, so that LOC counts the records from 1.
6C1E
RET C9
RETurn with the record number in Register Pair HL.

6C1FH - The Number of Records

Works out the number of records in the file, for LOF: the file's last sector (Index Register IX+0EH-0FH) times the record length plus the bytes in the last sector (Index Register IX+0AH).

6C1F
LD D,(IX+0AH) DD 56 0A
Load Register D with the bytes in the last sector from Index Register IX+0AH, the file control block's end of file byte.
6C22
LD L,(IX+0EH) DD 6E 0E
Load Register L with the low byte of the sector count from Index Register IX+0EH.
6C25
LD H,(IX+0FH) DD 66 0F
Load Register H with the high byte of the sector count from Index Register IX+0FH.
6C28
LD E,(IX+0BH) DD 5E 0B
Load Register E with the record length from Index Register IX+0BH, the file control block's logical record length.
6C2B
LD A,E 7B
Load Register A with Register E, the record length.
6C2C
ADD A,FFH C6 FF
ADD FFH to Register A, minus 1: the NC FLAG when the record length is 00H, meaning 256.
6C2E
If the NC FLAG is set (a record length of 256), JUMP to 6C42H.
6C30
ADD A,D 82
ADD Register D, the bytes in the last sector, to Register A (the record length less 1).
6C31
If the NC FLAG is set (no carry), JUMP to 6C35H.
6C33
LD D,A 57
Load Register D with Register A, the sum's low byte.
6C34
INC HL 23
INCrement Register Pair HL by 1, for the carry into the sector count.
6C35
LD A,E 7B
Load Register A with Register E, the record length.
6C36
GOSUB to 4451H, DIVD@, to divide the sector count in Register Pair HL by the record length in Register A: the quotient in Register Pair HL, the remainder in Register A.
6C39
LD B,L 45
Load Register B with Register L, the low byte of the quotient.
6C3A
LD H,A 67
Load Register H with Register A, the remainder, as the high byte.
6C3B
LD L,D 6A
Load Register L with Register D, the bytes in the last sector, as the low byte.
6C3C
LD A,E 7B
Load Register A with Register E, the record length.
6C3D
GOSUB to 4451H, DIVD@, to divide Register Pair HL by the record length in Register A.
6C40
LD H,B 60
Load Register H with Register B, the low byte of the first quotient.
6C41
RET C9
RETurn with the number of records in Register Pair HL.
6C42
INC D 14
INCrement Register D by 1, to test the bytes in the last sector.
6C43
DEC D 15
DECrement Register D by 1: the Z FLAG when the last sector is full.
6C44
RET Z C8
If the Z FLAG is set (the last sector is full), RETurn.
6C45
INC HL 23
INCrement Register Pair HL by 1, for the part record in the last sector.
6C46
RET C9
RETurn with the number of records in Register Pair HL.

6C47H - Wipe a Protected Program

When a program was loaded with an access level of 6 or 7 (62FBH), it may not be listed or saved: at READY, or before a direct statement, the program text is overwritten with 00H, cleared by the ROM's NEW, and the text RUN access only is shown. Otherwise the routine returns at once.

6C47
PUSH AF F5
Save Register Pair AF to the top of the stack.
6C48
PUSH HL E5
Save Register Pair HL to the top of the stack.
6C49
LD HL,62FBH 21 FB 62
Point Register Pair HL to 62FBH, the protection level of the program.
6C4C
XOR A AF
Set Register A to 00H by XORing it with itself.
6C4D
LD (62F7H),A 32 F7 62
Store Register A (00H) to 62F7H, the run flag, cleared.
6C50
CP (HL) BE
Compare Register A (00H) with the protection level at Register Pair HL: the Z FLAG when the program is not protected.
6C51
LD (HL),A 77
Store Register A (00H) at Register Pair HL (62FBH), the protection level cleared.
6C52
If the Z FLAG is set (not protected), JUMP to 6C6EH: nothing is wiped.
6C54
LD HL,044CH 21 4C 04
Load Register Pair HL with 044CH, the bytes of the text area to clear: 1100 bytes.
6C57
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
6C5B
ADD HL,DE 19
ADD Register Pair DE, the start, to Register Pair HL: the end of the area to clear.
6C5C
LD (HL),00H 36 00
Store 00H at Register Pair HL in the program text.
6C5E
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before.
6C5F
RST 18H DF
RST 18H: compare Register Pair HL with Register Pair DE, the start: the Z FLAG when the whole area is cleared.
6C60
If the NZ FLAG is set (more to clear), LOOP back to 6C5CH.
6C62
GOSUB to 1B4DH, the ROM's NEW, which clears the program and the variables.
6C65
LD HL,6C71H 21 71 6C
Point Register Pair HL to 6C71H, the text RUN access only.
6C68
GOSUB to 28A7H, the ROM's routine that shows the text at Register Pair HL up to its 00H.
6C6B
JUMP to 1A19H, the ROM's READY, after the protected program is wiped.
6C6E
POP HL E1
Restore Register Pair HL from the top of the stack.
6C6F
POP AF F1
Restore Register Pair AF from the top of the stack.
6C70
RET C9
RETurn to the caller: the program was not protected, so nothing was wiped.
6C71-6C82
DEFB 0DH / DEFM "RUN access only" / DEFB 0DH,00H 0D 52 55 4E 20 61 63 63 65 73 73 20 6F 6E 6C 79 0D 00
The text shown when a program protected against listing is wiped: a carriage return, the words, a carriage return and the 00H that ends it.

6C83H - The Error Exits

Ten entries, each loading a BASIC error offset into Register E, then the ROM's error routine. The entries after the first are each entered inside a LD BC,xx1EH instruction, at its 1EH xxH bytes, which read as LD E,xxH; from above they only load Register Pair BC.

6C83
LD E,6CH 1E 6C
Load Register E with 6CH, the offset of the error Bad file mode, and fall into the LD BC below.
6C85
LD BC,681EH 01 1E 68
6C86H enters inside this LD BC,681EH: its bytes 1EH 68H read as LD E,68H, the offset Bad file number; from above it only loads Register Pair BC.
6C88
LD BC,661EH 01 1E 66
6C89H enters inside this LD BC,661EH: its bytes 1EH 66H read as LD E,66H, the offset Internal error; from above it only loads Register Pair BC.
6C8B
LD BC,7C1EH 01 1E 7C
6C8CH enters inside this LD BC,7C1EH: its bytes 1EH 7CH read as LD E,7CH, the offset Input past end; from above it only loads Register Pair BC.
6C8E
LD BC,6E1EH 01 1E 6E
6C8FH enters inside this LD BC,6E1EH: its bytes 1EH 6EH read as LD E,6EH, the offset File already open; from above it only loads Register Pair BC.
6C91
LD BC,801EH 01 1E 80
6C92H enters inside this LD BC,801EH: its bytes 1EH 80H read as LD E,80H, the offset Bad file name; from above it only loads Register Pair BC.
6C94
LD BC,7E1EH 01 1E 7E
6C95H enters inside this LD BC,7E1EH: its bytes 1EH 7EH read as LD E,7EH, the offset Bad record number; from above it only loads Register Pair BC.
6C97
LD BC,641EH 01 1E 64
6C98H enters inside this LD BC,641EH: its bytes 1EH 64H read as LD E,64H, the offset Field overflow; from above it only loads Register Pair BC.
6C9A
LD BC,841EH 01 1E 84
6C9BH enters inside this LD BC,841EH: its bytes 1EH 84H read as LD E,84H, the offset Direct statement in file; from above it only loads Register Pair BC.
6C9D
LD BC,861EH 01 1E 86
6C9EH enters inside this LD BC,861EH: its bytes 1EH 86H read as LD E,86H, the offset Too many files; from above it only loads Register Pair BC.
6CA0
JUMP to 19A2H, the ROM's error routine, with the BASIC error offset in Register E.

6CA3H - Post a DOS Error

Takes a DOS error code in Register A, saves it for CMD"E" (62F6H), maps it to a BASIC error offset through the table 6CB6H (a code of 27H or more maps to the second entry, Internal error), and jumps to the ROM's error routine.

6CA3
LD HL,6CB6H 21 B6 6C
Point Register Pair HL to 6CB6H, the start of the map of DOS error codes to BASIC error offsets.
6CA6
LD (62F6H),A 32 F6 62
Store Register A, the DOS error code, to 62F6H, shown again by CMD"E".
6CA9
CP 27H FE 27
Compare Register A against 27H: the C FLAG for a code below 27H.
6CAB
If the C FLAG is set (a known code), JUMP to 6CAFH.
6CAD
LD A,01H 3E 01
Load Register A with 01H, so that an unknown code maps to the second entry, Internal error.
6CAF
LD C,A 4F
Load Register C with Register A, the code, as the offset into the table.
6CB0
LD B,00H 06 00
Load Register B with 00H, the high byte of the offset in Register Pair BC.
6CB2
ADD HL,BC 09
ADD Register Pair BC, the code, to Register Pair HL: the table entry of the code.
6CB3
LD E,(HL) 5E
Load Register E with the BASIC error offset at Register Pair HL.
6CB4
JUMP to 19A2H, the ROM's error routine, with the BASIC error offset in Register E.
6CB7-6CDF
DEFB 72H,72H,72H,72H,72H,72H,72H,80H,72H,72H,72H,72H,72H,72H,88H,66H,72H,72H,80H,72H,72H,72H,72H,6AH,8AH,86H,7AH,66H,66H,7AH,66H,80H,66H,66H,66H,66H,8AH,66H,3AH,00H,2CH 72 72 72 72 72 72 72 80 72 72 72 72 72 72 88 66 72 72 80 72 72 72 72 6A 8A 86 7A 66 66 7A 66 80 66 66 66 66 8A 66 3A 00 2C
The map of DOS error codes to BASIC error offsets, from code 01H: the code indexes the table at 6CB6H (whose first byte is the 19H high byte of the JUMP above, for the unused code 00H) and the byte is the offset the ROM's error routine is given (72H Disk I/O error, 6AH File not found, 66H Internal error and so on). The last three bytes are not used by codes up to 26H.
6CE0-6DDF
DEFS 256
The keyboard input buffer, pointed to by the ROM's 40A7H and used by the line input and the file reads.
6DE0-6DE1
DEFB 00H,00H 00 00
The two bytes before the file areas; the first file area begins at 6DE1H (its mode byte, loaded as 00H, closed).
6DE2-7FFF
DEFS 4638
The file areas (each 0222H bytes from 6DE1H: the mode byte, the column byte, the file control block and two 256 byte buffers) and, above them, the BASIC program, its variables and the string space, up to the top of memory. None of this is in the file.