Re: Bind features
- Posted by Joe Otto <jotto at NETZERO.NET> Jul 01, 1999
- 587 views
Okay, somebody's got to step in and straighten this out. DOS doesn't EVER load anything in a fixed place except for a couple of cryptic options available to gurus for loading device drivers, TSRs, and such. Both COM and EXE files are relocatable. The primary difference is as follows: The COM file format is a relic from CP/M, which ran on the 8080 with a total memory space of 64KB. Due to this fact COM files are restricted to 64KB in size, which just happens to be the size of a single segment in the 8086 architecture. Because of the shortage of available memory, when CP/M loaded a COM file it would overwrite the operating system memory with the program. Therefore CP/M had to reserve a little memory (100H bytes) for O/S overhead and to reload itself when the program completed. Thus, the 100H address referred to earlier is the *offset* into the segment wherever DOS chooses to load the file. Since, in the 8086 architecture, the segment is shifted left 4 bits before it's used in an address calculation, a new segment starts every 16 bytes, and DOS can load a COM file virtually anywhere in conventional memory (or upper memory under certain circumstances). Under DOS the usage of the reserved 100H bytes has changed, but it's still required since all COM files are based on a 100H load offset. The EXE file format allows programs larger than 64KB in size due to "fixups" that DOS does after it loads the file but before it executes it. It's been much too long for me to remember all the details, but it involves a fixup map generated by the linker that tells the DOS loader to go to an address and insert the current segment, then move to another address and insert the next segment, etc. It's a long tedious process that makes me happy I never had to write a loader for such a screwed up segmented architecture as the 8086... :) Btw, before anyone comes back with "I have COM files on my hard drive bigger than 64KB" let me explain... Back when the EXE format was a baby, Microsoft worked out a convoluted way (meaning I never even tried to figure it out) to put more than 64KB in the COM file, then have the program do its own fixups after it started executing. I don't think they ever released the specs on the actual procedure, and I believe it's still very much Microsoft proprietary. Sorry for boring you to tears... Joe -----Original Message----- From: Bernie Ryan [SMTP:bwryan at PCOM.NET] Sent: Thursday, July 01, 1999 4:17 PM To: EUPHORIA at LISTSERV.MUOHIO.EDU Subject: Re: Bind features J. Yazel you wrote: >> A .COM file will also run anywhere. If you change the boot parameters, >> DOS will then load programs at a different place in memory but the .COM >> program will still run without re-compiling. There is no way that I know of changing boot parameters in DOS. Command.com will always load a COM file at 100H. If you wish to load it at a different location you have to load the program using the EXEC DOS function. Then run it from the parent program that loaded it. Bernie ________________________________________________________ NetZero - We believe in a FREE Internet. Shouldn't you? Get your FREE Internet Access and Email at http://www.netzero.net/download/index.html