-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathregbanks_flags_test.psm
232 lines (228 loc) · 4.27 KB
/
regbanks_flags_test.psm
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
;This is a program I will run on
;actual PicoBlaze to test how
;flags behave when the regbank
;changes. Namely, it is possible,
;given what I know, that real
;PicoBlaze doesn't have separate
;flags for each regbank. In that
;case, this test will fail.
;I have started a
;<a href="https://stackoverflow.com/q/76653465/8902065">StackOverflow question about this</a>,
;thus far receiving no response.
;Now follows some boilerplate code
;we use in our Computer Architecture
;classes...
CONSTANT LED_PORT, 00
CONSTANT HEX1_PORT, 01
CONSTANT HEX2_PORT, 02
CONSTANT UART_TX_PORT, 03
CONSTANT UART_RESET_PORT, 04
CONSTANT SW_PORT, 00
CONSTANT BTN_PORT, 01
CONSTANT UART_STATUS_PORT, 02
CONSTANT UART_RX_PORT, 03
; Tx data_present
CONSTANT U_TX_D, 00000001'b
; Tx FIFO half_full
CONSTANT U_TX_H, 00000010'b
; TxFIFO full
CONSTANT U_TX_F, 00000100'b
; Rxdata_present
CONSTANT U_RX_D, 00001000'b
; RxFIFO half_full
CONSTANT U_RX_H, 00010000'b
; RxFIFO full
CONSTANT U_RX_F, 00100000'b
address 0
load s9, "R"
call UART_TX
load s9, "u"
call UART_TX
load s9, "n"
call UART_TX
load s9, "n"
call UART_TX
load s9, "i"
call UART_TX
load s9, "n"
call UART_TX
load s9, "g"
call UART_TX
load s9, " "
;The last line tokenizes correctly
;only as of the version
;<a href="https://sourceforge.net/projects/picoblaze-simulator/files/v2.7/">PicoBlaze_Simulator_in_JS v2.7</a>,
;see <a href="https://github.com/FlatAssembler/PicoBlaze_Simulator_in_JS/issues/5">this GitHub issue</a> for more
;information about that.
call UART_TX
load s9, "t"
call UART_TX
load s9, "h"
call UART_TX
load s9, "e"
call UART_TX
load s9, " "
call UART_TX
load s9, "r"
call UART_TX
load s9, "e"
call UART_TX
load s9, "g"
call UART_TX
load s9, "b"
call UART_TX
load s9, "a"
call UART_TX
load s9, "n"
call UART_TX
load s9, "k"
call UART_TX
load s9, "s"
call UART_TX
load s9, "-"
call UART_TX
load s9, "f"
call UART_TX
load s9, "l"
call UART_TX
load s9, "a"
call UART_TX
load s9, "g"
call UART_TX
load s9, "s"
call UART_TX
load s9, " "
call UART_TX
load s9, "t"
call UART_TX
load s9, "e"
call UART_TX
load s9, "s"
call UART_TX
load s9, "t"
call UART_TX
load s9, "."
call UART_TX
load s9, "."
call UART_TX
load s9, "."
call UART_TX
load s9, " "
call UART_TX
;Now follows the core of the test...
regbank a
load s0, 0
sub s0, 0
regbank b
load s0, 1
sub s0, 0
regbank a
;Now, if flags on PicoBlaze work
;the way I think they do, the zero
;flag will be set.
jump z , success
jump nz, failure
;This point should not be reached...
load s9, "I"
call UART_TX
load s9, "n"
call UART_TX
load s9, "d"
call UART_TX
load s9, "e"
call UART_TX
load s9, "t"
call UART_TX
load s9, "e"
call UART_TX
load s9, "r"
call UART_TX
load s9, "m"
call UART_TX
load s9, "i"
call UART_TX
load s9, "n"
call UART_TX
load s9, "a"
call UART_TX
load s9, "t"
call UART_TX
load s9, "e"
call UART_TX
load s9, "!"
call UART_TX
load s9, a ;New-line character.
;The last line is being highlighted
;incorrectly by the syntax
;highlighter, see <a href="https://github.com/FlatAssembler/PicoBlaze_Simulator_in_JS/issues/6">this GitHub issue</a> for
;more information about that.
;While I don't know how to solve that,
;there does appear to be a simple
;work-around: simply, when `<code>a</code>`
;is a hexadecimal constant, type `<code>0a</code>`
;instead, and it will be highlighted
;correctly.
call UART_TX
load s0, ff
output s0, LED_PORT
jump infinite_loop
success:
load s9, "S"
call UART_TX
load s9, "u"
call UART_TX
load s9, "c"
call UART_TX
load s9, "c"
call UART_TX
load s9, "e"
call UART_TX
load s9, "s"
call UART_TX
load s9, "s"
call UART_TX
load s9, "!"
call UART_TX
load s9, a ;New-line character.
call UART_TX
load s0, aa
output s0, LED_PORT
jump infinite_loop
failure:
load s9, "F"
call UART_TX
load s9, "a"
call UART_TX
load s9, "i"
call UART_TX
load s9, "l"
call UART_TX
load s9, "u"
call UART_TX
load s9, "r"
call UART_TX
load s9, "e"
call UART_TX
load s9, "!"
call UART_TX
load s9, a ;New-line character.
call UART_TX
load s0, 55
output s0, LED_PORT
infinite_loop:
jump infinite_loop
;Once again, some boilerplate code
;we use in our Computer Architecture
;classes...
UART_RX:
INPUT sA, UART_STATUS_PORT
TEST sA, U_RX_D
JUMP Z , UART_RX
INPUT s9, UART_RX_PORT
RETURN
UART_TX:
INPUT sA, UART_STATUS_PORT
TEST sA, U_TX_F
JUMP NZ, UART_TX
OUTPUT s9, UART_TX_PORT
RETURN