Skip to content

Instantly share code, notes, and snippets.

@revmischa
Last active August 29, 2015 14:06
Show Gist options
  • Save revmischa/0ac56ddd2026ca1d05ee to your computer and use it in GitHub Desktop.
Save revmischa/0ac56ddd2026ca1d05ee to your computer and use it in GitHub Desktop.
Hello world, linux x86 assembly version
.section .rodata
.hellostr:
.string "Hello, world\n"
.text
.globl _start
_start:
pushq %rbp
movq %rsp, %rbp
# write
movl $13, %edx # str length
movl $.hellostr, %esi # address of hellostr -> %esi
movl $1, %edi # file descriptor, 1 = STDOUT
movl $1, %eax # "write" syscall, 1 (c.f. /usr/include/asm/unistd_64.h)
syscall
# exit
movl $0, %eax # program return code (arg to "exit")
movl $60, %eax # "exit" syscall
syscall
# To assemble/link: as hello.s -o hello.o && ld hello.o -o hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment