Skip to content

Instantly share code, notes, and snippets.

@md2perpe
Last active December 23, 2020 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save md2perpe/ca349176531c710608d66b065ab84f03 to your computer and use it in GitHub Desktop.
Save md2perpe/ca349176531c710608d66b065ab84f03 to your computer and use it in GitHub Desktop.
Hello world in x86-64 assembly
.text
.globl _start
_start:
# Print greeting
movq $1, %rax # sys_write
movq $1, %rdi # stdout
movq $hello, %rsi # address of string
movq $hello_length, %rdx # length of string
syscall
# Exit
movq $60, %rax # sys_exit
movq $0, %rdi # return value
syscall
.section .rodata
hello:
.string "Hello World!\n"
hello_length = . - hello
hello:
as -o hello.o hello.s
ld -o hello hello.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment