-1

I just want to run ANY kind of Spim programm using an Syscall for open, read and/or write a file, but that doesn´t work out. I am aware that probably my program and the file are not in the working directory of QtSpim, but I have no Idea how to chance it or set a new directory. So after the first Syscall $v0 is -1, which indaicates an error. I tried using the whole pathname for the to-read-file (example below) and tried to write/create a file to see, where QtSpim would save a file. If I have a fundamental flaw, do not hesitate to let me know. I am using QtSpim under Windows

    .data
filename: .asciiz "C:\Users\...\test.txt"      #einzulesender Dateiname
buffer: .space 1024
    .text
main:
#open the file (to get the file descriptor)
li   $v0, 13       # system call for open file
la   $a0, filename # board file name
li   $a1, 0        # Open for reading
li   $a2,          # Mode 
syscall            # open a file (file descriptor returned in $v0)
move $s1, $v0      # save the file descriptor 

#read from file
li   $v0, 14       # system call for read from file
move $a0, $s1      # file descriptor 
la   $a1, buffer   # address of buffer to which to read
li   $a2, 1024     # hardcoded buffer length
syscall            # read from file

# Close the file 
li   $v0, 16       # system call for close file
move $a0, $s1      # file descriptor to close

1 Answers1

0

i got exactly the same problem and my code looks nearly the same. The most documentaries about the syscall functions of qtspim also tell me, that the file descriptor gets returned in $a0. Even thought we get the descriptor actually in $v0.

Burning for the answer :)

Hyrikan
  • 59
  • 7