aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-10 04:42:33 +0200
committerhachem <im@hachem.wtf>2026-09-10 04:42:33 +0200
commitbf157cf09b8b0888c54a165b887309a4e801f608 (patch)
treeb72735972c2edb46c9324a74aeda9ff46c64682a /examples
parentbf3bd19f79936fa519a5285701763da58935592a (diff)
feat: add aarch64 as target
Diffstat (limited to 'examples')
-rw-r--r--examples/arm64/exit.hdass14
-rw-r--r--examples/arm64/sum.hdass19
2 files changed, 33 insertions, 0 deletions
diff --git a/examples/arm64/exit.hdass b/examples/arm64/exit.hdass
new file mode 100644
index 0000000..a86e5e2
--- /dev/null
+++ b/examples/arm64/exit.hdass
@@ -0,0 +1,14 @@
+[entry: main]
+[enable: logical_registers]
+
+// Exits with status 42 on AArch64 Linux. Logical registers map r1 -> x0 and
+// r9 -> x8, so the exit code goes in x0 and the syscall number in x8; `syscall`
+// lowers to `svc #0`.
+const SYS_EXIT = 93
+
+proc main
+{
+ r1 = 42 // x0 = exit code
+ r9 = SYS_EXIT // x8 = syscall number
+ syscall
+}
diff --git a/examples/arm64/sum.hdass b/examples/arm64/sum.hdass
new file mode 100644
index 0000000..85820c9
--- /dev/null
+++ b/examples/arm64/sum.hdass
@@ -0,0 +1,19 @@
+[entry: main]
+[enable: logical_registers]
+
+// Sums 5 + 4 + 3 + 2 + 1 = 15 with a named countdown loop, returns it as the
+// exit status. Shows three-operand arithmetic (r1 = r1 + r2 -> add x0, x0, x1).
+const SYS_EXIT = 93
+
+proc main
+{
+ r1 = 0
+ r2 = 5
+ while .countdown r2 > 0
+ {
+ r1 = r1 + r2
+ r2 = r2 - 1
+ }
+ r9 = SYS_EXIT
+ syscall
+}