aboutsummaryrefslogtreecommitdiff
path: root/examples/circle.hdass
diff options
context:
space:
mode:
Diffstat (limited to 'examples/circle.hdass')
-rw-r--r--examples/circle.hdass17
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/circle.hdass b/examples/circle.hdass
new file mode 100644
index 0000000..8a4edaa
--- /dev/null
+++ b/examples/circle.hdass
@@ -0,0 +1,17 @@
+[entry: main]
+
+// Floating-point math on the SSE registers. Computes the area of a circle
+// (pi * r * r) with r = 3, then exits with the truncated result (28).
+const SYS_EXIT = 60
+
+proc main
+{
+ xmm0 = 3.0 // radius
+ xmm0 *= xmm0 // r * r = 9.0
+ xmm1 = 3.14159 // pi
+ xmm0 *= xmm1 // area ~= 28.27
+
+ rdi = xmm0 // truncate to int -> 28
+ rax = SYS_EXIT
+ syscall
+}