mips32 - access file in mips using mars tool -
i'm trying access on file using mips instruction.
want read file line line not of file @ time code(1) not work.
also want write file , not overwrite!
can 1 me?
code:
open file writing
li $v0, 13 # system call open file la $a0, file # board file name li $a1, 0 # open reading li $a2, 0 syscall # open file (file descriptor returned in $v0) move $s6, $v0 # save file descriptor read file
li $v0, 14 # system call read file move $a0, $s6 # file descriptor la $a1, buffer # address of buffer read li $a2, 40 # hardcoded buffer length syscall # read file close file
li $v0, 16 # system call close file move $a0, $s6 # file descriptor close syscall # close file
i want read file line line not of file @ time code(1) not work.
read chunks of data buffer (e.g. few kilobytes). process buffer line-by-line (by looking linefeed characters), , read more data file when you've reached end of buffer.
also want write file , not overwrite!
set flags ($a1) 9 when opening file (syscall 13). corresponds "write-only create , append" (see this mars syscall reference).
Comments
Post a Comment