stever@Octopus.COM (Steve Resnick ) (11/30/90)
In article <75004@iuvax.cs.indiana.edu> hughes@copper.ucs.indiana.edu (larry hughes) writes: >In article <1990Nov28.141911.18547@cec1.wustl.edu> jma7759@cec2.wustl.edu (James Michael Anderson) writes: >> [stuff deleted] >> One possiblity is for me to compile my program and then use the >>file size as a hardcoded value; however, there has got to be a "slicker" >>way to do this. Any suggesions? > >One way is to have the executable open() itself, and then use filelength(). > Bzzz. Nope, sorry, wrong answer. This will work on a .COM file only. In any other memory model, ie, one which creates a .EXE file, there can be uninitialized data such as empty arrays, etc which are defined in size but not stored in the .EXE file. I don't know a sure-fire way to determine the size of a program, but filelength on an EXE will almost always be wrong. There are some documented and undocumented internal variables, such as _heapbase, _heaplen, etc, which may point you in the right direction. You may also want to consider using the keep() function which calls DOS function 31 to TSR >64K .... Hope this helps ... Steve -- ---------------------------------------------------------------------------- steve.resnick@f105.n143.z1.FIDONET.ORG - or - apple!camphq!105!steve.resnick Flames, grammar errors, spelling errrors >/dev/nul The Asylum OS/2 BBS - (408)263-8017 IFNA 1:143/105.0
ralf@b.gp.cs.cmu.edu (Ralf Brown) (11/30/90)
In article <1990Nov29.162646.10584@Octopus.COM> stever@octopus.UUCP (Steve Resnick ) writes: }In article <75004@iuvax.cs.indiana.edu> hughes@copper.ucs.indiana.edu (larry hughes) writes: }>In article <1990Nov28.141911.18547@cec1.wustl.edu> jma7759@cec2.wustl.edu (James Michael Anderson) writes: }>> One possiblity is for me to compile my program and then use the }>>file size as a hardcoded value; however, there has got to be a "slicker" }>>way to do this. Any suggesions? }> }>One way is to have the executable open() itself, and then use filelength(). } }Bzzz. Nope, sorry, wrong answer. This will work on a .COM file only. }In any other memory model, ie, one which creates a .EXE file, there can }be uninitialized data such as empty arrays, etc which are defined in size }but not stored in the .EXE file. I don't know a sure-fire way to determine }the size of a program, but filelength on an EXE will almost always be wrong. It will also be wrong on .COMs, since uninitialized variables aren't stored in the executable in Tiny model, either (nor is the stack). TLINK has a switch to initialize all segments, in which case all that uninitialized data will be stored in the executable (either .COM or .EXE) as zeros. -- {backbone}!cs.cmu.edu!ralf ARPA: RALF@CS.CMU.EDU FIDO: Ralf Brown 1:129/3.1 BITnet: RALF%CS.CMU.EDU@CMUCCVMA AT&Tnet: (412)268-3053 (school) FAX: ask DISCLAIMER? Did | Everything is funny as long as it is happening to I claim something?| someone else. --Will Rogers