LDOS 5.3.1 for the Model III - SYS1/SYS Disassembled

Page Customization

Introduction/Summary

LDOS 5.3.1 SYS1/SYS Disassembly - The Command Interpreter (Model III)

SYS1/SYS is the command interpreter of LDOS. It is a system file, loaded into the overlay area at 4E00H by the supervisor dispatcher of SYS0/SYS (4BCCH) whenever a request code names it: bits 3-0 of the code are 3. It displays LDOS Ready, reads a command line, and carries the command out, either as a member of one of the two command libraries, SYS6/SYS and SYS7/SYS, or as a program file loaded and run by @RUN. It also serves three supervisor calls that programs use to read their command lines: @FSPEC (a file specification), @FEXT (a default extension) and @PARAM (a parameter list).

The file is a load module of 1100 bytes: a record of type 1FH with the text Copyright 1991 MISOSYS, Inc., All rights reserved, four load blocks for 4E00H-51FEH, a load block for the two bytes 4BC8H-4BC9H (the length of the file's part at 4E00H, 03FFH) and the transfer address record for 4E00H. A library command runs at 5200H, above SYS1/SYS, so SYS1/SYS is still in memory while it runs: the LIB command reads the command table at 4EC3H from there. The first request of the command that loads another system file into 4E00H replaces it.

Functions

4E00H masks the request code in Register A with 70H and branches on bits 6-4.

RequestFunction
83H00H: returns at once with Register A = 00H. No vector of SYS0/SYS issues it.
93H10H: the LDOS Ready command loop (4E2EH). @EXIT (402DH), @ABORT (4030H) and @CMD (4296H) issue it. The stack is set to 41E5H, so it never returns: each command ends at 402DH and the loop runs again.
A3H20H: carry out the command line at Register Pair HL and return to the caller (429CH; SYS6/SYS and SYS7/SYS jump there). A line that cannot be carried out returns Register A = 02H with the NZ FLAG instead of ending the program. Request F3H (function 70H) is carried out the same way; no vector of SYS0/SYS issues it.
B3H30H: @CMNDI (4299H): carry out the command line at Register Pair HL; when the command ends, @EXIT (402DH) runs and LDOS Ready follows. SYS0/SYS's reset uses it for the AUTO command.
C3H40H: @FSPEC (441CH), 4FDCH: copy the file specification in the text at Register Pair HL into the control block at Register Pair DE.
D3H50H: @FEXT (444BH), 504EH: give the file specification at Register Pair DE the extension at Register Pair HL when it has none.
E3H60H: @PARAM (4454H), 5114H: read the parameter list in the text at Register Pair HL against the parameter table at Register Pair DE.

The Command Line

A command line typed at LDOS Ready holds up to 63 characters (INBUF$, 4225H, ended by 0DH); a line given by a program is copied there, 63 bytes, with 03H in the 64th byte (4264H). The line is passed to the job log (428DH), then:

LineWhat SYS1/SYS does
.A comment: nothing is carried out. While a JCL job runs (bit 5 of SFLAG$, 442BH) the job goes on with its next line; otherwise the next line is read from the keyboard (4EACH).
!NAMENAME is run as a program file even when it is the name of a library command.
NAMEThe first word is taken as a file specification into CFCB$ (4485H). When it is one of the 35 names of the command table (4EC3H) the command is carried out by its library member (request 88H for SYS6/SYS, 89H for SYS7/SYS, the member number in Register B), or by the RST 00H at 4EC2H for BOOT. Any other name gets the extension /CMD when it has none and is loaded and run by @RUN (4433H). The command or program gets Register Pair HL pointing at the rest of the line.
Device or no nameA word that starts with an asterisk (a device name), an empty line, a line that starts with a space or another character that cannot start a name, and a line ended by BREAK end at @ABORT (4030H) and LDOS Ready, or, for a line from a program (function 20H), return to it with Register A = 02H (4EA3H).

While the command loop waits for the line, the BREAK trap switch (4405H) holds C3H when DEBUG is on (bit 7 of SFLAG$), so BREAK enters DEBUG; a library command runs with the switch at 00H, off.

The BREAK Vector at 4203H

Before every command line is carried out, typed or given by a program, 4E5CH stores JP 4206H at 4203H-4205H. The ROM jumps to 4203H when BREAK is pressed while it waits on the cassette or the RS-232 port, and SYS0/SYS's interrupt routine sends interrupt bits 0 and 1 there; SYS0/SYS's reset had put a jump to its cassette exit (44FAH) there. At 4206H-4208H SYS0/SYS holds three bytes of 00H, so the new jump runs on into its @CKDRV request at 4209H. Nothing on this diskette puts 44FAH back; BASIC/CMD stores an address of its own at 4204H (its 5C90H).

The Status Byte at 4758H

The fifth byte of SELECT among the disk primitives of SYS0/SYS is the status byte of the command interpreter. SYS1/SYS clears it for every line typed at LDOS Ready and for every line of @CMNDI (4E53H).

BitMeaning
1The command line came from a program through function 20H (set at 4E29H): a line that cannot be carried out returns to the program (4EA6H). SYS6/SYS and SYS7/SYS members test it too.
2A command line is being read from the keyboard (set at 4E47H, cleared at 4E53H).
3Not used by SYS1/SYS: members of SYS6/SYS (its 5A25H) and SYS7/SYS (its 5818H) set it, and KI/DVR, JL/DVR, RS232T/DVR, KSM/FLT and MINIDOS/FLT test it.
4Tested at 4E9DH: when set, a program file is not run; SYS1/SYS returns with its file specification in CFCB$ and Register Pair HL at its parameters. Of the files on this diskette only LCOMM/CMD sets it (its 6519H).
6, 7Not used by SYS1/SYS: SYS4/SYS tests them (6: no error message, 7: the short message) and clears bit 7; TED/CMD sets bit 7.

About This Page

Every byte of the file is shown, in address order: the load block at 4BC8H first, then 4E00H-51FEH. Each entry of the command table and of the table of words @FSPEC passes over has its own row. At 50B6H the operand byte of CP 23H is entered as an instruction by the loop that passes over spaces: 23H is INC HL (50B7H).

Memory Map

Load Blocks in File Order

The five load blocks of the file in the order the overlay loader (4C8CH) reads them, after the copyright record. The transfer address is 4E00H.

AddressContents
4E00H-4EFFH256 bytes
4F00H-4FFFH256 bytes
5000H-50FFH256 bytes
5100H-51FEH255 bytes
4BC8H-4BC9H2 bytes

Sections of the Disassembly

AddressContents
4BC8HThe Overlay Length (Data)
4E00HEntry: Pick the Function of the Request
4E2EHThe LDOS Ready Command Loop
4E5CHPoint the BREAK Vector at 4206H
4E68HCarry Out a Command Line
4EA3HEnd a Command That Cannot Be Carried Out
4EACHA Comment Line
4EB4HCarry Out a Library Command
4EC2HBOOT: Start the System Again
4EC3HThe Library Command Table (Data)
4FDCH@FSPEC: Take a File Specification
501EHA Device Name
502DHThe Words @FSPEC Passes Over (Data)
504EH@FEXT: Add a Default Extension
5066HPut the Extension In
507FHCopy a Field of Letters and Digits
50C3HIs It a Letter or a Digit?
50D1HLook a Word Up in a Table
5113H@PARAM: Read a Parameter List
515DHRead a Value
518EHA Value Given as a Word: Y, N, ON, OFF
51B1HRead a Decimal Number
51C6HRead a Hexadecimal Number in Quotes
51F0HThe Texts of SYS1/SYS (Data)

Memory SYS1/SYS Uses

AddressContents
0040HThe ROM's line input (05D9H): the command line typed at LDOS Ready (4E4FH).
0000HThe ROM's power up entry, reached by the RST 00H of BOOT (4EC2H).
402DH, 4030H@EXIT and @ABORT: 402DH is pushed as the return address of every command of functions 10H and 30H (4E5BH); 4EA9H jumps to @ABORT.
4203H-4208HThe BREAK vector of SYS0/SYS, made JP 4206H for every command (4E5CH-4E65H), and the three bytes of 00H it then jumps to.
41E5HThe stack of the command level: 4E2EH sets the Stack Pointer to 41E5H, so the stack grows down from 41E4H.
4300H-4306HThe system buffer: @PARAM copies each parameter name there, up to 6 characters and 03H (5123H, 5135H).
442BHSFLAG$: bit 7 DEBUG is on (4E32H), bit 5 a JCL job runs (4EACH).
4405HThe BREAK trap switch: C3H or 00H (4E3BH), 00H for a library command (4EB5H).
4225H-4264HINBUF$, the command line buffer: 63 characters and an end mark (4E16H-4E20H, 4E4AH).
4433H, 4467H, 428DH@RUN (4E9FH), @DSPLY (4E41H) and @LOGER (4E68H) of SYS0/SYS.
4485H-44A4HCFCB$, the control block that gets the command word as a file specification (4E78H).
4758HThe status byte of the command interpreter (4E22H, 4E44H, 4E9AH, 4EA3H).
4BC8H-4BC9HThe length of the system file in the overlay area: 03FFH for SYS1/SYS.
4E00H-51FEHSYS1/SYS in the overlay area.
5200HWhere a library member is loaded and run (the member of FILTER and SET at 5A00H).

Variables

The entry points of SYS1/SYS, then every data cell of the file and the cells of SYS0/SYS it uses, by address.

Entry Points

AddressNameContents
4E00HThe entry: 4E00H picks the function from bits 6-4 of the request code in Register A.
4E16H@CMNDIFunction 30H (request B3H, 4299H) and function 20H (request A3H, 429CH): carry out the command line at Register Pair HL.
4E2EH@CMD, @EXIT, @ABORTFunction 10H (request 93H), the LDOS Ready command loop, reached through 4296H, 402DH and 4030H.
4EC3HThe library command table, 35 entries of 8 bytes.
4FDCH@FSPECFunction 40H (request C3H, 441CH): take a file specification.
504EH@FEXTFunction 50H (request D3H, 444BH): add a default extension.
50D1HLook a word up in a table of 8 byte entries.
5114H@PARAMFunction 60H (request E3H, 4454H): read a parameter list.

Data in the File

Address
Size
Contents
4BC8H-4BC9H
2 bytes
DEFW 03FFH
4BC8H-4BC9H: 03FFH (1023), the number of bytes SYS1/SYS loads at 4E00H (4E00H-51FEH). Loading SYS1/SYS puts it over the length the system file loaded before it left here.
4EC3H-4ECAH
8 bytes
DEFM "APPEND" / DEFB 31H, 80H
APPEND: member 31H of SYS6/SYS (flags 80H, request 88H), entered at 5203H; the member of COPY (32H), which it shares.
4ECBH-4ED2H
8 bytes
DEFM "ATTRIB" / DEFB 51H, C0H
ATTRIB: member 51H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4ED3H-4EDAH
8 bytes
DEFM "AUTO " / DEFB 11H, C0H
AUTO: member 11H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4EDBH-4EE2H
8 bytes
DEFM "BOOT " / DEFB C2H, 4EH
BOOT: the address 4EC2H (bytes C2H 4EH; bit 7 of 4EH is clear), the code of BOOT in SYS1/SYS. Bit 6 of 4EH is set, so the LIB command lists BOOT with the commands of SYS7/SYS.
4EE3H-4EEAH
8 bytes
DEFM "BUILD " / DEFB 33H, C0H
BUILD: member 33H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4EEBH-4EF2H
8 bytes
DEFM "CLS " / DEFB 24H, 80H
CLS: member 24H of SYS6/SYS (flags 80H, request 88H), entered at 5203H; the member of LIB (19H), which it shares.
4EF3H-4EFAH
8 bytes
DEFM "COPY " / DEFB 32H, 80H
COPY: member 32H of SYS6/SYS (flags 80H, request 88H), entered at 5200H; the same code as APPEND (31H, 5203H).
4EFBH-4F02H
8 bytes
DEFM "CREATE" / DEFB 13H, C0H
CREATE: member 13H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F03H-4F0AH
8 bytes
DEFM "DATE " / DEFB 15H, C0H
DATE: member 15H of SYS7/SYS (flags C0H, request 89H), entered at 5203H; the member of TIME (16H), which it shares.
4F0BH-4F12H
8 bytes
DEFM "DEBUG " / DEFB 14H, C0H
DEBUG: member 14H of SYS7/SYS (flags C0H, request 89H), entered at 5203H; the member of VERIFY (1BH), which it shares.
4F13H-4F1AH
8 bytes
DEFM "DEVICE" / DEFB 61H, 80H
DEVICE: member 61H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F1BH-4F22H
8 bytes
DEFM "DIR " / DEFB 21H, 80H
DIR: member 21H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F23H-4F2AH
8 bytes
DEFM "DO " / DEFB 91H, 80H
DO: member 91H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F2BH-4F32H
8 bytes
DEFM "DUMP " / DEFB 71H, C0H
DUMP: member 71H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F33H-4F3AH
8 bytes
DEFM "FILTER" / DEFB 66H, 80H
FILTER: member 66H of SYS6/SYS (flags 80H, request 88H), entered at 5A00H; the same code as SET (65H, 5A01H).
4F3BH-4F42H
8 bytes
DEFM "FORMS " / DEFB B1H, C0H
FORMS: member B1H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F43H-4F4AH
8 bytes
DEFM "FREE " / DEFB 22H, C0H
FREE: member 22H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F4BH-4F52H
8 bytes
DEFM "KILL " / DEFB 18H, 80H
KILL: member 18H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F53H-4F5AH
8 bytes
DEFM "LIB " / DEFB 19H, 80H
LIB: member 19H of SYS6/SYS (flags 80H, request 88H), entered at 5200H; the same code as CLS (24H, 5203H) and TOF (25H, 5206H).
4F5BH-4F62H
8 bytes
DEFM "LINK " / DEFB 62H, 80H
LINK: member 62H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F63H-4F6AH
8 bytes
DEFM "LIST " / DEFB 41H, 80H
LIST: member 41H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F6BH-4F72H
8 bytes
DEFM "LOAD " / DEFB 81H, 80H
LOAD: member 81H of SYS6/SYS (flags 80H, request 88H), entered at 5203H; the member of RUN (82H), which it shares.
4F73H-4F7AH
8 bytes
DEFM "MEMORY" / DEFB 1EH, 80H
MEMORY: member 1EH of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F7BH-4F82H
8 bytes
DEFM "PURGE " / DEFB 72H, C0H
PURGE: member 72H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F83H-4F8AH
8 bytes
DEFM "RENAME" / DEFB 53H, 80H
RENAME: member 53H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F8BH-4F92H
8 bytes
DEFM "RESET " / DEFB 63H, 80H
RESET: member 63H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F93H-4F9AH
8 bytes
DEFM "ROUTE " / DEFB 64H, 80H
ROUTE: member 64H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F9BH-4FA2H
8 bytes
DEFM "RUN " / DEFB 82H, 80H
RUN: member 82H of SYS6/SYS (flags 80H, request 88H), entered at 5200H; the same code as LOAD (81H, 5203H).
4FA3H-4FAAH
8 bytes
DEFM "SET " / DEFB 65H, 80H
SET: member 65H of SYS6/SYS (flags 80H, request 88H), entered at 5A01H; the member of FILTER (66H), which it shares.
4FABH-4FB2H
8 bytes
DEFM "SETCOM" / DEFB B2H, C0H
SETCOM: member B2H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4FB3H-4FBAH
8 bytes
DEFM "SPOOL " / DEFB A2H, 80H
SPOOL: member A2H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4FBBH-4FC2H
8 bytes
DEFM "SYSTEM" / DEFB A1H, C0H
SYSTEM: member A1H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4FC3H-4FCAH
8 bytes
DEFM "TIME " / DEFB 16H, C0H
TIME: member 16H of SYS7/SYS (flags C0H, request 89H), entered at 5200H; the same code as DATE (15H, 5203H).
4FCBH-4FD2H
8 bytes
DEFM "TOF " / DEFB 25H, 80H
TOF: member 25H of SYS6/SYS (flags 80H, request 88H), entered at 5206H; the member of LIB (19H), which it shares.
4FD3H-4FDAH
8 bytes
DEFM "VERIFY" / DEFB 1BH, C0H
VERIFY: member 1BH of SYS7/SYS (flags C0H, request 89H), entered at 5200H; the same code as DEBUG (14H, 5203H).
4FDBH
1 byte
DEFB 00H
4FDBH: 00H, the end of the table: 50DEH finds 00H as the first byte of the next entry and the search ends with no match.
502DH-5034H
8 bytes
DEFM "TO " / DEFW 4300H
TO, the first word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search in Register Pair DE and dropped at 5019H.
5035H-503CH
8 bytes
DEFM "ON " / DEFW 4300H
ON, a word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search and dropped at 5019H.
503DH-5044H
8 bytes
DEFM "OVER " / DEFW 4300H
OVER, a word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search and dropped at 5019H.
5045H-504CH
8 bytes
DEFM "USING " / DEFW 4300H
USING, a word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search and dropped at 5019H.
504DH
1 byte
DEFB 00H
504DH: 00H, the end of the table: 50DEH finds 00H as the first byte of the next entry, so a word that is none of the four is not passed over.
51F0H-51F2H
3 bytes
DEFM "CMD"
51F0H-51F2H: CMD, the extension 4E96H adds through 504EH to a command word that is not a library command. 504EH copies exactly three characters, so the text needs no end mark.
51F3H
1 byte
DEFB 0AH
51F3H: 0AH, the first byte of the prompt that 4E41H displays: the video driver moves the cursor to the start of the next line for 0AH (as for 0DH), so LDOS Ready starts on a new line.
51F4H-51FDH
10 bytes
DEFM "LDOS Ready"
51F4H-51FDH: the prompt LDOS Ready, in capitals and small letters.
51FEH
1 byte
DEFB 0DH
51FEH: 0DH, the end of the prompt. @DSPLY displays it, so the cursor goes to the next line, where the command is typed. It is the last byte of the file's part at 4E00H (03FFH bytes, 4BC8H).

Self-Modified Operands

Address
Size
Contents
4E87H
1 byte
The operand of LD A,00H at 4E86H: 4E72H stores the first character of the command line less 21H, so it is 00H when the line starts with ! (the search of the command table is passed over).
50BFH
1 byte
The operand of LD A,00H at 50BEH: the field length (never 00H) stored by 5082H, 00H once 50A8H has copied a character, so the field copy returns the Z FLAG for a field that is not empty.

Cells of SYS0/SYS That SYS1/SYS Uses

Address
Size
Contents
4203H-4205H
3 bytes
The BREAK vector of SYS0/SYS: 4E5CH-4E65H store JP 4206H there before every command line is carried out.
4300H-4306H
7 bytes
The system buffer. @PARAM copies each parameter name there (5123H): up to 6 letters and digits and an 03H, which the table search (5138H) compares with the parameter table.
4405H
1 byte
The BREAK trap switch of SYS0/SYS. The command loop stores C3H (on) when bit 7 of SFLAG$ is set (DEBUG is on) and 00H (off) otherwise (4E3BH); 4EB5H stores 00H before a library command.
442BH
1 byte
SFLAG$, the system flags of SYS0/SYS. SYS1/SYS reads bit 7 (DEBUG is on, 4E32H) and bit 5 (a JCL job runs, 4EACH).
4225H-4264H
64 bytes
INBUF$, the command line buffer of SYS0/SYS. The ROM's line input puts a typed line of up to 63 characters there, ended by 0DH (4E4FH); functions 20H and 30H copy 63 bytes of the caller's line there and store 03H at 4264H (4E16H-4E20H).
4485H-44A4H
32 bytes
CFCB$, the control block of SYS0/SYS for the command: @FSPEC copies the command word into it as a file specification (4E7BH), 504EH adds /CMD, and @RUN loads the program it names (4E9FH).
4758H
1 byte
The status byte of the command interpreter, the fifth byte of SELECT among the disk primitives of SYS0/SYS. SYS1/SYS clears it (4E53H), sets bit 1 for a line from a program (4E29H) and bit 2 while a line is typed (4E47H), and tests bit 4 (4E9DH) and bit 1 (4EA6H). The table under The Status Byte above gives every bit.

Disassembly

4BC8H - The Overlay Length (Data)

Every system file from SYS1/SYS to SYS12/SYS carries a load block for the two bytes 4BC8H-4BC9H in the resident area of SYS0/SYS. They hold the length of the file's part in the overlay area: for SYS1/SYS 03FFH, the 1023 bytes 4E00H-51FEH. In the file this block is the last load block, after the four blocks of 4E00H-51FEH and before the transfer address record (4E00H). The member of SYS7/SYS that is entered for SYSTEM reads and writes the word (its 55E4H, 5692H). The two bytes are data, not instructions.

4BC8-4BC9
DEFW 03FFH FF 03
4BC8H-4BC9H: 03FFH (1023), the number of bytes SYS1/SYS loads at 4E00H (4E00H-51FEH). Loading SYS1/SYS puts it over the length the system file loaded before it left here.

4E00H - Entry: Pick the Function of the Request

The supervisor dispatcher (4BCCH) loads SYS1/SYS into 4E00H for a request code whose bits 3-0 are 3 and calls 4E00H with Register A = the request code (from OVRLY$, 4414H) and the caller's Register Pairs BC, DE and HL. Bits 6-4 of the code pick the function: 00H (83H) nothing; 10H (93H: @EXIT 402DH, @ABORT 4030H, @CMD 4296H) the LDOS Ready command loop; 20H (A3H, 429CH) carry out the command line at Register Pair HL and return to the caller; 30H (B3H, @CMNDI 4299H) carry out the command line at Register Pair HL, then LDOS Ready; 40H (C3H, @FSPEC 441CH) take a file specification; 50H (D3H, @FEXT 444BH) add a default extension; 60H (E3H, @PARAM 4454H) read a parameter list. Function 70H, which no vector of SYS0/SYS issues, is carried out as 20H.

4E00
AND 70H E6 70
Mask Register A (the request code, 83H to F3H, whose low four bits 3 name SYS1/SYS) with 70H, keeping bits 6-4, the function. The Z FLAG is set for function 00H.
4E02
RET Z C8
If the Z FLAG is set (function 00H, request code 83H, which no vector of SYS0/SYS issues), RETurn at once to the dispatcher with Register A = 00H.
4E03
CP 10H FE 10
Compare Register A (the function) against 10H, the command loop (request 93H).
4E05
If the Z FLAG is set (function 10H: @EXIT, @ABORT or @CMD), JUMP to 4E2EH to display LDOS Ready and take a command from the keyboard.
4E07
CP 40H FE 40
Compare Register A (the function) against 40H (request C3H, @FSPEC at 441CH).
4E09
If the Z FLAG is set (function 40H), JUMP to 4FDCH to take the file specification in the text at Register Pair HL into the control block at Register Pair DE.
4E0C
CP 50H FE 50
Compare Register A (the function) against 50H (request D3H, @FEXT at 444BH).
4E0E
If the Z FLAG is set (function 50H), JUMP to 504EH to give the file specification at Register Pair DE the extension at Register Pair HL when it has none.
4E11
CP 60H FE 60
Compare Register A (the function) against 60H (request E3H, @PARAM at 4454H).
4E13
If the Z FLAG is set (function 60H), JUMP to 5114H to read the parameter list in the text at Register Pair HL against the parameter table at Register Pair DE.
4E16
LD DE,4225H 11 25 42
Functions 20H, 30H and 70H: point Register Pair DE to 4225H, INBUF$, the command line buffer, where the caller's command line is copied.
4E19
PUSH DE D5
Save Register Pair DE (4225H, the start of INBUF$) to the stack; 4E2BH or 4E55H takes it back as the command line pointer.
4E1A
LD BC,003FH 01 3F 00
Load Register Pair BC with 003FH (63), the number of bytes to copy: the most characters a command line has.
4E1D
LDIR ED B0
Copy 63 bytes from the caller's command line at Register Pair HL to INBUF$ at Register Pair DE (4225H-4263H), the bytes after the line's 0DH included. For the AUTO command at the boot Register Pair HL is 4225H already and the bytes are copied onto themselves. Register Pair HL ends 63 bytes past the caller's line, Register Pair DE at 4264H and Register Pair BC at 0000H; Register A (the function) is not changed.
4E1F
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = 4264H, the byte after the 63 copied.
4E20
LD (HL),03H 36 03
Store 03H at Register Pair HL (4264H), the last byte of INBUF$: an end of text mark after the 63 bytes, at which the field copy (5086H) stops even when the line has no 0DH.
4E22
LD HL,4758H 21 58 47
Point Register Pair HL to 4758H, the status byte of the command interpreter (the fifth byte of SELECT among the disk primitives of SYS0/SYS).
4E25
CP 30H FE 30
Compare Register A (the function: 20H, 30H or 70H) against 30H, the function of @CMNDI.
4E27
If the Z FLAG is set (function 30H, @CMNDI at 4299H), JUMP to 4E53H to clear the status byte at Register Pair HL (4758H) and go on as for a line typed at LDOS Ready. The compare left the CARRY FLAG clear, so the JR C at 4E56H is not taken.
4E29
SET 1,(HL) CB CE
Function 20H (request A3H, 429CH) or 70H: set bit 1 of the status byte at Register Pair HL (4758H): the command line comes from a program, so a line that cannot be carried out returns to the program (4EA3H) instead of ending it. SYS6/SYS and SYS7/SYS test this bit too. The other bits of 4758H are left as they are.
4E2B
POP HL E1
Restore Register Pair HL from the stack: 4225H (pushed at 4E19H), the start of the copied command line in INBUF$.
4E2C
JUMP to 4E5CH to point the BREAK vector at 4206H and carry out the command. No return address is pushed, so the command's last RET goes back to the dispatcher (4BE6H) and from there to the program that called 429CH.

4E2EH - The LDOS Ready Command Loop

Function 10H (request 93H): @EXIT (402DH), @ABORT (4030H) and @CMD (4296H) all lead here. The stack is set up afresh at 41E5H, the BREAK trap is armed when DEBUG is on, LDOS Ready is displayed and a line of up to 63 characters is read from the keyboard into INBUF$ (4225H) through the ROM's line input at 0040H. The command gets 402DH (@EXIT) as its return address, so when it ends the loop runs again.

4E2E
LD SP,41E5H 31 E5 41
Load the Stack Pointer with 41E5H: the stack of the command level, which grows down from 41E4H. Whatever the program that ended left on the stack is dropped, the dispatcher's return address included, so function 10H never returns.
4E31
EI FB
Enable the interrupts: the clock, the disk controller interrupt and the keyboard scan of every interrupt (BREAK, the pause of SHIFT @) run while the command is typed and carried out.
4E32
LD A,(442BH) 3A 2B 44
Fetch SFLAG$, the system flags, from 442BH into Register A. Bit 7 is set while DEBUG is on.
4E35
RLCA 07
Rotate Register A (SFLAG$) left: bit 7 (DEBUG is on) goes into the CARRY FLAG.
4E36
LD A,C3H 3E C3
Load Register A with C3H, the value of the BREAK trap switch for on. LD does not change the CARRY FLAG.
4E38
If the CARRY FLAG is set (DEBUG is on), JUMP to 4E3BH with Register A = C3H.
4E3A
XOR A AF
DEBUG is off: set Register A to 00H (XOR A). Any value but C3H keeps the trap off.
4E3B
LD (4405H),A 32 05 44
Store Register A (C3H when DEBUG is on, 00H otherwise) at 4405H, the BREAK trap switch. With C3H the interrupt routine goes, on BREAK, to the address at 4406H-4407H (440DH, the DEBUG entry, unless a program has stored another there; SYS5/SYS (its 4F9BH) and the member of SYS7/SYS entered for DEBUG (its 5225H) store addresses there); with 00H it does not.
4E3E
LD HL,51F3H 21 F3 51
Point Register Pair HL to 51F3H, the prompt: a line feed, LDOS Ready and a carriage return.
4E41
GOSUB to 4467H (@DSPLY) to display the text at Register Pair HL (51F3H) on the video; the 0DH at its end is displayed too and puts the cursor at the start of the next line.
4E44
LD HL,4758H 21 58 47
Point Register Pair HL to 4758H, the status byte of the command interpreter. 4EB1H comes back here to read the next line after a comment line.
4E47
SET 2,(HL) CB D6
Set bit 2 of the status byte at Register Pair HL (4758H): a command line is being read from the keyboard. 4E53H clears the whole byte when the line is in.
4E49
PUSH HL E5
Save Register Pair HL (4758H, the status byte) to the stack, for 4E52H.
4E4A
LD HL,4225H 21 25 42
Point Register Pair HL to 4225H, INBUF$, the buffer for the line.
4E4D
LD B,3FH 06 3F
Load Register B with 3FH (63), the most characters the line may have.
4E4F
GOSUB to the ROM's line input at 0040H (05D9H): it reads up to Register B (63) characters into the buffer at Register Pair HL (4225H), echoing them, and stores 0DH after them when ENTER or BREAK is pressed. It returns Register Pair HL = 4225H, Register B = the number of characters typed and the CARRY FLAG set when BREAK ended the line.
4E52
EX (SP),HL E3
Exchange Register Pair HL (4225H, the line) with the top of the stack (the Stack Pointer is not changed): Register Pair HL = 4758H, the status byte, and 4225H is kept on the stack.
4E53
LD (HL),00H 36 00
Store 00H at Register Pair HL (4758H): every bit of the status byte is cleared, bit 2 (a line is being read) and bit 1 (the line came from a program) included. Function 30H (@CMNDI) joins here from 4E27H. LD does not change the flags.
4E55
POP HL E1
Restore Register Pair HL from the stack: 4225H, the start of the command line in INBUF$ (pushed at 4E52H, or at 4E19H for function 30H).
4E56
If the CARRY FLAG is set (BREAK ended the line typed at the keyboard), JUMP to 4EA3H, which ends at @ABORT (4030H) and LDOS Ready again. Function 30H arrives here with the CARRY FLAG clear.
4E58
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, @EXIT, the entry that ends a program and goes back to LDOS Ready.
4E5B
PUSH BC C5
Save Register Pair BC (402DH) to the stack as the return address of the command: when the command, or the program it runs, ends with a RET, @EXIT runs and LDOS Ready follows.

4E5CH - Point the BREAK Vector at 4206H

Every command line, typed or given by a program, passes here before it is carried out. The jump at 4203H, which SYS0/SYS's reset sets to its cassette exit at 44FAH, is made a jump to 4206H. The ROM jumps to 4203H when BREAK is pressed while it waits on the cassette or the RS-232 port, and SYS0/SYS's interrupt routine sends interrupt bits 0 and 1 there. At 4206H-4208H SYS0/SYS holds three bytes of 00H, which run on into its @CKDRV request at 4209H. Nothing on this diskette puts 44FAH back at 4204H-4205H; BASIC/CMD stores an address of its own there (its 5C90H).

4E5C
LD BC,4206H 01 06 42
Load Register Pair BC with 4206H, the new target of the jump at 4203H: three bytes of 00H in SYS0/SYS (4206H-4208H) followed by its @CKDRV request at 4209H.
4E5F
LD (4204H),BC ED 43 04 42
Store Register Pair BC (4206H) at 4204H-4205H, the address of the jump at 4203H, over 44FAH (SYS0/SYS's cassette exit, stored there by its reset) or the 4206H stored by the command before.
4E63
LD A,C3H 3E C3
Load Register A with C3H, the opcode of JP, for the byte at 4203H.
4E65
LD (4203H),A 32 03 42
Store Register A (C3H, JP) at 4203H: 4203H-4205H now hold JP 4206H, whatever a program had put at 4203H before.

4E68H - Carry Out a Command Line

Register Pair HL = the command line (in INBUF$, 4225H). The line is first passed to the job log (428DH). A line that starts with a period is a comment (4EACH). A line that starts with ! is always run as a program file. Otherwise the first word is taken as a file specification into CFCB$ (4485H) and looked up in the table of library commands at 4EC3H; a command found there is carried out by its member of SYS6/SYS or SYS7/SYS (4EB4H). Any other word gets the extension /CMD when it has none and is loaded and run by @RUN (4433H), with Register Pair HL pointing at the rest of the line.

4E68
GOSUB to 428DH (@LOGER) with Register Pair HL = the command line, to send it to the job log. SYS0/SYS holds a RET at 428DH, so nothing is sent until a module puts a JP to its own code there (428DH-428FH).
4E6B
LD A,(HL) 7E
Fetch the first character of the command line at Register Pair HL into Register A.
4E6C
CP 2EH FE 2E
Compare Register A (the first character) against 2EH, a period.
4E6E
If the Z FLAG is set (the line starts with a period: a comment), JUMP to 4EACH.
4E70
SUB 21H D6 21
SUBtract 21H from Register A (the first character): Register A = 00H and the Z FLAG set when it is ! (21H).
4E72
LD (4E87H),A 32 87 4E
Store Register A (the first character less 21H) at 4E87H, the operand of the LD A at 4E86H: 00H after a !, which makes 4E89H pass over the search of the command table.
4E75
If the NZ FLAG is set (the line does not start with !), JUMP to 4E78H with Register Pair HL at the first character.
4E77
INC HL 23
INCrement Register Pair HL past the ! to the first character of the program name.
4E78
LD DE,4485H 11 85 44
Point Register Pair DE to 4485H, CFCB$, the 32 byte control block for the command (4485H-44A4H).
4E7B
GOSUB to 4FDCH (as @FSPEC) to take the first word of the line at Register Pair HL as a file specification into CFCB$ at Register Pair DE (4485H), ended by 03H. It returns Register Pair DE = 4485H, Register Pair HL after the word and the Z FLAG set when the word is a file specification.
4E7E
If the NZ FLAG is set (no file specification: an empty line, or a line that starts with a space or another character that cannot start a name), JUMP to 4EA3H to end the command.
4E80
LD A,(DE) 1A
Fetch the first byte of the file specification at Register Pair DE (4485H) into Register A.
4E81
CP 2AH FE 2A
Compare Register A (the first byte of the specification) against 2AH, the asterisk that starts a device name such as the keyboard's KI.
4E83
If the Z FLAG is set (a device name), JUMP to 4EA3H: a device is not run as a command.
4E85
PUSH HL E5
Save Register Pair HL (the command line after the first word: the command's parameters) to the stack.
4E86
LD A,00H 3E 00
Load Register A with the first character of the line less 21H. Self-Modifying Code
The operand at 4E87H is 00H in the file; 4E72H stores the first character of the command line less 21H there, so it is 00H when the line starts with ! and not 00H otherwise.
4E88
OR A B7
Set the flags from Register A (OR A), the first character less 21H: the Z FLAG is set when the line started with !.
4E89
If the Z FLAG is set (the line started with !), JUMP to 4E93H: the word is run as a program file even when it is the name of a library command.
4E8B
LD BC,4EC3H 01 C3 4E
Point Register Pair BC to 4EC3H, the table of library commands: 35 entries of 8 bytes.
4E8E
GOSUB to 50D1H to look for the word at Register Pair DE (CFCB$, 4485H) in the table at Register Pair BC (4EC3H). On a match it returns the Z FLAG, Register A = 00H and Register Pair DE = the entry's last two bytes (Register E the member number, Register D the flags); Register Pair HL is kept.
4E91
If the Z FLAG is set (the word is a library command), JUMP to 4EB4H to carry it out.
4E93
LD HL,51F0H 21 F0 51
Point Register Pair HL to 51F0H, the text CMD, the extension of a program file.
4E96
GOSUB to 504EH (as @FEXT) to give the file specification at Register Pair DE (CFCB$, 4485H) the extension at Register Pair HL (51F0H, CMD) when it has none, so that a word such as FORMAT becomes FORMAT/CMD. Register Pair DE (4485H) is kept.
4E99
POP HL E1
Restore Register Pair HL from the stack: the command line after the first word (pushed at 4E85H).
4E9A
LD A,(4758H) 3A 58 47
Fetch the status byte of the command interpreter from 4758H into Register A.
4E9D
AND 10H E6 10
Mask Register A (the status byte) to bit 4: the Z FLAG is set when bit 4 is clear.
4E9F
If the Z FLAG is set (bit 4 clear; of the files on this diskette only LCOMM/CMD sets it, its 6519H), JUMP to 4433H (@RUN) to load and run the program named in CFCB$ at Register Pair DE (4485H). The program starts with Register Pair HL at its parameters (the rest of the command line) and ends by returning to the address on the stack: 402DH, or the dispatcher's return for function 20H.
4EA2
RET C9
Bit 4 set: RETurn without running the program, with the NZ FLAG, Register A = 10H, the file specification with its extension in CFCB$ (4485H) and Register Pair HL at the parameters.

4EA3H - End a Command That Cannot Be Carried Out

Reached when BREAK ended the typed line, when the first word is not a file specification and when it is a device name. A command line from a program (function 20H, bit 1 of 4758H set) returns to the program with Register A = 02H and the NZ FLAG; otherwise @ABORT (4030H) ends it and LDOS Ready follows.

4EA3
LD A,(4758H) 3A 58 47
Fetch the status byte of the command interpreter from 4758H into Register A.
4EA6
AND 02H E6 02
Mask Register A (the status byte) to bit 1, set by 4E29H when the command line came from a program.
4EA8
RET NZ C0
If the NZ FLAG is set (bit 1 set), RETurn to the dispatcher, and so to the program that called 429CH, with Register A = 02H and the NZ FLAG set.
4EA9
JUMP to 4030H, @ABORT, which issues request 93H: the command loop at 4E2EH runs again and displays LDOS Ready.

4EACH - A Comment Line

A command line that starts with a period is not carried out. While a JCL job runs (bit 5 of SFLAG$, 442BH) the command returns at once, so the job goes on with its next line; otherwise the next line is read from the keyboard without LDOS Ready being displayed again.

4EAC
LD A,(442BH) 3A 2B 44
Fetch SFLAG$, the system flags, from 442BH into Register A.
4EAF
BIT 5,A CB 6F
Test bit 5 of Register A (SFLAG$): set while a JCL job runs.
4EB1
If the Z FLAG is set (no JCL job), JUMP to 4E44H to read the next line from the keyboard. The return address already on the stack (402DH, or the dispatcher's return for function 20H) stays there, under the 402DH that the next line pushes.
4EB3
RET C9
RETurn with Register A = SFLAG$ (442BH) and the NZ FLAG set: to 402DH (@EXIT), whose request code SYS11/SYS changes while a job runs so that the job's next line follows, or to the program that called 429CH.

4EB4H - Carry Out a Library Command

The word was found in the table at 4EC3H: Register E = the entry's member number and Register D its flags. When bit 7 of the flags is clear, Register Pair DE is the address of the command's code in SYS1/SYS (only BOOT, 4EC2H). When it is set the command is a member of a library: of SYS6/SYS (request 88H) when bit 6 is clear, of SYS7/SYS (request 89H) when bit 6 is set. RST 28H loads member Register B and runs it with Register Pair HL at the parameters. SYS1/SYS stays in memory at 4E00H-51FEH while the member runs above it, at 5200H (5A00H for FILTER and SET).

4EB4
POP HL E1
Restore Register Pair HL from the stack: the command line after the command word (pushed at 4E85H), the parameters for the command.
4EB5
LD (4405H),A 32 05 44
Store Register A (00H, from the table search) at 4405H, the BREAK trap switch: the trap is off while a library command runs.
4EB8
LD A,D 7A
Copy Register D (the entry's flags: 80H for SYS6/SYS, C0H for SYS7/SYS, 4EH for BOOT) into Register A.
4EB9
RLA 17
Rotate Register A (the flags) left through the CARRY FLAG, which the table search left clear: bit 7 goes into the CARRY FLAG and bit 6 into bit 7 of Register A.
4EBA
PUSH DE D5
Save Register Pair DE (the entry's two bytes) to the stack.
4EBB
RET NC D0
If the NO CARRY FLAG is set (bit 7 clear: the two bytes are an address in SYS1/SYS), RETurn to the address in Register Pair DE just pushed: BOOT goes to 4EC2H.
4EBC
POP DE D1
A library command: restore Register Pair DE (the entry's two bytes) from the stack.
4EBD
LD B,E 43
Copy Register E (the member number, for example 21H for DIR) into Register B: the member the module loader looks for (SYS0/SYS 4CF7H).
4EBE
RLA 17
Rotate Register A left through the CARRY FLAG again: bit 6 of the flags goes into the CARRY FLAG and the CARRY FLAG (1) into bit 0, so Register A = 01H (bits 5-0 of the flags are 0).
4EBF
ADC A,87H CE 87
ADD 87H and the CARRY FLAG to Register A (01H): Register A = 88H for a member of SYS6/SYS (bit 6 clear) or 89H for a member of SYS7/SYS (bit 6 set).
4EC1
RST 28H EF
RST 28H: call the supervisor dispatcher (400CH, 4BCCH) with the request code in Register A (88H or 89H) and the member number in Register B. The dispatcher drops the return address the RST pushes, loads the member (at 5200H; the member of FILTER and SET at 5A00H) and calls it with Register Pair HL = the parameters. When the member returns, the dispatcher puts the BREAK trap switch back as it found it (00H) and returns to the address on the stack: 402DH, or the dispatcher's return for function 20H.

4EC2H - BOOT: Start the System Again

The table entry of BOOT holds the address 4EC2H instead of a member number. RST 00H jumps to the ROM's power up entry at 0000H, which starts the computer as if it had just been turned on: the boot sector of drive 0 is read and LDOS is loaded again.

4EC2
RST 00H C7
RST 00H: jump to 0000H, the ROM's power up entry (DI, XOR A, JP 3015H), which reads the boot sector of drive 0 into 4300H and starts it, so LDOS loads again from the start. The return address the RST pushes (4EC3H) is never used.

4EC3H - The Library Command Table (Data)

35 entries of 8 bytes, searched by 50D1H (called from 4E8EH) and listed by the LIB command (the member 19H of SYS6/SYS reads the table from 4EC3H while SYS1/SYS is still in memory). Each entry is the command name in capitals, padded with spaces to 6 characters, then two bytes: the member number and the flags. Flags 80H: a member of SYS6/SYS, request 88H; C0H: a member of SYS7/SYS, request 89H (bit 7 a library command, bit 6 SYS7/SYS). The two bytes of BOOT are the address 4EC2H. A 00H after the last entry ends the table (4FDBH). The member numbers are those of the type 08H member headers of SYS6/SYS and SYS7/SYS, which also give the address each member is entered at; several commands share the code of one member through different entry addresses. Member 1CH of SYS7/SYS has no entry here.

4EC3-4ECA
DEFM "APPEND" / DEFB 31H, 80H 41 50 50 45 4E 44 31 80
APPEND: member 31H of SYS6/SYS (flags 80H, request 88H), entered at 5203H; the member of COPY (32H), which it shares.
4ECB-4ED2
DEFM "ATTRIB" / DEFB 51H, C0H 41 54 54 52 49 42 51 C0
ATTRIB: member 51H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4ED3-4EDA
DEFM "AUTO " / DEFB 11H, C0H 41 55 54 4F 20 20 11 C0
AUTO: member 11H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4EDB-4EE2
DEFM "BOOT " / DEFB C2H, 4EH 42 4F 4F 54 20 20 C2 4E
BOOT: the address 4EC2H (bytes C2H 4EH; bit 7 of 4EH is clear), the code of BOOT in SYS1/SYS. Bit 6 of 4EH is set, so the LIB command lists BOOT with the commands of SYS7/SYS.
4EE3-4EEA
DEFM "BUILD " / DEFB 33H, C0H 42 55 49 4C 44 20 33 C0
BUILD: member 33H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4EEB-4EF2
DEFM "CLS " / DEFB 24H, 80H 43 4C 53 20 20 20 24 80
CLS: member 24H of SYS6/SYS (flags 80H, request 88H), entered at 5203H; the member of LIB (19H), which it shares.
4EF3-4EFA
DEFM "COPY " / DEFB 32H, 80H 43 4F 50 59 20 20 32 80
COPY: member 32H of SYS6/SYS (flags 80H, request 88H), entered at 5200H; the same code as APPEND (31H, 5203H).
4EFB-4F02
DEFM "CREATE" / DEFB 13H, C0H 43 52 45 41 54 45 13 C0
CREATE: member 13H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F03-4F0A
DEFM "DATE " / DEFB 15H, C0H 44 41 54 45 20 20 15 C0
DATE: member 15H of SYS7/SYS (flags C0H, request 89H), entered at 5203H; the member of TIME (16H), which it shares.
4F0B-4F12
DEFM "DEBUG " / DEFB 14H, C0H 44 45 42 55 47 20 14 C0
DEBUG: member 14H of SYS7/SYS (flags C0H, request 89H), entered at 5203H; the member of VERIFY (1BH), which it shares.
4F13-4F1A
DEFM "DEVICE" / DEFB 61H, 80H 44 45 56 49 43 45 61 80
DEVICE: member 61H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F1B-4F22
DEFM "DIR " / DEFB 21H, 80H 44 49 52 20 20 20 21 80
DIR: member 21H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F23-4F2A
DEFM "DO " / DEFB 91H, 80H 44 4F 20 20 20 20 91 80
DO: member 91H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F2B-4F32
DEFM "DUMP " / DEFB 71H, C0H 44 55 4D 50 20 20 71 C0
DUMP: member 71H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F33-4F3A
DEFM "FILTER" / DEFB 66H, 80H 46 49 4C 54 45 52 66 80
FILTER: member 66H of SYS6/SYS (flags 80H, request 88H), entered at 5A00H; the same code as SET (65H, 5A01H).
4F3B-4F42
DEFM "FORMS " / DEFB B1H, C0H 46 4F 52 4D 53 20 B1 C0
FORMS: member B1H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F43-4F4A
DEFM "FREE " / DEFB 22H, C0H 46 52 45 45 20 20 22 C0
FREE: member 22H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F4B-4F52
DEFM "KILL " / DEFB 18H, 80H 4B 49 4C 4C 20 20 18 80
KILL: member 18H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F53-4F5A
DEFM "LIB " / DEFB 19H, 80H 4C 49 42 20 20 20 19 80
LIB: member 19H of SYS6/SYS (flags 80H, request 88H), entered at 5200H; the same code as CLS (24H, 5203H) and TOF (25H, 5206H).
4F5B-4F62
DEFM "LINK " / DEFB 62H, 80H 4C 49 4E 4B 20 20 62 80
LINK: member 62H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F63-4F6A
DEFM "LIST " / DEFB 41H, 80H 4C 49 53 54 20 20 41 80
LIST: member 41H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F6B-4F72
DEFM "LOAD " / DEFB 81H, 80H 4C 4F 41 44 20 20 81 80
LOAD: member 81H of SYS6/SYS (flags 80H, request 88H), entered at 5203H; the member of RUN (82H), which it shares.
4F73-4F7A
DEFM "MEMORY" / DEFB 1EH, 80H 4D 45 4D 4F 52 59 1E 80
MEMORY: member 1EH of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F7B-4F82
DEFM "PURGE " / DEFB 72H, C0H 50 55 52 47 45 20 72 C0
PURGE: member 72H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F83-4F8A
DEFM "RENAME" / DEFB 53H, 80H 52 45 4E 41 4D 45 53 80
RENAME: member 53H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F8B-4F92
DEFM "RESET " / DEFB 63H, 80H 52 45 53 45 54 20 63 80
RESET: member 63H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F93-4F9A
DEFM "ROUTE " / DEFB 64H, 80H 52 4F 55 54 45 20 64 80
ROUTE: member 64H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F9B-4FA2
DEFM "RUN " / DEFB 82H, 80H 52 55 4E 20 20 20 82 80
RUN: member 82H of SYS6/SYS (flags 80H, request 88H), entered at 5200H; the same code as LOAD (81H, 5203H).
4FA3-4FAA
DEFM "SET " / DEFB 65H, 80H 53 45 54 20 20 20 65 80
SET: member 65H of SYS6/SYS (flags 80H, request 88H), entered at 5A01H; the member of FILTER (66H), which it shares.
4FAB-4FB2
DEFM "SETCOM" / DEFB B2H, C0H 53 45 54 43 4F 4D B2 C0
SETCOM: member B2H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4FB3-4FBA
DEFM "SPOOL " / DEFB A2H, 80H 53 50 4F 4F 4C 20 A2 80
SPOOL: member A2H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4FBB-4FC2
DEFM "SYSTEM" / DEFB A1H, C0H 53 59 53 54 45 4D A1 C0
SYSTEM: member A1H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4FC3-4FCA
DEFM "TIME " / DEFB 16H, C0H 54 49 4D 45 20 20 16 C0
TIME: member 16H of SYS7/SYS (flags C0H, request 89H), entered at 5200H; the same code as DATE (15H, 5203H).
4FCB-4FD2
DEFM "TOF " / DEFB 25H, 80H 54 4F 46 20 20 20 25 80
TOF: member 25H of SYS6/SYS (flags 80H, request 88H), entered at 5206H; the member of LIB (19H), which it shares.
4FD3-4FDA
DEFM "VERIFY" / DEFB 1BH, C0H 56 45 52 49 46 59 1B C0
VERIFY: member 1BH of SYS7/SYS (flags C0H, request 89H), entered at 5200H; the same code as DEBUG (14H, 5203H).
4FDB
DEFB 00H 00
4FDBH: 00H, the end of the table: 50DEH finds 00H as the first byte of the next entry and the search ends with no match.

4FDCH - @FSPEC: Take a File Specification

Function 40H (request C3H, 441CH); the command loop calls it too (4E7BH). Register Pair HL = the text, Register Pair DE = where the specification goes (a file control block). It copies NAME/EXT.PASSWORD:D: a name of up to 8 letters and digits, then a / and an extension of up to 3, a period and a password of up to 8, a colon and a drive of 1. Small letters become capitals and characters past a field's length are dropped. Instead of a name the text may hold an asterisk and a device name of up to 2 letters and digits, such as the keyboard's KI. The specification ends with 03H. When the word taken is TO, ON, OVER or USING (the table at 502DH) it is passed over and the next word is taken. Returns Register A = 00H and the Z FLAG, Register Pair DE unchanged and Register Pair HL after the specification (past the character that ended it and any spaces after it, or at an ending 0DH, 03H or open parenthesis); or the NZ FLAG with Register A = the character found where a name, a password or a drive was needed.

4FDC
PUSH DE D5
Save Register Pair DE (the start of the destination, a file control block such as CFCB$ at 4485H) to the stack.
4FDD
GOSUB to 507FH to copy the name, up to 8 letters and digits, from the text at Register Pair HL to Register Pair DE. It returns Register A = the character that ended the field, Register Pair DE at the 03H it stored after the field and the NZ FLAG when no character was copied.
4FE0
If the NZ FLAG is set (no name: the text starts with a character that is not a letter or a digit), JUMP to 501EH to see whether it is a device name.
4FE2
CP 2FH FE 2F
Compare Register A (the character that ended the name) against 2FH, the / before an extension.
4FE4
If the NZ FLAG is set (no extension), JUMP to 4FEDH.
4FE6
LD (DE),A 12
Store Register A (the /) at Register Pair DE, over the 03H after the name.
4FE7
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
4FE8
LD B,03H 06 03
Load Register B with 03H, the length of an extension.
4FEA
GOSUB to 5081H to copy the extension, up to Register B (3) letters and digits, from Register Pair HL to Register Pair DE; Register A returns the character that ended it. An empty extension is accepted: the flags are not tested.
4FED
CP 2EH FE 2E
Compare Register A (the character that ended the last field) against 2EH, the period before a password.
4FEF
If the NZ FLAG is set (no password), JUMP to 4FF8H.
4FF1
LD (DE),A 12
Store Register A (the period) at Register Pair DE, over the 03H after the last field.
4FF2
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
4FF3
GOSUB to 507FH to copy the password, up to 8 letters and digits, from Register Pair HL to Register Pair DE; Register A returns the character that ended it and the NZ FLAG for an empty password.
4FF6
If the NZ FLAG is set (a period with no password after it), JUMP to 502BH to return the error.
4FF8
CP 3AH FE 3A
Compare Register A (the character that ended the last field) against 3AH, the colon before a drive number.
4FFA
If the NZ FLAG is set (no drive), JUMP to 5005H.
4FFC
LD (DE),A 12
Store Register A (the colon) at Register Pair DE, over the 03H after the last field.
4FFD
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
4FFE
LD B,01H 06 01
Load Register B with 01H, the length of the drive field.
5000
GOSUB to 5081H to copy the drive, one letter or digit, from Register Pair HL to Register Pair DE; Register A returns the character that ended it. A second letter or digit is dropped.
5003
If the NZ FLAG is set (a colon with no drive after it), JUMP to 502BH to return the error.
5005
CP 21H FE 21
Compare Register A (the character that ended the specification) against 21H, an exclamation mark.
5007
If the NZ FLAG is set (not !), JUMP to 500CH to end the specification.
5009
LDI ED A0
A ! after the specification: copy the character after the ! from Register Pair HL to Register Pair DE, over the 03H, and step both on (Register Pair BC goes down by one and is not used).
500B
LD A,(HL) 7E
Fetch the next character at Register Pair HL, the one after the character copied, into Register A as the character that ends the specification.
500C
LD C,A 4F
Copy Register A (the character that ended the specification) into Register C. 5029H joins here after a device name.
500D
LD A,03H 3E 03
Load Register A with 03H, the end of a specification.
500F
LD (DE),A 12
Store Register A (03H) at Register Pair DE, after the last field.
5010
LD A,C 79
Copy Register C (the character that ended the specification) back into Register A.
5011
POP DE D1
Restore Register Pair DE from the stack: the start of the specification.
5012
PUSH DE D5
Save Register Pair DE (the start of the specification) to the stack again.
5013
LD BC,502DH 01 2D 50
Point Register Pair BC to 502DH, the table of the words TO, ON, OVER and USING.
5016
GOSUB to 50D1H to look for the specification at Register Pair DE in the table at Register Pair BC (502DH); the Z FLAG comes back set when it is one of the four words. Register Pair HL (the text) is kept.
5019
POP DE D1
Restore Register Pair DE from the stack: the start of the specification (on a match the search returned the entry's two bytes, 4300H, in Register Pair DE). POP does not change the flags.
501A
If the Z FLAG is set (the word is TO, ON, OVER or USING), JUMP to 4FDCH to take the next word of the text at Register Pair HL into Register Pair DE in its place.
501C
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set: the specification is good.
501D
RET C9
RETurn with Register A = 00H, the Z FLAG set, Register Pair DE = the specification and Register Pair HL after it.

501EH - A Device Name

The text did not start with a letter or a digit. When it starts with an asterisk, a device name of up to 2 letters and digits follows (KI, DO, PR); any other character is an error.

501E
CP 2AH FE 2A
Compare Register A (the first character of the text, which ended the empty name) against 2AH, an asterisk.
5020
If the NZ FLAG is set (not an asterisk), JUMP to 502BH to return the error with Register A = the character.
5022
LD (DE),A 12
Store Register A (2AH, the asterisk) at Register Pair DE, the first byte of the destination, over the 03H the empty name left there.
5023
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
5024
LD B,02H 06 02
Load Register B with 02H, the length of a device name.
5026
GOSUB to 5081H to copy the device name, up to Register B (2) letters and digits, from Register Pair HL to Register Pair DE; Register A returns the character that ended it and the Z FLAG is set when a character was copied.
5029
If the Z FLAG is set (a device name), JUMP to 500CH to end the specification with 03H.
502B
POP DE D1
Restore Register Pair DE from the stack: the start of the destination. 4FF6H and 5003H come here for an empty password or drive. POP does not change the flags.
502C
RET C9
RETurn with the NZ FLAG set and Register A = the character that was found where a field was needed.

502DH - The Words @FSPEC Passes Over (Data)

Four entries in the layout of the command table, searched by 50D1H from 5016H: a word padded with spaces to 6 characters and two bytes, here always 4300H, which @FSPEC does not use. A 00H ends the table. In a line such as FILE1 TO FILE2, a second call of @FSPEC after FILE1 takes TO, finds it here and takes FILE2 instead.

502D-5034
DEFM "TO " / DEFW 4300H 54 4F 20 20 20 20 00 43
TO, the first word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search in Register Pair DE and dropped at 5019H.
5035-503C
DEFM "ON " / DEFW 4300H 4F 4E 20 20 20 20 00 43
ON, a word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search and dropped at 5019H.
503D-5044
DEFM "OVER " / DEFW 4300H 4F 56 45 52 20 20 00 43
OVER, a word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search and dropped at 5019H.
5045-504C
DEFM "USING " / DEFW 4300H 55 53 49 4E 47 20 00 43
USING, a word @FSPEC passes over; its last two bytes, 00H 43H (4300H), are returned by the search and dropped at 5019H.
504D
DEFB 00H 00
504DH: 00H, the end of the table: 50DEH finds 00H as the first byte of the next entry, so a word that is none of the four is not passed over.

504EH - @FEXT: Add a Default Extension

Function 50H (request D3H, 444BH); the command loop calls it too, to add CMD (4E96H). Register Pair DE = a file specification ended by 03H, Register Pair HL = a 3 character extension. When the name has no extension, a / and the three characters are put in after the name, and the 16 bytes from the end of the name on (a password and a drive) move up 4 places. A specification that has a / is not changed. Register Pair DE comes back unchanged; Register Pair HL too when nothing is added, and otherwise one less than the address of the extension.

504E
PUSH DE D5
Save Register Pair DE (the file specification) to the stack.
504F
PUSH HL E5
Save Register Pair HL (the default extension, 3 characters) to the stack.
5050
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the file specification, Register Pair DE = the extension.
5051
INC HL 23
INCrement Register Pair HL past the first character of the name, which cannot be a /.
5052
LD B,09H 06 09
Load Register B with 09H: the name's other 7 characters and the 2 bytes after them are looked at.
5054
LD A,(HL) 7E
Fetch the next byte of the file specification at Register Pair HL into Register A. 5061H loops back here.
5055
CP 2FH FE 2F
Compare Register A (the byte of the specification) against 2FH, the / of an extension.
5057
If the Z FLAG is set (the name has an extension), JUMP to 5063H to return with nothing changed.
5059
If the CARRY FLAG is set (Register A is below 2FH: the 03H at the end, or the period before a password), JUMP to 5066H to put the extension in here.
505B
GOSUB to 50C3H: the CARRY FLAG comes back clear when Register A (the byte of the specification) is a digit or a capital letter.
505E
If the CARRY FLAG is set (not a letter or a digit: the colon before a drive), JUMP to 5066H to put the extension in here.
5060
INC HL 23
INCrement Register Pair HL to the next byte of the name.
5061
DECrement Register B and LOOP BACK to 5054H until 9 bytes have been looked at; after that the specification is left as it is.
5063
POP HL E1
Restore Register Pair HL from the stack: the default extension.
5064
POP DE D1
Restore Register Pair DE from the stack: the file specification.
5065
RET C9
RETurn with the specification at Register Pair DE unchanged and Register Pair HL = the default extension.

5066H - Put the Extension In

Register Pair HL = the byte after the name (the 03H, a period or a colon). The 16 bytes from there are moved up 4 places, then the / and the three characters of the extension are stored in the gap after the name.

5066
LD BC,000FH 01 0F 00
Load Register Pair BC with 000FH (15), the offset of the last of the 16 bytes to move from Register Pair HL (the byte after the name).
5069
ADD HL,BC 09
ADD Register Pair BC (15) to Register Pair HL (the byte after the name): Register Pair HL = the 16th byte from the end of the name, the last byte to move.
506A
LD D,H 54
Copy Register H (the high byte of the last byte to move) into Register D.
506B
LD E,L 5D
Copy Register L (the low byte) into Register E: Register Pair DE = Register Pair HL, the last byte to move.
506C
INC DE 13
INCrement Register Pair DE (the last byte to move) by one.
506D
INC DE 13
INCrement Register Pair DE again: two bytes past the last byte to move.
506E
INC DE 13
INCrement Register Pair DE again: three bytes past the last byte to move.
506F
INC DE 13
INCrement Register Pair DE again: Register Pair DE = 4 bytes past Register Pair HL, where the last byte goes.
5070
INC BC 03
INCrement Register Pair BC (000FH) to 0010H, the 16 bytes to move.
5071
LDDR ED B8
Move 16 bytes from Register Pair HL down to Register Pair DE, 4 places up, last byte first, so that no byte is overwritten before it is moved. Register Pair HL ends at the last character of the name, Register Pair DE at the last byte of the 4 byte gap and Register Pair BC at 0000H.
5073
POP HL E1
Restore Register Pair HL from the stack: the default extension.
5074
INC HL 23
INCrement Register Pair HL to the extension's second character.
5075
INC HL 23
INCrement Register Pair HL to the extension's third character.
5076
LD C,03H 0E 03
Load Register C with 03H: Register Pair BC = 0003H (Register B is 00H after the move), the three characters of the extension.
5078
LDDR ED B8
Copy Register Pair BC (3) characters from Register Pair HL (the extension, last character first) to Register Pair DE (the last 3 bytes of the gap). Register Pair DE ends at the first byte of the gap, just after the name, Register Pair HL one byte before the extension and Register Pair BC at 0000H.
507A
LD A,2FH 3E 2F
Load Register A with 2FH, the / before an extension.
507C
LD (DE),A 12
Store Register A (/) at Register Pair DE, the first byte of the gap after the name.
507D
POP DE D1
Restore Register Pair DE from the stack: the file specification, now with its extension.
507E
RET C9
RETurn with Register Pair DE = the specification and Register Pair HL = one byte before the default extension.

507FH - Copy a Field of Letters and Digits

507FH copies a field of up to 8 characters, 5081H of up to Register B characters, from the text at Register Pair HL to Register Pair DE. Letters and digits are copied, small letters as capitals; letters and digits past the field's length are passed over. The field ends at 03H, 0DH or an open parenthesis (Register Pair HL stays at it), or at any other character (Register Pair HL passes it, and any spaces after a space). An 03H is stored after the field. Returns Register A and Register C = the character that ended the field, Register Pair DE at the 03H and the Z FLAG set when at least one character was copied (the NZ FLAG for an empty field).

507F
LD B,08H 06 08
Load Register B with 08H, the length of a name or a password.
5081
LD A,B 78
Copy Register B (the field's length) into Register A. 4FEAH, 5000H, 5026H and 5127H enter here with their own length.
5082
LD (50BFH),A 32 BF 50
Store Register A (the length, never 00H) at 50BFH, the operand of the LD A at 50BEH: the field counts as empty until a character is copied.
5085
INC B 04
INCrement Register B (the field's length): one more, as 50A3H counts it down before each character it stores.
5086
LD A,(HL) 7E
Fetch the next character of the text at Register Pair HL into Register A. 50ACH and 50AFH loop back here.
5087
CP 03H FE 03
Compare Register A (the character) against 03H, an end of text mark.
5089
If the Z FLAG is set (03H), JUMP to 50B1H to end the field with Register Pair HL at it.
508B
CP 0DH FE 0D
Compare Register A (the character) against 0DH, the end of the line.
508D
If the Z FLAG is set (0DH), JUMP to 50B1H to end the field with Register Pair HL at it.
508F
CP 28H FE 28
Compare Register A (the character) against 28H, the open parenthesis of a parameter list.
5091
If the Z FLAG is set (the parenthesis), JUMP to 50B1H to end the field with Register Pair HL at it.
5093
INC HL 23
INCrement Register Pair HL past the character.
5094
GOSUB to 50C3H: the CARRY FLAG comes back clear when Register A (the character) is a digit or a capital letter.
5097
If the NO CARRY FLAG is set (a digit or a capital letter), JUMP to 50A3H to copy it.
5099
CP 61H FE 61
Compare Register A (the character) against 61H, a small a.
509B
If the CARRY FLAG is set (below a: not a letter or a digit), JUMP to 50B1H: the character ends the field, with Register Pair HL past it.
509D
CP 7BH FE 7B
Compare Register A (the character) against 7BH, the character after a small z.
509F
If the NO CARRY FLAG is set (above z), JUMP to 50B1H: the character ends the field, with Register Pair HL past it.
50A1
RES 5,A CB AF
Clear bit 5 of Register A (a small letter): it becomes the capital.
50A3
DEC B 05
DECrement Register B, the count of characters the field may still take (plus one).
50A4
If the Z FLAG is set (the field is full), JUMP to 50AEH: the character is passed over.
50A6
LD (DE),A 12
Store Register A (the letter or digit) at Register Pair DE, in the field.
50A7
XOR A AF
Set Register A to 00H (XOR A), the value of the field flag once a character is in the field.
50A8
LD (50BFH),A 32 BF 50
Store Register A (00H) at 50BFH, the operand of the LD A at 50BEH: a character has been copied.
50AB
INC DE 13
INCrement Register Pair DE to the next byte of the field.
50AC
JUMP to 5086H for the next character of the text at Register Pair HL.
50AE
INC B 04
INCrement Register B (00H) back to 01H, so that the next letter or digit is passed over too.
50AF
JUMP to 5086H for the next character of the text at Register Pair HL.
50B1
LD C,A 4F
Copy Register A (the character that ended the field) into Register C.
50B2
CP 20H FE 20
Compare Register A (the character that ended the field) against 20H, a space.
50B4
If the NZ FLAG is set (not a space), JUMP to 50BBH.
50B6
CP 23H FE 23
Compare Register A (20H, the space) against 23H: only the flags change, and the CP (HL) below follows. Entered at 50B7H by the JR Z at 50B9H, the operand byte 23H is the instruction INC HL, which moves Register Pair HL on to the next character.
50B8
CP (HL) BE
Compare Register A (20H, a space) against the character at Register Pair HL: the Z FLAG is set when it is another space.
50B9
If the Z FLAG is set (another space), JUMP to 50B7H, the INC HL inside the CP 23H above, to pass over it. Register Pair HL ends at the first character after the spaces.
50BB
LD A,03H 3E 03
Load Register A with 03H, the end of a field.
50BD
LD (DE),A 12
Store Register A (03H) at Register Pair DE, after the last character copied.
50BE
LD A,00H 3E 00
Load Register A with the field's flag. Self-Modifying Code
The operand at 50BFH is 00H in the file; 5082H stores the field's length there (never 00H) and 50A8H stores 00H when a character is copied, so Register A = 00H when the field has at least one character.
50C0
OR A B7
Set the flags from Register A (OR A), the field's flag: the Z FLAG is set when the field has a character, the NZ FLAG when it is empty.
50C1
LD A,C 79
Copy Register C (the character that ended the field) into Register A. LD does not change the flags.
50C2
RET C9
RETurn with Register A = Register C = the character that ended the field, Register Pair DE at the 03H after the field and the Z FLAG set when the field is not empty.

50C3H - Is It a Letter or a Digit?

Returns the CARRY FLAG clear when Register A is 30H-39H (a digit) or 41H-5AH (a capital letter), and set for any other character. Register A is not changed.

50C3
CP 30H FE 30
Compare Register A (the character) against 30H, the digit 0.
50C5
RET C D8
If the CARRY FLAG is set (Register A is below 0), RETurn with the CARRY FLAG set: not a letter or a digit.
50C6
CP 3AH FE 3A
Compare Register A (the character) against 3AH, the character after 9.
50C8
If the CARRY FLAG is set (Register A is a digit 0-9), JUMP to 50CFH to turn the CARRY FLAG into the answer.
50CA
CP 41H FE 41
Compare Register A (the character) against 41H, the letter A.
50CC
RET C D8
If the CARRY FLAG is set (Register A is 3AH-40H, punctuation), RETurn with the CARRY FLAG set.
50CD
CP 5BH FE 5B
Compare Register A (the character) against 5BH, the character after Z: the CARRY FLAG is set for A-Z.
50CF
CCF 3F
Complement the CARRY FLAG: now clear for a digit or a capital letter in Register A, set for 5BH and above.
50D0
RET C9
RETurn with the CARRY FLAG as the answer and Register A (the character) unchanged.

50D1H - Look a Word Up in a Table

Register Pair BC = a table of 8 byte entries (a word in capitals padded with spaces to 6 characters, then two bytes) ended by 00H; Register Pair DE = the word, ended by 03H, 0DH or any character that is not a letter or a digit. Used for the command table (4E8EH), the words @FSPEC passes over (5016H) and the parameter table of @PARAM (5138H). Up to 6 characters are compared: the word matches an entry when all 6 are equal, or when the word ends where the entry has a space. Returns the Z FLAG with Register A = 00H and Register Pair DE = the entry's two bytes, or Register A = 01H and the NZ FLAG when no entry matches. Register Pair HL and Register C are kept; Register B is not.

50D1
PUSH HL E5
Save Register Pair HL (the caller's) to the stack.
50D2
LD H,B 60
Copy Register B (the high byte of the table's address) into Register H.
50D3
LD L,C 69
Copy Register C (the low byte) into Register L: Register Pair HL = the table at Register Pair BC, its first entry.
50D4
LD A,(DE) 1A
Fetch the first character of the word at Register Pair DE into Register A. 50E0H loops back here for each entry.
50D5
CP (HL) BE
Compare Register A (the word's first character) against the first character of the entry at Register Pair HL.
50D6
If the Z FLAG is set (the same), JUMP to 50E5H to compare the rest.
50D8
PUSH BC C5
Save Register Pair BC (Register C the low byte of the table's address, Register B the count left by an earlier comparison) to the stack. 5111H comes back here after a mismatch.
50D9
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the length of an entry.
50DC
ADD HL,BC 09
ADD Register Pair BC (8) to Register Pair HL (the entry): Register Pair HL = the next entry.
50DD
POP BC C1
Restore Register Pair BC from the stack: Register C is again the low byte of the table's address.
50DE
LD A,(HL) 7E
Fetch the first byte of the next entry at Register Pair HL into Register A.
50DF
OR A B7
Set the flags from Register A (OR A), the entry's first byte: the Z FLAG is set by the 00H at the end of the table.
50E0
If the NZ FLAG is set (another entry), JUMP to 50D4H to compare it.
50E2
POP HL E1
Restore Register Pair HL (the caller's) from the stack.
50E3
INC A 3C
INCrement Register A (00H) to 01H with the NZ FLAG set: the word is not in the table.
50E4
RET C9
RETurn with Register A = 01H and the NZ FLAG set.
50E5
LD B,05H 06 05
Load Register B with 05H, the characters 2 to 6 still to compare.
50E7
PUSH HL E5
Save Register Pair HL (the entry) to the stack.
50E8
PUSH DE D5
Save Register Pair DE (the word) to the stack.
50E9
INC DE 13
INCrement Register Pair DE to the word's next character. 50F7H loops back here.
50EA
INC HL 23
INCrement Register Pair HL to the entry's next character.
50EB
LD A,(DE) 1A
Fetch the word's character at Register Pair DE into Register A.
50EC
CP 03H FE 03
Compare Register A (the word's character) against 03H, the end of the word.
50EE
If the Z FLAG is set (the word has ended), JUMP to 510AH: it matches if the entry has a space here.
50F0
CP 0DH FE 0D
Compare Register A (the word's character) against 0DH, the end of the line.
50F2
If the Z FLAG is set (the word has ended), JUMP to 510AH.
50F4
CP (HL) BE
Compare Register A (the word's character) against the entry's character at Register Pair HL.
50F5
If the NZ FLAG is set (they differ), JUMP to 5105H.
50F7
DECrement Register B (the characters left to compare) and LOOP BACK to 50E9H until all 6 have been found equal.
50F9
POP DE D1
A match: restore Register Pair DE from the stack (the word's start) and drop it. 510DH joins here.
50FA
POP DE D1
Restore Register Pair DE from the stack: the start of the entry that matched.
50FB
LD HL,0006H 21 06 00
Load Register Pair HL with 0006H, the offset of the entry's two bytes.
50FE
ADD HL,DE 19
ADD Register Pair DE (the entry) to Register Pair HL: Register Pair HL = the entry + 6.
50FF
LD E,(HL) 5E
Load Register E with byte +06H of the entry at Register Pair HL: the member number in the command table, the low byte of an address in a parameter table.
5100
INC HL 23
INCrement Register Pair HL to byte +07H of the entry.
5101
LD D,(HL) 56
Load Register D with byte +07H of the entry at Register Pair HL: the flags in the command table, the high byte of the address in a parameter table. Register Pair DE = the entry's two bytes.
5102
POP HL E1
Restore Register Pair HL (the caller's) from the stack.
5103
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set: the word was found.
5104
RET C9
RETurn with the Z FLAG set, Register A = 00H and Register Pair DE = the entry's two bytes.
5105
GOSUB to 50C3H: the CARRY FLAG comes back clear when the word's character in Register A is a digit or a capital letter.
5108
If the NO CARRY FLAG is set (a letter or a digit that differs from the entry's), JUMP to 510FH: no match.
510A
LD A,(HL) 7E
The word has ended (03H, 0DH or a character that is not a letter or a digit): fetch the entry's character at Register Pair HL into Register A.
510B
CP 20H FE 20
Compare Register A (the entry's character) against 20H, a space.
510D
If the Z FLAG is set (the entry's word ends here too), JUMP to 50F9H: a match.
510F
POP DE D1
Restore Register Pair DE from the stack: the start of the word.
5110
POP HL E1
Restore Register Pair HL from the stack: the start of the entry.
5111
JUMP to 50D8H to try the next entry of the table at Register Pair HL.

5113H - @PARAM: Read a Parameter List

Function 60H (request E3H, 4454H) enters at 5114H. Register Pair HL = the text after a command word, Register Pair DE = the caller's parameter table: entries of 8 bytes, a parameter name padded with spaces to 6 characters and the address of the word that takes its value, ended by 00H. After any spaces the list is an open parenthesis, NAME=value or NAME entries separated by commas, and a close parenthesis. A name given alone stores FFFFH. A value is a decimal number, X'hex', a text in quotation marks (the word gets the address of the text's first character in the command line) or a word that starts with Y or ON (FFFFH), N or OF (0000H). Returns the Z FLAG when the list was read or there is none (Register A = 0DH when the line ends with no list, otherwise 00H), with Register Pair HL past the list; the NZ FLAG for a name the table does not have, an empty name, a bad value or a character that does not belong.

5113
INC HL 23
INCrement Register Pair HL past a space. 511AH loops back here.
5114
LD A,(HL) 7E
@PARAM: fetch the next character of the text at Register Pair HL into Register A.
5115
CP 0DH FE 0D
Compare Register A (the character) against 0DH, the end of the line.
5117
RET Z C8
If the Z FLAG is set (the line ends: no parameters), RETurn with Register A = 0DH and the Z FLAG set.
5118
CP 20H FE 20
Compare Register A (the character) against 20H, a space.
511A
If the Z FLAG is set (a space), JUMP to 5113H to pass over it.
511C
CP 28H FE 28
Compare Register A (the character) against 28H, the open parenthesis of a list.
511E
If the NZ FLAG is set (no list), JUMP to 515BH to return with Register A = 00H and the Z FLAG set: there are no parameters.
5120
PUSH DE D5
Save Register Pair DE (the parameter table) to the stack. 5151H comes back here after a comma, for the next parameter.
5121
LD B,06H 06 06
Load Register B with 06H, the length of a parameter name.
5123
LD DE,4300H 11 00 43
Point Register Pair DE to 4300H, the system buffer, where the name is copied for the table search.
5126
INC HL 23
INCrement Register Pair HL past the open parenthesis or the comma to the first character of the name.
5127
GOSUB to 5081H to copy the name, up to Register B (6) letters and digits, from Register Pair HL to Register Pair DE (4300H), ended by 03H. Register A returns the character that ended it and the NZ FLAG when the name is empty.
512A
DEC HL 2B
DECrement Register Pair HL by one: back onto the equals sign, comma or close parenthesis that ended the name (5081H passed over it); when the line's 0DH ended it, onto the character before the 0DH, which 5131H puts right.
512B
POP DE D1
Restore Register Pair DE from the stack: the parameter table. POP does not change the flags.
512C
RET NZ C0
If the NZ FLAG is set (an empty name), RETurn with the NZ FLAG and Register A = the character found in its place.
512D
CP 0DH FE 0D
Compare Register A (the character that ended the name) against 0DH, the end of the line.
512F
If the NZ FLAG is set (not 0DH), JUMP to 5132H with Register Pair HL at that character.
5131
INC HL 23
INCrement Register Pair HL back onto the 0DH, where 5081H had left it.
5132
PUSH DE D5
Save Register Pair DE (the parameter table) to the stack.
5133
LD B,D 42
Copy Register D (the high byte of the parameter table) into Register B.
5134
LD C,E 4B
Copy Register E (the low byte) into Register C: Register Pair BC = the parameter table.
5135
LD DE,4300H 11 00 43
Point Register Pair DE to 4300H, the parameter name just copied.
5138
GOSUB to 50D1H to look for the name at Register Pair DE (4300H) in the parameter table at Register Pair BC. On a match it returns the Z FLAG and Register Pair DE = the entry's last two bytes, the address of the word for the value.
513B
If the Z FLAG is set (the name is in the table), JUMP to 513FH.
513D
POP DE D1
Restore Register Pair DE from the stack: the parameter table. 5178H and 5185H come here for a bad value.
513E
RET C9
RETurn with the NZ FLAG set: a parameter the table does not have (Register A = 01H) or a bad value.
513F
LD A,(HL) 7E
Fetch the character after the name at Register Pair HL into Register A.
5140
CP 3DH FE 3D
Compare Register A (the character after the name) against 3DH, the equals sign before a value.
5142
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H: the value is built here. LD does not change the flags.
5145
If the Z FLAG is set (an equals sign), JUMP to 515DH to read the value.
5147
DEC BC 0B
A name with no value: DECrement Register Pair BC (0000H) to FFFFH, the value of a parameter given alone.
5148
LD A,C 79
Copy Register C (the value's low byte) into Register A. 5176H, 517DH and 518CH come here with the value in Register Pair BC.
5149
LD (DE),A 12
Store Register A (the value's low byte) at Register Pair DE, the address the table gives for this parameter.
514A
INC DE 13
INCrement Register Pair DE to the word's high byte.
514B
LD A,B 78
Copy Register B (the value's high byte) into Register A.
514C
LD (DE),A 12
Store Register A (the value's high byte) at Register Pair DE.
514D
POP DE D1
Restore Register Pair DE from the stack: the parameter table.
514E
LD A,(HL) 7E
Fetch the character after the parameter at Register Pair HL into Register A.
514F
CP 2CH FE 2C
Compare Register A (the character) against 2CH, a comma: another parameter follows.
5151
If the Z FLAG is set (a comma), JUMP to 5120H for the next parameter.
5153
CP 0DH FE 0D
Compare Register A (the character) against 0DH, the end of the line.
5155
If the Z FLAG is set (the line ends before a close parenthesis), JUMP to 515BH: the list is accepted.
5157
CP 29H FE 29
Compare Register A (the character) against 29H, the close parenthesis of the list.
5159
RET NZ C0
If the NZ FLAG is set (any other character), RETurn with the NZ FLAG and Register A = that character.
515A
INC HL 23
INCrement Register Pair HL past the close parenthesis.
515B
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set. 511EH and 5155H come here too.
515C
RET C9
RETurn with Register A = 00H and the Z FLAG set: the parameters were read, Register Pair HL is after the list.

515DH - Read a Value

Register Pair HL = the equals sign, Register Pair BC = 0000H, Register Pair DE = the address of the parameter's word (the parameter table is on the stack). The first character of the value picks how it is read.

515D
INC HL 23
INCrement Register Pair HL past the equals sign to the first character of the value.
515E
LD A,(HL) 7E
Fetch the value's first character at Register Pair HL into Register A.
515F
CP 22H FE 22
Compare Register A (the value's first character) against 22H, a quotation mark.
5161
If the Z FLAG is set (a text in quotation marks), JUMP to 517FH.
5163
CP 41H FE 41
Compare Register A (the value's first character) against 41H, the letter A.
5165
If the CARRY FLAG is set (below A: a digit), JUMP to 517AH to read a decimal number.
5167
RES 5,A CB AF
Clear bit 5 of Register A (the letter): a small letter becomes a capital.
5169
CP 58H FE 58
Compare Register A (the letter, as a capital) against 58H, X.
516B
If the Z FLAG is set (X: a hexadecimal number X'..'), JUMP to 5172H.
516D
GOSUB to 518EH to read a word that starts with Y, N or O (Register A = its first letter): Register Pair BC = FFFFH for Y or ON and 0000H for N or OF, with the Z FLAG; the NZ FLAG for any other letter.
5170
JUMP to 5176H to test the result of the word in Register Pair BC and the Z FLAG.
5172
INC HL 23
INCrement Register Pair HL past the X to the quote.
5173
GOSUB to 51C6H to read the hexadecimal number in quotes at Register Pair HL into Register Pair BC; the NZ FLAG comes back when there is no quote.
5176
If the Z FLAG is set (a good value in Register Pair BC), JUMP to 5148H to store it.
5178
JUMP to 513DH to return with the NZ FLAG: a bad value.
517A
GOSUB to 51B1H to read the decimal number at Register Pair HL into Register Pair BC.
517D
JUMP to 5148H to store Register Pair BC (the number).
517F
INC HL 23
INCrement Register Pair HL past the quotation mark to the text's first character.
5180
LD B,H 44
Copy Register H (the high byte of the text's address) into Register B.
5181
LD C,L 4D
Copy Register L (the low byte) into Register C: Register Pair BC = the address of the text, the value stored for the parameter.
5182
LD A,(HL) 7E
Fetch the next character of the text at Register Pair HL into Register A. 518AH loops back here.
5183
CP 20H FE 20
Compare Register A (the character) against 20H, a space.
5185
If the CARRY FLAG is set (a control character, such as the 0DH at the end of the line, before the closing quotation mark), JUMP to 513DH to return with the NZ FLAG.
5187
INC HL 23
INCrement Register Pair HL past the character.
5188
CP 22H FE 22
Compare Register A (the character) against 22H, the closing quotation mark.
518A
If the NZ FLAG is set (not yet the closing quotation mark), JUMP to 5182H for the next character.
518C
JUMP to 5148H to store Register Pair BC (the address of the text), with Register Pair HL past the closing quotation mark. The text stays in the command line, ended by its quotation mark.

518EH - A Value Given as a Word: Y, N, ON, OFF

Register A = the value's first letter as a capital, Register Pair HL at it, Register Pair BC = 0000H. Y gives FFFFH, N gives 0000H, O followed by N gives FFFFH and O followed by F gives 0000H; the rest of the word (YES, NO, OFF) is passed over up to a close parenthesis, a comma or the end of the line. Any other letter returns the NZ FLAG.

518E
SUB 59H D6 59
SUBtract 59H, the letter Y, from Register A (the first letter): the Z FLAG is set for Y.
5190
If the Z FLAG is set (Y), JUMP to 51A3H to make Register Pair BC FFFFH.
5192
ADD A,0BH C6 0B
ADD 0BH to Register A (the letter less 59H): Register A = the letter less 4EH, 00H with the Z FLAG for N.
5194
If the Z FLAG is set (N), JUMP to 51A4H with Register Pair BC = 0000H.
5196
DEC A 3D
DECrement Register A (the letter less 4EH): the Z FLAG is set for O.
5197
RET NZ C0
If the NZ FLAG is set (another letter), RETurn with the NZ FLAG: a bad value.
5198
INC HL 23
INCrement Register Pair HL to the character after the O.
5199
LD A,(HL) 7E
Fetch the character after the O at Register Pair HL into Register A.
519A
RES 5,A CB AF
Clear bit 5 of Register A (the second letter): a small letter becomes a capital.
519C
CP 46H FE 46
Compare Register A (the second letter) against 46H, F.
519E
If the Z FLAG is set (OF, as in OFF), JUMP to 51A4H with Register Pair BC = 0000H.
51A0
CP 4EH FE 4E
Compare Register A (the second letter) against 4EH, N.
51A2
RET NZ C0
If the NZ FLAG is set (neither ON nor OF), RETurn with the NZ FLAG: a bad value.
51A3
DEC BC 0B
DECrement Register Pair BC (0000H) to FFFFH: Y or ON.
51A4
INC HL 23
INCrement Register Pair HL to the next character of the word. 51AFH loops back here.
51A5
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
51A6
CP 29H FE 29
Compare Register A (the character) against 29H, the close parenthesis of the list.
51A8
RET Z C8
If the Z FLAG is set (the close parenthesis), RETurn with the Z FLAG: the value is in Register Pair BC.
51A9
CP 0DH FE 0D
Compare Register A (the character) against 0DH, the end of the line.
51AB
RET Z C8
If the Z FLAG is set (0DH), RETurn with the Z FLAG and the value in Register Pair BC.
51AC
CP 2CH FE 2C
Compare Register A (the character) against 2CH, a comma.
51AE
RET Z C8
If the Z FLAG is set (a comma), RETurn with the Z FLAG and the value in Register Pair BC.
51AF
JUMP to 51A4H to pass over the next character of the word.

51B1H - Read a Decimal Number

Register Pair HL = the first digit, Register Pair BC = 0000H. Each digit makes Register Pair BC ten times larger plus the digit (the value wraps above 65535); the first character that is not a digit ends the number, with Register Pair HL at it. The caller (517AH) stores the result whatever the flags say.

51B1
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A. 51C4H loops back here.
51B2
SUB 30H D6 30
SUBtract 30H from Register A (the character): a digit becomes its value 0-9.
51B4
CP 0AH FE 0A
Compare Register A (the character less 30H) against 0AH.
51B6
RET NC D0
If the NO CARRY FLAG is set (not a digit), RETurn with the number in Register Pair BC.
51B7
PUSH BC C5
Save Register Pair BC (the number so far) to the stack.
51B8
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (the Stack Pointer is not changed): Register Pair HL = the number so far, and the text pointer is kept on the stack.
51B9
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 2.
51BA
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 4.
51BB
ADD HL,BC 09
ADD Register Pair BC (the number) to Register Pair HL: Register Pair HL = the number x 5.
51BC
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 10.
51BD
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit's value.
51BF
LD C,A 4F
Copy Register A (the digit's value) into Register C: Register Pair BC = the digit.
51C0
ADD HL,BC 09
ADD Register Pair BC (the digit) to Register Pair HL: Register Pair HL = the number x 10 + the digit.
51C1
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (the Stack Pointer is not changed): the text pointer comes back into Register Pair HL and the new number goes on the stack.
51C2
POP BC C1
Restore Register Pair BC from the stack: the new number.
51C3
INC HL 23
INCrement Register Pair HL to the next character.
51C4
JUMP to 51B1H for the next digit of the number at Register Pair HL.

51C6H - Read a Hexadecimal Number in Quotes

Register Pair HL = the character after the X, Register Pair BC = 0000H. A quote (27H) must come first; then each hexadecimal digit (0-9, A-F, a-f) makes Register Pair BC 16 times larger plus the digit, up to a character that is not one. The closing quote is passed over when it is there. The test also takes the characters 3AH-40H as the digits 3-9 and 5BH-60H as 4-9. Returns the Z FLAG with the number in Register Pair BC, or the NZ FLAG when the quote after the X is missing.

51C6
LD A,(HL) 7E
Fetch the character after the X at Register Pair HL into Register A.
51C7
CP 27H FE 27
Compare Register A (the character after the X) against 27H, a quote.
51C9
RET NZ C0
If the NZ FLAG is set (no quote), RETurn with the NZ FLAG: a bad value.
51CA
INC HL 23
INCrement Register Pair HL to the next character. 51EEH loops back here.
51CB
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
51CC
SUB 30H D6 30
SUBtract 30H from Register A (the character).
51CE
If the CARRY FLAG is set (Register A was below 30H, the digit 0), JUMP to 51DCH: the number ends.
51D0
CP 0AH FE 0A
Compare Register A (the character less 30H) against 0AH.
51D2
If the CARRY FLAG is set (a digit 0-9: Register A is its value), JUMP to 51E4H to add it.
51D4
RES 5,A CB AF
Clear bit 5 of Register A (the character less 30H): a small a-f (31H-36H) becomes 11H-16H, like a capital.
51D6
SUB 07H D6 07
SUBtract 07H from Register A: A-F become 0AH-0FH.
51D8
CP 10H FE 10
Compare Register A (the digit's value) against 10H.
51DA
If the CARRY FLAG is set (Register A is 00H-0FH), JUMP to 51E4H to add it as a digit.
51DC
LD A,(HL) 7E
Fetch the character that ended the number at Register Pair HL into Register A.
51DD
CP 27H FE 27
Compare Register A (the character) against 27H, the closing quote.
51DF
INC HL 23
INCrement Register Pair HL past the character. INC does not change the Z FLAG of the compare.
51E0
RET Z C8
If the Z FLAG is set (the closing quote), RETurn with the Z FLAG, the number in Register Pair BC and Register Pair HL past the quote.
51E1
DEC HL 2B
DECrement Register Pair HL back onto the character: there is no closing quote.
51E2
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set: the number is accepted all the same.
51E3
RET C9
RETurn with the Z FLAG, the number in Register Pair BC and Register Pair HL at the character after the digits.
51E4
PUSH BC C5
Save Register Pair BC (the number so far) to the stack.
51E5
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (the Stack Pointer is not changed): Register Pair HL = the number so far, and the text pointer is kept on the stack.
51E6
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 2.
51E7
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 4.
51E8
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 8.
51E9
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 16, so the low four bits of Register L are 0.
51EA
LD B,H 44
Copy Register H (the high byte of the number x 16) into Register B.
51EB
ADD A,L 85
ADD Register L (the low byte of the number x 16) to Register A (the digit, 00H-0FH): there is no carry, as the low four bits of Register L are 0.
51EC
LD C,A 4F
Copy Register A into Register C: Register Pair BC = the number x 16 + the digit.
51ED
POP HL E1
Restore Register Pair HL from the stack: the text pointer.
51EE
JUMP to 51CAH for the next character of the number at Register Pair HL.

51F0H - The Texts of SYS1/SYS (Data)

The extension the command loop gives a program name (4E93H) and the prompt it displays (4E3EH).

51F0-51F2
DEFM "CMD" 43 4D 44
51F0H-51F2H: CMD, the extension 4E96H adds through 504EH to a command word that is not a library command. 504EH copies exactly three characters, so the text needs no end mark.
51F3
DEFB 0AH 0A
51F3H: 0AH, the first byte of the prompt that 4E41H displays: the video driver moves the cursor to the start of the next line for 0AH (as for 0DH), so LDOS Ready starts on a new line.
51F4-51FD
DEFM "LDOS Ready" 4C 44 4F 53 20 52 65 61 64 79
51F4H-51FDH: the prompt LDOS Ready, in capitals and small letters.
51FE
DEFB 0DH 0D
51FEH: 0DH, the end of the prompt. @DSPLY displays it, so the cursor goes to the next line, where the command is typed. It is the last byte of the file's part at 4E00H (03FFH bytes, 4BC8H).