blob: 6244c5135589523015424d9afba666aecbef6a97 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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."
|