#-------------------------------------------
# Loops - Do-While Loops
# Ported by: Noah Gergel
# Last updated: May 29 2020
#-------------------------------------------

.text

# Dummy function our do-while loop appears in.
foo:
    
    # Code before do-while loop.
    # ...

    # Set count = 0, and t2 = 1 constant.
    # We assume t0 already contains our value.
    add     t1, zero, zero  # count = 0
    addi    t2, zero, 1     # t2 <- 1

    # Label starting the do-while loop.
_doWhileLoop:
    srli    t0, t0, 1       # value = value >> 1
    addi    t1, t1, 1       # count = count + 1

    # Check condition to see if we should continue looping.
    bge     t0, t2, _doWhileLoop

_doWhileLoopDone:
    # We are done the do-while loop.
    # ...

    # Return to caller.
    jalr    zero, ra, 0