这是一个通过 QTSpim 运行的 MIPS 汇编程序,它采用二次函数中的给定数字并显示抛物线。这是我的第一个低级程序之一,我不是任何形式的优秀程序员。
因此,当我运行程序时,它会显示未知系统调用:20。这是我为范围上限输入的数字。我用来测试的数字是系数 1、-1、-6,x 轴为 -10,10,y 轴为 -10,20。它应该显示一个抛物线,但它只显示 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"