Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Note that the assembly code is suboptimal, since it wastes 4 bytes for each immediate.

The optimal assembly code is this: "mov al, 42; xchg edi, eax; mov al, 60; syscall". Or just "mov al, 60; syscall" if you want to exit with 0 rather 42.



My instinct says "push 42 ; pop edi ; mov al, 60 ; syscall" instead, which makes use of the "push imm8 ; pop reg" trick to likewise avoid imm32s.


That's the same length. There is also "mov dil, 42".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: