CodeView Inserts an Additional Space in PSP Command Tail

ID Number: Q69583

3.00 3.10 3.11 3.14

MS-DOS

Summary:

The Program Segment Prefix (PSP) is created when a program is loaded

into memory. One of the items it contains is the command tail of the

executed file. Any item that is typed in at the DOS prompt after the

filename will be placed into this tail. The length of the command tail

is stored in the 128th byte of the PSP and its contents start at the

129th byte.

Whenever a program is run under CodeView, an extra space is added to

the beginning of the command tail, and the total length is increased

by one. For example, if the sample code below is run from the DOS

prompt with the command

test one

where "test" is the name of the program, the output is:

4 one

If the sample code belows is run from within CodeView, the output is:

5 one

More Information:

Another way to access this information is with the command-line

arguments argc and argv. The total number of command-line arguments is

indicated by argc, while argv is an array of strings, which contains

the arguments.

Code Example

------------

/* Compile options needed: none

*/

#include <stdio.h>

#include <dos.h>

extern unsigned _psp;

unsigned char far *psp_ptr;

void main(void)

{

FP_SEG(psp_ptr) = _psp;

FP_OFF(psp_ptr) = 0;

printf("%d%c", psp_ptr[128], psp_ptr[129]);

printf("%c%c", psp_ptr[130], psp_ptr[131]);

printf("%c%c", psp_ptr[132], psp_ptr[133]);

}