The Program Segment Prefix (PSP) is a data structure used in DOS systems to store the state of a program. It resembles the Zero Page in the CP/M operating system. The PSP has the following structure:
Offset | Size | Contents |
---|---|---|
00h-01h | 2 bytes (code) | CP/M exit (always contain INT 20h) |
02h-03h | word (2 bytes) | Memory size in paragraphs |
04h | byte | Reserved |
05h-09h | 5 bytes (code) | Far call to CP/M compatibility code within DOS |
0Ah-0Dh | dword (4 bytes) | Terminate address of previous program (old INT 22h) |
0Eh-11h | dword | Break address of previous program (old INT 23h) |
12h-15h | dword | Critical error address of previous program (old INT 24h) |
16h-17h | word | Caller's PSP segment (usually COMMAND.COM - internal) |
18h-2Bh | 20 bytes | Job File Table (JFT) (internal) |
2Ch-2Dh | word | Environment segment |
2Eh-31h | dword | SS:SP on entry to last INT 21h call (internal) |
32h-33h | word | JFT size (internal) |
34h-37h | dword | Pointer to JFT (internal) |
38h-3Bh | dword | Pointer to previous PSP (only used by SHARE in DOS 3.3 and later) |
3Ch-3Fh | 4 bytes | Reserved |
40h-41h | word | DOS version to return (DOS 4 and later, alterable via SETVER in DOS 5 and later) |
42h-4Fh | 14 bytes | Reserved |
50h-52h | 3 bytes (code) | Far call to DOS (always contain INT 21h + RETF) |
53h-5Bh | 9 bytes | Reserved |
5Ch-6Bh | 16 bytes | Unopened Standard FCB 1 |
6Ch-7Fh | 20 bytes | Unopened Standard FCB 2 (overwritten if FCB 1 is opened) |
80h | 1 byte | Number of bytes on command-line |
81h-FFh | 127 bytes | Command-line (terminated by a 0Dh) |
The PSP is most often used to get the command line arguments of a DOS program, for example the command "FOO.EXE /A /F" executes FOO.EXE with the arguments '/A' and '/F'.
The segment address of the PSP is passed in the DS register when the program is executed. It can also be determined later by using Int 21h function 51h or Int 21h function 62h. Either function will return the PSP address in register BX.
Alternatively, in .COM programs loaded at offset 100h, one can address the PSP directly just by using the offsets listed above. Offset 000h points to the beginning of the PSP, 0FFh points to the end, etc.
Famous quotes containing the word program:
“He believes without reservation that Kentucky is the garden spot of the world, and is ready to dispute with anyone who questions his claim. In his enthusiasm for his State he compares with the Methodist preacher whom Timothy Flint heard tell a congregation that Heaven is a Kentucky of a place.”
—For the State of Kentucky, U.S. public relief program (1935-1943)