reorganised code examples
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -28,5 +28,3 @@ fn main() -> u32 {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,4 +48,3 @@ main:
|
||||
call print::print_num
|
||||
pop zero
|
||||
jmp _ret
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
++++++++++++++++++++++++++++++++++++++++++++
|
||||
>++++++++++++++++++++++++++++++++
|
||||
>++++++++++++++++
|
||||
>
|
||||
>+
|
||||
<<
|
||||
[
|
||||
>>
|
||||
>
|
||||
>++++++++++
|
||||
<<
|
||||
[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]
|
||||
>[<+>-]
|
||||
>[-]
|
||||
>>
|
||||
>++++++++++
|
||||
<
|
||||
[->-[>+>>]>[+[-<+>]>+>>]<<<<<]
|
||||
>[-]
|
||||
>>[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]
|
||||
<[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]
|
||||
<<<++++++++++++++++++++++++++++++++++++++++++++++++.[-]
|
||||
<<<<<<<.>.
|
||||
>>[>>+<<-]
|
||||
>[>+<<+>-]
|
||||
>[<+>-]
|
||||
<<<-
|
||||
]
|
||||
<<++...
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user