TRS-80 DOS - TRSDOS v2.3 for the Model I - SYS4/SYS Disassembled
Page Customization
Page Index
SYS4/SYS
Other Navigation
Introduction/Summary
TRSDOS v2.3 SYS4/SYS Disassembly - Error Messages (Model I)
SYS4/SYS is the TRSDOS 2.3 system overlay that turns an error number into the message the person sees. SYS0/SYS loads it into the overlay area at 4E00H whenever an RST 28H code with 6 in bits 0-3 is executed. The error code is passed on the stack: bits 0-5 are the error number, bit 6 asks for the message text with no framing, and bit 7 makes SYS4/SYS return to the program that raised the error instead of going to DOS READY. The message itself is built from a dictionary of words, so the 62 messages fit in about 400 bytes.
The file holds 1,011 bytes in four load records covering 4E00H-51F2H, after a name record and a 169-byte copyright comment record; its transfer address is 4E00H. The code is 4E00H-4F35H and the rest is message data. Every byte is shown once on this page, in address order, checked against S:\1\SYS4.SYS and its listing.
Memory Map
| Address Range | Use |
|---|---|
| 4E00H-4E72H 115 bytes | Build and display a message, then return to the caller or to 4030H. |
| 4E73H-4F1AH 168 bytes | The DEVICE or FILE line and the REFERENCED AT line. |
| 4F1BH-4F35H 27 bytes | Display a word or a byte as hexadecimal digits. |
| 4F36H-4F83H 78 bytes | The fixed parts of the display: ERRCOD, DEVICE, FILE and REFERENCED AT. |
| 4F84H-4FC1H 62 bytes | One message offset per error number 00H-3DH. |
| 4FC2H-502FH 110 bytes | The address of each word in the dictionary. |
| 5030H-515AH 299 bytes | The words the messages are built from. |
| 515BH-51F2H 152 bytes | The word list for each message. |
How a Message Is Shown
SYS4/SYS first shows *** ERRCOD=nn, with the error number in decimal, unless bit 6 of the error code asked for the text only. It then looks the error number up in the offset table at 4F84H, which points into the word lists at 5100H. Each byte of a word list is a word number; the word's text is found through the address table at 4FC2H and sent to the display with a space after it, until the byte whose bit 7 marks the last word. For a full message it then shows a second and third line naming the file or device involved and the address that made the call, and finally an ENTER.
The DEVICE, FILE and REFERENCED AT Lines
When bit 6 of a message's last word byte is set, the error names a file or a device: SYS4/SYS reads the file control block SYS0/SYS recorded at 430AH and shows <FILE=name/ext:d> for an open file (building the name from its directory entry) or the filespec text the block already holds, or <DEVICE=*xx> for a device name. Otherwise it shows <DEVICE=> with the drive and locator from the block. The REFERENCED AT line shows the address at 430CH, less three, as four hexadecimal digits: the instruction that made the file call.
Notes from the Code
- The error number in the ERRCOD line is shown in decimal (4E14H divides by ten), while the REFERENCED AT address is shown in hexadecimal.
- The messages are stored as lists of word numbers into a 53-word dictionary, so a word such as ERROR or DURING is held once and shared by many messages.
- Error numbers 27H and above all share one word list, UNKNOWN ERROR CODE, at 51F0H.
- Bit 7 of the error code makes SYS4/SYS return to the caller; the return address is saved into the JP M at 4E6DH as the overlay starts.
- The error lines are indented with Model I video space compression bytes (C6H, C5H and C3H display six, five and three spaces).
Variables
Self-Modified Operands
| Address | Purpose |
|---|---|
| 4E6EH-4E6FH 2 bytes | Operand of JP M at 4E6DH: the caller's return address, saved at 4E01H. |
| 4F42H-4F43H 2 bytes | The two decimal digits of the error number in the ERRCOD line (set at 4E20H). |
| 4F55H-4F56H 2 bytes | The two characters of the device code in the DEVICE line (set at 4E94H). |
Addresses Outside SYS4/SYS
| Address Range | Use |
|---|---|
| 430AH-430BH 2 bytes | The file control block address SYS0/SYS's file call set-up recorded (4E7DH). |
| 430CH-430DH 2 bytes | The return address of the file call, shown less three on the REFERENCED AT line (4F0CH). |
| 4200H-42FFH 256 bytes | Directory sector read by SYS0/SYS's 4AC1H to name an open file. |
| 4030H 3 bytes | The exit after an error, taken when bit 7 of the error code is clear (4E70H). |
| 0033H ROM | Display one character, used for every character of the message. |
| 4467H, 4AC1H SYS0/SYS | Display a message, read a directory sector. |
Disassembly
4E00H - Display an Error Message (code 86H)
SYS0/SYS's overlay call enters SYS4/SYS here. The error code is on the stack above the overlay call's return address; Register A is the RST 28H code. Bits 0-5 of the error code are the error number, bit 6 asks for the message text only (no *** ERRCOD= prefix and no DEVICE, FILE or REFERENCED AT lines), and bit 7 makes SYS4/SYS return to the caller instead of jumping to 4030H. The message is built from a dictionary of words and sent to the display.
Load Register E with 30H, the digit 0, the tens digit so far.
SUBtract 0AH (ten) from Register A (the error number). 4E1BH loops back here.
Point Register Pair HL to 4F84H, the table of one offset byte per error number. 4E12H comes here.
Fetch a word byte from (HL) (Register Pair HL = the word list) into Register A. 4E5AH loops back here.
Fetch a character of the word from (HL) (Register Pair HL = the word's text) into Register A. 4E4FH loops back here.
DECrement Register B and LOOP BACK to 4E4AH until the word is printed.
If the NO CARRY FLAG is set (not the last word), LOOP BACK to 4E31H.
0000H in the file.
Save Register Pair HL (the word list pointer past the message) onto the stack. 4E60H calls here.
Fetch byte 00H of the FCB from (IX+00H) (Index Register IX = the FCB) into Register A. 4E84H comes here.
PUSH Index Register IX (the FCB) onto the stack. 4EA5H comes here.
Fetch a character of the filespec from (HL) (Register Pair HL = the FCB) into Register A. 4EC0H loops back here.
DECrement Register B and LOOP BACK to 4EB8H until 24 characters or the end.
GOSUB to SYS0/SYS's 4AC1H to read the directory entry with locator Register B of drive Register C into 4200H; Register Pair HL = the entry. 4E90H comes here.
Fetch a name character from (HL) (Register Pair HL = the entry's name) into Register A. 4ED8H loops back here.
DECrement Register B and LOOP BACK to 4ED0H until eight characters.
Fetch an extension character from (HL) (Register Pair HL = the extension field) into Register A. 4EECH loops back here.
DECrement Register B and LOOP BACK to 4EE4H until three characters.
Store 3EH, the closing angle bracket, into the template at (HL) (Register Pair HL = the name field). 4EBBH and 4EC2H come here.
Point Register Pair HL to 4F70H, the template REFERENCED AT X' up to its 03H. 4E9EH comes here.
Copy Register H (the high byte) into Register A. 4F12H calls here.
Save Register Pair AF (Register A = the byte) onto the stack. 4F1CH calls here.
AND Register A with 0FH, keeping the low four bits. 4F25H calls here.
4F36H - Message Text
The fixed parts of the error display, the table of word addresses, the table of one message offset per error number, the words and the per-error word lists. The error lines are indented with Model I video space compression bytes (a byte of C0H plus n displays n spaces). Nothing here is executed.
A line feed, the heading with two digit places, a comma and a space; 4E24H displays it and 4E20H stores the two decimal digits at 4F42H.
An ENTER ends it; 4E74H displays this short heading before the DEVICE or FILE line.
The C6H byte displays six spaces; the device code is stored in the two characters at 4F55H by 4E94H, and an ENTER ends the line.
The C5H byte displays five spaces; the name field at 4F60H follows this heading with no separator between them.
Filled in by 4EAFH to 4EFCH with the file name, a closing bracket and an ENTER; the bytes here are whatever a previous error left behind.
The C3H byte displays three spaces; 4F09H displays up to the 03H, the address follows as four hexadecimal digits, and 4F82H adds the closing quote and an ENTER.
4F84H - Message Offset Table
One byte for each error number from 00H to 3DH: the low byte of that error word list, which starts at 5100H plus the byte. 4E2AH reads it with the error number in Register Pair BC. Every error number from 22H upward points at 51F0H, the UNKNOWN ERROR CODE list.
The low byte into 5100H of the word list for each of these error numbers.
The low byte into 5100H of the word list for each of these error numbers.
The low byte into 5100H of the word list for each of these error numbers.
The low byte into 5100H of the word list for each of these error numbers.
The low byte into 5100H of the word list for each of these error numbers.
The low byte into 5100H of the word list for each of these error numbers.
The low byte into 5100H of the word list for each of these error numbers.
The low byte into 5100H of the word list for each of these error numbers.
4FC2H - Word Address Table
Two bytes for each word: the address of its text at 5030H and beyond. 4E39H reads the entry for a word and the following entry to work out the word length, so the words need no separators.
A placeholder entry; no error message refers to word number 0 in its word list.
One of the words the error messages are built from, used in the messages for errors 00H, 21H.
One of the words the error messages are built from, used in the messages for errors 00H, 01H, 02H, 04H, 09H, 0AH and more.
One of the words in the dictionary, not referenced by any current error message.
One of the words the error messages are built from, used in the messages for errors 01H, 04H, 09H, 0CH.
One of the words the error messages are built from, used in the messages for errors 01H, 02H, 03H, 04H, 05H, 09H and more.
One of the words the error messages are built from, used in the messages for errors 01H, 09H.
One of the words the error messages are built from, used in the messages for errors 03H, 05H, 06H, 07H, 0BH, 0DH.
One of the words the error messages are built from, used in the messages for errors 02H, 0AH.
One of the words the error messages are built from, used in the messages for errors 01H, 02H, 03H, 04H, 05H, 06H and more.
One of the words the error messages are built from, used in the messages for errors 09H, 0AH, 0BH, 0CH, 0DH, 0EH and more.
One of the words the error messages are built from, used in the messages for errors 03H, 0BH.
One of the words the error messages are built from, used in the messages for errors 05H, 08H, 0DH, 18H, 1FH, 26H.
One of the words the error messages are built from, used in the messages for errors 06H, 07H, 24H, 25H.
One of the words the error messages are built from, used in the messages for errors 06H.
One of the words the error messages are built from, used in the messages for errors 07H.
One of the words the error messages are built from, used in the messages for errors 11H, 12H, 18H, 1AH, 1EH.
One of the words the error messages are built from, used in the messages for errors 23H, 24H.
One of the words the error messages are built from, used in the messages for errors 0EH.
One of the words the error messages are built from, used in the messages for errors 0EH, 1BH.
One of the words the error messages are built from, used in the messages for errors 0FH.
One of the words the error messages are built from, used in the messages for errors 0EH, 23H.
One of the words the error messages are built from, used in the messages for errors 0FH, 25H.
One of the words the error messages are built from, used in the messages for errors 10H, 13H, 20H, 25H.
One of the words the error messages are built from, used in the messages for errors 10H.
One of the words the error messages are built from, used in the messages for errors 10H, 1DH, 20H.
One of the words the error messages are built from, used in the messages for errors 10H, 13H, 18H, 19H, 1CH, 1EH and more.
One of the words the error messages are built from, used in the messages for errors 05H, 06H, 07H, 0DH, 1DH.
One of the words the error messages are built from, used in the messages for errors 1CH.
One of the words the error messages are built from, used in the messages for errors 1CH, 1DH.
One of the words the error messages are built from, used in the messages for errors 1DH.
One of the words the error messages are built from, used in the messages for errors 1DH.
One of the words the error messages are built from, used in the messages for errors 1CH.
One of the words the error messages are built from, used in the messages for errors 27H, 28H, 29H, 2AH, 2BH, 2CH and more.
One of the words the error messages are built from, used in the messages for errors 14H, 15H.
One of the words the error messages are built from, used in the messages for errors 16H, 17H.
One of the words in the dictionary, not referenced by any current error message.
One of the words the error messages are built from, used in the messages for errors 27H, 28H, 29H, 2AH, 2BH, 2CH and more.
One of the words the error messages are built from, used in the messages for errors 22H, 24H.
One of the words the error messages are built from, used in the messages for errors 1AH, 1BH, 21H.
One of the words the error messages are built from, used in the messages for errors 24H.
One of the words the error messages are built from, used in the messages for errors 13H.
One of the words the error messages are built from, used in the messages for errors 08H, 21H.
One of the words the error messages are built from, used in the messages for errors 22H.
One of the words the error messages are built from, used in the messages for errors 05H, 0DH, 1FH.
One of the words the error messages are built from, used in the messages for errors 18H.
One of the words the error messages are built from, used in the messages for errors 19H, 25H.
One of the words the error messages are built from, used in the messages for errors 1AH, 1BH, 1EH.
One of the words the error messages are built from, used in the messages for errors 0EH, 20H.
One of the words the error messages are built from, used in the messages for errors 19H.
One of the words the error messages are built from, used in the messages for errors 1FH.
One of the words the error messages are built from, used in the messages for errors 08H, 21H.
One of the words the error messages are built from, used in the messages for errors 1EH.
One of the words the error messages are built from, used in the messages for errors 26H.
515BH, one past the last word, so the last word length can be found the same way.
5030H - The Words
The text of every word the error messages are built from, run together with no separators between them; the word address table at 4FC2H marks where each word begins and ends.
One of the words the error messages are built from, used in the messages for errors 00H, 21H.
One of the words the error messages are built from, used in the messages for errors 00H, 01H, 02H, 04H, 09H, 0AH and more.
One of the words in the dictionary, not referenced by any current error message.
One of the words the error messages are built from, used in the messages for errors 01H, 04H, 09H, 0CH.
One of the words the error messages are built from, used in the messages for errors 01H, 02H, 03H, 04H, 05H, 09H and more.
One of the words the error messages are built from, used in the messages for errors 01H, 09H.
One of the words the error messages are built from, used in the messages for errors 03H, 05H, 06H, 07H, 0BH, 0DH.
One of the words the error messages are built from, used in the messages for errors 02H, 0AH.
One of the words the error messages are built from, used in the messages for errors 01H, 02H, 03H, 04H, 05H, 06H and more.
One of the words the error messages are built from, used in the messages for errors 09H, 0AH, 0BH, 0CH, 0DH, 0EH and more.
One of the words the error messages are built from, used in the messages for errors 03H, 0BH.
One of the words the error messages are built from, used in the messages for errors 05H, 08H, 0DH, 18H, 1FH, 26H.
One of the words the error messages are built from, used in the messages for errors 06H, 07H, 24H, 25H.
One of the words the error messages are built from, used in the messages for errors 06H.
One of the words the error messages are built from, used in the messages for errors 07H.
One of the words the error messages are built from, used in the messages for errors 11H, 12H, 18H, 1AH, 1EH.
One of the words the error messages are built from, used in the messages for errors 23H, 24H.
One of the words the error messages are built from, used in the messages for errors 0EH.
One of the words the error messages are built from, used in the messages for errors 0EH, 1BH.
One of the words the error messages are built from, used in the messages for errors 0FH.
One of the words the error messages are built from, used in the messages for errors 0EH, 23H.
One of the words the error messages are built from, used in the messages for errors 0FH, 25H.
One of the words the error messages are built from, used in the messages for errors 10H, 13H, 20H, 25H.
One of the words the error messages are built from, used in the messages for errors 10H.
One of the words the error messages are built from, used in the messages for errors 10H, 1DH, 20H.
One of the words the error messages are built from, used in the messages for errors 10H, 13H, 18H, 19H, 1CH, 1EH and more.
One of the words the error messages are built from, used in the messages for errors 05H, 06H, 07H, 0DH, 1DH.
One of the words the error messages are built from, used in the messages for errors 1CH.
One of the words the error messages are built from, used in the messages for errors 1CH, 1DH.
One of the words the error messages are built from, used in the messages for errors 1DH.
One of the words the error messages are built from, used in the messages for errors 1DH.
One of the words the error messages are built from, used in the messages for errors 1CH.
One of the words the error messages are built from, used in the messages for errors 27H, 28H, 29H, 2AH, 2BH, 2CH and more.
One of the words the error messages are built from, used in the messages for errors 14H, 15H.
One of the words the error messages are built from, used in the messages for errors 16H, 17H.
One of the words in the dictionary, not referenced by any current error message.
One of the words the error messages are built from, used in the messages for errors 27H, 28H, 29H, 2AH, 2BH, 2CH and more.
One of the words the error messages are built from, used in the messages for errors 22H, 24H.
One of the words the error messages are built from, used in the messages for errors 1AH, 1BH, 21H.
One of the words the error messages are built from, used in the messages for errors 24H.
One of the words the error messages are built from, used in the messages for errors 13H.
One of the words the error messages are built from, used in the messages for errors 08H, 21H.
One of the words the error messages are built from, used in the messages for errors 22H.
One of the words the error messages are built from, used in the messages for errors 05H, 0DH, 1FH.
One of the words the error messages are built from, used in the messages for errors 18H.
One of the words the error messages are built from, used in the messages for errors 19H, 25H.
One of the words the error messages are built from, used in the messages for errors 1AH, 1BH, 1EH.
One of the words the error messages are built from, used in the messages for errors 0EH, 20H.
One of the words the error messages are built from, used in the messages for errors 19H.
One of the words the error messages are built from, used in the messages for errors 1FH.
One of the words the error messages are built from, used in the messages for errors 08H, 21H.
One of the words the error messages are built from, used in the messages for errors 1EH.
One of the words the error messages are built from, used in the messages for errors 26H.
515BH - Message Word Lists
One list for each distinct message: the word numbers that make it up, in order. In each byte bits 0-5 are the word number, bit 6 is set when the error names a file or device the FCB holds, and bit 7 is set on the last word. 4E31H walks the list and the offset table at 4F84H points into it.
NO ERROR, from word numbers in these bytes.
PARITY ERROR DURING HEADER READ, from word numbers in these bytes.
SEEK ERROR DURING READ, from word numbers in these bytes.
LOST DATA DURING READ, from word numbers in these bytes.
PARITY ERROR DURING READ, from word numbers in these bytes.
DATA RECORD NOT FOUND DURING READ, from word numbers in these bytes.
ATTEMPTED TO READ LOCKED/DELETED DATA RECORD, from word numbers in these bytes.
ATTEMPTED TO READ SYSTEM DATA RECORD, from word numbers in these bytes.
DEVICE NOT AVAILABLE, from word numbers in these bytes.
PARITY ERROR DURING HEADER WRITE, from word numbers in these bytes.
SEEK ERROR DURING WRITE, from word numbers in these bytes.
LOST DATA DURING WRITE, from word numbers in these bytes.
PARITY ERROR DURING WRITE, from word numbers in these bytes.
DATA RECORD NOT FOUND DURING WRITE, from word numbers in these bytes.
WRITE FAULT ON DISK DRIVE, from word numbers in these bytes.
WRITE PROTECTED DISKETTE, from word numbers in these bytes.
ILLEGAL LOGICAL FILE NUMBER, from word numbers in these bytes.
DIRECTORY READ ERROR, from word numbers in these bytes.
DIRECTORY WRITE ERROR, from word numbers in these bytes.
ILLEGAL FILE NAME, from word numbers in these bytes.
GAT READ ERROR, from word numbers in these bytes.
GAT WRITE ERROR, from word numbers in these bytes.
HIT READ ERROR, from word numbers in these bytes.
HIT WRITE ERROR, from word numbers in these bytes.
FILE NOT IN DIRECTORY, from word numbers in these bytes.
FILE ACCESS DENIED, from word numbers in these bytes.
DIRECTORY SPACE FULL, from word numbers in these bytes.
DISK SPACE FULL, from word numbers in these bytes.
END OF FILE ENCOUNTERED, from word numbers in these bytes.
RECORD NUMBER OUT OF RANGE, from word numbers in these bytes.
DIRECTORY FULL CAN'T EXTEND FILE, from word numbers in these bytes.
PROGRAM NOT FOUND, from word numbers in these bytes.
ILLEGAL DRIVE NUMBER, from word numbers in these bytes.
NO DEVICE SPACE AVAILABLE, from word numbers in these bytes.
LOAD FILE FORMAT ERROR, from word numbers in these bytes.
MEMORY FAULT, from word numbers in these bytes.
ATTEMPTED TO LOAD READ ONLY MEMORY, from word numbers in these bytes.
ILLEGAL ACCESS ATTEMPTED TO PROTECTED FILE, from word numbers in these bytes.
FILE NOT OPEN, from word numbers in these bytes.
UNKNOWN ERROR CODE, the list every error number from 27H upward uses.