Advertisement
tsounakis

MIPS (first part)

Dec 6th, 2021
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. .data
  2. arr: .word 0:20
  3.  
  4. .text
  5. .globl main
  6. main:
  7. li $s0, 0 # sum
  8. li $s1, 1 # array[0]
  9. li $s2, 2 # omega
  10. la $s3, array # initialise array
  11. add $t0, $t0, 1 # init. i = 0
  12. add $t1, $t1, 19 # init. j = 19
  13. sw $s1, 0($s3) # a[0] = s1 = 1
  14. beq $zero, $zero, TEST1
  15. TEST1:
  16. slt $t2, $t0, 20
  17. bne $t2, $zero, LOOP1
  18. LOOP1:
  19. add $t3, $t0, -1 # temp = i - 1
  20. add $t3, $t3, $s3 # a[i-1]
  21. add $t4, $t0, %s3 # a[i]
  22. add $t5, $t3, $s2
  23. sw $t4, 0($t5) # a[i] = omega + a[i-1]
  24. addi $t0, $t1, 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement