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

Page Customization

Summary:

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

SYS1/SYS is the LDOS command interpreter. On a Model I running LDOS 5.3.1 it is not resident: it is a system overlay that the SYS0 resident supervisor loads into the transient region at 4E00H whenever a command must be read and dispatched. Control reaches it through the RST 28H supervisor mechanism (ROM 0028H vectors to 400CH which jumps to the resident dispatcher at 4BCDH); that dispatcher reads the matching SYS file from the directory, loads it at 4E00H, patches its own self-modified CALL with the overlay entry, and calls 4E00H with the request code in Register A.

The entry at 4E00H masks Register A with 70H to isolate a three-bit sub-function selector and branches accordingly. Selector 10H is the interactive command level: it re-establishes the command stack, arms or disarms the DEBUG trap according to a system-configuration bit, displays the LDOS Ready prompt, and reads a command line from the keyboard through the ROM $KBLINE routine at 0040H. The first character of the buffered line is then examined: an exclamation-point force-execute prefix and a leading-period comment marker are handled, the command word is parsed into a file specification, and it is matched against a built-in command-name table located later in this overlay. The built-in command names in that table are APPEND, ATTRIB, AUTO, BOOT, BUILD, CLS, COPY, CREATE, DATE, DEBUG, DEVICE, DIR, DO, DUMP, FILTER, FORMS, FREE, KILL, LIB, LINK, LIST, LOAD, MEMORY, PURGE, RENAME, RESET, ROUTE, RUN, SET, SETCOM, SPOOL, SYSTEM, TIME, TOF and VERIFY. When no built-in matches, the interpreter appends the default /CMD extension and transfers to the resident @RUN service at 4433H to load and execute the named program file.

This page documents the resident-patch fragment at 4BC9H and the command-processor entry, prompt, keyboard line input, parse, dispatch, break/abort and comment-line paths (4E00H through the RETurn at 4EA7H). The filespec parser at 4FD6H, the extension-append routine at 5048H, the selector-60H routine at 510EH, the command-name lookup at 50CBH, and the command-name and message data (4EBDH onward) are documented in the sections that follow in later portions of this disassembly.

Variable and Buffer List

Addresses in the 43xxH through 47xxH range are resident SYS0 system-area locations shared by every overlay (cross-referenced to the SYS0 page). Addresses at 4E7BH and above lie within this SYS1 overlay image.

Address Range
Bytes
Purpose
4318H-4357H
64 bytes
Resident command-line input buffer. The caller's string (default path) or the keyboard line ($KBLINE) is placed here and terminated with 03H.
430FH
1 byte
Resident system configuration flags. Bit 7 enables the DEBUG single-step trap (read at 4E32H); bit 5 selects whether a leading-period comment line returns or loops for another line (read at 4EA0H).
4315H
1 byte
Resident DEBUG trap-vector opcode byte. Set to 0C3H (JP opcode, trap armed) or 00H (trap disarmed) at 4E3BH based on 430FH bit 7.
4480H
1 buffer
Resident parsed file-specification buffer. The command word is copied and validated into this buffer by the parser at 4FD6H.
4758H
1 byte
Resident command-processor status flags. Bit 1 marks caller-handled errors and gates the abort path (4E97H); bit 2 marks that a line is being entered (4E47H); bit 4 requests parse-only without executing the file (4E8EH).
4E7BH
1 byte
Self-modifying operand of the LD A,nn at 4E7AH. Written at 4E66H with (first command character minus 21H); zero indicates the exclamation-point force-execute prefix.
4EBDH-...
8 bytes/entry
Built-in command-name table. Each entry is a six-character, space-padded command name followed by a two-byte dispatch word: a one-byte command code (offset +6) and a one-byte dispatch flag (offset +7, bit 7 set for a library call, bit 6 selecting Library A or B). Searched by 50CBH with a stride of 8.
51EAH-51ECH
3 bytes
Default file extension string CMD (no terminator), appended to the file specification by 5048H.
51EDH-51F8H
12 bytes
Command prompt string: 0AH line feed, the text LDOS Ready, and 0DH carriage return. Displayed by @DSPLY at 4E41H.

Major Routine List

AddressName and Purpose
4BC9HResident Patch
Two bytes (F9H, 03H) deposited by the overlay load records into resident low RAM immediately below the RST 28H dispatcher, falling into the resident disk-operation executor at 4BCBH. Entry: reached in the resident supervisor context. Exit: falls into 4BCBH.
4E00HCommand Processor Entry and Sub-Function Dispatch
Isolates the sub-function selector from Register A and branches; the default path buffers a caller string to 4318H. Entry: Register A = RST 28H request code. Exit: to the selected sub-function, or RET on selector 00H.
4E2EHInteractive Prompt and Line Input
Re-establishes the command stack, arms/disarms the DEBUG trap, displays LDOS Ready, and reads a command line via ROM $KBLINE. Entry: selector 10H. Exit: falls into the parser at 4E5CH, or to the abort path on BREAK.
4E5CHCommand-Line Parse and Dispatch
Scans the line, handles the exclamation-point prefix, parses the file specification, searches the built-in command table, and otherwise appends /CMD and runs the file. Entry: HL points at the command line. Exit: JP @RUN (4433H), RET, or the abort path.
4E97HBreak and Abort Path
Returns quietly when status bit 1 is set, otherwise jumps to the resident @ABORT handler. Entry: BREAK, filespec error, or wildcard command word. Exit: RET or JP @ABORT (4030H).
4EA0HComment-Line Handling
Handles a command line beginning with a period; loops back for another line or returns based on configuration bit 5. Entry: first character is a period. Exit: LOOP to 4E44H or RET.

Cross-Reference Notes

SYS1/SYS is invoked by the resident SYS0 RST 28H supervisor dispatcher (4BCDH) as an overlay loaded at 4E00H, and returns to it. It calls into the resident SYS0 system area for @DSPLY (4467H), the command-line hook vector (447EH), @RUN (4433H) and @ABORT (4030H), and pushes @EXIT (402DH) as a completion return; all of these are documented on the LDOS Model I SYS0/SYS page. Internal forward references (4FD6H, 5048H, 510EH, 50CBH) are resolved within this overlay in later sections.

Disassembly:

4BC9H - Resident Patch (RST 28H Dispatcher Area)

A two-byte load block that the SYS1 overlay image deposits into resident low RAM at 4BC9H, immediately below the RST 28H supervisor dispatcher.

4BC9
LD SP,HL F9
Load the Stack Pointer from Register Pair HL. These two bytes are written by the overlay's load records into the resident system area at 4BC9H (a region left as padding in the SYS0 resident core), directly beneath the RST 28H supervisor dispatcher at 4BCDH.
4BCA
INC BC 03
INCrement Register Pair BC by 1. Execution then falls through into the resident disk-operation executor at 4BCBH in the SYS0 core.

This two-byte fragment is loaded to 4BC9H-4BCAH from the SYS1 file and patches the resident low-RAM area shared with SYS0. The overlay body proper begins at 4E00H.

4E00H - Command Processor Entry and Sub-Function Dispatch

SYS1 overlay entry point. The RST 28H supervisor loads this overlay and calls 4E00H with the request code in Register A; bits 4 through 6 select the sub-function and the low bits carry option flags.

4E00
AND 70H E6 70
AND Register A (the RST 28H request code passed by the caller) with 70H to isolate bits 4 through 6, the sub-function selector. The low nibble option bits are discarded. The Z FLAG is set when all three selector bits are zero.
4E02
RET Z C8
If the Z FLAG is set (masked selector 00H, no sub-function requested), RETurn to the RST 28H dispatcher immediately.
4E03
CP 10H FE 10
Compare Register A (the masked selector) against 10H. If Register A equals 10H the Z FLAG is set; otherwise the NZ FLAG is set.
4E05
If the Z FLAG is set (selector 10H, the interactive command-prompt entry), JUMP to 4E2EH to display the LDOS Ready prompt and read a command line.
4E07
CP 40H FE 40
Compare the masked selector in Register A against 40H. If equal the Z FLAG is set.
4E09
If the Z FLAG is set (selector 40H, the file-specification parse service), JUMP to the filespec parser at 4FD6H within this overlay.
4E0C
CP 50H FE 50
Compare the masked selector in Register A against 50H. If equal the Z FLAG is set.
4E0E
If the Z FLAG is set (selector 50H, the append-default-extension service), JUMP to 5048H within this overlay.
4E11
CP 60H FE 60
Compare the masked selector in Register A against 60H. If equal the Z FLAG is set.
4E13
If the Z FLAG is set (selector 60H), JUMP to 510EH within this overlay.
4E16
LD DE,4318H 11 18 43
Point Register Pair DE to 4318H, the resident command-line buffer in the SYS0 system area. This is the default path for selectors 20H, 30H and 70H, which pass a string in HL to be buffered.
4E19
PUSH DE D5
Save the buffer start address (4318H) on the stack for retrieval after the copy.
4E1A
LD BC,003FH 01 3F 00
Load Register Pair BC with 003FH (63), the byte count for the block copy.
4E1D
LDIR ED B0
Block-copy 63 bytes from the caller's string at (HL) to the command-line buffer at (DE=4318H), incrementing both pointers while BC counts down to zero. Source = caller string (HL); Destination = 4318H; Count = 63.
4E1F
EX DE,HL EB
Exchange DE and HL so that HL now points just past the copied block (4357H).
4E20
LD (HL),03H 36 03
Store 03H (the ETX end-of-text terminator) into the byte immediately following the copied command line at (HL=4357H).
4E22
LD HL,4758H 21 58 47
Point Register Pair HL to 4758H, the command-processor status-flag byte in the SYS0 system area.
4E25
CP 30H FE 30
Compare the masked selector still held in Register A against 30H. If equal the Z FLAG is set.
4E27
If the Z FLAG is set (selector 30H), JUMP to 4E53H, skipping the status-flag bit-1 set below.
4E29
SET 1,(HL) CB CE
Set bit 1 of the command-processor status-flag byte at (HL=4758H) for selectors 20H and 70H.
4E2B
POP HL E1
Restore HL to the command-line buffer start (4318H) saved earlier on the stack.
4E2C
JUMP to the command-line parser at 4E5CH.

4E2EH - Interactive Prompt: LDOS Ready and Line Input

Selector 10H entry. Re-establishes the command stack, arms or disarms the DEBUG trap, prints the LDOS Ready prompt, and reads a command line from the keyboard.

4E2E
LD SP,41E0H 31 E0 41
Load the Stack Pointer with 41E0H, re-establishing the resident command-level stack in the SYS0 system area and discarding any nested return addresses.
4E31
EI FB
Enable maskable interrupts so the real-time clock and keyboard interrupt tasks run while the interpreter waits for input.
4E32
LD A,(430FH) 3A 0F 43
Fetch the system configuration flags from 430FH (SYS0 system area) into Register A.
4E35
RLCA 07
Rotate Register A left circular, moving bit 7 (the DEBUG-enabled configuration flag) into the CARRY FLAG.
4E36
LD A,0C3H 3E C3
Load Register A with 0C3H, the opcode byte for an unconditional JP - the armed state of the DEBUG trap vector.
4E38
If the CARRY FLAG is set (bit 7 of 430FH was set, DEBUG enabled), JUMP to 4E3BH keeping Register A = 0C3H.
4E3A
XOR A AF
Exclusive-OR Register A with itself, setting Register A to 00H (DEBUG trap disarmed) when bit 7 of 430FH was clear.
4E3B
LD (4315H),A 32 15 43
Store Register A (0C3H armed, or 00H disarmed) to 4315H, the resident DEBUG trap-vector opcode byte in the SYS0 system area, arming or disarming the single-step trap.
4E3E
LD HL,51EDH 21 ED 51
Point Register Pair HL to the prompt string at 51EDH within this overlay: 0AH (line feed), the text LDOS Ready, and 0DH (carriage return).
4E41
GOSUB to the resident @DSPLY routine at 4467H (SYS0 system area) to display the LDOS Ready prompt string pointed to by HL.
4E44
LD HL,4758H 21 58 47
Point Register Pair HL to the command-processor status-flag byte at 4758H (SYS0 system area). This address is also the re-entry point from the comment-line path at 4EA5H, which reads the next command line without redisplaying the prompt.
4E47
SET 2,(HL) CB D6
Set bit 2 of the status-flag byte at (HL=4758H), marking that a command line is being entered.
4E49
PUSH HL E5
Save the status-flag pointer (4758H) on the stack for retrieval after line input.
4E4A
LD HL,4318H 21 18 43
Point Register Pair HL to the command-line input buffer at 4318H (SYS0 system area).
4E4D
LD B,3FH 06 3F
Load Register B with 3FH (63), the maximum number of characters the ROM line-input routine will accept.
4E4F
GOSUB to the ROM keyboard line-input routine $KBLINE at 0040H. It reads an edited line into the buffer at (HL=4318H) for up to B=63 characters and returns with the CARRY FLAG set if BREAK was pressed, or clear if ENTER was pressed.
4E52
EX (SP),HL E3
Exchange HL with the top of the stack, leaving the returned buffer pointer on the stack and recovering the status-flag pointer (4758H) into HL.
4E53
LD (HL),00H 36 00
Store 00H into the status-flag byte at (HL=4758H), clearing all command-processor status flags after input. Selector 30H enters the routine here directly.
4E55
POP HL E1
Restore HL to the command-line buffer pointer left on the stack.
4E56
If the CARRY FLAG is still set (BREAK was pressed during line input), JUMP to 4E97H, the break/abort path.
4E58
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, the address of the resident @EXIT routine (SYS0 system area).
4E5B
PUSH BC C5
Push 402DH (@EXIT) onto the stack as the completion return address, so the interpreter returns to @EXIT when command processing finishes.

4E5CH - Command-Line Parse and Dispatch

Scans the buffered command line, isolates the command word, matches it against the built-in command-name table, and otherwise runs it as a program file.

