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 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 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...
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. )...
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.
Write a mips assembly language program. Ask the user whether he wants to repeat the program:...
Write a mips assembly language program. Ask the user whether he wants to repeat the program: "\nRepeat [y/n]? ". Use service code 12 to read a character and the branch instruction to repeat the main function if the user input is character 'y'.
(8 marks) Write a program to ask user to enter an integer that represents the number...
Write a program to ask user to enter an integer that represents the number of elements, then generate an ArrayList containing elements which are all random integers in range [75, 144] , and finally display index and value of each element. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use ArrayList. Your program must use only printf(…) statements to adjust the alignment of your output. Your code must display the index in descending...
Write a mips assembly language program that asks the user to enter an alphabetic character (either...
Write a mips assembly language program that asks the user to enter an alphabetic character (either lower or upper case)and change the case of the character from lower to upper and from upper to lower and display it.
Please code C# 8. Write a program that prompts the user to enter an integer. The...
Please code C# 8. Write a program that prompts the user to enter an integer. The program then determines and displays the following: Whether the integer is divisible by 5 and 6 Whether the integer is divisible by 5 or 6
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT