TRS-80 DOS - VTOS 4.0.2 for the Model I - SYS1/SYS Disassembled

Page Customization

Introduction/Summary

VTOS 4.0.2 SYS1/SYS Disassembly - The Command Interpreter (Model I)

SYS1/SYS is the system overlay of the command level. It is loaded at 4E00H, over the reset code of SYS0/SYS (which runs only once at the boot), by the request handler of SYS0/SYS (4C31H) whenever a program asks for a request code whose bits 3-0 are 3 (directory entry code 03H), and stays there until another overlay is loaded in its place. It displays VTOS READY, reads the command line, runs the commands of the library SYS6/SYS and the program files, and gives every program three services: reading a file specification, supplying a default extension and reading a parameter list.

The file starts with a record of type 05H (the name SYS1), a record of type 1FH holding the copyright notice of Randolph Cook (1980), and five load blocks that fill 4E00H-51FFH. A record of type 07H then names the patch SYS1A, and a sixth load block puts its 23 bytes at 5185H-519BH, over the first blocks; the page shows the bytes as they are after it. The last record gives the transfer address 4E00H. The distributor's manual gives the patch as the work of Timothy P. Mann (12/12/80): it lets the parameter reader take small letters in the values ON, OFF, YES and NO.

The Functions

The request handler enters 4E00H with Register A = the request code; bits 6-4 choose the function. Registers BC, DE and HL hold the caller's values.

CodeFunction
83HFunction 0: returns at once.
93HFunction 1, the normal exit (402DH, 4400H): VTOS READY and the next command (4E38H).
A3HFunction 2, the abort exit (4030H): the same as 93H.
B3HFunction 3 (4405H): execute the command line at Register Pair HL, copied to 4318H first (4E20H). The boot's AUTO command, BASIC/CMD and SYS7/SYS use it.
C3HFunction 4 (441CH): read a file or device specification from the text at Register Pair HL into the control block at Register Pair DE (4FCEH).
D3HFunction 5 (4473H): put the extension at Register Pair HL into the specification at Register Pair DE when it has none (5042H).
E3HFunction 6 (4476H): read a parameter list from the text at Register Pair HL against the table at Register Pair DE (510FH).
F3HFunction 7: interpret the command line at Register Pair HL where it is (4E5CH). Nothing on this diskette uses it.

A Command Line

A line that starts with a period is a comment: it has been written to the job log when it was typed, and nothing else happens. A line that starts with an exclamation mark runs CHAIN on the rest of the line. Otherwise the first word is read as a file specification into the control block at 4480H and looked up in the command table (4EA5H). A word found there runs that member of SYS6/SYS through request 88H, with Register B = the member and Register Pair HL on the rest of the line; any other word is the name of a program file, which gets the extension CMD when it has none and is loaded and run through 4433H. Either way the address 402DH has been pushed, so a command or program that ends with RET returns to VTOS READY. A line that cannot be read, a device specification in place of a command and BREAK at the prompt all give WHAT?.

A file specification, as 4FCEH copies it into a control block: a name of 1-8 letters and digits, then /extension (up to 3), .password (1-8), :drive (1) and an exclamation mark, each when it is there, ended by 03H; or an asterisk and a device name of 1 or 2 characters. Small letters become capital letters; characters past the most a field may have are passed over. The words TO, ON, OVER and USING are passed over between specifications.

A parameter list (510FH) is in parentheses, entries parted by commas. The caller's table has entries of 8 bytes: a name of 6 characters padded with spaces and the address of the word that receives the value.

EntryValue stored
NAMEFFFFH
NAME=nnnThe decimal number
NAME=X'hhhh'The hexadecimal number
NAME="text"The address of the text in the line; its closing quote is replaced by 0DH
NAME=ON, YES, YFFFFH
NAME=OFF, NO, N0000H

The Commands

The table at 4EADH lists 36 commands, and with them the member of SYS6/SYS each one runs: ALLOC 13H, APPEND 31H, ATTRIB 51H, AUTO 11H, BUILD 33H, CHAIN 91H, CLOCK 17H, COPY 32H, DATE 15H, DEBUG 14H, DEVICE 61H, DIR 21H, DUMP 71H, FILTER 66H, FREE 22H, KILL 18H, LIB 19H, LINK 62H, LIST 41H, LOAD 81H, MEMORY 1EH, PRINT 42H, PROT 52H, PURGE 72H, RENAME 53H, RESET 63H, ROUTE 64H, RUN 82H, SET 65H, SPOOL A2H, SYSTEM A1H, TIME 16H, TRACE 1AH, VERIFY 1BH, XFER 73H. BOOT is the one command SYS1/SYS carries out itself: its word is the address 4EA9H, a HALT, which restarts the Model I as the reset button does. The first entry, matched only by the word O!, runs member 1DH (4EA5H).

Points to Note

The first entry of the command table (4EA5H) has the name O, an exclamation mark, a space, @ and two other bytes, and the word 801DH. The command word O! matches it and runs member 1DH of SYS6/SYS, which no other entry names. Its fifth byte is the HALT of BOOT; on the Model I a HALT raises the same non maskable interrupt as the reset button, and the ROM boots the system again.

The table search (50BCH) compares at most 6 characters and takes a word as ended at any character other than a letter or digit. A word longer than 6 characters that starts with a command's name runs that command; a program file whose name is the name of a command, given with its extension or drive (DIR/CMD), runs the library command, not the program. In the same way a file specification whose name is TO, ON, OVER or USING is taken for the preposition and passed over, extension and all (5007H).

After an exclamation mark in a file specification one more character of the line is passed over (4FFDH).

The flag reader (5181H) takes any value that starts with O and does not go on with F as ON, and passes over the rest of the value up to a comma or a closing parenthesis with no test for the end of the line (51A4H). The hexadecimal reader (51C0H) takes the characters from the colon to @ as the digits 3-9 and does not need the closing quote.

A comment line typed while bit 5 of 430FH is clear reads the next line with the return address 402DH still on the stack (4E93H); the stack is set again at the next VTOS READY.

Memory Map

Load Areas

Addresses
Size
Contents
4E00H-4EA4H
165 bytes
Dispatcher and Command Level
The seven functions, VTOS READY, the command line interpreter and the run of a command.
4EA5H-4FCDH
297 bytes
Command Table
Entry 1 (with the BOOT HALT at 4EA9H), the 36 commands and the 00H that ends the table.
4FCEH-5020H
83 bytes
File Specification
Function 4: a file or device specification into a control block.
5021H-5041H
33 bytes
Prepositions
TO, ON, OVER, USING and the 00H that ends the table.
5042H-50BBH
122 bytes
Default Extension and Fields
Function 5 and the routine that copies a field of letters and digits.
50BCH-510DH
82 bytes
Table Search
The search of a table of 6 character names.
510EH-51EAH
221 bytes
Parameter List
Function 6 and its readers of flags, decimal and hexadecimal numbers (5185H-519BH: the patch SYS1A).
51EBH-51FFH
21 bytes
Texts
CMD, VTOS READY and WHAT?.

Variables

Memory Outside the File

Address
Size
Contents
4200H-4206H
7 bytes
Parameter Name
The sector buffer of SYS0/SYS: 510FH copies the name of each parameter here (6 characters and 03H) to look it up.
4315H
1 byte
BREAK Vector Byte
C9H while a command runs (4E99H) and at the prompt; C3H at the prompt when DEBUG is set (4E44H), so that BREAK jumps to the address at 4316H-4317H.
430FH
1 byte
System Flags
Read only: bit 7 (DEBUG starts programs) at 4E3CH, bit 5 (set while SYS7/SYS runs) at 4E8EH.
4318H-4357H
64 bytes
Command Line Buffer
The line typed at VTOS READY (4E4FH-4E54H) or copied by function 3 (4E20H-4E2BH), 63 characters and 0DH or 03H.
4480H-449FH
32 bytes
Command File Control Block
The command word as a file specification (4E6EH-4E71H), with /CMD added for a program (4E87H); 4433H loads the program from it.

Data in the File

Address
Size
Contents
4EA5H-4FCDH
297 bytes
Command Table
8 bytes an entry: 6 characters of name, a word (80H and the member of SYS6/SYS, or an address).
5021H-5041H
33 bytes
Preposition Table
The same format, words 0000H.
51EBH-51EDH
3 bytes
Default Extension
CMD.
51EEH-51F9H
12 bytes
Prompt
0AH, VTOS READY, 0DH.
51FAH-51FFH
6 bytes
Error Message
WHAT? and 0DH.

Operands Changed While Running

Address
Size
Contents
50B8H
1 byte
Empty Field Flag
Operand of LD A,00H at 50B7H: the field's maximum while nothing is copied (5079H), 00H after the first character (50AAH).

Outside Routines

AddressContents
0040HROM: read a line from the keyboard into Register Pair HL, at most Register B characters, ended by 0DH; the CARRY FLAG set for BREAK (4E54H).
402DHSYS0/SYS: the normal exit, request 93H (pushed at 4E5FH).
4030HSYS0/SYS: the abort exit, request A3H (4E35H).
4433HSYS0/SYS: load and run the program named by the control block at Register Pair DE (4E8BH).
4467HSYS0/SYS: display the text at Register Pair HL (4E4CH).
447BHSYS0/SYS: display the text at Register Pair HL and write it to the job log (4E32H).
447EHSYS0/SYS: write the text at Register Pair HL to the job log (4E59H).
RST 28HSYS0/SYS: request 88H runs member Register B of SYS6/SYS (4EA4H).

Disassembly

4E00H - Request Dispatcher

SYS1/SYS is loaded at 4E00H by the request handler of SYS0/SYS (4C31H) for every request code whose bits 3-0 are 3, and entered here with Register A = the request code (the handler fetches it from 430EH, 4C45H). Bits 6-4 of the code choose one of seven functions: 1 (93H) and 2 (A3H) VTOS READY, 3 (B3H) execute a command line, 4 (C3H) a file specification, 5 (D3H) a default extension, 6 (E3H) a parameter list, 7 (F3H) interpret a command line already in memory. Function 0 (83H) returns at once. Registers BC, DE and HL hold the caller's values (the handler restores them before the call).

4E00
AND 70H E6 70
Mask Register A (the request code) to bits 6-4, the function number times 10H: 93H gives 10H, A3H 20H, B3H 30H, C3H 40H, D3H 50H, E3H 60H, F3H 70H, 83H 00H.
4E02
CP 10H FE 10
Compare Register A (the function bits) against 10H, function 1, request 93H: the normal exit of a program (402DH, 4400H).
4E04
If the Z FLAG is set (request 93H), JUMP to 4E38H to display VTOS READY and take a command.
4E06
CP 20H FE 20
Compare Register A (the function bits) against 20H, function 2, request A3H: the abort exit (4030H), used after an error.
4E08
If the Z FLAG is set (request A3H), JUMP to 4E38H as well: the abort exit and the normal exit end in the same prompt.
4E0A
CP 40H FE 40
Compare Register A (the function bits) against 40H, function 4, request C3H (441CH): read a file specification.
4E0C
If the Z FLAG is set (request C3H), JUMP to 4FCEH with Register Pair HL = the text and Register Pair DE = the file control block to fill.
4E0F
CP 50H FE 50
Compare Register A (the function bits) against 50H, function 5, request D3H (4473H): supply a default extension.
4E11
If the Z FLAG is set (request D3H), JUMP to 5042H with Register Pair DE = the file control block and Register Pair HL = the three letters of the extension.
4E14
CP 60H FE 60
Compare Register A (the function bits) against 60H, function 6, request E3H (4476H): read a parameter list.
4E16
If the Z FLAG is set (request E3H), JUMP to 510FH with Register Pair HL = the text and Register Pair DE = the caller's parameter table.
4E19
CP 70H FE 70
Compare Register A (the function bits) against 70H, function 7, request F3H: interpret the command line at Register Pair HL. No file on this diskette uses this code.
4E1B
If the Z FLAG is set (request F3H), JUMP to 4E5CH, which interprets the line at Register Pair HL as it stands: it is neither copied nor written to the job log.
4E1D
CP 30H FE 30
Compare Register A (the function bits) against 30H, function 3, request B3H (4405H): execute a command line.
4E1F
RET NZ C0
If the NZ FLAG is set (function 0, request 83H, the only one left), RETURN to the request handler at once with Register A = 00H: nothing is done.

4E20H - Function 3 (B3H): Execute a Command Line

Reached through 4405H. The text at Register Pair HL is copied into the command line buffer at 4318H-4357H (63 characters, then 03H) and interpreted from there as if it had been typed. The boot runs its AUTO command this way (SYS0/SYS 500BH); BASIC/CMD (its 66E3H, 66FDH) and SYS7/SYS (its 4E4FH, 4E89H) use it too.

4E20
LD DE,4318H 11 18 43
Point Register Pair DE to 4318H, the command line buffer (64 bytes, 4318H-4357H), the destination of the copy.
4E23
PUSH DE D5
Save Register Pair DE (4318H) to the stack: the line is interpreted from the buffer once it is there (4E2CH).
4E24
LD BC,003FH 01 3F 00
Load Register Pair BC with 003FH: 63 bytes are copied, the length of the longest line the keyboard input at 4E52H takes.
4E27
LDIR ED B0
Copy 63 bytes from the caller's text at Register Pair HL to the buffer at Register Pair DE (4318H) with LDIR. Register Pair DE ends at 4357H, the last byte of the buffer; Register Pair BC ends at 0000H.
4E29
LD A,03H 3E 03
Load Register A with 03H, an end of text, so that a line of 63 characters with no 0DH still ends inside the buffer.
4E2B
LD (DE),A 12
Store Register A (03H) to 4357H, the last byte of the buffer, at Register Pair DE.
4E2C
POP HL E1
Restore Register Pair HL from the stack: 4318H, the start of the copied line.
4E2D
JUMP to 4E59H to write the line at Register Pair HL (4318H) to the job log and interpret it.

4E2FH - The WHAT? Message

Every command line that cannot be interpreted comes here: a bad file specification, a device specification in place of a command, BREAK at the prompt. WHAT? is displayed and written to the job log, and the abort exit comes back to this overlay, still in memory, for the next command.

4E2F
LD HL,51FAH 21 FA 51
Point Register Pair HL to 51FAH, the text WHAT? followed by 0DH.
4E32
GOSUB to 447BH (SYS0/SYS), which displays the text at Register Pair HL (51FAH) and writes it to the job log JL when JL is not NIL.
4E35
JUMP to 4030H (SYS0/SYS), the abort exit: request A3H. The request handler finds SYS1/SYS still in memory (430EH bits 3-0 = 3, its 4C5EH-4C6BH), reads nothing and enters it at 4E00H, which goes to 4E38H and sets a fresh stack.

4E38H - Functions 1 and 2 (93H, A3H): VTOS READY

The command level. Every program ends here, through 402DH (normal) or 4030H (abort). The stack is set again, the BREAK vector 4315H is made live only when bit 7 of the system flags (DEBUG) is set, VTOS READY is displayed and a line of up to 63 characters is read from the keyboard into 4318H.

4E38
LD SP,41E0H 31 E0 41
Load the Stack Pointer with 41E0H, the stack the boot uses (SYS0/SYS 4E03H): whatever the program left on the stack is dropped.
4E3B
EI FB
Enable interrupts (EI): the clock and the tasks run while the line is typed.
4E3C
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A. Bit 7 is set when DEBUG is to start programs (SYS0/SYS 4CDEH).
4E3F
RLCA 07
Rotate Register A (the system flags) left: bit 7 goes into the CARRY FLAG.
4E40
LD A,C9H 3E C9
Load Register A with C9H, the value of the BREAK vector byte that leaves BREAK alone. LD does not change the flags.
4E42
If the NC FLAG is set (bit 7 of 430FH clear, no DEBUG), JUMP to 4E46H to store C9H.
4E44
LD A,C3H 3E C3
Load Register A with C3H (the opcode JP): with DEBUG set, BREAK under interrupt jumps to the address at 4316H-4317H (SYS0/SYS 4568H-4577H).
4E46
LD (4315H),A 32 15 43
Store Register A (C9H, or C3H with DEBUG) to 4315H, the BREAK vector byte.
4E49
LD HL,51EEH 21 EE 51
Point Register Pair HL to 51EEH, the text: 0AH (a new line), VTOS READY and 0DH.
4E4C
GOSUB to 4467H (SYS0/SYS 44DDH), which displays the text at Register Pair HL (51EEH) on the DO device.
4E4F
LD HL,4318H 21 18 43
Point Register Pair HL to 4318H, the command line buffer. A comment line (4E93H) comes back here to read the next line without the prompt.
4E52
LD B,3FH 06 3F
Load Register B with 3FH: at most 63 characters may be typed.
4E54
GOSUB to the ROM's line input at 0040H: the characters typed go into the buffer at Register Pair HL (4318H), ended by 0DH, with Register B the most that may be typed. It returns with the CARRY FLAG set when BREAK was pressed, Register Pair HL = 4318H again, Register B = the number of characters typed.
4E57
If the C FLAG is set (BREAK), JUMP to 4E2FH to display WHAT? and start again.
4E59
GOSUB to 447EH (SYS0/SYS), which writes the line at Register Pair HL (4318H) to the job log with the time in front, when JL is not NIL. Register Pair HL comes back unchanged.

4E5CH - Interpret a Command Line

Also function 7 (F3H). Register Pair HL = the line. 402DH, the normal exit, is pushed as the return address of whatever the command runs, so that a program or library command that ends with RET comes back to VTOS READY. A line that starts with a period is a comment; one that starts with ! is CHAIN (the manual: a bang). Otherwise the first word is read as a file specification into 4480H: a word in the command table runs a member of SYS6/SYS (or the BOOT code), any other word is a program file, with the extension CMD when it has none.

