TRS-80 DOS - TRSDOS v1.3 - Disassembled

Overview

TRSDOS v1.3 is comprised of a boot sector (track 0, sector 1, which the source calls BOOT), and then 15 Overlays (00-14), although there is room for a 16th.

The system files do not have corresponding directory entries. Rather, they appear at byte E0H in the HIT table just as a string of hex pairs, in the order of the overlay.

TRSDOS 1.3 Overlay Guide

The first byte of the two byte code is broken down into 2 numbers - bits 7-5, and bits 4-0. Each of those decimal values is multiplied by 3 since there are 3 sectors in a gran. The first value is the starting gran on the track and the second value is how many consecutive grans the overlay occupies.

The second byte of the two byte code represents the track number where the overlay starts.

Boot Sector (BOOT)

The bootstrap: sector 1 of track 0 of a system diskette. It is not a file and has no directory entry (no system file has one); the source's table of the system files calls it BOOT, and it is also known as BOOT/SYS. The pointer of SYS0 in the HIT (offset E0H) starts with this sector, and the load module of SYS0 follows it from sector 2. The ROM loads the boot sector at 4300H and jumps to it; it reads SYS0 from track 0, sector 2 on into memory and jumps to SYS0's transfer address, 4E00H. It also holds the backup counter (4322H), the serial number of the diskette (43F4H-43FBH), the version byte (43FEH, 13H) and the number of tracks (43FFH, 28H). Must be present on any bootable disk.

A disassembly of the boot sector can be found here.

SYS0/SYS (the "nucleus")

Purpose:

As soon as SYS0/SYS is loaded into RAM by the boot sector, it does the following:

  1. Disables interrupts, selects interrupt mode 1 and sets the stack to 409FH.
  2. Sends 00H to port E4H (no disk NMIs), 20H to port ECH (video wait states on) and 04H to port E0H (only the real time clock interrupt allowed).
  3. Copies the serial number from the boot sector (43F4H) into the sign on message as ASCII digits.
  4. Finds the end of RAM by testing FFFFH, BFFFH and 7FFFH, stores it in 4411H (MEMEND), 40A0H and 4415H (MEM2), clears the screen and puts 48, 32 or 16 into the memory size line.
  5. Selects drives 0 to 3 in turn and restores each to track 0 to count the drives, then stores the highest drive number in 4413H (MAXDRV) and the count in the sign on message.
  6. Displays the Model III picture, the version line and the copyright notice, and reads the whole keyboard (38FFH) to see whether a key is held down.
  7. Enables interrupts. If 42B5H already holds 4455H the date and time questions are skipped; otherwise it stores 4455H there and asks for the date (MM/DD/YY) and the time (HH:MM:SS, which may be left blank or typed as HH:MM), checking each value.
  8. Copies the saved date (42B7H-42B9H) to the clock (421AH-421CH).
  9. If a key was held down during the boot it goes straight to TRSDOS READY. Otherwise it reads the GAT of drive 0 and, when the GAT holds an AUTO command (offset E0H), makes the BREAK vector at 42AEH a RET, copies the command into the command buffer at 4225H, displays AUTO Function Engaged and runs it; with no AUTO command it goes to TRSDOS READY.

Location:

Overlay 00 is preset as HIT Table entry 0500H ...

Last 2 Digits = 00H = Decimal 00.

First 2 Digits = 05H = Binary 00000101.

000 = 0. 0 x 3 (3 sectors in a gran) = a starting sector of 0.
00101 = 5. 5 x 3 (3 sectors in a gran) = 15 sectors long.

So ... SYS00/SYS starts on Track 00 at sector 0, and continues for 15 sectors.

Disassembly:

A disassembly of SYS00/SYS can be found here.

SYS01/SYS aka OVERLAY 1

Purpose:

Overlay 1 is the TRSDOS v1.3 command interpreter and must be available on all SYSTEM disks. It loads at 4E00H-51F1H and has 7 entries, selected by bits 6-4 of Register A (the low 4 bits are 1, the overlay number). It also holds the library command table LIBCOM (37 commands) and the routines GETSYM, SEARCH, PARAM and CHKFLG that other overlays call while it is in memory.

