I am new in MIPS, and I am trying to judge whether each char in a string is an alpha. I used the ASCII code to help me to judge it, while I found there is no instruction representing larger than
meaning. So I try to implement a not
operation from the instructions I have known. Here's part of my code:
isAlpha:
sltiu $t0, $s2, 123
sltiu $t1, $s2, 97
nor $t1, $t1, $t1
and $t0, $t0, $t1
sltiu $t2, $s2, 107
sltiu $t3, $s2, 81
nor $t3, $t3, $t3
and $t2, $t2, $t3
or $t0, $t0, $t2
bne $t0, $zero, countAlpha
jr $ra
However, I could not get the result I want. I set a breakpoint and found that my not
operation seems to have some problems:
In my exception, $t1 should be 1 and $t2 should be 0, while the reality is not.
Where's the wrong place in my code? Is there any way to implement not
operation in MIPS? Or is there a better way to implement larger than
meaning in MIPS? Thanks in advance.