Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- sum: .asciiz "Matrix[C]: \n" #store string to sum
- matrixA: .word 6, 3, 7,
- .word 4, 4, 5,
- .word 1, 6, 4
- matrixB: .word 3, 4, 2,
- .word 3, 2, 1,
- .word 4, 2, 1
- matrixC: .space 4
- endl: .asciiz "\n"
- .text
- main:
- la $t1, matrixA
- la $t2, matrixB
- la $t3, matrixC
- li $t4, 0 #set t4=0, its counter
- li $s1, 11
- li $s2, 3
- li $s3, 7
- li $v0, 4 #syscall for string
- la $a0, sum #print out the actual string
- syscall
- j loop #skocz do petli
- loop:
- beq $t4, $s1, final
- beq $t4, $s2, loop2
- beq $t4, $s3, loop2
- lw $t5, 0($t1) #get value from array cell and store in $t5
- lw $t6, 0($t2)
- add $t7, $t5, $t6
- sw $t7, 0($t3) #store $t7 into the address of $t8
- li $v0, 1 #print integer
- move $a0, $t7 #move $t7 into $a0
- syscall
- li $a0, 32 #print the ASCII representation of 32 which is space
- li $v0, 11
- syscall
- addi $t1, $t1, 4 #incrementing $t1 by 4
- addi $t2, $t2, 4
- addi $t4, $t4, 1
- j loop
- loop2:
- li $v0, 4
- la $a0, endl
- addi $t4, $t4, 1
- syscall
- j loop
- final:
- li $v0, 10
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement