Qbasicnews.com

Full Version: Smallest EXE size possible?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.
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
but that .COM would crash the computer (in MSDOS) Wink you have to call DOS again to tell it "hey, you can take the CPU, I'm done" Smile
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
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. Wink

- Dav
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:

Code:
C3   RET
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.
Quote:EXE's are about as agile as refrigerators.
*watches refridgerator run through meadow*
What the...
yea EXE's can't be THAT small
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. Tongue