MIPS - Making a 64 bit number when you only have 32 bit register support

In summary, the programmer is trying to find a way to add 32 bit numbers together and if there is an overflow then output the result as a 64 bit number. He has four ideas, two of which do not work. The first idea is to increment another register when there is an overflow and the second idea is to allocate memory and save the result there. The third idea is to read in a binary input and if there is an overflow then add the bits to a new number and output that. The fourth idea is to use the $f register, but it seems like it is private and he cannot access it.
  • #1
Kerren
9
0
Hey guys I've been working on this program for just over a week now and I just can't seem to find any way around my problem. The problem I'm having is:

I'm trying to add 32 bit numbers together and if there is an overflow then I'd like to find a way to output the result as a 64 bit number.

I had a couple of ideas (as of yet, none of them have worked :biggrin:) so here they are:

  1. My first bright idea :biggrin:
    I tried to add numbers together and when there was an overflow I'd increment another register (lets call it the "overflow" register). Once the calculation was done I would just output the overflow register next to the other register to make a "64 bit" number :smile: In theory this would work IF we were working in decimal (base 10) because when there is an overflow a digit is added to the front of the result, however, in binary there is not always a whole new digit added to the front of the result so this didn't work for me and I got some pretty funny answers :smile:!
  2. The second idea
    I tried to allocate 8 bytes in the heap memory block and just save the result to that. The problem I had is that I can't dereference that allocated memory in the actual add function. This means that I have to use an intermediate register for calculating the result and then I would copy this intermediate register to the allocated memory. This defeats the point of the allocated memory because the intermediate register is only 32 bits :smile:
  3. The third (untested) idea
    I want to read in an actual binary input and then I can shift the bits and if there is an overflow I add them to a new binary number (the overflow register) and then output both the overflow register and the result register together to form a 64 bit number. The problem I'm having is that I don't actually know how to make a binary variable (is there even such a thing as a "binary variable" :biggrin:??)
  4. The fourth idea
    I tried to use the $f register because it looks to me like they are 64 bit registers but it seems like they are private registers that I cannot access. Does anyone know any way around this?
  5. Other thoughts
    Is there any way to link registers together so that they can form virtual 64 bit ones (I know that's a really hopeful thought :smile:)?

    Also does anyone have any other ideas on how to make a 64 bit system using only 32 bit registers?

Thanks guys!
 
Engineering news on Phys.org
  • #2
I'm an idiot! I thought I put this in the course work section :)! Can we move this quick?
 

FAQ: MIPS - Making a 64 bit number when you only have 32 bit register support

How does MIPS handle 64 bit numbers with only 32 bit register support?

MIPS handles 64 bit numbers by using a technique called "register pairing". This involves using two 32 bit registers to store a single 64 bit number. The first register holds the most significant bits and the second register holds the least significant bits.

What are the limitations of using register pairing for 64 bit numbers in MIPS?

The main limitation of using register pairing is that it requires extra instructions and processing time to work with 64 bit numbers. This can slow down the overall performance of the program. Additionally, the number of available registers is reduced when using register pairing, which can limit the amount of data that can be processed at once.

How does MIPS handle arithmetic operations on 64 bit numbers using register pairing?

MIPS uses a set of instructions specifically designed for register pairing to perform arithmetic operations on 64 bit numbers. These instructions allow for the two registers to be treated as a single 64 bit value, allowing for operations such as addition, subtraction, multiplication, and division to be performed on the full 64 bit number.

Can a 64 bit number be stored in a single 32 bit register in MIPS?

No, a 64 bit number cannot be stored in a single 32 bit register in MIPS. This is because the maximum value that can be stored in a 32 bit register is 2^32-1, which is only half of the maximum value of a 64 bit number (2^64-1). Therefore, a single 32 bit register is not large enough to hold a 64 bit number.

Are there any alternative methods for handling 64 bit numbers in MIPS?

Yes, there are alternative methods for handling 64 bit numbers in MIPS. One option is to use a data type called "doubleword" that is specifically designed to hold 64 bit numbers. This allows for easier manipulation of 64 bit numbers and does not require the use of register pairing. However, using doubleword data types may also come with its own limitations and trade-offs.

Similar threads

Back
Top