Program Segment Prefix: Difference between revisions

Content deleted Content added
Commented out faulty example until the code gets fixed. Not a good idea to give faulty examples. Some formatting.
Asmpgmr (talk | contribs)
add fields; mention Int 21h function 51h which is the same as Int 21h function 62h
Line 58:
| Pointer to JFT (internal)
|-
| 38h-4Fh3Bh
| dword
| 24 bytes
| Pointer to previous PSP (only used by SHARE in DOS 3.3 and later)
|-
| 3Ch-3Fh
| 244 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
|-
Line 89 ⟶ 101:
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 [[interrupt]]Int 21h subfunctionfunction 51h or Int 21h function 62h. ThisEither interruptfunction will return the PSP address in register BX.<ref>{{cite web|url=http://www.htl-steyr.ac.at/~morg/pcinfo/hardware/interrupts/inte8fjk.htm|title=INT 21h,62h - Get PSP address (DOS 3.x)}}</ref>
 
Alternatively, in [[.COM]] programs loaded at offset <tt>100h</tt>, one can address the PSP directly just by using the offsets listed above. Offset <tt>000h</tt> points to the beginning of the PSP, <tt>0FFh</tt> points to the end, etc.