Wirte the code in MASM. Step1: Write an assembly procedure which computes the fo
ID: 3763962 • Letter: W
Question
Wirte the code in MASM.
Step1: Write an assembly procedure which computes the following:
int myfib(n) /* n is a positive integer */
if (n<=3) return 1;
/* else */
return myfib(n-1)+myfib(n-2)+myfib(n-3);
NOTE THAT THE ABOVE FUNCTION IS RECURSIVE. YOUR PROCEDURE NEEDS TO BE RECURSIVE AND COMPUTE EXACTLY AS DESRIBED IN MYFIB(). NO CREDIT WILL BE GIVEN IF YOUR PROCEDURE IS NOT RECURSIVE. NO CREDIT WILL BE GIVEN IF YOUR PROGRAM IS CROSS-ASSEMBLED FROM ANOTHER LANGUAGE.
YOU DECIDE ON WHICH REGISTERS TO USE (FOR PARAMETER PASSING AND RETURNED VALUES, ETC).
Step 2: After completing Step 1, write an assembly program that computes and displays in a separate line the following:
i myfib(i)
for all integer i, from i=1 to 15.
The initial part of the output will look as the following:
1
1
1
3
5
9
17
. . .
Explanation / Answer
#include int main( int argc, char**argv ) { int fib[3] = {0,1}; int counter = 0; if (argc < 2) { printf ("usage: %s number ", argv[0]); return 1; } printf("The %dth Fibonacci number is: ", atoi(argv[1])); while ( counterRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.