Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- mat1: .word 3,3,3,3,3,3,3,3,3
- mat2: .word 3,3,3,3,3,3,3,3,3
- .equ row1,3
- .equ row2,3
- .equ col2,3
- res: .zero 36
- .text
- li x4,row1 #loading row number
- la x1, mat1 #loading matrix1 address
- la x3, res
- nextrow:
- li x5, col2 #loading column number
- la x2,mat2 #loading matrix2 address
- nextcol:
- li x6, row2
- mv x7, x0
- dotprod:
- lw x8, 0(x1)
- lw x9, 0(x2)
- mul x10, x8, x9 #element wise multiplication
- add x7, x7, x10 #column wise addition
- addi x1, x1, 4 #next element in a row
- addi x2, x2, col2*4 #next element in a column
- addi x6, x6, -1 #decrement for row number count
- bne x6, x0, dotprod
- sw x7, 0(x3)
- addi x3, x3, 4
- addi x5, x5, -1
- beq x5, x0, skip
- addi x1, x1, -row2*4
- addi x2, x2, 4-row2*col2*4
- j nextcol
- skip:
- addi x4,x4, -1
- bne x4,x0, nextrow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement