Created
April 7, 2022 02:16
-
-
Save snail5008/3d95325285a0907dc61c86425bf610e9 to your computer and use it in GitHub Desktop.
A 'Hello World' program in GAS for linux x86_64
This file contains 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
.global _start | |
.section .data | |
message: .ascii "Hello, World!\n" | |
len = . - message | |
.section .text | |
_start: | |
movq $1, %rax # sys_write | |
movq $1, %rdi # stdout | |
movq $message, %rsi # message | |
movq $len, %rdx # len of message | |
syscall # sys_write | |
movq $60, %rax # sys_exit | |
movq $0, %rdi # exit code 0 | |
syscall # sys_exit |
This file contains 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
mkdir -p build/ | |
mkdir -p build/part | |
as -c -o build/part/main.s.o main.s | |
ld -o build/a.out build/part/main.s.o | |
./build/a.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment