Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Last active October 22, 2019 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewrk/151c2083b47eea6c94d53d439ae9e7a4 to your computer and use it in GitHub Desktop.
Save andrewrk/151c2083b47eea6c94d53d439ae9e7a4 to your computer and use it in GitHub Desktop.
x86_64-linux hello world in assembly
.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
# 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