TRSDOS
TRSDOS is the operating system for the Tandy TRS-80 line of 8-bit Zilog Z80 microcomputers that were sold through Radio Shack from 1977 through 1991. Tandy's manuals recommended that it be pronounced triss-doss. TRSDOS should not be confused with Tandy DOS, a version of MS-DOS licensed from Microsoft for Tandy's x86 line of personal computers.
With the original TRS-80 Model I of 1977, TRSDOS was primarily a way of extending the MBASIC with additional I/O commands that worked with disk files rather than the cassette tapes that were used by non-disk Model I systems. Later disk-equipped Model III computers used a completely different version of TRSDOS by Radio Shack which culminated in 1981 with TRSDOS Version 1.3. From 1983 disk-equipped TRS-80 Model 4 computers used TRSDOS Version 6, which was a development of Model III LDOS by Logical Systems, Inc. This last was updated in 1987 and released as LS-DOS 6.3.
Completely unrelated was a version of TRSDOS by Radio Shack for its TRS-80 Model II professional computer from 1979, also based on the Z80 and equipped with 8 inch disk drives. The later machines in this line, the Models 12, 16 and 6000, used the Z80 as an alternate CPU to its main Motorola 68000 chip and could run this version of TRSDOS for backwards compatibility with older Z80 applications software.
History
's TRS-80 microcomputer did not have a disk drive or disk operating system at release. The first version of TRSDOS, by Randy Cook, was so buggy that others wrote alternatives, including NewDOS and LDOS. After disputes with Cook over ownership of the source code, Tandy hired Logical Systems, LDOS's developer, to continue TRSDOS development. TRSDOS 6, shipped with the TRS-80 Model 4 in 1983, is identical to LDOS 6.00.Dates
- May 8, 1979 – Radio Shack releases TRSDOS 2.3
- May 1, 1981 – Radio Shack releases Model III TRSDOS 1.3
- April 26, 1983 – Radio Shack introduces TRSDOS Version 6.0 with the new Model 4s
- 1984 – Radio Shack releases Version 6.2, the definitive version for the Model 4
- 1984 – Logical Systems publishes The Source, the commented assembler source code to TRSDOS 6.2
- Late 1986 – Logical Systems releases LS-DOS 6.3, the functionally equivalent update to TRSDOS 6.2. From this date, Tandy/Radio Shack ships it with the Model 4D.
Features and capabilities
Hard disk drives required custom driver software supplied by their manufacturers. These drivers permitted any TRSDOS installation to access them with up to eight possible drive partitions, each assigned to drive numbers zero through seven. Actually, a large hard drive could be formatted with more than eight partitions, but TRSDOS can only access eight during any one session. Hard drives could have some partitions formatted under TRSDOS and others under the CP/M OS. Each floppy drive in the system would also take up one drive number assignment. The Model 4, with its ability to set up a ramdisk, also required a drive number assignment for this.
All versions of TRSDOS use overlays to satisfy most system requests and disk directories are not maintained in memory. This has two implications for system performance. First, upon initial file access the DOS always references the disk directory to obtain information giving the physical mapping of disk space allocated to the file. After the initial access this information is maintained in a File Control Block, the memory space for which is supplied by the calling application. Further references do not need to read the disk directory. For this reason system performance depends greatly on how close a file's allocated disk space is/are to the directory cylinder, and how fragmented the file is as a whole. The farther away the directory cylinder is, the more the drive's read/write head will need to move, which slows disk access and produces more mechanical wear on the drive. TRSDOS has commands permitting the user to optimize placement of particular files on the disk's physical space, and the command to display a map of a file's physical placement on a drive.
The second implication of the overlay-based architecture is that a disk containing TRSDOS system files must always be present in whichever drive is assigned as logical drive number zero.. LDOS and TRSDOS 6 have a SYSRES command which loads selected system files into Z80 RAM, thus freeing space on the system disk for non-system data. All versions have variants of the SYSTEM command which can reassign logical drive numbers to physical drives. It is possible to assign drive numbers such that a physical drive is unassigned a logical drive number; this is sometimes useful to guarantee that the drive cannot be accessed for security or safety purposes. Drives may be set to be write protected by the DOS, also.
Disk management
The primary function of any operating system is to provide the user with a facility for managing and accessing files stored on disk storage devices. Since the user must not be burdened with the physical details of the storage devices themselves, it is the operating system's responsibility to translate file record access requests into specific drive, track, sector, and head parameters that pinpoint the storage location of each record.The system also maintains in Z80 memory within TRSDOS a Drive Control Table that stores the parameters associated with each of the eight logical drives. Disk drive parameters refer to how the total storage space on a drive is divided up into addressable units. The layer of magnetic particles on the surface of the disk media are magnetized into concentric circles of storage areas called TRACKS. Each track is divided into 256 byte sub-areas called SECTORS. Each sector is uniquely identified by a pattern of information preceding each sector called an ID FIELD. Although the number of sectors per track may vary from one media type to another, the number of sectors in each track of the same media must always be a constant.
Disks are organized as follows: each track is formatted into a specific number of 256 byte sectors with a maximum capacity of 32 sectors per track. Sectors are grouped into blocks called granules which vary in size according to total track capacity of the disk media, though granule size for each disk format is constant. For forty-cylinder disks formatted in double density, standard for the drives installed in the TRS-80 Models III and 4, the granule size is six 256 byte sectors, or 1.5 KB. Each track has three granules for 4.5 KB of storage. Each side of the disk is normally formatted with 40 tracks, yielding 180 KB per side. The Model 4D, with its double-sided drives, yields 360 KB of storage. Whenever additional disk space is needed for a file, an additional granule is allocated. The granule thus becomes the minimum size storage unit.
TRSDOS assigns numbers to every sector, every track, and every surface. Surfaces are numbered consecutively starting from zero. Tracks are numbered consecutively starting from zero at the outermost portion of the disk giving the innermost track the highest number. Where multiple headed drives are in use, the track numbers on a surface are duplicated on each surface with all similarly numbered tracks constituting a cylinder. For a double-sided floppy disk as formatted on a Model 4D, track zero of surface zero and track zero of surface one are grouped together into cylinder zero. Cylinder capacities also have an upper limit of 256 sectors per cylinder or eight granules per cylinder, while the system supports a maximum of eight heads per drive.
The disk's directory cylinder is placed during the format process on the middle-numbered cylinder; thus a standard 40 cylinder disk has its directory installed on cylinder 20. This reduces the average distance that the drive's read/write head must move to access the directory. The first sector of the disk directory contains the Granule Allocation Table. The GAT is bit mapped to each granule of space on the drive. Other fields in the GAT contain the PACK NAME, DATE of creation, pack PASSWORD, and data pertaining to the configuration of the drive.
When a file is to be opened for access, the system needs to search the directory for its directory record. Search time is minimized by using a hashing technique to reduce the 11-character string formed from the file name and extension to a one byte value. The hash code for each file is stored in a Hash Index Table which is the second sector of the directory. Each position in this table corresponds to a specific directory entry record. The hash table, being one sector in length, can index a maximum of 256 directory records or files. The directory itself is sized according to disk capacity by being a maximum of one cylinder. Thus, the larger the disk storage capacity, the larger its directory, and the greater the number of file names that can be stored on the disk.
The directory record contains information such as the date the file was last modified, its update and access password codes, its access level, and other attributes such as whether it is a SYStem or PDS file and if a backup has been made, the relative number of the last sector in the file, and the last byte within the last sector. The record also contains the physical storage in use by the file, by pointing to the cylinder, relative starting granule, and number of contiguous granules for each extent linking up the file. When a file has more than four extents, additional directory records are used as required with forward and backward pointers linking each record of each file.
When TRSDOS formats a disk, all of the parameters associated with the diskette are predetermined. Thus the number of sectors per track, number of sectors per granule and thus the granules per track, number of sides, and number of cylinders are all designated, as well as the density of the media. Some of these figures are written to fields in the Granule Allocation Table which is part of the disk directory. Others are part of the Drive Control Table fields. When the system attempts to open a file on a disk, it uses the @CKDRV SVC to ascertain the availability of the disk, and then logs the disk once it finds it available. This "logging" function will update the DIRCYL field, then update the DBLBIT and MAXCYL fields based on information stored in the GAT. This procedure frees the user from having to manually log a newly inserted disk; he is at liberty to change differently formatted disks in any drive without concern that the system will incorrectly access it.
The SVC disk primitives are funneled through common system routines contained in the driver software installed for each type of disk storage device. The driver for Model III or Model 4 floppy drives is named "$FD" and is located in the TRSDOS low memory region. Hard disk drives are supplied with their own driver software, and are usually installed in high memory above the system HIGH$ pointer, since room in the low memory region is usually insufficient. These driver routines establish a linkage protocol between the application requesting disk access and the computer's Floppy Disk Controller hardware. TRS-80s use controller chips from the Western Digital series: the WD1791 in the Model 4 non-gate array version, and the WD1773 in the Model 4 Gate Array version. When an I/O request is invoked by a higher level SVC, such as a request to READ a file record, the request is translated to that disk primitive needed to satisfy the function request. The linkage protocol is uniform across all disk devices that are connected to the system. This makes the access of files transparent to size or nature of the disk device within the scope of the parameters stored in the DCT for that drive.
File management
Disk files are supported with two types of access: Record I/O and character I/O. Logical records of from one to 256 bytes in length can be read or written using the @READ or @WRITE SVC requests. Record I/O can be random access or sequential access using repetitive READs or WRITEs. Character I/O is accomplished by @GET and @PUT SVC requests and is essentially the same as record I/O with a Logical Record Length equal to one.. However, if GET or PUT are used to implement sequential access, then a file can be considered a character I/O device just like a printer, a serial port, or a video display device. A byte I/O request is therefore independent of the physical device "connected" to the control block which is requesting the I/O. This makes the system "device independent".Filenames are limited to eight alphanumeric characters which are case insensitive. File extensions are up to three characters and obey the same rules. File passwords are up to eight characters obeying the same rules. Entire diskettes can also be assigned master passwords, which may limit user access via the BACKUP and PURGE commands.
Under TRSDOS and LDOS the system is never "logged in" to any current drive as with CP/M, PC DOS and MS-DOS. The system prompt is always. All file access requests are satisfied by searching the directory of the first drive specified and, if the requested file is not found, then searching the next drive in the system. This continues until the file is found or all the drives in the system have been searched.
Drive numbers are specified with a colon followed immediately with the drive number. The colon is optional unless the drive specification is used as a suffix for a filename. Using the directory command as an example:
displays all files starting with logical drive zero, then drive one, and so on.
or searches logical drive four.
or searches logical drives four, five, and six.
or searches logical drives four, five, six and seven.
searches for FILENAME on logical drive two.
searches for FILENAME on all logical drives starting from drive two.
As seen, the dash character is used to specify a range of drive numbers. The and commands display all file specifications matching the query on all drives. Other commands/utilities such as, and, and drive searches initiated by programs being executed, stop searching at the first drive found to match. If the same filespec exists on multiple drives, then those files on higher-numbered drives will be excluded.
File access by partial filenames, file extensions, and file dates are supported. For example:
will select files SAMPLE, SAMPLE1, SAMPLE23 and SAMPLEIT.
will select files SAMPLE/BAS, TEST/BAS, EXAMPLE/BAS, etc.
As with the example earlier, drive specifications may be appended to filespecs. These examples assume the selected files have not be made invisible in the disk directory. File access requests issued by applications programs running under TRSDOS work the same way.
Command-line interface
Under TRSDOS/LS-DOS 6.x, the standard system command interpreter can be functionally replaced with a custom interpreter by copying the new interpreter to the system file SYS13/SYS. This can be any machine code /CMD program file. This is referred to in the documentation as an "Extended Command Interpreter" or ECI.TRSDOS/LS-DOS 6.x support wildcard characters in filenames, both the single character ? and multicharacter *.
TRSDOS was notable for the inclusion of noise words, similar to the 1959 COBOL specification. These made commands more English-like. For example, the following commands functioned identically:
- COPY filea fileb
- COPY filea TO fileb
Under DOS and UNIX printing a file can be done with redirection; under UNIX it is normally done by spooling the file to the "line printer" because UNIX is conventionally a multi-user system. TRSDOS/LS-DOS 6.x print jobs can be redirected by applying the LINK or ROUTE commands to the system *PR device.
TRSDOS/LS-DOS 6.x do not support subdirectories or user areas. However, the DIR and CAT commands for displaying file data support the usual partial filenames, suffixes, and file dates.
Under TRSDOS/LS-DOS 6.x files can be made invisible to the DIR and CAT commands, and can be displayed with the INV parameter.
TRSDOS/LS-DOS 6.3 can dump the video screen to the line printer by pressing.
Many versions support a simple password security for files and programs, with separate Read/Execute and full access capabilities. ex: filename/ext.password:drive#. TRSDOS 6.x supports both Owner and User passwords for disk files. LS-DOS 6.3 uses the space for the User password for its extended dating scheme. Both Model 4 OSes can set various file access levels and permit software write protection for disk files and entire disks.
Commands
Although MS-DOS owes its heritage most closely to CP/M and thence to TOPS-10, many of the file manipulation commands are very similar to those of TRSDOS. By comparison, the CP/M command for copying files was called pip.Some typical TRSDOS utilities:
Command | DOS, OS/2, Windows | Unix, Unix-like | Description | - |
APPEND | type file1 >> file2 | cat file >> file2 | - | |
ATTRIB | attrib | chmod | ATTRIB, PROT, and the chmod UNIX command are all somewhat different in their semantics. UNIX/Linux is multi-user and each user can control read, write, and execute permissions on his or her own files and directories. MS-DOS is single user and the file attributes for "read-only," "hidden," and "system" are advisory in nature. TRSDOS was single user. | - |
AUTO | AUTOEXEC.BAT | ~/.profile or ~/.login or /etc/rc* | The AUTO command sets an automatic command to be executed on TRSDOS boot; under MS-DOS the special, reserved file named AUTOEXEC.BAT contained a list of such commands. TRSDOS/LS-DOS 6.x support Job Control Language in which any text file with the suffix /JCL could batch process any number of executable program files. Such a file could be the object of an AUTO command. On UNIX a set of one or more rc files under /etc/ are a set of boot time "run commands" and special "dot files" in a user's home directory are run for each time that a given user logs into the system. UNIX supports many other "dotfiles" for many of its commands which are akin to the Macintosh "preferences" folder contents. | - |
BACKUP | diskcopy | tar, cpio, pax, | TRSDOS/LS-DOS 6.x include the BACKUP/CMD utility which can mass copy files specified by partial filename matches, file suffixes, or by file date. BACKUP can be made to first query for permission to copy each file with the Q=Y parameter. On single drive computers the X parameter will permit copying between two disks by prompting the user when to switch disks in the drive. | - |
CLOCK | prompt $t * | in some shells: PS1="...\t..." * | The CLOCK command displays a real-time clock in the upper corner of the display, almost like a DOS TSR ; no exactly corresponding feature exists in MS-DOS or UNIX, though many programs provided similar features for DOS and the common UNIX shells could embed the time into their user-defined "prompt string". | - |
COPY | copy | cp | - | |
DIR | dir | ls | - | |
DISKCOPY | diskcopy | LS-DOS 6.3 includes the DISKCOPY/CMD utility which makes an exact copy of a source disk by formatting and copying to a blank destination disk. | - | |
FORMAT | format | mkfs | - | |
FREE | chkdsk | df | - | |
GETDISK/GETTAPE | dd | - | ||
KILL | del | rm | - | |
LIST | type | cat | Under TRSDOS/LS-DOS 6.x, the LIST command can display or print the contents of non-ASCII files with the HEX parameter. | |
LOAD program | Program invocation under TRSDOS, DOS and UNIX is done by filename; no explicit LOAD command is required for normal binary executables nor for text command files. The LOAD command under TRSDOS would load a binary program into memory, but would not execute it; neither DOS nor UNIX has an equivalent. | - | ||
MEMORY | The MEMORY command shows the names and sizes of memory resident modules. It is also used to modify system flag bytes. For example, flag A is the DOS Allocation byte, which the BACKUP command uses to specify the beginning cylinder of a disk to start copying files. This gives the user control over the physical placement of files on disks, which is important to minimize movement of the drive's read/write head during file access. | - | ||
type file >> | lpr | - | ||
PROT | attrib | chmod | ATTRIB, PROT, and the chmod UNIX command are all somewhat different in their semantics. UNIX/Linux is multi-user and each user can control read, write, and execute permissions on his or her own files and directories. MS-DOS is single user and the file attributes for "read-only," "hidden," and "system" are advisory in nature. TRSDOS was single user. | - |
PURGE | TRSDOS/LS-DOS 6.x support the PURGE command which will mass delete files specified by partial filename, file suffixes, or file dates. PURGE will query the user for permission to delete each file unless the Q=N parameter is given. | - | ||
RENAME | ren or rename | mv | - |