Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
What is Program Segment Prefix mean?
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:
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) 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.
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,
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.
referencePosted on 30 Apr 2022, this text provides information on Miscellaneous in Computing related to Computing. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
Ever curious about what that abbreviation stands for? fullforms has got them all listed out for you to explore. Simply,Choose a subject/topic and get started on a self-paced learning journey in a world of fullforms.
Write Your Comments or Explanations to Help Others