4E5C
GOSUB to the resident hook vector at 447EH (SYS0 system area), which by default is a JR to a return stub and returns immediately; a resident filter may intercept this entry. Register Pair HL still points at the first character of the command line held at 4318H.
4E5F
LD A,(HL) 7E
Fetch the first significant command character from (HL) into Register A.
4E60
CP 2EH FE 2E
Compare Register A against 2EH (ASCII ., the JCL comment marker). If equal the Z FLAG is set.
4E62
If the Z FLAG is set (the line begins with a period), JUMP to 4EA0H to handle the comment line.
4E64
SUB 21H D6 21
SUBtract 21H (ASCII !) from Register A. The result is zero only when the first character is an exclamation point, the force-execute prefix.
4E66
LD (4E7BH),A 32 7B 4E
Self-Modifying Code
Store the result into 4E7BH, the immediate operand of the LD A,nn instruction at 4E7AH below, preserving the exclamation-point test for use after the file specification has been parsed.
4E69
If the NZ FLAG is set (the first character is not an exclamation point), JUMP to 4E6CH without consuming the character.
4E6B
INC HL 23
INCrement HL to step past the exclamation-point prefix so it is not treated as part of the file name.
4E6C
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, the resident parsed file-specification buffer in the SYS0 system area.
4E6F
GOSUB to the filespec parser at 4FD6H (this overlay), which copies and validates the command word at (HL) into the file-specification buffer at (DE=4480H). It returns with the NZ FLAG set on a parse error.
4E72
If the NZ FLAG is set (the command word is not a valid file specification), JUMP to 4E97H, the break/abort path.
4E74
LD A,(DE) 1A
Fetch the first character of the parsed file specification from (DE=4480H) into Register A.
4E75
CP 2AH FE 2A
Compare Register A against 2AH (ASCII *). If equal the Z FLAG is set.
4E77
If the Z FLAG is set (the command word is a bare wildcard asterisk, which is not a legal command), JUMP to 4E97H, the break/abort path.
4E79
PUSH HL E5
Save the command-line pointer (HL) on the stack across the command-name table search.
4E7A
LD A,00H 3E 00
Load Register A with the exclamation-point test result held at 4E7BH. The operand shown as 00H is overwritten at run time by the Self-Modifying Code at 4E66H; it is zero only when the command carried the exclamation-point prefix.
4E7C
OR A B7
OR Register A with itself to test whether the value is zero, setting the Z FLAG when the exclamation-point prefix was present.
4E7D
If the Z FLAG is set (exclamation-point prefix, forcing execution as a program), JUMP to 4E87H, skipping the built-in command-name search.
4E7F
LD BC,4EBDH 01 BD 4E
Point Register Pair BC to 4EBDH, the base of this overlay's built-in command-name table (eight-byte entries: a six-character space-padded name, a one-byte command code at offset +6, and a one-byte dispatch flag at offset +7).
4E82
GOSUB to the command-name lookup routine at 50CBH (this overlay), which searches the table at (BC) for the parsed command word and returns with the Z FLAG set when a built-in command matches.
4E85
If the Z FLAG is set (a built-in command matched), JUMP to 4EA8H to dispatch that command.
4E87
LD HL,51EAH 21 EA 51
Point Register Pair HL to the three-character default extension string CMD at 51EAH within this overlay.
4E8A
GOSUB to the extension-append routine at 5048H (this overlay) to attach the default /CMD extension pointed to by HL to the parsed file specification.
4E8D
POP HL E1
Restore the command-line pointer (HL) saved before the table search.
4E8E
LD A,(4758H) 3A 58 47
Fetch the command-processor status-flag byte from 4758H (SYS0 system area) into Register A.
4E91
AND 10H E6 10
AND Register A with 10H to isolate bit 4 of the status flags. The Z FLAG is set when bit 4 is clear.
4E93
If the Z FLAG is set (status bit 4 clear), JUMP to the resident @RUN routine at 4433H (SYS0 system area) to load and execute the named /CMD program file.
4E96
RET C9
RETurn to the caller. Status bit 4 set requests parse-only, without executing the file.

4E97H - Break and Abort Path

Reached on BREAK during line input, a file-specification error, or a wildcard command word. Either returns quietly or aborts to the resident @ABORT handler depending on status bit 1.

4E97
LD A,(4758H) 3A 58 47
Fetch the command-processor status-flag byte from 4758H (SYS0 system area) into Register A.
4E9A
AND 02H E6 02
AND Register A with 02H to isolate bit 1 of the status flags. The NZ FLAG is set when bit 1 is set.
4E9C
RET NZ C0
If the NZ FLAG is set (status bit 1 set, the caller handles its own errors), RETurn to the caller.
4E9D
JUMP to the resident @ABORT routine at 4030H (SYS0 system area) to abort the current job when status bit 1 is clear.

4EA0H - Comment-Line Handling

Reached when the command line begins with a period. Loops back to read another line, or returns, based on system configuration bit 5.

4EA0
LD A,(430FH) 3A 0F 43
Fetch the system configuration flags from 430FH (SYS0 system area) into Register A.
4EA3
BIT 5,A CB 6F
Test bit 5 of Register A (the configuration flags). The Z FLAG is set when bit 5 is clear.
4EA5
If the Z FLAG is set (configuration bit 5 clear), LOOP BACK to 4E44H to read the next command line without redisplaying the prompt, ignoring the period comment.
4EA7
RET C9
RETurn to the caller when configuration bit 5 is set.

4EA8H - Built-in Command Dispatch

Entered from 4E85H when the typed command matches a name in the command table. Register Pair DE holds the matched entry's two dispatch bytes (E = command code, D = dispatch flag). Bit 7 of the flag chooses a direct jump into this overlay versus a library call through RST 28H.

4EA8
POP HL E1
Discard the command-line pointer saved on the stack at 4E79H, balancing the stack before dispatch.
4EA9
LD (4315H),A 32 15 43
Store Register A (00H, cleared by the table search at 50FDH) into 4315H, the resident DEBUG trap-vector opcode byte (SYS0 system area), disarming the single-step trap before the command runs.
4EAC
LD A,D 7A
Load Register A with Register D, the dispatch flag byte from the matched command-table entry.
4EAD
RLA 17
Rotate Register A left through carry (carry entered clear), moving flag bit 7 into the CARRY FLAG.
4EAE
PUSH DE D5
Push the dispatch word DE (E = command code, D = flag) so it can serve as a jump target for direct commands.
4EAF
RET NC D0
If the NO CARRY FLAG is set (flag bit 7 clear, a direct command such as BOOT), RETurn - popping the pushed DE off the stack as the return address and thereby JUMPing to the handler address it holds (4EB6H for BOOT).
4EB0
POP DE D1
Flag bit 7 was set (a library command). Restore Register Pair DE from the value just pushed.
4EB1
LD B,E 43
Load Register B with Register E, the command code byte, to pass to the command-library overlay.
4EB2
RLA 17
Rotate Register A left through carry again, bringing flag bit 6 into the CARRY FLAG and leaving A = 01H.
4EB3
ADC A,87H CE 87
Add 87H plus carry to Register A, forming the RST 28H request code: 88H when the flag was 80H (command library A) or 89H when the flag was 0C0H (command library B).
4EB5
RST 28 EF
Issue the RST 28H supervisor call with the computed request code in Register A and the command code in Register B, invoking the resident dispatcher to load and run the command-library overlay that implements this built-in command.

4EB6H - BOOT Command Handler

Direct-jump target for the BOOT command (dispatch word 4EB6H). Re-homes the disk and halts pending the system restart.

4EB6
XOR A AF
Exclusive-OR Register A with itself, setting Register A to 00H.
4EB7
LD D,A 57
Load Register D with 00H (track/parameter zero for the seek).
4EB8
LD C,A 4F
Load Register C with 00H (drive zero, the boot drive).
4EB9
GOSUB to the resident SEEK disk primitive at 475EH (SYS0 system area) with drive 0 (Register C) and track 0 (Register D), re-homing the boot drive read/write head to begin the reboot.
4EBC
HALT 76
HALT the CPU, suspending execution until the pending system-restart interrupt occurs. This byte also serves as the single filler byte before the command-name table.

4EBDH - Command Name Table

The table of built-in DOS command names searched by the lookup routine at 50CBH. There are thirty-five eight-byte entries: a six-character, space-padded command name followed by a one-byte command code and a one-byte dispatch flag.

Dispatch flag decoding (see 4EA8H): when flag bit 7 is clear the command code and flag together form a direct jump address inside this overlay (only BOOT, dispatch word 4EB6H). When flag bit 7 is set the interpreter issues RST 28H with request code 88H (flag 80H, command library A) or 89H (flag 0C0H, command library B) and Register B holding the command code, invoking the library overlay that runs the command.

