Overview
This section documents the core memory structures that DOS and BIOS rely on for program execution, file I/O, and interrupt handling. Understanding these structures is essential for low-level assembly language programming in the DOS environment.
Disk Transfer Address (DTA)
The DTA is a program-global address through which DOS funnels data during file operations. It is set via DOS function 1aH and queried via 2fH. When a program starts, the DTA defaults to PSP:0080. The DTA is used by the old FCB file I/O functions and by commonly-used services such as 4eH (find first matching file) and 4fH (find next matching file). When performing recursive directory searches, the DTA should be set to an instance-local area at each level.
Full details are available on the DTA reference page.
Program Segment Prefix (PSP)
The PSP is a 256-byte data structure that DOS creates when loading a program. It contains critical information including the command-line tail, the default DTA at offset 80h, and saved interrupt vectors for INT 22H (Terminate), INT 23H (Ctrl-Break), and INT 24H (Critical Error). The PSP also holds the segment address of the environment block and file handle references.
FCB Fields
File Control Blocks (FCBs) are legacy data structures used by DOS for file access before handle-based I/O became standard. An FCB contains fields for the drive code, filename, extension, current block and record numbers, record size, and file size. DOS maintains both standard (37-byte) and extended (44-byte) FCB formats.
Standard Handles
DOS predefines five standard handles for every process:
- 0 — STDIN (standard input)
- 1 — STDOUT (standard output)
- 2 — STDERR (standard error)
- 3 — STDAUX (standard auxiliary)
- 4 — STDPRN (standard printer)
Interrupt Vectors
Several interrupt vectors are stored in the PSP and restored upon program exit:
- INT 22H (Terminate) — stored at
PSP:000a. Points to the code that receives control when the program terminates. - INT 23H (Ctrl-Break) — stored at
PSP:000e. The vector at0000:008chandles Ctrl-Break and Ctrl+C signals. The original handler is restored from the PSP when a program exits, ensuring the parent's handler resumes. DOS invokes INT 23H when it sensesCtrl+C(ASCII 03H) or Ctrl-Break; the level of break sensing can be checked or set via function33H. - INT 24H (Critical Error) — stored at
PSP:0012. Handles critical hardware errors during DOS operations.
Swappable Data Area (SDA)
The Swappable Data Area is an internal DOS structure that holds the state of the currently executing DOS function. It is relevant when writing TSR (Terminate and Stay Resident) programs that must safely invoke DOS services while another DOS call may be in progress.