Function  51h    "Used Internally by DOS" - Get Program Segment Prefix 

* Returns the PSP address of currently executing program

entry AH 51h

return BX address of currently executing program

offset

00h program exit point

02h memory size in paragraphs

04h unused (0)

05h CP/M style entry point (far call to DOS)

0Ah terminate address (old int 22h)

0Ch terminate segment

0Eh break address (old int 23h)

10h break segment

12h error address (old int 24h)

14h error segment

16h parent PSP segment

18h DOS 2.0+ open files, 0FFh = unused

2Ch DOS 2.0+ environment segment

2Eh far ptr to process's SS:SP

32h DOS 3.x max open files

34h DOS 3.x openfile table address

36h DOS 3.x openfile table segment

38h unused by DOS versions struct#fcb">= 3.3

50h DOS function dispatcher (FAR routine)

53h unused

55h Struct -FCB #1 extension

5Ch Struct -FCB #1

6Ch Struct -FCB #2

80h command tail / default DTA buffer

note 1) Used in DOS 2.x, 3.x uses 62h

2) Function 51h is dangerous in background operations prior to DOS 3.x as

it uses the wrong stack for saving registers. (same as functions

0..0Ch in DOS 2.x)

3) 50h and 51h might be used if you have more than one process in a PC.

For instance if you have a resident program that needs to open a file

you could first call 51h to save the current id and then call 50h to set

the ID to your PSP.

4) Under DOS 2.x, this function cannot be invoked inside an int 28h handler

without setting the Critical Error flag

5) Used by DOS 3.3 PRINT, DEBUG