4EBD
DEFM 'APPEND',31H,80H 41 50 50 45 4E 44 31 80
The APPEND command. Command code 31H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 31H).
4EC5
DEFM 'ATTRIB',51H,0C0H 41 54 54 52 49 42 51 C0
The ATTRIB command. Command code 51H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 51H).
4ECD
DEFM 'AUTO ',11H,0C0H 41 55 54 4F 20 20 11 C0
The AUTO command. Command code 11H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 11H).
4ED5
DEFM 'BOOT ',0B6H,4EH 42 4F 4F 54 20 20 B6 4E
The BOOT command. Dispatch flag 4EH has bit 7 clear, so the two bytes form the direct jump address 4EB6H, the BOOT handler in this overlay.
4EDD
DEFM 'BUILD ',33H,0C0H 42 55 49 4C 44 20 33 C0
The BUILD command. Command code 33H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 33H).
4EE5
DEFM 'CLS ',24H,80H 43 4C 53 20 20 20 24 80
The CLS command. Command code 24H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 24H).
4EED
DEFM 'COPY ',32H,80H 43 4F 50 59 20 20 32 80
The COPY command. Command code 32H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 32H).
4EF5
DEFM 'CREATE',13H,0C0H 43 52 45 41 54 45 13 C0
The CREATE command. Command code 13H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 13H).
4EFD
DEFM 'DATE ',15H,0C0H 44 41 54 45 20 20 15 C0
The DATE command. Command code 15H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 15H).
4F05
DEFM 'DEBUG ',14H,0C0H 44 45 42 55 47 20 14 C0
The DEBUG command. Command code 14H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 14H).
4F0D
DEFM 'DEVICE',61H,80H 44 45 56 49 43 45 61 80
The DEVICE command. Command code 61H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 61H).
4F15
DEFM 'DIR ',21H,80H 44 49 52 20 20 20 21 80
The DIR command. Command code 21H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 21H).
4F1D
DEFM 'DO ',91H,80H 44 4F 20 20 20 20 91 80
The DO command. Command code 91H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 91H).
4F25
DEFM 'DUMP ',71H,0C0H 44 55 4D 50 20 20 71 C0
The DUMP command. Command code 71H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 71H).
4F2D
DEFM 'FILTER',66H,80H 46 49 4C 54 45 52 66 80
The FILTER command. Command code 66H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 66H).
4F35
DEFM 'FORMS ',0B1H,0C0H 46 4F 52 4D 53 20 B1 C0
The FORMS command. Command code 0B1H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 0B1H).
4F3D
DEFM 'FREE ',22H,0C0H 46 52 45 45 20 20 22 C0
The FREE command. Command code 22H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 22H).
4F45
DEFM 'KILL ',18H,80H 4B 49 4C 4C 20 20 18 80
The KILL command. Command code 18H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 18H).
4F4D
DEFM 'LIB ',19H,80H 4C 49 42 20 20 20 19 80
The LIB command. Command code 19H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 19H).
4F55
DEFM 'LINK ',62H,80H 4C 49 4E 4B 20 20 62 80
The LINK command. Command code 62H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 62H).
4F5D
DEFM 'LIST ',41H,80H 4C 49 53 54 20 20 41 80
The LIST command. Command code 41H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 41H).
4F65
DEFM 'LOAD ',81H,80H 4C 4F 41 44 20 20 81 80
The LOAD command. Command code 81H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 81H).
4F6D
DEFM 'MEMORY',1EH,80H 4D 45 4D 4F 52 59 1E 80
The MEMORY command. Command code 1EH; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 1EH).
4F75
DEFM 'PURGE ',72H,0C0H 50 55 52 47 45 20 72 C0
The PURGE command. Command code 72H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 72H).
4F7D
DEFM 'RENAME',53H,80H 52 45 4E 41 4D 45 53 80
The RENAME command. Command code 53H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 53H).
4F85
DEFM 'RESET ',63H,80H 52 45 53 45 54 20 63 80
The RESET command. Command code 63H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 63H).
4F8D
DEFM 'ROUTE ',64H,80H 52 4F 55 54 45 20 64 80
The ROUTE command. Command code 64H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 64H).
4F95
DEFM 'RUN ',82H,80H 52 55 4E 20 20 20 82 80
The RUN command. Command code 82H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 82H).
4F9D
DEFM 'SET ',65H,80H 53 45 54 20 20 20 65 80
The SET command. Command code 65H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 65H).
4FA5
DEFM 'SETCOM',0B2H,0C0H 53 45 54 43 4F 4D B2 C0
The SETCOM command. Command code 0B2H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 0B2H).
4FAD
DEFM 'SPOOL ',0A2H,80H 53 50 4F 4F 4C 20 A2 80
The SPOOL command. Command code 0A2H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 0A2H).
4FB5
DEFM 'SYSTEM',0A1H,0C0H 53 59 53 54 45 4D A1 C0
The SYSTEM command. Command code 0A1H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 0A1H).
4FBD
DEFM 'TIME ',16H,0C0H 54 49 4D 45 20 20 16 C0
The TIME command. Command code 16H; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 16H).
4FC5
DEFM 'TOF ',25H,80H 54 4F 46 20 20 20 25 80
The TOF command. Command code 25H; dispatch flag 80H selects library A (RST 28H code 88H, Register B = 25H).
4FCD
DEFM 'VERIFY',1BH,0C0H 56 45 52 49 46 59 1B C0
The VERIFY command. Command code 1BH; dispatch flag 0C0H selects library B (RST 28H code 89H, Register B = 1BH).
4FD5
DEFB 00H 00
Zero byte terminating the command-name table; the lookup routine at 50CBH stops when it reads a 00H first-character.

4FD6H - File Specification Parser

Selector 40H service. Parses a file specification at (HL) into the buffer at (DE), accepting name, /extension, .password and :drive fields, then checks the result against the connector-keyword table. Returns Register A = 00H (Z) on success or NZ on error.

4FD6
PUSH DE D5
Save the destination buffer start (DE) for the error and completion paths.
4FD7
GOSUB to the field scanner at 5079H (Register B set to 8) to copy the file name from (HL) into the buffer at (DE), returning the delimiter character in Register A.
4FDA
If the NZ FLAG is set (the field ended on something other than a clean terminator), JUMP to 5018H to test for a wildcard name.
4FDC
CP 2FH FE 2F
Compare the delimiter in Register A against 2FH (ASCII /, the extension separator). If equal the Z FLAG is set.
4FDE
If the NZ FLAG is set (no extension present), JUMP to 4FE7H.
4FE0
LD (DE),A 12
Store the / separator into the destination buffer at (DE).
4FE1
INC DE 13
Advance the destination pointer DE past the separator.
4FE2
LD B,03H 06 03
Load Register B with 3 (the maximum extension length).
4FE4
GOSUB to the field scanner at 507BH (Register B preset to 3) to copy the extension into the buffer, returning the next delimiter in Register A.
4FE7
CP 2EH FE 2E
Compare the delimiter in Register A against 2EH (ASCII ., the password separator). If equal the Z FLAG is set.
4FE9
If the NZ FLAG is set (no password present), JUMP to 4FF2H.
4FEB
LD (DE),A 12
Store the . separator into the destination buffer at (DE).
4FEC
INC DE 13
Advance the destination pointer DE past the separator.
4FED
GOSUB to the field scanner at 5079H (Register B set to 8) to copy the password field into the buffer, returning the next delimiter in Register A.
4FF0
If the NZ FLAG is set (the password field ended abnormally), JUMP to 5025H, the parser error exit.
4FF2
CP 3AH FE 3A
Compare the delimiter in Register A against 3AH (ASCII :, the drive separator). If equal the Z FLAG is set.
4FF4
If the NZ FLAG is set (no drive specifier present), JUMP to 4FFFH.
4FF6
LD (DE),A 12
Store the : separator into the destination buffer at (DE).
4FF7
INC DE 13
Advance the destination pointer DE past the separator.
4FF8
LD B,01H 06 01
Load Register B with 1 (a drive number is a single digit).
4FFA
GOSUB to the field scanner at 507BH (Register B preset to 1) to copy the drive digit into the buffer, returning the next delimiter in Register A.
4FFD
If the NZ FLAG is set (the drive field ended abnormally), JUMP to 5025H, the parser error exit.
4FFF
CP 21H FE 21
Compare the delimiter in Register A against 21H (ASCII !). If equal the Z FLAG is set.
5001
If the NZ FLAG is set (no ! present), JUMP to 5006H.
5003
LDI ED A0
Copy one byte from (HL) to (DE), advancing both and decrementing BC, carrying the ! character into the destination.
5005
LD A,(HL) 7E
Fetch the next source character at (HL) into Register A.
5006
LD C,A 4F
Save the current delimiter character (Register A) into Register C.
5007
LD A,03H 3E 03
Load Register A with 03H, the end-of-field terminator.
5009
LD (DE),A 12
Store the 03H terminator at the end of the parsed specification in (DE).
500A
LD A,C 79
Restore the saved delimiter character from Register C into Register A.
500B
POP DE D1
Restore DE to the destination buffer start saved at 4FD6H.
500C
PUSH DE D5
Re-save the buffer start for the keyword check that follows.
500D
LD BC,5027H 01 27 50
Point Register Pair BC to 5027H, the connector-keyword table.
5010
GOSUB to the table search at 50CBH to test whether the parsed word is a connector keyword (TO, ON, OVER, USING) held in the table at (BC).
5013
POP DE D1
Restore DE to the destination buffer start.
5014
If the Z FLAG is set (the word was a connector keyword), LOOP BACK to 4FD6H to parse the following file specification.
5016
XOR A AF
Set Register A to 00H, the success return code (Z FLAG set).
5017
RET C9
RETurn to the caller with a valid parsed file specification.
5018
CP 2AH FE 2A
Compare the delimiter in Register A against 2AH (ASCII *, the wildcard). If equal the Z FLAG is set.
501A
If the NZ FLAG is set (not a wildcard), JUMP to 5025H, the parser error exit.
501C
LD (DE),A 12
Store the * wildcard character into the destination buffer at (DE).
501D
INC DE 13
Advance the destination pointer DE past the wildcard.
501E
LD B,02H 06 02
Load Register B with 2 (accept a two-character wildcard field).
5020
GOSUB to the field scanner at 507BH to copy the wildcard field, returning the next delimiter in Register A.
5023
If the Z FLAG is set (clean field terminator), JUMP to 5006H to finish the specification.
5025
POP DE D1
Error exit: restore DE to the buffer start saved at 4FD6H.
5026
RET C9
RETurn to the caller with the NZ FLAG set, signalling a file-specification error.

