Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI735.ASC

 
Output of file : TI735.ASC contained in archive : BCPPTECH.ZIP







PRODUCT : Borland C++ NUMBER : 735
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 1/1

TITLE : Determining Program Size






/**********************************************************************

The size of a program cannot be determined statically because the
the stack and near heap are sized dynamically at run time. The
load size specified in the EXE header is incorrect for this
reason. The only way to accurately determine the program image
size is to check it at run time.

This program will get the current size of the program image in
memory. This size will change dynamically as the program acquires
memory from and releases memory to DOS. This in formation is
stored in the Memory Control Block (MCB). The MCB begins one
paragraph (16 bytes) before the Program Segment Prefix (PSP).
The current program size is stored at offset 0x3 from the
beginning of the MCB. Offset 0x3 represents the size in
paragraphs therefore it must be multiplied by 16 to obtain the
size in bytes.


WRITTEN BY
Jerry Shockley 9/19/91

**********************************************************************/
#include

unsigned _stklen = 63000u; //This size can be changed to see the
size
// size change.

void main()
{
unsigned far *size;

size = MK_FP( _psp - 1, 0x03 );
printf("\nSize of program in memory = %l0u", (unsigned long)
(*size) * 16 );
}












  3 Responses to “Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI735.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/