Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing 0x00000000 with 0xFFFFFFFF in MIPS

Tags:

assembly

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.

like image 420
Xturbed1442 Avatar asked Oct 10 '22 20:10

Xturbed1442


1 Answers

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

like image 198
aioobe Avatar answered Nov 13 '22 05:11

aioobe