diff --git a/c-print-for-loop/main.c b/c-print-for-loop/main.c index 83412a9..0f883f0 100644 --- a/c-print-for-loop/main.c +++ b/c-print-for-loop/main.c @@ -5,6 +5,7 @@ void _start(void) { asm ("law 04000"); asm ("dac 209"); + asm ("law 03000"); asm ("dac 208"); int c; diff --git a/c-test-recursion/Makefile b/c-test-recursion/Makefile new file mode 100644 index 0000000..49d1aab --- /dev/null +++ b/c-test-recursion/Makefile @@ -0,0 +1 @@ +include ../common/common.mk diff --git a/c-test-recursion/main.c b/c-test-recursion/main.c new file mode 100644 index 0000000..73ab9ab --- /dev/null +++ b/c-test-recursion/main.c @@ -0,0 +1,30 @@ +static void putc(); + +static void foo(int); + +void _start(void) +{ + /* TODO: handle sp/fp init better -- separate crt0.S? */ + asm ("law 03000"); + asm ("dac 209"); + asm ("law 04000"); + asm ("dac 208"); + + foo(20); + + asm ("hlt"); + __builtin_unreachable(); +} + +static void putc() { + asm ("lio %0" : : "r"(027) : "io"); + asm ("tyo"); +} + +static void foo(int n) +{ + if (n != 0) { + putc(); + foo(n - 1); + } +} diff --git a/pdp1-gcc b/pdp1-gcc index 53bbfaf..2804d4a 160000 --- a/pdp1-gcc +++ b/pdp1-gcc @@ -1 +1 @@ -Subproject commit 53bbfaff2662ac019da34bebc11b781bdf8c9722 +Subproject commit 2804d4aff1325f86a6967f91e9b8c9da76cea0db