Content deleted Content added
Artoria2e5 (talk | contribs) No edit summary |
Matthiaspaul (talk | contribs) CE +ref |
||
Line 1:
{{Short description|data structure in DOS}}
{{Use dmy dates|date=May 2019|cs1-dates=y}}
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 106 ⟶ 107:
The PSP is most often used to get the [[argc|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.<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.
Line 113 ⟶ 114:
<source lang="nasm">
org 100h ; .COM - not using ds
; INT 21h subfunction 9 requires '$' to terminate string
Line 119 ⟶ 120:
mov bl, [80h]
cmp bl, 7Eh
ja
mov byte [bx + 81h], '$'
Line 128 ⟶ 130:
exit:
mov ax, 4C00h ; subfunction 4C
int 21h
</source>
Line 135 ⟶ 137:
<source lang="nasm">
; 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
Line 155 ⟶ 157:
<source lang="nasm">
jmp start
mess1 db 'Hello world!$'
start:
mov dx, mess1
mov ah, 9
int 21h
int 20h
</source>
Line 176 ⟶ 178:
== References ==
{{reflist
<ref name="R1">{{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) |url-status=dead |archive-url=https://web.archive.org/web/20120207062050/http://www.htl-steyr.ac.at/~morg/pcinfo/hardware/interrupts/inte8fjk.htm |archive-date=2012-02-07}}</ref>
}}
==Further reading==
* {{cite web |title=Format of Program Segment Prefix (PSP) |date=2000 |work=[[INTER61]] |url=http://www.delorie.com/djgpp/doc/rbinter/it/78/13.html |access-date=2019-12-19 |url-status=live |archive-url= |archive-date=}}
==External links==
* [http://support.microsoft.com/kb/123729 Accessing Command Line Arguments] (Microsoft.com)
[[Category:DOS technology]]
|