Last active
December 23, 2020 16:40
-
-
Save md2perpe/ca349176531c710608d66b065ab84f03 to your computer and use it in GitHub Desktop.
Hello world in x86-64 assembly
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
*.o |
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
.text | |
.globl _start | |
_start: | |
# Print greeting | |
movq $1, %rax # sys_write | |
movq $1, %rdi # stdout | |
movq $hello, %rsi # address of string | |
movq $hello_length, %rdx # length of string | |
syscall | |
# Exit | |
movq $60, %rax # sys_exit | |
movq $0, %rdi # return value | |
syscall | |
.section .rodata | |
hello: | |
.string "Hello World!\n" | |
hello_length = . - hello |
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
hello: | |
as -o hello.o hello.s | |
ld -o hello hello.o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment