How to Find the Load Size Required for a ProgramLast reviewed: July 17, 1997Article ID: Q59768 |
6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS | WINDOWSkbprg The information in this article applies to:
SUMMARYThe final allocated segment within a program is stored in the second word of its program segment prefix (PSP). To find the size of the program in paragraphs, subtract the actual segment of the PSP from this segment number. This is useful in a number of applications, and can be used to find the amount of memory necessary to store a TSR (terminate-and-stay-resident) program.
MORE INFORMATIONIn Microsoft C, the segment of the PSP is stored in the global variable _psp. This makes program load size easily accessible within C programs as demonstrated below. For more information on the PSP, see the "MS-DOS Encyclopedia," pages 108-111. NOTE: The "MS_DOS Encyclopedia" is no longer being published. However, there are other third party reference books available that discuss the PSP.
Sample Code
#include<dos.h> extern unsigned _psp; /* segment of PSP */ unsigned size; /* size of program in paragraphs */ unsigned far *psp_pointer; /* pointer to beginning of PSP */ /* psp_pointer[1] will contain the final allocated */ /* segment of the program stored in the second word */ /* of the program segment prefix. */ void main(void){ FP_SEG(psp_pointer)=_psp; FP_OFF(psp_pointer)=0; size= psp_pointer[1]-_psp;} NOTE: _psp is also declared in STDLIB.H. You can include this header file rather explicitly declare _psp as shown above.
|
Additional reference words: kbinf 6.00 6.00a 6.00ax 7.00 1.00 1.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |