Last active
August 29, 2015 14:06
-
-
Save revmischa/0ac56ddd2026ca1d05ee to your computer and use it in GitHub Desktop.
Hello world, linux x86 assembly version
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
.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