5027H - Connector Keyword Table

Eight-byte entries searched at 5010H: a six-character, space-padded connector keyword followed by a two-byte handler pointer (4200H, the parameter work buffer). Terminated by a zero byte.

5027
DEFM 'TO ' 54 4F 20 20 20 20
The connector keyword TO, space-padded to six characters.
502D
DEFW 4200H 00 42
Handler pointer for TO: 4200H, the parameter work buffer used by the parameter parser at 510EH.
502F
DEFM 'ON ' 4F 4E 20 20 20 20
The connector keyword ON, space-padded to six characters.
5035
DEFW 4200H 00 42
Handler pointer for ON: 4200H, the parameter work buffer.
5037
DEFM 'OVER ' 4F 56 45 52 20 20
The connector keyword OVER, space-padded to six characters.
503D
DEFW 4200H 00 42
Handler pointer for OVER: 4200H, the parameter work buffer.
503F
DEFM 'USING ' 55 53 49 4E 47 20
The connector keyword USING, space-padded to six characters.
5045
DEFW 4200H 00 42
Handler pointer for USING: 4200H, the parameter work buffer.
5047
DEFB 00H 00
Zero byte terminating the connector-keyword table.

5048H - Append Default Extension

Selector 50H service. Scans the parsed file specification for an existing /extension; if none is present it inserts the default extension pointed to by HL (the string CMD at 51EAH). On entry HL points to the extension string and DE to the file specification.

5048
PUSH DE D5
Save the file-specification pointer (DE).
5049
PUSH HL E5
Save the default-extension pointer (HL).
504A
EX DE,HL EB
Exchange DE and HL so HL now scans the file specification.
504B
INC HL 23
Advance HL past the first character of the file name.
504C
LD B,09H 06 09
Load Register B with 9, the maximum number of name characters to scan for a separator.
504E
LD A,(HL) 7E
Fetch the next specification character at (HL) into Register A.
504F
CP 2FH FE 2F
Compare Register A against 2FH (ASCII /). If equal the Z FLAG is set.
5051
If the Z FLAG is set (an extension is already present), JUMP to 505DH to leave the specification unchanged.
5053
If the CARRY FLAG is set (the character is below /, a field terminator), JUMP to 5060H to insert the default extension.
5055
GOSUB to the alphanumeric classifier at 50BDH, which sets the CARRY FLAG when Register A is not a letter or digit.
5058
If the CARRY FLAG is set (a non-alphanumeric name terminator), JUMP to 5060H to insert the default extension.
505A
INC HL 23
Advance HL to the next specification character.
505B
DECrement Register B and LOOP BACK to 504EH while characters remain to scan.
505D
POP HL E1
Restore the default-extension pointer (HL).
505E
POP DE D1
Restore the file-specification pointer (DE).
505F
RET C9
RETurn to the caller; the specification already carried an extension.

5060H - Insert Default Extension

Reached when the file specification has no extension. Shifts the specification to open a four-byte gap and writes the / separator followed by the three-character default extension.

5060
LD BC,000FH 01 0F 00
Load Register Pair BC with 15, the span of the specification field being shifted.
5063
ADD HL,BC 09
Advance HL by 15 to the end of the specification field.
5064
LD D,H 54
Copy HL into DE (high byte) to build the block-move destination.
5065
LD E,L 5D
Copy HL into DE (low byte); DE now equals HL.
5066
INC DE 13
Advance the destination DE by one (first of four) to open the extension gap.
5067
INC DE 13
Advance the destination DE by one (second of four).
5068
INC DE 13
Advance the destination DE by one (third of four).
5069
INC DE 13
Advance the destination DE by one (fourth of four); the gap is now four bytes wide.
506A
INC BC 03
INCrement the move count in Register Pair BC to 16 bytes.
506B
LDDR ED B8
Block-copy 16 bytes downward from (HL) to (DE), shifting the specification tail four positions to the right to make room for the extension. Source = (HL); Destination = (DE); Count = BC.
506D
POP HL E1
Restore the default-extension pointer saved at 5049H into HL.
506E
INC HL 23
Advance HL to the last character of the three-character extension string.
506F
INC HL 23
Advance HL once more so it points at the final extension character for the backward copy.
5070
LD C,03H 0E 03
Load Register C with 3, the extension length for the backward copy.
5072
LDDR ED B8
Block-copy the three extension characters downward from (HL) into the gap at (DE). Source = (HL); Destination = (DE); Count = 3.
5074
LD A,2FH 3E 2F
Load Register A with 2FH (ASCII /), the extension separator.
5076
LD (DE),A 12
Store the / separator ahead of the inserted extension at (DE).
5077
POP DE D1
Restore the file-specification pointer saved at 5048H into DE.
5078
RET C9
RETurn to the caller with the default extension inserted.

5079H - Scan Name Field

Copies one file-specification field from (HL) to (DE), uppercasing letters, honouring the field-width limit in Register B, and stopping at a terminator. Entry 5079H presets an eight-character field; entry 507BH uses the width already in Register B. The delimiter character is returned in Register A.

