aboutsummaryrefslogtreecommitdiff
path: root/tests/stack_machine_load_store
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stack_machine_load_store')
-rwxr-xr-xtests/stack_machine_load_store/instructions.s.tcl55
l---------tests/stack_machine_load_store/test.v1
-rw-r--r--tests/stack_machine_load_store/words_to_verify.mem12
3 files changed, 68 insertions, 0 deletions
diff --git a/tests/stack_machine_load_store/instructions.s.tcl b/tests/stack_machine_load_store/instructions.s.tcl
new file mode 100755
index 0000000..4d6da2a
--- /dev/null
+++ b/tests/stack_machine_load_store/instructions.s.tcl
@@ -0,0 +1,55 @@
+#!/usr/bin/env tclsh
+
+source tclasm.tcl
+
+### set stack to 0, store 4 numbers (h2B, h3B, h4B and h5B) at addresses
+### h000002, h000012, h000022 and h000032 and load them back to stack (only 2
+### will really get written to stack's memory, other 2 will remain in r0 and
+### r1). Then, write them to h000008, h000018, h000028 and h000038.
+### At the and use operand-addressing to load back value h3B from h000018
+### (expressed as h000017 in im + h000001 in operand) and store it to h1FFFE2
+### (expressed as h1FFFC0 in im + h000022 in operand).
+
+### we're using small (in absolute) numbers and addresses for simplicity
+
+## set up stack
+_set_sp 0
+
+## get number h2B into r1, and store it - repeat for other 3 numbers;
+_const h2B
+_store h02
+
+_const h3B
+_store h12
+
+_const h2A
+_store h22
+
+_const h3A
+_store h32
+
+## get numbers back on stack
+_load h02
+_load h12
+_load h22
+_load h32
+
+## store copies to new locations
+_store h38
+_store h28
+_store h18
+_store h08
+
+## prepare operand for later store operation
+_const h22
+
+## use operand addressing to load back value from h000018
+_const h01
+_load+ h17
+
+## use operand addressing to trove value to h1FFFE2 = h1FFFC0 + h000022
+# immediate value gets sign-extended here!
+_store+ h40
+
+## finish test
+halt
diff --git a/tests/stack_machine_load_store/test.v b/tests/stack_machine_load_store/test.v
new file mode 120000
index 0000000..f5b6a59
--- /dev/null
+++ b/tests/stack_machine_load_store/test.v
@@ -0,0 +1 @@
+../stack_machine_store/test.v \ No newline at end of file
diff --git a/tests/stack_machine_load_store/words_to_verify.mem b/tests/stack_machine_load_store/words_to_verify.mem
new file mode 100644
index 0000000..c0b0d56
--- /dev/null
+++ b/tests/stack_machine_load_store/words_to_verify.mem
@@ -0,0 +1,12 @@
+// address value
+ 02 2B
+ 12 3B
+ 22 2A
+ 32 3A
+
+ 08 2B
+ 18 3B
+ 28 2A
+ 38 3A
+
+ 1FFFE2 3B