0

我还是 MIPS 的新手,我对出了什么问题感到困惑。我在 QTSimp 中进行测试。它告诉我“未知系统调用:-1000”。我对出了什么问题感到有些困惑。我在控制台中使用 -1000 跳转到 op 来设置我的操作数(构建一个简单的整数计算器)。

li $s7, 5   #Read a Character AS A INT and store in $s7
syscall

#Load values for each:
li $t0, 43 #Addition
li $t1, 45 #Subtraction
li $t2, 42 #Multiplication
li $t3, 47 #Division

#if $s7 is equal to any of these, then jump back to the main loop and wait for a second operand
beq $s7, $t0, loop #ADD
beq $s7, $t1, loop #SUB
beq $s7, $t2, loop #MULTI
beq $s7, $t3, loop #DIV

la $a0, error #Load error message
j ra
4

1 回答 1

1

您是否有 Qtspim 应该解释的标头 就像通常的 C 代码具有该功能一样main

这是 MIPS 标头。

.globl main # Make main global so you can refer to
# it by name in QtSPIM.

.text # This line tells the computer this is the
# text section of the program
# (No data contained here).

main: # Program actually starts here.
// your code

ori $v0, $0, 10 # Sets $v0 to "10" so when syscall is executed, program will exit.
syscall # Exit.

所以,你的代码应该是:

.globl main # Make main global so you can refer to
# it by name in QtSPIM.

.text # This line tells the computer this is the
# text section of the program
# (No data contained here).

main: # Program actually starts here.
li $s7, 5   #Read a Character AS A INT and store in $s7


#Load values for each:
li $t0, 43 #Addition
li $t1, 45 #Subtraction
li $t2, 42 #Multiplication
li $t3, 47 #Division

#if $s7 is equal to any of these, then jump back to the main loop and wait for a second operand
beq $s7, $t0, loop #ADD
beq $s7, $t1, loop #SUB
beq $s7, $t2, loop #MULTI
beq $s7, $t3, loop #DIV

la $a0, error #Load error message
j ra


ori $v0, $0, 10 # Sets $v0 to "10" so when syscall is executed, program will exit.
syscall # Exit.
于 2013-04-14T02:32:19.943 回答