4E00H — S1ENTY — Input Jump Vectors
Source label: S1ENTY — Entry point for SYS01/SYS. Register A holds the vector code (upper nibble) that determines which function to execute. The lower nibble is masked off, and the upper nibble is compared against VECT10 (90H) through VECT70 (F0H) to dispatch to the appropriate routine.
4E00S1ENTY
AND 0F0H
Mask off the lower nibble of Register A, keeping only the vector code (bits 7–4).
4E02
CP 90H
Test for VECT10 (90H) = normal entry to command interpreter.
4E04
If VECT10, jump to CMDRDY — normal DOS Ready entry point.
4E07
CP 0A0H
Test for VECT20 (A0H) = abort operation.
4E09
If VECT20, jump to CMDABT — display “Operation Aborted” and re-enter DOS.
4E0C
CP 0B0H
Test for VECT30 (B0H) = command to DOS, no return.
4E0E
If VECT30, jump to CMDLIN — execute a command line with return address pushed.
4E11
CP 0C0H
Test for VECT40 (C0H) = set up a filespec.
4E13
If VECT40, jump to FSPEC — parse a filespec from the command line.
4E16
CP 0D0H
Test for VECT50 (D0H) = add a default extension.
4E18
If VECT50, jump to FEXT — assign a default file extension.
4E1B
CP 0E0H
Test for VECT60 (E0H) = parse an options list.
4E1D
If VECT60, jump to PARAM — parse a parameter string.
4E20
CP 0F0H
Test for VECT70 (F0H) = command to DOS, return.
4E22
If VECT70, jump to CALCOM — execute a command and return to the caller.
4E25H — CMDABT — Abort the Current Command Chain
Source label: CMDABT — Reached via VECT20. Resets the stack, displays “Operation Aborted”, then falls through to CMDRDY.
4E25CMDABT
LD SP,409FH
Reset the stack pointer to
409FH (S3STCK — the DOS system stack).
4E28
Point HL to the ABTMSG string: “Operation Aborted”.
4E2B
Call the ROM PRINT routine to display the message (prints characters until a 0DH terminator is found).
4E2EH — CMDRDY — DOS Ready / Command Input Loop
Source label: CMDRDY — Main entry for the DOS Ready state. Enables interrupts, resets the stack, and falls through to CMDNXT which clears the command buffer and sets up the prompt.
4E2ECMDRDY
EI
Enable interrupts.
4E2F
LD SP,409FH
Reset the stack pointer to
409FH (S3STCK).
4E32H — CMDNXT — Clear Command Buffer and Prepare Prompt
Source label: CMDNXT — Clears the 64-byte command buffer at COMAND (4225H), resets the BREAK key vector to ABORT (4030H), and enables the BREAK key intercept.
4E32CMDNXT
Point HL to COMAND (4225H) — the 64-byte command line buffer.
4E35
Point DE to COMAND+1.
4E38
LD BC,003FH
Set BC = 63 for the LDIR clear loop (63 bytes after the first).
4E3B
LD (HL),00H
Store 00H into the first byte of the buffer.
4E3D
LDIR
Block-fill the remaining 63 bytes with 00H, clearing the entire command buffer.
4E3F
Point HL to ABORT (4030H) — the cassette BREAK handler entry point.
4E42
Store 4030H into READYY+1 (4204H) — resetting the BREAK key jump vector so that pressing BREAK returns to DOS Ready.
4E45
LD A,0C3H
Load A with 0C3H (the opcode for JP nn).
4E47
Store the JP opcode into BREAK (42AEH), enabling the BREAK key intercept. When BREAK is 0C3H (JP), the BREAK key is active; when 0C9H (RET), it is disabled.
4E4AH — CMDRD2 — Print DOS Ready Message
Source label: CMDRD2 — Displays the “TRSDOS Ready” prompt. If the cursor is already at column 0, the leading linefeed in the message is skipped. Then checks the CFLAG byte to determine if free memory should be cleared.
4E4ACMDRD2
Point HL to DOSMSG (509BH) — the “TRSDOS Ready” message (preceded by a linefeed byte 0AH).
4E4D
Fetch the low byte of CURSOR (4020H) — the current cursor screen position.
4E50
AND 3FH
Mask to the column position within the current 64-character line (bits 5–0).
4E52
If not at column 0, skip ahead to CMDR2X to print with the leading linefeed.
4E54
INC HL
Already at column 0, so skip past the leading linefeed byte in the message.
4E55H — CMDR2X — Print Message and Check CFLAG
Source label: CMDR2X — Prints the DOS Ready message, then checks if CFLAG (42B4H) is set to 55H, which signals that free memory should be cleared (e.g., after a protected program exits).
4E55CMDR2X
Call the ROM PRINT routine to display the “TRSDOS Ready” message.
4E58
Fetch CFLAG (42B4H) — the “clear RAM” flag.
4E5B
CP 55H
Test if CFLAG = 55H (the “clear memory” sentinel value).
4E5D
If not 55H, skip memory clearing and jump to CMD2R2 to display the command line dots.
4E5F
Fetch MEMEND (4411H) — the top of available memory.
4E62
LD DE,5200H
Load DE with SYSHI (5200H) — the start of free memory (immediately above SYS01/SYS).
4E65
OR A
Clear the carry flag for the SBC operation.
4E66
SBC HL,DE
HL = MEMEND − SYSHI = number of bytes of free memory to clear.
4E68
DEC HL
Subtract 1 (the LDIR loop needs count − 1 since the first byte is set manually).
4E69
4E6A
LD B,H
LD C,L
Copy the byte count from HL to BC for the LDIR.
Clear free memory from SYSHI (5200H) through MEMEND via LDIR.
4E6B
LD HL,5200H
Point HL to SYSHI (5200H) — start of area to clear.
4E6E
LD DE,5201H
Point DE to SYSHI+1.
4E71
LD (HL),00H
Store 00H into the first byte.
4E73
LDIR
Block-fill from SYSHI through MEMEND with 00H.
4E75H — CMD2R2 — Display Command Line and Accept Input
Source label: CMD2R2 — Displays a line of 62 periods representing the DOS command input area, then positions the cursor back to the start of the line.
4E75CMD2R2
LD B,3EH
Set loop counter B = 62 (the number of periods to display).
4E77CMDR22
LD A,2EH
Load A with 2EH (ASCII “.”).
4E79
Call the ROM character output routine (DSP) to print one period.
4E7C
Loop back to CMDR22 until all 62 periods are printed.
4E7E
LD A,1DH
Load A with 1DH (cursor control: move to beginning of line).
4E80
Output the cursor-home control character to reposition to the start of the line.
4E84
Clear SCRLCT (4214H) — reset the scroll protection line count.
4E87
Clear CFLAG (42B4H) — reset the “clear RAM” flag.
4E8A
Clear SCAFLG (42FFH) — clear the SCA (system command active) flag.
4E8D
DEC A
Decrement A to FFH.
4E8E
Store FFH into BASICG (427AH) — set the flag to indicate BASIC is not currently resident in memory.
Accept keyboard input into the command buffer.
4E91
Point HL to COMAND (4225H) — the command line buffer.
4E94
LD B,3FH
Set B = 63, the maximum number of characters to accept.
4E96
Call the ROM KEYN routine (0040H) to read a full line of keyboard input. On exit, B = number of characters entered, HL points past end of input, carry set if BREAK was pressed.
4E99
LD A,B
Copy the character count to A.
4E9A
OR A
Test if zero characters were entered (just ENTER pressed).
4E9B
If zero characters, loop back to CMDRD2 to redisplay the prompt.
Erase trailing periods after the typed command text.
4E9D
PUSH HL
Save the command line pointer.
4E9E
PUSH BC
Save the character count.
4E9F
Fetch CURSOR (4020H) — the current cursor position.
4EA2
PUSH HL
Save the original cursor position.
4EA3
LD C,B
Copy character count to C (B already = count).
4EA4
LD B,00H
Clear B so BC = character count.
4EA6
ADD HL,BC
HL = cursor position + character count = end of typed text.
4EA7
LD BC,0040H
BC = 64 (one full screen line width).
4EAA
OR A
Clear carry for SBC.
4EAB
SBC HL,BC
HL = (cursor + chars) − 64 = position of end of text on current line.
4EAD
Temporarily set CURSOR to this position.
4EB0
LD A,1EH
Load A with 1EH (cursor control: erase to end of line).
4EB2
Call DSP to erase the remaining periods after the typed command.
4EB5
POP HL
Restore the original cursor position.
4EB6
Restore CURSOR to its original position.
4EB9
POP BC
Restore the character count.
4EBA
POP HL
Restore the command line pointer.
4EBB
LD A,0C9H
Load A with 0C9H (the opcode for RET).
4EBD
Store RET into BREAK (42AEH) — re-enable the BREAK key intercept (0C9H = active; see CMDNXT at 4E45H for the inverse).
4EC0H — CMDLIN — Command to DOS, No Return
Source label: CMDLIN — Reached via VECT30. Pushes the SYS1IN return address (402DH) onto the stack so that after the command finishes, control returns to the SYS0 warm-start entry. Then falls through to CALCOM.
4EC0CMDLIN
Load BC with SYS1IN (402DH) — the SYS0 warm-start re-entry point.
4EC3
PUSH BC
Push the return address onto the stack.
4EC4H — CALCOM — User Command Line Entry Point
Source label: CALCOM — Reached via VECT70 or by fall-through from CMDLIN. Parses the filespec from the command line, searches the internal library command table (LIBCOM), and if found, dispatches to it. If not found, appends “/CMD” and attempts to load and execute it as a program file.
4EC4CALCOM
Point DE to DCB (4465H) — the Device Control Block buffer for filespec storage.
4EC7
Call FSPEC to parse the filespec from the command line pointed to by HL.
4ECA
If error (NZ), jump to CMDERR to report a bad filename.
4ECC
PUSH HL
Save the command line pointer (past the parsed filespec).
4ECD
Point BC to LIBCOM (50C9H) — the library command name table.
4ED0
Call SEARCH to look up the parsed command name in the library table.
4ED3
If found (Z), jump to CMDXEQ to execute the library command.
Command not found in the library table — try to load it as a /CMD program file.
4ED5
Point HL to CMDEXT (5098H) — the default extension string “CMD”.
4ED8
Call FEXT to add the “/CMD” extension to the filespec if no extension was specified.
4EDB
POP HL
Restore the command line pointer.
4EDC
Jump to EXEC (4433H) in SYS0 — the program load-and-execute routine. Only HL survives.
4EDFH — CMDXEQ — Execute Library Command
Source label: CMDXEQ — A matching command was found in LIBCOM. DE holds the overlay load vector address. HL is restored to the command line (for parameter passing), DE is pushed as a return address, and RET dispatches to the command handler.
4EDFCMDXEQ
POP HL
Restore HL to point to the command line (past the command name).
4EE0
PUSH DE
Push the command handler address (from the LIBCOM table vector field) onto the stack.
4EE1
RET
RET pops the handler address and jumps to it, effectively dispatching to the overlay loader for that command.
4EE2H — CMDERR — Command Error — Bad Filename
Source label: CMDERR — Reports an EBFN (bad file name) error. Error code 13H = decimal 19, but in the Tandy source this is equated as EBFN (error code 10 = bad filename). The source uses 0-based error numbering while the error handler adds an offset.
4EE2CMDERR
LD A,13H
Load A with error code 13H (EBFN = bad file name).
4EE4
Jump to ERROR (4409H) in SYS0 to display the error message and return to DOS Ready.
4EE7H — FSPEC — Fetch a File Spec
Source label: FSPEC — Parses a complete filespec from the text string pointed to by HL into the buffer pointed to by DE. A filespec has the format: filename/ext.password:drive. On exit, Z is set if a valid filespec was obtained, A = terminating character, DE = filespec buffer, HL = terminating character position.
4EE7FSPEC
PUSH DE
Save the filespec destination pointer.
4EE8
LD B,08H
Set B = 8 for the maximum filename length.
4EEA
Call GETSYM to fetch up to 8 characters for the filename field.
4EED
If no symbol found (NZ), jump to FSPEC6 — restore DE and return with error.
4EEF
CP 2FH
Test if the terminating character is / (extension delimiter).
4EF1
If not /, skip extension parsing and jump to FSPEC2.
4EF3
LD (DE),A
Store the / delimiter into the filespec buffer.
4EF4
INC DE
Advance DE past the delimiter.
4EF5
LD B,03H
Set B = 3 for the maximum extension length.
4EF7
Call GETSYM to fetch up to 3 characters for the extension field.
4EFA
If error (NZ), jump to FSPEC6.
4EFCH — FSPEC2 — Check for Password
Source label: FSPEC2 — Tests if a password follows (delimited by .).
4EFCFSPEC2
CP 2EH
Test if the terminating character is . (password delimiter).
4EFE
If not ., skip password parsing and jump to FSPEC3.
4F00
LD (DE),A
Store the . delimiter into the filespec buffer.
4F01
INC DE
Advance DE past the delimiter.
4F02
LD B,08H
Set B = 8 for the maximum password length.
4F04
Call GETSYM to fetch up to 8 characters for the password field.
4F07
If error (NZ), jump to FSPEC6.
4F09H — FSPEC3 — Check for Drive Number
Source label: FSPEC3 — Tests if a drive number follows (delimited by :).
4F09FSPEC3
CP 3AH
Test if the terminating character is : (drive number delimiter).
4F0B
If not :, skip drive number and jump to FSPEC4.
4F0D
LD (DE),A
Store the : delimiter into the filespec buffer.
4F0E
INC DE
Advance DE past the delimiter.
4F0F
LD B,01H
Set B = 1 for a single drive-number digit.
4F11
Call GETSYM to fetch 1 character for the drive number.
4F14
If error (NZ), jump to FSPEC6.
4F16H — FSPEC4 — Terminate Filespec and Check for Prepositions
Source label: FSPEC4 — Stores a 03H terminator at the end of the filespec, then searches the PREPTB table for the preposition “TO”. If found, FSPEC is called recursively to parse a second filespec (for commands like COPY file1 TO file2).
4F16FSPEC4
LD C,A
Save the terminator character in C.
4F17
LD A,03H
Load A with 03H — the end-of-filespec delimiter.
4F19
LD (DE),A
Store the 03H terminator into the filespec buffer.
4F1A
XOR A
Clear A and set the Z flag to indicate success.
4F1B
LD A,C
Restore the terminator character to A.
4F1C
POP DE
Restore DE to point to the start of the filespec buffer.
4F1D
PUSH DE
Re-save the filespec buffer pointer (for possible recursive call).
4F1E
Point BC to PREPTB (4F2BH) — the preposition table containing “TO”.
4F21
Call SEARCH to look for the word “TO” in the command line.
4F24
POP DE
Restore DE to the filespec buffer pointer.
4F25
If “TO” was found (Z), loop back to FSPEC to parse the second filespec.
4F27
XOR A
Set Z flag for a successful return (no “TO” found, single filespec).
4F28
RET
Return to the caller.
4F29H — FSPEC6 — Filespec Error Exit
Source label: FSPEC6 — Error exit for FSPEC. Restores DE from the stack and returns with NZ flag set (error condition).
4F29FSPEC6
POP DE
Restore the original filespec buffer pointer.
4F2A
RET
Return with NZ set (error).
4F2BH — PREPTB — Preposition Table
Source label: PREPTB — A SEARCH-format table containing the single entry “TO” (padded to 6 characters with spaces), followed by a 2-byte vector (0000H = no execute) and a 00H end-of-table marker.
4F2BPREPTB
DEFM
"TO " (6 bytes, space-padded)
4F31
DEFW 0000H
No execution vector (preposition only, not a command).
4F33
DEFB 00H
End-of-table marker.
4F34H — FEXT — Set Up a Default File Extension
Source label: FEXT — Adds a default extension to a filespec if one was not already supplied. On entry, DE points to the filespec buffer and HL points to the 3-byte default extension string. Scans the filespec for up to 9 characters looking for a / (extension already present) or a non-alphanumeric character (end of name). If no extension is present, shifts the trailing portion of the filespec right by 4 bytes to make room, then inserts / + the 3-byte extension.
4F34FEXT
PUSH DE
Save the filespec buffer pointer.
4F35
PUSH HL
Save the default extension pointer.
4F36
EX DE,HL
Swap so HL = filespec, DE = extension.
4F37
INC HL
Skip over the device declaration byte in the filespec.
4F38
LD B,09H
Set B = 9 as the maximum number of characters to scan.
4F3AH — FEXT1 — Extension Scan Loop
Source label: FEXT1 — Scans through the filespec looking for the / extension delimiter or the end of the filename.
4F3AFEXT1
LD A,(HL)
Fetch the next character from the filespec.
4F3B
CP 2FH
Test for / (extension delimiter).
4F3D
If / found, an extension already exists — jump to FEXT4 to return without modification.
4F3F
If A < / (non-alphanumeric), jump to FEXT5 to insert the default extension.
4F41
CP 3AH
Test for : (1 above 9).
4F43
If A < : (i.e., it is a digit 0–9), the character is valid — continue scanning.
4F47
If A < A (i.e., it is : through @), it is a special character — jump to FEXT5.
4F49
INC HL
Advance HL to the next filespec character.
4F4A
Loop back to FEXT1 until B reaches zero (max 9 characters scanned).
4F4CH — FEXT4 — Extension Already Present
Source label: FEXT4 — The filespec already has an extension. Simply restore registers and return.
4F4CFEXT4
POP HL
Restore the default extension pointer (discard it).
4F4D
POP DE
Restore the filespec buffer pointer.
4F4E
RET
Return to the caller.
4F4FH — FEXT5 — Insert Default Extension
Source label: FEXT5 — No extension was found in the filespec. Shifts the trailing portion of the filespec right by 4 bytes (to make room for “/ext”), then copies the 3-byte default extension and the / delimiter into the gap.
4F4FFEXT5
LD BC,000FH
BC = 15 (offset to the max end of the spec area).
4F52
ADD HL,BC
HL = current position + 15 = max end of spec.
4F54
LD E,L
DE = HL (copy the max-end position).
4F58
INC DE
DE = max end + 4 (destination for the rightward shift).
4F59
INC BC
BC = 16 (byte count for the LDDR move).
4F5A
LDDR
Block-move 16 bytes rightward by 4 positions, making room for the “/ext” insertion.
4F5C
POP HL
Restore HL = pointer to the default extension string.
4F5D
4F5E
INC HL
INC HL
Advance HL to the end of the 3-byte default extension (for the LDDR source).
4F5F
LD C,03H
Set C = 3 for a 3-byte LDDR move (B is already 0 from the first LDDR).
4F61
LDDR
Copy the 3-byte default extension into the gap in the filespec.
4F63
LD A,2FH
Load A with /.
4F65
LD (DE),A
Store the / delimiter immediately before the extension.
4F66
POP DE
Restore the filespec buffer pointer.
4F67
RET
Return to the caller.
4F68H — GETSYM — Get a Symbol from a Text String
Source label: GETSYM (GLOBALly exported) — Fetches up to B alphanumeric characters from the text string at (HL) into the buffer at (DE). Characters beyond B are consumed but not stored. On exit: Z if a symbol was found, NZ if no symbol found; DE points past end of stored symbol +1; HL points past end of consumed text +1; A = terminating character.
4F68GETSYM
LD A,B
Copy the maximum symbol length to A.
4F69
Store the symbol length into the self-modifying operand at GETLTH (4F8EH+1). This byte doubles as the “no symbol found” flag: if it is still non-zero at exit, no valid character was stored.
4F6C
INC B
Increment B to account for the pre-decrement in the loop.
4F6DH — GETSY2 — Symbol Fetch Loop
Source label: GETSY2 — Main character-fetching loop. Reads characters from (HL), validates them with LEGAL, and stores valid ones into (DE).
4F6DGETSY2
LD A,(HL)
Fetch the next character from the input text.
4F6E
CP 03H
Test for 03H — end-of-filespec delimiter.
4F70
If end-of-filespec, jump to GETSY5 to exit.
4F72
CP 0DH
Test for 0DH — carriage return (end of line).
4F74
If carriage return, jump to GETSY5 to exit.
4F76
INC HL
Advance HL to the next input character.
4F77
Call LEGAL to test if the character is alphanumeric (A–Z or 0–9). Returns carry set if illegal.
4F7A
If illegal character (carry set), jump to GETSY5 to exit.
4F7CH — GETSY3 — Store Valid Character
Source label: GETSY3 — A valid character was found. Decrements B and stores the character if within the maximum length.
4F7CGETSY3
DEC B
Decrement the residual character count.
4F7D
If B = 0, maximum length reached — jump to GETSY4 to skip storage but continue consuming.
4F7F
LD (DE),A
Store the valid character into the symbol buffer.
4F81
Clear the GETLTH flag byte (at 4F8EH+1) to indicate that at least one character was successfully stored.
4F84
INC DE
Advance DE to the next position in the symbol buffer.
4F85
Loop back to GETSY2 to fetch the next character.
4F87H — GETSY4 — Maximum Length Reached
Source label: GETSY4 — The maximum symbol length has been reached. Resets B to 1 (so the next DEC B will reach zero again) and continues consuming characters without storing them.
4F87GETSY4
INC B
Reset B to 1 so the loop continues consuming but not storing.
4F8AH — GETSY5 — Symbol Termination and Exit
Source label: GETSY5 — Exit point for GETSYM. Stores a 03H terminator at (DE), then uses the self-modifying byte at GETLTH (4F8EH) to determine the return status: if the byte is still non-zero, no valid symbol was found (NZ return); if zero, a valid symbol was stored (Z return).
4F8AGETSY5
LD C,A
Save the terminating character in C.
4F8B
LD A,03H
Load A with 03H — the end-of-symbol terminator.
4F8D
LD (DE),A
Store the 03H terminator at the current position in the symbol buffer.
4F8E
GETLTH
LD A,00H
GETLTH (self-modifying code): The operand byte at 4F8FH is patched by instructions at 4F69H and 4F81H. If no character was stored, this byte remains as the original symbol length (non-zero); if at least one character was stored, it was cleared to 00H.
4F90
OR A
Set flags based on the GETLTH value: Z if symbol found (byte was cleared to 0), NZ if no symbol found.
4F91
LD A,C
Restore A = the terminating character.
4F92
RET
Return to the caller. Z = symbol found, NZ = no symbol found.
4F93H — SEARCH — Search a Table for Specified Symbol
Source label: SEARCH (GLOBALly exported) — Searches a command/symbol table for a match against the symbol at (DE). Each table entry is 8 bytes: 6 bytes of name (space-padded) + 2 bytes of vector address. The table is terminated by a 00H byte. On exit: Z if found, C = entry number (1-based), DE = vector address from the matched entry.
4F93SEARCH
PUSH HL
Save HL.
4F94
4F95
LD H,B
LD L,C
Copy the table pointer from BC to HL.
4F96
LD C,01H
Initialize the entry counter C = 1 (first entry).
4F98H — SEAR1 — Compare First Character
Source label: SEAR1 — Compares the first character of the search symbol against the first character of the current table entry.
4F98SEAR1
LD A,(DE)
Fetch the first character of the search symbol.
4F99
CP (HL)
Compare against the first character of the current table entry.
4F9A
If match, jump to SEAR3 to compare the remaining characters.
4F9CH — SEAR2 — Skip to Next Table Entry
Source label: SEAR2 — First character did not match. Skips 8 bytes to the next table entry and checks if the end of table has been reached.
4F9CSEAR2
PUSH BC
Save BC (entry counter).
4F9D
LD BC,0008H
BC = 8 (size of one table entry).
4FA0
ADD HL,BC
Advance HL to the next table entry.
4FA2
INC C
Increment the entry counter.
4FA3
LD A,(HL)
Fetch the first byte of the next entry.
4FA4
OR A
Test if it is 00H (end-of-table marker).
4FA5
If not end-of-table, loop back to SEAR1 to check this entry.
4FA7
POP HL
End of table reached. Restore HL.
4FA8
OR 01H
Force A to non-zero to set NZ (not found).
4FAA
RET
Return with NZ flag set (symbol not found in table).
4FABH — SEAR3 — Full Name Comparison
Source label: SEAR3 — First character matched. Now compares up to 5 more characters (total 6-character name field). Saves the table pointer for possible backtracking.
4FABSEAR3
LD B,05H
Set B = 5 for the remaining characters to compare.
4FAD
PUSH HL
Save the current table entry pointer.
4FAE
PUSH DE
Save the symbol pointer.
4FABH — SEAR3 — Full Name Comparison
Source label: SEAR4
Source label: SEAR4 — Character-by-character comparison loop.
mdash; Character-by-character comparison loop. DJNZ loops back here (to 4FAFH, after the initial PUSH DE).
4FAFSEAR4
INC DE
Advance the symbol pointer.
4FB0
INC HL
Advance the table entry pointer.
4FB1
LD A,(DE)
Fetch the next symbol character.
4FB2
CP 03H
Test for 03H — end-of-symbol.
4FB4
If end-of-symbol, jump to SEAR7 to check if the remaining table characters are spaces (partial match).
4FB6
CP 0DH
Test for 0DH — carriage return.
4FB8
If carriage return, jump to SEAR7.
4FBA
CP (HL)
Compare the symbol character against the table entry character.
4FBB
If mismatch, jump to SEAR6 to test for a partial match (short symbol vs. space-padded entry).
4FBD
Loop back to SEAR4 until all 5 remaining characters are compared.
4FBFH — SEAR5 — Match Found — Pick Up Vector
Source label: SEAR5 — All characters matched (or the symbol ended before the table entry and the remainder of the entry is spaces). Extracts the 2-byte vector address from bytes 6–7 of the table entry. Note: due to the comparison loop, this label is reached by fall-through from the DJNZ, or jumped to from SEAR7 when the remaining table characters are all spaces.
4FBFSEAR5
POP DE
Restore DE = symbol pointer.
4FC0
LD A,C
Copy the entry number to A for later retrieval.
4FC1
POP BC
Pop the saved table entry base pointer into BC.
4FC2
LD HL,0006H
HL = 6 (offset to the vector field within the 8-byte entry).
4FC5
ADD HL,BC
HL = table entry base + 6 = address of the 2-byte vector.
4FC6
LD C,A
Restore C = entry number.
4FC9
LD D,(HL)
DE = the 2-byte vector address from the table entry.
4FCA
POP HL
Restore the original HL.
4FCB
XOR A
Set Z flag for a successful match.
4FCC
RET
Return with Z set, C = entry number, DE = vector.
4FCDH — Mismatch Handling
Source labels: SEAR6, SEAR7, SEAR8 — Handle the case where characters do not match. SEAR6 checks if the mismatching character in the symbol is non-alphanumeric (which would mean the symbol ended early). SEAR7 checks if the remaining table entry characters are spaces (which would still be a valid match for a shorter symbol). SEAR8 restores pointers and continues searching the next table entry.
4FCDSEAR6
SEAR6: Call LEGAL to test if the mismatching character is alphanumeric.
4FD0
If it is a legal character (no carry), this is a genuine mismatch — jump to SEAR8.
4FD2SEAR7
LD A,(HL)
SEAR7: Fetch the current table entry character.
4FD3
CP 20H
Test if it is a space.
4FD5
If space, the table entry name has ended (padded) — treat as a match and jump to SEAR5.
4FD7SEAR8
POP DE
SEAR8: Restore DE = symbol pointer.
4FD8
POP HL
Restore HL = table entry pointer.
4FD9
Jump to SEAR2 to skip to the next table entry and continue searching.
4FDBH — PARAM — Process a Parameter String
Source label: PARAM (GLOBALly exported) — Parses an options string from the text at (HL). Options are enclosed in parentheses and comma-separated, e.g., (PARM1=value,PARM2=ON). On entry, DE points to the parameter definition table. On exit: NZ if error, HL points past the options string.
4FDBPARAM
LD A,(HL)
Fetch the next character from the input text.
4FDC
CP 0DH
Test for carriage return (end of line).
4FDE
RET Z
If end of line, return (Z set = no error, no parameters).
4FDF
CP 28H
Test for ( (start of parameter string).
4FE1
If (, jump to PARAM2 to start parsing parameters.
4FE3
CP 20H
Test for space.
4FE5
If space, jump to PARAM1 to skip it.
4FE7
OR A
Set flags and return. NZ = non-space, non-paren, non-CR character found.
4FE8
RET
Return (A = the non-parameter character).
4FE9H — PARAM1 — Skip Spaces
Source label: PARAM1 — Skips over spaces in the input text.
4FE9PARAM1
INC HL
Advance past the space character.
4FEA
Loop back to PARAM to test the next character.
4FECH — PARAM2 — Parse Individual Parameter
Source label: PARAM2 — Parses one parameter name from the options string. Uses GETSYM to fetch up to 6 characters into the FIELD buffer, then SEARCH to look it up in the parameter table pointed to by DE.
4FECPARAM2
PUSH DE
Save the parameter table pointer.
4FED
LD B,06H
Set B = 6 for the maximum parameter name length.
4FEF
Point DE to FIELD (5090H) — the 8-byte temporary symbol buffer.
4FF2
INC HL
Advance HL past the ( or , delimiter.
4FF3
Call GETSYM to fetch the parameter name.
4FF6
DEC HL
Back up HL by 1 (GETSYM advanced past the terminator).
4FF7
POP DE
Restore the parameter table pointer.
4FF8
RET NZ
If GETSYM returned NZ (no symbol found), return with error.
4FF9
PUSH DE
Re-save the parameter table pointer.
4FFA
4FFB
LD B,D
LD C,E
Copy the table pointer from DE to BC (SEARCH expects table in BC).
4FFC
Point DE to FIELD — the symbol just fetched by GETSYM.
4FFF
Call SEARCH to look up the parameter name in the table.
5002
If found (Z), jump to PARAM3.
5004H — PARERR — Parameter Error
Source label: PARERR — Parameter not found in the table. Restores DE and returns with NZ (error).
5004PARERR
POP DE
Restore DE = parameter table pointer.
5005
RET
Return with NZ set (error).
5006H — PARAM3 — Parameter Found — Check for Value
Source label: PARAM3 — The parameter was found in the table. SEARCH returned DE = the 2-byte vector (value storage address). Checks if the parameter has an = sign followed by a value or flag.
5006PARAM3
LD A,(HL)
Fetch the next character after the parameter name.
5009
If =, jump to PARAM5 to parse the value.
500B
LD BC,0FFFFH
No =, assume “ON” / “YES” — set BC = −1 (FFFFH).
500EH — PARAM4 — Store Parameter Value
Source label: PARAM4 — Stores the 2-byte parameter value (in BC) into the address pointed to by DE, then checks for more parameters or end of the options string.
500EPARAM4
LD A,C
Get the low byte of the value.
500F
LD (DE),A
Store the low byte at (DE).
5011
LD A,B
Get the high byte of the value.
5012
LD (DE),A
Store the high byte at (DE+1).
5013
POP DE
Restore DE = parameter table pointer.
5014
LD A,(HL)
Fetch the next character.
5015
CP 2CH
Test for , (more parameters follow).
5017
If comma, loop back to PARAM2 to parse the next parameter.
5019
CP 0DH
Test for carriage return (end of line).
501B
If end of line, jump to PAROK.
501D
CP 03H
Test for 03H (end-of-filespec).
501F
If end-of-filespec, jump to PAROK.
5021
CP 29H
Test for ) (end of parameter string).
5023
RET NZ
If not ), return with NZ (error — unexpected character).
5024H — PAROK — Parameter String Complete
Source label: PAROK — Successfully completed parsing the parameter string.
5024PAROK
INC HL
Advance HL past the closing ) or terminator.
5025
XOR A
Set Z flag for successful return.
5026
RET
Return with Z set (no error).
5027H — PARAM5 — Process Equated Value or Flag
Source label: PARAM5 — An = was found after the parameter name. Determines whether the value is a numeric hex string or a flag keyword (ON/OFF).
5027PARAM5
INC HL
Advance past the =.
5028
LD A,(HL)
Fetch the first character of the value.
5029
CP 41H
Test if A ≥ A (alphabetic character).
502B
If A < A (i.e., it is a digit), jump to PARAM6 to parse a hex number.
502D
Call GETFLG to parse a flag condition (ON/OFF). Returns BC = −1 for ON, BC = 0 for OFF.
5030
If valid flag (Z), jump to PARAM4 to store it.
5032
Otherwise, jump to PARERR for error.
5034H — PARAM6 — Parse Hex Number
Source label: PARAM6 — Parses a hexadecimal number from the input text. Uses IX as a text pointer and HL as the running accumulator (shifted left 4 bits per digit).
5034PARAM6
PUSH DE
Save registers.
5038
POP IX
Transfer HL to IX (LD IX,HL via stack — PUSH HL / POP IX).
503A
LD HL,0000H
Clear the accumulator HL = 0.
503DH — ASCHE1 — Hex Digit Accumulation Loop
Source label: ASCHE1 — Main loop for accumulating hex digits into HL. Each iteration shifts HL left by 4 bits (multiply by 16) and adds the new digit.
503DASCHE1
LD A,(IX+0)
Fetch the next character from the text.
5040
Call LEGAL to test if the character is alphanumeric.
5043
If not alphanumeric (carry set), the number has ended — jump to ASCHE3.
5045
SUB 30H
Subtract ASCII 0 to convert to numeric value.
5047
CP 0AH
Test if the value is 10 or more (i.e., it is a letter A–F).
5049
If < 10 (a digit 0–9), skip the alpha adjustment and jump to ASCH11.
504B
SUB 07H
Subtract 7 more to convert letters A–F (41H–46H became 11H–16H after first SUB; now 0AH–0FH).
504DH — ASCH11 — Accumulate Digit
Source label: ASCH11 — Shifts the accumulator left 4 bits and adds the new hex digit.
504DASCH11
INC IX
Advance the text pointer.
5054
LD D,00H
DE = the hex digit value (0–15).
5056
ADD HL,DE
Add the new digit to the accumulator.
5057
Loop back to ASCHE1 for the next digit.
5059H — ASCHE3 — Hex Number Complete
Source label: ASCHE3 — The hex number is complete. Transfers the result from HL to BC, restores the text pointer from IX back to HL, and returns to PARAM4 to store the value.
5059-505AASCHE3
LD B,H
LD C,L
BC = the parsed hex value (from HL).
505D
POP HL
Transfer IX back to HL (LD HL,IX via stack).
505E
POP IX
Restore the original IX.
5061
Jump to PARAM4 to store the parsed hex value.
5063H — GETFLG — Get a Flag Condition
Source label: GETFLG — Parses a flag keyword (ON or OFF) from the text at (HL). Returns: Z set if valid, BC = −1 (FFFFH) for ON, BC = 0 for OFF.
5063GETFLG
LD BC,0000H
Initialize BC = 0 (assume OFF).
5066
LD A,(HL)
Fetch the first character.
5069
RET NZ
If not O, return with NZ (error — not ON or OFF).
506A
INC HL
Advance to the next character.
506B
LD A,(HL)
Fetch the second character.
506C
CP 46H
Test for F (OFF).
506E
If F, jump to GETFL3 — BC is already 0 (OFF).
5070
CP 4EH
Test for N (ON).
5072
RET NZ
If not N, return with NZ (error).
5073H — GETFL2 — Flag = ON
Source label: GETFL2 — Sets BC = −1 (FFFFH) for the ON condition.
5073GETFL2
LD BC,0FFFFH
BC = −1 (ON value).
5076H — GETFL3 — Consume Remaining Flag Characters
Source label: GETFL3 — Consumes remaining characters until ) or , is found, then returns with Z set.
5076GETFL3
INC HL
Advance to the next character.
5077
LD A,(HL)
Fetch the character.
5078
CP 29H
Test for ) (end of parameter string).
507A
RET Z
If ), return with Z set (valid).
507B
CP 2CH
Test for , (another parameter follows).
507D
RET Z
If ,, return with Z set (valid).
507E
Loop back to GETFL3 to consume the next character.
5080H — CHKFL2 — Check the Status of the Optional Flag
Source labels: CHKFL2, CHKFLG (both GLOBALly exported) — Scans past spaces in the input, then checks for a parenthesized flag option like (ON) or (OFF). CHKFL2 starts by advancing HL. CHKFLG starts at the current position. Returns NZ if ON, Z if OFF or no option found.
5080CHKFL2
INC HL
Advance past a space.
5081CHKFLG
LD A,(HL)
Fetch the next character.
5082
CP 20H
Test for space.
5084
If space, loop back to CHKFL2 to skip it.
5086
CP 28H
Test for ( (start of option).
5088
RET NZ
If not (, return with NZ (no option field present).
5089
INC HL
Advance past the (.
508A
Call GETFLG to parse the ON/OFF flag.
508D
LD A,B
Copy the high byte of BC to A.
508E
OR A
Set flags: NZ if ON (B = FFH), Z if OFF (B = 00H).
508F
RET
Return with NZ = ON, Z = OFF.
5090H — FIELD — Data Storage Areas
Static data areas: the FIELD temporary buffer, the default command extension, and the DOS prompt and abort messages.
5090FIELD
DEFS 8
FIELD — 8-byte temporary symbol buffer used by PARAM for parameter name storage (4 DEFWs of 0).
5098CMDEXT
DEFM "CMD"
CMDEXT — Default file extension for commands: CMD.
509BDOSMSG
DEFB 0AH
DOSMSG — Begins with a linefeed (0AH), followed by the “TRSDOS Ready” prompt string terminated by 0DH.
509C
DEFM "TRSDOS Ready"
The DOS Ready prompt text (13 bytes including the 0DH terminator at 50A8H).
50A9ABTMSG
DEFM "Operation Aborted"
ABTMSG — The “Operation Aborted” message (18 bytes including the 0DH terminator at 50BAH).
50BBH — LEGAL — Check for Legal Character
Source label: LEGAL — Tests if the character in A is alphanumeric (0–9 or A–Z). Returns: NC (no carry) if legal, C (carry) if illegal.
50BBLEGAL
CP 30H
Test if A ≥ 0 (30H).
50BD
RET C
If A < 0, return with carry set (illegal character).
50BE
CP 3AH
Test if A ≥ : (3AH, one above 9).
50C0
CCF
Complement the carry flag. If A was 0–9, carry was clear (A < 3AH); CCF sets it. Wait — actually: if A < 3AH (a digit), CP sets carry; CCF clears it → return NC (legal). If A ≥ 3AH, CP clears carry; CCF sets it, but we fall through.
50C1
RET NC
If A was a digit (0–9), return with NC (legal character).
50C2
CP 41H
Test if A ≥ A (41H).
50C4
RET C
If A < A (i.e., : through @), return with carry set (illegal).
50C5
CP 5BH
Test if A ≥ [ (5BH, one above Z).
50C7
CCF
Complement carry. If A was A–Z (carry set from CP 5BH), CCF clears it → NC (legal). If A ≥ 5BH (carry clear), CCF sets it → C (illegal).
50C8
RET
Return with NC if A–Z (legal) or C if above Z (illegal).
50C9H — LIBCOM — Library Command Table
Source label: LIBCOM (GLOBALly exported) — The DOS library command table. Each entry is 8 bytes: 6 characters of command name (space-padded, with bit 7 set on the last non-space character or 6th character) + 2 bytes of execution vector address (the SYS overlay loader entry point). The table is terminated by a single 00H byte. The DCA macro in MACRO.LIB generates these entries.
50C9
DCA APPEND
APPEND → 42BAH (UTIL) — Append data to a file
50D1
DCA ATTRIB
ATTRIB → 42BAH (UTIL) — Set/display file attributes
50D9
DCA AUTO
AUTO → 42BAH (UTIL) — Set auto-execute command
50E1
DCA BACKUP
BACKUP → 42A2H (BACKUP) — Backup a diskette
50E9
DCA BUILD
BUILD → 42BAH (UTIL) — Create a text file line by line
50F1
DCA CLEAR
CLEAR → 42BAH (UTIL) — Clear memory
50F9
DCA CLOCK
CLOCK → 42BAH (UTIL) — Display/set the clock
5101
DCA CLS
CLS → 01C9H (ROM) — Clear the screen (jumps directly to ROM CLS at 01C9H)
5109
DCA COPY
COPY → 42A8H (SSYS9) — Copy a file
5111
DCA CREATE
CREATE → 42BAH (UTIL) — Create an empty file
5119
DCA DATE
DATE → 42BAH (UTIL) — Display/set the date
5121
DCA DEBUG
DEBUG → 440DH (DEBUG) — Enter the debugger
5129
DCA DIR
DIR → 42BAH (UTIL) — Display directory listing
5131
DCA DO
DO → 42BAH (UTIL) — Execute a DO file
5139
DCA DUAL
DUAL → 42A8H (SSYS9) — Set dual-drive mode
5141
DCA DUMP
DUMP → 42BAH (UTIL) — Display file contents in hex
5149
DCA ERROR
ERROR → 42BAH (UTIL) — Display error message for code
5151
DCA FORMS
FORMS → 42A8H (SSYS9) — Set printer forms parameters
5159
DCA FORMAT
FORMAT → 429FH (FORMAT) — Format a diskette
5161
DCA FREE
FREE → 42BAH (UTIL) — Display free space on disk
5169
DCA HELP
HELP → 42A5H (SSYS8) — Display help information
5171
DCA KILL
KILL → 42A8H (SSYS9) — Delete a file
5179
DCA LIB
LIB → 42BAH (UTIL) — Display library command list
5181
DCA LIST
LIST → 42ABH (SSYS11) — List file contents
5189
DCA LOAD
LOAD → 42BAH (UTIL) — Load a program file
5191
DCA MASTER
MASTER → 42A8H (SSYS9) — Set the master password
5199
DCA PATCH
PATCH → 42A8H (SSYS9) — Patch disk sectors
51A1
DCA PAUSE
PAUSE → 42BAH (UTIL) — Pause command processing
51A9
DCA PROT
PROT → 42BAH (UTIL) — Set file protection level
51B1
DCA PURGE
PURGE → 42ABH (SSYS11) — Delete multiple files
51B9
DCA RELO
RELO → 42A8H (SSYS9) — Relocate the system
51C1
DCA RENAME
RENAME → 42BAH (UTIL) — Rename a file
51C9
DCA ROUTE
ROUTE → 42A8H (SSYS9) — Route device I/O
51D1
DCA SETCOM
SETCOM → 42A8H (SSYS9) — Set RS-232 communications parameters
51D9
DCA TAPE
TAPE → 42ABH (SSYS11) — Cassette tape operations
51E1
DCA TIME
TIME → 42BAH (UTIL) — Display/set the time
51E9
DCA WP
WP → 42A8H (SSYS9) — Set write-protect status
51F1
DEFB 00H
End-of-table marker.