Hi,
I need to write a program that receives a 20 char string from the user and transforms lowercase to uppercase letter, but it should not affect any other character not included in the lowercase range (97-122, a-z). I wrote my program and the filters for the a-z configuration but it doesn't returns what it should return. Eg. "hello world"----> "HELLO WORLD". It returns only what the array had on the initial state. This is my code:
.data
.align 0
array: .space 20
msg1: .asciiz "Please enter 20 characters\n"
.text
.globl main
main:
#prompting user for 20 char
addi $v0,$0,4
la $a0,msg1
syscall
#storring string in array
addi $v0,$0,8
la $a0,array
addi $a1,$0,20
syscall
#settting limits and counters
addi $t0,$0,32 #32 difference
addi $t1,$0,0 #counter
addi $t2,$0,20 #limit
addi $t3,$0,97 #limit for lower case chars(a)
addi $t4,$0,123 #limit for lower case chars(z)
loop:
lb $t3,array($t1) #loading byte from $t1 place of array
filtering1:
bge $t3,$t5,filtering2 #if char in array(i)>=97---->filtering2
beqz $t5,exit #if char in array(i)=null----> exit (it has already printed the rest of chars)
j nothing #if char in array(i)<97---> print character
filtering2:
blt $t3,$t5,transforming #if char in array(i)<=122---->filtering2
j nothing #if char in array(i)>122---> print character
transforming: #lower to uppercase
sub $t3,$t3,$t0 #substract 32 (eg. 97-32=65 --->A)
sb $t3,array($t1) #storring the new sub in place $t1 of array
addi $t1,$t1,1 #i=i+1
j loop #loop until char in array(i)=null
nothing:
addi $t1,$t1,1 #setting counter i=i+1
j loop #loop until char in array(i)=null
exit:
addi $v0,$0,4
la $a0,array #printing array
syscall
addi $v0,$0,10 #exit
syscall
Thank you for any kind of help!