From: Bryan English Date: Wed, 28 Jan 2026 04:50:38 +0000 (-0500) Subject: add more complete fib-example X-Git-Url: https://rethought.computer/gitweb//gitweb//git?a=commitdiff_plain;h=9529ebabe8a243bb3bc55531a49f9be4165411a5;p=sorel-lang.git add more complete fib-example --- diff --git a/hylo-lang/.gitignore b/hylo-lang/.gitignore index 7fa3f17..82f7d40 100644 --- a/hylo-lang/.gitignore +++ b/hylo-lang/.gitignore @@ -1,2 +1,4 @@ target qemu/machine +*.o +*.asm diff --git a/hylo-lang/fib-example/compile.sh b/hylo-lang/fib-example/compile.sh new file mode 100644 index 0000000..933ef72 --- /dev/null +++ b/hylo-lang/fib-example/compile.sh @@ -0,0 +1,4 @@ +../target/debug/hyloc fib.hylo > fib.asm +riscv64-unknown-linux-gnu-as -o fib.o fib.asm +riscv64-unknown-linux-gnu-cc -O1 -no-pie -o test fib.o putn.c -nostartfiles +./test diff --git a/hylo-lang/fib-example/fib.hylo b/hylo-lang/fib-example/fib.hylo new file mode 100644 index 0000000..2407f15 --- /dev/null +++ b/hylo-lang/fib-example/fib.hylo @@ -0,0 +1,24 @@ +\ foo bar +: fib + dup + 1 + > + if + dup + 1 - fib + swap + 2 + - + fib + + + endif +; + +0 fib putn drop +1 fib putn drop +2 fib putn drop +3 fib putn drop +4 fib putn drop +5 fib putn drop +6 fib putn drop +7 fib putn drop diff --git a/hylo-lang/fib-example/putn.c b/hylo-lang/fib-example/putn.c new file mode 100644 index 0000000..201050c --- /dev/null +++ b/hylo-lang/fib-example/putn.c @@ -0,0 +1,16 @@ +#include + +extern unsigned long data_stack_end; +register unsigned long * stack_pointer asm("s2"); + +void putn() { + unsigned long * stack_index = &data_stack_end; + printf("stack: "); + while (stack_index != stack_pointer) { + printf("%ld ", *stack_index); + stack_index -= 1; + } + printf("%ld\n", *stack_pointer); +} + +