Take the following program and translate it into PEP/9 assembly language:
#include <iostream>
using namespace std;
int fib(int n)
{
int temp;
if (n <= 0)
return 0;
else if (n <= 2)
return 1;
else {
temp = fib(n – 1);
return temp + fib(n-2);
}
}
int main()
{
int num;
cout << "Which fibonacci number? ";
cin >> num;
cout << fib(num) << endl;
return 0;
}
You must use equates to access the stack and follow the call to the function as discussed in the book (pass the parameter, return address, return a value and so on). There are NO global variables in the resulting code (except a global message of "Range num? "). It must be able to do sum a range greater than 2.
Submit source code.
it doesn't have to be the entire sequence just at least one number
Please, it must be done in PEP9 not other vers like PEP8
Solution: The above-given problem is actually solved using the Pep 9 assembly programming language and the code is up and running. This code actually prints the number of elements in a Fibonacci series please find attached the code for the same.
Code:
.MODEL SMALL
.DATA
.CODE
MAIN PROC
MOV AX,@DATA
MOV DX,AX
MOV AL,20
MOV CL,10
MOV AH,00
DIV CL
MOV DX,AX
ADD DX,3030h
MOV AH,02H
INT 21H
MOV DL,DH
INT 21H
MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN
Here's the solution to your question, please provide it a 100% rating. Thanks for asking and happy learning!!
Get Answers For Free
Most questions answered within 1 hours.