Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions helloworld.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; How to run assembler code on Linux
; nasm -f elf64 helloworld.asm -o helloworld.o
; ld helloworld.o -o helloworld
; ./helloworld

section .data
msg db "Hello, World!", 10

section .text
global _start

_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 14
syscall

mov rax, 60
xor rdi, rdi
syscall
22 changes: 22 additions & 0 deletions helloworld.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// How to run assembler code on MacOS:
// as helloworld.s -o helloworld.o
// ld helloworld.o -o helloworld -lSystem -syslibroot $(xcrun -sdk macosx --show-sdk-path) -e _start -arch arm64
// ./helloworld

.global _start
.align 2

_start:
mov x0, #1
adr x1, msg
mov x2, #14
mov x16, #4
svc #0x80

mov x0, #0
mov x16, #1
svc #0x80

msg:
.ascii "Hello, World!\n"