0
votes

I am working on a school project (if you couldn't figure that out just by the fact that I'm using MIPS and QTSpim), and my group chose to make a calculator for large (128-bit) numbers. We know how to do operations on 128-bit numbers, but what we're having trouble with is having the user input.

The professor doesn't quite know how to do it, so does anyone know if there is a way to load a 128-bit integer using MIPS and QTSpim?

MIPS registers hold 32-bit integers, so the result would have to be stored in 4 registers, but is there a way to make that happen?

Thanks!

2

2 Answers

3
votes

I would:

  • Read the user input as a string
  • Convert the ASCII codes of the each digit to a number 0-9 (i.e. subtract '0')
  • Apply a radix conversion from base 10 to base 2, and hold the results in four 32 bit words
1
votes

Why is there a difference between 8, 16, 32, 64, 128 bits? As gusbro described you validate the character string, for every new number character multipy by 10 and add the new number. You already mentioned you know how to do operations on 128 bit numbers so...just do the operations, multiply and add. If you dont know how to do the operations then you are mulitplying by 10 which 0xA which is 0b1010. Using elementary school math, starting with the ones column 0 times anything is zero. the base to the power 1 column (10s in elementary school the twos column here) 1 times anything is itself but you move over one location. the fours column is a zero, the eights column is a 1 so add in abcd shifted left three columns

    abcd
   x1010
   =====
    0000
   abcdx
  0000xx
 abcdxxx

So multiplying by 10 is the same as taking the number shifted left one plus the number shifted left three, shifting and adding an infinite number of bits using 32 bit registers is fairly easy. If need be do it 16 or 24 bits at a time leaving bit 17 or bit 24 as the carry bit.

if you dont have a way to multiply and add 128 bits you wont get very far with a 128 bit calculator, so perhaps the above was un necessary.