Advertisement
foreverfugazi

wowo

Oct 24th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. .data
  2. mat1: .word 3,3,3,3,3,3,3,3,3
  3. mat2: .word 3,3,3,3,3,3,3,3,3
  4. .equ row1,3
  5. .equ row2,3
  6. .equ col2,3
  7. res: .zero 36
  8.  
  9. .text
  10. li x4,row1 #loading row number
  11. la x1, mat1 #loading matrix1 address
  12. la x3, res
  13.  
  14. nextrow:
  15. li x5, col2 #loading column number
  16. la x2,mat2 #loading matrix2 address
  17.  
  18. nextcol:
  19. li x6, row2
  20. mv x7, x0
  21.  
  22. dotprod:
  23. lw x8, 0(x1)
  24. lw x9, 0(x2)
  25. mul x10, x8, x9 #element wise multiplication
  26. add x7, x7, x10 #column wise addition
  27. addi x1, x1, 4 #next element in a row
  28. addi x2, x2, col2*4 #next element in a column
  29. addi x6, x6, -1 #decrement for row number count
  30. bne x6, x0, dotprod
  31.  
  32. sw x7, 0(x3)
  33. addi x3, x3, 4
  34. addi x5, x5, -1
  35. beq x5, x0, skip
  36. addi x1, x1, -row2*4
  37. addi x2, x2, 4-row2*col2*4
  38. j nextcol
  39.  
  40. skip:
  41. addi x4,x4, -1
  42. bne x4,x0, nextrow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement