# Author: Dr. Zoppetti
# Hello World in assembly, demonstrating system calls
# OS loader (activated through execve function) calls _start,
#   which calls _libc_start_main,
#   which calls main
# Here we define our own _start instead of relying on library version. 
# Generate executable with
#   as HelloAsm.s -o HelloAsm.o
#   ld HelloAsm.o -o HelloAsm
	
.data

msg:
    .ascii "Hello, world!\n"
    len = . - msg

.text
    .global _start

_start:
    movq  $1, %rax
    movq  $1, %rdi
    movq  $msg, %rsi
    movq  $len, %rdx
    # 1 -- write (fd, buffer, len)
    syscall
    # int $0x80 -- old way

    movq  $60, %rax
    xorq  %rdi, %rdi
    # 60 -- exit (status)
    syscall
