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.
Write a program in MIPS ASSEMBLY LANGUAGE.. Take no of students as input from the user,...
Write a program in MIPS ASSEMBLY LANGUAGE.. Take no of students as input from the user, then take marks of 5 subjects for each student from the user. Then find Minimun, Maximum and Median of all the subjects. and comment each line in code also make flow chart
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 Python program to ask user input of a string, then ask user input of...
Write a Python program to ask user input of a string, then ask user input of what letters they want to remove from the string. User can either put in "odd", "even" or a number "n" that is greater than 2. When user input "odd", it will remove the characters which have odd numbers in the sequence of the string. When user input "even", it will remove the characters which have even numbers in the sequence of the string. When...
C++ Write a program that takes two integer arrays of different sizes from the user (this...
C++ Write a program that takes two integer arrays of different sizes from the user (this means that the user can tell the program the size of each array), and then computes the intersection and union of those arrays. Note: the arrays can be of different lengths and the intersection/union should have unique elements in sorted order. Use pointer notation of arrays for this question. Eg: *(arr+1) [10]
in C++ Write a program. The program should prompt the user for the number of shares...
in C++ Write a program. The program should prompt the user for the number of shares purchased, purchase price per share, the commission for the purchase, sale commission paid, and the price the shares were sold at. The program should validate each of these values to ensure they are acceptable (none can be less than zero) and should then pass them to a function called numberfunction.The function should use the following formula to determine the profit: Profit = ((number of...
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 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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT