TRS-80 DOS - LDOS 5.3.1 for the Model I - SYS1/SYS Disassembled

Page Customization

Introduction/Summary

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

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 (4BCDH) 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 1094 bytes: a record of type 1FH with the text Copyright 1991 MISOSYS, Inc., All rights reserved, four load blocks for 4E00H-51F8H, a load block for the two bytes 4BC9H-4BCAH (the length of the file's part at 4E00H, 03F9H) 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 4EBDH 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 (4400H) issue it. The stack is set to 41E0H, 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 (4451H; 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 (4405H): 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), 4FD6H: copy the file specification in the text at Register Pair HL into the control block at Register Pair DE.
D3H50H: @FEXT (4473H), 5048H: give the file specification at Register Pair DE the extension at Register Pair HL when it has none.
E3H60H: @PARAM (4476H), 510EH: 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$, 4318H, ended by 0DH); a line given by a program is copied there, 63 bytes, with 03H in the 64th byte (4357H). The line is passed to the job log (447EH), then:

LineWhat SYS1/SYS does
.A comment: nothing is carried out. While a JCL job runs (bit 5 of SFLAG$, 430FH) the job goes on with its next line; otherwise the next line is read from the keyboard (4EA0H).
!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$ (4480H). When it is one of the 35 names of the command table (4EBDH) 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 code at 4EB6H 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 (4E97H).

While the command loop waits for the line, the BREAK trap switch (4315H) 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 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 (4E9AH). 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 and SYS7/SYS set it and KI/DVR tests it.
4Tested at 4E91H: when set, a program file is not run; SYS1/SYS returns with its file specification in CFCB$ and Register Pair HL at its parameters. No file on this diskette sets it.
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 4BC9H first, then 4E00H-51F8H. Each entry of the command table and of the table of words @FSPEC passes over has its own row. At 50B0H the operand byte of CP 23H is entered as an instruction by the loop that passes over spaces: 23H is INC HL (50B1H).

Memory Map

Load Blocks in File Order

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

AddressContents
4E00H-4EFFH256 bytes
4F00H-4FFFH256 bytes
5000H-50FFH256 bytes
5100H-51F8H249 bytes
4BC9H-4BCAH2 bytes

Sections of the Disassembly

AddressContents
4BC9HThe Overlay Length (Data)
4E00HEntry: Pick the Function of the Request
4E2EHThe LDOS Ready Command Loop
4E5CHCarry Out a Command Line
4E97HEnd a Command That Cannot Be Carried Out
4EA0HA Comment Line
4EA8HCarry Out a Library Command
4EB6HBOOT: Start the System Again
4EBDHThe Library Command Table (Data)
4FD6H@FSPEC: Take a File Specification
5018HA Device Name
5027HThe Words @FSPEC Passes Over (Data)
5048H@FEXT: Add a Default Extension
5060HPut the Extension In
5079HCopy a Field of Letters and Digits
50BDHIs It a Letter or a Digit?
50CBHLook a Word Up in a Table
510DH@PARAM: Read a Parameter List
5157HRead a Value
5188HA Value Given as a Word: Y, N, ON, OFF
51ABHRead a Decimal Number
51C0HRead a Hexadecimal Number in Quotes
51EAHThe Texts of SYS1/SYS (Data)

Memory SYS1/SYS Uses

AddressContents
0040HThe ROM's line input (05D9H): the command line typed at LDOS Ready (4E4FH).
0066H, 0000HThe ROM's non maskable interrupt handler and power up routine, reached by the HALT of BOOT (4EBCH).
402DH, 4030H@EXIT and @ABORT: 402DH is pushed as the return address of every command of functions 10H and 30H (4E5BH); 4E9DH jumps to @ABORT.
41E0HThe stack of the command level: 4E2EH sets the Stack Pointer to 41E0H, so the stack grows down from 41DFH.
4200H-4206HThe system buffer: @PARAM copies each parameter name there, up to 6 characters and 03H (511DH, 512FH).
430FHSFLAG$: bit 7 DEBUG is on (4E32H), bit 5 a JCL job runs (4EA0H).
4315HThe BREAK trap switch: C3H or 00H (4E3BH), 00H for a library command (4EA9H).
4318H-4357HINBUF$, the command line buffer: 63 characters and an end mark (4E16H-4E20H, 4E4AH).
4433H, 4467H, 447EH@RUN (4E93H), @DSPLY (4E41H) and @LOGER (4E5CH) of SYS0/SYS.
4480H-449FHCFCB$, the control block that gets the command word as a file specification (4E6CH).
475EHSEEK, the disk primitive of SYS0/SYS that BOOT uses (4EB9H).
4758HThe status byte of the command interpreter (4E22H, 4E44H, 4E8EH, 4E97H).
4BC9H-4BCAHThe length of the system file in the overlay area: 03F9H for SYS1/SYS.
4E00H-51F8HSYS1/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, 4405H) and function 20H (request A3H, 4451H): carry out the command line at Register Pair HL.
4E2EH@CMD, @EXIT, @ABORTFunction 10H (request 93H), the LDOS Ready command loop, reached through 4400H, 402DH and 4030H.
4EBDHThe library command table, 35 entries of 8 bytes.
4FD6H@FSPECFunction 40H (request C3H, 441CH): take a file specification.
5048H@FEXTFunction 50H (request D3H, 4473H): add a default extension.
50CBHLook a word up in a table of 8 byte entries.
510EH@PARAMFunction 60H (request E3H, 4476H): read a parameter list.

Data in the File

Address
Size
Contents
4BC9H-4BCAH
2 bytes
DEFW 03F9H
4BC9H-4BCAH: 03F9H (1017), the number of bytes SYS1/SYS loads at 4E00H (4E00H-51F8H). Loading SYS1/SYS puts it over the length the system file loaded before it left here.
4EBDH-4EC4H
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.
4EC5H-4ECCH
8 bytes
DEFM "ATTRIB" / DEFB 51H, C0H
ATTRIB: member 51H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4ECDH-4ED4H
8 bytes
DEFM "AUTO " / DEFB 11H, C0H
AUTO: member 11H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4ED5H-4EDCH
8 bytes
DEFM "BOOT " / DEFB B6H, 4EH
BOOT: the address 4EB6H (bytes B6H 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.
4EDDH-4EE4H
8 bytes
DEFM "BUILD " / DEFB 33H, C0H
BUILD: member 33H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4EE5H-4EECH
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.
4EEDH-4EF4H
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).
4EF5H-4EFCH
8 bytes
DEFM "CREATE" / DEFB 13H, C0H
CREATE: member 13H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4EFDH-4F04H
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.
4F05H-4F0CH
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.
4F0DH-4F14H
8 bytes
DEFM "DEVICE" / DEFB 61H, 80H
DEVICE: member 61H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F15H-4F1CH
8 bytes
DEFM "DIR " / DEFB 21H, 80H
DIR: member 21H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F1DH-4F24H
8 bytes
DEFM "DO " / DEFB 91H, 80H
DO: member 91H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F25H-4F2CH
8 bytes
DEFM "DUMP " / DEFB 71H, C0H
DUMP: member 71H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F2DH-4F34H
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).
4F35H-4F3CH
8 bytes
DEFM "FORMS " / DEFB B1H, C0H
FORMS: member B1H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F3DH-4F44H
8 bytes
DEFM "FREE " / DEFB 22H, C0H
FREE: member 22H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F45H-4F4CH
8 bytes
DEFM "KILL " / DEFB 18H, 80H
KILL: member 18H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F4DH-4F54H
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).
4F55H-4F5CH
8 bytes
DEFM "LINK " / DEFB 62H, 80H
LINK: member 62H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F5DH-4F64H
8 bytes
DEFM "LIST " / DEFB 41H, 80H
LIST: member 41H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F65H-4F6CH
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.
4F6DH-4F74H
8 bytes
DEFM "MEMORY" / DEFB 1EH, 80H
MEMORY: member 1EH of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F75H-4F7CH
8 bytes
DEFM "PURGE " / DEFB 72H, C0H
PURGE: member 72H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4F7DH-4F84H
8 bytes
DEFM "RENAME" / DEFB 53H, 80H
RENAME: member 53H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F85H-4F8CH
8 bytes
DEFM "RESET " / DEFB 63H, 80H
RESET: member 63H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F8DH-4F94H
8 bytes
DEFM "ROUTE " / DEFB 64H, 80H
ROUTE: member 64H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4F95H-4F9CH
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).
4F9DH-4FA4H
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.
4FA5H-4FACH
8 bytes
DEFM "SETCOM" / DEFB B2H, C0H
SETCOM: member B2H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4FADH-4FB4H
8 bytes
DEFM "SPOOL " / DEFB A2H, 80H
SPOOL: member A2H of SYS6/SYS (flags 80H, request 88H), entered at 5200H.
4FB5H-4FBCH
8 bytes
DEFM "SYSTEM" / DEFB A1H, C0H
SYSTEM: member A1H of SYS7/SYS (flags C0H, request 89H), entered at 5200H.
4FBDH-4FC4H
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).
4FC5H-4FCCH
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.
4FCDH-4FD4H
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).
4FD5H
1 byte
DEFB 00H
4FD5H: 00H, the end of the table: 50D8H finds 00H as the first byte of the next entry and the search ends with no match.
5027H-502EH
8 bytes
DEFM "TO " / DEFW 4200H
TO, the first word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search in Register Pair DE and dropped at 5013H.
502FH-5036H
8 bytes
DEFM "ON " / DEFW 4200H
ON, a word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search and dropped at 5013H.
5037H-503EH
8 bytes
DEFM "OVER " / DEFW 4200H
OVER, a word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search and dropped at 5013H.
503FH-5046H
8 bytes
DEFM "USING " / DEFW 4200H
USING, a word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search and dropped at 5013H.
5047H
1 byte
DEFB 00H
5047H: 00H, the end of the table: 50D8H finds 00H as the first byte of the next entry, so a word that is none of the four is not passed over.
51EAH-51ECH
3 bytes
DEFM "CMD"
51EAH-51ECH: CMD, the extension 4E8AH adds through 5048H to a command word that is not a library command. 5048H copies exactly three characters, so the text needs no end mark.
51EDH
1 byte
DEFB 0AH
51EDH: 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.
51EEH-51F7H
10 bytes
DEFM "LDOS Ready"
51EEH-51F7H: the prompt LDOS Ready, in capitals and small letters.
51F8H
1 byte
DEFB 0DH
51F8H: 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 (03F9H bytes, 4BC9H).

Self-Modified Operands

Address
Size
Contents
4E7BH
1 byte
The operand of LD A,00H at 4E7AH: 4E66H 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).
50B9H
1 byte
The operand of LD A,00H at 50B8H: the field length (never 00H) stored by 507CH, 00H once 50A2H 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
4200H-4206H
7 bytes
The system buffer. @PARAM copies each parameter name there (511DH): up to 6 letters and digits and an 03H, which the table search (5132H) compares with the parameter table.
4315H
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); 4EA9H stores 00H before a library command.
430FH
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, 4EA0H).
4318H-4357H
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 4357H (4E16H-4E20H).
4480H-449FH
32 bytes
CFCB$, the control block of SYS0/SYS for the command: @FSPEC copies the command word into it as a file specification (4E6FH), 5048H adds /CMD, and @RUN loads the program it names (4E93H).
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 (4E91H) and bit 1 (4E9AH). The table under The Status Byte above gives every bit.

Disassembly

4BC9H - The Overlay Length (Data)

Every system file from SYS1/SYS to SYS12/SYS carries a load block for the two bytes 4BC9H-4BCAH in the resident area of SYS0/SYS. They hold the length of the file's part in the overlay area: for SYS1/SYS 03F9H, the 1017 bytes 4E00H-51F8H. In the file this block is the last load block, after the four blocks of 4E00H-51F8H and before the transfer address record (4E00H). SYS7/SYS reads and writes the word (its 5764H, 5812H). The two bytes are data, not instructions.

4BC9-4BCA
DEFW 03F9H F9 03
4BC9H-4BCAH: 03F9H (1017), the number of bytes SYS1/SYS loads at 4E00H (4E00H-51F8H). 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 (4BCDH) 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$, 430EH) 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 4400H) the LDOS Ready command loop; 20H (A3H, 4451H) carry out the command line at Register Pair HL and return to the caller; 30H (B3H, @CMNDI 4405H) carry out the command line at Register Pair HL, then LDOS Ready; 40H (C3H, @FSPEC 441CH) take a file specification; 50H (D3H, @FEXT 4473H) add a default extension; 60H (E3H, @PARAM 4476H) 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 4FD6H 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 4473H).
4E0E
If the Z FLAG is set (function 50H), JUMP to 5048H 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 4476H).
4E13
If the Z FLAG is set (function 60H), JUMP to 510EH to read the parameter list in the text at Register Pair HL against the parameter table at Register Pair DE.
4E16
LD DE,4318H 11 18 43
Functions 20H, 30H and 70H: point Register Pair DE to 4318H, INBUF$, the command line buffer, where the caller's command line is copied.
4E19
PUSH DE D5
Save Register Pair DE (4318H, 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 (4318H-4356H), the bytes after the line's 0DH included. For the AUTO command at the boot Register Pair HL is 4318H already and the bytes are copied onto themselves. Register Pair HL ends 63 bytes past the caller's line, Register Pair DE at 4357H 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 = 4357H, the byte after the 63 copied.
4E20
LD (HL),03H 36 03
Store 03H at Register Pair HL (4357H), the last byte of INBUF$: an end of text mark after the 63 bytes, at which the field copy (5080H) 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 4405H), 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, 4451H) 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 (4E97H) 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: 4318H (pushed at 4E19H), the start of the copied command line in INBUF$.
4E2C
JUMP to 4E5CH to carry out the command. No return address is pushed, so the command's last RET goes back to the dispatcher (4BE7H) and from there to the program that called 4451H.

4E2EH - The LDOS Ready Command Loop

Function 10H (request 93H): @EXIT (402DH), @ABORT (4030H) and @CMD (4400H) all lead here. The stack is set up afresh at 41E0H, 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$ (4318H) 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,41E0H 31 E0 41
Load the Stack Pointer with 41E0H: the stack of the command level, which grows down from 41DFH. 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,(430FH) 3A 0F 43
Fetch SFLAG$, the system flags, from 430FH 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 (4315H),A 32 15 43
Store Register A (C3H when DEBUG is on, 00H otherwise) at 4315H, the BREAK trap switch. With C3H the interrupt routine goes, on BREAK, to the address at 4316H-4317H (44B4H, the DEBUG entry, unless a program has stored another there; SYS0/SYS 455FH-456EH); with 00H it does not.
4E3E
LD HL,51EDH 21 ED 51
Point Register Pair HL to 51EDH, the prompt: a line feed, LDOS Ready and a carriage return.
4E41
GOSUB to 4467H (@DSPLY) to display the text at Register Pair HL (51EDH) 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. 4EA5H 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,4318H 21 18 43
Point Register Pair HL to 4318H, 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 (4318H), echoing them, and stores 0DH after them when ENTER or BREAK is pressed. It returns Register Pair HL = 4318H, 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 (4318H, the line) with the top of the stack (the Stack Pointer is not changed): Register Pair HL = 4758H, the status byte, and 4318H 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: 4318H, 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 4E97H, 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 - Carry Out a Command Line

Register Pair HL = the command line (in INBUF$, 4318H). The line is first passed to the job log (447EH). A line that starts with a period is a comment (4EA0H). A line that starts with ! is always run as a program file. Otherwise the first word is taken as a file specification into CFCB$ (4480H) and looked up in the table of library commands at 4EBDH; a command found there is carried out by its member of SYS6/SYS or SYS7/SYS (4EA8H). 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.

4E5C
GOSUB to 447EH (@LOGER) with Register Pair HL = the command line, to send it to the job log. SYS0/SYS's 447EH jumps to a RET (44FDH), so nothing is sent until a module points that jump elsewhere.
4E5F
LD A,(HL) 7E
Fetch the first character of the command line at Register Pair HL into Register A.
4E60
CP 2EH FE 2E
Compare Register A (the first character) against 2EH, a period.
4E62
If the Z FLAG is set (the line starts with a period: a comment), JUMP to 4EA0H.
4E64
SUB 21H D6 21
SUBtract 21H from Register A (the first character): Register A = 00H and the Z FLAG set when it is ! (21H).
4E66
LD (4E7BH),A 32 7B 4E
Store Register A (the first character less 21H) at 4E7BH, the operand of the LD A at 4E7AH: 00H after a !, which makes 4E7DH pass over the search of the command table.
4E69
If the NZ FLAG is set (the line does not start with !), JUMP to 4E6CH with Register Pair HL at the first character.
4E6B
INC HL 23
INCrement Register Pair HL past the ! to the first character of the program name.
4E6C
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, CFCB$, the 32 byte control block for the command (4480H-449FH).
4E6F
GOSUB to 4FD6H (as @FSPEC) to take the first word of the line at Register Pair HL as a file specification into CFCB$ at Register Pair DE (4480H), ended by 03H. It returns Register Pair DE = 4480H, Register Pair HL after the word and the Z FLAG set when the word is a file specification.
4E72
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 4E97H to end the command.
4E74
LD A,(DE) 1A
Fetch the first byte of the file specification at Register Pair DE (4480H) into Register A.
4E75
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.
4E77
If the Z FLAG is set (a device name), JUMP to 4E97H: a device is not run as a command.
4E79
PUSH HL E5
Save Register Pair HL (the command line after the first word: the command's parameters) to the stack.
4E7A
LD A,00H 3E 00
Load Register A with the first character of the line less 21H. Self-Modifying Code
The operand at 4E7BH is 00H in the file; 4E66H stores the first character of the command line less 21H there, so it is 00H when the line starts with ! and not 00H otherwise.
4E7C
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 !.
4E7D
If the Z FLAG is set (the line started with !), JUMP to 4E87H: the word is run as a program file even when it is the name of a library command.
4E7F
LD BC,4EBDH 01 BD 4E
Point Register Pair BC to 4EBDH, the table of library commands: 35 entries of 8 bytes.
4E82
GOSUB to 50CBH to look for the word at Register Pair DE (CFCB$, 4480H) in the table at Register Pair BC (4EBDH). 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.
4E85
If the Z FLAG is set (the word is a library command), JUMP to 4EA8H to carry it out.
4E87
LD HL,51EAH 21 EA 51
Point Register Pair HL to 51EAH, the text CMD, the extension of a program file.
4E8A
GOSUB to 5048H (as @FEXT) to give the file specification at Register Pair DE (CFCB$, 4480H) the extension at Register Pair HL (51EAH, CMD) when it has none, so that a word such as FORMAT becomes FORMAT/CMD. Register Pair DE (4480H) is kept.
4E8D
POP HL E1
Restore Register Pair HL from the stack: the command line after the first word (pushed at 4E79H).
4E8E
LD A,(4758H) 3A 58 47
Fetch the status byte of the command interpreter from 4758H into Register A.
4E91
AND 10H E6 10
Mask Register A (the status byte) to bit 4: the Z FLAG is set when bit 4 is clear.
4E93
If the Z FLAG is set (bit 4 clear; no file on this diskette sets it), JUMP to 4433H (@RUN) to load and run the program named in CFCB$ at Register Pair DE (4480H). 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.
4E96
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$ (4480H) and Register Pair HL at the parameters.

4E97H - 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.

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

4EA0H - A Comment Line

A command line that starts with a period is not carried out. While a JCL job runs (bit 5 of SFLAG$, 430FH) 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.

4EA0
LD A,(430FH) 3A 0F 43
Fetch SFLAG$, the system flags, from 430FH into Register A.
4EA3
BIT 5,A CB 6F
Test bit 5 of Register A (SFLAG$): set while a JCL job runs.
4EA5
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.
4EA7
RET C9
RETurn with Register A = SFLAG$ (430FH) 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 4451H.

4EA8H - Carry Out a Library Command

The word was found in the table at 4EBDH: 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, 4EB6H). 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-51F8H while the member runs above it, at 5200H (5A00H for FILTER and SET).

4EA8
POP HL E1
Restore Register Pair HL from the stack: the command line after the command word (pushed at 4E79H), the parameters for the command.
4EA9
LD (4315H),A 32 15 43
Store Register A (00H, from the table search) at 4315H, the BREAK trap switch: the trap is off while a library command runs.
4EAC
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.
4EAD
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.
4EAE
PUSH DE D5
Save Register Pair DE (the entry's two bytes) to the stack.
4EAF
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 4EB6H.
4EB0
POP DE D1
A library command: restore Register Pair DE (the entry's two bytes) from the stack.
4EB1
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 4CF8H).
4EB2
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).
4EB3
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).
4EB5
RST 28H EF
RST 28H: call the supervisor dispatcher (400CH, 4BCDH) 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.

4EB6H - BOOT: Start the System Again

The table entry of BOOT holds the address 4EB6H instead of a member number. The head of drive 0 is sent to cylinder 0, and the HALT makes the Model I boot again: on the Model I a HALT raises the same non maskable interrupt as the RESET button, and the ROM's handler at 0066H, which finds the disk controller, jumps to 0000H, where the ROM reads the boot sector of drive 0.

4EB6
XOR A AF
Set Register A to 00H (XOR A), the cylinder and the drive for the seek below.
4EB7
LD D,A 57
Copy Register A (00H) into Register D: cylinder 0.
4EB8
LD C,A 4F
Copy Register A (00H) into Register C: drive 0.
4EB9
GOSUB to 475EH (SEEK) to send the head of drive Register C (0) to cylinder Register D (0). The seek command is given and the routine returns without waiting for it; Register E (B6H, left from the table entry 4EB6H) goes to the controller's sector register and no sector is read.
4EBC
HALT 76
HALT. On the Model I the HALT raises the non maskable interrupt of the RESET button. The ROM's handler at 0066H reads the status of the disk controller (37ECH), finds one and jumps to 0000H, the power up routine, which loads the boot sector of drive 0 and starts LDOS again. The bytes after the HALT are the command table and are never run.

4EBDH - The Library Command Table (Data)

35 entries of 8 bytes, searched by 50CBH (called from 4E82H) and listed by the LIB command (the member 19H of SYS6/SYS reads the table from 4EBDH 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 4EB6H. A 00H after the last entry ends the table (4FD5H). 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.

4EBD-4EC4
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.
4EC5-4ECC
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.
4ECD-4ED4
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.
4ED5-4EDC
DEFM "BOOT " / DEFB B6H, 4EH 42 4F 4F 54 20 20 B6 4E
BOOT: the address 4EB6H (bytes B6H 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.
4EDD-4EE4
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.
4EE5-4EEC
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.
4EED-4EF4
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).
4EF5-4EFC
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.
4EFD-4F04
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.
4F05-4F0C
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.
4F0D-4F14
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.
4F15-4F1C
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.
4F1D-4F24
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.
4F25-4F2C
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.
4F2D-4F34
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).
4F35-4F3C
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.
4F3D-4F44
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.
4F45-4F4C
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.
4F4D-4F54
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).
4F55-4F5C
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.
4F5D-4F64
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.
4F65-4F6C
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.
4F6D-4F74
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.
4F75-4F7C
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.
4F7D-4F84
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.
4F85-4F8C
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.
4F8D-4F94
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.
4F95-4F9C
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).
4F9D-4FA4
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.
4FA5-4FAC
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.
4FAD-4FB4
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.
4FB5-4FBC
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.
4FBD-4FC4
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).
4FC5-4FCC
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.
4FCD-4FD4
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).
4FD5
DEFB 00H 00
4FD5H: 00H, the end of the table: 50D8H finds 00H as the first byte of the next entry and the search ends with no match.

4FD6H - @FSPEC: Take a File Specification

Function 40H (request C3H, 441CH); the command loop calls it too (4E6FH). 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 5027H) 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.

4FD6
PUSH DE D5
Save Register Pair DE (the start of the destination, a file control block such as CFCB$ at 4480H) to the stack.
4FD7
GOSUB to 5079H 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.
4FDA
If the NZ FLAG is set (no name: the text starts with a character that is not a letter or a digit), JUMP to 5018H to see whether it is a device name.
4FDC
CP 2FH FE 2F
Compare Register A (the character that ended the name) against 2FH, the / before an extension.
4FDE
If the NZ FLAG is set (no extension), JUMP to 4FE7H.
4FE0
LD (DE),A 12
Store Register A (the /) at Register Pair DE, over the 03H after the name.
4FE1
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
4FE2
LD B,03H 06 03
Load Register B with 03H, the length of an extension.
4FE4
GOSUB to 507BH 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.
4FE7
CP 2EH FE 2E
Compare Register A (the character that ended the last field) against 2EH, the period before a password.
4FE9
If the NZ FLAG is set (no password), JUMP to 4FF2H.
4FEB
LD (DE),A 12
Store Register A (the period) at Register Pair DE, over the 03H after the last field.
4FEC
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
4FED
GOSUB to 5079H 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.
4FF0
If the NZ FLAG is set (a period with no password after it), JUMP to 5025H to return the error.
4FF2
CP 3AH FE 3A
Compare Register A (the character that ended the last field) against 3AH, the colon before a drive number.
4FF4
If the NZ FLAG is set (no drive), JUMP to 4FFFH.
4FF6
LD (DE),A 12
Store Register A (the colon) at Register Pair DE, over the 03H after the last field.
4FF7
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
4FF8
LD B,01H 06 01
Load Register B with 01H, the length of the drive field.
4FFA
GOSUB to 507BH 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.
4FFD
If the NZ FLAG is set (a colon with no drive after it), JUMP to 5025H to return the error.
4FFF
CP 21H FE 21
Compare Register A (the character that ended the specification) against 21H, an exclamation mark.
5001
If the NZ FLAG is set (not !), JUMP to 5006H to end the specification.
5003
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).
5005
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.
5006
LD C,A 4F
Copy Register A (the character that ended the specification) into Register C. 5023H joins here after a device name.
5007
LD A,03H 3E 03
Load Register A with 03H, the end of a specification.
5009
LD (DE),A 12
Store Register A (03H) at Register Pair DE, after the last field.
500A
LD A,C 79
Copy Register C (the character that ended the specification) back into Register A.
500B
POP DE D1
Restore Register Pair DE from the stack: the start of the specification.
500C
PUSH DE D5
Save Register Pair DE (the start of the specification) to the stack again.
500D
LD BC,5027H 01 27 50
Point Register Pair BC to 5027H, the table of the words TO, ON, OVER and USING.
5010
GOSUB to 50CBH to look for the specification at Register Pair DE in the table at Register Pair BC (5027H); the Z FLAG comes back set when it is one of the four words. Register Pair HL (the text) is kept.
5013
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, 4200H, in Register Pair DE). POP does not change the flags.
5014
If the Z FLAG is set (the word is TO, ON, OVER or USING), JUMP to 4FD6H to take the next word of the text at Register Pair HL into Register Pair DE in its place.
5016
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set: the specification is good.
5017
RET C9
RETurn with Register A = 00H, the Z FLAG set, Register Pair DE = the specification and Register Pair HL after it.

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

5018
CP 2AH FE 2A
Compare Register A (the first character of the text, which ended the empty name) against 2AH, an asterisk.
501A
If the NZ FLAG is set (not an asterisk), JUMP to 5025H to return the error with Register A = the character.
501C
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.
501D
INC DE 13
INCrement Register Pair DE to the next byte of the destination.
501E
LD B,02H 06 02
Load Register B with 02H, the length of a device name.
5020
GOSUB to 507BH 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.
5023
If the Z FLAG is set (a device name), JUMP to 5006H to end the specification with 03H.
5025
POP DE D1
Restore Register Pair DE from the stack: the start of the destination. 4FF0H and 4FFDH come here for an empty password or drive. POP does not change the flags.
5026
RET C9
RETurn with the NZ FLAG set and Register A = the character that was found where a field was needed.

5027H - The Words @FSPEC Passes Over (Data)

Four entries in the layout of the command table, searched by 50CBH from 5010H: a word padded with spaces to 6 characters and two bytes, here always 4200H, 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.

5027-502E
DEFM "TO " / DEFW 4200H 54 4F 20 20 20 20 00 42
TO, the first word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search in Register Pair DE and dropped at 5013H.
502F-5036
DEFM "ON " / DEFW 4200H 4F 4E 20 20 20 20 00 42
ON, a word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search and dropped at 5013H.
5037-503E
DEFM "OVER " / DEFW 4200H 4F 56 45 52 20 20 00 42
OVER, a word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search and dropped at 5013H.
503F-5046
DEFM "USING " / DEFW 4200H 55 53 49 4E 47 20 00 42
USING, a word @FSPEC passes over; its last two bytes, 00H 42H (4200H), are returned by the search and dropped at 5013H.
5047
DEFB 00H 00
5047H: 00H, the end of the table: 50D8H finds 00H as the first byte of the next entry, so a word that is none of the four is not passed over.

5048H - @FEXT: Add a Default Extension

Function 50H (request D3H, 4473H); the command loop calls it too, to add CMD (4E8AH). 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.

5048
PUSH DE D5
Save Register Pair DE (the file specification) to the stack.
5049
PUSH HL E5
Save Register Pair HL (the default extension, 3 characters) to the stack.
504A
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the file specification, Register Pair DE = the extension.
504B
INC HL 23
INCrement Register Pair HL past the first character of the name, which cannot be a /.
504C
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.
504E
LD A,(HL) 7E
Fetch the next byte of the file specification at Register Pair HL into Register A. 505BH loops back here.
504F
CP 2FH FE 2F
Compare Register A (the byte of the specification) against 2FH, the / of an extension.
5051
If the Z FLAG is set (the name has an extension), JUMP to 505DH to return with nothing changed.
5053
If the CARRY FLAG is set (Register A is below 2FH: the 03H at the end, or the period before a password), JUMP to 5060H to put the extension in here.
5055
GOSUB to 50BDH: the CARRY FLAG comes back clear when Register A (the byte of the specification) is a digit or a capital letter.
5058
If the CARRY FLAG is set (not a letter or a digit: the colon before a drive), JUMP to 5060H to put the extension in here.
505A
INC HL 23
INCrement Register Pair HL to the next byte of the name.
505B
DECrement Register B and LOOP BACK to 504EH until 9 bytes have been looked at; after that the specification is left as it is.
505D
POP HL E1
Restore Register Pair HL from the stack: the default extension.
505E
POP DE D1
Restore Register Pair DE from the stack: the file specification.
505F
RET C9
RETurn with the specification at Register Pair DE unchanged and Register Pair HL = the default extension.

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

5060
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).
5063
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.
5064
LD D,H 54
Copy Register H (the high byte of the last byte to move) into Register D.
5065
LD E,L 5D
Copy Register L (the low byte) into Register E: Register Pair DE = Register Pair HL, the last byte to move.
5066
INC DE 13
INCrement Register Pair DE (the last byte to move) by one.
5067
INC DE 13
INCrement Register Pair DE again: two bytes past the last byte to move.
5068
INC DE 13
INCrement Register Pair DE again: three bytes past the last byte to move.
5069
INC DE 13
INCrement Register Pair DE again: Register Pair DE = 4 bytes past Register Pair HL, where the last byte goes.
506A
INC BC 03
INCrement Register Pair BC (000FH) to 0010H, the 16 bytes to move.
506B
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.
506D
POP HL E1
Restore Register Pair HL from the stack: the default extension.
506E
INC HL 23
INCrement Register Pair HL to the extension's second character.
506F
INC HL 23
INCrement Register Pair HL to the extension's third character.
5070
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.
5072
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.
5074
LD A,2FH 3E 2F
Load Register A with 2FH, the / before an extension.
5076
LD (DE),A 12
Store Register A (/) at Register Pair DE, the first byte of the gap after the name.
5077
POP DE D1
Restore Register Pair DE from the stack: the file specification, now with its extension.
5078
RET C9
RETurn with Register Pair DE = the specification and Register Pair HL = one byte before the default extension.

5079H - Copy a Field of Letters and Digits

5079H copies a field of up to 8 characters, 507BH 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).

