Question

In: Computer Science

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.  

Solutions

Expert Solution

Program:

.data
   msg_1: .asciiz "Enter 2 numbers:\n"
   msg_2: .asciiz "Enter operation to be performed(+,-,*,/): "
   result: .asciiz "\nExpression is:\n"
   equal_sign: .asciiz "="
  
.text
.globl main
main:
   #Printing the prompt to the user
   li $v0,4
   la $a0,msg_1
   syscall
  
   #Reading 2 numbers from user
   li $v0,5
   syscall
   move $t0,$v0
  
   li $v0,5
   syscall
   move $t1,$v0
  
   #Printing the prompt to the user
   li $v0,4
   la $a0,msg_2
   syscall

   #Reading character(operation to be performed) from user
   li $v0,12
   syscall
   move $t3,$v0
   #sb $v0,char
  
   #Printing the expression to the user
   li $v0,4
   la $a0,result
   syscall
  
   li $v0,1
   move $a0,$t0
   syscall
      
   li $v0,11
   move $a0,$t3
   syscall
  
   li $v0,1
   move $a0,$t1
   syscall
  
   li $v0,4
   la $a0,equal_sign
   syscall

Output:


Related Solutions

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').
using MIPs assembly, ask the user to enter two numbers. Then multiply the two numbers using...
using MIPs assembly, ask the user to enter two numbers. Then multiply the two numbers using bit shifting (not 'mul'). This should work multiplying 2 positive numbers, 2 negative numbers, and a positive/negative number. Then output the result and ask user if he/she has more calculations to complete.
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 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 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 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.
This is to be done using MIPS assembly language. Display the following menus, ask user to...
This is to be done using MIPS assembly language. Display the following menus, ask user to select one item. If 1-3 is selected, display message “item x is selected”, (x is the number of a menu item), display menus again; if 0 is selected, quit from the program. 1. Menu item 1 2. Menu item 2 3. Menu item 3 0. Quit Please select from above menu (1-3) to execute one function. Select 0 to quit
This is to be done using MIPS assembly language. Display the following menus, ask user to...
This is to be done using MIPS assembly language. Display the following menus, ask user to select one item. If 1-3 is selected, display message “item x is selected”, (x is the number of a menu item), display menus again; if 0 is selected, quit from the program. 1. Menu item 1 2. Menu item 2 3. Menu item 3 0. Quit Please select from above menu (1-3) to execute one function. Select 0 to quit
I need to ask a user what numbers they want to enter. They can enter as...
I need to ask a user what numbers they want to enter. They can enter as many as they like. Then inside I need to use conditionals to determine if the numbers are <=20, <=323 && > 30, >200. I can't figure out how to let the user enter as many inputs as they want. I know I need to use a loop to check each number entered and determine if it is small middle or greater but I can't...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT