The allowed range of the values for any register in MIPS are from : -2,147,483,648 to 2,147,483,647
However, I don't need the signed integer, so I want the values to be from 0 to 4,294,967,295.
I tried to define dword in MIPS but it didn't recognize the keyword.
Are there any ways to make the register unsigned?
Code I tried:
.data
.text
main:
li $v0, 5
syscall
move $t0, $v0
li $v0, 1
addu $a0, $t0, 0
syscall
I tried the instruction
addu
which is the unsigned addition, but I still cannot store values greater than 2,147,483,647, and the mars simulator gives me an execution error
Please don't suggest a string solution. I simply want to store values larger than 2,147,483,647
I have mentioned the signed because the sign takes one bit of the register.
A register just contains bits -- the interpretation of those bits is up to you. The value is not inherently signed or unsigned (or even an integer), but generally code will treat it as being some type.
In particular the MARS syscall 1
prints a signed integer. You probably just want the MARS syscall 36
to print an unsigned integer.
li $v0, 36
li $a0, -1
syscall
will print 4294967295
Unfortunately if you're using the old SPIM simulator, it only supports syscalls up to 17, so to print an unsigned, you'll need to write your own code to convert it to a string and print that with syscall 4