Chapter
2
I
MS-DOS
Control
Blocks
and
Work Areas
At
offset 0 within the Program Segment, MS-DOS builds the
256-byte Program Segment Prefix control block. At offset 200H,
EXEC loads the program. An .EXEfile with minalloc and max-
alloc both set
to
zero is loaded as high
as
possible.
The program returns from EXEC
by
one
of
four methods:
0
By
a
long jump to offset 0 in the Program Segment Prefix.
0
By issuing an INT 20H with CS:O pointing
at
the PSP
0
By issuing an INT 21H with AH
=
0 and with CS:0 pointing
0
By
a
long call
to
location 50H in the Program Segment Prefix
All programs must ensure the CS register contains the segment
address
of
the Program Segment Prefix when using any
of
these
methods except function call 4CH.
For
this reason, function call
4CH is the preferred method.
All four methods result in transferring control
to
the program
that issued the EXEC. During this returning process, interrupt
vectors 22H, 23H, and 24H (Terminate Address, CONTROL-C
Exit Address, and Fatal Error Abort Address) are restored from
the values saved in the Program Segment Prefix
of
the terminat-
ing program. Control is then given
to
the terminate address. If
this is a program returning
to
COMMAND.COM, control trans-
fers to its resident portion. If a batch file was in process, it is
continued. Otherwise, COMMAND.COM performs
a
checksum
on the transient portion, reloads it if necessary, issues the sys-
tem prompt, and waits
for
you
to
type the next command.
When
a
program receive control, the following conditions are in
effect:
For all programs:
The segment address
of
the passed environment is contained
The environment is
a
series
of
ASCII strings (totaling less
at
the PSP, or with AH
=
4CH
with AH
=
0
or
4CH
at
offset 2CH in the Program Segment Prefix.
than 32K) in the form:
NAME
=
parameter
154