#include /* common defines and macros: file found in CodeWarrior folder */
#include "derivative.h" /* derivative-specific definitions (e.g.: PORTA, DDDRK) */
#include // for malloc
/* Global Variables: // stored in $1100 (right after the Stack) */
unsigned char n=46; // n <= 46 . F(47) requires more than 32 bits (unsigned)!
unsigned char correct; // correct = 0: wrong result, correct = 1: right result
// Program starts at $C000
// Program: Find the Fibonacci numbers from F(0) to F(n)
// Function declaration:
// This is considered to be a Subroutine in the ASM Code:
void main(void) { // in Assembly code, this is treated as a SubRoutines
unsigned char i;
long int Fibo[47];
Fibo[0] = 0;
Fibo[1] = 1;
if ((n == 0) || (n == 1))
correct = 1;
else if (n > 46)
correct = 0;
else
{
correct = 1;;
i = 2;
do
{
Fibo[i] = Fibo[i-1] + Fibo[i-2];
i = i + 1;
} while (i <= n);
}
while (1);
}