by michidk on 12/30/24, 4:23 PM with 49 comments
by bd01 on 1/2/25, 8:32 PM
mov rax, 1
An actual "mov rax, 1" would assemble to 48 B8 01 00 00 00 00 00 00 00, a whopping TEN bytes.nasm will optimize this to the equivalent "mov eax, 1", that's 6 bytes, but still:
xor eax, eax ; 2 bytes
inc eax ; 2 bytes
would be much smaller. Second line: mov rdi, 1
You already have the value 1 in eax, so a "mov edi, eax" (two bytes) would suffice. Etc. etc.by Tepix on 1/2/25, 9:19 PM
;; 18 bytes
DB 'HELLO_WOIY<$' ; executes as machine code, returning SP to original position without overwriting return address
mov dx, si ; mov dx,0100h MS-DOS (all versions), FreeDOS 1.0, many other DOSes
xchg ax, bp ; mov ah,9 MS-DOS 4.0 and later, and FreeDOS 1.0
int 21h
ret
(credits: https://stackoverflow.com/questions/72635031/assembly-hello-...)by smokel on 1/2/25, 8:35 PM
Joking aside, this page [2] used to be a great tutorial on writing small ELF binaries, but I'm not sure whether it will still work in 64-bit land. It proved very helpful for writing a 4K intro back in 1999.
[1] https://esolangs.org/wiki/HQ9%2B
[2] https://www.muppetlabs.com/~breadbox/software/tiny/teensy.ht...
by mrfinn on 1/2/25, 8:22 PM
We've come a long way since then, and is like, at some point, nobody cared about optimizing executable size anymore
by 5- on 1/2/25, 10:08 PM
7f454c46488d3537000000ffc7b20eeb03003e00
b001eb1a01000000050000001800000000000000
1800000005000000b03c0f05ebfa380001006865
6c6c0000010068656c6c00006f20776f726c640a
i'm sure this can be improved -- but i could never get any x86_64 linux elf to under 80 bytes. see if you can fit the exclamation point still.by whynotmaybe on 1/2/25, 8:40 PM
Because it would be much smaller in a bat file than contains :
echo Hello World!
by gr33kdude on 1/2/25, 8:27 PM
by musicale on 1/3/25, 3:15 AM
? "hello, world!"
PILOT eliminates the quotes: T:hello, world!
Of course a typical REPL (Python, JavaScript, Lisp, etc.) will print out something similar (but often quoted) if you just type the quoted string.And I'm sure there is already some language (call it HELLO) which simply prints "hello, world!" for an empty program.
by fjfaase on 1/3/25, 10:07 AM
by xpasky on 1/2/25, 8:29 PM
by oneshtein on 1/2/25, 9:00 PM
by Multicomp on 1/3/25, 12:33 AM