TizzyT

Integer Addition -TizzyT

Sep 27th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. .data
  2. ask1: .asciiz "Enter the first number: "
  3. ask2: .asciiz "Enter the second number: "
  4. sum: .asciiz "The sum is: "
  5. .text
  6. # Asks the user for first number
  7. li $v0, 4
  8. la $a0, ask1
  9. syscall
  10.  
  11. # Gets the users input
  12. li $v0, 5
  13. syscall
  14.  
  15. # Move input to $t0
  16. move $t0, $v0
  17.  
  18. # Asks the user for second number
  19. li $v0, 4
  20. la $a0, ask2
  21. syscall
  22.  
  23. # Gets the users input
  24. li $v0, 5
  25. syscall
  26.  
  27. # Move input to $t1
  28. move $t1, $v0
  29.  
  30. # Display the sum message
  31. li $v0, 4
  32. la $a0, sum
  33. syscall
  34.  
  35. #adds the two numbers
  36. add $a0, $t0, $t1
  37. li $v0, 1
  38. syscall
Advertisement
Add Comment
Please, Sign In to add comment