main: li $v0, 5 syscall move $a0, $v0 jal printBits li $v0, 10 syscall printBits: # $t3 contains the number to print # $t1 contains a 1 bit in the current position # $t2 is the isolated bit move $t3, $a0 li $t1, 1 sll $t1, $t1, 31 loop: and $t2, $t1, $t3 beq $t2, $zero, printAzero li $a0, 1 li $v0, 1 syscall j loopEnd printAzero: li $a0, 0 li $v0, 1 syscall loopEnd: srl $t1, $t1, 1 bne $t1, $zero, loop jr $ra