4E00H - The Image of the Disk BASIC Vectors
Not run here: 533AH copies these 49 JP instructions (147 bytes) to 4152H-41E4H, the ROM's vectors for the disk keywords and its exits, which are RET or an error without a disk. After the copy the area from 4E00H on is free (BASIC/OV3 is loaded there, 54B6H). Each row names its vector.
4E00
Vector 0, copied to 4152H: JP 5D2CH to the CVI keyword (the ROM goes to 4152H for it).
4E03
Vector 1, copied to 4155H: JP 55F7H to the FN keyword (the ROM goes to 4155H for it).
4E06
Vector 2, copied to 4158H: JP 5D2FH to the CVS keyword (the ROM goes to 4158H for it).
4E09
Vector 3, copied to 415BH: JP 56D8H to the DEF keyword (the ROM goes to 415BH for it).
4E0C
Vector 4, copied to 415EH: JP 5D32H to the CVD keyword (the ROM goes to 415EH for it).
4E0F
Vector 5, copied to 4161H: JP 617BH to the EOF keyword (the ROM goes to 4161H for it).
4E12
Vector 6, copied to 4164H: JP 61B2H to the LOC keyword (the ROM goes to 4164H for it).
4E15
Vector 7, copied to 4167H: JP 61B7H to the LOF keyword (the ROM goes to 4167H for it).
4E18
Vector 8, copied to 416AH: JP 5D13H to the MKI$ keyword (the ROM goes to 416AH for it).
4E1B
Vector 9, copied to 416DH: JP 5D16H to the MKS$ keyword (the ROM goes to 416DH for it).
4E1E
Vector 10, copied to 4170H: JP 5D19H to the MKD$ keyword (the ROM goes to 4170H for it).
4E21
Vector 11, copied to 4173H: JP 57C6H to the CMD keyword (the ROM goes to 4173H for it).
4E24
Vector 12, copied to 4176H: JP 5A61H to the TIME$ keyword (the ROM goes to 4176H for it).
4E27
Vector 13, copied to 4179H: JP 62DBH to the OPEN keyword (the ROM goes to 4179H for it).
4E2A
Vector 14, copied to 417CH: JP 607EH to the FIELD keyword (the ROM goes to 417CH for it).
4E2D
Vector 15, copied to 417FH: JP 6205H to the GET keyword (the ROM goes to 417FH for it).
4E30
Vector 16, copied to 4182H: JP 6204H to the PUT keyword (the ROM goes to 4182H for it).
4E33
Vector 17, copied to 4185H: JP 6043H to the CLOSE keyword (the ROM goes to 4185H for it).
4E36
Vector 18, copied to 4188H: JP 5E78H to the LOAD keyword (the ROM goes to 4188H for it).
4E39
Vector 19, copied to 418BH: JP 5E42H to the MERGE keyword (the ROM goes to 418BH for it).
4E3C
Vector 20, copied to 418EH: JP 1E4AH to the NAME keyword (the ROM goes to 418EH for it). LBASIC has no NAME: 1E4AH is the ROM's Illegal function call error (FC).
4E3F
Vector 21, copied to 4191H: JP 6412H to the KILL keyword (the ROM goes to 4191H for it).
4E42
Vector 22, copied to 4194H: JP 5AFFH to the & keyword (the ROM goes to 4194H for it).
4E45
Vector 23, copied to 4197H: JP 60D9H to the LSET keyword (the ROM goes to 4197H for it).
4E48
Vector 24, copied to 419AH: JP 60D8H to the RSET keyword (the ROM goes to 419AH for it).
4E4B
Vector 25, copied to 419DH: JP 5A77H to the INSTR keyword (the ROM goes to 419DH for it).
4E4E
Vector 26, copied to 41A0H: JP 5FECH to the SAVE keyword (the ROM goes to 41A0H for it).
4E51
Vector 27, copied to 41A3H: JP 5912H to the LINE keyword (the ROM goes to 41A3H for it).
4E54
Vector 28, copied to 41A6H: JP 5A42H to the error exit, CALLed by the ROM's error routine at 19ECH: LBASIC gives its long error messages there.
4E57
Vector 29, copied to 41A9H: JP 56FBH to the USR link, CALLed by the ROM's USR at 27FEH.
4E5A
Vector 30, copied to 41ACH: JP 5FC4H to the READY exit, CALLed by the ROM at 1A1CH.
4E5D
Vector 31, copied to 41AFH: JP 5BD1H to the line input exit, CALLed by the ROM at 0368H.
4E60
Vector 32, copied to 41B2H: JP 5FD8H to the exit CALLed by the ROM at 1AA1H after a line is tokenized.
4E63
Vector 33, copied to 41B5H: JP 5CB6H to the exit CALLed by the ROM at 1AECH after the line links are rebuilt.
4E66
Vector 34, copied to 41B8H: JP 5CC3H to the exit CALLed by the ROM at 1AF2H, after the line links and a CLEAR.
4E69
Vector 35, copied to 41BBH: JP 6074H to the exit CALLed by the ROM at 1B8CH (NEW) and 1DB0H (END).
4E6C
Vector 36, copied to 41BEH: JP 587BH to the exit CALLed by the ROM at 2174H as a PRINT ends.
4E6F
Vector 37, copied to 41C1H: JP 5C00H to the byte output exit, CALLed by the ROM at 032CH for every byte sent to a device.
4E72
Vector 38, copied to 41C4H: JP 5C0EH to the keyboard scan exit, CALLed by the ROM at 0358H.
4E75
Vector 39, copied to 41C7H: JP 5E70H to the RUN exit, CALLed by the ROM at 1EA6H.
4E78
Vector 40, copied to 41CAH: JP 573CH to the PRINT exit, CALLed by the ROM at 206FH.
4E7B
Vector 41, copied to 41CDH: JP 5CD0H to the exit CALLed by the ROM at 20C6H after a number is made text.
4E7E
Vector 42, copied to 41D0H: JP 5CCFH to the exit CALLed by the ROM at 2103H after PRINT sends a new line.
4E81
Vector 43, copied to 41D3H: JP 5C9EH to the exit CALLed by the ROM at 2108H and 2141H (a comma field, TAB).
4E84
Vector 44, copied to 41D6H: JP 5882H to the INPUT exit, CALLed by the ROM at 219EH.
4E87
Vector 45, copied to 41D9H: JP 5B50H to the MID$ exit, reached by the ROM's JP at 2AECH (MID$ on the left of an assignment).
4E8A
Vector 46, copied to 41DCH: JP 5D49H to the exit CALLed by the ROM at 222DH as READ or INPUT takes the next field.
4E8D
Vector 47, copied to 41DFH: JP 5A2CH to the exit CALLed by the ROM at 2278H (after INPUT assigns) and 2B44H (LIST).
4E90
Vector 48, copied to 41E2H: JP 02B8H to the SYSTEM exit, CALLed by the ROM at 02B2H. 02B8H is past the ROM's LD SP,4288H at 02B5H, so the stack stays where it is, with the CALL's return address left on it.
4E93H - The Image of the Restart Vectors
Not run here: 530EH copies these 12 bytes to 4000H-400BH, the vectors of RST 08H, RST 10H, RST 18H and RST 20H. Three go to the ROM's own routines; RST 10H, which takes the next character of the BASIC text, goes to LBASIC's 6579H, and 57BAH puts the ROM's 1D78H back at the end.
4E93
Copied to 4000H, the RST 08H vector: JP 1C96H, the ROM's test that the next character of the text is the byte after the RST (else Syntax error).
4E96
Copied to 4003H, the RST 10H vector: JP 6579H, LBASIC's routine that takes the next character of the text, in place of the ROM's 1D78H.
4E99
Copied to 4006H, the RST 18H vector: JP 1C90H, the ROM's compare of Register Pair HL with Register Pair DE.
4E9C
Copied to 4009H, the RST 20H vector: JP 25D9H, the ROM's test of the type of the value (40AFH).
5200H - The Banner, the Messages and the Parameter Table
Texts for the ROM's STROUT (28A7H, ended by 00H) and for @LOGOT (447BH, ended by 0DH), then the table of @PARAM (53AEH): MEM, FILES, BLK, EXT and their short forms, 6 characters and the address of the cell, ended by 00H. BASIC/OV1, BASIC/OV2 and BASIC/OV4 are loaded over this area when they run.
5200
DEFB 0DH 0D
5200H: 0DH, a new line before the banner (5421H displays it through STROUT).
5201-5221
DEFM "LBASIC - Version 5.3.1 - 08/01/91" 4C 42 41 53 49 43 20 2D 20 56 65 72 73 69 6F 6E 20 35 2E 33 2E 31 20 2D 20 30 38 2F 30 31 2F 39 31
5201H-5221H: the first line of the banner, the name, version and date of LBASIC.
5222
DEFB 0DH 0D
5222H: 0DH, a new line before the copyright line of the banner.
5223-524D
DEFM "(C) 1991 MISOSYS, Inc., All rights reserved" 28 43 29 20 31 39 39 31 20 4D 49 53 4F 53 59 53 2C 20 49 6E 63 2E 2C 20 41 6C 6C 20 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64
5223H-524DH: the copyright line of the banner.
524E-524F
DEFB 0DH, 0DH 0D 0D
524EH-524FH: 0DH, 0DH: two new lines after the copyright line of the banner.
5250
DEFB 00H 00
5250H: 00H, the end of the banner for STROUT.
5251-5253
DEFM "V12" 56 31 32
5251H-5253H: the characters V12. No code of BASIC/CMD or of its overlays addresses them.
5254-5269
DEFM "Use LDOS 5.3 or later!" 55 73 65 20 4C 44 4F 53 20 35 2E 33 20 6F 72 20 6C 61 74 65 72 21
5254H-5269H: the text of 534BH when OSVER$ (403EH) is below 51H.
526A
DEFB 0DH 0D
526AH: 0DH, a new line after the text Use LDOS 5.3 or later!
526B
DEFB 00H 00
526BH: 00H, the end of the text for the ROM's STROUT (534EH).
526C-527A
DEFM "Parameter error" 50 61 72 61 6D 65 74 65 72 20 65 72 72 6F 72
526CH-527AH: the text of 5392H for a parameter @PARAM refuses or a FILES value out of range.
527B
DEFB 0DH 0D
527BH: 0DH, the end of the text Parameter error for @LOGOT.
527C-5288
DEFM "Out of memory" 4F 75 74 20 6F 66 20 6D 65 6D 6F 72 79
527CH-5288H: the text of 5388H when MEM is above HIGH$ or leaves too little room.
5289
DEFB 0DH 0D
5289H: 0DH, the end of the text Out of memory for @LOGOT.
528A
DEFB 00H 00
528AH: 00H, stored again by 533FH. No code reads it.
528B-5292
DEFM "MEM " / DEFW 53FEH 4D 45 4D 20 20 20 FE 53
528BH-5292H: MEM, the highest address BASIC may use: the cell 53FEH, the operand of LD DE at 53FDH.
5293-529A
DEFM "M " / DEFW 53FEH 4D 20 20 20 20 20 FE 53
5293H-529AH: M, the short form of MEM: 53FEH.
529B-52A2
DEFM "FILES " / DEFW 53C1H 46 49 4C 45 53 20 C1 53
529BH-52A2H: FILES, the number of file buffers: the cell 53C1H, the operand of LD DE at 53C0H (0003H in the file).
52A3-52AA
DEFM "F " / DEFW 53C1H 46 20 20 20 20 20 C1 53
52A3H-52AAH: F, the short form of FILES: 53C1H.
52AB-52B2
DEFM "BLK " / DEFW 53BAH 42 4C 4B 20 20 20 BA 53
52ABH-52B2H: BLK, blocked files: the cell 53BAH, the operand of LD DE at 53B9H (FFFFH in the file, on).
52B3-52BA
DEFM "B " / DEFW 53BAH 42 20 20 20 20 20 BA 53
52B3H-52BAH: B, the short form of BLK: 53BAH.
52BB-52C2
DEFM "EXT " / DEFW 6385H 45 58 54 20 20 20 85 63
52BBH-52C2H: EXT, the switch of the default extension /BAS: the cell 6385H, the operand of LD HL at 6384H (FFFFH in the file, on; 0000H for OFF).
52C3-52CA
DEFM "E " / DEFW 6385H 45 20 20 20 20 20 85 63
52C3H-52CAH: E, the short form of EXT: the switch at 6385H.
52CB
DEFB 00H 00
52CBH: 00H, the end of the table of the parameters.
52CCH - The Start: Saving the State, the Vectors, the Stack
The transfer address. LDOS runs BASIC with Register Pair HL at the command line after BASIC. The BREAK trap and OVRLY$ are cleared, the first character of the line (an asterisk asks to go back to the program in memory) and the line pointer, HIGH$, the start of the program text, the word at 408EH and the top of string space are kept in operands, the ROM's 39 bytes go to 4080H as at power on, the restart vectors to 4000H, the stack below the top of string space, the line buffer is set at 5309H (over this code), and the 49 vectors are copied to 4152H.
52CC
XOR A AF
Load Register A with 00H (XOR A), for the BREAK trap switch and OVRLY$.
52CD
LD (4315H),A 32 15 43
Store Register A (00H) at 4315H, the BREAK trap switch: any value but C3H means the trap is off.
52D0
LD (430EH),A 32 0E 43
Store Register A (00H) at 430EH, OVRLY$: no system file counts as loaded, since this file's block at 4E00H-4E9EH lies in the overlay area.
52D3
LD A,(HL) 7E
Load Register A with the first character of the command line at Register Pair HL.
52D4
LD (5354H),A 32 54 53
Store Register A (the first character) at 5354H, the operand of LD A at 5353H: 2AH, an asterisk, asks to go back to the program in memory.
52D7
LD (53ACH),HL 22 AC 53
Store Register Pair HL (the pointer to the command line) at 53ACH-53ADH, the operand of LD HL at 53ABH, for @PARAM.
52DA
GOSUB to 5C7FH to clear bits 0-2 of KFLAG$ (4423H), the keys pressed before BASIC ran; Register A is kept.
52DD
LD HL,(4049H) 2A 49 40
Load Register Pair HL with HIGH$ from 4049H-404AH, the highest address free for programs.
52E0
LD (53FEH),HL 22 FE 53
Store Register Pair HL (HIGH$) at 53FEH-53FFH, the operand of LD DE at 53FDH: the value MEM is compared with, and its value when MEM is not given.
52E3
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with 40A4H-40A5H, the start of the BASIC program text as it was.
52E6
LD (5366H),HL 22 66 53
Store Register Pair HL (the program's start) at 5366H-5367H, the operand of LD HL at 5365H, for going back to the program.
52E9
LD HL,(408EH) 2A 8E 40
Load Register Pair HL with the word at 408EH-408FH: the number of file buffers and the blocked mode flag of the last run.
52EC
LD (5301H),HL 22 01 53
Store Register Pair HL at 5301H-5302H, the operand of LD HL at 5300H: the LDIR below writes over 408EH-408FH.
52EF
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with 40A0H-40A1H, the top of string space as it was.
52F2
LD (5360H),HL 22 60 53
Store Register Pair HL (the top of string space) at 5360H-5361H, the operand of LD HL at 535FH.
52F5
LD DE,4080H 11 80 40
Point Register Pair DE to 4080H, where the ROM puts its 39 bytes at power on.
52F8
LD HL,18F7H 21 F7 18
Point Register Pair HL to 18F7H, those bytes in the ROM: the division routine with its self changed operands and the first cells of BASIC.
52FB
LD BC,0027H 01 27 00
Load Register Pair BC with 0027H, the count of the bytes: 39.
52FE
LDIR ED B0
Copy Register Pair BC (39) bytes from Register Pair HL (18F7H) to Register Pair DE (4080H-40A6H) (LDIR); Register Pair BC ends at 0000H.
5300
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5301H-5302H: the word of 408EH-408FH kept at 52ECH (0000H in the file).
5303
LD (408EH),HL 22 8E 40
Store Register Pair HL at 408EH-408FH again: the number of file buffers and the blocked mode flag, over what the LDIR wrote there.
5306
LD HL,4E93H 21 93 4E
Point Register Pair HL to 4E93H, the image of the restart vectors. 5326H-532BH write over these three bytes once they have run.
5309
LD DE,4000H 11 00 40
Point Register Pair DE to 4000H, the vectors of RST 08H, RST 10H, RST 18H and RST 20H.
530C
LD C,0CH 0E 0C
Load Register C with 0CH: Register Pair BC = 000CH (Register B is 00H after the LDIR), 12 bytes.
530E
LDIR ED B0
Copy Register Pair BC (12) bytes from Register Pair HL (4E93H) to Register Pair DE (4000H) (LDIR): RST 10H now goes to 6579H.
5310
LD HL,(4049H) 2A 49 40
Load Register Pair HL with HIGH$ from 4049H-404AH.
5313
LD DE,(5360H) ED 5B 60 53
Load Register Pair DE with the top of string space kept at 5360H-5361H.
5317
CP 2AH FE 2A
Compare Register A (the first character of the command line) against 2AH, an asterisk.
5319
If the NZ FLAG is set (no asterisk), JUMP to 531FH with HIGH$ in Register Pair HL.
531B
RST 18H DF
RST 18H, the ROM's compare of Register Pair HL (HIGH$) with Register Pair DE (the old top of string space): the CARRY FLAG when HIGH$ is lower.
531C
If the CARRY FLAG is set (HIGH$ is lower), JUMP to 531FH with HIGH$.
531E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the old top of string space, the lower of the two.
531F
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space.
5322
LD SP,HL F9
Load the Stack Pointer with Register Pair HL: the stack grows down from the top of string space.
5323
LD HL,5306H 21 06 53
Point Register Pair HL to 5306H, the LD HL,4E93H that has run.
5326
LD (HL),3AH 36 3A
Store 3AH, a colon, at Register Pair HL (5306H).
5328
INC HL 23
INCrement Register Pair HL to 5307H, the second byte written over the LD HL.
5329
LD (HL),B 70
Store Register B (00H, after the LDIR at 530EH) at Register Pair HL (5307H).
532A
INC HL 23
INCrement Register Pair HL to 5308H, the third byte written over the LD HL.
532B
LD (HL),2CH 36 2C
Store 2CH, a comma, at Register Pair HL (5308H): the byte before the line buffer.
532D
INC HL 23
INCrement Register Pair HL to 5309H, the line buffer.
532E
LD (40A7H),HL 22 A7 40
Store Register Pair HL (5309H) at 40A7H-40A8H, the ROM's pointer to the line buffer: typed lines go over this code from 5309H on (at most 240 characters: 036FH in the ROM, 5BDEH here), which has run by then.
5331
LD DE,4152H 11 52 41
Point Register Pair DE to 4152H, the ROM's first disk vector.
5334
LD HL,4E00H 21 00 4E
Point Register Pair HL to 4E00H, the image of the 49 vectors.
5337
LD BC,0093H 01 93 00
Load Register Pair BC with 0093H, the count of the bytes: 147, 49 vectors of 3 bytes.
533A
LDIR ED B0
Copy Register Pair BC (147) bytes from Register Pair HL (4E00H) to Register Pair DE (4152H-41E4H) (LDIR): the disk keywords and the exits now go to LBASIC.
533C
LD HL,528AH 21 8A 52
Point Register Pair HL to 528AH, the byte after the text Out of memory.
533F
LD (HL),00H 36 00
Store 00H at Register Pair HL (528AH), the byte between the texts and the parameter table.
5341
GOSUB to 1B8FH, the ROM's reset of the BASIC stack from the top of string space (40A0H), with the cells of the stack and of the temporary strings.
5344H - The LDOS Version, and Going Back to the Program
OSVER$ must be 51H or more, else Use LDOS 5.3 or later! and the end. BASIC with an asterisk first on the line builds the file buffers again for the old number of files and puts back the start of the program text and the top of string space as they were; when HIGH$ has come down below the old top of memory, the top moves down with it and the variables are cleared. Then the ROM's READY is reached with the program in memory.
5344
LD A,(403EH) 3A 3E 40
Load Register A with OSVER$ from 403EH, the version of the system: 53H for 5.3.
5347
CP 51H FE 51
Compare Register A against 51H: the CARRY FLAG below 51H.
5349
If the NO CARRY FLAG is set (51H or more), JUMP to 5353H.
534B
LD HL,5254H 21 54 52
Point Register Pair HL to 5254H, the text Use LDOS 5.3 or later! (0DH, then 00H for STROUT).
534E
GOSUB to 28A7H, the ROM's STROUT: display the text at Register Pair HL up to the 00H.
5351
JUMP to 538EH to end through @ABORT, the system being too old for LBASIC.
5353
LD A,00H 3E 00
Load Register A with the operand at 5354H: the first character of the command line (52D4H).
5355
CP 2AH FE 2A
Compare Register A against 2AH, an asterisk: back to the program in memory.
5357
If the NZ FLAG is set (no asterisk), JUMP to 5397H for a new start.
5359
LD A,(408EH) 3A 8E 40
Load Register A with the number of files at 408EH (put back at 5303H).
535C
GOSUB to 53CFH to build the file buffers and their table for Register A files; it returns at 53F6H.
535F
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5360H-5361H (0000H in the file): the top of string space kept at 52F2H.
5362
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space, as it was.
5365
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5366H-5367H (0000H in the file): the start of the program text kept at 52E6H.
5368
LD (40A4H),HL 22 A4 40
Store Register Pair HL at 40A4H-40A5H, the start of the program text, as it was.
536B
LD DE,(40B1H) ED 5B B1 40
Load Register Pair DE with 40B1H-40B2H, the top of memory BASIC used before.
536F
LD HL,(4049H) 2A 49 40
Load Register Pair HL with HIGH$ from 4049H-404AH.
5372
RST 18H DF
RST 18H, the ROM's compare of Register Pair HL (HIGH$) with Register Pair DE (the old top): the CARRY FLAG when HIGH$ is lower.
5373
If the NO CARRY FLAG is set (HIGH$ is not lower), JUMP to 5382H.
5375
LD (40B1H),HL 22 B1 40
Store Register Pair HL (HIGH$) at 40B1H-40B2H, the top of memory BASIC may use.
5378
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, minus 50, the room of the string space.
537B
ADD HL,DE 19
ADD Register Pair DE (minus 50) to Register Pair HL: HIGH$ less 50 bytes of string space.
537C
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space.
537F
GOSUB to 1B5DH, the ROM's CLEAR of RUN: the variables are dropped.
5382
LD BC,1A18H 01 18 1A
Load Register Pair BC with 1A18H, the ROM's way into READY.
5385
JUMP to 19AEH, the ROM: the stack is set from 40E8H, and 1B9AH-1BB2H returns to Register Pair BC (1A18H), READY, with the program in memory.
5388
LD HL,527CH 21 7C 52
Point Register Pair HL to 527CH, the text Out of memory.
538B
GOSUB to 447BH, @LOGOT, to display the text at Register Pair HL and write it to the job log.
538E
SCF 37
Set the CARRY FLAG (SCF): 57BAH ends through @ABORT.
538F
JUMP to 57BAH to put back the ROM's RST 10H routine and end through @ABORT.
5392
LD HL,526CH 21 6C 52
Point Register Pair HL to 526CH, the text Parameter error.
5395
JUMP to 538BH to display the text at Register Pair HL and end.
5397H - A New Start: the USR Vectors and the Parameters
The ten USR vectors (661CH-662FH) get 642FH, so a USR that DEF USR never set gives an error; 6630H gets 0000H. @PARAM reads MEM, FILES, BLK and EXT with the table at 528BH. BLK's high byte goes to 408FH; FILES must be 0-15 and goes to 408EH.
5397
LD DE,642FH 11 2F 64
Load Register Pair DE with 642FH, the start of the table of the errors: a USR not set by DEF USR goes there.
539A
LD HL,661CH 21 1C 66
Point Register Pair HL to 661CH, the ten USR vectors above the file.
539D
LD B,0AH 06 0A
Load Register B with 0AH, the count of the USR vectors: 10.
539F
LD (HL),E 73
Store Register E (2FH) at Register Pair HL, the low byte of the vector.
53A0
INC HL 23
INCrement Register Pair HL to the high byte of the vector.
53A1
LD (HL),D 72
Store Register D (64H) at Register Pair HL, the high byte of the vector.
53A2
INC HL 23
INCrement Register Pair HL to the next vector.
53A3
DECrement Register B and LOOP BACK to 539FH for the 10 vectors.
53A5
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, for the word above the USR vectors.
53A8
LD (6630H),HL 22 30 66
Store Register Pair HL (0000H) at 6630H-6631H, the word above the USR vectors.
53AB
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 53ACH-53ADH (0000H in the file): the pointer to the command line (52D7H).
53AE
LD DE,528BH 11 8B 52
Point Register Pair DE to 528BH, the table of the parameters.
53B1
GOSUB to 4476H, @PARAM, to read the parameters at Register Pair HL against the table at Register Pair DE: a cell gets FFFFH for a switch (0000H for =N or OFF) or the value; the Z FLAG on success, Register Pair HL after them.
53B4
If the NZ FLAG is set (a parameter @PARAM refuses), JUMP to 5392H: Parameter error.
53B6
LD (53ACH),HL 22 AC 53
Store Register Pair HL (the pointer after the parameters) at 53ACH-53ADH, for 542BH.
53B9
LD DE,FFFFH 11 FF FF
Load Register Pair DE with the operand at 53BAH-53BBH, the cell of BLK: FFFFH in the file (on), 0000H for BLK=OFF.
53BC
LD A,D 7A
Copy Register D (the high byte of BLK) into Register A.
53BD
LD (408FH),A 32 8F 40
Store Register A at 408FH, the blocked mode flag: not 00H gives each file buffer 256 bytes more (53DAH).
53C0
LD DE,0003H 11 03 00
Load Register Pair DE with the operand at 53C1H-53C2H, the cell of FILES: 0003H in the file.
53C3
LD A,D 7A
Copy Register D (the high byte of FILES) into Register A.
53C4
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for a value of 256 or more.
53C5
If the NZ FLAG is set, JUMP to 5392H: Parameter error.
53C7
LD A,E 7B
Copy Register E (the low byte of FILES) into Register A.
53C8
CP 10H FE 10
Compare Register A against 10H: the CARRY FLAG for 0-15.
53CA
If the NO CARRY FLAG is set (16 or more), JUMP to 5392H: Parameter error.
53CC
LD (408EH),A 32 8E 40
Store Register A (the number of files) at 408EH.
53CFH - Build the File Buffers
Register A = the number of files. Buffers for files 0 to that number are laid out from 6632H up, 0122H bytes each (0222H in blocked mode, 408FH not 00H), their addresses go to the table at 65FAH, the first also to 661AH, and the first byte of each gets 00H. For BASIC with an asterisk it returns to 535FH; else the program text starts after the last buffer, with a 00H before it.
53CF
INC A 3C
INCrement Register A: the buffers for files 0 to the number given.
53D0
LD HL,6632H 21 32 66
Point Register Pair HL to 6632H, the first buffer, above the USR vectors.
53D3
LD DE,65FAH 11 FA 65
Point Register Pair DE to 65FAH, the table of the buffers' addresses.
53D6
LD BC,0122H 01 22 01
Load Register Pair BC with 0122H, the size of a buffer: 290 bytes.
53D9
PUSH AF F5
Save Register Pair AF (Register A = the buffers) to the stack.
53DA
LD A,(408FH) 3A 8F 40
Load Register A with the blocked mode flag at 408FH.
53DD
AND A A7
Set the flags from Register A (AND A): the Z FLAG when blocked mode is off.
53DE
If the Z FLAG is set (blocked mode off), JUMP to 53E1H with 0122H.
53E0
INC B 04
INCrement Register B: Register Pair BC = 0222H, 256 bytes more for blocked mode.
53E1
POP AF F1
Restore Register Pair AF (Register A = the buffers) from the stack.
53E2
LD (661AH),HL 22 1A 66
Store Register Pair HL (6632H) at 661AH-661BH: the address of buffer 0.
53E5
LD (HL),00H 36 00
Store 00H at Register Pair HL, the first byte of the buffer.
53E7
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the table, Register Pair DE = the buffer.
53E8
LD (HL),E 73
Store Register E (the low byte of the buffer's address) at Register Pair HL.
53E9
INC HL 23
INCrement Register Pair HL to the high byte of the entry.
53EA
LD (HL),D 72
Store Register D (the high byte of the buffer's address) at Register Pair HL.
53EB
INC HL 23
INCrement Register Pair HL to the next entry of the table.
53EC
EX DE,HL EB
Exchange Register Pairs DE and HL back: Register Pair HL = the buffer, Register Pair DE = the table.
53ED
ADD HL,BC 09
ADD Register Pair BC (the size) to Register Pair HL: the next buffer.
53EE
DEC A 3D
DECrement Register A, the count of the buffers left to lay out.
53EF
If the NZ FLAG is set (buffers left), LOOP BACK to 53E5H.
53F1
LD A,(5354H) 3A 54 53
Load Register A with the first character of the command line at 5354H (52D4H).
53F4
CP 2AH FE 2A
Compare Register A against 2AH, an asterisk: going back to the program.
53F6
RET Z C8
If the Z FLAG is set (BASIC with an asterisk), RETurn to 535FH.
53F7
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte after the last buffer: the 00H before the program text.
53F9
INC HL 23
INCrement Register Pair HL to the first byte of the program text.
53FA
LD (40A4H),HL 22 A4 40
Store Register Pair HL at 40A4H-40A5H, the start of the program text.
53FDH - MEM
MEM (or HIGH$) must not be above HIGH$, and less 1 must leave 300 bytes above the start of the program text, else Out of memory. It becomes the top of memory (40B1H), with 50 bytes of string space below it; then the ROM's NEW empties the program.
53FD
LD DE,0000H 11 00 00
Load Register Pair DE with the operand at 53FEH-53FFH (0000H in the file), the cell of MEM: HIGH$ as it was at the start (52E0H) unless MEM was given.
5400
LD HL,(4049H) 2A 49 40
Load Register Pair HL with HIGH$ from 4049H-404AH.
5403
RST 18H DF
RST 18H, the ROM's compare of Register Pair HL (HIGH$) with Register Pair DE (MEM): the CARRY FLAG when HIGH$ is lower.
5404
If the CARRY FLAG is set (MEM above HIGH$), JUMP to 5388H: Out of memory.
5407
DEC DE 1B
DECrement Register Pair DE: MEM less 1, the last byte BASIC may use.
5408
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with 40A4H-40A5H, the start of the program text (53FAH). 5428H later stores 00H in this instruction's operand at 5409H.
540B
LD BC,012CH 01 2C 01
Load Register Pair BC with 012CH, the least room the program needs: 300 bytes.
540E
ADD HL,BC 09
ADD Register Pair BC (300) to Register Pair HL: the start of the program text plus 300.
540F
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = MEM less 1, Register Pair DE = the start plus 300.
5410
RST 18H DF
RST 18H, the ROM's compare of Register Pair HL (MEM less 1) with Register Pair DE: the CARRY FLAG when it is lower.
5411
If the CARRY FLAG is set (too little memory), JUMP to 5388H: Out of memory.
5414
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, minus 50, the room of the string space.
5417
LD (40B1H),HL 22 B1 40
Store Register Pair HL (MEM less 1) at 40B1H-40B2H, the top of memory BASIC may use.
541A
ADD HL,DE 19
ADD Register Pair DE (minus 50) to Register Pair HL: the top of string space, 50 bytes below.
541B
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space.
541E
GOSUB to 1B4DH, the ROM's NEW: the program text is emptied and the variables cleared.
5421H - The Banner and the Start of BASIC
The banner is shown. When the command line has more after the parameters, it is taken as a line typed at READY (ended by 00H) and run by the ROM; else the ROM's READY follows.
5421
LD HL,5200H 21 00 52
Point Register Pair HL to 5200H, the banner (00H at its end, 5250H).
5424
GOSUB to 28A7H, the ROM's STROUT: display the text at Register Pair HL up to the 00H.
5427
XOR A AF
Load Register A with 00H (XOR A), for the byte at 5409H.
5428
LD (5409H),A 32 09 54
Store Register A (00H) at 5409H, the low byte of the operand of LD HL,(40A4H) at 5408H, which has run: no code reads 5409H afterwards.
542B
LD HL,(53ACH) 2A AC 53
Load Register Pair HL with the pointer after the parameters at 53ACH-53ADH (53B6H).
542E
DEC HL 2B
DECrement Register Pair HL: RST 10H steps on before it takes a character.
542F
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character of the line and Register A = it, spaces passed over.
5430
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line.
5432
If the Z FLAG is set (nothing more), JUMP to 1A19H, the ROM's READY.
5435
PUSH HL E5
Save Register Pair HL (the start of the rest of the line) to the stack.
5436
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
5437
CP 20H FE 20
Compare Register A against 20H: the CARRY FLAG for a control character, the end of the line.
5439
If the CARRY FLAG is set (the end), JUMP to 543EH.
543B
INC HL 23
INCrement Register Pair HL to the next character.
543C
LOOP BACK to 5436H for the next character of the line.
543E
LD (HL),00H 36 00
Store 00H at Register Pair HL over the 0DH: the end of a line for the ROM.
5440
GOSUB to 038BH, the ROM: the output goes to the video again (409CH = 00H), with a new line to the printer if it is not at the start of a line.
5443
CALL 41ACH CD AC 41
GOSUB to 41ACH, the READY exit (5FC4H), as the ROM calls it on its way to READY.
5446
GOSUB to 20F9H, the ROM: a new line on the video unless the cursor is at the start of a line.
5449
LD HL,FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the line number of a line typed at READY.
544C
LD (40A2H),HL 22 A2 40
Store Register Pair HL (FFFFH) at 40A2H-40A3H, the number of the line being run.
544F
POP HL E1
Restore Register Pair HL (the start of the rest of the line) from the stack.
5450
DEC HL 2B
DECrement Register Pair HL: the ROM's RST 10H steps on before it takes a character.
5451
JP 1A81H C3 81 1A
JUMP to 1A81H, the ROM's main loop after a line was typed: the text at Register Pair HL is tokenized and run as a command.
5454H - CMD"command": an Overlay or a Command of LDOS
CMD with a text of 2 or more characters (57CBH): Register A = the length (less than 64, else Illegal function call), Register Pair DE = the text. N, X or V followed by a space runs BASIC/OV1, BASIC/OV2 or BASIC/OV4 with @RUN and the rest of the text as its command line; anything else goes to the LDOS command shell (54ECH). 5468H is the entry of 5803H for a single letter.
5454
LD C,A 4F
Copy Register A (the length of the text) into Register C.
5455
CP 40H FE 40
Compare Register A against 40H: the CARRY FLAG for a text of fewer than 64 characters.
5457
If the NO CARRY FLAG is set (64 or more), JUMP to 1E4AH, the ROM's Illegal function call error.
545A
PUSH HL E5
Save Register Pair HL (the pointer into the BASIC text) to the stack.
545B
INC DE 13
INCrement Register Pair DE to the second character of the text.
545C
LD A,(DE) 1A
Load Register A with the second character at Register Pair DE.
545D
DEC DE 1B
DECrement Register Pair DE back to the first character.
545E
CP 20H FE 20
Compare Register A against 20H, a space: a letter and a space ask for an overlay.
5460
LD HL,54ECH 21 EC 54
Point Register Pair HL to 54ECH, the command shell. LD does not change the flags.
5463
If the NZ FLAG is set (no space), JUMP to 5479H and on to the address in Register Pair HL (54ECH).
5465
LD A,(DE) 1A
Load Register A with the first character of the text at Register Pair DE.
5466
RES 5,A CB AF
Clear bit 5 of Register A: a lower case letter becomes upper case.
5468
LD B,31H 06 31
Load Register B with 31H, the digit 1 of BASIC/OV1.
546A
CP 4EH FE 4E
Compare Register A against 4EH, N: BASIC/OV1.
546C
If the Z FLAG is set (N), JUMP to 547AH with Register B = 31H.
546E
INC B 04
INCrement Register B: 32H, the digit 2 of BASIC/OV2.
546F
CP 58H FE 58
Compare Register A against 58H, X: BASIC/OV2.
5471
If the Z FLAG is set (X), JUMP to 547AH with Register B = 32H.
5473
LD B,34H 06 34
Load Register B with 34H, the digit 4 of BASIC/OV4.
5475
CP 56H FE 56
Compare Register A against 56H, V: BASIC/OV4.
5477
If the Z FLAG is set (V), JUMP to 547AH with Register B = 34H.
5479
JP (HL) E9
JUMP to the address in Register Pair HL: 54ECH, the command shell, from 5460H; 1E4AH, Illegal function call, from 5803H through 5468H.
547A
PUSH DE D5
Save Register Pair DE (the text) to the stack.
547B
PUSH BC C5
Save Register Pair BC (Register C = the length) to the stack.
547C
GOSUB to 54A5H to put BASIC/OVn, n the digit in Register B, in the control block at 4480H.
547F
POP BC C1
Restore Register Pair BC (Register C = the length) from the stack.
5480
POP HL E1
Restore Register Pair HL (the text) from the stack.
5481
GOSUB to 54E1H to copy Register C characters from Register Pair HL to 4318H, with 0DH after them.
5484
LD HL,4319H 21 19 43
Point Register Pair HL to 4319H, the text after its first letter: the overlay's command line.
5487
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, the control block with BASIC/OVn.
548A
JUMP to 4433H, @RUN, to load the file at Register Pair DE and run it with Register Pair HL at its command line.
548D-5494
DEFM "BASIC/OV" 42 41 53 49 43 2F 4F 56
548DH-5494H: the name of the overlays without the digit, copied to 4480H by 54A5H.
5495-54A2
DEFM "Can't load OV3" 43 61 6E 27 74 20 6C 6F 61 64 20 4F 56 33
5495H-54A2H: the text of 54D5H when BASIC/OV3 cannot be loaded.
54A3-54A4
DEFB 0DH, 00H 0D 00
54A3H-54A4H: 0DH, a new line, and 00H, the end of the text for STROUT.
54A5H - The Name of an Overlay
Puts BASIC/OVn and 00H in the control block at 4480H (CFCB$), n the digit in Register B.
54A5
LD A,B 78
Copy Register B (the digit) into Register A, since the LDIR clears Register Pair BC.
54A6
LD HL,548DH 21 8D 54
Point Register Pair HL to 548DH, the text BASIC/OV without its digit.
54A9
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, CFCB$, the control block of a command's file.
54AC
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the count of the bytes: 8.
54AF
LDIR ED B0
Copy Register Pair BC (8) bytes from Register Pair HL (548DH) to Register Pair DE (4480H) (LDIR).
54B1
LD (DE),A 12
Store Register A (the digit) at Register Pair DE (4488H).
54B2
INC DE 13
INCrement Register Pair DE to 4489H, after the digit of the name.
54B3
XOR A AF
Load Register A with 00H (XOR A), the end of the name.
54B4
LD (DE),A 12
Store Register A (00H) at Register Pair DE (4489H).
54B5
RET C9
RETurn with BASIC/OVn and 00H at 4480H-4489H.
54B6H - Call BASIC/OV3
BASIC/OV3 is loaded at 4E00H and called. When OVRLY$ (430EH) holds 01H, BASIC/OV3 is still there and is entered at once. Otherwise it is loaded with @LOAD and entered at its transfer address; a failure gives the error's message, Can't load OV3 and READY.
54B6
LD A,(430EH) 3A 0E 43
Load Register A with OVRLY$ from 430EH: 01H while BASIC/OV3 is in the overlay area.
54B9
LD B,33H 06 33
Load Register B with 33H, the digit 3 of BASIC/OV3.
54BB
DEC A 3D
DECrement Register A (OVRLY$): the Z FLAG for 01H, BASIC/OV3 in place.
54BC
If the Z FLAG is set (BASIC/OV3 is there), JUMP to 4E00H, its entry.
54BF
PUSH HL E5
Save Register Pair HL (the caller's value) to the stack.
54C0
GOSUB to 54A5H to put BASIC/OV3 in the control block at 4480H.
54C3
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, the control block.
54C6
LD HL,430FH 21 0F 43
Point Register Pair HL to 430FH, SFLAG$, the system flags.
54C9
SET 2,(HL) CB D6
Set bit 2 of SFLAG$ at Register Pair HL: the bit of a load by @RUN.
54CB
GOSUB to 4430H, @LOAD, to load the file at Register Pair DE; Register Pair HL = its transfer address, the Z FLAG on success.
54CE
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack at the Stack Pointer: the transfer address goes on the stack, the caller's value back to Register Pair HL.
54CF
RET Z C8
If the Z FLAG is set (loaded), RETurn: to the transfer address of BASIC/OV3.
54D0
OR C0H F6 C0
Set bits 7 and 6 of Register A (OR C0H, the error number): return to the caller, the short message.
54D2
GOSUB to 4409H, @ERROR, to display the message of the error number in Register A.
54D5
LD HL,5495H 21 95 54
Point Register Pair HL to 5495H, the text Can't load OV3.
54D8
GOSUB to 28A7H, the ROM's STROUT: display the text at Register Pair HL.
54DB
LD BC,1A18H 01 18 1A
Load Register Pair BC with 1A18H, the ROM's way into READY.
54DE
JUMP to 19AEH, the ROM: the stack is set from 40E8H and 1B9AH-1BB2H returns to Register Pair BC, READY.
54E1H - Copy a Command
Copies Register C bytes from Register Pair HL to 4318H (INBUF$, the command line buffer of LDOS) and puts 0DH after them.
54E1
LD DE,4318H 11 18 43
Point Register Pair DE to 4318H, INBUF$, the command line buffer of LDOS.
54E4
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the length in Register C.
54E6
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR); Register Pair DE ends after them.
54E8
LD A,0DH 3E 0D
Load Register A with 0DH, the end of a command line.
54EA
LD (DE),A 12
Store Register A (0DH) at Register Pair DE, after the copied command.
54EB
RET C9
RETurn with the command and its 0DH at 4318H.
54ECH - CMD"command": Run an LDOS Command and Come Back
The text goes to 4318H. If the stack is at least 3944 bytes above the end of BASIC's variables (40FDH), the vectors @EXIT, @ABORT and @ERROR are saved at 540AH-5413H, and BASIC's memory (5200H up to 40FDH, then 407DH-41E4H, then a header of 6 bytes for a module named &) is moved below the stack; HIGH$ goes below it, the three vectors are pointed into the moved copy (559CH, 559BH, 5596H), and @CMNDI runs the command over the memory BASIC has left. The moved copy then brings everything back (559EH).
54EC
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the text of the command, Register Pair DE = 54ECH.
54ED
GOSUB to 54E1H to copy Register C characters from Register Pair HL to 4318H, with 0DH after them.
54F0
GOSUB to 4750H, SYS0/SYS's select of the drive of the last disk call (LDRV$, 4308H).
54F3
LD HL,F098H 21 98 F0
Load Register Pair HL with F098H, minus 0F68H (3944).
54F6
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: the Stack Pointer less 3944 bytes.
54F7
LD DE,(40FDH) ED 5B FD 40
Load Register Pair DE with 40FDH-40FEH, the end of BASIC's variables and arrays (the first free byte).
54FB
XOR A AF
Load Register A with 00H (XOR A), which clears the CARRY FLAG for the SBC.
54FC
SBC HL,DE ED 52
SUBtract Register Pair DE (the end of the variables) from Register Pair HL: the CARRY FLAG when the room is less than 3944 bytes.
54FE
If the CARRY FLAG is set (too little room), JUMP to 197AH, the ROM's Out of memory error.
5501
LD HL,402DH 21 2D 40
Point Register Pair HL to 402DH, the vectors @EXIT (402DH-402FH) and @ABORT (4030H-4032H).
5504
LD DE,540AH 11 0A 54
Point Register Pair DE to 540AH, where they are kept: bytes of the MEM code at 5408H-5420H, which has run.
5507
LD BC,0006H 01 06 00
Load Register Pair BC with 0006H, the count of the bytes: 6.
550A
LDIR ED B0
Copy Register Pair BC (6) bytes from Register Pair HL (402DH) to Register Pair DE (540AH-540FH) (LDIR); Register Pair DE ends at 5410H.
550C
LD HL,4409H 21 09 44
Point Register Pair HL to 4409H, @ERROR, whose first 4 bytes are kept too.
550F
LD C,04H 0E 04
Load Register C with 04H: Register Pair BC = 0004H (Register B is 00H), 4 bytes.
5511
LDIR ED B0
Copy Register Pair BC (4) bytes from Register Pair HL (4409H) to Register Pair DE (5410H-5413H) (LDIR): the start of @ERROR.
5513
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with the end of the variables from 40FDH-40FEH.
5516
LD DE,AE00H 11 00 AE
Load Register Pair DE with AE00H, minus 5200H.
5519
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the bytes from 5200H to the end of the variables.
551A
LD (5572H),HL 22 72 55
Store Register Pair HL (the length) at 5572H-5573H, the operand of LD BC at 5571H.
551D
PUSH HL E5
Save Register Pair HL (the length) to the stack.
551E
LD DE,F200H 11 00 F2
Load Register Pair DE with F200H, minus 0E00H.
5521
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the length less 0E00H, the part above 6000H.
5522
LD (55BAH),HL 22 BA 55
Store Register Pair HL at 55BAH-55BBH, the operand of LD BC at 55B9H, for the second LDIR of the way back.
5525
POP DE D1
Restore Register Pair DE (the length) from the stack.
5526
LD HL,(4049H) 2A 49 40
Load Register Pair HL with HIGH$ from 4049H-404AH.
5529
LD (5592H),HL 22 92 55
Store Register Pair HL (HIGH$) at 5592H-5593H, the link word of the module header.
552C
LD (55BFH),HL 22 BF 55
Store Register Pair HL (HIGH$) at 55BFH-55C0H, the operand of LD HL at 55BEH, to put HIGH$ back.
552F
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, to take the Stack Pointer into it.
5532
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: Register Pair HL = the Stack Pointer.
5533
LD (55C5H),HL 22 C5 55
Store Register Pair HL (the Stack Pointer) at 55C5H-55C6H, the operand of LD SP at 55C4H.
5536
DEC HL 2B
DECrement Register Pair HL: the byte below the stack, the top of the moved block.
5537
LD (556BH),HL 22 6B 55
Store Register Pair HL at 556BH-556CH, the operand of LD DE at 556AH.
553A
XOR A AF
Load Register A with 00H (XOR A), which clears the CARRY FLAG for the SBC.
553B
SBC HL,DE ED 52
SUBtract Register Pair DE (the length) from Register Pair HL.
553D
INC HL 23
INCrement Register Pair HL: the Stack Pointer less the length, where 5200H is moved to.
553E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the new place of 5200H.
553F
DI F3
Disable interrupts while the stack and the vectors change.
5540
LD SP,41E0H 31 E0 41
Load the Stack Pointer with 41E0H, the stack of LDOS.
5543
LD A,C3H 3E C3
Load Register A with C3H, the opcode of JP, for the three vectors.
5545
LD (402DH),A 32 2D 40
Store Register A (C3H) at 402DH, the first byte of @EXIT.
5548
LD (4030H),A 32 30 40
Store Register A (C3H) at 4030H, the first byte of @ABORT.
554B
LD (4409H),A 32 09 44
Store Register A (C3H) at 4409H, @ERROR: a JP in place of its PUSH AF.
554E
LD HL,039CH 21 9C 03
Load Register Pair HL with 039CH, 559CH less 5200H.
5551
ADD HL,DE 19
ADD Register Pair DE (the new place of 5200H) to Register Pair HL: where 559CH is moved to.
5552
LD (402EH),HL 22 2E 40
Store Register Pair HL at 402EH-402FH: @EXIT goes to the moved XOR A of 559CH.
5555
LD HL,039BH 21 9B 03
Load Register Pair HL with 039BH, 559BH less 5200H.
5558
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: where 559BH is moved to.
5559
LD (4031H),HL 22 31 40
Store Register Pair HL at 4031H-4032H: @ABORT goes to the moved OR AFH of 559BH.
555C
LD HL,0396H 21 96 03
Load Register Pair HL with 0396H, 5596H less 5200H.
555F
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: where 5596H is moved to.
5560
LD (440AH),HL 22 0A 44
Store Register Pair HL at 440AH-440BH: @ERROR goes to the moved AND A of 5596H.
5563
LD HL,0210H 21 10 02
Load Register Pair HL with 0210H, 5410H less 5200H.
5566
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: where the kept start of @ERROR (5410H) is moved to.
5567
LD (5598H),HL 22 98 55
Store Register Pair HL at 5598H-5599H, the operand of JP M at 5597H (before the move, so the copy has it).
556A
LD DE,0000H 11 00 00
Load Register Pair DE with the operand at 556BH-556CH (0000H in the file): the byte below the stack (5537H).
556D
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with the end of the variables from 40FDH-40FEH.
5570
DEC HL 2B
DECrement Register Pair HL: the last byte of the block.
5571
LD BC,0000H 01 00 00
Load Register Pair BC with the operand at 5572H-5573H (0000H in the file): the length (551AH).
5574
LDDR ED B8
Copy Register Pair BC bytes from Register Pair HL down to Register Pair DE (LDDR): 5200H up to the end of the variables now lies below the stack.
5576
LD HL,41E4H 21 E4 41
Point Register Pair HL to 41E4H, the last byte of BASIC's cells 407DH-41E4H.
5579
LD BC,0168H 01 68 01
Load Register Pair BC with 0168H, the count of the bytes: 360, 407DH-41E4H.
557C
LDDR ED B8
Copy Register Pair BC (360) bytes from Register Pair HL down to Register Pair DE (LDDR), below the block.
557E
LD HL,5595H 21 95 55
Point Register Pair HL to 5595H, the last byte of the module header 5590H-5595H.
5581
LD C,06H 0E 06
Load Register C with 06H: Register Pair BC = 0006H, 6 bytes.
5583
LDDR ED B8
Copy Register Pair BC (6) bytes from Register Pair HL down to Register Pair DE (LDDR): the header lies below the cells. Register Pair DE ends one byte below it.
5585
EI FB
Enable interrupts: the vectors and the copy are in place.
5586
LD (4049H),DE ED 53 49 40
Store Register Pair DE (the byte below the header) at 4049H-404AH, HIGH$: the moved memory is kept from the command.
558A
LD HL,4318H 21 18 43
Point Register Pair HL to 4318H, the command line.
558D
JUMP to 4405H, @CMNDI, to run the command line at Register Pair HL; its end goes through @EXIT, @ABORT or @ERROR into the moved copy.
5590H - The Module Header and the Three Ways Back
Moved with the block below HIGH$. 5590H-5595H is the header of a module named & (JR to itself, the old HIGH$, the length 01H, the name), so the memory shows in the chain of modules. @ERROR comes to 5596H: an error whose number has bit 7 set (return to the caller) goes on into the kept start of @ERROR; another error, @ABORT (559BH: OR AFH, bit 7 set) and @EXIT (559CH: XOR A, the Z FLAG) keep their result in Register Pair AF' and go on at 559EH.
5590
JUMP to 5590H itself (JR, 18H FEH): the first two bytes of a module header; it is not run.
5592-5593
DEFW 0000H 00 00
5592H-5593H: the header's link word: HIGH$ before the move, stored by 5529H.
5594
DEFB 01H 01
5594H: 01H, the length of the module's name, one character.
5595
DEFM "&" 26
5595H: &, the name of the module that holds BASIC's memory.
5596
AND A A7
Set the flags from Register A (AND A), the error number @ERROR got: the S FLAG when bit 7 is set (return to the caller).
5597
If the S FLAG is set (M), JUMP to the operand at 5598H-5599H (0000H in the file): the moved copy of the start of @ERROR (5567H), so the command gets the error back.
559A
LD BC,AFF6H 01 F6 AF
Load Register Pair BC with AFF6H: from 5597H the bytes F6H AFH of 559BH are taken as the operand, so Register A and the flags pass to 559DH. Entered at 559BH (@ABORT) the bytes F6H AFH are OR AFH: Register A gets bit 7, and the NZ FLAG. Entered at 559CH (@EXIT) the byte AFH is XOR A: Register A = 00H with the Z FLAG.
559D
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': the result (Register A and the Z FLAG) is kept for 55DDH.
559EH - The Way Back
Runs in the moved copy until 55B6H. The cells 407DH-41E4H and the first 0E00H bytes of 5200H come back, then the original code goes on at 55B9H: the rest of the block, HIGH$, the Stack Pointer and the three vectors are put back. @EXIT returns to the CMD statement; @ABORT gives System command aborted; an error is made a BASIC error (644FH).
559E
LD HL,(4049H) 2A 49 40
Load Register Pair HL with HIGH$ from 4049H-404AH: the byte below the header (5586H).
55A1
LD DE,0007H 11 07 00
Load Register Pair DE with 0007H, the count to step over: the byte and the header of 6 bytes.
55A4
ADD HL,DE 19
ADD Register Pair DE (7) to Register Pair HL: the kept copy of 407DH.
55A5
LD DE,407DH 11 7D 40
Point Register Pair DE to 407DH, the first of BASIC's cells.
55A8
LD BC,0168H 01 68 01
Load Register Pair BC with 0168H, the count of the bytes: 360.
55AB
DI F3
Disable interrupts while the cells come back.
55AC
LDIR ED B0
Copy Register Pair BC (360) bytes from Register Pair HL to Register Pair DE (407DH-41E4H) (LDIR); Register Pair HL ends at the kept copy of 5200H.
55AE
LD DE,5200H 11 00 52
Point Register Pair DE to 5200H, the start of BASIC/CMD's memory.
55B1
LD BC,0E00H 01 00 0E
Load Register Pair BC with 0E00H, the count of the bytes: 3584, 5200H-5FFFH.
55B4
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): 5200H-5FFFH are back, this code with them.
55B6
JUMP to 55B9H, the original of the next instruction, now back in place.
55B9
LD BC,0000H 01 00 00
Load Register Pair BC with the operand at 55BAH-55BBH (0000H in the file): the length less 0E00H (5522H).
55BC
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): from 6000H to the end of the variables.
55BE
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 55BFH-55C0H (0000H in the file): HIGH$ as it was (552CH).
55C1
LD (4049H),HL 22 49 40
Store Register Pair HL at 4049H-404AH, HIGH$.
55C4
LD SP,0000H 31 00 00
Load the Stack Pointer with the operand at 55C5H-55C6H (0000H in the file): the Stack Pointer as it was (5533H).
55C7
LD HL,540AH 21 0A 54
Point Register Pair HL to 540AH, the kept @EXIT and @ABORT.
55CA
LD DE,402DH 11 2D 40
Point Register Pair DE to 402DH, @EXIT, to put it back.
55CD
LD C,06H 0E 06
Load Register C with 06H: Register Pair BC = 0006H, 6 bytes.
55CF
LDIR ED B0
Copy Register Pair BC (6) bytes from Register Pair HL (540AH) to Register Pair DE (402DH) (LDIR); Register Pair HL ends at 5410H.
55D1
LD DE,4409H 11 09 44
Point Register Pair DE to 4409H, @ERROR, to put it back.
55D4
LD C,04H 0E 04
Load Register C with 04H: Register Pair BC = 0004H, 4 bytes.
55D6
LDIR ED B0
Copy Register Pair BC (4) bytes from Register Pair HL (5410H) to Register Pair DE (4409H) (LDIR): @ERROR as it was.
55D8
EI FB
Enable interrupts: memory, the stack and the vectors are back.
55D9
GOSUB to 5C7FH to clear bits 0-2 of KFLAG$ (4423H), keys pressed during the command.
55DC
POP HL E1
Restore Register Pair HL (the pointer into the BASIC text, saved at 545AH) from the stack.
55DD
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': Register A and the flags the command ended with (559DH).
55DE
RET Z C8
If the Z FLAG is set (@EXIT), RETurn: the CMD statement is done.
55DF
LD E,8EH 1E 8E
Load Register E with 8EH, the error System command aborted.
55E1
BIT 7,A CB 7F
Test bit 7 of Register A: set after @ABORT (OR AFH at 559BH).
55E3
If the NZ FLAG is set (aborted), JUMP to 19A2H, the ROM's error routine with the error in Register E.
55E6
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the LDOS error number.
55E8
JUMP to 644FH to give the BASIC error of the LDOS error in Register A.
55EBH - Find a Function's Name
For FN (55F7H) and DEF FN (56DCH): the FN token (BEH) must come next; the name's first letter gets bit 7 (OR 80H) and goes into the ROM's variable search after its first character (2612H), with 40DCH = 80H (no array). Returns Register Pair DE at the function's value, the address of its definition, and its type at 40AFH.
55EB
RST 08H => BEH CF BE
RST 08H with the byte BEH, the ROM's test: the character at Register Pair HL must be BEH, the token FN (else Syntax error); Register Pair HL steps past it.
55ED
LD A,80H 3E 80
Load Register A with 80H, bit 7: a function's name.
55EF
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that no subscript follows the name.
55F2
OR (HL) B6
OR the name's first letter at Register Pair HL into Register A: the letter with bit 7 set, so a function is not taken for a variable of the same name.
55F3
LD B,A 47
Copy Register A (the marked letter) into Register B, where the ROM's search keeps the first character.
55F4
JUMP to 2612H, the ROM's variable search (PTRGET) after its LD B,(HL) at 2611H: it returns Register Pair DE at the value and 40AFH the type.
55F7H - FN: Call a Function Defined by DEF FN
Vector 1 (4155H). The function's value holds the address of its definition text (after the name). With parameters, the values of the variables named in the definition's list are saved on the stack (2, 4 or 8 bytes, or a string's descriptor), the arguments of the call are assigned to them, the body after = is evaluated, and the saved values are put back; the result is made the function's type (DEF FNA$, FNA%, ...). A function never defined gives Undefined user function.
55F7
GOSUB to 55EBH to find the function: Register Pair DE = its value, 40AFH its type.
55FA
LD A,(40AFH) 3A AF 40
Load Register A with the function's type from 40AFH (2 integer, 3 string, 4 single, 8 double).
55FD
AND A A7
Set the flags from Register A (AND A): NZ and NO CARRY, the mark of the bottom of the saved items.
55FE
PUSH AF F5
Save Register Pair AF (the function's type) to the stack: the bottom of the saved items, read again at 5687H.
55FF
LD (40F3H),HL 22 F3 40
Store Register Pair HL (the pointer into the calling text, after the name) at 40F3H-40F4H.
5602
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the function's value.
5603
LD A,(HL) 7E
Load Register A with the low byte of the value at Register Pair HL.
5604
INC HL 23
INCrement Register Pair HL to the high byte of the function's value.
5605
LD H,(HL) 66
Load Register H with the high byte of the value at Register Pair HL.
5606
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the address of the definition.
5607
OR H B4
OR Register H into Register A: the Z FLAG when the address is 0000H, no DEF FN for it.
5608
If the Z FLAG is set (not defined), JUMP to 642FH: Undefined user function.
560B
LD A,(HL) 7E
Load Register A with the definition's character at Register Pair HL.
560C
CP 28H FE 28
Compare Register A against 28H, an opening bracket: a list of parameters.
560E
If the NZ FLAG is set (no parameters), JUMP to 5678H to evaluate the body.
5610
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character and Register A = it, the first parameter's name.
5611
LD (40D8H),HL 22 D8 40
Store Register Pair HL (the first parameter in the definition) at 40D8H-40D9H.
5614
JUMP to 5618H, past the comma that comes between parameters.
5616
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next in the definition's list.
5618
LD C,04H 0E 04
Load Register C with 04H, the words of stack this parameter may need.
561A
GOSUB to 1963H, the ROM's check that the stack has room for Register C (4) more words; else Out of memory.
561D
LD A,80H 3E 80
Load Register A with 80H, the flag that no subscript follows a name.
561F
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that no subscript follows the name.
5622
GOSUB to 260DH, the ROM's variable search (PTRGET): the parameter named at Register Pair HL; Register Pair DE = its value, 40AFH its type.
5625
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the parameter's value, Register Pair DE = the definition pointer.
5626
RST 20H E7
RST 20H, the ROM's test of the type (40AFH): the Z FLAG for a string, the S FLAG for an integer, PO for single precision.
5627
SCF 37
Set the CARRY FLAG (SCF): the mark of a saved number.
5628
If the Z FLAG is set (a string), JUMP to 5645H.
562A
LD C,(HL) 4E
Load Register C with the first byte of the value at Register Pair HL.
562B
INC HL 23
INCrement Register Pair HL to the second byte.
562C
LD B,(HL) 46
Load Register B with the second byte at Register Pair HL.
562D
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
562E
If the S FLAG is set (an integer, 2 bytes), JUMP to 5643H.
5631
INC HL 23
INCrement Register Pair HL to the third byte.
5632
LD C,(HL) 4E
Load Register C with the third byte at Register Pair HL.
5633
INC HL 23
INCrement Register Pair HL to the fourth byte.
5634
LD B,(HL) 46
Load Register B with the fourth byte at Register Pair HL.
5635
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
5636
If PO is set (single precision, 4 bytes), JUMP to 5643H.
5639
INC HL 23
INCrement Register Pair HL to the fifth byte of a double precision value.
563A
LD C,(HL) 4E
Load Register C with the fifth byte at Register Pair HL.
563B
INC HL 23
INCrement Register Pair HL to the sixth byte.
563C
LD B,(HL) 46
Load Register B with the sixth byte at Register Pair HL.
563D
INC HL 23
INCrement Register Pair HL to the seventh byte.
563E
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
563F
LD C,(HL) 4E
Load Register C with the seventh byte at Register Pair HL.
5640
INC HL 23
INCrement Register Pair HL to the eighth byte.
5641
LD B,(HL) 46
Load Register B with the eighth byte at Register Pair HL.
5642
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
5643
If the CARRY FLAG is set (always here, 5627H), JUMP to 564FH.
5645
JP NC,2423H D2 23 24
If the NO CARRY FLAG is set, JUMP to 2423H in the ROM. Reached only from 5628H with the CARRY FLAG set, so it is never taken.
5648
PUSH DE D5
Save Register Pair DE (the definition pointer) to the stack.
5649
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the string's descriptor.
564A
GOSUB to 2888H, the ROM: a copy of the descriptor at Register Pair DE goes into the temporary strings (40B3H); Register Pair HL at it.
564D
POP DE D1
Restore Register Pair DE (the definition pointer) from the stack.
564E
XOR A AF
Load Register A with 00H (XOR A): the Z FLAG, the mark of a saved string.
564F
PUSH HL E5
Save Register Pair HL (the last byte of the saved value, or for a string the variable's descriptor, which 2888H gives back) to the stack.
5650
PUSH AF F5
Save Register Pair AF (the mark: the CARRY FLAG for a number with its type flags, the Z FLAG for a string) to the stack.
5651
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the definition pointer.
5652
LD A,(HL) 7E
Load Register A with the character after the parameter's name at Register Pair HL.
5653
CP 29H FE 29
Compare Register A against 29H, the closing bracket.
5655
If the NZ FLAG is set (more parameters), LOOP BACK to 5616H.
5657
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the pointer into the calling text from 40F3H-40F4H.
565A
RST 08H => 28H CF 28
RST 08H with the byte 28H: an opening bracket must follow FN and the name in the call.
565C
PUSH HL E5
Save Register Pair HL (the pointer into the call's arguments) to the stack.
565D
LD HL,(40D8H) 2A D8 40
Load Register Pair HL with the first parameter in the definition from 40D8H-40D9H.
5660
GOSUB to 260DH, the ROM's variable search: the next parameter at Register Pair HL; Register Pair DE = its value.
5663
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the pointer into the call, the definition pointer kept.
5664
GOSUB to 1F2BH, the ROM's assignment of LET: the argument at Register Pair HL is evaluated and stored in the variable at Register Pair DE.
5667
LD A,(HL) 7E
Load Register A with the character after the argument at Register Pair HL.
5668
CP 29H FE 29
Compare Register A against 29H, the closing bracket.
566A
If the Z FLAG is set (the last argument), JUMP to 5673H.
566C
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next in the call.
566E
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the definition pointer.
566F
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next in the definition's list.
5671
LOOP BACK to 5660H for the next parameter and argument.
5673
RST 10H D7
RST 10H (6579H): Register Pair HL past the closing bracket of the call, Register A = the next character.
5674
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the definition pointer, the call's pointer kept.
5675
RST 08H => 29H CF 29
RST 08H with the byte 29H: the closing bracket of the definition's list.
5677
LD A,D5H 3E D5
Load Register A with D5H: from 5675H this only steps over the byte D5H at 5678H. Entered at 5678H (from 560EH, no parameters) the byte D5H is PUSH DE.
5679
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: the body of the definition follows.
567B
GOSUB to 2337H, the ROM's expression evaluator: the body at Register Pair HL; the result in the accumulator (4121H), its type at 40AFH.
567E
DEC HL 2B
DECrement Register Pair HL, back to the character that ended the body.
567F
RST 10H D7
RST 10H (6579H): Register Pair HL on, Register A = that character, the Z FLAG at the end of the statement.
5680
If the NZ FLAG is set (more after the body), JUMP to 1997H, the ROM's Syntax error.
5683
RST 20H E7
RST 20H, the ROM's test of the type of the result: the Z FLAG for a string.
5684
If the Z FLAG is set (a string), JUMP to 56B5H.
5686
POP DE D1
Restore Register Pair DE (the pointer into the calling text) from the stack.
5687
POP AF F1
Restore Register Pair AF (the mark of the item saved last) from the stack.
5688
If the Z FLAG is set (a string), JUMP to 56C9H to put its descriptor back.
568A
If the NO CARRY FLAG is set (the function's type at the bottom), JUMP to 56A8H.
568C
POP HL E1
Restore Register Pair HL (the last byte of the variable's value) from the stack.
568D
POP BC C1
Restore Register Pair BC (the last two bytes saved) from the stack.
568E
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
568F
DEC HL 2B
DECrement Register Pair HL to the byte below.
5690
LD (HL),C 71
Store Register C (a saved byte) at Register Pair HL in the variable.
5691
If the S FLAG is set (an integer), JUMP to 5687H: its 2 bytes are back.
5694
DEC HL 2B
DECrement Register Pair HL to the byte below.
5695
POP BC C1
Restore Register Pair BC (two more bytes) from the stack.
5696
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
5697
DEC HL 2B
DECrement Register Pair HL to the byte below.
5698
LD (HL),C 71
Store Register C (a saved byte) at Register Pair HL in the variable.
5699
If PO is set (single precision), JUMP to 5687H: its 4 bytes are back.
569C
DEC HL 2B
DECrement Register Pair HL to the byte below.
569D
POP BC C1
Restore Register Pair BC (two more bytes) from the stack.
569E
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
569F
DEC HL 2B
DECrement Register Pair HL to the byte below.
56A0
LD (HL),C 71
Store Register C (a saved byte) at Register Pair HL in the variable.
56A1
DEC HL 2B
DECrement Register Pair HL to the byte below.
56A2
POP BC C1
Restore Register Pair BC (the first two bytes) from the stack.
56A3
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
56A4
DEC HL 2B
DECrement Register Pair HL to the byte below.
56A5
LD (HL),C 71
Store Register C at Register Pair HL: the 8 bytes of a double precision value are back.
56A6
LOOP BACK to 5687H for the next saved item, down to the function's type.
56A8
PUSH DE D5
Save Register Pair DE (the pointer into the calling text) to the stack.
56A9
PUSH AF F5
Save Register Pair AF (the function's type) to the stack.
56AA
RST 20H E7
RST 20H, the ROM's test of the type of the result: the Z FLAG for a string.
56AB
LD DE,40D3H 11 D3 40
Point Register Pair DE to 40D3H, the ROM's descriptor of the string being built.
56AE
If the Z FLAG is set (a string), GOSUB to 2888H to put the descriptor at Register Pair DE into the temporary strings.
56B1
POP AF F1
Restore Register Pair AF (Register A = the function's type) from the stack.
56B2
JUMP to 281AH, the ROM: the result is made the type in Register A, and the routine returns to the pointer on the stack.
56B5
LD HL,(40B3H) 2A B3 40
Load Register Pair HL with 40B3H-40B4H, the next free temporary string descriptor.
56B8
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = that pointer.
56B9
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the address of the result's descriptor from 4121H-4122H.
56BC
RST 18H DF
RST 18H, the ROM's compare of Register Pair HL with Register Pair DE: the CARRY FLAG when the descriptor lies below the free one, a temporary string.
56BD
If the CARRY FLAG is set (a temporary string), JUMP to 56C4H.
56BF
GOSUB to 2843H, the ROM: the string of the descriptor at Register Pair HL is copied into string space.
56C2
JUMP to 5686H to put the saved values back with the string kept.
56C4
POP DE D1
Restore Register Pair DE (the pointer into the calling text) from the stack.
56C5
LD HL,40D3H 21 D3 40
Point Register Pair HL to 40D3H, the descriptor being built.
56C8
PUSH HL E5
Save Register Pair HL (40D3H) to the stack, the place 56C9H stores into.
56C9
GOSUB to 29F5H, the ROM: Register Pair HL = the last temporary descriptor, Register Pair BC = its string's address; Register Pair DE (the text) is not it, so nothing is freed there.
56CC
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
56CD
LD (40B3H),HL 22 B3 40
Store Register Pair HL at 40B3H-40B4H: the temporary descriptor is free again.
56D0
POP HL E1
Restore Register Pair HL (the place for the descriptor: the variable's, or 40D3H) from the stack.
56D1
LD (HL),A 77
Store Register A (the length) at Register Pair HL.
56D2
INC HL 23
INCrement Register Pair HL to the address of the string.
56D3
LD (HL),C 71
Store Register C (the low byte of the string's address) at Register Pair HL.
56D4
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
56D5
LD (HL),B 70
Store Register B (the high byte of the string's address) at Register Pair HL: the descriptor is back.
56D6
LOOP BACK to 5687H for the next saved item, down to the function's type.
56D8H - DEF: DEF FN and DEF USR
Vector 3 (415BH), with Register A = the token after DEF. DEF USRn goes to 572DH. DEF FN (not in a line typed at READY) stores the address of the text after the name in the function's value, checks the list of parameters (every name is made a variable), and passes over the rest of the statement.
56D8
CP C1H FE C1
Compare Register A (the character after DEF) against C1H, the token USR.
56DA
If the Z FLAG is set (DEF USR), JUMP to 572DH.
56DC
GOSUB to 55EBH to find the function: Register Pair DE = its value, Register Pair HL after the name.
56DF
GOSUB to 2828H, the ROM: Illegal direct when the line was typed at READY.
56E2
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the function's value, Register Pair DE = the text after the name.
56E3
LD (HL),E 73
Store Register E (the low byte of the text's address) at Register Pair HL.
56E4
INC HL 23
INCrement Register Pair HL to the high byte of the value.
56E5
LD (HL),D 72
Store Register D (the high byte) at Register Pair HL: the function now points at its definition.
56E6
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the text after the name.
56E7
LD A,(HL) 7E
Load Register A with the character after the name at Register Pair HL.
56E8
CP 28H FE 28
Compare Register A against 28H, an opening bracket.
56EA
If the NZ FLAG is set (no parameters), JUMP to 1F05H, the ROM's DATA: the rest of the statement is passed over.
56ED
RST 10H D7
RST 10H (6579H): Register Pair HL to the first parameter's name, Register A = its first character.
56EE
GOSUB to 260DH, the ROM's variable search: the parameter at Register Pair HL is found or made.
56F1
LD A,(HL) 7E
Load Register A with the character after the name at Register Pair HL.
56F2
CP 29H FE 29
Compare Register A against 29H, the closing bracket.
56F4
If the Z FLAG is set (the end of the list), JUMP to 1F05H to pass over the rest of the statement.
56F7
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
56F9
LOOP BACK to 56EEH for the next parameter of the definition.
56FBH - USR: Call a Machine Language Routine
Vector 29 (41A9H), CALLed by the ROM's USR at 27FEH. The ROM's return address is dropped; the digit after USR (none: USR0) picks one of the ten vectors at 661CH, the argument in brackets is evaluated, and the routine is entered by a RET with 26E7H below it on the stack, Register Pair HL = 4121H (the accumulator), Register A = the type (a string argument's descriptor in Register Pair DE).
56FB
POP AF F1
Discard the return address of the ROM's CALL at 27FEH (POP AF into Register Pair AF): this routine finishes USR itself.
56FC
GOSUB to 571BH to read the digit after USR: Register Pair DE = its vector in 661CH-662FH.
56FF
PUSH DE D5
Save Register Pair DE (the vector's address) to the stack.
5700
GOSUB to 252CH, the ROM's evaluation of an expression in brackets at Register Pair HL; the value in the accumulator, its type at 40AFH.
5703
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the vector's address, the text pointer kept.
5704
LD C,(HL) 4E
Load Register C with the low byte of the routine's address at Register Pair HL.
5705
INC HL 23
INCrement Register Pair HL to the high byte of the vector.
5706
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the routine (642FH when DEF USR never set it).
5707
LD HL,26E7H 21 E7 26
Point Register Pair HL to 26E7H, the ROM's POP HL / RET, where the routine returns to.
570A
PUSH HL E5
Save Register Pair HL (26E7H) to the stack, under the routine's address.
570B
PUSH BC C5
Save Register Pair BC (the routine's address) to the stack, for the RET at 571AH.
570C
LD A,(40AFH) 3A AF 40
Load Register A with the type of the argument from 40AFH.
570F
PUSH AF F5
Save Register Pair AF (the type) to the stack.
5710
CP 03H FE 03
Compare Register A (the type) against 03H, the type of a string.
5712
If the Z FLAG is set (a string), GOSUB to 29DAH, the ROM: the temporary string is freed; Register Pair HL = its descriptor.
5715
POP AF F1
Restore Register Pair AF (Register A = the type) from the stack.
5716
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the string's descriptor for a string argument.
5717
LD HL,4121H 21 21 41
Point Register Pair HL to 4121H, the ROM's accumulator with the argument.
571A
RET C9
RETurn to the routine's address pushed at 570BH; its RET goes to 26E7H, which takes back the text pointer.
571BH - The Number of a USR
The character after USR: a digit 0-9 picks USR0-USR9, anything else USR0. Register Pair DE returns at its vector, 661CH + 2 x n.
571B
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character and Register A = it; the CARRY FLAG for a digit.
571C
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the offset of USR0.
571F
If the NO CARRY FLAG is set (no digit), JUMP to 5726H with USR0.
5721
SUB 30H D6 30
SUBtract 30H from Register A: the digit's value.
5723
RLCA 07
Rotate Register A left one bit (RLCA): twice the digit, the offset of its vector.
5724
LD C,A 4F
Copy Register A (the offset) into Register C: Register Pair BC = the offset.
5725
RST 10H D7
RST 10H (6579H): Register Pair HL past the digit, Register A = the next character.
5726
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the text pointer.
5727
LD HL,661CH 21 1C 66
Point Register Pair HL to 661CH, the vector of USR0.
572A
ADD HL,BC 09
ADD Register Pair BC (the offset) to Register Pair HL: the vector of the USR.
572B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the vector, Register Pair HL = the text pointer.
572C
RET C9
RETurn with Register Pair DE at the vector of the USR named.
572DH - DEF USR
DEF USRn = address: the value after = (an integer) is stored in the vector of USRn.
572D
GOSUB to 571BH to read the digit: Register Pair DE = the vector.
5730
PUSH DE D5
Save Register Pair DE (the vector's address) to the stack.
5731
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: it must come next.
5733
GOSUB to 2B02H, the ROM: the expression at Register Pair HL is evaluated as an integer into Register Pair DE.
5736
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the vector's address, the text pointer kept.
5737
LD (HL),E 73
Store Register E (the low byte of the address) at Register Pair HL.
5738
INC HL 23
INCrement Register Pair HL to the high byte of the vector.
5739
LD (HL),D 72
Store Register D (the high byte) at Register Pair HL: the USR is set.
573A
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
573B
RET C9
RETurn to the caller of DEF, the rest of the statement after it.
573CH - PRINT#: a File Number
Vector 40 (41CAH), CALLed by the ROM's PRINT at 206FH with Register Pair HL at the character after PRINT, the # (Register A). PRINT #- (the cassette) is left to the ROM; PRINT #n goes to 5CDCH for a file open for output (Register C = 02H).
573C
PUSH HL E5
Save Register Pair HL (the pointer at the #) to the stack.
573D
RST 10H D7
RST 10H (6579H): Register Pair HL past the #, Register A = the next character.
573E
CP CEH FE CE
Compare Register A against CEH, the token minus: PRINT #-1, the cassette.
5740
POP HL E1
Restore Register Pair HL (the pointer at the #) from the stack.
5741
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the #; LD does not change the flags.
5742
RET Z C8
If the Z FLAG is set (a minus sign), RETurn to the ROM's PRINT for the cassette.
5743
LD C,02H 0E 02
Load Register C with 02H, the mode the file must have: output.
5745
JUMP to 5CDCH to read the file number and make the file the current one.
5748H - ON or OFF
The second argument of CMD"B" and CMD"D": a comma, then a text of 2 or more characters; its second character (F of OFF, N of ON) gives the Z FLAG for OFF.
5748
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
574A
GOSUB to 2337H, the ROM's expression evaluator: the argument at Register Pair HL.
574D
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
574E
GOSUB to 29D7H, the ROM: the result must be a string (else Type mismatch); it is freed, Register Pair HL = its descriptor.
5751
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
5752
CP 02H FE 02
Compare Register A against 02H: the CARRY FLAG for fewer than 2 characters.
5754
If the CARRY FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
5757
INC HL 23
INCrement Register Pair HL to the string's address in the descriptor.
5758
LD A,(HL) 7E
Load Register A with the low byte of the address at Register Pair HL.
5759
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
575A
LD H,(HL) 66
Load Register H with the high byte at Register Pair HL.
575B
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the string.
575C
INC HL 23
INCrement Register Pair HL to the second character.
575D
LD A,(HL) 7E
Load Register A with the second character at Register Pair HL.
575E
RES 5,A CB AF
Clear bit 5 of Register A (the second character): f becomes F.
5760
CP 46H FE 46
Compare Register A against 46H, F: the Z FLAG for OFF.
5762
POP HL E1
Restore Register Pair HL (the text pointer) from the stack; POP does not change the flags.
5763
RET C9
RETurn with the Z FLAG for OFF, the NZ FLAG for ON.
5764H - CMD"L": Load a Program File
CMD"L","filespec": the file is loaded with @LOAD and not run (a USR can call it). A failure gives the BASIC error of the LDOS error.
5764
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
5766
LD BC,(661AH) ED 4B 1A 66
Load Register Pair BC with the address of buffer 0 from 661AH-661BH.
576A
GOSUB to 62A1H to put the file specification at Register Pair HL in the control block at Register Pair DE (buffer 0).
576D
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
576E
GOSUB to 4430H, @LOAD, to load the file at Register Pair DE; the Z FLAG on success.
5771
POP HL E1
Restore Register Pair HL (the text pointer) from the stack; POP does not change the flags.
5772
If the NZ FLAG is set (not loaded), JUMP to 644FH to give the BASIC error of the LDOS error in Register A.
5775
RET C9
RETurn to the caller: the file is in memory and is not run.
5776H - CMD"P": the Printer's Status
CMD"P",variable: the printer's status (37E8H, bits 7-4) goes into the variable, as a number or, for a string variable, as the text of the number.
5776
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
5778
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable named at Register Pair HL, 40AFH its type.
577B
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
577C
LD (40DFH),DE ED 53 DF 40
Store Register Pair DE (the variable's address) at 40DFH-40E0H.
5780
PUSH DE D5
Save Register Pair DE (the variable's address) to the stack.
5781
RST 20H E7
RST 20H, the ROM's test of the type (40AFH): the Z FLAG for a string variable.
5782
PUSH AF F5
Save Register Pair AF (the type's flags) to the stack.
5783
LD A,(37E8H) 3A E8 37
Load Register A with the printer's status from 37E8H: bit 7 busy, bit 6 out of paper, bit 5 selected, bit 4 fault.
5786
AND F0H E6 F0
Mask Register A to bits 7-4 (AND F0H), the four status lines.
5788
GOSUB to 27F8H, the ROM: Register A becomes an integer in the accumulator.
578B
POP AF F1
Restore Register Pair AF (the type's flags) from the stack.
578C
If the NZ FLAG is set (a numeric variable), JUMP to 579FH.
578E
PUSH AF F5
Save Register Pair AF (the type's flags) to the stack.
578F
GOSUB to 0FBDH, the ROM's number to text (FOUT): the number in the accumulator as text.
5792
GOSUB to 2865H, the ROM: a descriptor for that text.
5795
GOSUB to 29DAH, the ROM: the temporary descriptor is freed; Register Pair HL at it.
5798
GOSUB to 2843H, the ROM: the text is copied into string space.
579B
GOSUB to 2888H, the ROM: its descriptor becomes the value in the accumulator.
579E
POP AF F1
Restore Register Pair AF (the type's flags) from the stack.
579F
POP HL E1
Restore Register Pair HL (the variable's address, from 5780H) from the stack.
57A0
JUMP to 1F33H, the ROM's assignment of LET: the value is stored in the variable; it returns to the text pointer on the stack.
57A3H - CMD"B": the BREAK Key
CMD"B","OFF" sets bit 4 of SFLAG$ (430FH) and puts RET Z (C8H) at 4BF0H in SYS0/SYS's request code 01H; CMD"B","ON" clears the bit and puts back 00H.
57A3
GOSUB to 5748H to read ON or OFF: the Z FLAG for OFF.
57A6
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
57A7
LD HL,430FH 21 0F 43
Point Register Pair HL to 430FH, SFLAG$, the system flags. LD does not change the flags.
57AA
If the Z FLAG is set (OFF), JUMP to 57B4H to turn BREAK off.
57AC
RES 4,(HL) CB A6
Clear bit 4 of SFLAG$ at Register Pair HL: BREAK is on.
57AE
XOR A AF
Load Register A with 00H (XOR A), a NOP for 4BF0H.
57AF
LD (4BF0H),A 32 F0 4B
Store Register A at 4BF0H, in SYS0/SYS's handling of request code 01H: 00H lets it return Register A = 01H, C8H (RET Z) makes it return at once with Register A = 00H.
57B2
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
57B3
RET C9
RETurn to the caller of the CMD statement with BREAK on.
57B4
SET 4,(HL) CB E6
Set bit 4 of SFLAG$ at Register Pair HL: BREAK is off.
57B6
LD A,C8H 3E C8
Load Register A with C8H, the opcode of RET Z.
57B8
JUMP to 57AFH to store Register A (C8H) at 4BF0H.
57BAH - Back to LDOS
CMD"S", CMD"A" and the start's errors: the ROM's 1D78H goes back into the RST 10H vector, then @ABORT with the CARRY FLAG, else @EXIT.
57BA
LD HL,1D78H 21 78 1D
Load Register Pair HL with 1D78H, the ROM's routine of RST 10H.
57BD
LD (4004H),HL 22 04 40
Store Register Pair HL (1D78H) at 4004H-4005H, the operand of the RST 10H vector at 4003H.
57C0
If the CARRY FLAG is set (CMD"A" or an error at the start), JUMP to 4030H, @ABORT.
57C3
JUMP to 402DH, @EXIT, back to LDOS Ready with no error.
57C6H - CMD: the Letters
Vector 11 (4173H). The text after CMD: 2 characters or more go to 5454H; one letter (upper or lower case) picks L, P, T, R, S, A, I, the asterisk, O, B, E or D. Any other letter goes to 5468H, where N, X and V run their overlay with no command line, and anything else gives Illegal function call.
57C6
GOSUB to 5869H to evaluate the text after CMD: Register A = its length, Register Pair DE = the text.
57C9
CP 02H FE 02
Compare Register A (the length) against 02H: the NO CARRY FLAG for 2 or more.
57CB
If the NO CARRY FLAG is set, JUMP to 5454H: an overlay or a command of LDOS.
57CE
LD A,(DE) 1A
Load Register A with the letter at Register Pair DE.
57CF
RES 5,A CB AF
Clear bit 5 of Register A: a lower case letter becomes upper case (the asterisk 2AH becomes 0AH).
57D1
CP 4CH FE 4C
Compare Register A (the letter) against 4CH, L: load a program file.
57D3
If the Z FLAG is set (L), JUMP to 5764H to load a file.
57D6
CP 50H FE 50
Compare Register A (the letter) against 50H, P: the printer's status.
57D8
If the Z FLAG is set (P), JUMP to 5776H for the printer's status.
57DA
CP 54H FE 54
Compare Register A (the letter) against 54H, T: interrupts off.
57DC
If the Z FLAG is set (T), JUMP to 5810H: interrupts off.
57DE
CP 52H FE 52
Compare Register A (the letter) against 52H, R: interrupts on.
57E0
If the Z FLAG is set (R), JUMP to 580EH: interrupts on.
57E2
CP 53H FE 53
Compare Register A (the letter) against 53H, S: back to LDOS.
57E4
If the Z FLAG is set (S), JUMP to 57BAH: back to LDOS through @EXIT (the CARRY FLAG is clear after the compare).
57E6
CP 41H FE 41
Compare Register A (the letter) against 41H, A: back to LDOS through @ABORT.
57E8
SCF 37
Set the CARRY FLAG (SCF), for @ABORT; SCF does not change the Z FLAG.
57E9
If the Z FLAG is set (A), JUMP to 57BAH: back to LDOS through @ABORT.
57EB
CP 49H FE 49
Compare Register A (the letter) against 49H, I: a command of LDOS, staying there.
57ED
If the Z FLAG is set (I), JUMP to 583AH: a command, staying in LDOS.
57EF
CP 0AH FE 0A
Compare Register A against 0AH, the asterisk after bit 5 was cleared.
57F1
If the Z FLAG is set (the asterisk), JUMP to 5812H to print the screen.
57F3
CP 4FH FE 4F
Compare Register A (the letter) against 4FH, O: sort an array.
57F5
If the Z FLAG is set (O), JUMP to 5834H to sort an array.
57F7
CP 42H FE 42
Compare Register A (the letter) against 42H, B: the BREAK key.
57F9
If the Z FLAG is set (B), JUMP to 57A3H for the BREAK key.
57FB
CP 45H FE 45
Compare Register A (the letter) against 45H, E: the last LDOS error.
57FD
If the Z FLAG is set (E), JUMP to 584AH for the last LDOS error.
57FF
CP 44H FE 44
Compare Register A (the letter) against 44H, D: DEBUG.
5801
If the Z FLAG is set (D), JUMP to 5852H for DEBUG.
5803
LD HL,1E4AH 21 4A 1E
Point Register Pair HL to 1E4AH, the ROM's Illegal function call, where 5479H jumps for a letter that is not an overlay's.
5806
LD C,01H 0E 01
Load Register C with 01H, the length of the text.
5808
JUMP to 5468H to test the letter in Register A for N, X and V.
580B
JUMP to 1E4AH, the ROM's Illegal function call. No code comes here.
580EH - CMD"R" and CMD"T": Interrupts
580EH (R) enables interrupts; the next instruction's operand F3H is the DI that 5810H (T) runs.
580E
EI FB
Enable interrupts: CMD"R", the clock and the other interrupt tasks run again.
580F
LD A,F3H 3E F3
Load Register A with F3H: from 580EH only a step over the byte F3H. Entered at 5810H (CMD"T") the byte F3H is DI: interrupts off, which makes disk and other timing exact but stops the clock.
5811
RET C9
RETurn to the caller of the CMD statement, with interrupts on (R) or off (T).
5812H - CMD with an Asterisk: Print the Screen
The 1024 characters of the screen (3C00H-3FFFH) go to the printer, a new line before each row of 64; codes below 20H are printed as the letters they show (plus 40H). BREAK stops it.
5812
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack; 5879H takes it back.
5813
LD HL,3C00H 21 00 3C
Point Register Pair HL to 3C00H, the first character of the screen.
5816
LD A,L 7D
Copy Register L (the low byte of the screen address) into Register A.
5817
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the Z FLAG at the start of a row.
5819
LD A,0DH 3E 0D
Load Register A with 0DH, a new line; LD does not change the flags.
581B
If the Z FLAG is set (the start of a row), GOSUB to 003BH, the ROM's printer output of Register A.
581E
BIT 6,H CB 74
Test bit 6 of Register H: set at 4000H, past the screen.
5820
If the NZ FLAG is set (the screen is done), JUMP to 5879H to take back Register Pair HL and return.
5822
GOSUB to 5C81H to look at KFLAG$: the NZ FLAG for BREAK.
5825
If the NZ FLAG is set (BREAK), JUMP to 5879H to stop.
5827
LD A,(HL) 7E
Load Register A with the character on the screen at Register Pair HL.
5828
CP 20H FE 20
Compare Register A against 20H: the CARRY FLAG for codes below 20H.
582A
If the NO CARRY FLAG is set (a printable code), JUMP to 582EH.
582C
ADD A,40H C6 40
ADD 40H to Register A: codes 00H-1FH are shown as the letters 40H-5FH.
582E
INC HL 23
INCrement Register Pair HL to the next screen position.
582F
GOSUB to 003BH, the ROM's printer output of the character in Register A.
5832
LOOP BACK to 5816H for the next character of the screen.
5834H - CMD"O": Sort an Array
BASIC/OV3 does the sort: Register A' = 03H, its function, and BASIC/OV3 is called (54B6H).
5834
LD A,03H 3E 03
Load Register A with 03H, BASIC/OV3's function: the sort of CMD"O".
5836
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': the function is kept in Register A' for BASIC/OV3.
5837
JUMP to 54B6H to call BASIC/OV3 with its function in Register A'.
583AH - CMD"I": Run a Command and Stay in LDOS
CMD"I","command": the command gets 0DH at its end and runs through @CMNDI with the stack of LDOS; BASIC does not come back.
583A
GOSUB to 5867H for a comma and the text: Register A = its length, Register Pair DE = the text.
583D
LD L,A 6F
Copy Register A (the length) into Register L.
583E
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the length.
5840
ADD HL,DE 19
ADD Register Pair DE (the text) to Register Pair HL: the byte after the text.
5841
LD (HL),0DH 36 0D
Store 0DH at Register Pair HL: the end of the command line.
5843
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the command.
5844
LD SP,41E0H 31 E0 41
Load the Stack Pointer with 41E0H, the stack of LDOS.
5847
JUMP to 4405H, @CMNDI, to run the command at Register Pair HL; LDOS Ready follows.
584AH - CMD"E": the Last LDOS Error
The LDOS error kept at 65F7H (stored by BASIC/OV3 function 02H, which 644FH calls) is displayed by @ERROR with bits 7 and 6 set (the short message, and back to the caller).
584A
LD A,(65F7H) 3A F7 65
Load Register A with the last LDOS error from 65F7H.
584D
OR C0H F6 C0
Set bits 7 and 6 of Register A (OR C0H): return to the caller, the short message.
584F
JUMP to 4409H, @ERROR: the message is displayed and @ERROR returns to the caller of the CMD statement.
5852H - CMD"D": DEBUG
CMD"D" alone enters DEBUG at once (@DEBUG). CMD"D","ON" puts C3H in the BREAK trap switch (4315H), so BREAK enters DEBUG; CMD"D","OFF" puts C9H there.
5852
DEC HL 2B
DECrement Register Pair HL: RST 10H steps on before it takes a character.
5853
RST 10H D7
RST 10H (6579H): Register A = the character after CMD"D" at Register Pair HL; the Z FLAG at the end of the statement.
5854
If the Z FLAG is set (no switch), JUMP to 5863H.
5856
GOSUB to 5748H to read ON or OFF: the Z FLAG for OFF.
5859
LD A,C3H 3E C3
Load Register A with C3H, the opcode of JP: the trap is on. LD does not change the flags.
585B
If the NZ FLAG is set (ON), JUMP to 585FH with C3H in Register A.
585D
LD A,C9H 3E C9
Load Register A with C9H, the opcode of RET: the trap is off.
585F
LD (4315H),A 32 15 43
Store Register A at 4315H, the BREAK trap switch: with C3H, BREAK goes to the address at 4316H (44B4H, DEBUG).
5862
RET C9
RETurn to the caller of the CMD statement with the trap set.
5863
GOSUB to 440DH, @DEBUG, to enter DEBUG (SYS5/SYS).
5866
RET C9
RETurn to the caller of the CMD statement after DEBUG.
5867H - The Text of a CMD
5867H wants a comma first. A string expression is evaluated and freed; an empty string gives Illegal function call. Returns Register A = the length, Register Pair DE = the text.
5867
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
5869
GOSUB to 2337H, the ROM's expression evaluator: the expression at Register Pair HL.
586C
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
586D
GOSUB to 29D7H, the ROM: the result must be a string; it is freed, Register Pair HL = its descriptor.
5870
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
5871
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty string.
5872
If the Z FLAG is set (empty), JUMP to 1E4AH, the ROM's Illegal function call.
5875
INC HL 23
INCrement Register Pair HL to the string's address in the descriptor.
5876
LD E,(HL) 5E
Load Register E with the low byte of the address at Register Pair HL.
5877
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
5878
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the text.
5879
POP HL E1
Restore Register Pair HL (the text pointer) from the stack. 5812H ends here too.
587A
RET C9
RETurn with Register A = the length and Register Pair DE = the text.
587BH - The End of PRINT
Vector 36 (41BEH), CALLed by the ROM at 2174H after it set 409CH to 00H (Register A = 00H): 65F8H-65F9H, the current file, gets 0000H, so the output goes to the video again.
587B
LD (65F8H),A 32 F8 65
Store Register A (00H) at 65F8H, the low byte of the current file's buffer address.
587E
LD (65F9H),A 32 F9 65
Store Register A (00H) at 65F9H, the high byte: no file is current.
5881
RET C9
RETurn to the ROM's PRINT, with no file current.
5882H - INPUT# and INPUT@
Vector 44 (41D6H), CALLed by the ROM's INPUT at 219EH with Register A = the character after INPUT. INPUT #- is left to the ROM (the cassette). INPUT #n makes file n current (open for input, 5CDAH) and joins the ROM's INPUT at 21EBH, where the values are taken. INPUT @pos moves the cursor (pos 0-1023); without a field it is the ROM's INPUT with its prompt; with ,"prompt",width,"spec"; it reads a field (5922H). The spec is $ (any character 20H-7FH) or # (digits), an optional asterisk (the field ends when full), and a fill character (5FH, the underline, if none). A fill character of 60H-7FH also flips bit 6 (the asterisk) and is shown as itself less 40H (5909H).
5882
CP 23H FE 23
Compare Register A (the character after INPUT) against 23H, #.
5884
If the NZ FLAG is set (no #), JUMP to 5899H for INPUT@.
5886
PUSH HL E5
Save Register Pair HL (the pointer at the #) to the stack.
5887
RST 10H D7
RST 10H (6579H): Register Pair HL past the #, Register A = the next character.
5888
CP CEH FE CE
Compare Register A against CEH, the token minus: INPUT #-1, the cassette.
588A
POP HL E1
Restore Register Pair HL (the pointer at the #) from the stack.
588B
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the #; LD does not change the flags.
588C
RET Z C8
If the Z FLAG is set (a minus sign), RETurn to the ROM's INPUT for the cassette.
588D
POP BC C1
Discard the ROM's return address (POP BC into Register Pair BC): INPUT# goes on here.
588E
GOSUB to 5CDAH to read #n and make file n current, open for input (Register C = 01H).
5891
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack, as the ROM's INPUT keeps it.
5892
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H (5309H).
5895
DEC HL 2B
DECrement Register Pair HL to 5308H, the comma before the buffer.
5896
JUMP to 21EBH, the ROM's INPUT after a line was read: the values come from the current file.
5899
CP 40H FE 40
Compare Register A (the character after INPUT) against 40H, @.
589B
RET NZ C0
If the NZ FLAG is set (neither # nor @), RETurn to the ROM's INPUT.
589C
GOSUB to 2B01H, the ROM: the expression after @ as an integer in Register Pair DE (Register A = its high byte).
589F
CP 04H FE 04
Compare Register A (the high byte) against 04H: the CARRY FLAG for 0-1023.
58A1
If the NO CARRY FLAG is set (off the screen), JUMP to 1E4AH, the ROM's Illegal function call.
58A4
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
58A5
LD HL,3C00H 21 00 3C
Point Register Pair HL to 3C00H, the first character of the screen.
58A8
GOSUB to 5A22H to put the cursor at 3C00H + Register Pair DE (4020H).
58AB
LD A,E 7B
Copy Register E (the low byte of the position) into Register A.
58AC
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the column, 0-63.
58AE
LD (40A6H),A 32 A6 40
Store Register A (the column) at 40A6H, the ROM's cursor column.
58B1
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
58B2
POP AF F1
Discard the ROM's return address (POP AF into Register Pair AF): INPUT@ goes on here.
58B3
LD A,(HL) 7E
Load Register A with the character after the position at Register Pair HL.
58B4
CP 2CH FE 2C
Compare Register A against 2CH, a comma: a prompt or a field follows.
58B6
If the Z FLAG is set (a comma), JUMP to 58BDH.
58B8
RST 08H => 3BH CF 3B
RST 08H with the byte 3BH: a semicolon must come next.
58BA
JUMP to 21DBH, the ROM's INPUT with its prompt, at the cursor just set.
58BD
RST 10H D7
RST 10H (6579H): Register Pair HL past the comma, Register A = the next character.
58BE
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
58BF
CP 22H FE 22
Compare Register A against 22H, a quote: a prompt.
58C1
If the NZ FLAG is set (no prompt), JUMP to 58D2H for the width.
58C3
GOSUB to 2866H, the ROM: a descriptor for the quoted text at Register Pair HL.
58C6
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
58C7
GOSUB to 28AAH, the ROM: the string of the descriptor is displayed (STRPRT).
58CA
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
58CB
LD A,(HL) 7E
Load Register A with the character after the prompt at Register Pair HL.
58CC
CP 3BH FE 3B
Compare Register A against 3BH, a semicolon: no field.
58CE
If the Z FLAG is set, JUMP to 58B8H: the ROM's INPUT after the prompt.
58D0
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the width.
58D2
GOSUB to 2B1CH, the ROM: the width as a byte in Register A.
58D5
OR A B7
Set the flags from Register A (OR A): the Z FLAG for a width of 0.
58D6
If the Z FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
58D9
CP F1H FE F1
Compare Register A (the width) against F1H: the CARRY FLAG for 1-240.
58DB
If the NO CARRY FLAG is set (241 or more), JUMP to 1E4AH, Illegal function call.
58DE
PUSH AF F5
Save Register Pair AF (Register A = the width) to the stack.
58DF
GOSUB to 5867H for a comma and the field's spec: Register A = its length, Register Pair DE = the text.
58E2
LD B,A 47
Copy Register A (the length of the spec) into Register B.
58E3
LD C,3FH 0E 3F
Load Register C with 3FH: the field's code, bits 5-0 the fill character less 20H (3FH: the fill character 5FH, the underline), bits 7 and 6 clear.
58E5
LD A,(DE) 1A
Load Register A with the first character of the spec at Register Pair DE.
58E6
INC DE 13
INCrement Register Pair DE to the next character of the spec.
58E7
CP 24H FE 24
Compare Register A against 24H, $: any character.
58E9
If the Z FLAG is set ($, any character), JUMP to 58F2H with the field's code unchanged.
58EB
CP 23H FE 23
Compare Register A against 23H, #: only digits.
58ED
If the NZ FLAG is set (neither), JUMP to 1997H, the ROM's Syntax error.
58F0
SET 7,C CB F9
Set bit 7 of Register C (the field's code): a field that takes only digits.
58F2
DEC B 05
DECrement Register B, the characters of the spec left.
58F3
If the Z FLAG is set (no more), JUMP to 590CH.
58F5
LD A,(DE) 1A
Load Register A with the next character of the spec at Register Pair DE.
58F6
INC DE 13
INCrement Register Pair DE to the next character.
58F7
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk: the field ends when it is full.
58F9
If the NZ FLAG is set (not the asterisk), JUMP to 5901H: it is the fill character.
58FB
SET 6,C CB F1
Set bit 6 of Register C: the field ends by itself when full.
58FD
DEC B 05
DECrement Register B, the characters of the spec left.
58FE
If the Z FLAG is set (no more), JUMP to 590CH.
5900
LD A,(DE) 1A
Load Register A with the fill character at Register Pair DE.
5901
SUB 20H D6 20
SUBtract 20H from Register A: the fill character less 20H.
5903
CP 60H FE 60
Compare Register A against 60H: the CARRY FLAG for a printable character, 20H-7FH.
5905
If the NO CARRY FLAG is set, JUMP to 1997H, the ROM's Syntax error.
5908
XOR C A9
Exclusive OR Register C (the field's code) into Register A (the fill character less 20H).
5909
XOR 3FH EE 3F
Exclusive OR 3FH into Register A: with the line above, bits 5-0 of Register C become those of the fill character less 20H; bit 6 is flipped too for a fill character of 60H-7FH.
590B
LD C,A 4F
Copy Register A (the field's code) into Register C.
590C
POP AF F1
Restore Register Pair AF (Register A = the width) from the stack.
590D
LD B,A 47
Copy Register A (the width) into Register B: Register Pair BC = the width and the field's code.
590E
RST 08H => 3BH CF 3B
RST 08H with the byte 3BH: a semicolon must come before the variable.
5910
JUMP to 5922H to read the field into the string variable.
5912H - LINE INPUT
Vector 27 (41A3H), the token LINE: INPUT must follow (89H), not in a line typed at READY. LINE INPUT# goes to 5D5DH. Else after an optional prompt a whole line from the keyboard (0361H) goes into a string variable; 5922H is shared with INPUT@'s field (Register B = the width, Register C = its code), read by 5949H.
5912
RST 08H => 89H CF 89
RST 08H with the byte 89H, the token INPUT: it must follow LINE.
5914
GOSUB to 2828H, the ROM: Illegal direct for a line typed at READY.
5917
LD A,(HL) 7E
Load Register A with the character after INPUT at Register Pair HL.
5918
CP 23H FE 23
Compare Register A against 23H, #: LINE INPUT from a file.
591A
If the Z FLAG is set, JUMP to 5D5DH for LINE INPUT#.
591D
GOSUB to 21CDH, the ROM: a quoted prompt at Register Pair HL is displayed, with its semicolon.
5920
LD B,00H 06 00
Load Register B with 00H: no field, the whole line.
5922
PUSH BC C5
Save Register Pair BC (the width and the field's code) to the stack.
5923
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable at Register Pair HL.
5926
GOSUB to 0AF4H, the ROM: Type mismatch unless the variable is a string.
5929
POP BC C1
Restore Register Pair BC (the width and code) from the stack.
592A
PUSH DE D5
Save Register Pair DE (the variable's address) to the stack.
592B
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
592C
PUSH BC C5
Save Register Pair BC (the width and code) to the stack.
592D
INC B 04
INCrement Register B (the width), with the DEC next to set the flags.
592E
DEC B 05
DECrement Register B back: the Z FLAG for no field.
592F
If the Z FLAG is set (a whole line), GOSUB to 0361H, the ROM's line input from the keyboard into 40A7H's buffer (CARRY for BREAK); Register Pair HL = the byte before the buffer.
5932
POP BC C1
Restore Register Pair BC (the width and code) from the stack.
5933
INC B 04
INCrement Register B (the width), with the DEC next to set the flags.
5934
DEC B 05
DECrement Register B back: the NZ FLAG for a field.
5935
If the NZ FLAG is set (a field), GOSUB to 5949H to read the field; Register Pair HL = the byte before the text, CARRY for BREAK.
5938
POP DE D1
Restore Register Pair DE (the text pointer) from the stack.
5939
POP BC C1
Restore Register Pair BC (the variable's address) from the stack.
593A
If the CARRY FLAG is set (BREAK), JUMP to 1DBEH, the ROM's STOP: Break in the line.
593D
PUSH BC C5
Save Register Pair BC (the variable's address) to the stack.
593E
PUSH DE D5
Save Register Pair DE (the text pointer) to the stack.
593F
LD B,00H 06 00
Load Register B with 00H, the byte that ends the text.
5941
GOSUB to 2868H, the ROM: a temporary string of the text after Register Pair HL up to the 00H in Register B.
5944
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5945
XOR A AF
Load Register A with 00H (XOR A), the flag value the ROM's assignment at 1F32H expects.
5946
JUMP to 1F32H, the ROM's assignment: the string goes into the variable whose address is on the stack.
5949H - Read a Field
INPUT@ with a width: the field editor (5960H) reads at most Register B characters into the line buffer (40A7H); the text gets 00H at its end. An empty field (ended by ENTER) keeps the 0DH in Register A before the 00H, so the string is CHR$(13). Returns Register Pair HL at the byte before the text and the CARRY FLAG for BREAK.
5949
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
594C
GOSUB to 5960H, the field editor: Register B = the characters typed, CARRY for BREAK.
594F
PUSH AF F5
Save Register Pair AF (the CARRY FLAG of BREAK) to the stack.
5950
PUSH HL E5
Save Register Pair HL (the buffer) to the stack.
5951
LD C,B 48
Copy Register B (the characters typed) into Register C.
5952
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the count.
5954
ADD HL,BC 09
ADD Register Pair BC (the count) to Register Pair HL: the byte after the text.
5955
INC C 0C
INCrement Register C (the count), with the DEC next to set the flags.
5956
DEC C 0D
DECrement Register C back: the Z FLAG for an empty field.
5957
If the NZ FLAG is set (something typed), JUMP to 595BH.
5959
LD (HL),A 77
Store Register A (0DH, the key that ended the field) at Register Pair HL, the first byte of the buffer of an empty field.
595A
INC HL 23
INCrement Register Pair HL past the 0DH of the empty field.
595B
LD (HL),B 70
Store Register B (00H) at Register Pair HL: the end of the text.
595C
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
595D
DEC HL 2B
DECrement Register Pair HL to the byte before the text.
595E
POP AF F1
Restore Register Pair AF (the CARRY FLAG of BREAK) from the stack.
595F
RET C9
RETurn to the caller, 5935H's GOSUB in LINE INPUT, which goes on at 5938H.
5960H - Field Editor
CALLed from 594CH with Register Pair HL = the line buffer, Register B = the width and Register C = the field's code (bit 7 digits only, bit 6 end when full, bits 5-0 the fill character less 20H). The field is painted with the fill character and the cursor put back at its start; then keys are read (0049H) until ENTER, BREAK, or a full field with bit 6. Left arrow erases one character, shifted left arrow all of them. Returns Register B = the characters typed and the CARRY FLAG for BREAK.
5960
PUSH HL E5
Save Register Pair HL (the line buffer) to the stack.
5961
PUSH BC C5
Save Register Pair BC (Register B = the width, Register C = the field's code) to the stack.
5962
LD A,C 79
Copy Register C (the field's code) into Register A.
5963
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the fill character less 20H.
5965
ADD A,20H C6 20
ADD 20H to Register A: the fill character itself.
5967
LD (5A28H),A 32 28 5A
Store Register A (the fill character) at 5A28H, the operand of the LD A at 5A27H.
596A
GOSUB to 5A27H to display the fill character.
596D
DECrement Register B and LOOP BACK to 596AH until the whole width is painted.
596F
POP BC C1
Restore Register Pair BC (the width and the field's code) from the stack.
5970
PUSH BC C5
Save Register Pair BC (the width and the field's code) to the stack again.
5971
GOSUB to 5A04H to move the cursor one place to the left.
5974
DECrement Register B and LOOP BACK to 5971H: the cursor goes back to the start of the field.
5976
POP BC C1
Restore Register Pair BC (the width and the field's code) from the stack.
5977
PUSH BC C5
Save Register Pair BC to the stack again: 59BAH and 59DBH look at its Register C there.
5978
LD C,B 48
Copy Register B (the width) into Register C: Register B counts the places left, Register C the width.
5979
LD A,0EH 3E 0E
Load Register A with 0EH, the code that turns the cursor on: the top of the key loop.
597B
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
597E
GOSUB to 0049H, the ROM: wait for a key, returned in Register A.
5981
CP 20H FE 20
Compare Register A (the key) against 20H: NO CARRY for a printable character.
5983
If the NO CARRY FLAG is set, JUMP to 59B2H to take the character.
5985
CP 0DH FE 0D
Compare Register A (the key) against 0DH, ENTER.
5987
If the Z FLAG is set (ENTER), JUMP to 59E2H to end the field; CP left the CARRY FLAG clear.
5989
DEC A 3D
DECrement Register A (the key): the Z FLAG for 01H, BREAK.
598A
SCF 37
Set the CARRY FLAG (SCF), the mark of BREAK; SCF does not change the Z FLAG.
598B
If the Z FLAG is set (BREAK), JUMP to 59E2H to end the field with the CARRY FLAG set.
598D
LD DE,5979H 11 79 59
Load Register Pair DE with 5979H, the top of the key loop.
5990
PUSH DE D5
Save Register Pair DE (5979H) to the stack: the RETurns below go back to the key loop.
5991
CP 07H FE 07
Compare Register A (the key less 1) against 07H: the Z FLAG for 08H, left arrow.
5993
If the Z FLAG is set (left arrow), JUMP to 599EH to erase one character, which RETurns to 5979H.
5995
CP 17H FE 17
Compare Register A (the key less 1) against 17H: the Z FLAG for 18H, shifted left arrow.
5997
RET NZ C0
If the NZ FLAG is set (any other key), RETurn to 5979H: the key is ignored.
5998
GOSUB to 599EH to erase one character: the Z FLAG when none is left.
599B
If the NZ FLAG is set (characters left), LOOP BACK to 5998H.
599D
RET C9
RETurn to 5979H, the top of the key loop, through the address 5990H saved.
599EH - Erase One Character
Puts the fill character back in the last place typed and moves the cursor onto it. Register Pair HL (the buffer) goes back one byte and Register B (the places left) up one. Returns the Z FLAG when nothing was typed: Register B equal to Register C (the width).
599E
LD A,B 78
Copy Register B (the places left) into Register A.
599F
CP C B9
Compare Register A against Register C (the width): the Z FLAG when nothing was typed.
59A0
RET Z C8
If the Z FLAG is set (nothing to erase), RETurn to the caller with the Z FLAG set.
59A1
LD A,0FH 3E 0F
Load Register A with 0FH, the code that turns the cursor off.
59A3
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
59A6
GOSUB to 5A04H to move the cursor one place to the left, onto the last character typed.
59A9
GOSUB to 5A27H to display the fill character over it.
59AC
GOSUB to 5A04H to move the cursor back onto that place.
59AF
DEC HL 2B
DECrement Register Pair HL, the pointer in the line buffer.
59B0
INC B 04
INCrement Register B, the places left: never zero, so the NZ FLAG is set.
59B1
RET C9
RETurn to the caller with the NZ FLAG set: a character was erased.
59B2H - Take a Printable Character
Keys from 80H up are ignored, and so is any key when the field is full. A field of digits (bit 7 of the code) takes 0-9 and the characters minus, point and plus. The character goes into the buffer and on the screen; a field with bit 6 set ends when its last place is filled.
59B2
CP 80H FE 80
Compare Register A (the key) against 80H: NO CARRY for 80H and up.
59B4
If the NO CARRY FLAG is set, JUMP to 5979H: the key is ignored.
59B6
INC B 04
INCrement Register B (the places left), with the DEC next to set the flags.
59B7
DEC B 05
DECrement Register B back: the Z FLAG when the field is full.
59B8
If the Z FLAG is set (no place left), JUMP to 5979H: the key is ignored.
59BA
POP DE D1
Copy the field's width and code from the stack (POP DE) into Register Pair DE.
59BB
PUSH DE D5
Save Register Pair DE (the width and code) to the stack again, as it was.
59BC
BIT 7,E CB 7B
Test bit 7 of Register E (the field's code): the Z FLAG for any character.
59BE
If the Z FLAG is set (any character), JUMP to 59D4H to take it.
59C0
CP 3AH FE 3A
Compare Register A (the key) against 3AH, the character after 9.
59C2
If the NO CARRY FLAG is set (above 9), JUMP to 5979H: the key is ignored.
59C4
CP 30H FE 30
Compare Register A (the key) against 30H, the digit 0.
59C6
If the NO CARRY FLAG is set (0-9), JUMP to 59D4H to take it.
59C8
CP 2DH FE 2D
Compare Register A (the key) against 2DH, the minus sign.
59CA
If the Z FLAG is set (the minus sign), JUMP to 59D4H to take it.
59CC
CP 2EH FE 2E
Compare Register A (the key) against 2EH, the decimal point.
59CE
If the Z FLAG is set (the point), JUMP to 59D4H to take it.
59D0
CP 2BH FE 2B
Compare Register A (the key) against 2BH, the plus sign.
59D2
If the NZ FLAG is set (any other character), JUMP to 5979H: the key is ignored.
59D4
LD (HL),A 77
Store Register A (the character) at Register Pair HL, the line buffer.
59D5
GOSUB to 0033H, the ROM: Register A (the character) is displayed over the fill character.
59D8
INC HL 23
INCrement Register Pair HL to the next byte of the line buffer.
59D9
DECrement Register B (the places left) and JUMP to 5979H while places are left.
59DB
POP DE D1
Copy the field's width and code from the stack (POP DE) into Register Pair DE.
59DC
PUSH DE D5
Save Register Pair DE (the width and code) to the stack again, as it was.
59DD
BIT 6,E CB 73
Test bit 6 of Register E (the field's code): the NZ FLAG when a full field ends.
59DF
If the Z FLAG is set (no asterisk), JUMP to 5979H: the field waits for ENTER.
59E1
CP A BF
Compare Register A with itself (CP A): the Z FLAG set, the CARRY FLAG clear, then on to 59E2H.
59E2H - End the Field
Reached on ENTER (5987H), BREAK (598BH, the CARRY FLAG set) and a full field (59E1H). The cursor goes off, the places not typed are blanked with spaces, the ROM's column (40A6H) is set from the cursor, and Register B becomes the number of characters typed.
59E2
POP DE D1
Discard the field's width and code saved at 5977H (POP DE into Register Pair DE).
59E3
PUSH AF F5
Save Register Pair AF (the CARRY FLAG of BREAK) to the stack.
59E4
PUSH BC C5
Save Register Pair BC (Register B = the places left, Register C = the width) to the stack.
59E5
LD A,0FH 3E 0F
Load Register A with 0FH, the code that turns the cursor off.
59E7
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
59EA
INC B 04
INCrement Register B (the places left), with the DEC next to set the flags.
59EB
DEC B 05
DECrement Register B back: the Z FLAG when no place is left.
59EC
If the Z FLAG is set (the field is full), JUMP to 59F5H.
59EE
LD A,20H 3E 20
Load Register A with 20H, a space, to blank a place not typed.
59F0
GOSUB to 0033H, the ROM: Register A (the space) is displayed.
59F3
DECrement Register B and LOOP BACK to 59EEH until every place left is blank.
59F5
POP BC C1
Restore Register Pair BC (the places left and the width) from the stack.
59F6
LD A,(4020H) 3A 20 40
Load Register A with the low byte of the cursor's address from 4020H.
59F9
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the column of the cursor, 0-63.
59FB
LD (40A6H),A 32 A6 40
Store Register A (the column) at 40A6H, the ROM's cursor column.
59FE
LD A,C 79
Copy Register C (the width of the field) into Register A.
59FF
SUB B 90
SUBtract Register B (the places left) from Register A: the characters typed.
5A00
LD B,A 47
Copy Register A (the characters typed) into Register B for 5951H.
5A01
POP AF F1
Restore Register Pair AF (the CARRY FLAG of BREAK) from the stack.
5A02
POP HL E1
Restore Register Pair HL (the line buffer) from the stack.
5A03
RET C9
RETurn to 594FH with Register B = the characters typed and the CARRY FLAG for BREAK.
5A04H - Cursor Left
Sends 18H (backspace) to the display. When the cursor is at the left edge of a line, 5A1BH first moves the cursor's address in 4020H up one line; in the wide character mode (bit 3 of 403DH) the place before is tested too, as each character there takes two places.
5A04
PUSH HL E5
Save Register Pair HL (the pointer in the line buffer) to the stack.
5A05
LD HL,(4020H) 2A 20 40
Load Register Pair HL with the cursor's address from 4020H-4021H.
5A08
GOSUB to 5A1BH: at the left edge the cursor's address in 4020H goes up a line.
5A0B
DEC HL 2B
DECrement Register Pair HL to the place before the cursor.
5A0C
LD A,(403DH) 3A 3D 40
Load Register A with 403DH, the copy of what was last sent to port FFH.
5A0F
AND 08H E6 08
Mask Register A to bit 3 (AND 08H): the wide character mode.
5A11
If the NZ FLAG is set (wide characters), GOSUB to 5A1BH to test the place before as well.
5A14
LD A,18H 3E 18
Load Register A with 18H, the display code for backspace.
5A16
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
5A19
POP HL E1
Restore Register Pair HL (the pointer in the line buffer) from the stack.
5A1A
RET C9
RETurn to the caller with the cursor one place to the left.
5A1BH - Cursor Up at the Left Edge
5A1BH: if Register Pair HL is at column 0, 4020H gets Register Pair HL less 40H (64), one line up. 5A22H is entered from 58A8H by INPUT@: 4020H gets Register Pair HL + Register Pair DE.
5A1B
LD A,L 7D
Copy Register L (the low byte of the address) into Register A.
5A1C
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the Z FLAG for column 0.
5A1E
RET NZ C0
If the NZ FLAG is set (not at the left edge), RETurn to the caller.
5A1F
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 40H: one line of 64 characters back.
5A22
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the new address of the cursor.
5A23
LD (4020H),HL 22 20 40
Store Register Pair HL (the cursor's address) at 4020H-4021H, the display's cursor.
5A26
RET C9
RETurn to the caller with the new cursor address in Register Pair HL.
5A27H - Display the Fill Character
Register A gets the fill character that 5967H stored in the operand at 5A28H, and it is displayed (0033H).
5A27
LD A,5FH 3E 5F
Load Register A with the fill character, the operand at 5A28H (5FH in the file, stored by 5967H).
5A29
JUMP to 0033H, the ROM: Register A (the character) is displayed and the ROM RETurns to the caller.
5A2CH - INPUT and LIST With a File
Vector 47 (41DFH), CALLed by the ROM at 2278H (the end of INPUT and READ) and at 2B44H (LIST). With no current file (65F8H = 0000H) the ROM goes on. With one, INPUT skips the ROM's Extra ignored message (227BH) and goes on at 2282H; LIST (a SAVE with A) skips the ROM's test of the keyboard (CALL 1D9BH at 2B47H) and goes on at 2B4AH.
5A2C
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5A2D
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5A30
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5A31
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5A32
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5A33
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM.
5A34
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = the ROM's return address, the stack = the text pointer.
5A35
PUSH DE D5
Save Register Pair DE to the stack across the comparison.
5A36
LD DE,2B2EH 11 2E 2B
Load Register Pair DE with 2B2EH, an address in the ROM between the two callers.
5A39
RST 18H DF
RST 18H: compare Register Pair HL (the return address) against Register Pair DE; CARRY for 227BH, the end of INPUT.
5A3A
POP DE D1
Restore Register Pair DE from the stack after the comparison.
5A3B
POP HL E1
Restore Register Pair HL (the text pointer) from the stack; the return address is dropped.
5A3C
If the NO CARRY FLAG is set (LIST), JUMP to 2B4AH, the ROM's LIST past its test of the keyboard.
5A3F
JUMP to 2282H, the ROM's end of INPUT and READ, past its Extra ignored message.
5A42H - Error Messages
Vector 28 (41A6H), CALLed by the ROM's error handler with Register E = the error's E value. If 65F4H holds D6H (a RUN with V whose variables are parked, 5F50H), 5F83H puts 40A0H and the stack back, clears 65F4H and starts the program (5FB1H); it never comes back. Else BASIC/OV3 function 01H puts the message's text in Register Pair HL; it is displayed, 63EDH makes the protection test, and the ROM at 1A11H adds IN and the line number.
5A42
POP HL E1
Discard the ROM's return address (POP HL into Register Pair HL).
5A43
LD A,(65F4H) 3A F4 65
Load Register A with the run state byte at 65F4H (D6H for a RUN with V).
5A46
CP D6H FE D6
Compare Register A against D6H: the Z FLAG when a RUN with V has its variables parked.
5A48
If the NZ FLAG is set, JUMP to 5A4EH for the message.
5A4A
GOSUB to 5F83H: 40A0H, 40E8H and the stack are put back, 65F4H cleared and the program started at 5FB1H. This call never RETurns.
5A4D
LD SP,HL F9
Load the Stack Pointer from Register Pair HL. Never reached: the call at 5A4AH does not RETurn.
5A4E
LD L,E 6B
Copy Register E (the error's E value) into Register L for BASIC/OV3.
5A4F
LD A,01H 3E 01
Load Register A with 01H, BASIC/OV3's function for an error message.
5A51
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number in Register A' for 54B6H.
5A52
GOSUB to 54B6H to load and enter BASIC/OV3: Register Pair HL = the message's text.
5A55
GOSUB to 28A7H, the ROM: the text at Register Pair HL is displayed.
5A58
LD HL,(40EAH) 2A EA 40
Load Register Pair HL with 40EAH-40EBH, the line number of the error.
5A5B
GOSUB to 63EDH, the protection test (it RETurns with Register Pair HL unchanged unless memory was cleared).
5A5E
JP 1A11H C3 11 1A
JUMP to 1A11H, the ROM's error handler after its message: IN and the line number unless Register Pair HL is FFFFH (a line typed at READY).
5A61H - TIME$
Vector 12 (4176H). Makes a string of 11H (17) characters: the date from 4470H (8 characters), a space, and the time from 446DH (8 characters).
5A61
RST 10H D7
RST 10H (6579H): Register Pair HL past TIME$ and Register A = the next character.
5A62
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5A63
LD A,11H 3E 11
Load Register A with 11H, the length of the string: 17 characters.
5A65
GOSUB to 2857H, the ROM: space for a string of Register A characters; its descriptor at 40D3H.
5A68
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the string's address from 40D4H-40D5H.
5A6B
GOSUB to 4470H, @DATE: the date in 8 characters at Register Pair HL, which ends after it.
5A6E
LD (HL),20H 36 20
Store 20H, a space, at Register Pair HL, between the date and the time.
5A70
INC HL 23
INCrement Register Pair HL past the space, to the place of the time.
5A71
GOSUB to 446DH, @TIME: the time in 8 characters at Register Pair HL.
5A74
JUMP to 2884H, the ROM: the string's descriptor goes on the stack of strings and is the result.
5A77H - INSTR
Vector 25 (419DH): INSTR([n,]a$,b$) is the position of b$ in a$, the search starting at character n (1-255, 1 if left out). It is 0 when n is past the end of a$, a$ is empty, or b$ is not found; n when b$ is empty. The result goes through the ROM at 27F8H (an integer from Register A) and 26E7H (the text pointer back).
5A77
RST 10H D7
RST 10H (6579H): Register Pair HL past INSTR and Register A = the next character.
5A78
GOSUB to 2335H, the ROM: a left parenthesis must come, then the first expression is evaluated.
5A7B
RST 20H E7
RST 20H: the type of the result; the Z FLAG for a string.
5A7C
LD A,01H 3E 01
Load Register A with 01H, the start when n is left out; LD does not change the flags.
5A7E
PUSH AF F5
Save Register Pair AF (Register A = the start, 01H) to the stack.
5A7F
If the Z FLAG is set (a string: no n), JUMP to 5A92H with the start 01H on the stack.
5A81
POP AF F1
Discard the start 01H (POP AF into Register Pair AF): n was given.
5A82
GOSUB to 2B1FH, the ROM: the number n as a byte in Register A (0-255).
5A85
AND A A7
Set the flags from Register A (AND A): the Z FLAG for n = 0.
5A86
If the Z FLAG is set (n = 0), JUMP to 1E4AH, the ROM's Illegal function call.
5A89
PUSH AF F5
Save Register Pair AF (Register A = the start, n) to the stack.
5A8A
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before a$.
5A8C
GOSUB to 2337H, the ROM: evaluate the expression a$.
5A8F
GOSUB to 0AF4H, the ROM: Type mismatch unless the result is a string.
5A92
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before b$.
5A94
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5A95
LD HL,(4121H) 2A 21 41
Load Register Pair HL with a$'s descriptor address from 4121H-4122H.
5A98
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): the stack = a$'s descriptor, Register Pair HL = the text pointer.
5A99
GOSUB to 2337H, the ROM: evaluate the expression b$.
5A9C
RST 08H => 29H CF 29
RST 08H with the byte 29H: a right parenthesis must end INSTR.
5A9E
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5A9F
GOSUB to 29D7H, the ROM: b$ must be a string, its temporary freed; Register Pair HL = its descriptor.
5AA2
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = b$'s descriptor.
5AA3
POP BC C1
Restore Register Pair BC (the text pointer) from the stack.
5AA4
POP HL E1
Restore Register Pair HL (a$'s descriptor) from the stack.
5AA5
POP AF F1
Restore Register Pair AF (Register A = the start) from the stack.
5AA6
PUSH BC C5
Save Register Pair BC (the text pointer) to the stack, for 26E7H.
5AA7
LD BC,26E7H 01 E7 26
Load Register Pair BC with 26E7H, the ROM's POP HL and RET: the text pointer back.
5AAA
PUSH BC C5
Save Register Pair BC (26E7H) to the stack, a return address.
5AAB
LD BC,27F8H 01 F8 27
Load Register Pair BC with 27F8H, the ROM: Register A as an integer result.
5AAE
PUSH BC C5
Save Register Pair BC (27F8H) to the stack: the RETurns below go there with the result in Register A.
5AAF
PUSH AF F5
Save Register Pair AF (Register A = the start) to the stack.
5AB0
PUSH DE D5
Save Register Pair DE (b$'s descriptor) to the stack.
5AB1
GOSUB to 29DDH, the ROM: a$'s temporary is freed; Register Pair HL = its descriptor.
5AB4
POP DE D1
Restore Register Pair DE (b$'s descriptor) from the stack.
5AB5
POP AF F1
Restore Register Pair AF (Register A = the start) from the stack.
5AB6
LD B,A 47
Copy Register A (the start, 1-255) into Register B for 5AC2H.
5AB7
DEC A 3D
DECrement Register A: the start less 1, the characters to skip.
5AB8
LD C,A 4F
Copy Register A (the characters to skip) into Register C.
5AB9
CP (HL) BE
Compare Register A against a$'s length at Register Pair HL: NO CARRY when the start is past the end.
5ABA
LD A,00H 3E 00
Load Register A with 00H, the result for not found; LD does not change the flags.
5ABC
RET NC D0
If the NO CARRY FLAG is set (the start is past the end of a$), RETurn the result 0.
5ABD
LD A,(HL) 7E
Load Register A with a$'s length at Register Pair HL.
5ABE
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty a$.
5ABF
RET Z C8
If the Z FLAG is set (a$ is empty), RETurn the result 0 in Register A.
5AC0
LD A,(DE) 1A
Load Register A with b$'s length at Register Pair DE.
5AC1
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty b$.
5AC2
LD A,B 78
Copy Register B (the start) into Register A; LD does not change the flags.
5AC3
RET Z C8
If the Z FLAG is set (b$ is empty), RETurn the start as the result in Register A.
5AC4
LD A,(HL) 7E
Load Register A with a$'s length at Register Pair HL.
5AC5
INC HL 23
INCrement Register Pair HL to the low byte of a$'s address.
5AC6
LD B,(HL) 46
Load Register B with the low byte of a$'s address at Register Pair HL.
5AC7
INC HL 23
INCrement Register Pair HL to the high byte of a$'s address.
5AC8
LD H,(HL) 66
Load Register H with the high byte of a$'s address at Register Pair HL.
5AC9
LD L,B 68
Copy Register B (the low byte) into Register L: Register Pair HL = a$'s text.
5ACA
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the characters to skip.
5ACC
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the character of a$ at the start.
5ACD
SUB C 91
SUBtract Register C (the characters skipped) from Register A (a$'s length): the characters left.
5ACE
LD B,A 47
Copy Register A (the characters left in a$) into Register B.
5ACF
PUSH BC C5
Save Register Pair BC (Register B = the characters left, Register C = those skipped) to the stack.
5AD0
PUSH DE D5
Save Register Pair DE (b$'s descriptor) to the stack.
5AD1
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = b$'s descriptor, the stack = the place in a$.
5AD2
LD C,(HL) 4E
Load Register C with b$'s length at Register Pair HL.
5AD3
INC HL 23
INCrement Register Pair HL to the low byte of b$'s address.
5AD4
LD E,(HL) 5E
Load Register E with the low byte of b$'s address at Register Pair HL.
5AD5
INC HL 23
INCrement Register Pair HL to the high byte of b$'s address.
5AD6
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = b$'s text.
5AD7
POP HL E1
Restore Register Pair HL (the place in a$) from the stack.
5AD8
PUSH HL E5
Save Register Pair HL (the place in a$ being tried) to the stack: the top of the search loop.
5AD9
PUSH DE D5
Save Register Pair DE (b$'s text) to the stack.
5ADA
PUSH BC C5
Save Register Pair BC (Register B = the characters left in a$, Register C = b$'s length) to the stack.
5ADB
LD A,(DE) 1A
Load Register A with the character of b$ at Register Pair DE.
5ADC
CP (HL) BE
Compare Register A against the character of a$ at Register Pair HL.
5ADD
If the NZ FLAG is set (they differ), JUMP to 5AF6H to try the next place in a$.
5ADF
INC DE 13
INCrement Register Pair DE to the next character of b$.
5AE0
DEC C 0D
DECrement Register C, the characters of b$ left to match.
5AE1
If the Z FLAG is set (all of b$ matched), JUMP to 5AEDH for the position.
5AE3
INC HL 23
INCrement Register Pair HL to the next character of a$.
5AE4
DEC B 05
DECrement Register B, the characters left in a$.
5AE5
If the NZ FLAG is set (a$ has more), LOOP BACK to 5ADBH to match the next character.
5AE7
POP DE D1
Discard the saved counts (POP DE into Register Pair DE): a$ ended in the middle of b$.
5AE8
POP DE D1
Discard b$'s text pointer (POP DE into Register Pair DE).
5AE9
POP BC C1
Discard the place in a$ (POP BC into Register Pair BC).
5AEA
POP DE D1
Discard the counts saved at 5ACFH (POP DE into Register Pair DE).
5AEB
XOR A AF
Load Register A with 00H (XOR A): the result for not found.
5AEC
RET C9
RETurn the result 0 in Register A through the ROM at 27F8H.
5AED
POP HL E1
Restore into Register Pair HL the counts of the place tried: Register H = the characters of a$ left there.
5AEE
POP DE D1
Discard b$'s text pointer (POP DE into Register Pair DE).
5AEF
POP DE D1
Discard the place in a$ (POP DE into Register Pair DE).
5AF0
POP BC C1
Restore Register Pair BC (Register B = the characters left at the start, Register C = those skipped).
5AF1
LD A,B 78
Copy Register B (the characters left at the start) into Register A.
5AF2
SUB H 94
SUBtract Register H (those left at the match) from Register A: the characters passed over in the search.
5AF3
ADD A,C 81
ADD Register C (the characters skipped before the start) to Register A.
5AF4
INC A 3C
INCrement Register A: the position of b$ in a$, counting from 1.
5AF5
RET C9
RETurn the position in Register A through 27F8H.
5AF6
POP BC C1
Restore Register Pair BC (Register B = the characters left, Register C = b$'s length) from the stack.
5AF7
POP DE D1
Restore Register Pair DE (b$'s text) from the stack.
5AF8
POP HL E1
Restore Register Pair HL (the place in a$ tried) from the stack.
5AF9
INC HL 23
INCrement Register Pair HL to the next place in a$.
5AFA
DEC B 05
DECrement Register B, the characters left in a$.
5AFB
If the Z FLAG is set (no place left), JUMP to 5AEAH: the result 0.
5AFD
JUMP to 5AD8H to try b$ at the next place in a$.
5AFFH - &
Vector 22 (4194H), the constants &H (hexadecimal, at most 4 digits) and &O or & alone (octal) as an integer in the accumulator. A fifth hexadecimal digit or an octal value past FFFFH is the ROM's Overflow (07B2H); a digit 8 or 9 in an octal number is a Syntax error.
5AFF
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value so far.
5B02
RST 10H D7
RST 10H (6579H): Register Pair HL past the & and Register A = the next character.
5B03
CP 4FH FE 4F
Compare Register A against 4FH, the letter O: octal.
5B05
If the Z FLAG is set (&O), JUMP to 5B2FH for the octal digits.
5B07
CP 48H FE 48
Compare Register A against 48H, the letter H: hexadecimal.
5B09
If the NZ FLAG is set (& and a digit), JUMP to 5B2EH: octal, the character read again.
5B0B
LD B,05H 06 05
Load Register B with 05H: at most 4 hexadecimal digits, the fifth is an overflow.
5B0D
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character and Register A = it.
5B0E
NOP 00
No operation (NOP): Register A and the flags from the RST 10H are kept.
5B0F
GOSUB to 1E3EH, the ROM: the CARRY FLAG unless Register A is a letter A-Z.
5B12
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the value, Register Pair DE = the text pointer.
5B13
If the NO CARRY FLAG is set (a letter), JUMP to 5B1BH.
5B15
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9.
5B17
If the NO CARRY FLAG is set (not a digit), JUMP to 5B4BH: the number ends.
5B19
ADD A,07H C6 07
ADD 07H to Register A, with the SUB 37H next: a digit less 30H.
5B1B
SUB 37H D6 37
SUBtract 37H from Register A: A-F become 0AH-0FH, digits 00H-09H.
5B1D
CP 10H FE 10
Compare Register A against 10H: NO CARRY for a character that is not a hexadecimal digit.
5B1F
If the NO CARRY FLAG is set, JUMP to 5B4BH: the number ends.
5B21
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
5B22
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
5B23
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 8.
5B24
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 16.
5B25
OR L B5
OR Register L into Register A: the new digit in the low 4 bits.
5B26
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the value with the new digit.
5B27
DEC B 05
DECrement Register B, the hexadecimal digits still allowed.
5B28
If the Z FLAG is set (a fifth digit), JUMP to 07B2H, the ROM's Overflow.
5B2B
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the value, Register Pair HL = the text pointer.
5B2C
JUMP to 5B0DH for the next hexadecimal digit.
5B2E
DEC HL 2B
DECrement Register Pair HL back to the & so the RST 10H next reads the digit again.
5B2F
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character and Register A = it; CARRY for a digit.
5B30
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the value, Register Pair DE = the text pointer.
5B31
If the NO CARRY FLAG is set (not a digit), JUMP to 5B4BH: the number ends.
5B33
CP 38H FE 38
Compare Register A against 38H, the digit 8: NO CARRY for 8 or 9.
5B35
If the NO CARRY FLAG is set, JUMP to 1997H, the ROM's Syntax error.
5B38
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
5B39
If the CARRY FLAG is set (past FFFFH), JUMP to 5B3FH for the Overflow.
5B3B
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
5B3C
If the CARRY FLAG is set (past FFFFH), JUMP to 5B3FH for the Overflow.
5B3E
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 8.
5B3F
If the CARRY FLAG is set (past FFFFH), JUMP to 07B2H, the ROM's Overflow.
5B42
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit.
5B44
SUB 30H D6 30
SUBtract 30H from Register A: the octal digit, 0-7, as a number.
5B46
LD C,A 4F
Copy Register A (the digit) into Register C: Register Pair BC = the digit.
5B47
ADD HL,BC 09
ADD Register Pair BC (the digit) to Register Pair HL (the value times 8).
5B48
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the value, Register Pair HL = the text pointer.
5B49
JUMP to 5B2FH for the next octal digit of the constant.
5B4B
GOSUB to 0A9AH, the ROM: the accumulator = Register Pair HL, an integer.
5B4E
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the text pointer again.
5B4F
RET C9
RETurn to the ROM with the integer in the accumulator.
5B50H - MID$ =
Vector 45 (41D9H), reached by the ROM's JP at 2AECH for MID$(v$,p[,n]) = x$. A string still in the program text (below 40A0H) is first copied to string space (2843H, 09D3H), so the program is not changed. Then at most n characters of x$ (all of it if n is left out, E = FFH) go over v$ from position p, never past v$'s end; v$'s length is not changed. A p past v$'s end is the ROM's Illegal function call.
5B50
INC HL 23
INCrement Register Pair HL past the MID$ token.
5B51
RST 08H => 28H CF 28
RST 08H with the byte 28H: a left parenthesis must come.
5B53
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable v$.
5B56
GOSUB to 0AF4H, the ROM: Type mismatch unless v$ is a string.
5B59
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5B5A
PUSH DE D5
Save Register Pair DE (v$'s descriptor) to the stack.
5B5B
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = v$'s descriptor.
5B5C
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
5B5D
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
5B5E
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
5B5F
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = v$'s text.
5B60
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with 40A0H-40A1H, the start of string space.
5B63
RST 18H DF
RST 18H: compare Register Pair HL (string space) against Register Pair DE (v$'s text); CARRY when v$ is in string space.
5B64
If the CARRY FLAG is set (in string space), JUMP to 5B70H.
5B66
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
5B67
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack again.
5B68
GOSUB to 2843H, the ROM: a copy of v$ is made in string space, its new descriptor at Register Pair DE.
5B6B
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
5B6C
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack again.
5B6D
GOSUB to 09D3H, the ROM: the new descriptor at Register Pair DE is copied over v$'s at Register Pair HL.
5B70
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
5B71
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): the stack = v$'s descriptor, Register Pair HL = the text pointer.
5B72
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the position.
5B74
GOSUB to 2B1CH, the ROM: the position p as a byte in Register A.
5B77
AND A A7
Set the flags from Register A (AND A): the Z FLAG for p = 0.
5B78
If the Z FLAG is set (p = 0), JUMP to 1E4AH, the ROM's Illegal function call.
5B7B
PUSH AF F5
Save Register Pair AF (Register A = the position p) to the stack.
5B7C
LD A,(HL) 7E
Load Register A with the character after p at Register Pair HL.
5B7D
GOSUB to 5BC3H for the count n and the right parenthesis: Register E = n, FFH if left out.
5B80
PUSH DE D5
Save Register Pair DE (Register E = the count n) to the stack.
5B81
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: it must come next.
5B83
GOSUB to 2337H, the ROM: evaluate the expression x$.
5B86
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5B87
GOSUB to 29D7H, the ROM: x$ must be a string, its temporary freed; Register Pair HL = its descriptor.
5B8A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = x$'s descriptor.
5B8B
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5B8C
POP BC C1
Restore Register Pair BC (Register C = the count n) from the stack.
5B8D
POP AF F1
Restore Register Pair AF (Register A = the position p) from the stack.
5B8E
LD B,A 47
Copy Register A (the position p) into Register B.
5B8F
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): the stack = the text pointer, Register Pair HL = v$'s descriptor.
5B90
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
5B91
LD HL,26E7H 21 E7 26
Load Register Pair HL with 26E7H, the ROM's POP HL and RET: the text pointer back.
5B94
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): 26E7H is the return address, Register Pair HL = v$'s descriptor.
5B95
LD A,C 79
Copy Register C (the count n) into Register A.
5B96
AND A A7
Set the flags from Register A (AND A): the Z FLAG for n = 0.
5B97
RET Z C8
If the Z FLAG is set (n = 0, nothing to do), RETurn through 26E7H.
5B98
LD A,(HL) 7E
Load Register A with v$'s length at Register Pair HL.
5B99
SUB B 90
SUBtract Register B (the position p) from Register A: CARRY when p is past v$'s end.
5B9A
If the CARRY FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
5B9D
INC A 3C
INCrement Register A: the characters of v$ from p to its end.
5B9E
CP C B9
Compare Register A against Register C (the count n): CARRY when fewer than n.
5B9F
If the CARRY FLAG is set, JUMP to 5BA2H: the count is the characters to v$'s end.
5BA1
LD A,C 79
Copy Register C (the count n) into Register A.
5BA2
LD C,B 48
Copy Register B (the position p) into Register C.
5BA3
DEC C 0D
DECrement Register C: p less 1, the offset in v$.
5BA4
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the offset.
5BA6
PUSH DE D5
Save Register Pair DE (x$'s descriptor) to the stack.
5BA7
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
5BA8
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
5BA9
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
5BAA
LD H,(HL) 66
Load Register H with the high byte of v$'s address at Register Pair HL.
5BAB
LD L,E 6B
Copy Register E (the low byte) into Register L: Register Pair HL = v$'s text.
5BAC
ADD HL,BC 09
ADD Register Pair BC (the offset) to Register Pair HL: the place in v$ at p.
5BAD
LD B,A 47
Copy Register A (the characters to replace) into Register B.
5BAE
POP DE D1
Restore Register Pair DE (x$'s descriptor) from the stack.
5BAF
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = x$'s descriptor, Register Pair DE = the place in v$.
5BB0
LD C,(HL) 4E
Load Register C with x$'s length at Register Pair HL.
5BB1
INC HL 23
INCrement Register Pair HL to the low byte of x$'s address.
5BB2
LD A,(HL) 7E
Load Register A with the low byte of x$'s address at Register Pair HL.
5BB3
INC HL 23
INCrement Register Pair HL to the high byte of x$'s address.
5BB4
LD H,(HL) 66
Load Register H with the high byte of x$'s address at Register Pair HL.
5BB5
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = x$'s text.
5BB6
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = x$'s text, Register Pair HL = the place in v$.
5BB7
LD A,C 79
Copy Register C (x$'s length) into Register A.
5BB8
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty x$.
5BB9
RET Z C8
If the Z FLAG is set (x$ is empty), RETurn through 26E7H.
5BBA
LD A,(DE) 1A
Load Register A with a character of x$ at Register Pair DE.
5BBB
LD (HL),A 77
Store Register A at Register Pair HL, over the character of v$.
5BBC
INC DE 13
INCrement Register Pair DE to the next character of x$.
5BBD
INC HL 23
INCrement Register Pair HL to the next character of v$.
5BBE
DEC C 0D
DECrement Register C, the characters of x$ left.
5BBF
RET Z C8
If the Z FLAG is set (x$ is used up), RETurn through 26E7H.
5BC0
DECrement Register B (the characters of v$ left to replace) and LOOP BACK to 5BBAH.
5BC2
RET C9
RETurn through the ROM at 26E7H: the characters of v$ are replaced.
5BC3H - Optional Count
For MID$ =: with Register A = the character at Register Pair HL, a right parenthesis leaves Register E = FFH; else a comma and a byte (2B1CH) give Register E. The right parenthesis must follow.
5BC3
LD E,FFH 1E FF
Load Register E with FFH, the count when it is left out.
5BC5
CP 29H FE 29
Compare Register A against 29H, the right parenthesis.
5BC7
If the Z FLAG is set (no count), JUMP to 5BCEH.
5BC9
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the count.
5BCB
GOSUB to 2B1CH, the ROM: the count as a byte in Register A and Register E.
5BCE
RST 08H => 29H CF 29
RST 08H with the byte 29H: a right parenthesis must come.
5BD0
RET C9
RETurn to 5B80H with Register E = the count n (FFH if left out).
5BD1H - Line Input From a File
Vector 31 (41AFH), CALLed by the ROM's line input at 0368H. With no current file the keyboard line input at 6459H takes over. With one, up to 240 (F0H) bytes are read through 0384H (the keyboard exit 5C0EH then reads the file) into the line buffer up to a 0DH, which becomes 00H; a 0AH as the first byte is dropped. It RETurns past the ROM's line input with Register Pair HL at the byte before the buffer and the CARRY FLAG clear.
5BD1
PUSH HL E5
Save Register Pair HL to the stack across the test for a current file.
5BD2
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5BD5
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5BD6
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5BD7
POP HL E1
Restore Register Pair HL from the stack; POP does not change the flags.
5BD8
If the Z FLAG is set (no current file), JUMP to 6459H for a line from the keyboard.
5BDB
POP AF F1
Discard the ROM's return address 036BH (POP AF into Register Pair AF): this RETurns to the ROM's caller.
5BDC
PUSH BC C5
Save Register Pair BC to the stack while the line is read.
5BDD
PUSH DE D5
Save Register Pair DE to the stack while the line is read.
5BDE
LD B,F0H 06 F0
Load Register B with F0H, the longest line: 240 bytes.
5BE0
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5BE3
GOSUB to 0384H, the ROM: wait for a key, here the next byte of the file, in Register A.
5BE6
LD (HL),A 77
Store Register A (the byte) at Register Pair HL in the line buffer.
5BE7
CP 0DH FE 0D
Compare Register A against 0DH, the end of a line.
5BE9
If the Z FLAG is set (the end of the line), JUMP to 5BF7H.
5BEB
CP 0AH FE 0A
Compare Register A against 0AH, a line feed, kept unless it comes first.
5BED
If the NZ FLAG is set (any other byte), JUMP to 5BF4H to keep it.
5BEF
LD A,B 78
Copy Register B (the bytes left) into Register A.
5BF0
CP F0H FE F0
Compare Register A against F0H: the Z FLAG when the line feed is the first byte.
5BF2
If the Z FLAG is set, JUMP to 5BE3H: the first line feed is dropped (the next byte goes over it).
5BF4
INC HL 23
INCrement Register Pair HL to the next byte of the line buffer.
5BF5
DECrement Register B (the bytes left) and LOOP BACK to 5BE3H while room is left.
5BF7
XOR A AF
Load Register A with 00H (XOR A), clearing the CARRY FLAG: no BREAK.
5BF8
LD (HL),A 77
Store Register A (00H) at Register Pair HL: the end of the line, over the 0DH.
5BF9
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
5BFA
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
5BFB
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5BFE
DEC HL 2B
DECrement Register Pair HL to the byte before the line, as the ROM's line input returns it.
5BFF
RET C9
RETurn to the caller of the ROM's line input with the line in the buffer.
5C00H - Byte Output to a File
Vector 37 (41C1H), CALLed by the ROM at 032CH with Register C = the byte to send. With no current file the ROM goes on to its devices. With one, both the ROM's return address and the Register Pair BC it saved at 032AH are taken off the stack, and 61D0H writes the byte to the file and RETurns to the ROM's caller.
5C00
PUSH HL E5
Save Register Pair HL to the stack across the test for a current file.
5C01
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5C04
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5C05
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5C06
POP HL E1
Restore Register Pair HL from the stack; POP does not change the flags.
5C07
LD A,C 79
Copy Register C (the byte to send) into Register A; LD does not change the flags.
5C08
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM at 032FH with Register A = the byte.
5C09
POP BC C1
Discard the ROM's return address 032FH (POP BC into Register Pair BC).
5C0A
POP BC C1
Restore Register Pair BC, saved by the ROM at 032AH, from the stack.
5C0B
JUMP to 61D0H to write Register A (the byte) to the current file; it RETurns to the ROM's caller.
5C0EH - Keyboard Exit
Vector 38 (41C4H), CALLed by the ROM at 0358H, the bottom of every key request. Both return addresses are taken: 035BH and the caller's. For 0384H (wait for a key, return 0387H): with no current file the ROM scans the keyboard (035BH); with one, the next byte of the file (627BH) is the key, and at the end of the file the program is RUN (a run state other than 00H) or READY is shown and 0DH given (00H), a RUN with V going to 5F54H. Other callers go to 5C53H.
5C0E
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers are kept there.
5C0F
POP HL E1
Discard the return address 035BH (POP HL into Register Pair HL).
5C10
POP HL E1
Load Register Pair HL with the return address of the caller of 0358H (POP HL).
5C11
LD DE,0387H 11 87 03
Load Register Pair DE with 0387H, the return address inside the ROM's wait for a key at 0384H.
5C14
RST 18H DF
RST 18H: compare Register Pair HL (the caller) against Register Pair DE (0387H); the Z FLAG for 0384H.
5C15
If the NZ FLAG is set (another caller), JUMP to 5C53H.
5C17
PUSH HL E5
Save Register Pair HL (0387H) to the stack as the return address again.
5C18
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5C1B
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5C1C
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5C1D
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
5C1E
If the Z FLAG is set (no current file), JUMP to 035BH, the ROM's keyboard scan past the vector.
5C21
PUSH HL E5
Save Register Pair HL to the stack for 26E7H.
5C22
GOSUB to 627BH to read a byte of the current file: NO CARRY with it in Register A, CARRY at the end of the file.
5C25
If the NO CARRY FLAG is set (a byte), JUMP to 26E7H, the ROM's POP HL and RET: the byte goes to 0387H.
5C28
LD A,(65F4H) 3A F4 65
Load Register A with the run state at 65F4H (00H LOAD, D6H RUN with V, else RUN).
5C2B
CP D6H FE D6
Compare Register A against D6H: the Z FLAG for a RUN with V.
5C2D
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with 40F9H-40FAH, the end of the program just read; LD does not change the flags.
5C30
If the Z FLAG is set (RUN with V), JUMP to 5F54H to bring the variables back.
5C33
PUSH AF F5
Save Register Pair AF (Register A = the run state) to the stack.
5C34
PUSH BC C5
Save Register Pair BC to the stack across 5FC4H.
5C35
PUSH DE D5
Save Register Pair DE to the stack across 5FC4H.
5C36
GOSUB to 5FC4H, the READY exit: output back to the display and file 0 closed.
5C39
POP DE D1
Restore Register Pair DE from the stack after the READY exit.
5C3A
POP BC C1
Restore Register Pair BC from the stack after the READY exit.
5C3B
POP AF F1
Restore Register Pair AF (Register A = the run state) from the stack.
5C3C
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a plain LOAD.
5C3D
LD HL,5FB1H 21 B1 5F
Load Register Pair HL with 5FB1H, the start of the program after a load.
5C40
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): 5FB1H becomes the return address.
5C41
If the NZ FLAG is set (RUN), JUMP to 1B5DH, the ROM's RUN set up, which RETurns to 5FB1H to start the program.
5C44
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): the saved Register Pair HL back on top.
5C45
PUSH BC C5
Save Register Pair BC to the stack across the message.
5C46
PUSH DE D5
Save Register Pair DE to the stack across the message.
5C47
LD HL,1929H 21 29 19
Load Register Pair HL with 1929H, the ROM's READY message.
5C4A
GOSUB to 28A7H, the ROM: the text at Register Pair HL is displayed.
5C4D
POP DE D1
Restore Register Pair DE from the stack after the READY message.
5C4E
POP BC C1
Restore Register Pair BC from the stack after the READY message.
5C4F
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER: the key that ends the line.
5C51
POP HL E1
Restore Register Pair HL from the stack, the value saved at 5C21H.
5C52
RET C9
RETurn to 0387H with Register A = 0DH (ENTER).
5C53H - BREAK and Pause
The keyboard exit for every caller but 0384H. INKEY$ (return 01A8H) goes to the ROM's scan. For the others (the BREAK test at 1D9BH while a program runs) @KITSK (4300H) is called and KFLAG$ (4423H) read: BREAK gives Register A = 01H; the pause (SHIFT and @) waits for a key other than 60H, clears the flags (5C93H), and gives 01H if that key was BREAK. Else Register A = 00H, no key. Register A, as the compare of 5C14H left it, goes to 40A9H, which nothing in BASIC/CMD reads.
5C53
LD (40A9H),A 32 A9 40
Store Register A (left by the RST 18H compare at 5C14H) at 40A9H; nothing in BASIC/CMD reads it back.
5C56
LD DE,01A8H 11 A8 01
Load Register Pair DE with 01A8H, the return address of the ROM's INKEY$.
5C59
RST 18H DF
RST 18H: compare Register Pair HL (the caller) against Register Pair DE (01A8H); the Z FLAG for INKEY$.
5C5A
PUSH HL E5
Save Register Pair HL (the caller's return address) to the stack again.
5C5B
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
5C5C
If the Z FLAG is set (INKEY$), JUMP to 035BH, the ROM's keyboard scan past the vector.
5C5F
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers kept there.
5C60
GOSUB to 4300H, @KITSK, the keyboard task hook.
5C63
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
5C64
GOSUB to 5C81H: Register A = KFLAG$, the keys queued are read away, the NZ FLAG for BREAK.
5C67
If the NZ FLAG is set (BREAK), JUMP to 5C7CH to give Register A = 01H.
5C69
BIT 1,A CB 4F
Test bit 1 of Register A (KFLAG$): the pause, SHIFT and @.
5C6B
If the Z FLAG is set (no pause), JUMP to 5C7AH: Register A = 00H, no key.
5C6D
GOSUB to 0384H, the ROM: wait for a key, in Register A.
5C70
CP 60H FE 60
Compare Register A against 60H, the code of SHIFT and @.
5C72
If the Z FLAG is set (the pause again), LOOP BACK to 5C6DH to wait for another key.
5C74
GOSUB to 5C93H to clear bits 2-0 of KFLAG$ (4423H): ENTER, pause and BREAK.
5C77
DEC A 3D
DECrement Register A (the key): the Z FLAG for 01H, BREAK.
5C78
If the Z FLAG is set (BREAK), JUMP to 5C7CH to give Register A = 01H.
5C7A
XOR A AF
Load Register A with 00H (XOR A): no key, the Z FLAG set.
5C7B
RET C9
RETurn to the caller of 0358H with Register A = 00H.
5C7C
LD A,01H 3E 01
Load Register A with 01H, the code the ROM takes for BREAK.
5C7E
RET C9
RETurn to the caller of 0358H with Register A = 01H, BREAK.
5C7F
JUMP to 5C93H to clear bits 2-0 of KFLAG$: the entry CALLed at 52DAH and 55D9H.
5C81H - Read KFLAG$
Register A = KFLAG$ (4423H). When BREAK or the pause (bits 0 and 1) is set, the keys queued are read away through the ROM at 035BH until it gives 00H. RETurns the NZ FLAG for BREAK (bit 0). CALLed from 5C64H and 5822H.
5C81
LD A,(4423H) 3A 23 44
Load Register A with KFLAG$, the keyboard flags at 4423H.
5C84
PUSH AF F5
Save Register Pair AF (Register A = KFLAG$) to the stack.
5C85
AND 03H E6 03
Mask Register A to bits 1 and 0 (AND 03H): the pause and BREAK.
5C87
If the Z FLAG is set (neither), JUMP to 5C8FH.
5C89
GOSUB to 035BH, the ROM's keyboard scan past the vector: Register A = a key or 00H.
5C8C
OR A B7
Set the flags from Register A (OR A): the Z FLAG when no key is left.
5C8D
If the NZ FLAG is set (a key was read), LOOP BACK to 5C89H.
5C8F
POP AF F1
Restore Register Pair AF (Register A = KFLAG$) from the stack.
5C90
BIT 0,A CB 47
Test bit 0 of Register A (KFLAG$): the NZ FLAG for BREAK.
5C92
RET C9
RETurn to the caller with Register A = KFLAG$ and the NZ FLAG for BREAK.
5C93H - Clear the Key Flags
Clears bits 2-0 of KFLAG$ (4423H): ENTER, the pause and BREAK. Register Pair AF is kept. CALLed from 5C74H, 6472H and 651BH, and reached by the JP at 5C7FH.
5C93
PUSH AF F5
Save Register Pair AF to the stack: Register A and the flags are kept.
5C94
LD A,(4423H) 3A 23 44
Load Register A with KFLAG$, the keyboard flags at 4423H.
5C97
AND F8H E6 F8
Mask Register A with F8H (AND F8H): bits 2-0 cleared.
5C99
LD (4423H),A 32 23 44
Store Register A at 4423H, KFLAG$, with bits 2-0 now clear.
5C9C
POP AF F1
Restore Register Pair AF from the stack: Register A and the flags as on entry.
5C9D
RET C9
RETurn to the caller with KFLAG$ bits 2-0 cleared.
5C9EH - Comma and TAB to a File
Vector 43 (41D3H), CALLed by the ROM at 2108H (a comma in PRINT) and 2141H (TAB). With no current file the ROM goes on. With one, the file's column (the byte after the one 65F8H points to) is given to the ROM: at 2130H for a comma (to the next zone of 16), at 2156H for TAB.
5C9E
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5CA1
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5CA2
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5CA3
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM.
5CA4
INC HL 23
INCrement Register Pair HL to the file's column.
5CA5
LD A,(HL) 7E
Load Register A with the file's column at Register Pair HL.
5CA6
POP HL E1
Load Register Pair HL with the ROM's return address (POP HL): 210BH or 2144H.
5CA7
PUSH DE D5
Save Register Pair DE to the stack across the comparison.
5CA8
PUSH AF F5
Save Register Pair AF (Register A = the column) to the stack.
5CA9
LD DE,2130H 11 30 21
Load Register Pair DE with 2130H, between the two callers.
5CAC
RST 18H DF
RST 18H: compare Register Pair HL (the return address) against Register Pair DE; CARRY for 210BH, the comma.
5CAD
POP DE D1
Copy the column into Register D (POP DE into Register Pair DE: Register D = the column).
5CAE
LD A,D 7A
Copy Register D (the column) into Register A.
5CAF
POP DE D1
Restore Register Pair DE from the stack after the comparison.
5CB0
If the CARRY FLAG is set (a comma), JUMP to 2130H, the ROM: spaces to the next zone of 16.
5CB3
JUMP to 2156H, the ROM's TAB with Register A = the column.
5CB6H - Before CLEAR
Vector 33 (41B5H), CALLed by the ROM at 1AECH before its RUN set up (1B5DH). The current file pointer is kept at 40F3H, and file 0's slot in the pointer table (65FAH) points to 65F2H, a 00H byte, while the ROM clears.
5CB6
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5CB9
LD (40F3H),HL 22 F3 40
Store Register Pair HL (the current file) at 40F3H-40F4H to keep it.
5CBC
LD HL,65F2H 21 F2 65
Load Register Pair HL with 65F2H, a byte of 00H in the file.
5CBF
LD (65FAH),HL 22 FA 65
Store Register Pair HL (65F2H) at 65FAH-65FBH, file 0's slot in the pointer table.
5CC2
RET C9
RETurn to the ROM at 1AEFH, which CALLs its RUN set up 1B5DH.
5CC3H - After CLEAR
Vector 34 (41B8H), CALLed by the ROM at 1AF2H after its RUN set up. The current file pointer comes back from 40F3H and file 0's slot (65FAH) gets the address of buffer 0 from 661AH.
5CC3
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the current file pointer kept at 40F3H-40F4H.
5CC6
LD (65F8H),HL 22 F8 65
Store Register Pair HL at 65F8H-65F9H, the current file pointer.
5CC9
LD HL,(661AH) 2A 1A 66
Load Register Pair HL with the address of buffer 0 from 661AH-661BH.
5CCC
LD (65FAH),HL 22 FA 65
Store Register Pair HL at 65FAH-65FBH, file 0's slot in the pointer table.
5CCF
RET C9
RETurn to the ROM at 1AF5H, which JUMPs to 1A33H.
5CD0H - A Number to a File
Vector 41 (41CDH), CALLed by the ROM's PRINT at 20C6H after a number is made text. With no current file the ROM goes on. With one, the ROM's test of the line's length is skipped: 20E9H prints the text and a space.
5CD0
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5CD3
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5CD4
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5CD5
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM at 20C9H.
5CD6
POP HL E1
Discard the ROM's return address 20C9H (POP HL into Register Pair HL).
5CD7
JUMP to 20E9H, the ROM: the number's text is printed, then a space.
5CDAH - #n: Make a File Current
With Register A = the character at Register Pair HL: no # RETurns at once (the NZ FLAG). Else #n is read (5CEFH), file n must be open in the mode in Register C (01H here, input; PRINT# enters at 5CDCH from 5745H with Register C = 02H, output), a comma must follow, and 65F8H gets the file's buffer address.
5CDA
LD C,01H 0E 01
Load Register C with 01H, the mode the file must be open in: input.
5CDC
CP 23H FE 23
Compare Register A against 23H, #: a file number follows.
5CDE
RET NZ C0
If the NZ FLAG is set (no #), RETurn to the caller.
5CDF
PUSH BC C5
Save Register Pair BC (Register C = the mode wanted) to the stack.
5CE0
GOSUB to 5CEFH for the file number: Register Pair BC = its buffer, Register A = its mode (00H closed).
5CE3
POP DE D1
Restore Register Pair DE (Register E = the mode wanted) from the stack.
5CE4
CP E BB
Compare Register A (the file's mode) against Register E (the mode wanted).
5CE5
If the NZ FLAG is set (another mode or closed), JUMP to 6435H, Bad file mode (E = 6CH).
5CE8
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come after the file number.
5CEA
LD (65F8H),BC ED 43 F8 65
Store Register Pair BC (the file's buffer) at 65F8H-65F9H: the file is current.
5CEE
RET C9
RETurn to the caller with the file current and Register Pair HL past the comma.
5CEFH - The Buffer of File n
Reads a file number (an optional # and an expression, 0-255) at Register Pair HL. More than the files set aside (408EH) is Bad file number. Returns Register Pair BC = the buffer from the pointer table at 65FAH, Register A = its first byte (the mode, 00H when closed) and the Z FLAG for a closed file. 5CFCH is entered with the number in Register A.
5CEF
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
5CF0
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character and Register A = it.
5CF1
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
5CF3
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
5CF6
GOSUB to 2337H, the ROM: evaluate the expression of the file number.
5CF9
GOSUB to 2B1FH, the ROM: the number as a byte in Register A (0-255).
5CFC
LD E,A 5F
Copy Register A (the file number) into Register E.
5CFD
LD A,(408EH) 3A 8E 40
Load Register A with the number of files set aside from 408EH.
5D00
CP E BB
Compare Register A against Register E (the file number): CARRY when the number is larger.
5D01
If the CARRY FLAG is set, JUMP to 6438H, Bad file number (E = 68H).
5D04
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the file number.
5D06
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5D07
LD HL,65FAH 21 FA 65
Point Register Pair HL to 65FAH, the pointer table: a word for each file.
5D0A
ADD HL,DE 19
ADD Register Pair DE (the file number) to Register Pair HL.
5D0B
ADD HL,DE 19
ADD Register Pair DE again: Register Pair HL = 65FAH + 2 x the file number.
5D0C
LD C,(HL) 4E
Load Register C with the low byte of the buffer's address at Register Pair HL.
5D0D
INC HL 23
INCrement Register Pair HL to the high byte of the buffer's address.
5D0E
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the file's buffer.
5D0F
LD A,(BC) 0A
Load Register A with the first byte of the buffer at Register Pair BC, the file's mode.
5D10
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a closed file.
5D11
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5D12
RET C9
RETurn to the caller with Register Pair BC = the buffer, Register A = the mode.
5D13H - MKI$, MKS$ and MKD$
Vectors 8 (416AH), 9 (416DH) and 10 (4170H), with the argument already evaluated by the ROM. Register A = 02H (MKI$, 5D13H), 04H (MKS$, 5D16H, inside the LD BC at 5D15H) or 08H (MKD$, 5D19H, inside the LD BC at 5D18H): the number is made that type (2819H), and a string of that many bytes is made from the accumulator.
5D13
LD A,02H 3E 02
Load Register A with 02H, the length of an integer: MKI$.
5D15
LD BC,043EH 01 3E 04
Load Register Pair BC with 043EH: skipped bytes, 5D16H is LD A,04H, the entry for MKS$.
5D18
LD BC,083EH 01 3E 08
Load Register Pair BC with 083EH: skipped bytes, 5D19H is LD A,08H, the entry for MKD$.
5D1B
PUSH AF F5
Save Register Pair AF (Register A = the type and length) to the stack.
5D1C
GOSUB to 2819H, the ROM: the accumulator is made the type in Register A.
5D1F
POP AF F1
Restore Register Pair AF (Register A = the length) from the stack.
5D20
GOSUB to 2857H, the ROM: space for a string of Register A bytes; its descriptor at 40D3H.
5D23
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the string's address from 40D4H-40D5H.
5D26
GOSUB to 09FFH, the ROM: the accumulator's bytes are copied to Register Pair HL.
5D29
JUMP to 2A2BH, the ROM: a word off the stack, then the string is the result (2884H).
5D2CH - CVI, CVS and CVD
Vectors 0 (4152H), 2 (4158H) and 4 (415EH). Register A = 01H (CVI, 5D2CH), 03H (CVS, 5D2FH, inside the LD BC at 5D2EH) or 07H (CVD, 5D32H, inside the LD BC at 5D31H), one less than the bytes needed: a shorter string is Illegal function call. The type (40AFH) becomes 2, 4 or 8 and the string's first bytes are copied into the accumulator (09F7H).
5D2C
LD A,01H 3E 01
Load Register A with 01H, one less than the length of an integer: CVI.
5D2E
LD BC,033EH 01 3E 03
Load Register Pair BC with 033EH: skipped bytes, 5D2FH is LD A,03H, the entry for CVS.
5D31
LD BC,073EH 01 3E 07
Load Register Pair BC with 073EH: skipped bytes, 5D32H is LD A,07H, the entry for CVD.
5D34
PUSH AF F5
Save Register Pair AF (Register A = the length less 1) to the stack.
5D35
GOSUB to 29D7H, the ROM: the argument must be a string, its temporary freed; Register Pair HL = its descriptor.
5D38
POP AF F1
Restore Register Pair AF (Register A = the length less 1) from the stack.
5D39
CP (HL) BE
Compare Register A against the string's length at Register Pair HL: NO CARRY when the string is too short.
5D3A
If the NO CARRY FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
5D3D
INC A 3C
INCrement Register A: the type and length, 2, 4 or 8.
5D3E
INC HL 23
INCrement Register Pair HL to the low byte of the string's address.
5D3F
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
5D40
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
5D41
LD H,(HL) 66
Load Register H with the high byte of the string's address at Register Pair HL.
5D42
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the string's bytes.
5D43
LD (40AFH),A 32 AF 40
Store Register A (the type) at 40AFH, the type of the accumulator.
5D46
JUMP to 09F7H, the ROM: the bytes at Register Pair HL are copied into the accumulator.
5D49H - READ and INPUT From a File
Vector 46 (41DCH), CALLed by the ROM at 222DH for each variable of INPUT# (the variable's type in 40AFH). With no current file the ROM goes on. With one, the field is read from the file (5D71H) and the ROM's assignment at 2243H takes it. A number ends at a space or a comma (Register E = 20H, Register D = 2CH); a string at a comma (both 2CH), or at a quote when it begins with one; outside quotes a 0DH ends any field.
5D49
LD DE,(65F8H) ED 5B F8 65
Load Register Pair DE with the current file's buffer pointer from 65F8H-65F9H.
5D4D
LD A,D 7A
Copy Register D (the high byte of the pointer) into Register A.
5D4E
OR E B3
OR Register E into Register A: the Z FLAG when the pointer is 0000H, no current file.
5D4F
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM at 2230H.
5D50
POP AF F1
Discard the ROM's return address 2230H (POP AF into Register Pair AF).
5D51
RST 20H E7
RST 20H: the type of the variable; the Z FLAG for a string.
5D52
LD BC,2243H 01 43 22
Load Register Pair BC with 2243H, the ROM's assignment after INPUT takes a value.
5D55
LD DE,2C20H 11 20 2C
Load Register Pair DE with 2C20H: Register D = 2CH (a comma), Register E = 20H (a space) end a number.
5D58
If the NZ FLAG is set (a number), JUMP to 5D71H to read it.
5D5A
LD E,D 5A
Copy Register D (2CH) into Register E: a string ends only at a comma.
5D5B
JUMP to 5D71H to read the string field from the file.
5D5DH - LINE INPUT#
Reached from 5918H. File n is made current for input, the string variable found, and the whole line, up to a 0DH, read (no ends: Register Pair DE = 0000H); the ROM's assignment at 1F31H puts it in the variable and 2169H ends the statement. 5D71H is the field reader shared with INPUT#: leading spaces of a field are skipped, at most 255 bytes kept in the line buffer, 00H bytes dropped, a 0DH followed by 0AH taken as one end, and the end of the file before the field is Input past end.
5D5D
GOSUB to 5CDAH to read #n and make file n current, open for input.
5D60
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable at Register Pair HL.
5D63
GOSUB to 0AF4H, the ROM: Type mismatch unless the variable is a string.
5D66
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's end of an INPUT statement.
5D69
PUSH BC C5
Save Register Pair BC (2169H) to the stack, the last return address.
5D6A
PUSH DE D5
Save Register Pair DE (the variable's address) to the stack for 1F31H.
5D6B
LD BC,1F31H 01 31 1F
Load Register Pair BC with 1F31H, the ROM's assignment of the string to the variable.
5D6E
XOR A AF
Load Register A with 00H (XOR A): 1F31H adds 03H to it, the type of a string.
5D6F
LD D,A 57
Copy Register A (00H) into Register D: no character ends the line but 0DH.
5D70
LD E,A 5F
Copy Register A (00H) into Register E: the line is a string, kept whole.
5D71
PUSH AF F5
Save Register Pair AF (the type's flags) to the stack for 2243H or 1F31H.
5D72
PUSH BC C5
Save Register Pair BC (2243H or 1F31H) to the stack: the RETurn goes there.
5D73
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5D74
GOSUB to 627BH to read a byte of the file: CARRY at the end of the file.
5D77
If the CARRY FLAG is set, JUMP to 643BH, Input past end (E = 7CH).
5D7A
CP 20H FE 20
Compare Register A (the byte) against 20H, a space.
5D7C
If the NZ FLAG is set (not a space), JUMP to 5D82H.
5D7E
INC D 14
INCrement Register D, with the DEC next to set the flags.
5D7F
DEC D 15
DECrement Register D back: the NZ FLAG for INPUT#, the Z FLAG for LINE INPUT#.
5D80
If the NZ FLAG is set (INPUT#), LOOP BACK to 5D74H: leading spaces are skipped.
5D82
CP 22H FE 22
Compare Register A (the byte) against 22H, a quote.
5D84
If the NZ FLAG is set (no quote), JUMP to 5D94H.
5D86
LD B,A 47
Copy Register A (22H, the quote) into Register B to keep it.
5D87
LD A,E 7B
Copy Register E (the end of a field) into Register A.
5D88
CP 2CH FE 2C
Compare Register A against 2CH: the Z FLAG for a string of INPUT#.
5D8A
LD A,B 78
Copy Register B (22H) into Register A; LD does not change the flags.
5D8B
If the NZ FLAG is set (a number or a line), JUMP to 5D94H: the quote is kept.
5D8D
LD D,B 50
Copy Register B (22H) into Register D: the string ends at the closing quote.
5D8E
LD E,B 58
Copy Register B (22H) into Register E: a comma inside the quotes is kept.
5D8F
GOSUB to 627BH for the byte after the quote: CARRY at the end of the file.
5D92
If the CARRY FLAG is set (the end of the file), JUMP to 5DD7H.
5D94
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5D97
LD B,FFH 06 FF
Load Register B with FFH, the most bytes kept: 255.
5D99
LD C,A 4F
Copy Register A (the byte) into Register C: the top of the read loop.
5D9A
LD A,D 7A
Copy Register D (the first end character) into Register A.
5D9B
CP 22H FE 22
Compare Register A against 22H: the Z FLAG inside quotes.
5D9D
LD A,C 79
Copy Register C (the byte) into Register A; LD does not change the flags.
5D9E
If the Z FLAG is set (inside quotes), JUMP to 5DC6H: 0DH and 0AH are kept.
5DA0
CP 0DH FE 0D
Compare Register A (the byte) against 0DH, the end of a line.
5DA2
PUSH HL E5
Save Register Pair HL (the place in the buffer) to the stack for 5DF1H.
5DA3
If the Z FLAG is set (0DH), JUMP to 5DF1H: the field ends.
5DA5
POP HL E1
Restore Register Pair HL (the place in the buffer) from the stack.
5DA6
CP 0AH FE 0A
Compare Register A (the byte) against 0AH, a line feed.
5DA8
If the NZ FLAG is set (not a line feed), JUMP to 5DC6H.
5DAA
LD C,A 4F
Copy Register A (0AH, the line feed) into Register C to keep it.
5DAB
LD A,E 7B
Copy Register E (the end of a field) into Register A.
5DAC
CP 2CH FE 2C
Compare Register A against 2CH: the Z FLAG for a string of INPUT#.
5DAE
LD A,C 79
Copy Register C (0AH) into Register A; LD does not change the flags.
5DAF
If the NZ FLAG is set (a number or a line), GOSUB to 5E16H to keep the line feed.
5DB2
GOSUB to 627BH for the byte after the line feed: CARRY at the end of the file.
5DB5
If the CARRY FLAG is set (the end of the file), JUMP to 5DD7H.
5DB7
CP 0DH FE 0D
Compare Register A (the byte) against 0DH, a 0DH right after the line feed.
5DB9
If the NZ FLAG is set (not 0DH), JUMP to 5DC6H.
5DBB
LD A,E 7B
Copy Register E (the end of a field) into Register A: a 0DH after a line feed.
5DBC
CP 20H FE 20
Compare Register A against 20H: the Z FLAG for a number.
5DBE
If the Z FLAG is set (a number), JUMP to 5DD2H: the 0DH is dropped.
5DC0
CP 2CH FE 2C
Compare Register A against 2CH: the Z FLAG for a string of INPUT#.
5DC2
LD A,0DH 3E 0D
Load Register A with 0DH; LD does not change the flags.
5DC4
If the Z FLAG is set (a string of INPUT#), JUMP to 5DD2H: the 0DH is dropped; for a line it is kept.
5DC6
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a 00H byte.
5DC7
If the Z FLAG is set (00H), JUMP to 5DD2H: the byte is dropped.
5DC9
CP D BA
Compare Register A against Register D, the first end character.
5DCA
If the Z FLAG is set (an end), JUMP to 5DD7H.
5DCC
CP E BB
Compare Register A against Register E, the second end character.
5DCD
If the Z FLAG is set (an end), JUMP to 5DD7H.
5DCF
GOSUB to 5E16H to keep the byte in the line buffer.
5DD2
GOSUB to 627BH for the next byte: CARRY at the end of the file.
5DD5
If the NO CARRY FLAG is set (a byte), JUMP to 5D99H, the top of the read loop.
5DD7
PUSH HL E5
Save Register Pair HL (the end of the field in the buffer) to the stack.
5DD8
CP 22H FE 22
Compare Register A (the byte that ended the field) against 22H, a quote.
5DDA
If the Z FLAG is set (a closing quote), JUMP to 5DE0H to skip what follows it.
5DDC
CP 20H FE 20
Compare Register A against 20H: a space that ended a number.
5DDE
If the NZ FLAG is set (a comma or the end of the file), JUMP to 5DFDH.
5DE0
GOSUB to 627BH for the next byte: CARRY at the end of the file.
5DE3
If the CARRY FLAG is set (the end of the file), JUMP to 5DFDH.
5DE5
CP 20H FE 20
Compare Register A (the byte) against 20H, a space.
5DE7
If the Z FLAG is set (a space), LOOP BACK to 5DE0H: spaces are skipped.
5DE9
CP 2CH FE 2C
Compare Register A against 2CH, a comma: it ends the field.
5DEB
If the Z FLAG is set (a comma), JUMP to 5DFDH.
5DED
CP 0DH FE 0D
Compare Register A against 0DH, the end of a line.
5DEF
If the NZ FLAG is set (another byte), JUMP to 5DFAH to give it back to the file.
5DF1
GOSUB to 627BH for the byte after the 0DH: CARRY at the end of the file.
5DF4
If the CARRY FLAG is set (the end of the file), JUMP to 5DFDH.
5DF6
CP 0AH FE 0A
Compare Register A (the byte) against 0AH, a line feed after the 0DH.
5DF8
If the Z FLAG is set (a line feed), JUMP to 5DFDH: it is part of the end.
5DFA
GOSUB to 5E25H to back the file up one byte: the byte is read again next time.
5DFD
POP HL E1
Restore Register Pair HL (the end of the field in the buffer) from the stack.
5DFE
LD (HL),00H 36 00
Store 00H at Register Pair HL: the end of the text.
5E00
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5E03
DEC HL 2B
DECrement Register Pair HL to the byte before the text.
5E04
LD A,E 7B
Copy Register E (the end of a field) into Register A.
5E05
SUB 20H D6 20
SUBtract 20H from Register A: the Z FLAG for a number.
5E07
If the Z FLAG is set (a number), JUMP to 5E10H.
5E09
LD B,00H 06 00
Load Register B with 00H, the byte that ends the text.
5E0B
GOSUB to 2868H, the ROM: a temporary string of the text after Register Pair HL up to the 00H in Register B.
5E0E
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5E0F
RET C9
RETurn to 2243H or 1F31H, the ROM's assignment.
5E10
RST 10H D7
RST 10H (6579H): Register Pair HL to the first character of the text and Register A = it.
5E11
GOSUB to 0E6CH, the ROM: the text at Register Pair HL made a number in the accumulator.
5E14
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5E15
RET C9
RETurn to 2243H, the ROM's assignment of the number.
5E16H - Keep a Byte
Register A (unless 00H) is stored at Register Pair HL in the line buffer and Register B (the room left) counted down. When the buffer is full the caller's return address is dropped and the field ends at 5DFEH.
5E16
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a 00H byte.
5E17
RET Z C8
If the Z FLAG is set (00H), RETurn to the caller: the byte is not kept.
5E18
LD (HL),A 77
Store Register A (the byte) at Register Pair HL, the line buffer.
5E19
INC HL 23
INCrement Register Pair HL to the next byte of the line buffer.
5E1A
DEC B 05
DECrement Register B, the room left in the line buffer.
5E1B
RET NZ C0
If the NZ FLAG is set (room left), RETurn to the caller.
5E1C
POP BC C1
Discard the caller's return address (POP BC into Register Pair BC): the buffer is full.
5E1D
JUMP to 5DFEH to end the field with the bytes kept.
5E1FH - Open a Program File
For MERGE (5E43H) and LOAD and RUN (5E83H): Register D = 01H, input, and Register A = 00H, file 0, then OPEN's common part at 6333H, which RETurns to the caller.
5E1F
LD D,01H 16 01
Load Register D with 01H, the mode the file is opened in: input.
5E21
XOR A AF
Load Register A with 00H (XOR A): the file number, file 0.
5E22
JUMP to 6333H, OPEN's common part, which RETurns to the caller with file 0 open.
5E25H - Back Up One Byte
The current file is moved back one byte: the record length byte (FCB byte 9, at buffer + 0BH) is made 01H for @BKSP (4445H) and then put back. A DOS error goes to 644FH.
5E25
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5E28
LD BC,000BH 01 0B 00
Load Register Pair BC with 000BH, the offset of the FCB's record length in the buffer.
5E2B
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the record length byte.
5E2C
LD B,(HL) 46
Load Register B with the record length at Register Pair HL, to put back.
5E2D
LD (HL),01H 36 01
Store 01H at Register Pair HL: a record of one byte.
5E2F
PUSH HL E5
Save Register Pair HL (the record length byte) to the stack.
5E30
PUSH BC C5
Save Register Pair BC (Register B = the record length) to the stack.
5E31
LD BC,FFF7H 01 F7 FF
Load Register Pair BC with FFF7H, minus 9: from the record length back to the FCB.
5E34
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the FCB, at buffer + 02H.
5E35
PUSH DE D5
Save Register Pair DE to the stack across @BKSP.
5E36
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the FCB.
5E37
GOSUB to 4445H, @BKSP: the file goes back one record, here one byte; the Z FLAG when no error.
5E3A
POP DE D1
Restore Register Pair DE from the stack after @BKSP.
5E3B
POP BC C1
Restore Register Pair BC (Register B = the record length) from the stack.
5E3C
POP HL E1
Restore Register Pair HL (the record length byte) from the stack.
5E3D
LD (HL),B 70
Store Register B at Register Pair HL: the record length is put back.
5E3E
RET Z C8
If the Z FLAG is set (no error), RETurn to the caller.
5E3F
JUMP to 644FH with Register A = the DOS error code.
5E42H - MERGE
Vector 19 (418BH). The program file is opened as file 0 (5E1FH); anything after the filespec is a Syntax error (5FC4H closes the file first). A file whose first byte is FFH is not ASCII: Bad file mode. Else the byte is given back (5E25H) and the ROM's command loop (1A33H) takes the file's lines as if typed (5BD1H, 5C0EH); with 65F4H = 00H, READY ends it.
5E42
POP BC C1
Discard the ROM's return address (POP BC into Register Pair BC).
5E43
GOSUB to 5E1FH to open the program file as file 0 for input.
5E46
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
5E47
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character, Register A = it; the Z FLAG at the end of the statement.
5E48
If the Z FLAG is set (nothing follows), JUMP to 5E50H.
5E4A
GOSUB to 5FC4H, the READY exit, to close file 0.
5E4D
JUMP to 1997H, the ROM's Syntax error: something follows the filespec.
5E50
XOR A AF
Load Register A with 00H (XOR A), the run state of a MERGE: READY at the end.
5E51
LD (65F4H),A 32 F4 65
Store Register A (00H) at 65F4H, the run state.
5E54
GOSUB to 627BH to read the first byte of the file: CARRY at the end of the file.
5E57
If the CARRY FLAG is set (an empty file), JUMP to 1A33H, the ROM's command loop.
5E5A
INC A 3C
INCrement Register A (the first byte): the Z FLAG for FFH, a program SAVEd without A.
5E5B
If the Z FLAG is set, JUMP to 6435H, Bad file mode (E = 6CH).
5E5E
GOSUB to 5E25H to back the file up one byte: the first byte is read again.
5E61
JUMP to 1A33H, the ROM's command loop, which now reads its lines from the file.
5E64H - A Starting Line
For the R and V options of RUN and LOAD: after the letter an optional comma and line number; 5E68H is entered at a digit. The line number goes in the operand at 5FB2H, where the program will start.
5E64
RST 10H D7
RST 10H (6579H): Register Pair HL past the letter, Register A = it; the Z FLAG at the end of the statement.
5E65
RET Z C8
If the Z FLAG is set (no line number), RETurn to the caller.
5E66
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the line number.
5E68
GOSUB to 1E5AH, the ROM: the line number at Register Pair HL in Register Pair DE.
5E6B
LD (5FB2H),DE ED 53 B2 5F
Store Register Pair DE (the line number) at 5FB2H-5FB3H, the operand of the LD DE at 5FB1H.
5E6F
RET C9
RETurn to the caller with the starting line set.
5E70H - RUN and LOAD a Program
5E70H is vector 39 (41C7H), CALLed by the ROM's RUN at 1EA6H (with the CARRY FLAG for a line number, which the ROM keeps); 5E78H, inside the OR at 5E77H, is vector 18 (4188H), LOAD. 6630H is set for RUN (the protection state is noted at 63C4H) and 65F4H gets FFH for RUN or 00H for LOAD. After the filespec: R (keep the files open and run), V (OV3 function 04H keeps the variables too, 65F4H = D6H) or a line number, each with an optional starting line. A program SAVEd without A (first byte FFH) is read straight into the program area; else the ROM's command loop takes it line by line.
5E70
RET C D8
If the CARRY FLAG is set (RUN with a line number), RETurn to the ROM's RUN.
5E71
POP AF F1
Discard the ROM's return address (POP AF into Register Pair AF).
5E72
LD A,FFH 3E FF
Load Register A with FFH, the run state of RUN.
5E74
LD (6630H),A 32 30 66
Store Register A (FFH) at 6630H: the file is opened for RUN (63C4H).
5E77
OR AFH F6 AF
OR AFH into Register A, leaving FFH; the byte at 5E78H is XOR A, the entry for LOAD (Register A = 00H).
5E79
LD (65F4H),A 32 F4 65
Store Register A at 65F4H, the run state: FFH RUN, 00H LOAD.
5E7C
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: no starting line.
5E7F
LD (5FB2H),DE ED 53 B2 5F
Store Register Pair DE (0000H) at 5FB2H-5FB3H, the starting line.
5E83
GOSUB to 5E1FH to open the program file as file 0 for input.
5E86
LD A,(408EH) 3A 8E 40
Load Register A with the number of files set aside from 408EH.
5E89
LD (65F5H),A 32 F5 65
Store Register A at 65F5H, kept across the ROM's NEW.
5E8C
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
5E8D
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character, Register A = it; the Z FLAG at the end of the statement.
5E8E
If the Z FLAG is set (no option), JUMP to 5EB7H.
5E90
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the option; CARRY for a digit.
5E92
LD (65F4H),A 32 F4 65
Store Register A (the option) at 65F4H: any option makes a run.
5E95
If the NO CARRY FLAG is set (not a digit), JUMP to 5E9CH for a letter.
5E97
GOSUB to 5E68H for the starting line number given as the option.
5E9A
JUMP to 5EB3H: the files stay open across the ROM's NEW.
5E9C
CP 52H FE 52
Compare Register A (the option) against 52H, R.
5E9E
If the NZ FLAG is set (not R), JUMP to 5EA5H.
5EA0
GOSUB to 5E64H for an optional starting line.
5EA3
JUMP to 5EB3H: the files stay open across the ROM's NEW.
5EA5
CP 56H FE 56
Compare Register A (the option) against 56H, V.
5EA7
If the NZ FLAG is set (no valid option), JUMP to 1997H, the ROM's Syntax error.
5EAA
GOSUB to 5E64H for an optional starting line.
5EAD
LD A,04H 3E 04
Load Register A with 04H, BASIC/OV3's function to keep the variables.
5EAF
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number in Register A' for 54B6H.
5EB0
GOSUB to 54B6H to load and enter BASIC/OV3: the variables are parked and 65F4H set to D6H.
5EB3
XOR A AF
Load Register A with 00H (XOR A): no files for the ROM's NEW to close.
5EB4
LD (408EH),A 32 8E 40
Store Register A (00H) at 408EH, the number of files set aside.
5EB7
LD HL,65F2H 21 F2 65
Point Register Pair HL to 65F2H, a byte of 00H in the file.
5EBA
LD (65FAH),HL 22 FA 65
Store Register Pair HL (65F2H) at 65FAH-65FBH, file 0's slot: it reads as closed.
5EBD
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H, to keep it.
5EC0
LD (40A0H),SP ED 73 A0 40
Store the Stack Pointer at 40A0H-40A1H: the ROM's NEW sets the stack from there.
5EC4
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the old 40A0H is kept there.
5EC5
GOSUB to 1B4DH, the ROM's NEW: the old program is gone.
5EC8
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): Register Pair HL = the old 40A0H.
5EC9
LD SP,(40A0H) ED 7B A0 40
Load the Stack Pointer from 40A0H-40A1H, as it was before the NEW.
5ECD
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H: string space starts where it did.
5ED0
LD A,(65F5H) 3A F5 65
Load Register A with the number of files kept at 65F5H.
5ED3
LD (408EH),A 32 8E 40
Store Register A at 408EH, the number of files set aside.
5ED6
LD HL,(661AH) 2A 1A 66
Load Register Pair HL with the address of buffer 0 from 661AH-661BH.
5ED9
LD (65FAH),HL 22 FA 65
Store Register Pair HL at 65FAH-65FBH, file 0's slot: the program file again.
5EDC
LD (65F8H),HL 22 F8 65
Store Register Pair HL at 65F8H-65F9H: file 0 is the current file.
5EDF
GOSUB to 627BH to read the first byte of the file: CARRY at the end of the file.
5EE2
If the CARRY FLAG is set (an empty file), JUMP to 1A33H, the ROM's command loop.
5EE5
INC A 3C
INCrement Register A (the first byte): the Z FLAG for FFH, a program SAVEd without A.
5EE6
If the NZ FLAG is set (ASCII), JUMP to 5E5EH: the byte is given back and the lines read as typed.
5EE9
LD IX,(65F8H) DD 2A F8 65
Load Index Register IX with the buffer of file 0 from 65F8H-65F9H; its FCB starts at IX+02H.
5EED
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H.
5EF0
LD DE,FFAAH 11 AA FF
Load Register Pair DE with FFAAH, minus 56H: room kept for the stack.
5EF3
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the highest address the program may reach.
5EF4
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
5EF8
XOR A AF
Load Register A with 00H (XOR A), the CARRY FLAG cleared.
5EF9
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: the room for the program; CARRY for none.
5EFB
If the CARRY FLAG is set (no room), JUMP to 5F56H, Out of memory.
5EFD
OR (IX+0FH) DD B6 0F
OR the high byte of the FCB's last record number +0FH of the buffer at Index Register IX into Register A: NZ for 256 sectors or more.
5F00
If the NZ FLAG is set (too long), JUMP to 5F56H, Out of memory.
5F02
LD B,(IX+0EH) DD 46 0E
Load Register B with the low byte of the last record number +0EH of the buffer at Index Register IX: the sectors of the file.
5F05
LD C,A 4F
Copy Register A (00H) into Register C: Register Pair BC = the sectors x 256, the bytes.
5F06
SBC HL,BC ED 42
SUBtract Register Pair BC from Register Pair HL (the CARRY FLAG is clear): CARRY when the file does not fit.
5F08
If the CARRY FLAG is set, JUMP to 5F56H, Out of memory.
5F0A
LD H,(IX+06H) DD 66 06
Load Register H with the high byte of the FCB's buffer address +06H of the buffer at Index Register IX.
5F0D
LD L,(IX+05H) DD 6E 05
Load Register L with the low byte of the FCB's buffer address +05H of the buffer at Index Register IX: the first sector, already read.
5F10
INC HL 23
INCrement Register Pair HL past the first byte, FFH.
5F11
LD B,C 41
Copy Register C (00H) into Register B for the count of the copy.
5F12
DEC C 0D
DECrement Register C: Register Pair BC = 00FFH, the rest of the first sector.
5F13
LDIR ED B0
Copy 255 bytes from Register Pair HL to Register Pair DE (LDIR, Register Pair BC = the count): to the start of the program.
5F15
LD (IX+06H),D DD 72 06
Store Register D (the high byte of the next free byte) at +06H of the buffer at Index Register IX, the FCB's buffer address.
5F18
LD (IX+05H),E DD 73 05
Store Register E (the low byte) at +05H of the buffer at Index Register IX: the next sectors are read straight into the program area.
5F1B
LD L,E 6B
Copy Register E (the low byte of the buffer address) into Register L, which no read changes.
5F1C
PUSH IX DD E5
Save Index Register IX (the buffer) to the stack.
5F1E
POP DE D1
Restore Register Pair DE from the stack: Register Pair DE = the buffer.
5F1F
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
5F20
INC DE 13
INCrement Register Pair DE again: Register Pair DE = the FCB, at buffer + 02H.
5F21
LD (IX+07H),B DD 70 07
Store Register B (00H) at +07H of the buffer at Index Register IX, the FCB's byte offset in the record.
5F24
RES 7,(IX+03H) DD CB 03 BE
Reset bit 7 of the FCB's byte 1, +03H of the buffer at Index Register IX: byte mode off, so each @READ puts a whole sector at the buffer address.
5F28
GOSUB to 4436H, @READ: the next sector into the buffer, at Register Pair DE's FCB; NZ for an error.
5F2B
If the NZ FLAG is set (an error or the end of the file), JUMP to 5F32H.
5F2D
INC (IX+06H) DD 34 06
INCrement the high byte of the FCB's buffer address +06H of the buffer at Index Register IX: the next sector 256 bytes on.
5F30
JUMP to 5F28H to read the next sector of the program.
5F32
CP 1CH FE 1C
Compare Register A (the DOS error) against 1CH, the end of the file.
5F34
If the Z FLAG is set (1CH), JUMP to 5F3BH: the whole file is read.
5F36
CP 1DH FE 1D
Compare Register A (the DOS error) against 1DH, a record number past the end of the file.
5F38
If the NZ FLAG is set (another error), JUMP to 644FH with the DOS error in Register A.
5F3B
LD H,(IX+06H) DD 66 06
Load Register H with the high byte of the FCB's buffer address +06H of the buffer at Index Register IX.
5F3E
XOR A AF
Load Register A with 00H (XOR A) for the high byte of the count.
5F3F
LD D,A 57
Copy Register A (00H) into Register D, the high byte of the count.
5F40
LD E,(IX+0AH) DD 5E 0A
Load Register E with the FCB's end of file byte +0AH of the buffer at Index Register IX, the bytes in the last sector.
5F43
DEC E 1D
DECrement Register E, with the INC DE next: 00H becomes 0100H.
5F44
INC DE 13
INCrement Register Pair DE: the bytes in the last sector, 1-256.
5F45
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL. The result is not used: 1AF8H begins by loading Register Pair HL from 40A4H.
5F46
GOSUB to 1AF8H, the ROM: the links of the lines are made again; Register Pair HL ends at the program's last byte.
5F49
INC HL 23
INCrement Register Pair HL to the byte after the program.
5F4A
LD (40F9H),HL 22 F9 40
Store Register Pair HL at 40F9H-40FAH, the start of the variables: the end of the program.
5F4D
LD A,(65F4H) 3A F4 65
Load Register A with the run state at 65F4H (D6H for a RUN with V).
5F50
CP D6H FE D6
Compare Register A against D6H: the Z FLAG for a RUN with V.
5F52
If the NZ FLAG is set (no V), JUMP to 5F98H for the end of the load.
5F54
JUMP to 5F5CH to bring the variables back; also the entry from 5C30H.
5F56
GOSUB to 1B4DH, the ROM's NEW: the part of the program read is cleared.
5F59
JUMP to 197AH, the ROM's Out of memory: the program does not fit.
5F5CH - Bring the Variables Back
For a RUN with V, with Register Pair HL = the end of the new program (40F9H). BASIC/OV3 parked the variables above 40A0H and stored the old values in the operands at 5F5EH (the old 40F9H), 5F65H (the old 40FBH), 5F71H (the length), 5F7EH (40D6H) and 5F84H (40A0H). The variables are moved down after the new program, the pointers set, 65F4H cleared, the stack put back, the READY exit made and the program started (5FB1H). 5A4AH CALLs 5F83H to finish an error the same way.
5F5C
PUSH HL E5
Save Register Pair HL (the end of the new program) to the stack.
5F5D
LD DE,0000H 11 00 00
Load Register Pair DE with the old end of the program, the operand at 5F5EH (stored by BASIC/OV3; 0000H in the file).
5F60
AND A A7
Clear the CARRY FLAG (AND A); Register A is not changed.
5F61
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: how far the variables move.
5F63
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the distance.
5F64
LD HL,0000H 21 00 00
Load Register Pair HL with the old start of the arrays, the operand at 5F65H (0000H in the file).
5F67
ADD HL,DE 19
ADD Register Pair DE (the distance) to Register Pair HL: the new start of the arrays.
5F68
LD (40FBH),HL 22 FB 40
Store Register Pair HL at 40FBH-40FCH, the start of the arrays.
5F6B
POP DE D1
Restore Register Pair DE (the end of the new program) from the stack: where the variables go.
5F6C
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H.
5F6F
INC HL 23
INCrement Register Pair HL: the parked variables, just above it.
5F70
LD BC,0000H 01 00 00
Load Register Pair BC with the length of the variables, the operand at 5F71H (0000H in the file).
5F73
LD A,B 78
Copy Register B (the high byte of the length) into Register A.
5F74
OR C B1
OR Register C into Register A: the Z FLAG when there are no variables.
5F75
If the Z FLAG is set (nothing to move), JUMP to 5F79H.
5F77
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): the variables after the program.
5F79
LD (40FDH),DE ED 53 FD 40
Store Register Pair DE (the byte after the arrays) at 40FDH-40FEH, the end of the arrays.
5F7D
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5F7EH, the old 40D6H (0000H in the file).
5F80
LD (40D6H),HL 22 D6 40
Store Register Pair HL at 40D6H-40D7H, the next free byte of string space.
5F83
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5F84H, the old 40A0H (0000H in the file); the entry from 5A4AH.
5F86
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the start of string space.
5F89
DEC HL 2B
DECrement Register Pair HL, one byte below string space.
5F8A
DEC HL 2B
DECrement Register Pair HL again: 2 bytes below string space.
5F8B
LD (40E8H),HL 22 E8 40
Store Register Pair HL at 40E8H-40E9H, the ROM's saved Stack Pointer.
5F8E
XOR A AF
Load Register A with 00H (XOR A) to clear the run state.
5F8F
LD (65F4H),A 32 F4 65
Store Register A (00H) at 65F4H: the run state cleared.
5F92
LD SP,HL F9
Load the Stack Pointer from Register Pair HL: a new stack; no caller is RETurned to.
5F93
GOSUB to 5FC4H, the READY exit: output back to the display and file 0 closed.
5F96
JUMP to 5FB1H to start the program at its starting line.
5F98H - The End of a Load
MAXFIL (408EH) is made 0 across the ROM's RUN set up (1B5DH), so it closes no file, then put back. A plain LOAD (65F4H = 00H) goes to READY (1A19H); else the program starts at the line in 5FB2H, or at its first line when that is 0000H.
5F98
LD HL,408EH 21 8E 40
Point Register Pair HL to 408EH, the number of files set aside.
5F9B
LD A,(HL) 7E
Load Register A with the number of files at Register Pair HL.
5F9C
LD (65F5H),A 32 F5 65
Store Register A at 65F5H to keep the number of files.
5F9F
LD (HL),00H 36 00
Store 00H at Register Pair HL (408EH): no files across the RUN set up.
5FA1
GOSUB to 1B5DH, the ROM's RUN set up: variables cleared, the pointers set.
5FA4
LD A,(65F5H) 3A F5 65
Load Register A with the number of files kept at 65F5H.
5FA7
LD (408EH),A 32 8E 40
Store Register A at 408EH, the number of files set aside.
5FAA
LD A,(65F4H) 3A F4 65
Load Register A with the run state at 65F4H (00H for a plain LOAD).
5FAD
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a plain LOAD.
5FAE
If the Z FLAG is set (LOAD), JUMP to 1A19H, the ROM's READY.
5FB1
LD DE,0000H 11 00 00
Load Register Pair DE with the starting line, the operand at 5FB2H (0000H in the file; 5E6BH stores it).
5FB4
LD A,D 7A
Copy Register D (the high byte of the line number) into Register A.
5FB5
OR E B3
OR Register E into Register A: the Z FLAG when no line was given.
5FB6
If the Z FLAG is set (no line), JUMP to 5FC1H: the program starts at its first line.
5FB8
GOSUB to 1B2CH, the ROM: find the line in Register Pair DE; Register Pair BC = the line.
5FBB
If the NZ FLAG is set (no such line, between two lines), JUMP to 1ED9H, the ROM's Undefined line; a line past the last gives the Z FLAG and no error.
5FBE
DEC BC 0B
DECrement Register Pair BC to the byte before the line.
5FBF
LD H,B 60
Copy Register B (the high byte of the line's address) into Register H.
5FC0
LD L,C 69
Copy Register C into Register L: Register Pair HL = the byte before the line.
5FC1
JUMP to 1D1EH, the ROM's next statement: the program runs.
5FC4H - READY Exit
Vector 30 (41ACH), CALLed by the ROM at 1A1CH on its way to READY, and from 5C36H, 5E4AH, 5F93H and the JP at 6040H. The output goes back to the display (2169H, which leaves Register A = 00H) and file 0 is closed (6194H). Only for the ROM's READY (return address 1A1FH) is the protection test made (63EDH). It RETurns with Register Pair HL = 40DFH's word (1BAFH).
5FC4
GOSUB to 2169H, the ROM: output to the display (409CH = 00H); Register A = 00H.
5FC7
GOSUB to 6194H to close file n, Register A = 00H: file 0.
5FCA
POP HL E1
Load Register Pair HL with the return address (POP HL).
5FCB
PUSH DE D5
Save Register Pair DE to the stack across the comparison.
5FCC
LD DE,1A1FH 11 1F 1A
Load Register Pair DE with 1A1FH, the return address in the ROM's READY.
5FCF
RST 18H DF
RST 18H: compare Register Pair HL (the return address) against Register Pair DE; the Z FLAG for the ROM's READY.
5FD0
POP DE D1
Restore Register Pair DE from the stack; POP does not change the flags.
5FD1
PUSH HL E5
Save Register Pair HL (the return address) to the stack again.
5FD2
If the Z FLAG is set (the ROM's READY), GOSUB to 63EDH for the protection test.
5FD5
JUMP to 1BAFH, the ROM: Register Pair HL = the word at 40DFH, and RETurn.
5FD8H - A Line Typed
Vector 32 (41B2H), CALLed by the ROM at 1AA1H after a line is tokenized, the CARRY FLAG for a line with a number (the ROM stores it). A line without a number read from a file is Direct statement in file (E = 84H). Else the protection test (63EDH) is made and the statement executed (1D5AH).
5FD8
RET C D8
If the CARRY FLAG is set (a numbered line), RETurn to the ROM to store it.
5FD9
POP AF F1
Discard the ROM's return address 1AA4H (POP AF into Register Pair AF).
5FDA
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5FDB
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
5FDE
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5FDF
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5FE0
LD E,84H 1E 84
Load Register E with 84H, Direct statement in file; LD does not change the flags.
5FE2
If the NZ FLAG is set (a line from a file), JUMP to 19A2H, the ROM's error handler.
5FE5
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5FE6
GOSUB to 63EDH for the protection test before the statement runs.
5FE9
JUMP to 1D5AH, the ROM: the statement is executed.
5FECH - SAVE
Vector 26 (41A0H). The file is opened as file 0 for output (5E21H with Register D = 02H). SAVE "file",A goes to the ROM's LIST (2B2EH), whose text goes to the file through 5C00H. Without A the program is written as it is in memory: the byte before it (40A4H less 1) is made FFH, the file is first written at its last record to give it its size (@POSN, @WRITE, @REW), then a record is written from each page of memory; the end of file byte is set and 5FC4H closes the file.
5FEC
LD D,02H 16 02
Load Register D with 02H, the mode the file is opened in: output.
5FEE
GOSUB to 5E21H to open the file as file 0, here for output.
5FF1
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
5FF2
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character, Register A = it; the Z FLAG at the end.
5FF3
If the Z FLAG is set (nothing follows), JUMP to 5FFCH to save the program as it is in memory.
5FF5
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come after the filespec.
5FF7
RST 08H => 41H CF 41
RST 08H with the byte 41H: the letter A must come next.
5FF9
JUMP to 2B2EH, the ROM's LIST: the program goes to the file as text.
5FFC
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the end of the program from 40F9H-40FAH.
5FFF
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
6003
XOR A AF
Load Register A with 00H (XOR A), the CARRY FLAG cleared.
6004
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: the length of the program.
6006
DEC A 3D
DECrement Register A: FFH, the first byte of the file.
6007
DEC DE 1B
DECrement Register Pair DE to the byte before the program.
6008
LD (DE),A 12
Store Register A (FFH) at Register Pair DE, the byte before the program.
6009
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the byte before the program, Register Pair DE = the length.
600A
PUSH DE D5
Save Register Pair DE (the length) to the stack.
600B
LD C,D 4A
Copy Register D (the high byte of the length) into Register C.
600C
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the number of the last record.
600E
LD IX,(65F8H) DD 2A F8 65
Load Index Register IX with the buffer of file 0 from 65F8H-65F9H.
6012
LD (IX+06H),H DD 74 06
Store Register H at +06H of the buffer at Index Register IX, the high byte of the FCB's buffer address.
6015
LD (IX+05H),L DD 75 05
Store Register L at +05H of the buffer at Index Register IX: the records are written straight from the program.
6018
PUSH IX DD E5
Save Index Register IX (the buffer) to the stack.
601A
POP DE D1
Restore Register Pair DE from the stack: Register Pair DE = the buffer.
601B
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
601C
INC DE 13
INCrement Register Pair DE again: Register Pair DE = the FCB, at buffer + 02H.
601D
GOSUB to 4442H, @POSN: the file is positioned at record Register Pair BC, the last.
6020
RES 6,(IX+03H) DD CB 03 B6
Reset bit 6 of +03H of the buffer at Index Register IX, the FCB's byte 1.
6024
GOSUB to 4439H, @WRITE: the last record is written, giving the file its size; NZ for an error.
6027
If the Z FLAG is set (no error), GOSUB to 443FH, @REW: back to the first record.
602A
If the NZ FLAG is set (an error), JUMP to 6032H.
602C
POP BC C1
Restore Register Pair BC (the length) from the stack.
602D
INC C 0C
INCrement Register C: the bytes in the last record (00H for 256).
602E
INC B 04
INCrement Register B: the number of records to write.
602F
GOSUB to 4439H, @WRITE: 256 bytes of the program are written; NZ for an error.
6032
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte before the program, back as it was; LD does not change the flags.
6034
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
6037
INC (IX+06H) DD 34 06
INCrement +06H of the buffer at Index Register IX: the next record is the next page.
603A
DECrement Register B (the records left) and LOOP BACK to 602FH.
603C
LD (IX+0AH),C DD 71 0A
Store Register C at +0AH of the buffer at Index Register IX, the FCB's end of file byte.
603F
LD (HL),B 70
Store Register B (00H) at Register Pair HL, the byte before the program.
6040
JUMP to 5FC4H, the READY exit, which closes file 0.
6043H - CLOSE
Vector 17 (4185H). With the NZ FLAG (a list follows) each [#]n of the list is closed by 6194H; with the Z FLAG every file from the number set aside (408EH) down to 0 is closed. 6194H is reached by a RET (6053H) and by JP (HL) (6073H) with return addresses pushed before it.
6043
LD BC,6194H 01 94 61
Load Register Pair BC with 6194H, the routine that closes one file.
6046
LD A,(408EH) 3A 8E 40
Load Register A with the number of files set aside from 408EH; LD does not change the flags.
6049
If the NZ FLAG is set (a list of files), JUMP to 6063H.
604B
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
604C
PUSH BC C5
Save Register Pair BC (6194H, the close routine) to the stack.
604D
PUSH AF F5
Save Register Pair AF (Register A = the file number) to the stack.
604E
LD DE,6054H 11 54 60
Load Register Pair DE with 6054H, where the loop goes on.
6051
PUSH DE D5
Save Register Pair DE (6054H) to the stack: the return address of 6194H.
6052
PUSH BC C5
Save Register Pair BC (6194H) to the stack: the RET next goes there.
6053
RET C9
RETurn to 6194H to close file Register A; it RETurns to 6054H.
6054
POP AF F1
Restore Register Pair AF (Register A = the file number) from the stack.
6055
POP BC C1
Restore Register Pair BC (6194H) from the stack.
6056
DEC A 3D
DECrement Register A to the file before, and the S FLAG with it.
6057
If the P FLAG is set (0 or more), JUMP to 604CH to close it.
605A
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
605B
RET C9
RETurn to the ROM with every file set aside closed.
605C
POP BC C1
Restore Register Pair BC (6194H) from the stack: the return from a file of the list.
605D
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
605E
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
605F
CP 2CH FE 2C
Compare Register A against 2CH, a comma: another file follows.
6061
RET NZ C0
If the NZ FLAG is set (no comma), RETurn to the ROM.
6062
RST 10H D7
RST 10H (6579H): Register Pair HL past the comma, Register A = the next character.
6063
PUSH BC C5
Save Register Pair BC (6194H, the close routine) to the stack.
6064
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
6065
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
6067
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
606A
GOSUB to 2B1CH, the ROM: the file number as a byte in Register A.
606D
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = 6194H, the stack = the text pointer.
606E
PUSH HL E5
Save Register Pair HL (6194H, the close routine) to the stack.
606F
LD DE,605CH 11 5C 60
Load Register Pair DE with 605CH, where the list goes on.
6072
PUSH DE D5
Save Register Pair DE (605CH) to the stack: the return address of 6194H.
6073
JP (HL) E9
JUMP to the address in Register Pair HL, 6194H, to close file Register A.
6074H - Close Every File
Vector 35 (41BBH), CALLed by the ROM at 1B8CH, in the clear shared by RUN (1B5DH) and NEW, and at 1DB0H in END; STOP jumps past that call (1DABH), so it closes nothing here. XOR A gives CLOSE (6043H) the Z FLAG: every file is closed.
6074
PUSH DE D5
Save Register Pair DE to the stack across CLOSE.
6075
PUSH BC C5
Save Register Pair BC to the stack across CLOSE.
6076
XOR A AF
Load Register A with 00H (XOR A): the Z FLAG, no list of files.
6077
GOSUB to 6043H, CLOSE, to close every file set aside.
607A
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
607B
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
607C
XOR A AF
Load Register A with 00H (XOR A), as the ROM expects.
607D
RET C9
RETurn to the ROM with every file closed and Register A = 00H.
607EH - FIELD
Vector 14 (417CH). FIELD [#]n, w AS v$, ... for a file open for random (mode 03H). Each v$'s descriptor is pointed at the next w bytes of the file's data area (buffer + 22H). More than the record length (the FCB's byte 9, 00H for 256; kept at 65F3H) is FIELD overflow (E = 64H). When the fields total exactly 256 bytes FIELD ends there; that total is not tested against a shorter record length (Register B = 00H at 60BDH), so a record of 80 bytes may be fielded as 256.
607E
GOSUB to 5CEFH for the file number: Register Pair BC = its buffer, Register A = its mode.
6081
If the Z FLAG is set (the file is closed), JUMP to 6438H, Bad file number (E = 68H).
6084
SUB 03H D6 03
SUBtract 03H from Register A (the mode): the Z FLAG for random.
6086
If the NZ FLAG is set (not random), JUMP to 6435H, Bad file mode (E = 6CH).
6089
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the text pointer.
608A
LD HL,000BH 21 0B 00
Load Register Pair HL with 000BH, the offset of the FCB's record length in the buffer.
608D
ADD HL,BC 09
ADD Register Pair BC (the buffer) to Register Pair HL: the record length byte.
608E
LD A,(HL) 7E
Load Register A with the record length at Register Pair HL.
608F
LD (65F3H),A 32 F3 65
Store Register A (the record length) at 65F3H.
6092
XOR A AF
Load Register A with 00H (XOR A): no bytes in fields yet.
6093
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the text pointer.
6094
LD DE,0022H 11 22 00
Load Register Pair DE with 0022H, the offset of the data area in the buffer.
6097
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the offset or the place in the data area.
6098
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the place of the next field.
6099
LD B,A 47
Copy Register A (the bytes in fields so far) into Register B.
609A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the place, Register Pair HL = the text pointer.
609B
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
609C
CP 2CH FE 2C
Compare Register A against 2CH, a comma: another field follows.
609E
RET NZ C0
If the NZ FLAG is set (no comma), RETurn to the ROM.
609F
PUSH DE D5
Save Register Pair DE (the place of the field) to the stack.
60A0
PUSH BC C5
Save Register Pair BC (Register B = the bytes so far) to the stack.
60A1
GOSUB to 2B1BH, the ROM: past the comma, the width as a byte in Register A.
60A4
PUSH AF F5
Save Register Pair AF (Register A = the width) to the stack.
60A5
RST 08H => 41H CF 41
RST 08H with the byte 41H: the letter A must come next.
60A7
RST 08H => 53H CF 53
RST 08H with the byte 53H: the letter S, AS, must come next.
60A9
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable v$.
60AC
GOSUB to 0AF4H, the ROM: Type mismatch unless v$ is a string.
60AF
POP AF F1
Restore Register Pair AF (Register A = the width) from the stack.
60B0
POP BC C1
Restore Register Pair BC (Register B = the bytes so far) from the stack.
60B1
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = the place, the stack = the text pointer.
60B2
LD C,A 4F
Copy Register A (the width of the field) into Register C.
60B3
ADD A,B 80
ADD Register B (the bytes so far) to Register A: the bytes with this field.
60B4
If the NO CARRY FLAG is set (255 or less), JUMP to 60B9H.
60B6
If the NZ FLAG is set (more than 256), JUMP to 644AH, FIELD overflow (E = 64H).
60B9
LD B,A 47
Copy Register A (the bytes with this field, 00H for 256) into Register B.
60BA
LD A,(65F3H) 3A F3 65
Load Register A with the record length from 65F3H.
60BD
CP B B8
Compare Register A against Register B: NO CARRY when the fields fit, and always for a total of 256 (Register B = 00H).
60BE
If the NO CARRY FLAG is set (they fit), JUMP to 60C4H.
60C0
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a record length of 256 (00H).
60C1
If the NZ FLAG is set (a shorter record), JUMP to 644AH, FIELD overflow (E = 64H).
60C4
LD A,B 78
Copy Register B (the bytes with this field) into Register A.
60C5
AND A A7
Set the flags from Register A (AND A): the Z FLAG when the fields total 256 (or nothing).
60C6
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = v$'s descriptor, Register Pair DE = the place.
60C7
LD (HL),C 71
Store Register C (the width) at Register Pair HL, v$'s length.
60C8
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
60C9
LD (HL),E 73
Store Register E at Register Pair HL, the low byte of the place.
60CA
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
60CB
LD (HL),D 72
Store Register D at Register Pair HL: v$ is the field in the buffer.
60CC
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the width; LD does not change the flags.
60CE
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
60CF
If the NZ FLAG is set, JUMP to 6097H for the next field, after this one.
60D2
LD A,C 79
Copy Register C (the width of the field) into Register A.
60D3
AND A A7
Set the flags from Register A (AND A): the NZ FLAG when the fields reached 256 bytes.
60D4
RET NZ C0
If the NZ FLAG is set (the data area is full), RETurn to the ROM.
60D5
JUMP to 6097H for the next field (a width of 0 with nothing before it).
60D8H - RSET and LSET
60D8H (OR 37H, the CARRY FLAG clear) is vector 24 (419AH), RSET; 60D9H (SCF, inside it) is vector 23 (4197H), LSET. v$ = x$: v$ keeps its length and place; x$ is copied in, cut to v$'s length, and padded with spaces (615CH) on the left for RSET or the right for LSET. A v$ whose text is still in the program (between 40A4H and 40F9H) is first given space of its own (28BFH); when string space is short and x$ was a temporary just freed by 29D7H, 6165H tries to reserve it again, but that path goes wrong (6171H).
60D8
OR 37H F6 37
OR 37H into Register A, clearing the CARRY FLAG: RSET. The byte 37H at 60D9H is SCF, the entry for LSET.
60DA
PUSH AF F5
Save Register Pair AF (the CARRY FLAG: set for LSET) to the stack.
60DB
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable v$.
60DE
GOSUB to 0AF4H, the ROM: Type mismatch unless v$ is a string.
60E1
PUSH DE D5
Save Register Pair DE (v$'s descriptor) to the stack.
60E2
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: it must come next.
60E4
GOSUB to 2337H, the ROM: evaluate the expression x$.
60E7
POP BC C1
Restore Register Pair BC (v$'s descriptor) from the stack.
60E8
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = the saved flags, the stack = the text pointer.
60E9
PUSH HL E5
Save Register Pair HL (the LSET or RSET flags) to the stack.
60EA
PUSH BC C5
Save Register Pair BC (v$'s descriptor) to the stack.
60EB
GOSUB to 29D7H, the ROM: x$ must be a string, a temporary freed (the Z FLAG); Register Pair HL = its descriptor.
60EE
LD B,(HL) 46
Load Register B with x$'s length at Register Pair HL.
60EF
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = v$'s descriptor, the stack = x$'s.
60F0
LD A,(HL) 7E
Load Register A with v$'s length at Register Pair HL.
60F1
LD C,A 4F
Copy Register A (v$'s length) into Register C.
60F2
PUSH BC C5
Save Register Pair BC (Register B = x$'s length, Register C = v$'s) to the stack.
60F3
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
60F4
PUSH AF F5
Save Register Pair AF (Register A = v$'s length, the flags of 29D7H) to the stack.
60F5
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
60F6
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
60F7
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
60F8
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = v$'s text.
60F9
AND A A7
Set the flags from Register A (AND A): the Z FLAG when v$ is empty.
60FA
If the Z FLAG is set (v$ is empty), JUMP to 6152H: nothing to do.
60FD
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
6100
RST 18H DF
RST 18H: compare Register Pair HL (the start of the program) against Register Pair DE (v$'s text).
6101
If the NO CARRY FLAG is set (v$ is below the program), JUMP to 612EH.
6103
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the end of the program from 40F9H-40FAH.
6106
RST 18H DF
RST 18H: compare Register Pair HL (the end of the program) against Register Pair DE (v$'s text).
6107
If the CARRY FLAG is set (v$ is above the program), JUMP to 612EH.
6109
LD E,C 59
Copy Register C (v$'s length) into Register E.
610A
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = v$'s length.
610C
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H.
610F
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: string space plus v$'s length.
6110
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = that address.
6111
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with the next free byte of string space from 40D6H-40D7H.
6114
RST 18H DF
RST 18H: compare Register Pair HL against Register Pair DE: CARRY when the room is short.
6115
If the CARRY FLAG is set (short), JUMP to 6165H to keep x$ safe first.
6117
POP AF F1
Restore Register Pair AF (Register A = v$'s length) from the stack.
6118
LD A,C 79
Copy Register C (v$'s length) into Register A.
6119
GOSUB to 28BFH, the ROM: space for Register A bytes of string; Register Pair DE = its address.
611C
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
611D
POP BC C1
Restore Register Pair BC (the two lengths) from the stack.
611E
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = x$'s descriptor, the stack = v$'s.
611F
PUSH DE D5
Save Register Pair DE (the new space) to the stack.
6120
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
6121
GOSUB to 29D7H, the ROM: x$'s temporary freed again; Register Pair HL = its descriptor.
6124
POP BC C1
Restore Register Pair BC (the two lengths) from the stack.
6125
POP DE D1
Restore Register Pair DE (the new space) from the stack.
6126
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = v$'s descriptor, the stack = x$'s.
6127
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
6128
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
6129
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
612A
LD (HL),E 73
Store Register E at Register Pair HL, the low byte of the new space.
612B
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
612C
LD (HL),D 72
Store Register D at Register Pair HL: v$ now has space of its own.
612D
PUSH AF F5
Save Register Pair AF to the stack, for the POP AF next.
612E
POP AF F1
Discard a word (POP AF into Register Pair AF).
612F
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
6130
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
6131
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
6132
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
6133
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = v$'s text.
6134
POP BC C1
Restore Register Pair BC (Register B = x$'s length, Register C = v$'s) from the stack.
6135
POP HL E1
Restore Register Pair HL (x$'s descriptor) from the stack.
6136
PUSH DE D5
Save Register Pair DE (v$'s text) to the stack.
6137
INC HL 23
INCrement Register Pair HL to the low byte of x$'s address.
6138
LD E,(HL) 5E
Load Register E with the low byte of x$'s address at Register Pair HL.
6139
INC HL 23
INCrement Register Pair HL to the high byte of x$'s address.
613A
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = x$'s text.
613B
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = x$'s text.
613C
POP DE D1
Restore Register Pair DE (v$'s text) from the stack.
613D
LD A,C 79
Copy Register C (v$'s length) into Register A.
613E
CP B B8
Compare Register A against Register B (x$'s length): NO CARRY when x$ fits.
613F
If the NO CARRY FLAG is set (it fits), JUMP to 6142H.
6141
LD B,A 47
Copy Register A (v$'s length) into Register B: x$ is cut to it.
6142
SUB B 90
SUBtract Register B (the characters copied) from Register A: the spaces to pad.
6143
LD C,A 4F
Copy Register A (the spaces) into Register C.
6144
POP AF F1
Restore Register Pair AF (the CARRY FLAG: set for LSET) from the stack.
6145
If the NO CARRY FLAG is set (RSET), GOSUB to 615CH: the spaces come first.
6148
INC B 04
INCrement Register B (the characters to copy), with the DEC next to set the flags.
6149
DEC B 05
DECrement Register B: the Z FLAG when the copy is done.
614A
If the Z FLAG is set (the copy is done), JUMP to 6157H.
614C
LD A,(HL) 7E
Load Register A with a character of x$ at Register Pair HL.
614D
LD (DE),A 12
Store Register A at Register Pair DE, a character of v$.
614E
INC HL 23
INCrement Register Pair HL to the next character of x$.
614F
INC DE 13
INCrement Register Pair DE to the next character of v$.
6150
JUMP to 6149H for the next character of x$ to copy.
6152
POP BC C1
Discard a word (POP BC into Register Pair BC): v$ is empty.
6153
POP BC C1
Discard a second word (POP BC into Register Pair BC).
6154
POP BC C1
Discard a third word (POP BC into Register Pair BC).
6155
POP BC C1
Discard a fourth word (POP BC into Register Pair BC).
6156
POP BC C1
Restore the saved flags (POP BC into Register Pair BC): Register C = the flags, so the CARRY FLAG is unchanged from 60F9H, clear.
6157
If the CARRY FLAG is set (LSET), GOSUB to 615CH: the spaces come last.
615A
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
615B
RET C9
RETurn to the ROM with v$ set from x$ and padded.
615CH - Spaces
Stores Register C spaces (20H) at Register Pair DE onward.
615C
LD A,20H 3E 20
Load Register A with 20H, a space, the character that pads.
615E
INC C 0C
INCrement Register C (the spaces left), with the DEC next to set the flags.
615F
DEC C 0D
DECrement Register C: the Z FLAG when none are left.
6160
RET Z C8
If the Z FLAG is set (no space left to store), RETurn to the caller.
6161
LD (DE),A 12
Store Register A (a space) at Register Pair DE.
6162
INC DE 13
INCrement Register Pair DE to the next character of v$.
6163
JUMP to 615FH for the next space to store in v$.
6165H - Keep x$ Safe
Reached from 6115H when string space is short and 28BFH may collect garbage. The flags saved at 60F4H are those of 29D7H: with the Z FLAG x$ was a temporary just freed, and 2857H and 2884H are meant to reserve x$'s length again as a temporary over the same bytes; but 2884H RETurns through the saved lengths (6171H), so this path fails. With the NZ FLAG 6117H allocates v$'s space.
6165
POP AF F1
Restore Register Pair AF (Register A = v$'s length, the flags of 29D7H) from the stack.
6166
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
6167
POP BC C1
Restore Register Pair BC (the two lengths) from the stack.
6168
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = x$'s descriptor, the stack = v$'s.
6169
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = x$'s descriptor.
616A
If the NZ FLAG is set (x$ was not a temporary), JUMP to 6175H.
616C
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
616D
LD A,B 78
Copy Register B (x$'s length) into Register A.
616E
GOSUB to 2857H, the ROM: Register A bytes of string space reserved, the descriptor at 40D3H.
6171
GOSUB to 2884H, the ROM: the descriptor goes on the stack of temporaries, but 2884H is meant to be entered with a word pushed: its POP HL (289EH) takes 6174H and its RET NZ goes to the lengths saved at 616CH, an address of nothing. 6174H is not reached.
6174
POP BC C1
Restore Register Pair BC (the two lengths) from the stack; never reached from 6171H (see there).
6175
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = v$'s descriptor.
6176
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
6177
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
6178
PUSH AF F5
Save Register Pair AF (Register A = v$'s length) to the stack.
6179
JUMP to 6117H to allocate v$'s space in string space.
617BH - EOF
Vector 5 (4161H), with the file number already in the accumulator: -1 at the end of the file (@CKEOF NZ), else 0. A file open for output is Bad file mode.
617B
GOSUB to 5CF9H for the file number in the accumulator: Register Pair BC = its buffer, Register A = its mode.
617E
CP 02H FE 02
Compare Register A (the mode) against 02H, output.
6180
If the Z FLAG is set (output), JUMP to 6435H, Bad file mode (E = 6CH).
6183
INC BC 03
INCrement Register Pair BC toward the FCB inside the buffer.
6184
INC BC 03
INCrement Register Pair BC again: the FCB, at buffer + 02H.
6185
LD D,B 50
Copy Register B (the high byte of the FCB's address) into Register D.
6186
LD E,C 59
Copy Register C into Register E: Register Pair DE = the FCB.
6187
GOSUB to 444BH, @CKEOF: the Z FLAG when there is more to read.
618A
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the result false; LD does not change the flags.
618D
If the Z FLAG is set (more to read), JUMP to 0A9AH, the ROM: the result 0.
6190
DEC HL 2B
DECrement Register Pair HL: FFFFH, the result -1, true.
6191
JUMP to 0A9AH, the ROM: the accumulator = Register Pair HL, an integer.
6194H - Close One File
Closes file Register A: nothing for a closed file. A file open for input (mode 01H) is not given to @CLOSE; for the others the mode is cleared first and @CLOSE (4428H) called. The buffer's first 22H (34) bytes, the mode, the column and the FCB, are then cleared.
6194
GOSUB to 5CFCH for file Register A: Register Pair BC = its buffer, Register A = its mode, the Z FLAG when closed.
6197
RET Z C8
If the Z FLAG is set (the file is closed), RETurn to the caller.
6198
CP 01H FE 01
Compare Register A (the mode) against 01H, input.
619A
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
619B
If the Z FLAG is set (input), JUMP to 61A9H: no @CLOSE.
619D
XOR A AF
Load Register A with 00H (XOR A), the mode of a closed file.
619E
LD (BC),A 02
Store Register A (00H) at Register Pair BC, the file's mode: closed.
619F
INC BC 03
INCrement Register Pair BC toward the FCB inside the buffer.
61A0
INC BC 03
INCrement Register Pair BC again: the FCB, at buffer + 02H.
61A1
LD D,B 50
Copy Register B (the high byte of the FCB's address) into Register D.
61A2
LD E,C 59
Copy Register C (the low byte) into Register E: Register Pair DE = the FCB.
61A3
GOSUB to 4428H, @CLOSE: the file is closed; NZ for an error.
61A6
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
61A9
POP DE D1
Restore Register Pair DE (the buffer) from the stack.
61AA
LD B,22H 06 22
Load Register B with 22H, the bytes to clear: the mode, the column and the FCB.
61AC
XOR A AF
Load Register A with 00H (XOR A), the byte to store.
61AD
LD (DE),A 12
Store Register A (00H) at Register Pair DE in the buffer.
61AE
INC DE 13
INCrement Register Pair DE to the next byte of the buffer.
61AF
DECrement Register B and LOOP BACK to 61ADH until 34 bytes are clear.
61B1
RET C9
RETurn to the caller with the file closed and its buffer cleared.
61B2H - LOC and LOF
61B2H is vector 6 (4164H), LOC, with @LOC (445AH); 61B7H is vector 7 (4167H), LOF, with @LOF (445DH). The file number is already in the accumulator; a closed file is Bad file number. The value the call gives in Register Pair BC (the current record, or the number of records) is the result, an integer; an error from the call is the ROM's Overflow (07B2H).
61B2
LD HL,445AH 21 5A 44
Load Register Pair HL with 445AH, @LOC: the current record number.
61B5
JUMP to 61BAH, past LOF's own LD of Register Pair HL.
61B7
LD HL,445DH 21 5D 44
Load Register Pair HL with 445DH, @LOF: the number of records in the file.
61BA
GOSUB to 5CF9H for the file number in the accumulator: Register Pair BC = its buffer, the Z FLAG when closed.
61BD
If the Z FLAG is set (the file is closed), JUMP to 6438H, Bad file number (E = 68H).
61C0
INC BC 03
INCrement Register Pair BC toward the FCB inside the buffer.
61C1
INC BC 03
INCrement Register Pair BC again: the FCB, at buffer + 02H.
61C2
LD D,B 50
Copy Register B (the high byte of the FCB's address) into Register D.
61C3
LD E,C 59
Copy Register C (the low byte) into Register E: Register Pair DE = the FCB.
61C4
GOSUB to 61CFH, which JUMPs to the call in Register Pair HL: Register Pair BC = the record number.
61C7
If the NZ FLAG is set (an error), JUMP to 07B2H, the ROM's Overflow.
61CA
LD H,B 60
Copy Register B (the high byte of the record number) into Register H.
61CB
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the record number.
61CC
JUMP to 0A9AH, the ROM: the accumulator = Register Pair HL, an integer.
61CF
JP (HL) E9
JUMP to the address in Register Pair HL, @LOC or @LOF, which RETurns to 61C7H.
61D0H - A Byte to the Current File
From 5C00H with Register A = the byte. A file open for input takes nothing (1DFDH: POP AF, POP HL and RET). Else the file's column (buffer + 01H) goes to 0 for 0DH and up one for a byte of 20H or more, and the byte is written with $PUT (001BH). An error ends at 644FH only for an open disk file (bit 7 of the FCB's byte 0); for a device it is ignored. Every register is kept.
61D0
PUSH HL E5
Save Register Pair HL to the stack, kept for the caller.
61D1
PUSH AF F5
Save Register Pair AF (Register A = the byte) to the stack.
61D2
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
61D5
LD A,(HL) 7E
Load Register A with the file's mode at Register Pair HL.
61D6
CP 01H FE 01
Compare Register A against 01H: the Z FLAG for input.
61D8
If the Z FLAG is set (input), JUMP to 1DFDH, the ROM: POP AF, POP HL and RETurn; nothing is written.
61DB
POP AF F1
Restore Register Pair AF (Register A = the byte) from the stack.
61DC
PUSH DE D5
Save Register Pair DE to the stack, kept for the caller.
61DD
PUSH BC C5
Save Register Pair BC to the stack, kept for the caller.
61DE
INC HL 23
INCrement Register Pair HL to the file's column, at buffer + 01H.
61DF
LD B,00H 06 00
Load Register B with 00H, the column after a 0DH.
61E1
PUSH AF F5
Save Register Pair AF (Register A = the byte) to the stack.
61E2
LD D,(HL) 56
Load Register D with the file's column at Register Pair HL.
61E3
CP 0DH FE 0D
Compare Register A (the byte) against 0DH, the end of a line.
61E5
LD (HL),B 70
Store Register B (00H) at Register Pair HL, the column; LD does not change the flags.
61E6
If the Z FLAG is set (0DH), JUMP to 61EDH with the column 0.
61E8
ADD A,E0H C6 E0
ADD E0H to Register A: the CARRY FLAG for a byte of 20H or more.
61EA
LD A,D 7A
Copy Register D (the old column) into Register A.
61EB
ADC A,B 88
ADD Register B (00H) and the CARRY FLAG to Register A: the column up one for a printable byte.
61EC
LD (HL),A 77
Store Register A (the new column) at Register Pair HL.
61ED
INC HL 23
INCrement Register Pair HL to the FCB, at buffer + 02H.
61EE
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the FCB.
61EF
POP AF F1
Restore Register Pair AF (Register A = the byte) from the stack.
61F0
PUSH AF F5
Save Register Pair AF (Register A = the byte) to the stack again.
61F1
GOSUB to 001BH, the ROM's $PUT: Register A goes to the file or device at Register Pair DE; NZ for an error.
61F4
If the NZ FLAG is set (an error), JUMP to 61FBH.
61F6
POP AF F1
Restore Register Pair AF (Register A = the byte) from the stack.
61F7
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
61F8
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
61F9
POP HL E1
Restore Register Pair HL from the stack, as it was on entry.
61FA
RET C9
RETurn to the caller with the byte written and the registers kept.
61FB
LD C,A 4F
Copy Register A (the error code) into Register C.
61FC
LD A,(DE) 1A
Load Register A with the FCB's byte 0 at Register Pair DE.
61FD
AND A A7
Set the flags from Register A (AND A): the M FLAG (bit 7) for an open disk file.
61FE
LD A,C 79
Copy Register C (the error code) into Register A; LD does not change the flags.
61FF
If the M FLAG is set (a disk file), JUMP to 644FH with the DOS error in Register A.
6202
JUMP to 61F6H: for a device the error is ignored.
6204H - PUT and GET
6204H (OR AFH, Register A not 00H) is vector 16 (4182H), PUT; 6205H (XOR A, inside it) is GET, Register A = 00H; 65F6H keeps which. [#]n[,r] for a file open for random (mode 03H): with r, @POSN goes to record r-1 (r = 0 is Bad record number); without it @CKEOF tests the place. A GET past the end (1CH or 1DH) gives a record of 256 zero bytes; else @READ, or @WRITE for PUT, with Register Pair HL at the data area (buffer + 22H).
6204
OR AFH F6 AF
OR AFH into Register A: not 00H, PUT. The byte AFH at 6205H is XOR A, the entry for GET (00H).
6206
LD (65F6H),A 32 F6 65
Store Register A at 65F6H: 00H for GET, else PUT.
6209
GOSUB to 5CEFH for the file number: Register Pair BC = its buffer, Register A = its mode.
620C
CP 03H FE 03
Compare Register A (the mode) against 03H, random.
620E
If the NZ FLAG is set (not random), JUMP to 6435H, Bad file mode (E = 6CH).
6211
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
6212
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
6213
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character, Register A = it; the Z FLAG at the end.
6214
If the NZ FLAG is set (more follows), JUMP to 6224H for the record number.
6216
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = the buffer, the stack = the text pointer.
6217
PUSH HL E5
Save Register Pair HL (the buffer) to the stack.
6218
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
6219
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
621A
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
621B
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, from the FCB to the data area.
621E
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the data area, buffer + 22H.
621F
GOSUB to 444BH, @CKEOF: the Z FLAG when the place is inside the file.
6222
JUMP to 6241H to act on the result of @CKEOF.
6224
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
6225
CP 2CH FE 2C
Compare Register A against 2CH, a comma before the record number.
6227
If the NZ FLAG is set (no comma), JUMP to 1997H, the ROM's Syntax error.
622A
GOSUB to 2B01H, the ROM: the record number as an integer in Register Pair DE.
622D
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = the buffer, the stack = the text pointer.
622E
PUSH HL E5
Save Register Pair HL (the buffer) to the stack.
622F
LD A,D 7A
Copy Register D (the high byte of the record number) into Register A.
6230
OR E B3
OR Register E into Register A: the Z FLAG for record 0.
6231
If the Z FLAG is set (record 0), JUMP to 6447H, Bad record number (E = 7EH).
6234
DEC DE 1B
DECrement Register Pair DE: the DOS counts records from 0.
6235
LD B,D 42
Copy Register D (the high byte of the record) into Register B.
6236
LD C,E 4B
Copy Register E into Register C: Register Pair BC = the record wanted.
6237
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
6238
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
6239
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
623A
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, from the FCB to the data area.
623D
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the data area, buffer + 22H.
623E
GOSUB to 4442H, @POSN: the file is positioned at record Register Pair BC; NZ with an error code.
6241
If the Z FLAG is set (no error), JUMP to 625BH.
6243
CP 1CH FE 1C
Compare Register A against 1CH, the end of the file.
6245
If the Z FLAG is set (1CH, the end of the file), JUMP to 624CH.
6247
CP 1DH FE 1D
Compare Register A against 1DH, a record past the end of the file.
6249
If the NZ FLAG is set (another error), JUMP to 644FH with the DOS error in Register A.
624C
LD A,(65F6H) 3A F6 65
Load Register A with the byte at 65F6H: 00H for GET, else PUT.
624F
AND A A7
Set the flags from Register A (AND A): the Z FLAG for GET.
6250
If the Z FLAG is set (GET past the end), JUMP to 626EH for a record of zero bytes.
6252
GOSUB to 4439H, @WRITE: the data area is written as the record; NZ for an error.
6255
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
6258
POP AF F1
Discard the buffer (POP AF into Register Pair AF).
6259
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
625A
RET C9
RETurn to the ROM with the record written to the file.
625B
LD A,(65F6H) 3A F6 65
Load Register A with the byte at 65F6H: 00H for GET, else PUT.
625E
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for PUT.
625F
If the NZ FLAG is set (PUT), JUMP to 6252H to write the record.
6261
GOSUB to 4436H, @READ: the record is read into the data area; NZ for an error.
6264
If the NZ FLAG is set (an error), JUMP to 6269H.
6266
POP BC C1
Discard the buffer (POP BC into Register Pair BC).
6267
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
6268
RET C9
RETurn to the ROM with the record read into the data area.
6269
CP 1CH FE 1C
Compare Register A against 1CH, the end of the file.
626B
If the NZ FLAG is set (another error), JUMP to 644FH with the DOS error in Register A.
626E
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
626F
LD DE,0022H 11 22 00
Load Register Pair DE with 0022H, the offset of the data area.
6272
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the data area, buffer + 22H.
6273
XOR A AF
Load Register A with 00H (XOR A), the byte to store.
6274
LD B,A 47
Copy Register A into Register B: 256 bytes to clear.
6275
LD (HL),A 77
Store Register A (00H) at Register Pair HL in the data area.
6276
INC HL 23
INCrement Register Pair HL to the next byte of the data area.
6277
DECrement Register B and LOOP BACK to 6275H until 256 bytes are clear.
6279
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
627A
RET C9
RETurn to the ROM with a record of zero bytes.
627BH - Read a Byte of the Current File
$GET (0013H) at the FCB of the current file. For an open disk file (bit 7 of the FCB's byte 0): NO CARRY with the byte in Register A, CARRY at the end of the file (1CH); other errors go to 644FH. For a device, a Z FLAG reads again and anything else is RETurned. Registers BC, DE and HL are kept.
627B
PUSH BC C5
Save Register Pair BC to the stack, kept for the caller.
627C
PUSH HL E5
Save Register Pair HL to the stack, kept for the caller.
627D
LD HL,(65F8H) 2A F8 65
Load Register Pair HL with the current file's buffer pointer from 65F8H-65F9H.
6280
PUSH DE D5
Save Register Pair DE to the stack, kept for the caller.
6281
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
6282
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
6283
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
6284
GOSUB to 0013H, the ROM's $GET: a byte in Register A from the FCB at Register Pair DE; NZ for an error.
6287
PUSH AF F5
Save Register Pair AF (the byte and the flags) to the stack.
6288
LD A,(DE) 1A
Load Register A with the FCB's byte 0 at Register Pair DE.
6289
AND A A7
Set the flags from Register A (AND A): the P FLAG (bit 7 clear) for a device.
628A
If the P FLAG is set (a device), JUMP to 629CH.
628D
POP AF F1
Restore Register Pair AF (the byte and the flags) from the stack.
628E
If the Z FLAG is set (a byte), JUMP to 6297H to clear the CARRY FLAG.
6290
CP 1CH FE 1C
Compare Register A (the error code) against 1CH, the end of the file.
6292
If the NZ FLAG is set (another error), JUMP to 644FH with the DOS error in Register A.
6295
SCF 37
Set the CARRY FLAG (SCF): the end of the file.
6296
LD B,A7H 06 A7
Load Register B with A7H: skipped bytes, 6297H is AND A, which clears the CARRY FLAG; Register B comes back from the stack.
6298
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
6299
POP HL E1
Restore Register Pair HL from the stack, as it was on entry.
629A
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
629B
RET C9
RETurn to the caller: NO CARRY with a byte, CARRY at the end of the file.
629C
POP AF F1
Restore Register Pair AF (the byte and the flags) from the stack.
629D
If the Z FLAG is set, JUMP to 6284H to read the device again.
629F
JUMP to 6297H to RETurn with the CARRY FLAG clear.
62A1H - A Filespec Into an FCB
The string expression at Register Pair HL (1 to 24 characters, else Bad file name) is copied to 5414H with a 00H after it, and @FSPEC (441CH) puts it into the FCB of the buffer in Register Pair BC (buffer + 02H). An error, or a character after the filespec (Register A not 00H), is Bad file name (E = 80H). Register Pair BC is kept.
62A1
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
62A2
GOSUB to 2337H, the ROM: evaluate the expression of the filespec.
62A5
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
62A6
GOSUB to 29D7H, the ROM: it must be a string, its temporary freed; Register Pair HL = its descriptor.
62A9
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
62AA
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty string.
62AB
If the Z FLAG is set (empty), JUMP to 6444H, Bad file name (E = 80H).
62AE
CP 19H FE 19
Compare Register A against 19H: NO CARRY for 25 characters or more.
62B0
If the NO CARRY FLAG is set (too long), JUMP to 6444H, Bad file name (E = 80H).
62B3
INC HL 23
INCrement Register Pair HL to the low byte of the string's address.
62B4
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
62B5
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
62B6
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the string's text.
62B7
LD HL,5414H 21 14 54
Point Register Pair HL to 5414H, where the filespec is put (inside the start up code).
62BA
LD E,A 5F
Copy Register A (the length) into Register E, the characters to copy.
62BB
LD A,(BC) 0A
Load Register A with a character of the filespec at Register Pair BC.
62BC
LD (HL),A 77
Store Register A at Register Pair HL, the copy at 5414H.
62BD
INC HL 23
INCrement Register Pair HL to the next byte at 5414H.
62BE
INC BC 03
INCrement Register Pair BC to the next character of the filespec.
62BF
DEC E 1D
DECrement Register E, the characters of the filespec left.
62C0
If the NZ FLAG is set (more), LOOP BACK to 62BBH.
62C2
LD (HL),E 73
Store Register E (00H) at Register Pair HL: the end of the filespec.
62C3
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
62C4
POP DE D1
Restore Register Pair DE (the buffer) from the stack.
62C5
LD B,D 42
Copy Register D (the high byte of the buffer) into Register B.
62C6
LD C,E 4B
Copy Register E into Register C: Register Pair BC = the buffer.
62C7
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
62C8
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
62C9
LD HL,5414H 21 14 54
Point Register Pair HL to 5414H, the filespec.
62CC
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
62CD
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
62CE
GOSUB to 441CH, @FSPEC: the filespec at Register Pair HL into the FCB at Register Pair DE; NZ for an error.
62D1
If the NZ FLAG is set (an error), JUMP to 6444H, Bad file name (E = 80H).
62D4
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for a character after the filespec.
62D5
If the NZ FLAG is set, JUMP to 6444H, Bad file name (E = 80H).
62D8
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
62D9
POP BC C1
Restore Register Pair BC (the buffer) from the stack.
62DA
RET C9
RETurn to the caller with the FCB set from the filespec.
62DBH - OPEN
Vector 13 (4179H): OPEN "m",[#]n,"filespec"[,length]. The first letter of m gives the mode byte in Register D: I 11H (input, the file must exist), O 02H (output), R 0BH (random, a record length may follow), E 06H (output at the end of the file); lower case is taken. After O, R or E a second letter O sets bit 4 (the file must exist) and N bit 5 (it must be new). File 0 is kept for LOAD and SAVE (Bad file number). 2169H, pushed first, is where the RET at 63ECH goes.
62DB
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's end of a statement that may have used a file.
62DE
PUSH BC C5
Save Register Pair BC (2169H) to the stack: OPEN RETurns there.
62DF
GOSUB to 2337H, the ROM: evaluate the expression of the mode.
62E2
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
62E3
GOSUB to 29D7H, the ROM: it must be a string, its temporary freed; Register Pair HL = its descriptor.
62E6
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
62E7
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty string.
62E8
If the Z FLAG is set (no mode), JUMP to 6435H, Bad file mode (E = 6CH).
62EB
INC HL 23
INCrement Register Pair HL to the low byte of the string's address.
62EC
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
62ED
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
62EE
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the mode's text.
62EF
LD E,A 5F
Copy Register A (the length) into Register E.
62F0
LD A,(BC) 0A
Load Register A with the first letter of the mode at Register Pair BC.
62F1
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter made upper case.
62F3
CP 49H FE 49
Compare Register A against 49H, I: input from a file that exists.
62F5
LD D,11H 16 11
Load Register D with 11H, the mode byte of I: input, the file must exist.
62F7
If the Z FLAG is set (I), JUMP to 631FH; any other letters are not looked at.
62F9
CP 4FH FE 4F
Compare Register A against 4FH, O: output to a new or old file.
62FB
LD D,02H 16 02
Load Register D with 02H, the mode byte of O: output.
62FD
If the Z FLAG is set (O), JUMP to 630CH for a second letter.
62FF
CP 52H FE 52
Compare Register A against 52H, R: random, records read and written.
6301
LD D,0BH 16 0B
Load Register D with 0BH, the mode byte of R: random, with a record length allowed (bit 3).
6303
If the Z FLAG is set (R), JUMP to 630CH for a second letter.
6305
CP 45H FE 45
Compare Register A against 45H, E: output added at the end.
6307
LD D,06H 16 06
Load Register D with 06H, the mode byte of E: output, at the end of the file (bit 2).
6309
If the NZ FLAG is set (no valid letter), JUMP to 6435H, Bad file mode (E = 6CH).
630C
DEC E 1D
DECrement Register E, the letters left: the Z FLAG for one letter.
630D
If the Z FLAG is set (one letter), JUMP to 631FH.
630F
INC BC 03
INCrement Register Pair BC to the second letter of the mode.
6310
LD A,(BC) 0A
Load Register A with the second letter at Register Pair BC.
6311
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter made upper case.
6313
CP 4FH FE 4F
Compare Register A against 4FH, O: the file must be old.
6315
If the NZ FLAG is set (not O), JUMP to 6319H.
6317
SET 4,D CB E2
Set bit 4 of Register D (the mode byte): the file must exist.
6319
CP 4EH FE 4E
Compare Register A against 4EH, N: the file must be new.
631B
If the NZ FLAG is set (not N), JUMP to 631FH.
631D
SET 5,D CB EA
Set bit 5 of Register D (the mode byte): the file must not exist.
631F
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
6320
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come after the mode.
6322
PUSH DE D5
Save Register Pair DE (Register D = the mode byte) to the stack.
6323
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
6325
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
6328
GOSUB to 2B1CH, the ROM: the file number as a byte in Register A and Register E.
632B
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the filespec.
632D
LD A,E 7B
Copy Register E (the file number) into Register A.
632E
AND A A7
Set the flags from Register A (AND A): the Z FLAG for file 0.
632F
If the Z FLAG is set (file 0, kept for programs), JUMP to 6438H, Bad file number (E = 68H).
6332
CP D5H FE D5
Compare Register A against D5H: no use; the byte D5H at 6333H is PUSH DE, the entry from 5E22H with Register A = 00H.
6334
LD (638CH),A 32 8C 63
Store Register A (the file number) at 638CH, the operand of LD A at 638BH.
6337
GOSUB to 5CFCH for file Register A: Register Pair BC = its buffer, the Z FLAG when closed.
633A
If the NZ FLAG is set (open), JUMP to 643EH, File already open (E = 6EH).
633D
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
633E
GOSUB to 62A1H: the filespec into the FCB of the buffer at Register Pair BC.
6341
LD B,00H 06 00
Load Register B with 00H: a record length of 256.
6343
POP DE D1
Restore Register Pair DE (the buffer) from the stack.
6344
POP AF F1
Restore Register Pair AF from the stack: Register A = the mode byte.
6345
PUSH AF F5
Save Register Pair AF (the mode byte) to the stack again.
6346
PUSH DE D5
Save Register Pair DE (the buffer) to the stack.
6347
BIT 3,A CB 5F
Test bit 3 of Register A (the mode byte): the NZ FLAG for random.
6349
If the Z FLAG is set (not random), JUMP to 635FH.
634B
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
634C
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character, Register A = it; the Z FLAG at the end.
634D
If the Z FLAG is set (no record length), JUMP to 635FH.
634F
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the record length.
6351
GOSUB to 2B1CH, the ROM: the record length as a byte in Register E (0 for 256).
6354
LD A,(408FH) 3A 8F 40
Load Register A with the blocked mode flag at 408FH.
6357
AND A A7
Set the flags from Register A (AND A): the NZ FLAG in blocked mode.
6358
If the NZ FLAG is set (blocked mode), JUMP to 635EH.
635A
OR E B3
OR Register E (the record length) into Register A: the Z FLAG for 0 (256).
635B
If the NZ FLAG is set (a short record without blocked mode), JUMP to 6432H, Blocked file error (E = 8CH).
635E
LD B,E 43
Copy Register E (the record length) into Register B.
635F
LD (40DFH),HL 22 DF 40
Store Register Pair HL (the text pointer) at 40DFH-40E0H, to keep it.
6362
LD HL,430FH 21 0F 43
Point Register Pair HL to 430FH, SFLAG$, the system flags.
6365
RES 2,(HL) CB 96
Reset bit 2 of SFLAG$ at Register Pair HL: not a load for @RUN.
6367
LD A,(6630H) 3A 30 66
Load Register A with the RUN flag at 6630H (FFH from 5E74H).
636A
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for RUN.
636B
If the Z FLAG is set (not RUN), JUMP to 636FH.
636D
SET 2,(HL) CB D6
Set bit 2 of SFLAG$ at Register Pair HL: a program is being loaded to run.
636F
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
6370
POP AF F1
Restore Register Pair AF (Register A = the mode byte) from the stack.
6371
PUSH AF F5
Save Register Pair AF (the mode byte) to the stack again.
6372
PUSH HL E5
Save Register Pair HL (the buffer) to the stack again.
6373
LD (65F8H),HL 22 F8 65
Store Register Pair HL (the buffer) at 65F8H-65F9H: the file is current.
6376
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
6377
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
6378
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
6379
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, from the FCB to the sector buffer.
637C
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the sector buffer at buffer + 22H.
637D
LD C,A 4F
Copy Register A (the mode byte) into Register C.
637E
LD A,B 78
Copy Register B (the record length) into Register A.
637F
AND A A7
Set the flags from Register A (AND A): the Z FLAG for 256.
6380
If the Z FLAG is set (a record of 256), JUMP to 6383H.
6382
INC H 24
INCrement Register H: the sector buffer 256 bytes on (buffer + 122H); buffer + 22H holds the record.
6383
PUSH HL E5
Save Register Pair HL (the sector buffer) to the stack.
6384
LD HL,FFFFH 21 FF FF
Load Register Pair HL with the EXT parameter, the operand at 6385H (FFFFH in the file, on; 0000H for OFF).
6387
LD A,H 7C
Copy Register H (the high byte of EXT) into Register A.
6388
OR L B5
OR Register L into Register A: 00H only for EXT=OFF.
6389
CPL 2F
Complement Register A (CPL): 00H for EXT on, FFH for EXT=OFF.
638A
LD L,A 6F
Copy Register A (00H for EXT on) into Register L.
638B
LD A,00H 3E 00
Load Register A with the file number, the operand at 638CH (00H in the file; 6334H stores it).
638D
OR L B5
OR Register L into Register A: the Z FLAG for file 0 with EXT on.
638E
LD HL,548DH 21 8D 54
Point Register Pair HL to 548DH, the text BASIC/OV, whose first 3 letters BAS are the extension.
6391
PUSH BC C5
Save Register Pair BC (the record length and the mode byte) to the stack.
6392
If the Z FLAG is set, GOSUB to 4473H, @FEXT: the extension /BAS is added when the filespec has none.
6395
POP BC C1
Restore Register Pair BC (the record length and the mode byte) from the stack.
6396
POP HL E1
Restore Register Pair HL (the sector buffer) from the stack.
6397
LD A,C 79
Copy Register C (the mode byte) into Register A.
6398
CP 01H FE 01
Compare Register A against 01H, the mode byte of a program file (5E1FH).
639A
If the Z FLAG is set (a program file), JUMP to 63C0H.
639C
BIT 4,C CB 61
Test bit 4 of Register C (the mode byte): the NZ FLAG when the file must exist.
639E
If the NZ FLAG is set, JUMP to 63AFH for @OPEN.
63A0
GOSUB to 4420H, @INIT: the file opened, made if it is new (the CARRY FLAG); NZ for an error.
63A3
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
63A6
If the CARRY FLAG is set (a new file), JUMP to 63B5H.
63A8
BIT 5,C CB 69
Test bit 5 of Register C (the mode byte): the NZ FLAG when the file had to be new.
63AA
If the NZ FLAG is set, JUMP to 6441H, File already exists (E = 74H).
63AD
JUMP to 63B5H to finish the open of the file.
63AF
GOSUB to 4424H, @OPEN: the file must exist; NZ for an error.
63B2
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
63B5
BIT 2,C CB 51
Test bit 2 of Register C (the mode byte): the NZ FLAG for E.
63B7
If the NZ FLAG is set (E), GOSUB to 4448H, @PEOF: to the end of the file.
63BA
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
63BB
POP AF F1
Restore Register Pair AF (Register A = the mode byte) from the stack.
63BC
AND 03H E6 03
Mask Register A to bits 1 and 0 (AND 03H): the mode, 01H input, 02H output, 03H random.
63BE
JUMP to 63DDH to store the mode in the file's buffer.
63C0
GOSUB to 4424H, @OPEN: the program file; NZ for an error.
63C3
PUSH AF F5
Save Register Pair AF (the result of @OPEN) to the stack.
63C4
LD A,(6630H) 3A 30 66
Load Register A with the RUN flag at 6630H (FFH from 5E74H).
63C7
AND A A7
Set the flags from Register A (AND A): the Z FLAG when not a RUN.
63C8
If the Z FLAG is set (not RUN), JUMP to 63D7H.
63CA
XOR A AF
Load Register A with 00H (XOR A) to clear the RUN flag.
63CB
LD (6630H),A 32 30 66
Store Register A (00H) at 6630H: the RUN flag cleared.
63CE
LD A,(430FH) 3A 0F 43
Load Register A with SFLAG$ from 430FH, as @OPEN left it.
63D1
RRA 1F
Rotate Register A right through the CARRY FLAG (RRA).
63D2
RRA 1F
Rotate Register A right again (RRA): bit 1 of SFLAG$, run without DEBUG, in the CARRY FLAG.
63D3
SBC A,A 9F
SUBtract Register A and the CARRY FLAG from Register A (SBC A,A): FFH for bit 1 set, else 00H.
63D4
LD (6631H),A 32 31 66
Store Register A at 6631H: FFH, the program may run but not be looked at.
63D7
POP AF F1
Restore Register Pair AF (the result of @OPEN) from the stack.
63D8
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
63DB
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
63DC
POP AF F1
Restore Register Pair AF (Register A = the mode byte, 01H) from the stack.
63DD
LD (HL),A 77
Store Register A (the mode) at Register Pair HL, the buffer's first byte: the file is open.
63DE
INC HL 23
INCrement Register Pair HL to the file's column.
63DF
LD (HL),00H 36 00
Store 00H at Register Pair HL, the file's column, at the left.
63E1
INC HL 23
INCrement Register Pair HL to the FCB's byte 0.
63E2
INC HL 23
INCrement Register Pair HL to the FCB's byte 1.
63E3
CP 03H FE 03
Compare Register A (the mode) against 03H, random.
63E5
If the NZ FLAG is set (not random), JUMP to 63E9H.
63E7
SET 6,(HL) CB F6
Set bit 6 of the FCB's byte 1 at Register Pair HL, for a random file.
63E9
LD HL,(40DFH) 2A DF 40
Load Register Pair HL with the text pointer kept at 40DFH-40E0H.
63EC
RET C9
RETurn to the caller (2169H for OPEN) with the file open.
63EDH - The Protection Test
CALLed from 5A5BH, 5FD2H and 5FE6H. 6630H is cleared. When 6631H is set (a program opened to run only, 63D4H) the program area is cleared (044DH bytes from 40A4H), 6631H cleared, the ROM's NEW made and the error Protection has cleared memory (E = 90H) given. Else every register is kept.
63ED
PUSH AF F5
Save Register Pair AF to the stack, kept for the caller.
63EE
XOR A AF
Load Register A with 00H (XOR A) to clear the RUN flag.
63EF
LD (6630H),A 32 30 66
Store Register A (00H) at 6630H, the RUN flag.
63F2
LD A,(6631H) 3A 31 66
Load Register A with the protection flag at 6631H.
63F5
AND A A7
Set the flags from Register A (AND A): the Z FLAG when not protected.
63F6
If the Z FLAG is set (not protected), JUMP to 6410H.
63F8
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
63FB
LD D,H 54
Copy Register H (the high byte of the program's start) into Register D.
63FC
LD E,L 5D
Copy Register L into Register E: Register Pair DE = the start of the program.
63FD
INC DE 13
INCrement Register Pair DE: the byte after it.
63FE
LD BC,044CH 01 4C 04
Load Register Pair BC with 044CH, the bytes to copy: 044DH (1101) bytes are cleared.
6401
XOR A AF
Load Register A with 00H (XOR A), the byte that clears the program.
6402
LD (HL),A 77
Store Register A (00H) at Register Pair HL, the first byte of the program.
6403
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): the 00H is spread over the program.
6405
LD (6631H),A 32 31 66
Store Register A (00H) at 6631H: the protection flag cleared.
6408
GOSUB to 1B4DH, the ROM's NEW: the program and variables are gone.
640B
LD E,90H 1E 90
Load Register E with 90H, the E value of Protection has cleared memory.
640D
JUMP to 19A2H, the ROM's error handler, with Register E = 90H.
6410
POP AF F1
Restore Register Pair AF from the stack, as it was on entry.
6411
RET C9
RETurn to the caller with nothing changed and the RUN flag cleared.
6412H - KILL
Vector 21 (4191H). The filespec is put in file 0's FCB (62A1H), the file opened (@OPEN, 4424H) and killed (@KILL, 442CH); file 0's mode is then cleared.
6412
XOR A AF
Load Register A with 00H (XOR A): file 0, kept for programs and KILL.
6413
GOSUB to 5CFCH for file 0: Register Pair BC = its buffer.
6416
GOSUB to 62A1H: the filespec into the FCB of the buffer at Register Pair BC.
6419
LD DE,(65FAH) ED 5B FA 65
Load Register Pair DE with file 0's buffer from 65FAH-65FBH.
641D
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
641E
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
641F
GOSUB to 4424H, @OPEN: the file must exist; NZ for an error.
6422
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
6425
GOSUB to 442CH, @KILL: the file is removed; NZ for an error.
6428
If the NZ FLAG is set (an error), JUMP to 644FH with the DOS error in Register A.
642B
DEC DE 1B
DECrement Register Pair DE toward the buffer.
642C
DEC DE 1B
DECrement Register Pair DE again: file 0's buffer.
642D
LD (DE),A 12
Store Register A (00H) at Register Pair DE, the mode: file 0 closed.
642E
RET C9
RETurn to the ROM with the file killed and file 0 closed.
642FH - BASIC Errors
Each entry loads Register E with an error's E value; the 3 bytes after it are LD BC, so the next entries are skipped, and 644CH JUMPs to the ROM's error handler (19A2H). 642FH is also the USR vector set by 5397H for a USR with no DEF USR. 644FH: a DOS error in Register A goes to Register L, and BASIC/OV3 function 02H gives its E value.
642F
LD E,2EH 1E 2E
Load Register E with 2EH: Undefined user function.
6431
LD BC,8C1EH 01 1E 8C
Load Register Pair BC with 8C1EH: skipped bytes, 6432H is LD E,8CH, Blocked file error.
6434
LD BC,6C1EH 01 1E 6C
Load Register Pair BC with 6C1EH: skipped bytes, 6435H is LD E,6CH, Bad file mode.
6437
LD BC,681EH 01 1E 68
Load Register Pair BC with 681EH: skipped bytes, 6438H is LD E,68H, Bad file number.
643A
LD BC,7C1EH 01 1E 7C
Load Register Pair BC with 7C1EH: skipped bytes, 643BH is LD E,7CH, Input past end.
643D
LD BC,6E1EH 01 1E 6E
Load Register Pair BC with 6E1EH: skipped bytes, 643EH is LD E,6EH, File already open.
6440
LD BC,741EH 01 1E 74
Load Register Pair BC with 741EH: skipped bytes, 6441H is LD E,74H, File already exists.
6443
LD BC,801EH 01 1E 80
Load Register Pair BC with 801EH: skipped bytes, 6444H is LD E,80H, Bad file name.
6446
LD BC,7E1EH 01 1E 7E
Load Register Pair BC with 7E1EH: skipped bytes, 6447H is LD E,7EH, Bad record number.
6449
LD BC,641EH 01 1E 64
Load Register Pair BC with 641EH: skipped bytes, 644AH is LD E,64H, FIELD overflow.
644C
JUMP to 19A2H, the ROM's error handler, with the E value in Register E.
644F
LD L,A 6F
Copy Register A (the DOS error code) into Register L for BASIC/OV3.
6450
LD A,02H 3E 02
Load Register A with 02H, BASIC/OV3's function for a DOS error.
6452
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number in Register A' for 54B6H.
6453
GOSUB to 54B6H to load and enter BASIC/OV3: Register E = the E value of the DOS error.
6456
JUMP to 19A2H, the ROM's error handler, with the E value in Register E.
6459H - The Command Line at READY
5BD8H JUMPs here when the ROM's line input (0361H) runs with no current file. Unless it was called from the ROM's command loop (return 1A7EH) or a JCL job runs (bit 5 of SFLAG$ 430FH), the ROM's line input goes on. Else the first key decides: up arrow (5BH), down arrow (0AH), period and comma work on the current line (40ECH), left arrow (08H) shows the first line and right arrow (09H) the last; a line is shown by the ROM's LIST (2B33H) or, for comma, edited (2E65H). Any other key starts a line, collected by the ROM (05E3H) and RETurned to 651AH.
6459
POP HL E1
Load Register Pair HL with the return address 036BH, in the ROM's line input (POP HL).
645A
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = the return address of the caller of 0361H.
645B
LD DE,1A7EH 11 7E 1A
Load Register Pair DE with 1A7EH, the return address in the ROM's command loop after 0361H.
645E
RST 18H DF
RST 18H: compare Register Pair HL against Register Pair DE (1A7EH); the Z FLAG for the command loop.
645F
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): the caller's return address back.
6460
PUSH HL E5
Save Register Pair HL (036BH) to the stack again.
6461
RET NZ C0
If the NZ FLAG is set (not the command loop), RETurn to 036BH, the ROM's own line input.
6462
LD HL,430FH 21 0F 43
Point Register Pair HL to 430FH, SFLAG$, the system flags.
6465
BIT 5,(HL) CB 6E
Test bit 5 of SFLAG$ at Register Pair HL: the NZ FLAG when a JCL job runs.
6467
RET NZ C0
If the NZ FLAG is set (JCL), RETurn to 036BH, the ROM's own line input.
6468
POP HL E1
Discard the return address 036BH (POP HL into Register Pair HL): the stack now holds 1A7EH.
6469
LD A,0EH 3E 0E
Load Register A with 0EH, the code that turns the cursor on.
646B
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
646E
GOSUB to 0049H, the ROM: wait for a key, returned in Register A.
6471
PUSH AF F5
Save Register Pair AF (Register A = the first key) to the stack.
6472
GOSUB to 5C93H to clear bits 2-0 of KFLAG$ (4423H): ENTER, pause and BREAK.
6475
CP 5BH FE 5B
Compare Register A (the key) against 5BH, the up arrow.
6477
If the Z FLAG is set (up arrow), JUMP to 64A3H for the current line.
6479
CP 0AH FE 0A
Compare Register A (the key) against 0AH, the down arrow.
647B
If the Z FLAG is set (down arrow), JUMP to 64A3H for the current line.
647D
CP 2EH FE 2E
Compare Register A (the key) against 2EH, a period.
647F
If the Z FLAG is set (period), JUMP to 64A3H for the current line.
6481
CP 2CH FE 2C
Compare Register A (the key) against 2CH, a comma.
6483
If the Z FLAG is set (comma), JUMP to 64A3H for the current line.
6485
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
6488
CP 08H FE 08
Compare Register A (the key) against 08H, the left arrow.
648A
If the Z FLAG is set (left arrow), JUMP to 64DFH to show the first line, at Register Pair HL.
648C
LD DE,FFFFH 11 FF FF
Load Register Pair DE with FFFFH, a line number past every line.
648F
CP 09H FE 09
Compare Register A (the key) against 09H, the right arrow.
6491
If the Z FLAG is set (right arrow), JUMP to 64A7H: no line FFFFH, so the last line.
6493
POP AF F1
Restore Register Pair AF (Register A = the first key) from the stack.
6494
PUSH BC C5
Save Register Pair BC to the stack, as the ROM's line input does at 036BH.
6495
LD HL,651AH 21 1A 65
Point Register Pair HL to 651AH, where the line goes when it is complete.
6498
PUSH HL E5
Save Register Pair HL (651AH) to the stack: the RETurn of the ROM's collector goes there.
6499
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
649C
PUSH HL E5
Save Register Pair HL (the line buffer) to the stack, as 05D9H does.
649D
LD B,F0H 06 F0
Load Register B with F0H, the longest line: 240 characters.
649F
LD C,B 48
Copy Register B (F0H) into Register C, as 05DFH does.
64A0
JUMP to 05E3H, the ROM's line collector, with the first key in Register A.
64A3
LD DE,(40ECH) ED 5B EC 40
Load Register Pair DE with the current line's number from 40ECH-40EDH.
64A7
GOSUB to 1B2CH, the ROM: find line Register Pair DE; CARRY when found (Register Pair BC = it, Register Pair HL = the next line), else Register Pair BC = the next higher line, the Z FLAG when none.
64AA
POP DE D1
Load Register Pair DE with the first key from the stack (POP DE): Register D = the key.
64AB
PUSH DE D5
Save Register Pair DE (the first key) to the stack again.
64AC
LD A,D 7A
Copy Register D (the first key) into Register A; LD does not change the flags.
64AD
If the NO CARRY FLAG is set (the line was not found), JUMP to 64C3H.
64AF
CP 2EH FE 2E
Compare Register A (the key) against 2EH, a period.
64B1
If the Z FLAG is set (period), JUMP to 64DDH to show the line found.
64B3
CP 2CH FE 2C
Compare Register A (the key) against 2CH, a comma.
64B5
If the Z FLAG is set (comma), JUMP to 64DDH to edit the line found.
64B7
CP 0AH FE 0A
Compare Register A (the key) against 0AH, the down arrow.
64B9
If the NZ FLAG is set (the up arrow), JUMP to 64C5H for the line before.
64BB
LD A,(HL) 7E
Load Register A with the low byte of the next line's link at Register Pair HL.
64BC
INC HL 23
INCrement Register Pair HL to the high byte of the link.
64BD
OR (HL) B6
OR the high byte of the link at Register Pair HL into Register A: the Z FLAG at the end of the program.
64BE
DEC HL 2B
DECrement Register Pair HL back to the next line.
64BF
If the NZ FLAG is set (there is a next line), JUMP to 64DFH to show it.
64C1
JUMP to 64DDH: the line found is the last, it is shown again.
64C3
If the Z FLAG is set (no higher line), JUMP to 64C9H for the last line of the program.
64C5
CP 5BH FE 5B
Compare Register A (the key) against 5BH, the up arrow.
64C7
If the NZ FLAG is set (not the up arrow), JUMP to 64DDH to show the line in Register Pair BC.
64C9
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
64CC
AND A A7
Clear the CARRY FLAG (AND A); Register A is not changed.
64CD
SBC HL,BC ED 42
SUBtract Register Pair BC from Register Pair HL: the Z FLAG when Register Pair BC is the first line.
64CF
If the Z FLAG is set (no line before it), JUMP to 64DDH to show it.
64D1
ADD HL,BC 09
ADD Register Pair BC back: Register Pair HL = the start of the program again.
64D2
LD D,B 50
Copy Register B (the high byte of the line) into Register D.
64D3
LD E,C 59
Copy Register C into Register E: Register Pair DE = the line whose predecessor is wanted.
64D4
LD B,H 44
Copy Register H (the high byte of the line looked at) into Register B.
64D5
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the line being looked at.
64D6
LD A,(HL) 7E
Load Register A with the low byte of its link at Register Pair HL.
64D7
INC HL 23
INCrement Register Pair HL to the high byte of the link.
64D8
LD H,(HL) 66
Load Register H with the high byte of the link at Register Pair HL.
64D9
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the next line.
64DA
RST 18H DF
RST 18H: compare Register Pair HL (the next line) against Register Pair DE.
64DB
If the NZ FLAG is set (not yet), LOOP BACK to 64D4H: Register Pair BC ends at the line before.
64DD
LD H,B 60
Copy Register B (the high byte of the line to show) into Register H.
64DE
LD L,C 69
Copy Register C into Register L: Register Pair HL = the line to show.
64DF
LD A,0FH 3E 0F
Load Register A with 0FH, the code that turns the cursor off.
64E1
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
64E4
LD A,1DH 3E 1D
Load Register A with 1DH, the code that moves the cursor to the start of the line.
64E6
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
64E9
POP AF F1
Restore Register Pair AF (Register A = the first key) from the stack.
64EA
POP BC C1
Discard the return address 1A7EH (POP BC into Register Pair BC): the ROM's LIST and EDIT go to READY themselves.
64EB
LD B,H 44
Copy Register H (the high byte of the line to show) into Register B.
64EC
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the line to show.
64ED
INC HL 23
INCrement Register Pair HL past the low byte of the link.
64EE
INC HL 23
INCrement Register Pair HL to the line's number.
64EF
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL.
64F0
INC HL 23
INCrement Register Pair HL to the high byte of the line number.
64F1
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the line number.
64F2
CP 2CH FE 2C
Compare Register A (the key) against 2CH, a comma.
64F4
If the Z FLAG is set (comma), JUMP to 2E65H, the ROM's EDIT of line Register Pair DE at Register Pair BC.
64F7
PUSH DE D5
Save Register Pair DE (the line number, the last to list) to the stack.
64F8
PUSH BC C5
Save Register Pair BC (the line, the first to list) to the stack.
64F9
LD HL,(4020H) 2A 20 40
Load Register Pair HL with the cursor's address from 4020H-4021H.
64FC
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 40H: one line of 64 characters back.
64FF
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the start of the line above.
6500
LD B,05H 06 05
Load Register B with 05H, the letters of READY.
6502
LD DE,1929H 11 29 19
Point Register Pair DE to 1929H, the ROM's READY message.
6505
LD A,(DE) 1A
Load Register A with a letter of READY at Register Pair DE.
6506
CP (HL) BE
Compare Register A against the character on the screen at Register Pair HL.
6507
If the NZ FLAG is set (they differ), JUMP to 6512H: the line above is not READY.
6509
INC DE 13
INCrement Register Pair DE to the next letter of READY.
650A
INC HL 23
INCrement Register Pair HL to the next character on the screen.
650B
DECrement Register B and LOOP BACK to 6505H for the 5 letters.
650D
LD A,1BH 3E 1B
Load Register A with 1BH, the code that moves the cursor up a line, onto READY.
650F
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
6512
LD A,1EH 3E 1E
Load Register A with 1EH, the code that erases to the end of the line.
6514
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
6517
JUMP to 2B33H, the ROM's LIST, from the line on the stack to the line number under it: one line.
651AH - A Line Was Typed
The ROM's collector RETurns here with Register Pair HL at the line, Register B = its length and the CARRY FLAG for BREAK. A line of a single letter A, D, E or L, alone or followed by a digit, period or minus sign (no left parenthesis or equal sign up to the 0DH), gets the letter changed into a token: AUTO, DELETE, EDIT or LIST. M and C give BASIC/OV3's functions 05H and 06H instead. The line then goes on at 0375H in the ROM's line input.
651A
PUSH AF F5
Save Register Pair AF (the CARRY FLAG of BREAK) to the stack.
651B
GOSUB to 5C93H to clear bits 2-0 of KFLAG$ (4423H): ENTER, pause and BREAK.
651E
POP AF F1
Restore Register Pair AF (the CARRY FLAG of BREAK) from the stack.
651F
PUSH AF F5
Save Register Pair AF to the stack, as the ROM does at 0374H.
6520
If the CARRY FLAG is set (BREAK), JUMP to 6569H to give the line to the ROM.
6522
PUSH BC C5
Save Register Pair BC (Register B = the length) to the stack.
6523
LD A,(HL) 7E
Load Register A with the first character of the line at Register Pair HL.
6524
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter made upper case.
6526
PUSH HL E5
Save Register Pair HL (the line) to the stack.
6527
LD HL,656BH 21 6B 65
Point Register Pair HL to 656BH, the byte before the table of letters.
652A
INC HL 23
INCrement Register Pair HL to the next letter of the table.
652B
INC (HL) 34
INCrement the byte at Register Pair HL, with the DEC next to set the flags.
652C
DEC (HL) 35
DECrement the byte at Register Pair HL back: the Z FLAG at the 00H that ends the table.
652D
If the Z FLAG is set (no letter matched), JUMP to 6567H.
652F
CP (HL) BE
Compare Register A (the first character) against the letter at Register Pair HL.
6530
INC HL 23
INCrement Register Pair HL to the letter's code.
6531
If the NZ FLAG is set (another letter), LOOP BACK to 652AH.
6533
LD C,(HL) 4E
Load Register C with the letter's code at Register Pair HL.
6534
POP HL E1
Restore Register Pair HL (the line) from the stack.
6535
PUSH HL E5
Save Register Pair HL (the line) to the stack again.
6536
RST 10H D7
RST 10H (6579H): Register Pair HL to the character after the letter, Register A = it; CARRY for a digit.
6537
If the CARRY FLAG is set (a digit), JUMP to 6545H.
6539
CP 2EH FE 2E
Compare Register A against 2EH, a period: the current line.
653B
If the Z FLAG is set (a period), JUMP to 6545H.
653D
CP 0DH FE 0D
Compare Register A against 0DH: the letter alone.
653F
If the Z FLAG is set (the letter alone), JUMP to 6552H to change it.
6541
CP 2DH FE 2D
Compare Register A against 2DH, a minus sign: a range of lines.
6543
If the NZ FLAG is set (anything else), JUMP to 6567H: the line is left as typed.
6545
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character, Register A = it.
6546
CP 28H FE 28
Compare Register A against 28H, a left parenthesis.
6548
If the Z FLAG is set, JUMP to 6567H: the line is left as typed.
654A
CP 3DH FE 3D
Compare Register A against 3DH, an equal sign.
654C
If the Z FLAG is set, JUMP to 6567H: the line is left as typed.
654E
CP 0DH FE 0D
Compare Register A against 0DH, the end of the line.
6550
If the NZ FLAG is set (more), LOOP BACK to 6545H.
6552
POP HL E1
Restore Register Pair HL (the line) from the stack.
6553
LD (HL),C 71
Store Register C (the code) at Register Pair HL, over the letter.
6554
LD A,C 79
Copy Register C (the code from the table) into Register A.
6555
CP 07H FE 07
Compare Register A against 07H: NO CARRY for a token.
6557
If the NO CARRY FLAG is set (a token), JUMP to 6568H to give the line to the ROM.
6559
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number (05H or 06H) in Register A' for 54B6H.
655A
POP BC C1
Restore Register Pair BC (Register B = the length) from the stack.
655B
POP AF F1
Discard the AF saved at 651FH (POP AF into Register Pair AF).
655C
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the line.
655D
LD L,B 68
Copy Register B (the length) into Register L.
655E
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the length.
6560
ADD HL,DE 19
ADD Register Pair DE (the line) to Register Pair HL: the byte after the line.
6561
LD (HL),00H 36 00
Store 00H at Register Pair HL: the end of the line.
6563
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the line.
6564
JUMP to 54B6H to load and enter BASIC/OV3 for M or C, which ends in the ROM (its EDIT exit 2FEBH or an error) and does not RETurn here.
6567
POP HL E1
Restore Register Pair HL (the line) from the stack.
6568
POP BC C1
Restore Register Pair BC (Register B = the length) from the stack.
6569
JUMP to 0375H, the ROM's line input after its collector: the 00H is put after the line.
656C-6577
DEFM "L" / DEFB B4H / DEFM "D" / DEFB B6H / DEFM "A" / DEFB B7H / DEFM "E" / DEFB 9DH / DEFM "M" / DEFB 05H / DEFM "C" / DEFB 06H 4C B4 44 B6 41 B7 45 9D 4D 05 43 06
656CH-6577H: the letters and their codes: L the token LIST (B4H), D DELETE (B6H), A AUTO (B7H), E EDIT (9DH); M and C BASIC/OV3's functions 05H and 06H. 656BH before it is the high byte of the JP at 6569H.
6578
DEFB 00H 00
6578H: 00H, the end of the table of letters (652CH).
6579H - The RST 10H Code
4003H JUMPs here (the LDIR at 530EH copies the vector) for every RST 10H. The ROM's own code (1D78H) fetches the character. Only for the statement fetch of the ROM's interpreter (return address 1D5BH) and a token: SET EOF (83H then E9H) [#]n sets a random file's end at its current place; RESTORE (90H) n makes READ start at line n. Else Register A and the flags are RETurned as the ROM gave them.
6579
GOSUB to 1D78H, the ROM's RST 10H code: Register Pair HL to the next character, Register A = it.
657C
RET Z C8
If the Z FLAG is set (the end of a statement), RETurn to the caller.
657D
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX) for the test.
657E
POP HL E1
Load Register Pair HL with the caller's return address (POP HL).
657F
PUSH HL E5
Save Register Pair HL (the return address) to the stack again.
6580
PUSH AF F5
Save Register Pair AF (the character and the flags) to the stack.
6581
LD DE,1D5BH 11 5B 1D
Load Register Pair DE with 1D5BH, the return address of the RST 10H at 1D5AH, the statement fetch.
6584
AND A A7
Clear the CARRY FLAG (AND A); Register A is not changed.
6585
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: the Z FLAG for the statement fetch.
6587
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
6588
If the NZ FLAG is set (another caller), JUMP to 65F0H to RETurn the character.
658A
CP 83H FE 83
Compare Register A (the token) against 83H, SET.
658C
If the NZ FLAG is set (not SET), JUMP to 65D0H.
658E
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
658F
RST 10H D7
RST 10H (6579H): Register Pair HL to the next character, Register A = it.
6590
CP E9H FE E9
Compare Register A against E9H, the token EOF.
6592
If the NZ FLAG is set (SET without EOF), JUMP to 65EFH: the ROM's SET.
6594
POP DE D1
Discard the text pointer saved at 658EH (POP DE into Register Pair DE).
6595
POP DE D1
Discard the character and flags saved at 6580H (POP DE into Register Pair DE).
6596
RST 10H D7
RST 10H (6579H): Register Pair HL past EOF, Register A = the next character.
6597
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
6599
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
659C
GOSUB to 2B1CH, the ROM: the file number as a byte in Register A.
659F
AND A A7
Set the flags from Register A (AND A): the Z FLAG for file 0.
65A0
If the Z FLAG is set (file 0), JUMP to 6438H, Bad file number (E = 68H).
65A3
GOSUB to 5CFCH for file Register A: Register Pair BC = its buffer, Register A = its mode.
65A6
If the Z FLAG is set (the file is closed), JUMP to 6438H, Bad file number (E = 68H).
65A9
CP 03H FE 03
Compare Register A (the mode) against 03H, random.
65AB
If the NZ FLAG is set (not random), JUMP to 6435H, Bad file mode (E = 6CH).
65AE
LD D,B 50
Copy Register B (the high byte of the buffer) into Register D.
65AF
LD E,C 59
Copy Register C (the low byte) into Register E: Register Pair DE = the buffer.
65B0
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
65B1
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
65B2
GOSUB to 444BH, @CKEOF: the Z FLAG when the place is inside the file.
65B5
If the NZ FLAG is set (at the end or past it), JUMP to 65CCH: nothing changes.
65B7
PUSH DE D5
Save Register Pair DE (the FCB) to the stack.
65B8
POP IX DD E1
Load Index Register IX with the FCB from the stack (POP IX).
65BA
LD E,(IX+0AH) DD 5E 0A
Load Register E with +0AH of the FCB at Index Register IX: the low byte of the next record number.
65BD
LD D,(IX+0BH) DD 56 0B
Load Register D with +0BH of the FCB at Index Register IX: the high byte of the next record number.
65C0
LD A,(IX+05H) DD 7E 05
Load Register A with +05H of the FCB at Index Register IX: the place in the record.
65C3
LD (IX+0CH),E DD 73 0C
Store Register E at +0CH of the FCB at Index Register IX: the low byte of the last record number.
65C6
LD (IX+0DH),D DD 72 0D
Store Register D at +0DH of the FCB at Index Register IX: the high byte of the last record number.
65C9
LD (IX+08H),A DD 77 08
Store Register A at +08H of the FCB at Index Register IX: the end of file byte, the place in the record.
65CC
POP DE D1
Discard the return address 1D5BH (POP DE into Register Pair DE): SET EOF is done here.
65CD
JUMP to 1D1EH, the ROM's next statement, as the interpreter would.
65D0
CP 90H FE 90
Compare Register A (the token) against 90H, RESTORE.
65D2
If the NZ FLAG is set (not RESTORE), JUMP to 65F0H to RETurn the character.
65D4
POP DE D1
Discard the saved character and flags (POP DE into Register Pair DE).
65D5
POP DE D1
Discard the return address 1D5BH (POP DE into Register Pair DE): RESTORE is done here.
65D6
LD DE,1D1EH 11 1E 1D
Load Register Pair DE with 1D1EH, the ROM's next statement.
65D9
PUSH DE D5
Save Register Pair DE (1D1EH) to the stack: the RETurns below go there.
65DA
RST 10H D7
RST 10H (6579H): Register Pair HL past RESTORE, Register A = the next character; the Z FLAG at the end.
65DB
If the Z FLAG is set (no line number), JUMP to 1D91H, the ROM's RESTORE: READ starts at the first DATA.
65DE
GOSUB to 1E5AH, the ROM: the line number at Register Pair HL in Register Pair DE.
65E1
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
65E2
GOSUB to 1B2CH, the ROM: find line Register Pair DE; CARRY when found, Register Pair BC = the line.
65E5
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
65E6
If the NO CARRY FLAG is set (no such line), JUMP to 1ED9H, the ROM's Undefined line.
65E9
DEC BC 0B
DECrement Register Pair BC to the byte before the line.
65EA
LD (40FFH),BC ED 43 FF 40
Store Register Pair BC at 40FFH-4100H, the place READ goes on from.
65EE
RET C9
RETurn to 1D1EH, the ROM's next statement, with READ set to line n.
65EF
POP HL E1
Restore Register Pair HL (the text pointer at SET) from the stack.
65F0
POP AF F1
Restore Register Pair AF (the character and the flags) from the stack.
65F1
RET C9
RETurn to the caller with Register A and the flags from the ROM's RST 10H code.
65F2H - Work Cells
The last bytes of the file, 00H in the file, and the memory BASIC/CMD uses above it (not in the file): the table of the file buffers, the USR vectors and two flags. The file buffers follow from 6632H (5397H, 53CFH).
65F2
DEFB 00H 00
65F2H: a byte of 00H; file 0's slot points here while the ROM clears (5CBCH, 5EB7H), so file 0 reads as closed.
65F3
DEFB 00H 00
65F3H: the record length of the file in FIELD (stored at 608FH, read at 60BAH).
65F4
DEFB 00H 00
65F4H: the run state of a load: 00H LOAD or MERGE, FFH RUN, the option character, or D6H for a RUN with V (BASIC/OV3). Read at 5A43H, 5C28H, 5F4DH and 5FAAH.
65F5
DEFB 00H 00
65F5H: the number of files set aside (408EH), kept across the ROM's NEW and RUN set up (5E89H, 5ED0H, 5F9CH, 5FA4H).
65F6
DEFB 00H 00
65F6H: 00H for GET, else PUT (stored at 6206H, read at 624CH and 625BH).
65F7
DEFB 00H 00
65F7H: the last LDOS error, stored by BASIC/OV3 function 02H and read by CMD"E" at 584AH.
65F8-65F9
DEFW 0000H 00 00
65F8H-65F9H: the buffer of the current file, 0000H for none: set by 5CC6H, 5CEAH, 5EDCH and 6373H, cleared by 587BH as a PRINT ends.
65FA-65FB
DEFW 0000H 00 00
65FAH-65FBH: file 0's slot in the table of the buffers' addresses (53D3H); the slots of files 1-15 follow beyond the file.
65FC-6619
DEFS 30
65FCH-6619H: not in the file. The slots of files 1-15 in the table of the buffers' addresses, built at 53E5H and read by 5D07H.
661A-661B
DEFS 2
661AH-661BH: not in the file. The address of buffer 0 (6632H, 53E2H), put back in file 0's slot at 5CC9H and 5ED6H and read by KILL through the slot.
661C-662F
DEFS 20
661CH-662FH: not in the file. The ten USR vectors, 642FH (Undefined user function) until DEF USR sets one (539AH, 5727H).
6630
DEFS 1
6630H: not in the file. The RUN flag: FFH while RUN opens its program (5E74H), cleared at 53A8H, 63CBH and 63EFH.
6631
DEFS 1
6631H: not in the file. The protection flag: FFH for a program that may run but not be looked at (63D4H); 63EDH clears memory when it is set.