6 ms·
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, 6
by devit 3y ago
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.
- userbinator 3y agoMy 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.
- devit 3y agoThat's the same length. There is also "mov dil, 42".