I am trying to convert a number in 2's complement in MIPS to sign magnitude. To do this, I think I would:
For example, 11111111111111111111111111111001 (0xfffffff9) would become 00000000000000000000000000000111 (0x00000007).
I figured out how to do step 1 & 2, but can't figure out step 3. Does anyone know how I would do this?
Also, is there a better way to convert from 2's complement to sign magnitude format in MIPS?
If you XOR the value with 0x80000000, the most significant bit will flip. You can do the last two steps (retaining the most significant bit and flipping the others) by XOR'ing with 0x7fffffff.
User contributions licensed under CC BY-SA 3.0