Question

Write an interactive program that inputs a decimal num1 and an integer num2. If num1 is...


Write an interactive program that inputs a decimal num1 and an integer num2. If num1 is less than num2, then it displays "num 1 is less than num 2"; if they are identical, it starts over again; if . If num2 is less than num1, then it displays "num 2 is less than num 1"

(((((((((((in MIPS assembly language)))))))))))

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MIPS code to perform the given task is provided below, please comment if any doubts:

MIPS Code:

.data
    NUM1: .asciiz "Enter the NUM1: \n"
    NUM2: .asciiz "Enter the NUM2: \n"
    msg1: .asciiz "num 2 is less than num 1\n"
    msg2: .asciiz "num 1 is less than num 2\n"
main:
.text

LOOP:
   #the first number prompt
   la        $a0, NUM1
   li        $v0, 4
   syscall

   #read the num1
   li        $v0, 5
   syscall
   move     $t0,$v0

   #the second number prompt
   la       $a0, NUM2
   li       $v0,4
   syscall

   #read the num2
   li       $v0, 5
   syscall
   move     $t1,$v0

   #if num1 is greater than num2
   bgt      $t0,$t1, bigger1
  
   #if num2 is gretaer
   bgt      $t1,$t0, bigger2

   #if equal display loop forever
  
   b        LOOP
  
bigger1:
   #display the message
   la        $a0, msg1
   li        $v0, 4
   syscall
   b exit
  
bigger2:
   #display the message
   la        $a0, msg2
   li        $v0, 4
   syscall  

#exit code
exit:
   li       $v0,10
   syscall

Output test:

Code screenshot:

Add a comment
Know the answer?
Add Answer to:
Write an interactive program that inputs a decimal num1 and an integer num2. If num1 is...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Write a program that prompts the user to enter two positive integers: num1 and num2....

    C++ Write a program that prompts the user to enter two positive integers: num1 and num2. - Validate that num1 is less than num2 and that both numbers are positive. If any of these conditions are not met, allow the user to re-enter num1 and num2 until the input is determined valid. - For all integers from num1 through num2, print the word keyboard if the current integer is divisible by 2 and print the word mouse if the current...

  • Use assembly language to write a complete program that will input values fornum1 ,num2 and num3...

    Use assembly language to write a complete program that will input values fornum1 ,num2 and num3 and display the value of the expression ( (num1 ^ 3) * num2 + 5 * ( num2 ^ 2) ) / num3. assume that the user enters only numbers that are greater than zero and the calculation never exceed 4 bytes size. Sample run: num1 = 1 num2 = 2 num3 = 3 ((num1 ^ 3) * num2 + 5 * ( num2...

  • Write MARIE assembly language programs that do the following: Write a program that inputs an integer...

    Write MARIE assembly language programs that do the following: Write a program that inputs an integer and prints to output a countdown from the integer to 0. For example, if 7 is input: 7 6 5 4 3 2 1 0

  • In the C language, Write a program that inputs 4 hexadecimal digits as strings (example 7F),...

    In the C language, Write a program that inputs 4 hexadecimal digits as strings (example 7F), converts the string digits to a long – use strtol(input string,&ptr,base) to do the conversion. Just declare ptr as a char ptr, don’t worry about what it does. Copy each converted number [ a long] into unsigned char’s [like the variable num1 below – hint: cast a long variable into the unsigned char’s] before performing the following logical operations on them (parenthesis might help,...

  • This is an external javascript file // Problem 1:   Declare the variables num1, num2, ans1, //  ...

    This is an external javascript file // Problem 1:   Declare the variables num1, num2, ans1, //               greet1, greet2. Then initialize them to //               hold the values 1, 2, 0, "Hello", and //               "World", respectively. var num1 = 1; var num2 = 2; var ans1 = 0; var greet1 = "Hello"; var greet2 = "World"; // Problem 1a:   Display the values stored in the previous //               variables in the...

  • Problem Description: Write s Java program to find and display the product of three integer values...

    Problem Description: Write s Java program to find and display the product of three integer values based on the rue mentioned below it should display the product of the three values except when one of thevalues is 7n that case 7 should not be ingluded in the product and the values to its left also shouid not be included If there is only one value to be considered display that value tself f no values can be included in the...

  • Write MARIE assembly language programs that do the following: I. Write a program that inputs thre...

    Write MARIE assembly language programs that do the following: I. Write a program that inputs three integers, a, b, and c, in that order. It computes the following ia-bi-fc+ c The result should be written to output 2. Write a program that inputs integers, s. y, and z. It outputs the difference of the langest and first element entered. You may assume x. y, and z all have different values. So if 8, 12, and 9 are input, the output...

  • Please select the output: main         declare X as integer, Y as integer                        &nbsp

    Please select the output: main         declare X as integer, Y as integer                                 set x=1                                 set y=2                                 call sub(x, y)                                 write x                                 write y End program Subprogram sub( integer Num1 as ref, Integer Mum2 as reference)                                                              declare x as integer                                                 set Num1 = 3                                                 set Num2 = 4                                                 set x= 5                                                 write x end subprogram           Please select one:      5/42, 5/34, 5/32, 5/24 What is the output of this...

  • For this interactive assignment, you will continue to utilize loops and functions and write a Python...

    For this interactive assignment, you will continue to utilize loops and functions and write a Python program that asks the user for an integer (number) greater than 1. Once the user enters an integer, it should then allow the user to CHOOSE between the following two options: If 1 is entered, a countdown from that number to zero is printed. If 2 is entered, the factorial of the number is printed. If the user inputs a number less than 1,...

  • So the assignment is to write a program that have the user entered 3 numbers and...

    So the assignment is to write a program that have the user entered 3 numbers and than it will sort it by ascending order. Here are the code I wrote, but it won't compiled and I kept on getting an error message "Using uninitiazed memory" for all the variables. Can someone please help take a look and see whats going on? #include <iostream> using namespace std; int main() { //variables int num1, num2, num3; int lowest, middle, highest; //user inputs...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT