Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .globl main
- main:
- ###############################################################
- # system call to display the author of this code
- la $a0,outpAuth # system call 4 for print string needs address of string in $a0
- li $v0,4 # system call 4 for print string needs 4 in $v0
- syscall
- #
- # system call to prompt user for input
- la $a0,outpPrompt # system call 4 for print string needs address of string in $a0
- li $v0,4 # system call 4 for print string needs 4 in $v0
- syscall
- ###############################################################
- # write a system call to read the user's integer value
- li $v0, 5
- syscall
- move $t0, $v0
- # We have not studied looping, so you will need to repeat the prompt for input
- # and do the calculation as you see fit
- la $a0, outpPrompt #asking user to input a number
- li $v0, 4 #storing it in $v0 and using system call 4 since used the address $a0
- syscall
- li $v0, 5 #reading in an integer
- syscall
- move $t1, $v0 #moving the contents of the user input into register $t1
- ###############################################################
- la $a0,outpPrompt #asks user for input
- li $v0, 4 #stores it in $v0
- syscall #syscall 4 called since address #a0 is used
- li $v0, 5 #int is read in
- syscall
- move $t2, $v0 #move stores the user int in register $t2
- ################################################################
- #
- # system call to display "The sum of your numbers multiplied by 3 is: "
- la $a0,outpStr # system call 4 for print string needs address of string in $a0
- li $v0,4 # system call 4 for print string needs 4 in $v0
- syscall
- ################################################################
- # write a system call to display the calculation
- add $t3, $t1, $t2 #add the first two user inputs and store them in register $t3
- add $t4, $t3, $t0 #take the sum of the last registers and add it to the last user input
- li $v0, 1
- mul $t5, $t4, 3 #multiply the sum of all user inputs by 3 and store in register $t5
- add $a0, $zero, $t5 #store that answer and do a syscall to read the int
- syscall
- #
- # Exit gracefully
- li $v0, 10 # system call for exit
- syscall # close file
- ################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement