Smallest x86 ELF Hello World
timelessname.com
timelessname.com
http://www.muppetlabs.com/~breadbox/software/tiny/
(62-byte hello world among other things)
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...
http://www.returninfinity.com/baremetal-helloworld.html
Why use ELF or Linux? Flat binaries (and a custom OS) to the rescue! :)
As with all games (even Nomic) a game is only a game if there are rules that limit what one can do.
Surely, once you get below page-size (e.g. 4K) you are just wasting memory that will get loaded anyway?
But this was a genuine question rather than a put-down. I was hoping to have my assumption debunked.
EDIT: I have no idea why you're being down-voted seems unfair
Compile "Hello world" into an executable, and see how many kilobytes it takes on most architectures, despite the object file being a few bytes.
This thread pretty much responds to that. It is no 17000 lines, nor 17000K, it is just 142 bytes (other comments suggest it is 62).
[surki@linux-vrse tt]$ cat | gcc -nostdlib -x c - -o helloworld
#define SYS_exit 1
#define SYS_write 4
#define stdout 1
int strlen(const char *str)
{
long len = 0;
while (str && *str++)
{
len++;
}
return len;
}
void print(const char *str)
{
int len = strlen(str);
long ret;
/* Can't touch ebx directly, PIC uses it */
__asm__ __volatile__ ("pushl %%ebx\n"
"movl %%esi, %%ebx\n"
"int $0x80\n;"
"popl %%ebx"
"a" (SYS_write),
"S" ((long) stdout),
"c" ((long) str),
"d" ((long) len));
return;
}
void _start()
{
main();
__asm__ __volatile__ (
"xorl %%ebx, %%ebx\n"
"int $0x80\n"
"a" (SYS_exit));
}
int main()
{
print("Hello World\n");
return 0;
}
[surki@linux-vrse tt]$ strip -R .comment -R .comment.SUSE.OPTs -R .note.gnu.build-id helloworld
[surki@linux-vrse tt]$ ll helloworld
-rwxr-xr-x 1 suresh users 540 2010-07-21 13:19 helloworld
[surki@linux-vrse tt]$ ./helloworld
Hello World 31 c0 xor %eax, %eax
is shorter than b8 00 00 00 00 mov $0, %eax
but that's not the main reason it's often used in shellcode. The xor reg, reg is preferred because it means the resulting shellcode will not contain a null byte. This is desirable since the null-byte is often used as a string terminator, in environment variables for example.The 8086 assembly tutorial book I used then recommended to use "sub ax, ax" instead because it was less surprising.
You can't have a genetic algorithm run on something where almost every attempt will simply produce invalid code. Genetic algorithms work when you can try various strategies to maximize a fitness function. But here the fitness is yes or no, does it work or not. There is nothing to maximize - and you can't try to maximize the "size fitness" because pretty much all the attempts will produce invalid code, so there is nothing to mix together for various generations.
Google "automatic programming" if you think it's never been done, your mind is about to be expanded.
You should really learn to think for a while before you dismiss ideas as "nonsensical".
By this stupid metric, PHP is the greatest programming language ever made.
12 byte Hello World must mean that it's also the ideal solution for every other programming problem, right?
Second, there is no point in using it for that when you have bash ... because bash has echo built-in and bash is a programming language:
$ echo "Hello World!"
1 line bitches! I can feel my unix beard growing ...
There was another comment about how this will be the next "Fibonacci debacle", related to how Ted Dzubia trolled the node.js crowd by pointing out it's weakness for CPU-intensive tasks, then had a ton of people wasting time on writing faster Fibonacci algorithms in node just to prove him wrong.
My point was that comparing languages by the size of their Hello World programs is a useless exercise.