Posts: 16
Threads: 9
Joined: May 2004
This is more a question than a challenge, but I guess it could also be a challenge: what is the smallest EXE size possible? I just saved a program in qbasic with no lines of code at all and the EXE size is 10K. Is it possible to get any smaller than that?
Fade to nothing... your weakness disgusts me..."
Posts: 1,439
Threads: 15
Joined: Apr 2003
It's quite possible... but not compiling with QB. You could write a smaller program in ASM and then you wouldn't have the overhead of the standard QB library. Also, if you tell QB not to link the QB library, the size of an EXE with no QB code is about 2 kilobytes. Of course, you'd then need the QB runtime, which is about 8 kilobytes.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Hmm - I believe an EXE could be 10 bytes - wait, what's the header size? From a quick look at a few EXEs in notepad, looks like the first 15 bytes (rough estimate) are the same. So whatever the header size is, plus one instruction (a NOP, maybe? that's a one-byter, I think?) is the minimum.
Of course, a .COM could be one byte :wink:
Code:
.model tiny ;in MASM this means a .com file
.code
main PROC
NOP
main ENDP
END main
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 6,419
Threads: 74
Joined: Mar 2002
but that .COM would crash the computer (in MSDOS)
you have to call DOS again to tell it "hey, you can take the CPU, I'm done"
Posts: 3,616
Threads: 287
Joined: Jan 2003
Good point.
So 4 bytes for a proper, non-crashing executable .COM file.
Code:
.model tiny
.code
main PROC
mov ah,4ch
int 21h
main ENDP
END main
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 440
Threads: 65
Joined: Sep 2001
Quote:This is more a question than a challenge, but I guess it could also be a challenge: what is the smallest EXE size possible? I just saved a program in qbasic with no lines of code at all and the EXE size is 10K. Is it possible to get any smaller than that?
You could link out things your EXE doesn't need, like link it with the SMALLERR.OBJ which will reduce all error messages to just a few ones. That would only save you about 1k of EXE size. Here's a doc on that:
http://qbnz.com/dav/qbkb/Q44358.TXT
Oh, if this is a challenge, that gave me a 9013 byte EXE.
- Dav
Posts: 1,752
Threads: 21
Joined: Jun 2002
Quote:Good point.
So 4 bytes for a proper, non-crashing executable .COM file.
Code:
.model tiny
.code
main PROC
mov ah,4ch
int 21h
main ENDP
END main
You were right the first time...one byte non-crashing COM file:
Posts: 3,522
Threads: 189
Joined: Dec 2003
Wouldn't the smallest possible EXE file be 512bytes?
EXE's are built up in layers of 256 bytes each, aren't they?
The first layer is the header, then comes the program code, then program data/constants
It might even be 768, header+code+data
EXE's are about as agile as refrigerators.
Posts: 2,765
Threads: 138
Joined: Nov 2002
Quote:EXE's are about as agile as refrigerators.
*watches refridgerator run through meadow*
What the...
yea EXE's can't be THAT small
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 1,752
Threads: 21
Joined: Jun 2002
The DOS EXE header is only 28 bytes...with a blank relocation table, you can have a non-crashing EXE in 34 bytes.
EXEs are also a lot more flexible than COM files.