; intel syntax

section .data
    msg db "Hello, World!", 10      ; 10 is the ASCII code for a newline
    msg_len equ $ - msg             ; calculate the length of the string

section .text
    global _start

print_hello:
    mov rax, 1          ; 1 -> sys_write
    mov rdi, 1          ; file descriptor (1 = stdout)
    mov rsi, msg        ; pointer to the string
    mov rdx, msg_len    ; length of the string
    syscall             ; call the kernel
    ret                 ; return to where i was

exit:
    mov rax, 60  ; 60 -> sys_exit
    xor rdi, rdi ; exit '0'
    syscall

_start:
    mov rdi, [rsp]     ; argc
    lea rsi, [rsp + 8] ; argv

;   mov rax, [rsi]     ; rax = argv[0] <- i already know what i'm called thank you
    mov rax, [rsi + 8] ; rax = argv[1]
;   mov rbx, [rsi + 8*n] rbx = argv[n]

    call print_hello
    jmp exit ; goodbye
