TRS-80 DOS - NEWDOS/80 v2.0 for the Model I - SYS1/SYS Disassembled
Page Customization
Page Index
SYS1/SYS
Other Navigation
Introduction/Summary
SYS1/SYS is the **command interpreter and dispatcher** overlay for NEWDOS/80 v2.0 on the TRS-80 Model I. It is loaded into the overlay area at approximately 4D00H–51FFH when a DOS command is entered. Its primary purpose is to examine the command line, look up the command name in an internal table, and dispatch execution to the appropriate handler (either directly or by loading another SYS module via RST 28H SVC calls).
Core Functionality
SYS1/SYS is entered at 4D00H with a dispatch code in Register A (and sometimes a secondary counter in C). It performs the following key tasks:
- Handles special cases such as comment lines (starting with #), DOS-CALL mode, and MINI-DOS entry/exit.
- Parses the command name from the input buffer at 4318H.
- Searches the internal command name table (starting at 4F58H) for a match.
- Dispatches to the matching handler using attributes stored with each command (module number, parameter requirements, etc.).
- Supports the special "R" (recall last command) feature and asterisk (*) for running programs.
- Handles file specification parsing and default extension insertion (/CMD) when required by a command.
- Manages clean exits, error conditions, and return to the DOS READY prompt (or MINI-DOS prompt).
Most library commands (APPEND, COPY, DIR, KILL, etc.) are dispatched to other overlay modules (SYS2–SYSn). SYS1 itself focuses on command recognition and routing rather than performing the actual I/O or disk operations.
After dispatching or completing a command, control typically returns to the main DOS loop in SYS0/SYS via the no-error exit at 402DH or through RST 28H mechanisms.
Variables:
| Address Range | Purpose |
|---|---|
| 4022H-4022H (1 byte) | Cursor State - Blink state storage: Non-zero = ON, Zero = OFF |
| 402DH-402FH (3 bytes) | No-Error Exit - DOS successful completion jump vector (JP nnnn) |
| 4030H-4032H (3 bytes) | Error-Shown Exit - DOS exit vector used when error has already been displayed |
| 4200H-42FFH (256 bytes) | Sector Buffer - DOS sector I/O buffer (aliased at 5100H-51FFH) |
| 4300H-4317H (24 bytes) | PDRIVE/SYS Spec - Storage area for PDRIVE and SYSTEM specifications |
| 4312H-4312H (1 byte) | BREAK Flag - BREAK enable: C9H = RET (Disabled/Ignore), C3H = JP (Enabled) |
| 4313H-4314H (2 bytes) | BREAK Handler - Address of the BREAK key handler routine |
| 4318H-4367H (80 bytes) | Command Buffer - Workspace for user input and DOS command processing |
| 4368H-4369H (2 bytes) | System State - SYSTEM storage flags (bit 5 checked for specific operations) |
| 436AH-436AH (1 byte) | Sys Flags 1 - B7: MINI-DOS, B6: DOS-CALL, B5: Command state, B4: Overlay/Chain |
| 436BH-436BH (1 byte) | Sys Flags 2 - B7: Special return, B6: Stack save, B2: Error state |
| 436CH-436CH (1 byte) | Sys Flags 3 - B6: Chaining active flag, B5: Additional state |
| 436DH-436DH (1 byte) | Sys Flags 4 - B5: R command repeat flag |
| 4371H-439AH (42 bytes) | PDRIVE Area - Physical drive configuration data storage |
| 439BH-439CH (2 bytes) | MINI-DOS Stack - Saved stack pointer (SP) for MINI-DOS restoration |
| 439DH-439EH (2 bytes) | DOS-CALL Stack - Saved stack pointer (SP) for DOS-CALL mode |
| 43A7H-43A8H (2 bytes) | Saved Cmd Ptr - Original command buffer pointer for R command repeat |
| 4408H-440AH (3 bytes) | Return Vector - Return address vector for DOS command execution |
| 4480H-449FH (32 bytes) | Parsing Buffer - Buffer for components of the parsed filename |
| 51A7H-51A9H (3 bytes) | "CMD" String - Constant: Command file extension |
| 51AAH-51ACH (3 bytes) | "JCL" String - Constant: Job Control Language extension |
| 51ADH-51AFH (3 bytes) | "TO" String - Constant: COPY command "TO" keyword with null terminator |
| 51B0H-51B4H (5 bytes) | "MINI-" String - Constant: Prefix for the MINI-DOS ready message |
| 51B5H-51C4H (16 bytes) | Ready Message - "NEWDOS/80 READY" with CR terminator |
| 51C5H-51C8H (4 bytes) | Param Table - System parameter table (1CH, 1FH, 03H, 00H) |
| 51E0H-51FFH (32 bytes) | Working Buffer - Temporary filename storage at end of overlay area |
Disassembly
4D00H - DOS OVERLAY COMMAND DISPATCHER
This is the main command dispatcher entry point for NEWDOS/80 v2.0 SYS1/SYS. Register A contains a dispatch code that selects the requested function. Dispatch code A3H specifically calls the default extension insertion routine at 4F2AH. Register C is used as a secondary counter for some dispatch paths.
The following section uses Register C as a countdown counter to dispatch to different command handlers. Each DEC C decrements the counter, and when it reaches zero, that handler is called.
If none of the dispatch codes matched, return an ILLEGAL ENTRY error (error code 2AH).
4D48H - ERROR MESSAGE DISPLAY AND EXIT
This routine displays an error message and exits via the DOS display routine at 4467H. HL points to a message table entry at 51C5H.
4D4EH - RST 28H SVC PREPARATION ROUTINE
This routine prepares for a DOS supervisor call (RST 28H) by saving the alternate register set and setting up parameters. This is used internally by DOS to load and execute system modules.
4D59H - SIMPLE POP AND RETURN
Simple return routine that pops the AF register and returns. Used when a command completes with the status already set.
4D5BH - DOS-CALL ENTRY HANDLER
This routine handles entry into DOS-CALL mode, which allows user programs to invoke DOS functions and commands. It saves all registers, manages the DOS-CALL nesting level, and sets up the stack for DOS operations. Address 4419H vectors here via dispatch code C3H.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
4D78H - DOUBLE POP AND CONTINUE TO EXIT
This routine pops two values from the stack (discarding return addresses) and continues to the standard exit routine.
4D7CH - SET CARRY AND EXIT
This routine clears A, sets the Carry flag, and exits. Used to indicate a specific completion state (possibly indicating BREAK was pressed or a special condition).
4D80H - CLEAR SYSTEM FLAGS AND EXIT
This routine clears certain system flags in the DOS status bytes at 4369H and 436AH, then exits cleanly. Used when completing operations that need to reset DOS state.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
4D8AH - CLEAN EXIT ENTRY POINT
This is a common entry point for clean exits. A is zeroed and processing continues to check DOS state and return appropriately.
4D8BH - MAIN EXIT PROCESSING ROUTINE
This is the main exit processing routine for DOS commands. It disables interrupts, checks DOS state flags to determine if in DOS-CALL or MINI-DOS mode, and handles the appropriate exit sequence. The entry flags (Z, C) from previous code indicate the exit status.
- Bit 7 = special return mode
- Bit 6 = stack save mode
- Bit 2 = error state
- Bit 7 = special return mode
- Bit 6 = stack save mode
- Bit 2 = error state
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
If we reach here, NZ and NC are set, meaning there's a non-zero error code in A.
Continue with normal error/exit processing.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
- Bit 6 = chaining active flag
- Bit 5 = additional state
- Bit 6 = chaining active flag
- Bit 5 = additional state
Execute RST 28H to invoke DOS error handler or load another module.
Check if MINI-DOS mode is active.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
Normal DOS READY mode - reset stack to DOS area and set up BREAK key handling.
- Bit 6 = chaining active flag
- Bit 5 = additional state
Set up to display DOS READY prompt.
MINI-DOS mode - restore stack and display MINI-DOS prompt.
Display the prompt and wait for next command.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
Set up to read the next command from keyboard.
4E10H - DOS-CALL EXIT HANDLER
This routine handles exiting from DOS-CALL mode. It restores the stack pointer and registers that were saved on DOS-CALL entry, and manages nested DOS-CALL levels.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
Pop the previous stack pointer and manage DOS-CALL nesting.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
4E30H - COMMAND EXECUTION WITH STACK RESET
This routine resets the stack pointer to the DOS stack area and then processes a command. Used for dispatch code 63H.
4E34H - COMMAND EXECUTION WITHOUT STACK RESET
Entry point for command execution without resetting stack. Falls through from 4E33H or jumped to directly.
4E35H - COMMAND SETUP AND PARSING
This routine sets up error handling vectors and begins parsing the command in the DOS command buffer. HL points to the command string. This is the main entry point after DOS-CALL setup or direct command entry.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
[LOOP START] Copy the command from DE to the DOS command buffer at 4318H, converting to uppercase via 45B5H.
Command too long - return error code 36H (LINE TOO LONG).
Command copied successfully. Check for "R" (recall) command.
- Bit 5 = R command repeat flag
The "R" command was entered - recall the previous command.
Continue with command lookup in command table.
[LOOP START] Compare command against entries in the command table. Each table entry has the command name followed by attribute byte and jump address.
If the Z FLAG is set (characters matched), LOOP BACK to 4E7AH to compare next character.
Characters didn't match. Check if we've matched enough (bit 7 of table char indicates end of command name).
Bit 7 was set - we reached end of table command name. Now check if input command also ended here.
Command name in table doesn't match. Skip to next table entry.
If the NO CARRY FLAG is set (bit 7 was 0), LOOP BACK to 4E8BH to skip more characters.
Reached end of this table entry's name. Skip the 2-byte attribute and address that follow.
If the NZ FLAG is set (not end of table), LOOP BACK to 4E79H to try next command.
End of command table - command not found. Check if it might be a * (asterisk/star) command for running programs.
Asterisk command - invoke RST 28H to load and run a program file.
4EA7H - COMMAND FOUND - EXECUTE HANDLER
A matching command was found in the table. DE points to the attribute byte. Extract the attribute and jump address, then execute the command.
Check command attributes and permissions before executing.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
Extract module number from attribute and prepare to load/execute the command handler.
Additional command parameter processing (for commands like CLTO, etc.).
Check more attribute bits and continue setup.
Check attribute bits 0-2 for additional handler setup.
[LOOP] Calculate offset into abbreviation table based on parameter count.
Final setup before calling the command handler.
Handler needs to be loaded from disk. Set up RST 28H call to load the SYS module.
4F2AH - Insert Default Extension (/CMD) if Absent
This routine is called during command processing (e.g. from the command dispatcher) to ensure that a filename has a file extension. If the parsed name has no extension separator ("/"), it inserts the default extension (usually "/CMD") by shifting the string with LDDR and inserting the extension from the table pointed to by HL. Drive-related checks are only used to determine field boundaries and are secondary. This fixes the common case where the user types "MYPROG" and it should become "MYPROG/CMD" before loading.
4F58H - DOS COMMAND NAME TABLE
This is the DOS Command Name Table. Each entry contains: the command name (with bit 7 set on the last character), an attribute byte, and a 2-byte handler address. The table is terminated by a 00H byte. The disassembler has interpreted these as instructions, but they are actually ASCII data.
Attribute: 68H, Address: 0068H (points to handler)
The remaining entries follow the same pattern. Here are a few notable ones identified in the data:
50B7H - LIB COMMAND - DISPLAY LIBRARY LIST
This routine implements the LIB command, which displays a list of all available DOS commands from the command table. It walks through the table at 4F58H and displays each command name, formatting them in columns.
[LOOP START] - Process each command table entry.
[INNER LOOP START] - Display characters of one command name.
DECrement B and Jump if Not Zero back to 50BEH to display next character.
Done with this command name - skip the attribute and address bytes.
50DBH - MINI-DOS ENTRY HANDLER
This routine handles entry into MINI-DOS mode. MINI-DOS is a special feature of NEWDOS/80 that allows the user to execute DOS commands while a user program is suspended (typically entered by pressing DFG simultaneously). This routine saves the current program state and prepares the system for MINI-DOS operation.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
At this point, we've confirmed DOS is in a normal state and can safely enter MINI-DOS mode. Now save the current context and set up MINI-DOS.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
50FAH - MINI-DOS EXIT HANDLER (MDRET Command)
This routine handles exiting from MINI-DOS mode and returning to the interrupted user program. It corresponds to the MDRET DOS command. The routine restores all saved CPU state and resumes execution of the suspended program.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
MINI-DOS mode is confirmed active. Now restore the saved state and return to the interrupted program.
- Bit 7 = MINI-DOS active
- Bit 6 = DOS-CALL active
- Bit 5 = command processing state
- Bit 4 = additional state flag
511AH - REGISTER RESTORATION AND RETURN
This routine restores all CPU registers from the stack and returns to the caller. It is used both as the exit path from MINI-DOS (MDRET) and as an abort path when MINI-DOS entry is rejected.
512BH - SAVE ALL REGISTERS TO STACK
This routine saves all CPU registers (including alternate register sets, IX, and IY) onto the stack. It is called at the start of operations that need to preserve the complete CPU state, such as entering MINI-DOS or handling DOS-CALL.
513DH - SKIP FILENAME EXTENSION HANDLER
This routine processes a filename and skips past any extension marker (period or slash) to position HL at the start of the actual filename or past the extension.
514DH - PARSE FILENAME WITH DESTINATION BUFFER
Entry point that sets up a destination buffer address before calling the main filename parser.
5150H - FILENAME PARSER
This routine parses a filename from the source buffer (pointed to by HL) and copies valid characters to the destination buffer (pointed to by DE). It handles special cases like asterisk wildcards and validates alphanumeric characters.
515AH - CHARACTER-BY-CHARACTER FILENAME PARSER
This is the inner parsing loop that processes each character of a filename. It handles wildcards (*), validates alphanumeric characters, and copies valid characters to the destination buffer. Called with HL pointing to source, DE pointing to destination, and B containing the maximum character count.
Character is an asterisk (*) wildcard - copy it and advance pointers.
LOOP START
- Main character validation loop begins here.
Character passed the digit test or was confirmed alphabetic. Now check for special delimiters.
Character is a delimiter (like period) - mark end of filename portion.
Character is valid - copy it to destination and continue loop.
Decrement B and if not zero, LOOP BACK to 516EH to process the next character.
Reached end of loop (maximum characters processed) or hit invalid character.
5189H - ALPHABETIC CHARACTER CHECK
This subroutine checks if the character at (HL) is an alphabetic letter (A-Z or a-z). Returns with CARRY set if the character is alphabetic. If called after a digit test fails, it determines if the character is a valid filename character.
Not an uppercase letter - check for lowercase.
5195H - DISPLAY MULTIPLE SPACES
This routine displays multiple space characters. Called with B containing the count of spaces to display.
Load Register A with 20H (ASCII space character).
519DH - DISPLAY CARRIAGE RETURN
This routine displays a carriage return character (0DH), moving the cursor to the beginning of the next line.
519FH - DISPLAY CHARACTER WITH REGISTER PRESERVATION
This utility routine displays the character in Register A while preserving the DE register pair. This is important when DE is being used as a pointer during string operations.
51A7H - DOS COMMAND NAME STRINGS
This area contains ASCII strings used by DOS, including abbreviated command names. These are not executable code but data referenced by command lookup and display routines.
51B0H - MINI-DOS READY MESSAGE
This is the "MINI-" prefix displayed before "NEWDOS/80 READY" when in MINI-DOS mode.
51B5H - NEWDOS/80 READY MESSAGE
This is the main DOS prompt message displayed when DOS is ready for command input.
51C5H - SYSTEM PARAMETER TABLE
This small table contains system configuration parameters used by various DOS routines.
51E0H - END OF DOS OVERLAY AREA
The remaining bytes from 51E0H to 51FFH are reserved space at the end of the DOS overlay area. This area may be used for temporary storage or left as padding.