I am trying to write a program that reads characters from a .dat file, corresponding to the different colors that will be displayed in the LED simulator; x = off, R = red, etc. My problem is that I cannot understand what I am doing wrong by opening the .dat file. I looked around and tried everything I could think of, but every time I build and run, I get -1 in $ v0, which means an error. Here is my code for opening / reading / closing a file:
.data
fin: .asciiz "maze1.dat"
buffer: .asciiz ""
.text
li $v0, 13
la $a0, fin
li $a1, 0
li $a2, 0
syscall
move $s6, $v0
li $v0, 14
move $a0, $s6
la $a1, buffer
li $a2, 1024
syscall
li $v0, 16
move $a0, $s6
syscall
The maze1.dat file is in the same directory as the MIPS program. Any help or suggestions are welcome.
source
share