4E5C
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, the normal exit of SYS0/SYS (request 93H, VTOS READY).
4E5F
PUSH BC C5
Save Register Pair BC (402DH) to the stack: the return address of the command.
4E60
LD A,(HL) 7E
Fetch the first character of the line from Register Pair HL into Register A.
4E61
CP 2EH FE 2E
Compare Register A (the first character) against 2EH, a period: the line is a comment.
4E63
If the Z FLAG is set (a period), JUMP to 4E8EH. A comment typed at the prompt or given to function 3 has been written to the job log already (4E59H); one given to function 7 is not logged.
4E65
CP 21H FE 21
Compare Register A (the first character) against 21H, an exclamation mark: the short form of CHAIN.
4E67
LD DE,8091H 11 91 80
Load Register Pair DE with 8091H, the table word of CHAIN (4EE3H-4EE4H): Register D = 80H marks a member of SYS6/SYS, Register E = 91H is the member. LD does not change the flags.
4E6A
INC HL 23
Increment Register Pair HL past the first character. INC of a register pair does not change the flags.
4E6B
If the Z FLAG is set (the line starts with an exclamation mark), JUMP to 4E97H to run CHAIN (Register Pair DE = 8091H) with Register Pair HL on the character after it.
4E6D
DEC HL 2B
Decrement Register Pair HL back to the first character of the line.
4E6E
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, the file control block SYS1/SYS uses for the command word (SYS0/SYS keeps it free at 4480H-449FH).
4E71
GOSUB to 4FCEH to read the first word of the line at Register Pair HL as a file specification into 4480H (Register Pair DE). It returns with the Z FLAG set when the specification is good, Register Pair HL past it and Register Pair DE = 4480H.
4E74
If the NZ FLAG is set (no valid specification), JUMP to 4E2FH to display WHAT?.
4E76
LD A,(DE) 1A
Fetch the first byte of the specification from Register Pair DE (4480H) into Register A.
4E77
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk of a device specification (such as the two letters DO after it): a device is not a command.
4E79
If the Z FLAG is set (a device specification), JUMP to 4E2FH to display WHAT?.
4E7B
PUSH HL E5
Save Register Pair HL (the line after the command word) to the stack: the command or the program reads its parameters from there.
4E7C
LD BC,4EA5H 01 A5 4E
Point Register Pair BC to 4EA5H, the command table (8 bytes an entry, ended by 00H at 4FCDH).
4E7F
GOSUB to 50BCH to look up the command word at Register Pair DE (4480H) in the table at Register Pair BC. It returns with the Z FLAG set and Register Pair DE = the entry's word when it is found.
4E82
If the Z FLAG is set (a command of the table), JUMP to 4E96H to run it.
4E84
LD HL,51EBH 21 EB 51
Point Register Pair HL to 51EBH, the letters CMD: the default extension of a program file.
4E87
GOSUB to 5042H, which puts /CMD into the specification at Register Pair DE (4480H) when it has no extension.
4E8A
POP HL E1
Restore Register Pair HL from the stack: the line after the command word, for the program.
4E8B
JUMP to 4433H (SYS0/SYS 4CCBH) to load the program named by the file control block at Register Pair DE (4480H) and run it, with Register Pair HL on the rest of the line. A load error goes to the error message; a program that ends with RET returns to 402DH (pushed at 4E5FH).

4E8EH - A Comment Line

The line starts with a period. When bit 5 of the system flags is clear the next line is read at once, without VTOS READY; when it is set, the return address 402DH is taken, which displays VTOS READY again.

4E8E
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A.
4E91
BIT 5,A CB 6F
Test bit 5 of Register A (the system flags), the bit that SYS7/SYS keeps set while it runs (the job control of CHAIN).
4E93
If the Z FLAG is set (bit 5 clear), JUMP to 4E4FH to read the next line into 4318H. The return address 402DH pushed at 4E5FH stays on the stack; 4E38H sets the Stack Pointer again later.
4E95
RET C9
RETURN to 402DH, pushed at 4E5FH: request 93H and VTOS READY.

4E96H - Run a Command of the Table

Register Pair DE = the word of the entry found (or 8091H for !). Bit 7 of Register D set: Register E names a member of SYS6/SYS, which request 88H loads and runs with Register Pair HL on the rest of the line. Bit 7 clear: Register Pair DE is the address of code to jump to (BOOT, 4EA9H).

4E96
POP HL E1
Restore Register Pair HL from the stack: the line after the command word, pushed at 4E7BH.
4E97
LD A,C9H 3E C9
Load Register A with C9H, the BREAK vector byte that leaves BREAK alone.
4E99
LD (4315H),A 32 15 43
Store Register A (C9H) to 4315H, the BREAK vector byte: BREAK does not jump anywhere while the command runs.
4E9C
LD A,D 7A
Copy Register D (the high byte of the entry's word) into Register A.
4E9D
RLCA 07
Rotate Register A left: bit 7 of Register D goes into the CARRY FLAG.
4E9E
PUSH DE D5
Save Register Pair DE (the entry's word) to the stack.
4E9F
RET NC D0
If the NC FLAG is set (bit 7 of Register D clear), RETURN, which jumps to the address in Register Pair DE just pushed: the BOOT entry's 4EA9H.
4EA0
POP DE D1
Restore Register Pair DE (the entry's word) from the stack.
4EA1
LD B,E 43
Copy Register E (the member) into Register B: the member of SYS6/SYS request 88H loads (SYS0/SYS 4C55H).
4EA2
LD A,88H 3E 88
Load Register A with 88H, the request code of SYS6/SYS (bits 3-0 = 8), the library of the commands.
4EA4
RST 28H EF
RESTART 28H with Register A = 88H and Register B = the member: SYS0/SYS loads that member of SYS6/SYS and runs it with Register Pair HL on the rest of the line. The return address of RST 28H is dropped by the handler, so the member returns to 402DH (pushed at 4E5FH).

4EA5H - The Command Table: Entry 1 and the BOOT Code

Each entry is 8 bytes: a name of 6 characters (padded with spaces) and a word. A word with bit 15 set names the member of SYS6/SYS in its low byte; a word with bit 15 clear is an address. 50BCH searches it from here. The first entry's name is the bytes 4FH 21H 20H 40H 76H C3H and its word 801DH. It is matched by one command word only, O! (an O followed at once by an exclamation mark, which 4FCEH keeps in the specification, 4FF7H-4FFCH): 50E2H finds the exclamation marks equal, the word ends at 03H where the name has a space, and member 1DH of SYS6/SYS runs, a member no other entry names. Its fifth byte, 76H at 4EA9H, is the HALT that the BOOT entry jumps to.

4EA5-4EA8
DEFM "O! @" 4F 21 20 40
Entry 1, the first four bytes of its name: O, an exclamation mark, a space and @. The command word O! matches it (the third byte, a space, is where that word ends); any other word that starts with O differs at its second character.
4EA9
HALT 76
HALT. The BOOT entry (word 4EA9H at 4ED3H-4ED4H) jumps here from 4E9FH. On the Model I a HALT raises the same non maskable interrupt as the reset button, and the ROM's handler at 0066H boots the system again from drive 0, so the bytes after it are never run: the manual says BOOT has the same effect as the reset button. The byte is also the fifth character of entry 1's name.
4EAA-4EAC
DEFB C3H,1DH,80H C3 1D 80
The sixth character of entry 1's name (C3H) and its word, 801DH: member 1DH of SYS6/SYS, run by the command word O! (4EA5H). Nothing runs these bytes as code: the HALT before them restarts the system.

4EADH - The Library Commands

The commands of the library SYS6/SYS, in alphabetical order, 8 bytes each: the name padded with spaces to 6 characters, then the word: 80H in the high byte and the member of SYS6/SYS in the low byte, except BOOT, whose word is the address 4EA9H. 50BCH compares at most 6 characters, so a longer word that starts with a full name (SYSTEMS, say) runs that command too. The manual describes each command.

4EAD-4EB4
DEFM "ALLOC " / DEFW 8013H 41 4C 4C 4F 43 20 13 80
Entry 2: ALLOC, member 13H of SYS6/SYS (allocate space to a file).
4EB5-4EBC
DEFM "APPEND" / DEFW 8031H 41 50 50 45 4E 44 31 80
Entry 3: APPEND, member 31H of SYS6/SYS (append one file or device to another).
4EBD-4EC4
DEFM "ATTRIB" / DEFW 8051H 41 54 54 52 49 42 51 80
Entry 4: ATTRIB, member 51H of SYS6/SYS (passwords and protection of a file).
4EC5-4ECC
DEFM "AUTO " / DEFW 8011H 41 55 54 4F 20 20 11 80
Entry 5: AUTO, member 11H of SYS6/SYS (the command line the boot runs).
4ECD-4ED4
DEFM "BOOT " / DEFW 4EA9H 42 4F 4F 54 20 20 A9 4E
Entry 6: BOOT. Bit 15 of the word is clear: 4E9FH jumps to the address 4EA9H, the HALT.
4ED5-4EDC
DEFM "BUILD " / DEFW 8033H 42 55 49 4C 44 20 33 80
Entry 7: BUILD, member 33H of SYS6/SYS (write keyboard lines to a file).
4EDD-4EE4
DEFM "CHAIN " / DEFW 8091H 43 48 41 49 4E 20 91 80
Entry 8: CHAIN, member 91H of SYS6/SYS (run a file of commands). The same word is loaded at 4E67H for a line that starts with an exclamation mark.
4EE5-4EEC
DEFM "CLOCK " / DEFW 8017H 43 4C 4F 43 4B 20 17 80
Entry 9: CLOCK, member 17H of SYS6/SYS (the time on the display).
4EED-4EF4
DEFM "COPY " / DEFW 8032H 43 4F 50 59 20 20 32 80
Entry 10: COPY, member 32H of SYS6/SYS (copy a file or device).
4EF5-4EFC
DEFM "DATE " / DEFW 8015H 44 41 54 45 20 20 15 80
Entry 11: DATE, member 15H of SYS6/SYS (set or show the date).
4EFD-4F04
DEFM "DEBUG " / DEFW 8014H 44 45 42 55 47 20 14 80
Entry 12: DEBUG, member 14H of SYS6/SYS (the DEBUG monitor on or off).
4F05-4F0C
DEFM "DEVICE" / DEFW 8061H 44 45 56 49 43 45 61 80
Entry 13: DEVICE, member 61H of SYS6/SYS (show the devices and the drives).
4F0D-4F14
DEFM "DIR " / DEFW 8021H 44 49 52 20 20 20 21 80
Entry 14: DIR, member 21H of SYS6/SYS (the directory of a diskette).
4F15-4F1C
DEFM "DUMP " / DEFW 8071H 44 55 4D 50 20 20 71 80
Entry 15: DUMP, member 71H of SYS6/SYS (write memory to a file).
4F1D-4F24
DEFM "FILTER" / DEFW 8066H 46 49 4C 54 45 52 66 80
Entry 16: FILTER, member 66H of SYS6/SYS (put a filter on a device).
4F25-4F2C
DEFM "FREE " / DEFW 8022H 46 52 45 45 20 20 22 80
Entry 17: FREE, member 22H of SYS6/SYS (free space of the diskettes).
4F2D-4F34
DEFM "KILL " / DEFW 8018H 4B 49 4C 4C 20 20 18 80
Entry 18: KILL, member 18H of SYS6/SYS (remove a file or a device).
4F35-4F3C
DEFM "LIB " / DEFW 8019H 4C 49 42 20 20 20 19 80
Entry 19: LIB, member 19H of SYS6/SYS (list the library commands).
4F3D-4F44
DEFM "LINK " / DEFW 8062H 4C 49 4E 4B 20 20 62 80
Entry 20: LINK, member 62H of SYS6/SYS (link two devices).
4F45-4F4C
DEFM "LIST " / DEFW 8041H 4C 49 53 54 20 20 41 80
Entry 21: LIST, member 41H of SYS6/SYS (display a file).
4F4D-4F54
DEFM "LOAD " / DEFW 8081H 4C 4F 41 44 20 20 81 80
Entry 22: LOAD, member 81H of SYS6/SYS (load a program file without running it).
4F55-4F5C
DEFM "MEMORY" / DEFW 801EH 4D 45 4D 4F 52 59 1E 80
Entry 23: MEMORY, member 1EH of SYS6/SYS (the top of memory).
4F5D-4F64
DEFM "PRINT " / DEFW 8042H 50 52 49 4E 54 20 42 80
Entry 24: PRINT, member 42H of SYS6/SYS (print a file).
4F65-4F6C
DEFM "PROT " / DEFW 8052H 50 52 4F 54 20 20 52 80
Entry 25: PROT, member 52H of SYS6/SYS (protection of a whole diskette).
4F6D-4F74
DEFM "PURGE " / DEFW 8072H 50 55 52 47 45 20 72 80
Entry 26: PURGE, member 72H of SYS6/SYS (remove files one by one).
4F75-4F7C
DEFM "RENAME" / DEFW 8053H 52 45 4E 41 4D 45 53 80
Entry 27: RENAME, member 53H of SYS6/SYS (rename a file).
4F7D-4F84
DEFM "RESET " / DEFW 8063H 52 45 53 45 54 20 63 80
Entry 28: RESET, member 63H of SYS6/SYS (put a device back as it was).
4F85-4F8C
DEFM "ROUTE " / DEFW 8064H 52 4F 55 54 45 20 64 80
Entry 29: ROUTE, member 64H of SYS6/SYS (send a device to another device or a file).
4F8D-4F94
DEFM "RUN " / DEFW 8082H 52 55 4E 20 20 20 82 80
Entry 30: RUN, member 82H of SYS6/SYS (load and run a program file).
4F95-4F9C
DEFM "SET " / DEFW 8065H 53 45 54 20 20 20 65 80
Entry 31: SET, member 65H of SYS6/SYS (give a device a driver).
4F9D-4FA4
DEFM "SPOOL " / DEFW 80A2H 53 50 4F 4F 4C 20 A2 80
Entry 32: SPOOL, member A2H of SYS6/SYS (the printer spooler).
4FA5-4FAC
DEFM "SYSTEM" / DEFW 80A1H 53 59 53 54 45 4D A1 80
Entry 33: SYSTEM, member A1H of SYS6/SYS (the system options and SYSGEN).
4FAD-4FB4
DEFM "TIME " / DEFW 8016H 54 49 4D 45 20 20 16 80
Entry 34: TIME, member 16H of SYS6/SYS (set or show the time).
4FB5-4FBC
DEFM "TRACE " / DEFW 801AH 54 52 41 43 45 20 1A 80
Entry 35: TRACE, member 1AH of SYS6/SYS (the program counter on the display).
4FBD-4FC4
DEFM "VERIFY" / DEFW 801BH 56 45 52 49 46 59 1B 80
Entry 36: VERIFY, member 1BH of SYS6/SYS (read back every sector written).
4FC5-4FCC
DEFM "XFER " / DEFW 8073H 58 46 45 52 20 20 73 80
Entry 37: XFER, member 73H of SYS6/SYS (move files between diskettes).
4FCD
DEFB 00H 00
The end of the command table: 50CCH stops when the first byte of an entry is 00H.

4FCEH - Function 4 (C3H): Read a File Specification

Reached through 441CH and from 4E71H. Register Pair HL = the text, Register Pair DE = a file control block (at least 32 bytes). The specification is copied into the block as text, upper case, ended by 03H: a name of 1-8 letters and digits, then /extension (up to 3), .password (up to 8), :drive (1) and an exclamation mark when they are there; or an asterisk and a device name of 1 or 2 characters. A word that is a preposition (TO, ON, OVER, USING, the table at 5021H) is passed over and the next word is read in its place. Returns the Z FLAG set and Register A = 00H when a specification was read, the NZ FLAG when not; Register Pair HL is past the specification and the character that ended it (a space, a comma), except that 03H, 0DH and an opening parenthesis stay where they are; after an exclamation mark one more character, whatever it is, is passed over. Register Pair DE is the block again.

4FCE
PUSH DE D5
Save Register Pair DE (the start of the file control block) to the stack: it is restored at the end.
4FCF
GOSUB to 5076H to copy the name, at most 8 letters and digits, from Register Pair HL to Register Pair DE. It returns with Register A = the character that ended it and the Z FLAG set when at least one character was copied.
4FD2
If the NZ FLAG is set (no name), JUMP to 5012H, where an asterisk starts a device specification.
4FD4
CP 2FH FE 2F
Compare Register A (the character after the name) against 2FH, a slash: an extension follows.
4FD6
If the NZ FLAG is set (no slash), JUMP to 4FDFH to look for a password.
4FD8
LD (DE),A 12
Store Register A (the slash) to the file control block at Register Pair DE, over the 03H that 5076H put after the name.
4FD9
INC DE 13
Increment Register Pair DE to the byte after the slash.
4FDA
LD B,03H 06 03
Load Register B with 03H: the extension has at most 3 characters.
4FDC
GOSUB to 5078H to copy the extension, at most Register B (3) letters and digits. An empty extension is not refused: Register A = the character after it either way.
4FDF
CP 2EH FE 2E
Compare Register A (the character after the name or the extension) against 2EH, a period: a password follows.
4FE1
If the NZ FLAG is set (no period), JUMP to 4FEAH to look for a drive.
4FE3
LD (DE),A 12
Store Register A (the period) to the file control block at Register Pair DE, over the 03H.
4FE4
INC DE 13
Increment Register Pair DE to the byte after the period.
4FE5
GOSUB to 5076H to copy the password, at most 8 letters and digits, from Register Pair HL to Register Pair DE.
4FE8
If the NZ FLAG is set (a period with no password after it), JUMP to 501FH to return with the NZ FLAG: not a specification.
4FEA
CP 3AH FE 3A
Compare Register A (the character that ended the last field) against 3AH, a colon: a drive number follows.
4FEC
If the NZ FLAG is set (no colon), JUMP to 4FF7H.
4FEE
LD (DE),A 12
Store Register A (the colon) to the file control block at Register Pair DE, over the 03H.
4FEF
INC DE 13
Increment Register Pair DE to the byte after the colon.
4FF0
LD B,01H 06 01
Load Register B with 01H: the drive is one character.
4FF2
GOSUB to 5078H to copy the drive, one letter or digit, from Register Pair HL to Register Pair DE.
4FF5
If the NZ FLAG is set (a colon with no drive after it), JUMP to 501FH to return with the NZ FLAG.
4FF7
CP 21H FE 21
Compare Register A (the character that ended the last field) against 21H, an exclamation mark.
4FF9
If the NZ FLAG is set (no exclamation mark), JUMP to 4FFFH to end the text.
4FFB
LD (DE),A 12
Store Register A (the exclamation mark) to the file control block at Register Pair DE, over the 03H.
4FFC
INC DE 13
Increment Register Pair DE to the byte after the exclamation mark.
4FFD
INC HL 23
Increment Register Pair HL: one more character of the line, the one after the exclamation mark (5078H has already passed the mark itself), is passed over.
4FFE
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A: the one after the character passed over.
4FFF
LD C,A 4F
Copy Register A into Register C, to keep it while Register A is used. A specification without an exclamation mark (4FF9H) and a device specification (501DH) join here with Register A = the character that ended the last field.
5000
LD A,03H 3E 03
Load Register A with 03H, the end of text of the specification.
5002
LD (DE),A 12
Store Register A (03H) to the file control block at Register Pair DE, after the last character copied.
5003
XOR A AF
Set Register A to 00H and set the Z FLAG (XOR A).
5004
LD A,C 79
Copy Register C (the character at Register Pair HL) back into Register A. LD does not change the flags.
5005
POP DE D1
Restore Register Pair DE from the stack: the start of the file control block.
5006
PUSH DE D5
Save Register Pair DE (the start of the block) to the stack again, for after the search.
5007
LD BC,5021H 01 21 50
Point Register Pair BC to 5021H, the table of the prepositions TO, ON, OVER and USING.
500A
GOSUB to 50BCH to look up the specification at Register Pair DE in the table at Register Pair BC: the Z FLAG is set when it is one of the prepositions.
500D
POP DE D1
Restore Register Pair DE from the stack: the start of the file control block (50BCH returned a table word in it).
500E
If the Z FLAG is set (a preposition), JUMP to 4FCEH to read the next word of the line, at Register Pair HL, into the same block in its place.
5010
XOR A AF
Set Register A to 00H and set the Z FLAG (XOR A): the specification is good.
5011
RET C9
RETURN with the Z FLAG set, Register A = 00H, Register Pair DE = the file control block and Register Pair HL past the specification.
5012
CP 2AH FE 2A
Compare Register A (the character that ended the empty name) against 2AH, an asterisk: a device specification.
5014
If the NZ FLAG is set (neither a name nor an asterisk), JUMP to 501FH to return with the NZ FLAG.
5016
LD (DE),A 12
Store Register A (the asterisk) to the file control block at Register Pair DE, over the 03H.
5017
INC DE 13
Increment Register Pair DE to the byte after the asterisk.
5018
LD B,02H 06 02
Load Register B with 02H: a device name has 2 characters.
501A
GOSUB to 5078H to copy the device name, at most Register B (2) letters and digits.
501D
If the Z FLAG is set (at least one character), JUMP to 4FFFH to end the text with 03H (Register A = the character after the name). The search of the prepositions at 500AH that follows never matches a specification that starts with an asterisk.
501F
POP DE D1
Restore Register Pair DE from the stack: the start of the file control block. POP does not change the flags.
5020
RET C9
RETURN with the NZ FLAG set: no specification was read.

5021H - The Prepositions

The words that 4FCEH passes over between specifications (the manual: they are there for readability, and a space or comma does as well). The same format as the command table, with words of 0000H that nothing uses.

5021-5028
DEFM "TO " / DEFW 0000H 54 4F 20 20 20 20 00 00
Entry 1: TO, padded to 6 characters, word 0000H.
5029-5030
DEFM "ON " / DEFW 0000H 4F 4E 20 20 20 20 00 00
Entry 2: ON, padded to 6 characters, word 0000H.
5031-5038
DEFM "OVER " / DEFW 0000H 4F 56 45 52 20 20 00 00
Entry 3: OVER, padded to 6 characters, word 0000H.
5039-5040
DEFM "USING " / DEFW 0000H 55 53 49 4E 47 20 00 00
Entry 4: USING, padded to 6 characters, word 0000H.
5041
DEFB 00H 00
The end of the table of prepositions: 50CCH stops at 00H.

5042H - Function 5 (D3H): Supply a Default Extension

Reached through 4473H and from 4E87H. Register Pair DE = a file control block holding a specification as text (from 4FCEH), Register Pair HL = three letters. When the name has no extension, a slash and the three letters are put in after the name, and the password, drive and 03H that follow move up 4 bytes. Nothing changes when there is an extension already, or when no end of the name is found in the 9 characters after the first. Register Pair DE is returned unchanged; Register Pair HL is unchanged when nothing is put in, otherwise 1 below the three letters; Register Pair BC is changed.

5042
PUSH DE D5
Save Register Pair DE (the file control block) to the stack.
5043
PUSH HL E5
Save Register Pair HL (the three letters) to the stack.
5044
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL = the file control block, Register Pair DE = the three letters.
5045
INC HL 23
Increment Register Pair HL past the first character of the name, which is always a letter or digit.
5046
LD B,09H 06 09
Load Register B with 09H, the most characters looked at after the first: the other 7 of a name of 8, the character after it and one more.
5048
LD A,(HL) 7E
Fetch a character of the specification from Register Pair HL into Register A.
5049
CP 2FH FE 2F
Compare Register A against 2FH, a slash: the name has an extension.
504B
If the Z FLAG is set (a slash), JUMP to 505AH to return with nothing changed.
504D
If the C FLAG is set (below 2FH: 03H, the period of a password, an exclamation mark), JUMP to 505DH: the name ends here and the extension goes in.
504F
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9.
5051
If the C FLAG is set (a digit), JUMP to 5057H: still the name.
5053
CP 41H FE 41
Compare Register A against 41H, the letter A.
5055
If the C FLAG is set (3AH-40H: the colon of a drive), JUMP to 505DH to put the extension in.
5057
INC HL 23
Increment Register Pair HL to the next character of the specification.
5058
Decrement Register B and JUMP back to 5048H while it is not zero.
505A
POP HL E1
Restore Register Pair HL from the stack: the three letters.
505B
POP DE D1
Restore Register Pair DE from the stack: the file control block.
505C
RET C9
RETURN to the caller with the specification unchanged: it has an extension already, or no end of the name was found.
505D
LD BC,000FH 01 0F 00
Load Register Pair BC with 000FH. Register Pair HL = the character where the extension goes.
5060
ADD HL,BC 09
Add Register Pair BC (15) to Register Pair HL: the 16th byte from there, the highest of the 16 bytes to move, the first one LDDR moves.
5061
LD D,H 54
Copy Register H (the high byte of the highest byte to move) into Register D.
5062
LD E,L 5D
Copy Register L into Register E: Register Pair DE = the same byte as Register Pair HL.
5063
INC DE 13
Increment Register Pair DE: one byte above the last byte to move.
5064
INC DE 13
Increment Register Pair DE: two bytes above the last byte to move.
5065
INC DE 13
Increment Register Pair DE: three bytes above the last byte to move.
5066
INC DE 13
Increment Register Pair DE: four bytes above the last byte to move, the room for a slash and three letters.
5067
INC BC 03
Increment Register Pair BC to 0010H: 16 bytes are moved.
5068
LDDR ED B8
Move 16 bytes 4 bytes up, from the top down (LDDR from Register Pair HL to Register Pair DE, Register Pair BC = 16): the rest of the specification makes room for the extension. Register Pair HL ends 1 byte below the place of the slash and Register Pair DE on the place of the third letter; Register Pair BC ends at 0000H.
506A
POP HL E1
Restore Register Pair HL from the stack: the three letters.
506B
INC HL 23
Increment Register Pair HL from the first to the second of the three letters.
506C
INC HL 23
Increment Register Pair HL from the second to the third of the three letters: the LDDR below copies from the top down.
506D
LD C,03H 0E 03
Load Register C with 03H (Register B is 00H after the LDDR): Register Pair BC = 0003H, the three letters.
506F
LDDR ED B8
Copy the three letters from the top down (LDDR from Register Pair HL to Register Pair DE, Register Pair BC = 3) into the room made: Register Pair DE ends on the place of the slash.
5071
LD A,2FH 3E 2F
Load Register A with 2FH, the slash that starts the extension.
5073
LD (DE),A 12
Store Register A (the slash) to Register Pair DE, in front of the extension.
5074
POP DE D1
Restore Register Pair DE from the stack: the file control block.
5075
RET C9
RETURN to the caller with the extension in place. Register Pair HL is 1 byte below the letters the caller gave.

5076H - Copy a Field of Letters and Digits

5076H copies a field of at most 8 characters, 5078H one of at most Register B characters, from the text at Register Pair HL to Register Pair DE. Letters are made upper case. Characters past the most allowed are passed over. The field ends at the first character that is not a letter or a digit; 03H, 0DH and an opening parenthesis are left at Register Pair HL, any other one is passed over. 03H is put after the field. Returns Register A = the character that ended the field and the Z FLAG set when at least one character was copied; Register Pair DE on the 03H.

5076
LD B,08H 06 08
Load Register B with 08H: a name or a password has at most 8 characters.
5078
LD A,B 78
Copy Register B (the most characters of the field) into Register A.
5079
LD (50B8H),A 32 B8 50
Store Register A to 50B8H, the operand of LD A,00H at 50B7H: it stays at this value, never 00H, while no character has been copied, and becomes the result of the test at 50B9H.
507C
INC B 04
Increment Register B by one: the count runs out at the character after the last one allowed (50A5H).
507D
LD A,(HL) 7E
Fetch a character from the text at Register Pair HL into Register A.
507E
CP 03H FE 03
Compare Register A against 03H, an end of text.
5080
If the Z FLAG is set (03H), JUMP to 50B3H to end the field with Register Pair HL on it.
5082
CP 0DH FE 0D
Compare Register A against 0DH, the end of a line.
5084
If the Z FLAG is set (0DH), JUMP to 50B3H to end the field with Register Pair HL on it.
5086
CP 28H FE 28
Compare Register A against 28H, an opening parenthesis: a parameter list starts.
5088
If the Z FLAG is set (an opening parenthesis), JUMP to 50B3H to end the field with Register Pair HL on it.
508A
INC HL 23
Increment Register Pair HL past the character. INC of a register pair does not change the flags.
508B
CP 30H FE 30
Compare Register A (the character) against 30H, the digit 0.
508D
If the C FLAG is set (below 30H: a space, a comma, a slash, a period), JUMP to 50B3H to end the field. Register Pair HL is past the character.
508F
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9.
5091
If the C FLAG is set (a digit), JUMP to 50A5H to copy it.
5093
CP 41H FE 41
Compare Register A against 41H, the letter A.
5095
If the C FLAG is set (3AH-40H: a colon), JUMP to 50B3H to end the field.
5097
CP 5BH FE 5B
Compare Register A against 5BH, the character after Z.
5099
If the C FLAG is set (a capital letter), JUMP to 50A5H to copy it.
509B
CP 61H FE 61
Compare Register A against 61H, the letter a.
509D
If the C FLAG is set (5BH-60H), JUMP to 50B3H to end the field.
509F
CP 7BH FE 7B
Compare Register A against 7BH, the character after z.
50A1
If the NC FLAG is set (7BH and up), JUMP to 50B3H to end the field.
50A3
SUB 20H D6 20
SUBtract 20H from Register A: a small letter becomes the capital letter.
50A5
DEC B 05
Decrement Register B, the characters the field may still take plus one.
50A6
If the Z FLAG is set (the field is full), JUMP to 50B0H to pass over the character without copying it.
50A8
LD (DE),A 12
Store Register A (the letter or digit) to Register Pair DE.
50A9
XOR A AF
Set Register A to 00H (XOR A), the mark that a character has been copied.
50AA
LD (50B8H),A 32 B8 50
Store Register A (00H) to 50B8H, the operand of LD A,00H at 50B7H: a character has been copied.
50AD
INC DE 13
Increment Register Pair DE to the next byte of the destination.
50AE
JUMP back to 507DH for the next character of the field at Register Pair HL.
50B0
INC B 04
Increment Register B back to 1, so that every later letter or digit of the field is passed over as well.
50B1
JUMP back to 507DH for the next character of the field at Register Pair HL.
50B3
LD C,A 4F
Copy Register A (the character that ended the field) into Register C.
50B4
LD A,03H 3E 03
Load Register A with 03H, the end of text put after the field.
50B6
LD (DE),A 12
Store Register A (03H) to Register Pair DE, after the last character copied.
50B7
LD A,00H 3E 00
Load Register A with the operand at 50B8H: 00H when a character was copied (50AAH), the field's maximum when none was (5079H).
50B9
OR A B7
OR Register A with itself: the Z FLAG is set when a character was copied.
50BA
LD A,C 79
Copy Register C (the character that ended the field) into Register A. LD does not change the flags.
50BB
RET C9
RETURN with Register A = that character and the Z FLAG set when the field is not empty.

50BCH - Search a Table of Names

Register Pair DE = a word (letters and digits, ended by any other character), Register Pair BC = a table of 8 byte entries (a name of 6 characters padded with spaces, then a word), ended by 00H. A name matches when its first 6 characters equal the word's, or the word ends where the name has a space. A character other than a letter or digit ends the word only where it differs from the name's character; where it equals it (the exclamation mark of entry 1) the comparison goes on. Returns the Z FLAG set, Register A = 00H, Register Pair DE = the entry's word and Register C = the entry's number (1 for the first); the NZ FLAG and Register A = 01H when no entry matches. Register Pair HL is returned unchanged. Used for the commands (4E7FH), the prepositions (500AH) and the parameters (512EH).

50BC
PUSH HL E5
Save Register Pair HL (the caller's) to the stack.
50BD
LD H,B 60
Copy Register B (the high byte of the table) into Register H.
50BE
LD L,C 69
Copy Register C (the low byte of the table) into Register L: Register Pair HL = the first entry.
50BF
LD C,01H 0E 01
Load Register C with 01H, the number of the first entry.
50C1
LD A,(DE) 1A
Fetch the first character of the word from Register Pair DE into Register A.
50C2
CP (HL) BE
Compare Register A against the first character of the entry's name at Register Pair HL.
50C3
If the Z FLAG is set (the same), JUMP to 50D3H to compare the rest.
50C5
PUSH BC C5
Save Register Pair BC (Register C = the entry's number) to the stack.
50C6
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the length of an entry.
50C9
ADD HL,BC 09
Add Register Pair BC (8) to Register Pair HL: the next entry.
50CA
POP BC C1
Restore Register Pair BC from the stack: Register C = the entry's number.
50CB
INC C 0C
Increment Register C, the number of the next entry.
50CC
LD A,(HL) 7E
Fetch the first byte of the next entry from Register Pair HL into Register A.
50CD
OR A B7
OR Register A with itself: the Z FLAG is set at the 00H that ends the table.
50CE
If the NZ FLAG is set (another entry), JUMP back to 50C1H to compare it.
50D0
POP HL E1
Restore Register Pair HL from the stack: the caller's.
50D1
INC A 3C
Increment Register A (00H) to 01H: the NZ FLAG is set, no entry matched.
50D2
RET C9
RETURN with the NZ FLAG set and Register A = 01H: the word is not in the table.
50D3
LD B,05H 06 05
Load Register B with 05H: the other 5 characters of the name.
50D5
PUSH HL E5
Save Register Pair HL (the entry) to the stack.
50D6
PUSH DE D5
Save Register Pair DE (the word) to the stack.
50D7
INC DE 13
Increment Register Pair DE to the next character of the word.
50D8
INC HL 23
Increment Register Pair HL to the next character of the name.
50D9
LD A,(DE) 1A
Fetch the character of the word from Register Pair DE into Register A.
50DA
CP 03H FE 03
Compare Register A against 03H, the end of the word.
50DC
If the Z FLAG is set (03H), JUMP to 5105H: the name must have a space here.
50DE
CP 0DH FE 0D
Compare Register A against 0DH, the end of a line.
50E0
If the Z FLAG is set (0DH), JUMP to 5105H: the name must have a space here.
50E2
CP (HL) BE
Compare Register A (the character of the word) against the character of the name at Register Pair HL.
50E3
If the NZ FLAG is set (they differ), JUMP to 50F5H.
50E5
Decrement Register B and JUMP back to 50D7H while characters of the name are left.
50E7
POP DE D1
Restore Register Pair DE from the stack: the word.
50E8
LD A,C 79
Copy Register C (the entry's number) into Register A.
50E9
POP BC C1
Restore Register Pair BC from the stack: the address of the entry, pushed at 50D5H.
50EA
LD HL,0006H 21 06 00
Load Register Pair HL with 0006H, the place of the word in an entry.
50ED
ADD HL,BC 09
Add Register Pair BC (the entry) to Register Pair HL: Register Pair HL = the entry's word.
50EE
LD C,A 4F
Copy Register A (the entry's number) into Register C.
50EF
LD E,(HL) 5E
Fetch the low byte of the entry's word from Register Pair HL into Register E.
50F0
INC HL 23
Increment Register Pair HL to the high byte of the entry's word.
50F1
LD D,(HL) 56
Fetch the high byte of the entry's word from Register Pair HL into Register D: Register Pair DE = the word.
50F2
POP HL E1
Restore Register Pair HL from the stack: the caller's.
50F3
XOR A AF
Set Register A to 00H and set the Z FLAG (XOR A): the entry matched.
50F4
RET C9
RETURN with the Z FLAG set, Register Pair DE = the word, Register C = the entry's number.
50F5
CP 30H FE 30
Compare Register A (the character of the word) against 30H, the digit 0.
50F7
If the C FLAG is set (below 30H: the slash, period or other character that ends the word), JUMP to 5105H.
50F9
CP 3AH FE 3A
Compare Register A against 3AH, the character after 9.
50FB
If the C FLAG is set (a digit that differs), JUMP to 510AH: no match.
50FD
CP 41H FE 41
Compare Register A against 41H, the letter A.
50FF
If the C FLAG is set (3AH-40H, a colon: the end of the word), JUMP to 5105H.
5101
CP 5BH FE 5B
Compare Register A against 5BH, the character after Z.
5103
If the C FLAG is set (a letter that differs), JUMP to 510AH: no match.
5105
LD A,(HL) 7E
Fetch the character of the name from Register Pair HL into Register A: the word has ended here.
5106
CP 20H FE 20
Compare Register A (the character of the name) against 20H, a space.
5108
If the Z FLAG is set (the name ends here too), JUMP to 50E7H: the entry matches.
510A
POP DE D1
Restore Register Pair DE from the stack: the start of the word.
510B
POP HL E1
Restore Register Pair HL from the stack: the entry.
510C
JUMP back to 50C5H to go on to the next entry.

510EH - Function 6 (E3H): Read a Parameter List

Reached through 4476H at 510FH. Register Pair HL = the text, Register Pair DE = the caller's parameter table (the format of the command table: a name of 6 characters, then the address of a word to receive the value). The list is in parentheses, entries parted by commas: NAME alone stores FFFFH; NAME=nnn a decimal number; NAME=X'hhhh' a hexadecimal number; NAME="text" the address of the text (its closing quote becomes 0DH); NAME=ON, OFF, YES, NO, Y or N FFFFH or 0000H. Returns the Z FLAG set when the list is good or there is none; the NZ FLAG for an unknown name or a bad value. Register Pair HL ends past the closing parenthesis.

510E
INC HL 23
Increment Register Pair HL past a space before the list.
510F
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
5110
CP 0DH FE 0D
Compare Register A against 0DH, the end of the line.
5112
RET Z C8
If the Z FLAG is set (0DH: no list), RETURN with the Z FLAG set.
5113
CP 20H FE 20
Compare Register A (the character at Register Pair HL) against 20H, a space.
5115
If the Z FLAG is set (a space), JUMP back to 510EH to pass over it.
5117
CP 28H FE 28
Compare Register A against 28H, an opening parenthesis.
5119
If the NZ FLAG is set (no list here), JUMP to 514CH to return with the Z FLAG set: nothing is stored.
511B
PUSH DE D5
Save Register Pair DE (the parameter table) to the stack.
511C
LD B,06H 06 06
Load Register B with 06H: a parameter's name has at most 6 characters.
511E
LD DE,4200H 11 00 42
Point Register Pair DE to 4200H, the sector buffer of SYS0/SYS, used here to hold the name.
5121
INC HL 23
Increment Register Pair HL past the opening parenthesis or the comma.
5122
GOSUB to 5078H to copy the name, at most Register B (6) letters and digits, from Register Pair HL to 4200H at Register Pair DE.
5125
DEC HL 2B
Decrement Register Pair HL back onto the character that ended the name (5078H passed over an equals sign, a comma or a closing parenthesis). When the name ends at 0DH, 03H or an opening parenthesis, which 5078H does not pass over, this lands on the name's last letter and 5143H refuses the list.
5126
POP DE D1
Restore Register Pair DE from the stack: the parameter table. POP does not change the flags.
5127
RET NZ C0
If the NZ FLAG is set (no name), RETURN with the NZ FLAG set.
5128
PUSH DE D5
Save Register Pair DE (the parameter table) to the stack.
5129
LD B,D 42
Copy Register D (the high byte of the table) into Register B.
512A
LD C,E 4B
Copy Register E (the low byte of the table) into Register C: Register Pair BC = the table.
512B
LD DE,4200H 11 00 42
Point Register Pair DE to 4200H, the name just copied.
512E
GOSUB to 50BCH to look up the name at Register Pair DE in the table at Register Pair BC: Register Pair DE = the address in the entry when it is found.
5131
If the Z FLAG is set (the name is in the table), JUMP to 5135H.
5133
POP DE D1
Restore Register Pair DE from the stack: the parameter table. POP does not change the flags.
5134
RET C9
RETURN with the NZ FLAG set: an unknown name or a bad value.
5135
LD A,(HL) 7E
Fetch the character after the name from Register Pair HL into Register A.
5136
CP 3DH FE 3D
Compare Register A against 3DH, an equals sign.
5138
If the Z FLAG is set (a value follows), JUMP to 514EH.
513A
LD BC,FFFFH 01 FF FF
Load Register Pair BC with FFFFH: a name with no value is a flag that is on.
513D
LD A,C 79
Copy Register C (the low byte of the value) into Register A.
513E
LD (DE),A 12
Store Register A to the word at Register Pair DE, the address the table gives.
513F
INC DE 13
Increment Register Pair DE to the high byte of the word.
5140
LD A,B 78
Copy Register B (the high byte of the value) into Register A.
5141
LD (DE),A 12
Store Register A to Register Pair DE: the word holds Register Pair BC.
5142
POP DE D1
Restore Register Pair DE from the stack: the parameter table.
5143
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A: the one after the name or its value.
5144
CP 2CH FE 2C
Compare Register A against 2CH, a comma: another parameter follows.
5146
If the Z FLAG is set (a comma), JUMP to 511BH for the next parameter.
5148
CP 29H FE 29
Compare Register A against 29H, a closing parenthesis.
514A
RET NZ C0
If the NZ FLAG is set (anything else), RETURN with the NZ FLAG set: a bad list.
514B
INC HL 23
Increment Register Pair HL past the closing parenthesis.
514C
XOR A AF
Set Register A to 00H and set the Z FLAG (XOR A).
514D
RET C9
RETURN with the Z FLAG set: the list is good (or there was none).
514E
INC HL 23
Increment Register Pair HL past the equals sign.
514F
LD A,(HL) 7E
Fetch the first character of the value from Register Pair HL into Register A.
5150
CP 22H FE 22
Compare Register A against 22H, a double quote: a text.
5152
If the Z FLAG is set (a text), JUMP to 516EH.
5154
CP 58H FE 58
Compare Register A against 58H, the letter X: a hexadecimal number in single quotes.
5156
If the Z FLAG is set (the letter X), JUMP to 5161H to read a hexadecimal number.
5158
CP 41H FE 41
Compare Register A against 41H, the letter A.
515A
If the C FLAG is set (any character below A, the digits among them), JUMP to 5169H for a decimal number.
515C
GOSUB to 5181H to read ON, OFF, YES, NO, Y or N into Register Pair BC: the Z FLAG is set when it is one of them.
515F
JUMP to 5165H to test the Z FLAG that 5181H returned.
5161
INC HL 23
Increment Register Pair HL past the X, onto the opening single quote.
5162
GOSUB to 51C0H to read the hexadecimal number into Register Pair BC: the NZ FLAG is set when no single quote follows the X.
5165
If the Z FLAG is set (a value was read), JUMP to 513DH to store Register Pair BC.
5167
JUMP to 5133H to return with the NZ FLAG set: a bad value.
5169
GOSUB to 51A6H to read the decimal number into Register Pair BC (0000H when the first character is not a digit).
516C
JUMP to 513DH to store Register Pair BC. A value that starts with a character below A that is not a digit stores 0000H; 5143H then refuses the list unless that character is a comma or a closing parenthesis.
516E
INC HL 23
Increment Register Pair HL past the opening double quote.
516F
LD B,H 44
Copy Register H (the high byte of the text address) into Register B.
5170
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the address of the first character of the text, the value stored.
5171
LD A,(HL) 7E
Fetch a character of the text from Register Pair HL into Register A.
5172
CP 20H FE 20
Compare Register A (the character of the text) against 20H, a space.
5174
If the C FLAG is set (a control character, the 0DH of the line: no closing quote), JUMP to 5133H to return with the NZ FLAG set.
5176
INC HL 23
Increment Register Pair HL to the next character. INC of a register pair does not change the flags.
5177
CP 22H FE 22
Compare Register A against 22H, a double quote: the end of the text.
5179
If the NZ FLAG is set (not yet), JUMP back to 5171H.
517B
DEC HL 2B
Decrement Register Pair HL back to the closing double quote.
517C
LD (HL),0DH 36 0D
Store 0DH over the closing double quote at Register Pair HL: the text ends at 0DH for the command that uses it.
517E
INC HL 23
Increment Register Pair HL past the 0DH, onto the character after the text.
517F
JUMP to 513DH to store Register Pair BC, the address of the text.

5181H - Read a Flag Value

Register Pair HL = the value after the equals sign. Y (YES) and ON give FFFFH, N (NO) and OFF give 0000H, in Register Pair BC, with the Z FLAG set; the rest of the value is passed over up to the comma or closing parenthesis. Any other first letter returns the NZ FLAG. Bytes 5185H-519BH are the patch SYS1A, which the file carries as a second load block over the first: it clears bit 5 of each letter tested, so that small letters are taken too, and takes any value that starts with O and does not go on with F as ON.

5181
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value of OFF and NO.
5184
LD A,(HL) 7E
Fetch the first letter of the value from Register Pair HL into Register A.
5185
RES 5,A CB AF
Reset bit 5 of Register A: a small letter becomes the capital letter.
5187
CP 59H FE 59
Compare Register A against 59H, the letter Y (YES).
5189
If the Z FLAG is set (Y), JUMP to 519BH to make Register Pair BC = FFFFH.
518B
CP 4EH FE 4E
Compare Register A against 4EH, the letter N (NO).
518D
If the Z FLAG is set (N), JUMP to 519CH with Register Pair BC = 0000H.
518F
CP 4FH FE 4F
Compare Register A against 4FH, the letter O (ON or OFF).
5191
RET NZ C0
If the NZ FLAG is set (another letter), RETURN with the NZ FLAG set: not a flag value.
5192
INC HL 23
Increment Register Pair HL to the letter after the O.
5193
LD A,(HL) 7E
Fetch the letter after the O from Register Pair HL into Register A.
5194
RES 5,A CB AF
Reset bit 5 of Register A: a small letter becomes the capital letter.
5196
CP 46H FE 46
Compare Register A against 46H, the letter F (OFF).
5198
If the Z FLAG is set (F), JUMP to 519CH with Register Pair BC = 0000H.
519A
NOP 00
No operation: the byte fills the place the patch left.
519B
DEC BC 0B
Decrement Register Pair BC from 0000H to FFFFH: the value of ON and YES.
519C
INC HL 23
Increment Register Pair HL to the next character of the value.
519D
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
519E
CP 29H FE 29
Compare Register A against 29H, a closing parenthesis.
51A0
RET Z C8
If the Z FLAG is set (a closing parenthesis), RETURN with the Z FLAG set and Register Pair HL on it.
51A1
CP 2CH FE 2C
Compare Register A (the character at Register Pair HL) against 2CH, a comma.
51A3
RET Z C8
If the Z FLAG is set (a comma), RETURN with the Z FLAG set and Register Pair HL on it.
51A4
JUMP back to 519CH to pass over the rest of the word. No other character stops it, not even 0DH: a flag value in a list that is not closed makes the loop run on past the end of the line until a comma or closing parenthesis is met in memory.

51A6H - Read a Decimal Number

Register Pair HL = the first digit. Returns Register Pair BC = the number (modulo 65536) and Register Pair HL on the first character that is not a digit.

51A6
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the number so far.
51A9
LD A,(HL) 7E
Fetch a character from Register Pair HL into Register A.
51AA
SUB 30H D6 30
SUBtract 30H from Register A: a digit becomes its value 0-9.
51AC
RET C D8
If the C FLAG is set (below the digit 0), RETURN with the number in Register Pair BC.
51AD
CP 0AH FE 0A
Compare Register A (the character less 30H) against 0AH, the value after the digit 9.
51AF
RET NC D0
If the NC FLAG is set (above the digit 9), RETURN with the number in Register Pair BC.
51B0
PUSH BC C5
Save Register Pair BC (the number so far) to the stack.
51B1
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the number, the stack holds the text address.
51B2
ADD HL,HL 29
Add Register Pair HL to itself: twice the number.
51B3
ADD HL,HL 29
Add Register Pair HL to itself: four times the number.
51B4
ADD HL,BC 09
Add Register Pair BC (the number) to Register Pair HL: five times the number.
51B5
ADD HL,HL 29
Add Register Pair HL to itself: ten times the number.
51B6
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit's value.
51B8
LD C,A 4F
Copy Register A (the digit's value) into Register C: Register Pair BC = the digit.
51B9
ADD HL,BC 09
Add Register Pair BC (the digit) to Register Pair HL: ten times the number plus the digit.
51BA
LD B,H 44
Copy Register H (the high byte of the new number) into Register B.
51BB
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the new number.
51BC
POP HL E1
Restore Register Pair HL from the stack: the text address.
51BD
INC HL 23
Increment Register Pair HL to the next character.
51BE
JUMP back to 51A9H for the next digit of the number at Register Pair HL.

51C0H - Read a Hexadecimal Number

Register Pair HL = the character after the X, which must be a single quote. Returns Register Pair BC = the number (the last four digits count) with the Z FLAG set and Register Pair HL past the closing quote, or on the first character that is not a digit when there is none; the NZ FLAG when there is no opening quote. The test takes the characters 3AH-40H (the colon up to @) as the digits 3-9 as well.

51C0
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the number so far.
51C3
LD A,(HL) 7E
Fetch the character after the X from Register Pair HL into Register A.
51C4
CP 27H FE 27
Compare Register A against 27H, a single quote.
51C6
RET NZ C0
If the NZ FLAG is set (no quote), RETURN with the NZ FLAG set.
51C7
INC HL 23
Increment Register Pair HL to the next character.
51C8
LD A,(HL) 7E
Fetch the character from Register Pair HL into Register A.
51C9
SUB 30H D6 30
SUBtract 30H from Register A: the digits 0-9 become 0-9.
51CB
If the C FLAG is set (below the digit 0), JUMP to 51D7H: not a digit.
51CD
CP 0AH FE 0A
Compare Register A (the character less 30H) against 0AH, the value after the digit 9.
51CF
If the C FLAG is set (0-9), JUMP to 51DFH to add the digit.
51D1
SUB 07H D6 07
SUBtract 07H from Register A: the letters A-F (41H-46H) become 0AH-0FH.
51D3
CP 10H FE 10
Compare Register A (the character less 37H) against 10H, the value after the digit F.
51D5
If the C FLAG is set (A-F, and also the characters 3AH-40H, which become 03H-09H here), JUMP to 51DFH to add the digit.
51D7
LD A,(HL) 7E
Fetch the character from Register Pair HL into Register A again.
51D8
CP 27H FE 27
Compare Register A against 27H, the closing single quote.
51DA
INC HL 23
Increment Register Pair HL past the character. INC of a register pair does not change the flags.
51DB
RET Z C8
If the Z FLAG is set (the closing quote), RETURN with the Z FLAG set and Register Pair HL past it.
51DC
DEC HL 2B
Decrement Register Pair HL back onto the character.
51DD
XOR A AF
Set Register A to 00H and set the Z FLAG (XOR A).
51DE
RET C9
RETURN with the Z FLAG set: the number ends at a character other than the quote, Register Pair HL on it.
51DF
PUSH BC C5
Save Register Pair BC (the number so far) to the stack.
51E0
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL = the number, the stack holds the text address.
51E1
ADD HL,HL 29
Add Register Pair HL to itself: 2 times the number.
51E2
ADD HL,HL 29
Add Register Pair HL to itself: 4 times the number.
51E3
ADD HL,HL 29
Add Register Pair HL to itself: 8 times the number.
51E4
ADD HL,HL 29
Add Register Pair HL to itself: 16 times the number; Register L has 0 in bits 3-0.
51E5
LD B,H 44
Copy Register H into Register B: the high byte of the new number.
51E6
ADD A,L 85
Add Register L to Register A (the digit's value 0-15): the low byte with the digit in bits 3-0.
51E7
LD C,A 4F
Copy Register A into Register C: Register Pair BC = 16 times the number plus the digit.
51E8
POP HL E1
Restore Register Pair HL from the stack: the text address.
51E9
JUMP back to 51C7H for the next character of the number at Register Pair HL.

51EBH - Texts

The default extension of a program file and the two messages of the command level. The manual of the distributor shows how to change the prompt with PATCH (X'51EF'), up to 10 bytes ending in 0DH or 03H.

51EB-51ED
DEFM "CMD" 43 4D 44
The default extension of a program named as a command (4E84H).
51EE-51F9
DEFB 0AH / DEFM "VTOS READY" / DEFB 0DH 0A 56 54 4F 53 20 52 45 41 44 59 0D
The prompt (4E49H): 0AH starts a new line, the text VTOS READY, and 0DH, which 44DDH displays as the end of the line, so the command is typed on the next line.
51FA-51FF
DEFM "WHAT?" / DEFB 0DH 57 48 41 54 3F 0D
The message of a command line that cannot be interpreted (4E2FH), ended by 0DH.