TRS-80 DOS - LDOS 5.3.1 for the Model I - Disassembled

Overview & History

Overview

LDOS 5.3.1 for the Model I is a Disk Operating System originally developed by Logical Systems, Inc. and, in this final release, maintained and published by MISOSYS, Inc. (1991). The system disk carries the banner "LDOS - THE LOGICAL DISK OPERATING SYSTEM - VER 5.3.1" and the header "Copyright 1991 MISOSYS, Inc., All rights reserved."

The operating system is built around a resident core, SYS0/SYS (SYSRES), which stays permanently in memory, plus a set of system overlays (SYS1/SYS through SYS12/SYS) that are loaded from the system drive on demand. Two additional system files, BOOT/SYS and DIR/SYS, are written to a diskette by the FORMAT utility and are never copied from one disk to another; DOS maintains them automatically. Because overlays are only pulled in when their functions are needed, unneeded overlays can be purged to free space on a working system diskette.

On the Model I, LDOS drives the WD1771 Floppy Disk Controller through memory-mapped I/O (command/status at 37ECH, track at 37EDH, sector at 37EEH, and data at 37EFH, with the drive-select and interrupt-status latches at 37E1H and 37E0H). System services and overlay loading are reached through a single Z80 instruction, RST 28H (see "How Service Calls Work" below).

One of LDOS's defining features is media and code interchangeability: a diskette created under LDOS on a Model I or Model III can be read or written on either machine, and assembly-language programs written to the LDOS SVC table are portable across LDOS installations regardless of the host computer. The bundled LBASIC language allows most standard Microsoft BASIC programs to run unmodified.

History

LDOS was created by Logical Systems, Inc. and first released in 1981 as LDOS 5.1 for the TRS-80 Model I and Model III. It was the product of a collaboration among three companies: MISOSYS (Roy Soltoff, of Alexandria, Virginia), Galactic Software Ltd. (Bill Schroeder, of Mequon, Wisconsin), and Lobo Drives (of Goleta, California) - and the "LDOS" name originally stood for "Lobo Drives Operating System." The development team credited in the original manual comprised Bill Schroeder (project leader), Roy Soltoff (systems analyst), Chuck Jensen, Doug Kennedy, Dick Konop, and Tim Mann.

LDOS set itself apart from Radio Shack's own Model I and III TRSDOS by providing full media interchangeability between the two machines, allowing programs to be written or patched to run on both, and by supporting hard drives. On the strength of that hard-drive support, Tandy licensed LDOS as its official hard-drive operating system and sold it through the Radio Shack catalog as RS26-2213, and Logical Systems was subsequently chosen to write TRSDOS 6 for the Model 4.

The 5.1 line was maintained by Logical Systems through updates 5.1.3 and 5.1.4 (1981-1983). Roy Soltoff's company, MISOSYS, later took over maintenance of the Model I/III product, releasing LDOS 5.3.0 in 1987 and LDOS 5.3.1 in 1991 - the final release of the line. The 5.3 series expanded the date range to accept dates from January 1, 1980 through December 31, 1999, added a modification time stamp to each directory entry, and brought the on-disk directory convention into line with LS-DOS 6.3. The disk disassembled on this page is that final LDOS 5.3.1 release.

Disassembly Highlights

This page serves as the index for the commented disassembly of the LDOS 5.3.1 system files. Over time, this section will be populated with summary highlights for each system file, overlay, utility, driver, and filter.

How Service Calls Work

In LDOS, the RST 28H (Restart 28 Hex) instruction is the central gateway to operating-system services and overlay management. It is a single-byte Z80 instruction that acts as a high-speed trap into the resident kernel (SYS0/SYS), letting programs invoke disk operations, file services, and system extensions without needing to know the physical addresses of those routines, which may shift between releases.

When an RST 28H is executed, the CPU vectors through ROM address 0028H into the resident DOS vector at 400CH, which jumps to the supervisor-call dispatcher at 4BCDH. The request being made is encoded in the A register:

  1. Request Code Evaluation: The value in the Accumulator (A register) is treated as a request code.
  2. Resident vs. Overlay Service: If the high bit of the code is set (code >= 80H), the dispatcher saves and disarms the DEBUG-trap flag (at 4315H) and calls the overlay loader (at 4BF5H). The loader finds the matching SYS overlay in the directory, reads it into the transient region at 4E00H, and patches the dispatcher's self-modified CALL with the overlay's entry point. The overlay runs and returns, after which the trap flag is restored.
  3. Resident Return Path: If the high bit is clear (code < 80H), the request is typically handled resident - most often a simple return (code 1) or an error path at 4BEF.
  4. Overlay Tracking: Location 430EH holds the number of the overlay currently resident in the transient area, so the loader can avoid reloading an overlay that is already present.

In addition to this internal supervisor mechanism, LDOS (DOS version 5) offers a user-loadable SVC table - a jump table placed in high memory by the SYSTEM (SVC) command - that gives assembly-language programs a stable, machine-independent set of entry points. The SVC table requires the KI/DVR keyboard driver to be active.

Resident SVC Vector Table

The resident core exposes a fixed vector table (addresses 4420H-4454H) that overlays and applications call for essential services. These vector addresses are stable across the Model I DOSes, which is what makes SVC-level program compatibility possible. The confirmed vectors on this LDOS 5.3.1 build are:

VectorAddressPurpose
@INIT4420HOpen or initialize a file/logical device (serviced by SYS2/SYS).
@OPEN4424HOpen an existing file.
@CLOSE4428HClose a file or logical device (serviced by SYS3/SYS).
@KILL442CHDelete a file and release its space (serviced by SYS10/SYS).
@LOAD4430HLoad a program load-module into memory.
@RUN4433HLoad and execute a program.
@READ4436HRead a logical record from an open file.
@WRITE4439HWrite a logical record to an open file.
@VER443CHWrite and verify a record.
@REW443FHRewind a file to its first record.
@POSN4442HPosition a file to a given record.
@BKSP4445HBackspace one record.
@PEOF4448HPosition to the end of file.
@DSPLY4467HDisplay a string to the video (*DO).
@PRINT446AHSend a string to the printer (*PR).
@DIV4451HArithmetic divide helper.

Known RST 28H Request Codes

Request codes with the high bit set select an overlay service; the codes decoded so far in the SYS0/SYS, SYS1/SYS, SYS2/SYS, SYS3/SYS, SYS4/SYS, SYS5/SYS and SYS6/SYS disassemblies are:

Code (A)Function
87H
@DEBUG
SYS5/SYS Loads and enters the DEBUG machine-language monitor. The resident @DEBUG launcher at 44B4H issues RST 28H code 87H; the overlay takes a full register snapshot, then runs its interactive command loop. Breakpoints re-enter DEBUG through the RST 30H hook at 400FH.
88HCommand library A dispatch - run a built-in DOS command; Register B holds the command code (issued by the SYS1 command interpreter; serviced by SYS6/SYS).
89HLibrary B command dispatch. Register B selects one of 13 SYS7/SYS command overlays (15 command codes), each loaded to 5200H by the resident overlay loader at 4BF5H. Commands: AUTO, DATE, TIME, CREATE, DEBUG, VERIFY, SYSGEN, FREE, SYSTEM, BUILD, ATTRIB, DUMP, PURGE, FORMS, SETCOM. See SYS7/SYS.
93HReturn to DOS (DOS Ready).
94H@OPEN - open or initialize a file or logical device; also performs the drive-availability check for @CKDRV (serviced by SYS2/SYS, which hashes the filename to a one-byte directory HIT code and the password to a 16-bit value).
95H@CLOSE - close a file or logical device; for a disk file this finalizes the directory entry (end-of-file, ending record number, and modification date/time stamp) and releases any pre-allocated but unused granules back to the free space (serviced by SYS3/SYS).
96H@ERROR - display a system error message; the message text is decompressed from a packed 56-word dictionary and may be followed by the offending device or file specification and the caller's return address (serviced by SYS4/SYS).
9AHAllocate a granule / extend a file.
9CH@KILL - delete a file.
9EHTimed-delay helper.
A3H@DIV - divide helper.
A5H@FNAME - build the printable file specification (NAME/EXT:d) for a directory record into a caller-supplied buffer (serviced by SYS3/SYS).
C3H@FSPEC - parse a file specification.

Additional codes (including B3H, AEH, D3H, E3H, 87H, C4H, and CDH) are implemented in the various SYS overlays and are decoded as each overlay is analyzed.

BOOT/SYS

Purpose:

The LDOS 5.3.1 bootstrap program written to a diskette by FORMAT and SYSGEN. The Model I boot ROM loads track 0, sector 0 of drive 0 to 4200H and jumps to it; that sector reads the resident system loader's directory record from the directory cylinder, streams the file as an LDOS load module, and transfers to its entry point. Disk access is direct to the memory-mapped WD1771 (Seek 1BH, Read Sector 88H, Force Interrupt 0D0H). The 1792-byte file also stores an alternate drive-geometry-aware boot sector, a Drive Code Table (DCT) initialization-template table, the day/month name tables, the "LDOS531 07/14/91" identification string, and a secondary loader.

Disassembly:

A disassembly of BOOT/SYS can be found here.

SYS0/SYS

Purpose:

SYS0/SYS is not an overlay - it is the resident part of the operating system (SYSRES). It remains permanently in memory and must be present on any disk used to boot the system, but may be removed from disks not used for booting.

From the disassembly, SYS0/SYS spans 3C00H through 50FFH and contains the sign-on text and block-graphics "LDOS" logo, the RST/DOS vectors at 400CH, the device control blocks for *KI/*DO/*PR and *JL/*SI/*SO, the clock and interrupt workspace and task-vector table, the SVC vector table (4420H-4454H), the low-level WD1771 disk I/O engine, the record-positioning and file-access routines, the directory read/write and granule-allocation code, the 16-bit multiply/divide primitives, the RST 28H supervisor dispatcher and overlay loader, and the boot-time initialization and date/time prompt code.

Role:

It provides the fundamental, non-changing operating-system services:

  • Low-level disk I/O (reading and writing raw sectors via the memory-mapped WD1771).
  • Basic file-system primitives (directory search, granule allocation, record positioning, open/read/write/close support).
  • Interrupt handling for the real-time clock and the task scheduler.
  • Fixed entry points for character output, file services, and program exit/error handling through the resident vector table.

Disassembly:

A detailed, commented disassembly of SYS0/SYS can be found here.

SYS1/SYS

Purpose:

SYS1/SYS contains the DOS command interpreter, together with the routines that service the @FEXT (default file-extension), @FSPEC (file-specification parsing), and @PARAM (parameter-list parsing) system vectors. It holds the built-in command-name table (APPEND through VERIFY) and routes each typed command either directly within the overlay or to the Library A/B command overlays through RST 28H request codes 88H and 89H. This overlay must be available on all SYSTEM disks.

Disassembly:

A disassembly of SYS1/SYS can be found here.

SYS2/SYS

Purpose:

SYS2/SYS opens and initializes disk files and logical devices. It also contains the routines that check the availability of a disk pack (servicing the @CKDRV vector) and the routines that hash file specifications and passwords. This overlay must reside on all SYSTEM disks; along with SYS3/SYS it must remain on any booting disk if a SYSGEN configuration file is to be loaded.

Disassembly:

A disassembly of SYS2/SYS can be found here.

SYS3/SYS

Purpose:

SYS3/SYS contains all of the system routines needed to close files and logical devices, plus the routines that service the @FNAME system vector. This overlay must not be eliminated, and together with SYS2/SYS must remain on any booting disk if a SYSGEN configuration file is to be loaded.

When a disk file is closed, SYS3/SYS finalizes its directory entry - flushing any buffered record, updating the end-of-file byte and ending record number, and, on drives whose dating is enabled, stamping the modification date and time - and then releases any pre-allocated but unused granules back to the Granule Allocation Table, unlinking and de-hashing any secondary (FXDE) directory record that becomes empty. Closing a logical device instead rebuilds its control block into a re-openable device specification. The @FNAME service (RST 28H code A5H) builds the printable NAME/EXT:d specification for a directory record into a caller-supplied buffer.

Disassembly:

A disassembly of SYS3/SYS can be found here.

SYS4/SYS

Purpose:

SYS4/SYS holds the system error dictionary - the text of messages such as "File not in directory" and "Directory read error." It is the overlay that services the @ERROR system call (RST 28H request code 96H): it turns a numeric error code into readable text, frames it as "*** Error code = NN, message ***", and displays it. If this overlay is purged, all system errors instead produce the terse message "SYS ERROR." Because it occupies only a single granule, it is recommended that it be kept.

To fit its 46 messages into one granule, SYS4/SYS does not store them as literal strings. It keeps a dictionary of 56 English words once, a compact per-error table that lists each message as a short sequence of word numbers, and a one-byte index that locates each message; every dictionary word is marked by setting the high bit on its final character. When an error is displayed, the routine can also append the identity of the offending object - either <Device=*XX> for a logical device or <File=NAME/EXT:D> for a disk file read from the directory - and a "Referenced at X'NNNN'" line giving the address from which the failing service was called. Option bits in the caller's accumulator choose how much of this framing is produced and whether control returns to the caller or aborts to DOS.

Disassembly:

A disassembly of SYS4/SYS can be found here.

SYS5/SYS

Purpose:

SYS5/SYS is the LDOS 5.3.1 DEBUG overlay for the Model I. It provides an interactive machine-language monitor: display and edit of the full Z80 register set (captured on entry into the resident DEBUG save area DBGSV$ at 405DH-407CH), hexadecimal and ASCII memory examination and patching, execution breakpoints planted as RST 30H (F7H) opcodes, and single-step or trace execution driven by a built-in instruction-length decoder.

DEBUG is loaded at 4E00H by the resident RST 28H overlay loader (request code 87H) and re-entered by the RST 30H breakpoint hook at 400FH. It performs no disk I/O of its own; it drives the screen and keyboard through the Model I ROM (0033H, 002BH, 0049H) and reuses the resident video DCB cursor field at 4020H. The command set is single-key: g (Go), r (register modify), m (memory modify), d (set memory window), ; and - (scroll), a and h (ASCII/hex display), s and x (screen layout), c (step over), i (step into), and u (live update).

Disassembly:

A disassembly of SYS5/SYS can be found here.

SYS6/SYS

Purpose:

SYS6/SYS contains the algorithms and routines that service the primary command library - the commands identified as "Library A" by the LIB command. Very limited use can be made of DOS if this overlay is removed from a working SYSTEM disk. It also contains the DO command; if SYS6/SYS is purged there is no purpose in keeping the JCL processor (SYS11/SYS).

Disassembly:

A disassembly of SYS6/SYS can be found here.

SYS7/SYS - Library B command set (ATTRIB, AUTO, CREATE, DATE, DUMP, PURGE, FORMS, SETCOM, SYSTEM, ...)

Purpose:

SYS7/SYS contains the routines that service the secondary command library - the commands identified as "Library B" by the LIB command. These are more specialized functions; a great deal of use can be made of DOS even without this overlay, so it may be purged with the PURGE command if its commands are not needed on a working SYSTEM diskette.

Disassembly:

A disassembly of SYS7/SYS can be found here.

SYS8/SYS

Purpose:

On DOS version 5 (LDOS for the Model I), SYS8/SYS is the routine that dynamically allocates file space as files are written. It must be present on any working SYSTEM diskette, and must be on the boot disk if a configuration file is to be loaded.

SYS9/SYS

Purpose:

SYS9/SYS contains the routines that service the extended debugging commands available after a DEBUG (EXT) is performed. It may be purged if the extended debugging commands are not needed; if SYS5/SYS has also been purged, keeping SYS9/SYS serves no purpose.

SYS10/SYS

Purpose:

SYS10/SYS contains the procedures that service the request to delete a file (the @KILL function). It should remain on working SYSTEM diskettes.

SYS11/SYS

Purpose:

SYS11/SYS contains the procedures that perform the Job Control Language (JCL) execution phase. It may be removed from working disks if no JCL functions will be invoked. Because the DO command that launches JCL resides in SYS6/SYS, keeping SYS11/SYS serves no purpose if SYS6/SYS has been purged.

SYS12/SYS

Purpose:

SYS12/SYS contains the routines that service the @DODIR and @RAMDIR directory vectors. These routines are used by the MiniDOS filter and may also be used by other application programs that provide a directory display. It can be removed if the two "mini" directory routines are not needed.

BACKUP/CMD

Purpose:

BACKUP/CMD duplicates data from one disk to another. It supports mirror-image and file-by-file (class) backups, with parameters to select, exclude, and filter the files that are copied.

DATECONV/CMD

Purpose:

DATECONV/CMD updates LDOS disks created under version 5.1.4 or earlier to the 5.3 style of dating. LDOS 5.3 expanded the date range to 1980-1999 and added a modification time stamp to each directory entry, bringing the on-disk convention into line with LS-DOS 6.3; DATECONV converts older disks so their date/time information is interpreted correctly.

FDUBL/CMD

Purpose:

FDUBL/CMD installs the double-density disk driver used with double-density hardware modifications on the Model I under DOS version 5. It patches the floppy driver so the Radio Shack interface (fitted with a supported double-density board) can read and write double-density diskettes.

FORMAT/CMD

Purpose:

FORMAT/CMD writes the track, sector, and directory information onto a diskette, organizing it into cylinders, tracks, and sectors so DOS can access it. This is the utility that creates the BOOT/SYS and DIR/SYS system files on a new disk.

PATCH/CMD

Purpose:

PATCH/CMD makes minor changes to existing disk files. It accepts patches in either a symbolic library-command format (Dnn,rr / X'nnnn) or a direct record-and-byte format, and is the standard mechanism for applying official fixes to the system and utility files.

SOLE/CMD

Purpose:

SOLE/CMD is a Model I utility that installs a double-density (DDEN) boot driver under DOS version 5, allowing the system to boot from a double-density system diskette on suitably equipped Model I hardware.

Disassembly:

A disassembly of SOLE/CMD can be found here.

TED/CMD

Purpose:

TED/CMD is a full-screen ASCII text editor supplied with LDOS. It can be attached to the system as an Immediate Execution Program so it can be invoked directly from the DOS Ready prompt.

Disassembly:

KI/DVR

Purpose:

KI/DVR is the DOS version 5 keyboard driver. It provides Type Ahead, Screen Print, key repeat, and special <clear>-key control functions, and establishes <shift><0> as a CAPS-lock key. It is a required foundation for many DOS features: SPOOL, the SYSTEM (SVC) table, KSM, MiniDOS, and LCOMM all depend on it. Using the driver with the TYPE option is strongly recommended.

PR/FLT

Purpose:

PR/FLT is the DOS version 5 printer filter. It lets the user format printed output - controlling page length, margins, line spacing, and character translation - by filtering data on its way to the *PR device.

BASIC/CMD

Purpose:

BASIC/CMD is LBASIC, the enhanced Disk BASIC interpreter supplied with LDOS. It extends standard Microsoft BASIC and allows most standard Microsoft BASIC programs to run unmodified. It uses the overlay files BASIC/OV1 through BASIC/OV4 for certain extended features.

BASIC/OV1

Purpose:

BASIC/OV1 is the DOS version 5 LBASIC overlay that provides the CMD"N" renumber feature.

BASIC/OV2

Purpose:

BASIC/OV2 is the DOS version 5 LBASIC overlay that provides the cross-reference CMD"X" feature.

BASIC/OV3

Purpose:

BASIC/OV3 contains the error-display and Sort routines for DOS version 5 LBASIC. It must be present whenever version 5 BASIC is in use.

BASIC/OV4

Purpose:

BASIC/OV4 is the DOS version 5 LBASIC overlay that dumps a list of the currently active variables.