I'm trying to use the open syscall in Linux, from the manual page it takes 3 arguments, the pathname, flags, and the file mode. I tried to implement it with assembly x86_64 (Linux), but it doesn't create the file. By the way, where does the return value of this syscall is stored? The return value of open() is the file descriptor of the file, which then I want to write into.
section .text
    global _start
section .data
    pathname db "/home/user/Desktop/myfile.txt"
_start:
    mov rax, 2 ; syscall open
    mov rbx, pathname ; absolute path
    mov rcx, "O_CREAT" ; flag (create)
    mov rdx, "w" ; write (create file if not exists)
    syscall
    
    mov rax, 60
    mov rbx, 0
    syscall
The duplicate seems not to work for me, it doesn't create the file. And my path is valid.
section .text
    global _start
section .data
    pathname db "/home/user/Desktop/myfile.txt"
_start:
    mov rax, 2
    mov rdi, pathname
    mov rsi, 0x441   ; O_CREAT| O _WRONLY | O_APPEND
    syscall
    
    mov r8, rax      ; save the file handle
    
    mov rax, 60 ; exit syscall
    mov rbx, 0 ; 0 successful
    syscall
