I'm trying to do some access on file using mips instruction.
I want to read file line by line not all of the file at a time so this code(1) does not work.
Also I want to write to the file and not overwrite!
Can any one help me?
Code:
Open a file for writing
li $v0, 13 # system call for open file
la $a0, file # board file name
li $a1, 0 # Open for reading
li $a2, 0
syscall # open a file (file descriptor returned in $v0)
move $s6, $v0 # save the file descriptor
Read from file
li $v0, 14 # system call for read from file
move $a0, $s6 # file descriptor
la $a1, buffer # address of buffer to which to read
li $a2, 40 # hardcoded buffer length
syscall # read from file
Close the file
li $v0, 16 # system call for close file
move $a0, $s6 # file descriptor to close
syscall # close file