diff options
author | Tim Newsome <tim@sifive.com> | 2016-08-15 12:52:03 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2016-08-16 12:01:59 -0700 |
commit | 87b55cae7014a375588a3d24d03903ca170f6d7e (patch) | |
tree | 4bfc1e749f07da46bd2861483d100a6cb0ccf444 /debug/programs | |
parent | 22541b6099cb176fd3ec34f9e893da9e2baaa297 (diff) | |
download | riscv-tests-87b55cae7014a375588a3d24d03903ca170f6d7e.zip riscv-tests-87b55cae7014a375588a3d24d03903ca170f6d7e.tar.gz riscv-tests-87b55cae7014a375588a3d24d03903ca170f6d7e.tar.bz2 |
Simplify test_function_call.
Now it doesn't rely on malloc, which can be tricky to get to work in and
of itself.
Diffstat (limited to 'debug/programs')
-rw-r--r-- | debug/programs/debug.c | 18 |
1 files changed, 18 insertions, 0 deletions
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) { |