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):
MIPS Assembly
Complete gcd_cur function, which recursively calculates the GCD (Greatest Common Divisor) of two given positive integers input using the following Euclidean
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff10f25b0-b536-4ace-9c3b-52e2fea79779%2F28dbf212-481d-4de4-a1d7-49aeebb656d7%2Fpjejntn_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)