TRSDOS (Tandy Radio Shack Disk Operating System) is the operating system for the Tandy TRS-80 line of eight-bit Zilog Z80 microcomputers 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 (PCs).

With the original TRS-80 Model I of 1977, TRSDOS was primarily a way of extending the MBASIC (BASIC in ROM) with additional I/O (input/output) 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 and TRS-80 Model 12 professional computers from 1979, also based on the Z80 and equipped with 8-inch disk drives. The later machines in this line, the Models 16 and 16B and Tandy 6000, used the Z80 as an I/O processor for its main Motorola 68000 chip when running operating systems on the 68000, and could run the Model II version of TRSDOS for backwards compatibility with older Z80 applications software. When running the older Z80 operating systems, the 68000 was unused.

History Tandy Corporation'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 October, 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 Radio Shack's Z80-based line of TRS-80 computers (Models I/III and Model 4) support up to four physical floppy (mini-diskette) drives which (as sold) use 5¼-inch diskettes. The original TRSDOS for the Model I supported only single-sided disks with 35 tracks formatted in single density (sectors are encoded using the frequency modulation technique). Model III TRSDOS (culminating in version 1.3) supported 40-track disks formatted in double density (using modified frequency modulation). Model Is retrofitted with double density controllers and Models I/III equipped with 80-track drives or double-sided drives could not use TRSDOS; RadioShack sold Logical System's LDOS operating system which could control these types of drives. The Model 4's TRSDOS 6 is a development of LDOS and has the same capabilities.

Hard disk drives (then also known as Winchester 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. A large hard drive could be formatted with more than eight partitions, but TRSDOS can only access eight drives 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 could also create and use a ramdisk (Memdisk), which would then also require a drive number assigned to it.

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 (including its extents, if any). 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 (unless the file is written to and more disk space needs to be allocated). For this reason system performance depends greatly on how close a file's allocated disk space(s) is/are to the directory cylinder, and how fragmented (having extents located in non-contiguous locations) the file is. 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 a command, which displays 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 (file extension /SYS) must always be present in whichever drive is assigned as logical drive number zero. (On the Model 4 this may be the Memdisk, thus freeing physical drive zero be used for a non-system data disk). 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 in a way 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 (write protection) purposes. (Drives may also be set by the DOS to be write protected.)

Disk management The primary function of any disk 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 a Drive Control Table in Z80 memory within TRSDOS that stores the parameters associated with each of the eight logical drives. Disk drive parameters control how the total storage space on a drive is divided up into addressable units. The layer(s) of magnetic particles on the surface of the disk media are magnetized (during the format process) 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 (and in each granule) 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, although 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 (surface) 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 (such as extending a file while being written to), 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 edge of the disk giving the innermost track the highest number. Where multiple-head 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 (for hard drives with multiple platters of storage media) 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 (and access time) 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 (GAT). The GAT is bitmapped to each granule of space on the drive. Other fields in the GAT contain the pack name, date of creation (when the disk was formatted), 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 (HIT) 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 (up to 34 sectors). 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 (Partitioned Data Set) 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 (or End Of File). The record also contains the physical area(s) in use by the file, by pointing to the cylinder, relative starting granule, and number of contiguous granules for each extent comprising 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. Thus the theoretical maximum of 256 files possible on a floppy diskette is realizable only if there is no file fragmentation.