From 2f91c4127c3e7ba2fd76fde438d444ea1e27d3b3 Mon Sep 17 00:00:00 2001 From: zxq5 Date: Thu, 5 Feb 2026 01:10:31 +0000 Subject: [PATCH] reorganised code examples --- resources/dsa/example.dsa | 16 ++++++++-------- resources/dsa/example.dsc | 2 -- resources/dsa/main.dsa | 1 - {assembler => resources/examples}/brainf.bf | 0 resources/examples/example.c | 11 +++++++++++ 5 files changed, 19 insertions(+), 11 deletions(-) rename {assembler => resources/examples}/brainf.bf (100%) create mode 100644 resources/examples/example.c diff --git a/resources/dsa/example.dsa b/resources/dsa/example.dsa index 07913c1..0d70938 100644 --- a/resources/dsa/example.dsa +++ b/resources/dsa/example.dsa @@ -1,10 +1,10 @@ // GENERATED BY DSC COMPILER -// Generated at 2026-02-04 01:55:11 +// Generated at 2026-02-05 00:42:40 // Imports -include arena: "./lib/memory/arena_alloc.dsa" include print: "./lib/io/print.dsa" +include arena: "./lib/memory/arena_alloc.dsa" // Globals & Reserved Memory @@ -65,8 +65,8 @@ main: pop zero subi bpr 16 rg0 ldw rg0, rg0 // bpr-24: alloc - push rg0 // bpr-24: alloc - push rg4 // bpr-28: ptr2 + push rg4 // bpr-24: ptr2 + push rg0 // bpr-28: alloc push rg0 // push arg 0 call print::print_hex_word pop zero @@ -78,8 +78,8 @@ main: call print::print_hex_word pop zero call print::print_newline - subi bpr 28 rg0 - ldw rg0, rg0 // bpr-36: ptr2 + subi bpr 24 rg0 + ldw rg0, rg0 // bpr-32: ptr2 push rg0 // bpr-36: ptr2 push rg0 // push arg 0 call print::print_hex_word @@ -110,8 +110,8 @@ main: call print::print_num pop zero call print::print_newline - db str_12: "end" - lwi str_12, rg5 + db str_1: "end" + lwi str_1, rg5 push rg5 // push arg 0 call print::println pop zero diff --git a/resources/dsa/example.dsc b/resources/dsa/example.dsc index 0b49b0c..47ebd9d 100644 --- a/resources/dsa/example.dsc +++ b/resources/dsa/example.dsc @@ -28,5 +28,3 @@ fn main() -> u32 { return 0; } - - diff --git a/resources/dsa/main.dsa b/resources/dsa/main.dsa index 2029c7a..cf0559d 100644 --- a/resources/dsa/main.dsa +++ b/resources/dsa/main.dsa @@ -48,4 +48,3 @@ main: call print::print_num pop zero jmp _ret - diff --git a/assembler/brainf.bf b/resources/examples/brainf.bf similarity index 100% rename from assembler/brainf.bf rename to resources/examples/brainf.bf diff --git a/resources/examples/example.c b/resources/examples/example.c new file mode 100644 index 0000000..2cc3308 --- /dev/null +++ b/resources/examples/example.c @@ -0,0 +1,11 @@ +int factorial(int n) { + if (n <= 1) { + return 1; + } + return n * factorial(n - 1); +} + +int main() { + int res = factorial(3); + return res; +}