aboutsummaryrefslogtreecommitdiff
path: root/tests/stack_machine_old_load_store/instructions.s.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stack_machine_old_load_store/instructions.s.tcl')
-rwxr-xr-xtests/stack_machine_old_load_store/instructions.s.tcl109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/stack_machine_old_load_store/instructions.s.tcl b/tests/stack_machine_old_load_store/instructions.s.tcl
new file mode 100755
index 0000000..13cabcb
--- /dev/null
+++ b/tests/stack_machine_old_load_store/instructions.s.tcl
@@ -0,0 +1,109 @@
+#!/usr/bin/env tclsh
+
+source tclasm.tcl
+
+### another simple test - set stack to h7FFFC, store 4 numbers on stack (only 2
+### will really get written to memory, other 2 will remain in r0 and r1),
+### then pop all the numbers and write them to h57574
+
+
+## set sp to h7FFFC (actually, lowest bit is assumed 0 and not stored there)
+# 7777 FFFF F
+# bits 19:11 of h7FFFC are 0111 1111 1
+_immediate im=b011111111
+# FFf FFFF CCCC
+# bits 10:0 of h7FFFC are 111 1111 1100
+_immediate im<<=b11111111100
+
+_extended_instruction set_sp
+
+## get value h01010202 into r1
+# 0000 1111 00
+# bits 31:22 of h01010202 are 0000 0001 00
+_immediate im<<=b0000000100
+# 00 1111 0000 2
+# bits 21:11 of h01010202 are 00 0001 0000 0
+_immediate im<<=b00000100000
+# 222 0000 2222
+# bits 10:0 of h01010202 are 010 0000 0010
+_exchange_im im<<=b01000000010
+
+## get value h03030404 into r1
+stack down
+# 0000 3333 00
+# bits 31:22 of h03030404 are 0000 0011 00
+_immediate im<<=b0000001100
+# 00 3333 0000 4
+# bits 21:11 of h03030404 are 00 0011 0000 0
+_immediate im<<=b00001100000
+# 444 0000 4444
+# bits 10:0 of h03030404 are 100 0000 0100
+_exchange_im im<<=b10000000100
+
+## get value h05050606 into r1
+stack down
+# 0000 5555 00
+# bits 31:22 of h05050606 are 0000 0101 00
+_immediate im<<=b0000010100
+# 00 5555 0000 6
+# bits 21:11 of h05050606 are 00 0101 0000 0
+_immediate im<<=b00010100000
+# 666 0000 6666
+# bits 10:0 of h05050606 are 110 0000 0110
+_exchange_im im<<=b11000000110
+
+## get value h07070808 into r1
+stack down
+# 0000 7777 00
+# bits 31:22 of h07070808 are 0000 0111 00
+_immediate im<<=b0000011100
+# 00 7777 0000 8
+# bits 21:11 of h07070808 are 00 0111 0000 1
+_immediate im<<=b00011100001
+# 888 0000 8888
+# bits 10:0 of h07070808 are 000 0000 1000
+_exchange_im im<<=b00000001000
+
+## get address h57574 into im and write r1 to that address
+# 5555 7777 5
+# bits 19:11 of h57574 are 0101 0111 0
+_immediate im=b010101110
+# 555 7777 4444
+# bits 10:0 of h57574 are 101 0111 0100
+store im<<=b10101110100
+
+# get r0 to r1
+stack up
+
+## get address h57578 into im and write r1 to that address
+# 5555 7777 5
+# bits 19:11 of h57578 are 0101 0111 0
+_immediate im=b010101110
+# 555 7777 8888
+# bits 10:0 of h57578 are 101 0111 1000
+store im<<=b10101111000
+
+# get r0 to r1
+stack up
+
+## get address h5757C into im and write r1 to that address
+# 5555 7777 5
+# bits 19:11 of h5757C are 0101 0111 0
+_immediate im=b010101110
+# 555 7777 CCCC
+# bits 10:0 of h5757C are 101 0111 1100
+store im<<=b10101111100
+
+# get r0 to r1
+stack up
+
+## get address h57580 into im and write r1 to that address
+# 5555 7777 5
+# bits 19:11 of h57580 are 0101 0111 0
+_immediate im=b010101110
+# 555 8888 0000
+# bits 10:0 of h57580 are 101 1000 0000
+store im<<=b10110000000
+
+## finish test
+halt