So for example if the input is Hello, the output should be HELLO and return 0.
but if the input is Hello?, then the output should be Hello? and return 1.
uppercase: li $v0, 0 touppercase: lb $t2, 0($a0) add $t1, $t2, 0 beq $t2, $0, exit blt $t2, 48, error #$v0 < 48? bgt $t2, 122, error #$v0 > 122? blt $t2, 57, next #$v0 < 57? blt $t2, 65, error #$v0 < 65? blt $t2, 90, next #$v0 < 90? blt $t2, 97, error #$v0 < 97? sub $t2, $t2, 32 sb $t2, 0($a0) sb $t1, 0($a1) next: addi $a0, $a0, 1 addi $a1, $a1, 1 j touppercase error: li $v0, 1 #store 1 sw $a0, $a1 j exit exit: jr $ra
I am able to get the right return number of 1 when the input contains an illegal character but for example if the input is Hello?, ny program would return HELLO? and 1.
I believe that I need to store the input somewere, and if the program ever goes to the error branch, then set the output as the input again, but am not sure what I am doing wrong.
Thank you in advance.

New Topic/Question
Reply


MultiQuote



|