aboutsummaryrefslogtreecommitdiff
path: root/tests/stack_machine_old_load_store/instructions.s.tcl
blob: 40a657e50eaf0b8fc6207c2779e0990567bdf70e (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env tclsh

source tclasm_old.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