TRS-80 DOS - NEWDOS/80 v2.0 for the Model I - SYS4/SYS Disassembled
Page Customization
Page Index
SYS4/SYS
Other Navigation
Introduction:
SYS4/SYS is a multi-purpose NEWDOS/80 overlay module that provides error message handling, queue management, system configuration, and directory display functions. The overlay loads at address 4D00H and occupies memory through 51E7H.
Error Message System: The primary function of SYS4 is displaying DOS error messages. To conserve memory, error messages use a compressed word-based encoding scheme. A vocabulary of approximately 90 common words (such as "ERROR", "FILE", "DISK", "ILLEGAL", etc.) is stored in a lookup table starting at 4E75H. Each error message is encoded as a sequence of 1-byte word indices, with bit 7 set on the final word to mark the end of the phrase. This compression allows complex error messages like "ILLEGAL INITIALIZATION DATA ON SYSTEM DISKETTE" to be stored in just 6 bytes instead of the full 44-character string.
Command Dispatch: Entry at 4D00H examines Register A for command codes: 25H (display error message), 45H (file operation setup), 65H (queue add), 85H (queue remove), A5H (screen dump), C5H (file query), and E5H (system configuration with sub-functions in Register C).
Queue Management: Functions at 4D47H and 4D55H implement a singly-linked list for managing system queues. The queue head pointer is stored at 4584H, with each queue entry containing a 2-byte forward pointer to the next entry.
System Configuration: The E5H command provides sub-functions (selected by Register C) to toggle various system flags: keyboard echo control (401CH), display routing (4019H), error suppression (4289H), and debug hook installation (4478H-447AH).
Directory Display: Function 503AH implements the DIR command processing, scanning directory sectors and displaying file entries with optional password filtering. The display prompt "KILL IT? (Y/N/Q)" at 5144H supports file deletion confirmation.
Screen Dump: Function 515FH at command code A5H provides a screen memory dump utility, reading video RAM at 3C00H and outputting displayable characters while converting graphics characters to periods.
Variables:
| Address | Bytes | Purpose |
|---|---|---|
| 4019H | 1 | Display routing flag. Bit 0: when set, routes output to alternate destination. |
| 401CH | 1 | Keyboard echo flag. Bit 0: when set, enables keyboard character echo. |
| 427EH | 1 | Current drive number for error message display. |
| 4288H | 1 | System status flag, cleared during error message processing. |
| 4289H | 1 | Error control flag. Bit 7: when set, suppresses error message display. |
| 428BH | 1 | System control flags. Bit 2: when set, bypasses filename display in error messages. |
| 4290H | 1 | Maximum displayable character code for screen dump function. |
| 431FH | 1 | Track count offset used in DIR command sector calculations. |
| 4478H-447AH | 3 | Debug hook vector. First byte is opcode (C3H=JP or C9H=RET), followed by 2-byte address at 4479H. |
| 4480H | 1 | Directory operation control flag. |
| 4487H | 1 | Current directory slot pointer for DIR command processing. |
| 4584H-4585H | 2 | Queue head pointer. Points to first entry in linked list, or 0000H if queue is empty. |
| 4A2DH | 1 | IX prefix configuration byte. Set to DDH for IX mode or 00H for normal mode. |
| 4A2EH-4A2FH | 2 | Index register offset configuration. Set to 017EH or FF3EH depending on mode. |
| 4D00H-4DBFH | 192 | Scratch buffer area. Used as bitmap workspace during KILL operations (C0H bytes). |
| 4DC0H-4DDFH | 32 | Secondary scratch buffer area (20H bytes) for granule allocation tracking. |
| 4EA1H | 1 | Current directory entry low-byte position within sector buffer. |
| 4FB8H | 1 | Error display mode flag. 00H=normal error display, 01H=alternate processing mode. |
| 5130H | 1 | Computed track count for DIR command processing. |
| 5140H | 1 | DIR command filter flags. Bit 0: password filter active, Bit 1: USR filter active. |
| 5141H-5143H | 3 | Password filter string for DIR command (3 characters). |
| 5144H-515EH | 27 | DIR command prompt string: "KILL IT? (Y/N/Q)" with trailing spaces and ETX terminator. |
Disassembly
4D00H - Error Message Handler Entry Point
This is the entry point for SYS4/SYS, the NEWDOS/80 error message handler. Register A contains either a command code or an error code. The routine checks for special codes first, then displays the appropriate error message from a compressed message table stored at 4D84H. Word components are stored separately at 4E74H and combined to form complete error messages.
The code did not return, so A contains something other than E6H. Now check if A is 46H (ASCII F), which indicates a FORMAT command context.
A = 46H (ASCII F), indicating this is being called during FORMAT command processing. Set bit 2 of the DOS system flags at 436AH to remember this state.
Now save the caller's return address for later use. The stack currently contains: [Return Address]. We exchange HL with the stack to capture this address.
Now check if A = 66H (lowercase f), which is another FORMAT-related code that skips certain validity checks.
A was not 66H. Check the DOS system flags to determine if special error handling is needed.
Check additional driver and system flags at 4369H and 436AH to determine if SVC call is appropriate.
Conditions are met for an SVC call. Mask the error code, set up carry flag, and call SVC E3H (SYS1/SYS function 7) with C=07H.
4D3CH - Error Message Lookup and Display
This section looks up the error code in a compressed message table at 4D84H. Each entry in the table contains an index byte (with high bit marking end of index chain) followed by word component indices. Word text is stored separately at 4E74H.
[LOOP START] - Scan through the message table to find the entry for error code B. Each entry is a variable-length sequence of bytes with the high bit (bit 7) set on the last byte of each entry's index portion.
Found the target message entry. Now process the word component indices. Each byte's lower 7 bits specify a word index; bit 7 marks the last component.
[INNER LOOP START] - Scan through the word table to find word number B.
[CHARACTER OUTPUT LOOP] - Output the characters of the found word. Each character has bit 7 clear except the last character which has bit 7 set.
Finished outputting one word. Print a space separator between words.
Check if there are more word components to output for this error message.
4D74H - Error Message Cleanup and Exit
All word components have been displayed. Print a carriage return to end the message line, restore all saved registers, and exit either via system reset (cold boot) or return to DOS Ready.
4D84H - Error Message Index Table (Data)
This is the Error Message Index Table, a data structure used by the error handler at 4D00H. Each entry corresponds to an error code (0-63). Each byte's lower 7 bits specify a word index into the Word Component Table at 4E74H; bit 7 set marks the last word of that error message. The disassembler incorrectly interpreted these bytes as Z80 instructions - they are pure data.
Error Code 00H - Empty/No Message
Error Code 01H - NO ERROR (DOS Error 00H)
Error Code 02H - BAD FILE DATA (DOS Error 01H)
Error Code 03H - SEEK ERROR DURING READ (DOS Error 02H)
Error Code 04H - LOST DATA DURING READ (DOS Error 03H)
Error Code 05H - PARITY ERROR DURING READ (DOS Error 04H)
Error Code 06H - DATA RECORD NOT FOUND DURING READ (DOS Error 05H)
Error Code 07H - TRIED TO READ LOCKED/DELETED RECORD (DOS Error 06H)
Error Code 08H - TRIED TO READ SYSTEM RECORD (DOS Error 07H)
Error Code 09H - DEVICE NOT AVAILABLE (DOS Error 08H)
Error Code 0AH - UNDEFINED ERROR CODE (DOS Error 09H)
Error Code 0BH - SEEK ERROR DURING WRITE (DOS Error 0AH)
Error Code 0CH - LOST DATA DURING WRITE (DOS Error 0BH)
Error Code 0DH - PARITY ERROR DURING WRITE (DOS Error 0CH)
Error Code 0EH - DATA RECORD NOT FOUND DURING WRITE (DOS Error 0DH)
Error Code 0FH - WRITE FAULT ON DISK DRIVE (DOS Error 0EH)
Error Code 10H - WRITE PROTECTED DISKETTE (DOS Error 0FH)
Error Code 11H - DEVICE NOT AVAILABLE (DOS Error 10H)
Error Code 12H - DIRECTORY READ ERROR (DOS Error 11H)
Error Code 13H - DIRECTORY WRITE ERROR (DOS Error 12H)
Error Code 14H -ILLEGAL FILE NAME (DOS Error 13H)
Error Code 15H - TRACK # TOO HIGH (DOS Error 14H)
Error Code 16H - ILLEGAL FUNCTION UNDER DOS-CALL (DOS Error 15H)
Error Code 17H - UNDEFINED ERROR CODE (DOS Error 16H)
Error Code 18H - UNDEFINED ERROR CODE (DOS Error 17H)
Error Code 19H - FILE NOT IN DIRECTORY (DOS Error 18H)
Error Code 1AH - FILE ACCESS DENIED (DOS Error 19H)
Error Code 1BH - DIRECTORY SPACE FULL (DOS Error 1AH)
Error Code 1CH - DISKETTE SPACE FULL (DOS Error 1BH)
Error Code 1DH - END OF FILE ENCOUNTERED (DOS Error 1CH)
Error Code 1EH - PAST END OF FILE (DOS Error 1DH)
Error Code 1FH - DIRECTORY FULL. CAN'T EXTEND FILE (DOS ERROR 1EH)
Error Code 20H - PROGRAM NOT FOUND (DOS Error 1FH)
Error Code 21H - ILLEGAL OR MISSING DRIVE # (DOS Error 20H)
Error Code 22H - NO DEVICE SPACE AVAILABLE (DOS Error 21H)
Error Code 23H - LOAD FILE FORMAT ERROR (DOS Error 22H)
Error Code 24H - MEMORY FAULT (DOS Error 23H)
Error Code 25H - TRIED TO LOAD READ ONLY MEMORY (DOS Error 24H)
Error Code 26H - ILLEGAL ACCESS TRIED TO PROTECTED FILE (DOS Error 25H)
Error Code 27H - FILE NOT OPEN (DOS Error 26H)
Error Code 28H - ILLEGAL INITIALIZATION DATA ON SYSTEM DISKETTE (DOS Error 27H)
Error Code 29H - ILLEGAL DISKETTE TRACK COUNT (DOS Error 28H)
Error Code 2AH - ILLEGAL LOGICAL FILE # (DOS Error 29H)
Error Code 2BH - ILLEGAL DOS FUNCTION (DOS Error 2AH)
Error Code 2CH - ILLEGAL FUNCTION UNDER CHAINING (DOS Error 2BH)
Error Code 2DH - BAD DIRECTORY DATA (DOS Error 2CH)
Error Code 2EH - BAD FCB DATA (DOS Error 2DH)
Error Code 2FH - SYSTEM PROGRAM NOT FOUND (DOS Error 2EH)
Error Code 30H - BAD PARAMETER(S) (DOS Error 2FH)
Error Code 31H - BAD FILESPEC (DOS Error 30H)
Error Code 32H - WRONG DISKETTE RECORD TYPE (DOS Error 31H)
Error Code 33H - BOOT READ ERROR (DOS Error 32H)
Error Code 34H - DOS FATAL ERROR (DOS Error 33H)
Error Code 35H - ILLEGAL KEYWORD OR SEPARATOR OR TERMINATOR (DOS Error 34H)
Error Code 36H - FILE ALREADY EXISTS (DOS Error 35H)
Error Code 37H - COMMAND TOO LONG (DOS Error 36H)
Error Code 38H - DISKETTE ACCESS DENIED (DOS Error 37H)
Error Code 39H - ILLEGAL MINI DOS FUNCTION (DOS Error 38H)
Error Code 3AH - OPERATOR/PROGRAM/PARAMETER REQUIRE FUNCTION TERMINATION (DOS Error 39H)
Error Code 3BH - DATA COMPARE MISMATCH (DOS Error 3AH)
Error Code 3CH - INSUFFICIENT MEMORY (DOS Error 3BH)
Error Code 3DH - INCOMPATIBLE DRIVES OR DISKETTES (DOS Error 3CH)
Error Code 3EH - ASE=N ATTRIBUTE. CAN'T EXTEND FILE (DOS Error 3DH)
Error Code 3FH - CAN'T EXTEND FILE VIA READ (DOS Error 3EH)
Padding bytes between error message table and word lookup table.