News for hackers. Stuff that matters.
Re:What's the difference between the com and exe extensions?... by mojuba on Saturday May 27, 2017 @10:47AM (#14430276)
If I remember correctly, not just the files themselves but the entire memory available to COM programs at run time was limited to 64k.

It's funny how engineers think those times are long gone whereas the demand for very compact systems with low energy footprint is still there. So mastering programming within kilobytes is still a thing, don't disregard it!

Re:What's the difference between the com and exe extensions?... by dfox on Saturday May 27, 2017 @11:13AM (#14430411)
COM files were not limited to only 64k of accessible memory, but the difference was that upon loading COM file got one full preallocated 64kB segment that got used for all of data, code and stack, while MZ format files specified in their header how many paragraphs (segment register increments, ie. 16 byte blocks) they need for code and how many additional uninitialized paragraphs should follow that (minimum and maximum required).

In both cases programs were free to allocate additional memory from DOS, but by default EXE files were loaded in such way that this wasn't necessary and automatically got the largest continuous block of free memory allocated to them (in fact they got the highest addressed block of free memory, but in any sane state of DOS it was also the largest).

Re:What's the difference between the com and exe extensions?... by nils-m-holm on Sunday May 28, 2017 @02:31PM (#14435497)
> upon loading COM file got one full preallocated 64kB segment

IIRC, COM files got all available memory up to the 640K boundary and if you wanted to load additional programs, you had to shrink the preallocated region first.

Re:What's the difference between the com and exe extensions?... by pizza234 on Saturday May 27, 2017 @10:58AM (#14430327)
To be more specific, COM files were loaded into a single segment (64k) - this is where the limitation comes from.

At the time of DOS, memory access was unrestricted, so, in a basic form, one had direct access to the entire base memory (640k). DOS viruses for example frequently resided just below the top of it, and/or manipulated the interrupt descriptor table (located instead at the very beginning).

Re:What's the difference between the com and exe extensions?... by userbinator on Saturday May 27, 2017 @10:58AM (#14430328)
COM files can access all addressable memory in the system:

https://news.ycombinator.com/item?id=14427269

Remember that they run in an environment with no memory protection.

Re:What's the difference between the com and exe extensions?... by bluedino on Saturday May 27, 2017 @12:14PM (#14430670)
Your C (or more likely, Pascal) compiler just didn't allow you to use it in their 'tiny' memory model
Re:What's the difference between the com and exe extensions?... by WalterBright on Saturday May 27, 2017 @12:44PM (#14430781)
The Datalight C compiler would generate COM files that provided for 64K code and 64K data, as long as the code + static data was < 64K.

Of course, you could still access all the memory in the machine by using "far pointers" and far allocators.

Re:What's the difference between the com and exe extensions?... by int_19h on Sunday May 28, 2017 @01:39AM (#14433222)
Digital Mars C++ (!) compiler can generate COM files as output.

http://www.digitalmars.com/download/freecompiler.html

It can be amusing trying to use the C++ standard library given the 64k code size constraint. You can pretty much forget about iostreams...