3 ms·
Always use the standard function prologs and epilogs This sounds like another one of those common "learn Asm by acting like a compiler" articles, which IMHO co
by userbinator 3y ago
Always use the standard function prologs and epilogs
This sounds like another one of those common "learn Asm by acting like a compiler" articles, which IMHO completely misses one of the best reasons to learn Asm: you can beat the compiler on size (relatively easy), speed (often harder), or both, precisely by not acting like one. I suspect the author, like so many others, also learned from only reading (some) compiler output. The complete lack of any use of static initialised data is shocking.
mov rdi, rdi
lea rsi, [rsp]
Please don't do this. Even a compiler can do better at O0.
Stripped and OMAGIC (--omagic linker flag, from the man page: Set the text and data sections to be readable and writable. Also, do not page-align the data segment): 1776 bytes (1 KiB)
Besides being a very notable date (was that deliberate?), 1776 is closer to 2k than 1k. I suspect if you wrote it in C with inline Asm for the syscalls, it wouldn't be much bigger (and may even be a little smaller.)
If you want to see what Asm can really do, the sub-1k categories in the demoscene are well worth looking at.
- jart 3y agoLike the Lambda Calculus in 383 bytes. https://justine.lol/lambda/ https://justine.lol/lambda/