| Table of Contents |
This appendix details some of the important functions that DOS provides for an application program.
Program Segment Prefix, Etc.
When DOS hands over control of the CPU to a .EXE program, some of the registers are preset with data. In order for the program to run, it must preset the CS:IP registers to index the start of the application program execution logic. The SS:SP stack area is preset. The data values in DS and ES will be predefined to index the Program Segment Prefix (PSP). Inside the PSP, there are two areas of general importance: the environment pointer at location 2CH and the command line data string starting at location 80H. The byte at location 80H tells how many bytes of command line data follow starting at 81H. The data word at 2CH is a segment offset to index the start of the environment passed by the calling process. The environment data area contains ASCII strings of information like PATH=C:\. The environment can be seen at the DOS prompt by entering the SET command.
Example:
From a DOS command prompt, you enter the following line:
| MODE CO80,43 |
DOS then tries to execute MODE.COM and passes the following ASCII data string in the PSP data area at DS:81H (note that the first character will be a space):
| CO80,43 |
with the value 9 at 80H
DOS Calling
Most DOS calls are made through the INT 21H function calls. With a standard DOS function call, you preset register AH with a DOS function code value and the other registers with the necessary data for the called function. Then you execute an INT 21H instruction to pass control of the CPU to DOS until it finishes the task and returns to your program. In general, if it returns with the carry bit set in the Flag register, then the function failed.
A main function of the DOS is to assist in handling files. When an application program calls the DOS to open or create a file, the DOS returns a file handle to the program. This is a 16-bit data word that the program needs to keep track of. When the application tries to access an open file, DOS will require the file handle to reference the correct file. The basic file functions are:
| Table of Contents |