aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/fibonacci.hdass16
-rw-r--r--examples/loop_sum.hdass10
-rw-r--r--examples/records.hdass6
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