Last active
March 11, 2025 16:20
-
-
Save qexat/792b082c878a3f12e133739150668744 to your computer and use it in GitHub Desktop.
least portable C hello world program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // only works on Compiler Explorer with x86-64 gcc | |
| // gcc hello.c -o hello && ./hello | |
| extern int(puts)(char const *); | |
| char static *message = "Hello World!\n"; | |
| __attribute__((used)) void f(void) | |
| { | |
| puts(message); | |
| } | |
| int main(void) | |
| { | |
| asm("mov $0x402004, %edi"); | |
| asm("call 0x401030"); | |
| asm("xor %eax, %eax"); | |
| asm("pop %rbp"); | |
| asm("ret"); | |
| while (1) | |
| { | |
| f(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment