Skip to content

Instantly share code, notes, and snippets.

@jcrubino
Created November 12, 2014 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcrubino/061c49b167de62d2ec66 to your computer and use it in GitHub Desktop.
Save jcrubino/061c49b167de62d2ec66 to your computer and use it in GitHub Desktop.
# 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