Advertisement
metalni

MIPS

Apr 10th, 2020
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. .data
  2. A: .word 1, 3, 5, 7, 9, 10, 11, 12, 13, 15
  3. i: .word 10
  4. j: .word 14
  5. .text
  6. la $s1, A
  7. lw $s2, i
  8. lw $s3, j
  9.  
  10. andi $s3, $s3, 3 # j = j & 3
  11.  
  12. #print j (first part of task)
  13. li $v0,1
  14. move $a0, $s3
  15. syscall
  16.  
  17. addi $t0, $s2, 1 # i + 1
  18.  
  19. addi $t8, $zero, 2 # const 2
  20. div $s2, $t8 # i / 2
  21. mflo $t1 # $t1 = i / 2
  22.  
  23. addi $t9, $zero, 4 # const 4
  24. div $s3, $t9 # j % 4
  25. mfhi $t2 # $t1 = j % 4
  26.  
  27. add $t3, $s1, $t0 #A[i+1]
  28. add $t4, $s1, $t1 #A[i/2]
  29.  
  30. lw $t5, 0($t3) #A[i+1]
  31. lw $t6, 0($t4) #A[i/2]
  32. add $t5, $t6, $t2 #A[i/2] + j%4
  33.  
  34. #print A[i+1]
  35. li $v0, 1
  36. move $a1, $t5
  37. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement