aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-31 01:11:54 +0200
committerhachem <im@hachem.wtf>2026-08-31 01:11:54 +0200
commitcf24f576891ece60bdf04928d3c39dd0bbb9b5f6 (patch)
treef0e5492dca4e0c3bbbff256c2c1fa98b15dcfab5 /examples
parent3e20038bbf7206e2270655418d7884ccfe91a4e4 (diff)
feat: add logical_registers
Diffstat (limited to 'examples')
-rw-r--r--examples/logical.hdass19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/logical.hdass b/examples/logical.hdass
new file mode 100644
index 0000000..5e82b42
--- /dev/null
+++ b/examples/logical.hdass
@@ -0,0 +1,19 @@
+[entry: main]
+[enable: logical_registers]
+
+// With the logical_registers extension, r1..r14 name the general-purpose
+// registers (r1 = rax, r2 = rbx, ...) instead of the architecture names.
+// Computes (4 + 3) * 3 = 21 and returns it as the exit status.
+const SYS_EXIT = 60
+
+proc main
+{
+ r1 = 4 // rax
+ r2 = 3 // rbx
+ r1 += r2 // 7
+ r1 *= r2 // 21
+
+ r6 = r1 // rdi = 21 (the exit status)
+ r1 = SYS_EXIT
+ syscall
+}