Question

I need help creating an MIPS program that takes a user's input of three positive integers and outputs their greatest common prime factor.

phpHDWcOz.png


I have this so far but when instruction reaches the loop I get an error.

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

 .globl main
   
main:
    la $a0, m1                  # Display a message.
    li $v0, 4
    syscall   
    li $v0, 5
    syscall                
              move $t1,$v0           
             la $a0, m2                  # Display a message.
    li $v0, 4
    syscall   
    li $v0, 5
    syscall                
              move $t2,$v0          
              bne $t1,$t2,different
               la $a0, m3      
                 li $v0 4
                 syscall
                j exit
different:
               bgt $t1,$t2,t1bigger
               sw $t2,big
               sub $t3,$t2,$t1
               j out
t1bigger:
                sw $t1,big
                sub $t3,$t1,$t2
out:
                sw $t3, diff
                lw $a0, big   
                li $v0,1
                syscall
                 li $v0 4
                 la $a0,m4
                 syscall
                 li $v0 4
                 la $a0,m5
                 syscall
                  lw $a0, diff  
                li $v0,1
                syscall
       
exit:
        la $v0,10
       syscall       #exit.

#################################################################
#                                #
#            data segment                #
#                                #
#################################################################

    .data

m1:    .asciiz "Enter a Number: "
m2:         .asciiz "Enter another number: "
m3:    .asciiz "Your numbers are equal, there difference is 0\n "
m4:          .asciiz " is bigger "
m5:            .asciiz " the difference is "
                   .align 4
big:            .space 4
diff:            .space 4   

answered by: anonymous

> The answer provided is completely different than the question asked.

Anirudd Pokhrel Fri, Dec 31, 2021 2:02 PM

Add a comment
Know the answer?
Add Answer to:
I need help creating an MIPS program that takes a user's input of three positive integers and outputs their greatest common prime factor.
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
  • Please write a MIPS program to prompt the user to input three positive integers and then print out their greatest common prime factor.

    Please write a MIPS program to prompt the user to input three positive integers and then print out their greatest common prime factor.What to submit:1. Your MIPS program file.2. The log file of simulation in SPIM. The log file should contain the Registers,  Text Segments, Data Segments, and Console.

  • IN MIPS PLEASE. Need help writing a MIPS program that reads from a text file named...

    IN MIPS PLEASE. Need help writing a MIPS program that reads from a text file named "input.txt" and places it in a buffer. A buffer of 80 bytes is more than enough. Before you call your function, set $a0 equal to the address of the filename and $a1 to the address of the buffer where data is stored. The function should return the number of bytes read in $v0. In the main program, print an error message and terminate the...

  • **URGENT** Please help with this MIPS program? (calculator program that uses values from a user's input...

    **URGENT** Please help with this MIPS program? (calculator program that uses values from a user's input file and solves them; needs order of operations) Write a MIPS Assembly Language program to read hexadecimal values and operations (one per line) from a file. The file name should be requested and read in from the console. Once the ascii number has been read in, convert it to internal, binary, storage (decimal). The input format may be either fixed-format, 32-bit, twos compliment values,...

  • I need help with this MIPS program. Write a program that makes an array of integers...

    I need help with this MIPS program. Write a program that makes an array of integers called array in the .data section. It should print the number of zeroes in that array. You should also have a variable called array_size in the .data section which is set to the number of elements in your array. Let's say you name your program count_zeroes.s. To submit your program, you must upload it to hills and run the following command (assuming you are...

  • I need help creating program for the Test_Bisection pseudocode. I need to find a root for...

    I need help creating program for the Test_Bisection pseudocode. I need to find a root for each function f and g and get the output below. Pseudocode Now let's construct pseudocode to carry out this procedure. We shall not try to create a piece of high-quality software with many "bells and whistles,” but we write the pseudocode in the form of a procedure for general use. This allows the reader an opportunity to review how a main program and one...

  • [JAVA] I need help creating a method to calculate the Standard Deviation of a 2D Array....

    [JAVA] I need help creating a method to calculate the Standard Deviation of a 2D Array. This is what I have so far: public double calcStdDev() {    int total = 0;    for(int i = 0; i < arr.length; i++){        total += arr[i][i];    }    double mean = total / arr.length;    return mean; } The numbers I'm using at just 1,2,3,4,5,6 and the standard deviation is coming out wrong. Can I have help fixing my...

  • I need help creating a Mean Filter for Matlab 3 by 3. ( I need the...

    I need help creating a Mean Filter for Matlab 3 by 3. ( I need the Actual Matlab WORking code) It's dude tomorrow, final project worth 40% of my grade. It can not use Matlab Function, must be user define fuction. So far what I have is, I am not sure how to start this, I was told it requires 2 for loops A= imread('lena_256.tif'); % Reads the image in matrix M = ones(3,3)/9; % Creates a matrix of 3...

  • I NEED THIS PROGRAM COMPLETE WITH THE INPUT ALREADY IN IT. I HAVE NO TIME LEFT...

    I NEED THIS PROGRAM COMPLETE WITH THE INPUT ALREADY IN IT. I HAVE NO TIME LEFT TO GET IT DONE AND IT'S BEEN KICKING MY BEHIND FOR THE PAST FEW DAYS. THIS IS MY FINAL PROGRAM AND I HAVE NO CLUE ABOUT WHAT I'M DOING. SO, IF SOME WILL...WILL YOU PLEASE DO THE PROGRAM WITH THE INPUT ALREADY IN IT...I JUST WANT TO BE ABLE TO COPY PASTE AND RUN IT. I WOULD APPRECIATE IT A HECK OF A LOT....

  • I need help with the last three questions the Loop A mass m -82 kg slides...

    I need help with the last three questions the Loop A mass m -82 kg slides on a frictionless track that has a drop, followed by a loop-the-loop with radius R 7.8 m and finally a flat straight section at the same height as the center of the loop (17.8 m off the ground). Since the mass would not make it around the loop if released from the height of the top of the loop (do you know why?) it...

  • i NEED HELP WITH RED HIGHLIGHTED TEXT PLZ A2. Write a program to calculate the voltage...

    i NEED HELP WITH RED HIGHLIGHTED TEXT PLZ A2. Write a program to calculate the voltage and prints the voltage, when you ask from the user to give the current and resis tance. Print the voltage to 4 decimal places. NOTE V-IR For example do not add values to the code (hard coding) The user inputs are 9.2 and 2.0, so the co mputer calcul ates 1.84. You should ask clear questions from the user and get 2 values. Then...

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