aboutsummaryrefslogtreecommitdiff
path: root/examples/loop_sum.hdass
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-30 21:21:53 +0200
committerhachem <im@hachem.wtf>2026-08-30 21:21:53 +0200
commit294777178f9203283364f3e672569becb4dd1e7c (patch)
treeb97447843d06f8f63a01505c85e6e9f9e804b797 /examples/loop_sum.hdass
parent13704a1df5c15af7163cc7764b0aeebc81ad2bdd (diff)
test: add automated docker testing for the whole test suite
Diffstat (limited to 'examples/loop_sum.hdass')
-rw-r--r--examples/loop_sum.hdass18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/loop_sum.hdass b/examples/loop_sum.hdass
new file mode 100644
index 0000000..bb8d115
--- /dev/null
+++ b/examples/loop_sum.hdass
@@ -0,0 +1,18 @@
+// Sums 5 + 4 + 3 + 2 + 1 = 15 with a countdown loop, returns it as the status.
+const SYS_EXIT = 60
+
+proc main
+{
+ rbx = 0 // running total
+ rcx = 5 // counter
+
+loop:
+ rbx += rcx
+ rcx -= 1
+ if rcx != 0
+ goto loop
+
+ rdi = rbx
+ rax = SYS_EXIT
+ syscall
+}