TRS-80 DOS - NEWDOS/80 v2.0 for the Model III - SYS4/SYS Disassembled
Page Customization
Page Index
SYS4/SYS
Other Navigation
Introduction/Summary
NEWDOS/80 v2.0 SYS4/SYS Disassembly - The DOS Error Messages (Model III)
SYS4/SYS is the error message overlay. It loads into the overlay area at 4D00H-51E7H (1,256 bytes in five load records, transfer address 4D00H) and is called with LD A,code / RST 28H; the SYS0/SYS dispatcher at 4B67H loads it when 4288H does not already hold its directory slot, 06H. Only 132 bytes are code (4D00H-4D83H); the rest is the message table, the word list and 316 unused bytes of 00H. If SYS4/SYS itself cannot be loaded, SYS0/SYS halts (4BBDH), since no error could be shown.
The page shows every byte of the file once, in address order. The words are stored in upper and lower case, so the messages appear on the display as shown in the table below.
RST 28H Codes Handled by SYS4/SYS
| Code | Called from | Function |
|---|---|---|
| 26H | 4409H | The DOS error exit (manual 3.6): the error code is on the stack. With bit 7 of the code set the message is displayed and SYS4/SYS returns to the caller; without it the message is displayed and the DOS is entered at 402DH, or under DOS-CALL or chaining the error is passed to SYS1/SYS (4D31H) without a message. |
| 46H | SYS0/SYS reset (4DE0H) | An error while the system starts: sets bit 2 of 428AH (4D0BH) and displays the message. |
| 66H | SYS14/SYS 4D4CH | Display the message whatever the DOS state (4D1AH). SYS14/SYS pushes the error code in Register H and calls it. |
| E6H | none found | Return at once (4D02H): the RST 28H only loads SYS4/SYS. E6H is what the overlay loader of SYS6/SYS (568DH-5698H: OR 0E0H / RST 28H) produces for slot 06H. |
| any other | none found | Treated like 26H. |
None found: no other file of this DOS was found to load Register A with that code.
How the Messages Are Stored
The messages are built from 94 words. The word list (4E74H) holds the words one after another, the last character of each with bit 7 set. The message table (4D84H) holds, for each error number in turn, the numbers of its words, the last one with bit 7 set. To find message n, SYS4/SYS counts n + 1 ends from 4D84H (whose 80H is an empty list); to find word n it counts n ends from 4E74H (whose 80H is an empty word). Each word is displayed followed by a space, and the message by a carriage return. Only bits 0-5 of the error code choose the message; the 00H at 4E70H ends the table, so error 3FH gives Undefined Error Code from the list after it.
The Error Messages
Error numbers 09H, 16H and 17H have no message of their own (Undefined Error Code), and 08H and 10H share Device Not Available.
Variables
Memory Used by SYS4/SYS
| Address Size | Contents |
|---|---|
| 4D7FH-4D80H 2 bytes | Return Address (Self-Modifying Code) Operand of the JP M,nnnn at 4D7EH (0000H in the file), stored at 4D0FH: 4BC5H, the return into the SYS0/SYS dispatcher. |
| 402DH 3 bytes | DOS Exit JUMPed to at 4D81H when the caller did not ask for control back. |
| 4289H 1 byte | System Flags Bit 5, a chain file is running, tested at 4D28H. |
| 428AH 1 byte | DOS State Flags Bit 2, an error during the reset, set at 4D0BH and tested at 4D1FH. Bit 6, a DOS-CALL is active, tested at 4D2DH. |
Outside Routines Called
| Address | Contents |
|---|---|
| 0033H | ROM: display the character in Register A (4D61H, 4D6BH, 4D76H). |
| 4BC5H | SYS0/SYS: the end of the RST 28H dispatcher, which RETurns to the caller of the error exit (4D7EH). |
| RST 28H, code E3H | SYS1/SYS function 7 sub-function 7 (its 4D78H), the exit used under DOS-CALL or chaining (4D3BH). |
Disassembly
4D00H - Function Dispatcher and Error Entry
SYS4/SYS is entered here by the SYS0/SYS RST 28H dispatcher (4B67H) with Register A = the RST 28H code (bits 0-4 = 06H, SYS4/SYS's directory slot). The dispatcher has dropped the RST's own return address, so the stack holds 4BC5H (the return into the dispatcher, pushed by its CALL at 4BC2H), then the error word pushed by the caller (Register A = the error code), then the return address of whoever called the error exit. Codes: 26H (function 1) from the DOS error exit 4409H (manual 3.6); 46H (function 2) from the SYS0/SYS reset code (4DE0H) for an error during the reset; 66H (function 3, used by SYS14/SYS at 4D4CH) displays the message whatever the DOS state; E6H (function 7) returns at once, so that an RST 28H with E6H only loads SYS4/SYS. Error code bit 7 set means display the message and return to the caller; otherwise the message is displayed and the DOS is re-entered at 402DH, or, under DOS-CALL or chaining, the error is handed to SYS1/SYS without a message.
4D31H - Hand the Error to SYS1/SYS
Under DOS-CALL or chaining (and bit 7 of the error code clear) the message is not displayed here: the error code is pushed as a word and SYS1/SYS function 7 sub-function 7 (its 4D78H) is called, which drops its return address, takes this word as the result of the command and goes to its exit (4D8BH), where the DOS-CALL or chaining code deals with the error. It does not come back.
4D3CH - Find the Message of the Error
Register A = the error code. The message table at 4D84H holds, for each error number 00H-3EH in turn, a list of word numbers whose last one has bit 7 set; 4D84H itself is an 80H that ends an empty list before error 00H. Counting the ends from 4D84H finds the start of the message. The 00H at 4E70H ends the table: any error number not reached before it (3FH) uses the message after it, UNDEFINED ERROR CODE.
Table Search Loop
Register Pair HL = the next byte of the table, Register B = the list ends still to pass.
4D4DH - Display the Words of the Message
Register Pair HL points to the next word number of the message. The word list at 4E74H holds the words one after another, each ending with a character that has bit 7 set; 4E74H itself is an 80H that ends an empty word 00H. Each word is displayed followed by a space.
Word Loop
Register Pair HL = the word number in the message table.
Word Search Loop
Register B = the word ends still to pass.
Character Loop
4D74H - End the Line and Leave
The message has been displayed. The caller's registers come back; with bit 7 of the error code set the RETurn goes through the dispatcher (4BC5H) to the caller of the error exit, otherwise to the DOS through 402DH.
The operand at 4D7FH-4D80H is 0000H in the file and is stored at 4D0FH.
4D84H - Error Message Table (Data)
One list of word numbers (bits 0-6, into the word list at 4E74H) per error number 00H-3EH, in order; bit 7 set marks the last word of a list. 4D3CH finds a message by counting the list ends from 4D84H. Word 1DH (a period and a space) is followed by the usual space, so messages 1EH and 3DH show two spaces after the period.
4E74H - Word List (Data)
The words of the messages, one after another, each ending with a character that has bit 7 set. 4D54H starts counting word ends at 4E74H, so the word after the n-th end is word n. 4D5EH displays a word with bit 7 dropped and 4D69H adds a space after it.
50ACH - Unused Bytes
The end of the file. Nothing in SYS4/SYS reaches these bytes.