Created
March 1, 2022 21:05
-
-
Save pedrominicz/5a1f02159022c59ec5d49e99169cf92a to your computer and use it in GitHub Desktop.
Hello, world! (GNU Assembler & NASM)
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
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 |
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
.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" |
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
#!/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