I'm trying to sort through a list of 32-bit numbers using MIPS assembler and xspim. I've been stepping trough my code to see what fails and noticed that when comparing 0x00000000 with 0xFFFFFFFF it doesn't compare these numbers as it should. At the point where the program fails I got 0x00000000 in $t3 and 开发者_运维技巧0xFFFFFFFF in $t4 and it looks like this:
bge $t3,$t4,lol
#So if t3
is greater than or equal I should jump forward else continue. Now the problem is that the program jumps even though t3
is smaller.
This is because 0xffffffff
is interpreted as -1
, i.e., in 2-complement.
There are specific instructions to deal with numbers as if they were unsigned. Use these instructions. (Compare for instance bgt
and bgtu
where u
stands for unsigned.)
精彩评论