diff options
| author | hachem <im@hachem.wtf> | 2026-09-09 05:14:44 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-09 05:14:44 +0200 |
| commit | 8b76d35b0a045e0a3277be422513b938ef33dcce (patch) | |
| tree | b876d92ba3afb810e38f3f83792fc3fb849dd457 /examples | |
| parent | b9eff51ee157b22d8fa46aeecac7b95d5ed345d9 (diff) | |
feat: fasm backend
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/fibonacci.hdass | 16 | ||||
| -rw-r--r-- | examples/loop_sum.hdass | 10 | ||||
| -rw-r--r-- | examples/records.hdass | 6 |
3 files changed, 17 insertions, 15 deletions
diff --git a/examples/fibonacci.hdass b/examples/fibonacci.hdass index 9436580..47224fb 100644 --- a/examples/fibonacci.hdass +++ b/examples/fibonacci.hdass @@ -45,16 +45,16 @@ proc main r13 = 1 r15 = 10 // syscall clobbers rcx/r11, so keep the counter in r15 -loop: - print_number(r12) + while .sequence r15 > 0 + { + print_number(r12) - rax = r12 - r12 = r13 - r13 += rax + rax = r12 + r12 = r13 + r13 += rax - r15 -= 1 - if r15 != 0 - goto loop + r15 -= 1 + } rax = SYS_EXIT rdi = 0 diff --git a/examples/loop_sum.hdass b/examples/loop_sum.hdass index 2427b17..130f055 100644 --- a/examples/loop_sum.hdass +++ b/examples/loop_sum.hdass @@ -8,11 +8,11 @@ proc main rbx = 0 // running total rcx = 5 // counter -loop: - rbx += rcx - rcx -= 1 - if rcx != 0 - goto loop + while .countdown rcx > 0 + { + rbx += rcx + rcx -= 1 + } rdi = rbx rax = SYS_EXIT diff --git a/examples/records.hdass b/examples/records.hdass index f8553d6..8e87a4c 100644 --- a/examples/records.hdass +++ b/examples/records.hdass @@ -22,15 +22,17 @@ proc main stack pair[Pair.size] rsi = pair + rsi += Pair.a rbx = 40 - ^rsi = rbx // pair.a (offset 0) + ^rsi = rbx // pair.a rsi = pair rsi += Pair.b rcx = Status.Fail // 2 - ^rsi = rcx // pair.b (offset 8) + ^rsi = rcx // pair.b rsi = pair + rsi += Pair.a rdi = ^rsi // load a = 40 rsi = pair rsi += Pair.b |
