Xturbed1442
Xturbed1442

Reputation: 95

Comparing 0x00000000 with 0xFFFFFFFF in MIPS

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.

Upvotes: 5

Views: 1114

Answers (1)

aioobe
aioobe

Reputation: 421100

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

Upvotes: 4

Related Questions