about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2025-01-19 11:17:47 -0500
committerelioat <elioat@tilde.institute>2025-01-19 11:17:47 -0500
commit6e1e7c2731f5eb429c7e9e0eb3bfc00aedaa3bf4 (patch)
tree373ea6acffc42272f85dfa1e71fc9c07359203dd
parent960044a20058f16e738780dd10b1b89ff68a97ca (diff)
downloadtour-6e1e7c2731f5eb429c7e9e0eb3bfc00aedaa3bf4.tar.gz
*
-rwxr-xr-xawk/vm/vm.awk6
1 files changed, 3 insertions, 3 deletions
diff --git a/awk/vm/vm.awk b/awk/vm/vm.awk
index a130d88..9467661 100755
--- a/awk/vm/vm.awk
+++ b/awk/vm/vm.awk
@@ -211,7 +211,8 @@ function execute_instruction(inst) {
     if (inst == "BYE")      { exit 0 } # not really in the minimal spec as set out by Chuck Moore, but useful for a graceful exit.
     if (inst == "DROP")     { op_drop(); return }
     if (inst == "DUP")      { op_dup(); return }
-    if (inst == "OVER")     { op_over(); return }
+    if (inst == "OVER")     { op_over(); return } # copy second item to top of stack
+    if (inst == "SWAP")     { op_swap(); return } # swap top two stack items
     if (inst == "+")        { op_add(); return }
     if (inst == "AND")      { op_and(); return }
     if (inst == "XOR")      { op_xor(); return }
@@ -231,8 +232,7 @@ function execute_instruction(inst) {
     if (inst == "@P")       { op_fetchp(); return } # fetch from memory at P
     if (inst == "!P")       { op_storep(); return } # store to memory at P
     if (inst == ".")        { return }  # NO-OP
-    if (inst == "SHOW")     { print_state(); return }
-    if (inst == "SWAP")     { op_swap(); return }
+    if (inst == "SHOW")     { print_state(); return } # show state info
     
     print "Unknown instruction: " inst > "/dev/stderr"
     exit 1