Reading from one file and writing to another - MIPS

222 Views Asked by At

I have written some code which opens and reads from a file, input.txt, in a loop. I now want to take each word from the first file, and write it to a new file like so.

If file 1 says "This is my file", File 2 would say "This /n is /n my /n file" each on a separate line.

I have written a label which opens the file to be written to, now I am unsure of what I should write in order to access each word from my input.txt.

file_open:
    li $v0, 13
    la $a0, output_file_name # output.txt
    li $a1, 1
    li $a2, 0
    syscall  # File descriptor gets returned in $v0
file_write:
    move $a0, $v0  
    li $v0, 15
    la $a1, str_data # my random string 
    la $a2, str_data_end
    la $a3, str_data
    subu $a2, $a2, $a3  
    syscall
file_close:
    li $v0, 16  
    syscall 

This is my practice, as current it just prints a random string which I have given it. How do I modify this so as I am now writing the words from input.txt into output.txt

0

There are 0 best solutions below