5079
LD B,08H 06 08
Load Register B with 8, the default field width for a file name or password.
507B
LD A,B 78
Copy the field-width count from Register B into Register A. Alternate entry used when the caller has preset Register B.
507C
LD (50B9H),A 32 B9 50
Self-Modifying Code
Store the field width into 50B9H, the immediate operand of the LD A,nn at 50B8H, recording the starting width for the terminator logic.
507F
INC B 04
INCrement Register B so the following decrement loop counts the full field width.
5080
LD A,(HL) 7E
Fetch the next source character at (HL) into Register A.
5081
CP 03H FE 03
Compare Register A against 03H (the end-of-line terminator). If equal the Z FLAG is set.
5083
If the Z FLAG is set (end of line), JUMP to 50ABH to finish the field.
5085
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If equal the Z FLAG is set.
5087
If the Z FLAG is set (carriage return), JUMP to 50ABH to finish the field.
5089
CP 28H FE 28
Compare Register A against 28H (ASCII (, the start of a parameter list). If equal the Z FLAG is set.
508B
If the Z FLAG is set (a parameter list begins), JUMP to 50ABH to finish the field.
508D
INC HL 23
Advance the source pointer HL past this character.
508E
GOSUB to the alphanumeric classifier at 50BDH, which returns the CARRY FLAG clear when Register A is a letter or digit.
5091
If the NO CARRY FLAG is set (an upper-case letter or digit), JUMP to 509DH to store the character as is.
5093
CP 61H FE 61
Compare Register A against 61H (ASCII a). Sets the CARRY FLAG when the character is below lower-case a.
5095
If the CARRY FLAG is set (a punctuation delimiter below a), JUMP to 50ABH to finish the field.
5097
CP 7BH FE 7B
Compare Register A against 7BH (ASCII {, one past lower-case z).
5099
If the NO CARRY FLAG is set (above lower-case z), JUMP to 50ABH to finish the field.
509B
RES 5,A CB AF
Reset bit 5 of Register A, converting a lower-case letter to upper case.
509D
DEC B 05
DECrement the remaining field-width count in Register B.
509E
If the Z FLAG is set (the field width is exhausted), JUMP to 50A8H to keep scanning without storing.
50A0
LD (DE),A 12
Store the accepted character into the destination buffer at (DE).
50A1
XOR A AF
Set Register A to 00H.
50A2
LD (50B9H),A 32 B9 50
Self-Modifying Code
Clear the width operand at 50B9H (the LD A,nn at 50B8H) once at least one character has been stored.
50A5
INC DE 13
Advance the destination pointer DE past the stored character.
50A6
LOOP BACK to 5080H for the next character.
50A8
INC B 04
Restore Register B to zero so the field-full state persists while scanning the remaining characters.
50A9
LOOP BACK to 5080H to continue past the overlong field to its delimiter.
50AB
LD C,A 4F
Save the delimiter character (Register A) into Register C.
50AC
CP 20H FE 20
Compare the delimiter against 20H (space). If equal the Z FLAG is set.
50AE
If the NZ FLAG is set (the delimiter is not a space), JUMP to 50B5H.
50B0
CP 23H FE 23
Overlapping Code
Entered here (delimiter was a space) this is CP 23H, priming the flags. The byte at 50B1H (23H) is also the target of the JR Z at 50B3H, where it is executed as INC HL to form a skip-spaces loop.
50B1
INC HL 23
Overlapping Code
Loop entry from 50B3H: INC HL advances past a space in the source.
50B2
CP (HL) BE
Compare Register A (still the space) against the next source character at (HL). The Z FLAG is set while spaces continue.
50B3
If the Z FLAG is set (another space follows), LOOP BACK to 50B1H, skipping consecutive spaces.
50B5
LD A,03H 3E 03
Load Register A with 03H, the field terminator to write into the destination.
50B7
LD (DE),A 12
Store the 03H terminator at the end of the copied field in (DE).
50B8
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the field-width remainder written at 50B9H by 507CH/50A2H. The operand shown as 00H is overwritten at run time; it is non-zero when no character was stored (an empty field).
50BA
OR A B7
OR Register A with itself so the Z FLAG reflects whether the field was empty (NZ when the caller must reject an empty field).
50BB
LD A,C 79
Restore the delimiter character from Register C into Register A for the caller.
50BC
RET C9
RETurn to the caller with the delimiter in Register A and the empty-field flag in the Z FLAG.

50BDH - Alphanumeric Classifier

Tests the character in Register A. Returns the CARRY FLAG clear when the character is a digit (0-9) or upper-case letter (A-Z), and set otherwise. Register A is preserved.

50BD
CP 30H FE 30
Compare Register A against 30H (ASCII 0). Sets the CARRY FLAG when the character is below 0.
50BF
RET C D8
If the CARRY FLAG is set (below 0, not alphanumeric), RETurn with carry set.
50C0
CP 3AH FE 3A
Compare Register A against 3AH (one past ASCII 9). Sets the CARRY FLAG for digits 0 through 9.
50C2
If the CARRY FLAG is set (a digit), JUMP to 50C9H to return the alphanumeric result.
50C4
CP 41H FE 41
Compare Register A against 41H (ASCII A). Sets the CARRY FLAG when the character is below A.
50C6
RET C D8
If the CARRY FLAG is set (between 9 and A, not alphanumeric), RETurn with carry set.
50C7
CP 5BH FE 5B
Compare Register A against 5BH (one past ASCII Z). Sets the CARRY FLAG for letters A through Z.
50C9
CCF 3F
Complement the CARRY FLAG so it ends clear for alphanumeric characters and set otherwise.
50CA
RET C9
RETurn to the caller with the classification in the CARRY FLAG.

50CBH - Command and Keyword Table Search

Searches an eight-byte-entry table at (BC) for the word at (DE). On a match returns the Z FLAG set with Register Pair DE holding the entry's two-byte dispatch/handler word; on no match returns Register A = 01H (NZ). Used for the command table (4E82H), the connector-keyword table (5010H) and parameter keywords (5132H).

50CB
PUSH HL E5
Save the caller's HL across the search.
50CC
LD H,B 60
Copy the table base (Register B) into H.
50CD
LD L,C 69
Copy the table base (Register C) into L; HL now points to the current table entry.
50CE
LD A,(DE) 1A
Fetch the first character of the search word at (DE) into Register A.
50CF
CP (HL) BE
Compare it against the entry's first character at (HL). If equal the Z FLAG is set.
50D0
If the Z FLAG is set (first characters match), JUMP to 50DFH to compare the rest of the name.
50D2
PUSH BC C5
Save the table base while advancing to the next entry.
50D3
LD BC,0008H 01 08 00
Load Register Pair BC with 8, the entry stride.
50D6
ADD HL,BC 09
Advance HL by 8 to the next table entry.
50D7
POP BC C1
Restore the table base into Register Pair BC.
50D8
LD A,(HL) 7E
Fetch the first character of the next entry into Register A.
50D9
OR A B7
OR Register A with itself; the Z FLAG is set at the table's 00H terminator.
50DA
If the NZ FLAG is set (more entries remain), LOOP BACK to 50CEH to compare the next entry.
50DC
POP HL E1
End of table: restore the caller's HL.
50DD
INC A 3C
INCrement Register A from 00H to 01H, setting the NZ FLAG to signal no match.
50DE
RET C9
RETurn to the caller with no match (NZ).
50DF
LD B,05H 06 05
Load Register B with 5, the count of remaining name characters to compare.
50E1
PUSH HL E5
Save the entry pointer (HL) for the handler-word fetch.
50E2
PUSH DE D5
Save the search-word pointer (DE).
50E3
INC DE 13
Advance the search-word pointer DE to the next character.
50E4
INC HL 23
Advance the entry pointer HL to the next character.
50E5
LD A,(DE) 1A
Fetch the next search-word character at (DE) into Register A.
50E6
CP 03H FE 03
Compare Register A against 03H (end of the search word). If equal the Z FLAG is set.
50E8
If the Z FLAG is set (word ended), JUMP to 5104H to accept a shorter word against the entry's trailing spaces.
50EA
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If equal the Z FLAG is set.
50EC
If the Z FLAG is set (word ended at a carriage return), JUMP to 5104H.
50EE
CP (HL) BE
Compare the search-word character against the entry character at (HL). If equal the Z FLAG is set.
50EF
If the NZ FLAG is set (a character mismatch), JUMP to 50FFH to resolve or reject the entry.
50F1
DECrement Register B and LOOP BACK to 50E3H while name characters remain.
50F3
POP DE D1
Full match: discard the saved search-word pointer.
50F4
POP DE D1
Recover the entry pointer (saved at 50E1H) into Register Pair DE.
50F5
LD HL,0006H 21 06 00
Load Register Pair HL with 6, the offset to the entry's dispatch word.
50F8
ADD HL,DE 19
Add the entry base (DE) to form the address of the two dispatch bytes.
50F9
LD E,(HL) 5E
Load Register E with the low dispatch byte.
50FA
INC HL 23
Advance HL to the high dispatch byte.
50FB
LD D,(HL) 56
Load Register D with the high dispatch byte; Register Pair DE now holds the entry's dispatch/handler word.
50FC
POP HL E1
Restore the caller's HL.
50FD
XOR A AF
Set Register A to 00H, the match return code (Z FLAG set).
50FE
RET C9
RETurn to the caller with a match and the dispatch word in DE.
50FF
GOSUB to the alphanumeric classifier at 50BDH to test whether the mismatching search-word character is still a name character.
5102
If the NO CARRY FLAG is set (the word has more name characters, so it cannot match this shorter entry), JUMP to 5109H to advance to the next entry.
5104
LD A,(HL) 7E
Fetch the entry character at (HL) into Register A.
5105
CP 20H FE 20
Compare it against 20H (space). If equal the Z FLAG is set.
5107
If the Z FLAG is set (the entry is space-padded here, so the shorter word matches), JUMP to 50F3H to return a match.
5109
POP DE D1
No match on this entry: restore the search-word pointer (DE).
510A
POP HL E1
Restore the entry pointer (HL).
510B
JUMP to 50D2H to advance to the next table entry and continue the search.

510EH - Parameter List Parser

Selector 60H service. Parses a parenthesised parameter list "(KEYWORD=value,...)" at (HL). Register Pair DE points to a parameter-keyword table whose entries carry the storage address for each value. Reads each keyword into the buffer at 4200H, looks it up, and stores the parsed value.

510D
INC HL 23
Advance the source pointer HL past a leading space (loop entry from 5114H).
510E
LD A,(HL) 7E
Fetch the current source character at (HL) into Register A.
510F
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If equal the Z FLAG is set.
5111
RET Z C8
If the Z FLAG is set (end of line), RETurn; there is no parameter list.
5112
CP 20H FE 20
Compare Register A against 20H (space). If equal the Z FLAG is set.
5114
If the Z FLAG is set (a leading space), LOOP BACK to 510DH to skip it.
5116
CP 28H FE 28
Compare Register A against 28H (ASCII (, the parameter-list opener). If equal the Z FLAG is set.
5118
If the NZ FLAG is set (no parameter list), JUMP to 5155H to return success.
511A
PUSH DE D5
Save the parameter-keyword table pointer (DE). Loop entry for each parameter (from 5149H).
511B
LD B,06H 06 06
Load Register B with 6, the maximum keyword length.
511D
LD DE,4200H 11 00 42
Point Register Pair DE to 4200H, the parameter work buffer that receives the keyword.
5120
INC HL 23
Advance the source pointer HL past the ( or the preceding delimiter.
5121
GOSUB to the field scanner at 507BH to copy the keyword from (HL) into the buffer at 4200H, returning the delimiter in Register A.
5124
DEC HL 2B
Step HL back one so the delimiter is re-read below.
5125
POP DE D1
Restore the parameter-keyword table pointer (DE).
5126
RET NZ C0
If the NZ FLAG is set (the keyword scan failed on an empty field), RETurn.
5127
CP 0DH FE 0D
Compare the delimiter in Register A against 0DH (carriage return). If equal the Z FLAG is set.
5129
If the NZ FLAG is set (more text follows), JUMP to 512CH.
512B
INC HL 23
Advance HL past the carriage return.
512C
PUSH DE D5
Save the parameter-keyword table pointer (DE) across the lookup.
512D
LD B,D 42
Copy the table pointer high byte into Register B.
512E
LD C,E 4B
Copy the table pointer low byte into Register C; Register Pair BC now addresses the keyword table.
512F
LD DE,4200H 11 00 42
Point Register Pair DE to the buffered keyword at 4200H for the search.
5132
GOSUB to the table search at 50CBH to find the keyword; on a match it returns Register Pair DE = the value's storage address.
5135
If the Z FLAG is set (the keyword is known), JUMP to 5139H to parse its value.
5137
POP DE D1
Unknown keyword: restore DE.
5138
RET C9
RETurn to the caller with the NZ FLAG set, flagging an unrecognised parameter.
5139
LD A,(HL) 7E
Fetch the character following the keyword at (HL) into Register A.
513A
CP 3DH FE 3D
Compare Register A against 3DH (ASCII =, the assignment operator). If equal the Z FLAG is set.
513C
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the default value for a keyword given without =.
513F
If the Z FLAG is set (an = follows), JUMP to 5157H to parse the assigned value.
5141
DEC BC 0B
DECrement Register Pair BC to 0FFFFH, the implied true value for a bare keyword.
5142
LD A,C 79
Load Register A with the low byte of the value in Register C.
5143
LD (DE),A 12
Store the value low byte at the keyword's storage address (DE).
5144
INC DE 13
Advance the storage pointer DE.
5145
LD A,B 78
Load Register A with the high byte of the value in Register B.
5146
LD (DE),A 12
Store the value high byte, completing the two-byte value.
5147
POP DE D1
Restore the parameter-keyword table pointer (DE).
5148
LD A,(HL) 7E
Fetch the delimiter after the value at (HL) into Register A.
5149
CP 2CH FE 2C
Compare Register A against 2CH (ASCII ,, the parameter separator). If equal the Z FLAG is set.
514B
If the Z FLAG is set (another parameter follows), LOOP BACK to 511AH.
514D
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If equal the Z FLAG is set.
514F
If the Z FLAG is set (end of line), JUMP to 5155H to return success.
5151
CP 29H FE 29
Compare Register A against 29H (ASCII ), the parameter-list closer). If equal the Z FLAG is set.
5153
RET NZ C0
If the NZ FLAG is set (neither ) nor a separator, a syntax error), RETurn.
5154
INC HL 23
Advance HL past the closing ).
5155
XOR A AF
Set Register A to 00H, the success return code (Z FLAG set).
5156
RET C9
RETurn to the caller with the parameter list processed.

5157H - Parameter Value Parser

Parses the value after an =: a quoted string, a decimal number, an X'..' hexadecimal number, or a Yes/No/False option. Returns the value in Register Pair BC for storage at 5142H.

5157
INC HL 23
Advance the source pointer HL past the =.
5158
LD A,(HL) 7E
Fetch the first value character at (HL) into Register A.
5159
CP 22H FE 22
Compare Register A against 22H (ASCII double quote). If equal the Z FLAG is set.
515B
If the Z FLAG is set (a quoted string), JUMP to 5179H.
515D
CP 41H FE 41
Compare Register A against 41H (ASCII A). Sets the CARRY FLAG for characters below A (the digits).
515F
If the CARRY FLAG is set (a decimal digit), JUMP to 5174H to parse a decimal number.
5161
RES 5,A CB AF
Reset bit 5 of Register A, forcing the letter to upper case.
5163
CP 58H FE 58
Compare Register A against 58H (ASCII X, the hexadecimal prefix). If equal the Z FLAG is set.
5165
If the Z FLAG is set (an X'..' hexadecimal constant), JUMP to 516CH.
5167
GOSUB to the option helper at 5188H to interpret a Yes/No/False keyword value.
516A
JUMP to 5170H to store the resulting value.
516C
INC HL 23
Advance HL past the X prefix.
516D
GOSUB to the hexadecimal parser at 51C0H to read the quoted hex value into Register Pair BC.
5170
If the Z FLAG is set (a valid value was parsed), JUMP to 5142H to store it.
5172
JUMP to 5137H to return an error for an invalid value.
5174
GOSUB to the decimal parser at 51ABH to read the decimal value into Register Pair BC.
5177
JUMP to 5142H to store the parsed decimal value.
5179
INC HL 23
Advance HL past the opening double quote.
517A
LD B,H 44
Copy HL into Register B (high byte); BC will point to the string body.
517B
LD C,L 4D
Copy HL into Register C (low byte); Register Pair BC now points to the start of the quoted string.
517C
LD A,(HL) 7E
Fetch the next string character at (HL) into Register A.
517D
CP 20H FE 20
Compare Register A against 20H (space). Sets the CARRY FLAG for control characters below a space.
517F
If the CARRY FLAG is set (an unterminated string hit a control character), JUMP to 5137H to return an error.
5181
INC HL 23
Advance HL to the next string character.
5182
CP 22H FE 22
Compare Register A against 22H (double quote). If equal the Z FLAG is set.
5184
If the NZ FLAG is set (not the closing quote), LOOP BACK to 517CH.
5186
JUMP to 5142H to store the string pointer (Register Pair BC) as the value.

5188H - Yes / No / False Option Helper

Interprets an option value beginning with a letter: Y or ON gives true (Register Pair BC = 0FFFFH via 519DH), N or OFF or F gives false (BC = 0). Skips to the next delimiter afterward.

5188
SUB 59H D6 59
Subtract 59H (ASCII Y) from Register A. The result is zero when the value is Y.
518A
If the Z FLAG is set (value Y), JUMP to 519DH to set the true value.
518C
ADD A,0BH C6 0B
Add 0BH to Register A; the result is zero when the original character was N (4EH).
518E
If the Z FLAG is set (value N), JUMP to 519EH leaving the false value (BC unchanged at 0).
5190
DEC A 3D
DECrement Register A; the result is zero when the original character was O (as in ON/OFF).
5191
RET NZ C0
If the NZ FLAG is set (not Y, N or O), RETurn with the error still indicated.
5192
INC HL 23
Advance HL to the second character of ON or OFF.
5193
LD A,(HL) 7E
Fetch that character into Register A.
5194
RES 5,A CB AF
Reset bit 5 of Register A, forcing it to upper case.
5196
CP 46H FE 46
Compare Register A against 46H (ASCII F, as in OFF). If equal the Z FLAG is set.
5198
If the Z FLAG is set (OFF), JUMP to 519EH leaving the false value.
519A
CP 4EH FE 4E
Compare Register A against 4EH (ASCII N, as in ON). If equal the Z FLAG is set.
519C
RET NZ C0
If the NZ FLAG is set (neither OFF nor ON), RETurn with the error indicated.
519D
DEC BC 0B
DECrement Register Pair BC from 0 to 0FFFFH, the true value.
519E
INC HL 23
Advance HL to the next character while skipping to the value delimiter.
519F
LD A,(HL) 7E
Fetch that character into Register A.
51A0
CP 29H FE 29
Compare Register A against 29H (ASCII )). If equal the Z FLAG is set.
51A2
RET Z C8
If the Z FLAG is set (parameter list closes), RETurn with the value in Register Pair BC.
51A3
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If equal the Z FLAG is set.
51A5
RET Z C8
If the Z FLAG is set (end of line), RETurn with the value.
51A6
CP 2CH FE 2C
Compare Register A against 2CH (ASCII ,). If equal the Z FLAG is set.
51A8
RET Z C8
If the Z FLAG is set (a separator), RETurn with the value.
51A9
LOOP BACK to 519EH to skip any remaining option characters.

