Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1.  
  2. matrix_mult:
  3. move $s0, $a0 # move the adress the first matrix
  4. move $s1,$a1 #move the adress of the second matrix
  5. la $s2, productArray
  6. li $t1,0 #counter for loops
  7. loopRowOne:
  8. move $s0, $a0 # reset the adress the first matrix
  9. li $t6,0
  10. beq $t1,0,loopIndex
  11. addi $s1,$a1,4
  12. beq $t1,4,loopIndex
  13. addi $s1,$a1,8
  14. beq $t1,8,loopIndex
  15. addi $s1,$a1,12
  16. beq $t1,12,loopIndex
  17. jr $ra
  18. loopIndex:
  19. lw $t3, ($s0)#load word from matrix one
  20. lw $t4, ($s1)#load word from matrix two
  21. mult $t3,$t4#mulitply them
  22. mflo $t5 #load that value into $t5
  23. add $t6,$t6,$t5#add to total that will become a value in the index of the row
  24.  
  25. addi $s0,$s0,4 #go right to the next element of the row in the first matrix
  26. addi $s1,$s1,16 #go down a row in second matrix
  27. addi $t1,$t1,1 #update loop counter
  28.  
  29. bne $t1,4,loopIndex
  30. sw $t6,($s2) #store into product matrix
  31. addi $s2,$s2,4 #update index for product matrix
  32. j loopRowOne
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement