Program segment prefix

from Wikipedia, the free encyclopedia

As a program segment ( English program segment prefix , PSP) refers to the first 256 bytes of a of MS-DOS program loaded. The PSP is not included in the executable Exe or COM files , but is created by the operating system when the program is loaded . The first half of the PSP contains various information for the operating system, in particular for handling several (one after the other) executed programs. The second half contains the command line ( command tail , without the actual name of the program).

structure

Offset (hexadecimal)
00 - 01 Interrupt -20h – Command to end the program after jumping to address 0000h
02 - 03 Segment address of the first memory that is no longer occupied by the program
05 - 09 Code to execute interrupt 21h with a NEAR CALL to address 0005h
0A - 0D Copy of interrupt vector 22h, return address after ending the program
0E - 11 Copy of the interrupt vector 23h, interrupt for Ctrl-C
12-15 Copy of the interrupt vector 24h, interrupt for fatal errors
16-17 Parent PSP segment: the program that executed this program
18-2B Standard Job File Table (JFT), each contains a file table number (System File Table, SFT) for up to 20 file handles
2C - 2D Environment variable block segment for this program
2E - 31 Address of the stack when interrupt 21h was last executed
32 - 33 Number of all file handles in the JFT, 20 by default
34 - 37 Address of the current JFT, standard offset 0018h in this PSP
50-52 Code to execute interrupt 21h with a FAR CALL to address 0050h
5C-6B File Control Block (FCB) of the first parameter on the command line
6C-7B FCB of the second parameter
80 Length of the command line
81 - FF Command line with all parameters, but without the command name itself
80 - AB Overwritten by the standard Disk Transfer Area (DTA) during file searches

Other areas of the PSP are used by operating system extensions or some TSR programs .

Sample program

This program shows the command line from its PSP: ( COM file , written in assembly language )

org  100h

; Interrupt 21h, Funktion 09h benötigt ein Dollarzeichen als Endmarkierung
mov  bl, byte [0080h]
xor  bh, bh
mov  byte [0081h+bx], '$'

; Ausgabe der Kommandozeile (bis zum ersten Dollarzeichen) mit Funktion 09h
mov  ah, 09h
mov  dx, 0081h
int  21h

; Beenden des Programmes mit Funktion 4Ch, Rückgabewert 00h
mov  ax, 4C00h
int  21h