If-Else with nested If in MIPS assembly
<p>I am trying to code something that continually takes in an integer from the user and stores the minimum value into $s2.</p>

<p>This is a C code representation of what I am trying to do</p>

<pre><code>if ( $s2 == 0 )
    $s2 = $t0
else {
    if ( $t0 &lt; $s2 )
    $s2 = $t0
}
</code></pre>

<p>Basically, I loaded $s2 with zero outside of the input loop. This checks if $s2 has zero, and sets it to the current (first) user input ($t0) since that is the minimum value. If $s2 no longer contains zero then it checks the new user input  against what is already in $s2 and if it is less than it becomes the new minimum value.</p>

<p>How can I implement this in MIPS assembly?</p>

<p>I have this so far (this is the end piece of a loop called read) but all it does is when I press the first int, it skips to the end and prints the min without looping over.</p>

<pre><code>read:
    ...

    beq         $s2, $zero, LOAD    

    slt     $s6, $t0, $s2
    bne     $s6, $zero, LOAD

    j       read

LOAD:

    li      $s2, 0
    addu        $s2, $s2, $t0
</code></pre>