OpenCores
URL https://opencores.org/ocsvn/8051/8051/trunk

Subversion Repositories 8051

[/] [8051/] [trunk/] [asm/] [fib.c] - Blame information for rev 186

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 simont
/*
2
 * Copyright (c) 1999-2001 Tony Givargis.  Permission to copy is granted
3
 * provided that this header remains intact.  This software is provided
4
 * with no warranties.
5
 *
6
 * Version : 2.9
7
 */
8
 
9
/*---------------------------------------------------------------------------*/
10
 
11
#include <reg51.h>
12
 
13
/*---------------------------------------------------------------------------*/
14
 
15
void fib(unsigned char* buf, unsigned char n) {
16
 
17
    char i;
18
 
19
    buf[0] = 1;
20
    buf[1] = 1;
21
    for(i=2; i<n; i++) {
22
 
23
        buf[i] = buf[i-1] + buf[i-2];
24
    }
25
}
26
 
27
/*---------------------------------------------------------------------------*/
28
 
29
void print(unsigned char* buf, unsigned char n) {
30
 
31
    char i;
32
 
33
    for(i=0; i<n; i++) {
34
 
35
        P0 = buf[i];
36
    }
37
}
38
 
39
/*---------------------------------------------------------------------------*/
40
 
41
void main() {
42
 
43
    unsigned char buf[10];
44
 
45
    fib(buf, 10);
46
    print(buf, 10);
47
    while(1);
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.