Question

In: Computer Science

Write a mips assembly code program that ask the user to enter an integer value, and...

Write a mips assembly code program that ask the user to enter an integer value, and then print
the result of doubling that number.

Solutions

Expert Solution

.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.......


Related Solutions

Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers....
Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers. The program will store these numbers in an array in memory (sequential memory locations). It will then print out the list of numbers in three different formats: The numbers will be printed each on a separate line. The numbers will be printed on a single line, with spaces between the numbers. The program will ask the user to enter a number n. The program...
Write a mips assembly language program to ask the user to enter two integers A and...
Write a mips assembly language program to ask the user to enter two integers A and B and then display the result of computing the expression: A + 2B - 5.
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and compute xy
Write a program that does the following. It will ask the user to enter an integer...
Write a program that does the following. It will ask the user to enter an integer larger than 1, and the if entered integer is not larger than 1, it keeps prompting the user. After the user enters a valid integer, the program prints all the prime factors of the integer (including the repeated factors). For example, if the entered integer is 24, the program prints: 2 2 2 3 Run your program with the test cases where the entered...
In MIPS assembly: Ask the user to enter two numbers and an operation (+ - /...
In MIPS assembly: Ask the user to enter two numbers and an operation (+ - / *). Print the expression back to the user with a blank after the = sign (since the calculation is not being completed.  
Write a MIPS assembly program that prompts the user for some number of cents (integer) and...
Write a MIPS assembly program that prompts the user for some number of cents (integer) and read the user input. Then translate that number of into a number of quarters, dimes, nickels and pennies (all integers) equal to that amount and outputs the result. The output should adequately tell the user what is being output (not just the numeric results).
Write a MIPS assembly program that prompts the user for some number of cents (integer) and...
Write a MIPS assembly program that prompts the user for some number of cents (integer) and read the user input. Then translate that number of into a number of quarters, dimes, nickels and pennies (all integers) equal to that amount and outputs the result. The output should adequately tell the user what is being output (not just the numeric results). (Make sure you use comments next to each line to describe what actions you are taking in your code. )...
in MIPS assembly, ask a user for two numbers and to either enter a '1' for...
in MIPS assembly, ask a user for two numbers and to either enter a '1' for addition or '2' for subtraction. using jal, jump to the appropriate procedure for additing or subtracting. then print out result and ask if there is another calculation (terminate program if 'no').
Write a mips assembly language program that asks the user to enter an unsigned number and...
Write a mips assembly language program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT