What is the best way to test if the byte stored in a reg开发者_运维技巧ister is a letter a-z and A-Z. I tried
blt $t1, 'a', next
blt $t1, 'Z', next
but that didnt work. Any help? PS I am using SPIM to test the code.
Try this:
blt $t1, 'A', next
bgt $t1, 'z', next
ble $t1, 'Z', ok
blt $t1, 'a', next
ok:
# code to run if byte in $t1 is a letter
next:
# code to run if byte in $t1 is a not letter
Basically you need to check the content of the register to be between 'A' and 'Z' or 'a' and 'z'.
精彩评论