Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- matrix_mult:
- move $s0, $a0 # move the adress the first matrix
- move $s1,$a1 #move the adress of the second matrix
- la $s2, productArray
- li $t1,0 #counter for loops
- loopRowOne:
- move $s0, $a0 # reset the adress the first matrix
- li $t6,0
- beq $t1,0,loopIndex
- addi $s1,$a1,4
- beq $t1,4,loopIndex
- addi $s1,$a1,8
- beq $t1,8,loopIndex
- addi $s1,$a1,12
- beq $t1,12,loopIndex
- jr $ra
- loopIndex:
- lw $t3, ($s0)#load word from matrix one
- lw $t4, ($s1)#load word from matrix two
- mult $t3,$t4#mulitply them
- mflo $t5 #load that value into $t5
- add $t6,$t6,$t5#add to total that will become a value in the index of the row
- addi $s0,$s0,4 #go right to the next element of the row in the first matrix
- addi $s1,$s1,16 #go down a row in second matrix
- addi $t1,$t1,1 #update loop counter
- bne $t1,4,loopIndex
- sw $t6,($s2) #store into product matrix
- addi $s2,$s2,4 #update index for product matrix
- j loopRowOne
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement