Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. .data
  2. sum: .asciiz "Matrix[C]: \n" #store string to sum
  3. matrixA: .word 6, 3, 7,
  4. .word 4, 4, 5,
  5. .word 1, 6, 4
  6.  
  7. matrixB: .word 3, 4, 2,
  8. .word 3, 2, 1,
  9. .word 4, 2, 1
  10.  
  11. matrixC: .space 4
  12.  
  13. endl: .asciiz "\n"
  14.  
  15. .text
  16. main:
  17. la $t1, matrixA
  18. la $t2, matrixB
  19. la $t3, matrixC
  20.  
  21. li $t4, 0 #set t4=0, its counter
  22. li $s1, 11
  23. li $s2, 3
  24. li $s3, 7
  25. li $v0, 4 #syscall for string
  26. la $a0, sum #print out the actual string
  27. syscall
  28.  
  29. j loop #skocz do petli
  30.  
  31. loop:
  32.  
  33. beq $t4, $s1, final
  34. beq $t4, $s2, loop2
  35. beq $t4, $s3, loop2
  36. lw $t5, 0($t1) #get value from array cell and store in $t5
  37. lw $t6, 0($t2)
  38.  
  39. add $t7, $t5, $t6
  40.  
  41. sw $t7, 0($t3) #store $t7 into the address of $t8
  42.  
  43. li $v0, 1 #print integer
  44. move $a0, $t7 #move $t7 into $a0
  45. syscall
  46.  
  47. li $a0, 32 #print the ASCII representation of 32 which is space
  48. li $v0, 11
  49. syscall
  50.  
  51. addi $t1, $t1, 4 #incrementing $t1 by 4
  52. addi $t2, $t2, 4
  53. addi $t4, $t4, 1
  54.  
  55. j loop
  56.  
  57. loop2:
  58. li $v0, 4
  59. la $a0, endl
  60. addi $t4, $t4, 1
  61. syscall
  62. j loop
  63.  
  64.  
  65. final:
  66. li $v0, 10
  67. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement