Example of using GNU Assembler online via https://cocalc.com.
1# ---------------------------------------------------------------------------------------- 2# 3# From https://cs.lmu.edu/~ray/notes/gasexamples/ 4# 5# Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only. 6# To assemble and run: 7# 8# gcc -c hello.s && ld hello.o && ./a.out 9# 10# ---------------------------------------------------------------------------------------- 11 12 .global _start 13 14 .text 15_start: 16 # write(1, message, 13) 17 mov $1, %rax # system call 1 is write 18 mov $1, %rdi # file handle 1 is stdout 19 mov $message, %rsi # address of string to output 20 mov $13, %rdx # number of bytes 21 syscall # invoke operating system to do the write 22 23 # exit(0) 24 mov $60, %rax # system call 60 is exit 25 xor %rdi, %rdi # we want return code 0 26 syscall # invoke operating system to exit 27message: 28 .ascii "Hello, world\n" 29 30