IDE Mars を使用して R3000 MIPS アセンブリでプログラムを作成しています。私が受けている授業です。タスクは、リンクされたリストを反復処理し、引数で指定された整数より小さい値を持つノードを削除する関数を作成することです。解決策を見つけたと思いますが、テスト中に次のランタイム例外が発生し続けます。
開発者: テキスト セグメントに書き込むには setStatement() を使用する必要があります!0x00000014
このエラーの原因が何なのか、私にはまったくわかりません。グーグルで試してみましたが、リモートで関連するものは何も表示されません。それがアセンブリ コードの問題なのか、それとも Mars IDE の問題なのかさえわかりません。本当に奇妙なことは、同じ状況下であっても、常に表示されるとは限らないことです。エラーが発生した場合は、コードを変更して (通常は syscall の 1 つをコメントアウトして) 実行します。コードを元に戻してもエラーはなくなり、元に戻りません。
関数のコードは次のとおりです。引数は、リンクされたリストの最初のノードのアドレスと、ノードを削除するためのカットオフ値で、それぞれ $a0 と $a1 にあります。
.text
cleanup:
add $t0, $a0, $0 #keep the argument from being modified
la $t1, head #the address for the first node
sw $a0, head #the head points at the first word now
li $v0, 1 #DEBUG
li $t7, 0 #DEBUG
while:
lw $t2, ($t0) #get the node value
bge $t2, $a1, else #IF the node value is >= x, skip the next bit
add $a0, $t1, $0 #DEBUG
syscall #DEBUG
lw $t3, 4($t0) #get the address of the next node
sw $t3, 4($t1) #store the address of the next node to the next node address of the previous node
b ifend #skip to the end of the if statement
else:
lw $t1, ($t0) #ELSE set pointer to previous node to this node
ifend:
la $t4, 4($t0) #need to check if the end of the list is nigh
beq $t4, -1, out #exit loop at the end of the list
lw $t0, 4($t0) #set current node pointer to the next node
addi $t7, $t7, 1 #DEBUG
addi $a0, $t7, 0 #DEBUG
syscall #DEBUG
b while #and loop!
out:
.data
head:
.word 0