Many, many define main routine, define foo routine, etc.
Chris Pressey
3 years ago
14 | 14 | |
15 | 15 | Routines must declare their inputs, outputs, and memory locations they trash. |
16 | 16 | |
17 | | routine up | |
17 | | define up routine | |
18 | 18 | | inputs a |
19 | 19 | | outputs a |
20 | 20 | | trashes c, z, v, n |
26 | 26 | |
27 | 27 | Routines may not declare a memory location to be both an output and trashed. |
28 | 28 | |
29 | | routine main | |
29 | | define main routine | |
30 | 30 | | outputs a |
31 | 31 | | trashes a |
32 | 32 | | { |
36 | 36 | |
37 | 37 | If a routine declares it outputs a location, that location should be initialized. |
38 | 38 | |
39 | | routine main | |
39 | | define main routine | |
40 | 40 | | outputs a, x, z, n |
41 | 41 | | { |
42 | 42 | | ld x, 0 |
43 | 43 | | } |
44 | 44 | ? UnmeaningfulOutputError: a |
45 | 45 | |
46 | | routine main | |
46 | | define main routine | |
47 | 47 | | inputs a |
48 | 48 | | outputs a |
49 | 49 | | { |
53 | 53 | If a routine declares it outputs a location, that location may or may not have |
54 | 54 | been initialized. Trashing is mainly a signal to the caller. |
55 | 55 | |
56 | | routine main | |
56 | | define main routine | |
57 | 57 | | trashes x, z, n |
58 | 58 | | { |
59 | 59 | | ld x, 0 |
60 | 60 | | } |
61 | 61 | = ok |
62 | 62 | |
63 | | routine main | |
63 | | define main routine | |
64 | 64 | | trashes x, z, n |
65 | 65 | | { |
66 | 66 | | } |
68 | 68 | |
69 | 69 | If a routine modifies a location, it needs to either output it or trash it. |
70 | 70 | |
71 | | routine main | |
71 | | define main routine | |
72 | 72 | | { |
73 | 73 | | ld x, 0 |
74 | 74 | | } |
75 | 75 | ? ForbiddenWriteError: x |
76 | 76 | |
77 | | routine main | |
77 | | define main routine | |
78 | 78 | | outputs x, z, n |
79 | 79 | | { |
80 | 80 | | ld x, 0 |
81 | 81 | | } |
82 | 82 | = ok |
83 | 83 | |
84 | | routine main | |
84 | | define main routine | |
85 | 85 | | trashes x, z, n |
86 | 86 | | { |
87 | 87 | | ld x, 0 |
90 | 90 | |
91 | 91 | This is true regardless of whether it's an input or not. |
92 | 92 | |
93 | | routine main | |
93 | | define main routine | |
94 | 94 | | inputs x |
95 | 95 | | { |
96 | 96 | | ld x, 0 |
97 | 97 | | } |
98 | 98 | ? ForbiddenWriteError: x |
99 | 99 | |
100 | | routine main | |
100 | | define main routine | |
101 | 101 | | inputs x |
102 | 102 | | outputs x, z, n |
103 | 103 | | { |
105 | 105 | | } |
106 | 106 | = ok |
107 | 107 | |
108 | | routine main | |
108 | | define main routine | |
109 | 109 | | inputs x |
110 | 110 | | trashes x, z, n |
111 | 111 | | { |
115 | 115 | |
116 | 116 | If a routine trashes a location, this must be declared. |
117 | 117 | |
118 | | routine foo | |
118 | | define foo routine | |
119 | 119 | | trashes x |
120 | 120 | | { |
121 | 121 | | trash x |
122 | 122 | | } |
123 | 123 | = ok |
124 | 124 | |
125 | | routine foo | |
125 | | define foo routine | |
126 | 126 | | { |
127 | 127 | | trash x |
128 | 128 | | } |
129 | 129 | ? ForbiddenWriteError: x |
130 | 130 | |
131 | | routine foo | |
131 | | define foo routine | |
132 | 132 | | outputs x |
133 | 133 | | { |
134 | 134 | | trash x |
137 | 137 | |
138 | 138 | If a routine causes a location to be trashed, this must be declared in the caller. |
139 | 139 | |
140 | | routine trash_x | |
140 | | define trash_x routine | |
141 | 141 | | trashes x, z, n |
142 | 142 | | { |
143 | 143 | | ld x, 0 |
144 | 144 | | } |
145 | 145 | | |
146 | | routine foo | |
146 | | define foo routine | |
147 | 147 | | trashes x, z, n |
148 | 148 | | { |
149 | 149 | | call trash_x |
150 | 150 | | } |
151 | 151 | = ok |
152 | 152 | |
153 | | routine trash_x | |
153 | | define trash_x routine | |
154 | 154 | | trashes x, z, n |
155 | 155 | | { |
156 | 156 | | ld x, 0 |
157 | 157 | | } |
158 | 158 | | |
159 | | routine foo | |
159 | | define foo routine | |
160 | 160 | | trashes z, n |
161 | 161 | | { |
162 | 162 | | call trash_x |
163 | 163 | | } |
164 | 164 | ? ForbiddenWriteError: x |
165 | 165 | |
166 | | routine trash_x | |
166 | | define trash_x routine | |
167 | 167 | | trashes x, z, n |
168 | 168 | | { |
169 | 169 | | ld x, 0 |
170 | 170 | | } |
171 | 171 | | |
172 | | routine foo | |
172 | | define foo routine | |
173 | 173 | | outputs x |
174 | 174 | | trashes z, n |
175 | 175 | | { |
184 | 184 | | word w1 @ 60001 |
185 | 185 | | word w2 : 2000 |
186 | 186 | | |
187 | | routine main | |
187 | | define main routine | |
188 | 188 | | inputs b1, w1 |
189 | 189 | | outputs b2, w2 |
190 | 190 | | trashes a, z, n |
201 | 201 | |
202 | 202 | | byte up |
203 | 203 | | |
204 | | routine main outputs x, y trashes z, n { | |
204 | | define main routine outputs x, y trashes z, n { | |
205 | 205 | | ld x, 0 |
206 | 206 | | ld y, 1 |
207 | 207 | | call up |
208 | 208 | | } |
209 | 209 | ? TypeMismatchError: up |
210 | 210 | |
211 | | routine main outputs x, y trashes z, n { | |
211 | | define main routine outputs x, y trashes z, n { | |
212 | 212 | | ld x, 0 |
213 | 213 | | ld y, 1 |
214 | 214 | | call x |
219 | 219 | |
220 | 220 | | byte foo |
221 | 221 | | |
222 | | routine main { | |
222 | | define main routine { | |
223 | 223 | | goto foo |
224 | 224 | | } |
225 | 225 | ? TypeMismatchError: foo |
228 | 228 | |
229 | 229 | Can't `ld` from a memory location that isn't initialized. |
230 | 230 | |
231 | | routine main | |
231 | | define main routine | |
232 | 232 | | inputs a, x |
233 | 233 | | trashes a, z, n |
234 | 234 | | { |
236 | 236 | | } |
237 | 237 | = ok |
238 | 238 | |
239 | | routine main | |
239 | | define main routine | |
240 | 240 | | inputs a |
241 | 241 | | trashes a |
242 | 242 | | { |
246 | 246 | |
247 | 247 | Can't `ld` to a memory location that doesn't appear in (outputs ∪ trashes). |
248 | 248 | |
249 | | routine main | |
249 | | define main routine | |
250 | 250 | | trashes a, z, n |
251 | 251 | | { |
252 | 252 | | ld a, 0 |
253 | 253 | | } |
254 | 254 | = ok |
255 | 255 | |
256 | | routine main | |
256 | | define main routine | |
257 | 257 | | outputs a |
258 | 258 | | trashes z, n |
259 | 259 | | { |
261 | 261 | | } |
262 | 262 | = ok |
263 | 263 | |
264 | | routine main | |
264 | | define main routine | |
265 | 265 | | outputs z, n |
266 | 266 | | trashes a |
267 | 267 | | { |
269 | 269 | | } |
270 | 270 | = ok |
271 | 271 | |
272 | | routine main | |
272 | | define main routine | |
273 | 273 | | trashes z, n |
274 | 274 | | { |
275 | 275 | | ld a, 0 |
276 | 276 | | } |
277 | 277 | ? ForbiddenWriteError: a |
278 | 278 | |
279 | | routine main | |
279 | | define main routine | |
280 | 280 | | trashes a, n |
281 | 281 | | { |
282 | 282 | | ld a, 0 |
287 | 287 | |
288 | 288 | | word foo |
289 | 289 | | |
290 | | routine main | |
290 | | define main routine | |
291 | 291 | | inputs foo |
292 | 292 | | trashes a, n, z |
293 | 293 | | { |
300 | 300 | Can't `st` from a memory location that isn't initialized. |
301 | 301 | |
302 | 302 | | byte lives |
303 | | routine main | |
303 | | define main routine | |
304 | 304 | | inputs x |
305 | 305 | | trashes lives |
306 | 306 | | { |
309 | 309 | = ok |
310 | 310 | |
311 | 311 | | byte lives |
312 | | routine main | |
312 | | define main routine | |
313 | 313 | | trashes x, lives |
314 | 314 | | { |
315 | 315 | | st x, lives |
319 | 319 | Can't `st` to a memory location that doesn't appear in (outputs ∪ trashes). |
320 | 320 | |
321 | 321 | | byte lives |
322 | | routine main | |
322 | | define main routine | |
323 | 323 | | trashes lives |
324 | 324 | | { |
325 | 325 | | st 0, lives |
327 | 327 | = ok |
328 | 328 | |
329 | 329 | | byte lives |
330 | | routine main | |
330 | | define main routine | |
331 | 331 | | outputs lives |
332 | 332 | | { |
333 | 333 | | st 0, lives |
335 | 335 | = ok |
336 | 336 | |
337 | 337 | | byte lives |
338 | | routine main | |
338 | | define main routine | |
339 | 339 | | inputs lives |
340 | 340 | | { |
341 | 341 | | st 0, lives |
346 | 346 | |
347 | 347 | | word foo |
348 | 348 | | |
349 | | routine main | |
349 | | define main routine | |
350 | 350 | | outputs foo |
351 | 351 | | trashes a, n, z |
352 | 352 | | { |
362 | 362 | | byte one |
363 | 363 | | byte table[256] many |
364 | 364 | | |
365 | | routine main | |
365 | | define main routine | |
366 | 366 | | outputs one |
367 | 367 | | trashes a, x, n, z |
368 | 368 | | { |
375 | 375 | | byte one |
376 | 376 | | byte table[256] many |
377 | 377 | | |
378 | | routine main | |
378 | | define main routine | |
379 | 379 | | outputs many |
380 | 380 | | trashes a, x, n, z |
381 | 381 | | { |
388 | 388 | | byte one |
389 | 389 | | byte table[256] many |
390 | 390 | | |
391 | | routine main | |
391 | | define main routine | |
392 | 392 | | outputs one |
393 | 393 | | trashes a, x, n, z |
394 | 394 | | { |
401 | 401 | | byte one |
402 | 402 | | byte table[256] many |
403 | 403 | | |
404 | | routine main | |
404 | | define main routine | |
405 | 405 | | outputs many |
406 | 406 | | trashes a, x, n, z |
407 | 407 | | { |
416 | 416 | | byte one |
417 | 417 | | byte table[256] many |
418 | 418 | | |
419 | | routine main | |
419 | | define main routine | |
420 | 420 | | outputs many |
421 | 421 | | trashes a, x, n, z |
422 | 422 | | { |
429 | 429 | |
430 | 430 | | byte one |
431 | 431 | | |
432 | | routine main | |
432 | | define main routine | |
433 | 433 | | outputs one |
434 | 434 | | trashes a, x, n, z |
435 | 435 | | { |
441 | 441 | |
442 | 442 | | byte one |
443 | 443 | | |
444 | | routine main | |
444 | | define main routine | |
445 | 445 | | outputs one |
446 | 446 | | trashes a, x, n, z |
447 | 447 | | { |
453 | 453 | |
454 | 454 | | byte table[256] many |
455 | 455 | | |
456 | | routine main | |
456 | | define main routine | |
457 | 457 | | outputs many |
458 | 458 | | trashes a, x, n, z |
459 | 459 | | { |
466 | 466 | |
467 | 467 | | byte table[256] many |
468 | 468 | | |
469 | | routine main | |
469 | | define main routine | |
470 | 470 | | outputs many |
471 | 471 | | trashes a, x, n, z |
472 | 472 | | { |
479 | 479 | |
480 | 480 | | byte table[256] many |
481 | 481 | | |
482 | | routine main | |
482 | | define main routine | |
483 | 483 | | inputs many |
484 | 484 | | outputs many |
485 | 485 | | trashes a, x, n, z |
493 | 493 | |
494 | 494 | | byte table[256] many |
495 | 495 | | |
496 | | routine main | |
496 | | define main routine | |
497 | 497 | | inputs many |
498 | 498 | | outputs many |
499 | 499 | | trashes a, x, n, z |
506 | 506 | |
507 | 507 | | byte table[256] many |
508 | 508 | | |
509 | | routine main | |
509 | | define main routine | |
510 | 510 | | inputs many |
511 | 511 | | outputs many |
512 | 512 | | trashes a, x, c, n, z, v |
524 | 524 | |
525 | 525 | | byte table[256] many |
526 | 526 | | |
527 | | routine main | |
527 | | define main routine | |
528 | 528 | | inputs many |
529 | 529 | | outputs many |
530 | 530 | | trashes a, x, c, n, z |
541 | 541 | |
542 | 542 | | byte table[256] many |
543 | 543 | | |
544 | | routine main | |
544 | | define main routine | |
545 | 545 | | inputs many |
546 | 546 | | outputs many |
547 | 547 | | trashes a, x, c, n, z |
561 | 561 | | word one |
562 | 562 | | word table[256] many |
563 | 563 | | |
564 | | routine main | |
564 | | define main routine | |
565 | 565 | | inputs one, many |
566 | 566 | | outputs one, many |
567 | 567 | | trashes a, x, n, z |
575 | 575 | | word one |
576 | 576 | | word table[256] many |
577 | 577 | | |
578 | | routine main | |
578 | | define main routine | |
579 | 579 | | inputs one, many |
580 | 580 | | outputs one, many |
581 | 581 | | trashes a, x, n, z |
588 | 588 | | word one |
589 | 589 | | word table[256] many |
590 | 590 | | |
591 | | routine main | |
591 | | define main routine | |
592 | 592 | | inputs one, many |
593 | 593 | | outputs one, many |
594 | 594 | | trashes a, x, n, z |
603 | 603 | |
604 | 604 | | word table[32] many |
605 | 605 | | |
606 | | routine main | |
606 | | define main routine | |
607 | 607 | | inputs many |
608 | 608 | | outputs many |
609 | 609 | | trashes a, x, n, z |
627 | 627 | |
628 | 628 | | byte table[32] many |
629 | 629 | | |
630 | | routine main | |
630 | | define main routine | |
631 | 631 | | inputs many |
632 | 632 | | outputs many |
633 | 633 | | trashes a, x, n, z |
640 | 640 | |
641 | 641 | | byte table[32] many |
642 | 642 | | |
643 | | routine main | |
643 | | define main routine | |
644 | 644 | | inputs many |
645 | 645 | | outputs many |
646 | 646 | | trashes a, x, n, z |
652 | 652 | |
653 | 653 | | byte table[32] many |
654 | 654 | | |
655 | | routine main | |
655 | | define main routine | |
656 | 656 | | inputs many |
657 | 657 | | outputs many |
658 | 658 | | trashes a, x, n, z |
668 | 668 | | word one: 77 |
669 | 669 | | word table[32] many |
670 | 670 | | |
671 | | routine main | |
671 | | define main routine | |
672 | 672 | | inputs many, one |
673 | 673 | | outputs many, one |
674 | 674 | | trashes a, x, n, z |
682 | 682 | | word one: 77 |
683 | 683 | | word table[32] many |
684 | 684 | | |
685 | | routine main | |
685 | | define main routine | |
686 | 686 | | inputs many, one |
687 | 687 | | outputs many, one |
688 | 688 | | trashes a, x, n, z |
695 | 695 | | word one: 77 |
696 | 696 | | word table[32] many |
697 | 697 | | |
698 | | routine main | |
698 | | define main routine | |
699 | 699 | | inputs many, one |
700 | 700 | | outputs many, one |
701 | 701 | | trashes a, x, n, z |
713 | 713 | | word one: 77 |
714 | 714 | | word table[32] many |
715 | 715 | | |
716 | | routine main | |
716 | | define main routine | |
717 | 717 | | inputs a, many, one |
718 | 718 | | outputs many, one |
719 | 719 | | trashes a, x, n, z |
730 | 730 | | word one: 77 |
731 | 731 | | word table[32] many |
732 | 732 | | |
733 | | routine main | |
733 | | define main routine | |
734 | 734 | | inputs a, many, one |
735 | 735 | | outputs many, one |
736 | 736 | | trashes a, x, n, z |
748 | 748 | | word one: 77 |
749 | 749 | | word table[32] many |
750 | 750 | | |
751 | | routine main | |
751 | | define main routine | |
752 | 752 | | inputs a, many, one |
753 | 753 | | outputs many, one |
754 | 754 | | trashes a, x, n, z |
765 | 765 | |
766 | 766 | Can't `add` from or to a memory location that isn't initialized. |
767 | 767 | |
768 | | routine main | |
768 | | define main routine | |
769 | 769 | | inputs a |
770 | 770 | | outputs a |
771 | 771 | | trashes c, z, v, n |
776 | 776 | = ok |
777 | 777 | |
778 | 778 | | byte lives |
779 | | routine main | |
779 | | define main routine | |
780 | 780 | | inputs a |
781 | 781 | | outputs a |
782 | 782 | | trashes c, z, v, n |
787 | 787 | ? UnmeaningfulReadError: lives |
788 | 788 | |
789 | 789 | | byte lives |
790 | | routine main | |
790 | | define main routine | |
791 | 791 | | inputs lives |
792 | 792 | | outputs a |
793 | 793 | | trashes c, z, v, n |
799 | 799 | |
800 | 800 | Can't `add` to a memory location that isn't writeable. |
801 | 801 | |
802 | | routine main | |
802 | | define main routine | |
803 | 803 | | inputs a |
804 | 804 | | trashes c |
805 | 805 | | { |
811 | 811 | You can `add` a word constant to a word memory location. |
812 | 812 | |
813 | 813 | | word score |
814 | | routine main | |
814 | | define main routine | |
815 | 815 | | inputs a, score |
816 | 816 | | outputs score |
817 | 817 | | trashes a, c, z, v, n |
824 | 824 | `add`ing a word constant to a word memory location trashes `a`. |
825 | 825 | |
826 | 826 | | word score |
827 | | routine main | |
827 | | define main routine | |
828 | 828 | | inputs a, score |
829 | 829 | | outputs score, a |
830 | 830 | | trashes c, z, v, n |
837 | 837 | To be sure, `add`ing a word constant to a word memory location trashes `a`. |
838 | 838 | |
839 | 839 | | word score |
840 | | routine main | |
840 | | define main routine | |
841 | 841 | | inputs score |
842 | 842 | | outputs score |
843 | 843 | | trashes c, z, v, n |
851 | 851 | |
852 | 852 | | word score |
853 | 853 | | word delta |
854 | | routine main | |
854 | | define main routine | |
855 | 855 | | inputs score, delta |
856 | 856 | | outputs score |
857 | 857 | | trashes a, c, z, v, n |
865 | 865 | |
866 | 866 | | word score |
867 | 867 | | word delta |
868 | | routine main | |
868 | | define main routine | |
869 | 869 | | inputs score, delta |
870 | 870 | | outputs score |
871 | 871 | | trashes c, z, v, n |
879 | 879 | |
880 | 880 | | pointer ptr |
881 | 881 | | word delta |
882 | | routine main | |
882 | | define main routine | |
883 | 883 | | inputs ptr, delta |
884 | 884 | | outputs ptr |
885 | 885 | | trashes a, c, z, v, n |
894 | 894 | |
895 | 895 | | pointer ptr |
896 | 896 | | word delta |
897 | | routine main | |
897 | | define main routine | |
898 | 898 | | inputs ptr, delta |
899 | 899 | | outputs ptr |
900 | 900 | | trashes c, z, v, n |
909 | 909 | |
910 | 910 | Can't `sub` from or to a memory location that isn't initialized. |
911 | 911 | |
912 | | routine main | |
912 | | define main routine | |
913 | 913 | | inputs a |
914 | 914 | | outputs a |
915 | 915 | | trashes c, z, v, n |
920 | 920 | = ok |
921 | 921 | |
922 | 922 | | byte lives |
923 | | routine main | |
923 | | define main routine | |
924 | 924 | | inputs a |
925 | 925 | | outputs a |
926 | 926 | | trashes c, z, v, n |
931 | 931 | ? UnmeaningfulReadError: lives |
932 | 932 | |
933 | 933 | | byte lives |
934 | | routine main | |
934 | | define main routine | |
935 | 935 | | inputs lives |
936 | 936 | | outputs a |
937 | 937 | | trashes c, z, v, n |
943 | 943 | |
944 | 944 | Can't `sub` to a memory location that isn't writeable. |
945 | 945 | |
946 | | routine main | |
946 | | define main routine | |
947 | 947 | | inputs a |
948 | 948 | | trashes c |
949 | 949 | | { |
955 | 955 | You can `sub` a word constant from a word memory location. |
956 | 956 | |
957 | 957 | | word score |
958 | | routine main | |
958 | | define main routine | |
959 | 959 | | inputs a, score |
960 | 960 | | outputs score |
961 | 961 | | trashes a, c, z, v, n |
968 | 968 | `sub`ing a word constant from a word memory location trashes `a`. |
969 | 969 | |
970 | 970 | | word score |
971 | | routine main | |
971 | | define main routine | |
972 | 972 | | inputs a, score |
973 | 973 | | outputs score, a |
974 | 974 | | trashes c, z, v, n |
982 | 982 | |
983 | 983 | | word score |
984 | 984 | | word delta |
985 | | routine main | |
985 | | define main routine | |
986 | 986 | | inputs score, delta |
987 | 987 | | outputs score |
988 | 988 | | trashes a, c, z, v, n |
996 | 996 | |
997 | 997 | | word score |
998 | 998 | | word delta |
999 | | routine main | |
999 | | define main routine | |
1000 | 1000 | | inputs score, delta |
1001 | 1001 | | outputs score |
1002 | 1002 | | trashes c, z, v, n |
1010 | 1010 | |
1011 | 1011 | Location must be initialized and writeable. |
1012 | 1012 | |
1013 | | routine main | |
1013 | | define main routine | |
1014 | 1014 | | outputs x |
1015 | 1015 | | trashes z, n |
1016 | 1016 | | { |
1018 | 1018 | | } |
1019 | 1019 | ? UnmeaningfulReadError: x |
1020 | 1020 | |
1021 | | routine main | |
1021 | | define main routine | |
1022 | 1022 | | inputs x |
1023 | 1023 | | trashes z, n |
1024 | 1024 | | { |
1026 | 1026 | | } |
1027 | 1027 | ? ForbiddenWriteError: x |
1028 | 1028 | |
1029 | | routine main | |
1029 | | define main routine | |
1030 | 1030 | | inputs x |
1031 | 1031 | | outputs x |
1032 | 1032 | | trashes z, n |
1039 | 1039 | |
1040 | 1040 | | word foo |
1041 | 1041 | | |
1042 | | routine main | |
1042 | | define main routine | |
1043 | 1043 | | inputs foo |
1044 | 1044 | | outputs foo |
1045 | 1045 | | trashes z, n |
1052 | 1052 | |
1053 | 1053 | Location must be initialized and writeable. |
1054 | 1054 | |
1055 | | routine main | |
1055 | | define main routine | |
1056 | 1056 | | outputs x |
1057 | 1057 | | trashes z, n |
1058 | 1058 | | { |
1060 | 1060 | | } |
1061 | 1061 | ? UnmeaningfulReadError: x |
1062 | 1062 | |
1063 | | routine main | |
1063 | | define main routine | |
1064 | 1064 | | inputs x |
1065 | 1065 | | trashes z, n |
1066 | 1066 | | { |
1068 | 1068 | | } |
1069 | 1069 | ? ForbiddenWriteError: x |
1070 | 1070 | |
1071 | | routine main | |
1071 | | define main routine | |
1072 | 1072 | | inputs x |
1073 | 1073 | | outputs x |
1074 | 1074 | | trashes z, n |
1081 | 1081 | |
1082 | 1082 | | word foo |
1083 | 1083 | | |
1084 | | routine main | |
1084 | | define main routine | |
1085 | 1085 | | inputs foo |
1086 | 1086 | | outputs foo |
1087 | 1087 | | trashes z, n |
1094 | 1094 | |
1095 | 1095 | Some rudimentary tests for `cmp`. |
1096 | 1096 | |
1097 | | routine main | |
1097 | | define main routine | |
1098 | 1098 | | inputs a |
1099 | 1099 | | trashes z, c, n |
1100 | 1100 | | { |
1102 | 1102 | | } |
1103 | 1103 | = ok |
1104 | 1104 | |
1105 | | routine main | |
1105 | | define main routine | |
1106 | 1106 | | inputs a |
1107 | 1107 | | trashes z, n |
1108 | 1108 | | { |
1110 | 1110 | | } |
1111 | 1111 | ? ForbiddenWriteError: c |
1112 | 1112 | |
1113 | | routine main | |
1113 | | define main routine | |
1114 | 1114 | | trashes z, c, n |
1115 | 1115 | | { |
1116 | 1116 | | cmp a, 4 |
1121 | 1121 | |
1122 | 1122 | Some rudimentary tests for `and`. |
1123 | 1123 | |
1124 | | routine main | |
1124 | | define main routine | |
1125 | 1125 | | inputs a |
1126 | 1126 | | outputs a, z, n |
1127 | 1127 | | { |
1129 | 1129 | | } |
1130 | 1130 | = ok |
1131 | 1131 | |
1132 | | routine main | |
1132 | | define main routine | |
1133 | 1133 | | inputs a |
1134 | 1134 | | trashes z, n |
1135 | 1135 | | { |
1137 | 1137 | | } |
1138 | 1138 | ? ForbiddenWriteError: a |
1139 | 1139 | |
1140 | | routine main | |
1140 | | define main routine | |
1141 | 1141 | | trashes z, n |
1142 | 1142 | | { |
1143 | 1143 | | and a, 4 |
1148 | 1148 | |
1149 | 1149 | Some rudimentary tests for `or`. |
1150 | 1150 | |
1151 | | routine main | |
1151 | | define main routine | |
1152 | 1152 | | inputs a |
1153 | 1153 | | outputs a, z, n |
1154 | 1154 | | { |
1156 | 1156 | | } |
1157 | 1157 | = ok |
1158 | 1158 | |
1159 | | routine main | |
1159 | | define main routine | |
1160 | 1160 | | inputs a |
1161 | 1161 | | trashes z, n |
1162 | 1162 | | { |
1164 | 1164 | | } |
1165 | 1165 | ? ForbiddenWriteError: a |
1166 | 1166 | |
1167 | | routine main | |
1167 | | define main routine | |
1168 | 1168 | | trashes z, n |
1169 | 1169 | | { |
1170 | 1170 | | or a, 4 |
1175 | 1175 | |
1176 | 1176 | Some rudimentary tests for `xor`. |
1177 | 1177 | |
1178 | | routine main | |
1178 | | define main routine | |
1179 | 1179 | | inputs a |
1180 | 1180 | | outputs a, z, n |
1181 | 1181 | | { |
1183 | 1183 | | } |
1184 | 1184 | = ok |
1185 | 1185 | |
1186 | | routine main | |
1186 | | define main routine | |
1187 | 1187 | | inputs a |
1188 | 1188 | | trashes z, n |
1189 | 1189 | | { |
1191 | 1191 | | } |
1192 | 1192 | ? ForbiddenWriteError: a |
1193 | 1193 | |
1194 | | routine main | |
1194 | | define main routine | |
1195 | 1195 | | trashes z, n |
1196 | 1196 | | { |
1197 | 1197 | | xor a, 4 |
1203 | 1203 | Some rudimentary tests for `shl`. |
1204 | 1204 | |
1205 | 1205 | | byte foo |
1206 | | routine main | |
1206 | | define main routine | |
1207 | 1207 | | inputs foo, a, c |
1208 | 1208 | | outputs foo, a, c, z, n |
1209 | 1209 | | { |
1212 | 1212 | | } |
1213 | 1213 | = ok |
1214 | 1214 | |
1215 | | routine main | |
1215 | | define main routine | |
1216 | 1216 | | inputs a, c |
1217 | 1217 | | outputs c, z, n |
1218 | 1218 | | { |
1220 | 1220 | | } |
1221 | 1221 | ? ForbiddenWriteError: a |
1222 | 1222 | |
1223 | | routine main | |
1223 | | define main routine | |
1224 | 1224 | | inputs a |
1225 | 1225 | | outputs a, c, z, n |
1226 | 1226 | | { |
1233 | 1233 | Some rudimentary tests for `shr`. |
1234 | 1234 | |
1235 | 1235 | | byte foo |
1236 | | routine main | |
1236 | | define main routine | |
1237 | 1237 | | inputs foo, a, c |
1238 | 1238 | | outputs foo, a, c, z, n |
1239 | 1239 | | { |
1242 | 1242 | | } |
1243 | 1243 | = ok |
1244 | 1244 | |
1245 | | routine main | |
1245 | | define main routine | |
1246 | 1246 | | inputs a, c |
1247 | 1247 | | outputs c, z, n |
1248 | 1248 | | { |
1250 | 1250 | | } |
1251 | 1251 | ? ForbiddenWriteError: a |
1252 | 1252 | |
1253 | | routine main | |
1253 | | define main routine | |
1254 | 1254 | | inputs a |
1255 | 1255 | | outputs a, c, z, n |
1256 | 1256 | | { |
1262 | 1262 | |
1263 | 1263 | Some rudimentary tests for `nop`. |
1264 | 1264 | |
1265 | | routine main | |
1265 | | define main routine | |
1266 | 1266 | | { |
1267 | 1267 | | nop |
1268 | 1268 | | } |
1275 | 1275 | |
1276 | 1276 | | byte lives |
1277 | 1277 | | |
1278 | | routine foo | |
1278 | | define foo routine | |
1279 | 1279 | | inputs x |
1280 | 1280 | | trashes lives |
1281 | 1281 | | { |
1282 | 1282 | | st x, lives |
1283 | 1283 | | } |
1284 | 1284 | | |
1285 | | routine main | |
1285 | | define main routine | |
1286 | 1286 | | { |
1287 | 1287 | | call foo |
1288 | 1288 | | } |
1292 | 1292 | |
1293 | 1293 | | byte lives |
1294 | 1294 | | |
1295 | | routine foo | |
1295 | | define foo routine | |
1296 | 1296 | | inputs x |
1297 | 1297 | | trashes lives |
1298 | 1298 | | { |
1299 | 1299 | | st x, lives |
1300 | 1300 | | } |
1301 | 1301 | | |
1302 | | routine main | |
1302 | | define main routine | |
1303 | 1303 | | outputs x, z, n |
1304 | 1304 | | { |
1305 | 1305 | | ld x, 0 |
1309 | 1309 | |
1310 | 1310 | | byte lives |
1311 | 1311 | | |
1312 | | routine foo | |
1312 | | define foo routine | |
1313 | 1313 | | inputs x |
1314 | 1314 | | trashes lives |
1315 | 1315 | | { |
1316 | 1316 | | st x, lives |
1317 | 1317 | | } |
1318 | 1318 | | |
1319 | | routine main | |
1319 | | define main routine | |
1320 | 1320 | | outputs x, z, n |
1321 | 1321 | | trashes lives |
1322 | 1322 | | { |
1329 | 1329 | |
1330 | 1330 | | byte lives |
1331 | 1331 | | |
1332 | | routine foo | |
1332 | | define foo routine | |
1333 | 1333 | | inputs x |
1334 | 1334 | | trashes lives |
1335 | 1335 | | { |
1336 | 1336 | | st x, lives |
1337 | 1337 | | } |
1338 | 1338 | | |
1339 | | routine main | |
1339 | | define main routine | |
1340 | 1340 | | outputs x, z, n, lives |
1341 | 1341 | | { |
1342 | 1342 | | ld x, 0 |
1348 | 1348 | |
1349 | 1349 | | byte lives |
1350 | 1350 | | |
1351 | | routine foo | |
1351 | | define foo routine | |
1352 | 1352 | | inputs x |
1353 | 1353 | | trashes lives |
1354 | 1354 | | { |
1355 | 1355 | | st x, lives |
1356 | 1356 | | } |
1357 | 1357 | | |
1358 | | routine main | |
1358 | | define main routine | |
1359 | 1359 | | outputs x, z, n, lives |
1360 | 1360 | | { |
1361 | 1361 | | ld x, 0 |
1367 | 1367 | If a routine declares outputs, they are initialized in the caller after |
1368 | 1368 | calling it. |
1369 | 1369 | |
1370 | | routine foo | |
1370 | | define foo routine | |
1371 | 1371 | | outputs x, z, n |
1372 | 1372 | | { |
1373 | 1373 | | ld x, 0 |
1374 | 1374 | | } |
1375 | 1375 | | |
1376 | | routine main | |
1376 | | define main routine | |
1377 | 1377 | | outputs a |
1378 | 1378 | | trashes x, z, n |
1379 | 1379 | | { |
1382 | 1382 | | } |
1383 | 1383 | = ok |
1384 | 1384 | |
1385 | | routine foo | |
1386 | | { | |
1387 | | } | |
1388 | | | |
1389 | | routine main | |
1385 | | define foo routine | |
1386 | | { | |
1387 | | } | |
1388 | | | |
1389 | | define main routine | |
1390 | 1390 | | outputs a |
1391 | 1391 | | trashes x |
1392 | 1392 | | { |
1398 | 1398 | If a routine trashes locations, they are uninitialized in the caller after |
1399 | 1399 | calling it. |
1400 | 1400 | |
1401 | | routine foo | |
1401 | | define foo routine | |
1402 | 1402 | | trashes x, z, n |
1403 | 1403 | | { |
1404 | 1404 | | ld x, 0 |
1405 | 1405 | | } |
1406 | 1406 | = ok |
1407 | 1407 | |
1408 | | routine foo | |
1408 | | define foo routine | |
1409 | 1409 | | trashes x, z, n |
1410 | 1410 | | { |
1411 | 1411 | | ld x, 0 |
1412 | 1412 | | } |
1413 | 1413 | | |
1414 | | routine main | |
1414 | | define main routine | |
1415 | 1415 | | outputs a |
1416 | 1416 | | trashes x, z, n |
1417 | 1417 | | { |
1428 | 1428 | | trashes a |
1429 | 1429 | | @ 65490 |
1430 | 1430 | | |
1431 | | routine main | |
1431 | | define main routine | |
1432 | 1432 | | trashes a, z, n |
1433 | 1433 | | { |
1434 | 1434 | | ld a, 65 |
1441 | 1441 | | trashes a |
1442 | 1442 | | @ 65490 |
1443 | 1443 | | |
1444 | | routine main | |
1444 | | define main routine | |
1445 | 1445 | | trashes a, z, n |
1446 | 1446 | | { |
1447 | 1447 | | call chrout |
1453 | 1453 | | trashes a |
1454 | 1454 | | @ 65490 |
1455 | 1455 | | |
1456 | | routine main | |
1456 | | define main routine | |
1457 | 1457 | | trashes a, x, z, n |
1458 | 1458 | | { |
1459 | 1459 | | ld a, 65 |
1466 | 1466 | |
1467 | 1467 | Trash does nothing except indicate that we do not care about the value anymore. |
1468 | 1468 | |
1469 | | routine foo | |
1469 | | define foo routine | |
1470 | 1470 | | inputs a |
1471 | 1471 | | outputs x |
1472 | 1472 | | trashes a, z, n |
1477 | 1477 | | } |
1478 | 1478 | = ok |
1479 | 1479 | |
1480 | | routine foo | |
1480 | | define foo routine | |
1481 | 1481 | | inputs a |
1482 | 1482 | | outputs a, x |
1483 | 1483 | | trashes z, n |
1488 | 1488 | | } |
1489 | 1489 | ? UnmeaningfulOutputError: a |
1490 | 1490 | |
1491 | | routine foo | |
1491 | | define foo routine | |
1492 | 1492 | | inputs a |
1493 | 1493 | | outputs x |
1494 | 1494 | | trashes a, z, n |
1503 | 1503 | |
1504 | 1504 | Both blocks of an `if` are analyzed. |
1505 | 1505 | |
1506 | | routine foo | |
1506 | | define foo routine | |
1507 | 1507 | | inputs a |
1508 | 1508 | | outputs x |
1509 | 1509 | | trashes a, z, n, c |
1519 | 1519 | |
1520 | 1520 | If a location is initialized in one block, is must be initialized in the other as well. |
1521 | 1521 | |
1522 | | routine foo | |
1522 | | define foo routine | |
1523 | 1523 | | inputs a |
1524 | 1524 | | outputs x |
1525 | 1525 | | trashes a, z, n, c |
1533 | 1533 | | } |
1534 | 1534 | ? InconsistentInitializationError: x |
1535 | 1535 | |
1536 | | routine foo | |
1536 | | define foo routine | |
1537 | 1537 | | inputs a |
1538 | 1538 | | outputs x |
1539 | 1539 | | trashes a, z, n, c |
1547 | 1547 | | } |
1548 | 1548 | ? InconsistentInitializationError: x |
1549 | 1549 | |
1550 | | routine foo | |
1550 | | define foo routine | |
1551 | 1551 | | inputs a |
1552 | 1552 | | outputs x |
1553 | 1553 | | trashes a, z, n, c |
1566 | 1566 | input to the routine, and it is initialized in one branch, it need not |
1567 | 1567 | be initialized in the other. |
1568 | 1568 | |
1569 | | routine foo | |
1569 | | define foo routine | |
1570 | 1570 | | outputs x |
1571 | 1571 | | trashes a, z, n, c |
1572 | 1572 | | { |
1581 | 1581 | | } |
1582 | 1582 | = ok |
1583 | 1583 | |
1584 | | routine foo | |
1584 | | define foo routine | |
1585 | 1585 | | inputs x |
1586 | 1586 | | outputs x |
1587 | 1587 | | trashes a, z, n, c |
1598 | 1598 | |
1599 | 1599 | An `if` with a single block is analyzed as if it had an empty `else` block. |
1600 | 1600 | |
1601 | | routine foo | |
1601 | | define foo routine | |
1602 | 1602 | | inputs a |
1603 | 1603 | | outputs x |
1604 | 1604 | | trashes a, z, n, c |
1610 | 1610 | | } |
1611 | 1611 | ? InconsistentInitializationError: x |
1612 | 1612 | |
1613 | | routine foo | |
1613 | | define foo routine | |
1614 | 1614 | | inputs a |
1615 | 1615 | | outputs x |
1616 | 1616 | | trashes a, z, n, c |
1623 | 1623 | | } |
1624 | 1624 | = ok |
1625 | 1625 | |
1626 | | routine foo | |
1626 | | define foo routine | |
1627 | 1627 | | inputs a |
1628 | 1628 | | outputs x |
1629 | 1629 | | trashes a, z, n, c |
1640 | 1640 | trashes {`a`} and the other branch trashes {`b`} then the whole `if` statement |
1641 | 1641 | trashes {`a`, `b`}. |
1642 | 1642 | |
1643 | | routine foo | |
1643 | | define foo routine | |
1644 | 1644 | | inputs a, x, z |
1645 | 1645 | | trashes a, x |
1646 | 1646 | | { |
1652 | 1652 | | } |
1653 | 1653 | = ok |
1654 | 1654 | |
1655 | | routine foo | |
1655 | | define foo routine | |
1656 | 1656 | | inputs a, x, z |
1657 | 1657 | | trashes a |
1658 | 1658 | | { |
1664 | 1664 | | } |
1665 | 1665 | ? ForbiddenWriteError: x (in foo, line 10) |
1666 | 1666 | |
1667 | | routine foo | |
1667 | | define foo routine | |
1668 | 1668 | | inputs a, x, z |
1669 | 1669 | | trashes x |
1670 | 1670 | | { |
1680 | 1680 | |
1681 | 1681 | Repeat loop. |
1682 | 1682 | |
1683 | | routine main | |
1683 | | define main routine | |
1684 | 1684 | | outputs x, y, n, z, c |
1685 | 1685 | | { |
1686 | 1686 | | ld x, 0 |
1695 | 1695 | |
1696 | 1696 | You can initialize something inside the loop that was uninitialized outside. |
1697 | 1697 | |
1698 | | routine main | |
1698 | | define main routine | |
1699 | 1699 | | outputs x, y, n, z, c |
1700 | 1700 | | { |
1701 | 1701 | | ld x, 0 |
1710 | 1710 | But you can't UNinitialize something at the end of the loop that you need |
1711 | 1711 | initialized at the start. |
1712 | 1712 | |
1713 | | routine foo | |
1713 | | define foo routine | |
1714 | 1714 | | trashes y |
1715 | 1715 | | { |
1716 | 1716 | | } |
1717 | 1717 | | |
1718 | | routine main | |
1718 | | define main routine | |
1719 | 1719 | | outputs x, y, n, z, c |
1720 | 1720 | | { |
1721 | 1721 | | ld x, 0 |
1735 | 1735 | | word one : 0 |
1736 | 1736 | | word two : 0 |
1737 | 1737 | | |
1738 | | routine main | |
1738 | | define main routine | |
1739 | 1739 | | inputs one, two |
1740 | 1740 | | outputs two |
1741 | 1741 | | trashes a, z, n |
1748 | 1748 | |
1749 | 1749 | The body of `repeat forever` can be empty. |
1750 | 1750 | |
1751 | | routine main | |
1751 | | define main routine | |
1752 | 1752 | | { |
1753 | 1753 | | repeat { |
1754 | 1754 | | } forever |
1757 | 1757 | |
1758 | 1758 | While `repeat` is most often used with `z`, it can also be used with `n`. |
1759 | 1759 | |
1760 | | routine main | |
1760 | | define main routine | |
1761 | 1761 | | outputs y, n, z |
1762 | 1762 | | { |
1763 | 1763 | | ld y, 15 |
1933 | 1933 | |
1934 | 1934 | You can initialize something inside the loop that was uninitialized outside. |
1935 | 1935 | |
1936 | | routine main | |
1936 | | define main routine | |
1937 | 1937 | | outputs x, y, n, z |
1938 | 1938 | | trashes c |
1939 | 1939 | | { |
1947 | 1947 | But you can't UNinitialize something at the end of the loop that you need |
1948 | 1948 | initialized at the start of that loop. |
1949 | 1949 | |
1950 | | routine foo | |
1950 | | define foo routine | |
1951 | 1951 | | trashes y |
1952 | 1952 | | { |
1953 | 1953 | | } |
1954 | 1954 | | |
1955 | | routine main | |
1955 | | define main routine | |
1956 | 1956 | | outputs x, y, n, z |
1957 | 1957 | | trashes c |
1958 | 1958 | | { |
1969 | 1969 | |
1970 | 1970 | Basic neutral test, where the `save` makes no difference. |
1971 | 1971 | |
1972 | | routine main | |
1972 | | define main routine | |
1973 | 1973 | | inputs a, x |
1974 | 1974 | | outputs a, x |
1975 | 1975 | | trashes z, n |
1984 | 1984 | |
1985 | 1985 | Saving any location (other than `a`) will trash `a`. |
1986 | 1986 | |
1987 | | routine main | |
1987 | | define main routine | |
1988 | 1988 | | inputs a, x |
1989 | 1989 | | outputs a, x |
1990 | 1990 | | trashes z, n |
1998 | 1998 | |
1999 | 1999 | Saving `a` does not trash anything. |
2000 | 2000 | |
2001 | | routine main | |
2001 | | define main routine | |
2002 | 2002 | | inputs a, x |
2003 | 2003 | | outputs a, x |
2004 | 2004 | | trashes z, n |
2014 | 2014 | A defined value that has been saved can be trashed inside the block. |
2015 | 2015 | It will continue to be defined outside the block. |
2016 | 2016 | |
2017 | | routine main | |
2017 | | define main routine | |
2018 | 2018 | | outputs x, y |
2019 | 2019 | | trashes a, z, n |
2020 | 2020 | | { |
2031 | 2031 | |
2032 | 2032 | (Note, both x and a are unmeaningful in this test.) |
2033 | 2033 | |
2034 | | routine main | |
2034 | | define main routine | |
2035 | 2035 | | inputs a |
2036 | 2036 | | outputs a, x |
2037 | 2037 | | trashes z, n |
2050 | 2050 | | word one: 77 |
2051 | 2051 | | word table[32] many |
2052 | 2052 | | |
2053 | | routine main | |
2053 | | define main routine | |
2054 | 2054 | | inputs a, many, one |
2055 | 2055 | | outputs many, one |
2056 | 2056 | | trashes a, x, n, z |
2068 | 2068 | | word one: 77 |
2069 | 2069 | | word table[32] many |
2070 | 2070 | | |
2071 | | routine main | |
2071 | | define main routine | |
2072 | 2072 | | inputs a, many, one |
2073 | 2073 | | outputs many, one |
2074 | 2074 | | trashes a, x, n, z |
2088 | 2088 | | word one: 77 |
2089 | 2089 | | word table[32] many |
2090 | 2090 | | |
2091 | | routine main | |
2091 | | define main routine | |
2092 | 2092 | | inputs a, many, one |
2093 | 2093 | | outputs many, one |
2094 | 2094 | | trashes a, x, n, z |
2107 | 2107 | A value which is not output from the routine, is preserved by the |
2108 | 2108 | routine; and can appear in a `save` exactly because a `save` preserves it. |
2109 | 2109 | |
2110 | | routine main | |
2110 | | define main routine | |
2111 | 2111 | | outputs y |
2112 | 2112 | | trashes a, z, n |
2113 | 2113 | | { |
2121 | 2121 | Because saving anything except `a` trashes `a`, a common idiom is to save `a` |
2122 | 2122 | first in a nested series of `save`s. |
2123 | 2123 | |
2124 | | routine main | |
2124 | | define main routine | |
2125 | 2125 | | inputs a |
2126 | 2126 | | outputs a |
2127 | 2127 | | trashes z, n |
2137 | 2137 | |
2138 | 2138 | There is a shortcut syntax for a nested series of `save`s. |
2139 | 2139 | |
2140 | | routine main | |
2140 | | define main routine | |
2141 | 2141 | | inputs a |
2142 | 2142 | | outputs a |
2143 | 2143 | | trashes z, n |
2151 | 2151 | |
2152 | 2152 | `a` is only preserved if it is the outermost thing `save`d. |
2153 | 2153 | |
2154 | | routine main | |
2154 | | define main routine | |
2155 | 2155 | | inputs a |
2156 | 2156 | | outputs a |
2157 | 2157 | | trashes z, n |
2167 | 2167 | |
2168 | 2168 | | byte foo |
2169 | 2169 | | |
2170 | | routine main | |
2170 | | define main routine | |
2171 | 2171 | | trashes a, z, n |
2172 | 2172 | | { |
2173 | 2173 | | save foo { |
2180 | 2180 | |
2181 | 2181 | | word foo |
2182 | 2182 | | |
2183 | | routine main | |
2183 | | define main routine | |
2184 | 2184 | | trashes a, z, n |
2185 | 2185 | | { |
2186 | 2186 | | save foo { |
2191 | 2191 | |
2192 | 2192 | | byte table[16] tab |
2193 | 2193 | | |
2194 | | routine main | |
2194 | | define main routine | |
2195 | 2195 | | trashes a, y, z, n |
2196 | 2196 | | { |
2197 | 2197 | | save tab { |
2203 | 2203 | |
2204 | 2204 | A `goto` cannot appear within a `save` block, even if it is otherwise in tail position. |
2205 | 2205 | |
2206 | | routine other | |
2206 | | define other routine | |
2207 | 2207 | | trashes a, z, n |
2208 | 2208 | | { |
2209 | 2209 | | ld a, 0 |
2210 | 2210 | | } |
2211 | 2211 | | |
2212 | | routine main | |
2212 | | define main routine | |
2213 | 2213 | | trashes a, z, n |
2214 | 2214 | | { |
2215 | 2215 | | ld a, 1 |
2228 | 2228 | | trashes z, n |
2229 | 2229 | | bar |
2230 | 2230 | | |
2231 | | routine foo | |
2231 | | define foo routine | |
2232 | 2232 | | inputs x |
2233 | 2233 | | outputs x |
2234 | 2234 | | trashes z, n |
2236 | 2236 | | inc x |
2237 | 2237 | | } |
2238 | 2238 | | |
2239 | | routine main | |
2239 | | define main routine | |
2240 | 2240 | | outputs bar |
2241 | 2241 | | trashes a, n, z |
2242 | 2242 | | { |
2255 | 2255 | | trashes z, n |
2256 | 2256 | | bar |
2257 | 2257 | | |
2258 | | routine foo | |
2258 | | define foo routine | |
2259 | 2259 | | inputs x |
2260 | 2260 | | outputs x |
2261 | 2261 | | trashes z, n |
2269 | 2269 | | ld a, 0 |
2270 | 2270 | | } |
2271 | 2271 | | |
2272 | | routine main | |
2272 | | define main routine | |
2273 | 2273 | | trashes bar, a, n, z |
2274 | 2274 | | { |
2275 | 2275 | | with interrupts off { |
2284 | 2284 | Can't `copy` from a memory location that isn't initialized. |
2285 | 2285 | |
2286 | 2286 | | byte lives |
2287 | | routine main | |
2287 | | define main routine | |
2288 | 2288 | | inputs x |
2289 | 2289 | | outputs lives |
2290 | 2290 | | trashes a, z, n |
2294 | 2294 | = ok |
2295 | 2295 | |
2296 | 2296 | | byte lives |
2297 | | routine main | |
2297 | | define main routine | |
2298 | 2298 | | outputs lives |
2299 | 2299 | | trashes x, a, z, n |
2300 | 2300 | | { |
2305 | 2305 | Can't `copy` to a memory location that doesn't appear in (outputs ∪ trashes). |
2306 | 2306 | |
2307 | 2307 | | byte lives |
2308 | | routine main | |
2308 | | define main routine | |
2309 | 2309 | | trashes lives, a, z, n |
2310 | 2310 | | { |
2311 | 2311 | | copy 0, lives |
2313 | 2313 | = ok |
2314 | 2314 | |
2315 | 2315 | | byte lives |
2316 | | routine main | |
2316 | | define main routine | |
2317 | 2317 | | outputs lives |
2318 | 2318 | | trashes a, z, n |
2319 | 2319 | | { |
2322 | 2322 | = ok |
2323 | 2323 | |
2324 | 2324 | | byte lives |
2325 | | routine main | |
2325 | | define main routine | |
2326 | 2326 | | inputs lives |
2327 | 2327 | | trashes a, z, n |
2328 | 2328 | | { |
2335 | 2335 | (Note, both n and z are forbidden writes in this test.) |
2336 | 2336 | |
2337 | 2337 | | byte lives |
2338 | | routine main | |
2338 | | define main routine | |
2339 | 2339 | | outputs lives |
2340 | 2340 | | { |
2341 | 2341 | | copy 0, lives |
2347 | 2347 | (Note, both n and a are unmeaningful outputs in this test.) |
2348 | 2348 | |
2349 | 2349 | | byte lives |
2350 | | routine main | |
2350 | | define main routine | |
2351 | 2351 | | outputs lives, a, z, n |
2352 | 2352 | | { |
2353 | 2353 | | copy 0, lives |
2357 | 2357 | Unless of course you subsequently initialize them. |
2358 | 2358 | |
2359 | 2359 | | byte lives |
2360 | | routine main | |
2360 | | define main routine | |
2361 | 2361 | | outputs lives, a, z, n |
2362 | 2362 | | { |
2363 | 2363 | | copy 0, lives |
2370 | 2370 | | byte source : 0 |
2371 | 2371 | | byte dest |
2372 | 2372 | | |
2373 | | routine main | |
2373 | | define main routine | |
2374 | 2374 | | inputs source |
2375 | 2375 | | outputs dest |
2376 | 2376 | | trashes a, z, n |
2385 | 2385 | | byte source : 0 |
2386 | 2386 | | byte dest |
2387 | 2387 | | |
2388 | | routine main | |
2388 | | define main routine | |
2389 | 2389 | | inputs source |
2390 | 2390 | | outputs dest |
2391 | 2391 | | trashes a, z, n |
2399 | 2399 | | word source : 0 |
2400 | 2400 | | word dest |
2401 | 2401 | | |
2402 | | routine main | |
2402 | | define main routine | |
2403 | 2403 | | inputs source |
2404 | 2404 | | outputs dest |
2405 | 2405 | | trashes a, z, n |
2413 | 2413 | | byte source : 0 |
2414 | 2414 | | word dest |
2415 | 2415 | | |
2416 | | routine main | |
2416 | | define main routine | |
2417 | 2417 | | inputs source |
2418 | 2418 | | outputs dest |
2419 | 2419 | | trashes a, z, n |
2427 | 2427 | | word source : 0 |
2428 | 2428 | | byte dest |
2429 | 2429 | | |
2430 | | routine main | |
2430 | | define main routine | |
2431 | 2431 | | inputs source |
2432 | 2432 | | outputs dest |
2433 | 2433 | | trashes a, z, n |
2458 | 2458 | | buffer[2048] buf |
2459 | 2459 | | pointer ptr |
2460 | 2460 | | |
2461 | | routine main | |
2461 | | define main routine | |
2462 | 2462 | | inputs buf |
2463 | 2463 | | outputs y, buf |
2464 | 2464 | | trashes a, z, n, ptr |
2474 | 2474 | | buffer[2048] buf |
2475 | 2475 | | pointer ptr |
2476 | 2476 | | |
2477 | | routine main | |
2477 | | define main routine | |
2478 | 2478 | | inputs buf |
2479 | 2479 | | outputs buf |
2480 | 2480 | | trashes a, z, n, ptr |
2490 | 2490 | | pointer ptr |
2491 | 2491 | | byte foo |
2492 | 2492 | | |
2493 | | routine main | |
2493 | | define main routine | |
2494 | 2494 | | inputs foo, buf |
2495 | 2495 | | outputs y, buf |
2496 | 2496 | | trashes a, z, n, ptr |
2507 | 2507 | | pointer ptr |
2508 | 2508 | | byte foo |
2509 | 2509 | | |
2510 | | routine main | |
2510 | | define main routine | |
2511 | 2511 | | inputs buf |
2512 | 2512 | | outputs foo |
2513 | 2513 | | trashes a, y, z, n, ptr |
2524 | 2524 | | pointer ptra |
2525 | 2525 | | pointer ptrb |
2526 | 2526 | | |
2527 | | routine main | |
2527 | | define main routine | |
2528 | 2528 | | inputs buf |
2529 | 2529 | | outputs buf |
2530 | 2530 | | trashes a, y, z, n, ptra, ptrb |
2543 | 2543 | | pointer ptr |
2544 | 2544 | | byte foo |
2545 | 2545 | | |
2546 | | routine main | |
2546 | | define main routine | |
2547 | 2547 | | inputs buf |
2548 | 2548 | | outputs a |
2549 | 2549 | | trashes y, z, n, ptr |
2561 | 2561 | | pointer ptr |
2562 | 2562 | | byte foo |
2563 | 2563 | | |
2564 | | routine main | |
2564 | | define main routine | |
2565 | 2565 | | inputs buf |
2566 | 2566 | | outputs buf |
2567 | 2567 | | trashes a, y, z, n, ptr |
2584 | 2584 | | trashes z, n |
2585 | 2585 | | vec |
2586 | 2586 | | |
2587 | | routine foo | |
2587 | | define foo routine | |
2588 | 2588 | | inputs x |
2589 | 2589 | | outputs x |
2590 | 2590 | | trashes z, n |
2592 | 2592 | | inc x |
2593 | 2593 | | } |
2594 | 2594 | | |
2595 | | routine main | |
2595 | | define main routine | |
2596 | 2596 | | inputs foo |
2597 | 2597 | | outputs vec |
2598 | 2598 | | trashes a, z, n |
2607 | 2607 | | trashes z, n |
2608 | 2608 | | vec |
2609 | 2609 | | |
2610 | | routine foo | |
2610 | | define foo routine | |
2611 | 2611 | | inputs x |
2612 | 2612 | | outputs x |
2613 | 2613 | | trashes z, n |
2615 | 2615 | | inc x |
2616 | 2616 | | } |
2617 | 2617 | | |
2618 | | routine main | |
2618 | | define main routine | |
2619 | 2619 | | outputs vec, foo |
2620 | 2620 | | trashes a, z, n |
2621 | 2621 | | { |
2629 | 2629 | | trashes z, n |
2630 | 2630 | | vec |
2631 | 2631 | | |
2632 | | routine foo | |
2632 | | define foo routine | |
2633 | 2633 | | inputs x |
2634 | 2634 | | outputs x |
2635 | 2635 | | trashes z, n |
2637 | 2637 | | inc x |
2638 | 2638 | | } |
2639 | 2639 | | |
2640 | | routine main | |
2640 | | define main routine | |
2641 | 2641 | | outputs vec |
2642 | 2642 | | trashes a, z, n, foo |
2643 | 2643 | | { |
2662 | 2662 | | trashes z, n |
2663 | 2663 | | vec |
2664 | 2664 | | |
2665 | | routine foo | |
2665 | | define foo routine | |
2666 | 2666 | | inputs x, y |
2667 | 2667 | | outputs x, y |
2668 | 2668 | | trashes z, n |
2671 | 2671 | | inc y |
2672 | 2672 | | } |
2673 | 2673 | | |
2674 | | routine main | |
2674 | | define main routine | |
2675 | 2675 | | outputs vec |
2676 | 2676 | | trashes a, z, n |
2677 | 2677 | | { |
2689 | 2689 | | trashes z, n |
2690 | 2690 | | vec |
2691 | 2691 | | |
2692 | | routine foo | |
2692 | | define foo routine | |
2693 | 2693 | | inputs x, y |
2694 | 2694 | | outputs x, y |
2695 | 2695 | | trashes z, n |
2698 | 2698 | | inc y |
2699 | 2699 | | } |
2700 | 2700 | | |
2701 | | routine main | |
2701 | | define main routine | |
2702 | 2702 | | outputs vec |
2703 | 2703 | | trashes a, z, n |
2704 | 2704 | | { |
2714 | 2714 | | trashes z, n |
2715 | 2715 | | vec |
2716 | 2716 | | |
2717 | | routine foo | |
2717 | | define foo routine | |
2718 | 2718 | | inputs x, y |
2719 | 2719 | | outputs x, y |
2720 | 2720 | | trashes z, n |
2723 | 2723 | | inc y |
2724 | 2724 | | } |
2725 | 2725 | | |
2726 | | routine main | |
2726 | | define main routine | |
2727 | 2727 | | outputs vec |
2728 | 2728 | | trashes a, z, n |
2729 | 2729 | | { |
2742 | 2742 | | trashes z, n |
2743 | 2743 | | vec |
2744 | 2744 | | |
2745 | | routine foo | |
2745 | | define foo routine | |
2746 | 2746 | | inputs x, y |
2747 | 2747 | | outputs x, y |
2748 | 2748 | | trashes z, n |
2751 | 2751 | | inc y |
2752 | 2752 | | } |
2753 | 2753 | | |
2754 | | routine main | |
2754 | | define main routine | |
2755 | 2755 | | outputs vec |
2756 | 2756 | | trashes a, z, n |
2757 | 2757 | | { |
2767 | 2767 | | trashes z, n |
2768 | 2768 | | vec |
2769 | 2769 | | |
2770 | | routine foo | |
2770 | | define foo routine | |
2771 | 2771 | | inputs x, y |
2772 | 2772 | | outputs x, y |
2773 | 2773 | | trashes z, n |
2776 | 2776 | | inc y |
2777 | 2777 | | } |
2778 | 2778 | | |
2779 | | routine main | |
2779 | | define main routine | |
2780 | 2780 | | outputs vec |
2781 | 2781 | | trashes a, z, n |
2782 | 2782 | | { |
2792 | 2792 | | trashes z |
2793 | 2793 | | vec |
2794 | 2794 | | |
2795 | | routine foo | |
2795 | | define foo routine | |
2796 | 2796 | | inputs x, y |
2797 | 2797 | | outputs x, y |
2798 | 2798 | | trashes z, n |
2801 | 2801 | | inc y |
2802 | 2802 | | } |
2803 | 2803 | | |
2804 | | routine main | |
2804 | | define main routine | |
2805 | 2805 | | outputs vec |
2806 | 2806 | | trashes a, z, n |
2807 | 2807 | | { |
2820 | 2820 | | trashes a, z, n |
2821 | 2821 | | vec |
2822 | 2822 | | |
2823 | | routine foo | |
2823 | | define foo routine | |
2824 | 2824 | | inputs x, y |
2825 | 2825 | | outputs x, y |
2826 | 2826 | | trashes z, n |
2829 | 2829 | | inc y |
2830 | 2830 | | } |
2831 | 2831 | | |
2832 | | routine main | |
2832 | | define main routine | |
2833 | 2833 | | outputs vec |
2834 | 2834 | | trashes a, z, n |
2835 | 2835 | | { |
2847 | 2847 | | trashes z, n |
2848 | 2848 | | vec |
2849 | 2849 | | |
2850 | | routine foo | |
2850 | | define foo routine | |
2851 | 2851 | | inputs x |
2852 | 2852 | | outputs x |
2853 | 2853 | | trashes z, n |
2855 | 2855 | | inc x |
2856 | 2856 | | } |
2857 | 2857 | | |
2858 | | routine main | |
2858 | | define main routine | |
2859 | 2859 | | outputs vec |
2860 | 2860 | | trashes a, z, n |
2861 | 2861 | | { |
2869 | 2869 | | outputs x trashes z, n |
2870 | 2870 | | foo |
2871 | 2871 | | |
2872 | | routine bar outputs x trashes z, n { | |
2872 | | define bar routine outputs x trashes z, n { | |
2873 | 2873 | | ld x, 200 |
2874 | 2874 | | } |
2875 | 2875 | | |
2876 | | routine main outputs x, foo trashes a, z, n { | |
2876 | | define main routine outputs x, foo trashes a, z, n { | |
2877 | 2877 | | copy bar, foo |
2878 | 2878 | | call foo |
2879 | 2879 | | } |
3070 | 3070 | | outputs x |
3071 | 3071 | | trashes a, z, n foo |
3072 | 3072 | | |
3073 | | routine bar | |
3073 | | define bar routine | |
3074 | 3074 | | outputs x |
3075 | 3075 | | trashes a, z, n { |
3076 | 3076 | | ld x, 200 |
3077 | 3077 | | } |
3078 | 3078 | | |
3079 | | routine sub | |
3079 | | define sub routine | |
3080 | 3080 | | outputs x |
3081 | 3081 | | trashes foo, a, z, n { |
3082 | 3082 | | ld x, 0 |
3084 | 3084 | | goto foo |
3085 | 3085 | | } |
3086 | 3086 | | |
3087 | | routine main | |
3087 | | define main routine | |
3088 | 3088 | | outputs a |
3089 | 3089 | | trashes foo, x, z, n { |
3090 | 3090 | | call sub |
3105 | 3105 | | trashes a, z, n) |
3106 | 3106 | | table[256] many |
3107 | 3107 | | |
3108 | | routine bar outputs x trashes a, z, n { | |
3108 | | define bar routine outputs x trashes a, z, n { | |
3109 | 3109 | | ld x, 200 |
3110 | 3110 | | } |
3111 | 3111 | | |
3112 | | routine main | |
3112 | | define main routine | |
3113 | 3113 | | inputs one, many |
3114 | 3114 | | outputs one, many |
3115 | 3115 | | trashes a, x, n, z |
3131 | 3131 | | trashes a, z, n) |
3132 | 3132 | | table[256] many |
3133 | 3133 | | |
3134 | | routine bar outputs x trashes a, z, n { | |
3134 | | define bar routine outputs x trashes a, z, n { | |
3135 | 3135 | | ld x, 200 |
3136 | 3136 | | } |
3137 | 3137 | | |
3138 | | routine main | |
3138 | | define main routine | |
3139 | 3139 | | inputs one, many |
3140 | 3140 | | outputs one, many |
3141 | 3141 | | trashes a, x, n, z |
3153 | 3153 | | trashes a, z, n) |
3154 | 3154 | | table[256] many |
3155 | 3155 | | |
3156 | | routine bar outputs x trashes a, z, n { | |
3156 | | define bar routine outputs x trashes a, z, n { | |
3157 | 3157 | | ld x, 200 |
3158 | 3158 | | } |
3159 | 3159 | | |
3160 | | routine main | |
3160 | | define main routine | |
3161 | 3161 | | inputs many |
3162 | 3162 | | outputs many |
3163 | 3163 | | trashes a, x, n, z |
3178 | 3178 | | ld x, 200 |
3179 | 3179 | | } |
3180 | 3180 | | |
3181 | | routine main | |
3181 | | define main routine | |
3182 | 3182 | | inputs many |
3183 | 3183 | | outputs many |
3184 | 3184 | | trashes a, x, n, z |
3202 | 3202 | | |
3203 | 3203 | | vector routine_type vec |
3204 | 3204 | | |
3205 | | routine foo | |
3205 | | define foo routine | |
3206 | 3206 | | inputs x |
3207 | 3207 | | outputs x |
3208 | 3208 | | trashes z, n |
3210 | 3210 | | inc x |
3211 | 3211 | | } |
3212 | 3212 | | |
3213 | | routine main | |
3213 | | define main routine | |
3214 | 3214 | | outputs vec |
3215 | 3215 | | trashes a, z, n |
3216 | 3216 | | { |
3233 | 3233 | | inc x |
3234 | 3234 | | } |
3235 | 3235 | | |
3236 | | routine main | |
3236 | | define main routine | |
3237 | 3237 | | outputs vec |
3238 | 3238 | | trashes a, z, n |
3239 | 3239 | | { |