#-------------------------------------------
# Conditionals - If Conditional
# Ported by: Noah Gergel
# Last updated: May 27 2020
#-------------------------------------------

.text

# Function that exhibits the conditional with the same order as original code.
foo:
    # Potential code before conditional.
    # ...

    # Start of the conditional code.
    bne t0, zero, _sub     # if x != 0 goto _sub
    add t1, t2, t3         # a = b + c;
_sub:
    # This subtraction is executed regardless so we fall-through in both cases.
    sub t1, t2, t3         # a = b - c;



# Function with same condition expression as original code.
bar:
    # Potential bar code before conditional.
    # ...
    li t0, 0xAAA
    li t1 0xA
    li t2 0xAA
    li t3 0x0F0F0AAA
    lui t2, 0x0F0F0
    #addi t2, t2, 0xAAA
    # Start of if conditional.
    beq t0, zero, _add     # if x == 0 goto _add
    sub t1, t2, t3         # a = b - c;
    j _after
_add:
    add t1, t2, t3         # a = b + c;
_after:

    # Afterwards, bar continues as normal.
