Skip to content

Instantly share code, notes, and snippets.

@djg
Last active December 28, 2015 19:59
Show Gist options
  • Save djg/7553993 to your computer and use it in GitHub Desktop.
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?
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