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
Trending now
This is a popular solution!
Step by step
Solved in 2 steps