3 ms·
"Hello World" in C++, compiled to x86 Assembly
- dlsspy 15y agoIt's significantly smaller when I do it on my machine with an optimizer. Interestingly, g++ compiles it to the exact same code if you remove all the crap that isn't the main with the cout printing a literal string.
- DasFuxx 15y agoWithout and with some optimization i get this results. g++ -o hello hello.cpp objdump --disassemble hello | wc -l 289 With some optimization g++ -o hello hello.cpp -O3 -fno-rtti -fno-exceptions -fmessage-length=0 -funroll-all-loops -fomit-frame-pointer -falign-loops=2 -falign-jumps=2 -falign-functions=2 ; objdump --disassemble hello | wc -l 256
- greyfade 15y agoThis looks like it was compiled with `-O0 -g`. It'll be a lot slimmer with `-O1` or even `-Os`. Edit: In fact, GCC 4.6.1 compiles it down to two function calls and some stack operations - about 15 instructions in all.