Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smallest EXE size possible?
#1
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..."
Reply
#2
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.
Reply
#3
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.
Reply
#4
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
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#5
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.
Reply
#6
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
Reply
#7
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
Reply
#8
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.
Reply
#9
Quote:EXE's are about as agile as refrigerators.
*watches refridgerator run through meadow*
What the...
yea EXE's can't be THAT small
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#10
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)