|
4 | 4 |
|
5 | 5 | # MIT License
|
6 | 6 | #
|
7 |
| -# Copyright (c) 2019 corax89, 2023 Timendus |
| 7 | +# Copyright (c) 2019 corax89, 2023,2024 Timendus |
8 | 8 | #
|
9 | 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy
|
10 | 10 | # of this software and associated documentation files (the "Software"), to deal
|
|
32 | 32 | :macro drawop A B {
|
33 | 33 | i := A
|
34 | 34 | sprite x0 y 4
|
| 35 | + |
35 | 36 | i := B
|
36 | 37 | sprite x1 y 4
|
37 | 38 | }
|
38 | 39 |
|
39 | 40 | : test-2X-0E
|
40 | 41 | v0 := 1
|
41 | 42 | return
|
| 43 | + # These opcodes will run if the interpreter doesn't have return (00EE) implemented: |
42 | 44 | v0 := 2
|
43 | 45 | jump test-2X-0E-hard-return
|
44 | 46 |
|
45 | 47 | : main
|
46 | 48 | clear
|
| 49 | + |
| 50 | + # Display current version |
47 | 51 | x0 := 50
|
48 | 52 | y := 26
|
49 | 53 | i := version-0-0
|
|
52 | 56 | i := version-1-0
|
53 | 57 | sprite x0 y 4
|
54 | 58 |
|
| 59 | + # Show output in the first column |
55 | 60 | x0 := 2
|
56 | 61 | x1 := 6
|
57 | 62 | x2 := 11
|
58 | 63 | y := 1
|
| 64 | + |
| 65 | +################# |
| 66 | +# Test 3xNN |
| 67 | + |
59 | 68 | v5 := 42
|
60 | 69 | v6 := 43
|
61 |
| - |
62 |
| - #test 3x |
63 | 70 | drawop im3 imX
|
64 | 71 | i := image-ok
|
65 | 72 | if v6 != 43 then i := image-no
|
66 | 73 | sprite x2 y 4
|
67 | 74 |
|
68 |
| - #test 4x |
| 75 | +################# |
| 76 | +# Test 4xNN |
| 77 | + |
69 | 78 | y := 6
|
70 | 79 | drawop im4 imX
|
71 | 80 | i := image-no
|
72 | 81 | if v5 == 42 then i := image-ok
|
73 | 82 | sprite x2 y 4
|
74 | 83 |
|
75 |
| - #test 5x |
| 84 | +################# |
| 85 | +# Test 5xy0 |
| 86 | + |
76 | 87 | y := 11
|
77 | 88 | drawop im5 imX
|
78 | 89 | i := image-no
|
79 | 90 | if v5 != v6 then i := image-ok
|
80 | 91 | sprite x2 y 4
|
81 | 92 |
|
82 |
| - #test 7x |
| 93 | +################# |
| 94 | +# Test 7xNN |
| 95 | + |
83 | 96 | y := 16
|
84 | 97 | drawop im7 imX
|
85 | 98 | i := image-no
|
86 | 99 | v6 += 255
|
87 | 100 | if v6 == 42 then i := image-ok
|
88 | 101 | sprite x2 y 4
|
89 | 102 |
|
90 |
| - #test 9x |
| 103 | +################# |
| 104 | +# Test 9xy0 |
| 105 | + |
91 | 106 | y += 5
|
92 | 107 | drawop im9 imX
|
93 | 108 | i := image-no
|
94 | 109 | if v5 == v6 then i := image-ok
|
95 | 110 | sprite x2 y 4
|
96 | 111 |
|
97 |
| - #test 1x |
| 112 | +################# |
| 113 | +# Test 1NNN (displayed as 1X) |
| 114 | + |
98 | 115 | y += 5
|
99 | 116 | drawop im1 imX
|
100 | 117 | i := image-ok
|
101 |
| - jump test1x |
| 118 | + jump test-1X-pass |
102 | 119 | i := image-no
|
103 |
| -: test1x |
| 120 | +: test-1X-pass |
104 | 121 | sprite x2 y 4
|
105 | 122 |
|
106 |
| - # Test calling and returning from subroutines (2NNN and 00EE) |
| 123 | + # Show output in the second column |
107 | 124 | x0 := 18
|
108 | 125 | x1 := 22
|
109 | 126 | x2 := 27
|
110 | 127 | y := 1
|
| 128 | + |
| 129 | +################# |
| 130 | +# Test calling subroutines (2NNN, displayed as 2X) |
| 131 | + |
111 | 132 | drawop im2 imX
|
112 |
| - |
113 |
| - # Attempt to run a subroutine |
114 | 133 | v0 := 0
|
115 |
| - test-2X-0E |
116 |
| - |
| 134 | + test-2X-0E # Attempt to run a subroutine |
117 | 135 | : test-2X-0E-hard-return
|
118 | 136 | i := image-ok
|
119 | 137 | if v0 == 0 then i := image-no # Subroutine was never called
|
120 | 138 | sprite x2 y 4
|
121 |
| - |
| 139 | + |
| 140 | +################# |
| 141 | +# Test returning from subroutines (00EE, displayed as 0E) |
| 142 | + |
122 | 143 | y += 5
|
123 | 144 | drawop im0 imE
|
124 | 145 | i := image-ok
|
125 | 146 | if v0 == 2 then i := image-no # Return didn't work
|
126 | 147 | if v0 != 0 then sprite x2 y 4 # If subroutine wasn't called, return wasn't tested
|
127 | 148 |
|
128 |
| - #test 8xy0 |
| 149 | +################# |
| 150 | +# Test 8xy0 |
| 151 | + |
129 | 152 | y += 5
|
130 | 153 | drawop im8 im0
|
131 | 154 | i := image-no
|
|
135 | 158 | if v7 == 42 then i := image-ok
|
136 | 159 | sprite x2 y 4
|
137 | 160 |
|
138 |
| - #test 8xy1 |
| 161 | +################# |
| 162 | +# Test 8xy1 |
| 163 | + |
139 | 164 | y += 5
|
140 | 165 | drawop im8 im1
|
141 | 166 | i := image-no
|
|
145 | 170 | if v7 == 43 then i := image-ok
|
146 | 171 | sprite x2 y 4
|
147 | 172 |
|
148 |
| - #test 8xy2 |
| 173 | +################# |
| 174 | +# Test 8xy2 |
| 175 | + |
149 | 176 | y += 5
|
150 | 177 | drawop im8 im2
|
151 | 178 | i := image-no
|
|
155 | 182 | if v7 == 24 then i := image-ok
|
156 | 183 | sprite x2 y 4
|
157 | 184 |
|
158 |
| - #test 8xy3 |
| 185 | +################# |
| 186 | +# Test 8xy3 |
| 187 | + |
159 | 188 | y += 5
|
160 | 189 | drawop im8 im3
|
161 | 190 | i := image-no
|
|
165 | 194 | if v7 == 103 then i := image-ok
|
166 | 195 | sprite x2 y 4
|
167 | 196 |
|
168 |
| - #test 8xy4 |
| 197 | + # Show output in the third column |
169 | 198 | x0 := 34
|
170 | 199 | x1 := 38
|
171 | 200 | x2 := 43
|
172 | 201 | y := 1
|
| 202 | + |
| 203 | +################# |
| 204 | +# Test 8xy4 |
| 205 | + |
173 | 206 | drawop im8 im4
|
174 | 207 | i := image-no
|
175 | 208 | v6 := 140
|
|
178 | 211 | if v7 == 24 then i := image-ok
|
179 | 212 | sprite x2 y 4
|
180 | 213 |
|
181 |
| - #test 8xy5 |
| 214 | +################# |
| 215 | +# Test 8xy5 |
| 216 | + |
182 | 217 | y += 5
|
183 | 218 | drawop im8 im5
|
184 | 219 | i := image-no
|
|
188 | 223 | if v7 == 236 then i := image-ok
|
189 | 224 | sprite x2 y 4
|
190 | 225 |
|
191 |
| - #test 8xy7 |
| 226 | +################# |
| 227 | +# Test 8xy7 |
| 228 | + |
192 | 229 | y += 5
|
193 | 230 | drawop im8 im7
|
194 | 231 | i := image-no
|
|
198 | 235 | if v7 == 236 then i := image-ok
|
199 | 236 | sprite x2 y 4
|
200 | 237 |
|
201 |
| - #test "8xyE" |
202 |
| - # Note by Timendus: This should be 8XY6, changed the label here too. |
203 |
| - # See PR: https://github.com/corax89/chip8-test-rom/pull/7 |
| 238 | +################# |
| 239 | +# Test 8xy6 |
| 240 | + |
204 | 241 | y += 5
|
205 | 242 | drawop im8 im6
|
206 | 243 | i := image-no
|
|
209 | 246 | if v6 == 7 then i := image-ok
|
210 | 247 | sprite x2 y 4
|
211 | 248 |
|
212 |
| - #test "8xy6" |
213 |
| - # Note by Timendus: This should be 8XYE, changed the label here too. |
214 |
| - # See PR: https://github.com/corax89/chip8-test-rom/pull/7 |
| 249 | +################# |
| 250 | +# Test 8xyE |
| 251 | + |
215 | 252 | y += 5
|
216 | 253 | drawop im8 imE
|
217 | 254 | i := image-no
|
|
220 | 257 | if v6 == 192 then i := image-ok
|
221 | 258 | sprite x2 y 4
|
222 | 259 |
|
223 |
| - #test Fx65 |
| 260 | +################# |
| 261 | +# Test Fx65 |
| 262 | + |
224 | 263 | y += 5
|
225 | 264 | drawop imF im6
|
226 | 265 | i := scratchpad
|
|
230 | 269 | if v1 != 0x55 then i := image-no
|
231 | 270 | sprite x2 y 4
|
232 | 271 |
|
233 |
| - #test Fx55 |
| 272 | +################# |
| 273 | +# Test Fx55 |
| 274 | + |
234 | 275 | x0 := 50
|
235 | 276 | x1 := 54
|
236 | 277 | x2 := 59
|
|
250 | 291 | if v1 != 0 then i := image-no
|
251 | 292 | sprite x2 y 4
|
252 | 293 |
|
253 |
| - #test Fx33 |
| 294 | +################# |
| 295 | +# Test Fx33 |
| 296 | + |
254 | 297 | y += 5
|
255 | 298 | drawop imF im3
|
256 |
| - |
257 |
| - # >= 100 |
| 299 | + |
| 300 | + # N >= 100 |
258 | 301 | i := scratchpad
|
259 | 302 | v6 := 137
|
260 | 303 | bcd v6
|
261 | 304 | load v2
|
262 |
| - |
263 | 305 | i := image-no
|
264 |
| - |
265 | 306 | if v0 != 1 then jump fx33-fail
|
266 | 307 | if v1 != 3 then jump fx33-fail
|
267 | 308 | if v2 != 7 then jump fx33-fail
|
268 | 309 |
|
269 |
| - # < 100 |
| 310 | + # N < 100 |
270 | 311 | i := scratchpad
|
271 | 312 | v6 := 65
|
272 | 313 | bcd v6
|
273 | 314 | load v2
|
| 315 | + i := image-no |
274 | 316 | if v0 != 0 then jump fx33-fail
|
275 | 317 | if v1 != 6 then jump fx33-fail
|
276 | 318 | if v2 != 5 then jump fx33-fail
|
277 | 319 |
|
278 |
| - # < 10 |
| 320 | + # N < 10 |
279 | 321 | i := scratchpad
|
280 | 322 | v6 := 4
|
281 | 323 | bcd v6
|
282 | 324 | load v2
|
283 |
| - |
| 325 | + i := image-no |
284 | 326 | if v0 != 0 then jump fx33-fail
|
285 | 327 | if v1 != 0 then jump fx33-fail
|
286 | 328 | if v2 != 4 then jump fx33-fail
|
287 | 329 |
|
288 | 330 | i := image-ok
|
289 |
| - |
290 | 331 | : fx33-fail
|
291 | 332 | sprite x2 y 4
|
292 | 333 |
|
293 |
| - #test Fx1E |
| 334 | +################# |
| 335 | +# Test Fx1E |
| 336 | + |
294 | 337 | y += 5
|
295 | 338 | drawop imF imE
|
296 | 339 | i := image-no
|
297 | 340 | v6 := 4
|
298 | 341 | i += v6
|
299 | 342 | sprite x2 y 4
|
300 | 343 |
|
301 |
| - # Test to see if registers are 8 bit, as much as we can |
| 344 | +################# |
| 345 | +# Test to see if registers are 8 bit, as thoroughly as possible. |
| 346 | + |
302 | 347 | y += 5
|
303 | 348 | drawop imV imX
|
304 | 349 | i := image-ok
|
| 350 | + |
305 | 351 | # Addition opcodes should not allow us to overflow
|
306 | 352 | v6 := 255
|
307 | 353 | v6 += 10
|
|
314 | 360 | if v6 != 9 then i := image-no
|
315 | 361 | v6 >>= v6
|
316 | 362 | if v6 != 4 then i := image-no
|
| 363 | + |
317 | 364 | # Shift opcodes should not retain bits
|
318 | 365 | v6 := 255
|
319 | 366 | v6 <<= v6
|
|
322 | 369 | v6 >>= v6
|
323 | 370 | v6 <<= v6
|
324 | 371 | if v6 != 126 then i := image-no
|
| 372 | + |
325 | 373 | # Subtraction should wrap back to positive
|
326 | 374 | v6 := 5
|
327 | 375 | v6 -= 10
|
|
332 | 380 | v6 := 5
|
333 | 381 | v0 =- v6
|
334 | 382 | if v0 != 251 then i := image-no
|
| 383 | + |
335 | 384 | sprite x2 y 4
|
336 | 385 |
|
| 386 | +################# |
| 387 | +# Test is done! |
| 388 | + |
337 | 389 | loop again
|
338 | 390 |
|
339 | 391 | :segment data
|
|
0 commit comments