I am attempting to multiply two 32 bit numbers in MIPS. I have some code here that uses the mult operation. I use the mfhi and mflo operations to get the two parts from mult, but I am not sure how to properly put these together. I have them print out the operations separately just for example.
The input numbers I have been using are: 1143330295 and 999999223
The output I get from this program (obviously needs some work) is: 266202121 -1483441327
The correct output would be 1143329406632360785 or I can do it in binary if that would be easier.
This code is from a larger project I am working on that will have to multiply two 32 bit numbers using a shift and add algorithm without using the mult function. I am just trying to wrap my head around representing the 64 bit number first. Thanks for any advice/input.
.data
getA: .asciiz "Please enter the first number(multiplicand): "
getB: .asciiz "Please enter the second number(multiplier): "
space: .asciiz " "
promptStart: .asciiz "This program multiplies two numbers. "
mipMult: .asciiz "The product, using MIPs mult is: "
endLine: .asciiz "\n"
.text
main:
li $v0,4
la $a0,promptStart
syscall
li $v0,4
la $a0,endLine
syscall
#prompt for multiplicand
li $v0,4
la $a0,getA
syscall
#acquire multiplicand
li $v0,5
syscall
move $s0,$v0
move $s5,$s0
#prompt for multiplier
li $v0,4
la $a0,getB
syscall
#acquire multiplier
li $v0,5
syscall
move $s1,$v0
move $s6,$s1 # copy
mult $s5, $s6
mfhi $t0
mflo $t1
li $v0,4
la $a0,mipMult
syscall
# print out the result (This is obviously not correct, I need some help)
li $v0,1
move $a0,$t0
syscall
li $v0,4
la $a0,space
syscall
# print out the result
li $v0,1
move $a0,$t1
syscall
# print the line feed
li $v0,4
la $a0,endLine
syscall
li $v0,10
syscall # exit program