Reputation: 1
I'm tryng to open a file with a list of contacts, and when i verify if are with the correctly format (name ',' number), i use a bgt and a blt instruction to see if the chars are bigger than z or lower than a, so rejected. but when i do this, my blt instruction doesn't work. when its executed jump do the label, and if before i have a beq with a value bigger than the blt, he jumps to.
Maiuscula:
lb $t0,0($a0) #carrega a0 em t0
#slt $t1, $zero,$t0 #carater de t0 com zero
beq $t0,$zero,END
nop #se t1=0 entao, t0 tem o carater nulo, logo END
li $t3,0x41 # A maiusculo em ascii
li $t4,0x5a # Z maiusculo em ascii
slt $t5,$t0,$t4
bgt $t0,$t4,Erro #tinha bgt
nop
blt $t0,$t3,zero #here is the error
nop
j minuscula
nop
Upvotes: 0
Views: 2358
Reputation: 22585
Remove the line slt $t5,$t0,$t4
, as you are using pseudoinstruction bgt
/blt
which already uses slt
+ bne
to accomplish the task.
Aside from that, your code will:
So there seems to be some logic errors there...
For example, you should use bge
instead of bgt
and ble
instead of blt
because otherwise you will not check 'A' and 'Z' correctly.
Aside from that, I guess the logic is not doing what you meant it to do...
Upvotes: 1