Skip to content

Commit

Permalink
gcc: add support for recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
fkokosinski committed Jun 21, 2024
1 parent 37ad3b3 commit e98d642
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions c-print-for-loop/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ void _start(void)
{
asm ("law 04000");
asm ("dac 209");
asm ("law 03000");
asm ("dac 208");

int c;
Expand Down
1 change: 1 addition & 0 deletions c-test-recursion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../common/common.mk
30 changes: 30 additions & 0 deletions c-test-recursion/main.c
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 1 addition & 1 deletion pdp1-gcc

0 comments on commit e98d642

Please sign in to comment.