-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday16_tests.tal
208 lines (177 loc) · 5.85 KB
/
day16_tests.tal
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
~library/macros.tal
~library/devices.tal
( variables )
|0000
|0100 @program
T< "input: >T
S<
"D2FE28 0a ( 110100101111111000101000 )
>S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x01 )
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x01 )
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x00 )
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x01 )
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x00 )
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x00 )
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x01 )
;decoder/get-bit JSR2 DBGBYTE POP ( EXPECT 0x00 )
T< "version: >T
S<
"D2FE28 0a ( 110100101111111000101000 )
>S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/read-version JSR2 DBGBYTE POP ( EXPECT 0x06 )
T< "type: >T
;decoder/read-type JSR2 DBGBYTE POP ( EXPECT 0x04 )
T< "digit: >T
;decoder/read-digit JSR2 DBGBYTEn POP SP DBGBYTE POP
( EXPECT 0x07 0x00 )
;decoder/read-digit JSR2 DBGBYTEn POP SP DBGBYTE POP
( EXPECT 0x0e 0x00 )
;decoder/read-digit JSR2 DBGBYTEn POP SP DBGBYTE POP
( EXPECT 0x05 0x01 )
T< "value: >T
S<
"D2FE28 0a ( 110100101111111000101000 )
>S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/read-version JSR2 DBGBYTEn POP SP
;decoder/read-type JSR2 DBGBYTEn POP SP
;testvar/n1 ;decoder/read-value JSR2
;testvar/n1 ;print64/no-pad JSR2 LF
( EXPECT 0x06 0x04 2021 )
T< "length_type_0: >T
S<
"38006F45291200 0a
>S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/read-version JSR2 DBGBYTEn POP SP
;decoder/read-type JSR2 DBGBYTEn POP SP
;decoder/get-bit JSR2 DBGBYTEn POP SP
;decoder/read-length15 JSR2 DBGSHORTDEC POP2
( EXPECT 0x01 0x06 0x00 27 )
T< "length_type_1: >T
S<
"EE00D40C823060 0a
>S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/read-version JSR2 DBGBYTEn POP SP
;decoder/read-type JSR2 DBGBYTEn POP SP
;decoder/get-bit JSR2 DBGBYTEn POP SP
;decoder/read-count11 JSR2 DBGSHORTDEC POP2
( EXPECT 0x07 0x03 0x01 3 )
T< "print-tree: >T
S< "9C0141080250320F1802104A08 >S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/print-tree JSR2
( EXPECT = )
( EXPECT + )
( EXPECT 1 )
( EXPECT 3 )
( EXPECT * )
( EXPECT 2 )
( EXPECT 2 )
T< "compute+: >T
S< "C200B40A82 >S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/compute JSR2
( EXPECT 1 | 1 )
( EXPECT 2 | 1 2 )
( EXPECT + | 3 )
T< "computem: >T
S< "880086C3E88112 >S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/compute JSR2
( EXPECT 7 | 7 )
( EXPECT 8 | 7 8 )
( EXPECT 9 | 7 8 9 )
( EXPECT m | 7 8 )
( EXPECT m | 7 )
T< "computeM: >T
S< "CE00C43D881120 >S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/compute JSR2
( EXPECT 7 | 7 )
( EXPECT 8 | 7 8 )
( EXPECT 9 | 7 8 9 )
( EXPECT M | 7 9 )
( EXPECT M | 9 )
T< "compute<: >T
S< "D8005AC2A8F0 >S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/compute JSR2
( EXPECT 5 | 5 )
( EXPECT 15 | 5 15 )
( EXPECT < | 1 )
T< "compute>: >T
S< "F600BC2D8F >S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/compute JSR2
( EXPECT 5 | 5 )
( EXPECT 15 | 5 15 )
( EXPECT > | 0 )
T< "compute+*=: >T
S< "9C0141080250320F1802104A08 >S ;make-get-byte JSR2 ;decoder/set-input JSR2
;decoder/compute JSR2
( EXPECT 1 | 1 )
( EXPECT 3 | 1 3 )
( EXPECT + | 4 )
( EXPECT 2 | 4 2 )
( EXPECT 2 | 4 2 2 )
( EXPECT * | 4 4 )
( EXPECT = | 1 )
T< "op-lth<: >T
;testvar/n1 #0001 ;short-to-64 JSR2
;testvar/n2 #0002 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-lth JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 1 )
T< "op-lth=: >T
;testvar/n1 #0003 ;short-to-64 JSR2
;testvar/n2 #0003 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-lth JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 0 )
T< "op-lth>: >T
;testvar/n1 #0004 ;short-to-64 JSR2
;testvar/n2 #0002 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-lth JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 0 )
T< "op-gth<: >T
;testvar/n1 #0001 ;short-to-64 JSR2
;testvar/n2 #0002 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-gth JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 0 )
T< "op-gth=: >T
;testvar/n1 #0003 ;short-to-64 JSR2
;testvar/n2 #0003 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-gth JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 0 )
T< "op-gth>: >T
;testvar/n1 #0004 ;short-to-64 JSR2
;testvar/n2 #0002 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-gth JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 1 )
T< "op-min: >T
;testvar/n1 #2000 ;short-to-64 JSR2
;testvar/n2 #7000 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-min JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 8192 )
T< "op-max: >T
;testvar/n1 #2000 ;short-to-64 JSR2
;testvar/n2 #7000 ;short-to-64 JSR2
;testvar/out ;testvar/n1 ;testvar/n2 ;decoder/op-max JSR2
;testvar/out ;print64/no-pad JSR2 LF
( EXPECT 28672 )
T< "🎄 >T
BRK !
@testvar [ &n1 $8 &n2 $8 &out $8 ]
( s* -- get-byte )
@make-get-byte
;input STA2
;get-byte-from-input
RTN
( -- b )
@get-byte-from-input
[ ;input LDA2 ] LDA STH
[ ;input LDA2 ] INC2 [ ;input STA2 ]
STHr
RTN
@input $2
~library/test.tal
~day16_lib.tal