Skip to content

Instantly share code, notes, and snippets.

@pedrominicz
Created March 1, 2022 21:05
Show Gist options
  • Save pedrominicz/5a1f02159022c59ec5d49e99169cf92a to your computer and use it in GitHub Desktop.
Save pedrominicz/5a1f02159022c59ec5d49e99169cf92a to your computer and use it in GitHub Desktop.
Hello, world! (GNU Assembler & NASM)
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, hello_world
mov rdx, 14
syscall
mov rax, 60
xor rdi, rdi
syscall
section .data
hello_world:
db "Hello, world!", 10
.text
.globl _start
_start:
mov $1, %rax
mov $1, %rdi
mov $hello_world, %rsi
mov $13, %rdx
syscall
mov $60, %rax
xor %rdi, %rdi
syscall
.data
hello_world:
.ascii "Hello, world!\n"
#!/bin/sh
trap clean 0 1 2 3 6
clean() {
rm -f main.o main
}
set -e
as -o main.o main.S
ld -o main main.o
./main
nasm -felf64 main.asm
ld -o main main.o
./main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment