Question

In MIPS, how would you add and multiply two integer numbers like 5 & 6 and...

In MIPS, how would you add and multiply two integer numbers like 5 & 6 and display on the screen?

Homework Answers

Answer #1
.data
   num1:  .asciiz "Enter first number: "
   num2:  .asciiz "Enter second number: "
   newline: .asciiz "\n"
   sum:   .asciiz "Sum of two numbers is "
   product: .asciiz "Product of two numbers is "

.text
   
   la $a0, num1
   li $v0, 4
   syscall
   
   li $v0, 5
   syscall
   
   addi $s0, $v0, 0
   
   la $a0, num2
   li $v0, 4
   syscall
   
   li $v0, 5
   syscall
   
   addi $s1, $v0, 0
   
   add $t0, $s0, $s1
   mul $t1, $s0, $s1
   
   la $a0, sum
   li $v0, 4
   syscall
   
   addi $a0, $t0, 0
   li $v0, 1
   syscall
   
   la $a0, newline
   li $v0, 4
   syscall
   
   la $a0, product
   li $v0, 4
   syscall
   
   addi $a0, $t1, 0
   li $v0, 1
   syscall
   
   la $a0, newline
   li $v0, 4
   syscall

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
For Java programming code: Write methods to add and multiply 1) Two integers 2) Two decimals...
For Java programming code: Write methods to add and multiply 1) Two integers 2) Two decimals 3) One integer and one decimal
In regards to intersections, how would I add the events A (2, 3, 4, 5) and...
In regards to intersections, how would I add the events A (2, 3, 4, 5) and B (2, 3, 6, 7)? I know that A *inverted u like an umbrella* B will be (2, 3) because A and B both have these numbers in common What, then, happens to the rest? like A (4, 5) and B (6, 7) ? Please express to me how to write this and also the difference between the *u* between two letters or the...
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci...
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, … The sequence Fn of Fibonacci numbers is defined by the recurrence relation: Fn = Fn-1 + Fn with seed values F1 = 1 F2 = 1 For more information on...
Write a function that takes two integer inputs and returns the sum of all even numbers...
Write a function that takes two integer inputs and returns the sum of all even numbers between these inputs, and another function that takes two integer inputs and returns the sum of odd numbers between these inputs .In main function, the program will asks the user to enter two integer numbers and then passes them to these two functions and display the result of each of them.         [0.5 mark] (BY USING C PROGRAM)
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
MATLAB Task: Use a for loop to find how many numbers you have to add to...
MATLAB Task: Use a for loop to find how many numbers you have to add to get a sum greater than 1,000. The numbers in the problem are consecutive, so adding up 1+2+3+4+5+6+.... until you reach the user defined value 1000. Method : must Make a variable equal to 1 then add 2, 3, 4...to it, until you reach 1000, then you break out the loop once the sum hits 1,000.
I have a MIPS reference sheet if you could explain the solution that would be much...
I have a MIPS reference sheet if you could explain the solution that would be much appreciated. Convert the following MIPS code to hexadecimal machine code: sub $10, $8, $6 slt $1, $9, 2
I would like to add n bits all together, how many XOR, AND and OR gates...
I would like to add n bits all together, how many XOR, AND and OR gates I need at the minimum? Could you please explain your answer with examples like n=3,4,5 etc.
You would like to have $1,000 5 years from now and believe you can earn 6%...
You would like to have $1,000 5 years from now and believe you can earn 6% on your money. How much would you have to deposit today to reach your $1,000 goal?
So I would like to multiply a first digit by 2. I have to randomize either...
So I would like to multiply a first digit by 2. I have to randomize either 51-55 but multiply that very first digit by 2 whichever the number may come out to be. I also need to keep the string. FOR EXMAPLE: Code generates 51, multiply 5 * 2 to get 10 1 or if it generates 54, multiply 5 * 2 to get 10 4 the 1 and the 4 always stay the same, only the 5 is getting...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT