Question

In: Computer Science

Write code in MIPS ,read tow number from the user that do the following: 1- multiply...

Write code in MIPS ,read tow number from the user that do the following:

1- multiply

2- Dividing

3- sum

4- average

5- minimum

6- maximum

7- print message to thank the user for using my program


Solutions

Expert Solution

Greetings!!

Code:

.data
prompt: .asciiz "\nSelect the operation: \n1. X x Y\n2. X / Y\n3. X + Y\n4. AVERAGE\n5. MINIMUM\n6. MAXIMUM\n7. EXIT\n"
prompt1: .asciiz "Enter first number X\n "
prompt2: .asciiz "Enter second number Y\n "
out: .asciiz "Result= "
thank: .asciiz "Thank You!!"
.text
main:   #DISPLAY PROMPT
   la $a0,prompt
   li $v0,4
   syscall
   #READ OPTION
   li $v0,5
   syscall
   move $t0,$v0   #save the value to t0
   beq $t0,7,exit   #if the option is 7,then exit from the program
   #PROMPT FOR X
   la $a0,prompt1
   li $v0,4
   syscall
   #READ X
   li $v0,5
   syscall
   move $t1,$v0   #save X to t1
   #PROMPT FOR Y  
   la $a0,prompt2
   li $v0,4
   syscall
   #READ Y
   li $v0,5
   syscall
   move $t2,$v0   #save Y to t2
   beq $t0,1,mmul   #if the option is 1 then do multiplication
   beq $t0,2,ddiv   #if the option is 2 then do division
   beq $t0,3,ssum   #if the option is 2 then do addition
   beq $t0,4,aav   #if the option is 4 then calculate average
   beq $t0,5,min   #if the option is 5 then find minimum
   beq $t0,6,max   #if the option is 6 then find maximum
   j main       #repeat the loop
   #MUL OPERATION
mmul:   mul $t3,$t1,$t2   #if the option is 1 then do mul operation
   j display   #goto display
   #DIV OPERATION
ddiv:   div $t3,$t1,$t2   #if the option is 2 then go division operation
   j display   #goto display
   #SUM OPERATION
ssum:   add $t3,$t1,$t2   #if the option is 3 then do addition
   j display   #goto display
   #AVERAGE OPERATION
aav:   add $t3,$t1,$t2   #if the option is 4 then do avearge
   div $t3,$t3,2   #average
   j display   #goto display
   #MIN
min:   bgtu $t1,$t2,else   #if the option is 5 then do the addition
   move $t3,$t1   #copy the minimum to t3
   j display
else:   move $t3,$t2   #copy the minimum to t3
   j display   #goto display
   #MAX
max:   bltu $t1,$t2,elsem   #if the option is 5 then do the addition
   move $t3,$t1   #copy the maximum to t3
   j display
elsem:   move $t3,$t2   #copy the maximum to t3
   #DISPLAY RESULTS= MESSAGE
display:la $a0,out
   li $v0,4
   syscall
   #DISPLAY THE RESULT
   li $v0,1
   move $a0,$t3   #loading the answer from t3 to a0 for display
   syscall
   j main       #repeat
   #DISPLAY THANK YOU
exit:   la $a0,thank
   li $v0,4
   syscall
   #STANDARD TERMINATION
   li $v0,10  
   syscall
  

Output screenshot:

Hope this helps


Related Solutions

Write MIPs program that will read two integers from the user and compute for the sum...
Write MIPs program that will read two integers from the user and compute for the sum and difference of the two integers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".
Write MIPs program that will read two intergers from the user and compute for the sum...
Write MIPs program that will read two intergers from the user and compute for the sum and difference of the two intergers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".
Count the number of 1’s and 0’s Write a MIPS program that will ask the user...
Count the number of 1’s and 0’s Write a MIPS program that will ask the user to enter an integer, and then output the number of 1’s and 0’s that are present in the integer’s signed 32-bit binary representation. For example, 15 has a binary representation of 0000 0000 0000 0000 0000 0000 0000 1111, which has 28 zeroes and 4 ones. We have provided you the starter code that deals with the input/output logic. The integer input is saved...
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.
Prompt user to enter an integer number from console. Use 2 methods to multiply this number...
Prompt user to enter an integer number from console. Use 2 methods to multiply this number by factor 7, display result. This is required to be done in MIPS Assembly Language.
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
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 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 c++ QUESTION 4: Write the code to do the following: -read input from the keyboard...
in c++ QUESTION 4: Write the code to do the following: -read input from the keyboard by displaying the message on the screen to ask and read the following information: * customer ID (string) * customer name (string)                                                        * balance (float) -open output file customer .txt to write -Write to the output file customer.txt the following information:                 Customer ID – customer name – balance For example: 1561175753 - James Smith – 1255.25 -close file QUESTION 5: -create one notepad...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT