1

Actually, my task is to multiply two 32bits number in MIPS which then generate the output of 64bits. Least significant 32bits are to be saved in 'lo' register and the remaining in 'hi' register to my understanding.

When I multiply 100000 and 200000 I get a817c800 in 'lo' register and 4 in 'hi' register

mult $t1, $t2 
    mflo $s0
    mfhi $s1 

enter image description here

Alain Merigot
  • 10,667
  • 3
  • 18
  • 31
Abdul Ahad
  • 51
  • 5

1 Answers1

1

When I multiply 100000 and 200000 I get a817c800 in 'lo' register and 4 in 'hi' register

Correct.

Because the result is 64 bits wide and you are using a 32-bit MIPS CPU, you need two registers to store the result.

In your code, the high 32 bits are in s1 and the low 32 bits are in s0. So the two registers s1 and s0 represent the 64-bit value 4a817c800 (hexadecimal) which is 20000000000 (decimal). And this is the correct result.

Your next question might be how you can print out a 64-bit number with qtspim. Unfortunately, I have no experiences with MIPS simulators (only with real MIPS CPUs), so I don't know if this is possible at all.

Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38
  • SPIM can print strings so you can always write your own function, but I think only has built-in support for printing signed decimal integers (or float/double). MARS has some "extended" system calls that SPIM doesn't support (http://courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html), including for printing hex. That would let you easily print the two halves of a 64-bit integer. (For future readers: 16 is a power of 2, so the low hex digits don't depend high bits of the number. But 10 isn't, so printing the 2 halves separately as decimal doesn't work.) – Peter Cordes Apr 01 '19 at 04:58