你好我需要帮助增加2个matricies。下面的程序是MARS汇编程序中的MIPS程序,用于3x3矩阵乘法。到目前为止,我有下面的代码,但我仍然接受000的输出当我需要输出应该是0,6,12,0,6,12,0,6,12分隔一个新的线,这是矩阵乘法AxB。代码有什么问题?我真的需要很多帮助!
.data
newline:.asciiz "\n" # newline
A: .word 1,3,2,1,3,2,1,3,2
B: .word 0,1,2,0,1,2,0,1,2
C: .space 36
A_row: .word 3
A_col: .word 3
B_row: .word 3
B_col: .word 3
.text
main:
la $s0, A
la $s1, B
la $s2, C
lw $t0, A_row
lw $t1, A_col
lw $t2, B_row
lw $t3, B_col
li $s3, -1 #i
li $s4, -1 #j
li $s5, -1 #k
j LOOP1
LOOP1: addi $s3, $s3, 1 # i++
bge $s3, $t0, END
j LOOP2
LOOP2: addi $s4, $s4, 1 # j++
bge $s4, $t1, LOOP1
j LOOP3
LOOP3: addi $s5, $s5, 1 # k++
bge $s5, $t2, Show_C
mul $s6, $t1, $s3 # s6 = A_col * i
add $s6, $s6, $s5 # s6 = s6 + k
mul $s6, $s6, 4 # s6 = s6 * 4
add $s6, $s6, $s0 # s6 = s6 + A
lw $t4, 0($s6) # load s6 to t4
mul $s7, $t3, $s5 # s7 = B_col * k
add $s7, $s7, $s4 # s7 = s7 + j
mul $s7, $s7, 4 # s7 = s7 * 4
add $s7, $s7, $s1 # s7 = s7 + B
lw $t5, 0($s7) # load s7 to t5
mul $t8, $t3, $s3 # s8 = B_col * i
add $t8, $t8, $s4 # s8 = s8 + j
mul $t8, $t8, 4 # s8 = s8 * 4
add $t8, $t8, $s2 # s8 = s8 + C
mul $t4, $t4, $t5 # t4 = t4 * t5
add $t6, $t4, $t6 # t6 = t4 + t6
sw $t6, 0($t8) # store s8 to t6
j LOOP3
Show_C: li $v0, 1
lw $a0, 0($t8)
syscall
la $a0, newline
li $v0, 4
syscall
j LOOP2