Int 21H [3.0] Function 62H (98) Get PSP address

Obtains the segment (paragraph) address of the program segment prefix (PSP) for the currently executing program.

Call with:

AH = 62H

Returns:

BX = segment address of program segment prefix

Notes:

Before a program receives control from MS-DOS, its program segment prefix is set up to contain certain vital information, such as:

the segment address of the program's environment block

the command line originally entered by the user

the original contents of the terminate, Ctrl-C, and critical-error handler vectors

the top address of available RAM

The segment address of the PSP is normally passed to the program in registers DS and ES when it initially receives control from MS-DOS. This function allows a program to conveniently recover the PSP address at any point during its execution, without having to save it at program entry.

Example:

Get the segment base of the program segment prefix, then copy the command tail from the PSP into the local buffer named buff.

ctail equ 080H ; PSP offset, command tail

buff db 80 dup (?) ; copy of command tail

.

.

.

; get PSP address

mov ah,62H ; function number

int 21h ; transfer to MS-DOS

; copy command tail

mov ds,bx ; PSP segment to DS

mov si,offset ctail ; offset of command tail

mov di,seg buff ; local buffer address

mov es,di

mov di,offset buff

mov cl,[si] ; length of command tail

inc cl ; include count byte

xor ch,ch

cld

rep movsb ; copy to local buffer

.

.

.