We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 69c88f0 commit 1d96d30Copy full SHA for 1d96d30
hello/Makefile
@@ -0,0 +1,5 @@
1
+all:
2
+ nasm -f macho64 hello.asm
3
+ ld -macosx_version_min 10.10 -lSystem -o hello hello.o
4
+clear:
5
+ rm hello hello.o
hello/hello.asm
@@ -0,0 +1,17 @@
+; Hello world in NASM assembly for Mac OS X x64
+
+section .data
+ msg: db "hello", 0xA ; text to print ("hello\n")
+ .len: equ $ - msg ; text length
6
7
+section .text
8
+ global _main
9
+_main:
10
+ mov rax, 0x2000004 ; put the write-system-call-code into register rax
11
+ mov rdi, 1 ; tell kernel to use stdout
12
+ mov rsi, msg ; put address of the text into register rsi
13
+ mov rdx, msg.len ; put the length of the text into register rdx
14
+ syscall
15
+ mov rax, 0x2000001 ; exit system call
16
+ mov rdi, 0 ; out error code 0 to exit successfully
17
0 commit comments