TRS-80 DOS - NEWDOS/80 v2.0 for the Model I - SYS13/SYS Disassembled
Page Customization
Page Index
SYS13/SYS
Other Navigation
Introduction/Summary
NEWDOS/80 v2.0 SYS13/SYS Disassembly - BASIC Error Messages and RENUM, First Part (Model I)
SYS13/SYS holds the texts of all BASIC error messages and the first part of the RENUM command. It loads into the overlay area at 4D00H-51E7H (1,256 bytes in five load records); the transfer address is 4D0CH, as 4D00H-4D0BH are the RENUM parameters. 51CDH-51E7H are unused zero bytes.
BASIC/CMD copies its table of links to 4152H-41E4H; the entry that lands at 41A6H is LD A,2FH / RST 28H (BASIC 680FH). The ROM's error routine calls 41A6H before it prints an error (19ECH), so every BASIC error loads SYS13 and shows the full message text instead of the ROM's two-letter code. RENUM is RST 28H code 4FH from BASIC's direct statement code (SYS18); SYS13 then loads SYS11 for the second part.
The page shows every byte of the file once, in address order.
Error Codes and Messages
Register E holds the ROM's error offset: codes 00H-2EH are the ROM's own (E/2 = the message number), 64H-A6H are Disk BASIC's ((E - 34H)/2). Anything from 2FH to 62H, and any code past the table, shows UNPRINTABLE ERROR. For 9CH-A1H the number of the item (from SYS10) is printed first. The table is on this page at 4D46H; Part 5 of the notes lists the Disk BASIC codes.
Variables
Locations inside SYS13 whose contents change while it runs:
| Address Range | Purpose |
|---|---|
| 4D00H-4D01H 2 bytes | RENUM: the next new line number (000AH in the file; typed value stored at 511AH, counted up at 519FH). |
| 4D02H-4D03H 2 bytes | RENUM: the increment (000AH in the file). |
| 4D04H-4D07H 4 bytes | RENUM: the first and last old line of the range (0000H and FFF9H in the file). |
| 4D08H-4D09H 2 bytes | RENUM: the last new number given (written at 518EH), read by SYS11. |
| 4D0AH-4D0BH 2 bytes | RENUM options U and X (00H, or the letter; written at 5133H). |
Locations outside SYS13 that it reads or writes:
| Address Range | Purpose |
|---|---|
| 409AH 1 byte | The ROM's saved error code for RESUME, cleared for SYNTAX ERROR (4D30H). |
| 40A4H-40A5H 2 bytes | The ROM's pointer to the first program line (515FH, 51C7H). |
| 4317H 1 byte | SYS0's record of the overlay in 4D00H, cleared at 50FFH so SYS13 is reloaded with its default parameters. |
| Program lines link fields | Each line's link field gets its new number (51A5H-51A7H); SYS11 rebuilds the links. |
| 64CAH SYS11's table | 128 entries used by SYS11; its address is passed in Register Pair DE (51C2H). |
RENUM
RENUM [new][,[inc][,[first][,[last]]]][,U][,X] as read by the code: new (default 10) is the first new number, inc (10) the increment, first (0) and last (65529) the range of old lines renumbered. A number typed as 0 is a SYNTAX ERROR, as is RENUM with nothing after it. U only lists the problems SYS11 finds; X reports missing target lines only when they lie inside the range. SYS13 stores each line's new number (or, outside the range, its old number) in the line's link field, checks that every link matches the line, counts the lines and loads SYS11 (SYS11/SYS) with RST 28H 2DH. It clears 4317H first, so a later call of SYS13 reloads it with the default parameters.
Errors: SYNTAX ERROR, 96H CAN'T PROCESS LINE 0 (a line numbered 0), 8CH SEQ # OVERFLOW (a new number above 65529), 72H DOS ERROR (a link that does not match the line). They go through BASIC 5E09H, which rebuilds the links first.
Disassembly
4D00H - RENUM Parameters
Data, not code: twelve bytes at the start of the file. SYS13's RENUM part (50FEH) stores the typed values over the defaults, and SYS11, which loads at 4D0CH over the rest of SYS13, reads them. The file's transfer address is 4D0CH.
4D0CH - Entry: Error Message or RENUM
The SYS0 dispatcher calls 4D0CH with Register A = the RST 28H code. Code 4FH (function 2) is RENUM. Code 2FH (function 1) comes from BASIC's link at 41A6H (BASIC 680FH copied there), which the ROM's error routine calls at 19ECH with Register E = the error code: SYS13 finds the message and makes the ROM carry on at 1A01H with Register Pair HL pointing at it, past the code that prints the ROM's own two-letter code.
MESSAGE SEARCH LOOP
Register Pair HL walks through the texts; Register B counts the 00H ends still to pass.
4D46H - BASIC Error Messages
Data, not code: the texts for every BASIC error, each ended by 00H, in the order of the message numbers. Message n is E/2 for the ROM's codes (E below 2FH) and (E - 34H)/2 for Disk BASIC's (E = 64H up). A 00H byte in place of a message ends the table (50FDH).
50FEH - RENUM, First Part
Called through RST 28H with code 4FH by SYS18 after tokenizing, with Register Pair HL = the text after RENUM. Syntax, from the code: up to four numbers separated by commas (the first new number, the increment, the first and the last old line of the range; a number may be left out, but not given as 0), then the options U and X. It writes each line's new number into the line's link field (SYS11 4D0CH rebuilds the links later), counts the lines and loads SYS11.
PARAMETER LOOP
Register Pair BC = the parameter's address (4D00H, 4D02H, 4D04H, 4D06H), Register Pair HL = the text; the count is in the alternate Register A.
LINE LOOP
Register Pair HL = the line, Register Pair BC = the lines counted; the new number goes into the line's link field.
LINES PER ENTRY
Register C counts how many times 128 goes into the number of lines (rounded up, at least 1).
51CDH - Unused Bytes
51CDH-51E7H fill the last load record; nothing reads or executes them.