Assembly MIPS - Create a file, specific extension
<p>I am coding a program in asm, I know a bit, but no expert. I am using Mars emulator. The part I do not understand is how does one create a file and make it have an specific extension like, file.vig? What I want is to create a file, give a name I want, write to it. None of this worked so far. I have the rest of the program working, but not this file creation and modification while in run time of Mars.</p>

<p>res points to a string</p>

<p>FileName points to a string like: file.vig</p>

<pre><code>li   $v0, 13        # system call for open file
la   $a0, FileName  # output file name
li   $a1, 577       # Open for writing (flags are 0: read, 1: write)
li   $a2, 0x1ff     # was recommended for file permissions
syscall             # open a file (file descriptor returned in $v0)
move $s6, $v0       # save the file descriptor 
</code></pre>

<p># Write to file just opened</p>

<pre><code>li   $v0, 15        # system call for write to file
move $a0, $s6       # file descriptor 
la   $a1, res       # address of buffer from which to write
li   $a2, 15        # hardcoded buffer length
syscall  
move $a0, $s6
li $v0, 16          # close
syscall
li $v0, 10
syscall
</code></pre>