Question

write a program that takes twoinput values from the user and calculate the subtraction if the...

write a program that takes twoinput values from the user and calculate the subtraction if the first number is greater than the second one other wise calculate the summation in MIPS

Homework Answers

Answer #1

.data

message1:.asciiz"enter number 1"
message2:.asciiz"enter number 2"
message3:.asciiz"the sum is: "
message4:.asciiz"the difference is:"

.text

main:
#enter the input by the user
li $v0,4
la $a0,message1
syscall

#read the user input
li,$v0,5
syscall

#store the enteres value in the register
move $t0,$v0

#enter the input by the user
li $v0,4
la $a0,message2
syscall

#read the user input
li,$v0,5
syscall

#store the enteres value in the register
move $t1,$v0

#compare the values stored in the register

bgt $t0,$t1,difference
add $t3,$t0,$t1
li $v0,0
la $a0,message3
syscall
move $a0,$t3


difference:
sub $t3,$t0,$t1
li $v0,0
la $a0,message4
syscall
move $a0,$t3

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
write a MIPS assembly program to get an integer input from the user and multiply it...
write a MIPS assembly program to get an integer input from the user and multiply it by 2 and print output to the console
Write Java program Lab51.java which takes in a string from the user, converts it to an...
Write Java program Lab51.java which takes in a string from the user, converts it to an array of characters (char[] word) and calls the method: public static int countVowels(char[]) which returns the number of vowels in word. (You have to write countVowels(char[]) ).
Create a MIPS program that takes an ASCII string of hexadecimal digits inputted by the user...
Create a MIPS program that takes an ASCII string of hexadecimal digits inputted by the user and converts it into an integer.
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Write a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
Write a program that plays a number guessing game with a human user. The human user...
Write a program that plays a number guessing game with a human user. The human user will think of a number between 1 and 100, inclusive. Then the program has to guess what the user entered. keep track of the number of interaction it takes for the computer to guess the number. sample run: enter number to be guessed:88 output: you entered 88, and it took the program 3 iterations to guess.
(Write in C++) Write a program that reads in two numbers and, if the input is...
(Write in C++) Write a program that reads in two numbers and, if the input is valid, outputs 2 times the product of the integers that lie between the two values (including the values themselves). If either number is not an integer, or if the first number is not less than the second number, just output an error message. The sample runs below should give the idea. User inputs are in bold. Important Notes: Your program should use a loop...
Write a python program that does the following: Prompts the user for three numbers in one...
Write a python program that does the following: Prompts the user for three numbers in one request. Be sure to specify the “delimiter” by which a user enters those three numbers. Divides the first number by the second number and add that result to the third number. Prints output that shows in one line the formula applied and the result of the calculation. Validate input by: •    Checking the user entered 3 values •    Appropriately checking for the following errors:...
Write a program that prompts the user for the number of values for which it will...
Write a program that prompts the user for the number of values for which it will calculate the base 2 log of each value. Use a for loop to iterate the set of values and print the log for each. Here is the formula to change the base of a log: loga b = log10 b / log10 a Sample output appears below. This program will calculate the Base 2 log of a set of numbers<LINERETURN> ===============================================================<LINERETURN> Enter the upper...
I'm new to MIPS. How to write a program that prompts the user for a temperature...
I'm new to MIPS. How to write a program that prompts the user for a temperature in Celsius and then display the result in Fahrenheit. Have to use ineteger to float conversion.