Skip to content

Instantly share code, notes, and snippets.

@VikVin
Forked from carloscarcamo/hello.s
Created February 11, 2026 17:39
Show Gist options
  • Select an option

  • Save VikVin/9a9fdfae0e1dc45acd42a012202bee2e to your computer and use it in GitHub Desktop.

Select an option

Save VikVin/9a9fdfae0e1dc45acd42a012202bee2e to your computer and use it in GitHub Desktop.
Hello world in GNU Assembler (GAS)
# -------------------------------------------------------------
#
# Using Linux System calls for 64-bit
# to run:
# gcc -c hello.s && ld hello.o && ./a.out
# o
# gcc -nostdlib hello.s && ./a.out
#
# --------------------------------------------------------------
.global _start
.text
_start:
# write (1, msj, 13)
mov $1, %rax # system call 1 is write
mov $1, %rdi # file handler 1 is stdout
mov $message, %rsi # address of string to output
mov $13, %rdx # number of bytes
syscall
# exit(0)
mov $60, %rax # system call 60 is exit
xor %rdi, %rdi # we want to return code 0
syscall
message:
.ascii "Hello, world\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment