about summary refs log tree commit diff stats
path: root/awk/vm/vm_tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'awk/vm/vm_tests.sh')
-rwxr-xr-xawk/vm/vm_tests.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/awk/vm/vm_tests.sh b/awk/vm/vm_tests.sh
new file mode 100755
index 0000000..6244c51
--- /dev/null
+++ b/awk/vm/vm_tests.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+echo "Running VM tests..."
+echo
+
+echo "Test 1: Basic register A operations"
+echo "42 A! A A     # Store 42 in A, then read A twice" | awk -f vm.awk
+echo
+
+echo "Test 2: Register A and B with memory operations"
+echo "100 A! 200 B! 42 @B     # Store 100 in A, 200 in B, read from B's address" | awk -f vm.awk
+echo
+
+echo "Test 3: Sequential memory operations using P register"
+echo "0 !P 1 !+ 2 !+ 3 !+ 4 !+ 5 !+     # Store 1-5 sequentially using P" | awk -f vm.awk
+echo "0 !P @+ @+ @+ @+ @+     # Read back values using P" | awk -f vm.awk
+echo
+
+echo "Test 4: Complex register manipulation"
+echo "42 A! A DUP B! @B     # Store 42 in A, copy to B, read via B" | awk -f vm.awk
+echo
+
+echo "Test 5: Register arithmetic"
+echo "5 A! 3 B! A @B +     # Store 5 in A, 3 in B, add A + mem[B]" | awk -f vm.awk
+echo
+
+echo "Test 6: Memory pointer operations"
+echo "42 0 ! 1 !P @P     # Store 42 at addr 0, point P to 1, read P" | awk -f vm.awk
+echo
+
+echo "Test 7: Register and memory interaction"
+echo "10 A! 20 B! A @B !     # Store A's value at B's address" | awk -f vm.awk
+echo "@B     # Read from memory at B's address" | awk -f vm.awk
+echo
+
+echo "Test 8: Demonstrating B! vs !B"
+echo "100 B!     # Set B register to 100" | awk -f vm.awk
+echo "42 !B      # Store 42 at memory location 100" | awk -f vm.awk
+echo "@B         # Read from memory location 100" | awk -f vm.awk
+echo
+
+echo "Tests completed." 
\ No newline at end of file