0

これは、二次関数で与えられた数値を取り、放物線を表示する QTSpim を介して実行される MIPS アセンブリのプログラムです。これは私の最初の低レベル プログラムの 1 つであり、私はどのような形でも優れたプログラマーではありません。
そのため、プログラムを実行すると、Unknown system call: 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"
4

1 に答える 1