Reputation: 489
My program has to accept an input between between 0 and 2^32 or 4,294,967,295.
Which bit-wise 32 bytes should be able to do, but i'm overflowing into the negatives because i'm not sure how to make this an unsigned integer. I see that i have instructions that can do it via arithmetic, but what if i just want to load it into a register and print it? It always prints out the negative number right now.
Upvotes: 0
Views: 2789
Reputation: 9
http://courses.missouristate.edu/KenVollmar/mars/Help/SyscallHelp.html
Try service call 36. That prints an unsigned int.
Upvotes: 1
Reputation: 2137
Whether the int is signed or unsigned should not matter for how it exists in the register. Either way it is just a sequence of bits. 2^32 -1 = 0xFFFFFF. If you interpret this as an unsigned integer, this is 4,294,967,295 or 2^32-1. If you read it as a signed integer using two's complement, 0xFFFFFFFF is -1. I would guess the problem is in your print command. Try formatting your print output as unsigned.
Upvotes: 1