Advertisement
cesarcardinale

MIPS M2101 TP2 Exo3

Jun 5th, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2. save:
  3. .word
  4. 0x000000000,
  5. 0x000000000,
  6. 0x000000000,
  7. 0x000000000,
  8. 0x000000000,
  9. 0x000000000,
  10. 0x000000000,
  11. 0x000000001,
  12. 0x000000002,
  13. 0x000000003
  14.  
  15. .text
  16. main:
  17. la $a0, save #Affectation de $a0 à save
  18. ori $a1, $zero, 1 #Affectation de $v0 à 1
  19. ori $a2, $zero, 9 #Affectation de $v0 à 9
  20. jal Recherche # goto Recherche
  21.  
  22. or $a0, $zero, $v0 #$a0 = $zero || $v0
  23.  
  24. ori $v0, $zero, 1 #Affectation de $v0 à 1
  25. syscall #Vérification de $v0: 5 - read $a0
  26.  
  27. ori $v0, $zero, 10 #EXIT
  28. syscall #EXIT
  29.  
  30. Recherche:
  31. or $s0, $zero, $zero #$s0 = $zero || $zero
  32.  
  33. for:
  34. slt $t0, $a2, $s0 #if($a2 < $s0) $t0 = 1 else $t0 = 0
  35. bne $t0, $zero, exitfor #if ($t0 != $zero) goto exitfor
  36. sll $t0, $s0, 2 #$t0 = $s0 << 2
  37. add $t0, $t0, $a0 #$t0 = $t0 + $a0
  38. lw $t0, 0($t0) #$t0 = Mem[$t0]
  39. beq $t0, $a1, exitfor #if($t0 = $a1) goto exitfor
  40. addi $s0, $s0, 1 #$s0 = $s0 + 1
  41. j for #goto for
  42.  
  43. exitfor:
  44. or $v0, $zero, $s0 #$v0 = $zero || $s0
  45. jr $ra #goto $ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement