On 09/11/2019 13:46, Michael Van Canneyt wrote:
It's never enough:
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
Michael.
That level of byte-counting is just plain insanity, even for me! Still,
when it comes to byte-counting, I did do something similar in my first
ever patch for FPC, which was to look for things like "MOV RAX,
4000000000" and replace them with "MOV EAX, 4000000000" to shave off 5
bytes each time (4 bytes if the register is R8-R15 due to the REX
prefix). It actually cut the FPC executable down by about 50 kilobytes
overall. This optimisation works because if you set a 32-bit register
to a particular value, the upper 32 bits are guaranteed to be set to
zero (obviously this only works with values that are less than 2^32).
In regards to small executables though, I remember back in the mid-90s,
I came across a file on a floppy disk named "RESTART.COM". Now, COM
files (don't confuse with the Component Object Model) are super-simple
executables, pretty much containing only machine code with no sections
or headers beyond a signature or two. It was designed to be run from a
batch file and its function was to restart the computer (I think it
called a particular interrupt). The file was something like 28 bytes in
size, if that.
One thing to note though is that going THAT small with an executable is
wasted effort unless you're just trying to show off. Why? The cluster
size on a 1.44 MB floppy disk is 512 bytes, so even if RESTART.COM was
only 28 bytes in size, it took 512 bytes of disk space. Similar issues
occur with hard drive partitions, although the cluster size I believe is
4 KB in most cases.
Gareth aka. Kit
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel