Skip to content

Instantly share code, notes, and snippets.

@adrianratnapala
Created October 28, 2011 06:59
Show Gist options
  • Save adrianratnapala/1321776 to your computer and use it in GitHub Desktop.
Save adrianratnapala/1321776 to your computer and use it in GitHub Desktop.
Hello World on amd64 under Linux.
# Hello World on amd64 under Linux.
#
# One way to build this is with:
#
# gcc hello.S -s -nostartfiles -nostdlib -o hello
#
# for syscall numbers look in /usr/include/asm/unistd_64.h
# for examples look at http://99-bottles-of-beer.net/language-assembler-(amd64)-933.html
# for insipration look at http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
hello:
.string "Hello world!\n"
.globl _start
_start:
# write(1, hello, 13)
mov $1, %rdi
mov $hello, %rsi
mov $13, %rdx
mov $1, %rax
syscall
# _exit(0)
xor %rdi, %rdi
mov $60, %rax
syscall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment