Provided for this assignment is testasm a test file which in
Provided for this assignment is test.asm, a test file which includes code template with test input. Feel free to edit the test file and add your implementation under corresponding assembly labels (gcf and gcf r). You are required to submit your code that contains both versions. Include your answers to Question 3 and 4 into the source as a comment (#). Convert the following recursive Greatest-Common-Factor function into MIPS assembly language. gcf(a, b) {r = a % b; r is the Remainder of a/b (see rem) if (r == 0) return b; else return gcf(b, r);}
Solution
gcd: # a and b are the two integer parameters # return value is in v0 move $t0, $a move $t1, $b loop: beq $t1, $0, done div $t0, $t1 move $t0, $t1 mfhi $t1 j loop done: move $v0, $t0 jr $ra