51ABH - Decimal Value Parser

Reads a run of decimal digits at (HL) into Register Pair BC, accumulating value times ten plus each digit.

51AB
LD A,(HL) 7E
Fetch the next character at (HL) into Register A.
51AC
SUB 30H D6 30
Subtract 30H (ASCII 0) to convert an ASCII digit to its binary value 0 through 9.
51AE
CP 0AH FE 0A
Compare the result against 10. Sets the NO CARRY FLAG when the character was not a digit.
51B0
RET NC D0
If the NO CARRY FLAG is set (not a digit), RETurn with the accumulated value in Register Pair BC.
51B1
PUSH BC C5
Save the running value (BC) on the stack.
51B2
EX (SP),HL E3
Exchange HL with the top of stack, placing the running value into HL and saving the text pointer.
51B3
ADD HL,HL 29
Double the running value in HL (times two).
51B4
ADD HL,HL 29
Double it again (times four).
51B5
ADD HL,BC 09
Add the original value (times five in total).
51B6
ADD HL,HL 29
Double once more, giving the running value times ten.
51B7
LD B,00H 06 00
Clear Register B so Register Pair BC holds just the new digit.
51B9
LD C,A 4F
Load Register C with the digit value in Register A.
51BA
ADD HL,BC 09
Add the digit to the value-times-ten in HL.
51BB
EX (SP),HL E3
Exchange HL with the top of stack, restoring the text pointer to HL and stacking the new value.
51BC
POP BC C1
Pop the updated running value into Register Pair BC.
51BD
INC HL 23
Advance the text pointer HL to the next digit.
51BE
LOOP BACK to 51ABH for the next decimal digit.

51C0H - Hexadecimal Value Parser

Reads an X'..' hexadecimal constant at (HL) into Register Pair BC, accumulating value times sixteen plus each hex digit. Requires the value to be enclosed in single quotes.

51C0
LD A,(HL) 7E
Fetch the character at (HL) into Register A.
51C1
CP 27H FE 27
Compare Register A against 27H (ASCII single quote, the hex delimiter). If equal the Z FLAG is set.
51C3
RET NZ C0
If the NZ FLAG is set (no opening quote), RETurn with an error.
51C4
INC HL 23
Advance HL past the quote (loop entry from 51E8H).
51C5
LD A,(HL) 7E
Fetch the next hex character at (HL) into Register A.
51C6
SUB 30H D6 30
Subtract 30H (ASCII 0). Sets the CARRY FLAG for characters below 0.
51C8
If the CARRY FLAG is set (below 0, the closing quote or a delimiter), JUMP to 51D6H.
51CA
CP 0AH FE 0A
Compare the result against 10. Sets the CARRY FLAG for digits 0 through 9.
51CC
If the CARRY FLAG is set (a decimal digit), JUMP to 51DEH to accumulate it.
51CE
RES 5,A CB AF
Reset bit 5 of Register A, forcing a hex letter to upper case.
51D0
SUB 07H D6 07
Subtract a further 7 so letters A through F map onto values 10 through 15.
51D2
CP 10H FE 10
Compare against 16. Sets the CARRY FLAG for valid hex values 0 through 15.
51D4
If the CARRY FLAG is set (a valid hex letter), JUMP to 51DEH to accumulate it.
51D6
LD A,(HL) 7E
Not a hex digit: fetch the character at (HL) into Register A.
51D7
CP 27H FE 27
Compare Register A against 27H (closing single quote). If equal the Z FLAG is set.
51D9
INC HL 23
Advance HL past the character.
51DA
RET Z C8
If the Z FLAG is set (properly closed), RETurn with the value in Register Pair BC.
51DB
DEC HL 2B
Step HL back to the offending character.
51DC
XOR A AF
Set Register A to 00H, clearing the Z FLAG expectation to signal a malformed hex constant.
51DD
RET C9
RETurn to the caller with an unterminated hexadecimal error.
51DE
PUSH BC C5
Save the running value (BC) on the stack.
51DF
EX (SP),HL E3
Exchange HL with the top of stack, placing the running value into HL and saving the text pointer.
51E0
ADD HL,HL 29
Double the running value (times two).
51E1
ADD HL,HL 29
Double again (times four).
51E2
ADD HL,HL 29
Double again (times eight).
51E3
ADD HL,HL 29
Double again, giving the running value times sixteen.
51E4
LD B,H 44
Copy the shifted value high byte into Register B.
51E5
ADD A,L 85
Add the new hex digit (Register A) to the shifted value low byte (Register L).
51E6
LD C,A 4F
Store the combined low byte into Register C; Register Pair BC now holds value times sixteen plus digit.
51E7
POP HL E1
Restore the text pointer into HL.
51E8
LOOP BACK to 51C4H for the next hexadecimal digit.

51EAH - Default Extension and Prompt Strings

The literal strings used by the overlay: the default command extension and the interactive prompt.

51EA
DEFM 'CMD' 43 4D 44
The default command file extension, appended by the routine at 5048H when a bare command name is run as a program.
51ED
DEFB 0AH 0A
Line-feed byte that opens the prompt string displayed at 4E41H.
51EE
DEFM 'LDOS Ready' 4C 44 4F 53 20 52 65 61 64 79
The interactive command prompt text shown by @DSPLY.
51F8
DEFB 0DH 0D
Carriage-return byte terminating the LDOS Ready prompt string. This is the final byte of the overlay (END 4E00H).