encyclopegia.org

Program Segment Prefix

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: 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'. If the PSP entry for the command line length is non-zero and the pointer to the environment segment is neither 0000h nor FFFFh , programs should first try to retrieve the command line from the environment variable %CMDLINE% before extracting it from the PSP. This way, it is possible to pass command lines longer than 126 characters to applications. 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.…

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: 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'. If the PSP entry for the command line length is non-zero and the pointer to the environment segment is neither 0000h nor FFFFh , programs should first try to retrieve the command line from the environment variable %CMDLINE% before extracting it from the PSP. This way, it is possible to pass command lines longer than 126 characters to applications. 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. For example, the following code displays the command line arguments: org 100h ; .COM - not using ds INT 21h subfunction 9 requires '$' to terminate string xor bx,bx mov bl,[80h] cmp bl,7Eh ja exit ; preventing overflow mov byte [bx+81h],'$' print the string mov ah,9 mov dx,81h int 21h exit: mov ax,4C00h ; subfunction 4C int 21h In DOS 1.x, it was necessary for the CS (Code Segment) register to contain the same segment as the PSP at program termination, thus standard programming practice involved saving the DS register (since the DS register is loaded with the PSP segment) along with a zero word to the stack at program start and terminating the program with a RETF instruction, which would pop the saved segment value off the stack and jump to address 0 of the PSP, which contained an INT 20h instruction. save push ds xor ax,ax push ax move to the default data group (@data) mov ax,@data mov ds,ax print message in mess1 (21h subfunction 9) mov dx,mess1 mov ah,9 int 21h retf If the executable was a .COM file, this procedure was unnecessary and the program could be terminated merely with a direct INT 20h instruction or else calling INT 21h function 0. However, the programmer still had to ensure that the CS register contained the segment address of the PSP at program termination. Thus, jmp start mess1 db 'Hello world!$' start: mov dx,mess1 mov ah,9 int 21h int 20h In DOS 2.x and higher, program termination was accomplished instead with INT 21h function 4Ch which did not require the CS register to contain the segment value of the PSP. ==Further reading== (41 pages) (1123+v pages, foldout, 5.25"-floppy) ==External links== Accessing Command Line Arguments (Microsoft.com)

References

No reference rows published for this article.

Cite this article

MLA

"Program Segment Prefix." encyclopegia.org, 2026, https://encyclopegia.org/wiki/program-segment-prefix. Accessed 24 November 2026.

Chicago

"Program Segment Prefix." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/program-segment-prefix.

APA

encyclopegia.org. (2026). Program Segment Prefix. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/program-segment-prefix

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

List of James Bond vehicles

enwiki · references available

Scranton Button Company

enwiki · references available

Eddie Griffin

enwiki · references available

List of James Bond gadgets

enwiki · references available

List of LGBTQ Jews

enwiki · references available

New South

enwiki · references available

Joss Ackland

enwiki · references available

Karur

enwiki · references available

Lagwagon

enwiki · references available

Kalan Porter

enwiki · references available

Professional wrestling aerial techniques

enwiki · references available

Edgell Rickword

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1353701258 · 0.5 · snapshot enwiki-001353701258

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.