about summary refs log tree commit diff stats
path: root/examples/ex1.subx
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ex1.subx')
-rw-r--r--examples/ex1.subx21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/ex1.subx b/examples/ex1.subx
new file mode 100644
index 00000000..0aca40f8
--- /dev/null
+++ b/examples/ex1.subx
@@ -0,0 +1,21 @@
+# First program: same as https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
+# Just return 42.
+#
+# To run (from the subx directory):
+#   $ ./subx translate examples/ex1.2.subx -o examples/ex1
+#   $ ./subx run examples/ex1
+# Expected result:
+#   $ echo $?
+#   42
+
+== code 0x09000000
+
+Entry:
+# syscall(exit, 42)
+bb/copy-to-EBX  2a/imm32  # 42 in hex
+b8/copy-to-EAX  1/imm32/exit
+cd/syscall  0x80/imm8
+
+== data 0x0a000000
+
+# . . vim:nowrap:textwidth=0