    .set noreorder
    .section .text, "ax", @progbits
    .align 2
    .global busy_loop
    .type busy_loop, @function

busy_loop:
    sw    $a0, 0($sp)
    lw    $v0, 0($sp)
    lw    $v1, 0($sp)
    nop
    addiu $v1, -1
    beqz  $v0, early_exit
    sw    $v1, 0($sp)

busy_loop_loop:
    lw    $v0, 0($sp)
    lw    $v1, 0($sp)
    nop
    addiu $v1, -1
    bnez  $v0, busy_loop_loop
    sw    $v1, 0($sp)

early_exit:
    jr    $ra
    nop
