TRS-80 DOS - LDOS 5.3.1 for the Model I - SYS7/SYS Disassembled
Page Customization
Page Index
SYS7/SYS
Other Navigation
Summary:
LDOS 5.3.1 SYS7/SYS Disassembly - Library B Command Set (Model I)
SYS7/SYS holds the second half of the LDOS 5.3.1 command library. Like SYS6/SYS (Library A), it is not a single overlay but a partitioned file of independent command overlays, each assembled with .ORG 5200H. Every overlay loads at 5200H and runs one at a time. The resident RST 28H dispatcher at 4BCDH recognizes request code 89H as "Library B", and the resident overlay loader at 4BF5H brings the requested command overlay into 5200H (in register B) and enters it at its first byte. The command name a user types is mapped to a (library, command-number) pair by the resident command interpreter (SYS1) through its command-name table at 4EBDH; SYS7 itself never sees the typed name, only the loaded overlay and the command number.
SYS7/SYS contains 13 overlays that together serve 15 command codes. Two overlays each serve a related pair of commands: the DATE/TIME overlay and the DEBUG/VERIFY overlay each expose two entry points at the top of the overlay, one per command number. The file is framed as an LDOS load module: a type 05 header (module name "sys7 "), a type 1F comment ("(C) 1982-4,6,90 MISOSYS"), then fifteen 6-byte type 08 directory entries (one per command code, giving the command code and the file offset of its overlay), then the 13 overlays as runs of type 01 load records, and a closing type 02 transfer record. The entire memory image of all 13 overlays was rebuilt from the binary through these load records and compared byte-for-byte against the disassembly listing: 0 mismatches.
Every overlay follows the common LDOS command shape: it saves the caller's stack pointer with a self-modifying LD (nnnnH),SP at entry (patching the operand of the exit's LD SP,nnnn), skips leading blanks on the command line, parses its keyword parameters, performs its work through the resident SYS0 supervisor services, and exits by returning to the RST 28H dispatcher (or aborting to @ABORT at 4030H when it is invoked from something other than the LDOS command level). The resident system flag SFLAG$ at 430FH bit 5 ("not at LDOS command level") gates the commands that are only valid at command level.
Command / Overlay Directory (verified against the SYS7.SYS load module)
| Cmd Code | Load Range | Bytes | Command / Function |
|---|---|---|---|
| 11H | 5200-5351H | 338 | AUTO Set, display, or clear the diskette's auto-execute command line (stored in the GAT sector at offset E0H). Documented below. |
| 15H / 16H | 5200-548DH | 654 | DATE / TIME Display or set the system date (15H) and time/clock (16H); shares one overlay with two entry points (5200H JP for DATE, 5203H JP for TIME). Carries the 3-letter day and month name tables. |
| 13H | 5200-53D2H | 467 | CREATE Pre-allocate a file to a fixed size and set its record attributes (SIZE/HRS/HRREC/ARR/ARLRL/WRL/WRFILL/RF/RSHRINK); message "Creating: ". |
| 14H / 1BH | 5200-5349H | 330 | DEBUG / VERIFY Arm/disarm the DEBUG breakpoint re-entry (writes "JP 400FH" at 4315-4317, issues RST 28H code 8BH) and patch the @WRITE vector for write-verification; two entry points (5200H / 5203H). Command-code binding to be confirmed against the SYS1 4EBDH table. |
| 1CH | 5200-552FH | 816 | SYSGEN Build or delete the stored system configuration file CONFIG/SYS.CCC:0; messages "User configuration built/deleted", "*** CONFIGURING ***". |
| 22H | 5200-55A3H | 932 | FREE Display drive free-space and diskette information ("Drive :d packname packdate cyldh Free=sssss.s/sssss.s Fi=nnn/nnn"). |
| A1H | 5200-5EE6H | 3303 | SYSTEM System configuration command (SYSGEN/SYSRES/DRIVE/TYPE-ahead and more); "Can't SYSGEN with active SPOOLER!", "New SYSTEM drive installed", "Insert SYSTEM diskette in drive". Largest overlay in the file. |
| 33H | 5200-5402H | 515 | BUILD Build or append a keystroke/JCL file ("Building: ", "Appending: *KI to "), with HEX and APPEND options; "Odd # of hex digits!". |
| 51H | 5200-56D5H | 1238 | ATTRIB Set file/diskette attributes and passwords (PW/LOCK/UNLOCK/NAME/MPW); "New Master password ?", "Invalid master password!", "ATTRIB aborted!". |
| 71H | 5200-5405H | 518 | DUMP Dump memory to a file in CIM/TXT format with START/END/TRA/RELO/ASCII/ETX options; "Dumping: ", "START or END error!", "Start less than X'5500'!". |
| 72H | 5200-577CH | 1405 | PURGE Selectively delete files with INV/SYS/MPW/QUERY options and date filtering; "Purge file: ", "Purging: ", "Master password ?". |
| B1H | 5200-5525H | 806 | FORMS Set the Forms printer-filter parameters (LINES/PAGE/CHARS/INDENT/ADDLF/FFHARD/TAB/XLATE/MARGIN); "Forms Filter not Resident". |
| B2H | 5200-569CH | 1181 | SETCOM Set the RS-232 driver parameters (BAUD/WORD/STOP/PARITY/BREAK/DTR/RTS/DSR/CTS); "RS232/DVR not installed". |
AUTO (Command 11H) - Variables and Self-Modifying Cells
| Address Range | Purpose |
|---|---|
| 5220H 2 bytes | Saved stack pointer. Written by the entry LD (5220H),SP at 5200H and consumed both as the operand of LD SP,nnnn at 521FH and by LD SP,(5220H) at 525AH to restore the caller's stack. Self-Modifying Code. |
| 5268H 1 byte | Drive-valid flag. The operand of LD A,00H at 5267H, patched by the drive-check routine at 52A1H to 00H when the target drive is valid or FFH when it is not. Self-Modifying Code. |
| 52A2H 1 byte | Parsed drive number. The operand of LD C,00H at 52A1H, patched by the ":d" drive parser at 52B4H (default 0). Read back at 528DH to select which drive's GAT to write. Self-Modifying Code. |
| 42E0H 32 bytes | The auto-execute command field inside the shared directory/sector buffer SBUFF$ (4200H). LDOS stores the AUTO command string at offset E0H of the diskette's GAT sector; AUTO reads that sector into 4200H so 42E0H holds the current auto command, terminated by 0DH. |
AUTO (Command 11H) - Major Routines
| Address | Name / Purpose |
|---|---|
| 5200H | AUTO Entry Save SP, skip blanks, and branch on the first command-line character: "?" displays the current auto command, "=" re-executes the stored auto command, anything else stores a new auto command. |
| 52A1H | Validate Drive and Read GAT Load C with the parsed drive number, call @CKDRV (44B8H), record the valid/invalid result, and (when valid) read the GAT sector into 4200H via 52D0H. |
| 52B4H | Parse Optional Drive Spec If the next command-line character is ":", read the following digit as the drive number and store it in the 52A2H cell; validate it is 0-7. |
| 52D0H | Read GAT Sector Seek the directory cylinder (DIRCYL 4B65H) and read sector 0 (the GAT, which holds the auto command at offset E0H) into 4200H via RDSSEC (4B45H). Returns error code 14H on failure. |
| 52E3H | Write GAT Sector Write the 4200H buffer back to the directory cylinder's sector 0 with a deleted-data address mark (WRPROT 4768H) and verify it (VERSEC 4772H). Returns error code 15H on failure. |
Cross-Reference Notes
SYS7/SYS is loaded and dispatched by the resident RST 28H supervisor in SYS0/SYS (dispatcher 4BCDH, overlay loader 4BF5H) in response to request code 89H. The command name to command-number mapping is performed by the SYS1/SYS command interpreter through its command-name table at 4EBDH. The AUTO overlay calls the following resident SYS0 services: @LOGOT (447BH, display a carriage-return-terminated string), @CKDRV (44B8H, validate a drive number), @ERROR (4409H, report an error code), @ABORT (4030H, return to DOS), DIRCYL (4B65H, seek the directory cylinder), RDSSEC (4B45H, read a directory-track sector), WRPROT (4768H, write a directory sector with a deleted-data address mark), and VERSEC (4772H, verify a sector). The "=" path additionally jumps to the resident entry at 4451H to re-execute the stored auto command line.
Disassembly:
5200H - AUTO Command (RST 28H Code 89H, Command 11H)
Set, display, or re-execute the diskette's auto-execute command line. On entry from the resident overlay loader HL points to the command line just past the command name, and register B held the command number (11H) used by the loader to select this overlay. The auto command is stored in the diskette's GAT sector at offset E0H, which AUTO reads into the shared buffer at 42E0H.
Save the caller's stack pointer into 5220H, which is simultaneously the operand of the LD SP,nnnn instruction at 521FH and the source read by LD SP,(5220H) at 525AH. This lets AUTO restore the caller's stack on the way out.
Advance HL to the next command-line character. HL is the running command-line pointer.
Restore the caller's stack pointer. The operand at 5220H was overwritten at 5200H with the caller's SP, so this loads SP with the caller's stack pointer.
Restore the caller's stack pointer from 5220H, where it was saved at 5200H, before transferring to the resident command executor.
Load Register A with the drive-valid flag. The operand at 5268H was patched by 52A1H to 00H (drive valid) or FFH (drive invalid).
Fetch the next source character of the new command from the command line (addressed by HL) into Register A.
On straight fall-through from 527DH this loads IX with 52FBH and has no effect on the message (HL already points to "Command line too long!"). Entered at 5281H (skipping the DD prefix) the bytes 21 FB 52 decode instead as LD HL,52FBH, pointing HL at the message "Destination disk is write protected!". 5281H is the write-protect error entry reached from 526AH.
On fall-through this loads IX with 5337H with no effect. Entered at 5285H (skipping the DD prefix) the bytes 21 37 53 decode as LD HL,5337H, pointing HL at the message "No AUTO command installed!". 5285H is the empty-command entry reached from 524DH.
52A1H - Validate Drive and Read GAT Sector
Load Register C with the parsed drive number, validate it with the resident @CKDRV service, record whether the drive is usable in the self-modifying flag at 5268H, and (when the drive is valid) read the drive's GAT sector into the buffer at 4200H.
Load Register C with the drive number. The operand at 52A2H is patched by the drive parser at 52B4H, so C receives the parsed drive number (default 0).
Store the 00H/FFH drive-valid flag (Register A) into 5268H, the operand of the LD A,00H at 5267H, so the store path can later branch on drive validity.
52B4H - Parse Optional Drive Specifier
If the command line at HL continues with a ":d" drive specifier, read the drive digit, store it in the drive-number cell 52A2H, and validate the range 0-7. If there is no drive specifier the routine returns leaving the default in place.
Advance the command-line pointer HL past the drive digit (and past any trailing blanks on subsequent iterations).
Store the binary drive number (Register A) into 52A2H, the operand of the LD C,00H at 52A1H, so the drive-check routine uses this drive.
52D0H - Read GAT Sector
Seek the directory cylinder of the current drive and read its sector 0 (the Granule Allocation Table, which carries the auto command at offset E0H) into the shared buffer at 4200H. Returns error code 14H (GAT read error) on failure.
52E3H - Write GAT Sector
Write the updated buffer at 4200H (now holding the new auto command at 42E0H) back to sector 0 of the directory cylinder, using a deleted-data address mark as all directory sectors require, and verify the write. Returns error code 15H (GAT write error) on failure.
52FBH - AUTO Message Text
The three carriage-return-terminated message strings displayed by @LOGOT (447BH). These are data, not code; the disassembler renders the bytes as spurious instructions. The strings are reached through the overlapping LD IX / LD HL entry points at 5280H, 5284H, and the direct load at 527DH.