Note: This API call is for DOS and Win16 personality only. Use Family API for portability.

Int 21H, AH=26H

Version

1 and higher

Brief

CREATE NEW PROGRAM SEGMENT PREFIX

Family API

Input

AH = 26h
DX = segment at which to create PSP (see #01378)

Return

Return: AL destroyed

Notes

new PSP is updated with memory size information; INTs 22h, 23h, 24h
taken from interrupt vector table; the parent PSP field is set to 0
(DOS 2+) DOS assumes that the caller's CS is the segment of the PSP to
copy

BUG: DR DOS 6.0 original releases 05/1991 & 08/1991 had a problem where the

segment from which the PSP was copied was incorrect so that the PSP
was not filled correctly and did not contain the command tail. The
DR DOS 6.0 BDOS patch "PAT312" English (1992/01/07, XDIR /C: A0C6h)
and later "full" rebuilds fix this problem (see INT 21/AX=4452h).

Format of Program Segment Prefix (PSP): Offset Size Description (Table 01378) 00h 2 BYTEs INT 20 instruction for CP/M CALL 0 program termination

the CDh 20h here is often used as a signature for a valid PSP

02h WORD segment of first byte beyond memory allocated to program 04h BYTE (DOS) unused filler

(OS/2) count of fake DOS version returns

05h BYTE CP/M CALL 5 service request (FAR CALL to absolute 000C0h)

BUG: (DOS 2+ DEBUG) PSPs created by DEBUG point at 000BEh

06h WORD CP/M compatibility–size of first segment for .COM files 08h 2 BYTEs remainder of FAR JMP at 05h 0Ah DWORD stored INT 22 termination address 0Eh DWORD stored INT 23 control-Break handler address 12h DWORD DOS 1.1+ stored INT 24 critical error handler address 16h WORD segment of parent PSP 18h 20 BYTEs DOS 2+ Job File Table, one byte per file handle, FFh = closed 2Ch WORD DOS 2+ segment of environment for process (see #01379) 2Eh DWORD DOS 2+ process's SS:SP on entry to last INT 21 call 32h WORD DOS 3+ number of entries in JFT (default 20) 34h DWORD DOS 3+ pointer to JFT (default PSP:0018h) 38h DWORD DOS 3+ pointer to previous PSP (default FFFFFFFFh in 3.x)

used by SHARE in DOS 3.3

3Ch BYTE DOS 4+ (DBCS) interim console flag (see AX=6301h)

Novell DOS 7 DBCS interim flag as set with AX=6301h
(possibly also used by Far East MS-DOS 3.2-3.3)

3Dh BYTE (APPEND) TrueName flag (see INT 2F/AX=B711h) 3Eh BYTE (Novell NetWare) flag: next byte initialized if CEh

(OS/2) capabilities flag

3Fh BYTE (Novell NetWare) Novell task number if previous byte is CEh 40h 2 BYTEs DOS 5+ version to return on INT 21/AH=30h 42h WORD (MSWindows3) selector of next PSP (PDB) in linked list

Windows keeps a linked list of Windows programs only

44h WORD (MSWindows3) “PDB_Partition” 46h WORD (MSWindows3) “PDB_NextPDB” 48h BYTE (MSWindows3) bit 0 set if non-Windows application (WINOLDAP) 49h BYTE unused by DOS versions ⇐ 6.00 4Ch WORD (MSWindows3) “PDB_EntryStack” 4Eh 2 BYTEs unused by DOS versions ⇐ 6.00 50h 3 BYTEs DOS 2+ service request (INT 21/RETF instructions) 53h 2 BYTEs unused in DOS versions ⇐ 6.00 55h 7 BYTEs unused in DOS versions ⇐ 6.00; can be used to make first FCB

into an extended FCB

5Ch 16 BYTEs first default FCB, filled in from first commandline argument

overwrites second FCB if opened

6Ch 16 BYTEs second default FCB, filled in from second commandline argument

overwrites beginning of commandline if opened

7Ch 4 BYTEs unused 80h 128 BYTEs commandline / default DTA

command tail is BYTE for length of tail, N BYTEs for the tail,
followed by a BYTE containing 0Dh

Notes: in DOS v3+, the limit on simultaneously open files may be increased by

allocating memory for a new open file table, filling it with FFh,
copying the first 20 bytes from the default table, and adjusting the
pointer and count at 34h and 32h. However, DOS will only copy the
first 20 file handles into a child PSP (including the one created on
EXEC).
in an OS/2 DOS box, values of D0h-FEh in the open file table indicate
device drivers
network redirectors based on the original MS-Net implementation use
values of 80h-FEh in the open file table to indicate remote files;
Novell NetWare also uses values from FEh down to 80h or one more than
FILES= (whichever is greater) to indicate remote files (except on
OS/2, where is uses CFh down to 80h)
MS-DOS 5.00 incorrectly fills the FCB fields when loading a program
high; the first FCB is empty and the second contains the first
parameter
some DOS extenders place protected-mode values in various PSP fields
such as the "parent" field, which can confuse PSP walkers. Always
check either for the CDh 20h signature or that the suspected PSP is
at the beginning of a memory block which owns itself (the preceding
paragraph should be a valid MCB with "owner" the same as the
suspected PSP).
Novell NetWare updates the fields at offsets 3Eh and 3Fh without
checking that a legal PSP segment is current; see AH=50h for further
discussion
for 4DOS and Windows95, the command tail may be more than 126
characters; in that case, the length byte will be set to 7Fh (with
an 0Dh in the 127th position at offset FFh), and the first 126
characters will be stored in the PSP, with the entire command line
in the environment variable CMDLINE; under at least some versions
of 4DOS, the byte at offset FFh is *not* set to 0Dh, so there is no
terminating carriage return in the PSP's command tail.

BUG: When shelling out from the Borland Pascal 7.00 IDE, overly-long

command lines will not be delimited by a 0Dh character, and the
length byte is set to 80h! A workaround is to always patch in a
0Dh at the last position of the command line buffer before scanning
the command line.

Format of environment block: Offset Size Description (Table 01379) 00h N BYTEs first environment variable, ASCIZ string of form “var=value”

N BYTEs second environment variable, ASCIZ string
...
N BYTEs last environment variable, ASCIZ string of form "var=value"
BYTE 00h

—DOS 3.0+ —

WORD number of strings following environment (normally 1)
N BYTEs ASCIZ full pathname of program owning this environment
other strings may follow

See also

AH=4Bh,AH=50h,AH=51h,AH=55h,AH=62h,AH=67h

Note

Text based on Ralf Brown Interrupt List Release 61

DOS API
Process manager	INT 20H, INT 21H: 00H, 25H, 26H, 31H, 34H, 35H, 4BH, 4CH, 4DH, 50H, 51H, 52H, 55H, 62H, INT 22H, INT 27H, INT 28H
File manager	INT 25H, INT 26H, INT 21H: 0DH, 0EH, 0FH, 10H, 11H, 12H, 13H, 14H, 15H, 16H, 17H, 19H, 1AH, 1BH, 1CH, 21H, 22H, 23H, 24H, 27H, 28H, 29H, 2EH, 2FH, 32H, 3305H, 36H, 39H, 3AH, 3BH, 3CH, 3DH, 3EH, 3FH, 40H, 41H, 42H, 4300H, 4301H, 45H, 45H, 46H, 4EH, 4FH, 54H, 56H, 5700H, 5701H, 5AH, 5BH, 5c00H, 5c01H, 60H, 67H, 68H, 6900H, 6901H, 6AH, 6CH
Character Device I/O	INT 29H, INT 21H: 01H, 02H, 03H, 04H, 05H, 06H, 07H, 08H, 09H, 0AH, 0BH, 0AH, 0CH, 5D07H, 5D08H, 5D09H, 5D0AH
Signals	INT 23H, INT 24H, INT 21H: 3300H, 3301H, 3302H
Memory manager	INT 21H: 48H, 49H, 4AH, 5800H, 5801H, 5802H, 5803H
Date and Time	INT 21H: 2AH, 2BH, 2CH, 2DH
Misc	INT 21H: 30H, 3306H, 3700H, 3701H, 3702H, 3703H, 59H
NLS	INT 21H: 3303H, 3304H, 3800H, 3801H, 6300H, 6301H, 6301H, 6500H, 6501H, 6502H, 6503H, 6504H, 6505H, 6506H, 6507H, 6520H, 6521H, 6522H, 6523H, 65A0H, 65A1H, 65A2H, 6601H, 6602H
Devices	INT 21H: 4400H, 4401H, 4402H, 4403H, 4404H, 4405H, 4406H, 4407H, 4408H, 4409H, 440AH, 440BH, 440CH, 440DH, 440EH, 440FH, 4410H, 4411H, 53H
Network	INT 21H: 5E00H, 5E01H, 5E02H, 5E03H, 5E04H, 5E05H, 5F00H, 5F01H, 5F02H, 5F03H, 5F04H, 5F05H, 5F07H, 5F08H
osFree Macro Library
Video I/O	@SetMode @SetCurSz @SetCurPos @GetCur @SetPage @ScrollUp @ScrollDn @Scroll @GetChAtr @PutChAtr @PutCh @SetPalet @SetColor @SetDot @GetDot @WrtTTY @VideoState @GetMode @GetDisplay @GetVideoState @GetEGAInfo @Cls
Hardware info	@Equipment @MemSize
Serial I/O	@AuxInit @AuxSendChar @AuxRecieveChar @AuxStatus
Tape I/O	@TapeOn @TapeOff @TapeRead @TapeWrite
Keyboard I/O	@KbdStatus @CharIn @CharPeek
Printer I/O	@PrnPrint @PrnInit @PrnStatus
Disk I/O	@DskReset @DskStatus @DskRead @DskWrite @DskVerify @DskFormat
Date and Time	@SetTime @GetTime
Mouse	@MouInit @MouShowPointer @MouStatus @MouSetPos @MouSetMickey @MouRegion
Memory manager	@ModBlok SET_BLOCK
Family API
DOS	Process Manager	DosBeep DosExit DosSleep DosExecPgm
File Manager	DosChDir DosChgFilePtr DosClose DosDelete DosDupHandle DosMkDir DosMove DosQCurDir DosQCurDisk DosSetFileMode DosOpen DosQFileInfo DosRead DosQFileMode DosQFSInfo DosQVerify DosRmDir DosSelectDisk DosFindClose DosFindFirst DosFindNext DosSetFileInfo DosSetVerify DosWrite DosFileLocks DosSetFHandState DosNewSize DosBufReset DosQFHandState DosSetFSinfo DosShutdown
Memory Manager	DosFreeSeg DosSubAlloc DosSubFree DosSubSet DosAllocHuge DosAllocSeg DosReallocHuge DosReallocSeg DosGetHugeShift DosCreateCSAlias
NLS	DosCaseMap DosGetCtryInfo DosGetDBCSEv DosSetCtryCode DosGetCollate DosGetMessage DosInsMessage DosPutMessage
Date and Time	DosSetDateTime DosGetDateTime
Devices	DosDevConfig DosDevIOCtl DosDevIOCtl2
Signals	DosHoldSignal DosSetSigHandler
Misc	BadDynLink DosGetEnv DosGetMachineMode DosGetVersion DosError DosErrClass DosSetVec
KBD	KbdCharIn KbdFlushBuffer KbdGetStatus KbdSetStatus KbdStringIn KbdPeek
VIO	VioGetBuf VioGetConfig VioGetCurPos VioGetCurType VioGetPhysBuf VioReadCellStr VioReadCharStr VioScrollUp VioScrollDn VioScrollLf VioScrollRt VioScrUnLock VioSetCurPos VioSetCurType VioSetMode VioGetMode VioShowBuf VioWrtCellStr VioWrtCharStr VioWrtCharStrAtt VioWrtNAttr VioWrtNCell VioWrtNChar VioWrtTTY VioScrLock VioPopUp
Tools	BIND
Modules	DOSCALLS.DLL VIOCALLS.DLL KBDCALLS.DLL MSG.DLL
Libraries	API.LIB OS2386.LIB FAPI.LIB DOSCALLS.LIB SUBCALLS.LIB