Reputation: 137
for a homework assignment I'm supposed to multiply a single precision IEEE 754 number stored in the data segment with 4 and store the result back. I perfectly understand how IEEE 754 works and how this simple multiplication can be accomplished(Exp +2).
However, I can't figure out how I'm supposed to work with the 32-bit binary, since MIPS does not seem to support binary representation as such, and reading 32 zeros and ones from the data segment seems a little bit complicated to me, especially since we're supposed to write the instructions down instead of uploading a program.
Is there any way of messing around with the binary IEEE754 representation other than stupidly handling the bits one by one? I'm not allowed to use any floating point operations and should ignore overflows etc.
Upvotes: 2
Views: 1842
Reputation: 182829
You can manipulate the bits in groups. For example, you can extract selected bits by masking (with logical AND) and then shifting. You can put specific bits back by removing the existing bit values (with AND), shifting the bits you want to put back to the right place, and then combining (with OR).
Logical AND, OR, shift left, and shift right, in combination allow you to manipulate bits as a large group.
For example, to extract the four high bits from a 32-bit unsigned value, AND with F0000000 and then shift right 28 bits. To replace the four high bits of X with Y, AND X with 0FFFFFFFF and the OR it with Y shifted right 28 bits. And so on.
Upvotes: 3