Global Information Lookup Global Information

Program Segment Prefix information


The Program Segment Prefix (PSP) is a data structure used in DOS systems to store the state of a program. It resembles the Zero Page in the CP/M operating system. The PSP has the following structure:

Offset Size Contents
00h–01h 2 bytes (code) CP/M-80-like exit (always contains INT 20h)[1][2]
02h–03h word (2 bytes) Segment of the first byte beyond the memory allocated to the program
04h byte Reserved
05h–09h 5 bytes (code) CP/M-80-like far call entry into DOS, and program segment size[1][3]
0Ah–0Dh dword (4 bytes) Terminate address of previous program (old INT 22h)
0Eh–11h dword Break address of previous program (old INT 23h)
12h–15h dword Critical error address of previous program (old INT 24h)
16h–17h word Parent's PSP segment (usually COMMAND.COM - internal)
18h–2Bh 20 bytes Job File Table (JFT) (internal)
2Ch–2Dh word Environment segment
2Eh–31h dword SS:SP on entry to last INT 21h call (internal)
32h–33h word JFT size (internal)
34h–37h dword Pointer to JFT (internal)
38h–3Bh dword Pointer to previous PSP (only used by SHARE in DOS 3.3 and later)
3Ch–3Fh 4 bytes Reserved
40h–41h word DOS version to return (DOS 5 and later, alterable via SETVER in DOS 5 and later)
42h–4Fh 14 bytes Reserved
50h–52h 3 bytes (code) Unix-like far call entry into DOS (always contains INT 21h + RETF)
53h–54h 2 bytes Reserved
55h–5Bh 7 bytes Reserved (can be used to make first FCB into an extended FCB)
5Ch–6Bh 16 bytes Unopened Standard FCB 1
6Ch–7Fh 20 bytes Unopened Standard FCB 2 (overwritten if FCB 1 is opened)
80h 1 byte Number of bytes on command-line
81h–FFh 127 bytes Command-line tail (terminated by a 0Dh)[4][5]

The PSP is most often used to get the command line arguments of a DOS program; for example, the command "FOO.EXE /A /F" executes FOO.EXE with the arguments '/A' and '/F'.

If the PSP entry for the command line length is non-zero and the pointer to the environment segment is neither 0000h nor FFFFh, programs should first try to retrieve the command line from the environment variable %CMDLINE% before extracting it from the PSP. This way, it is possible to pass command lines longer than 126 characters to applications.

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.[6]

Alternatively, in .COM programs loaded at offset 100h, one can address the PSP directly just by using the offsets listed above. Offset 000h points to the beginning of the PSP, 0FFh points to the end, etc.

For example, the following code displays the command line arguments:

org   100h      ; .COM - not using ds

; INT 21h subfunction 9 requires '$' to terminate string
xor   bx,bx
mov   bl,[80h]
cmp   bl,7Eh
 ja   exit      ; preventing overflow

mov   byte [bx+81h],'$'

; print the string
mov   ah,9
mov   dx,81h
int   21h

exit:
mov   ax,4C00h  ; subfunction 4C
int   21h

In DOS 1.x, it was necessary for the CS (Code Segment) register to contain the same segment as the PSP at program termination, thus standard programming practice involved saving the DS register (since the DS register is loaded with the PSP segment) along with a zero word to the stack at program start and terminating the program with a RETF instruction, which would pop the saved segment value off the stack and jump to address 0 of the PSP, which contained an INT 20h instruction.

; 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

If the executable was a .COM file, this procedure was unnecessary and the program could be terminated merely with a direct INT 20h instruction or else calling INT 21h function 0. However, the programmer still had to ensure that the CS register contained the segment address of the PSP at program termination. Thus,

jmp   start

mess1 db 'Hello world!$'

start:
mov   dx,mess1
mov   ah,9
int   21h

int   20h

In DOS 2.x and higher, program termination was accomplished instead with INT 21h function 4Ch which did not require the CS register to contain the segment value of the PSP.

  1. ^ a b Cite error: The named reference Taylor_1982_Translators was invoked but never defined (see the help page).
  2. ^ Cite error: The named reference Paul_2002_COM was invoked but never defined (see the help page).
  3. ^ Cite error: The named reference Necasek_2011_CALL5 was invoked but never defined (see the help page).
  4. ^ Cite error: The named reference Paul_1997_MSDOS was invoked but never defined (see the help page).
  5. ^ Cite error: The named reference Paul_1997_4DOSTIP was invoked but never defined (see the help page).
  6. ^ Cite error: The named reference R1 was invoked but never defined (see the help page).

and 24 Related for: Program Segment Prefix information

Request time (Page generated in 0.9082 seconds.)

Program Segment Prefix

Last Update:

The Program Segment Prefix (PSP) is a data structure used in DOS systems to store the state of a program. It resembles the Zero Page in the CP/M operating...

Word Count : 1558

File Control Block

Last Update:

Program Segment Prefix (PSP). Relevant fields within this structure include: This data structure could be found at the beginning of the data segment whose...

Word Count : 1598

DOS MZ executable

Last Update:

EXE program run by DOS is found in its Program Segment Prefix. EXE files normally have separate segments for the code, data, and stack. Program execution...

Word Count : 614

PSP

Last Update:

microcontrollers Personal software process, development process Program Segment Prefix, DOS data structure Python Server Pages, for embedding Python in...

Word Count : 358

A20 line

Last Update:

to +7) in the Program Segment Prefix (PSP) (which partially resembles CP/M-80's zero page). This was, in particular, utilized by programs machine-translated...

Word Count : 4913

Process control block

Last Update:

bottom of the process stack. Thread control block (TCB) Program segment prefix (PSP) Data segment "Process Control Block | Baeldung on Computer Science"...

Word Count : 754

Job File Table

Last Update:

The Job File Table (JFT) is a DOS data structure in the Program Segment Prefix (PSP). It starts at PSP offset 0x18 and is 20 bytes long. For each open...

Word Count : 229

Process identifier

Last Update:

User identifier (UID) Group identifier (GID) Handle (computing) Program Segment Prefix (PSP) comp.unix.aix Frequently Asked Questions, retrieved 2008-07-21...

Word Count : 643

Windows 95

Last Update:

starting a program, even a native 32-bit Windows program, MS-DOS momentarily executes to create a data structure known as the Program Segment Prefix. It is...

Word Count : 5974

Prefix code

Last Update:

requires that there is no whole code word in the system that is a prefix (initial segment) of any other code word in the system. It is trivially true for...

Word Count : 1517

Commodore 128

Last Update:

what chip sees what.[citation needed] In CP/M mode, the Program Segment Prefix and Transient Program Area reside in Bank 1 and the I/O registers and CP/M...

Word Count : 7351

Prefix sum

Last Update:

form the basis of the scan higher-order function in functional programming languages. Prefix sums have also been much studied in parallel algorithms, both...

Word Count : 5242

SoftRAM

Last Update:

becoming full. Windows needed to allocate a Program Segment Prefix (PSP) in this area of memory for each program started. Some utilities prevented DLLs from...

Word Count : 1162

X86 memory segmentation

Last Update:

The instruction format allows an optional segment prefix byte which can be used to override the default segment for selected instructions if desired. In...

Word Count : 3020

IP address

Last Update:

network segment, i.e. the local administration of the segment's available space, from the addressing prefix used to route traffic to and from external networks...

Word Count : 4169

Hexadecimal

Last Update:

hexadecimal as 6F8016. In programming, several notations denote hexadecimal numbers, usually involving a prefix. The prefix 0x is used in C, which would...

Word Count : 5715

Kolmogorov complexity

Last Update:

and prefix-free. The plain complexity is the minimal description length of any program, and denoted C ( x ) {\displaystyle C(x)} while the prefix-free...

Word Count : 7143

Timeline of DOS operating systems

Last Update:

microcomputers (advertisement)". Electronics. pp. 44–45. "2,048-bit erasable PROM programs in two minutes". Electronics. 1973-01-04. p. 139. Sideris, George (1973-03-01)...

Word Count : 7232

Imperative programming

Last Update:

computer science, imperative programming is a programming paradigm of software that uses statements that change a program's state. In much the same way...

Word Count : 3585

URL

Last Update:

more path segments that do not refer to an existing physical resource name (e.g. a file, an internal module program or an executable program) but to a...

Word Count : 2233

X86

Last Update:

by setting all four segment registers once and then only using 16-bit offsets (optionally with default-segment override prefixes) to address memory, but...

Word Count : 10771

Computer program

Last Update:

A computer program is a sequence or set of instructions in a programming language for a computer to execute. It is one component of software, which also...

Word Count : 13233

X86 instruction listings

Last Update:

where the DS segment is indicated, the DS segment can be overridden by a segment-override prefix – where the ES segment is indicated, the segment is always...

Word Count : 15580

GPSS

Last Update:

The "program" is comprised between the SIMULATE and END statements, and is divided into "model segments" and "control cards". The first segment models...

Word Count : 3003

PDF Search Engine © AllGlobal.net