X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=debug%2Fprograms%2Fdebug.c;h=3ba51bca9249cd768ee298515ac2456477eccdad;hb=87b55cae7014a375588a3d24d03903ca170f6d7e;hp=20b1cdcf29f18d6e042884f18c3f86ad915dde5a;hpb=22541b6099cb176fd3ec34f9e893da9e2baaa297;p=riscv-tests.git diff --git a/debug/programs/debug.c b/debug/programs/debug.c index 20b1cdc..3ba51bc 100644 --- a/debug/programs/debug.c +++ b/debug/programs/debug.c @@ -5,6 +5,24 @@ unsigned int crc32a(uint8_t *message, unsigned int size); +unsigned int fib(unsigned int n) +{ + if (n == 0) { + return 0; + } + + unsigned int a = 0; + unsigned int b = 1; + + for (unsigned int i = 1; i < n; i++) { + unsigned int next = a + b; + a = b; + b = next; + } + + return b; +} + void rot13(char *buf) { while (*buf) {