Browse code

Auto-ported Neralie to new assembler

Andrew Alderwick authored on 22/04/2021 23:40:54
Showing 2 changed files
1 1
deleted file mode 100644
... ...
@@ -1,294 +0,0 @@
1
-(
2
-	app/neralie : clock with arvelie date
3
-
4
-	TODO
5
-		- Implement higher resolution time rather than counting fps
6
-)
7
-
8
-;fps { current 1 next 1 second 1 }
9
-;number { started 1 count 1 }
10
-;lines { x1 2 x2 2 y1 2 y2 2 addr 2 }
11
-;neralie { n0123 2 n4 1 n5 1 n6 1 n7 1 n8 1 n9 1 color 1 x 2 y 2 w 2 h 2 }
12
-;mul { ahi 1 alo 1 bhi 1 blo 1 }
13
-
14
-|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
15
-|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 }
16
-|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
17
-|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 }
18
-
19
-( program )
20
-
21
-|0200
22
-
23
-	( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b
24
-	( vectors ) ,on-screen =Screen.vector
25
-	#01 =fps.current
26
-
27
-	#000c
28
-	DUP2 =lines.x1
29
-	DUP2 =lines.y1
30
-	DUP2 ~Screen.width SWP2 SUB2 #0001 SUB2 =lines.x2
31
-	     ~Screen.height SWP2 SUB2 =lines.y2
32
-
33
-	#02 =neralie.color
34
-	~lines.x1 ~lines.x2
35
-	OVR2 OVR2 ~lines.y1 ,h JSR2
36
-	          ~lines.y2 ,h JSR2
37
-	~lines.y1 #0001 SUB2 ~lines.y2 #0001 ADD2
38
-	OVR2 OVR2 ~lines.x1 ,v JSR2
39
-	          ~lines.x2 ,v JSR2
40
-
41
-@on-screen
42
-	,update-fps JSR2
43
-	#00 =neralie.color
44
-	,neralie-lines JSR2
45
-	,neralie-calc JSR2
46
-	#02 =neralie.color
47
-	,arvelie-text JSR2
48
-	,neralie-text JSR2
49
-	,neralie-lines JSR2
50
-	BRK
51
-
52
-	#22 =Screen.color
53
-	#0000 #00 ~number.count DUP2 ,h JSR2
54
-	~number.count #01 ADD =number.count
55
-
56
-@neralie-calc ( -- )
57
-	( add up fractions of a pulse, store tenths in n6 )
58
-	#0120 #00 ~DateTime.hour MUL2
59
-	#00c0 #00 ~DateTime.minute MUL2 ADD2
60
-	#00f8 #00 ~DateTime.second MUL2 ADD2
61
-	#0271 #00 ~fps.next MUL2 #00 ~fps.current DIV2 #0008 MUL2 ADD2
62
-	#01b0 ,modf JSR2 SWP2 #0017 MUL2 #03e8 DIV2 =neralie.n6 POP
63
-
64
-	( add up units and tens of pulses, store in n5 and n4 )
65
-	#0042 #00 ~DateTime.hour MUL2 ADD2
66
-	#005e #00 ~DateTime.minute MUL2 ADD2
67
-	#000b #00 ~DateTime.second MUL2 ADD2
68
-	#000a ,modf JSR2 SWP2 =neralie.n5 POP
69
-	#000a ,modf JSR2 SWP2 =neralie.n4 POP
70
-
71
-	( add up hundreds of pulses + 10 x beats, store in n0123 )
72
-	#01a0 #00 ~DateTime.hour MUL2 ADD2
73
-	#0006 #00 ~DateTime.minute MUL2 ADD2 =neralie.n0123
74
-
75
-	JMP2r
76
-
77
-@arvelie-text ( -- )
78
-	~Screen.width #0002 DIV2 #0034 SUB2 =Screen.x
79
-	~Screen.height #0008 SUB2 =Screen.y
80
-	~DateTime.year #07d6 SUB2
81
-	#000a ,modf JSR2 ,digit JSR2
82
-	                 ,digit JSR2
83
-	~DateTime.doty
84
-	#000e ,modf JSR2 ^letter JSR
85
-	#000a ,modf JSR2 ^digit JSR
86
-	                 ^digit JSR
87
-	JMP2r
88
-
89
-@neralie-text ( -- )
90
-	~Screen.width #0002 DIV2 #0004 SUB2 =Screen.x
91
-	~neralie.n0123
92
-	#03e8 ,modf JSR2 ^digit JSR
93
-	#0064 ,modf JSR2 ^digit JSR
94
-	#000a ,modf JSR2 ^digit JSR
95
-	           #000b ^digit JSR ( the colon )
96
-	                 ^digit JSR
97
-	#00 ~neralie.n4  ^digit JSR
98
-	#00 ~neralie.n5  ^digit JSR
99
-	JMP2r
100
-
101
-@letter ( index* -- )
102
-	#0008 MUL2 ,font-letters ADD2 =Screen.addr
103
-	^digit-middle JMP
104
-
105
-@digit ( index* -- )
106
-	#0008 MUL2 ,font-numbers ADD2 =Screen.addr
107
-	$middle
108
-	~neralie.color #20 ADD =Screen.color
109
-	~Screen.x #0008 ADD2 =Screen.x
110
-	JMP2r
111
-
112
-@neralie-lines ( -- )
113
-	~lines.x2 ~lines.x1 DUP2 =neralie.x SUB2 =neralie.w
114
-	~lines.y2 ~lines.y1 DUP2 =neralie.y SUB2 =neralie.h
115
-
116
-	,neralie.n4 SWP POP ~neralie.n0123
117
-	DUP2 ,$h JSR2
118
-	,$next JSR2 #0001 =Screen.x ~neralie.y #0003 SUB2 =Screen.y ^digit JSR
119
-	DUP2 ,$v JSR2
120
-	#04 ,v-spacing POK2
121
-	~lines.y1 #0003 SUB2 ~neralie.y ~neralie.x ,v JSR2
122
-	#01 ,v-spacing POK2
123
-	^$next JSR #0001 =Screen.y ~neralie.x #0003 SUB2 =Screen.x ,digit JSR2
124
-	DUP2 ^$h JSR
125
-	^$next JSR ~Screen.width #0009 SUB2 =Screen.x ~neralie.y #0003 SUB2 =Screen.y ,digit JSR2
126
-	DUP2 ^$v JSR
127
-	^$next JSR POP2
128
-	DUP2 ^$h JSR
129
-	^$next JSR POP2
130
-	DUP2 ^$v JSR
131
-	POP2 POP
132
-	JMP2r
133
-
134
-	$next ( digit-addr number* -- next-digit-addr next-number* prev-digit* )
135
-	#03e8 ,modf JSR2 STH2 #000a MUL2
136
-	ROT DUP STH #01 ADD ROT ROT
137
-	#00 STHr PEK ADD2
138
-	STH2r
139
-	JMP2r
140
-
141
-	$h ( number* -- )
142
-	^scale JSR
143
-	~neralie.h ,mul2hi JSR2
144
-	DUP2 #0000 NEQ2 #02 JNZ POP2 JMP2r
145
-	DUP2 ~neralie.y ADD2 =neralie.y
146
-	~neralie.h SWP2 SUB2 =neralie.h
147
-	~neralie.x DUP2 ~neralie.w ADD2 ~neralie.y ^h JMP
148
-
149
-	$v ( number* -- )
150
-	^scale JSR
151
-	~neralie.w ,mul2hi JSR2
152
-	DUP2 #0000 NEQ2 #02 JNZ POP2 JMP2r
153
-	DUP2 ~neralie.x ADD2 =neralie.x
154
-	~neralie.w SWP2 SUB2 =neralie.w
155
-	~neralie.y DUP2 ~neralie.h ADD2 ~neralie.x ^v JMP
156
-
157
-@scale ( 0..10000* -- 0..65535* )
158
-	DUP2 #8db8 ,mul2hi JSR2
159
-	SWP2 #0006 MUL2 ADD2
160
-	JMP2r
161
-
162
-@h ( x1* x2* y* -- )
163
-	=Screen.y
164
-	,Screen.x =lines.addr
165
-	^v-draw-line JMP
166
-
167
-@v ( y1* y2* x* -- )
168
-	=Screen.x
169
-	,Screen.y =lines.addr
170
-
171
-	$draw-line ( v1* v2* -- )
172
-	OVR2 OVR2 LTH2 #01 JNZ SWP2
173
-	STH2
174
-
175
-	$loop
176
-	LIT2 [ 00 ] $spacing [ 01 ] ADD2
177
-	DUP2 DUP2r STH2r LTH2 ^$keep-going JNZ
178
-	POP2 POP2r
179
-	JMP2r
180
-
181
-	$keep-going
182
-	DUP2 ~lines.addr STR2
183
-	~neralie.color =Screen.color
184
-	^$loop JMP
185
-
186
-@update-fps ( -- )
187
-	#00 =DateTime.refresh
188
-	~fps.next #01 ADD =fps.next
189
-	~DateTime.second ~fps.second NEQ JMP JMP2r
190
-	~DateTime.second =fps.second
191
-	~fps.next =fps.current
192
-
193
-	( ~fps.next ^print-byte-decimal JSR
194
-	,strings-fps ^print-string JSR )
195
-
196
-	#00 =fps.next
197
-	JMP2r
198
-
199
-@print-string ( string* -- )
200
-	DUP2 PEK2 DUP ^$not-end JNZ
201
-	POP POP2 JMP2r
202
-
203
-	$not-end
204
-	=Console.char
205
-	#0001 ADD2 ^print-string JMP
206
-
207
-@print-byte-decimal ( byte -- )
208
-	#00 =number.started
209
-	#00 SWP
210
-	^print-short-decimal-byte-start JMP
211
-
212
-@print-short-decimal ( short* -- )
213
-	#00 =number.started
214
-	#2710 ^modf JSR ^$digit JSR
215
-	#03e8 ^modf JSR ^$digit JSR
216
-	$byte-start
217
-	#0064 ^modf JSR ^$digit JSR
218
-	#000a ^modf JSR ^$digit JSR
219
-	                ^$digit JSR
220
-	~number.started ^$end JNZ
221
-	#30 =Console.char
222
-	$end JMP2r
223
-
224
-	$digit
225
-	SWP POP
226
-	DUP ~number.started ORA #02 JNZ
227
-	POP JMP2r
228
-	#30 ADD =Console.char
229
-	#01 =number.started
230
-	JMP2r
231
-
232
-@modf ( dividend* divisor* -- remainder* quotient* )
233
-	OVR2 OVR2 DIV2 DUP2 STH2 MUL2 SUB2 STH2r JMP2r
234
-
235
-@mul2hi ( a* b* -- product-top-16-bits* )
236
-	(
237
-		Multiplying two 16-bit numbers yields a 32-bit number.
238
-		MUL2 returns the lowest 16 bits, we want the highest.
239
-
240
-		We split each short into hi and lo bytes, then sum
241
-		the following multiplications:
242
-
243
-		31..24 23..16 15..08 07..00
244
-		{ ahi * bhi }
245
-		       { alo * bhi }
246
-		       { ahi * blo }
247
-		              { alo * blo }
248
-
249
-		Bits 07..00 can be ignored, but each sum in bits 23..16
250
-		can end up overflowing into bit 24.
251
-	)
252
-	,mul.bhi STR2 ,mul.ahi STR2
253
-	#00
254
-		#00
255
-			#00 ~mul.alo #00 ~mul.blo MUL2
256
-		POP
257
-		#00 ~mul.ahi #00 ~mul.blo MUL2 ^$adc JSR
258
-		#00 ~mul.alo #00 ~mul.bhi MUL2 ^$adc JSR
259
-	POP
260
-	#00 ~mul.ahi #00 ~mul.bhi MUL2 ADD2
261
-	JMP2r
262
-
263
-	$adc ( 31..24 a* b* -- 31..24 sum* )
264
-	OVR2 ADD2 SWP2 OVR2
265
-	GTH2 ^$carry JNZ
266
-	JMP2r
267
-	$carry
268
-	ROT #01 ADD ROT ROT
269
-	JMP2r
270
-
271
-@strings
272
-	$fps [ 20 fps 0a 00 ]
273
-
274
-@font-numbers
275
-[
276
-	7cc6 ced6 e6c6 7c00 1838 1818 1818 7e00 3c66 063c 6066 7e00
277
-	3c66 061c 0666 3c00 1c3c 6ccc fe0c 1e00 7e62 607c 0666 3c00
278
-	3c66 607c 6666 3c00 7e66 060c 1818 1800 3c66 663c 6666 3c00
279
-	3c66 663e 0666 3c00 7cc6 ced6 e6c6 7c00 0018 1800 1818 0000
280
-]
281
-
282
-@font-letters
283
-[
284
-	183c 6666 7e66 6600 fc66 667c 6666 fc00 3c66 c0c0 c066 3c00
285
-	f86c 6666 666c f800 fe62 6878 6862 fe00 fe62 6878 6860 f000
286
-	3c66 c0c0 ce66 3e00 6666 667e 6666 6600 7e18 1818 1818 7e00
287
-	1e0c 0c0c cccc 7800 e666 6c78 6c66 e600 f060 6060 6266 fe00
288
-	c6ee fefe d6c6 c600 c6e6 f6de cec6 c600 386c c6c6 c66c 3800
289
-	fc66 667c 6060 f000 386c c6c6 dacc 7600 fc66 667c 6c66 e600
290
-	3c66 603c 0666 3c00 7e5a 1818 1818 3c00 6666 6666 6666 3c00
291
-	6666 6666 663c 1800 c6c6 c6d6 feee c600 c66c 3838 6cc6 c600
292
-	6666 663c 1818 3c00 fec6 8c18 3266 fe00 0018 187e 1818 0000
293
-]
294
-
295 0
new file mode 100644
... ...
@@ -0,0 +1,301 @@
1
+(
2
+	app/neralie : clock with arvelie date
3
+
4
+	TODO
5
+		- Implement higher resolution time rather than counting fps
6
+)
7
+
8
+( devices )
9
+
10
+|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
11
+|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
12
+|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
13
+|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ]
14
+
15
+( variables )
16
+
17
+|0000
18
+
19
+@fps [ &current $1 &next $1 &second $1 ]
20
+@number [ &started $1 &count $1 ]
21
+@lines [ &x1 $2 &x2 $2 &y1 $2 &y2 $2 &addr $1 ]
22
+@neralie [ &n0123 $2 &n4 $1 &n5 $1 &n6 $1 &n7 $1 &n8 $1 &n9 $1 &color $1 &x $2 &y $2 &w $2 &h $2 ]
23
+@mul [ &ahi $1 &alo $1 &bhi $1 &blo $1 ]
24
+
25
+( program )
26
+
27
+|0100
28
+
29
+	( theme )  #03fd .System/r DEO2 #0ef3 .System/g DEO2 #0bf2 .System/b DEO2
30
+	( vectors )  ;on-screen .Screen/vector DEO2
31
+	#01 .fps/current POK
32
+
33
+	#000c
34
+	DUP2 .lines/x1 POK2
35
+	DUP2 .lines/y1 POK2
36
+	DUP2 .Screen/width DEI2 SWP2 SUB2 #0001 SUB2 .lines/x2 POK2
37
+	     .Screen/height DEI2 SWP2 SUB2 .lines/y2 POK2
38
+
39
+	#02 .neralie/color POK
40
+	.lines/x1 PEK2 .lines/x2 PEK2
41
+	OVR2 OVR2 .lines/y1 PEK2 ;h JSR2
42
+	          .lines/y2 PEK2 ;h JSR2
43
+	.lines/y1 PEK2 #0001 SUB2 .lines/y2 PEK2 #0001 ADD2
44
+	OVR2 OVR2 .lines/x1 PEK2 ;v JSR2
45
+	          .lines/x2 PEK2 ;v JSR2
46
+
47
+@on-screen
48
+	;update-fps JSR2
49
+	#00 .neralie/color POK
50
+	;neralie-lines JSR2
51
+	;neralie-calc JSR2
52
+	#02 .neralie/color POK
53
+	;arvelie-text JSR2
54
+	;neralie-text JSR2
55
+	;neralie-lines JSR2
56
+	BRK
57
+
58
+	#22 .Screen/color DEO
59
+	#0000 #00 .number/count PEK DUP2 ;h JSR2
60
+	.number/count PEK #01 ADD .number/count POK
61
+
62
+@neralie-calc ( -- )
63
+	( add up fractions of a pulse, store tenths in n6 )
64
+	#0120 #00 .DateTime/hour DEI MUL2
65
+	#00c0 #00 .DateTime/minute DEI MUL2 ADD2
66
+	#00f8 #00 .DateTime/second DEI MUL2 ADD2
67
+	#0271 #00 .fps/next PEK MUL2 #00 .fps/current PEK DIV2 #0008 MUL2 ADD2
68
+	#01b0 ;modf JSR2 SWP2 #0017 MUL2 #03e8 DIV2 .neralie/n6 POK POP
69
+
70
+	( add up units and tens of pulses, store in n5 and n4 )
71
+	#0042 #00 .DateTime/hour DEI MUL2 ADD2
72
+	#005e #00 .DateTime/minute DEI MUL2 ADD2
73
+	#000b #00 .DateTime/second DEI MUL2 ADD2
74
+	#000a ;modf JSR2 SWP2 .neralie/n5 POK POP
75
+	#000a ;modf JSR2 SWP2 .neralie/n4 POK POP
76
+
77
+	( add up hundreds of pulses + 10 x beats, store in n0123 )
78
+	#01a0 #00 .DateTime/hour DEI MUL2 ADD2
79
+	#0006 #00 .DateTime/minute DEI MUL2 ADD2 .neralie/n0123 POK2
80
+
81
+	JMP2r
82
+
83
+@arvelie-text ( -- )
84
+	.Screen/width DEI2 #0002 DIV2 #0034 SUB2 .Screen/x DEO2
85
+	.Screen/height DEI2 #0008 SUB2 .Screen/y DEO2
86
+	.DateTime/year DEI2 #07d6 SUB2
87
+	#000a ;modf JSR2 ;digit JSR2
88
+	                 ;digit JSR2
89
+	.DateTime/doty DEI2
90
+	#000e ;modf JSR2 ,letter JSR
91
+	#000a ;modf JSR2 ,digit JSR
92
+	                 ,digit JSR
93
+	JMP2r
94
+
95
+@neralie-text ( -- )
96
+	.Screen/width DEI2 #0002 DIV2 #0004 SUB2 .Screen/x DEO2
97
+	.neralie/n0123 PEK2
98
+	#03e8 ;modf JSR2 ,digit JSR
99
+	#0064 ;modf JSR2 ,digit JSR
100
+	#000a ;modf JSR2 ,digit JSR
101
+	           #000b ,digit JSR ( the colon )
102
+	                 ,digit JSR
103
+	#00 .neralie/n4 PEK  ,digit JSR
104
+	#00 .neralie/n5 PEK  ,digit JSR
105
+	JMP2r
106
+
107
+@letter ( index* -- )
108
+	#0008 MUL2 ;font-letters ADD2 .Screen/addr DEO2
109
+	,digit/middle JMP
110
+
111
+@digit ( index* -- )
112
+	#0008 MUL2 ;font-numbers ADD2 .Screen/addr DEO2
113
+	&middle
114
+	.neralie/color PEK #20 ADD .Screen/color DEO
115
+	.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
116
+	JMP2r
117
+
118
+@neralie-lines ( -- )
119
+	.lines/x2 PEK2 .lines/x1 PEK2 DUP2 .neralie/x POK2 SUB2 .neralie/w POK2
120
+	.lines/y2 PEK2 .lines/y1 PEK2 DUP2 .neralie/y POK2 SUB2 .neralie/h POK2
121
+
122
+	;neralie/n4 SWP POP .neralie/n0123 PEK2
123
+	DUP2 ;&h JSR2
124
+	;&next JSR2 #0001 .Screen/x DEO2 .neralie/y PEK2 #0003 SUB2 .Screen/y DEO2 ,digit JSR
125
+	DUP2 ;&v JSR2
126
+	#04 ;v/spacing PUT
127
+	.lines/y1 PEK2 #0003 SUB2 .neralie/y PEK2 .neralie/x PEK2 ;v JSR2
128
+	#01 ;v/spacing PUT
129
+	,&next JSR #0001 .Screen/y DEO2 .neralie/x PEK2 #0003 SUB2 .Screen/x DEO2 ;digit JSR2
130
+	DUP2 ,&h JSR
131
+	,&next JSR .Screen/width DEI2 #0009 SUB2 .Screen/x DEO2 .neralie/y PEK2 #0003 SUB2 .Screen/y DEO2 ;digit JSR2
132
+	DUP2 ,&v JSR
133
+	,&next JSR POP2
134
+	DUP2 ,&h JSR
135
+	,&next JSR POP2
136
+	DUP2 ,&v JSR
137
+	POP2 POP
138
+	JMP2r
139
+
140
+	&next ( digit-addr number* -- next-digit-addr next-number* prev-digit* )
141
+	#03e8 ;modf JSR2 STH2 #000a MUL2
142
+	ROT DUP STH #01 ADD ROT ROT
143
+	#00 STHr PEK ADD2
144
+	STH2r
145
+	JMP2r
146
+
147
+	&h ( number* -- )
148
+	,scale JSR
149
+	.neralie/h PEK2 ;mul2hi JSR2
150
+	DUP2 #0000 NEQ2 #02 JNZ POP2 JMP2r
151
+	DUP2 .neralie/y PEK2 ADD2 .neralie/y POK2
152
+	.neralie/h PEK2 SWP2 SUB2 .neralie/h POK2
153
+	.neralie/x PEK2 DUP2 .neralie/w PEK2 ADD2 .neralie/y PEK2 ,h JMP
154
+
155
+	&v ( number* -- )
156
+	,scale JSR
157
+	.neralie/w PEK2 ;mul2hi JSR2
158
+	DUP2 #0000 NEQ2 #02 JNZ POP2 JMP2r
159
+	DUP2 .neralie/x PEK2 ADD2 .neralie/x POK2
160
+	.neralie/w PEK2 SWP2 SUB2 .neralie/w POK2
161
+	.neralie/y PEK2 DUP2 .neralie/h PEK2 ADD2 .neralie/x PEK2 ,v JMP
162
+
163
+@scale ( 0..10000* -- 0..65535* )
164
+	DUP2 #8db8 ;mul2hi JSR2
165
+	SWP2 #0006 MUL2 ADD2
166
+	JMP2r
167
+
168
+@h ( x1* x2* y* -- )
169
+	.Screen/y DEO2
170
+	.Screen/x .lines/addr POK
171
+	,v/draw-line JMP
172
+
173
+@v ( y1* y2* x* -- )
174
+	.Screen/x DEO2
175
+	.Screen/y .lines/addr POK
176
+
177
+	&draw-line ( v1* v2* -- )
178
+	OVR2 OVR2 LTH2 #01 JNZ SWP2
179
+	STH2
180
+
181
+	&loop
182
+	LIT2 [ 00 ] &spacing [ 01 ] ADD2
183
+	DUP2 DUP2r STH2r LTH2 ,&keep-going JNZ
184
+	POP2 POP2r
185
+	JMP2r
186
+
187
+	&keep-going
188
+	DUP2 .lines/addr PEK DEO2
189
+	.neralie/color PEK .Screen/color DEO
190
+	,&loop JMP
191
+
192
+@update-fps ( -- )
193
+	#00 .DateTime/refresh DEO
194
+	.fps/next PEK #01 ADD .fps/next POK
195
+	.DateTime/second DEI .fps/second PEK NEQ JMP JMP2r
196
+	.DateTime/second DEI .fps/second POK
197
+	.fps/next PEK .fps/current POK
198
+
199
+	( ~fps.next ^print-byte-decimal JSR
200
+	,strings-fps ^print-string JSR )
201
+
202
+	#00 .fps/next POK
203
+	JMP2r
204
+
205
+@print-string ( string* -- )
206
+	DUP2 GET DUP ,&not-end JNZ
207
+	POP POP2 JMP2r
208
+
209
+	&not-end
210
+	.Console/char DEO
211
+	#0001 ADD2 ,print-string JMP
212
+
213
+@print-byte-decimal ( byte -- )
214
+	#00 .number/started POK
215
+	#00 SWP
216
+	,print-short-decimal/byte-start JMP
217
+
218
+@print-short-decimal ( short* -- )
219
+	#00 .number/started POK
220
+	#2710 ,modf JSR ,&digit JSR
221
+	#03e8 ,modf JSR ,&digit JSR
222
+	&byte-start
223
+	#0064 ,modf JSR ,&digit JSR
224
+	#000a ,modf JSR ,&digit JSR
225
+	                ,&digit JSR
226
+	.number/started PEK ,&end JNZ
227
+	#30 .Console/char DEO
228
+	&end JMP2r
229
+
230
+	&digit
231
+	SWP POP
232
+	DUP .number/started PEK ORA #02 JNZ
233
+	POP JMP2r
234
+	#30 ADD .Console/char DEO
235
+	#01 .number/started POK
236
+	JMP2r
237
+
238
+@modf ( dividend* divisor* -- remainder* quotient* )
239
+	OVR2 OVR2 DIV2 DUP2 STH2 MUL2 SUB2 STH2r JMP2r
240
+
241
+@mul2hi ( a* b* -- product-top-16-bits* )
242
+	(
243
+		Multiplying two 16-bit numbers yields a 32-bit number.
244
+		MUL2 returns the lowest 16 bits, we want the highest.
245
+
246
+		We split each short into hi and lo bytes, then sum
247
+		the following multiplications:
248
+
249
+		31..24 23..16 15..08 07..00
250
+		{ ahi * bhi }
251
+		       { alo * bhi }
252
+		       { ahi * blo }
253
+		              { alo * blo }
254
+
255
+		Bits 07..00 can be ignored, but each sum in bits 23..16
256
+		can end up overflowing into bit 24.
257
+	)
258
+	
259
+	;mul/bhi PUT2 ;mul/ahi PUT2
260
+	#00
261
+		#00
262
+			#00 .mul/alo PEK #00 .mul/blo PEK MUL2
263
+		POP
264
+		#00 .mul/ahi PEK #00 .mul/blo PEK MUL2 ,&adc JSR
265
+		#00 .mul/alo PEK #00 .mul/bhi PEK MUL2 ,&adc JSR
266
+	POP
267
+	#00 .mul/ahi PEK #00 .mul/bhi PEK MUL2 ADD2
268
+	JMP2r
269
+
270
+	&adc ( 31..24 a* b* -- 31..24 sum* )
271
+	OVR2 ADD2 SWP2 OVR2
272
+	GTH2 ,&carry JNZ
273
+	JMP2r
274
+	&carry
275
+	ROT #01 ADD ROT ROT
276
+	JMP2r
277
+
278
+@strings
279
+	&fps [ 20 "fps 0a 00 ]
280
+
281
+@font-numbers
282
+[
283
+	7cc6 ced6 e6c6 7c00 1838 1818 1818 7e00 3c66 063c 6066 7e00
284
+	3c66 061c 0666 3c00 1c3c 6ccc fe0c 1e00 7e62 607c 0666 3c00
285
+	3c66 607c 6666 3c00 7e66 060c 1818 1800 3c66 663c 6666 3c00
286
+	3c66 663e 0666 3c00 7cc6 ced6 e6c6 7c00 0018 1800 1818 0000
287
+]
288
+
289
+@font-letters
290
+[
291
+	183c 6666 7e66 6600 fc66 667c 6666 fc00 3c66 c0c0 c066 3c00
292
+	f86c 6666 666c f800 fe62 6878 6862 fe00 fe62 6878 6860 f000
293
+	3c66 c0c0 ce66 3e00 6666 667e 6666 6600 7e18 1818 1818 7e00
294
+	1e0c 0c0c cccc 7800 e666 6c78 6c66 e600 f060 6060 6266 fe00
295
+	c6ee fefe d6c6 c600 c6e6 f6de cec6 c600 386c c6c6 c66c 3800
296
+	fc66 667c 6060 f000 386c c6c6 dacc 7600 fc66 667c 6c66 e600
297
+	3c66 603c 0666 3c00 7e5a 1818 1818 3c00 6666 6666 6666 3c00
298
+	6666 6666 663c 1800 c6c6 c6d6 feee c600 c66c 3838 6cc6 c600
299
+	6666 663c 1818 3c00 fec6 8c18 3266 fe00 0018 187e 1818 0000
300
+]
301
+