aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tc100_instructions/stw_operators.awl
blob: 8130eb2825506745f371f6482586d1c01ae05593 (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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
FUNCTION FC 1 : VOID
BEGIN
	// Store the status word in MW 0.
	L	STW
	T	MW 0

	// Compare U BIE to the actual STW bit.
	U		BIE
	=		M 10.0
	__ASSERT==	M 10.0,	M 0.0 // BIE
	__ASSERT==	M 10.0, __STW BIE

	// Compare U OV to the actual STW bit.
	U		OV
	=		M 10.0
	__ASSERT==	M 10.0,	M 1.5 // OV
	__ASSERT==	M 10.0, __STW OV

	// Compare U OS to the actual STW bit.
	U		OS
	=		M 10.0
	__ASSERT==	M 10.0,	M 1.4 // OS
	__ASSERT==	M 10.0, __STW OS

	// Compare U ==0 to the actual STW bits.
	U		==0
	=		M 10.0
	UN		M 1.6 // A0
	UN		M 1.7 // A1
	=		M 10.1
	UN		__STW A0
	UN		__STW A1
	=		M 10.2
	__ASSERT==	M 10.0,	M 10.1
	__ASSERT==	M 10.0,	M 10.2

	// Compare U <>0 to the actual STW bits.
	U		<>0
	=		M 10.0
	O		M 1.6 // A0
	O		M 1.7 // A1
	=		M 10.1
	O		__STW A0
	O		__STW A1
	=		M 10.2
	__ASSERT==	M 10.0,	M 10.1
	__ASSERT==	M 10.0,	M 10.2

	// Compare U >0 to the actual STW bits.
	U		>0
	=		M 10.0
	UN		M 1.6 // A0
	U		M 1.7 // A1
	=		M 10.1
	UN		__STW A0
	U		__STW A1
	=		M 10.2
	__ASSERT==	M 10.0,	M 10.1
	__ASSERT==	M 10.0,	M 10.2

	// Compare U <0 to the actual STW bits.
	U		<0
	=		M 10.0
	U		M 1.6 // A0
	UN		M 1.7 // A1
	=		M 10.1
	U		__STW A0
	UN		__STW A1
	=		M 10.2
	__ASSERT==	M 10.0,	M 10.1
	__ASSERT==	M 10.0,	M 10.2

	// Compare U >=0 to the actual STW bits.
	U		>=0
	=		M 10.0
	UN		M 1.6 // A0
	=		M 10.1
	UN		__STW A0
	=		M 10.2
	__ASSERT==	M 10.0,	M 10.1
	__ASSERT==	M 10.0,	M 10.2

	// Compare U <=0 to the actual STW bits.
	U		<=0
	=		M 10.0
	UN		M 1.7 // A1
	=		M 10.1
	UN		__STW A1
	=		M 10.2
	__ASSERT==	M 10.0,	M 10.1
	__ASSERT==	M 10.0,	M 10.2

	// Compare U UO to the actual STW bits.
	U		UO
	=		M 10.0
	U		M 1.6 // A0
	U		M 1.7 // A1
	=		M 10.1
	U		__STW A0
	U		__STW A1
	=		M 10.2
	__ASSERT==	M 10.0,	M 10.1
	__ASSERT==	M 10.0,	M 10.2
END_FUNCTION


ORGANIZATION_BLOCK OB 1
BEGIN
	// Test STW=0
	__STWRST
	__ASSERT==	BIE,	0
	__ASSERT==	OV,	0
	__ASSERT==	OS,	0
	__ASSERT==	==0,	1
	__ASSERT==	<>0,	0
	__ASSERT==	>0,	0
	__ASSERT==	<0,	0
	__ASSERT==	>=0,	1
	__ASSERT==	<=0,	1
	__ASSERT==	UO,	0
	CALL		FC 1


	// Test zero
	__STWRST
	L		0
	L		0
	+I
	__ASSERT==	BIE,	0
	__ASSERT==	OV,	0
	__ASSERT==	OS,	0
	__ASSERT==	==0,	1
	__ASSERT==	<>0,	0
	__ASSERT==	>0,	0
	__ASSERT==	<0,	0
	__ASSERT==	>=0,	1
	__ASSERT==	<=0,	1
	__ASSERT==	UO,	0
	CALL		FC 1


	// Test positive
	__STWRST
	L		0
	L		1
	+I
	__ASSERT==	BIE,	0
	__ASSERT==	OV,	0
	__ASSERT==	OS,	0
	__ASSERT==	==0,	0
	__ASSERT==	<>0,	1
	__ASSERT==	>0,	1
	__ASSERT==	<0,	0
	__ASSERT==	>=0,	1
	__ASSERT==	<=0,	0
	__ASSERT==	UO,	0
	CALL		FC 1


	// Test negative
	__STWRST
	L		0
	L		1
	-I
	__ASSERT==	BIE,	0
	__ASSERT==	OV,	0
	__ASSERT==	OS,	0
	__ASSERT==	==0,	0
	__ASSERT==	<>0,	1
	__ASSERT==	>0,	0
	__ASSERT==	<0,	1
	__ASSERT==	>=0,	0
	__ASSERT==	<=0,	1
	__ASSERT==	UO,	0
	CALL		FC 1


	// Test overflow (OV)
	__STWRST
	L		32767
	L		1
	+I
	__ASSERT==	BIE,	0
	__ASSERT==	OV,	1
	__ASSERT==	OS,	1
	__ASSERT==	==0,	0
	__ASSERT==	<>0,	1
	__ASSERT==	>0,	0
	__ASSERT==	<0,	1
	__ASSERT==	>=0,	0
	__ASSERT==	<=0,	1
	__ASSERT==	UO,	0
	CALL		FC 1


	// Test overflow (OS)
	__STWRST
	L		32767
	L		1
	+I
	L		1
	L		2
	+I
	__ASSERT==	BIE,	0
	__ASSERT==	OV,	0
	__ASSERT==	OS,	1
	__ASSERT==	==0,	0
	__ASSERT==	<>0,	1
	__ASSERT==	>0,	1
	__ASSERT==	<0,	0
	__ASSERT==	>=0,	1
	__ASSERT==	<=0,	0
	__ASSERT==	UO,	0
	CALL		FC 1


	// Test BIE
	__STWRST
	SET
	SAVE
	__ASSERT==	BIE,	1
	__ASSERT==	OV,	0
	__ASSERT==	OS,	0
	__ASSERT==	==0,	1
	__ASSERT==	<>0,	0
	__ASSERT==	>0,	0
	__ASSERT==	<0,	0
	__ASSERT==	>=0,	1
	__ASSERT==	<=0,	1
	__ASSERT==	UO,	0
	CALL		FC 1


	// Test division by zero (UO)
	__STWRST
	L		1
	L		0
	/I
	__ASSERT==	BIE,	0
	__ASSERT==	OV,	1
	__ASSERT==	OS,	1
	__ASSERT==	==0,	0
	__ASSERT==	<>0,	1
	__ASSERT==	>0,	0
	__ASSERT==	<0,	0
	__ASSERT==	>=0,	0
	__ASSERT==	<=0,	0
	__ASSERT==	UO,	1
	CALL		FC 1


	CALL SFC 46 // STOP CPU
END_ORGANIZATION_BLOCK
bues.ch cgit interface