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
In Java program: Write a program that takes a character from the user and classifies it...
In Java program: Write a program that takes a character from the user and classifies it as a number (‘1’,’2’, ‘3’,4, 5, 6, 7  …), a letter from the alphabet (‘A’, ‘a’, ‘B’, ‘b’, …, ‘Z’, ‘z’), an arithmetic operator (‘+’, ‘-‘, ‘/’, ‘*’, ‘%’), a comparison operator (‘<’, ‘>’, ‘=’), punctuation (‘!’, ‘?’, ‘,’, ‘,’, ‘:’, ‘;’), and all other characters as a Special Character, and informs the user of the same. If the user entered the character A, the...
Write a MIPS assembly program that asks the user first for a string, then for a...
Write a MIPS assembly program that asks the user first for a string, then for a character. The program should search the string for the character and print out the number of times the character appears in the string. Restrictions can be used, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
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 that takes n integer numbers from the user, and then counts the number...
Write a program that takes n integer numbers from the user, and then counts the number of even numbers and odd numbers and print them to the screen. Sample Output: Enter how many numbers you have: 10 Enter the 10 numbers: 1 3 19 50 4 10 75 20 68 100 The number of even numbers is: 6 The number of odd numbers is: 4 (( in java ))
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...
(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...