#-------------------------------------------
# Conditionals - If/Else Conditional
# Ported by: Noah Gergel
# Last updated: May 29 2020
#-------------------------------------------

.text

# Generic example.
foo:

    # Before if/else

    bne   t0, t1, _f2Else   # Example comparison, seeing if t0 == t1

    # "Then" block

    j     _f2Join           # Join the two blocks of code
_f2Else:

    # "Else" block

    j     _f2Join           # Join the two blocks of code
_f2Join:
    
    # After if/else conditional
    # ...

    jalr  zero, ra, 0

# Specific example.
bar:
    blt  t0, zero, _else    # if T < 0 goto _else
    add  t1, t2, zero       # ptr <- string
    j    _join              # goto _join
_else:
    add  t1, zero, zero     # ptr <- 0
_join:
    addi t1, t1, 1          # ptr++