TRS-80 DOS - TRSDOS (Main Page)

TRSDOS Commands

APPEND (Merges 2 files)

Syntax: APPEND file-1 TO file-2

This command lets you append (add) one file onto the end of another. This is primarily useful with data files. APPEND copies the contents of file-1 onto the end of file-2. File-1 is unaffected, while file-2 is extended to include the contents of file-1.


Example: APPEND FTWORTH/TXT TO NTEXAS/TXT

NTEXAS/TXT will now include the contents of FTWORTH/TXT at the end, while FTWORTH/TXT remains unchanged.


Note: To APPEND BASIC programs, both files must be saved in ASCII format (using the "A" option). Also, line numbers in file-1 must be higher than those in file-2.

AUTO (Automatic key-in on power-up)

Syntax: AUTO [dos-command]

Specifies a command to be executed immediately after power-up. This writes the command as an "automatic key-in" on the drive 0 diskette, replacing any previous automatic key-in. Typing AUTO (with no arguments) eliminates any automatic key-ins.


Examples:

AUTO CLOCK (Loads and executes the display clock on power-up)

AUTO BASIC (Loads DISK BASIC and begins initialization)


Note: The system diskette must not be write-protected. You can override an automatic key-in by holding down the BREAK key during power-up.

ATTRIB (Set protection attributes)

Syntax: ATTRIB filespec [(param ...)]

I:
Makes the file invisible to the normal DIR command.
ACC=psw1:
Assigns psw1 as the new access password.
UPD=psw2:
Assigns psw2 as the new update password.
PROT=level:
Assigns protection level (KILL, RENAME, WRITE, READ, or EXEC).

The protection levels are hierarchical; each level includes the privileges of the levels below it:

KILL:
Total privilege (Kill, Rename, Write, Read, Execute)
RENAME:
Rename, Write, Read, Execute
WRITE:
Write, Read, Execute
READ:
Read and Execute
EXEC:
Execute only

Example: ATTRIB PAYROLL (ACC=EMPLOYEE, UPD=MANAGER, PROT=READ)

BASIC / BASIC2 / BASICR (Load and run BASIC)

Syntax: BASIC [\*]

Loads DISK BASIC into the system. Use BASIC \* (note the mandatory space before the asterisk) to return to BASIC from TRSDOS without losing programs currently in memory.

BASIC:
Loads the standard Disk BASIC.
BASIC2:
Loads Disk BASIC for a 2-drive system.
BASICR:
Loads Disk BASIC with the RS-232-C driver.

CLOCK (Display real-time clock)

Syntax: CLOCK [ON|OFF]

Displays the internal real-time clock on the top line of the video display (positions 53-60). The clock is updated once per second via a foreground task. Note that any characters at those display locations will be overwritten.

COPY (Copy a file)

Syntax: COPY source-filespec TO destination-filespec

Copies a file from one diskette to another or to the same diskette under a different name. If the destination file already exists, TRSDOS will ask for permission to overwrite it.

DATE (Display or set the date)

Syntax: DATE [MM/DD/YY]

Displays or sets the current system date. The date is used for file directory stamping.

DEBUG (Real-time debugging program)

Syntax: DEBUG [ON|OFF]

A package for debugging machine language programs. When ON, it is triggered by the BREAK key or a disk error.

A:
ASCII/graphics display toggle.
C:
Call-Step (executes a CALL in full).
Daaaa:
Display memory starting at address aaaa.
Gaaaa:
Go to address aaaa.
Maaaa:
Modify memory at address aaaa.
Rrp dddd:
Load register pair with data.
S:
Single-Step.

DEVICE (Display device status)

Syntax: DEVICE

Displays the status of all system devices (Disk Drives, Printer, etc.).

DIR (Display directory)

Syntax: DIR [drive] [(param ...)]

A:
Display all information (including passwords/attributes).
I:
Include invisible files in the listing.
S:
Include system files.

DUMP (Save memory to file)

Syntax: DUMP filespec (START=aaaa, END=bbbb, TRA=cccc)

Saves a block of memory from address aaaa to bbbb into a loadable file. TRA specifies the optional transfer (execution) address.

KILL (Delete a file)

Syntax: KILL filespec

Deletes the specified file from the diskette and frees its space for other files.

FREE (Display available space)

Syntax: FREE [drive]

Displays the number of free "grans" (granules) available on the specified drive.

LIB (Display library commands)

Syntax: LIB

Lists the names of all commands currently resident in the TRSDOS library (internal commands).

LIST (Display text file)

Syntax: LIST filespec

Displays the contents of an ASCII text file on the video screen.

LOAD (Load machine language file)

Syntax: LOAD filespec

Loads a machine language program from disk into memory without executing it.

PRINT (Print text file)

Syntax: PRINT filespec

Sends the contents of an ASCII text file to the line printer.

PROT (Change diskette password)

Syntax: PROT [drive]

Allows the user to change the Master Password of the diskette in the specified drive.

RENAME (Rename a file)

Syntax: RENAME old-filespec TO new-filespec

Changes the name of an existing file. The file remains on the same drive and retains its original contents.

TIME (Display or set the time)

Syntax: TIME [HH:MM:SS]

Displays or sets the internal real-time clock.

TRACE (Display execution address)

Syntax: TRACE [ON|OFF]

Enables a foreground task that displays the Program Counter (PC) in the upper right of the screen. It is updated every 8ms. This operates in TRSDOS, BASIC, or any other program unless interrupts are disabled.

VERIFY (Automatic read-after-write)

Syntax: VERIFY [ON|OFF]

Causes TRSDOS to verify all user disk writes (e.g., file-writes from DISK BASIC) to ensure data integrity. When ON, disk access speed is reduced by approximately 50%. TRSDOS defaults to VERIFY OFF on power-up.

Extended Utilities

BACKUP (Duplicate a diskette)

Syntax: BACKUP [:d1] [TO] [:d2]

This utility duplicates an entire TRSDOS or data diskette. You can use any two drives for the backup, or you can perform the backup using drive 0 by swapping source and destination diskettes when BACKUP tells you to. If the destination diskette is unformatted, BACKUP will format it, locking out any defective tracks, and will then proceed to copy all source disk files onto it.


Examples:

BACKUP (Prompts for source and destination drive numbers)

BACKUP :0 TO :0 (One-drive backup sequence)

BACKUP :0 TO :1 (Two-drive backup sequence)


Note: BACKUP will accept a pre-formatted diskette only when its Master Password and Diskette Name match that of the source disk. In this case, BACKUP will skip the formatting step and begin the copy and verify process.

FORMAT (Prepare a data diskette)

Syntax: FORMAT

This utility lets you prepare data diskettes containing a minimum of system information and leaving you with a maximum amount of space for program and data files. TRSDOS diskettes have 44 granules (55K bytes) available; data diskettes have 67 granules (83.75K bytes).


Example: 1,3-5 (Locks out tracks 1, 3, 4, and 5)


Note: Data diskettes can only be used in drives 1, 2, and 3, except during a BACKUP or FORMAT. If you get READ errors, reformat the diskette; FORMAT will lock out defective tracks and leave the diskette usable.

TAPEDISK (Copy tape file to disk file)

Syntax: TAPEDISK

This utility lets you load a SYSTEM tape into RAM and then dump it into a specified file on the disk. Do not attempt to use TAPEDISK to load tape files which load below hexadecimal address 54F4, as TAPEDISK uses this area.

CommandFunction
CLoad from tape; activates the cassette recorder.
F filename[/ext].psw :d aaaa bbbb ccccDump to disk. aaaa: hex start address; bbbb: hex end address; cccc: execution entry point.
EExit to TRSDOS via the normal re-entry point.

Example: F USRCODE/CMD:1 7000 70FF 700A

DISKDUMP/BAS (Examine disk file)

Syntax: RUN "DISKDUMP/BAS"

A BASIC program that lets you look at the contents of any disk file. It is useful for experimenting with random/sequential output and debugging I/O routines. Sectors are printed 16 bytes at a time in both hexadecimal and ASCII.


Note: The program is written to dump to a Line Printer. If no printer is connected, change LPRINTs to PRINTs (lines 170, 240, 250) and change line 160 to 160 GETLSN.

GETDISK/BAS & GETTAPE/BAS

Syntax: RUN "GETDISK/BAS" or RUN "GETTAPE/BAS"

GETDISK/BAS copies any disk file onto cassette; GETTAPE/BAS reads the cassette data and writes it into a disk file. These allow one-drive users to copy data files to a revised version of BASIC.


Note: These do not set the EOF pointer for sequential files. Use a marker at the end of the file or count data items to avoid inputting invalid data. Do not use these for BASIC programs; use CSAVE and CLOAD instead.

TEST1 (Test memory)

Syntax: TEST1

Tests the TRS-80’s ROM and RAM. It automatically checks all locations regardless of memory size. If all checks pass, it prompts you to press ENTER to return to TRSDOS.


Note: TEST1 changes the entire contents of RAM. Ensure you have saved any valuable code to disk before running.

TEST2/BAS (Test stress)

Syntax: RUN "TEST2/BAS"

A stress test for 32K or 48K RAM systems only, taking approximately 10 minutes. It creates test files on selected drives to check the integrity of the disk system.


Example: WHICH DRIVES ARE TO BE USED? 0,1,3 (Tests drives 0, 1, and 3)


Note: During the test, the display will be filled with "meaningless" characters and "STILL TESTING" messages; these should be ignored.

Technical Information

Memory Organization

The TRS-80 Disk Operating System is comprised of 1K of ROM resident CIO (Character-oriented I/O) drivers and 4K of RAM drivers, schedulers, tables, pointers, etc. The ROM resident CIO drivers are also used by LEVEL II BASIC and therefore are part of its 12K ROM requirement.

Since LEVEL II is upward compatible with DISK BASIC, an additional 0.5K of RAM is required for both versions of BASIC. This means that user memory starts at hex 5200, resulting in 11.5K of user RAM in a 16K machine.

Note: The memory which is completely untouched by both TRSDOS and DISK BASIC code begins at hex 7000.

TRSDOS is comprised of a resident system and several overlays which are loaded from disk as the need arises (for example, to open or close a file). The system has a modular design. System entry-point vectors are in the lowest portion of the 4K RAM, followed by the interrupt handling, disk file handling, task scheduling and general purpose resident system routines. System buffers and overlays comprise the last portion of the 4K RAM requirement.

Since all major system commands are actually loaded as needed from disk in the form of utilities (the “library commands” and the extended utility programs), the TRSDOS system facilities can easily be enhanced without affecting the RAM memory requirement.

Disk Organization

Each TRSDOS system diskette contains a TRSDOS system, a utility command library, a file directory, and system tables. The minimum system overhead amounts to one full track of directory information and a half track of TRSDOS bootstrap program and other information.

This means that every TRSDOS diskette is self-loading, although it may or may not actually contain the TRSDOS system. This is done to prevent the Computer from attempting to bootstrap a diskette containing only user data files.

The utility command library is optionally available on the diskette. Since the utility command programs are not always required, it will often be advantageous for multi-drive users to format diskettes for use in drives 1 through 3. Such “data diskettes” contain a minimum of system code, leaving more space for user files.

Maximum file size is limited only by the physical size of the diskette, since a file must be wholly contained on one diskette. Each diskette is single-sided and has 35 tracks of information. Each track contains 10 sectors of 256 bytes each.

