MIPS MARS 4.5で挿入ソートを実行しようとしています。配列値を別の配列値にロードする
A:
私はと特異的にいくつかのトラブルを抱えている
lw myArray($s4), myArray($s6)# alist[position] = alist[position-1]
B:
lw myArray($s4), $s5 # alist[position] = current value
私は取得しています問題は、「あまりにも多くのか、正しくフォーマットされたオペランドであります"、" myArrayオペランドの型が間違っています "をそれぞれ示しています。
基本的に私は展覧会Aで何をしようとしているのかはコメントに記載されていますが、私はmyArray($ s4)= myArray($ s6)を作ろうとしていますが、また、私はそれを移動するために追加しようとしました。展示BIのために
$ S5で値にmyarrayの($のS4)の値を変更したい
オペレータIで私を助けることができる誰でもここで使うはずですか? ありがとう
必要に応じて、以下の残りの機能をリンクしました。
もう一度おねがいします。
sort:
addi $sp, $sp, -32 # save values on stack
sw $ra, 0($sp) # Store the saved values on the stack to restore when done
sw $s0, 4($sp) # s0 = base address of array
sw $s1, 8($sp) # s1 = size of array
sw $s2, 12($sp) # s2 = i
sw $s3, 16($sp) # s3 = j
sw $s4, 20($sp) # s4 = position
sw $s5, 24($sp) # s5 = currentvalue
sw $s6, 28($sp) # s6 = position - 1
la $a0, myArray # load array address into a0
la $a1, myArray($s2) # load size of array into a1
move $s0, $a0 # move array address into s0
move $s1, $a1 # move size of array into s1
li $s2, 0 # set i to 0
li $s3, 0 # set j to 0
li $t0, 0 # set t0 to 0
iloop:
# if s1 >= size of array go to end
slt $t5, $s2, $s1 # check if a1 > s2
beq $t5, 0, endWhile # if it is, jump to the end
lw $s5, myArray($s2) # currentvalue = alist[i]
add $s4, $zero, $s2 # position = i
sub $s6, $s4, 4 # position - 1
j jloop # else go to jloop
jloop:
# if position is <= 0
slt $t5, $s4, $t0 # check if s4 is greater than 0
beq $t5, 0, iloop # if its less, jump to the end
# and alist[position-1] < currentvalue
slt $t5, $s6, $s5 # check if alist[position-1] > current value
beq $t5, 0, iloop # if less than jump back to iloop
lw myArray($s4), myArray($s6)# alist[position] = alist[position-1]
sub $s4, $s4, 1 # position = position - 1
j setArray
setArray:
lw myArray($s4), $s5 # alist[position] = current value
j iloop
endWhile: