title: Specify path to file for sys_create and sys_write in assembly
body: <p>I'm trying to open a file in assembly using this code:</p>
  <pre><code>.data
  filename: .asciz &quot;/home/student/Documents/hw2&quot;
  file_descriptor: .quad 0
  
  .text
  .global main
  main:
      # create output
      movq $85, %rax
      movq $filename, %rdi
      movq $0777, %rsi
      syscall
      movq %rax, (file_descriptor)
      ret
  </code></pre>
  <p>But I don't understand how do I put the PATH into filename? It won't create any file and it return -21 in return value (%rax).</p>
  <p>I'm also trying to use the following code in order to read from existing file - but again, I don't see anything written inside digit (the place in the memory) after running this code (right before exiting).</p>
  <pre><code>.data
  filename: .asciz &quot;input.txt&quot;
  file_descriptor_in: .quad 0
  digit: .quad 0
  .text
  .global main
  main:
      # open INPUT
      movq $2, %rax           # save service number
      movq $filename, %rdi    # save path to file
      movq $0, %rsi           # save authorization level
      syscall
      movq %rax, (file_descriptor_in) # save file-descriptor number
      
      # read input
      movq $0, %rax                       # save service number               
      movq $file_descriptor_in, %rdi      # save descriptor of file
      movq $digit, %rsi                   # save buffer address to where the data will be saved
      movq $1, %rdx                       # save size of data to read
      syscall
      ret
  </code></pre>
  <p>I don't succeed writing either (I'm getting -9 return value)</p>
  <p>I can't find any explanation online about how to use those command or what errors do they return. How can I learn to determine what's wrong with my code?</p>