Normally, data read/write operations may only be initiated at sector boundaries, and must consist of exactly 256 bytes. However, TRSDOS allows the user to have maximum flexibility with minimal effort by automatically blocking and de-blocking all file accesses to user-specified logical record lengths, even if this requires “spanning” of two sectors.

The system disk file structure allows maximum use of disk file space by automatically segmenting files across a diskette in several small pieces. These pieces are correlated into one logically contiguous file by the system without your needing to know the physical file location. This structure eliminates time-consuming disk-packing operations.

File Structure

A TRSDOS file is composed of one or more segments of storage space. Each segment consists of from one to 32 physically contiguous granules of storage. A granule is the minimum allocatable unit of storage, and consists of five sectors (1.25K bytes).

Since a file is always lengthened by granules, a small amount of free storage is generally present at the end of every file. This free storage allows minor file additions to be made in space which is physically contiguous to the file. The effect is to decrease the amount of “thrashing” present in a file which has had frequent additions made. (A wholly sector-mapped system could not offer this benefit.)

Every time a disk file is extended (either initialized or lengthened), extra granules may be allocated to that file, depending on the file’s accumulated length, diskette space, saturation, etc. These extra granules, along with all granules after the one containing the file’s EOF mark, are recovered and returned to the system when the file is closed.

TermExplanation
LRNLogical Record Number: Used to specify an individual, user-defined logical record.
FileA group of logical records; the largest unit of information addressable by a TRSDOS command.
SectorA physical record, composed of 256 contiguous bytes.
GranuleThe minimum allocatable unit of storage for a particular file.

System Routines for Assembly-Language I/O

This information is provided for customers who wish to write their own assembly level I/O routines. An explanation of the calling sequence and parameters for each necessary I/O routine is given. A knowledge of Z-80 machine code is assumed.

NotationExplanation
HL => xxxxRegisters HL contain the address of (point to) xxxx in machine format.
DE => xxxxRegisters DE contain the address of (point to) xxxx in machine format.
B = xxRegister B contains the numeric value of xx in binary form.
A = xxRegister A contains the numeric value of xx in binary form.
Z = OKZero flag is set (OK) if successful return from the system routines.
X'nnnn'Hard RAM address in hex notation (e.g., 402D is X'402D').
LRLLogical Record Length. 1–255 bytes only.
BUFFER256 user-designated bytes in RAM for TRSDOS to read sectors from or write sectors into.
URECUser Record: the address of the contiguous RAM byte-string assigned by the user as the logical record area.

Data/Device Control Blocks (DCB)

The DCB is defined as 32 contiguous bytes of RAM designated by the user. Before OPEN and after CLOSE, it is a left justified, compressed (no spaces) ASCII string, as in a standard TRSDOS filespec.

Addr.Len.Explanation
DCB+03Reserved
+32Physical Buffer address (LSB/MSB)
+51Offset to delimiter at end of current record
+61File drive number residence
+71Reserved
+81EOF offset of last delimiter in last physical record
+91LRL (Logical Record Length)
+102NRN (Next Record Number — LSB/MSB)
+122ERN (Ending Record Number — LSB/MSB)

Physical and Logical Records

BytesSectorsGranulesTracksDisk
2561———
128051——
25601021—
8960035070351

Fundamental TRSDOS I/O Calls

Routine (Address)Description
INIT (4420H)Creates a new file in the directory and opens it for use.
OPEN (4424H)Opens an existing disk file for use.
READ (4436H)Reads one logical record into UREC or physical record into BUFFER.
WRITE (4439H)Writes one logical or physical record to disk.
CLOSE (4428H)Closes an open file and updates directory entries.

TRSDOS Error Codes

DecimalCausesDescription
00—No error
02DSeek error during read
15UDXWrite protected diskette
24UPFile not in directory
27UPDisk space full (70 granules max)
28PEOF encountered (End Of File)
32UPIllegal drive number specified

C = CPU fault, D = Drive, F = Format, M = Media, P = Program/User, S = System, X = Expansion.