Skip to content

Instantly share code, notes, and snippets.

@sroccaserra
Last active October 31, 2019 11:39
Show Gist options
  • Select an option

  • Save sroccaserra/1826a5ba9adfb0a5eaef045f91148c88 to your computer and use it in GitHub Desktop.

Select an option

Save sroccaserra/1826a5ba9adfb0a5eaef045f91148c88 to your computer and use it in GitHub Desktop.
"Hello World" program in x64 assembly for macOs
global _main
section .text
_main:
mov rax, 0x2000004 ; write
mov rdi, 1 ; stdout
lea rsi, [rel msg]
mov rdx, msg.len
syscall
mov rax, 0x2000001 ; exit
mov rdi, 0
syscall
section .data
msg: db "Hello, world!", 10
.len: equ $ - msg
run: hello
./hello
hello: hello.o
ld -macosx_version_min 10.13.0 -lSystem -o hello hello.o
hello.o: hello.asm
nasm -f macho64 hello.asm -o hello.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment