Advertisement
math230

add2.asm

Oct 23rd, 2019
3,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 1.12 KB | None | 0 0
  1. #  http://codepad.org/BDXAySsj
  2. #  https://pastebin.com/xhKiJHSG
  3.  
  4. # Daniel J. Ellard -- 02/21/94
  5. # add2.asm -- A program that computes and prints the sum
  6. #             of two numbers specified at runtime by the user.
  7.  
  8. # Registers used:
  9. #           $t0 - used to hold the first number.
  10. #           $t1 - used to hold the second number.
  11. #           $t2 - used to hold the sum of the $t1 and $t2.
  12. #           $v0 - syscall parameter and return value.
  13. #           $a0 - syscall parameter.
  14.  
  15. main:
  16.     ## Get first number from user, put into $t0.
  17.     li $v0, 5           # load syscall read_int into $v0.
  18.     syscall             # make the syscall.
  19.     move $t0, $v0       # move the number read into $t0.
  20.    
  21.    
  22.     ## Get second number from user, put into $t1.
  23.     li $v0, 5           # load syscall read_int into $v0.
  24.     syscall             # make the syscall.
  25.     move $t1, $v0       # move the number read into $t1.
  26.     add $t2, $t0, $t1   # compute the sum.
  27.    
  28.    
  29.     ## Print out $t2.
  30.     move $a0, $t2       # move the number to print into $a0.
  31.     li $v0, 1           # load syscall print_int into $v0.
  32.     syscall             # make the syscall.
  33.    
  34. exit:  
  35.     li $v0, 10          # syscall code 10 is for exit.
  36.     syscall             # make the syscall.
  37. # end of add2.asm.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement