Mips- print to file
<p>I want to print some content (strings and floating point numbers) to a file.</p>

<p>That's what I've implemented so far:</p>

<pre><code>.data:
    line_break: .asciiz "\n"
    buffer: .space 1024
.text:
main:
    addi $t0, $zero, -1
    jal open_file                           # open the file to write to
    beq $v0, $t0, create_file               # if return value -1 --&gt; file not available --&gt; create the file
    move $s6, $v0                           # save the file descriptor  
    [...]
    ulw $t0, print_initiaton_message        # save the print_initiaton_message in a temp
    sw $t0, buffer                          # put print_initiaton_message on buffer
    li $v0, 15                              # syscall to write to file
    move $a0, $s6                           # move file descriptor to $a0
    la $a1, buffer                          # target to write from
    li $a2, 1024                            # amount to be written
    syscall                                 # syscall to write in file
    [...]
    s.s $f12, buffer
    li $v0, 15                              # syscall to write to file
    move $a0, $s3                           # move file descriptor to $a0
    la $a1, buffer                          # target to write from
    li $a2, 4                               # amount to be written
    syscall                                 # syscall to write in file
    [...]
</code></pre>

<p>The basic idea is to put the necessary information in the buffer and then do the syscall.</p>

<p>It seems to work-since the file is correctly created, opened and closed afterwards. There is also content in it, but there is not the expected outcome:</p>

<pre><code>’®)@

PÀ&lt;@

[...]
</code></pre>

<p>At the first position, there should be a string, followed by a line break, followed by a floating point.</p>

<p>Now my questions:
- How can I realize a proper formatting of my output?
- What does the buffer size stand for and what happens, if my input exceeds the buffer size?
- What does the amount to be written mean?</p>

<p>I tried to go through several syscall references (i.e. <a href="http://courses.missouristate.edu/KenVollmar/mars/Help/SyscallHelp.html" rel="nofollow">this one</a>), looked for examples (and <a href="https://www.daniweb.com/programming/software-development/threads/434460/writing-integers-to-a-file-mips-assembly" rel="nofollow">found this</a>, or <a href="https://www.physicsforums.com/threads/mips-programming-file-i-o-problem.595052/" rel="nofollow">that</a>), but the main problem is that they only deliver code and do not cover my questions above.</p>