Reading from one file and writing to another - MIPS

↘锁芯ラ 提交于 2020-12-15 05:36:12

问题


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

来源:https://stackoverflow.com/questions/64389225/reading-from-one-file-and-writing-to-another-mips

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!