Yeen 0 Newbie Poster

First of all, yes this is homework. Secondly, I'm pretty much stuck :-/

As an example, say I have a word:
0000 0000 0000 0000 0000 0000 0010 0011 ; 35

I want to convert it into IEEE 754 using MIPS:
0100 0010 0000 1100 0000 0000 0000 0000 ; 35.0


This is my current train of thought:
1. I get the exponent by counting how many bits there are after the most significant 1 (marked in red), and then add 127 to get the proper exponent. In this case 132.
2. I get rid of the 'hidden' 1 (by subtracting or using 'andi'). Then I shift left 23 - exponent (this case: 23 - 5 = 18) times to get 00011 into place.
3. Then I insert the exponent by adding it to the word. I'll have to store it in a temp register and place it properly there first of course.
4. Finally I modify the 32st bit (0 or 1) depending on if it's positive or negative. (The assignment is two's complement -> IEEE 754, but handling that is not a problem as of now. I have a pretty good idea of how to construct my functions to check for negatives and convert if necessary.)

The problem I'm having is that I don't really know how to get the exponent. Counting the bits after the most significant 1 is a fine thought, but I have no idea on how to implement it in MIPS.

Other than that I feel like I have a working solution for this problem. Albeit a somewhat ineffective one at glance.

Questions:
-How do I get the exponent?
-Am I approaching this in the right way? Maybe getting the exponent first isn't the way to go?
-Is there already a MIPS instruction for converting into IEEE 754 that I've missed?

The only hint I got from the prof was "remember, it's always an integer". Wooppee :P

Thanks for reading. Any help is appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.