Question

In: Computer Science

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] ?".

Solutions

Expert Solution

Greetings!!

Code:

#DATA SEGMENT
.data
prompt1: .asciiz "Enter the first number: "
prompt2: .asciiz "Enter the second number: "
sum: .asciiz "\nThe sum is: "
dif: .asciiz "\nThe difference is: "
rep: .asciiz "\nDo you want to continue? Y/y | N/n: "
#CODE SEGMENT
.text
main:
#MAIN STARTS HERE
#DISPLAY PROMPT1
repeat:
la $a0,prompt1
li $v0,4
syscall
#READ NUMBER1
li $v0,5
syscall
move $t0,$v0
#DISPLAY PROMPT2
la $a0,prompt2
li $v0,4
syscall
#READ NUMBER2
li $v0,5
syscall
move $t1,$v0
#CALCULTE THE SUM AND DIFFERENCE
add $t2,$t0,$t1
sub $t3,$t0,$t1
#DISPLAY SUM IS
la $a0,sum
li $v0,4
syscall
#DISPLAY SUM
add $a0,$0,$t2
li $v0,1
syscall
#DISPLAY DIFFERENCE IS
la $a0,dif
li $v0,4
syscall
#DISPLAY DIFF
add $a0,$0,$t3
li $v0,1
syscall
#DISPLAY CONTINUE?
la $a0,rep
li $v0,4
syscall
#READ OPTIONS
li $v0,12
syscall
beq $v0,'Y',repeat
beq $v0,'y',repeat
#EXIT
li $v0,10
syscall

Output screenshot:

Hope this helps


Related Solutions

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] ?".
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 asks the user for 2 numbers. Output the sum of the...
Write a MIPS program that asks the user for 2 numbers. Output the sum of the 2 numbers. The difference between the 2 numbers (num1-num2) and (num2-num1) The value that is 305 more than the 1st number. The value that is 305 less than the 2nd number
Question 1: Write a program to receive two integers as user input and then print: Sum...
Question 1: Write a program to receive two integers as user input and then print: Sum Difference Product Average Maximum of the two Minimum of the two You may use the min and max functions declared in the math class. ********************************************************************************** Question 2: An online bank wants you to create a program that will show a prospective customer, how the deposit will grow. Your program should read the initial balance and the annual interest rate. Interest rate is compounded monthly....
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers...
Write a MIPS Assembly Language program to perform the following operations: Request and read two integers from the console (Dn and Up), Call a recursive function to compute the result int RecurseFunc( int Dn, int Up ) { if( Dn < 1 ) return 0; return Dn * Up + RecurseFunc( Dn - 1, Up + 1 ); } Print out the results
Write a program that uses a while statement to read integers from the user and prints...
Write a program that uses a while statement to read integers from the user and prints the sum, average, and largest of these numbers. The input should terminate if the user enters 999. The average should be output with 4 digits of precision. c++ please ASAP
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT