Is it possible to overwrite a file using MIPS? I have a file and, under certain conditions (i.e. a user decide to update his personal data or delete completely) I need to delete/overwrite some words or row of the text file I have. I tried this thing: I already know how to find which word I would like to replace and, with a store byte i write on a buffer the "new" word. Then I should save it on file. And that's where my problems begin since, using flag 1 (on syscall 13) overwrites the whole file and flag 9 doesn't apply any change. Here's my code. What am I doing wrong?
loop:
la $t6, empty_space
sb $t6, buffer($s7)
beq $s7, $t5, save_on_file
subi $s7, $s7, 1
j loop
save_on_file:
#open file
li $v0, 13
la $a0, file_out
li $a1, 1
li $a2, 0
syscall
move $s6, $v0
#write on file
li $v0, 15
move $a0, $s6
la $a1, buffer
move $a2, $s7
syscall
#close
li $v0, 16
move $a0, $s6
syscall
j menu