5079
LD B,08H 06 08
Load Register B with 08H, the length of a name or a password.
507B
LD A,B 78
Copy Register B (the field's length) into Register A. 4FE4H, 4FFAH, 5020H and 5121H enter here with their own length.
507C
LD (50B9H),A 32 B9 50
Store Register A (the length, never 00H) at 50B9H, the operand of the LD A at 50B8H: the field counts as empty until a character is copied.
507F
INC B 04
INCrement Register B (the field's length): one more, as 509DH counts it down before each character it stores.
5080
LD A,(HL) 7E
Fetch the next character of the text at Register Pair HL into Register A. 50A6H and 50A9H loop back here.
5081
CP 03H FE 03
Compare Register A (the character) against 03H, an end of text mark.
5083
If the Z FLAG is set (03H), JUMP to 50ABH to end the field with Register Pair HL at it.
5085
CP 0DH FE 0D
Compare Register A (the character) against 0DH, the end of the line.
5087
If the Z FLAG is set (0DH), JUMP to 50ABH to end the field with Register Pair HL at it.
5089
CP 28H FE 28
Compare Register A (the character) against 28H, the open parenthesis of a parameter list.
508B
If the Z FLAG is set (the parenthesis), JUMP to 50ABH to end the field with Register Pair HL at it.
508D
INC HL 23
INCrement Register Pair HL past the character.
508E
GOSUB to 50BDH: the CARRY FLAG comes back clear when Register A (the character) is a digit or a capital letter.
5091
If the NO CARRY FLAG is set (a digit or a capital letter), JUMP to 509DH to copy it.
5093
CP 61H FE 61
Compare Register A (the character) against 61H, a small a.
5095
If the CARRY FLAG is set (below a: not a letter or a digit), JUMP to 50ABH: the character ends the field, with Register Pair HL past it.
5097
CP 7BH FE 7B
Compare Register A (the character) against 7BH, the character after a small z.
5099
If the NO CARRY FLAG is set (above z), JUMP to 50ABH: the character ends the field, with Register Pair HL past it.
509B
RES 5,A CB AF
Clear bit 5 of Register A (a small letter): it becomes the capital.
509D
DEC B 05
DECrement Register B, the count of characters the field may still take (plus one).
509E
If the Z FLAG is set (the field is full), JUMP to 50A8H: the character is passed over.
50A0
LD (DE),A 12
Store Register A (the letter or digit) at Register Pair DE, in the field.
50A1
XOR A AF
Set Register A to 00H (XOR A), the value of the field flag once a character is in the field.
50A2
LD (50B9H),A 32 B9 50
Store Register A (00H) at 50B9H, the operand of the LD A at 50B8H: a character has been copied.
50A5
INC DE 13
INCrement Register Pair DE to the next byte of the field.
50A6
JUMP to 5080H for the next character of the text at Register Pair HL.
50A8
INC B 04
INCrement Register B (00H) back to 01H, so that the next letter or digit is passed over too.
50A9
JUMP to 5080H for the next character of the text at Register Pair HL.
50AB
LD C,A 4F
Copy Register A (the character that ended the field) into Register C.
50AC
CP 20H FE 20
Compare Register A (the character that ended the field) against 20H, a space.
50AE
If the NZ FLAG is set (not a space), JUMP to 50B5H.
50B0
CP 23H FE 23
Compare Register A (20H, the space) against 23H: only the flags change, and the CP (HL) below follows. Entered at 50B1H by the JR Z at 50B3H, the operand byte 23H is the instruction INC HL, which moves Register Pair HL on to the next character.
50B2
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.
50B3
If the Z FLAG is set (another space), JUMP to 50B1H, the INC HL inside the CP 23H above, to pass over it. Register Pair HL ends at the first character after the spaces.
50B5
LD A,03H 3E 03
Load Register A with 03H, the end of a field.
50B7
LD (DE),A 12
Store Register A (03H) at Register Pair DE, after the last character copied.
50B8
LD A,00H 3E 00
Load Register A with the field's flag. Self-Modifying Code
The operand at 50B9H is 00H in the file; 507CH stores the field's length there (never 00H) and 50A2H stores 00H when a character is copied, so Register A = 00H when the field has at least one character.
50BA
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.
50BB
LD A,C 79
Copy Register C (the character that ended the field) into Register A. LD does not change the flags.
50BC
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.

50BDH - 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.

50BD
CP 30H FE 30
Compare Register A (the character) against 30H, the digit 0.
50BF
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.
50C0
CP 3AH FE 3A
Compare Register A (the character) against 3AH, the character after 9.
50C2
If the CARRY FLAG is set (Register A is a digit 0-9), JUMP to 50C9H to turn the CARRY FLAG into the answer.
50C4
CP 41H FE 41
Compare Register A (the character) against 41H, the letter A.
50C6
RET C D8
If the CARRY FLAG is set (Register A is 3AH-40H, punctuation), RETurn with the CARRY FLAG set.
50C7
CP 5BH FE 5B
Compare Register A (the character) against 5BH, the character after Z: the CARRY FLAG is set for A-Z.
50C9
CCF 3F
Complement the CARRY FLAG: now clear for a digit or a capital letter in Register A, set for 5BH and above.
50CA
RET C9
RETurn with the CARRY FLAG as the answer and Register A (the character) unchanged.

50CBH - 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 (4E82H), the words @FSPEC passes over (5010H) and the parameter table of @PARAM (5132H). 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.

50CB
PUSH HL E5
Save Register Pair HL (the caller's) to the stack.
50CC
LD H,B 60
Copy Register B (the high byte of the table's address) into Register H.
50CD
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.
50CE
LD A,(DE) 1A
Fetch the first character of the word at Register Pair DE into Register A. 50DAH loops back here for each entry.
50CF
CP (HL) BE
Compare Register A (the word's first character) against the first character of the entry at Register Pair HL.
50D0
If the Z FLAG is set (the same), JUMP to 50DFH to compare the rest.
50D2
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. 510BH comes back here after a mismatch.
50D3
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the length of an entry.
50D6
ADD HL,BC 09
ADD Register Pair BC (8) to Register Pair HL (the entry): Register Pair HL = the next entry.
50D7
POP BC C1
Restore Register Pair BC from the stack: Register C is again the low byte of the table's address.
50D8
LD A,(HL) 7E
Fetch the first byte of the next entry at Register Pair HL into Register A.
50D9
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.
50DA
If the NZ FLAG is set (another entry), JUMP to 50CEH to compare it.
50DC
POP HL E1
Restore Register Pair HL (the caller's) from the stack.
50DD
INC A 3C
INCrement Register A (00H) to 01H with the NZ FLAG set: the word is not in the table.
50DE
RET C9
RETurn with Register A = 01H and the NZ FLAG set.
50DF
LD B,05H 06 05
Load Register B with 05H, the characters 2 to 6 still to compare.
50E1
PUSH HL E5
Save Register Pair HL (the entry) to the stack.
50E2
PUSH DE D5
Save Register Pair DE (the word) to the stack.
50E3
INC DE 13
INCrement Register Pair DE to the word's next character. 50F1H loops back here.
50E4
INC HL 23
INCrement Register Pair HL to the entry's next character.
50E5
LD A,(DE) 1A
Fetch the word's character at Register Pair DE into Register A.
50E6
CP 03H FE 03
Compare Register A (the word's character) against 03H, the end of the word.
50E8
If the Z FLAG is set (the word has ended), JUMP to 5104H: it matches if the entry has a space here.
50EA
CP 0DH FE 0D
Compare Register A (the word's character) against 0DH, the end of the line.
50EC
If the Z FLAG is set (the word has ended), JUMP to 5104H.
50EE
CP (HL) BE
Compare Register A (the word's character) against the entry's character at Register Pair HL.
50EF
If the NZ FLAG is set (they differ), JUMP to 50FFH.
50F1
DECrement Register B (the characters left to compare) and LOOP BACK to 50E3H until all 6 have been found equal.
50F3
POP DE D1
A match: restore Register Pair DE from the stack (the word's start) and drop it. 5107H joins here.
50F4
POP DE D1
Restore Register Pair DE from the stack: the start of the entry that matched.
50F5
LD HL,0006H 21 06 00
Load Register Pair HL with 0006H, the offset of the entry's two bytes.
50F8
ADD HL,DE 19
ADD Register Pair DE (the entry) to Register Pair HL: Register Pair HL = the entry + 6.
50F9
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.
50FA
INC HL 23
INCrement Register Pair HL to byte +07H of the entry.
50FB
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.
50FC
POP HL E1
Restore Register Pair HL (the caller's) from the stack.
50FD
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set: the word was found.
50FE
RET C9
RETurn with the Z FLAG set, Register A = 00H and Register Pair DE = the entry's two bytes.
50FF
GOSUB to 50BDH: the CARRY FLAG comes back clear when the word's character in Register A is a digit or a capital letter.
5102
If the NO CARRY FLAG is set (a letter or a digit that differs from the entry's), JUMP to 5109H: no match.
5104
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.
5105
CP 20H FE 20
Compare Register A (the entry's character) against 20H, a space.
5107
If the Z FLAG is set (the entry's word ends here too), JUMP to 50F3H: a match.
5109
POP DE D1
Restore Register Pair DE from the stack: the start of the word.
510A
POP HL E1
Restore Register Pair HL from the stack: the start of the entry.
510B
JUMP to 50D2H to try the next entry of the table at Register Pair HL.

510DH - @PARAM: Read a Parameter List

Function 60H (request E3H, 4476H) enters at 510EH. 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.

510D
INC HL 23
INCrement Register Pair HL past a space. 5114H loops back here.
510E
LD A,(HL) 7E
@PARAM: fetch the next character of the text at Register Pair HL into Register A.
510F
CP 0DH FE 0D
Compare Register A (the character) against 0DH, the end of the line.
5111
RET Z C8
If the Z FLAG is set (the line ends: no parameters), RETurn with Register A = 0DH and the Z FLAG set.
5112
CP 20H FE 20
Compare Register A (the character) against 20H, a space.
5114
If the Z FLAG is set (a space), JUMP to 510DH to pass over it.
5116
CP 28H FE 28
Compare Register A (the character) against 28H, the open parenthesis of a list.
5118
If the NZ FLAG is set (no list), JUMP to 5155H to return with Register A = 00H and the Z FLAG set: there are no parameters.
511A
PUSH DE D5
Save Register Pair DE (the parameter table) to the stack. 514BH comes back here after a comma, for the next parameter.
511B
LD B,06H 06 06
Load Register B with 06H, the length of a parameter name.
511D
LD DE,4200H 11 00 42
Point Register Pair DE to 4200H, the system buffer, where the name is copied for the table search.
5120
INC HL 23
INCrement Register Pair HL past the open parenthesis or the comma to the first character of the name.
5121
GOSUB to 507BH to copy the name, up to Register B (6) letters and digits, from Register Pair HL to Register Pair DE (4200H), ended by 03H. Register A returns the character that ended it and the NZ FLAG when the name is empty.
5124
DEC HL 2B
DECrement Register Pair HL by one: back onto the equals sign, comma or close parenthesis that ended the name (507BH passed over it); when the line's 0DH ended it, onto the character before the 0DH, which 512BH puts right.
5125
POP DE D1
Restore Register Pair DE from the stack: the parameter table. POP does not change the flags.
5126
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.
5127
CP 0DH FE 0D
Compare Register A (the character that ended the name) against 0DH, the end of the line.
5129
If the NZ FLAG is set (not 0DH), JUMP to 512CH with Register Pair HL at that character.
512B
INC HL 23
INCrement Register Pair HL back onto the 0DH, where 507BH had left it.
512C
PUSH DE D5
Save Register Pair DE (the parameter table) to the stack.
512D
LD B,D 42
Copy Register D (the high byte of the parameter table) into Register B.
512E
LD C,E 4B
Copy Register E (the low byte) into Register C: Register Pair BC = the parameter table.
512F
LD DE,4200H 11 00 42
Point Register Pair DE to 4200H, the parameter name just copied.
5132
GOSUB to 50CBH to look for the name at Register Pair DE (4200H) 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.
5135
If the Z FLAG is set (the name is in the table), JUMP to 5139H.
5137
POP DE D1
Restore Register Pair DE from the stack: the parameter table. 5172H and 517FH come here for a bad value.
5138
RET C9
RETurn with the NZ FLAG set: a parameter the table does not have (Register A = 01H) or a bad value.
5139
LD A,(HL) 7E
Fetch the character after the name at Register Pair HL into Register A.
513A
CP 3DH FE 3D
Compare Register A (the character after the name) against 3DH, the equals sign before a value.
513C
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H: the value is built here. LD does not change the flags.
513F
If the Z FLAG is set (an equals sign), JUMP to 5157H to read the value.
5141
DEC BC 0B
A name with no value: DECrement Register Pair BC (0000H) to FFFFH, the value of a parameter given alone.
5142
LD A,C 79
Copy Register C (the value's low byte) into Register A. 5170H, 5177H and 5186H come here with the value in Register Pair BC.
5143
LD (DE),A 12
Store Register A (the value's low byte) at Register Pair DE, the address the table gives for this parameter.
5144
INC DE 13
INCrement Register Pair DE to the word's high byte.
5145
LD A,B 78
Copy Register B (the value's high byte) into Register A.
5146
LD (DE),A 12
Store Register A (the value's high byte) at Register Pair DE.
5147
POP DE D1
Restore Register Pair DE from the stack: the parameter table.
5148
LD A,(HL) 7E
Fetch the character after the parameter at Register Pair HL into Register A.
5149
CP 2CH FE 2C
Compare Register A (the character) against 2CH, a comma: another parameter follows.
514B
If the Z FLAG is set (a comma), JUMP to 511AH for the next parameter.
514D
CP 0DH FE 0D
Compare Register A (the character) against 0DH, the end of the line.
514F
If the Z FLAG is set (the line ends before a close parenthesis), JUMP to 5155H: the list is accepted.
5151
CP 29H FE 29
Compare Register A (the character) against 29H, the close parenthesis of the list.
5153
RET NZ C0
If the NZ FLAG is set (any other character), RETurn with the NZ FLAG and Register A = that character.
5154
INC HL 23
INCrement Register Pair HL past the close parenthesis.
5155
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set. 5118H and 514FH come here too.
5156
RET C9
RETurn with Register A = 00H and the Z FLAG set: the parameters were read, Register Pair HL is after the list.

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

5157
INC HL 23
INCrement Register Pair HL past the equals sign to the first character of the value.
5158
LD A,(HL) 7E
Fetch the value's first character at Register Pair HL into Register A.
5159
CP 22H FE 22
Compare Register A (the value's first character) against 22H, a quotation mark.
515B
If the Z FLAG is set (a text in quotation marks), JUMP to 5179H.
515D
CP 41H FE 41
Compare Register A (the value's first character) against 41H, the letter A.
515F
If the CARRY FLAG is set (below A: a digit), JUMP to 5174H to read a decimal number.
5161
RES 5,A CB AF
Clear bit 5 of Register A (the letter): a small letter becomes a capital.
5163
CP 58H FE 58
Compare Register A (the letter, as a capital) against 58H, X.
5165
If the Z FLAG is set (X: a hexadecimal number X'..'), JUMP to 516CH.
5167
GOSUB to 5188H 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.
516A
JUMP to 5170H to test the result of the word in Register Pair BC and the Z FLAG.
516C
INC HL 23
INCrement Register Pair HL past the X to the quote.
516D
GOSUB to 51C0H 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.
5170
If the Z FLAG is set (a good value in Register Pair BC), JUMP to 5142H to store it.
5172
JUMP to 5137H to return with the NZ FLAG: a bad value.
5174
GOSUB to 51ABH to read the decimal number at Register Pair HL into Register Pair BC.
5177
JUMP to 5142H to store Register Pair BC (the number).
5179
INC HL 23
INCrement Register Pair HL past the quotation mark to the text's first character.
517A
LD B,H 44
Copy Register H (the high byte of the text's address) into Register B.
517B
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.
517C
LD A,(HL) 7E
Fetch the next character of the text at Register Pair HL into Register A. 5184H loops back here.
517D
CP 20H FE 20
Compare Register A (the character) against 20H, a space.
517F
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 5137H to return with the NZ FLAG.
5181
INC HL 23
INCrement Register Pair HL past the character.
5182
CP 22H FE 22
Compare Register A (the character) against 22H, the closing quotation mark.
5184
If the NZ FLAG is set (not yet the closing quotation mark), JUMP to 517CH for the next character.
5186
JUMP to 5142H 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.

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

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

51ABH - 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 (5174H) stores the result whatever the flags say.

51AB
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A. 51BEH loops back here.
51AC
SUB 30H D6 30
SUBtract 30H from Register A (the character): a digit becomes its value 0-9.
51AE
CP 0AH FE 0A
Compare Register A (the character less 30H) against 0AH.
51B0
RET NC D0
If the NO CARRY FLAG is set (not a digit), RETurn with the number in Register Pair BC.
51B1
PUSH BC C5
Save Register Pair BC (the number so far) to the stack.
51B2
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.
51B3
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 2.
51B4
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 4.
51B5
ADD HL,BC 09
ADD Register Pair BC (the number) to Register Pair HL: Register Pair HL = the number x 5.
51B6
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 10.
51B7
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit's value.
51B9
LD C,A 4F
Copy Register A (the digit's value) into Register C: Register Pair BC = the digit.
51BA
ADD HL,BC 09
ADD Register Pair BC (the digit) to Register Pair HL: Register Pair HL = the number x 10 + the digit.
51BB
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.
51BC
POP BC C1
Restore Register Pair BC from the stack: the new number.
51BD
INC HL 23
INCrement Register Pair HL to the next character.
51BE
JUMP to 51ABH for the next digit of the number at Register Pair HL.

51C0H - 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.

51C0
LD A,(HL) 7E
Fetch the character after the X at Register Pair HL into Register A.
51C1
CP 27H FE 27
Compare Register A (the character after the X) against 27H, a quote.
51C3
RET NZ C0
If the NZ FLAG is set (no quote), RETurn with the NZ FLAG: a bad value.
51C4
INC HL 23
INCrement Register Pair HL to the next character. 51E8H loops back here.
51C5
LD A,(HL) 7E
Fetch the character at Register Pair HL into Register A.
51C6
SUB 30H D6 30
SUBtract 30H from Register A (the character).
51C8
If the CARRY FLAG is set (Register A was below 30H, the digit 0), JUMP to 51D6H: the number ends.
51CA
CP 0AH FE 0A
Compare Register A (the character less 30H) against 0AH.
51CC
If the CARRY FLAG is set (a digit 0-9: Register A is its value), JUMP to 51DEH to add it.
51CE
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.
51D0
SUB 07H D6 07
SUBtract 07H from Register A: A-F become 0AH-0FH.
51D2
CP 10H FE 10
Compare Register A (the digit's value) against 10H.
51D4
If the CARRY FLAG is set (Register A is 00H-0FH), JUMP to 51DEH to add it as a digit.
51D6
LD A,(HL) 7E
Fetch the character that ended the number at Register Pair HL into Register A.
51D7
CP 27H FE 27
Compare Register A (the character) against 27H, the closing quote.
51D9
INC HL 23
INCrement Register Pair HL past the character. INC does not change the Z FLAG of the compare.
51DA
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.
51DB
DEC HL 2B
DECrement Register Pair HL back onto the character: there is no closing quote.
51DC
XOR A AF
Set Register A to 00H (XOR A) with the Z FLAG set: the number is accepted all the same.
51DD
RET C9
RETurn with the Z FLAG, the number in Register Pair BC and Register Pair HL at the character after the digits.
51DE
PUSH BC C5
Save Register Pair BC (the number so far) to the stack.
51DF
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.
51E0
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 2.
51E1
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 4.
51E2
ADD HL,HL 29
ADD Register Pair HL to itself: Register Pair HL = the number x 8.
51E3
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.
51E4
LD B,H 44
Copy Register H (the high byte of the number x 16) into Register B.
51E5
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.
51E6
LD C,A 4F
Copy Register A into Register C: Register Pair BC = the number x 16 + the digit.
51E7
POP HL E1
Restore Register Pair HL from the stack: the text pointer.
51E8
JUMP to 51C4H for the next character of the number at Register Pair HL.

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

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

51EA-51EC
DEFM "CMD" 43 4D 44
51EAH-51ECH: CMD, the extension 4E8AH adds through 5048H to a command word that is not a library command. 5048H copies exactly three characters, so the text needs no end mark.
51ED
DEFB 0AH 0A
51EDH: 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.
51EE-51F7
DEFM "LDOS Ready" 4C 44 4F 53 20 52 65 61 64 79
51EEH-51F7H: the prompt LDOS Ready, in capitals and small letters.
51F8
DEFB 0DH 0D
51F8H: 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 (03F9H bytes, 4BC9H).