Created
November 12, 2014 02:27
-
-
Save jcrubino/061c49b167de62d2ec66 to your computer and use it in GitHub Desktop.
This file contains 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 world in GAS syntax | |
# to compile and run | |
# $ yasm -f elf -p gas helloGAS.s 2>&1 | |
.text # section declaration | |
# we must export the entry point to the ELF linker or | |
.global _start # loader. They conventionally recognize _start as their | |
# entry point. Use ld -e foo to override the default. | |
_start: | |
# write our string to stdout | |
movl $len,%edx # third argument: message length | |
movl $msg,%ecx # second argument: pointer to message to write | |
movl $1,%ebx # first argument: file handle (stdout) | |
movl $4,%eax # system call number (sys_write) | |
int $0x80 # call kernel | |
# and exit | |
movl $0,%ebx # first argument: exit code | |
movl $1,%eax # system call number (sys_exit) | |
int $0x80 # call kernel | |
.data # section declaration | |
msg: | |
.ascii "Hello, GAS world!\n" # our dear string | |
len = . - msg # length of our dear string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment