COMP-2660 – Assignment #4 DUE DATE is: Wednesday, December 2, 2020, at 11:59 PM. WARNINGS: You must only use instructions and directives discussed in Lectures 1 to 12 (Chapt_08.pptx). This is a group assignment of no more than 2 students in a group. However, submit individually as usual but making sure you include as a comment the last-name, first-name and student-number of each member in the group. What I mean: all member of the group should submit the work as if it was done individually. Simply, I do not know how to correctly set the group submission feature on Blackboard. Do only one (1) of the following programming exercises; if you do both, then I will use one (the worst one) as a bonus mark in your favour. Programming Exercise 1 (10 points): [call it Ass4-Q1.asm] – Chapter-8 The greatest common divisor (GCD) of two integers X and Y is the largest integer Z that will evenly divide both integers. The GCD algorithm involves integer division in a loop. Write the recursive GCD function in ASM. Your main program must call this function with a pairs of 32-bit unsigned parameters X and Y. Your GCD function should return the greatest common divisor of X and Y in register EAX, and your main program should display this value EAX [= GCD of X and Y]. You can test your program using the following pairs (5, 20), (24, 18), (11, 7), (432, 226), (0, 0) or other pairs. The pseudocode of the recursive GCD algorithm is given below. function gcd(a, b) if b = 0 return a; else return gcd(b, a mod b); Programming Exercise 2 (10 points): [call it Ass4-Q2.asm] – Chapter-8 Write an ASM program that reads an integer N and then displays the first N values of the Fibonacci number sequence, described by: Fib(0) = 0, Fib(1) = 1, Fib(N) = Fib(N-2) + Fib(N-1) Thus, if the input is N = 10, your program Ass4-Q1.exe should display the following single line: Fibonacci sequence with N = 10 is: 0 1 1 2 3 5 8 13 21 34 55. Your MAIN program should call a recursive Fib procedure with parameter k, and the Fib procedure should return the k-th Fibonacci number in register EAX, and then the MAIN program should display the k-th Fibonacci number in the sequence. You may want to declare the Fibonacci sequence as an array of size N, called FibSeq, and then have the Fib procedure to compute the value of each cell of the array. Also, there are other ways to do this.
欢迎咨询51作业君