So I'm converting a binary number that the user gives to its decimal equivalent. I finished the conversion without problems, but now I am trying to validate the input. If the user enters any characters besides 1
or 0
, I want to branch to a label that will tell the user that their input is improper. This is what I have right now:
ValidateInput:
lb $s1, userNumber($t8)
beq $s1, 0, Calculate
bgt $s1, '1', InvalidInput
blt $s1, '0', InvalidInput
addi $t8, $t8, 1
j ValidateInput
I thought I could validate the input by using their ASCII table values, but it now thinks any input I try is improper. Even if I only enter 1s and 0s. Any help on this would be greatly appreciated.