Skip to content

Instantly share code, notes, and snippets.

@warabanshi
Last active December 10, 2015 12:28
Show Gist options
  • Save warabanshi/4434217 to your computer and use it in GitHub Desktop.
Save warabanshi/4434217 to your computer and use it in GitHub Desktop.
read character from stdin and write stdout by system call
.intel_syntax noprefix
.comm mem, 30000
.globl main
main:
lea rbx, mem
# read systemcall
mov rax, 0 # specify read system call
mov edx, 0x1 # 3nd argument (count)
mov rsi, rbx # 2nd argument (string pointer)
mov edi, 0x0 # 1st argument (stdout)
syscall
# write systemcall
mov rax, 1 # specify write system call
mov edx, 0x1 # 3nd argument (count)
mov rsi, rbx # 2nd argument (string pointer)
mov edi, 0x1 # 1st argument (stdout)
syscall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment