LDOS 5.3.1 for the Model III - BASIC/CMD Disassembled

Page Customization

Introduction/Summary

LDOS 5.3.1 BASIC/CMD Disassembly - Disk BASIC for the Model III ROM (Model III)

BASIC/CMD adds the disk to the BASIC of the Model III ROM: BASIC [*] [(FILES=n,MEM=a,BLK=sw,EXT=sw,HIGH|LOW)] [command]. The ROM jumps through 49 vectors at 4152H-41E4H for the disk keywords and calls them at its exits (output of a byte, the keyboard, a line typed, READY, an error, CLEAR, PRINT, INPUT, LIST); without a disk they hold RET or an error. The start (52ECH, the transfer address) copies the image at 4E00H to those vectors and the restart vectors to 4000H-400BH, so RST 10H goes to 658DH, reads the parameters with @PARAM, lays out the file buffers above the code and starts the ROM's BASIC. The code of the start (5329H on) then becomes the line buffer, and 543CH holds the filespecs.

The file is a load module of 5438 bytes: a copyright record, the vector image 4E00H-4E9EH, the code and data 5200H-660FH, and the transfer address 52ECH. BASIC/OV3 is loaded at 4E00H when it is needed (54DEH); BASIC/OV1, BASIC/OV2 and BASIC/OV4 are run over 5200H by CMD"N", CMD"X" and CMD"V".

The Parameters

ParameterCellMeaning in the code
FILES, F53E9HThe number of files, 0-15 (3 if not given), to 408EH. Buffers for files 0 to n are laid out from 6646H, 0122H bytes each (53F7H). File 0 is kept for LOAD, SAVE, MERGE, RUN and KILL; OPEN and SET EOF refuse it.
MEM, M5426HThe top of memory for BASIC, not above HIGH$ (5425H).
BLK, B53E2HOn (the default): 408FH not 00H, each buffer 0222H bytes, and OPEN "R" takes a record length; off: only records of 256 bytes (Blocked file error).
HIGH, H
LOW, L
0000H
53DAH
The cassette speed, only in the Model III file: LOW stores 00H at 4211H, the ROM's cassette speed, for 500 baud; without it 4211H gets FFH, 1500 baud (53D9H). HIGH's cell is 0000H, so HIGH changes nothing.
EXT, E6399HOn (the default): the program file of LOAD, SAVE, MERGE and RUN gets /BAS when it has no extension (@FEXT at 63A6H).

BASIC with an asterisk first goes back to the program in memory (5364H). More text after the parameters is run as a line typed at READY.

Files

Each buffer starts with the mode (00H closed, 01H input, 02H output, 03H random), the column of PRINT, the FCB (32 bytes) and, from buffer + 22H, the sector or the record. 660CH holds the buffer of the current file: the exits for a byte out (5C0EH), the keyboard (5C1CH), a line in (5BDFH), PRINT and INPUT send the ROM's own input and output to it, and 589FH ends it when PRINT ends. LOAD and MERGE of a program saved with A, and RUN of one, work through these exits: the ROM's command loop reads the lines of the file as if typed, and at its end the program is run or READY shown (5C36H). A program saved without A is read straight into memory (5EFDH).

The errors of BASIC/CMD are E values for the ROM's error handler (6443H); an LDOS error goes through BASIC/OV3 (6463H), which also gives the long messages of every error (5A66H). A program the DOS lets run but not be read (bit 1 of SFLAG$ after @OPEN for RUN) sets 6645H; then the next READY or line typed clears memory with Protection has cleared memory (6401H).

About This Page

Every byte is shown at its address in the file. The ROM routines named are those of the Model III ROM, version 3.1 (BASIC's routines and the exits through the vectors are at the same addresses as in the Level II ROM of the Model I, version 1.3); jumps into the ROM link to its page where it has a row there. The Model III file is the Model I file with these changes: the parameters HIGH and LOW (52CBH-52EAH, 53D9H-53E0H); TIME$ is the ROM's own (vector 12, JP 3030H; the Model I code for it is gone); CMD"R" and CMD"T" turn the clock display on and off through the ROM (5836H) instead of enabling and disabling the interrupts; the screen print sends every code as it is (583CH); the wide character mode is bit 2 of 4210H (5A28H); 5C8DH points the BREAK vector at 4203H to READY; the line buffer starts at 5331H; and the operands that name the Model III resident area (OSVER$ 441FH, KFLAG$ 429FH, HIGH$ 4411H, the stack 41E5H and the others). Found in the code: the end address worked out at 5F4FH-5F59H is not used, as 1AF8H loads Register Pair HL itself; a file open for input is never given to @CLOSE (61A8H); an error of @LOC or @LOF becomes Overflow (61DBH); EOF of a closed file is not refused (618FH); the LD SP,HL at 5A71H is never reached; 40A9H (5C61H) and 528AH are written and never read; the JP NC,2423H at 566DH is never taken; FIELD does not test a total of 256 bytes against a shorter record (60D1H); and in LSET and RSET the path that keeps x$ safe when string space is short calls 2884H, which RETurns through the lengths on the stack (6185H).

Memory Map

Load Blocks

The file starts with a copyright record (type 1FH), then 22 load blocks with 5295 bytes in two parts, and the transfer address 52ECH.

AddressContents
4E00H-4E9EH159 bytes in 1 load blocks
5200H-660FH5136 bytes in 21 load blocks

The Parts of the File

AddressContents
4E00H-4E92HThe image of the 49 vectors, copied to 4152H-41E4H (4E00H); BASIC/OV3 is loaded here later.
4E93H-4E9EHThe image of the restart vectors, copied to 4000H-400BH.
5200H-52EBHThe banner, the messages and the table of @PARAM; BASIC/OV1, BASIC/OV2 and BASIC/OV4 run over this area.
52ECH-547BHThe start, used once; from 5331H the line buffer (40A7H), and 543CH holds a filespec (62B5H).
547CH-561EHCMD with a command of LDOS, BASIC/OV3's loader and the way back from a command.
561FH-58A5HFN, DEF FN, USR, DEF USR, PRINT#, the letters of CMD.
58A6H-5CEDHINPUT#, INPUT@ and its field editor, LINE INPUT, INSTR, &H, MID$ =, and the exits of the ROM for a current file.
5CEEH-646CHThe files: #n, MKI$ and CVI, INPUT# fields, MERGE, LOAD, RUN, SAVE, CLOSE, FIELD, LSET, RSET, EOF, LOC, LOF, PUT, GET, OPEN, KILL, the errors.
646DH-6605HThe command line at READY and the RST 10H code (SET EOF and RESTORE n).
6606H-660FHWork cells.
6610H-6645HNot in the file: the table of the buffers, the USR vectors and two flags.
6646H upNot in the file: the file buffers, then the program text.

Sections of the Disassembly

AddressContents
4E00HThe Image of the Disk BASIC Vectors
4E93HThe Image of the Restart Vectors
5200HThe Banner, the Messages and the Parameter Table
52ECHThe Start: Saving the State, the Vectors, the Stack
5364HThe LDOS Version, and Going Back to the Program
53B7HA New Start: the USR Vectors and the Parameters
53F7HBuild the File Buffers
5425HMEM
5449HThe Banner and the Start of BASIC
547CHCMD"command": an Overlay or a Command of LDOS
54CDHThe Name of an Overlay
54DEHCall BASIC/OV3
5509HCopy a Command
5514HCMD"command": Run an LDOS Command and Come Back
55B8HThe Module Header and the Three Ways Back
55C6HThe Way Back
5613HFind a Function's Name
561FHFN: Call a Function Defined by DEF FN
5700HDEF: DEF FN and DEF USR
5723HUSR: Call a Machine Language Routine
5743HThe Number of a USR
5755HDEF USR
5764HPRINT#: a File Number
5770HON or OFF
578CHCMD"L": Load a Program File
579EHCMD"P": the Printer's Status
57CBHCMD"B": the BREAK Key
57E2HBack to LDOS
57EEHCMD: the Letters
5836HCMD"R" and CMD"T": the Clock Display
583CHCMD with an Asterisk: Print the Screen
5858HCMD"O": Sort an Array
585EHCMD"I": Run a Command and Stay in LDOS
586EHCMD"E": the Last LDOS Error
5876HCMD"D": DEBUG
588BHThe Text of a CMD
589FHThe End of PRINT
58A6HINPUT# and INPUT@
5936HLINE INPUT
596DHRead a Field
5984HField Editor
59C2HErase One Character
59D6HTake a Printable Character
5A06HEnd the Field
5A28HCursor Left
5A3FHCursor Up at the Left Edge
5A4BHDisplay the Fill Character
5A50HINPUT and LIST With a File
5A66HError Messages
5A85HINSTR
5B0DH&
5B5EHMID$ =
5BD1HOptional Count
5BDFHLine Input From a File
5C0EHByte Output to a File
5C1CHKeyboard Exit
5C61HBREAK and Pause
5C8DHPoint the BREAK Vector at READY, Then Clear KFLAG$
5C95HRead KFLAG$
5CA7HClear the Key Flags
5CB2HComma and TAB to a File
5CCAHBefore CLEAR
5CD7HAfter CLEAR
5CE4HA Number to a File
5CEEH#n: Make a File Current
5D03HThe Buffer of File n
5D27HMKI$, MKS$ and MKD$
5D40HCVI, CVS and CVD
5D5DHREAD and INPUT From a File
5D71HLINE INPUT#
5E2AHKeep a Byte
5E33HOpen a Program File
5E39HBack Up One Byte
5E56HMERGE
5E78HA Starting Line
5E84HRUN and LOAD a Program
5F70HBring the Variables Back
5FACHThe End of a Load
5FD8HREADY Exit
5FECHA Line Typed
6000HSAVE
6057HCLOSE
6088HClose Every File
6092HFIELD
60ECHRSET and LSET
6170HSpaces
6179HKeep x$ Safe
618FHEOF
61A8HClose One File
61C6HLOC and LOF
61E4HA Byte to the Current File
6218HPUT and GET
628FHRead a Byte of the Current File
62B5HA Filespec Into an FCB
62EFHOPEN
6401HThe Protection Test
6426HKILL
6443HBASIC Errors
646DHThe Command Line at READY
652EHA Line Was Typed
658DHThe RST 10H Code
6606HWork Cells

Memory BASIC/CMD Uses

AddressContents
0013H, 001BH, 0033H, 0049HThe ROM: $GET, $PUT, display a character, wait for a key.
4000H-400BHThe restart vectors RST 08H-RST 20H, RST 10H to 658DH.
4020H-4021HThe cursor of the display.
4210H, 4211HThe copy of port ECH: bit 2, wide characters; bit 0, the clock display (0298H, 02A1H). The ROM's cassette speed (LOW).
4203H-4205HThe JP the ROM's waits take on BREAK: its operand gets 1A19H, READY (5C8DH).
4080H-41E4HThe ROM's cells; 4152H-41E4H the 49 vectors. 408EH the number of files, 408FH the blocked mode flag (under LDOS BASIC's, not the ROM's).
40A0H, 40A4H, 40A7H, 40D6H, 40DFH, 40E8H, 40EAH, 40ECH, 40F9H, 40FBH, 40FDH, 40FFHThe ROM's pointers: string space, the program, the line buffer, the next free string byte, a text pointer, the stack, the error line, the current line, the variables, the arrays, the end of the arrays, READ.
4411H-4412HHIGH$.
4414HOVRLY$: 01H while BASIC/OV3 is at 4E00H.
442BHSFLAG$: bit 1 run only, bit 2 a load to run, bit 4 BREAK off, bit 5 a JCL job.
4405HThe BREAK trap.
4225HINBUF$: the command line of LDOS (CMD).
429FHKFLAG$: bits 0 (BREAK), 1 (pause) and 2 (ENTER).
4285H@KITSK.
441CH, 4420H, 4424H, 4428H, 442CH, 4436H, 4439H, 443FH, 4442H, 4445H, 4448H, 4458H, 446DH, 4470H@FSPEC, @INIT, @OPEN, @CLOSE, @KILL, @READ, @WRITE, @REW, @POSN, @BKSP, @PEOF, @CKEOF, @LOC, @LOF.
444BH, 4454H, 428AH@FEXT, @PARAM, @LOGOT.
4485HCFCB$: the control block of the overlays.

Variables

The vectors, the data of the file and the memory above it, and the operands BASIC/CMD changes while it runs.

The Vectors

Vector
Address
RoutineUse
0
4152H
5D40HCVI keyword (the ROM goes to 4152H for it).
1
4155H
561FHFN keyword (the ROM goes to 4155H for it).
2
4158H
5D43HCVS keyword (the ROM goes to 4158H for it).
3
415BH
5700HDEF keyword (the ROM goes to 415BH for it).
4
415EH
5D46HCVD keyword (the ROM goes to 415EH for it).
5
4161H
618FHEOF keyword (the ROM goes to 4161H for it).
6
4164H
61C6HLOC keyword (the ROM goes to 4164H for it).
7
4167H
61CBHLOF keyword (the ROM goes to 4167H for it).
8
416AH
5D27HMKI$ keyword (the ROM goes to 416AH for it).
9
416DH
5D2AHMKS$ keyword (the ROM goes to 416DH for it).
10
4170H
5D2DHMKD$ keyword (the ROM goes to 4170H for it).
11
4173H
57EEHCMD keyword (the ROM goes to 4173H for it).
12
4176H
3030HTIME$ keyword (the ROM goes to 4176H for it): the Model III ROM's own TIME$.
13
4179H
62EFHOPEN keyword (the ROM goes to 4179H for it).
14
417CH
6092HFIELD keyword (the ROM goes to 417CH for it).
15
417FH
6219HGET keyword (the ROM goes to 417FH for it).
16
4182H
6218HPUT keyword (the ROM goes to 4182H for it).
17
4185H
6057HCLOSE keyword (the ROM goes to 4185H for it).
18
4188H
5E8CHLOAD keyword (the ROM goes to 4188H for it).
19
418BH
5E56HMERGE keyword (the ROM goes to 418BH for it).
20
418EH
1E4AH, the ROMNAME keyword (the ROM goes to 418EH for it). LBASIC has no NAME: 1E4AH is the ROM's Illegal function call error (FC).
21
4191H
6426HKILL keyword (the ROM goes to 4191H for it).
22
4194H
5B0DH& keyword (the ROM goes to 4194H for it).
23
4197H
60EDHLSET keyword (the ROM goes to 4197H for it).
24
419AH
60ECHRSET keyword (the ROM goes to 419AH for it).
25
419DH
5A85HINSTR keyword (the ROM goes to 419DH for it).
26
41A0H
6000HSAVE keyword (the ROM goes to 41A0H for it).
27
41A3H
5936HLINE keyword (the ROM goes to 41A3H for it).
28
41A6H
5A66Herror exit, CALLed by the ROM's error routine at 19ECH: LBASIC gives its long error messages there.
29
41A9H
5723HUSR link, CALLed by the ROM's USR at 27FEH.
30
41ACH
5FD8HREADY exit, CALLed by the ROM at 1A1CH.
31
41AFH
5BDFHline input exit, CALLed by the ROM at 0368H.
32
41B2H
5FECHexit CALLed by the ROM at 1AA1H after a line is tokenized.
33
41B5H
5CCAHexit CALLed by the ROM at 1AECH after the line links are rebuilt.
34
41B8H
5CD7Hexit CALLed by the ROM at 1AF2H, after the line links and a CLEAR.
35
41BBH
6088Hexit CALLed by the ROM at 1B8CH (NEW) and 1DB0H (END).
36
41BEH
589FHexit CALLed by the ROM at 2174H as a PRINT ends.
37
41C1H
5C0EHbyte output exit, CALLed by the ROM at 032CH for every byte sent to a device.
38
41C4H
5C1CHkeyboard scan exit, CALLed by the ROM at 0358H.
39
41C7H
5E84HRUN exit, CALLed by the ROM at 1EA6H.
40
41CAH
5764HPRINT exit, CALLed by the ROM at 206FH.
41
41CDH
5CE4Hexit CALLed by the ROM at 20C6H after a number is made text.
42
41D0H
5CE3Hexit CALLed by the ROM at 2103H after PRINT sends a new line.
43
41D3H
5CB2Hexit CALLed by the ROM at 2108H and 2141H (a comma field, TAB).
44
41D6H
58A6HINPUT exit, CALLed by the ROM at 219EH.
45
41D9H
5B5EHMID$ exit, reached by the ROM's JP at 2AECH (MID$ on the left of an assignment).
46
41DCH
5D5DHexit CALLed by the ROM at 222DH as READ or INPUT takes the next field.
47
41DFH
5A50Hexit CALLed by the ROM at 2278H (after INPUT assigns) and 2B44H (LIST).
48
41E2H
02B8H, the ROMSYSTEM exit, CALLed by the ROM at 02B2H. 02B8H is past the ROM's LD SP,4388H at 02B5H, so the stack stays where it is, with the CALL's return address left on it.

Data in the File and the Memory Above It

Address
Size
Contents
5200H
1 byte
DEFB 0DH
5200H: 0DH, a new line before the banner (5449H displays it through STROUT).
5201H-5221H
33 bytes
DEFM "LBASIC - Version 5.3.1 - 08/01/91"
5201H-5221H: the first line of the banner, the name, version and date of LBASIC.
5222H
1 byte
DEFB 0DH
5222H: 0DH, a new line before the copyright line of the banner.
5223H-524DH
43 bytes
DEFM "(C) 1991 MISOSYS, Inc., All rights reserved"
5223H-524DH: the copyright line of the banner.
524EH-524FH
2 bytes
DEFB 0DH, 0DH
524EH-524FH: 0DH, 0DH: two new lines after the copyright line of the banner.
5250H
1 byte
DEFB 00H
5250H: 00H, the end of the banner for STROUT.
5251H-5253H
3 bytes
DEFM "V12"
5251H-5253H: the characters V12. No code of BASIC/CMD or of its overlays addresses them.
5254H-5269H
22 bytes
DEFM "Use LDOS 5.3 or later!"
5254H-5269H: the text of 536BH when OSVER$ (441FH) is below 51H.
526AH
1 byte
DEFB 0DH
526AH: 0DH, a new line after the text Use LDOS 5.3 or later!
526BH
1 byte
DEFB 00H
526BH: 00H, the end of the text for the ROM's STROUT (536EH).
526CH-527AH
15 bytes
DEFM "Parameter error"
526CH-527AH: the text of 53B2H for a parameter @PARAM refuses or a FILES value out of range.
527BH
1 byte
DEFB 0DH
527BH: 0DH, the end of the text Parameter error for @LOGOT.
527CH-5288H
13 bytes
DEFM "Out of memory"
527CH-5288H: the text of 53A8H when MEM is above HIGH$ or leaves too little room.
5289H
1 byte
DEFB 0DH
5289H: 0DH, the end of the text Out of memory for @LOGOT.
528AH
1 byte
DEFB 00H
528AH: 00H, stored again by 535FH. No code reads it.
528BH-5292H
8 bytes
DEFM "MEM " / DEFW 5426H
528BH-5292H: MEM, the highest address BASIC may use: the cell 5426H, the operand of LD DE at 5425H.
5293H-529AH
8 bytes
DEFM "M " / DEFW 5426H
5293H-529AH: M, the short form of MEM: 5426H.
529BH-52A2H
8 bytes
DEFM "FILES " / DEFW 53E9H
529BH-52A2H: FILES, the number of file buffers: the cell 53E9H, the operand of LD DE at 53E8H (0003H in the file).
52A3H-52AAH
8 bytes
DEFM "F " / DEFW 53E9H
52A3H-52AAH: F, the short form of FILES: 53E9H.
52ABH-52B2H
8 bytes
DEFM "BLK " / DEFW 53E2H
52ABH-52B2H: BLK, blocked files: the cell 53E2H, the operand of LD DE at 53E1H (FFFFH in the file, on).
52B3H-52BAH
8 bytes
DEFM "B " / DEFW 53E2H
52B3H-52BAH: B, the short form of BLK: 53E2H.
52BBH-52C2H
8 bytes
DEFM "EXT " / DEFW 6399H
52BBH-52C2H: EXT, the switch of the default extension /BAS: the cell 6399H, the operand of LD HL at 6398H (FFFFH in the file, on; 0000H for OFF).
52C3H-52CAH
8 bytes
DEFM "E " / DEFW 6399H
52C3H-52CAH: E, the short form of EXT: the switch at 6399H.
52CBH-52D2H
8 bytes
DEFM "HIGH " / DEFW 0000H
52CBH-52D2H: HIGH, 1500 baud, the default: cell 0000H, no effect.
52D3H-52DAH
8 bytes
DEFM "H " / DEFW 0000H
52D3H-52DAH: H, the short form of HIGH.
52DBH-52E2H
8 bytes
DEFM "LOW " / DEFW 53DAH
52DBH-52E2H: LOW, 500 baud: the cell 53DAH, the operand of LD DE at 53D9H.
52E3H-52EAH
8 bytes
DEFM "L " / DEFW 53DAH
52E3H-52EAH: L, the short form of LOW.
52EBH
1 byte
DEFB 00H
52EBH: 00H, the end of the table of the parameters.
54B5H-54BCH
8 bytes
DEFM "BASIC/OV"
54B5H-54BCH: the name of the overlays without the digit, copied to 4485H by 54CDH.
54BDH-54CAH
14 bytes
DEFM "Can't load OV3"
54BDH-54CAH: the text of 54FDH when BASIC/OV3 cannot be loaded.
54CBH-54CCH
2 bytes
DEFB 0DH, 00H
54CBH-54CCH: 0DH, a new line, and 00H, the end of the text for STROUT.
55BAH-55BBH
2 bytes
DEFW 0000H
55BAH-55BBH: the header's link word: HIGH$ before the move, stored by 5551H.
55BCH
1 byte
DEFB 01H
55BCH: 01H, the length of the module's name, one character.
55BDH
1 byte
DEFM "&"
55BDH: &, the name of the module that holds BASIC's memory.
6580H-658BH
12 bytes
DEFM "L" / DEFB B4H / DEFM "D" / DEFB B6H / DEFM "A" / DEFB B7H / DEFM "E" / DEFB 9DH / DEFM "M" / DEFB 05H / DEFM "C" / DEFB 06H
6580H-658BH: 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. 657FH before it is the high byte of the JP at 657DH.
658CH
1 byte
DEFB 00H
658CH: 00H, the end of the table of letters (6540H).
6606H
1 byte
DEFB 00H
6606H: a byte of 00H; file 0's slot points here while the ROM clears (5CD0H, 5ECBH), so file 0 reads as closed.
6607H
1 byte
DEFB 00H
6607H: the record length of the file in FIELD (stored at 60A3H, read at 60CEH).
6608H
1 byte
DEFB 00H
6608H: 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 5A67H, 5C36H, 5F61H and 5FBEH.
6609H
1 byte
DEFB 00H
6609H: the number of files set aside (408EH), kept across the ROM's NEW and RUN set up (5E9DH, 5EE4H, 5FB0H, 5FB8H).
660AH
1 byte
DEFB 00H
660AH: 00H for GET, else PUT (stored at 621AH, read at 6260H and 626FH).
660BH
1 byte
DEFB 00H
660BH: the last LDOS error, stored by BASIC/OV3 function 02H and read by CMD"E" at 586EH.
660CH-660DH
2 bytes
DEFW 0000H
660CH-660DH: the buffer of the current file, 0000H for none: set by 5CDAH, 5CFEH, 5EF0H and 6387H, cleared by 589FH as a PRINT ends.
660EH-660FH
2 bytes
DEFW 0000H
660EH-660FH: file 0's slot in the table of the buffers' addresses (53FBH); the slots of files 1-15 follow beyond the file.
6610H-662DH
30 bytes
DEFS 30
6610H-662DH: not in the file. The slots of files 1-15 in the table of the buffers' addresses, built at 540DH and read by 5D1BH.
662EH-662FH
2 bytes
DEFS 2
662EH-662FH: not in the file. The address of buffer 0 (6646H, 540AH), put back in file 0's slot at 5CDDH and 5EEAH and read by KILL through the slot.
6630H-6643H
20 bytes
DEFS 20
6630H-6643H: not in the file. The ten USR vectors, 6443H (Undefined user function) until DEF USR sets one (53BAH, 574FH).
6644H
1 byte
DEFS 1
6644H: not in the file. The RUN flag: FFH while RUN opens its program (5E88H), cleared at 53C8H, 63DFH and 6403H.
6645H
1 byte
DEFS 1
6645H: not in the file. The protection flag: FFH for a program that may run but not be looked at (63E8H); 6401H clears memory when it is set.

Operands Changed While It Runs

Address
Size
Contents
5321H-5322H
2 bytes
The word of 408EH-408FH at the start (530CH).
5374H
1 byte
The first character of the command line: 2AH for BASIC with an asterisk (52F4H).
5380H-5381H
2 bytes
The top of string space at the start (5312H).
5386H-5387H
2 bytes
The start of the program text at the start (5306H).
53CCH-53CDH
2 bytes
The command line for @PARAM (52F7H).
53E2H-53E3H
2 bytes
The BLK cell (@PARAM).
53E9H-53EAH
2 bytes
The FILES cell (@PARAM).
5426H-5427H
2 bytes
The MEM cell: HIGH$ unless MEM is given (5300H).
5431H
1 byte
00H stored at 5450H; never read.
5593H-5594H, 559AH-559BH, 55C0H-55C1H, 55E2H-55E3H, 55E7H-55E8H, 55EDH-55EEH
2 bytes each
The way back from a command of LDOS (5542H-558FH).
5A4CH
1 byte
The fill character of INPUT@ (598BH).
5F72H-5F73H, 5F79H-5F7AH, 5F85H-5F86H, 5F92H-5F93H, 5F98H-5F99H
2 bytes each
The old pointers of a RUN with V, stored by BASIC/OV3.
5FC6H-5FC7H
2 bytes
The starting line of RUN and LOAD (5E7FH, 5E93H).
6399H-639AH
2 bytes
The EXT cell (@PARAM).
63A0H
1 byte
The file number of OPEN (6348H).

Disassembly

4E00H - The Image of the Disk BASIC Vectors

Not run here: 535AH 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, 54DEH). Each row names its vector.

4E00
Vector 0, copied to 4152H: JP 5D40H to the CVI keyword (the ROM goes to 4152H for it).
4E03
Vector 1, copied to 4155H: JP 561FH to the FN keyword (the ROM goes to 4155H for it).
4E06
Vector 2, copied to 4158H: JP 5D43H to the CVS keyword (the ROM goes to 4158H for it).
4E09
Vector 3, copied to 415BH: JP 5700H to the DEF keyword (the ROM goes to 415BH for it).
4E0C
Vector 4, copied to 415EH: JP 5D46H to the CVD keyword (the ROM goes to 415EH for it).
4E0F
Vector 5, copied to 4161H: JP 618FH to the EOF keyword (the ROM goes to 4161H for it).
4E12
Vector 6, copied to 4164H: JP 61C6H to the LOC keyword (the ROM goes to 4164H for it).
4E15
Vector 7, copied to 4167H: JP 61CBH to the LOF keyword (the ROM goes to 4167H for it).
4E18
Vector 8, copied to 416AH: JP 5D27H to the MKI$ keyword (the ROM goes to 416AH for it).
4E1B
Vector 9, copied to 416DH: JP 5D2AH to the MKS$ keyword (the ROM goes to 416DH for it).
4E1E
Vector 10, copied to 4170H: JP 5D2DH to the MKD$ keyword (the ROM goes to 4170H for it).
4E21
Vector 11, copied to 4173H: JP 57EEH to the CMD keyword (the ROM goes to 4173H for it).
4E24
Vector 12, copied to 4176H: JP 3030H, the Model III ROM's own TIME$ routine (3030H jumps to 3799H); the ROM goes to 4176H for the TIME$ keyword. BASIC/CMD for the Model III has no TIME$ code of its own (the Model I file has one at 5A61H).
4E27
Vector 13, copied to 4179H: JP 62EFH to the OPEN keyword (the ROM goes to 4179H for it).
4E2A
Vector 14, copied to 417CH: JP 6092H to the FIELD keyword (the ROM goes to 417CH for it).
4E2D
Vector 15, copied to 417FH: JP 6219H to the GET keyword (the ROM goes to 417FH for it).
4E30
Vector 16, copied to 4182H: JP 6218H to the PUT keyword (the ROM goes to 4182H for it).
4E33
Vector 17, copied to 4185H: JP 6057H to the CLOSE keyword (the ROM goes to 4185H for it).
4E36
Vector 18, copied to 4188H: JP 5E8CH to the LOAD keyword (the ROM goes to 4188H for it).
4E39
Vector 19, copied to 418BH: JP 5E56H 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 6426H to the KILL keyword (the ROM goes to 4191H for it).
4E42
Vector 22, copied to 4194H: JP 5B0DH to the & keyword (the ROM goes to 4194H for it).
4E45
Vector 23, copied to 4197H: JP 60EDH to the LSET keyword (the ROM goes to 4197H for it).
4E48
Vector 24, copied to 419AH: JP 60ECH to the RSET keyword (the ROM goes to 419AH for it).
4E4B
Vector 25, copied to 419DH: JP 5A85H to the INSTR keyword (the ROM goes to 419DH for it).
4E4E
Vector 26, copied to 41A0H: JP 6000H to the SAVE keyword (the ROM goes to 41A0H for it).
4E51
Vector 27, copied to 41A3H: JP 5936H to the LINE keyword (the ROM goes to 41A3H for it).
4E54
Vector 28, copied to 41A6H: JP 5A66H 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 5723H to the USR link, CALLed by the ROM's USR at 27FEH.
4E5A
Vector 30, copied to 41ACH: JP 5FD8H to the READY exit, CALLed by the ROM at 1A1CH.
4E5D
Vector 31, copied to 41AFH: JP 5BDFH to the line input exit, CALLed by the ROM at 0368H.
4E60
Vector 32, copied to 41B2H: JP 5FECH to the exit CALLed by the ROM at 1AA1H after a line is tokenized.
4E63
Vector 33, copied to 41B5H: JP 5CCAH to the exit CALLed by the ROM at 1AECH after the line links are rebuilt.
4E66
Vector 34, copied to 41B8H: JP 5CD7H to the exit CALLed by the ROM at 1AF2H, after the line links and a CLEAR.
4E69
Vector 35, copied to 41BBH: JP 6088H to the exit CALLed by the ROM at 1B8CH (NEW) and 1DB0H (END).
4E6C
Vector 36, copied to 41BEH: JP 589FH to the exit CALLed by the ROM at 2174H as a PRINT ends.
4E6F
Vector 37, copied to 41C1H: JP 5C0EH 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 5C1CH to the keyboard scan exit, CALLed by the ROM at 0358H.
4E75
Vector 39, copied to 41C7H: JP 5E84H to the RUN exit, CALLed by the ROM at 1EA6H.
4E78
Vector 40, copied to 41CAH: JP 5764H to the PRINT exit, CALLed by the ROM at 206FH.
4E7B
Vector 41, copied to 41CDH: JP 5CE4H to the exit CALLed by the ROM at 20C6H after a number is made text.
4E7E
Vector 42, copied to 41D0H: JP 5CE3H to the exit CALLed by the ROM at 2103H after PRINT sends a new line.
4E81
Vector 43, copied to 41D3H: JP 5CB2H to the exit CALLed by the ROM at 2108H and 2141H (a comma field, TAB).
4E84
Vector 44, copied to 41D6H: JP 58A6H to the INPUT exit, CALLed by the ROM at 219EH.
4E87
Vector 45, copied to 41D9H: JP 5B5EH 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 5D5DH to the exit CALLed by the ROM at 222DH as READ or INPUT takes the next field.
4E8D
Vector 47, copied to 41DFH: JP 5A50H 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,4388H 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: 532EH 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 658DH, and 57E2H 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 658DH, 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 (428AH, ended by 0DH), then the table of @PARAM (53CEH): MEM, FILES, BLK, EXT, HIGH and LOW (the last two only in the Model III file) 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 (5449H 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 536BH when OSVER$ (441FH) 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 (536EH).
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 53B2H 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 53A8H 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 535FH. No code reads it.
528B-5292
DEFM "MEM " / DEFW 5426H 4D 45 4D 20 20 20 26 54
528BH-5292H: MEM, the highest address BASIC may use: the cell 5426H, the operand of LD DE at 5425H.
5293-529A
DEFM "M " / DEFW 5426H 4D 20 20 20 20 20 26 54
5293H-529AH: M, the short form of MEM: 5426H.
529B-52A2
DEFM "FILES " / DEFW 53E9H 46 49 4C 45 53 20 E9 53
529BH-52A2H: FILES, the number of file buffers: the cell 53E9H, the operand of LD DE at 53E8H (0003H in the file).
52A3-52AA
DEFM "F " / DEFW 53E9H 46 20 20 20 20 20 E9 53
52A3H-52AAH: F, the short form of FILES: 53E9H.
52AB-52B2
DEFM "BLK " / DEFW 53E2H 42 4C 4B 20 20 20 E2 53
52ABH-52B2H: BLK, blocked files: the cell 53E2H, the operand of LD DE at 53E1H (FFFFH in the file, on).
52B3-52BA
DEFM "B " / DEFW 53E2H 42 20 20 20 20 20 E2 53
52B3H-52BAH: B, the short form of BLK: 53E2H.
52BB-52C2
DEFM "EXT " / DEFW 6399H 45 58 54 20 20 20 99 63
52BBH-52C2H: EXT, the switch of the default extension /BAS: the cell 6399H, the operand of LD HL at 6398H (FFFFH in the file, on; 0000H for OFF).
52C3-52CA
DEFM "E " / DEFW 6399H 45 20 20 20 20 20 99 63
52C3H-52CAH: E, the short form of EXT: the switch at 6399H.
52CB-52D2
DEFM "HIGH " / DEFW 0000H 48 49 47 48 20 20 00 00
52CBH-52D2H: HIGH, the cassette at 1500 baud, the default: its cell is 0000H, so the FFFFH that @PARAM stores for it goes to the ROM and changes nothing.
52D3-52DA
DEFM "H " / DEFW 0000H 48 20 20 20 20 20 00 00
52D3H-52DAH: H, the short form of HIGH: cell 0000H, no effect.
52DB-52E2
DEFM "LOW " / DEFW 53DAH 4C 4F 57 20 20 20 DA 53
52DBH-52E2H: LOW, the cassette at 500 baud: the cell 53DAH, the operand of LD DE at 53D9H (0000H in the file, FFFFH when LOW is given).
52E3-52EA
DEFM "L " / DEFW 53DAH 4C 20 20 20 20 20 DA 53
52E3H-52EAH: L, the short form of LOW: 53DAH.
52EB
DEFB 00H 00
52EBH: 00H, the end of the table of the parameters.

52ECH - 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 5331H (over this code), and the 49 vectors are copied to 4152H.

52EC
XOR A AF
Load Register A with 00H (XOR A), for the BREAK trap switch and OVRLY$.
52ED
LD (4405H),A 32 05 44
Store Register A (00H) at 4405H, the BREAK trap switch: any value but C3H means the trap is off.
52F0
LD (4414H),A 32 14 44
Store Register A (00H) at 4414H, OVRLY$: no system file counts as loaded, since this file's block at 4E00H-4E9EH lies in the overlay area.
52F3
LD A,(HL) 7E
Load Register A with the first character of the command line at Register Pair HL.
52F4
LD (5374H),A 32 74 53
Store Register A (the first character) at 5374H, the operand of LD A at 5373H: 2AH, an asterisk, asks to go back to the program in memory.
52F7
LD (53CCH),HL 22 CC 53
Store Register Pair HL (the pointer to the command line) at 53CCH-53CDH, the operand of LD HL at 53CBH, for @PARAM.
52FA
GOSUB to 5C8DH to point the BREAK vector at 4203H to READY (1A19H) and clear bits 0-2 of KFLAG$ (429FH), the keys pressed before BASIC ran; Register A is kept.
52FD
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HIGH$ from 4411H-4412H, the highest address free for programs.
5300
LD (5426H),HL 22 26 54
Store Register Pair HL (HIGH$) at 5426H-5427H, the operand of LD DE at 5425H: the value MEM is compared with, and its value when MEM is not given.
5303
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with 40A4H-40A5H, the start of the BASIC program text as it was.
5306
LD (5386H),HL 22 86 53
Store Register Pair HL (the program's start) at 5386H-5387H, the operand of LD HL at 5385H, for going back to the program.
5309
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.
530C
LD (5321H),HL 22 21 53
Store Register Pair HL at 5321H-5322H, the operand of LD HL at 5320H: the LDIR below writes over 408EH-408FH.
530F
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with 40A0H-40A1H, the top of string space as it was.
5312
LD (5380H),HL 22 80 53
Store Register Pair HL (the top of string space) at 5380H-5381H, the operand of LD HL at 537FH.
5315
LD DE,4080H 11 80 40
Point Register Pair DE to 4080H, where the ROM puts its 39 bytes at power on.
5318
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.
531B
LD BC,0027H 01 27 00
Load Register Pair BC with 0027H, the count of the bytes: 39.
531E
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.
5320
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5321H-5322H: the word of 408EH-408FH kept at 530CH (0000H in the file).
5323
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.
5326
LD HL,4E93H 21 93 4E
Point Register Pair HL to 4E93H, the image of the restart vectors.
5329
LD DE,4000H 11 00 40
Point Register Pair DE to 4000H, the vectors of RST 08H, RST 10H, RST 18H and RST 20H.
532C
LD C,0CH 0E 0C
Load Register C with 0CH: Register Pair BC = 000CH (Register B is 00H after the LDIR), 12 bytes.
532E
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 658DH. 5343H-534BH later write over this LDIR and the byte after it, once they have run.
5330
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HIGH$ from 4411H-4412H.
5333
LD DE,(5380H) ED 5B 80 53
Load Register Pair DE with the top of string space kept at 5380H-5381H.
5337
CP 2AH FE 2A
Compare Register A (the first character of the command line) against 2AH, an asterisk.
5339
If the NZ FLAG is set (no asterisk), JUMP to 533FH with HIGH$ in Register Pair HL.
533B
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.
533C
If the CARRY FLAG is set (HIGH$ is lower), JUMP to 533FH with HIGH$.
533E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the old top of string space, the lower of the two.
533F
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space.
5342
LD SP,HL F9
Load the Stack Pointer with Register Pair HL: the stack grows down from the top of string space.
5343
LD HL,532EH 21 2E 53
Point Register Pair HL to 532EH, the LDIR that has run.
5346
LD (HL),3AH 36 3A
Store 3AH, a colon, at Register Pair HL (532EH).
5348
INC HL 23
INCrement Register Pair HL to 532FH, the second byte written over the code that has run.
5349
LD (HL),B 70
Store Register B (00H, after the LDIR at 532EH) at Register Pair HL (532FH).
534A
INC HL 23
INCrement Register Pair HL to 5330H, the third byte written over the code that has run.
534B
LD (HL),2CH 36 2C
Store 2CH, a comma, at Register Pair HL (5330H): the byte before the line buffer.
534D
INC HL 23
INCrement Register Pair HL to 5331H, the line buffer.
534E
LD (40A7H),HL 22 A7 40
Store Register Pair HL (5331H) at 40A7H-40A8H, the ROM's pointer to the line buffer: typed lines go over this code from 5331H on (at most 240 characters: 036FH in the ROM, 5BECH here), which has run by then.
5351
LD DE,4152H 11 52 41
Point Register Pair DE to 4152H, the ROM's first disk vector.
5354
LD HL,4E00H 21 00 4E
Point Register Pair HL to 4E00H, the image of the 49 vectors.
5357
LD BC,0093H 01 93 00
Load Register Pair BC with 0093H, the count of the bytes: 147, 49 vectors of 3 bytes.
535A
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.
535C
LD HL,528AH 21 8A 52
Point Register Pair HL to 528AH, the byte after the text Out of memory.
535F
LD (HL),00H 36 00
Store 00H at Register Pair HL (528AH), the byte between the texts and the parameter table.
5361
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.

5364H - 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.

5364
LD A,(441FH) 3A 1F 44
Load Register A with OSVER$ from 441FH, the version of the system: 53H for 5.3.
5367
CP 51H FE 51
Compare Register A against 51H: the CARRY FLAG below 51H.
5369
If the NO CARRY FLAG is set (51H or more), JUMP to 5373H.
536B
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).
536E
GOSUB to 28A7H, the ROM's STROUT: display the text at Register Pair HL up to the 00H.
5371
JUMP to 53AEH to end through @ABORT, the system being too old for LBASIC.
5373
LD A,00H 3E 00
Load Register A with the operand at 5374H: the first character of the command line (52F4H).
5375
CP 2AH FE 2A
Compare Register A against 2AH, an asterisk: back to the program in memory.
5377
If the NZ FLAG is set (no asterisk), JUMP to 53B7H for a new start.
5379
LD A,(408EH) 3A 8E 40
Load Register A with the number of files at 408EH (put back at 5323H).
537C
GOSUB to 53F7H to build the file buffers and their table for Register A files; it returns at 541EH.
537F
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5380H-5381H (0000H in the file): the top of string space kept at 5312H.
5382
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space, as it was.
5385
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5386H-5387H (0000H in the file): the start of the program text kept at 5306H.
5388
LD (40A4H),HL 22 A4 40
Store Register Pair HL at 40A4H-40A5H, the start of the program text, as it was.
538B
LD DE,(40B1H) ED 5B B1 40
Load Register Pair DE with 40B1H-40B2H, the top of memory BASIC used before.
538F
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HIGH$ from 4411H-4412H.
5392
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.
5393
If the NO CARRY FLAG is set (HIGH$ is not lower), JUMP to 53A2H.
5395
LD (40B1H),HL 22 B1 40
Store Register Pair HL (HIGH$) at 40B1H-40B2H, the top of memory BASIC may use.
5398
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, minus 50, the room of the string space.
539B
ADD HL,DE 19
ADD Register Pair DE (minus 50) to Register Pair HL: HIGH$ less 50 bytes of string space.
539C
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space.
539F
GOSUB to 1B5DH, the ROM's CLEAR of RUN: the variables are dropped.
53A2
LD BC,1A18H 01 18 1A
Load Register Pair BC with 1A18H, the ROM's way into READY.
53A5
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.
53A8
LD HL,527CH 21 7C 52
Point Register Pair HL to 527CH, the text Out of memory.
53AB
GOSUB to 428AH, @LOGOT, to display the text at Register Pair HL and write it to the job log.
53AE
SCF 37
Set the CARRY FLAG (SCF): 57E2H ends through @ABORT.
53AF
JUMP to 57E2H to put back the ROM's RST 10H routine and end through @ABORT.
53B2
LD HL,526CH 21 6C 52
Point Register Pair HL to 526CH, the text Parameter error.
53B5
JUMP to 53ABH to display the text at Register Pair HL and end.

53B7H - A New Start: the USR Vectors and the Parameters

The ten USR vectors (6630H-6643H) get 6443H, so a USR that DEF USR never set gives an error; 6644H gets 0000H. @PARAM reads MEM, FILES, BLK, EXT, HIGH and LOW with the table at 528BH; LOW sets the ROM's cassette speed at 4211H to 500 baud, else it is 1500 baud. BLK's high byte goes to 408FH; FILES must be 0-15 and goes to 408EH.

53B7
LD DE,6443H 11 43 64
Load Register Pair DE with 6443H, the start of the table of the errors: a USR not set by DEF USR goes there.
53BA
LD HL,6630H 21 30 66
Point Register Pair HL to 6630H, the ten USR vectors above the file.
53BD
LD B,0AH 06 0A
Load Register B with 0AH, the count of the USR vectors: 10.
53BF
LD (HL),E 73
Store Register E (43H) at Register Pair HL, the low byte of the vector.
53C0
INC HL 23
INCrement Register Pair HL to the high byte of the vector.
53C1
LD (HL),D 72
Store Register D (64H) at Register Pair HL, the high byte of the vector.
53C2
INC HL 23
INCrement Register Pair HL to the next vector.
53C3
DECrement Register B and LOOP BACK to 53BFH for the 10 vectors.
53C5
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, for the word above the USR vectors.
53C8
LD (6644H),HL 22 44 66
Store Register Pair HL (0000H) at 6644H-6645H, the word above the USR vectors.
53CB
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 53CCH-53CDH (0000H in the file): the pointer to the command line (52F7H).
53CE
LD DE,528BH 11 8B 52
Point Register Pair DE to 528BH, the table of the parameters.
53D1
GOSUB to 4454H, @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.
53D4
If the NZ FLAG is set (a parameter @PARAM refuses), JUMP to 53B2H: Parameter error.
53D6
LD (53CCH),HL 22 CC 53
Store Register Pair HL (the pointer after the parameters) at 53CCH-53CDH, for 5453H.
53D9
LD DE,0000H 11 00 00
Load Register Pair DE with the operand at 53DAH-53DBH, the cell of LOW: 0000H in the file, FFFFH when LOW (or L) is given.
53DC
LD A,D 7A
Copy Register D (the high byte of LOW) into Register A.
53DD
CPL 2F
Complement Register A (CPL): FFH without LOW, 00H with LOW.
53DE
LD (4211H),A 32 11 42
Store Register A at 4211H, the ROM's cassette speed: 00H for 500 baud (LOW), any other value for 1500 baud (HIGH, the default).
53E1
LD DE,FFFFH 11 FF FF
Load Register Pair DE with the operand at 53E2H-53E3H, the cell of BLK: FFFFH in the file (on), 0000H for BLK=OFF.
53E4
LD A,D 7A
Copy Register D (the high byte of BLK) into Register A.
53E5
LD (408FH),A 32 8F 40
Store Register A at 408FH, the blocked mode flag: not 00H gives each file buffer 256 bytes more (5402H).
53E8
LD DE,0003H 11 03 00
Load Register Pair DE with the operand at 53E9H-53EAH, the cell of FILES: 0003H in the file.
53EB
LD A,D 7A
Copy Register D (the high byte of FILES) into Register A.
53EC
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for a value of 256 or more.
53ED
If the NZ FLAG is set, JUMP to 53B2H: Parameter error.
53EF
LD A,E 7B
Copy Register E (the low byte of FILES) into Register A.
53F0
CP 10H FE 10
Compare Register A against 10H: the CARRY FLAG for 0-15.
53F2
If the NO CARRY FLAG is set (16 or more), JUMP to 53B2H: Parameter error.
53F4
LD (408EH),A 32 8E 40
Store Register A (the number of files) at 408EH.

53F7H - Build the File Buffers

Register A = the number of files. Buffers for files 0 to that number are laid out from 6646H up, 0122H bytes each (0222H in blocked mode, 408FH not 00H), their addresses go to the table at 660EH, the first also to 662EH, and the first byte of each gets 00H. For BASIC with an asterisk it returns to 537FH; else the program text starts after the last buffer, with a 00H before it.

53F7
INC A 3C
INCrement Register A: the buffers for files 0 to the number given.
53F8
LD HL,6646H 21 46 66
Point Register Pair HL to 6646H, the first buffer, above the USR vectors.
53FB
LD DE,660EH 11 0E 66
Point Register Pair DE to 660EH, the table of the buffers' addresses.
53FE
LD BC,0122H 01 22 01
Load Register Pair BC with 0122H, the size of a buffer: 290 bytes.
5401
PUSH AF F5
Save Register Pair AF (Register A = the buffers) to the stack.
5402
LD A,(408FH) 3A 8F 40
Load Register A with the blocked mode flag at 408FH.
5405
AND A A7
Set the flags from Register A (AND A): the Z FLAG when blocked mode is off.
5406
If the Z FLAG is set (blocked mode off), JUMP to 5409H with 0122H.
5408
INC B 04
INCrement Register B: Register Pair BC = 0222H, 256 bytes more for blocked mode.
5409
POP AF F1
Restore Register Pair AF (Register A = the buffers) from the stack.
540A
LD (662EH),HL 22 2E 66
Store Register Pair HL (6646H) at 662EH-662FH: the address of buffer 0.
540D
LD (HL),00H 36 00
Store 00H at Register Pair HL, the first byte of the buffer.
540F
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the table, Register Pair DE = the buffer.
5410
LD (HL),E 73
Store Register E (the low byte of the buffer's address) at Register Pair HL.
5411
INC HL 23
INCrement Register Pair HL to the high byte of the entry.
5412
LD (HL),D 72
Store Register D (the high byte of the buffer's address) at Register Pair HL.
5413
INC HL 23
INCrement Register Pair HL to the next entry of the table.
5414
EX DE,HL EB
Exchange Register Pairs DE and HL back: Register Pair HL = the buffer, Register Pair DE = the table.
5415
ADD HL,BC 09
ADD Register Pair BC (the size) to Register Pair HL: the next buffer.
5416
DEC A 3D
DECrement Register A, the count of the buffers left to lay out.
5417
If the NZ FLAG is set (buffers left), LOOP BACK to 540DH.
5419
LD A,(5374H) 3A 74 53
Load Register A with the first character of the command line at 5374H (52F4H).
541C
CP 2AH FE 2A
Compare Register A against 2AH, an asterisk: going back to the program.
541E
RET Z C8
If the Z FLAG is set (BASIC with an asterisk), RETurn to 537FH.
541F
LD (HL),00H 36 00
Store 00H at Register Pair HL, the byte after the last buffer: the 00H before the program text.
5421
INC HL 23
INCrement Register Pair HL to the first byte of the program text.
5422
LD (40A4H),HL 22 A4 40
Store Register Pair HL at 40A4H-40A5H, the start of the program text.

5425H - 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.

5425
LD DE,0000H 11 00 00
Load Register Pair DE with the operand at 5426H-5427H (0000H in the file), the cell of MEM: HIGH$ as it was at the start (5300H) unless MEM was given.
5428
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HIGH$ from 4411H-4412H.
542B
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.
542C
If the CARRY FLAG is set (MEM above HIGH$), JUMP to 53A8H: Out of memory.
542F
DEC DE 1B
DECrement Register Pair DE: MEM less 1, the last byte BASIC may use.
5430
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with 40A4H-40A5H, the start of the program text (5422H). 5450H later stores 00H in this instruction's operand at 5431H.
5433
LD BC,012CH 01 2C 01
Load Register Pair BC with 012CH, the least room the program needs: 300 bytes.
5436
ADD HL,BC 09
ADD Register Pair BC (300) to Register Pair HL: the start of the program text plus 300.
5437
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = MEM less 1, Register Pair DE = the start plus 300.
5438
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.
5439
If the CARRY FLAG is set (too little memory), JUMP to 53A8H: Out of memory.
543C
LD DE,FFCEH 11 CE FF
Load Register Pair DE with FFCEH, minus 50, the room of the string space.
543F
LD (40B1H),HL 22 B1 40
Store Register Pair HL (MEM less 1) at 40B1H-40B2H, the top of memory BASIC may use.
5442
ADD HL,DE 19
ADD Register Pair DE (minus 50) to Register Pair HL: the top of string space, 50 bytes below.
5443
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the top of string space.
5446
GOSUB to 1B4DH, the ROM's NEW: the program text is emptied and the variables cleared.

5449H - 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.

5449
LD HL,5200H 21 00 52
Point Register Pair HL to 5200H, the banner (00H at its end, 5250H).
544C
GOSUB to 28A7H, the ROM's STROUT: display the text at Register Pair HL up to the 00H.
544F
XOR A AF
Load Register A with 00H (XOR A), for the byte at 5431H.
5450
LD (5431H),A 32 31 54
Store Register A (00H) at 5431H, the low byte of the operand of LD HL,(40A4H) at 5430H, which has run: no code reads 5431H afterwards.
5453
LD HL,(53CCH) 2A CC 53
Load Register Pair HL with the pointer after the parameters at 53CCH-53CDH (53D6H).
5456
DEC HL 2B
DECrement Register Pair HL: RST 10H steps on before it takes a character.
5457
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character of the line and Register A = it, spaces passed over.
5458
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line.
545A
If the Z FLAG is set (nothing more), JUMP to 1A19H, the ROM's READY.
545D
PUSH HL E5
Save Register Pair HL (the start of the rest of the line) to the stack.
545E
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
545F
CP 20H FE 20
Compare Register A against 20H: the CARRY FLAG for a control character, the end of the line.
5461
If the CARRY FLAG is set (the end), JUMP to 5466H.
5463
INC HL 23
INCrement Register Pair HL to the next character.
5464
LOOP BACK to 545EH for the next character of the line.
5466
LD (HL),00H 36 00
Store 00H at Register Pair HL over the 0DH: the end of a line for the ROM.
5468
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.
546B
CALL 41ACH CD AC 41
GOSUB to 41ACH, the READY exit (5FD8H), as the ROM calls it on its way to READY.
546E
GOSUB to 20F9H, the ROM: a new line on the video unless the cursor is at the start of a line.
5471
LD HL,FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the line number of a line typed at READY.
5474
LD (40A2H),HL 22 A2 40
Store Register Pair HL (FFFFH) at 40A2H-40A3H, the number of the line being run.
5477
POP HL E1
Restore Register Pair HL (the start of the rest of the line) from the stack.
5478
DEC HL 2B
DECrement Register Pair HL: the ROM's RST 10H steps on before it takes a character.
5479
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.

547CH - CMD"command": an Overlay or a Command of LDOS

CMD with a text of 2 or more characters (57F3H): 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 (5514H). 5490H is the entry of 582BH for a single letter.

547C
LD C,A 4F
Copy Register A (the length of the text) into Register C.
547D
CP 40H FE 40
Compare Register A against 40H: the CARRY FLAG for a text of fewer than 64 characters.
547F
If the NO CARRY FLAG is set (64 or more), JUMP to 1E4AH, the ROM's Illegal function call error.
5482
PUSH HL E5
Save Register Pair HL (the pointer into the BASIC text) to the stack.
5483
INC DE 13
INCrement Register Pair DE to the second character of the text.
5484
LD A,(DE) 1A
Load Register A with the second character at Register Pair DE.
5485
DEC DE 1B
DECrement Register Pair DE back to the first character.
5486
CP 20H FE 20
Compare Register A against 20H, a space: a letter and a space ask for an overlay.
5488
LD HL,5514H 21 14 55
Point Register Pair HL to 5514H, the command shell. LD does not change the flags.
548B
If the NZ FLAG is set (no space), JUMP to 54A1H and on to the address in Register Pair HL (5514H).
548D
LD A,(DE) 1A
Load Register A with the first character of the text at Register Pair DE.
548E
RES 5,A CB AF
Clear bit 5 of Register A: a lower case letter becomes upper case.
5490
LD B,31H 06 31
Load Register B with 31H, the digit 1 of BASIC/OV1.
5492
CP 4EH FE 4E
Compare Register A against 4EH, N: BASIC/OV1.
5494
If the Z FLAG is set (N), JUMP to 54A2H with Register B = 31H.
5496
INC B 04
INCrement Register B: 32H, the digit 2 of BASIC/OV2.
5497
CP 58H FE 58
Compare Register A against 58H, X: BASIC/OV2.
5499
If the Z FLAG is set (X), JUMP to 54A2H with Register B = 32H.
549B
LD B,34H 06 34
Load Register B with 34H, the digit 4 of BASIC/OV4.
549D
CP 56H FE 56
Compare Register A against 56H, V: BASIC/OV4.
549F
If the Z FLAG is set (V), JUMP to 54A2H with Register B = 34H.
54A1
JP (HL) E9
JUMP to the address in Register Pair HL: 5514H, the command shell, from 5488H; 1E4AH, Illegal function call, from 582BH through 5490H.
54A2
PUSH DE D5
Save Register Pair DE (the text) to the stack.
54A3
PUSH BC C5
Save Register Pair BC (Register C = the length) to the stack.
54A4
GOSUB to 54CDH to put BASIC/OVn, n the digit in Register B, in the control block at 4485H.
54A7
POP BC C1
Restore Register Pair BC (Register C = the length) from the stack.
54A8
POP HL E1
Restore Register Pair HL (the text) from the stack.
54A9
GOSUB to 5509H to copy Register C characters from Register Pair HL to 4225H, with 0DH after them.
54AC
LD HL,4226H 21 26 42
Point Register Pair HL to 4226H, the text after its first letter: the overlay's command line.
54AF
LD DE,4485H 11 85 44
Point Register Pair DE to 4485H, the control block with BASIC/OVn.
54B2
JUMP to 4433H, @RUN, to load the file at Register Pair DE and run it with Register Pair HL at its command line.
54B5-54BC
DEFM "BASIC/OV" 42 41 53 49 43 2F 4F 56
54B5H-54BCH: the name of the overlays without the digit, copied to 4485H by 54CDH.
54BD-54CA
DEFM "Can't load OV3" 43 61 6E 27 74 20 6C 6F 61 64 20 4F 56 33
54BDH-54CAH: the text of 54FDH when BASIC/OV3 cannot be loaded.
54CB-54CC
DEFB 0DH, 00H 0D 00
54CBH-54CCH: 0DH, a new line, and 00H, the end of the text for STROUT.

54CDH - The Name of an Overlay

Puts BASIC/OVn and 00H in the control block at 4485H (CFCB$), n the digit in Register B.

54CD
LD A,B 78
Copy Register B (the digit) into Register A, since the LDIR clears Register Pair BC.
54CE
LD HL,54B5H 21 B5 54
Point Register Pair HL to 54B5H, the text BASIC/OV without its digit.
54D1
LD DE,4485H 11 85 44
Point Register Pair DE to 4485H, CFCB$, the control block of a command's file.
54D4
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the count of the bytes: 8.
54D7
LDIR ED B0
Copy Register Pair BC (8) bytes from Register Pair HL (54B5H) to Register Pair DE (4485H) (LDIR).
54D9
LD (DE),A 12
Store Register A (the digit) at Register Pair DE (448DH).
54DA
INC DE 13
INCrement Register Pair DE to 448EH, after the digit of the name.
54DB
XOR A AF
Load Register A with 00H (XOR A), the end of the name.
54DC
LD (DE),A 12
Store Register A (00H) at Register Pair DE (448EH).
54DD
RET C9
RETurn with BASIC/OVn and 00H at 4485H-448EH.

54DEH - Call BASIC/OV3

BASIC/OV3 is loaded at 4E00H and called. When OVRLY$ (4414H) 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.

54DE
LD A,(4414H) 3A 14 44
Load Register A with OVRLY$ from 4414H: 01H while BASIC/OV3 is in the overlay area.
54E1
LD B,33H 06 33
Load Register B with 33H, the digit 3 of BASIC/OV3.
54E3
DEC A 3D
DECrement Register A (OVRLY$): the Z FLAG for 01H, BASIC/OV3 in place.
54E4
If the Z FLAG is set (BASIC/OV3 is there), JUMP to 4E00H, its entry.
54E7
PUSH HL E5
Save Register Pair HL (the caller's value) to the stack.
54E8
GOSUB to 54CDH to put BASIC/OV3 in the control block at 4485H.
54EB
LD DE,4485H 11 85 44
Point Register Pair DE to 4485H, the control block.
54EE
LD HL,442BH 21 2B 44
Point Register Pair HL to 442BH, SFLAG$, the system flags.
54F1
SET 2,(HL) CB D6
Set bit 2 of SFLAG$ at Register Pair HL: the bit of a load by @RUN.
54F3
GOSUB to 4430H, @LOAD, to load the file at Register Pair DE; Register Pair HL = its transfer address, the Z FLAG on success.
54F6
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.
54F7
RET Z C8
If the Z FLAG is set (loaded), RETurn: to the transfer address of BASIC/OV3.
54F8
OR C0H F6 C0
Set bits 7 and 6 of Register A (OR C0H, the error number): return to the caller, the short message.
54FA
GOSUB to 4409H, @ERROR, to display the message of the error number in Register A.
54FD
LD HL,54BDH 21 BD 54
Point Register Pair HL to 54BDH, the text Can't load OV3.
5500
GOSUB to 28A7H, the ROM's STROUT: display the text at Register Pair HL.
5503
LD BC,1A18H 01 18 1A
Load Register Pair BC with 1A18H, the ROM's way into READY.
5506
JUMP to 19AEH, the ROM: the stack is set from 40E8H and 1B9AH-1BB2H returns to Register Pair BC, READY.

5509H - Copy a Command

Copies Register C bytes from Register Pair HL to 4225H (INBUF$, the command line buffer of LDOS) and puts 0DH after them.

5509
LD DE,4225H 11 25 42
Point Register Pair DE to 4225H, INBUF$, the command line buffer of LDOS.
550C
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the length in Register C.
550E
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR); Register Pair DE ends after them.
5510
LD A,0DH 3E 0D
Load Register A with 0DH, the end of a command line.
5512
LD (DE),A 12
Store Register A (0DH) at Register Pair DE, after the copied command.
5513
RET C9
RETurn with the command and its 0DH at 4225H.

5514H - CMD"command": Run an LDOS Command and Come Back

The text goes to 4225H. 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 5432H-543BH, 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 (55C4H, 55C3H, 55BEH), and @CMNDI runs the command over the memory BASIC has left. The moved copy then brings everything back (55C6H).

5514
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the text of the command, Register Pair DE = 5514H.
5515
GOSUB to 5509H to copy Register C characters from Register Pair HL to 4225H, with 0DH after them.
5518
GOSUB to 4750H, SYS0/SYS's select of the drive of the last disk call (LDRV$, 4427H).
551B
LD HL,F098H 21 98 F0
Load Register Pair HL with F098H, minus 0F68H (3944).
551E
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: the Stack Pointer less 3944 bytes.
551F
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).
5523
XOR A AF
Load Register A with 00H (XOR A), which clears the CARRY FLAG for the SBC.
5524
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.
5526
If the CARRY FLAG is set (too little room), JUMP to 197AH, the ROM's Out of memory error.
5529
LD HL,402DH 21 2D 40
Point Register Pair HL to 402DH, the vectors @EXIT (402DH-402FH) and @ABORT (4030H-4032H).
552C
LD DE,5432H 11 32 54
Point Register Pair DE to 5432H, where they are kept: bytes of the MEM code at 5430H-5448H, which has run.
552F
LD BC,0006H 01 06 00
Load Register Pair BC with 0006H, the count of the bytes: 6.
5532
LDIR ED B0
Copy Register Pair BC (6) bytes from Register Pair HL (402DH) to Register Pair DE (5432H-5437H) (LDIR); Register Pair DE ends at 5438H.
5534
LD HL,4409H 21 09 44
Point Register Pair HL to 4409H, @ERROR, whose first 4 bytes are kept too.
5537
LD C,04H 0E 04
Load Register C with 04H: Register Pair BC = 0004H (Register B is 00H), 4 bytes.
5539
LDIR ED B0
Copy Register Pair BC (4) bytes from Register Pair HL (4409H) to Register Pair DE (5438H-543BH) (LDIR): the start of @ERROR.
553B
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with the end of the variables from 40FDH-40FEH.
553E
LD DE,AE00H 11 00 AE
Load Register Pair DE with AE00H, minus 5200H.
5541
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the bytes from 5200H to the end of the variables.
5542
LD (559AH),HL 22 9A 55
Store Register Pair HL (the length) at 559AH-559BH, the operand of LD BC at 5599H.
5545
PUSH HL E5
Save Register Pair HL (the length) to the stack.
5546
LD DE,F200H 11 00 F2
Load Register Pair DE with F200H, minus 0E00H.
5549
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the length less 0E00H, the part above 6014H.
554A
LD (55E2H),HL 22 E2 55
Store Register Pair HL at 55E2H-55E3H, the operand of LD BC at 55E1H, for the second LDIR of the way back.
554D
POP DE D1
Restore Register Pair DE (the length) from the stack.
554E
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HIGH$ from 4411H-4412H.
5551
LD (55BAH),HL 22 BA 55
Store Register Pair HL (HIGH$) at 55BAH-55BBH, the link word of the module header.
5554
LD (55E7H),HL 22 E7 55
Store Register Pair HL (HIGH$) at 55E7H-55E8H, the operand of LD HL at 55E6H, to put HIGH$ back.
5557
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, to take the Stack Pointer into it.
555A
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: Register Pair HL = the Stack Pointer.
555B
LD (55EDH),HL 22 ED 55
Store Register Pair HL (the Stack Pointer) at 55EDH-55EEH, the operand of LD SP at 55ECH.
555E
DEC HL 2B
DECrement Register Pair HL: the byte below the stack, the top of the moved block.
555F
LD (5593H),HL 22 93 55
Store Register Pair HL at 5593H-5594H, the operand of LD DE at 5592H.
5562
XOR A AF
Load Register A with 00H (XOR A), which clears the CARRY FLAG for the SBC.
5563
SBC HL,DE ED 52
SUBtract Register Pair DE (the length) from Register Pair HL.
5565
INC HL 23
INCrement Register Pair HL: the Stack Pointer less the length, where 5200H is moved to.
5566
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the new place of 5200H.
5567
DI F3
Disable interrupts while the stack and the vectors change.
5568
LD SP,41E5H 31 E5 41
Load the Stack Pointer with 41E5H, the stack of LDOS.
556B
LD A,C3H 3E C3
Load Register A with C3H, the opcode of JP, for the three vectors.
556D
LD (402DH),A 32 2D 40
Store Register A (C3H) at 402DH, the first byte of @EXIT.
5570
LD (4030H),A 32 30 40
Store Register A (C3H) at 4030H, the first byte of @ABORT.
5573
LD (4409H),A 32 09 44
Store Register A (C3H) at 4409H, @ERROR: a JP in place of its PUSH AF.
5576
LD HL,03C4H 21 C4 03
Load Register Pair HL with 03C4H, 55C4H less 5200H.
5579
ADD HL,DE 19
ADD Register Pair DE (the new place of 5200H) to Register Pair HL: where 55C4H is moved to.
557A
LD (402EH),HL 22 2E 40
Store Register Pair HL at 402EH-402FH: @EXIT goes to the moved XOR A of 55C4H.
557D
LD HL,03C3H 21 C3 03
Load Register Pair HL with 03C3H, 55C3H less 5200H.
5580
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: where 55C3H is moved to.
5581
LD (4031H),HL 22 31 40
Store Register Pair HL at 4031H-4032H: @ABORT goes to the moved OR AFH of 55C3H.
5584
LD HL,03BEH 21 BE 03
Load Register Pair HL with 03BEH, 55BEH less 5200H.
5587
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: where 55BEH is moved to.
5588
LD (440AH),HL 22 0A 44
Store Register Pair HL at 440AH-440BH: @ERROR goes to the moved AND A of 55BEH.
558B
LD HL,0238H 21 38 02
Load Register Pair HL with 0238H, 5438H less 5200H.
558E
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: where the kept start of @ERROR (5438H) is moved to.
558F
LD (55C0H),HL 22 C0 55
Store Register Pair HL at 55C0H-55C1H, the operand of JP M at 55BFH (before the move, so the copy has it).
5592
LD DE,0000H 11 00 00
Load Register Pair DE with the operand at 5593H-5594H (0000H in the file): the byte below the stack (555FH).
5595
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with the end of the variables from 40FDH-40FEH.
5598
DEC HL 2B
DECrement Register Pair HL: the last byte of the block.
5599
LD BC,0000H 01 00 00
Load Register Pair BC with the operand at 559AH-559BH (0000H in the file): the length (5542H).
559C
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.
559E
LD HL,41E4H 21 E4 41
Point Register Pair HL to 41E4H, the last byte of BASIC's cells 407DH-41E4H.
55A1
LD BC,0168H 01 68 01
Load Register Pair BC with 0168H, the count of the bytes: 360, 407DH-41E4H.
55A4
LDDR ED B8
Copy Register Pair BC (360) bytes from Register Pair HL down to Register Pair DE (LDDR), below the block.
55A6
LD HL,55BDH 21 BD 55
Point Register Pair HL to 55BDH, the last byte of the module header 55B8H-55BDH.
55A9
LD C,06H 0E 06
Load Register C with 06H: Register Pair BC = 0006H, 6 bytes.
55AB
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.
55AD
EI FB
Enable interrupts: the vectors and the copy are in place.
55AE
LD (4411H),DE ED 53 11 44
Store Register Pair DE (the byte below the header) at 4411H-4412H, HIGH$: the moved memory is kept from the command.
55B2
LD HL,4225H 21 25 42
Point Register Pair HL to 4225H, the command line.
55B5
JUMP to 4299H, @CMNDI, to run the command line at Register Pair HL; its end goes through @EXIT, @ABORT or @ERROR into the moved copy.

55B8H - The Module Header and the Three Ways Back

Moved with the block below HIGH$. 55B8H-55BDH 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 55BEH: an error whose number has bit 7 set (return to the caller) goes on into the kept start of @ERROR; another error, @ABORT (55C3H: OR AFH, bit 7 set) and @EXIT (55C4H: XOR A, the Z FLAG) keep their result in Register Pair AF' and go on at 55C6H.

55B8
JUMP to 55B8H itself (JR, 18H FEH): the first two bytes of a module header; it is not run.
55BA-55BB
DEFW 0000H 00 00
55BAH-55BBH: the header's link word: HIGH$ before the move, stored by 5551H.
55BC
DEFB 01H 01
55BCH: 01H, the length of the module's name, one character.
55BD
DEFM "&" 26
55BDH: &, the name of the module that holds BASIC's memory.
55BE
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).
55BF
If the S FLAG is set (M), JUMP to the operand at 55C0H-55C1H (0000H in the file): the moved copy of the start of @ERROR (558FH), so the command gets the error back.
55C2
LD BC,AFF6H 01 F6 AF
Load Register Pair BC with AFF6H: from 55BFH the bytes F6H AFH of 55C3H are taken as the operand, so Register A and the flags pass to 55C5H. Entered at 55C3H (@ABORT) the bytes F6H AFH are OR AFH: Register A gets bit 7, and the NZ FLAG. Entered at 55C4H (@EXIT) the byte AFH is XOR A: Register A = 00H with the Z FLAG.
55C5
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': the result (Register A and the Z FLAG) is kept for 5605H.

55C6H - The Way Back

Runs in the moved copy until 55DEH. The cells 407DH-41E4H and the first 0E00H bytes of 5200H come back, then the original code goes on at 55E1H: 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 (6463H).

55C6
LD HL,(4411H) 2A 11 44
Load Register Pair HL with HIGH$ from 4411H-4412H: the byte below the header (55AEH).
55C9
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.
55CC
ADD HL,DE 19
ADD Register Pair DE (7) to Register Pair HL: the kept copy of 407DH.
55CD
LD DE,407DH 11 7D 40
Point Register Pair DE to 407DH, the first of BASIC's cells.
55D0
LD BC,0168H 01 68 01
Load Register Pair BC with 0168H, the count of the bytes: 360.
55D3
DI F3
Disable interrupts while the cells come back.
55D4
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.
55D6
LD DE,5200H 11 00 52
Point Register Pair DE to 5200H, the start of BASIC/CMD's memory.
55D9
LD BC,0E00H 01 00 0E
Load Register Pair BC with 0E00H, the count of the bytes: 3584, 5200H-6013H.
55DC
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): 5200H-6013H are back, this code with them.
55DE
JUMP to 55E1H, the original of the next instruction, now back in place.
55E1
LD BC,0000H 01 00 00
Load Register Pair BC with the operand at 55E2H-55E3H (0000H in the file): the length less 0E00H (554AH).
55E4
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): from 6014H to the end of the variables.
55E6
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 55E7H-55E8H (0000H in the file): HIGH$ as it was (5554H).
55E9
LD (4411H),HL 22 11 44
Store Register Pair HL at 4411H-4412H, HIGH$.
55EC
LD SP,0000H 31 00 00
Load the Stack Pointer with the operand at 55EDH-55EEH (0000H in the file): the Stack Pointer as it was (555BH).
55EF
LD HL,5432H 21 32 54
Point Register Pair HL to 5432H, the kept @EXIT and @ABORT.
55F2
LD DE,402DH 11 2D 40
Point Register Pair DE to 402DH, @EXIT, to put it back.
55F5
LD C,06H 0E 06
Load Register C with 06H: Register Pair BC = 0006H, 6 bytes.
55F7
LDIR ED B0
Copy Register Pair BC (6) bytes from Register Pair HL (5432H) to Register Pair DE (402DH) (LDIR); Register Pair HL ends at 5438H.
55F9
LD DE,4409H 11 09 44
Point Register Pair DE to 4409H, @ERROR, to put it back.
55FC
LD C,04H 0E 04
Load Register C with 04H: Register Pair BC = 0004H, 4 bytes.
55FE
LDIR ED B0
Copy Register Pair BC (4) bytes from Register Pair HL (5438H) to Register Pair DE (4409H) (LDIR): @ERROR as it was.
5600
EI FB
Enable interrupts: memory, the stack and the vectors are back.
5601
GOSUB to 5C8DH to point the BREAK vector at 4203H to READY (1A19H) again and clear bits 0-2 of KFLAG$ (429FH), keys pressed during the command.
5604
POP HL E1
Restore Register Pair HL (the pointer into the BASIC text, saved at 5482H) from the stack.
5605
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': Register A and the flags the command ended with (55C5H).
5606
RET Z C8
If the Z FLAG is set (@EXIT), RETurn: the CMD statement is done.
5607
LD E,8EH 1E 8E
Load Register E with 8EH, the error System command aborted.
5609
BIT 7,A CB 7F
Test bit 7 of Register A: set after @ABORT (OR AFH at 55C3H).
560B
If the NZ FLAG is set (aborted), JUMP to 19A2H, the ROM's error routine with the error in Register E.
560E
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the LDOS error number.
5610
JUMP to 6463H to give the BASIC error of the LDOS error in Register A.

5613H - Find a Function's Name

For FN (561FH) and DEF FN (5704H): 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.

5613
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.
5615
LD A,80H 3E 80
Load Register A with 80H, bit 7: a function's name.
5617
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that no subscript follows the name.
561A
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.
561B
LD B,A 47
Copy Register A (the marked letter) into Register B, where the ROM's search keeps the first character.
561C
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.

561FH - 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.

561F
GOSUB to 5613H to find the function: Register Pair DE = its value, 40AFH its type.
5622
LD A,(40AFH) 3A AF 40
Load Register A with the function's type from 40AFH (2 integer, 3 string, 4 single, 8 double).
5625
AND A A7
Set the flags from Register A (AND A): NZ and NO CARRY, the mark of the bottom of the saved items.
5626
PUSH AF F5
Save Register Pair AF (the function's type) to the stack: the bottom of the saved items, read again at 56AFH.
5627
LD (40F3H),HL 22 F3 40
Store Register Pair HL (the pointer into the calling text, after the name) at 40F3H-40F4H.
562A
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the function's value.
562B
LD A,(HL) 7E
Load Register A with the low byte of the value at Register Pair HL.
562C
INC HL 23
INCrement Register Pair HL to the high byte of the function's value.
562D
LD H,(HL) 66
Load Register H with the high byte of the value at Register Pair HL.
562E
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the address of the definition.
562F
OR H B4
OR Register H into Register A: the Z FLAG when the address is 0000H, no DEF FN for it.
5630
If the Z FLAG is set (not defined), JUMP to 6443H: Undefined user function.
5633
LD A,(HL) 7E
Load Register A with the definition's character at Register Pair HL.
5634
CP 28H FE 28
Compare Register A against 28H, an opening bracket: a list of parameters.
5636
If the NZ FLAG is set (no parameters), JUMP to 56A0H to evaluate the body.
5638
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character and Register A = it, the first parameter's name.
5639
LD (40D8H),HL 22 D8 40
Store Register Pair HL (the first parameter in the definition) at 40D8H-40D9H.
563C
JUMP to 5640H, past the comma that comes between parameters.
563E
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next in the definition's list.
5640
LD C,04H 0E 04
Load Register C with 04H, the words of stack this parameter may need.
5642
GOSUB to 1963H, the ROM's check that the stack has room for Register C (4) more words; else Out of memory.
5645
LD A,80H 3E 80
Load Register A with 80H, the flag that no subscript follows a name.
5647
LD (40DCH),A 32 DC 40
Store Register A (80H) at 40DCH, the ROM's flag that no subscript follows the name.
564A
GOSUB to 260DH, the ROM's variable search (PTRGET): the parameter named at Register Pair HL; Register Pair DE = its value, 40AFH its type.
564D
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the parameter's value, Register Pair DE = the definition pointer.
564E
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.
564F
SCF 37
Set the CARRY FLAG (SCF): the mark of a saved number.
5650
If the Z FLAG is set (a string), JUMP to 566DH.
5652
LD C,(HL) 4E
Load Register C with the first byte of the value at Register Pair HL.
5653
INC HL 23
INCrement Register Pair HL to the second byte.
5654
LD B,(HL) 46
Load Register B with the second byte at Register Pair HL.
5655
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
5656
If the S FLAG is set (an integer, 2 bytes), JUMP to 566BH.
5659
INC HL 23
INCrement Register Pair HL to the third byte.
565A
LD C,(HL) 4E
Load Register C with the third byte at Register Pair HL.
565B
INC HL 23
INCrement Register Pair HL to the fourth byte.
565C
LD B,(HL) 46
Load Register B with the fourth byte at Register Pair HL.
565D
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
565E
If PO is set (single precision, 4 bytes), JUMP to 566BH.
5661
INC HL 23
INCrement Register Pair HL to the fifth byte of a double precision value.
5662
LD C,(HL) 4E
Load Register C with the fifth byte at Register Pair HL.
5663
INC HL 23
INCrement Register Pair HL to the sixth byte.
5664
LD B,(HL) 46
Load Register B with the sixth byte at Register Pair HL.
5665
INC HL 23
INCrement Register Pair HL to the seventh byte.
5666
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
5667
LD C,(HL) 4E
Load Register C with the seventh byte at Register Pair HL.
5668
INC HL 23
INCrement Register Pair HL to the eighth byte.
5669
LD B,(HL) 46
Load Register B with the eighth byte at Register Pair HL.
566A
PUSH BC C5
Save Register Pair BC (two bytes of the value) to the stack.
566B
If the CARRY FLAG is set (always here, 564FH), JUMP to 5677H.
566D
JP NC,2423H D2 23 24
If the NO CARRY FLAG is set, JUMP to 2423H in the ROM. Reached only from 5650H with the CARRY FLAG set, so it is never taken.
5670
PUSH DE D5
Save Register Pair DE (the definition pointer) to the stack.
5671
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the string's descriptor.
5672
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.
5675
POP DE D1
Restore Register Pair DE (the definition pointer) from the stack.
5676
XOR A AF
Load Register A with 00H (XOR A): the Z FLAG, the mark of a saved string.
5677
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.
5678
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.
5679
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the definition pointer.
567A
LD A,(HL) 7E
Load Register A with the character after the parameter's name at Register Pair HL.
567B
CP 29H FE 29
Compare Register A against 29H, the closing bracket.
567D
If the NZ FLAG is set (more parameters), LOOP BACK to 563EH.
567F
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the pointer into the calling text from 40F3H-40F4H.
5682
RST 08H => 28H CF 28
RST 08H with the byte 28H: an opening bracket must follow FN and the name in the call.
5684
PUSH HL E5
Save Register Pair HL (the pointer into the call's arguments) to the stack.
5685
LD HL,(40D8H) 2A D8 40
Load Register Pair HL with the first parameter in the definition from 40D8H-40D9H.
5688
GOSUB to 260DH, the ROM's variable search: the next parameter at Register Pair HL; Register Pair DE = its value.
568B
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.
568C
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.
568F
LD A,(HL) 7E
Load Register A with the character after the argument at Register Pair HL.
5690
CP 29H FE 29
Compare Register A against 29H, the closing bracket.
5692
If the Z FLAG is set (the last argument), JUMP to 569BH.
5694
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next in the call.
5696
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the definition pointer.
5697
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next in the definition's list.
5699
LOOP BACK to 5688H for the next parameter and argument.
569B
RST 10H D7
RST 10H (658DH): Register Pair HL past the closing bracket of the call, Register A = the next character.
569C
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.
569D
RST 08H => 29H CF 29
RST 08H with the byte 29H: the closing bracket of the definition's list.
569F
LD A,D5H 3E D5
Load Register A with D5H: from 569DH this only steps over the byte D5H at 56A0H. Entered at 56A0H (from 5636H, no parameters) the byte D5H is PUSH DE.
56A1
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: the body of the definition follows.
56A3
GOSUB to 2337H, the ROM's expression evaluator: the body at Register Pair HL; the result in the accumulator (4121H), its type at 40AFH.
56A6
DEC HL 2B
DECrement Register Pair HL, back to the character that ended the body.
56A7
RST 10H D7
RST 10H (658DH): Register Pair HL on, Register A = that character, the Z FLAG at the end of the statement.
56A8
If the NZ FLAG is set (more after the body), JUMP to 1997H, the ROM's Syntax error.
56AB
RST 20H E7
RST 20H, the ROM's test of the type of the result: the Z FLAG for a string.
56AC
If the Z FLAG is set (a string), JUMP to 56DDH.
56AE
POP DE D1
Restore Register Pair DE (the pointer into the calling text) from the stack.
56AF
POP AF F1
Restore Register Pair AF (the mark of the item saved last) from the stack.
56B0
If the Z FLAG is set (a string), JUMP to 56F1H to put its descriptor back.
56B2
If the NO CARRY FLAG is set (the function's type at the bottom), JUMP to 56D0H.
56B4
POP HL E1
Restore Register Pair HL (the last byte of the variable's value) from the stack.
56B5
POP BC C1
Restore Register Pair BC (the last two bytes saved) from the stack.
56B6
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
56B7
DEC HL 2B
DECrement Register Pair HL to the byte below.
56B8
LD (HL),C 71
Store Register C (a saved byte) at Register Pair HL in the variable.
56B9
If the S FLAG is set (an integer), JUMP to 56AFH: its 2 bytes are back.
56BC
DEC HL 2B
DECrement Register Pair HL to the byte below.
56BD
POP BC C1
Restore Register Pair BC (two more bytes) from the stack.
56BE
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
56BF
DEC HL 2B
DECrement Register Pair HL to the byte below.
56C0
LD (HL),C 71
Store Register C (a saved byte) at Register Pair HL in the variable.
56C1
If PO is set (single precision), JUMP to 56AFH: its 4 bytes are back.
56C4
DEC HL 2B
DECrement Register Pair HL to the byte below.
56C5
POP BC C1
Restore Register Pair BC (two more bytes) from the stack.
56C6
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
56C7
DEC HL 2B
DECrement Register Pair HL to the byte below.
56C8
LD (HL),C 71
Store Register C (a saved byte) at Register Pair HL in the variable.
56C9
DEC HL 2B
DECrement Register Pair HL to the byte below.
56CA
POP BC C1
Restore Register Pair BC (the first two bytes) from the stack.
56CB
LD (HL),B 70
Store Register B (a saved byte) at Register Pair HL in the variable.
56CC
DEC HL 2B
DECrement Register Pair HL to the byte below.
56CD
LD (HL),C 71
Store Register C at Register Pair HL: the 8 bytes of a double precision value are back.
56CE
LOOP BACK to 56AFH for the next saved item, down to the function's type.
56D0
PUSH DE D5
Save Register Pair DE (the pointer into the calling text) to the stack.
56D1
PUSH AF F5
Save Register Pair AF (the function's type) to the stack.
56D2
RST 20H E7
RST 20H, the ROM's test of the type of the result: the Z FLAG for a string.
56D3
LD DE,40D3H 11 D3 40
Point Register Pair DE to 40D3H, the ROM's descriptor of the string being built.
56D6
If the Z FLAG is set (a string), GOSUB to 2888H to put the descriptor at Register Pair DE into the temporary strings.
56D9
POP AF F1
Restore Register Pair AF (Register A = the function's type) from the stack.
56DA
JUMP to 281AH, the ROM: the result is made the type in Register A, and the routine returns to the pointer on the stack.
56DD
LD HL,(40B3H) 2A B3 40
Load Register Pair HL with 40B3H-40B4H, the next free temporary string descriptor.
56E0
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = that pointer.
56E1
LD HL,(4121H) 2A 21 41
Load Register Pair HL with the address of the result's descriptor from 4121H-4122H.
56E4
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.
56E5
If the CARRY FLAG is set (a temporary string), JUMP to 56ECH.
56E7
GOSUB to 2843H, the ROM: the string of the descriptor at Register Pair HL is copied into string space.
56EA
JUMP to 56AEH to put the saved values back with the string kept.
56EC
POP DE D1
Restore Register Pair DE (the pointer into the calling text) from the stack.
56ED
LD HL,40D3H 21 D3 40
Point Register Pair HL to 40D3H, the descriptor being built.
56F0
PUSH HL E5
Save Register Pair HL (40D3H) to the stack, the place 56F1H stores into.
56F1
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.
56F4
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
56F5
LD (40B3H),HL 22 B3 40
Store Register Pair HL at 40B3H-40B4H: the temporary descriptor is free again.
56F8
POP HL E1
Restore Register Pair HL (the place for the descriptor: the variable's, or 40D3H) from the stack.
56F9
LD (HL),A 77
Store Register A (the length) at Register Pair HL.
56FA
INC HL 23
INCrement Register Pair HL to the address of the string.
56FB
LD (HL),C 71
Store Register C (the low byte of the string's address) at Register Pair HL.
56FC
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
56FD
LD (HL),B 70
Store Register B (the high byte of the string's address) at Register Pair HL: the descriptor is back.
56FE
LOOP BACK to 56AFH for the next saved item, down to the function's type.

5700H - DEF: DEF FN and DEF USR

Vector 3 (415BH), with Register A = the token after DEF. DEF USRn goes to 5755H. 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.

5700
CP C1H FE C1
Compare Register A (the character after DEF) against C1H, the token USR.
5702
If the Z FLAG is set (DEF USR), JUMP to 5755H.
5704
GOSUB to 5613H to find the function: Register Pair DE = its value, Register Pair HL after the name.
5707
GOSUB to 2828H, the ROM: Illegal direct when the line was typed at READY.
570A
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.
570B
LD (HL),E 73
Store Register E (the low byte of the text's address) at Register Pair HL.
570C
INC HL 23
INCrement Register Pair HL to the high byte of the value.
570D
LD (HL),D 72
Store Register D (the high byte) at Register Pair HL: the function now points at its definition.
570E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the text after the name.
570F
LD A,(HL) 7E
Load Register A with the character after the name at Register Pair HL.
5710
CP 28H FE 28
Compare Register A against 28H, an opening bracket.
5712
If the NZ FLAG is set (no parameters), JUMP to 1F05H, the ROM's DATA: the rest of the statement is passed over.
5715
RST 10H D7
RST 10H (658DH): Register Pair HL to the first parameter's name, Register A = its first character.
5716
GOSUB to 260DH, the ROM's variable search: the parameter at Register Pair HL is found or made.
5719
LD A,(HL) 7E
Load Register A with the character after the name at Register Pair HL.
571A
CP 29H FE 29
Compare Register A against 29H, the closing bracket.
571C
If the Z FLAG is set (the end of the list), JUMP to 1F05H to pass over the rest of the statement.
571F
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
5721
LOOP BACK to 5716H for the next parameter of the definition.

5723H - 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 6630H, 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).

5723
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.
5724
GOSUB to 5743H to read the digit after USR: Register Pair DE = its vector in 6630H-6643H.
5727
PUSH DE D5
Save Register Pair DE (the vector's address) to the stack.
5728
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.
572B
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.
572C
LD C,(HL) 4E
Load Register C with the low byte of the routine's address at Register Pair HL.
572D
INC HL 23
INCrement Register Pair HL to the high byte of the vector.
572E
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the routine (6443H when DEF USR never set it).
572F
LD HL,26E7H 21 E7 26
Point Register Pair HL to 26E7H, the ROM's POP HL / RET, where the routine returns to.
5732
PUSH HL E5
Save Register Pair HL (26E7H) to the stack, under the routine's address.
5733
PUSH BC C5
Save Register Pair BC (the routine's address) to the stack, for the RET at 5742H.
5734
LD A,(40AFH) 3A AF 40
Load Register A with the type of the argument from 40AFH.
5737
PUSH AF F5
Save Register Pair AF (the type) to the stack.
5738
CP 03H FE 03
Compare Register A (the type) against 03H, the type of a string.
573A
If the Z FLAG is set (a string), GOSUB to 29DAH, the ROM: the temporary string is freed; Register Pair HL = its descriptor.
573D
POP AF F1
Restore Register Pair AF (Register A = the type) from the stack.
573E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the string's descriptor for a string argument.
573F
LD HL,4121H 21 21 41
Point Register Pair HL to 4121H, the ROM's accumulator with the argument.
5742
RET C9
RETurn to the routine's address pushed at 5733H; its RET goes to 26E7H, which takes back the text pointer.

5743H - 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, 6630H + 2 x n.

5743
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character and Register A = it; the CARRY FLAG for a digit.
5744
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the offset of USR0.
5747
If the NO CARRY FLAG is set (no digit), JUMP to 574EH with USR0.
5749
SUB 30H D6 30
SUBtract 30H from Register A: the digit's value.
574B
RLCA 07
Rotate Register A left one bit (RLCA): twice the digit, the offset of its vector.
574C
LD C,A 4F
Copy Register A (the offset) into Register C: Register Pair BC = the offset.
574D
RST 10H D7
RST 10H (658DH): Register Pair HL past the digit, Register A = the next character.
574E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the text pointer.
574F
LD HL,6630H 21 30 66
Point Register Pair HL to 6630H, the vector of USR0.
5752
ADD HL,BC 09
ADD Register Pair BC (the offset) to Register Pair HL: the vector of the USR.
5753
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the vector, Register Pair HL = the text pointer.
5754
RET C9
RETurn with Register Pair DE at the vector of the USR named.

5755H - DEF USR

DEF USRn = address: the value after = (an integer) is stored in the vector of USRn.

5755
GOSUB to 5743H to read the digit: Register Pair DE = the vector.
5758
PUSH DE D5
Save Register Pair DE (the vector's address) to the stack.
5759
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: it must come next.
575B
GOSUB to 2B02H, the ROM: the expression at Register Pair HL is evaluated as an integer into Register Pair DE.
575E
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.
575F
LD (HL),E 73
Store Register E (the low byte of the address) at Register Pair HL.
5760
INC HL 23
INCrement Register Pair HL to the high byte of the vector.
5761
LD (HL),D 72
Store Register D (the high byte) at Register Pair HL: the USR is set.
5762
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5763
RET C9
RETurn to the caller of DEF, the rest of the statement after it.

5764H - 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 5CF0H for a file open for output (Register C = 02H).

5764
PUSH HL E5
Save Register Pair HL (the pointer at the #) to the stack.
5765
RST 10H D7
RST 10H (658DH): Register Pair HL past the #, Register A = the next character.
5766
CP CEH FE CE
Compare Register A against CEH, the token minus: PRINT #-1, the cassette.
5768
POP HL E1
Restore Register Pair HL (the pointer at the #) from the stack.
5769
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the #; LD does not change the flags.
576A
RET Z C8
If the Z FLAG is set (a minus sign), RETurn to the ROM's PRINT for the cassette.
576B
LD C,02H 0E 02
Load Register C with 02H, the mode the file must have: output.
576D
JUMP to 5CF0H to read the file number and make the file the current one.

5770H - 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.

5770
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
5772
GOSUB to 2337H, the ROM's expression evaluator: the argument at Register Pair HL.
5775
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5776
GOSUB to 29D7H, the ROM: the result must be a string (else Type mismatch); it is freed, Register Pair HL = its descriptor.
5779
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
577A
CP 02H FE 02
Compare Register A against 02H: the CARRY FLAG for fewer than 2 characters.
577C
If the CARRY FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
577F
INC HL 23
INCrement Register Pair HL to the string's address in the descriptor.
5780
LD A,(HL) 7E
Load Register A with the low byte of the address at Register Pair HL.
5781
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
5782
LD H,(HL) 66
Load Register H with the high byte at Register Pair HL.
5783
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the string.
5784
INC HL 23
INCrement Register Pair HL to the second character.
5785
LD A,(HL) 7E
Load Register A with the second character at Register Pair HL.
5786
RES 5,A CB AF
Clear bit 5 of Register A (the second character): f becomes F.
5788
CP 46H FE 46
Compare Register A against 46H, F: the Z FLAG for OFF.
578A
POP HL E1
Restore Register Pair HL (the text pointer) from the stack; POP does not change the flags.
578B
RET C9
RETurn with the Z FLAG for OFF, the NZ FLAG for ON.

578CH - 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.

578C
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
578E
LD BC,(662EH) ED 4B 2E 66
Load Register Pair BC with the address of buffer 0 from 662EH-662FH.
5792
GOSUB to 62B5H to put the file specification at Register Pair HL in the control block at Register Pair DE (buffer 0).
5795
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5796
GOSUB to 4430H, @LOAD, to load the file at Register Pair DE; the Z FLAG on success.
5799
POP HL E1
Restore Register Pair HL (the text pointer) from the stack; POP does not change the flags.
579A
If the NZ FLAG is set (not loaded), JUMP to 6463H to give the BASIC error of the LDOS error in Register A.
579D
RET C9
RETurn to the caller: the file is in memory and is not run.

579EH - CMD"P": the Printer's Status

CMD"P",variable: the printer's status (37E8H, bits 7-4, the address the Model I file reads; the Model III answers there too: ROM C passes reads of 37E8H-37E9H through to the printer, the status the ROM's own routine at 044BH reads from port F8H) goes into the variable, as a number or, for a string variable, as the text of the number.

579E
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
57A0
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable named at Register Pair HL, 40AFH its type.
57A3
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
57A4
LD (40DFH),DE ED 53 DF 40
Store Register Pair DE (the variable's address) at 40DFH-40E0H.
57A8
PUSH DE D5
Save Register Pair DE (the variable's address) to the stack.
57A9
RST 20H E7
RST 20H, the ROM's test of the type (40AFH): the Z FLAG for a string variable.
57AA
PUSH AF F5
Save Register Pair AF (the type's flags) to the stack.
57AB
LD A,(37E8H) 3A E8 37
Load Register A with the printer's status from 37E8H, the same address as in the Model I file (on the Model III a read of 37E8H gives the printer's status, not the ROM byte AAH there): bit 7 busy, bit 6 out of paper, bit 5 selected, bit 4 fault.
57AE
AND F0H E6 F0
Mask Register A to bits 7-4 (AND F0H), the four status lines.
57B0
GOSUB to 27F8H, the ROM: Register A becomes an integer in the accumulator.
57B3
POP AF F1
Restore Register Pair AF (the type's flags) from the stack.
57B4
If the NZ FLAG is set (a numeric variable), JUMP to 57C7H.
57B6
PUSH AF F5
Save Register Pair AF (the type's flags) to the stack.
57B7
GOSUB to 0FBDH, the ROM's number to text (FOUT): the number in the accumulator as text.
57BA
GOSUB to 2865H, the ROM: a descriptor for that text.
57BD
GOSUB to 29DAH, the ROM: the temporary descriptor is freed; Register Pair HL at it.
57C0
GOSUB to 2843H, the ROM: the text is copied into string space.
57C3
GOSUB to 2888H, the ROM: its descriptor becomes the value in the accumulator.
57C6
POP AF F1
Restore Register Pair AF (the type's flags) from the stack.
57C7
POP HL E1
Restore Register Pair HL (the variable's address, from 57A8H) from the stack.
57C8
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.

57CBH - CMD"B": the BREAK Key

CMD"B","OFF" sets bit 4 of SFLAG$ (442BH) and puts RET Z (C8H) at 4BEFH in SYS0/SYS's request code 01H; CMD"B","ON" clears the bit and puts back 00H.

57CB
GOSUB to 5770H to read ON or OFF: the Z FLAG for OFF.
57CE
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
57CF
LD HL,442BH 21 2B 44
Point Register Pair HL to 442BH, SFLAG$, the system flags. LD does not change the flags.
57D2
If the Z FLAG is set (OFF), JUMP to 57DCH to turn BREAK off.
57D4
RES 4,(HL) CB A6
Clear bit 4 of SFLAG$ at Register Pair HL: BREAK is on.
57D6
XOR A AF
Load Register A with 00H (XOR A), a NOP for 4BEFH.
57D7
LD (4BEFH),A 32 EF 4B
Store Register A at 4BEFH, 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.
57DA
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
57DB
RET C9
RETurn to the caller of the CMD statement with BREAK on.
57DC
SET 4,(HL) CB E6
Set bit 4 of SFLAG$ at Register Pair HL: BREAK is off.
57DE
LD A,C8H 3E C8
Load Register A with C8H, the opcode of RET Z.
57E0
JUMP to 57D7H to store Register A (C8H) at 4BEFH.

57E2H - 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.

57E2
LD HL,1D78H 21 78 1D
Load Register Pair HL with 1D78H, the ROM's routine of RST 10H.
57E5
LD (4004H),HL 22 04 40
Store Register Pair HL (1D78H) at 4004H-4005H, the operand of the RST 10H vector at 4003H.
57E8
If the CARRY FLAG is set (CMD"A" or an error at the start), JUMP to 4030H, @ABORT.
57EB
JUMP to 402DH, @EXIT, back to LDOS Ready with no error.

57EEH - CMD: the Letters

Vector 11 (4173H). The text after CMD: 2 characters or more go to 547CH; 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 5490H, where N, X and V run their overlay with no command line, and anything else gives Illegal function call.

57EE
GOSUB to 588DH to evaluate the text after CMD: Register A = its length, Register Pair DE = the text.
57F1
CP 02H FE 02
Compare Register A (the length) against 02H: the NO CARRY FLAG for 2 or more.
57F3
If the NO CARRY FLAG is set, JUMP to 547CH: an overlay or a command of LDOS.
57F6
LD A,(DE) 1A
Load Register A with the letter at Register Pair DE.
57F7
RES 5,A CB AF
Clear bit 5 of Register A: a lower case letter becomes upper case (the asterisk 2AH becomes 0AH).
57F9
CP 4CH FE 4C
Compare Register A (the letter) against 4CH, L: load a program file.
57FB
If the Z FLAG is set (L), JUMP to 578CH to load a file.
57FE
CP 50H FE 50
Compare Register A (the letter) against 50H, P: the printer's status.
5800
If the Z FLAG is set (P), JUMP to 579EH for the printer's status.
5802
CP 54H FE 54
Compare Register A (the letter) against 54H, T: the clock display off.
5804
If the Z FLAG is set (T), JUMP to 5839H to turn the clock display off.
5806
CP 52H FE 52
Compare Register A (the letter) against 52H, R: the clock display on.
5808
If the Z FLAG is set (R), JUMP to 5836H to turn the clock display on.
580A
CP 53H FE 53
Compare Register A (the letter) against 53H, S: back to LDOS.
580C
If the Z FLAG is set (S), JUMP to 57E2H: back to LDOS through @EXIT (the CARRY FLAG is clear after the compare).
580E
CP 41H FE 41
Compare Register A (the letter) against 41H, A: back to LDOS through @ABORT.
5810
SCF 37
Set the CARRY FLAG (SCF), for @ABORT; SCF does not change the Z FLAG.
5811
If the Z FLAG is set (A), JUMP to 57E2H: back to LDOS through @ABORT.
5813
CP 49H FE 49
Compare Register A (the letter) against 49H, I: a command of LDOS, staying there.
5815
If the Z FLAG is set (I), JUMP to 585EH: a command, staying in LDOS.
5817
CP 0AH FE 0A
Compare Register A against 0AH, the asterisk after bit 5 was cleared.
5819
If the Z FLAG is set (the asterisk), JUMP to 583CH to print the screen.
581B
CP 4FH FE 4F
Compare Register A (the letter) against 4FH, O: sort an array.
581D
If the Z FLAG is set (O), JUMP to 5858H to sort an array.
581F
CP 42H FE 42
Compare Register A (the letter) against 42H, B: the BREAK key.
5821
If the Z FLAG is set (B), JUMP to 57CBH for the BREAK key.
5823
CP 45H FE 45
Compare Register A (the letter) against 45H, E: the last LDOS error.
5825
If the Z FLAG is set (E), JUMP to 586EH for the last LDOS error.
5827
CP 44H FE 44
Compare Register A (the letter) against 44H, D: DEBUG.
5829
If the Z FLAG is set (D), JUMP to 5876H for DEBUG.
582B
LD HL,1E4AH 21 4A 1E
Point Register Pair HL to 1E4AH, the ROM's Illegal function call, where 54A1H jumps for a letter that is not an overlay's.
582E
LD C,01H 0E 01
Load Register C with 01H, the length of the text.
5830
JUMP to 5490H to test the letter in Register A for N, X and V.
5833
JUMP to 1E4AH, the ROM's Illegal function call. No code comes here.

5836H - CMD"R" and CMD"T": the Clock Display

On the Model III CMD"R" turns the clock display on and CMD"T" turns it off, through the ROM's routines at 0298H and 02A1H, which set and clear bit 0 of 4210H, the switch the ROM's clock interrupt tests before it shows the time. The Model I file enables and disables the interrupts here.

5836
JUMP to 0298H, the ROM routine that sets bit 0 of 4210H: CMD"R", the clock is shown. Its RET returns to the caller of the CMD statement.
5839
JUMP to 02A1H, the ROM routine that clears bit 0 of 4210H: CMD"T", the clock display is off. Its RET returns to the caller of the CMD statement.

583CH - 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; every code is sent as it is (the Model I file prints codes below 20H as 40H-5FH; that step is not in this file). BREAK stops it.

583C
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack; 589DH takes it back.
583D
LD HL,3C00H 21 00 3C
Point Register Pair HL to 3C00H, the first character of the screen.
5840
LD A,L 7D
Copy Register L (the low byte of the screen address) into Register A.
5841
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the Z FLAG at the start of a row.
5843
LD A,0DH 3E 0D
Load Register A with 0DH, a new line; LD does not change the flags.
5845
If the Z FLAG is set (the start of a row), GOSUB to 003BH, the ROM's printer output of Register A.
5848
BIT 6,H CB 74
Test bit 6 of Register H: set at 4000H, past the screen.
584A
If the NZ FLAG is set (the screen is done), JUMP to 589DH to take back Register Pair HL and return.
584C
GOSUB to 5C95H to look at KFLAG$: the NZ FLAG for BREAK.
584F
If the NZ FLAG is set (BREAK), JUMP to 589DH to stop.
5851
LD A,(HL) 7E
Load Register A with the character on the screen at Register Pair HL.
5852
INC HL 23
INCrement Register Pair HL to the next screen position.
5853
GOSUB to 003BH, the ROM's printer output of the character in Register A.
5856
LOOP BACK to 5840H for the next character of the screen.

5858H - CMD"O": Sort an Array

BASIC/OV3 does the sort: Register A' = 03H, its function, and BASIC/OV3 is called (54DEH).

5858
LD A,03H 3E 03
Load Register A with 03H, BASIC/OV3's function: the sort of CMD"O".
585A
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF': the function is kept in Register A' for BASIC/OV3.
585B
JUMP to 54DEH to call BASIC/OV3 with its function in Register A'.

585EH - 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.

585E
GOSUB to 588BH for a comma and the text: Register A = its length, Register Pair DE = the text.
5861
LD L,A 6F
Copy Register A (the length) into Register L.
5862
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the length.
5864
ADD HL,DE 19
ADD Register Pair DE (the text) to Register Pair HL: the byte after the text.
5865
LD (HL),0DH 36 0D
Store 0DH at Register Pair HL: the end of the command line.
5867
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the command.
5868
LD SP,41E5H 31 E5 41
Load the Stack Pointer with 41E5H, the stack of LDOS.
586B
JUMP to 4299H, @CMNDI, to run the command at Register Pair HL; LDOS Ready follows.

586EH - CMD"E": the Last LDOS Error

The LDOS error kept at 660BH (stored by BASIC/OV3 function 02H, which 6463H calls) is displayed by @ERROR with bits 7 and 6 set (the short message, and back to the caller).

586E
LD A,(660BH) 3A 0B 66
Load Register A with the last LDOS error from 660BH.
5871
OR C0H F6 C0
Set bits 7 and 6 of Register A (OR C0H): return to the caller, the short message.
5873
JUMP to 4409H, @ERROR: the message is displayed and @ERROR returns to the caller of the CMD statement.

5876H - CMD"D": DEBUG

CMD"D" alone enters DEBUG at once (@DEBUG). CMD"D","ON" puts C3H in the BREAK trap switch (4405H), so BREAK enters DEBUG; CMD"D","OFF" puts C9H there.

5876
DEC HL 2B
DECrement Register Pair HL: RST 10H steps on before it takes a character.
5877
RST 10H D7
RST 10H (658DH): Register A = the character after CMD"D" at Register Pair HL; the Z FLAG at the end of the statement.
5878
If the Z FLAG is set (no switch), JUMP to 5887H.
587A
GOSUB to 5770H to read ON or OFF: the Z FLAG for OFF.
587D
LD A,C3H 3E C3
Load Register A with C3H, the opcode of JP: the trap is on. LD does not change the flags.
587F
If the NZ FLAG is set (ON), JUMP to 5883H with C3H in Register A.
5881
LD A,C9H 3E C9
Load Register A with C9H, the opcode of RET: the trap is off.
5883
LD (4405H),A 32 05 44
Store Register A at 4405H, the BREAK trap switch: with C3H, BREAK goes to the address at 4406H (440DH, DEBUG).
5886
RET C9
RETurn to the caller of the CMD statement with the trap set.
5887
GOSUB to 440DH, @DEBUG, to enter DEBUG (SYS5/SYS).
588A
RET C9
RETurn to the caller of the CMD statement after DEBUG.

588BH - The Text of a CMD

588BH 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.

588B
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come next.
588D
GOSUB to 2337H, the ROM's expression evaluator: the expression at Register Pair HL.
5890
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5891
GOSUB to 29D7H, the ROM: the result must be a string; it is freed, Register Pair HL = its descriptor.
5894
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
5895
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty string.
5896
If the Z FLAG is set (empty), JUMP to 1E4AH, the ROM's Illegal function call.
5899
INC HL 23
INCrement Register Pair HL to the string's address in the descriptor.
589A
LD E,(HL) 5E
Load Register E with the low byte of the address at Register Pair HL.
589B
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
589C
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the text.
589D
POP HL E1
Restore Register Pair HL (the text pointer) from the stack. 583CH ends here too.
589E
RET C9
RETurn with Register A = the length and Register Pair DE = the text.

589FH - The End of PRINT

Vector 36 (41BEH), CALLed by the ROM at 2174H after it set 409CH to 00H (Register A = 00H): 660CH-660DH, the current file, gets 0000H, so the output goes to the video again.

589F
LD (660CH),A 32 0C 66
Store Register A (00H) at 660CH, the low byte of the current file's buffer address.
58A2
LD (660DH),A 32 0D 66
Store Register A (00H) at 660DH, the high byte: no file is current.
58A5
RET C9
RETurn to the ROM's PRINT, with no file current.

58A6H - 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, 5CEEH) 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 (5946H). 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 (592DH).

58A6
CP 23H FE 23
Compare Register A (the character after INPUT) against 23H, #.
58A8
If the NZ FLAG is set (no #), JUMP to 58BDH for INPUT@.
58AA
PUSH HL E5
Save Register Pair HL (the pointer at the #) to the stack.
58AB
RST 10H D7
RST 10H (658DH): Register Pair HL past the #, Register A = the next character.
58AC
CP CEH FE CE
Compare Register A against CEH, the token minus: INPUT #-1, the cassette.
58AE
POP HL E1
Restore Register Pair HL (the pointer at the #) from the stack.
58AF
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the #; LD does not change the flags.
58B0
RET Z C8
If the Z FLAG is set (a minus sign), RETurn to the ROM's INPUT for the cassette.
58B1
POP BC C1
Discard the ROM's return address (POP BC into Register Pair BC): INPUT# goes on here.
58B2
GOSUB to 5CEEH to read #n and make file n current, open for input (Register C = 01H).
58B5
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack, as the ROM's INPUT keeps it.
58B6
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H (5331H).
58B9
DEC HL 2B
DECrement Register Pair HL to 5330H, the comma before the buffer.
58BA
JUMP to 21EBH, the ROM's INPUT after a line was read: the values come from the current file.
58BD
CP 40H FE 40
Compare Register A (the character after INPUT) against 40H, @.
58BF
RET NZ C0
If the NZ FLAG is set (neither # nor @), RETurn to the ROM's INPUT.
58C0
GOSUB to 2B01H, the ROM: the expression after @ as an integer in Register Pair DE (Register A = its high byte).
58C3
CP 04H FE 04
Compare Register A (the high byte) against 04H: the CARRY FLAG for 0-1023.
58C5
If the NO CARRY FLAG is set (off the screen), JUMP to 1E4AH, the ROM's Illegal function call.
58C8
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
58C9
LD HL,3C00H 21 00 3C
Point Register Pair HL to 3C00H, the first character of the screen.
58CC
GOSUB to 5A46H to put the cursor at 3C00H + Register Pair DE (4020H).
58CF
LD A,E 7B
Copy Register E (the low byte of the position) into Register A.
58D0
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the column, 0-63.
58D2
LD (40A6H),A 32 A6 40
Store Register A (the column) at 40A6H, the ROM's cursor column.
58D5
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
58D6
POP AF F1
Discard the ROM's return address (POP AF into Register Pair AF): INPUT@ goes on here.
58D7
LD A,(HL) 7E
Load Register A with the character after the position at Register Pair HL.
58D8
CP 2CH FE 2C
Compare Register A against 2CH, a comma: a prompt or a field follows.
58DA
If the Z FLAG is set (a comma), JUMP to 58E1H.
58DC
RST 08H => 3BH CF 3B
RST 08H with the byte 3BH: a semicolon must come next.
58DE
JUMP to 21DBH, the ROM's INPUT with its prompt, at the cursor just set.
58E1
RST 10H D7
RST 10H (658DH): Register Pair HL past the comma, Register A = the next character.
58E2
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
58E3
CP 22H FE 22
Compare Register A against 22H, a quote: a prompt.
58E5
If the NZ FLAG is set (no prompt), JUMP to 58F6H for the width.
58E7
GOSUB to 2866H, the ROM: a descriptor for the quoted text at Register Pair HL.
58EA
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
58EB
GOSUB to 28AAH, the ROM: the string of the descriptor is displayed (STRPRT).
58EE
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
58EF
LD A,(HL) 7E
Load Register A with the character after the prompt at Register Pair HL.
58F0
CP 3BH FE 3B
Compare Register A against 3BH, a semicolon: no field.
58F2
If the Z FLAG is set, JUMP to 58DCH: the ROM's INPUT after the prompt.
58F4
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the width.
58F6
GOSUB to 2B1CH, the ROM: the width as a byte in Register A.
58F9
OR A B7
Set the flags from Register A (OR A): the Z FLAG for a width of 0.
58FA
If the Z FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
58FD
CP F1H FE F1
Compare Register A (the width) against F1H: the CARRY FLAG for 1-240.
58FF
If the NO CARRY FLAG is set (241 or more), JUMP to 1E4AH, Illegal function call.
5902
PUSH AF F5
Save Register Pair AF (Register A = the width) to the stack.
5903
GOSUB to 588BH for a comma and the field's spec: Register A = its length, Register Pair DE = the text.
5906
LD B,A 47
Copy Register A (the length of the spec) into Register B.
5907
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.
5909
LD A,(DE) 1A
Load Register A with the first character of the spec at Register Pair DE.
590A
INC DE 13
INCrement Register Pair DE to the next character of the spec.
590B
CP 24H FE 24
Compare Register A against 24H, $: any character.
590D
If the Z FLAG is set ($, any character), JUMP to 5916H with the field's code unchanged.
590F
CP 23H FE 23
Compare Register A against 23H, #: only digits.
5911
If the NZ FLAG is set (neither), JUMP to 1997H, the ROM's Syntax error.
5914
SET 7,C CB F9
Set bit 7 of Register C (the field's code): a field that takes only digits.
5916
DEC B 05
DECrement Register B, the characters of the spec left.
5917
If the Z FLAG is set (no more), JUMP to 5930H.
5919
LD A,(DE) 1A
Load Register A with the next character of the spec at Register Pair DE.
591A
INC DE 13
INCrement Register Pair DE to the next character.
591B
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk: the field ends when it is full.
591D
If the NZ FLAG is set (not the asterisk), JUMP to 5925H: it is the fill character.
591F
SET 6,C CB F1
Set bit 6 of Register C: the field ends by itself when full.
5921
DEC B 05
DECrement Register B, the characters of the spec left.
5922
If the Z FLAG is set (no more), JUMP to 5930H.
5924
LD A,(DE) 1A
Load Register A with the fill character at Register Pair DE.
5925
SUB 20H D6 20
SUBtract 20H from Register A: the fill character less 20H.
5927
CP 60H FE 60
Compare Register A against 60H: the CARRY FLAG for a printable character, 20H-7FH.
5929
If the NO CARRY FLAG is set, JUMP to 1997H, the ROM's Syntax error.
592C
XOR C A9
Exclusive OR Register C (the field's code) into Register A (the fill character less 20H).
592D
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.
592F
LD C,A 4F
Copy Register A (the field's code) into Register C.
5930
POP AF F1
Restore Register Pair AF (Register A = the width) from the stack.
5931
LD B,A 47
Copy Register A (the width) into Register B: Register Pair BC = the width and the field's code.
5932
RST 08H => 3BH CF 3B
RST 08H with the byte 3BH: a semicolon must come before the variable.
5934
JUMP to 5946H to read the field into the string variable.

5936H - LINE INPUT

Vector 27 (41A3H), the token LINE: INPUT must follow (89H), not in a line typed at READY. LINE INPUT# goes to 5D71H. Else after an optional prompt a whole line from the keyboard (0361H) goes into a string variable; 5946H is shared with INPUT@'s field (Register B = the width, Register C = its code), read by 596DH.

5936
RST 08H => 89H CF 89
RST 08H with the byte 89H, the token INPUT: it must follow LINE.
5938
GOSUB to 2828H, the ROM: Illegal direct for a line typed at READY.
593B
LD A,(HL) 7E
Load Register A with the character after INPUT at Register Pair HL.
593C
CP 23H FE 23
Compare Register A against 23H, #: LINE INPUT from a file.
593E
If the Z FLAG is set, JUMP to 5D71H for LINE INPUT#.
5941
GOSUB to 21CDH, the ROM: a quoted prompt at Register Pair HL is displayed, with its semicolon.
5944
LD B,00H 06 00
Load Register B with 00H: no field, the whole line.
5946
PUSH BC C5
Save Register Pair BC (the width and the field's code) to the stack.
5947
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable at Register Pair HL.
594A
GOSUB to 0AF4H, the ROM: Type mismatch unless the variable is a string.
594D
POP BC C1
Restore Register Pair BC (the width and code) from the stack.
594E
PUSH DE D5
Save Register Pair DE (the variable's address) to the stack.
594F
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5950
PUSH BC C5
Save Register Pair BC (the width and code) to the stack.
5951
INC B 04
INCrement Register B (the width), with the DEC next to set the flags.
5952
DEC B 05
DECrement Register B back: the Z FLAG for no field.
5953
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.
5956
POP BC C1
Restore Register Pair BC (the width and code) from the stack.
5957
INC B 04
INCrement Register B (the width), with the DEC next to set the flags.
5958
DEC B 05
DECrement Register B back: the NZ FLAG for a field.
5959
If the NZ FLAG is set (a field), GOSUB to 596DH to read the field; Register Pair HL = the byte before the text, CARRY for BREAK.
595C
POP DE D1
Restore Register Pair DE (the text pointer) from the stack.
595D
POP BC C1
Restore Register Pair BC (the variable's address) from the stack.
595E
If the CARRY FLAG is set (BREAK), JUMP to 1DBEH, the ROM's STOP: Break in the line.
5961
PUSH BC C5
Save Register Pair BC (the variable's address) to the stack.
5962
PUSH DE D5
Save Register Pair DE (the text pointer) to the stack.
5963
LD B,00H 06 00
Load Register B with 00H, the byte that ends the text.
5965
GOSUB to 2868H, the ROM: a temporary string of the text after Register Pair HL up to the 00H in Register B.
5968
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5969
XOR A AF
Load Register A with 00H (XOR A), the flag value the ROM's assignment at 1F32H expects.
596A
JUMP to 1F32H, the ROM's assignment: the string goes into the variable whose address is on the stack.

596DH - Read a Field

INPUT@ with a width: the field editor (5984H) 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.

596D
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5970
GOSUB to 5984H, the field editor: Register B = the characters typed, CARRY for BREAK.
5973
PUSH AF F5
Save Register Pair AF (the CARRY FLAG of BREAK) to the stack.
5974
PUSH HL E5
Save Register Pair HL (the buffer) to the stack.
5975
LD C,B 48
Copy Register B (the characters typed) into Register C.
5976
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the count.
5978
ADD HL,BC 09
ADD Register Pair BC (the count) to Register Pair HL: the byte after the text.
5979
INC C 0C
INCrement Register C (the count), with the DEC next to set the flags.
597A
DEC C 0D
DECrement Register C back: the Z FLAG for an empty field.
597B
If the NZ FLAG is set (something typed), JUMP to 597FH.
597D
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.
597E
INC HL 23
INCrement Register Pair HL past the 0DH of the empty field.
597F
LD (HL),B 70
Store Register B (00H) at Register Pair HL: the end of the text.
5980
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
5981
DEC HL 2B
DECrement Register Pair HL to the byte before the text.
5982
POP AF F1
Restore Register Pair AF (the CARRY FLAG of BREAK) from the stack.
5983
RET C9
RETurn to the caller, 5959H's GOSUB in LINE INPUT, which goes on at 595CH.

5984H - Field Editor

CALLed from 5970H 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.

5984
PUSH HL E5
Save Register Pair HL (the line buffer) to the stack.
5985
PUSH BC C5
Save Register Pair BC (Register B = the width, Register C = the field's code) to the stack.
5986
LD A,C 79
Copy Register C (the field's code) into Register A.
5987
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the fill character less 20H.
5989
ADD A,20H C6 20
ADD 20H to Register A: the fill character itself.
598B
LD (5A4CH),A 32 4C 5A
Store Register A (the fill character) at 5A4CH, the operand of the LD A at 5A4BH.
598E
GOSUB to 5A4BH to display the fill character.
5991
DECrement Register B and LOOP BACK to 598EH until the whole width is painted.
5993
POP BC C1
Restore Register Pair BC (the width and the field's code) from the stack.
5994
PUSH BC C5
Save Register Pair BC (the width and the field's code) to the stack again.
5995
GOSUB to 5A28H to move the cursor one place to the left.
5998
DECrement Register B and LOOP BACK to 5995H: the cursor goes back to the start of the field.
599A
POP BC C1
Restore Register Pair BC (the width and the field's code) from the stack.
599B
PUSH BC C5
Save Register Pair BC to the stack again: 59DEH and 59FFH look at its Register C there.
599C
LD C,B 48
Copy Register B (the width) into Register C: Register B counts the places left, Register C the width.
599D
LD A,0EH 3E 0E
Load Register A with 0EH, the code that turns the cursor on: the top of the key loop.
599F
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
59A2
GOSUB to 0049H, the ROM: wait for a key, returned in Register A.
59A5
CP 20H FE 20
Compare Register A (the key) against 20H: NO CARRY for a printable character.
59A7
If the NO CARRY FLAG is set, JUMP to 59D6H to take the character.
59A9
CP 0DH FE 0D
Compare Register A (the key) against 0DH, ENTER.
59AB
If the Z FLAG is set (ENTER), JUMP to 5A06H to end the field; CP left the CARRY FLAG clear.
59AD
DEC A 3D
DECrement Register A (the key): the Z FLAG for 01H, BREAK.
59AE
SCF 37
Set the CARRY FLAG (SCF), the mark of BREAK; SCF does not change the Z FLAG.
59AF
If the Z FLAG is set (BREAK), JUMP to 5A06H to end the field with the CARRY FLAG set.
59B1
LD DE,599DH 11 9D 59
Load Register Pair DE with 599DH, the top of the key loop.
59B4
PUSH DE D5
Save Register Pair DE (599DH) to the stack: the RETurns below go back to the key loop.
59B5
CP 07H FE 07
Compare Register A (the key less 1) against 07H: the Z FLAG for 08H, left arrow.
59B7
If the Z FLAG is set (left arrow), JUMP to 59C2H to erase one character, which RETurns to 599DH.
59B9
CP 17H FE 17
Compare Register A (the key less 1) against 17H: the Z FLAG for 18H, shifted left arrow.
59BB
RET NZ C0
If the NZ FLAG is set (any other key), RETurn to 599DH: the key is ignored.
59BC
GOSUB to 59C2H to erase one character: the Z FLAG when none is left.
59BF
If the NZ FLAG is set (characters left), LOOP BACK to 59BCH.
59C1
RET C9
RETurn to 599DH, the top of the key loop, through the address 59B4H saved.

59C2H - 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).

59C2
LD A,B 78
Copy Register B (the places left) into Register A.
59C3
CP C B9
Compare Register A against Register C (the width): the Z FLAG when nothing was typed.
59C4
RET Z C8
If the Z FLAG is set (nothing to erase), RETurn to the caller with the Z FLAG set.
59C5
LD A,0FH 3E 0F
Load Register A with 0FH, the code that turns the cursor off.
59C7
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
59CA
GOSUB to 5A28H to move the cursor one place to the left, onto the last character typed.
59CD
GOSUB to 5A4BH to display the fill character over it.
59D0
GOSUB to 5A28H to move the cursor back onto that place.
59D3
DEC HL 2B
DECrement Register Pair HL, the pointer in the line buffer.
59D4
INC B 04
INCrement Register B, the places left: never zero, so the NZ FLAG is set.
59D5
RET C9
RETurn to the caller with the NZ FLAG set: a character was erased.

59D6H - 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.

59D6
CP 80H FE 80
Compare Register A (the key) against 80H: NO CARRY for 80H and up.
59D8
If the NO CARRY FLAG is set, JUMP to 599DH: the key is ignored.
59DA
INC B 04
INCrement Register B (the places left), with the DEC next to set the flags.
59DB
DEC B 05
DECrement Register B back: the Z FLAG when the field is full.
59DC
If the Z FLAG is set (no place left), JUMP to 599DH: the key is ignored.
59DE
POP DE D1
Copy the field's width and code from the stack (POP DE) into Register Pair DE.
59DF
PUSH DE D5
Save Register Pair DE (the width and code) to the stack again, as it was.
59E0
BIT 7,E CB 7B
Test bit 7 of Register E (the field's code): the Z FLAG for any character.
59E2
If the Z FLAG is set (any character), JUMP to 59F8H to take it.
59E4
CP 3AH FE 3A
Compare Register A (the key) against 3AH, the character after 9.
59E6
If the NO CARRY FLAG is set (above 9), JUMP to 599DH: the key is ignored.
59E8
CP 30H FE 30
Compare Register A (the key) against 30H, the digit 0.
59EA
If the NO CARRY FLAG is set (0-9), JUMP to 59F8H to take it.
59EC
CP 2DH FE 2D
Compare Register A (the key) against 2DH, the minus sign.
59EE
If the Z FLAG is set (the minus sign), JUMP to 59F8H to take it.
59F0
CP 2EH FE 2E
Compare Register A (the key) against 2EH, the decimal point.
59F2
If the Z FLAG is set (the point), JUMP to 59F8H to take it.
59F4
CP 2BH FE 2B
Compare Register A (the key) against 2BH, the plus sign.
59F6
If the NZ FLAG is set (any other character), JUMP to 599DH: the key is ignored.
59F8
LD (HL),A 77
Store Register A (the character) at Register Pair HL, the line buffer.
59F9
GOSUB to 0033H, the ROM: Register A (the character) is displayed over the fill character.
59FC
INC HL 23
INCrement Register Pair HL to the next byte of the line buffer.
59FD
DECrement Register B (the places left) and JUMP to 599DH while places are left.
59FF
POP DE D1
Copy the field's width and code from the stack (POP DE) into Register Pair DE.
5A00
PUSH DE D5
Save Register Pair DE (the width and code) to the stack again, as it was.
5A01
BIT 6,E CB 73
Test bit 6 of Register E (the field's code): the NZ FLAG when a full field ends.
5A03
If the Z FLAG is set (no asterisk), JUMP to 599DH: the field waits for ENTER.
5A05
CP A BF
Compare Register A with itself (CP A): the Z FLAG set, the CARRY FLAG clear, then on to 5A06H.

5A06H - End the Field

Reached on ENTER (59ABH), BREAK (59AFH, the CARRY FLAG set) and a full field (5A05H). 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.

5A06
POP DE D1
Discard the field's width and code saved at 599BH (POP DE into Register Pair DE).
5A07
PUSH AF F5
Save Register Pair AF (the CARRY FLAG of BREAK) to the stack.
5A08
PUSH BC C5
Save Register Pair BC (Register B = the places left, Register C = the width) to the stack.
5A09
LD A,0FH 3E 0F
Load Register A with 0FH, the code that turns the cursor off.
5A0B
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
5A0E
INC B 04
INCrement Register B (the places left), with the DEC next to set the flags.
5A0F
DEC B 05
DECrement Register B back: the Z FLAG when no place is left.
5A10
If the Z FLAG is set (the field is full), JUMP to 5A19H.
5A12
LD A,20H 3E 20
Load Register A with 20H, a space, to blank a place not typed.
5A14
GOSUB to 0033H, the ROM: Register A (the space) is displayed.
5A17
DECrement Register B and LOOP BACK to 5A12H until every place left is blank.
5A19
POP BC C1
Restore Register Pair BC (the places left and the width) from the stack.
5A1A
LD A,(4020H) 3A 20 40
Load Register A with the low byte of the cursor's address from 4020H.
5A1D
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the column of the cursor, 0-63.
5A1F
LD (40A6H),A 32 A6 40
Store Register A (the column) at 40A6H, the ROM's cursor column.
5A22
LD A,C 79
Copy Register C (the width of the field) into Register A.
5A23
SUB B 90
SUBtract Register B (the places left) from Register A: the characters typed.
5A24
LD B,A 47
Copy Register A (the characters typed) into Register B for 5975H.
5A25
POP AF F1
Restore Register Pair AF (the CARRY FLAG of BREAK) from the stack.
5A26
POP HL E1
Restore Register Pair HL (the line buffer) from the stack.
5A27
RET C9
RETurn to 5973H with Register B = the characters typed and the CARRY FLAG for BREAK.

5A28H - Cursor Left

Sends 18H (backspace) to the display. When the cursor is at the left edge of a line, 5A3FH first moves the cursor's address in 4020H up one line; in the wide character mode (bit 2 of 4210H, the copy of port ECH) the place before is tested too, as each character there takes two places.

5A28
PUSH HL E5
Save Register Pair HL (the pointer in the line buffer) to the stack.
5A29
LD HL,(4020H) 2A 20 40
Load Register Pair HL with the cursor's address from 4020H-4021H.
5A2C
GOSUB to 5A3FH: at the left edge the cursor's address in 4020H goes up a line.
5A2F
DEC HL 2B
DECrement Register Pair HL to the place before the cursor.
5A30
LD A,(4210H) 3A 10 42
Load Register A with the byte at 4210H, the copy of what was last sent to port ECH.
5A33
AND 04H E6 04
Mask Register A to bit 2 (AND 04H): the wide character mode, 32 characters to a line.
5A35
If the NZ FLAG is set (wide characters), GOSUB to 5A3FH to test the place before as well.
5A38
LD A,18H 3E 18
Load Register A with 18H, the display code for backspace.
5A3A
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
5A3D
POP HL E1
Restore Register Pair HL (the pointer in the line buffer) from the stack.
5A3E
RET C9
RETurn to the caller with the cursor one place to the left.

5A3FH - Cursor Up at the Left Edge

5A3FH: if Register Pair HL is at column 0, 4020H gets Register Pair HL less 40H (64), one line up. 5A46H is entered from 58CCH by INPUT@: 4020H gets Register Pair HL + Register Pair DE.

5A3F
LD A,L 7D
Copy Register L (the low byte of the address) into Register A.
5A40
AND 3FH E6 3F
Mask Register A to bits 5-0 (AND 3FH): the Z FLAG for column 0.
5A42
RET NZ C0
If the NZ FLAG is set (not at the left edge), RETurn to the caller.
5A43
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 40H: one line of 64 characters back.
5A46
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the new address of the cursor.
5A47
LD (4020H),HL 22 20 40
Store Register Pair HL (the cursor's address) at 4020H-4021H, the display's cursor.
5A4A
RET C9
RETurn to the caller with the new cursor address in Register Pair HL.

5A4BH - Display the Fill Character

Register A gets the fill character that 598BH stored in the operand at 5A4CH, and it is displayed (0033H).

5A4B
LD A,5FH 3E 5F
Load Register A with the fill character, the operand at 5A4CH (5FH in the file, stored by 598BH).
5A4D
JUMP to 0033H, the ROM: Register A (the character) is displayed and the ROM RETurns to the caller.

5A50H - 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 (660CH = 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.

5A50
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5A51
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5A54
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5A55
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5A56
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5A57
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM.
5A58
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.
5A59
PUSH DE D5
Save Register Pair DE to the stack across the comparison.
5A5A
LD DE,2B2EH 11 2E 2B
Load Register Pair DE with 2B2EH, an address in the ROM between the two callers.
5A5D
RST 18H DF
RST 18H: compare Register Pair HL (the return address) against Register Pair DE; CARRY for 227BH, the end of INPUT.
5A5E
POP DE D1
Restore Register Pair DE from the stack after the comparison.
5A5F
POP HL E1
Restore Register Pair HL (the text pointer) from the stack; the return address is dropped.
5A60
If the NO CARRY FLAG is set (LIST), JUMP to 2B4AH, the ROM's LIST past its test of the keyboard.
5A63
JUMP to 2282H, the ROM's end of INPUT and READ, past its Extra ignored message.

5A66H - Error Messages

Vector 28 (41A6H), CALLed by the ROM's error handler with Register E = the error's E value. If 6608H holds D6H (a RUN with V whose variables are parked, 5F64H), 5F97H puts 40A0H and the stack back, clears 6608H and starts the program (5FC5H); it never comes back. Else BASIC/OV3 function 01H puts the message's text in Register Pair HL; it is displayed, 6401H makes the protection test, and the ROM at 1A11H adds IN and the line number.

5A66
POP HL E1
Discard the ROM's return address (POP HL into Register Pair HL).
5A67
LD A,(6608H) 3A 08 66
Load Register A with the run state byte at 6608H (D6H for a RUN with V).
5A6A
CP D6H FE D6
Compare Register A against D6H: the Z FLAG when a RUN with V has its variables parked.
5A6C
If the NZ FLAG is set, JUMP to 5A72H for the message.
5A6E
GOSUB to 5F97H: 40A0H, 40E8H and the stack are put back, 6608H cleared and the program started at 5FC5H. This call never RETurns.
5A71
LD SP,HL F9
Load the Stack Pointer from Register Pair HL. Never reached: the call at 5A6EH does not RETurn.
5A72
LD L,E 6B
Copy Register E (the error's E value) into Register L for BASIC/OV3.
5A73
LD A,01H 3E 01
Load Register A with 01H, BASIC/OV3's function for an error message.
5A75
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number in Register A' for 54DEH.
5A76
GOSUB to 54DEH to load and enter BASIC/OV3: Register Pair HL = the message's text.
5A79
GOSUB to 28A7H, the ROM: the text at Register Pair HL is displayed.
5A7C
LD HL,(40EAH) 2A EA 40
Load Register Pair HL with 40EAH-40EBH, the line number of the error.
5A7F
GOSUB to 6401H, the protection test (it RETurns with Register Pair HL unchanged unless memory was cleared).
5A82
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).

5A85H - 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).

5A85
RST 10H D7
RST 10H (658DH): Register Pair HL past INSTR and Register A = the next character.
5A86
GOSUB to 2335H, the ROM: a left parenthesis must come, then the first expression is evaluated.
5A89
RST 20H E7
RST 20H: the type of the result; the Z FLAG for a string.
5A8A
LD A,01H 3E 01
Load Register A with 01H, the start when n is left out; LD does not change the flags.
5A8C
PUSH AF F5
Save Register Pair AF (Register A = the start, 01H) to the stack.
5A8D
If the Z FLAG is set (a string: no n), JUMP to 5AA0H with the start 01H on the stack.
5A8F
POP AF F1
Discard the start 01H (POP AF into Register Pair AF): n was given.
5A90
GOSUB to 2B1FH, the ROM: the number n as a byte in Register A (0-255).
5A93
AND A A7
Set the flags from Register A (AND A): the Z FLAG for n = 0.
5A94
If the Z FLAG is set (n = 0), JUMP to 1E4AH, the ROM's Illegal function call.
5A97
PUSH AF F5
Save Register Pair AF (Register A = the start, n) to the stack.
5A98
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before a$.
5A9A
GOSUB to 2337H, the ROM: evaluate the expression a$.
5A9D
GOSUB to 0AF4H, the ROM: Type mismatch unless the result is a string.
5AA0
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before b$.
5AA2
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5AA3
LD HL,(4121H) 2A 21 41
Load Register Pair HL with a$'s descriptor address from 4121H-4122H.
5AA6
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.
5AA7
GOSUB to 2337H, the ROM: evaluate the expression b$.
5AAA
RST 08H => 29H CF 29
RST 08H with the byte 29H: a right parenthesis must end INSTR.
5AAC
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5AAD
GOSUB to 29D7H, the ROM: b$ must be a string, its temporary freed; Register Pair HL = its descriptor.
5AB0
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = b$'s descriptor.
5AB1
POP BC C1
Restore Register Pair BC (the text pointer) from the stack.
5AB2
POP HL E1
Restore Register Pair HL (a$'s descriptor) from the stack.
5AB3
POP AF F1
Restore Register Pair AF (Register A = the start) from the stack.
5AB4
PUSH BC C5
Save Register Pair BC (the text pointer) to the stack, for 26E7H.
5AB5
LD BC,26E7H 01 E7 26
Load Register Pair BC with 26E7H, the ROM's POP HL and RET: the text pointer back.
5AB8
PUSH BC C5
Save Register Pair BC (26E7H) to the stack, a return address.
5AB9
LD BC,27F8H 01 F8 27
Load Register Pair BC with 27F8H, the ROM: Register A as an integer result.
5ABC
PUSH BC C5
Save Register Pair BC (27F8H) to the stack: the RETurns below go there with the result in Register A.
5ABD
PUSH AF F5
Save Register Pair AF (Register A = the start) to the stack.
5ABE
PUSH DE D5
Save Register Pair DE (b$'s descriptor) to the stack.
5ABF
GOSUB to 29DDH, the ROM: a$'s temporary is freed; Register Pair HL = its descriptor.
5AC2
POP DE D1
Restore Register Pair DE (b$'s descriptor) from the stack.
5AC3
POP AF F1
Restore Register Pair AF (Register A = the start) from the stack.
5AC4
LD B,A 47
Copy Register A (the start, 1-255) into Register B for 5AD0H.
5AC5
DEC A 3D
DECrement Register A: the start less 1, the characters to skip.
5AC6
LD C,A 4F
Copy Register A (the characters to skip) into Register C.
5AC7
CP (HL) BE
Compare Register A against a$'s length at Register Pair HL: NO CARRY when the start is past the end.
5AC8
LD A,00H 3E 00
Load Register A with 00H, the result for not found; LD does not change the flags.
5ACA
RET NC D0
If the NO CARRY FLAG is set (the start is past the end of a$), RETurn the result 0.
5ACB
LD A,(HL) 7E
Load Register A with a$'s length at Register Pair HL.
5ACC
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty a$.
5ACD
RET Z C8
If the Z FLAG is set (a$ is empty), RETurn the result 0 in Register A.
5ACE
LD A,(DE) 1A
Load Register A with b$'s length at Register Pair DE.
5ACF
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty b$.
5AD0
LD A,B 78
Copy Register B (the start) into Register A; LD does not change the flags.
5AD1
RET Z C8
If the Z FLAG is set (b$ is empty), RETurn the start as the result in Register A.
5AD2
LD A,(HL) 7E
Load Register A with a$'s length at Register Pair HL.
5AD3
INC HL 23
INCrement Register Pair HL to the low byte of a$'s address.
5AD4
LD B,(HL) 46
Load Register B with the low byte of a$'s address at Register Pair HL.
5AD5
INC HL 23
INCrement Register Pair HL to the high byte of a$'s address.
5AD6
LD H,(HL) 66
Load Register H with the high byte of a$'s address at Register Pair HL.
5AD7
LD L,B 68
Copy Register B (the low byte) into Register L: Register Pair HL = a$'s text.
5AD8
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the characters to skip.
5ADA
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the character of a$ at the start.
5ADB
SUB C 91
SUBtract Register C (the characters skipped) from Register A (a$'s length): the characters left.
5ADC
LD B,A 47
Copy Register A (the characters left in a$) into Register B.
5ADD
PUSH BC C5
Save Register Pair BC (Register B = the characters left, Register C = those skipped) to the stack.
5ADE
PUSH DE D5
Save Register Pair DE (b$'s descriptor) to the stack.
5ADF
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$.
5AE0
LD C,(HL) 4E
Load Register C with b$'s length at Register Pair HL.
5AE1
INC HL 23
INCrement Register Pair HL to the low byte of b$'s address.
5AE2
LD E,(HL) 5E
Load Register E with the low byte of b$'s address at Register Pair HL.
5AE3
INC HL 23
INCrement Register Pair HL to the high byte of b$'s address.
5AE4
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = b$'s text.
5AE5
POP HL E1
Restore Register Pair HL (the place in a$) from the stack.
5AE6
PUSH HL E5
Save Register Pair HL (the place in a$ being tried) to the stack: the top of the search loop.
5AE7
PUSH DE D5
Save Register Pair DE (b$'s text) to the stack.
5AE8
PUSH BC C5
Save Register Pair BC (Register B = the characters left in a$, Register C = b$'s length) to the stack.
5AE9
LD A,(DE) 1A
Load Register A with the character of b$ at Register Pair DE.
5AEA
CP (HL) BE
Compare Register A against the character of a$ at Register Pair HL.
5AEB
If the NZ FLAG is set (they differ), JUMP to 5B04H to try the next place in a$.
5AED
INC DE 13
INCrement Register Pair DE to the next character of b$.
5AEE
DEC C 0D
DECrement Register C, the characters of b$ left to match.
5AEF
If the Z FLAG is set (all of b$ matched), JUMP to 5AFBH for the position.
5AF1
INC HL 23
INCrement Register Pair HL to the next character of a$.
5AF2
DEC B 05
DECrement Register B, the characters left in a$.
5AF3
If the NZ FLAG is set (a$ has more), LOOP BACK to 5AE9H to match the next character.
5AF5
POP DE D1
Discard the saved counts (POP DE into Register Pair DE): a$ ended in the middle of b$.
5AF6
POP DE D1
Discard b$'s text pointer (POP DE into Register Pair DE).
5AF7
POP BC C1
Discard the place in a$ (POP BC into Register Pair BC).
5AF8
POP DE D1
Discard the counts saved at 5ADDH (POP DE into Register Pair DE).
5AF9
XOR A AF
Load Register A with 00H (XOR A): the result for not found.
5AFA
RET C9
RETurn the result 0 in Register A through the ROM at 27F8H.
5AFB
POP HL E1
Restore into Register Pair HL the counts of the place tried: Register H = the characters of a$ left there.
5AFC
POP DE D1
Discard b$'s text pointer (POP DE into Register Pair DE).
5AFD
POP DE D1
Discard the place in a$ (POP DE into Register Pair DE).
5AFE
POP BC C1
Restore Register Pair BC (Register B = the characters left at the start, Register C = those skipped).
5AFF
LD A,B 78
Copy Register B (the characters left at the start) into Register A.
5B00
SUB H 94
SUBtract Register H (those left at the match) from Register A: the characters passed over in the search.
5B01
ADD A,C 81
ADD Register C (the characters skipped before the start) to Register A.
5B02
INC A 3C
INCrement Register A: the position of b$ in a$, counting from 1.
5B03
RET C9
RETurn the position in Register A through 27F8H.
5B04
POP BC C1
Restore Register Pair BC (Register B = the characters left, Register C = b$'s length) from the stack.
5B05
POP DE D1
Restore Register Pair DE (b$'s text) from the stack.
5B06
POP HL E1
Restore Register Pair HL (the place in a$ tried) from the stack.
5B07
INC HL 23
INCrement Register Pair HL to the next place in a$.
5B08
DEC B 05
DECrement Register B, the characters left in a$.
5B09
If the Z FLAG is set (no place left), JUMP to 5AF8H: the result 0.
5B0B
JUMP to 5AE6H to try b$ at the next place in a$.

5B0DH - &

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.

5B0D
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value so far.
5B10
RST 10H D7
RST 10H (658DH): Register Pair HL past the & and Register A = the next character.
5B11
CP 4FH FE 4F
Compare Register A against 4FH, the letter O: octal.
5B13
If the Z FLAG is set (&O), JUMP to 5B3DH for the octal digits.
5B15
CP 48H FE 48
Compare Register A against 48H, the letter H: hexadecimal.
5B17
If the NZ FLAG is set (& and a digit), JUMP to 5B3CH: octal, the character read again.
5B19
LD B,05H 06 05
Load Register B with 05H: at most 4 hexadecimal digits, the fifth is an overflow.
5B1B
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character and Register A = it.
5B1C
NOP 00
No operation (NOP): Register A and the flags from the RST 10H are kept.
5B1D
GOSUB to 1E3EH, the ROM: the CARRY FLAG unless Register A is a letter A-Z.
5B20
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the value, Register Pair DE = the text pointer.
5B21
If the NO CARRY FLAG is set (a letter), JUMP to 5B29H.
5B23
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9.
5B25
If the NO CARRY FLAG is set (not a digit), JUMP to 5B59H: the number ends.
5B27
ADD A,07H C6 07
ADD 07H to Register A, with the SUB 37H next: a digit less 30H.
5B29
SUB 37H D6 37
SUBtract 37H from Register A: A-F become 0AH-0FH, digits 00H-09H.
5B2B
CP 10H FE 10
Compare Register A against 10H: NO CARRY for a character that is not a hexadecimal digit.
5B2D
If the NO CARRY FLAG is set, JUMP to 5B59H: the number ends.
5B2F
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
5B30
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
5B31
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 8.
5B32
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 16.
5B33
OR L B5
OR Register L into Register A: the new digit in the low 4 bits.
5B34
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the value with the new digit.
5B35
DEC B 05
DECrement Register B, the hexadecimal digits still allowed.
5B36
If the Z FLAG is set (a fifth digit), JUMP to 07B2H, the ROM's Overflow.
5B39
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the value, Register Pair HL = the text pointer.
5B3A
JUMP to 5B1BH for the next hexadecimal digit.
5B3C
DEC HL 2B
DECrement Register Pair HL back to the & so the RST 10H next reads the digit again.
5B3D
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character and Register A = it; CARRY for a digit.
5B3E
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the value, Register Pair DE = the text pointer.
5B3F
If the NO CARRY FLAG is set (not a digit), JUMP to 5B59H: the number ends.
5B41
CP 38H FE 38
Compare Register A against 38H, the digit 8: NO CARRY for 8 or 9.
5B43
If the NO CARRY FLAG is set, JUMP to 1997H, the ROM's Syntax error.
5B46
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
5B47
If the CARRY FLAG is set (past FFFFH), JUMP to 5B4DH for the Overflow.
5B49
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
5B4A
If the CARRY FLAG is set (past FFFFH), JUMP to 5B4DH for the Overflow.
5B4C
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 8.
5B4D
If the CARRY FLAG is set (past FFFFH), JUMP to 07B2H, the ROM's Overflow.
5B50
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit.
5B52
SUB 30H D6 30
SUBtract 30H from Register A: the octal digit, 0-7, as a number.
5B54
LD C,A 4F
Copy Register A (the digit) into Register C: Register Pair BC = the digit.
5B55
ADD HL,BC 09
ADD Register Pair BC (the digit) to Register Pair HL (the value times 8).
5B56
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the value, Register Pair HL = the text pointer.
5B57
JUMP to 5B3DH for the next octal digit of the constant.
5B59
GOSUB to 0A9AH, the ROM: the accumulator = Register Pair HL, an integer.
5B5C
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the text pointer again.
5B5D
RET C9
RETurn to the ROM with the integer in the accumulator.

5B5EH - 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.

5B5E
INC HL 23
INCrement Register Pair HL past the MID$ token.
5B5F
RST 08H => 28H CF 28
RST 08H with the byte 28H: a left parenthesis must come.
5B61
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable v$.
5B64
GOSUB to 0AF4H, the ROM: Type mismatch unless v$ is a string.
5B67
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5B68
PUSH DE D5
Save Register Pair DE (v$'s descriptor) to the stack.
5B69
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = v$'s descriptor.
5B6A
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
5B6B
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
5B6C
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
5B6D
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = v$'s text.
5B6E
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with 40A0H-40A1H, the start of string space.
5B71
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.
5B72
If the CARRY FLAG is set (in string space), JUMP to 5B7EH.
5B74
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
5B75
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack again.
5B76
GOSUB to 2843H, the ROM: a copy of v$ is made in string space, its new descriptor at Register Pair DE.
5B79
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
5B7A
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack again.
5B7B
GOSUB to 09D3H, the ROM: the new descriptor at Register Pair DE is copied over v$'s at Register Pair HL.
5B7E
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
5B7F
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.
5B80
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the position.
5B82
GOSUB to 2B1CH, the ROM: the position p as a byte in Register A.
5B85
AND A A7
Set the flags from Register A (AND A): the Z FLAG for p = 0.
5B86
If the Z FLAG is set (p = 0), JUMP to 1E4AH, the ROM's Illegal function call.
5B89
PUSH AF F5
Save Register Pair AF (Register A = the position p) to the stack.
5B8A
LD A,(HL) 7E
Load Register A with the character after p at Register Pair HL.
5B8B
GOSUB to 5BD1H for the count n and the right parenthesis: Register E = n, FFH if left out.
5B8E
PUSH DE D5
Save Register Pair DE (Register E = the count n) to the stack.
5B8F
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: it must come next.
5B91
GOSUB to 2337H, the ROM: evaluate the expression x$.
5B94
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5B95
GOSUB to 29D7H, the ROM: x$ must be a string, its temporary freed; Register Pair HL = its descriptor.
5B98
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = x$'s descriptor.
5B99
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5B9A
POP BC C1
Restore Register Pair BC (Register C = the count n) from the stack.
5B9B
POP AF F1
Restore Register Pair AF (Register A = the position p) from the stack.
5B9C
LD B,A 47
Copy Register A (the position p) into Register B.
5B9D
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.
5B9E
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
5B9F
LD HL,26E7H 21 E7 26
Load Register Pair HL with 26E7H, the ROM's POP HL and RET: the text pointer back.
5BA2
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.
5BA3
LD A,C 79
Copy Register C (the count n) into Register A.
5BA4
AND A A7
Set the flags from Register A (AND A): the Z FLAG for n = 0.
5BA5
RET Z C8
If the Z FLAG is set (n = 0, nothing to do), RETurn through 26E7H.
5BA6
LD A,(HL) 7E
Load Register A with v$'s length at Register Pair HL.
5BA7
SUB B 90
SUBtract Register B (the position p) from Register A: CARRY when p is past v$'s end.
5BA8
If the CARRY FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
5BAB
INC A 3C
INCrement Register A: the characters of v$ from p to its end.
5BAC
CP C B9
Compare Register A against Register C (the count n): CARRY when fewer than n.
5BAD
If the CARRY FLAG is set, JUMP to 5BB0H: the count is the characters to v$'s end.
5BAF
LD A,C 79
Copy Register C (the count n) into Register A.
5BB0
LD C,B 48
Copy Register B (the position p) into Register C.
5BB1
DEC C 0D
DECrement Register C: p less 1, the offset in v$.
5BB2
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the offset.
5BB4
PUSH DE D5
Save Register Pair DE (x$'s descriptor) to the stack.
5BB5
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
5BB6
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
5BB7
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
5BB8
LD H,(HL) 66
Load Register H with the high byte of v$'s address at Register Pair HL.
5BB9
LD L,E 6B
Copy Register E (the low byte) into Register L: Register Pair HL = v$'s text.
5BBA
ADD HL,BC 09
ADD Register Pair BC (the offset) to Register Pair HL: the place in v$ at p.
5BBB
LD B,A 47
Copy Register A (the characters to replace) into Register B.
5BBC
POP DE D1
Restore Register Pair DE (x$'s descriptor) from the stack.
5BBD
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$.
5BBE
LD C,(HL) 4E
Load Register C with x$'s length at Register Pair HL.
5BBF
INC HL 23
INCrement Register Pair HL to the low byte of x$'s address.
5BC0
LD A,(HL) 7E
Load Register A with the low byte of x$'s address at Register Pair HL.
5BC1
INC HL 23
INCrement Register Pair HL to the high byte of x$'s address.
5BC2
LD H,(HL) 66
Load Register H with the high byte of x$'s address at Register Pair HL.
5BC3
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = x$'s text.
5BC4
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$.
5BC5
LD A,C 79
Copy Register C (x$'s length) into Register A.
5BC6
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty x$.
5BC7
RET Z C8
If the Z FLAG is set (x$ is empty), RETurn through 26E7H.
5BC8
LD A,(DE) 1A
Load Register A with a character of x$ at Register Pair DE.
5BC9
LD (HL),A 77
Store Register A at Register Pair HL, over the character of v$.
5BCA
INC DE 13
INCrement Register Pair DE to the next character of x$.
5BCB
INC HL 23
INCrement Register Pair HL to the next character of v$.
5BCC
DEC C 0D
DECrement Register C, the characters of x$ left.
5BCD
RET Z C8
If the Z FLAG is set (x$ is used up), RETurn through 26E7H.
5BCE
DECrement Register B (the characters of v$ left to replace) and LOOP BACK to 5BC8H.
5BD0
RET C9
RETurn through the ROM at 26E7H: the characters of v$ are replaced.

5BD1H - 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.

5BD1
LD E,FFH 1E FF
Load Register E with FFH, the count when it is left out.
5BD3
CP 29H FE 29
Compare Register A against 29H, the right parenthesis.
5BD5
If the Z FLAG is set (no count), JUMP to 5BDCH.
5BD7
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the count.
5BD9
GOSUB to 2B1CH, the ROM: the count as a byte in Register A and Register E.
5BDC
RST 08H => 29H CF 29
RST 08H with the byte 29H: a right parenthesis must come.
5BDE
RET C9
RETurn to 5B8EH with Register E = the count n (FFH if left out).

5BDFH - 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 646DH takes over. With one, up to 240 (F0H) bytes are read through 0384H (the keyboard exit 5C1CH 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.

5BDF
PUSH HL E5
Save Register Pair HL to the stack across the test for a current file.
5BE0
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5BE3
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5BE4
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5BE5
POP HL E1
Restore Register Pair HL from the stack; POP does not change the flags.
5BE6
If the Z FLAG is set (no current file), JUMP to 646DH for a line from the keyboard.
5BE9
POP AF F1
Discard the ROM's return address 036BH (POP AF into Register Pair AF): this RETurns to the ROM's caller.
5BEA
PUSH BC C5
Save Register Pair BC to the stack while the line is read.
5BEB
PUSH DE D5
Save Register Pair DE to the stack while the line is read.
5BEC
LD B,F0H 06 F0
Load Register B with F0H, the longest line: 240 bytes.
5BEE
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5BF1
GOSUB to 0384H, the ROM: wait for a key, here the next byte of the file, in Register A.
5BF4
LD (HL),A 77
Store Register A (the byte) at Register Pair HL in the line buffer.
5BF5
CP 0DH FE 0D
Compare Register A against 0DH, the end of a line.
5BF7
If the Z FLAG is set (the end of the line), JUMP to 5C05H.
5BF9
CP 0AH FE 0A
Compare Register A against 0AH, a line feed, kept unless it comes first.
5BFB
If the NZ FLAG is set (any other byte), JUMP to 5C02H to keep it.
5BFD
LD A,B 78
Copy Register B (the bytes left) into Register A.
5BFE
CP F0H FE F0
Compare Register A against F0H: the Z FLAG when the line feed is the first byte.
5C00
If the Z FLAG is set, JUMP to 5BF1H: the first line feed is dropped (the next byte goes over it).
5C02
INC HL 23
INCrement Register Pair HL to the next byte of the line buffer.
5C03
DECrement Register B (the bytes left) and LOOP BACK to 5BF1H while room is left.
5C05
XOR A AF
Load Register A with 00H (XOR A), clearing the CARRY FLAG: no BREAK.
5C06
LD (HL),A 77
Store Register A (00H) at Register Pair HL: the end of the line, over the 0DH.
5C07
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
5C08
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
5C09
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5C0C
DEC HL 2B
DECrement Register Pair HL to the byte before the line, as the ROM's line input returns it.
5C0D
RET C9
RETurn to the caller of the ROM's line input with the line in the buffer.

5C0EH - 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 61E4H writes the byte to the file and RETurns to the ROM's caller.

5C0E
PUSH HL E5
Save Register Pair HL to the stack across the test for a current file.
5C0F
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5C12
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5C13
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5C14
POP HL E1
Restore Register Pair HL from the stack; POP does not change the flags.
5C15
LD A,C 79
Copy Register C (the byte to send) into Register A; LD does not change the flags.
5C16
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM at 032FH with Register A = the byte.
5C17
POP BC C1
Discard the ROM's return address 032FH (POP BC into Register Pair BC).
5C18
POP BC C1
Restore Register Pair BC, saved by the ROM at 032AH, from the stack.
5C19
JUMP to 61E4H to write Register A (the byte) to the current file; it RETurns to the ROM's caller.

5C1CH - 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 (628FH) 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 5F68H. Other callers go to 5C61H.

5C1C
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers are kept there.
5C1D
POP HL E1
Discard the return address 035BH (POP HL into Register Pair HL).
5C1E
POP HL E1
Load Register Pair HL with the return address of the caller of 0358H (POP HL).
5C1F
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.
5C22
RST 18H DF
RST 18H: compare Register Pair HL (the caller) against Register Pair DE (0387H); the Z FLAG for 0384H.
5C23
If the NZ FLAG is set (another caller), JUMP to 5C61H.
5C25
PUSH HL E5
Save Register Pair HL (0387H) to the stack as the return address again.
5C26
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5C29
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5C2A
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5C2B
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
5C2C
If the Z FLAG is set (no current file), JUMP to 035BH, the ROM's keyboard scan past the vector.
5C2F
PUSH HL E5
Save Register Pair HL to the stack for 26E7H.
5C30
GOSUB to 628FH to read a byte of the current file: NO CARRY with it in Register A, CARRY at the end of the file.
5C33
If the NO CARRY FLAG is set (a byte), JUMP to 26E7H, the ROM's POP HL and RET: the byte goes to 0387H.
5C36
LD A,(6608H) 3A 08 66
Load Register A with the run state at 6608H (00H LOAD, D6H RUN with V, else RUN).
5C39
CP D6H FE D6
Compare Register A against D6H: the Z FLAG for a RUN with V.
5C3B
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.
5C3E
If the Z FLAG is set (RUN with V), JUMP to 5F68H to bring the variables back.
5C41
PUSH AF F5
Save Register Pair AF (Register A = the run state) to the stack.
5C42
PUSH BC C5
Save Register Pair BC to the stack across 5FD8H.
5C43
PUSH DE D5
Save Register Pair DE to the stack across 5FD8H.
5C44
GOSUB to 5FD8H, the READY exit: output back to the display and file 0 closed.
5C47
POP DE D1
Restore Register Pair DE from the stack after the READY exit.
5C48
POP BC C1
Restore Register Pair BC from the stack after the READY exit.
5C49
POP AF F1
Restore Register Pair AF (Register A = the run state) from the stack.
5C4A
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a plain LOAD.
5C4B
LD HL,5FC5H 21 C5 5F
Load Register Pair HL with 5FC5H, the start of the program after a load.
5C4E
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): 5FC5H becomes the return address.
5C4F
If the NZ FLAG is set (RUN), JUMP to 1B5DH, the ROM's RUN set up, which RETurns to 5FC5H to start the program.
5C52
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.
5C53
PUSH BC C5
Save Register Pair BC to the stack across the message.
5C54
PUSH DE D5
Save Register Pair DE to the stack across the message.
5C55
LD HL,1929H 21 29 19
Load Register Pair HL with 1929H, the ROM's READY message.
5C58
GOSUB to 28A7H, the ROM: the text at Register Pair HL is displayed.
5C5B
POP DE D1
Restore Register Pair DE from the stack after the READY message.
5C5C
POP BC C1
Restore Register Pair BC from the stack after the READY message.
5C5D
LD A,0DH 3E 0D
Load Register A with 0DH, ENTER: the key that ends the line.
5C5F
POP HL E1
Restore Register Pair HL from the stack, the value saved at 5C2FH.
5C60
RET C9
RETurn to 0387H with Register A = 0DH (ENTER).

5C61H - 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 (4285H) is called and KFLAG$ (429FH) read: BREAK gives Register A = 01H; the pause (SHIFT and @) waits for a key other than 60H, clears the flags (5CA7H), and gives 01H if that key was BREAK. Else Register A = 00H, no key. Register A, as the compare of 5C22H left it, goes to 40A9H, which nothing in BASIC/CMD reads.

5C61
LD (40A9H),A 32 A9 40
Store Register A (left by the RST 18H compare at 5C22H) at 40A9H; nothing in BASIC/CMD reads it back.
5C64
LD DE,01A8H 11 A8 01
Load Register Pair DE with 01A8H, the return address of the ROM's INKEY$.
5C67
RST 18H DF
RST 18H: compare Register Pair HL (the caller) against Register Pair DE (01A8H); the Z FLAG for INKEY$.
5C68
PUSH HL E5
Save Register Pair HL (the caller's return address) to the stack again.
5C69
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
5C6A
If the Z FLAG is set (INKEY$), JUMP to 035BH, the ROM's keyboard scan past the vector.
5C6D
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers kept there.
5C6E
GOSUB to 4285H, @KITSK, the keyboard task hook.
5C71
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
5C72
GOSUB to 5C95H: Register A = KFLAG$, the keys queued are read away, the NZ FLAG for BREAK.
5C75
If the NZ FLAG is set (BREAK), JUMP to 5C8AH to give Register A = 01H.
5C77
BIT 1,A CB 4F
Test bit 1 of Register A (KFLAG$): the pause, SHIFT and @.
5C79
If the Z FLAG is set (no pause), JUMP to 5C88H: Register A = 00H, no key.
5C7B
GOSUB to 0384H, the ROM: wait for a key, in Register A.
5C7E
CP 60H FE 60
Compare Register A against 60H, the code of SHIFT and @.
5C80
If the Z FLAG is set (the pause again), LOOP BACK to 5C7BH to wait for another key.
5C82
GOSUB to 5CA7H to clear bits 2-0 of KFLAG$ (429FH): ENTER, pause and BREAK.
5C85
DEC A 3D
DECrement Register A (the key): the Z FLAG for 01H, BREAK.
5C86
If the Z FLAG is set (BREAK), JUMP to 5C8AH to give Register A = 01H.
5C88
XOR A AF
Load Register A with 00H (XOR A): no key, the Z FLAG set.
5C89
RET C9
RETurn to the caller of 0358H with Register A = 00H.
5C8A
LD A,01H 3E 01
Load Register A with 01H, the code the ROM takes for BREAK.
5C8C
RET C9
RETurn to the caller of 0358H with Register A = 01H, BREAK.

5C8DH - Point the BREAK Vector at READY, Then Clear KFLAG$

CALLed at 52FAH (the start) and 5601H (after CMD"command"). The word at 4204H, the operand of the JP at 4203H that the ROM's waits for the cassette and the RS-232 take on BREAK, gets 1A19H, the ROM's READY, so BREAK there comes back to BASIC; then bits 2-0 of KFLAG$ are cleared. The Model I file only clears KFLAG$ here.

5C8D
LD HL,1A19H 21 19 1A
Load Register Pair HL with 1A19H, the ROM's READY of BASIC.
5C90
LD (4204H),HL 22 04 42
Store Register Pair HL (1A19H) at 4204H-4205H, the operand of the JP at 4203H: BREAK in the ROM's waits now goes to READY.
5C93
JUMP to 5CA7H to clear bits 2-0 of KFLAG$: the end of 5C8DH.

5C95H - Read KFLAG$

Register A = KFLAG$ (429FH). 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 5C72H and 584CH.

5C95
LD A,(429FH) 3A 9F 42
Load Register A with KFLAG$, the keyboard flags at 429FH.
5C98
PUSH AF F5
Save Register Pair AF (Register A = KFLAG$) to the stack.
5C99
AND 03H E6 03
Mask Register A to bits 1 and 0 (AND 03H): the pause and BREAK.
5C9B
If the Z FLAG is set (neither), JUMP to 5CA3H.
5C9D
GOSUB to 035BH, the ROM's keyboard scan past the vector: Register A = a key or 00H.
5CA0
OR A B7
Set the flags from Register A (OR A): the Z FLAG when no key is left.
5CA1
If the NZ FLAG is set (a key was read), LOOP BACK to 5C9DH.
5CA3
POP AF F1
Restore Register Pair AF (Register A = KFLAG$) from the stack.
5CA4
BIT 0,A CB 47
Test bit 0 of Register A (KFLAG$): the NZ FLAG for BREAK.
5CA6
RET C9
RETurn to the caller with Register A = KFLAG$ and the NZ FLAG for BREAK.

5CA7H - Clear the Key Flags

Clears bits 2-0 of KFLAG$ (429FH): ENTER, the pause and BREAK. Register Pair AF is kept. CALLed from 5C82H, 6486H and 652FH, and reached by the JP at 5C93H.

5CA7
PUSH AF F5
Save Register Pair AF to the stack: Register A and the flags are kept.
5CA8
LD A,(429FH) 3A 9F 42
Load Register A with KFLAG$, the keyboard flags at 429FH.
5CAB
AND F8H E6 F8
Mask Register A with F8H (AND F8H): bits 2-0 cleared.
5CAD
LD (429FH),A 32 9F 42
Store Register A at 429FH, KFLAG$, with bits 2-0 now clear.
5CB0
POP AF F1
Restore Register Pair AF from the stack: Register A and the flags as on entry.
5CB1
RET C9
RETurn to the caller with KFLAG$ bits 2-0 cleared.

5CB2H - 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 660CH points to) is given to the ROM: at 2130H for a comma (to the next zone of 16), at 2156H for TAB.

5CB2
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5CB5
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5CB6
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5CB7
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM.
5CB8
INC HL 23
INCrement Register Pair HL to the file's column.
5CB9
LD A,(HL) 7E
Load Register A with the file's column at Register Pair HL.
5CBA
POP HL E1
Load Register Pair HL with the ROM's return address (POP HL): 210BH or 2144H.
5CBB
PUSH DE D5
Save Register Pair DE to the stack across the comparison.
5CBC
PUSH AF F5
Save Register Pair AF (Register A = the column) to the stack.
5CBD
LD DE,2130H 11 30 21
Load Register Pair DE with 2130H, between the two callers.
5CC0
RST 18H DF
RST 18H: compare Register Pair HL (the return address) against Register Pair DE; CARRY for 210BH, the comma.
5CC1
POP DE D1
Copy the column into Register D (POP DE into Register Pair DE: Register D = the column).
5CC2
LD A,D 7A
Copy Register D (the column) into Register A.
5CC3
POP DE D1
Restore Register Pair DE from the stack after the comparison.
5CC4
If the CARRY FLAG is set (a comma), JUMP to 2130H, the ROM: spaces to the next zone of 16.
5CC7
JUMP to 2156H, the ROM's TAB with Register A = the column.

5CCAH - 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 (660EH) points to 6606H, a 00H byte, while the ROM clears.

5CCA
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5CCD
LD (40F3H),HL 22 F3 40
Store Register Pair HL (the current file) at 40F3H-40F4H to keep it.
5CD0
LD HL,6606H 21 06 66
Load Register Pair HL with 6606H, a byte of 00H in the file.
5CD3
LD (660EH),HL 22 0E 66
Store Register Pair HL (6606H) at 660EH-660FH, file 0's slot in the pointer table.
5CD6
RET C9
RETurn to the ROM at 1AEFH, which CALLs its RUN set up 1B5DH.

5CD7H - 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 (660EH) gets the address of buffer 0 from 662EH.

5CD7
LD HL,(40F3H) 2A F3 40
Load Register Pair HL with the current file pointer kept at 40F3H-40F4H.
5CDA
LD (660CH),HL 22 0C 66
Store Register Pair HL at 660CH-660DH, the current file pointer.
5CDD
LD HL,(662EH) 2A 2E 66
Load Register Pair HL with the address of buffer 0 from 662EH-662FH.
5CE0
LD (660EH),HL 22 0E 66
Store Register Pair HL at 660EH-660FH, file 0's slot in the pointer table.
5CE3
RET C9
RETurn to the ROM at 1AF5H, which JUMPs to 1A33H.

5CE4H - 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.

5CE4
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5CE7
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5CE8
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5CE9
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM at 20C9H.
5CEA
POP HL E1
Discard the ROM's return address 20C9H (POP HL into Register Pair HL).
5CEB
JUMP to 20E9H, the ROM: the number's text is printed, then a space.

5CEEH - #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 (5D03H), file n must be open in the mode in Register C (01H here, input; PRINT# enters at 5CF0H from 576DH with Register C = 02H, output), a comma must follow, and 660CH gets the file's buffer address.

5CEE
LD C,01H 0E 01
Load Register C with 01H, the mode the file must be open in: input.
5CF0
CP 23H FE 23
Compare Register A against 23H, #: a file number follows.
5CF2
RET NZ C0
If the NZ FLAG is set (no #), RETurn to the caller.
5CF3
PUSH BC C5
Save Register Pair BC (Register C = the mode wanted) to the stack.
5CF4
GOSUB to 5D03H for the file number: Register Pair BC = its buffer, Register A = its mode (00H closed).
5CF7
POP DE D1
Restore Register Pair DE (Register E = the mode wanted) from the stack.
5CF8
CP E BB
Compare Register A (the file's mode) against Register E (the mode wanted).
5CF9
If the NZ FLAG is set (another mode or closed), JUMP to 6449H, Bad file mode (E = 6CH).
5CFC
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come after the file number.
5CFE
LD (660CH),BC ED 43 0C 66
Store Register Pair BC (the file's buffer) at 660CH-660DH: the file is current.
5D02
RET C9
RETurn to the caller with the file current and Register Pair HL past the comma.

5D03H - 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 660EH, Register A = its first byte (the mode, 00H when closed) and the Z FLAG for a closed file. 5D10H is entered with the number in Register A.

5D03
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
5D04
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character and Register A = it.
5D05
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
5D07
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
5D0A
GOSUB to 2337H, the ROM: evaluate the expression of the file number.
5D0D
GOSUB to 2B1FH, the ROM: the number as a byte in Register A (0-255).
5D10
LD E,A 5F
Copy Register A (the file number) into Register E.
5D11
LD A,(408EH) 3A 8E 40
Load Register A with the number of files set aside from 408EH.
5D14
CP E BB
Compare Register A against Register E (the file number): CARRY when the number is larger.
5D15
If the CARRY FLAG is set, JUMP to 644CH, Bad file number (E = 68H).
5D18
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the file number.
5D1A
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5D1B
LD HL,660EH 21 0E 66
Point Register Pair HL to 660EH, the pointer table: a word for each file.
5D1E
ADD HL,DE 19
ADD Register Pair DE (the file number) to Register Pair HL.
5D1F
ADD HL,DE 19
ADD Register Pair DE again: Register Pair HL = 660EH + 2 x the file number.
5D20
LD C,(HL) 4E
Load Register C with the low byte of the buffer's address at Register Pair HL.
5D21
INC HL 23
INCrement Register Pair HL to the high byte of the buffer's address.
5D22
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the file's buffer.
5D23
LD A,(BC) 0A
Load Register A with the first byte of the buffer at Register Pair BC, the file's mode.
5D24
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a closed file.
5D25
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5D26
RET C9
RETurn to the caller with Register Pair BC = the buffer, Register A = the mode.

5D27H - MKI$, MKS$ and MKD$

Vectors 8 (416AH), 9 (416DH) and 10 (4170H), with the argument already evaluated by the ROM. Register A = 02H (MKI$, 5D27H), 04H (MKS$, 5D2AH, inside the LD BC at 5D29H) or 08H (MKD$, 5D2DH, inside the LD BC at 5D2CH): the number is made that type (2819H), and a string of that many bytes is made from the accumulator.

5D27
LD A,02H 3E 02
Load Register A with 02H, the length of an integer: MKI$.
5D29
LD BC,043EH 01 3E 04
Load Register Pair BC with 043EH: skipped bytes, 5D2AH is LD A,04H, the entry for MKS$.
5D2C
LD BC,083EH 01 3E 08
Load Register Pair BC with 083EH: skipped bytes, 5D2DH is LD A,08H, the entry for MKD$.
5D2F
PUSH AF F5
Save Register Pair AF (Register A = the type and length) to the stack.
5D30
GOSUB to 2819H, the ROM: the accumulator is made the type in Register A.
5D33
POP AF F1
Restore Register Pair AF (Register A = the length) from the stack.
5D34
GOSUB to 2857H, the ROM: space for a string of Register A bytes; its descriptor at 40D3H.
5D37
LD HL,(40D4H) 2A D4 40
Load Register Pair HL with the string's address from 40D4H-40D5H.
5D3A
GOSUB to 09FFH, the ROM: the accumulator's bytes are copied to Register Pair HL.
5D3D
JUMP to 2A2BH, the ROM: a word off the stack, then the string is the result (2884H).

5D40H - CVI, CVS and CVD

Vectors 0 (4152H), 2 (4158H) and 4 (415EH). Register A = 01H (CVI, 5D40H), 03H (CVS, 5D43H, inside the LD BC at 5D42H) or 07H (CVD, 5D46H, inside the LD BC at 5D45H), 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).

5D40
LD A,01H 3E 01
Load Register A with 01H, one less than the length of an integer: CVI.
5D42
LD BC,033EH 01 3E 03
Load Register Pair BC with 033EH: skipped bytes, 5D43H is LD A,03H, the entry for CVS.
5D45
LD BC,073EH 01 3E 07
Load Register Pair BC with 073EH: skipped bytes, 5D46H is LD A,07H, the entry for CVD.
5D48
PUSH AF F5
Save Register Pair AF (Register A = the length less 1) to the stack.
5D49
GOSUB to 29D7H, the ROM: the argument must be a string, its temporary freed; Register Pair HL = its descriptor.
5D4C
POP AF F1
Restore Register Pair AF (Register A = the length less 1) from the stack.
5D4D
CP (HL) BE
Compare Register A against the string's length at Register Pair HL: NO CARRY when the string is too short.
5D4E
If the NO CARRY FLAG is set, JUMP to 1E4AH, the ROM's Illegal function call.
5D51
INC A 3C
INCrement Register A: the type and length, 2, 4 or 8.
5D52
INC HL 23
INCrement Register Pair HL to the low byte of the string's address.
5D53
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
5D54
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
5D55
LD H,(HL) 66
Load Register H with the high byte of the string's address at Register Pair HL.
5D56
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the string's bytes.
5D57
LD (40AFH),A 32 AF 40
Store Register A (the type) at 40AFH, the type of the accumulator.
5D5A
JUMP to 09F7H, the ROM: the bytes at Register Pair HL are copied into the accumulator.

5D5DH - 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 (5D85H) 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.

5D5D
LD DE,(660CH) ED 5B 0C 66
Load Register Pair DE with the current file's buffer pointer from 660CH-660DH.
5D61
LD A,D 7A
Copy Register D (the high byte of the pointer) into Register A.
5D62
OR E B3
OR Register E into Register A: the Z FLAG when the pointer is 0000H, no current file.
5D63
RET Z C8
If the Z FLAG is set (no current file), RETurn to the ROM at 2230H.
5D64
POP AF F1
Discard the ROM's return address 2230H (POP AF into Register Pair AF).
5D65
RST 20H E7
RST 20H: the type of the variable; the Z FLAG for a string.
5D66
LD BC,2243H 01 43 22
Load Register Pair BC with 2243H, the ROM's assignment after INPUT takes a value.
5D69
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.
5D6C
If the NZ FLAG is set (a number), JUMP to 5D85H to read it.
5D6E
LD E,D 5A
Copy Register D (2CH) into Register E: a string ends only at a comma.
5D6F
JUMP to 5D85H to read the string field from the file.

5D71H - LINE INPUT#

Reached from 593CH. 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. 5D85H 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.

5D71
GOSUB to 5CEEH to read #n and make file n current, open for input.
5D74
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable at Register Pair HL.
5D77
GOSUB to 0AF4H, the ROM: Type mismatch unless the variable is a string.
5D7A
LD BC,2169H 01 69 21
Load Register Pair BC with 2169H, the ROM's end of an INPUT statement.
5D7D
PUSH BC C5
Save Register Pair BC (2169H) to the stack, the last return address.
5D7E
PUSH DE D5
Save Register Pair DE (the variable's address) to the stack for 1F31H.
5D7F
LD BC,1F31H 01 31 1F
Load Register Pair BC with 1F31H, the ROM's assignment of the string to the variable.
5D82
XOR A AF
Load Register A with 00H (XOR A): 1F31H adds 03H to it, the type of a string.
5D83
LD D,A 57
Copy Register A (00H) into Register D: no character ends the line but 0DH.
5D84
LD E,A 5F
Copy Register A (00H) into Register E: the line is a string, kept whole.
5D85
PUSH AF F5
Save Register Pair AF (the type's flags) to the stack for 2243H or 1F31H.
5D86
PUSH BC C5
Save Register Pair BC (2243H or 1F31H) to the stack: the RETurn goes there.
5D87
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5D88
GOSUB to 628FH to read a byte of the file: CARRY at the end of the file.
5D8B
If the CARRY FLAG is set, JUMP to 644FH, Input past end (E = 7CH).
5D8E
CP 20H FE 20
Compare Register A (the byte) against 20H, a space.
5D90
If the NZ FLAG is set (not a space), JUMP to 5D96H.
5D92
INC D 14
INCrement Register D, with the DEC next to set the flags.
5D93
DEC D 15
DECrement Register D back: the NZ FLAG for INPUT#, the Z FLAG for LINE INPUT#.
5D94
If the NZ FLAG is set (INPUT#), LOOP BACK to 5D88H: leading spaces are skipped.
5D96
CP 22H FE 22
Compare Register A (the byte) against 22H, a quote.
5D98
If the NZ FLAG is set (no quote), JUMP to 5DA8H.
5D9A
LD B,A 47
Copy Register A (22H, the quote) into Register B to keep it.
5D9B
LD A,E 7B
Copy Register E (the end of a field) into Register A.
5D9C
CP 2CH FE 2C
Compare Register A against 2CH: the Z FLAG for a string of INPUT#.
5D9E
LD A,B 78
Copy Register B (22H) into Register A; LD does not change the flags.
5D9F
If the NZ FLAG is set (a number or a line), JUMP to 5DA8H: the quote is kept.
5DA1
LD D,B 50
Copy Register B (22H) into Register D: the string ends at the closing quote.
5DA2
LD E,B 58
Copy Register B (22H) into Register E: a comma inside the quotes is kept.
5DA3
GOSUB to 628FH for the byte after the quote: CARRY at the end of the file.
5DA6
If the CARRY FLAG is set (the end of the file), JUMP to 5DEBH.
5DA8
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5DAB
LD B,FFH 06 FF
Load Register B with FFH, the most bytes kept: 255.
5DAD
LD C,A 4F
Copy Register A (the byte) into Register C: the top of the read loop.
5DAE
LD A,D 7A
Copy Register D (the first end character) into Register A.
5DAF
CP 22H FE 22
Compare Register A against 22H: the Z FLAG inside quotes.
5DB1
LD A,C 79
Copy Register C (the byte) into Register A; LD does not change the flags.
5DB2
If the Z FLAG is set (inside quotes), JUMP to 5DDAH: 0DH and 0AH are kept.
5DB4
CP 0DH FE 0D
Compare Register A (the byte) against 0DH, the end of a line.
5DB6
PUSH HL E5
Save Register Pair HL (the place in the buffer) to the stack for 5E05H.
5DB7
If the Z FLAG is set (0DH), JUMP to 5E05H: the field ends.
5DB9
POP HL E1
Restore Register Pair HL (the place in the buffer) from the stack.
5DBA
CP 0AH FE 0A
Compare Register A (the byte) against 0AH, a line feed.
5DBC
If the NZ FLAG is set (not a line feed), JUMP to 5DDAH.
5DBE
LD C,A 4F
Copy Register A (0AH, the line feed) into Register C to keep it.
5DBF
LD A,E 7B
Copy Register E (the end of a field) into Register A.
5DC0
CP 2CH FE 2C
Compare Register A against 2CH: the Z FLAG for a string of INPUT#.
5DC2
LD A,C 79
Copy Register C (0AH) into Register A; LD does not change the flags.
5DC3
If the NZ FLAG is set (a number or a line), GOSUB to 5E2AH to keep the line feed.
5DC6
GOSUB to 628FH for the byte after the line feed: CARRY at the end of the file.
5DC9
If the CARRY FLAG is set (the end of the file), JUMP to 5DEBH.
5DCB
CP 0DH FE 0D
Compare Register A (the byte) against 0DH, a 0DH right after the line feed.
5DCD
If the NZ FLAG is set (not 0DH), JUMP to 5DDAH.
5DCF
LD A,E 7B
Copy Register E (the end of a field) into Register A: a 0DH after a line feed.
5DD0
CP 20H FE 20
Compare Register A against 20H: the Z FLAG for a number.
5DD2
If the Z FLAG is set (a number), JUMP to 5DE6H: the 0DH is dropped.
5DD4
CP 2CH FE 2C
Compare Register A against 2CH: the Z FLAG for a string of INPUT#.
5DD6
LD A,0DH 3E 0D
Load Register A with 0DH; LD does not change the flags.
5DD8
If the Z FLAG is set (a string of INPUT#), JUMP to 5DE6H: the 0DH is dropped; for a line it is kept.
5DDA
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a 00H byte.
5DDB
If the Z FLAG is set (00H), JUMP to 5DE6H: the byte is dropped.
5DDD
CP D BA
Compare Register A against Register D, the first end character.
5DDE
If the Z FLAG is set (an end), JUMP to 5DEBH.
5DE0
CP E BB
Compare Register A against Register E, the second end character.
5DE1
If the Z FLAG is set (an end), JUMP to 5DEBH.
5DE3
GOSUB to 5E2AH to keep the byte in the line buffer.
5DE6
GOSUB to 628FH for the next byte: CARRY at the end of the file.
5DE9
If the NO CARRY FLAG is set (a byte), JUMP to 5DADH, the top of the read loop.
5DEB
PUSH HL E5
Save Register Pair HL (the end of the field in the buffer) to the stack.
5DEC
CP 22H FE 22
Compare Register A (the byte that ended the field) against 22H, a quote.
5DEE
If the Z FLAG is set (a closing quote), JUMP to 5DF4H to skip what follows it.
5DF0
CP 20H FE 20
Compare Register A against 20H: a space that ended a number.
5DF2
If the NZ FLAG is set (a comma or the end of the file), JUMP to 5E11H.
5DF4
GOSUB to 628FH for the next byte: CARRY at the end of the file.
5DF7
If the CARRY FLAG is set (the end of the file), JUMP to 5E11H.
5DF9
CP 20H FE 20
Compare Register A (the byte) against 20H, a space.
5DFB
If the Z FLAG is set (a space), LOOP BACK to 5DF4H: spaces are skipped.
5DFD
CP 2CH FE 2C
Compare Register A against 2CH, a comma: it ends the field.
5DFF
If the Z FLAG is set (a comma), JUMP to 5E11H.
5E01
CP 0DH FE 0D
Compare Register A against 0DH, the end of a line.
5E03
If the NZ FLAG is set (another byte), JUMP to 5E0EH to give it back to the file.
5E05
GOSUB to 628FH for the byte after the 0DH: CARRY at the end of the file.
5E08
If the CARRY FLAG is set (the end of the file), JUMP to 5E11H.
5E0A
CP 0AH FE 0A
Compare Register A (the byte) against 0AH, a line feed after the 0DH.
5E0C
If the Z FLAG is set (a line feed), JUMP to 5E11H: it is part of the end.
5E0E
GOSUB to 5E39H to back the file up one byte: the byte is read again next time.
5E11
POP HL E1
Restore Register Pair HL (the end of the field in the buffer) from the stack.
5E12
LD (HL),00H 36 00
Store 00H at Register Pair HL: the end of the text.
5E14
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
5E17
DEC HL 2B
DECrement Register Pair HL to the byte before the text.
5E18
LD A,E 7B
Copy Register E (the end of a field) into Register A.
5E19
SUB 20H D6 20
SUBtract 20H from Register A: the Z FLAG for a number.
5E1B
If the Z FLAG is set (a number), JUMP to 5E24H.
5E1D
LD B,00H 06 00
Load Register B with 00H, the byte that ends the text.
5E1F
GOSUB to 2868H, the ROM: a temporary string of the text after Register Pair HL up to the 00H in Register B.
5E22
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5E23
RET C9
RETurn to 2243H or 1F31H, the ROM's assignment.
5E24
RST 10H D7
RST 10H (658DH): Register Pair HL to the first character of the text and Register A = it.
5E25
GOSUB to 0E6CH, the ROM: the text at Register Pair HL made a number in the accumulator.
5E28
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5E29
RET C9
RETurn to 2243H, the ROM's assignment of the number.

5E2AH - 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 5E12H.

5E2A
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a 00H byte.
5E2B
RET Z C8
If the Z FLAG is set (00H), RETurn to the caller: the byte is not kept.
5E2C
LD (HL),A 77
Store Register A (the byte) at Register Pair HL, the line buffer.
5E2D
INC HL 23
INCrement Register Pair HL to the next byte of the line buffer.
5E2E
DEC B 05
DECrement Register B, the room left in the line buffer.
5E2F
RET NZ C0
If the NZ FLAG is set (room left), RETurn to the caller.
5E30
POP BC C1
Discard the caller's return address (POP BC into Register Pair BC): the buffer is full.
5E31
JUMP to 5E12H to end the field with the bytes kept.

5E33H - Open a Program File

For MERGE (5E57H) and LOAD and RUN (5E97H): Register D = 01H, input, and Register A = 00H, file 0, then OPEN's common part at 6347H, which RETurns to the caller.

5E33
LD D,01H 16 01
Load Register D with 01H, the mode the file is opened in: input.
5E35
XOR A AF
Load Register A with 00H (XOR A): the file number, file 0.
5E36
JUMP to 6347H, OPEN's common part, which RETurns to the caller with file 0 open.

5E39H - 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 6463H.

5E39
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5E3C
LD BC,000BH 01 0B 00
Load Register Pair BC with 000BH, the offset of the FCB's record length in the buffer.
5E3F
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the record length byte.
5E40
LD B,(HL) 46
Load Register B with the record length at Register Pair HL, to put back.
5E41
LD (HL),01H 36 01
Store 01H at Register Pair HL: a record of one byte.
5E43
PUSH HL E5
Save Register Pair HL (the record length byte) to the stack.
5E44
PUSH BC C5
Save Register Pair BC (Register B = the record length) to the stack.
5E45
LD BC,FFF7H 01 F7 FF
Load Register Pair BC with FFF7H, minus 9: from the record length back to the FCB.
5E48
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the FCB, at buffer + 02H.
5E49
PUSH DE D5
Save Register Pair DE to the stack across @BKSP.
5E4A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the FCB.
5E4B
GOSUB to 4445H, @BKSP: the file goes back one record, here one byte; the Z FLAG when no error.
5E4E
POP DE D1
Restore Register Pair DE from the stack after @BKSP.
5E4F
POP BC C1
Restore Register Pair BC (Register B = the record length) from the stack.
5E50
POP HL E1
Restore Register Pair HL (the record length byte) from the stack.
5E51
LD (HL),B 70
Store Register B at Register Pair HL: the record length is put back.
5E52
RET Z C8
If the Z FLAG is set (no error), RETurn to the caller.
5E53
JUMP to 6463H with Register A = the DOS error code.

5E56H - MERGE

Vector 19 (418BH). The program file is opened as file 0 (5E33H); anything after the filespec is a Syntax error (5FD8H closes the file first). A file whose first byte is FFH is not ASCII: Bad file mode. Else the byte is given back (5E39H) and the ROM's command loop (1A33H) takes the file's lines as if typed (5BDFH, 5C1CH); with 6608H = 00H, READY ends it.

5E56
POP BC C1
Discard the ROM's return address (POP BC into Register Pair BC).
5E57
GOSUB to 5E33H to open the program file as file 0 for input.
5E5A
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
5E5B
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character, Register A = it; the Z FLAG at the end of the statement.
5E5C
If the Z FLAG is set (nothing follows), JUMP to 5E64H.
5E5E
GOSUB to 5FD8H, the READY exit, to close file 0.
5E61
JUMP to 1997H, the ROM's Syntax error: something follows the filespec.
5E64
XOR A AF
Load Register A with 00H (XOR A), the run state of a MERGE: READY at the end.
5E65
LD (6608H),A 32 08 66
Store Register A (00H) at 6608H, the run state.
5E68
GOSUB to 628FH to read the first byte of the file: CARRY at the end of the file.
5E6B
If the CARRY FLAG is set (an empty file), JUMP to 1A33H, the ROM's command loop.
5E6E
INC A 3C
INCrement Register A (the first byte): the Z FLAG for FFH, a program SAVEd without A.
5E6F
If the Z FLAG is set, JUMP to 6449H, Bad file mode (E = 6CH).
5E72
GOSUB to 5E39H to back the file up one byte: the first byte is read again.
5E75
JUMP to 1A33H, the ROM's command loop, which now reads its lines from the file.

5E78H - A Starting Line

For the R and V options of RUN and LOAD: after the letter an optional comma and line number; 5E7CH is entered at a digit. The line number goes in the operand at 5FC6H, where the program will start.

5E78
RST 10H D7
RST 10H (658DH): Register Pair HL past the letter, Register A = it; the Z FLAG at the end of the statement.
5E79
RET Z C8
If the Z FLAG is set (no line number), RETurn to the caller.
5E7A
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the line number.
5E7C
GOSUB to 1E5AH, the ROM: the line number at Register Pair HL in Register Pair DE.
5E7F
LD (5FC6H),DE ED 53 C6 5F
Store Register Pair DE (the line number) at 5FC6H-5FC7H, the operand of the LD DE at 5FC5H.
5E83
RET C9
RETurn to the caller with the starting line set.

5E84H - RUN and LOAD a Program

5E84H is vector 39 (41C7H), CALLed by the ROM's RUN at 1EA6H (with the CARRY FLAG for a line number, which the ROM keeps); 5E8CH, inside the OR at 5E8BH, is vector 18 (4188H), LOAD. 6644H is set for RUN (the protection state is noted at 63D8H) and 6608H 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, 6608H = 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.

5E84
RET C D8
If the CARRY FLAG is set (RUN with a line number), RETurn to the ROM's RUN.
5E85
POP AF F1
Discard the ROM's return address (POP AF into Register Pair AF).
5E86
LD A,FFH 3E FF
Load Register A with FFH, the run state of RUN.
5E88
LD (6644H),A 32 44 66
Store Register A (FFH) at 6644H: the file is opened for RUN (63D8H).
5E8B
OR AFH F6 AF
OR AFH into Register A, leaving FFH; the byte at 5E8CH is XOR A, the entry for LOAD (Register A = 00H).
5E8D
LD (6608H),A 32 08 66
Store Register A at 6608H, the run state: FFH RUN, 00H LOAD.
5E90
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: no starting line.
5E93
LD (5FC6H),DE ED 53 C6 5F
Store Register Pair DE (0000H) at 5FC6H-5FC7H, the starting line.
5E97
GOSUB to 5E33H to open the program file as file 0 for input.
5E9A
LD A,(408EH) 3A 8E 40
Load Register A with the number of files set aside from 408EH.
5E9D
LD (6609H),A 32 09 66
Store Register A at 6609H, kept across the ROM's NEW.
5EA0
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
5EA1
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character, Register A = it; the Z FLAG at the end of the statement.
5EA2
If the Z FLAG is set (no option), JUMP to 5ECBH.
5EA4
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the option; CARRY for a digit.
5EA6
LD (6608H),A 32 08 66
Store Register A (the option) at 6608H: any option makes a run.
5EA9
If the NO CARRY FLAG is set (not a digit), JUMP to 5EB0H for a letter.
5EAB
GOSUB to 5E7CH for the starting line number given as the option.
5EAE
JUMP to 5EC7H: the files stay open across the ROM's NEW.
5EB0
CP 52H FE 52
Compare Register A (the option) against 52H, R.
5EB2
If the NZ FLAG is set (not R), JUMP to 5EB9H.
5EB4
GOSUB to 5E78H for an optional starting line.
5EB7
JUMP to 5EC7H: the files stay open across the ROM's NEW.
5EB9
CP 56H FE 56
Compare Register A (the option) against 56H, V.
5EBB
If the NZ FLAG is set (no valid option), JUMP to 1997H, the ROM's Syntax error.
5EBE
GOSUB to 5E78H for an optional starting line.
5EC1
LD A,04H 3E 04
Load Register A with 04H, BASIC/OV3's function to keep the variables.
5EC3
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number in Register A' for 54DEH.
5EC4
GOSUB to 54DEH to load and enter BASIC/OV3: the variables are parked and 6608H set to D6H.
5EC7
XOR A AF
Load Register A with 00H (XOR A): no files for the ROM's NEW to close.
5EC8
LD (408EH),A 32 8E 40
Store Register A (00H) at 408EH, the number of files set aside.
5ECB
LD HL,6606H 21 06 66
Point Register Pair HL to 6606H, a byte of 00H in the file.
5ECE
LD (660EH),HL 22 0E 66
Store Register Pair HL (6606H) at 660EH-660FH, file 0's slot: it reads as closed.
5ED1
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H, to keep it.
5ED4
LD (40A0H),SP ED 73 A0 40
Store the Stack Pointer at 40A0H-40A1H: the ROM's NEW sets the stack from there.
5ED8
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the old 40A0H is kept there.
5ED9
GOSUB to 1B4DH, the ROM's NEW: the old program is gone.
5EDC
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): Register Pair HL = the old 40A0H.
5EDD
LD SP,(40A0H) ED 7B A0 40
Load the Stack Pointer from 40A0H-40A1H, as it was before the NEW.
5EE1
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H: string space starts where it did.
5EE4
LD A,(6609H) 3A 09 66
Load Register A with the number of files kept at 6609H.
5EE7
LD (408EH),A 32 8E 40
Store Register A at 408EH, the number of files set aside.
5EEA
LD HL,(662EH) 2A 2E 66
Load Register Pair HL with the address of buffer 0 from 662EH-662FH.
5EED
LD (660EH),HL 22 0E 66
Store Register Pair HL at 660EH-660FH, file 0's slot: the program file again.
5EF0
LD (660CH),HL 22 0C 66
Store Register Pair HL at 660CH-660DH: file 0 is the current file.
5EF3
GOSUB to 628FH to read the first byte of the file: CARRY at the end of the file.
5EF6
If the CARRY FLAG is set (an empty file), JUMP to 1A33H, the ROM's command loop.
5EF9
INC A 3C
INCrement Register A (the first byte): the Z FLAG for FFH, a program SAVEd without A.
5EFA
If the NZ FLAG is set (ASCII), JUMP to 5E72H: the byte is given back and the lines read as typed.
5EFD
LD IX,(660CH) DD 2A 0C 66
Load Index Register IX with the buffer of file 0 from 660CH-660DH; its FCB starts at IX+02H.
5F01
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H.
5F04
LD DE,FFAAH 11 AA FF
Load Register Pair DE with FFAAH, minus 56H: room kept for the stack.
5F07
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the highest address the program may reach.
5F08
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
5F0C
XOR A AF
Load Register A with 00H (XOR A), the CARRY FLAG cleared.
5F0D
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: the room for the program; CARRY for none.
5F0F
If the CARRY FLAG is set (no room), JUMP to 5F6AH, Out of memory.
5F11
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.
5F14
If the NZ FLAG is set (too long), JUMP to 5F6AH, Out of memory.
5F16
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.
5F19
LD C,A 4F
Copy Register A (00H) into Register C: Register Pair BC = the sectors x 256, the bytes.
5F1A
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.
5F1C
If the CARRY FLAG is set, JUMP to 5F6AH, Out of memory.
5F1E
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.
5F21
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.
5F24
INC HL 23
INCrement Register Pair HL past the first byte, FFH.
5F25
LD B,C 41
Copy Register C (00H) into Register B for the count of the copy.
5F26
DEC C 0D
DECrement Register C: Register Pair BC = 00FFH, the rest of the first sector.
5F27
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.
5F29
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.
5F2C
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.
5F2F
LD L,E 6B
Copy Register E (the low byte of the buffer address) into Register L, which no read changes.
5F30
PUSH IX DD E5
Save Index Register IX (the buffer) to the stack.
5F32
POP DE D1
Restore Register Pair DE from the stack: Register Pair DE = the buffer.
5F33
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
5F34
INC DE 13
INCrement Register Pair DE again: Register Pair DE = the FCB, at buffer + 02H.
5F35
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.
5F38
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.
5F3C
GOSUB to 4436H, @READ: the next sector into the buffer, at Register Pair DE's FCB; NZ for an error.
5F3F
If the NZ FLAG is set (an error or the end of the file), JUMP to 5F46H.
5F41
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.
5F44
JUMP to 5F3CH to read the next sector of the program.
5F46
CP 1CH FE 1C
Compare Register A (the DOS error) against 1CH, the end of the file.
5F48
If the Z FLAG is set (1CH), JUMP to 5F4FH: the whole file is read.
5F4A
CP 1DH FE 1D
Compare Register A (the DOS error) against 1DH, a record number past the end of the file.
5F4C
If the NZ FLAG is set (another error), JUMP to 6463H with the DOS error in Register A.
5F4F
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.
5F52
XOR A AF
Load Register A with 00H (XOR A) for the high byte of the count.
5F53
LD D,A 57
Copy Register A (00H) into Register D, the high byte of the count.
5F54
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.
5F57
DEC E 1D
DECrement Register E, with the INC DE next: 00H becomes 0100H.
5F58
INC DE 13
INCrement Register Pair DE: the bytes in the last sector, 1-256.
5F59
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.
5F5A
GOSUB to 1AF8H, the ROM: the links of the lines are made again; Register Pair HL ends at the program's last byte.
5F5D
INC HL 23
INCrement Register Pair HL to the byte after the program.
5F5E
LD (40F9H),HL 22 F9 40
Store Register Pair HL at 40F9H-40FAH, the start of the variables: the end of the program.
5F61
LD A,(6608H) 3A 08 66
Load Register A with the run state at 6608H (D6H for a RUN with V).
5F64
CP D6H FE D6
Compare Register A against D6H: the Z FLAG for a RUN with V.
5F66
If the NZ FLAG is set (no V), JUMP to 5FACH for the end of the load.
5F68
JUMP to 5F70H to bring the variables back; also the entry from 5C3EH.
5F6A
GOSUB to 1B4DH, the ROM's NEW: the part of the program read is cleared.
5F6D
JUMP to 197AH, the ROM's Out of memory: the program does not fit.

5F70H - 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 5F72H (the old 40F9H), 5F79H (the old 40FBH), 5F85H (the length), 5F92H (40D6H) and 5F98H (40A0H). The variables are moved down after the new program, the pointers set, 6608H cleared, the stack put back, the READY exit made and the program started (5FC5H). 5A6EH CALLs 5F97H to finish an error the same way.

5F70
PUSH HL E5
Save Register Pair HL (the end of the new program) to the stack.
5F71
LD DE,0000H 11 00 00
Load Register Pair DE with the old end of the program, the operand at 5F72H (stored by BASIC/OV3; 0000H in the file).
5F74
AND A A7
Clear the CARRY FLAG (AND A); Register A is not changed.
5F75
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: how far the variables move.
5F77
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the distance.
5F78
LD HL,0000H 21 00 00
Load Register Pair HL with the old start of the arrays, the operand at 5F79H (0000H in the file).
5F7B
ADD HL,DE 19
ADD Register Pair DE (the distance) to Register Pair HL: the new start of the arrays.
5F7C
LD (40FBH),HL 22 FB 40
Store Register Pair HL at 40FBH-40FCH, the start of the arrays.
5F7F
POP DE D1
Restore Register Pair DE (the end of the new program) from the stack: where the variables go.
5F80
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H.
5F83
INC HL 23
INCrement Register Pair HL: the parked variables, just above it.
5F84
LD BC,0000H 01 00 00
Load Register Pair BC with the length of the variables, the operand at 5F85H (0000H in the file).
5F87
LD A,B 78
Copy Register B (the high byte of the length) into Register A.
5F88
OR C B1
OR Register C into Register A: the Z FLAG when there are no variables.
5F89
If the Z FLAG is set (nothing to move), JUMP to 5F8DH.
5F8B
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): the variables after the program.
5F8D
LD (40FDH),DE ED 53 FD 40
Store Register Pair DE (the byte after the arrays) at 40FDH-40FEH, the end of the arrays.
5F91
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5F92H, the old 40D6H (0000H in the file).
5F94
LD (40D6H),HL 22 D6 40
Store Register Pair HL at 40D6H-40D7H, the next free byte of string space.
5F97
LD HL,0000H 21 00 00
Load Register Pair HL with the operand at 5F98H, the old 40A0H (0000H in the file); the entry from 5A6EH.
5F9A
LD (40A0H),HL 22 A0 40
Store Register Pair HL at 40A0H-40A1H, the start of string space.
5F9D
DEC HL 2B
DECrement Register Pair HL, one byte below string space.
5F9E
DEC HL 2B
DECrement Register Pair HL again: 2 bytes below string space.
5F9F
LD (40E8H),HL 22 E8 40
Store Register Pair HL at 40E8H-40E9H, the ROM's saved Stack Pointer.
5FA2
XOR A AF
Load Register A with 00H (XOR A) to clear the run state.
5FA3
LD (6608H),A 32 08 66
Store Register A (00H) at 6608H: the run state cleared.
5FA6
LD SP,HL F9
Load the Stack Pointer from Register Pair HL: a new stack; no caller is RETurned to.
5FA7
GOSUB to 5FD8H, the READY exit: output back to the display and file 0 closed.
5FAA
JUMP to 5FC5H to start the program at its starting line.

5FACH - 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 (6608H = 00H) goes to READY (1A19H); else the program starts at the line in 5FC6H, or at its first line when that is 0000H.

5FAC
LD HL,408EH 21 8E 40
Point Register Pair HL to 408EH, the number of files set aside.
5FAF
LD A,(HL) 7E
Load Register A with the number of files at Register Pair HL.
5FB0
LD (6609H),A 32 09 66
Store Register A at 6609H to keep the number of files.
5FB3
LD (HL),00H 36 00
Store 00H at Register Pair HL (408EH): no files across the RUN set up.
5FB5
GOSUB to 1B5DH, the ROM's RUN set up: variables cleared, the pointers set.
5FB8
LD A,(6609H) 3A 09 66
Load Register A with the number of files kept at 6609H.
5FBB
LD (408EH),A 32 8E 40
Store Register A at 408EH, the number of files set aside.
5FBE
LD A,(6608H) 3A 08 66
Load Register A with the run state at 6608H (00H for a plain LOAD).
5FC1
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a plain LOAD.
5FC2
If the Z FLAG is set (LOAD), JUMP to 1A19H, the ROM's READY.
5FC5
LD DE,0000H 11 00 00
Load Register Pair DE with the starting line, the operand at 5FC6H (0000H in the file; 5E7FH stores it).
5FC8
LD A,D 7A
Copy Register D (the high byte of the line number) into Register A.
5FC9
OR E B3
OR Register E into Register A: the Z FLAG when no line was given.
5FCA
If the Z FLAG is set (no line), JUMP to 5FD5H: the program starts at its first line.
5FCC
GOSUB to 1B2CH, the ROM: find the line in Register Pair DE; Register Pair BC = the line.
5FCF
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.
5FD2
DEC BC 0B
DECrement Register Pair BC to the byte before the line.
5FD3
LD H,B 60
Copy Register B (the high byte of the line's address) into Register H.
5FD4
LD L,C 69
Copy Register C into Register L: Register Pair HL = the byte before the line.
5FD5
JUMP to 1D1EH, the ROM's next statement: the program runs.

5FD8H - READY Exit

Vector 30 (41ACH), CALLed by the ROM at 1A1CH on its way to READY, and from 5C44H, 5E5EH, 5FA7H and the JP at 6054H. The output goes back to the display (2169H, which leaves Register A = 00H) and file 0 is closed (61A8H). Only for the ROM's READY (return address 1A1FH) is the protection test made (6401H). It RETurns with Register Pair HL = 40DFH's word (1BAFH).

5FD8
GOSUB to 2169H, the ROM: output to the display (409CH = 00H); Register A = 00H.
5FDB
GOSUB to 61A8H to close file n, Register A = 00H: file 0.
5FDE
POP HL E1
Load Register Pair HL with the return address (POP HL).
5FDF
PUSH DE D5
Save Register Pair DE to the stack across the comparison.
5FE0
LD DE,1A1FH 11 1F 1A
Load Register Pair DE with 1A1FH, the return address in the ROM's READY.
5FE3
RST 18H DF
RST 18H: compare Register Pair HL (the return address) against Register Pair DE; the Z FLAG for the ROM's READY.
5FE4
POP DE D1
Restore Register Pair DE from the stack; POP does not change the flags.
5FE5
PUSH HL E5
Save Register Pair HL (the return address) to the stack again.
5FE6
If the Z FLAG is set (the ROM's READY), GOSUB to 6401H for the protection test.
5FE9
JUMP to 1BAFH, the ROM: Register Pair HL = the word at 40DFH, and RETurn.

5FECH - 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 (6401H) is made and the statement executed (1D5AH).

5FEC
RET C D8
If the CARRY FLAG is set (a numbered line), RETurn to the ROM to store it.
5FED
POP AF F1
Discard the ROM's return address 1AA4H (POP AF into Register Pair AF).
5FEE
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
5FEF
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
5FF2
LD A,H 7C
Copy Register H (the high byte of the pointer) into Register A.
5FF3
OR L B5
OR Register L into Register A: the Z FLAG when the pointer is 0000H, no current file.
5FF4
LD E,84H 1E 84
Load Register E with 84H, Direct statement in file; LD does not change the flags.
5FF6
If the NZ FLAG is set (a line from a file), JUMP to 19A2H, the ROM's error handler.
5FF9
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5FFA
GOSUB to 6401H for the protection test before the statement runs.
5FFD
JUMP to 1D5AH, the ROM: the statement is executed.

6000H - SAVE

Vector 26 (41A0H). The file is opened as file 0 for output (5E35H with Register D = 02H). SAVE "file",A goes to the ROM's LIST (2B2EH), whose text goes to the file through 5C0EH. 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 5FD8H closes the file.

6000
LD D,02H 16 02
Load Register D with 02H, the mode the file is opened in: output.
6002
GOSUB to 5E35H to open the file as file 0, here for output.
6005
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
6006
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character, Register A = it; the Z FLAG at the end.
6007
If the Z FLAG is set (nothing follows), JUMP to 6010H to save the program as it is in memory.
6009
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come after the filespec.
600B
RST 08H => 41H CF 41
RST 08H with the byte 41H: the letter A must come next.
600D
JUMP to 2B2EH, the ROM's LIST: the program goes to the file as text.
6010
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the end of the program from 40F9H-40FAH.
6013
LD DE,(40A4H) ED 5B A4 40
Load Register Pair DE with the start of the program from 40A4H-40A5H.
6017
XOR A AF
Load Register A with 00H (XOR A), the CARRY FLAG cleared.
6018
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: the length of the program.
601A
DEC A 3D
DECrement Register A: FFH, the first byte of the file.
601B
DEC DE 1B
DECrement Register Pair DE to the byte before the program.
601C
LD (DE),A 12
Store Register A (FFH) at Register Pair DE, the byte before the program.
601D
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.
601E
PUSH DE D5
Save Register Pair DE (the length) to the stack.
601F
LD C,D 4A
Copy Register D (the high byte of the length) into Register C.
6020
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the number of the last record.
6022
LD IX,(660CH) DD 2A 0C 66
Load Index Register IX with the buffer of file 0 from 660CH-660DH.
6026
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.
6029
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.
602C
PUSH IX DD E5
Save Index Register IX (the buffer) to the stack.
602E
POP DE D1
Restore Register Pair DE from the stack: Register Pair DE = the buffer.
602F
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
6030
INC DE 13
INCrement Register Pair DE again: Register Pair DE = the FCB, at buffer + 02H.
6031
GOSUB to 4442H, @POSN: the file is positioned at record Register Pair BC, the last.
6034
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.
6038
GOSUB to 4439H, @WRITE: the last record is written, giving the file its size; NZ for an error.
603B
If the Z FLAG is set (no error), GOSUB to 443FH, @REW: back to the first record.
603E
If the NZ FLAG is set (an error), JUMP to 6046H.
6040
POP BC C1
Restore Register Pair BC (the length) from the stack.
6041
INC C 0C
INCrement Register C: the bytes in the last record (00H for 256).
6042
INC B 04
INCrement Register B: the number of records to write.
6043
GOSUB to 4439H, @WRITE: 256 bytes of the program are written; NZ for an error.
6046
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.
6048
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
604B
INC (IX+06H) DD 34 06
INCrement +06H of the buffer at Index Register IX: the next record is the next page.
604E
DECrement Register B (the records left) and LOOP BACK to 6043H.
6050
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.
6053
LD (HL),B 70
Store Register B (00H) at Register Pair HL, the byte before the program.
6054
JUMP to 5FD8H, the READY exit, which closes file 0.

6057H - CLOSE

Vector 17 (4185H). With the NZ FLAG (a list follows) each [#]n of the list is closed by 61A8H; with the Z FLAG every file from the number set aside (408EH) down to 0 is closed. 61A8H is reached by a RET (6067H) and by JP (HL) (6087H) with return addresses pushed before it.

6057
LD BC,61A8H 01 A8 61
Load Register Pair BC with 61A8H, the routine that closes one file.
605A
LD A,(408EH) 3A 8E 40
Load Register A with the number of files set aside from 408EH; LD does not change the flags.
605D
If the NZ FLAG is set (a list of files), JUMP to 6077H.
605F
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
6060
PUSH BC C5
Save Register Pair BC (61A8H, the close routine) to the stack.
6061
PUSH AF F5
Save Register Pair AF (Register A = the file number) to the stack.
6062
LD DE,6068H 11 68 60
Load Register Pair DE with 6068H, where the loop goes on.
6065
PUSH DE D5
Save Register Pair DE (6068H) to the stack: the return address of 61A8H.
6066
PUSH BC C5
Save Register Pair BC (61A8H) to the stack: the RET next goes there.
6067
RET C9
RETurn to 61A8H to close file Register A; it RETurns to 6068H.
6068
POP AF F1
Restore Register Pair AF (Register A = the file number) from the stack.
6069
POP BC C1
Restore Register Pair BC (61A8H) from the stack.
606A
DEC A 3D
DECrement Register A to the file before, and the S FLAG with it.
606B
If the P FLAG is set (0 or more), JUMP to 6060H to close it.
606E
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
606F
RET C9
RETurn to the ROM with every file set aside closed.
6070
POP BC C1
Restore Register Pair BC (61A8H) from the stack: the return from a file of the list.
6071
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
6072
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
6073
CP 2CH FE 2C
Compare Register A against 2CH, a comma: another file follows.
6075
RET NZ C0
If the NZ FLAG is set (no comma), RETurn to the ROM.
6076
RST 10H D7
RST 10H (658DH): Register Pair HL past the comma, Register A = the next character.
6077
PUSH BC C5
Save Register Pair BC (61A8H, the close routine) to the stack.
6078
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
6079
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
607B
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
607E
GOSUB to 2B1CH, the ROM: the file number as a byte in Register A.
6081
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = 61A8H, the stack = the text pointer.
6082
PUSH HL E5
Save Register Pair HL (61A8H, the close routine) to the stack.
6083
LD DE,6070H 11 70 60
Load Register Pair DE with 6070H, where the list goes on.
6086
PUSH DE D5
Save Register Pair DE (6070H) to the stack: the return address of 61A8H.
6087
JP (HL) E9
JUMP to the address in Register Pair HL, 61A8H, to close file Register A.

6088H - 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 (6057H) the Z FLAG: every file is closed.

6088
PUSH DE D5
Save Register Pair DE to the stack across CLOSE.
6089
PUSH BC C5
Save Register Pair BC to the stack across CLOSE.
608A
XOR A AF
Load Register A with 00H (XOR A): the Z FLAG, no list of files.
608B
GOSUB to 6057H, CLOSE, to close every file set aside.
608E
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
608F
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
6090
XOR A AF
Load Register A with 00H (XOR A), as the ROM expects.
6091
RET C9
RETurn to the ROM with every file closed and Register A = 00H.

6092H - 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 6607H) 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 60D1H), so a record of 80 bytes may be fielded as 256.

6092
GOSUB to 5D03H for the file number: Register Pair BC = its buffer, Register A = its mode.
6095
If the Z FLAG is set (the file is closed), JUMP to 644CH, Bad file number (E = 68H).
6098
SUB 03H D6 03
SUBtract 03H from Register A (the mode): the Z FLAG for random.
609A
If the NZ FLAG is set (not random), JUMP to 6449H, Bad file mode (E = 6CH).
609D
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the text pointer.
609E
LD HL,000BH 21 0B 00
Load Register Pair HL with 000BH, the offset of the FCB's record length in the buffer.
60A1
ADD HL,BC 09
ADD Register Pair BC (the buffer) to Register Pair HL: the record length byte.
60A2
LD A,(HL) 7E
Load Register A with the record length at Register Pair HL.
60A3
LD (6607H),A 32 07 66
Store Register A (the record length) at 6607H.
60A6
XOR A AF
Load Register A with 00H (XOR A): no bytes in fields yet.
60A7
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the text pointer.
60A8
LD DE,0022H 11 22 00
Load Register Pair DE with 0022H, the offset of the data area in the buffer.
60AB
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the offset or the place in the data area.
60AC
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the place of the next field.
60AD
LD B,A 47
Copy Register A (the bytes in fields so far) into Register B.
60AE
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the place, Register Pair HL = the text pointer.
60AF
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
60B0
CP 2CH FE 2C
Compare Register A against 2CH, a comma: another field follows.
60B2
RET NZ C0
If the NZ FLAG is set (no comma), RETurn to the ROM.
60B3
PUSH DE D5
Save Register Pair DE (the place of the field) to the stack.
60B4
PUSH BC C5
Save Register Pair BC (Register B = the bytes so far) to the stack.
60B5
GOSUB to 2B1BH, the ROM: past the comma, the width as a byte in Register A.
60B8
PUSH AF F5
Save Register Pair AF (Register A = the width) to the stack.
60B9
RST 08H => 41H CF 41
RST 08H with the byte 41H: the letter A must come next.
60BB
RST 08H => 53H CF 53
RST 08H with the byte 53H: the letter S, AS, must come next.
60BD
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable v$.
60C0
GOSUB to 0AF4H, the ROM: Type mismatch unless v$ is a string.
60C3
POP AF F1
Restore Register Pair AF (Register A = the width) from the stack.
60C4
POP BC C1
Restore Register Pair BC (Register B = the bytes so far) from the stack.
60C5
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.
60C6
LD C,A 4F
Copy Register A (the width of the field) into Register C.
60C7
ADD A,B 80
ADD Register B (the bytes so far) to Register A: the bytes with this field.
60C8
If the NO CARRY FLAG is set (255 or less), JUMP to 60CDH.
60CA
If the NZ FLAG is set (more than 256), JUMP to 645EH, FIELD overflow (E = 64H).
60CD
LD B,A 47
Copy Register A (the bytes with this field, 00H for 256) into Register B.
60CE
LD A,(6607H) 3A 07 66
Load Register A with the record length from 6607H.
60D1
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).
60D2
If the NO CARRY FLAG is set (they fit), JUMP to 60D8H.
60D4
AND A A7
Set the flags from Register A (AND A): the Z FLAG for a record length of 256 (00H).
60D5
If the NZ FLAG is set (a shorter record), JUMP to 645EH, FIELD overflow (E = 64H).
60D8
LD A,B 78
Copy Register B (the bytes with this field) into Register A.
60D9
AND A A7
Set the flags from Register A (AND A): the Z FLAG when the fields total 256 (or nothing).
60DA
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = v$'s descriptor, Register Pair DE = the place.
60DB
LD (HL),C 71
Store Register C (the width) at Register Pair HL, v$'s length.
60DC
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
60DD
LD (HL),E 73
Store Register E at Register Pair HL, the low byte of the place.
60DE
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
60DF
LD (HL),D 72
Store Register D at Register Pair HL: v$ is the field in the buffer.
60E0
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the width; LD does not change the flags.
60E2
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
60E3
If the NZ FLAG is set, JUMP to 60ABH for the next field, after this one.
60E6
LD A,C 79
Copy Register C (the width of the field) into Register A.
60E7
AND A A7
Set the flags from Register A (AND A): the NZ FLAG when the fields reached 256 bytes.
60E8
RET NZ C0
If the NZ FLAG is set (the data area is full), RETurn to the ROM.
60E9
JUMP to 60ABH for the next field (a width of 0 with nothing before it).

60ECH - RSET and LSET

60ECH (OR 37H, the CARRY FLAG clear) is vector 24 (419AH), RSET; 60EDH (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 (6170H) 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, 6179H tries to reserve it again, but that path goes wrong (6185H).

60EC
OR 37H F6 37
OR 37H into Register A, clearing the CARRY FLAG: RSET. The byte 37H at 60EDH is SCF, the entry for LSET.
60EE
PUSH AF F5
Save Register Pair AF (the CARRY FLAG: set for LSET) to the stack.
60EF
GOSUB to 260DH, the ROM's variable search: Register Pair DE = the variable v$.
60F2
GOSUB to 0AF4H, the ROM: Type mismatch unless v$ is a string.
60F5
PUSH DE D5
Save Register Pair DE (v$'s descriptor) to the stack.
60F6
RST 08H => D5H CF D5
RST 08H with the byte D5H, the token =: it must come next.
60F8
GOSUB to 2337H, the ROM: evaluate the expression x$.
60FB
POP BC C1
Restore Register Pair BC (v$'s descriptor) from the stack.
60FC
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.
60FD
PUSH HL E5
Save Register Pair HL (the LSET or RSET flags) to the stack.
60FE
PUSH BC C5
Save Register Pair BC (v$'s descriptor) to the stack.
60FF
GOSUB to 29D7H, the ROM: x$ must be a string, a temporary freed (the Z FLAG); Register Pair HL = its descriptor.
6102
LD B,(HL) 46
Load Register B with x$'s length at Register Pair HL.
6103
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.
6104
LD A,(HL) 7E
Load Register A with v$'s length at Register Pair HL.
6105
LD C,A 4F
Copy Register A (v$'s length) into Register C.
6106
PUSH BC C5
Save Register Pair BC (Register B = x$'s length, Register C = v$'s) to the stack.
6107
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
6108
PUSH AF F5
Save Register Pair AF (Register A = v$'s length, the flags of 29D7H) to the stack.
6109
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
610A
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
610B
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
610C
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = v$'s text.
610D
AND A A7
Set the flags from Register A (AND A): the Z FLAG when v$ is empty.
610E
If the Z FLAG is set (v$ is empty), JUMP to 6166H: nothing to do.
6111
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
6114
RST 18H DF
RST 18H: compare Register Pair HL (the start of the program) against Register Pair DE (v$'s text).
6115
If the NO CARRY FLAG is set (v$ is below the program), JUMP to 6142H.
6117
LD HL,(40F9H) 2A F9 40
Load Register Pair HL with the end of the program from 40F9H-40FAH.
611A
RST 18H DF
RST 18H: compare Register Pair HL (the end of the program) against Register Pair DE (v$'s text).
611B
If the CARRY FLAG is set (v$ is above the program), JUMP to 6142H.
611D
LD E,C 59
Copy Register C (v$'s length) into Register E.
611E
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = v$'s length.
6120
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with the start of string space from 40A0H-40A1H.
6123
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: string space plus v$'s length.
6124
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = that address.
6125
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with the next free byte of string space from 40D6H-40D7H.
6128
RST 18H DF
RST 18H: compare Register Pair HL against Register Pair DE: CARRY when the room is short.
6129
If the CARRY FLAG is set (short), JUMP to 6179H to keep x$ safe first.
612B
POP AF F1
Restore Register Pair AF (Register A = v$'s length) from the stack.
612C
LD A,C 79
Copy Register C (v$'s length) into Register A.
612D
GOSUB to 28BFH, the ROM: space for Register A bytes of string; Register Pair DE = its address.
6130
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
6131
POP BC C1
Restore Register Pair BC (the two lengths) from the stack.
6132
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.
6133
PUSH DE D5
Save Register Pair DE (the new space) to the stack.
6134
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
6135
GOSUB to 29D7H, the ROM: x$'s temporary freed again; Register Pair HL = its descriptor.
6138
POP BC C1
Restore Register Pair BC (the two lengths) from the stack.
6139
POP DE D1
Restore Register Pair DE (the new space) from the stack.
613A
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.
613B
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
613C
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
613D
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
613E
LD (HL),E 73
Store Register E at Register Pair HL, the low byte of the new space.
613F
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
6140
LD (HL),D 72
Store Register D at Register Pair HL: v$ now has space of its own.
6141
PUSH AF F5
Save Register Pair AF to the stack, for the POP AF next.
6142
POP AF F1
Discard a word (POP AF into Register Pair AF).
6143
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
6144
INC HL 23
INCrement Register Pair HL to the low byte of v$'s address.
6145
LD E,(HL) 5E
Load Register E with the low byte of v$'s address at Register Pair HL.
6146
INC HL 23
INCrement Register Pair HL to the high byte of v$'s address.
6147
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = v$'s text.
6148
POP BC C1
Restore Register Pair BC (Register B = x$'s length, Register C = v$'s) from the stack.
6149
POP HL E1
Restore Register Pair HL (x$'s descriptor) from the stack.
614A
PUSH DE D5
Save Register Pair DE (v$'s text) to the stack.
614B
INC HL 23
INCrement Register Pair HL to the low byte of x$'s address.
614C
LD E,(HL) 5E
Load Register E with the low byte of x$'s address at Register Pair HL.
614D
INC HL 23
INCrement Register Pair HL to the high byte of x$'s address.
614E
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = x$'s text.
614F
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = x$'s text.
6150
POP DE D1
Restore Register Pair DE (v$'s text) from the stack.
6151
LD A,C 79
Copy Register C (v$'s length) into Register A.
6152
CP B B8
Compare Register A against Register B (x$'s length): NO CARRY when x$ fits.
6153
If the NO CARRY FLAG is set (it fits), JUMP to 6156H.
6155
LD B,A 47
Copy Register A (v$'s length) into Register B: x$ is cut to it.
6156
SUB B 90
SUBtract Register B (the characters copied) from Register A: the spaces to pad.
6157
LD C,A 4F
Copy Register A (the spaces) into Register C.
6158
POP AF F1
Restore Register Pair AF (the CARRY FLAG: set for LSET) from the stack.
6159
If the NO CARRY FLAG is set (RSET), GOSUB to 6170H: the spaces come first.
615C
INC B 04
INCrement Register B (the characters to copy), with the DEC next to set the flags.
615D
DEC B 05
DECrement Register B: the Z FLAG when the copy is done.
615E
If the Z FLAG is set (the copy is done), JUMP to 616BH.
6160
LD A,(HL) 7E
Load Register A with a character of x$ at Register Pair HL.
6161
LD (DE),A 12
Store Register A at Register Pair DE, a character of v$.
6162
INC HL 23
INCrement Register Pair HL to the next character of x$.
6163
INC DE 13
INCrement Register Pair DE to the next character of v$.
6164
JUMP to 615DH for the next character of x$ to copy.
6166
POP BC C1
Discard a word (POP BC into Register Pair BC): v$ is empty.
6167
POP BC C1
Discard a second word (POP BC into Register Pair BC).
6168
POP BC C1
Discard a third word (POP BC into Register Pair BC).
6169
POP BC C1
Discard a fourth word (POP BC into Register Pair BC).
616A
POP BC C1
Restore the saved flags (POP BC into Register Pair BC): Register C = the flags, so the CARRY FLAG is unchanged from 610DH, clear.
616B
If the CARRY FLAG is set (LSET), GOSUB to 6170H: the spaces come last.
616E
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
616F
RET C9
RETurn to the ROM with v$ set from x$ and padded.

6170H - Spaces

Stores Register C spaces (20H) at Register Pair DE onward.

6170
LD A,20H 3E 20
Load Register A with 20H, a space, the character that pads.
6172
INC C 0C
INCrement Register C (the spaces left), with the DEC next to set the flags.
6173
DEC C 0D
DECrement Register C: the Z FLAG when none are left.
6174
RET Z C8
If the Z FLAG is set (no space left to store), RETurn to the caller.
6175
LD (DE),A 12
Store Register A (a space) at Register Pair DE.
6176
INC DE 13
INCrement Register Pair DE to the next character of v$.
6177
JUMP to 6173H for the next space to store in v$.

6179H - Keep x$ Safe

Reached from 6129H when string space is short and 28BFH may collect garbage. The flags saved at 6108H 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 (6185H), so this path fails. With the NZ FLAG 612BH allocates v$'s space.

6179
POP AF F1
Restore Register Pair AF (Register A = v$'s length, the flags of 29D7H) from the stack.
617A
POP HL E1
Restore Register Pair HL (v$'s descriptor) from the stack.
617B
POP BC C1
Restore Register Pair BC (the two lengths) from the stack.
617C
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.
617D
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = x$'s descriptor.
617E
If the NZ FLAG is set (x$ was not a temporary), JUMP to 6189H.
6180
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
6181
LD A,B 78
Copy Register B (x$'s length) into Register A.
6182
GOSUB to 2857H, the ROM: Register A bytes of string space reserved, the descriptor at 40D3H.
6185
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 6188H and its RET NZ goes to the lengths saved at 6180H, an address of nothing. 6188H is not reached.
6188
POP BC C1
Restore Register Pair BC (the two lengths) from the stack; never reached from 6185H (see there).
6189
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): Register Pair HL = v$'s descriptor.
618A
PUSH BC C5
Save Register Pair BC (the two lengths) to the stack.
618B
PUSH HL E5
Save Register Pair HL (v$'s descriptor) to the stack.
618C
PUSH AF F5
Save Register Pair AF (Register A = v$'s length) to the stack.
618D
JUMP to 612BH to allocate v$'s space in string space.

618FH - 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.

618F
GOSUB to 5D0DH for the file number in the accumulator: Register Pair BC = its buffer, Register A = its mode.
6192
CP 02H FE 02
Compare Register A (the mode) against 02H, output.
6194
If the Z FLAG is set (output), JUMP to 6449H, Bad file mode (E = 6CH).
6197
INC BC 03
INCrement Register Pair BC toward the FCB inside the buffer.
6198
INC BC 03
INCrement Register Pair BC again: the FCB, at buffer + 02H.
6199
LD D,B 50
Copy Register B (the high byte of the FCB's address) into Register D.
619A
LD E,C 59
Copy Register C into Register E: Register Pair DE = the FCB.
619B
GOSUB to 4458H, @CKEOF: the Z FLAG when there is more to read.
619E
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the result false; LD does not change the flags.
61A1
If the Z FLAG is set (more to read), JUMP to 0A9AH, the ROM: the result 0.
61A4
DEC HL 2B
DECrement Register Pair HL: FFFFH, the result -1, true.
61A5
JUMP to 0A9AH, the ROM: the accumulator = Register Pair HL, an integer.

61A8H - 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.

61A8
GOSUB to 5D10H for file Register A: Register Pair BC = its buffer, Register A = its mode, the Z FLAG when closed.
61AB
RET Z C8
If the Z FLAG is set (the file is closed), RETurn to the caller.
61AC
CP 01H FE 01
Compare Register A (the mode) against 01H, input.
61AE
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
61AF
If the Z FLAG is set (input), JUMP to 61BDH: no @CLOSE.
61B1
XOR A AF
Load Register A with 00H (XOR A), the mode of a closed file.
61B2
LD (BC),A 02
Store Register A (00H) at Register Pair BC, the file's mode: closed.
61B3
INC BC 03
INCrement Register Pair BC toward the FCB inside the buffer.
61B4
INC BC 03
INCrement Register Pair BC again: the FCB, at buffer + 02H.
61B5
LD D,B 50
Copy Register B (the high byte of the FCB's address) into Register D.
61B6
LD E,C 59
Copy Register C (the low byte) into Register E: Register Pair DE = the FCB.
61B7
GOSUB to 4428H, @CLOSE: the file is closed; NZ for an error.
61BA
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
61BD
POP DE D1
Restore Register Pair DE (the buffer) from the stack.
61BE
LD B,22H 06 22
Load Register B with 22H, the bytes to clear: the mode, the column and the FCB.
61C0
XOR A AF
Load Register A with 00H (XOR A), the byte to store.
61C1
LD (DE),A 12
Store Register A (00H) at Register Pair DE in the buffer.
61C2
INC DE 13
INCrement Register Pair DE to the next byte of the buffer.
61C3
DECrement Register B and LOOP BACK to 61C1H until 34 bytes are clear.
61C5
RET C9
RETurn to the caller with the file closed and its buffer cleared.

61C6H - LOC and LOF

61C6H is vector 6 (4164H), LOC, with @LOC (446DH); 61CBH is vector 7 (4167H), LOF, with @LOF (4470H). 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).

61C6
LD HL,446DH 21 6D 44
Load Register Pair HL with 446DH, @LOC: the current record number.
61C9
JUMP to 61CEH, past LOF's own LD of Register Pair HL.
61CB
LD HL,4470H 21 70 44
Load Register Pair HL with 4470H, @LOF: the number of records in the file.
61CE
GOSUB to 5D0DH for the file number in the accumulator: Register Pair BC = its buffer, the Z FLAG when closed.
61D1
If the Z FLAG is set (the file is closed), JUMP to 644CH, Bad file number (E = 68H).
61D4
INC BC 03
INCrement Register Pair BC toward the FCB inside the buffer.
61D5
INC BC 03
INCrement Register Pair BC again: the FCB, at buffer + 02H.
61D6
LD D,B 50
Copy Register B (the high byte of the FCB's address) into Register D.
61D7
LD E,C 59
Copy Register C (the low byte) into Register E: Register Pair DE = the FCB.
61D8
GOSUB to 61E3H, which JUMPs to the call in Register Pair HL: Register Pair BC = the record number.
61DB
If the NZ FLAG is set (an error), JUMP to 07B2H, the ROM's Overflow.
61DE
LD H,B 60
Copy Register B (the high byte of the record number) into Register H.
61DF
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the record number.
61E0
JUMP to 0A9AH, the ROM: the accumulator = Register Pair HL, an integer.
61E3
JP (HL) E9
JUMP to the address in Register Pair HL, @LOC or @LOF, which RETurns to 61DBH.

61E4H - A Byte to the Current File

From 5C0EH 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 6463H only for an open disk file (bit 7 of the FCB's byte 0); for a device it is ignored. Every register is kept.

61E4
PUSH HL E5
Save Register Pair HL to the stack, kept for the caller.
61E5
PUSH AF F5
Save Register Pair AF (Register A = the byte) to the stack.
61E6
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
61E9
LD A,(HL) 7E
Load Register A with the file's mode at Register Pair HL.
61EA
CP 01H FE 01
Compare Register A against 01H: the Z FLAG for input.
61EC
If the Z FLAG is set (input), JUMP to 1DFDH, the ROM: POP AF, POP HL and RETurn; nothing is written.
61EF
POP AF F1
Restore Register Pair AF (Register A = the byte) from the stack.
61F0
PUSH DE D5
Save Register Pair DE to the stack, kept for the caller.
61F1
PUSH BC C5
Save Register Pair BC to the stack, kept for the caller.
61F2
INC HL 23
INCrement Register Pair HL to the file's column, at buffer + 01H.
61F3
LD B,00H 06 00
Load Register B with 00H, the column after a 0DH.
61F5
PUSH AF F5
Save Register Pair AF (Register A = the byte) to the stack.
61F6
LD D,(HL) 56
Load Register D with the file's column at Register Pair HL.
61F7
CP 0DH FE 0D
Compare Register A (the byte) against 0DH, the end of a line.
61F9
LD (HL),B 70
Store Register B (00H) at Register Pair HL, the column; LD does not change the flags.
61FA
If the Z FLAG is set (0DH), JUMP to 6201H with the column 0.
61FC
ADD A,E0H C6 E0
ADD E0H to Register A: the CARRY FLAG for a byte of 20H or more.
61FE
LD A,D 7A
Copy Register D (the old column) into Register A.
61FF
ADC A,B 88
ADD Register B (00H) and the CARRY FLAG to Register A: the column up one for a printable byte.
6200
LD (HL),A 77
Store Register A (the new column) at Register Pair HL.
6201
INC HL 23
INCrement Register Pair HL to the FCB, at buffer + 02H.
6202
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the FCB.
6203
POP AF F1
Restore Register Pair AF (Register A = the byte) from the stack.
6204
PUSH AF F5
Save Register Pair AF (Register A = the byte) to the stack again.
6205
GOSUB to 001BH, the ROM's $PUT: Register A goes to the file or device at Register Pair DE; NZ for an error.
6208
If the NZ FLAG is set (an error), JUMP to 620FH.
620A
POP AF F1
Restore Register Pair AF (Register A = the byte) from the stack.
620B
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
620C
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
620D
POP HL E1
Restore Register Pair HL from the stack, as it was on entry.
620E
RET C9
RETurn to the caller with the byte written and the registers kept.
620F
LD C,A 4F
Copy Register A (the error code) into Register C.
6210
LD A,(DE) 1A
Load Register A with the FCB's byte 0 at Register Pair DE.
6211
AND A A7
Set the flags from Register A (AND A): the M FLAG (bit 7) for an open disk file.
6212
LD A,C 79
Copy Register C (the error code) into Register A; LD does not change the flags.
6213
If the M FLAG is set (a disk file), JUMP to 6463H with the DOS error in Register A.
6216
JUMP to 620AH: for a device the error is ignored.

6218H - PUT and GET

6218H (OR AFH, Register A not 00H) is vector 16 (4182H), PUT; 6219H (XOR A, inside it) is GET, Register A = 00H; 660AH 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).

6218
OR AFH F6 AF
OR AFH into Register A: not 00H, PUT. The byte AFH at 6219H is XOR A, the entry for GET (00H).
621A
LD (660AH),A 32 0A 66
Store Register A at 660AH: 00H for GET, else PUT.
621D
GOSUB to 5D03H for the file number: Register Pair BC = its buffer, Register A = its mode.
6220
CP 03H FE 03
Compare Register A (the mode) against 03H, random.
6222
If the NZ FLAG is set (not random), JUMP to 6449H, Bad file mode (E = 6CH).
6225
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
6226
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
6227
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character, Register A = it; the Z FLAG at the end.
6228
If the NZ FLAG is set (more follows), JUMP to 6238H for the record number.
622A
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.
622B
PUSH HL E5
Save Register Pair HL (the buffer) to the stack.
622C
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
622D
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
622E
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
622F
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, from the FCB to the data area.
6232
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the data area, buffer + 22H.
6233
GOSUB to 4458H, @CKEOF: the Z FLAG when the place is inside the file.
6236
JUMP to 6255H to act on the result of @CKEOF.
6238
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
6239
CP 2CH FE 2C
Compare Register A against 2CH, a comma before the record number.
623B
If the NZ FLAG is set (no comma), JUMP to 1997H, the ROM's Syntax error.
623E
GOSUB to 2B01H, the ROM: the record number as an integer in Register Pair DE.
6241
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.
6242
PUSH HL E5
Save Register Pair HL (the buffer) to the stack.
6243
LD A,D 7A
Copy Register D (the high byte of the record number) into Register A.
6244
OR E B3
OR Register E into Register A: the Z FLAG for record 0.
6245
If the Z FLAG is set (record 0), JUMP to 645BH, Bad record number (E = 7EH).
6248
DEC DE 1B
DECrement Register Pair DE: the DOS counts records from 0.
6249
LD B,D 42
Copy Register D (the high byte of the record) into Register B.
624A
LD C,E 4B
Copy Register E into Register C: Register Pair BC = the record wanted.
624B
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
624C
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
624D
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
624E
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, from the FCB to the data area.
6251
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the data area, buffer + 22H.
6252
GOSUB to 4442H, @POSN: the file is positioned at record Register Pair BC; NZ with an error code.
6255
If the Z FLAG is set (no error), JUMP to 626FH.
6257
CP 1CH FE 1C
Compare Register A against 1CH, the end of the file.
6259
If the Z FLAG is set (1CH, the end of the file), JUMP to 6260H.
625B
CP 1DH FE 1D
Compare Register A against 1DH, a record past the end of the file.
625D
If the NZ FLAG is set (another error), JUMP to 6463H with the DOS error in Register A.
6260
LD A,(660AH) 3A 0A 66
Load Register A with the byte at 660AH: 00H for GET, else PUT.
6263
AND A A7
Set the flags from Register A (AND A): the Z FLAG for GET.
6264
If the Z FLAG is set (GET past the end), JUMP to 6282H for a record of zero bytes.
6266
GOSUB to 4439H, @WRITE: the data area is written as the record; NZ for an error.
6269
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
626C
POP AF F1
Discard the buffer (POP AF into Register Pair AF).
626D
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
626E
RET C9
RETurn to the ROM with the record written to the file.
626F
LD A,(660AH) 3A 0A 66
Load Register A with the byte at 660AH: 00H for GET, else PUT.
6272
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for PUT.
6273
If the NZ FLAG is set (PUT), JUMP to 6266H to write the record.
6275
GOSUB to 4436H, @READ: the record is read into the data area; NZ for an error.
6278
If the NZ FLAG is set (an error), JUMP to 627DH.
627A
POP BC C1
Discard the buffer (POP BC into Register Pair BC).
627B
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
627C
RET C9
RETurn to the ROM with the record read into the data area.
627D
CP 1CH FE 1C
Compare Register A against 1CH, the end of the file.
627F
If the NZ FLAG is set (another error), JUMP to 6463H with the DOS error in Register A.
6282
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
6283
LD DE,0022H 11 22 00
Load Register Pair DE with 0022H, the offset of the data area.
6286
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the data area, buffer + 22H.
6287
XOR A AF
Load Register A with 00H (XOR A), the byte to store.
6288
LD B,A 47
Copy Register A into Register B: 256 bytes to clear.
6289
LD (HL),A 77
Store Register A (00H) at Register Pair HL in the data area.
628A
INC HL 23
INCrement Register Pair HL to the next byte of the data area.
628B
DECrement Register B and LOOP BACK to 6289H until 256 bytes are clear.
628D
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
628E
RET C9
RETurn to the ROM with a record of zero bytes.

628FH - 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 6463H. For a device, a Z FLAG reads again and anything else is RETurned. Registers BC, DE and HL are kept.

628F
PUSH BC C5
Save Register Pair BC to the stack, kept for the caller.
6290
PUSH HL E5
Save Register Pair HL to the stack, kept for the caller.
6291
LD HL,(660CH) 2A 0C 66
Load Register Pair HL with the current file's buffer pointer from 660CH-660DH.
6294
PUSH DE D5
Save Register Pair DE to the stack, kept for the caller.
6295
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
6296
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
6297
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
6298
GOSUB to 0013H, the ROM's $GET: a byte in Register A from the FCB at Register Pair DE; NZ for an error.
629B
PUSH AF F5
Save Register Pair AF (the byte and the flags) to the stack.
629C
LD A,(DE) 1A
Load Register A with the FCB's byte 0 at Register Pair DE.
629D
AND A A7
Set the flags from Register A (AND A): the P FLAG (bit 7 clear) for a device.
629E
If the P FLAG is set (a device), JUMP to 62B0H.
62A1
POP AF F1
Restore Register Pair AF (the byte and the flags) from the stack.
62A2
If the Z FLAG is set (a byte), JUMP to 62ABH to clear the CARRY FLAG.
62A4
CP 1CH FE 1C
Compare Register A (the error code) against 1CH, the end of the file.
62A6
If the NZ FLAG is set (another error), JUMP to 6463H with the DOS error in Register A.
62A9
SCF 37
Set the CARRY FLAG (SCF): the end of the file.
62AA
LD B,A7H 06 A7
Load Register B with A7H: skipped bytes, 62ABH is AND A, which clears the CARRY FLAG; Register B comes back from the stack.
62AC
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
62AD
POP HL E1
Restore Register Pair HL from the stack, as it was on entry.
62AE
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
62AF
RET C9
RETurn to the caller: NO CARRY with a byte, CARRY at the end of the file.
62B0
POP AF F1
Restore Register Pair AF (the byte and the flags) from the stack.
62B1
If the Z FLAG is set, JUMP to 6298H to read the device again.
62B3
JUMP to 62ABH to RETurn with the CARRY FLAG clear.

62B5H - A Filespec Into an FCB

The string expression at Register Pair HL (1 to 24 characters, else Bad file name) is copied to 543CH 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.

62B5
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
62B6
GOSUB to 2337H, the ROM: evaluate the expression of the filespec.
62B9
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
62BA
GOSUB to 29D7H, the ROM: it must be a string, its temporary freed; Register Pair HL = its descriptor.
62BD
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
62BE
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty string.
62BF
If the Z FLAG is set (empty), JUMP to 6458H, Bad file name (E = 80H).
62C2
CP 19H FE 19
Compare Register A against 19H: NO CARRY for 25 characters or more.
62C4
If the NO CARRY FLAG is set (too long), JUMP to 6458H, Bad file name (E = 80H).
62C7
INC HL 23
INCrement Register Pair HL to the low byte of the string's address.
62C8
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
62C9
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
62CA
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the string's text.
62CB
LD HL,543CH 21 3C 54
Point Register Pair HL to 543CH, where the filespec is put (inside the start up code).
62CE
LD E,A 5F
Copy Register A (the length) into Register E, the characters to copy.
62CF
LD A,(BC) 0A
Load Register A with a character of the filespec at Register Pair BC.
62D0
LD (HL),A 77
Store Register A at Register Pair HL, the copy at 543CH.
62D1
INC HL 23
INCrement Register Pair HL to the next byte at 543CH.
62D2
INC BC 03
INCrement Register Pair BC to the next character of the filespec.
62D3
DEC E 1D
DECrement Register E, the characters of the filespec left.
62D4
If the NZ FLAG is set (more), LOOP BACK to 62CFH.
62D6
LD (HL),E 73
Store Register E (00H) at Register Pair HL: the end of the filespec.
62D7
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
62D8
POP DE D1
Restore Register Pair DE (the buffer) from the stack.
62D9
LD B,D 42
Copy Register D (the high byte of the buffer) into Register B.
62DA
LD C,E 4B
Copy Register E into Register C: Register Pair BC = the buffer.
62DB
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
62DC
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
62DD
LD HL,543CH 21 3C 54
Point Register Pair HL to 543CH, the filespec.
62E0
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
62E1
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
62E2
GOSUB to 441CH, @FSPEC: the filespec at Register Pair HL into the FCB at Register Pair DE; NZ for an error.
62E5
If the NZ FLAG is set (an error), JUMP to 6458H, Bad file name (E = 80H).
62E8
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for a character after the filespec.
62E9
If the NZ FLAG is set, JUMP to 6458H, Bad file name (E = 80H).
62EC
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
62ED
POP BC C1
Restore Register Pair BC (the buffer) from the stack.
62EE
RET C9
RETurn to the caller with the FCB set from the filespec.

62EFH - 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 6400H goes.

62EF
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.
62F2
PUSH BC C5
Save Register Pair BC (2169H) to the stack: OPEN RETurns there.
62F3
GOSUB to 2337H, the ROM: evaluate the expression of the mode.
62F6
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
62F7
GOSUB to 29D7H, the ROM: it must be a string, its temporary freed; Register Pair HL = its descriptor.
62FA
LD A,(HL) 7E
Load Register A with the string's length at Register Pair HL.
62FB
AND A A7
Set the flags from Register A (AND A): the Z FLAG for an empty string.
62FC
If the Z FLAG is set (no mode), JUMP to 6449H, Bad file mode (E = 6CH).
62FF
INC HL 23
INCrement Register Pair HL to the low byte of the string's address.
6300
LD C,(HL) 4E
Load Register C with the low byte of the string's address at Register Pair HL.
6301
INC HL 23
INCrement Register Pair HL to the high byte of the string's address.
6302
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the mode's text.
6303
LD E,A 5F
Copy Register A (the length) into Register E.
6304
LD A,(BC) 0A
Load Register A with the first letter of the mode at Register Pair BC.
6305
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter made upper case.
6307
CP 49H FE 49
Compare Register A against 49H, I: input from a file that exists.
6309
LD D,11H 16 11
Load Register D with 11H, the mode byte of I: input, the file must exist.
630B
If the Z FLAG is set (I), JUMP to 6333H; any other letters are not looked at.
630D
CP 4FH FE 4F
Compare Register A against 4FH, O: output to a new or old file.
630F
LD D,02H 16 02
Load Register D with 02H, the mode byte of O: output.
6311
If the Z FLAG is set (O), JUMP to 6320H for a second letter.
6313
CP 52H FE 52
Compare Register A against 52H, R: random, records read and written.
6315
LD D,0BH 16 0B
Load Register D with 0BH, the mode byte of R: random, with a record length allowed (bit 3).
6317
If the Z FLAG is set (R), JUMP to 6320H for a second letter.
6319
CP 45H FE 45
Compare Register A against 45H, E: output added at the end.
631B
LD D,06H 16 06
Load Register D with 06H, the mode byte of E: output, at the end of the file (bit 2).
631D
If the NZ FLAG is set (no valid letter), JUMP to 6449H, Bad file mode (E = 6CH).
6320
DEC E 1D
DECrement Register E, the letters left: the Z FLAG for one letter.
6321
If the Z FLAG is set (one letter), JUMP to 6333H.
6323
INC BC 03
INCrement Register Pair BC to the second letter of the mode.
6324
LD A,(BC) 0A
Load Register A with the second letter at Register Pair BC.
6325
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter made upper case.
6327
CP 4FH FE 4F
Compare Register A against 4FH, O: the file must be old.
6329
If the NZ FLAG is set (not O), JUMP to 632DH.
632B
SET 4,D CB E2
Set bit 4 of Register D (the mode byte): the file must exist.
632D
CP 4EH FE 4E
Compare Register A against 4EH, N: the file must be new.
632F
If the NZ FLAG is set (not N), JUMP to 6333H.
6331
SET 5,D CB EA
Set bit 5 of Register D (the mode byte): the file must not exist.
6333
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
6334
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come after the mode.
6336
PUSH DE D5
Save Register Pair DE (Register D = the mode byte) to the stack.
6337
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
6339
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
633C
GOSUB to 2B1CH, the ROM: the file number as a byte in Register A and Register E.
633F
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the filespec.
6341
LD A,E 7B
Copy Register E (the file number) into Register A.
6342
AND A A7
Set the flags from Register A (AND A): the Z FLAG for file 0.
6343
If the Z FLAG is set (file 0, kept for programs), JUMP to 644CH, Bad file number (E = 68H).
6346
CP D5H FE D5
Compare Register A against D5H: no use; the byte D5H at 6347H is PUSH DE, the entry from 5E36H with Register A = 00H.
6348
LD (63A0H),A 32 A0 63
Store Register A (the file number) at 63A0H, the operand of LD A at 639FH.
634B
GOSUB to 5D10H for file Register A: Register Pair BC = its buffer, the Z FLAG when closed.
634E
If the NZ FLAG is set (open), JUMP to 6452H, File already open (E = 6EH).
6351
PUSH BC C5
Save Register Pair BC (the buffer) to the stack.
6352
GOSUB to 62B5H: the filespec into the FCB of the buffer at Register Pair BC.
6355
LD B,00H 06 00
Load Register B with 00H: a record length of 256.
6357
POP DE D1
Restore Register Pair DE (the buffer) from the stack.
6358
POP AF F1
Restore Register Pair AF from the stack: Register A = the mode byte.
6359
PUSH AF F5
Save Register Pair AF (the mode byte) to the stack again.
635A
PUSH DE D5
Save Register Pair DE (the buffer) to the stack.
635B
BIT 3,A CB 5F
Test bit 3 of Register A (the mode byte): the NZ FLAG for random.
635D
If the Z FLAG is set (not random), JUMP to 6373H.
635F
DEC HL 2B
DECrement Register Pair HL, so the RST 10H next reads the character again.
6360
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character, Register A = it; the Z FLAG at the end.
6361
If the Z FLAG is set (no record length), JUMP to 6373H.
6363
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must come before the record length.
6365
GOSUB to 2B1CH, the ROM: the record length as a byte in Register E (0 for 256).
6368
LD A,(408FH) 3A 8F 40
Load Register A with the blocked mode flag at 408FH.
636B
AND A A7
Set the flags from Register A (AND A): the NZ FLAG in blocked mode.
636C
If the NZ FLAG is set (blocked mode), JUMP to 6372H.
636E
OR E B3
OR Register E (the record length) into Register A: the Z FLAG for 0 (256).
636F
If the NZ FLAG is set (a short record without blocked mode), JUMP to 6446H, Blocked file error (E = 8CH).
6372
LD B,E 43
Copy Register E (the record length) into Register B.
6373
LD (40DFH),HL 22 DF 40
Store Register Pair HL (the text pointer) at 40DFH-40E0H, to keep it.
6376
LD HL,442BH 21 2B 44
Point Register Pair HL to 442BH, SFLAG$, the system flags.
6379
RES 2,(HL) CB 96
Reset bit 2 of SFLAG$ at Register Pair HL: not a load for @RUN.
637B
LD A,(6644H) 3A 44 66
Load Register A with the RUN flag at 6644H (FFH from 5E88H).
637E
AND A A7
Set the flags from Register A (AND A): the NZ FLAG for RUN.
637F
If the Z FLAG is set (not RUN), JUMP to 6383H.
6381
SET 2,(HL) CB D6
Set bit 2 of SFLAG$ at Register Pair HL: a program is being loaded to run.
6383
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
6384
POP AF F1
Restore Register Pair AF (Register A = the mode byte) from the stack.
6385
PUSH AF F5
Save Register Pair AF (the mode byte) to the stack again.
6386
PUSH HL E5
Save Register Pair HL (the buffer) to the stack again.
6387
LD (660CH),HL 22 0C 66
Store Register Pair HL (the buffer) at 660CH-660DH: the file is current.
638A
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the buffer.
638B
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
638C
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
638D
LD HL,0020H 21 20 00
Load Register Pair HL with 0020H, from the FCB to the sector buffer.
6390
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the sector buffer at buffer + 22H.
6391
LD C,A 4F
Copy Register A (the mode byte) into Register C.
6392
LD A,B 78
Copy Register B (the record length) into Register A.
6393
AND A A7
Set the flags from Register A (AND A): the Z FLAG for 256.
6394
If the Z FLAG is set (a record of 256), JUMP to 6397H.
6396
INC H 24
INCrement Register H: the sector buffer 256 bytes on (buffer + 122H); buffer + 22H holds the record.
6397
PUSH HL E5
Save Register Pair HL (the sector buffer) to the stack.
6398
LD HL,FFFFH 21 FF FF
Load Register Pair HL with the EXT parameter, the operand at 6399H (FFFFH in the file, on; 0000H for OFF).
639B
LD A,H 7C
Copy Register H (the high byte of EXT) into Register A.
639C
OR L B5
OR Register L into Register A: 00H only for EXT=OFF.
639D
CPL 2F
Complement Register A (CPL): 00H for EXT on, FFH for EXT=OFF.
639E
LD L,A 6F
Copy Register A (00H for EXT on) into Register L.
639F
LD A,00H 3E 00
Load Register A with the file number, the operand at 63A0H (00H in the file; 6348H stores it).
63A1
OR L B5
OR Register L into Register A: the Z FLAG for file 0 with EXT on.
63A2
LD HL,54B5H 21 B5 54
Point Register Pair HL to 54B5H, the text BASIC/OV, whose first 3 letters BAS are the extension.
63A5
PUSH BC C5
Save Register Pair BC (the record length and the mode byte) to the stack.
63A6
If the Z FLAG is set, GOSUB to 444BH, @FEXT: the extension /BAS is added when the filespec has none.
63A9
POP BC C1
Restore Register Pair BC (the record length and the mode byte) from the stack.
63AA
POP HL E1
Restore Register Pair HL (the sector buffer) from the stack.
63AB
LD A,C 79
Copy Register C (the mode byte) into Register A.
63AC
CP 01H FE 01
Compare Register A against 01H, the mode byte of a program file (5E33H).
63AE
If the Z FLAG is set (a program file), JUMP to 63D4H.
63B0
BIT 4,C CB 61
Test bit 4 of Register C (the mode byte): the NZ FLAG when the file must exist.
63B2
If the NZ FLAG is set, JUMP to 63C3H for @OPEN.
63B4
GOSUB to 4420H, @INIT: the file opened, made if it is new (the CARRY FLAG); NZ for an error.
63B7
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
63BA
If the CARRY FLAG is set (a new file), JUMP to 63C9H.
63BC
BIT 5,C CB 69
Test bit 5 of Register C (the mode byte): the NZ FLAG when the file had to be new.
63BE
If the NZ FLAG is set, JUMP to 6455H, File already exists (E = 74H).
63C1
JUMP to 63C9H to finish the open of the file.
63C3
GOSUB to 4424H, @OPEN: the file must exist; NZ for an error.
63C6
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
63C9
BIT 2,C CB 51
Test bit 2 of Register C (the mode byte): the NZ FLAG for E.
63CB
If the NZ FLAG is set (E), GOSUB to 4448H, @PEOF: to the end of the file.
63CE
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
63CF
POP AF F1
Restore Register Pair AF (Register A = the mode byte) from the stack.
63D0
AND 03H E6 03
Mask Register A to bits 1 and 0 (AND 03H): the mode, 01H input, 02H output, 03H random.
63D2
JUMP to 63F1H to store the mode in the file's buffer.
63D4
GOSUB to 4424H, @OPEN: the program file; NZ for an error.
63D7
PUSH AF F5
Save Register Pair AF (the result of @OPEN) to the stack.
63D8
LD A,(6644H) 3A 44 66
Load Register A with the RUN flag at 6644H (FFH from 5E88H).
63DB
AND A A7
Set the flags from Register A (AND A): the Z FLAG when not a RUN.
63DC
If the Z FLAG is set (not RUN), JUMP to 63EBH.
63DE
XOR A AF
Load Register A with 00H (XOR A) to clear the RUN flag.
63DF
LD (6644H),A 32 44 66
Store Register A (00H) at 6644H: the RUN flag cleared.
63E2
LD A,(442BH) 3A 2B 44
Load Register A with SFLAG$ from 442BH, as @OPEN left it.
63E5
RRA 1F
Rotate Register A right through the CARRY FLAG (RRA).
63E6
RRA 1F
Rotate Register A right again (RRA): bit 1 of SFLAG$, run without DEBUG, in the CARRY FLAG.
63E7
SBC A,A 9F
SUBtract Register A and the CARRY FLAG from Register A (SBC A,A): FFH for bit 1 set, else 00H.
63E8
LD (6645H),A 32 45 66
Store Register A at 6645H: FFH, the program may run but not be looked at.
63EB
POP AF F1
Restore Register Pair AF (the result of @OPEN) from the stack.
63EC
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
63EF
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
63F0
POP AF F1
Restore Register Pair AF (Register A = the mode byte, 01H) from the stack.
63F1
LD (HL),A 77
Store Register A (the mode) at Register Pair HL, the buffer's first byte: the file is open.
63F2
INC HL 23
INCrement Register Pair HL to the file's column.
63F3
LD (HL),00H 36 00
Store 00H at Register Pair HL, the file's column, at the left.
63F5
INC HL 23
INCrement Register Pair HL to the FCB's byte 0.
63F6
INC HL 23
INCrement Register Pair HL to the FCB's byte 1.
63F7
CP 03H FE 03
Compare Register A (the mode) against 03H, random.
63F9
If the NZ FLAG is set (not random), JUMP to 63FDH.
63FB
SET 6,(HL) CB F6
Set bit 6 of the FCB's byte 1 at Register Pair HL, for a random file.
63FD
LD HL,(40DFH) 2A DF 40
Load Register Pair HL with the text pointer kept at 40DFH-40E0H.
6400
RET C9
RETurn to the caller (2169H for OPEN) with the file open.

6401H - The Protection Test

CALLed from 5A7FH, 5FE6H and 5FFAH. 6644H is cleared. When 6645H is set (a program opened to run only, 63E8H) the program area is cleared (044DH bytes from 40A4H), 6645H cleared, the ROM's NEW made and the error Protection has cleared memory (E = 90H) given. Else every register is kept.

6401
PUSH AF F5
Save Register Pair AF to the stack, kept for the caller.
6402
XOR A AF
Load Register A with 00H (XOR A) to clear the RUN flag.
6403
LD (6644H),A 32 44 66
Store Register A (00H) at 6644H, the RUN flag.
6406
LD A,(6645H) 3A 45 66
Load Register A with the protection flag at 6645H.
6409
AND A A7
Set the flags from Register A (AND A): the Z FLAG when not protected.
640A
If the Z FLAG is set (not protected), JUMP to 6424H.
640C
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
640F
LD D,H 54
Copy Register H (the high byte of the program's start) into Register D.
6410
LD E,L 5D
Copy Register L into Register E: Register Pair DE = the start of the program.
6411
INC DE 13
INCrement Register Pair DE: the byte after it.
6412
LD BC,044CH 01 4C 04
Load Register Pair BC with 044CH, the bytes to copy: 044DH (1101) bytes are cleared.
6415
XOR A AF
Load Register A with 00H (XOR A), the byte that clears the program.
6416
LD (HL),A 77
Store Register A (00H) at Register Pair HL, the first byte of the program.
6417
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR): the 00H is spread over the program.
6419
LD (6645H),A 32 45 66
Store Register A (00H) at 6645H: the protection flag cleared.
641C
GOSUB to 1B4DH, the ROM's NEW: the program and variables are gone.
641F
LD E,90H 1E 90
Load Register E with 90H, the E value of Protection has cleared memory.
6421
JUMP to 19A2H, the ROM's error handler, with Register E = 90H.
6424
POP AF F1
Restore Register Pair AF from the stack, as it was on entry.
6425
RET C9
RETurn to the caller with nothing changed and the RUN flag cleared.

6426H - KILL

Vector 21 (4191H). The filespec is put in file 0's FCB (62B5H), the file opened (@OPEN, 4424H) and killed (@KILL, 442CH); file 0's mode is then cleared.

6426
XOR A AF
Load Register A with 00H (XOR A): file 0, kept for programs and KILL.
6427
GOSUB to 5D10H for file 0: Register Pair BC = its buffer.
642A
GOSUB to 62B5H: the filespec into the FCB of the buffer at Register Pair BC.
642D
LD DE,(660EH) ED 5B 0E 66
Load Register Pair DE with file 0's buffer from 660EH-660FH.
6431
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
6432
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
6433
GOSUB to 4424H, @OPEN: the file must exist; NZ for an error.
6436
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
6439
GOSUB to 442CH, @KILL: the file is removed; NZ for an error.
643C
If the NZ FLAG is set (an error), JUMP to 6463H with the DOS error in Register A.
643F
DEC DE 1B
DECrement Register Pair DE toward the buffer.
6440
DEC DE 1B
DECrement Register Pair DE again: file 0's buffer.
6441
LD (DE),A 12
Store Register A (00H) at Register Pair DE, the mode: file 0 closed.
6442
RET C9
RETurn to the ROM with the file killed and file 0 closed.

6443H - 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 6460H JUMPs to the ROM's error handler (19A2H). 6443H is also the USR vector set by 53B7H for a USR with no DEF USR. 6463H: a DOS error in Register A goes to Register L, and BASIC/OV3 function 02H gives its E value.

6443
LD E,2EH 1E 2E
Load Register E with 2EH: Undefined user function.
6445
LD BC,8C1EH 01 1E 8C
Load Register Pair BC with 8C1EH: skipped bytes, 6446H is LD E,8CH, Blocked file error.
6448
LD BC,6C1EH 01 1E 6C
Load Register Pair BC with 6C1EH: skipped bytes, 6449H is LD E,6CH, Bad file mode.
644B
LD BC,681EH 01 1E 68
Load Register Pair BC with 681EH: skipped bytes, 644CH is LD E,68H, Bad file number.
644E
LD BC,7C1EH 01 1E 7C
Load Register Pair BC with 7C1EH: skipped bytes, 644FH is LD E,7CH, Input past end.
6451
LD BC,6E1EH 01 1E 6E
Load Register Pair BC with 6E1EH: skipped bytes, 6452H is LD E,6EH, File already open.
6454
LD BC,741EH 01 1E 74
Load Register Pair BC with 741EH: skipped bytes, 6455H is LD E,74H, File already exists.
6457
LD BC,801EH 01 1E 80
Load Register Pair BC with 801EH: skipped bytes, 6458H is LD E,80H, Bad file name.
645A
LD BC,7E1EH 01 1E 7E
Load Register Pair BC with 7E1EH: skipped bytes, 645BH is LD E,7EH, Bad record number.
645D
LD BC,641EH 01 1E 64
Load Register Pair BC with 641EH: skipped bytes, 645EH is LD E,64H, FIELD overflow.
6460
JUMP to 19A2H, the ROM's error handler, with the E value in Register E.
6463
LD L,A 6F
Copy Register A (the DOS error code) into Register L for BASIC/OV3.
6464
LD A,02H 3E 02
Load Register A with 02H, BASIC/OV3's function for a DOS error.
6466
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number in Register A' for 54DEH.
6467
GOSUB to 54DEH to load and enter BASIC/OV3: Register E = the E value of the DOS error.
646A
JUMP to 19A2H, the ROM's error handler, with the E value in Register E.

646DH - The Command Line at READY

5BE6H 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$ 442BH), 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 652EH.

646D
POP HL E1
Load Register Pair HL with the return address 036BH, in the ROM's line input (POP HL).
646E
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.
646F
LD DE,1A7EH 11 7E 1A
Load Register Pair DE with 1A7EH, the return address in the ROM's command loop after 0361H.
6472
RST 18H DF
RST 18H: compare Register Pair HL against Register Pair DE (1A7EH); the Z FLAG for the command loop.
6473
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (at the Stack Pointer): the caller's return address back.
6474
PUSH HL E5
Save Register Pair HL (036BH) to the stack again.
6475
RET NZ C0
If the NZ FLAG is set (not the command loop), RETurn to 036BH, the ROM's own line input.
6476
LD HL,442BH 21 2B 44
Point Register Pair HL to 442BH, SFLAG$, the system flags.
6479
BIT 5,(HL) CB 6E
Test bit 5 of SFLAG$ at Register Pair HL: the NZ FLAG when a JCL job runs.
647B
RET NZ C0
If the NZ FLAG is set (JCL), RETurn to 036BH, the ROM's own line input.
647C
POP HL E1
Discard the return address 036BH (POP HL into Register Pair HL): the stack now holds 1A7EH.
647D
LD A,0EH 3E 0E
Load Register A with 0EH, the code that turns the cursor on.
647F
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
6482
GOSUB to 0049H, the ROM: wait for a key, returned in Register A.
6485
PUSH AF F5
Save Register Pair AF (Register A = the first key) to the stack.
6486
GOSUB to 5CA7H to clear bits 2-0 of KFLAG$ (429FH): ENTER, pause and BREAK.
6489
CP 5BH FE 5B
Compare Register A (the key) against 5BH, the up arrow.
648B
If the Z FLAG is set (up arrow), JUMP to 64B7H for the current line.
648D
CP 0AH FE 0A
Compare Register A (the key) against 0AH, the down arrow.
648F
If the Z FLAG is set (down arrow), JUMP to 64B7H for the current line.
6491
CP 2EH FE 2E
Compare Register A (the key) against 2EH, a period.
6493
If the Z FLAG is set (period), JUMP to 64B7H for the current line.
6495
CP 2CH FE 2C
Compare Register A (the key) against 2CH, a comma.
6497
If the Z FLAG is set (comma), JUMP to 64B7H for the current line.
6499
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
649C
CP 08H FE 08
Compare Register A (the key) against 08H, the left arrow.
649E
If the Z FLAG is set (left arrow), JUMP to 64F3H to show the first line, at Register Pair HL.
64A0
LD DE,FFFFH 11 FF FF
Load Register Pair DE with FFFFH, a line number past every line.
64A3
CP 09H FE 09
Compare Register A (the key) against 09H, the right arrow.
64A5
If the Z FLAG is set (right arrow), JUMP to 64BBH: no line FFFFH, so the last line.
64A7
POP AF F1
Restore Register Pair AF (Register A = the first key) from the stack.
64A8
PUSH BC C5
Save Register Pair BC to the stack, as the ROM's line input does at 036BH.
64A9
LD HL,652EH 21 2E 65
Point Register Pair HL to 652EH, where the line goes when it is complete.
64AC
PUSH HL E5
Save Register Pair HL (652EH) to the stack: the RETurn of the ROM's collector goes there.
64AD
LD HL,(40A7H) 2A A7 40
Load Register Pair HL with the line buffer's address from 40A7H-40A8H.
64B0
PUSH HL E5
Save Register Pair HL (the line buffer) to the stack, as 05D9H does.
64B1
LD B,F0H 06 F0
Load Register B with F0H, the longest line: 240 characters.
64B3
LD C,B 48
Copy Register B (F0H) into Register C, as 05DFH does.
64B4
JUMP to 05E3H, the ROM's line collector, with the first key in Register A.
64B7
LD DE,(40ECH) ED 5B EC 40
Load Register Pair DE with the current line's number from 40ECH-40EDH.
64BB
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.
64BE
POP DE D1
Load Register Pair DE with the first key from the stack (POP DE): Register D = the key.
64BF
PUSH DE D5
Save Register Pair DE (the first key) to the stack again.
64C0
LD A,D 7A
Copy Register D (the first key) into Register A; LD does not change the flags.
64C1
If the NO CARRY FLAG is set (the line was not found), JUMP to 64D7H.
64C3
CP 2EH FE 2E
Compare Register A (the key) against 2EH, a period.
64C5
If the Z FLAG is set (period), JUMP to 64F1H to show the line found.
64C7
CP 2CH FE 2C
Compare Register A (the key) against 2CH, a comma.
64C9
If the Z FLAG is set (comma), JUMP to 64F1H to edit the line found.
64CB
CP 0AH FE 0A
Compare Register A (the key) against 0AH, the down arrow.
64CD
If the NZ FLAG is set (the up arrow), JUMP to 64D9H for the line before.
64CF
LD A,(HL) 7E
Load Register A with the low byte of the next line's link at Register Pair HL.
64D0
INC HL 23
INCrement Register Pair HL to the high byte of the link.
64D1
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.
64D2
DEC HL 2B
DECrement Register Pair HL back to the next line.
64D3
If the NZ FLAG is set (there is a next line), JUMP to 64F3H to show it.
64D5
JUMP to 64F1H: the line found is the last, it is shown again.
64D7
If the Z FLAG is set (no higher line), JUMP to 64DDH for the last line of the program.
64D9
CP 5BH FE 5B
Compare Register A (the key) against 5BH, the up arrow.
64DB
If the NZ FLAG is set (not the up arrow), JUMP to 64F1H to show the line in Register Pair BC.
64DD
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the start of the program from 40A4H-40A5H.
64E0
AND A A7
Clear the CARRY FLAG (AND A); Register A is not changed.
64E1
SBC HL,BC ED 42
SUBtract Register Pair BC from Register Pair HL: the Z FLAG when Register Pair BC is the first line.
64E3
If the Z FLAG is set (no line before it), JUMP to 64F1H to show it.
64E5
ADD HL,BC 09
ADD Register Pair BC back: Register Pair HL = the start of the program again.
64E6
LD D,B 50
Copy Register B (the high byte of the line) into Register D.
64E7
LD E,C 59
Copy Register C into Register E: Register Pair DE = the line whose predecessor is wanted.
64E8
LD B,H 44
Copy Register H (the high byte of the line looked at) into Register B.
64E9
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the line being looked at.
64EA
LD A,(HL) 7E
Load Register A with the low byte of its link at Register Pair HL.
64EB
INC HL 23
INCrement Register Pair HL to the high byte of the link.
64EC
LD H,(HL) 66
Load Register H with the high byte of the link at Register Pair HL.
64ED
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the next line.
64EE
RST 18H DF
RST 18H: compare Register Pair HL (the next line) against Register Pair DE.
64EF
If the NZ FLAG is set (not yet), LOOP BACK to 64E8H: Register Pair BC ends at the line before.
64F1
LD H,B 60
Copy Register B (the high byte of the line to show) into Register H.
64F2
LD L,C 69
Copy Register C into Register L: Register Pair HL = the line to show.
64F3
LD A,0FH 3E 0F
Load Register A with 0FH, the code that turns the cursor off.
64F5
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
64F8
LD A,1DH 3E 1D
Load Register A with 1DH, the code that moves the cursor to the start of the line.
64FA
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
64FD
POP AF F1
Restore Register Pair AF (Register A = the first key) from the stack.
64FE
POP BC C1
Discard the return address 1A7EH (POP BC into Register Pair BC): the ROM's LIST and EDIT go to READY themselves.
64FF
LD B,H 44
Copy Register H (the high byte of the line to show) into Register B.
6500
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the line to show.
6501
INC HL 23
INCrement Register Pair HL past the low byte of the link.
6502
INC HL 23
INCrement Register Pair HL to the line's number.
6503
LD E,(HL) 5E
Load Register E with the low byte of the line number at Register Pair HL.
6504
INC HL 23
INCrement Register Pair HL to the high byte of the line number.
6505
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the line number.
6506
CP 2CH FE 2C
Compare Register A (the key) against 2CH, a comma.
6508
If the Z FLAG is set (comma), JUMP to 2E65H, the ROM's EDIT of line Register Pair DE at Register Pair BC.
650B
PUSH DE D5
Save Register Pair DE (the line number, the last to list) to the stack.
650C
PUSH BC C5
Save Register Pair BC (the line, the first to list) to the stack.
650D
LD HL,(4020H) 2A 20 40
Load Register Pair HL with the cursor's address from 4020H-4021H.
6510
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 40H: one line of 64 characters back.
6513
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the start of the line above.
6514
LD B,05H 06 05
Load Register B with 05H, the letters of READY.
6516
LD DE,1929H 11 29 19
Point Register Pair DE to 1929H, the ROM's READY message.
6519
LD A,(DE) 1A
Load Register A with a letter of READY at Register Pair DE.
651A
CP (HL) BE
Compare Register A against the character on the screen at Register Pair HL.
651B
If the NZ FLAG is set (they differ), JUMP to 6526H: the line above is not READY.
651D
INC DE 13
INCrement Register Pair DE to the next letter of READY.
651E
INC HL 23
INCrement Register Pair HL to the next character on the screen.
651F
DECrement Register B and LOOP BACK to 6519H for the 5 letters.
6521
LD A,1BH 3E 1B
Load Register A with 1BH, the code that moves the cursor up a line, onto READY.
6523
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
6526
LD A,1EH 3E 1E
Load Register A with 1EH, the code that erases to the end of the line.
6528
GOSUB to 0033H, the ROM: Register A (the character) is displayed.
652B
JUMP to 2B33H, the ROM's LIST, from the line on the stack to the line number under it: one line.

652EH - 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.

652E
PUSH AF F5
Save Register Pair AF (the CARRY FLAG of BREAK) to the stack.
652F
GOSUB to 5CA7H to clear bits 2-0 of KFLAG$ (429FH): ENTER, pause and BREAK.
6532
POP AF F1
Restore Register Pair AF (the CARRY FLAG of BREAK) from the stack.
6533
PUSH AF F5
Save Register Pair AF to the stack, as the ROM does at 0374H.
6534
If the CARRY FLAG is set (BREAK), JUMP to 657DH to give the line to the ROM.
6536
PUSH BC C5
Save Register Pair BC (Register B = the length) to the stack.
6537
LD A,(HL) 7E
Load Register A with the first character of the line at Register Pair HL.
6538
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter made upper case.
653A
PUSH HL E5
Save Register Pair HL (the line) to the stack.
653B
LD HL,657FH 21 7F 65
Point Register Pair HL to 657FH, the byte before the table of letters.
653E
INC HL 23
INCrement Register Pair HL to the next letter of the table.
653F
INC (HL) 34
INCrement the byte at Register Pair HL, with the DEC next to set the flags.
6540
DEC (HL) 35
DECrement the byte at Register Pair HL back: the Z FLAG at the 00H that ends the table.
6541
If the Z FLAG is set (no letter matched), JUMP to 657BH.
6543
CP (HL) BE
Compare Register A (the first character) against the letter at Register Pair HL.
6544
INC HL 23
INCrement Register Pair HL to the letter's code.
6545
If the NZ FLAG is set (another letter), LOOP BACK to 653EH.
6547
LD C,(HL) 4E
Load Register C with the letter's code at Register Pair HL.
6548
POP HL E1
Restore Register Pair HL (the line) from the stack.
6549
PUSH HL E5
Save Register Pair HL (the line) to the stack again.
654A
RST 10H D7
RST 10H (658DH): Register Pair HL to the character after the letter, Register A = it; CARRY for a digit.
654B
If the CARRY FLAG is set (a digit), JUMP to 6559H.
654D
CP 2EH FE 2E
Compare Register A against 2EH, a period: the current line.
654F
If the Z FLAG is set (a period), JUMP to 6559H.
6551
CP 0DH FE 0D
Compare Register A against 0DH: the letter alone.
6553
If the Z FLAG is set (the letter alone), JUMP to 6566H to change it.
6555
CP 2DH FE 2D
Compare Register A against 2DH, a minus sign: a range of lines.
6557
If the NZ FLAG is set (anything else), JUMP to 657BH: the line is left as typed.
6559
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character, Register A = it.
655A
CP 28H FE 28
Compare Register A against 28H, a left parenthesis.
655C
If the Z FLAG is set, JUMP to 657BH: the line is left as typed.
655E
CP 3DH FE 3D
Compare Register A against 3DH, an equal sign.
6560
If the Z FLAG is set, JUMP to 657BH: the line is left as typed.
6562
CP 0DH FE 0D
Compare Register A against 0DH, the end of the line.
6564
If the NZ FLAG is set (more), LOOP BACK to 6559H.
6566
POP HL E1
Restore Register Pair HL (the line) from the stack.
6567
LD (HL),C 71
Store Register C (the code) at Register Pair HL, over the letter.
6568
LD A,C 79
Copy Register C (the code from the table) into Register A.
6569
CP 07H FE 07
Compare Register A against 07H: NO CARRY for a token.
656B
If the NO CARRY FLAG is set (a token), JUMP to 657CH to give the line to the ROM.
656D
EX AF,AF' 08
Exchange Register Pair AF with Register Pair AF' to hold the function number (05H or 06H) in Register A' for 54DEH.
656E
POP BC C1
Restore Register Pair BC (Register B = the length) from the stack.
656F
POP AF F1
Discard the AF saved at 6533H (POP AF into Register Pair AF).
6570
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the line.
6571
LD L,B 68
Copy Register B (the length) into Register L.
6572
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the length.
6574
ADD HL,DE 19
ADD Register Pair DE (the line) to Register Pair HL: the byte after the line.
6575
LD (HL),00H 36 00
Store 00H at Register Pair HL: the end of the line.
6577
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the line.
6578
JUMP to 54DEH 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.
657B
POP HL E1
Restore Register Pair HL (the line) from the stack.
657C
POP BC C1
Restore Register Pair BC (Register B = the length) from the stack.
657D
JUMP to 0375H, the ROM's line input after its collector: the 00H is put after the line.
6580-658B
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
6580H-658BH: 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. 657FH before it is the high byte of the JP at 657DH.
658C
DEFB 00H 00
658CH: 00H, the end of the table of letters (6540H).

658DH - The RST 10H Code

4003H JUMPs here (the LDIR at 532EH 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.

658D
GOSUB to 1D78H, the ROM's RST 10H code: Register Pair HL to the next character, Register A = it.
6590
RET Z C8
If the Z FLAG is set (the end of a statement), RETurn to the caller.
6591
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX) for the test.
6592
POP HL E1
Load Register Pair HL with the caller's return address (POP HL).
6593
PUSH HL E5
Save Register Pair HL (the return address) to the stack again.
6594
PUSH AF F5
Save Register Pair AF (the character and the flags) to the stack.
6595
LD DE,1D5BH 11 5B 1D
Load Register Pair DE with 1D5BH, the return address of the RST 10H at 1D5AH, the statement fetch.
6598
AND A A7
Clear the CARRY FLAG (AND A); Register A is not changed.
6599
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL: the Z FLAG for the statement fetch.
659B
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the caller's registers back.
659C
If the NZ FLAG is set (another caller), JUMP to 6604H to RETurn the character.
659E
CP 83H FE 83
Compare Register A (the token) against 83H, SET.
65A0
If the NZ FLAG is set (not SET), JUMP to 65E4H.
65A2
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
65A3
RST 10H D7
RST 10H (658DH): Register Pair HL to the next character, Register A = it.
65A4
CP E9H FE E9
Compare Register A against E9H, the token EOF.
65A6
If the NZ FLAG is set (SET without EOF), JUMP to 6603H: the ROM's SET.
65A8
POP DE D1
Discard the text pointer saved at 65A2H (POP DE into Register Pair DE).
65A9
POP DE D1
Discard the character and flags saved at 6594H (POP DE into Register Pair DE).
65AA
RST 10H D7
RST 10H (658DH): Register Pair HL past EOF, Register A = the next character.
65AB
CP 23H FE 23
Compare Register A against 23H, #: it may come before the number.
65AD
If the Z FLAG is set (#), GOSUB to 1D78H, the ROM's RST 10H code: past the #.
65B0
GOSUB to 2B1CH, the ROM: the file number as a byte in Register A.
65B3
AND A A7
Set the flags from Register A (AND A): the Z FLAG for file 0.
65B4
If the Z FLAG is set (file 0), JUMP to 644CH, Bad file number (E = 68H).
65B7
GOSUB to 5D10H for file Register A: Register Pair BC = its buffer, Register A = its mode.
65BA
If the Z FLAG is set (the file is closed), JUMP to 644CH, Bad file number (E = 68H).
65BD
CP 03H FE 03
Compare Register A (the mode) against 03H, random.
65BF
If the NZ FLAG is set (not random), JUMP to 6449H, Bad file mode (E = 6CH).
65C2
LD D,B 50
Copy Register B (the high byte of the buffer) into Register D.
65C3
LD E,C 59
Copy Register C (the low byte) into Register E: Register Pair DE = the buffer.
65C4
INC DE 13
INCrement Register Pair DE toward the FCB inside the buffer.
65C5
INC DE 13
INCrement Register Pair DE again: the FCB, at buffer + 02H.
65C6
GOSUB to 4458H, @CKEOF: the Z FLAG when the place is inside the file.
65C9
If the NZ FLAG is set (at the end or past it), JUMP to 65E0H: nothing changes.
65CB
PUSH DE D5
Save Register Pair DE (the FCB) to the stack.
65CC
POP IX DD E1
Load Index Register IX with the FCB from the stack (POP IX).
65CE
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.
65D1
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.
65D4
LD A,(IX+05H) DD 7E 05
Load Register A with +05H of the FCB at Index Register IX: the place in the record.
65D7
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.
65DA
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.
65DD
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.
65E0
POP DE D1
Discard the return address 1D5BH (POP DE into Register Pair DE): SET EOF is done here.
65E1
JUMP to 1D1EH, the ROM's next statement, as the interpreter would.
65E4
CP 90H FE 90
Compare Register A (the token) against 90H, RESTORE.
65E6
If the NZ FLAG is set (not RESTORE), JUMP to 6604H to RETurn the character.
65E8
POP DE D1
Discard the saved character and flags (POP DE into Register Pair DE).
65E9
POP DE D1
Discard the return address 1D5BH (POP DE into Register Pair DE): RESTORE is done here.
65EA
LD DE,1D1EH 11 1E 1D
Load Register Pair DE with 1D1EH, the ROM's next statement.
65ED
PUSH DE D5
Save Register Pair DE (1D1EH) to the stack: the RETurns below go there.
65EE
RST 10H D7
RST 10H (658DH): Register Pair HL past RESTORE, Register A = the next character; the Z FLAG at the end.
65EF
If the Z FLAG is set (no line number), JUMP to 1D91H, the ROM's RESTORE: READ starts at the first DATA.
65F2
GOSUB to 1E5AH, the ROM: the line number at Register Pair HL in Register Pair DE.
65F5
PUSH HL E5
Save Register Pair HL (the text pointer) to the stack.
65F6
GOSUB to 1B2CH, the ROM: find line Register Pair DE; CARRY when found, Register Pair BC = the line.
65F9
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
65FA
If the NO CARRY FLAG is set (no such line), JUMP to 1ED9H, the ROM's Undefined line.
65FD
DEC BC 0B
DECrement Register Pair BC to the byte before the line.
65FE
LD (40FFH),BC ED 43 FF 40
Store Register Pair BC at 40FFH-4100H, the place READ goes on from.
6602
RET C9
RETurn to 1D1EH, the ROM's next statement, with READ set to line n.
6603
POP HL E1
Restore Register Pair HL (the text pointer at SET) from the stack.
6604
POP AF F1
Restore Register Pair AF (the character and the flags) from the stack.
6605
RET C9
RETurn to the caller with Register A and the flags from the ROM's RST 10H code.

6606H - 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 6646H (53B7H, 53F7H).

6606
DEFB 00H 00
6606H: a byte of 00H; file 0's slot points here while the ROM clears (5CD0H, 5ECBH), so file 0 reads as closed.
6607
DEFB 00H 00
6607H: the record length of the file in FIELD (stored at 60A3H, read at 60CEH).
6608
DEFB 00H 00
6608H: 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 5A67H, 5C36H, 5F61H and 5FBEH.
6609
DEFB 00H 00
6609H: the number of files set aside (408EH), kept across the ROM's NEW and RUN set up (5E9DH, 5EE4H, 5FB0H, 5FB8H).
660A
DEFB 00H 00
660AH: 00H for GET, else PUT (stored at 621AH, read at 6260H and 626FH).
660B
DEFB 00H 00
660BH: the last LDOS error, stored by BASIC/OV3 function 02H and read by CMD"E" at 586EH.
660C-660D
DEFW 0000H 00 00
660CH-660DH: the buffer of the current file, 0000H for none: set by 5CDAH, 5CFEH, 5EF0H and 6387H, cleared by 589FH as a PRINT ends.
660E-660F
DEFW 0000H 00 00
660EH-660FH: file 0's slot in the table of the buffers' addresses (53FBH); the slots of files 1-15 follow beyond the file.
6610-662D
DEFS 30
6610H-662DH: not in the file. The slots of files 1-15 in the table of the buffers' addresses, built at 540DH and read by 5D1BH.
662E-662F
DEFS 2
662EH-662FH: not in the file. The address of buffer 0 (6646H, 540AH), put back in file 0's slot at 5CDDH and 5EEAH and read by KILL through the slot.
6630-6643
DEFS 20
6630H-6643H: not in the file. The ten USR vectors, 6443H (Undefined user function) until DEF USR sets one (53BAH, 574FH).
6644
DEFS 1
6644H: not in the file. The RUN flag: FFH while RUN opens its program (5E88H), cleared at 53C8H, 63DFH and 6403H.
6645
DEFS 1
6645H: not in the file. The protection flag: FFH for a program that may run but not be looked at (63E8H); 6401H clears memory when it is set.