Website Summary Files Commits Branches @commit @diff @stats
path: root / vm
diff options
context:
space:
mode:
Commitbb8c3f02d7c3c318e67575167886de1da123b95a (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-02-16 13:33:56 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-02-16 13:33:56 +0200
Files1a8a914cedb85c9ee007cdd4e5d6a9dbf1b368ed /vm
tonkobali-bb8c3f02d7c3c318e67575167886de1da123b95a.tar
tonkobali-bb8c3f02d7c3c318e67575167886de1da123b95a.tar.gz
tonkobali-bb8c3f02d7c3c318e67575167886de1da123b95a.zip
Parentba21ce6a6337d42f2359db6b0911d6eb1e74c094 (diff)
feat: Add rough documentation
1 files changed, 54 insertions, 0 deletions
-rw-r--r--vm/README.md54
diff --git a/vm/README.md b/vm/README.md
new file mode 100644
index 0000000..e488993
--- /dev/null
+++ b/vm/README.md
@@ -0,0 +1,54 @@
+# tonkobali virtual machine
+
+This is a virtual machine which executes SUBLEQ instructions.
+The idea is we have a vector of words (i64) which represents our entire memory.
+We use a certain amount of addresses in the beginning of this memory for our purposes.
+
+Since we have only one instruction we only store data, no opcodes.
+When the virtual machine program counter is at a certain location, the next three values from memory are read and SUBLEQ is executed with those values as arguments.
+This continues until the program jumps to address 0, when we reach a "HALTED" state.
+
+## TUI
+
+Once started, you may enter commands for the VM, and to the left of your cursor you'll see vertical bars.
+If the contents of these bars is empty, it means the machine is executing instructions.
+If the contents are "HALTED", the machine has stopped executing.
+If the contents are "STEP", the VM is in single-step mode.
+
+All commands and their meaning can be found by issuing `help`:
+
+```
+<ADDRESS> is a usize constant
+<VALUE> is a Word (i64) constant
+
+Multiple 'Memory IO' commands may be put on a single line, when
+separated by spaces
+
+General commands:
+ h, ?, help This menu
+ q, e, quit, exit Stop and exit the virtual machine
+
+Normal execution:
+ r, run <ADDRESS> Start normal execution at ADDRESS
+ Only applicable when 'HALTED'
+
+Single-step execution:
+ s, single <ADDRESS> Start single-step execution at ADDRESS
+ c, continue Resume normal execution
+ Only applicable when in 'STEP' mode
+ n, next Execute next instruction
+ Only applicable when in 'STEP' mode
+
+Memory IO:
+ <ADDRESS> Print the value at the location
+ <ADDRESS>.<ADDRESS> Print the values between the locations
+ (inclusive range)
+ <ADDRESS>:<VALUE> Set value at ADDRESS to VALUE
+```
+
+Single-step mode allows you to execute only a single instruction at a time.
+After each execution the arguments to SUBLEQ are printed.
+At any point you may manipulate the memory.
+Then you can execute the next single instruction (with `next`) or resume normal execution (with `continue`).
+
+The memory io commands are inspired from Steve Wozniak's wozmon.