Last active
December 28, 2015 19:59
-
-
Save djg/7553993 to your computer and use it in GitHub Desktop.
I was going for less bytes, hence the push/pop/push shenanigans. There must be an easier way to do this. Why does BSD require the syscall on the top of the stack *and* in EAX?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getchar: ; read a byte from stdin | |
push 0 | |
mov eax, esp | |
push 1 | |
push eax | |
push STDIN_FILENO | |
push SYS_READ | |
pop eax | |
push eax | |
int 80h | |
test eax, eax | |
je exit | |
add esp, 16 | |
pop eax | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment