Program Segment Prefix: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Removed parameters. | Use this bot. Report bugs. | Suggested by Whoop whoop pull up | Category:DOS technology | #UCB_Category 28/82
Cvpines (talk | contribs)
m Fixed broken links
 
(3 intermediate revisions by 3 users not shown)
Line 2:
{{Use dmy dates|date=May 2019|cs1-dates=y}}
{{Use list-defined references|date=December 2021}}
{{TOC right}}
The '''Program Segment Prefix''' (PSP) is a data structure used in [[DOS]] systems to store the state of a [[computer program|program]]. It resembles the [[Zero page (CP/M)|Zero Page]] in the [[CP/M]] operating system. The PSP has the following structure:
 
Line 11 ⟶ 12:
| 00h–01h
| 2 bytes (code)
| [[CP/M-80]]-like<!-- not CP/M-86! --> exit (always contains [[DOS_API#Interrupt_vectors_used_by_DOS|INT 20h]])<ref name="Taylor_1982_Translators"/><ref name="Paul_2002_COM"/>
|-
| 02h–03h
Line 27 ⟶ 28:
| 0Ah–0Dh
| [[dword]] (4 bytes)
| Terminate address of previous program (old [[DOS_API#Interrupt_vectors_used_by_DOS|INT 22h]])
|-
| 0Eh–11h
| dword
| Break address of previous program (old [[DOS_API#Interrupt_vectors_used_by_DOS|INT 23h]])
|-
| 12h–15h
| dword
| Critical error address of previous program (old [[DOS_API#Interrupt_vectors_used_by_DOS|INT 24h]])
|-
| 16h–17h
Line 71 ⟶ 72:
| 40h–41h
| word
| DOS version to return (DOS 45 and later, alterable via SETVER in DOS 5 and later)
|-
| 42h–4Fh
Line 137 ⟶ 138:
</syntaxhighlight>
 
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 to the stack at program start (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.
 
<syntaxhighlight lang="nasm">