0
我想編寫一個程序來檢查兩個數組的大小,確保它們小於某個值(99),並確保它們的總和也小於一個值( 99)。然而,這兩個陣列大小的總和正被放入R13但如果這些值大於99MIPS檢查數組中的元素數
.data
arrayOne: .word 5 1 3 6 7 8
arrayTwo: .word 3 5 7 9
arrayMerged: .word 99
.text
main:
ld r1, arrayOne(r0) ;load the num elements into r1
ld r2, arrayTwo(r0) ;load the num elements into r2
lui r31, 99
slt r30, r1, r31 ;check to see if r1 is larger than 99
beq r30, r31, l3 ;if r1 is larger than 99, goto l3
slt r30, r2, r31 ;check to see if r2 is larger than 99
beq r30, r31, l3 ;if r2 is larger than 99, goto l3
dadd r13, r1, r2 ;add the sum of r1 and r2 and store in r13
slt r30, r13, r31 ;check to see if the sum of arrayOne and arrayTwo is larger than 99
beq r30, r31, l3 ;if r13 is larger than 99, goto l3
l3: halt
您正在使用'lui r31,99',您應該使用'li r31,99'。但是你應該遵循MIPS寄存器使用慣例,特別是'r31'保留給當前例程的返回地址。 – markgz