Mips 为什么我的计划是;从底部掉下来;?
我正在写一个MIPS程序,它应该要求用户输入两个数字,然后加、减、乘、除这两个数字。我被要求使用函数。每当我执行我的程序时,我的加法/减法函数都会工作,但由于某种原因,当程序到达我的乘法函数时,它不会打印答案,MARS会给我一条消息“从底部掉下来” 我补充说Mips 为什么我的计划是;从底部掉下来;?,mips,computer-architecture,Mips,Computer Architecture,我正在写一个MIPS程序,它应该要求用户输入两个数字,然后加、减、乘、除这两个数字。我被要求使用函数。每当我执行我的程序时,我的加法/减法函数都会工作,但由于某种原因,当程序到达我的乘法函数时,它不会打印答案,MARS会给我一条消息“从底部掉下来” 我补充说 li$v0,10#10是要退出的系统调用 系统呼叫 这为我修正了相乘(multlabel)后的“下拉底部”错误,即退出而不是从函数调用返回,即,代替li$v0,10syscall您应该发出jr$ra .text main
li$v0,10#10是要退出的系统调用 系统呼叫
这为我修正了相乘(
mult
label)后的“下拉底部”错误,即退出而不是从函数调用返回,即,代替li$v0,10
syscall
您应该发出jr$ra
.text
main:
la $a0,prompt1
li $v0,4
syscall #Asks for first integer
li $v0,5
syscall #stores first int in $v0
add $s0,$v0, $zero
la $a0,prompt2
li $v0,4
syscall #puts first int into $t0, asks for second int.
li $v0,5
syscall #stores second int in $v0
move $s1,$v0 #moves second int into $t1
move $a0, $s0 #moves first int into $a0
move $a1, $s1 #moves second int into $a1
jal add #jumps to add method
move $t2, $v0 #moves the result of add method into $t2
la $a0,ans1
li $v0,4
syscall # print string before result
move $a0,$t2
li $v0,1
syscall # print result of sum
la $a0,endl
li $v0,4
syscall #prints blank line
#--------------------------------------------SUB
move $a0, $s0 #moves first int into $a0
move $a1, $s1 #moves second int into $a1
jal sub #jumps to sub method
move $t0, $v0 #Moves answer from sub method to $t0
la $a0,ans2
li $v0,4
syscall # print string before result
move $a0, $t0 #moves answer from sub method $t0 into $a0 to be printed.
li $v0, 1
syscall#prints result of difference
la $a0,endl
li $v0,4
syscall #prints blank line
#------------------------------------------mult
la $a0,ans3
li $v0,4
syscall # print string before result
move $a0, $s0 #moves first int into $a0
move $a1, $s1 #moves second int into $a1
jal mult
move $t0, $v0 #moves answer into $a0
move $a0, $t0 #moves answer from sub method $t0 into $a0 to be printed.
li $v0, 1
syscall#prints result of difference
la $a0,endl
li $v0,4
syscall #prints blank line
#------------------------------------------
li $v0,10
syscall #ENDS PROGRAM
add:
move $t0, $a0
move $t1, $a1
add $v0, $t0, $t1
jr $ra #jumps back
sub:
move $t0, $a0
move $t1, $a1
sub $v0, $t0, $t1
jr $ra # jumps back
mult:
move $t0, $a0
move $t1, $a1
mult $t0, $t1 #multiplies $t0,$t1
mfhi $a0 #overflow
mflo $v0 #answer
.text
main:
la $a0,prompt1
li $v0,4
syscall #Asks for first integer
li $v0,5
syscall #stores first int in $v0
add $s0,$v0, $zero
la $a0,prompt2
li $v0,4
syscall #puts first int into $t0, asks for second int.
li $v0,5
syscall #stores second int in $v0
move $s1,$v0 #moves second int into $t1
move $a0, $s0 #moves first int into $a0
move $a1, $s1 #moves second int into $a1
jal add #jumps to add method
move $t2, $v0 #moves the result of add method into $t2
la $a0,ans1
li $v0,4
syscall # print string before result
move $a0,$t2
li $v0,1
syscall # print result of sum
la $a0,endl
li $v0,4
syscall #prints blank line
#--------------------------------------------SUB
move $a0, $s0 #moves first int into $a0
move $a1, $s1 #moves second int into $a1
jal sub #jumps to sub method
move $t0, $v0 #Moves answer from sub method to $t0
la $a0,ans2
li $v0,4
syscall # print string before result
move $a0, $t0 #moves answer from sub method $t0 into $a0 to be printed.
li $v0, 1
syscall#prints result of difference
la $a0,endl
li $v0,4
syscall #prints blank line
#------------------------------------------mult
la $a0,ans3
li $v0,4
syscall # print string before result
move $a0, $s0 #moves first int into $a0
move $a1, $s1 #moves second int into $a1
jal mult
move $t0, $v0 #moves answer into $a0
move $a0, $t0 #moves answer from sub method $t0 into $a0 to be printed.
li $v0, 1
syscall#prints result of difference
la $a0,endl
li $v0,4
syscall #prints blank line
#------------------------------------------
li $v0,10
syscall #ENDS PROGRAM
add:
move $t0, $a0
move $t1, $a1
add $v0, $t0, $t1
jr $ra #jumps back
sub:
move $t0, $a0
move $t1, $a1
sub $v0, $t0, $t1
jr $ra # jumps back
mult:
move $t0, $a0
move $t1, $a1
mult $t0, $t1 #multiplies $t0,$t1
mfhi $a0 #overflow
mflo $v0 #answer
li $v0,10
syscall
.data
prompt1:.asciiz "Enter the first integer: "
prompt2:.asciiz "Enter the second integer: "
ans1: .asciiz "The sum is "
ans2: .asciiz "The difference is "
ans3: .asciiz "The product is "
ans4: .asciiz "The quotient is "
endl:.asciiz "\n"
.data
prompt1:.asciiz "Enter the first integer: "
prompt2:.asciiz "Enter the second integer: "
ans1: .asciiz "The sum is "
ans2: .asciiz "The difference is "
ans3: .asciiz "The product is "
ans4: .asciiz "The quotient is "
endl:.asciiz "\n"