From 61367525aea8f3f11c29e628fe49768dda959cef Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 19 Jun 2023 22:33:35 +0200 Subject: backend: compile comparison instrs and branches --- test/fib.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/fib.c (limited to 'test') 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: */ -- cgit v1.2.3