diff options
| author | 2023-06-19 22:33:35 +0200 | |
|---|---|---|
| committer | 2023-06-19 22:33:35 +0200 | |
| commit | 61367525aea8f3f11c29e628fe49768dda959cef (patch) | |
| tree | 7f3f428b40086c20ebc2e7aa54f49b4394b6e820 /test | |
| parent | 88bf0602d09bebbf18213fbf02821e9f63b964a8 (diff) | |
backend: compile comparison instrs and branches
Diffstat (limited to 'test')
| -rw-r--r-- | test/fib.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/fib.c b/test/fib.c new file mode 100644 index 0000000..6254a5f --- /dev/null +++ b/test/fib.c @@ -0,0 +1,19 @@ +unsigned fib(unsigned x) { + unsigned r = 0, q = 1; + while (x--) { + unsigned s = r + q; + r = q; + q = s; + } + return q; +} + +int atoi(const char *); +int printf(const char *, ...); + +int main(int argc, char **argv) { + unsigned n = argv[1] ? atoi(argv[1]) : 10; + printf("fib(%u) = %u\n", n, fib(n)); +} + +/* vim:set ts=3 sw=3 expandtab: */ |