Skip to content

Instantly share code, notes, and snippets.

@kuuote
Last active April 3, 2018 11:12
Show Gist options
  • Save kuuote/d4dfc79c4787802aa99cca4764ee4550 to your computer and use it in GitHub Desktop.
Save kuuote/d4dfc79c4787802aa99cca4764ee4550 to your computer and use it in GitHub Desktop.
本物のプログラマはlibcを使わない[要出典]のでlibcレスHelloworld
#required x86-64 linux
#as -o hello.o hello.s
#ld -o hello -dynamic-linker (path to ld-linux...) hello.o
#./hello
.global hello
.global _start
.data
hello:
.string "Hello world!\n"
helloend:
.equ len, helloend - hello
.text
_start:
movq $1, %rax #sys_write
movq $1, %rdi #stdout
movq $hello, %rsi #head of hello
movq $len, %rdx #length helloend - hello
syscall
movq $60, %rax #sys_exit
movq $0, %rdi #normal exit code
syscall
#real programmers don't use return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment