Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write below code in MPI MASM 8086. not in C language.. Step1: Write an assembly

ID: 3764513 • Letter: W

Question

Write below code in MPI MASM 8086. not in C language..

Step1: Write an assembly procedure (mpi masm 8086) 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

2 1

3 1

4 3

5 5

6 9

7 17

Explanation / Answer

Fibonacci proc PUSH EBP ; save previous frame pointer MOV EBP, ESP ; set current frame pointer MOV EAX, [EBP+8] ; get argument N CMP EAX, 1 ; N<=1? JA Recurse ; no, compute it recursively MOV ECX, 1 ; yes, Fib(1)--> 1 JMP exit Recurse: DEC EAX ; = N-1 MOV EDX, EAX ; = N-1 PUSH EDX ; save N-1 PUSH EAX ; set argument = N-1 CALL Fibonacci ; compute Fib(N-1) to ECX POP EAX ; pop N-1 DEC EAX ; = N-2 PUSH ECX ; save Fib(N-1) PUSH EAX ; set argument = N-2 CALL Fibonacci ; compute Fib(N-2) to ECX POP EAX ; = Fib(N-1) ADD ECX, EAX ; = Fib(N-1)+FIB(N-2) exit: MOV ESP,EBP ; reset stack to value at function entry POP EBP ; restore caller's frame pointer RET ; and return

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote