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