Created
March 31, 2015 02:52
-
-
Save rmccullagh/df925305cc39b354edc3 to your computer and use it in GitHub Desktop.
Hello World in x86 compiled on Linux 64 bit
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
| global _start | |
| section .text | |
| _start: | |
| ; write (sys_write) | |
| ; %rdi | |
| ; unsigned int fd | |
| ; %rsi | |
| ; const char __user *buf | |
| ; %rdx | |
| ; size_t count | |
| mov rax, 1 ; system call write is 1 | |
| mov rdi, 1 ; 1 is stdout | |
| mov rsi, message ; address of string | |
| mov rdx, 15 ; number of bytes | |
| syscall ; invoke operating system call | |
| ; exit (sys_exit) | |
| ; %rdi | |
| ; int error_code | |
| mov eax, 60 ; system call 60 is exit | |
| xor rdi, rdi ; exit code 0 | |
| syscall ; invoke exit | |
| message: | |
| db 10, "Hello, World", 10, 10 | |
| ; 1 byte for newline character | |
| ; 12 bytes for string literal | |
| ; 1 byte for newline character | |
| ; 1 byte for newline character |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment