7 ms·
; set the first syscall argument to 42 push 0x2a pop edi ; select syscall 60 (sys_exit) push 0x3c pop eax ; sys_exit(42)
by qguv 4y ago
; set the first syscall argument to 42
push 0x2a
pop edi
; select syscall 60 (sys_exit)
push 0x3c
pop eax
; sys_exit(42)
syscall
- enriquto 4y agoLOL my asm is rusty, didn't even know about the syscall instruction (I'd have used int 0x80 here)
- mFixman 4y agoWhat's the point of `push`ing constants to the stack and `pop`ing them to registers instead of `mov`ing them directly?
- saagarjha 4y agoI think they encode smaller?
- anshargal 4y agoThat's cool - I wonder why exit code is not set to 42 in practice? binary still returns 0, must be a bug somewhere.
- saagarjha 4y agoA successful run not exiting with EXIT_SUCCESS usually requires a good reason to justify it.