aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/fact.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-09-08 22:05:33 +0200
committerlemon <lsof@mailbox.org>2025-09-08 22:05:33 +0200
commite043811980db560fc2507bb53b644e54c80527dc (patch)
tree6ea563d81c9d3767f439e361fc2c884cf4f9b64d /test/fact.c
parent36b5b19bf183cb01525201ccbddd6afa692f21bb (diff)
regalloc: start implementing linear scan
Diffstat (limited to 'test/fact.c')
-rw-r--r--test/fact.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/fact.c b/test/fact.c
new file mode 100644
index 0000000..1147d8f
--- /dev/null
+++ b/test/fact.c
@@ -0,0 +1,13 @@
+int
+fact(int x)
+{
+ int y = 1;
+ while (x >= 1) {
+ y *= x;
+ x -= 1;
+ }
+ return y;
+}
+
+extern int printf();
+int main() { printf("6! = %d\n", fact(6)); }