title: MIPS Assembly - Open File failing
body: <p>I can't seem to open a file with the following MIPS code.</p>
  
  <p>Here I prompt a user for a string filepath, and read the input.</p>
  
  <pre><code>.text
  .globl main
  
  main:
      li $v0, 0
  reprompt_case_return:
  
      bltz $v0, reprompt_case_print
      # Print prompt.
      la $a0, prompt
      li $v0, 4
      syscall
  
      # Read input string.
      li $v0, 8
      la $a0, buffer
      li $a1, 1024
      syscall
  </code></pre>
  
  <p>Here I load sys code 13 for opening a file, and I make the assumption that $a0 register contains the string filepath address.</p>
  
  <pre><code>    # Open file.
      li $v0, 13
      # Note: filename string is already in $a0.
      li $a1, 0  # Flag for reading.
      li $a2, 0  # Mode is ignored.
      syscall
  
      j return_here
  </code></pre>
  
  <p>My issue is that <code>$v0</code> , the file descriptor, contains a neg number.</p>
  
  <p>The below code is the rest of the program logic but I think likely unrelated to the problem.</p>
  
  <pre><code>reprompt_case_print:
      # Print prompt.
      la $a0, reprompt
      li $v0, 4
      syscall
  
  return_here:
      # Check if $v0 is less than zero.
      bltz $v0, reprompt_case_return
  
  .data
  
  prompt: .asciiz "Enter the file path to a UTF-8 encoded file: \n"
  reprompt: .asciiz "The path was invalid, try re-entering the file-path: \n"
  buffer: .space 1024
  </code></pre>
  
  <p>I have tried moving the .jar file where I run the simulator to a folder containing a file, but I'm not able to read it. Any ideas?</p>
  
  <p>Thanks</p>