MIPS Assembly Complete gcd_cur function, which recursively calculates the GCD (Greatest Common Divisor) of two given positive integers input using the following Euclidean algorithm (Links to an external site.).             def gcd_recur(a, b):

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

MIPS Assembly

Complete gcd_cur function, which recursively calculates the GCD (Greatest Common Divisor) of two given positive integers input using the following Euclidean algorithm (Links to an external site.).

            def gcd_recur(a, b):
                   if b = 0:
                              return a;
                    else:
                             return gcd_recur( b, (a mod b) );

>> a0: the 1st input argument, a
>> a1: the 2nd input argument, b

My Code:

###############################################################
###############################################################
###############################################################
# PART 2 (gcd_recur)
#a0: input number
#a1: input number
###############################################################
gcd_recur:
############################### Part 2: your code begins here ##
## return value is v0
move $t0, $a0

move $t1, $a1

loop:

beq $t1, $0, done

div $t0, $t1

move $t0, $t1

mfhi $t1

j loop

done:

move $v0, $t0

jr $ra
############################### Part 2: your code ends here ##
jr $ra

 

The Problem:

(attached screenshot) - I need it to match the expected out and I am unsure how to 

Testing gcd_recur:
Program input: 1 12 4 79322 1378 75 28300 74000
Expected output: 1 4 22 1 25 100
Obtained output: 4 4 4 4 4 4 4
Transcribed Image Text:Testing gcd_recur: Program input: 1 12 4 79322 1378 75 28300 74000 Expected output: 1 4 22 1 25 100 Obtained output: 4 4 4 4 4 4 4
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education