I know how to convert from two's complement to base 10 by hand.
http://sandbox.mc.edu/~bennet/cs110/tc/tctod.html
as shown by the link. You can tell if a number is negative or positive by the first bit, so my idea was since the number is 8 bit i would divide by 1000 0000 in binary or hex 0x00000080.
Does anyone have a better solution because right now this is not really working for me, my code is at the bottom. Register 1 is where the two's complement number is.
lis $8
.word 0x00000080
div $1, $8
mflo $9
jr $31
First what you can do is to create the NOT of the variable. MIPS doesn't have a built in NOT but you can use the XOR to get it (setting a register's value to -1 with addi, using XOR on the register to be negated with the register with -1 in it, which is storing all 1's)
After that it's easy, just add 1 to it.
User contributions licensed under CC BY-SA 3.0