TRS-80 DOS - TRSDOS v2.3 - Disassembled
Page Index
Introduction
General Overview
TRSDOS was the DOS which Tandy supplied when a Model I user bought a Drive 0 kit. While there are a few different DOS's available for the Model I, TRSDOS was the first and, as a result, the most simplistic. It required a minimum of 32K of RAM and at least one disk drive, although four disk drives were supported.
TRSDOS v2.3 is broken into two types of programs: The nucleus and overlays/user programs.
- The nucleus, SYS0/SYS, stays in memory. Its jump vectors and variables are loaded at 400CH-405CH and 4300H-44AFH and its code at 4398H-4CFFH; it keeps sector buffers at 4200H-42FFH and 4D00H-4DFFH. It contains the DOS entry points, the overlay loader, the file read, write and positioning routines, the disk driver, the TRACE and time displays, the interrupt handler with its timer tasks and the clock. Its start-up code at 4E00H-4F28H runs once and is then overwritten by the overlays. See the SYS0/SYS disassembly.
- The remainder of TRSDOS v2.3 is overlay modules and user programs which are loaded on demand. To make the most of the little RAM available, only the nucleus stays in memory. In general, overlays load from 4E00H-5200H and utility programs load from 5200H.
TRSDOS v2.3 services the clock interrupt from the moment it starts: the clock task in timer slot 7 keeps the time and date at 4041H-4046H. The library functions TRACE and CLOCK add display tasks to the same list (slots 11 and 6).
Technical Overview
TRSDOS is a single-user, disk-resident operating system. It is composed of a core-resident nucleus and disk-resident system overlays and utilities. The minimum configuration required for TRSDOS is 32K bytes of memory, and one disk drive which must be addressable as drive zero. In order to properly run, TRSDOS requires a system diskette to be mounted in drive zero at all times. TRSDOS supports any memory size from 32K to 48K bytes of memory and up to four, 35-track, single-sided, single-density, 5-1/4 floppy disk drives.
TRSDOS is loaded by a bootstrap program which is read from disk by LEVEL II. The portion of TRSDOS initially loaded is called the nucleus.
The nucleus is loaded in pieces between 400CH and 4CFFH: jump vectors, variables and the DOS entry point table at 400CH-405CH and 4300H-44AFH, code from 4398H to 4CFFH. Its system initialization code is loaded at 4E00H-4F28H and runs immediately after the system has been loaded.
The bulk of TRSDOS resides on the system disk. The disk resident portion consists of overlay modules and system utility programs.
Overlay modules are loaded on a demand basis by the nucleus. They contain code for system functions which need not be permanently core-resident. Exam pl es of these functions are: the command line processor; OPEN and CLOSE routines plus select system commands, such as DEBUG, TRACE and BASIC 2.
The overlay area begins at the end of the nucleus (4E00) and ends at the start of the utility load area (5200). Only one overlay is loaded at a time. Overlays could be constructed which call secondary overlays; however, this is not a standard practice in TRSDOS.
System utility programs such as BACKUP and FORMAT are loaded at address 5200. SYS6, which is technically an overlay module, is also loaded at 5200. It contains code for the DOS commands AUTO, KILL, DATE and TIME, to name a few. Utility programs may make nucleus calls which result in an overlay being loaded; thus, they must reside in separate areas of memory.
The system utility programs and overlays exist as files on the system diskette. Since they are assigned the invisible attributes, "SEE TRSDOS MANUAL," they are not displayed when the DIR command is used unless the 'I' (invisible) parameter is specified.
Overlay files have a SYS suffix, while utility program files have a CMD suffix. The exception is SYS6/SYS, which is loaded into the utility area.
SYS6 is also the only module in the system with multiple entry points. The editor/assembler and loader used by TRSDOS do not support relocatable code, multiple entry points or symbolic external references. SYS6 does not have multiple entry points in the traditional sense of the word, but it achieves the same effect by being called with a command index value, which specifies which of its nineteen commands is to be executed.
A command index is passed to SYS6 in the C register by the program that requested it to be loaded. In the usual case, the command line interpreter (SYS1/SYS) is the caller.
Utility programs fetch their parameters from the command line used to call the utility. Upon entry, the HL register points to the first character after the command specification in the command line buffer.
TRSDOS is not an interrupt driven system; however, it does support interrupts. A clock interrupt is generated every 25 milliseconds on systems with an expansion interface. This interrupt, plus any spurious interrupts, are fielded by a general purpose service routine in TRSDOS.
Upon detection of a clock interrupt, the clock interrupt processor is entered. This processor executes sub-tasks indicated by an interrupt task list of twelve entries. At start-up only the clock task is in it (slot 7). The CLOCK and TRACE commands use two more entries (slots 6 and 11).
The remainder of the entries in the list are unused. Subroutines in the nucleus are defined, which will add or delete entries to this list. This means some sort of scheduling or multi-tasking function could easily be added as an application program.
The nucleus contains other useful subroutines which can be called from users programs. The complete list of nucleus entry points is in the SYS0/SYS disassembly.
The major features of TRSDOS are its file management system, the disk space manager, the file loader, the overlay loader, interrupt service routines and the various command processors. Each of those features is discussed in detail in subsequent sections. The following descriptions of some of these features is very general and is intended to acquaint the reader with the external characteristics of these features.
Disk I/O Services
Disk services in TRSDOS support the file management system. They create and delete directory entries, allocate disk space, translate relative record numbers into absolute track and sector addresses, rewind files, position files to specified records, test for end of file conditions, and call the disk driver to perform data transfers. The disk management system does not support: file overflow from one device to another, any sector size other than 256 (dee.) bytes, or the ability to bypass irrecoverable errors.
Embedded in the disk services is an elementary record manager. It provides record movement between the user and system data areas, as well as packing and unpacking services. Two record types are supported. They are: fixed-length physical records (always one sector), and logical records. Logical records can vary in size from 1to255 bytes in length. All logical records in a file must be the same length except for DISK BASIC files. DISK BASIC supports variable length logical records because it has its own record management routines.
Disk space is allocated on an as-needed basis in units called granules where 1 granule equals 5 consecutive sectors. A permanent record of the assigned and available granules is maintained in a special sector of the disk directory. Each file entry in the directory has a list of assigned granules. When a file is purged (KILL'ed in TRSDOS nomenclature), the granules assigned to the file are returned to the list of available granules.
Directory Structure
The TRSDOS 2.3 directory is on track 17 (11H), unless the diskette's boot sector names another track in its byte 2. Sector 0 holds the granule allocation table (GAT), sector 1 the hash index table (HIT), and sectors 2-9 the directory entries, eight entries of 32 bytes in each sector. These sectors are written with the FAH data mark that SYS0/SYS uses for system sectors.
The Hash Index Table (HIT)
The HIT lets SYS2/SYS find a file without reading every directory sector. Every directory entry has a locator, a byte whose bits 5-7 give the entry's place in its sector and bits 0-4 the sector minus 2. The HIT byte at the offset of that locator is 00H when the entry is free, and otherwise the one-byte hash of the file name in it.
- Opening a file: SYS2/SYS hashes the eleven characters of the name and extension, reads the HIT and walks it for bytes equal to the hash. The offset of each matching byte is the locator of a candidate entry; that directory sector is read and the eleven name bytes compared, because two names can share a hash.
- Creating a file: SYS2/SYS searches the HIT for a 00H byte, starting at a place taken from the clock so new files spread through the directory, stores the name's hash there and writes the HIT back.
- Continuation entries: a continuation entry is given the same hash as the file's primary entry; its attribute bit 7 makes the open skip it.
The Granule Allocation Table (GAT)
Space is allocated in granules of five sectors, two to a track (sectors 0-4 and 5-9). GAT byte t belongs to track t: bit 0 set means granule 0 is in use, bit 1 granule 1, and FFH marks a track with no free granule. Bytes E0H-FFH of the GAT sector hold the AUTO command.
Directory Entries and Extents
A directory entry is 32 bytes:
- Byte 0: attributes. Bits 0-2 are the access level; bit 7 is set on a continuation entry (90H).
- Byte 1: on a continuation entry, the locator of the file's primary entry.
- Byte 3: the end-of-file byte, the offset after the last byte in the last sector (00H for a full sector).
- Byte 4: the logical record length.
- Bytes 5-15: the eight-character name and three-character extension, padded with spaces.
- Bytes 16-19: the owner and user password hashes.
- Bytes 20-21: the ending record number, the count of sectors in the file.
- Bytes 22-31: five extents of two bytes. The first is the track; in the second, bits 5-7 are the first granule and bits 0-4 one less than the number of granules. A track of FEH means the file goes on in the entry whose locator follows; FFH ends the list.
Operational Flow
- SYS2/SYS parses the filespec, hashes the name and the password.
- The HIT of each drive (or only the drive named) is searched for the hash; the offset of a match is the entry's locator.
- The directory entry is read, its name compared and its password hashes checked.
- The FCB is filled from the entry, with up to five extents and a running count of granules, and SYS0/SYS's file routines turn record numbers into tracks and sectors from it.
BOOT/SYS
When a Model I is powered on or RESET with a diskette in drive 0, the ROM reads track 0, sector 0 into 4200H-42FFH and jumps to 4200H. That sector is the first of the five sectors of BOOT/SYS (track 0, sectors 0-4; granule 0); the other four are not loaded or used. Byte 2 of the sector holds the diskette's directory track (11H on the system diskette), which SYS0/SYS also reads from there (4B35H).
What the Boot Sector Does
- Disables interrupts, sets the Stack Pointer to 41FCH and clears the screen.
- Selects drive 0 and reads sector 4 of the directory track into 4D00H. Entry 0 of that sector is the entry of SYS0/SYS (locator 02H); when it is not in use, NO SYSTEM is shown.
- Takes the first extent of the entry (track and first granule), and reads the sectors of SYS0/SYS one after the other from there into 4D00H, going on to the next track after sector 9.
- Works through the load records: type 01H blocks are stored at their addresses (SYS0/SYS fills 400CH-4F28H in parts, nothing at 4200H-42FFH or 4D00H-4DFFH), other types are skipped, and the type 02H record gives the transfer address, 4E00H, SYS0/SYS's start-up code, which it jumps to with interrupts still disabled.
- A sector that cannot be read in two tries shows DISK ERROR. After either message the code waits for ENTER and halts.
File Attributes
FORMAT/CMD writes the directory entry of BOOT/SYS with the attribute byte 5EH: a system file, in use, invisible, access level 6. As an invisible file it is not shown by DIR unless invisible files are asked for.
Commented Disassembly:
A disassembly of BOOT/SYS can be found here.
SYS0/SYS
Overview
SYS0/SYS is the nucleus, the part of TRSDOS 2.3 that stays in memory. It holds the DOS entry point table at 4400H-4478H, the RST 28H overlay loader, the file routines (read, write, position, rewind, back up a record, position to the end), the conversion of a record number into a track and sector with the search of the file's extents and the allocation of granules, the WD1771 disk driver, the program loader, the interrupt handler with twelve timer task slots, the clock, the keyboard scan with debounce, and the TRACE and time displays. Two 256-byte sector buffers are used: 4200H-42FFH for directory sectors and 4D00H-4DFFH for loading and for the allocation table.
All system command processors and utility programs are disk resident. The overlays SYS1/SYS-SYS5/SYS are loaded at 4E00H by RST 28H, whose code names the overlay and the function in it; utilities and SYS6/SYS are loaded at 5200H.
As soon as SYS0/SYS is loaded into RAM by BOOT/SYS, its start-up code at 4E00H does the following:
- Disables interrupts and selects interrupt mode 1.
- Sets the stack to 41FCH and stores 5200H in 4047H.
- Finds the top of memory and stores it in 4049H.
- Puts the keyboard scan at 43D8H into the keyboard control block (4016H).
- Stores the keyboard, video and printer driver addresses at 43B8H-43BDH and builds the device list (KI, DO, PR) at 43C0H-43CCH.
- Copies the keyboard control block to 4358H-435FH, followed by eight 00H bytes and sixteen FFH bytes.
- Disarms the BREAK vector at 4315H, sets the RST 38H vector at 4012H to JP 4518H, and enables the clock routine (4560H, vector 405BH) and the disk interrupt routine (4669H, vector 4059H) in the mask at 404CH.
- Sets the system flags at 430FH to 01H (DEBUG off) and puts the clock task 45AFH into timer slot 7.
- Displays the TRSDOS banner.
- If ENTER is down, or the allocation table sector holds no AUTO command, goes to DOS READY; otherwise runs the AUTO command.
Loading the Nucleus
When the system is brought up or RESET is activated, control passes to LEVEL II. LEVEL II immediately determines if the system has disks. If it does, a special program called a boot loader is read from disk. The boot loader is used to load the nucleus for the disk operating system.
There are several aspects of the boot program that make it unique. Like the rest of the system programs, it exists as a named file. But because the space in LEVEL II used for reading the boot is restriced, it is assumed to exist at track 0, sector 0. Furthermore, it is an absolute core image program, one sector long. Thus it can be read directly into memory and executed.
The boot is the only core image program in TRSDOS. Binary modules produced by the editor assembler have embedded control codes indicating the load address, length of string to be loaded and a execution address. The core image of the boot was created by writing a section of memory containing the boot to disk
Control is passed to the boot after it has been read into locations 4200 - 42FF. Notice that this is one of the sector buffer address for the nucleus, so there is no conflict between the addresses for the boot and those of the nucleus. The boot then finds the disk address of SYSO/SYS (the nucleus), and loads it into memory. Since SYSO/SYS is not a core image program, the boot must be able to interpret the loader codes, and it must contain its own disk 1/0 routines, as well as a sector buffer. The sector buffer address is 4DOO - 4DFF; again there is no conflict with code in the nucleus because it has a sector buffer at the same address.
The boot has a limited facility for interpreting the granule allocation pairs in the directory describing the disk addresses for the nucleus. Therefore, it cannot have more than one granule allocation pair.
System Initialization
The initialization code at 4E00H runs once; it sits at the start of the overlay area, so the first overlay loaded overwrites it.
4E00H-4E1DH disable interrupts, select interrupt mode 1, set the stack to 41FCH, store 5200H in 4047H and find the top of memory: starting at FFFFH and going down 1K at a time, the first address that keeps a written value is stored in 4049H.
4E20H jumps to 4F20H, which stores 43D8H (the keyboard scan with debounce) into the keyboard control block at 4016H. Back at 4E23H the driver addresses of the keyboard, video and printer control blocks are stored at 43B8H-43BDH and, with the two-letter names from bytes 6-7 of each control block, in the device list at 43C0H-43CBH; 43CCH is set to 00H to end the list. The SYS6/SYS routine at 531DH lists the names.
4E57H-4E70H copy the keyboard control block to 4358H-435FH and store eight 00H and sixteen FFH bytes after it. The JR NZ instructions at 4E53H and 4E74H have a displacement of 00H, so the loops they belong to run only once.
4E76H-4E9DH read the disk status register, store 00H at 4315H (BREAK vector off) and at 404CH (no interrupt enabled), make 4012H a JP 4518H, put 4560H (clock) at 405BH and 4669H (disk) at 4059H, and set bits 7 and 6 of 404CH.
4E9FH-4EA9H set 430FH to 01H and put the clock task control block 45AFH into timer slot 7. Slot 7 runs once every eight clock ticks; the task counts five runs and then adds one second to the time at 4041H-4043H, carrying into the date at 4044H-4046H.
4EACH-4EB8H display the banner, stored as negated characters at 4EEDH. 4EBAH scans the keyboard once: with ENTER down the code goes to 4400H (DOS READY). Otherwise 4EC2H-4ECBH read sector 0 of track 11H, the granule allocation table sector, into 4200H; a read error goes to 4409H. If its byte at 42E0H is a carriage return no AUTO command is set and the code goes to 4400H; otherwise the 32 bytes at 42E0H-42FFH are copied to the command line buffer at 4318H, displayed, and run through 4405H (SYS1/SYS).
Nucleus Functions
The nucleus contains code for interrupt processing, the timer tasks and the clock, disk and file services, the program loader, the overlay loader, the TRACE and time displays and the keyboard scan. Its data structures include the DOS entry point table, the per-drive track and directory track tables at 4300H-4307H, the command line buffer at 4318H, the overlay FCB at 44A0H and the interrupt vectors at 404DH-405CH. The SYS0/SYS disassembly has the details.
Commented Disassembly:
A disassembly of SYS0/SYS can be found here.
SYS1/SYS
SYS1/SYS is the command interpreter of TRSDOS 2.3. It is a system overlay: SYS0/SYS loads it into 4E00H-51FFH when an RST 28H code with 3 in bits 0-3 is executed and enters it at 4E00H with the code in Register A. It shows DOS READY, reads a command line of up to 63 characters into 4318H, and decides whether the first word is one of its own commands, a library command for SYS6/SYS, or a program to load from the diskette.
Functions
Bits 4-6 of the RST 28H code select the function. SYS0/SYS's fixed entry points supply the codes:
- 93H (10H) and A3H (20H): DOS READY. 402DH and 4400H use 93H; 4030H, the exit after an error, uses A3H. Interrupts are enabled, the stack is set to 41FCH, the prompt is displayed and a line is read with the ROM's 0040H.
- B3H (30H), from 4405H: run the command line at Register Pair HL. This is how the typed line is run, and how AUTO and BASIC/CMD hand a command to TRSDOS 2.3.
- C3H (40H), from 441CH: parse the filespec at Register Pair HL into the FCB at Register Pair DE: up to 8 characters of name, then optionally a slash and 3 characters of extension, a period and 8 characters of password, a colon and a 1-character drive, with 03H after the last field. A name starting with an asterisk is a device name. The words TO, ON and OVER are passed over.
- D3H (50H), from 4473H: add the three-character extension at Register Pair HL to the filespec in the FCB at Register Pair DE when it has none, moving the rest of the filespec up four bytes to make room for the slash and the extension.
- E3H (60H), from 4476H: parse a parameter list (NAME=value,...) at Register Pair HL using the table at Register Pair DE. Values can be X'hex digits', a decimal number, or YES, NO, ON or OFF; a name with no value stores FFFFH.
Running a Command
- Push 402DH, the DOS READY exit, as the return address of the command.
- Parse the first word as a filespec into the command FCB at 4480H; a word that is not a filespec, or a device name, displays WHAT?.
- Look the name up in the first table: BASIC2, DEBUG and TRACE are carried out inside SYS1/SYS.
- Look the name up in the second table: the nineteen library commands APPEND, ATTRIB, AUTO, CLOCK, COPY, DATE, DEVICE, DIR, DUMP, FREE, KILL, LIB, LIST, LOAD, PRINT, PROT, RENAME, TIME and VERIFY are passed to SYS6/SYS at 5200H with their number (1-19) in Register C. SYS6/SYS is loaded through RST 28H code 88H unless bit 4 of the system flags at 430FH shows it is still in memory.
- Otherwise add /CMD when the name has no extension, clear bit 4 of 430FH, and load and run the program through SYS0/SYS's 4433H with Register Pair HL at the rest of the command line.
The Commands Inside SYS1/SYS
- BASIC2 copies the ROM's initial values back to 4000H-4035H, clears 4036H-405CH and jumps to the ROM's 0075H, leaving TRSDOS 2.3 for Level II BASIC.
- DEBUG (or DEBUG (ON)) sets bit 7 of 430FH and makes both the BREAK vector at 4315H and the error exit at 4030H go to the RST 30H vector at 400FH, the DEBUG entry. DEBUG (OFF) undoes this.
- TRACE (or TRACE (ON)) puts the task at 4CD9H, which shows the interrupted program counter at the top of the screen, into timer slot 11; TRACE (OFF) removes it.
Commented Disassembly:
A disassembly of SYS1/SYS can be found here.
SYS2/SYS - File Opening and Initialization
SYS2/SYS is the system overlay that opens files. SYS0/SYS loads it into 4E00H when an RST 28H code with 4 in bits 0-3 is executed. It has three functions:
- Open (code 94H, entry 4424H): parses the filespec in the FCB, searches the HIT of the drive named, or of drives 0-3 in turn, checks the name and the password, and fills the FCB from the directory entry. A drive that does not show an index pulse is skipped. Errors include 13H (ILLEGAL FILE NAME), 18H (FILE NOT IN DIRECTORY) and 19H (FILE ACCESS DENIED).
- Open or create (code A4H, entry 4420H): the same open; when the file is not found it is created on the first drive that is ready and not write protected and has a free HIT entry. The new entry gets the name, the logical record length from Register B, the typed password's hash in both password words and five empty extents. It returns the CARRY FLAG when a file was created; 1AH (DIRECTORY SPACE FULL) when none had room.
- Continuation entry (code B4H): when SYS0/SYS's granule allocation needs a new extent and only the entry's last extent field is left, SYS2/SYS claims a free entry, marks it 90H with a link back to the primary entry, and sets the primary's last extent to FEH and the new entry's locator; 1EH (DIRECTORY FULL - CAN'T EXTEND FILE) when there is no room.
Each file has an owner password and a user password, stored as sixteen-bit hashes. The owner password opens the file at access level 0, the user password at the file's own level. A password whose hash is 61A2H opens any file, and a file at access level 7 can be opened only with that one.
Commented Disassembly:
A disassembly of SYS2/SYS can be found here.
SYS3/SYS - File Closing and Deletion
SYS3/SYS is the system overlay that closes and kills files. SYS0/SYS loads it into 4E00H when an RST 28H code with 5 in bits 0-3 is executed, with the FCB in Register Pair DE. It first checks every field of the FCB and refuses a stray or closed one with error 26H (FILE NOT OPEN).
- Close (code 95H, entry 4428H): writes the buffer if it holds changed records, updates the directory entry's end-of-file byte and ending record number, then counts the granules the file holds (following continuation entries) and frees any that the ending record number no longer needs. It unlinks a continuation entry that empties, writes the directory sector, the hash index table and the allocation table back, and leaves the FCB holding the filespec text so it can be reopened.
- Kill (code A5H, entry 442CH): refused with error 25H when the file's access level is 2 or more. Otherwise it frees every granule of the primary entry and of each continuation entry, clears each 32-byte entry and its hash index byte, writes the tables back and clears the FCB.
SYS3/SYS works on three sectors of the directory track in three buffers: the directory sector in 4200H, the granule allocation table in 4D00H, and the hash index table in 5100H, just above the overlay.
Commented Disassembly:
A disassembly of SYS3/SYS can be found here.
SYS4/SYS - Error Message Processor
SYS4/SYS is the system overlay that turns an error number into the message the person sees. SYS0/SYS loads it into 4E00H when an RST 28H code with 6 in bits 0-3 is executed, with the error code on the stack. Bits 0-5 of the code are the error number, bit 6 asks for the message text with no framing, and bit 7 makes SYS4/SYS return to the program that raised the error instead of going to DOS READY.
To save memory, the 62 messages are not stored as whole strings. Each is a list of word numbers into a dictionary of 53 words (ERROR, DURING, DISK, DIRECTORY and so on), so a common word is held once and shared. SYS4/SYS shows *** ERRCOD=nn, with the number in decimal, then the words of the message, and for a full error a second line naming the file or device involved (<FILE=name> or <DEVICE=*xx>) and a third line, REFERENCED AT X'addr', giving the address that made the call.
The full error table, from 00H NO ERROR through 26H FILE NOT OPEN, is reconstructed byte for byte on the disassembly page; error numbers 27H and above all share the message UNKNOWN ERROR CODE.
Commented Disassembly:
A disassembly of SYS4/SYS can be found here.
SYS5/SYS - DEBUG
SYS5/SYS is the system overlay that holds DEBUG. SYS0/SYS loads it into 4E00H when an RST 28H code with 7 in bits 0-3 is executed; the RST 30H vector at 400FH and the DEBUG entry at 440DH both jump to 44B4H, which calls it with code 87H. SYS5/SYS saves every register of the interrupted program in 4065H-407CH, takes out the breakpoints it planted, and shows the registers with the memory they point to. It never returns to SYS0/SYS: it leaves only by restarting the program.
- Display: X shows the twelve registers, each with the 16 bytes it points to, and four lines of memory; S shows a full screen of 256 bytes; D sets the display address, and the semicolon and minus sign move it forward or back; A and H show the bytes as characters or as hexadecimal; U redraws the display until a key is pressed.
- Changing memory and registers: M examines and changes memory byte by byte; R changes a saved register by name.
- Running the program: G puts back the registers and resumes, optionally at a new address and with up to two RST 30H breakpoints, and arms BREAK to come back to DEBUG; I executes one instruction, following a CALL into the subroutine, and C does the same but runs a called subroutine at full speed.
The disassembly page records what the code does in detail, including that the JP (IX) instruction is single stepped as JP (IY), and that an instruction whose next address or jump target is in ROM cannot be single stepped, because the breakpoint byte cannot be written there.
Commented Disassembly:
A disassembly of SYS5/SYS can be found here.
SYS6/SYS - The Library Commands
SYS6/SYS holds the nineteen library commands. It is loaded at 5200H, the address programs are loaded at, not into the overlay area at 4E00H, so SYS1/SYS and SYS2/SYS can still be called while it runs. SYS1/SYS finds the command name in its second command table and enters SYS6/SYS at 5200H with the command's number in Register C (1 APPEND to 19 VERIFY, in alphabetical order) and the rest of the command line in Register Pair HL. It loads SYS6/SYS through RST 28H code 88H only when bit 4 of the system flags at 430FH shows that SYS6/SYS is not already in memory; loading a program clears the bit. Every command goes back to DOS READY.
- Files: APPEND adds one file to the end of another, byte by byte; COPY copies a file sector by sector, creating the new file when needed; KILL deletes a file; RENAME changes a file's name on its own drive; LIST shows a text file on the display and PRINT sends it to the printer; LOAD loads a program without running it; DUMP saves memory from 7000H up as a program file with the extension CIM.
- Directories and diskettes: DIR lists the files with their system, invisible and password flags, and with (A) their record length, record count and granules; FREE shows, for every drive with a diskette, its name, date, free directory entries and free granules; ATTRIB sets a file's passwords, access level and invisible bit; PROT checks the diskette's master password and can change it, or give every user file the master password (LOCK) or the blank password (UNLOCK).
- System settings: AUTO stores the command TRSDOS runs at start-up in drive 0's allocation table; CLOCK turns the time display on or off; DATE and TIME set the date and time; VERIFY makes every write read the sector back, or stops it; DEVICE lists the device names KI, DO and PR; LIB lists the library commands.
The disassembly page also records the faults in the code, among them PROT's password input writing over the start of APPEND when eight characters are typed, LIST's LINE parameter that never reaches its variable, ATTRIB resetting the access level to 0 when PROT is not given, and DIR (A) miscounting records for record lengths above 128.
Commented Disassembly:
A disassembly of SYS6/SYS can be found here.