Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
5 files changed, 49 insertions, 0 deletions
-rw-r--r--README.md4
-rw-r--r--detailed_demo.mp4bin0 -> 2933407 bytes
-rw-r--r--examples/example1.s14
-rw-r--r--examples/example2.s13
-rw-r--r--examples/example3.s18
diff --git a/README.md b/README.md
index 89b9cf6..0a2ddde 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,10 @@ This is a small [SUBLEQ](https://en.wikipedia.org/wiki/One-instruction_set_compu
More information can be found in the READMEs of the appropriate crates.
Some example programs are provided in `examples`.
+## Detailed demo
+
+![](detailed_demo.mp4)
+
## Usage
Install `cargo` on your system.
diff --git a/detailed_demo.mp4 b/detailed_demo.mp4
new file mode 100644
index 0000000..3f43ef1
--- /dev/null
+++ b/detailed_demo.mp4
Binary files differ
diff --git a/examples/example1.s b/examples/example1.s
new file mode 100644
index 0000000..b1e38ed
--- /dev/null
+++ b/examples/example1.s
@@ -0,0 +1,14 @@
+; Assembler produces binary files, containing series of big-endian i64 values
+
+; Arguments in the form "%NUMBER" signify absolute addresses
+
+subleq %10, %11, %12
+
+; Higher-order instructions convert to a series of subleq instructions
+; https://en.wikipedia.org/wiki/One-instruction_set_computer#Synthesized_instructions
+
+jmp %20 ; subleq %0, %0, %20
+
+add %39, %41 ; subleq %39, %0, next_address
+ ; subleq %0, %41, next_address
+ ; subleq %0, %0, next_address
diff --git a/examples/example2.s b/examples/example2.s
new file mode 100644
index 0000000..b0213b5
--- /dev/null
+++ b/examples/example2.s
@@ -0,0 +1,13 @@
+; Variables allow "aliases" for arguments
+
+first = %1
+subleq first, %2, last
+last = %3
+
+; Higher-order instructions can also take in numeric constants
+; Constants are automatically stored at the start of memory,
+; and all references are replaced with that address
+
+num = 50
+add 60, num ; num += 60
+add num, 70 ; address_of(70) += num
diff --git a/examples/example3.s b/examples/example3.s
new file mode 100644
index 0000000..fa65c4b
--- /dev/null
+++ b/examples/example3.s
@@ -0,0 +1,18 @@
+; Tonkobali assembler will assemble this program into a series of i64 values
+; Every instruction here is composed of SUBLEQ instructions!
+
+condition = 0
+modifier = 5
+operand = 10
+jmp main ; Start execution from main
+
+label_add: add modifier, operand ; operand += modifier
+ rts ; return from subroutine
+label_sub: sub modifier, operand ; operand -= modifier
+ rts ; return from subroutine
+
+main: beq condition, do_add ; if condition == 0 goto do_add
+do_sub: jsr label_sub ; else enter label_sub subroutine
+ jmp continue
+do_add: jsr label_add ; enter label_add subroutine
+continue: mov operand, %1000 ; Mem[1000] = operand