SemiOT: Mourning for Classic Computing
It was thus said that the Great Richard Erlacher once stated:
>
> Even today's compilers demand several hundred Kbytes for a simple "hello-world"
> program on one of today's machines, while it took well fewer than 256 bytes of
> executable code to print a short text string on a Z-80 or 6502.
It depends on how well you know the compiler. On my system here (Linux
2.0 with GCC 2.7.2.3:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello world\n");
return(EXIT_SUCCESS);
}
I compiled using ``gcc -O4 -fomit-frame-pointer -o hello hello.c ; strip
hello'' and I got an executable of 2,684 bytes in size. Not content with
that, I then wrote:
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
write(STDOUT_FILENO,"Hello world\n",12);
_exit(EXIT_SUCCESS);
}
Which avoids the Standard C Library and calls the Unix kernel directly. I
then did:
gcc -O4 -fomit-frame-pointer -c -o h2.o h2.c
ld -o h2 -Bstatic -e main h2.o /usr/lib/libc.a
strip h2
Which got me an executable of 768 bytes.
Many years ago I hand crafted a 168 byte ``Hello World'' program on the
SGI. And by hand crafted, that means I built the executable (including
headers) byte by byte. That was (and perhaps still is) the smallest binary
you could have had on an SGI.
It was several years later when I came across an incantation that would
turn the C version (the second one above) into a ~350 byte executable. I
don't recall the incantation but it was impressive.
-spc (The smallest I've been able to get is 372, and that's by writing
directly in assembler and discarding unused segments ... )
Received on Tue Aug 21 2001 - 18:47:57 BST
This archive was generated by hypermail 2.3.0
: Fri Oct 10 2014 - 23:33:33 BST