开发者

test byte stored in register mips

开发者 https://www.devze.com 2023-03-03 09:55 出处:网络
What is the best way to test if the byte stored in a reg开发者_运维技巧ister is a letter a-z and A-Z.

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'.

0

精彩评论

暂无评论...
验证码 换一张
取 消