我是MIPS语言的新手,我正在尝试自学这部分作业。我正在使用QTSpim来运行代码,我得到的语法错误是在第18行(我用 - >标记)。解析器只指向该行的末尾。
代码的目的是通过迭代找到arrayA中的最大值。如果有人能帮我解释为什么会出现这个错误,我会非常感激。
.data
arrayA: .word 5, 2, 4, 7, 14, 10, 3, 17, 11, 19
arrayB: .word 15, 16, 8, 1, 6, 12, 13, 9, 20, 18
arrayC: .space 40
arrayD: .space 40
.text
.globl main
main:
li $t3, 40 #t3 will hold size of array
li $t0, 0 #t0 will be incremented index
lw $t1, arrayA($t0) #t1 is the first value in A and will eventually be the max
lw $t2, arrayB($t0) #t2 is the first value in B and will eventually be the max
findMAX:
lw $t4, arrayA($t0) #current value of A stored in t4
blt $t4, $t1, skip #if current value of A is less than stored max, then skip next line
----> lw $t1, $t4 #(runs if current value is = or > stored max) stores new max
skip:
addi $t0, $t0, 4 #increment t0
blt $t0, $t3, findMAX #if t0 is not at the end of the array, then continue search
li $v0, 1 #allow syscall to print int stored in a0
move $a0, $t1 #store new found max in a0
syscall #print max