Skip to content

Commit 1d96d30

Browse files
committedSep 15, 2016
Hello world added.
1 parent 69c88f0 commit 1d96d30

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
 

‎hello/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -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

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; Hello world in NASM assembly for Mac OS X x64
2+
3+
section .data
4+
msg: db "hello", 0xA ; text to print ("hello\n")
5+
.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+
syscall

0 commit comments

Comments
 (0)
Please sign in to comment.