Skip to content

Instantly share code, notes, and snippets.

@madureira
Created April 9, 2019 12:16
Show Gist options
  • Save madureira/b109b8d9538c1c0f09e2c62e9d125276 to your computer and use it in GitHub Desktop.
Save madureira/b109b8d9538c1c0f09e2c62e9d125276 to your computer and use it in GitHub Desktop.
Hello World in Assembly (NASM)
; ----------------------------------------------------------------------------------------
; "Hello, World" in Assembly.
; *Runs on 64-bit Linux only.
;
; $ nasm -felf64 hello.asm -o hello.o && ld hello.o -o hello && rm hello.o && ./hello
; ----------------------------------------------------------------------------------------
global _start
section .text
_start: mov rax, 1 ; system call for write
mov rdi, 1 ; file handle 1 is stdout
mov rsi, message ; address of string to output
mov rdx, 13 ; number of bytes
syscall ; invoke operating system to do the write
mov rax, 60 ; system call for exit
xor rdi, rdi ; exit code 0
syscall ; invoke operating system to exit
section .data
message: db "Hello, World", 10 ; note the newline at the end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment