Last active
October 31, 2019 11:39
-
-
Save sroccaserra/1826a5ba9adfb0a5eaef045f91148c88 to your computer and use it in GitHub Desktop.
"Hello World" program in x64 assembly for macOs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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