Created
December 18, 2014 18:39
-
-
Save DForshner/e044fc5c9e2c69d48c57 to your computer and use it in GitHub Desktop.
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
| # --------------------------------------------------------------- | |
| # Hello assembly! | |
| # Compile: gcc -o helloassembly -nostdlib helloassembly.s | |
| # Tested on Ubuntu 14 (x64) | |
| # --------------------------------------------------------------- | |
| .global _start | |
| .text | |
| _start: | |
| # write(1, message, 13) | |
| mov $1, %rax # system call ID (1 is write) | |
| mov $1, %rdi # file handle 1 is stdout | |
| mov $message, %rsi # address of string to output | |
| mov $17, %rdx # string length | |
| syscall # system call invocation | |
| # exit(0) | |
| mov $60, %rax # system call ID (60 is exit) | |
| xor %rdi, %rdi # return code 0 | |
| syscall # system call invocation | |
| message: | |
| .ascii "Hello, Assembly!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment