Advertisement
Tyler_Elric

add three numbers

Sep 20th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data # variable declarations follow this line
  2. .text # instructions follow this line
  3.  
  4. main:
  5. ## Code Part 1: Get first number from user, put into $t0.
  6. ori $v0, $0, 5 # OUR CODE BEGINS HERE: load syscall read_int into $v0.
  7. syscall # make the syscall.
  8. addu $t0, $0, $v0 # move the number read into $t0.
  9. ## Get second number from user, put into $t1.
  10. ori $v0, $0, 5 # load syscall read_int into $v0.
  11. syscall # make the syscall.
  12. addu $t1, $0, $v0 # move the number read into $t1.
  13. ori $v0, $0, 5 # load syscall read_int into $v0.
  14. syscall # make the syscall.
  15. addu $t2, $0, $v0 # move the number read into $t1.
  16. add $t3, $t0, $t1 # compute the sum.
  17. add $t3, $t3, $t2
  18. ## Print out $t3.
  19. addu $a0, $0, $t3 # move the number to print into $a0.
  20. ori $v0, $0, 1 # load syscall print_int into $v0.
  21. syscall # make the syscall.
  22. ori $v0, $0, 10 # syscall code 10 is for exit.
  23. syscall # make the syscall.
  24. ## end of add2.asm.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement