Last active
October 22, 2019 20:55
-
-
Save andrewrk/151c2083b47eea6c94d53d439ae9e7a4 to your computer and use it in GitHub Desktop.
x86_64-linux hello world in assembly
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: | |
movl $1, %eax | |
movl $1, %edi | |
movl $msg, %esi | |
movl $12, %edx | |
syscall | |
movl $60, %eax | |
xorl %edi, %edi | |
syscall | |
.section .rodata,"a" | |
msg: | |
.ascii "hello world\n" | |
.size msg, 12 |
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
# with zig | |
$ zig build-exe --c-source hello.s && ./hello | |
# with gcc toolchain | |
$ gcc -c hello.s && ld -o hello hello.o && ./hello | |
hello world | |
# with llvm toolchain | |
$ clang -c hello.s && ld.lld -o hello hello.o && ./hello | |
hello world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment