这是通过QTSpim运行的MIPS程序集中的程序,它以二次函数获取给定数字并显示抛物线。这是我的第一个低级程序之一,我不是任何形式的优秀程序员 因此,当我运行该程序时,它会显示未知的系统调用:20。这是我为该范围的上限输入的数字。我用来测试的数字是1,-1,-6表示系数,-10,10表示x轴,-10,20表示y。它应该显示一个抛物线,但它只显示X和Y轴。这是向前迈出的一步,因为昨天它不会显示任何东西。帮助!
.text
.globl main
main:
la $a0,prompt1 # display "Enter the coeficiants of the quadratic: "
li $v0,4
syscall
li $v0,5 # enter A -> v0
syscall
move $t0,$v0 # t0 <--- v0
li $v0,5 # enter B -> v0
syscall
move $t1,$v0 # t1 <--- v0
li $v0, 5 # enter C -> v0
syscall
move $t2,$v0 # t2 <--- v0
la $a0,prompt2 # display "Enter the lower (first) and upper (second) bounds of the domain: "
li $v0, 4
syscall
li $v0, 5 # enter lower bound -> v0
syscall
move $t3, $v0 # t3 <--- v0
li $v0, 5 # enter upper bound -> v0
syscall
move $t4, $v0 # t4 <--- v0
la $a0, prompt3 # display "Enter the lower (first) and upper (second) bounds of the range: "
li $v0, 4
syscall
li $v0, 5 # enter lower bound -> v0
syscall
move $t6, $v0 # t6 <--- v0
li $v0, 5 # enter upper bound -> v0
syscall
move $t7, $v0 # t7 <--- v0
move $t8, $t7 # t8 <--- t7
syscall
step10: move $t9, $t3 # t9 <--- t3
syscall
step11: mul $t5,$t3,$t0 # t0 * t3 -> t5
add $t5,$t1,$t5 # t5 + t1 -> t5
mul $t5,$t5,$t3 # t5 * t3 -> t5
add $t5,$t5,$t2 # t5 + t2 -> t5
beq $t8, $t5, point # if y = f(x) goto point marker
beqz $t9, yaxis # if x = 0 goto yaxis
beqz $t8, xaxis # if y = 0 goto xaxis
la $a0,space # display " "
li $v0,4
syscall
step16: beq $t9, $t4, newl # if x = x-max goto newl
add $t9, $t9, 1 # $t9 += 1
j step11
step18: beq $t8, $t6, EOP # if y = y-min end program
sub $t8, $t8, 1 # $t8 -= 1
j step10
EOP: li $v0,10 # EOP
syscall
newl: la $a0,endl # display "\n"
li $v0,4
syscall
j step18
point: la $a0,star # display "*"
li $v0,4
syscall
j step16
yaxis: la $a0,bar # display "|"
li $v0,4
syscall
j step16
xaxis: la $a0,hyph # display "-"
li $v0,4
syscall
j step16
.data
prompt1: .asciiz "Enter the coeficiants of the quadratic: "
prompt2: .asciiz "Enter the lower (first) and upper (second) bounds of the domain: "
prompt3: .asciiz "Enter the lower (first) and upper (second) bounds of the range: "
bar: .asciiz "|"
star: .asciiz "*"
hyph: .asciiz "-"
space: .asciiz " "
endl: .asciiz "\n"
答案 0 :(得分:0)
所以,当你正在阅读输入时,你会去:
[...]
li $v0, 5 # enter upper bound -> v0
syscall
move $t7, $v0 # t7 <--- v0
move $t8, $t7 # t8 <--- t7
syscall #$v0 is still whatever user input for upper bound
step10: move $t9, $t3 # t9 <--- t3
syscall #$v0 is whatever the last (unspecified) syscall returned
我不知道您想要致电的syscall
,所以我无法帮助您。我建议在编写汇编之前用更高级的语言编写代码。