为什么我的程序是"Dropping off bottom"?
Why is my program "Dropping off bottom"?
我正在编写一个 MIPS 程序,它应该向用户询问两个数字,然后对这两个数字进行加、减、乘和除。我需要使用函数。每当我执行我的程序时,我的 add/subtract 函数都会工作,但由于某种原因,当程序到达我的乘法函数时,它不会打印答案,MARS 会给我消息 "dropped off bottom"。
.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"
我加了
li $v0, 10 #10是退出的系统调用
系统调用
这为我修复了 "drop off bottom" 错误
我正在编写一个 MIPS 程序,它应该向用户询问两个数字,然后对这两个数字进行加、减、乘和除。我需要使用函数。每当我执行我的程序时,我的 add/subtract 函数都会工作,但由于某种原因,当程序到达我的乘法函数时,它不会打印答案,MARS 会给我消息 "dropped off bottom"。
.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"
我加了
li $v0, 10 #10是退出的系统调用 系统调用
这为我修复了 "drop off bottom" 错误