15 のテスト スコアのリストを調べる MiPS プログラムを作成しています。そして、ターミナルから入力していきます。まあ、合格基準は50点です。ターミナルへの出力には、各カテゴリのスコアと、合格者と不合格者の数が含まれます。入力プロンプトと出力ステートメントを使用して...以下は私が書いたプログラムですが、動作しませんでした....必要があります....間違っているかどうかわかりません..
.globl main
.text
main: li $t0, 0 #合格点のカウンター la $t1, pass #合格配列のポインター
li $t2, 0 #不合格点のカウンター la $t3, fail #合格配列のポインター li $t4, 0 #全体のカウンター李 $t5, 0 李 $t6, 0
loop: li $v0, 4 #文字列を表示するためのシステムコール la $a0, prompt #文字列を読み込む syscall
li $v0, 5 #system call for read integer
syscall #read integer
bltu $v0, 50, else #if $v0 < 50 branch to else (failing grade)
sw $v0, 0($t1) #store word in pass array
addi $t1, $t1, 4 #t1 = t1 + 4 (increment pass pointer)
addi $t0, $t0, 1 #t0 = t0 + 1 (increment pass counter)
b l_end #branch over else statement
else: sw $v0, 0($t3) #単語をフェイル配列に格納 addi $t3, $t3, 4 #t3 = t3 + 4 (フェイル ポインタをインクリメント) addi $t2, $t2, 1 #t1 = t1 + 1 (インクリメント失敗カウンター)
l_end: addi $t4, $t4, 1 #インクリメント 全体カウンタ bltu $t4, 15, loop #if t4 <= 15 ループへ分岐
出力カウント
li $v0, 4 #system call for print string
la $a0, o_pasc #load string
syscall #output "Number of Passing Scores:
la $v0, 1 #system call for print integer
add $a0, $t0, 0 #load value of pass counter into $a0
syscall #output value
li $v0, 4 #system call for print string
la $a0, o_fasc #load string
syscall #output "Number of Failing Scores: "
la $v0, 1 #system call for print string
add $a0, $t2, 0 #load value of fail counter into $a0
syscall #output value
合格点を出力する
li $v0, 4 #setup output
la $a0, o_pass #setup text
syscall #output string o_pass
la $t1, pass #load address of pass pointer to t1
lw $a0, 0($t1) #load word at $t1 into $a0
li $v0, 1 #system call for print integer
loop_a: bleu $t0, $t5, lp_a_end #if t0 <= t5 lp_a_end syscall に分岐 #単一スコアを出力
li $v0, 4 #system call for print string
la $a0, o_coma #load string
syscall #ouput comma and space
li $v0, 1 #setup output
addi $t1, $t1, 4 #move pointer down by 1 word
lw $a0, 0($t1) #move word at pointer into $a0
addi $t5, $t5, 1 #add 1 to counter
b loop_a #branch to top
lp_a_end:
失敗スコアを出力する
la $t5, 0 #clear t5 (counter)
li $v0, 4 #setup output
la $a0, o_fail #setup text
syscall #output string o_fail
la $t3, fail #load address for fail pointer into $t3
lw $a0, 0($t3) #load word at mem addy $t3 into $a0
li $v0, 1 #system call for print integer
loop_b: bleu $t2, $t5, lp_b_end #if t2 <= t5 lp_a_end syscall に分岐 #単一スコアを出力
li $v0, 4 #system call for print string
la $a0, o_coma #load string
syscall #output comma and space
li $v0, 1 #setup output
addi $t3, $t3, 4 #move pointer down by 1 word
lw $a0, 0($t3) #load word from mem addy $t3 to $a0
addi $t5, $t5, 1 #add 1 to counter
b loop_b #branch to top
lp_b_end:
終わり
li $v0, 4 #setup output
la $a0, o_brk #setup text
syscall #output line break
li $v0, 10 #loads 10 to $v0
syscall #ends program