MIPS Multiply中的汇编语言和使用MARS的Divide

时间:2013-02-25 01:11:59

标签: assembly mips

我正在试图找出为什么它在div之后就行了。也许我设置div错了?或存储错误?还有,我是否打电话给它打印总距离?

li $t0, 284  #distance in miles from OR to WA
li $t1, 387  #6 hours and 27 minutes, 6 hours = 360 minutes +27 minutes, 387 minutes
li $t2, 5280 #5280 feet in a mile
li $t3, 60   #60 seconds in a minutes

main:
    mult $t0, $t2        #gets the total feet in the 284 miles and places it into $t4
    mfhi $t4

    mult $t1, $t3       #gets the total seconds in the 6 hours an 27 minutes
    mfhi $t5

    div $t4, $t5    #divides the total feet by the total seconds
    mflo    $t6
        li $v0, 1
    move $a0, $t6
    syscall

    addi $v0, $zero, 10 ##system call to leave the program
    syscall         ##exits the program 

2 个答案:

答案 0 :(得分:1)

我没有看到您在第一个$v0之前将任何系统电话号码加载到syscall

答案 1 :(得分:0)

问题是你要除以0.怎么可能?那么,你的产品284 * 5280 = 1499520和387 * 60 = 23220适合32位。 mult生成64位乘积,hi寄存器中最高有效32位,lo寄存器中最低有效32位。因此,在hi之后,mults为0。但由于某种原因,您决定使用hi而不是lo

另外,奇怪的是main:位于lis之后。那些lis可能根本没有执行。

相关问题