Im trying to write a MIPS code that generates two random bits one by one and stores it in $v0.The bits need to be 00,01 or 10 (if both bits are 1 the function needs to create the bits again).The problem is I can’t get a output when I run a test on gen_byte.
gen_byte:
li $t0, 0
loop:
jal gen_bit
move $t1, $v0
jal gen_bit
move $t2, $v0
sll $t0, $t0, 1
or $t0, $t1, $t2
# Check if the generated byte is 11
beq $t1, 3,loop
move $v0, $t0
jr $ra
**gen_bit: **
li $a0, 0
li $v0, 41
syscall
andi $v0, $a0, 1
jr $ra
New contributor
Tagore is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.