TRS-80 DOS - TRSDOS 6.2 for the Model 4 - Disassembled
Page Index
Overview
TRSDOS 6.2 is the operating system Logical Systems wrote for Tandy and Tandy sold for the Model 4 from late 1984; its history, its patch levels and its manuals are on the TRSDOS 6.2 reference page. These pages disassemble the 6.2.1 system diskette, whose name string at 0410H reads TRSDOS62Level-AR, the last level of the line and the one the 6.2.1 manuals describe. Every row is written from the bytes of the release file and checked back against them. The labels and many of the comments come from the source code Logical Systems published in 1984 as The Source; where that source is one patch level behind the release, which it is, the difference is named rather than taken on trust.
Thirty-two of the thirty-five files on the diskette have a page. DIR/SYS, the directory itself, has none, and neither do the help text DOS/HLP nor MODELA/III, the Model III ROM image for the 4P, because neither is code of this system.
Memory Map
TRSDOS 6.2 runs the Model 4 in its native mode, with no ROM in the memory map. The boot sector sends 86H to the Operation Register (port 84H), which leaves RAM from 0000H to F3FFH, the keyboard at F400H-F7FFH and the video memory at F800H-FFFFH. The system then holds the bottom of memory:
| Address | Contents |
|---|---|
| 0000H-01FFH | Restart vectors, system flags and storage, and the supervisor call table at 0100H-01FFH: 128 words, of which 99 are services and the rest point at the invalid call routine (loaded by SYS0/SYS). |
| 0200H-12FFH | Device control blocks, the stack, the system information, the command line buffer, the drive code tables and the resident keyboard, video, printer and floppy disk drivers (BOOT/SYS, read in at boot to 0200H-11FFH; 0380H-03FFH loaded over by SYS0/SYS). The low memory zone for added drivers starts at 0FF4H. |
| 1300H-1DFFH | The resident system, SYSRES (SYS0/SYS). |
| 1E00H-23FFH | The system overlay area: the SYS0/SYS start-up first, then SYS1/SYS to SYS5/SYS and SYS9/SYS to SYS13/SYS. The directory buffer is at 2300H, and every overlay but SYS13/SYS carries its own length at 23FEH. |
| 2400H- | The library overlays SYS6/SYS to SYS8/SYS, drivers and filters. FLOPPY/DCT and MEMDISK/DCT load at 2C00H, and so does the SET member of SYS6/SYS. Utilities load at 2600H, COMM/CMD at 3C00H and BASIC at 3000H-82FFH. |
BOOT/SYS
Purpose:
BOOT/SYS is cylinder 0, sectors 0 to 15 of the system diskette, 4096 bytes written by FORMAT and never copied from one diskette to another. It is not a load module. The ROM reads sector 1 into 4300H and runs it: that boot code turns on the all RAM memory map (86H to port 84H), saves the value it sent in OPREG$ at 0078H, clears the screen, reads all of BOOT/SYS to 0200H-11FFH, sets up the 6845 video controller, reads the GAT for the number of sides and for the directory entry of SYS0/SYS, and hands over to the loader at 0238H, which reads SYS0/SYS through the resident floppy driver and jumps to 1E00H. The directory cylinder it looks on is the operand byte of the CP 14H that is its second instruction, so a formatter chooses that cylinder by patching one byte of this file.
Most of BOOT/SYS stays in memory as part of the resident system: the bank bytes and the six device control blocks at 0200H, the system information, the command line buffer and the drive code tables at 0400H, and the resident I/O code at 0500H-0FF3H, which is the character I/O supervisor calls (@DSPLY, @KEYIN, @GET, @PUT, @CTL and their relatives), @MUL16 and @DIV16, the decimal and hex conversions, the clock task with the cursor blink, @BANK, the keyboard driver with its type-ahead buffer, the video driver with @VDCTL, the printer driver and the floppy disk driver. Sectors 14 and 15 carry nothing but format fill, and 0FF4H up is the low memory zone that added drivers load into.
Of the 4096 bytes, 4062 are the same as LS-DOS 6.3.1's, and 2643 of the 2668 instructions sit at the same address doing the same thing, so this is the file where the two generations are closest; the ten places they differ are set out in the introduction to the page. Four bugs are on these rows, T1 to T4 on the reference page. Three of them stand in the same instructions in LS-DOS 6.3.1 and are its bugs as well. The fourth belongs to this generation alone: nothing here tests whether a date has been set before the midnight roll-over steps the day, so a machine booted past the date prompt gives itself 01/01/00 at the first midnight, and MISOSYS fixed it.
Disassembly:
A disassembly of BOOT/SYS can be found here.
SYS0/SYS
Purpose:
SYS0/SYS is everything resident in the system that is not in BOOT/SYS: the loader reads it record by record at boot and jumps to 1E00H. It is a load module of 43 blocks, 4708 bytes of file and 4499 loaded, and the blocks go to five places. Low memory 0000H-01FFH takes the restart vectors, the time, the interrupt vectors and the task table, the 26 system flags A to Z, the system file control blocks and the 128 word supervisor call table. 0380H-03FFH takes the stack guard, @PAUSE, @SOUND with its table of eight notes, @DECHEX and the five byte stub that reboots the machine. 1300H-1CFFH is SYSRES, which stays for the life of the system: the file positioning and record services, the translation of a record number into a cylinder and sector, the allocation of space as a file grows, the directory, GAT and HIT routines, the supervisor call dispatcher, the reader that brings an overlay into 1E00H or a library member into 2400H, @LOAD and @RUN, and the task processor with its interrupt handler and twelve task slots. 1E00H-2166H is the start-up, which runs once and is then overwritten by the first overlay to load. And sixteen blocks go straight into video memory at F80DH-FE27H, which is how the sign-on screen is painted without any code to paint it.
This is the file where TRSDOS 6.2 and LS-DOS 6.3.1 differ most: 501 of its 2929 instructions have no counterpart in the later release at all, and only 1758 stand at the same address doing the same thing. Three of the differences are worth naming here. This release answers 99 supervisor calls where LS-DOS answers 107, and the two LS-DOS adds, @HEXD and @VDPRT, hold the invalid call word in this table. @DATE is call 18 at 07A8H here, in the clock module of BOOT/SYS beside @TIME, where LS-DOS moves it into this file. And @SEEKSC, call 71, is a routine of its own here that seeks the drive to a record, where LS-DOS points the call at a RET so that it does nothing, which its own update sheet records.
Disassembly:
A disassembly of SYS0/SYS can be found here.
SYS1/SYS
Purpose:
SYS1/SYS is the command interpreter: the overlay behind the TRSDOS Ready prompt, and the parser that every command and most programs use to read a file specification or a parameter list. It is a load module of 1336 bytes in six blocks, 1275 of them loaded at 1E00H-22F8H with the overlay length at 23FEH-23FFH, and its transfer address is 1E00H. RST 28H reaches it with six requests: @EXIT, @CMNDR and @CMNDI for a command line, and @FSPEC, @FEXT and @PARAM for the parser. @EXIT goes through CLEANUP, which puts the stack back, gives BREAK to the system, sets the debugger hook from SFLAG$ and clears the flags a program may have set; the interpreter then shows the prompt, reads up to 79 characters, parses the first word into the system command block and looks it up in a table of 38 library commands. A name that is not in the table has /CMD added and is run as a program.
Two things on this page are worth the visit on their own. The library table holds a dormant KILL command: the 00H at 2054H that ends the table is also the place where the letter K of its name would stand, and the source's own comment there reads Patch 'K' here for KILL, so one byte turns it into a 39th command that removes a file exactly as REMOVE does. And the file is the clearest case in the release of how Logical Systems tightened the code afterwards: six places differ from LS-DOS 6.3.1, and in five of them the later release does the same work in fewer bytes, one of them by running an operand byte as an instruction. The sixth is the command LS-DOS adds, ID, which this release does not have.
Disassembly:
A disassembly of SYS1/SYS can be found here.
SYS2/SYS
Purpose:
Opens and initializes disk files and logical devices, services @CKDRV, and hashes file names and passwords.
Disassembly:
The disassembly of SYS2/SYS is in progress.
SYS3/SYS
Purpose:
Closes files and logical devices, and services @FNAME.
Disassembly:
The disassembly of SYS3/SYS is in progress.
SYS4/SYS
Purpose:
SYS4/SYS turns an error number into its message: the system error dictionary behind @ERROR (SVC 26). It is a load module of 1307 bytes, 1242 of them loaded at 1E00H-2171H, 2177H-22DCH and the length word at 23FEH-23FFH, with its transfer address at 1E00H. The messages are not stored as text. Each error from 0 to 45 has a sentence, which is a list of word numbers held in page 1EH, and the words are in a dictionary of 58 of them, each ended by setting bit 7 of its last character; the message is built a word at a time, with a space after each and a capital on the first letter. Error 63, the extended error, has a line of its own that shows the program's Register Pair HL in hex, and every number from 46 to 62 gives Unknown error code. A program chooses the short display or the long one with bit 6 of the number it passes, and asks to be given control back rather than aborted with bit 7; the long display adds the error number and return address, the file or device the error was about, and the number and return address of the supervisor call before it.
Every instruction of this file is the same instruction at the same address in LS-DOS 6.3.1, and the two files differ only in the twenty bytes of the copyright record, which is never loaded. MISOSYS left the error dictionary alone. Six bugs are recorded against it, T13 to T18, of which the one worth knowing is that the long display of an extended error shows its own line and nothing else, so the error number and the program's return address never reach the screen.
Disassembly:
A disassembly of SYS4/SYS can be found here.
SYS5/SYS
Purpose:
SYS5/SYS is the resident part of the debugger that the DEBUG command turns on and @DEBUG (SVC 27) calls, the one Logical Systems called the ghost debugger because it is read into the overlay area over whatever was there and leaves nothing behind. It is a load module of 1536 bytes, 1471 of them loaded at 1E00H-23BCH and the length word at 23FEH-23FFH, with its transfer address at 1E00H. Every entry saves the program's twenty registers into low memory at 00A8H-00BFH, puts back any byte a breakpoint replaced, and draws the register display; from there the single letter commands show and change memory, single step one instruction or run a call in full, fill a range, move the Program Counter, and read and write disk sectors. A breakpoint is an F7H written over the program's own byte, which the Z80 runs as RST 30H.
Every instruction of this file is the same instruction at the same address in LS-DOS 6.3.1, and the two files differ only in the twenty bytes of the copyright record, which is never loaded. Nine bugs are recorded against it, T19 to T27: the two that bite are that single stepping a JP (IX) sets the breakpoint from Index Register IY and so loses the program, and that a disk command with its buffer address left out reads into whatever number was typed last, which with nothing typed at all is 124CH and runs over the resident file routines.
Disassembly:
A disassembly of SYS5/SYS can be found here.
SYS6/SYS
Purpose:
Library A: MEMORY, DIR, COPY, LIB, REMOVE, RENAME, DEVICE, ROUTE, LINK, RESET, SET, LIST, DO and LOAD, fourteen members in one file.
Disassembly:
The disassembly of SYS6/SYS is in progress.
SYS7/SYS
Purpose:
Library B: FREE, DATE with TIME, DEBUG, ATTRIB, PURGE, DUMP, CREATE, AUTO and BUILD, nine members in one file.
Disassembly:
The disassembly of SYS7/SYS is in progress.
SYS8/SYS
Purpose:
Library C, the machine specific commands: SYSTEM, SYSGEN, FORMS, SETCOM, SETKI and SPOOL.
Disassembly:
The disassembly of SYS8/SYS is in progress.
SYS9/SYS
Purpose:
The extended debugging commands, available after DEBUG (EXT).
Disassembly:
The disassembly of SYS9/SYS is in progress.
SYS10/SYS
Purpose:
SYS10/SYS is @REMOVE (SVC 57), the only way this system has of deleting a file. It is a load module of 257 bytes, 212 of them loaded at 1E00H-1ED1H and the length word at 23FEH-23FFH, with its transfer address at 1E00H, and it is the smallest overlay of the system but for SYS13. A program opens the file and calls @REMOVE with Register Pair DE at the FCB; the REMOVE and PURGE commands, SYSGEN, BACKUP/CMD, CONV/CMD and BASIC's KILL all go through it. It checks that the file was opened with FULL or REMOVE access, reads the GAT, then walks the file's primary directory entry and every extended entry it links to, clearing each extent's granules in the GAT copy, marking the entry spare and releasing its slot in the HIT; the GAT is written once at the end. The granule bits are cleared by an instruction the code writes for itself, a RES n,B built from the granule number.
Every instruction of this file is the same instruction at the same address in LS-DOS 6.3.1, and the two files differ only in the twenty bytes of the copyright record, which is never loaded. The routine was written in February 1983 and never changed again. Two bugs are recorded against it, T28 and T29: a disk error part way through leaves a file half removed with its space still allocated, and an entry is freed without any test that it is still the file's, so an FCB held across a removal or a diskette change deletes whatever file now holds that directory entry code.
Disassembly:
A disassembly of SYS10/SYS can be found here.
SYS11/SYS
Purpose:
The execution phase of the Job Control Language.
Disassembly:
The disassembly of SYS11/SYS is in progress.
SYS12/SYS
Purpose:
The @DODIR and @RAMDIR directory services.
Disassembly:
The disassembly of SYS12/SYS is in progress.
SYS13/SYS
Purpose:
SYS13/SYS is the place the system keeps a program of the user's own to run in place of a command. The Model 4 manual calls it an Immediate Execution Program and has the owner install one by copying a /CMD file over SYS13/SYS; the file's own messages, and Logical Systems afterwards, call the same thing an Extended Command Interpreter. It is a load module of 700 bytes, 651 of them loaded at 1E00H-208AH with its transfer address at 1E00H, and 532 of those 651 are zero bytes kept as room for the program. It is the only overlay with no length word at 23FEH-23FFH, which is why SYSTEM (SYSRES=13) refuses it. As the release ships there is no program in it, only two messages that say so: a command line beginning with an asterisk gets No command <*> present, as SYS13, and a request from the Ready prompt, which comes only when EFLAG$ has been set, gets No Extended Command Interpreter Present, as SYS13.
SYS13 is new at 6.2. On all four of the 6.0 and 6.1 diskettes the file exists with a length of zero. Every instruction of this file is the same instruction at the same address in LS-DOS 6.3.1, and the two files differ only in the twenty bytes of the copyright record; two bytes of the messages were themselves patched during 6.2, Level AH spelling the word Interpretor and ending each line with an exclamation mark where Level AN and Level AR spell it Interpreter and end with a space. Two bugs are recorded against it, T30 and T31: the address of the message is left in Register Pair HL as the return code, which aborts a DO job, and an EFLAG$ whose top bits are set makes the message repeat without end.
Disassembly:
A disassembly of SYS13/SYS can be found here.
BASIC/CMD
Purpose:
Disk BASIC for the Model 4, one module loading 3000H-82FFH with its transfer address at 8048H.
Disassembly:
The disassembly of BASIC/CMD is in progress.
BASIC/OV1
Purpose:
BASIC/OV1 is the arithmetic and function package of Disk BASIC, a load module of 2604 bytes loaded whole at 2600H-2FFFH with its transfer address at 2600H. BASIC/CMD branches into it in 230 places, and it holds the single and double precision addition, multiplication and division with their normalising, rounding and shifting; the logarithm with its two coefficient tables and LOG under it; the sign of a value, the accumulator moved four ways and the three comparisons; CINT, CSNG, CDBL, FIX, INT and the whole of the integer arithmetic; and the reading of a number out of the text of a BASIC line. There is no source for it in any of the five trees the project holds, so every row of its page was read from the bytes.
This is the one file of the release that is byte for byte identical to LS-DOS 6.3.1H's, all 2604 bytes of it, the load records and the copyright record included. It reached that form at 6.2.1 and not before: Level AH's differs in 137 operands and 59 instructions that have no counterpart at all, so the arithmetic was still being worked on through the 6.2.0 sub-levels. Level AR settled it, and nothing touched it again in the seven years to LS-DOS 6.3.1H. No bugs are recorded against it.
Disassembly:
A disassembly of BASIC/OV1 can be found here.
BACKUP/CMD
Purpose:
Copies diskettes: mirror image, by class, and reconstruct.
Disassembly:
The disassembly of BACKUP/CMD is in progress.
COMM/CMD
Purpose:
The communications (terminal) program.
Disassembly:
The disassembly of COMM/CMD is in progress.
CONV/CMD
Purpose:
Copies files from a Model III TRSDOS or LDOS diskette.
Disassembly:
The disassembly of CONV/CMD is in progress.
FORMAT/CMD
Purpose:
Formats a diskette, and writes BOOT/SYS and the directory.
Disassembly:
The disassembly of FORMAT/CMD is in progress.
HELP/CMD
Purpose:
Shows the help screens kept in DOS/HLP. New at 6.2, and its module name is HELP62.
Disassembly:
The disassembly of HELP/CMD is in progress.
LOG/CMD
Purpose:
Logs in a diskette after it has been changed in a drive.
Disassembly:
The disassembly of LOG/CMD is in progress.
PATCH/CMD
Purpose:
Applies a patch to a program or a system file, in memory load or direct disk mode.
Disassembly:
The disassembly of PATCH/CMD is in progress.
REPAIR/CMD
Purpose:
Brings the directory of a diskette back into the shape the system expects.
Disassembly:
The disassembly of REPAIR/CMD is in progress.
TAPE100/CMD
Purpose:
Moves files to and from cassette in the format of the TRS-80 Model 100.
Disassembly:
The disassembly of TAPE100/CMD is in progress.
COM/DVR
Purpose:
The RS-232 serial driver.
Disassembly:
The disassembly of COM/DVR is in progress.
CLICK/FLT
Purpose:
The keyboard click filter.
Disassembly:
The disassembly of CLICK/FLT is in progress.
FORMS/FLT
Purpose:
The printer forms filter: page length, margins and line spacing.
Disassembly:
The disassembly of FORMS/FLT is in progress.
KSM/FLT
Purpose:
The KeyStroke Multiply filter: a phrase for each ALPHA key.
Disassembly:
The disassembly of KSM/FLT is in progress.
FLOPPY/DCT
Purpose:
The floppy disk drive table for added drives; it loads at 2C00H.
Disassembly:
The disassembly of FLOPPY/DCT is in progress.
MEMDISK/DCT
Purpose:
The memory disk driver, which turns spare memory into a drive; it loads at 2C00H.
Disassembly:
The disassembly of MEMDISK/DCT is in progress.