だから私は現在立ち往生しているMIPSのタスクを持っています。私の仕事も:
1) 配列の最初の要素から始まるループを書く 2) 次に、各要素に順番に 1 を追加し、結果を配列に格納する 3) ゼロが検出された場合、プログラムを終了する
これが私がすでに持っているものです:
.data #by default, the "data segment" starts at address 0x10010000
.word 1
.word 2
.word 3
.word 4
.word 5
.word 6
.word 7
.word 8
.word 9
.word 0
.text #instructions start below
lui $s0, 0x1001 # $s0 holds base address of the array
addi $s1, $zero, 0 # $s1 holds the index of the array
jal increment # call loop procedure
increment:
beq $s0, $zero, Exit # if $s0 value is zero, branch and go to else
addi $s0, $s0, 1 # adds 1 to each element
addi $s1, $s1, 1 # i = i + 1
j increment # jump back to loop
Exit:
infinite: j infinite
私がそれを実行するときに私が抱えている問題は、それが実行され続けることです。そして、10 番目の単語 (.word0) に値 0 が含まれていることがわかります。
コードのどこが間違っているのでしょうか?
どうもありがとう
@Robert B、これは私が今持っているものです:
main: #instructions start below
la $s0, myData # $s0 holds base address of the array
addi $s1, $zero, 0 # $s1 holds the index of the array
loop:
beq $s0, $zero, else # if $s0 value is zero, branch and go to else
addi $s0, $s0, 2 # adds 2 to each element
addi $s1, $s1, 1 # i = i + 1
j loop # call loop procedure
else:
addi $v0, $zero, 10 # terminate execution
syscall