RoutineReg A
on Entry
Routine Summary
CMDRDY
(TRSDOS Ready)
90HEntry 1 (S1RST1 at 4296H, reached through SYS1IN at 402DH). Clears the command buffer at 4225H, resets the cassette BREAK vector and turns the BREAK key off, clears user memory when CFLAG (42B4H) is 55H, clears SCRLCT, CFLAG and SCAFLG, sets BASICG to FFH, displays TRSDOS Ready and a line of periods, reads a command line and runs it.
CMDABT
(Abort)
A0HEntry 2 (ABORT at 4030H). Displays Operation Aborted, then continues as CMDRDY.
CMDLINB0HEntry 3 (S1RST2 at 4299H). Runs the command line at HL with 402DH pushed as the return address, so the command ends at TRSDOS Ready.
FSPEC
(SYNTAX)
C0HEntry 4 (the SYNTAX vector at 441CH). Copies a filespec from the text at HL to DE: up to 8 letters or digits of name, then / and up to 3 of extension, . and up to 8 of password, : and 1 drive digit, ended with 03H. A word TO is skipped. Returns Z when a name was found.
FEXT
(PUTEXT)
D0HEntry 5 (the PUTEXT vector at 444BH). Adds the 3 byte default extension at HL to the filespec at DE when it has none.
PARAM
(SWITCH)
E0HEntry 6 (the SWITCH vector at 4454H). Reads an options list in parentheses at HL, NAME=value,..., using the parameter table at DE; a value is a hexadecimal number, ON (FFFFH) or OFF (0000H), and a name alone means ON.
CALCOMF0HEntry 7 (S1RST7 at 429CH). Runs the command line at HL and returns to the caller: a library command goes through its LIBCOM vector, any other name gets /CMD added and is loaded and run through EXEC (4433H).

Location:

Overlay 01 is preset as HIT Table entry 0210H ...

Last 2 Digits = 10H = Decimal 16.

First 2 Digits = 02H = Binary 00000010.

000 = 0. 0 x 3 (3 sectors in a gran) = a starting sector of 00.
00010 = 2. 2 x 3 (3 sectors in a gran) = 6 sectors long.

So ... SYS01/SYS starts on Track 16 at sector 00, and continues for 6 sectors.

Disassembly:

A disassembly of SYS01/SYS can be found here.

SYS02/SYS aka OVERLAY 2

Purpose:

Overlay 2 handles the following and must be available on all SYSTEM disks.

RoutineReg A
on Entry
Routine Summary
Disk File OPEN90HEntry 1 (the OPEN vector at 4424H). DE = a DCB holding the filespec, B = the logical record length (0 = 256), HL = the buffer. Finds the file through the hash index table on the drive given (or each drive in turn), checks the passwords against the protection level and fills in the DCB. Returns Z, or NZ with the error code in A.
Disk File INITializeA0HEntry 2 (the INIT vector at 4420H). Opens the file as OPEN does and sets its end of file to 0; when the file is not found it creates it (a hash index table entry and a directory record) on the drive given or the first drive with room, and returns with the CARRY FLAG set.
Password Encode (Hash)C0HThe PASSWORD ENCODE routine takes an 8 character string pointed to by (DE) and turns it into a two byte value. This value is stored in the directory entry by INIT and ATTRIB. Any other value of A returns at once.

Location:

Overlay 02 is preset as HIT Table entry 4210H ...

Last 2 Digits = 10H = Decimal 16.

First 2 Digits = 42H = Binary 01000010.

010 = 2. 2 x 3 (3 sectors in a gran) = a starting sector of 6.
00010 = 2. 2 x 3 (3 sectors in a gran) = 6 sectors long.

So ... SYS02/SYS starts on Track 16 at sector 6, and continues for 6 sectors.

Disassembly:

A disassembly of SYS02/SYS can be found here.

SYS03/SYS aka OVERLAY 3

Purpose:

Overlay 3 handles the CLOSE (enters with 90H in Register A) and KILL (enters with A0H in Register A) routines for TRSDOS v1.3. Any other entry returns error 38 (I/O attempt to unopen file). This overlay must be available on all SYSTEM disks.

Location:

Overlay 03 is preset as HIT Table entry 8310H ...

Last 2 Digits = 10H = Decimal 16.

First 2 Digits = 83H = Binary 10000011.

100 = 4. 4 x 3 (3 sectors in a gran) = a starting sector of 12.
00011 = 3. 3 x 3 (3 sectors in a gran) = 09 sectors long.

So ... SYS03/SYS starts on Track 16 at sector 12, and continues for 09 sectors.

Disassembly:

A disassembly of SYS03/SYS can be found here.

SYS04/SYS aka OVERLAY 4 

Purpose:

Overlay 4 is the TRSDOS v1.3 DOS Error Handler. It first starts by checking memory location 4CFDH to see if chaining is active (and if so, ending the chaining). It then gets the error message (by POPing Register Pair AF), and the return address from the top of the stack, prints the error, and exits. This overlay must be available on all SYSTEM disks.

Location:

Overlay 04 is preset as HIT Table entry A110H ...

Last 2 Digits = 10H = Decimal 16.

First 2 Digits = A1H = Binary 10100001.

101 = 5. 5 x 3 (3 sectors in a gran) = a starting sector of 15.
00001 = 1. 1 x 3 (3 sectors in a gran) = 03 sectors long.

So ... SYS04/SYS starts on Track 16 at sector 15, and continues for 03 sectors.

Disassembly:

A disassembly of SYS04/SYS can be found here.

SYS05/SYS aka OVERLAY 5

Purpose:

Overlay 5 processes DEBUG. This overlay is optional and may be deleted if there is no need for DEBUG.

Location:

Overlay 05 is preset as HIT Table entry A300H ...

Last 2 Digits = 00H = Decimal 00.

First 2 Digits = A3H = Binary 10100011.

101 = 5. 5 x 3 (3 sectors in a gran) = a starting sector of 15.
00011 = 3. 3 x 3 (3 sectors in a gran) = 09 sectors long.

So ... SYS05/SYS starts on Track 00 at sector 15, and continues for 09 sectors.

Disassembly:

A disassembly of SYS05/SYS can be found here.

SYS06/SYS aka OVERLAY 6

Purpose:

Overlay 6 processes the APPEND, ATTRIB, AUTO, BUILD, CLEAR, CLOCK, CREATE, DATE, DIR, DO, DUMP, ERROR, FREE, LIB, LOAD, PAUSE, PROT, RENAME, and TIME library commands. This overlay is optional.

Location:

Overlay 06 is preset as HIT Table entry 0612H ...

Last 2 Digits = 12H = Decimal 18.

First 2 Digits = 06H = Binary 00000110.

000 = 0. 0 x 3 (3 sectors in a gran) = a starting sector of 00.
00110 = 6. 6 x 3 (3 sectors in a gran) = 18 sectors long.

So ... SYS06/SYS starts on Track 18 at sector 00, and continues for 18 sectors.

Disassembly:

A disassembly of SYS06/SYS can be found here.

SYS07/SYS aka OVERLAY 7

Purpose:

Overlay 7 processes the BACKUP and FORMAT commands. This overlay is optional.

Location:

Overlay 07 is preset as HIT Table entry 4601H ...

Last 2 Digits = 01H = Decimal 01.

First 2 Digits = 46H = Binary 01000110.

010 = 2. 2 x 3 (3 sectors in a gran) = a starting sector of 06.
00110 = 6. 6 x 3 (3 sectors in a gran) = 18 sectors long.

So ... SYS07/SYS starts on Track 01 at sector 06, and continues for 18 sectors.

Disassembly:

A disassembly of SYS07/SYS can be found here.

SYS08/SYS aka OVERLAY 8

Purpose:

Overlay 8 processes the HELP command. This overlay is optional.

Location:

Overlay 08 is preset as HIT Table entry 0613H ...

Last 2 Digits = 13H = Decimal 19.

First 2 Digits = 06H = Binary 00000110.

000 = 0. 0 x 3 (3 sectors in a gran) = a starting sector of 0.
00110 = 6. 6 x 3 (3 sectors in a gran) = 18 sectors long.

So ... SYS08/SYS starts on Track 19 at sector 00, and continues for 18 sectors.

Disassembly:

A disassembly of SYS08/SYS can be found here.

SYS09/SYS aka OVERLAY 9

Purpose:

Overlay 9 processes the COPY, DUAL, FORMS, KILL, MASTER, PATCH, RELO, ROUTE, SETCOM, and WP commands (ROUTE only returns error 31, Program not found; the rest of its code is never reached). SYS1 runs it through the vector at 42A8H (LD A,99H / RST 28H) with the command's LIBCOM number in Register C. This overlay is optional.

Location:

Overlay 09 is preset as HIT Table entry 0514H ...

Last 2 Digits = 14H = Decimal 20.

First 2 Digits = 05H = Binary 00000101.

000 = 0. 0 x 3 (3 sectors in a gran) = a starting sector of 0.
00101 = 5. 5 x 3 (3 sectors in a gran) = 15 sectors long.

So ... SYS09/SYS starts on Track 20 at sector 0, and continues for 15 sectors.

Disassembly:

A disassembly of SYS09/SYS can be found here.

SYS10/SYS aka OVERLAY 10

Purpose:

Overlay 10 shows the short directory of a drive ($DSPDIR, 4419H: LD A,8AH / RST 28H, used by BASIC's CMD"D:d") and the texts of the BASIC error messages for Disk BASIC (SYSS10, 427BH: LD A,9AH / RST 28H, reached from the ROM's error vector 41A6H). This overlay is optional.

Location:

Overlay 10 is preset as HIT Table entry 020FH ...

Last 2 Digits = 0FH = Decimal 15.

First 2 Digits = 02H = Binary 00000010.

000 = 0. 0 x 3 (3 sectors in a gran) = a starting sector of 0.
00010 = 2. 2 x 3 (3 sectors in a gran) = 6 sectors long.

So ... SYS10/SYS starts on Track 15 at sector 0, and continues for 6 sectors.

Disassembly:

A disassembly of SYS10/SYS can be found here.

SYS11/SYS aka OVERLAY 11

Purpose:

Overlay 11 carries the library commands LIST, PURGE and TAPE (SSYS11, 42ABH: LD A,9BH / RST 28H, with the LIBCOM number in Register C). TAPE copies a SYSTEM tape to disk or into memory, or a disk load module to tape; PURGE asks for the master password and kills the files the user confirms, and with * also takes the system off the diskette; LIST shows a file as text or in hex. This overlay is optional.

Location:

Overlay 11 is preset as HIT Table entry A414H ...

Last 2 Digits = 14H = Decimal 20.

First 2 Digits = A4H = Binary 10100100.

101 = 5. 5 x 3 (3 sectors in a gran) = a starting sector of 15.
00100 = 4. 4 x 3 (3 sectors in a gran) = 12 sectors long.

So ... SYS11/SYS starts on Track 20 at sector 15, and continues for 12 sectors.

Disassembly:

A disassembly of SYS11/SYS can be found here.

SYS12/SYS aka OVERLAY 12

Purpose:

Overlay 12 carries two Disk BASIC commands: NAME, which renumbers the program and every line number reference in it (SSYS12, 427EH: LD A,8CH / RST 28H), and CMD"C", which takes the remarks and the spaces out of the program (SYSS12, 4281H: LD A,9CH / RST 28H). This overlay is optional.

Location:

Overlay 12 is preset as HIT Table entry 420FH ...

Last 2 Digits = 0FH = Decimal 15.

First 2 Digits = 42H = Binary 01000010.

010 = 2. 2 x 3 (3 sectors in a gran) = a starting sector of 6.
00010 = 2. 2 x 3 (3 sectors in a gran) = 6 sectors long.

So ... SYS12/SYS starts on Track 15 at sector 6, and continues for 6 sectors.

Disassembly:

A disassembly of SYS12/SYS can be found here.

SYS13/SYS aka OVERLAY 13

Purpose:

Overlay 13 carries three Disk BASIC commands: CMD"O", which sorts a string array (SSYS13, 4284H: LD A,8DH / RST 28H), CMD"J", which turns MM/DD/YY into the day of the year and -YY/DDD back into MM/DD/YY (SYSS13, 4287H: LD A,9DH / RST 28H), and CMD"X", which shows the numbers of the program lines that hold a keyword or a string (SSSY13, 428AH: LD A,ADH / RST 28H). This overlay is optional.

Location:

Overlay 13 is preset as HIT Table entry 820FH ...

Last 2 Digits = 0FH = Decimal 15.

First 2 Digits = 82H = Binary 10000010.

100 = 4. 4 x 3 (3 sectors in a gran) = a starting sector of 12.
00010 = 2. 2 x 3 (3 sectors in a gran) = 6 sectors long.

So ... SYS13/SYS starts on Track 15 at sector 12, and continues for 6 sectors.

Disassembly:

A disassembly of SYS13/SYS can be found here.

SYS14/SYS aka OVERLAY 14

Purpose:

Overlay 14 carries two system calls for programs: $FILPTR, which gives the drive and the logical file number of an open file (SSYS14, 428DH: LD A,8EH / RST 28H), and $RAMDIR, which copies one directory record, the records of every file that is not a system file, or the used and free granule counts of a drive into a RAM area (SSSY14, 4290H: LD A,9EH / RST 28H). This overlay is optional.

Location:

Overlay 14 is preset as HIT Table entry 6115H ...

Last 2 Digits = 15H = Decimal 21.

First 2 Digits = 61H = Binary 01100001.

011 = 3. 3 x 3 (3 sectors in a gran) = a starting sector of 9.
00001 = 1. 1 x 3 (3 sectors in a gran) = 3 sectors long.

So ... SYS14/SYS starts on Track 21 at sector 9, and continues for 3 sectors.

Disassembly:

A disassembly of SYS14/SYS can be found here.