In: Computer Science
Write a mips assembly code program that ask the user
to enter an integer value, and then print
the result of doubling that number.
.data
prompt1: .asciiz "Enter the first number: "
resultText: .asciiz "Your final result is: "
.text
.globl main
main:
#The following block of code is to pre-load the integer values representing the various instructions into registers for storage
li $t3, 1 #This is to load the immediate value of 1 into the temporary register $t3
li $t4, 2 #This is to load the immediate value of 2 into the temporary register $t4
li $t5, 3 #This is to load the immediate value of 3 into the temporary register $t5
#asking the user to provide the number
li $v0, 4 #command for printing a string
la $a0, prompt1 #loading the string to print into the argument to enable printing
syscall #executing the command
#the next block of code is for reading the first number provided by the user
li $v0, 5 #command for reading an integer
syscall #executing the command for reading an integer
move $t0, $v0 #moving the number read from the user input into the temporary register $t0
add $t6,$t0,$t0 #this adds the values stored in $t0 and $t1 and assigns them to the temporary register $t6
#The following line of code is to print the results of the computation above
li $v0,4 #this is the command for printing a string
la $a0,resultText #this loads the string to print into the argument $a0 for printing
syscall #executes the command
#the following line of code prints out the result of the addition computation
li $v0,1
la $a0, ($t6)
syscall
li $v0,10 #This is to terminate the program
Note: Plzzz don' t give dislike.....Plzzz comment if u have any problem i will try to resolve it.......