我试图在 MIPS 中将两个 32 位数字相乘。我使用 mfhi 和 mflo 操作从 mult 中获取两个部分,但我不确定如何正确地将它们放在一起。
我一直使用的输入数字是:2101234567和-1101234567
我从这个程序中得到的输出(显然需要一些工作)是:-538758966 841098447
正确的输出是 -2313952138555677489 但我不知道如何显示它。
这段代码来自我正在处理的作业,它必须使用移位和加法算法将两个 32 位数字相乘,而不使用 mult 函数。我只是想首先考虑代表 64 位数字。感谢您的任何建议。
.data
getA: .asciiz "Please enter the first number: "
getB: .asciiz "Please enter the second number: "
space: .asciiz " "
promptStart: .asciiz "This program multiplies two numbers. "
mipMult: .asciiz "The product 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