首页 > 解决方案 > 为什么我收到“程序已完成运行(掉到底部)错误?

问题描述

我不确定为什么这给了我一个脱落的错误。有人知道怎么修这个东西吗?我正在尝试创建一个可以在 MIPS 中转换十进制、十六进制和二进制的程序。我应该请求输入数据类型和输入数据,然后请求输出数据类型,并输出数据。任何和所有的帮助表示赞赏,谢谢!

代码:

#Provide data variable and data as an input and output
.Data
Input1: .asciiz "Kindly enter the input X:"
Input2: .asciiz "Please provide the number system Y details:"
Output: .asciiz "\nThe result will be R:"

#starts global main
.Globl main
main:
addi $A0, $zero, 2
addi $A1, $zero, 15

#get the input value dropped by the user
getX:

li $M0, 4
la $N0, Input1
syscall
li $M0, 5
syscall
blt $M0, $zero, getX

move $K0, $M0

#get the value of the number system dropped by the user
getY:

li $M0, 4
la $N0, Input2
syscall
li $M0, 5
syscall
blt $M0, $A0, getY
bgt $M0, $A1, getY

add $K1, $zero, $M0

li $M0, 4
la $N0, Output
syscall

add $N0, $zero, $K0
add $N1, $zero, $K1

jal convert

li $M0, 15
syscall

#perform conversion over the respective input and number system
convert:
addi $sp, $sp, -16

sw $A3, 12($sp)

#Applying counter that is used to check that how many
#times values will be popped up from the stack
sw $A0, 8($sp)
sw $A1, 4($sp)
sw $ra, 0($sp)

add $A0, $zero, $N0
add $A1, $zero, $N1

beqz $A0, end

div $K4, $A0, $A1
rem $K3, $A0, $A1
add $sp, $sp, -4
sw $K3, 0($sp)

add $N0, $zero, $K4
add $N1, $zero, $A1
addi $A3, $A3, 1

jal convert

end:

lw $ra, 0($sp)
lw $A1, 4($sp)
lw $A0, 8($sp)
lw $A3, 12($sp)
beqz $A3, done
lw $N0, 16($sp)
li $M0, 1
syscall

#operation performed
done:
addi $sp, $sp, 20
jr $ra

#return to the main

标签: mips

解决方案


li $v0, 10
syscall

我没有看到你调用这个,所以在你完成的分支结束时它不会结束系统。Opcode 10 将在 MIPS 中为您执行此操作。


推荐阅读