SYS4/SYS is the TRSDOS 1.3 error handler overlay. It is loaded at 4E00H by the SYS0 resident ERROR entry point at 4409H (via DO 00,4) whenever a DOS or BASIC operation posts an error code on the stack. The overlay decodes the error code, prints either a short numeric message ("* * ERROR nn * *") or a detailed word-based English message, then either returns to the DOS prompt (via ABORT at 4030H) or reboots (via JP 0000H), depending on bit 7 of the error code.
On entry to SYS4, Register A holds the error code with meaning encoded in three fields: bits 0–5 are the numeric error code (0–63), bit 6 selects detailed (1) versus short (0) message format, and bit 7 selects return-to-calling-program (1) versus return-to-DOS (0). If the system's DO-file chaining flag (DOFLAG at 4CFDH) is active, SYS4 first aborts the DO file — clearing DOFLAG, forcing return-to-DOS by masking bit 7, restoring the keyboard driver vector from GOSAVE, and resetting the end-of-memory pointer from the backup — before proceeding to the normal error-display path.
The overlay contains two parallel lookup tables that together implement the error messages. TABLE2 at 4E9BH is the word dictionary: 66 English words (NO, ERROR, FOUND, CRC, DURING, READ, SEEK, LOST, DATA, RECORD, NOT, ATTEMPT, SYSTEM, DISK, DRIVE, READY, WRITE, FAULT, ON, PROTECTED, ILLEGAL, LOGICAL, FILE, NUMBER, DIRECTORY, IMPROPER, NAME, GAT, HIT, IN, ACCESS, DENIED, DUE TO, PASSWORD, PROTECTION, SPACE, FULL, PAST EOF, OUTSIDE OF, LIMITS, MORE, EXTENTS, OPEN, PROGRAM, AVAILABLE, USE, AS A, MEMORY, LOAD, I/O, UNOPEN, INVALID, COMMAND PARAMETER, REQUIRED, ALREADY, SECTOR, UNDEFINED ERROR CODE, TIME OUT, RS-232, ACTIVE, RECEIVE, TRANSMIT, NON, TO, HARDWARE, LENGTH) each with bit 7 set on its first character to mark word boundaries. TABLE1 at 502BH is the per-error word-index list: each error entry starts with a byte whose bit 7 is set, followed by zero or more continuation bytes, each byte naming a word number from TABLE2. Errors 7, 33, and 36 are unfilled slots that display the literal UNDEFINED ERROR CODE text, and errors 43–63 are filled from 50D1H to 50E5H with a repeating UNDFN+80H pattern.