Skip to content

Instantly share code, notes, and snippets.

@DForshner
Created December 18, 2014 18:39
Show Gist options
  • Select an option

  • Save DForshner/e044fc5c9e2c69d48c57 to your computer and use it in GitHub Desktop.

Select an option

Save DForshner/e044fc5c9e2c69d48c57 to your computer and use it in GitHub Desktop.
Hello world in assembly
# ---------------------------------------------------------------
# Hello assembly!
# Compile: gcc -o helloassembly -nostdlib helloassembly.s
# Tested on Ubuntu 14 (x64)
# ---------------------------------------------------------------
.global _start
.text
_start:
# write(1, message, 13)
mov $1, %rax # system call ID (1 is write)
mov $1, %rdi # file handle 1 is stdout
mov $message, %rsi # address of string to output
mov $17, %rdx # string length
syscall # system call invocation
# exit(0)
mov $60, %rax # system call ID (60 is exit)
xor %rdi, %rdi # return code 0
syscall # system call invocation
message:
.ascii "Hello, Assembly!\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment