Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:16 2018                                                                                               Page    1
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
          2500 A.D. 65816 Macro Assembler #26960 - Version 5.02g
10
          -----------------------------------------------------
11
 
12
                       Input  Filename : src\F8\fpuemu.asm
13
                       Output Filename : obj\F8\fpuemu.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2588                        	.LIST		on
18
 2589
19
 2590
20
 2591                        	;----------------------------------------------------------
21
 2592                        	; variabili in Direct-Page 02
22
 2593                        	;----------------------------------------------------------
23
 2594  F8FFB1
24
 2595  F8FFB1                		.INCLUDE inc\dirp02.inc
25
 2596                        	;----------------------------------------------------------
26
 2597                        	; DIRP02.ASM
27
 2598                        	; PROGETTO: B1601
28
 2599                        	;
29
 2600                        	; Variabili in Direct Page $02
30
 2601                        	;----------------------------------------------------------
31
 2602
32
 2603                        	; sezione COMMON -- questo permette di includere il file in piu' file
33
 2604
34
 2605                        	DIRP02:	.SECTION page0, ref_only, common	;Direct-Page 02
35
 2606
36
 2607  000000                		.ABSOLUTE		;; inizia sempre da $00
37
 2608  000000                		.ORG		0x00
38
 2609  000000
39
 2610                        	; variabili usate nella funzione _vprintl e famiglia funzioni di formattazione
40
 2611  000000  0000          	FmtParm		.DW		;; ptr array parametri banco 0
41
 2612  000002                	FmtLPFmt	LP		;; long ptr stringa szFmt
42
 2613  000005                	FmtLPPut	LP		;; long ptr funzione 'putter'
43
 2614  000008  00            	FmtSpec		.DB		;; indice '%' corrente in szFmt
44
 2615  000009  00            	FmtWidth	.DB		;; campo width
45
 2616  00000A  00            	FmtPrec		.DB		;; campo precision
46
 2617  00000B  00            	FmtFlag		.DB		;; flag formattazione
47
 2618  00000C  00            	FmtSgn		.DB		;; segno positivo (se 0 -> no segno)
48
 2619  00000D  00            	VStoreF		.DB		;; flag modo store
49
 2620  00000E  00            	FmtMod		.DB		;; flag modificatori
50
 2621  00000F  00            	FmtDst		.DB		;; ptr stringa szDst banco 0
51
 2622
52
 2623  000010  0000          	FmtCnt		.DW		;; contatore caratteri
53
 2624  000012  0000          	FmtGMax		.DW		;; max. len stringa globale
54
 2625  000014
55
 2626  000014  0000          	XVDec		.DW		; esponente decimale (signed)
56
 2627  000016  00            	XVFlag		.DB		; flag per conversioni numeriche
57
 2628  000017
58
 2629  000017  00            	ACMCmps		.DB		; flag compare segno e tipo (intero)
59
 2630
60
 2631  000018                	ACM		DQ		; accumulatore #1 integer 64 bit
61
 2632  000020  00            	ACMSize		.DB		; size
62
 2633  000021  00            	ACMSgn		.DB		; <7>:segno, <6>:tipo signed
63
  Tue Jul 17 11:00:16 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2634  000022  00            	ACMMinSize	.DB		; minima dimensione richiesta per ACM
69
 2635  000023  00            	IARGMinSize	.DB
70
 2636
71
 2637  000024  00            	FPTmp1		.DB		; byte temporaneo
72
 2638  000025  00            	FPTmp2		.DB		; byte temporaneo
73
 2639  000026  00            	FPTmp3		.DB		; byte temporaneo
74
 2640  000027  00            	FPTmp4		.DB		; byte temporaneo
75
 2641
76
 2642  000028                	IARG		DQ		; accumulatore #2 integer 64 bit
77
 2643  000030  00            	IARGSize	.DB		; size
78
 2644  000031  00            	IARGSgn		.DB		; <7>:segno, <6>:tipo signed
79
 2645
80
 2646  000032                	FOP		DS	9	; temporaneo per FDIV/FMULT/integer MULT/DIV
81
 2647                        					; conversione integer -> string
82
 2648  00003B  00            	FPIndx		.DB		; byte generico indice
83
 2649  00003C  0000          	FPWTmp7		.DW		; word temporanea
84
 2650  00003E  0000          	FPWTmp8		.DW		; word temporanea
85
 2651
86
 2652                        	; variabili temporanee sovrapposte a FOP
87
 2653          000036        	FACXM		.EQU	FOP+4	; byte temporaneo
88
 2654          000037        	ARGXM		.EQU	FOP+5	; byte temporaneo
89
 2655          000038        	FPWTmp5		.EQU	FOP+6	; word temporanea
90
 2656          00003A        	FPTmp6		.EQU	FOP+8	; byte temporaneo
91
 2657
92
 2658                        	; Floating Point Accumulator #1 - FAC
93
 2659  000040  00            	FACSGN		.DB		; FAC mantissa sign
94
 2660  000041  00            	FACEXT		.DB		; FAC 8 bit extension (rounding)
95
 2661  000042                	FACM		DQ		; FAC Mantissa (64 bit)
96
 2662  00004A  0000          	FACExp		.DW		; FAC Exponent
97
 2663          00004A        	FACEXPL		.EQU	FACExp		; FAC Exponent Low
98
 2664          00004B        	FACEXPH		.EQU	FACExp+1	; FAC Exponent Hi
99
 2665
100
 2666  00004C  00            	FACSCMP		.DB		; Sign Comparison Result: FAC vs ARG
101
 2667  00004D  00            	FACMlt		.DB		; flag MULT
102
 2668  00004E  00            	FACUndf		.DB		; conteggio shift per underflow
103
 2669  00004F  00            	FPDCnt		.DB		; contatore per inserzione punto decimale
104
 2670  000050
105
 2671                        	; Floating Point Accumulator #2 - ARG
106
 2672  000050  00            	ARGSGN		.DB		; ARG mantissa sign
107
 2673  000051  00            	ARGEXT		.DB		; ARG 8 bit extension (rounding)
108
 2674  000052                	ARGM		DQ		; ARG Mantissa (64 bit)
109
 2675  00005A  0000          	ARGExp		.DW		; ARG Exponent
110
 2676          00005A        	ARGEXPL		.EQU	ARGExp		; ARG Exponent Low
111
 2677          00005B        	ARGEXPH		.EQU	ARGExp+1	; ARG Exponent Hi
112
 2678
113
 2679                        	; numero bytes FAC
114
 2680          00000A        	FACSIZE		.EQU	(FACEXPH - FACEXT)
115
 2681          000008        	MANTSIZE	.EQU	(FACSIZE - 2)
116
 2682          000040        	FACMBITS	.EQU	(MANTSIZE * 8)
117
 2683          000041        	FAC		.EQU	FACEXT
118
 2684          000051        	ARG		.EQU	ARGEXT
119
 2685
120
 2686  00005C  0000          	FPWTmp		.DW
121
 2687  00005E  0000          	FPExp		.DW		; esponente conversioni str/float
122
 2688  000060                	FPLPtr		LP		; long ptr operazioni move
123
 2689  000063  00            	FPFlag		.DB		; flag generico operazioni FPU
124
 2690  000064                	FACTmp		.DS	12	; registro FAC temporaneo (con sgn ed ext)
125
  Tue Jul 17 11:00:16 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2691
131
 2692                        	; buffer per conversione da int/float a string (20 digit + 2)
132
 2693          000016        	FPSTRSIZE	.EQU	22
133
 2694  000070                	FPUStr		.DS	FPSTRSIZE
134
 2695
135
 2696                        	; buffer per formattazione int/float
136
 2697          000030        	XFSTRSIZE	.EQU	48
137
 2698  000086                	XCVTStr		.DS	XFSTRSIZE
138
 2699          0000B5        	XCVTStrEnd	.EQU	($ - 1)
139
 2700
140
 2701  0000B6                	DUMMY100	.DS	22
141
 2702
142
 2703          000060        	PTR1	.EQU	FPLPtr		; long ptr operazioni 'move'
143
 2704          000063        	FPFLAG	.EQU	FPFlag
144
 2705          00004F        	FPDCNT	.EQU	FPDCnt
145
 2706  0000CC
146
 2707  0000CC                		.RELATIVE
147
 2708
148
 2709                        		.ENDS
149
 2710
150
 2711          FFFFB0        	MAXMANTSHIFT	.EQU	(-(FACMBITS + 16))	; max. shift divisione mant.
151
 2712          00002F        	XCVTMAXF	.EQU	(XFSTRSIZE - 1)		; max. caratteri formato F
152
 2713          000027        	XCVTMAXE	.EQU	(XCVTMAXF -  8)		; max. caratteri formato E
153
 2714          00002E        	XCVTMAXI	.EQU	(XFSTRSIZE - 2)		; max. caratteri stringa int.
154
 2715
155
 2716  F8FFB1
156
 2717
157
 2718  F8FFB1
158
 2719                        	;----------------------------------------------------------
159
 2720                        	; segmento codice banco $F8
160
 2721                        	;----------------------------------------------------------
161
 2722
162
 2723                        		.CODEF8
163
 2724                        		.EXTERN _UI2Str, _iSMult16, Byte2Hex
164
 2725                        		.GLOBAL _Str2Fl, _MovRndF2A, _feMUL, _MovRF2Mem, _MovMem2A, _feDIV
165
 2726                        		.GLOBAL _feSUB, _feADD, _feFAC2S, _MovMem2Fa
166
 2727
167
 2728          003FFF        	EXPBIAS		.EQU	$3FFF		; bias esponente
168
 2729          007FFF        	EXPINF		.EQU	$7FFF		; esponente INF e NAN
169
 2730          008000        	MANTINF		.EQU	$8000		; mantissa INF
170
 2731          00FF00        	MANTNAN		.EQU	$FF00		; mantissa NAN
171
 2732          004006        	BIASBYTE	.EQU 	(EXPBIAS + 7)	; bias BYTE (8 bit)
172
 2733          00400E        	BIASWORD	.EQU 	(BIASBYTE + 8)	; bias WORD (16 bit)
173
 2734          00401E        	BIASDWORD	.EQU 	(BIASWORD + 16)	; bias DWORD (32 bit)
174
 2735          00403E        	BIASQWORD	.EQU 	(BIASDWORD + 32); bias QWORD (64 bit)
175
 2736          003FFF        	MAXPEXP		.EQU	EXPBIAS		; massimo esponente positivo
176
 2737          FFC001        	MINNEXP		.EQU	-(EXPBIAS)	; minimo esponente negativo
177
 2738          004D10        	LOG2H		.EQU	19728		; LG(2) * $10000
178
 2739          001387        	EXP10LIM	.EQU	4999		; limite esponente in FStr2Float
179
 2740          000013        	MAXDIGITS	.EQU	19		; max. numero cifre decimali
180
 2741          000014        	MAXINTDGTS	.EQU	20		; max. cifre unsigned int
181
 2742          00007F        	MAXDECSTR	.EQU	127
182
 2743          000007        	MAXFEXP		.EQU	7		; max. esp. dec. negativo formato G/F
183
 2744          000024        	MAXFDEC		.EQU	36		; max. esp. decimale positivo form. F
184
 2745
185
 2746                        		.LONGA	off
186
 2747                        		.LONGI	off
187
  Tue Jul 17 11:00:16 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2748
193
 2749
194
 2750  F83387                	_test1:
195
 2751                        		.EXTERN fpmult, fpdiv, ldfac, ldarg, fround
196
 2752  F83387
197
 2753  F83387  8B            		phb			; salva DBR
198
 2754  F83388  0B            		phd			; salva DPR
199
 2755  F83389  F4 00 02      		pea	#DP02ADDR	; imposta DPR a pag 2
200
 2756  F8338C  2B            		pld
201
 2757  F8338D  A0 00         		ldy	#0
202
 2758  F8338F  5A            		phy
203
 2759  F83390  AB            		plb			; imposta DBR su banco 0
204
 2760
205
 2761  F83391  A0 F8         		ldy	#^?510		; ARG = 1.0
206
 2762  F83393  A9 36         		lda	#>?510
207
 2763  F83395  EB            		xba
208
 2764  F83396  A9 D2         		lda	#<?510
209
 2765  F83398  20 62 3D      		jsr	_MovMem2F
210
 2766  F8339B  A0 F8         		ldy	#^?500		; ARG = 1.0
211
 2767  F8339D  A9 36         		lda	#>?510
212
 2768  F8339F  EB            		xba
213
 2769  F833A0  A9 DC         		lda	#<?500
214
 2770  F833A2  20 98 3D      		jsr	_MovMem2A
215
 2771  F833A5  20 30 3A      		jsr	_feDIV		; FAC=ARG/FAC
216
 2772  F833A8  20 43 38      		jsr	_Round
217
 2773  F833AB
218
 2774  F833AB  0B            		phd
219
 2775  F833AC  F4 00 3F      		pea	#$3f00
220
 2776  F833AF  2B            		pld
221
 2777  F833B0  A0 F8         		ldy	#^?610		; ARG = 1.0
222
 2778  F833B2  A9 36         		lda	#>?610
223
 2779  F833B4  EB            		xba
224
 2780  F833B5  A9 F2         		lda	#<?610
225
 2781  F833B7  20 82 86      		jsr	ldfac
226
 2782  F833BA  A0 F8         		ldy	#^?600		; ARG = 1.0
227
 2783  F833BC  A9 36         		lda	#>?600
228
 2784  F833BE  EB            		xba
229
 2785  F833BF  A9 E6         		lda	#<?600
230
 2786  F833C1  20 CF 86      		jsr	ldarg
231
 2787  F833C4  20 DD 49      		jsr	fpmult		; FAC=ARG/FAC
232
 2788  F833C7  20 FA 4F      		jsr	fround
233
 2789  F833CA  2B            		pld
234
 2790  F833CB  2B            		pld
235
 2791  F833CC  AB            		plb
236
 2792  F833CD  00 00         		brk
237
 2793
238
 2794  F833CF  4B            		phk
239
 2795  F833D0  F4 A0 36      		pea	#?400
240
 2796  F833D3  4B            		phk
241
 2797  F833D4  F4 5A 36      		pea	#?210
242
 2798  F833D7  A9 07         		lda	#7
243
 2799  F833D9  48            		pha
244
 2800  F833DA                		BPRINTF
245
 2801  F833DA  02 11         		cop	$11
246
 2802                        		.MNLIST
247
 2803  F833DC  4B            		phk
248
 2804  F833DD  F4 AA 36      		pea	#?410
249
  Tue Jul 17 11:00:16 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2805  F833E0  4B            		phk
255
 2806  F833E1  F4 5A 36      		pea	#?210
256
 2807  F833E4  A9 07         		lda	#7
257
 2808  F833E6  48            		pha
258
 2809  F833E7                		BPRINTF
259
 2810  F833E7  02 11         		cop	$11
260
 2811                        		.MNLIST
261
 2812
262
 2813  F833E9  A9 36         		lda	#>?100		; 1.0
263
 2814  F833EB  EB            		xba
264
 2815  F833EC  A9 29         		lda	#<?100
265
 2816  F833EE  A2 F8         		ldx	#^?100
266
 2817  F833F0  20 5A 3F      		jsr	_Str2Fl
267
 2818  F833F3  A0 20         		ldy	#$20
268
 2819  F833F5  A9 00         		lda	#0
269
 2820  F833F7  EB            		xba
270
 2821  F833F8  A9 00         		lda	#0
271
 2822  F833FA  20 26 3D      		jsr	_MovRF2Mem
272
 2823  F833FD
273
 2824  F833FD  A9 36         		lda	#>?105		; 1.0001
274
 2825  F833FF  EB            		xba
275
 2826  F83400  A9 2D         		lda	#<?105
276
 2827  F83402  A2 F8         		ldx	#^?105
277
 2828  F83404  20 5A 3F      		jsr	_Str2Fl
278
 2829  F83407  A0 20         		ldy	#$20
279
 2830  F83409  A9 00         		lda	#0
280
 2831  F8340B  EB            		xba
281
 2832  F8340C  A9 10         		lda	#$10
282
 2833  F8340E  20 26 3D      		jsr	_MovRF2Mem
283
 2834
284
 2835  F83411  A9 36         		lda	#>?110		; 0.9999
285
 2836  F83413  EB            		xba
286
 2837  F83414  A9 37         		lda	#<?110
287
 2838  F83416  A2 F8         		ldx	#^?110
288
 2839  F83418  20 5A 3F      		jsr	_Str2Fl
289
 2840  F8341B  A0 20         		ldy	#$20
290
 2841  F8341D  A9 00         		lda	#0
291
 2842  F8341F  EB            		xba
292
 2843  F83420  A9 20         		lda	#$20
293
 2844  F83422  20 26 3D      		jsr	_MovRF2Mem
294
 2845
295
 2846  F83425  A9 36         		lda	#>?115		; 0.0001
296
 2847  F83427  EB            		xba
297
 2848  F83428  A9 41         		lda	#<?115
298
 2849  F8342A  A2 F8         		ldx	#^?115
299
 2850  F8342C  20 5A 3F      		jsr	_Str2Fl
300
 2851  F8342F  A0 20         		ldy	#$20
301
 2852  F83431  A9 00         		lda	#0
302
 2853  F83433  EB            		xba
303
 2854  F83434  A9 30         		lda	#$30
304
 2855  F83436  20 26 3D      		jsr	_MovRF2Mem
305
 2856
306
 2857  F83439  A0 20         		ldy	#$20		; ARG = 1.0
307
 2858  F8343B  A9 00         		lda	#0
308
 2859  F8343D  EB            		xba
309
 2860  F8343E  A9 00         		lda	#0
310
 2861  F83440  20 98 3D      		jsr	_MovMem2A
311
  Tue Jul 17 11:00:16 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2862
317
 2863  F83443  A0 20         		ldy	#$20		; FAC = .0001
318
 2864  F83445  A9 00         		lda	#0
319
 2865  F83447  EB            		xba
320
 2866  F83448  A9 30         		lda	#$30
321
 2867  F8344A  20 62 3D      		jsr	_MovMem2F
322
 2868  F8344D  20 30 3A      		jsr	_feDIV		; FAC=ARG/FAC
323
 2869  F83450  00 00         		brk
324
 2870
325
 2871  F83452  A0 20         		ldy	#$20		; ARG = 1.0001
326
 2872  F83454  A9 00         		lda	#0
327
 2873  F83456  EB            		xba
328
 2874  F83457  A9 10         		lda	#$10
329
 2875  F83459  20 98 3D      		jsr	_MovMem2A
330
 2876  F8345C  20 FE 36      		jsr	_feSUB		; FAC=ARG-FAC
331
 2877  F8345F  A0 20         		ldy	#$20
332
 2878  F83461  A9 00         		lda	#0
333
 2879  F83463  EB            		xba
334
 2880  F83464  A9 40         		lda	#$40
335
 2881  F83466  20 26 3D      		jsr	_MovRF2Mem
336
 2882
337
 2883  F83469  A0 20         		ldy	#$20		; FAC = 0.9999
338
 2884  F8346B  A9 00         		lda	#0
339
 2885  F8346D  EB            		xba
340
 2886  F8346E  A9 20         		lda	#$20
341
 2887  F83470  20 62 3D      		jsr	_MovMem2F
342
 2888  F83473
343
 2889  F83473  A0 20         		ldy	#$20		; ARG = 1.0
344
 2890  F83475  A9 00         		lda	#0
345
 2891  F83477  EB            		xba
346
 2892  F83478  A9 00         		lda	#$00
347
 2893  F8347A  20 98 3D      		jsr	_MovMem2A
348
 2894  F8347D  20 FE 36      		jsr	_feSUB		; FAC=ARG-FAC
349
 2895  F83480  A0 20         		ldy	#$20
350
 2896  F83482  A9 00         		lda	#0
351
 2897  F83484  EB            		xba
352
 2898  F83485  A9 50         		lda	#$50
353
 2899  F83487  20 26 3D      		jsr	_MovRF2Mem
354
 2900
355
 2901  F8348A  A0 20         		ldy	#$20		; FAC = 1.0
356
 2902  F8348C  A9 00         		lda	#0
357
 2903  F8348E  EB            		xba
358
 2904  F8348F  A9 00         		lda	#0
359
 2905  F83491  20 62 3D      		jsr	_MovMem2F
360
 2906  F83494
361
 2907  F83494  A0 20         		ldy	#$20		; ARG = 0.0001
362
 2908  F83496  A9 00         		lda	#0
363
 2909  F83498  EB            		xba
364
 2910  F83499  A9 30         		lda	#$30
365
 2911  F8349B  20 98 3D      		jsr	_MovMem2A
366
 2912  F8349E  20 04 37      		jsr	_feADD		; FAC=ARG+FAC
367
 2913  F834A1  A0 20         		ldy	#$20
368
 2914  F834A3  A9 00         		lda	#0
369
 2915  F834A5  EB            		xba
370
 2916  F834A6  A9 60         		lda	#$60
371
 2917  F834A8  20 26 3D      		jsr	_MovRF2Mem
372
 2918
373
  Tue Jul 17 11:00:16 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2919  F834AB  A9 36         		lda	#>?120		; 0.0001
379
 2920  F834AD  EB            		xba
380
 2921  F834AE  A9 4B         		lda	#<?120
381
 2922  F834B0  A2 F8         		ldx	#^?120
382
 2923  F834B2  20 5A 3F      		jsr	_Str2Fl
383
 2924  F834B5  A0 20         		ldy	#$20
384
 2925  F834B7  A9 00         		lda	#0
385
 2926  F834B9  EB            		xba
386
 2927  F834BA  A9 70         		lda	#$70
387
 2928  F834BC  20 26 3D      		jsr	_MovRF2Mem
388
 2929
389
 2930  F834BF  A0 20         		ldy	#$20		; FAC = 1.0
390
 2931  F834C1  A9 00         		lda	#0
391
 2932  F834C3  EB            		xba
392
 2933  F834C4  A9 00         		lda	#0
393
 2934  F834C6  20 62 3D      		jsr	_MovMem2F
394
 2935  F834C9  A0 20         		ldy	#$20		; ARG = 1.0001
395
 2936  F834CB  A9 00         		lda	#0
396
 2937  F834CD  EB            		xba
397
 2938  F834CE  A9 10         		lda	#$10
398
 2939  F834D0  20 98 3D      		jsr	_MovMem2A
399
 2940  F834D3  20 04 37      		jsr	_feADD		; FAC=ARG+FAC
400
 2941  F834D6  A0 20         		ldy	#$20
401
 2942  F834D8  A9 00         		lda	#0
402
 2943  F834DA  EB            		xba
403
 2944  F834DB  A9 80         		lda	#$80
404
 2945  F834DD  20 26 3D      		jsr	_MovRF2Mem
405
 2946
406
 2947  F834E0  A9 20         		lda	#$20
407
 2948  F834E2  48            		pha
408
 2949  F834E3  F4 30 00      		pea	#$0030
409
 2950  F834E6  4B            		phk
410
 2951  F834E7  F4 52 36      		pea	#?200
411
 2952  F834EA  A9 07         		lda	#7
412
 2953  F834EC  48            		pha
413
 2954  F834ED                		BPRINTF
414
 2955  F834ED  02 11         		cop	$11
415
 2956                        		.MNLIST
416
 2957  F834EF  A9 20         		lda	#$20
417
 2958  F834F1  48            		pha
418
 2959  F834F2  F4 40 00      		pea	#$0040
419
 2960  F834F5  4B            		phk
420
 2961  F834F6  F4 52 36      		pea	#?200
421
 2962  F834F9  A9 07         		lda	#7
422
 2963  F834FB  48            		pha
423
 2964  F834FC                		BPRINTF
424
 2965  F834FC  02 11         		cop	$11
425
 2966                        		.MNLIST
426
 2967  F834FE  A9 20         		lda	#$20
427
 2968  F83500  48            		pha
428
 2969  F83501  F4 50 00      		pea	#$0050
429
 2970  F83504  4B            		phk
430
 2971  F83505  F4 52 36      		pea	#?200
431
 2972  F83508  A9 07         		lda	#7
432
 2973  F8350A  48            		pha
433
 2974  F8350B                		BPRINTF
434
 2975  F8350B  02 11         		cop	$11
435
  Tue Jul 17 11:00:16 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 2976                        		.MNLIST
441
 2977
442
 2978  F8350D  A9 20         		lda	#$20
443
 2979  F8350F  48            		pha
444
 2980  F83510  F4 30 00      		pea	#$0030
445
 2981  F83513  4B            		phk
446
 2982  F83514  F4 5A 36      		pea	#?210
447
 2983  F83517  A9 07         		lda	#7
448
 2984  F83519  48            		pha
449
 2985  F8351A                		BPRINTF
450
 2986  F8351A  02 11         		cop	$11
451
 2987                        		.MNLIST
452
 2988  F8351C  A9 20         		lda	#$20
453
 2989  F8351E  48            		pha
454
 2990  F8351F  F4 40 00      		pea	#$0040
455
 2991  F83522  4B            		phk
456
 2992  F83523  F4 5A 36      		pea	#?210
457
 2993  F83526  A9 07         		lda	#7
458
 2994  F83528  48            		pha
459
 2995  F83529                		BPRINTF
460
 2996  F83529  02 11         		cop	$11
461
 2997                        		.MNLIST
462
 2998  F8352B  A9 20         		lda	#$20
463
 2999  F8352D  48            		pha
464
 3000  F8352E  F4 50 00      		pea	#$0050
465
 3001  F83531  4B            		phk
466
 3002  F83532  F4 5A 36      		pea	#?210
467
 3003  F83535  A9 07         		lda	#7
468
 3004  F83537  48            		pha
469
 3005  F83538                		BPRINTF
470
 3006  F83538  02 11         		cop	$11
471
 3007                        		.MNLIST
472
 3008
473
 3009  F8353A  A9 36         		lda	#>?305
474
 3010  F8353C  EB            		xba
475
 3011  F8353D  A9 76         		lda	#<?305
476
 3012  F8353F  A2 F8         		ldx	#^?305
477
 3013  F83541  20 5A 3F      		jsr	_Str2Fl
478
 3014  F83544  A0 20         		ldy	#$20
479
 3015  F83546  A9 00         		lda	#0
480
 3016  F83548  EB            		xba
481
 3017  F83549  A9 90         		lda	#$90
482
 3018  F8354B  20 26 3D      		jsr	_MovRF2Mem
483
 3019
484
 3020  F8354E  A9 36         		lda	#>?300
485
 3021  F83550  EB            		xba
486
 3022  F83551  A9 62         		lda	#<?300
487
 3023  F83553  A2 F8         		ldx	#^?300
488
 3024  F83555  20 5A 3F      		jsr	_Str2Fl
489
 3025  F83558  A0 20         		ldy	#$20
490
 3026  F8355A  A9 00         		lda	#0
491
 3027  F8355C  EB            		xba
492
 3028  F8355D  A9 A0         		lda	#$A0
493
 3029  F8355F  20 26 3D      		jsr	_MovRF2Mem
494
 3030  F83562  A0 20         		ldy	#$20
495
 3031  F83564  A9 00         		lda	#0
496
 3032  F83566  EB            		xba
497
  Tue Jul 17 11:00:16 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 3033  F83567  A9 90         		lda	#$90
503
 3034  F83569  20 20 3A      		jsr	_feDIVRM
504
 3035  F8356C  A0 20         		ldy	#$20
505
 3036  F8356E  A9 00         		lda	#0
506
 3037  F83570  EB            		xba
507
 3038  F83571  A9 B0         		lda	#$B0
508
 3039  F83573  20 26 3D      		jsr	_MovRF2Mem
509
 3040  F83576  A9 20         		lda	#$20
510
 3041  F83578  48            		pha
511
 3042  F83579  F4 B0 00      		pea	#$00B0
512
 3043  F8357C  4B            		phk
513
 3044  F8357D  F4 5A 36      		pea	#?210
514
 3045  F83580  A9 07         		lda	#7
515
 3046  F83582  48            		pha
516
 3047  F83583                		BPRINTF
517
 3048  F83583  02 11         		cop	$11
518
 3049                        		.MNLIST
519
 3050
520
 3051  F83585  A9 36         		lda	#>?310
521
 3052  F83587  EB            		xba
522
 3053  F83588  A9 80         		lda	#<?310
523
 3054  F8358A  A2 F8         		ldx	#^?310
524
 3055  F8358C  20 5A 3F      		jsr	_Str2Fl
525
 3056  F8358F  A0 20         		ldy	#$20
526
 3057  F83591  A9 00         		lda	#0
527
 3058  F83593  EB            		xba
528
 3059  F83594  A9 D0         		lda	#$D0
529
 3060  F83596  20 26 3D      		jsr	_MovRF2Mem
530
 3061  F83599  A0 20         		ldy	#$20		; ARG = 1.0
531
 3062  F8359B  A9 00         		lda	#0
532
 3063  F8359D  EB            		xba
533
 3064  F8359E  A9 00         		lda	#$00
534
 3065  F835A0  20 98 3D      		jsr	_MovMem2A
535
 3066  F835A3  20 FE 36      		jsr	_feSUB		; FAC=ARG-FAC
536
 3067  F835A6  A0 20         		ldy	#$20
537
 3068  F835A8  A9 00         		lda	#0
538
 3069  F835AA  EB            		xba
539
 3070  F835AB  A9 C0         		lda	#$C0
540
 3071  F835AD  20 26 3D      		jsr	_MovRF2Mem
541
 3072  F835B0  A9 20         		lda	#$20
542
 3073  F835B2  48            		pha
543
 3074  F835B3  F4 C0 00      		pea	#$00C0
544
 3075  F835B6  4B            		phk
545
 3076  F835B7  F4 5A 36      		pea	#?210
546
 3077  F835BA  A9 07         		lda	#7
547
 3078  F835BC  48            		pha
548
 3079  F835BD                		BPRINTF
549
 3080  F835BD  02 11         		cop	$11
550
 3081                        		.MNLIST
551
 3082
552
 3083  F835BF  A9 36         		lda	#>?320
553
 3084  F835C1  EB            		xba
554
 3085  F835C2  A9 94         		lda	#<?320
555
 3086  F835C4  A2 F8         		ldx	#^?320
556
 3087  F835C6  20 5A 3F      		jsr	_Str2Fl
557
 3088  F835C9  A0 20         		ldy	#$20
558
 3089  F835CB  A9 00         		lda	#0
559
  Tue Jul 17 11:00:16 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3090  F835CD  EB            		xba
565
 3091  F835CE  A9 E0         		lda	#$E0
566
 3092  F835D0  20 26 3D      		jsr	_MovRF2Mem
567
 3093  F835D3  A9 36         		lda	#>?325
568
 3094  F835D5  EB            		xba
569
 3095  F835D6  A9 88         		lda	#<?325
570
 3096  F835D8  A2 F8         		ldx	#^?325
571
 3097  F835DA  20 5A 3F      		jsr	_Str2Fl
572
 3098  F835DD  A0 20         		ldy	#$20
573
 3099  F835DF  A9 00         		lda	#0
574
 3100  F835E1  EB            		xba
575
 3101  F835E2  A9 F0         		lda	#$F0
576
 3102  F835E4  20 26 3D      		jsr	_MovRF2Mem
577
 3103  F835E7  A0 20         		ldy	#$20		; ARG = 1.0
578
 3104  F835E9  A9 00         		lda	#0
579
 3105  F835EB  EB            		xba
580
 3106  F835EC  A9 E0         		lda	#$E0
581
 3107  F835EE  20 98 3D      		jsr	_MovMem2A
582
 3108  F835F1  20 04 37      		jsr	_feADD
583
 3109  F835F4  A0 20         		ldy	#$20
584
 3110  F835F6  A9 01         		lda	#1
585
 3111  F835F8  EB            		xba
586
 3112  F835F9  A9 00         		lda	#$00
587
 3113  F835FB  20 26 3D      		jsr	_MovRF2Mem
588
 3114
589
 3115  F835FE  4B            		phk
590
 3116  F835FF  F4 B4 36      		pea	#?420
591
 3117  F83602  4B            		phk
592
 3118  F83603  F4 5A 36      		pea	#?210
593
 3119  F83606  A9 07         		lda	#7
594
 3120  F83608  48            		pha
595
 3121  F83609                		BPRINTF
596
 3122  F83609  02 11         		cop	$11
597
 3123                        		.MNLIST
598
 3124
599
 3125  F8360B  4B            		phk
600
 3126  F8360C  F4 BE 36      		pea	#?425
601
 3127  F8360F  4B            		phk
602
 3128  F83610  F4 5A 36      		pea	#?210
603
 3129  F83613  A9 07         		lda	#7
604
 3130  F83615  48            		pha
605
 3131  F83616                		BPRINTF
606
 3132  F83616  02 11         		cop	$11
607
 3133                        		.MNLIST
608
 3134
609
 3135  F83618  4B            		phk
610
 3136  F83619  F4 C8 36      		pea	#?430
611
 3137  F8361C  4B            		phk
612
 3138  F8361D  F4 5A 36      		pea	#?210
613
 3139  F83620  A9 07         		lda	#7
614
 3140  F83622  48            		pha
615
 3141  F83623                		BPRINTF
616
 3142  F83623  02 11         		cop	$11
617
 3143                        		.MNLIST
618
 3144  F83625
619
 3145  F83625  2B            		pld
620
 3146  F83626  AB            		plb
621
  Tue Jul 17 11:00:16 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3147  F83627  00 00         		brk
627
 3148  F83629
628
 3149  F83629  31 2E 30 00   	?100:	.DB	'1.0', 0
629
 3150                        	;?105:	.DB	'1.0001', 0
630
 3151                        	;?110:	.DB	'0.9999', 0
631
 3152                        	;?115:	.DB	'0.0001', 0
632
 3153
633
 3154  F8362D  31 2E 30 30 30 	?105:	.DB	'1.0000001', 0
634
               30 30 30 31 00
635
 3155  F83637  30 2E 39 39 39 	?110:	.DB	'0.9999999', 0
636
               39 39 39 39 00
637
 3156  F83641  30 2E 30 30 30 	?115:	.DB	'0.0000001', 0
638
               30 30 30 31 00
639
 3157
640
 3158  F8364B  32 2E 30 30 30 	?120:	.DB	'2.0001', 0
641
               31 00
642
 3159  F83652  0D 25 32 2E 31 	?200:	.DB	13, '%2.16f', 0
643
               36 66 00
644
 3160  F8365A  0D 25 31 2E 32 	?210:	.DB	13, '%1.20e', 0
645
               30 65 00
646
 3161
647
 3162  F83662  38 34 35 2E 37 	?300:	.DB	'845.782345177785467',0
648
               38 32 33 34 35
649
               31 37 37 37 38
650
               35 34 36 37 00
651
 3163  F83676  31 37 2E 31 37 	?305:	.DB	'17.171779',0
652
               31 37 37 39 00
653
 3164  F83680  31 2E 30 65 2D 	?310:	.DB	'1.0e-17',0
654
               31 37 00
655
 3165
656
 3166                        	;?320:	.DB	'3.645e-4951',0
657
 3167  F83688  33 2E 36 34 35 	?325:	.DB	'3.645e-4941',0
658
               65 2D 34 39 34
659
               31 00
660
 3168  F83694  33 2E 33 36 32 	?320:	.DB	'3.362e-4932',0
661
               65 2D 34 39 33
662
               32 00
663
 3169
664
 3170  F836A0  BD 7F 18 F6 D1 	?400:	.DB	$BD, $7F, $18, $F6, $d1, $8e, $7d, $94, $e4, $0a
665
               8E 7D 94 E4 0A
666
 3171  F836AA  76 CB E2 7B C2 	?410:	.DB	$76, $cb, $e2, $7b, $c2, $5e, $1e, $ff, $ff, $4a
667
               5E 1E FF FF 4A
668
 3172  F836B4  FF FF FF FF FF 	?420:	.DB	$ff, $ff, $ff, $ff, $ff, $ff, $ff, $7f, $01, $00
669
               FF FF 7F 01 00
670
 3173  F836BE  00 00 00 00 00 	?425:	.DB	$00, $00, $00, $00, $00, $00, $00, $80, $ff, $00
671
               00 00 80 FF 00
672
 3174  F836C8  FF FF FF 00 00 	?430:	.DB	$ff, $ff, $ff, $00, $00, $00, $00, $00, $01, $00
673
               00 00 00 01 00
674
 3175  F836D2  00 00 00 00 00 	?510:	.DB	$00, $00, $00, $00, $00, $00, $00, $88, $ff, $3f
675
               00 00 88 FF 3F
676
 3176                        	;?510:	.DB	$ff, $ff, $ff, $ff, $00, $ff, $ff, $ff, $ff, $3f
677
 3177  F836DC  00 00 00 00 00 	?500:	.DB	$00, $00, $00, $00, $00, $00, $00, $E0, $ff, $3f
678
               00 00 E0 FF 3F
679
 3178
680
 3179                        	;?610:	.DB	$00, $00, $00, $00, $00, $00, $00, $00, $00, $88, $ff, $3f
681
 3180                        	;?600:	.DB	$00, $00, $00, $00, $00, $00, $00, $00, $00, $E0, $ff, $3f
682
 3181
683
  Tue Jul 17 11:00:16 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
 3182                        	;?610:	.DB	$00, $00, $00,$00,$00,$04,$BF,$C9,$1B,$8E,$34,$40 ; 1E16
689
 3183
690
 3184  F836E6  00 00 00 B4 57 	?600:	.DB	$00,$00,$00,$B4,$57,$0A,$3F,$16,$68,$A9,$4B,$40	; 1E23
691
               0A 3F 16 68 A9
692
               4B 40
693
 3185  F836F2  00 00 00 00 00 	?610:	.DB	$00,$00,$00,$00,$00,$00,$00,$00,$00,$A0,$02,$40
694
               00 00 00 00 A0
695
               02 40
696
 3186
697
 3187
698
 3188                        	;; $00,$00,$00,$A1,$ED,$CC,$CE,$1B,$C2,$D3,$4E,$40	; 1E24
699
 3189                        	;; $00,$00,$00,$B4,$57,$0A,$3F,$16,$68,$A9,$4B,$40	; 1E23
700
 3190
701
 3191                        	;; rounded
702
 3192                        	;; $20,$F0,$9D,$B5,$70,$2B,$A8,$AD,$C5,$9D,$69,$40	; 1E32
703
 3193                        	;; $BF,$3C,$D5,$A6,$CF,$FF,$49,$1F,$78,$C2,$D3,$40	; 1E64
704
 3194                        	;; $6F,$C6,$DF,$8C,$E9,$80,$C9,$47,$BA,$93,$A8,$41	; 1E128
705
 3195                        	;; $BB,$DD,$8D,$DE,$F9,$9D,$FB,$EB,$7E,$AA,$51,$43	; 1E256
706
 3196                        	;; $64,$CC,$C6,$91,$0E,$A6,$AE,$A0,$19,$E3,$A3,$46	; 1E512
707
 3197                        	;; $0B,$65,$17,$0C,$75,$81,$86,$75,$76,$C9,$48,$4D	; 1E1024
708
 3198                        	;; $4A,$A7,$E4,$5D,$3D,$C5,$5D,$3B,$8B,$9E,$92,$5A	; 1E2048
709
 3199                        	;; $44,$C9,$9A,$97,$20,$8A,$02,$52,$60,$C4,$25,$75	; 1E4096
710
 3200
711
 3201                        	;; not rounded
712
 3202                        	;; $00,$00,$20,$F0,$9D,$B5,$70,$2B,$A8,$AD,$C5,$9D,$69,$40	; 1E32
713
 3203                        	;; $70,$6B,$BF,$3C,$D5,$A6,$CF,$FF,$49,$1F,$78,$C2,$D3,$40	; 1E64
714
 3204                        	;; $69,$33,$6F,$C6,$DF,$8C,$E9,$80,$C9,$47,$BA,$93,$A8,$41	; 1E128
715
 3205                        	;; $14,$90,$BB,$DD,$8D,$DE,$F9,$9D,$FB,$EB,$7E,$AA,$51,$43	; 1E256
716
 3206                        	;; $40,$5C,$65,$CC,$C6,$91,$0E,$A6,$AE,$A0,$19,$E3,$A3,$46	; 1E512
717
 3207                        	;; $04,$3D,$0D,$65,$17,$0C,$75,$81,$86,$75,$76,$C9,$48,$4D	; 1E1024
718
 3208                        	;; $94,$28,$4D,$A7,$E4,$5D,$3D,$C5,$5D,$3B,$8B,$9E,$92,$5A	; 1E2048
719
 3209                        	;; $AE,$14,$4C,$C9,$9A,$97,$20,$8A,$02,$52,$60,$C4,$25,$75	; 1E4096
720
 3210
721
 3211                        	;FCon1E8:	.DB	$00,$00,$00,$00,$00,$20,$BC,$BE,$19,$40	; 1E8
722
 3212                        	;FCon1E16:	.DB	$00,$00,$00,$04,$BF,$C9,$1B,$8E,$34,$40	; 1E16
723
 3213                        	;FCon1E32:	.DB	$9E,$B5,$70,$2B,$A8,$AD,$C5,$9D,$69,$40	; 1E32
724
 3214                        	;FCon1E64:	.DB	$D5,$A6,$CF,$FF,$49,$1F,$78,$C2,$D3,$40	; 1E64
725
 3215                        	;FCon1E128:	.DB	$DF,$8C,$E9,$80,$C9,$47,$BA,$93,$A8,$41	; 1E128
726
 3216                        	;FCon1E256:	.DB	$8C,$DE,$F9,$9D,$FB,$EB,$7E,$AA,$51,$43	; 1E256
727
 3217                        	;FCon1E512:	.DB	$C2,$91,$0E,$A6,$AE,$A0,$19,$E3,$A3,$46	; 1E512
728
 3218                        	;FCon1E1024:	.DB	$0F,$0C,$75,$81,$86,$75,$76,$C9,$48,$4D	; 1E1024
729
 3219                        	;FCon1E2048:	.DB	$D7,$5D,$3D,$C5,$5D,$3B,$8B,$9E,$92,$5A	; 1E2048
730
 3220                        	;FCon1E4096:	.DB	$79,$97,$20,$8A,$02,$52,$60,$C4,$25,$75	; 1E4096
731
 3221
732
 3222                        	;;	.DB	$00, $00, $00, $A1, $ED, $CC, $CE, $1B, $C2, $D3, $00	; +1E24
733
 3223                        	;;	.DB	$00, $00, $80, $09, $B5, $1E, $38, $FD, $D2, $EA, $FF	; -1E23
734
 3224                        	;;	.DB	$00, $00, $40, $B2, $BA, $C9, $E0, $19, $1E, $02, $00	; +1E22
735
 3225                        	;;	.DB	$00, $00, $60, $21, $3A, $52, $36, $CA, $C9, $FF, $FF	; -1E21
736
 3226                        	;;	.DB	$00, $00, $10, $63, $2D, $5E, $C7, $6B, $05, $00, $00	; +1E20
737
 3227                        	;;CONSTDECTBL:
738
 3228                        	;;	.DB	$00, $00, $18, $76, $FB, $DC, $38, $75, $FF, $FF, $FF	; -1E19
739
 3229                        	;;CONSTDECTBL1:
740
 3230                        	;;	.DB	$00, $00, $64, $A7, $B3, $B6, $E0, $0D, $00, $00, $00	; +1E18
741
 3231                        	;;	.DB	$00, $00, $76, $A2, $87, $BA, $9C, $FE, $FF, $FF, $FF	; -1E17
742
 3232                        	;;	.DB	$00, $00, $C1, $6F, $F2, $86, $23, $00, $00, $00, $00	; +1E16
743
 3233                        	;;	.DB	$00, $80, $39, $5B, $81, $72, $FC, $FF, $FF, $FF, $FF	; -1E15
744
 3234                        	;;	.DB	$00, $40, $7A, $10, $F3, $5A, $00, $00, $00, $00, $00	; +1E14
745
  Tue Jul 17 11:00:16 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3235                        	;;	.DB	$00, $60, $8D, $B1, $E7, $F6, $FF, $FF, $FF, $FF, $FF	; -1E13
751
 3236                        	;;	.DB	$00, $10, $A5, $D4, $E8, $00, $00, $00, $00, $00, $00	; +1E12
752
 3237                        	;;	.DB	$00, $18, $89, $B7, $E8, $FF, $FF, $FF, $FF, $FF, $FF	; -1E11
753
 3238                        	;;	.DB	$00, $E4, $0B, $54, $02, $00, $00, $00, $00, $00, $00	; +1E10
754
 3239                        	;;	.DB	$00, $36, $65, $C4, $FF, $FF, $FF, $FF, $FF, $FF, $FF	; -1E9
755
 3240                        	;;	.DB	$00, $E1, $F5, $05, $00, $00, $00, $00, $00, $00, $00	; +1E8
756
 3241                        	;;	.DB	$80, $69, $67, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF	; -1E7
757
 3242                        	;;	.DB	$40, $42, $0F, $00, $00, $00, $00, $00, $00, $00, $00	; +1E6
758
 3243                        	;;	.DB	$60, $79, $FE, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF	; -1E5
759
 3244                        	;;	.DB	$10, $27, $00, $00, $00, $00, $00, $00, $00, $00, $00	; +1E4
760
 3245                        	;;	.DB	$18, $FC, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF	; -1E3
761
 3246                        	;;	.DB	$64, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00	; +1E2
762
 3247                        	;;	.DB	$F6, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF	; -1E1
763
 3248                        	;;	.DB	$01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00	; +1E0
764
 3249
765
 3250                        	;-------------------------------------------------------------
766
 3251                        	; _feADD, _feSUB - IMPLEMENTAZIONE ADD - SUB
767
 3252                        	;-------------------------------------------------------------
768
 3253
769
 3254                        	; _feSUB: esegue sottrazione tra ARG e FAC e pone il risultato in FAC
770
 3255                        	; In:	FAC, ARG
771
 3256                        	; Out:	FAC = ARG - FAC
772
 3257                        	;	CF = 1 se overflow/invalid
773
 3258                        	; Uso:	A,X,Y,FPWTmp,FACXM,ARGXM
774
 3259  F836FE                	_feSUB:
775
 3260  F836FE  A5 40         		LDA	FACSGN		; Cambia di segno a FAC
776
 3261  F83700  49 FF         		EOR	#$FF
777
 3262  F83702  85 40         		STA	FACSGN
778
 3263
779
 3264                        	; _feADD: esegue somma di FAC e ARG e pone il risultato in FAC
780
 3265                        	; In:	FAC, ARG
781
 3266                        	; Out:	FAC = ARG + FAC
782
 3267                        	;	CF = 1 se overflow/invalid
783
 3268                        	; Uso:	A,X,Y,FPWTmp,FACXM,ARGXM
784
 3269  F83704                	_feADD:
785
 3270  F83704  20 CF 3A      		jsr	addtst		; test FAC ed ARG e setta confronto segni
786
 3271
787
 3272                        		; per eseguire somma/sottrazione e' necessario che
788
 3273                        		; FAC ed ARG abbiano lo stesso esponente. Occorre quindi
789
 3274                        		; denormalizzare FAC se Exp(ARG) > Exp(FAC), oppure ARG
790
 3275                        		; se Exp(FAC) > Exp(ARG)
791
 3276  F83707  A2 51         	?15:	LDX	#ARG		; X -> ARG (ptr acc# da denormalizzare)
792
 3277  F83709  A4 41         		ldy	FACEXT		; se si denormalizza ARG vengono usati
793
 3278  F8370B  84 51         		sty	ARGEXT		; bit di guardia di ARG
794
 3279  F8370D  A0 00         		ldy	#0
795
 3280  F8370F  38            		SEC
796
 3281  F83710                		ACC16			; calcola N = Exp(ARG) - Exp(FAC)
797
 3282  F83710  C2 20         		rep	#PMFLAG
798
 3283                        		.LONGA	on
799
 3284                        		.MNLIST
800
 3285  F83712  A5 5A         		lda	ARGExp		; C = N = Exp(ARG) - Exp(FAC)
801
 3286  F83714  E5 4A         		sbc	FACExp
802
 3287  F83716  F0 3D         		BEQ	?30		; N = 0 => somma mantisse
803
 3288                        					; A = 0 = bit di guardia, CF = 1
804
 3289  F83718  90 13         		BCC	?18		; N < 0 => denorm. ARG -> aumenta Exp(ARG)
805
 3290  F8371A
806
 3291                        		; N > 0 => denormalizza FAC -> aumenta Exp(FAC)
807
  Tue Jul 17 11:00:16 2018                                                                                               Page   14
808
 
809
 
810
 
811
 
812
 3292                        		; a questo punto CF = 1
813
 3293  F8371A  85 5C         		sta	FPWTmp		; salva N (> 0)
814
 3294  F8371C  A5 5A         		LDA	ARGExp
815
 3295  F8371E  85 4A         		STA	FACExp		; imposta Exp(FAC) = Exp(ARG)
816
 3296  F83720  A6 50         		LDX	ARGSGN		; segno di FAC = segno di ARG
817
 3297  F83722  86 40         		STX	FACSGN		; segno operazione = segno acc. Exp maggiore
818
 3298  F83724  98            		tya			; A = B = 0 (C = 0)
819
 3299  F83725  E5 5C         		SBC	FPWTmp		; cambia segno ad N
820
 3300  F83727  84 51         		sty	ARGEXT		; azzera bit di guardia di ARG
821
 3301  F83729  A2 41         		LDX	#FAC		; X = puntatore a FAC
822
 3302  F8372B  80 02         		bra	?20		; denormalizza FAC
823
 3303
824
 3304                        	?18:	; azzera bit di guardia di FAC - segno operazione = segno FAC
825
 3305  F8372D  84 41         		sty	FACEXT		; denormalizza ARG
826
 3306
827
 3307                        		; X -> puntatore (- 1) acc# (FAC/ARG) da denormalizzare
828
 3308                        		; A =  -N, numero di shift (negativo) -- ACC16
829
 3309                        		; Y = 0
830
 3310                        		; Se N < MAXMANTSHIFT la mantissa viene azzerata senza eseguire shift
831
 3311                        		; dunque deve essere  MAXMANTSHIFT <= N <= FFFF
832
 3312  F8372F  C9 B0 FF      	?20:	cmp	#MAXMANTSHIFT
833
 3313  F83732  B0 10         		bcs	?23		; shift mantissa (denormalizza)
834
 3314  F83734  94 00         		STY	<0,X		; azzera bit di guardia
835
 3315  F83736  74 01         		STZ	<1,X		; azzera mantissa X (ACC/MEM16)
836
 3316  F83738  74 03         		STZ	<3,X
837
 3317  F8373A  74 05         		STZ	<5,X
838
 3318  F8373C  74 07         		STZ	<7,X
839
 3319  F8373E                		ACC08
840
 3320  F8373E  E2 20         		sep	#PMFLAG
841
 3321                        		.LONGA	off
842
 3322                        		.MNLIST
843
 3323  F83740  A5 41         		lda	FACEXT		; A = bit di guardia
844
 3324  F83742  80 11         		BRA	?30		; esegue somma/sottrazione
845
 3325  F83744
846
 3326                        		; a questo punto A = -N => numero di shift mantissa (divisioni x 2)
847
 3327                        		; il numero N e' contenuto solo in A (B = $FF) e si imposta ACC08
848
 3328  F83744                	?23:	ACC08
849
 3329  F83744  E2 20         		sep	#PMFLAG
850
 3330                        		.LONGA	off
851
 3331                        		.MNLIST
852
 3332  F83746  C9 F9         		CMP	#$F9		; test N < -7
853
 3333  F83748  10 05         		BPL	?25		; N >= -7, shift bit x bit (CF = 1)
854
 3334  F8374A  20 C8 38      		JSR	_RShiftXB	; N < -7, shifta byte x byte (CF = 0)
855
 3335  F8374D  80 06         		BRA	?30		; esegue somma/sottrazione
856
 3336  F8374F  A8            	?25:	TAY			; Y = -N
857
 3337  F83750  A5 41         		LDA	FACEXT		; A = bit di guardia
858
 3338  F83752  20 D5 38      		JSR	_RShiftXN	; shift bit x bit (CF = 0)
859
 3339
860
 3340                        		; ora gli esponenti di FAC ed ARG sono uguali
861
 3341                        		; CF = 0 se FAC o ARG denormalizzato
862
 3342                        		; CF = 1 se FAC e ARG hanno lo stesso esponente
863
 3343                        		; A = bits di guardia (= 0 se FAC e ARG stesso esponente)
864
 3344  F83755                	?30:	ACC08
865
 3345  F83755  E2 20         		sep	#PMFLAG
866
 3346                        		.LONGA	off
867
 3347                        		.MNLIST
868
 3348  F83757  24 4C         		BIT	FACSCMP		; se FAC ed ARG hanno segni discordi
869
  Tue Jul 17 11:00:16 2018                                                                                               Page   15
870
 
871
 
872
 
873
 
874
 3349  F83759  30 42         		BMI	_subm		; esegue sottrazione mantisse
875
 3350  F8375B
876
 3351                        		; segni concordi, addiziona mantisse con CF
877
 3352  F8375B  18            		clc
878
 3353  F8375C  65 51         		ADC	ARGEXT
879
 3354  F8375E  85 41         		STA	FACEXT
880
 3355  F83760                		ACC16
881
 3356  F83760  C2 20         		rep	#PMFLAG
882
 3357                        		.LONGA	on
883
 3358                        		.MNLIST
884
 3359  F83762  A5 42         		LDA	FAC+1
885
 3360  F83764  65 52         		ADC	ARG+1
886
 3361  F83766  85 42         		STA	FAC+1
887
 3362  F83768  A5 44         		LDA	FAC+3
888
 3363  F8376A  65 54         		ADC	ARG+3
889
 3364  F8376C  85 44         		STA	FAC+3
890
 3365  F8376E  A5 46         		LDA	FAC+5
891
 3366  F83770  65 56         		ADC	ARG+5
892
 3367  F83772  85 46         		STA	FAC+5
893
 3368  F83774  A5 48         		LDA	FAC+7
894
 3369  F83776  65 58         		ADC	ARG+7
895
 3370  F83778  85 48         		STA	FAC+7
896
 3371  F8377A                		ACC08
897
 3372  F8377A  E2 20         		sep	#PMFLAG
898
 3373                        		.LONGA	off
899
 3374                        		.MNLIST
900
 3375  F8377C  90 5B         		BCC	_Normalize	; OK, no overflow
901
 3376
902
 3377                        		; Incrementa esponente di FAC e shifta a destra la mantissa
903
 3378                        		; per impostare il primo bit della mantissa ad 1 (normalizza).
904
 3379                        		; Il bit meno significativo viene ruotato nei bits di guardia
905
 3380                        		; in caso di overflow imposta FAC = INF ed esce con CF = 1
906
 3381                        		; in caso di risultato corretto esce con CF = 0
907
 3382
908
 3383  F8377E                	_IncEXP:
909
 3384  F8377E                		ACC16
910
 3385  F8377E  C2 20         		rep	#PMFLAG
911
 3386                        		.LONGA	on
912
 3387                        		.MNLIST
913
 3388  F83780  A5 4A         		lda	FACExp
914
 3389  F83782  1A            		inc	a		; incrementa esponente
915
 3390  F83783  85 4A         		sta	FACExp
916
 3391  F83785  C9 FF 7F      		cmp	#EXPINF		; test overflow
917
 3392  F83788  90 03         		bcc	?04		; OK
918
 3393  F8378A  4C 75 3B      		jmp	_feLDINF1	; overflow => FAC = =/- INF
919
 3394  F8378D  38            	?04:	SEC			; imposta MSB bit = 1
920
 3395  F8378E  66 48         		ROR	FAC+7		; shift a destra della mantissa
921
 3396  F83790  66 46         		ROR	FAC+5
922
 3397  F83792  66 44         		ROR	FAC+3
923
 3398  F83794  66 42         		ROR	FAC+1
924
 3399  F83796                		ACC08
925
 3400  F83796  E2 20         		sep	#PMFLAG
926
 3401                        		.LONGA	off
927
 3402                        		.MNLIST
928
 3403  F83798  66 41         		ROR	FACEXT		; salva LSB nei bits di guardia
929
 3404  F8379A  4C FF 3B      		jmp	_feXAM		; OK -- return flag
930
 3405
931
  Tue Jul 17 11:00:16 2018                                                                                               Page   16
932
 
933
 
934
 
935
 
936
 3406                        		; segni discordi => sub mantisse
937
 3407  F8379D                	_subm:
938
 3408  F8379D  08            		php			; salva CF
939
 3409  F8379E  A0 41         		LDY	#FAC
940
 3410  F837A0  E0 51         		CPX	#ARG
941
 3411  F837A2  F0 02         		BEQ	?36		; FAC(Y) - ARG(X)
942
 3412  F837A4  A0 51         		LDY	#ARG		; ARG(Y) - FAC(X)
943
 3413                        		; X = puntatore mantissa 1
944
 3414                        		; Y = puntatore mantissa 2
945
 3415                        		; FAC = ACC(Y) - ACC(X)
946
 3416                        		; A = bit di guardia
947
 3417  F837A6  28            	?36:	plp
948
 3418  F837A7  B0 03         		bcs	?36b
949
 3419  F837A9  38            		sec
950
 3420  F837AA  B0 01         		bcs	?36c
951
 3421  F837AC  18            	?36b:	clc
952
 3422  F837AD                	?36c:
953
 3423  F837AD  38            		SEC			; -A + ARGEXT
954
 3424  F837AE  49 FF         		EOR	#$FF
955
 3425  F837B0  65 51         		ADC	ARGEXT
956
 3426  F837B2  85 41         		STA	FACEXT
957
 3427  F837B4                		ACC16
958
 3428  F837B4  C2 20         		rep	#PMFLAG
959
 3429                        		.LONGA	on
960
 3430                        		.MNLIST
961
 3431  F837B6  B9 01 02      		LDA	DP02ADDR+1,Y
962
 3432  F837B9  F5 01         		SBC	<1,X
963
 3433  F837BB  85 42         		STA	FAC+1
964
 3434  F837BD  B9 03 02      		LDA	DP02ADDR+3,Y
965
 3435  F837C0  F5 03         		SBC	<3,X
966
 3436  F837C2  85 44         		STA	FAC+3
967
 3437  F837C4  B9 05 02      		LDA	DP02ADDR+5,Y
968
 3438  F837C7  F5 05         		SBC	<5,X
969
 3439  F837C9  85 46         		STA	FAC+5
970
 3440  F837CB  B9 07 02      		LDA	DP02ADDR+7,Y
971
 3441  F837CE  F5 07         		SBC	<7,X
972
 3442  F837D0  85 48         		STA	FAC+7
973
 3443  F837D2                		ACC08
974
 3444  F837D2  E2 20         		sep	#PMFLAG
975
 3445                        		.LONGA	off
976
 3446                        		.MNLIST
977
 3447  F837D4  B0 03         		BCS	_Normalize	; OK => normalizza FAC
978
 3448  F837D6  20 65 38      		JSR	_NegateFAC	; CF = 0 => complementa FAC
979
 3449                        					; in quanto il risultato cambia segno
980
 3450                        		; ????
981
 3451                        		;beq	_IncEXP		; MSB = 0 => incrementa exp e normalizza
982
 3452
983
 3453                        	; Normalizza FAC
984
 3454                        	; In:	FAC
985
 3455                        	; Out:	FAC normalizzato oppure denormalizzato
986
 3456                        	; Uso:	A,X,Y,FPWTmp
987
 3457                        	; Nota:	Esegue N shift della mantissa a sinistra e
988
 3458                        	;	decrementa esponente di N volte fino ad avere
989
 3459                        	;	la mantissa con MSB = 1 oppure fino ad avere
990
 3460                        	;	esponente nullo (numero denormalizzato)
991
 3461  F837D9                	_Normalize:
992
 3462  F837D9                		ACC16
993
  Tue Jul 17 11:00:16 2018                                                                                               Page   17
994
 
995
 
996
 
997
 
998
 3463  F837D9  C2 20         		rep	#PMFLAG
999
 3464                        		.LONGA	on
1000
 3465                        		.MNLIST
1001
 3466  F837DB  A5 4A         		lda	FACExp		; C = FACExp
1002
 3467  F837DD  F0 5C         		beq	?12		; esponente nullo => fine
1003
 3468  F837DF  38            		sec
1004
 3469  F837E0  A0 09         		ldy	#9		; max. cicli byte-shift
1005
 3470  F837E2  A6 49         	?02:	LDX	FAC+8
1006
 3471  F837E4  D0 4C         		BNE	?08		; shift bit x bit
1007
 3472  F837E6  E9 08 00      		sbc	#8		; possibili 8 shift ?
1008
 3473  F837E9  90 30         		bcc	?04		; no => shift bit x bit
1009
 3474  F837EB  A6 48         		LDX	FAC+7		; left shift byte x byte
1010
 3475  F837ED  86 49         		STX	FAC+8
1011
 3476  F837EF  A6 47         		LDX	FAC+6
1012
 3477  F837F1  86 48         		STX	FAC+7
1013
 3478  F837F3  A6 46         		LDX	FAC+5
1014
 3479  F837F5  86 47         		STX	FAC+6
1015
 3480  F837F7  A6 45         		LDX	FAC+4
1016
 3481  F837F9  86 46         		STX	FAC+5
1017
 3482  F837FB  A6 44         		LDX	FAC+3
1018
 3483  F837FD  86 45         		STX	FAC+4
1019
 3484  F837FF  A6 43         		LDX	FAC+2
1020
 3485  F83801  86 44         		STX	FAC+3
1021
 3486  F83803  A6 42         		LDX	FAC+1
1022
 3487  F83805  86 43         		STX	FAC+2
1023
 3488  F83807  A6 41         		LDX	FACEXT
1024
 3489  F83809  86 42         		STX	FAC+1
1025
 3490  F8380B  A2 00         		ldx	#0
1026
 3491  F8380D  86 41         		STX	FACEXT		; azzera bit di guardia
1027
 3492  F8380F  88            		dey
1028
 3493  F83810  D0 D0         		bne	?02		; loop
1029
 3494  F83812
1030
 3495                        		; a questo punto la mantissa e' azzerata e ZF = 1 => FAC = 0
1031
 3496  F83812  64 4A         		stz	FACExp		; mantissa ed esponente azzerati => FAC = 0
1032
 3497  F83814                		ACC08
1033
 3498  F83814  E2 20         		sep	#PMFLAG
1034
 3499                        		.LONGA	off
1035
 3500                        		.MNLIST
1036
 3501  F83816  64 40         		stz	FACSGN
1037
 3502  F83818  18            		clc
1038
 3503  F83819  B8            		clv			; esce con ZF = 1, CF = 0, VF = 0, NF = 0
1039
 3504  F8381A  60            		rts
1040
 3505
1041
 3506                        	?04:	; shift bit a bit: ripristina C (esponente) -- CF = 1
1042
 3507                        		LONGA	on		; qui ACC16
1043
 3508  F8381B  69 08 00      		adc	#8
1044
 3509  F8381E
1045
 3510                        	?06:	; shift 1 bit a sinistra della mantissa FAC
1046
 3511                        		; C = FACExp (> 0)
1047
 3512                        		LONGA	on		; qui ACC16
1048
 3513                        		;cmp	#0
1049
 3514  F8381E  C9 01 00      		cmp	#1
1050
 3515  F83821  F0 11         		beq	?10		; esponente azzerato => fine
1051
 3516  F83823  3A            		dec	a		; decrementa esponente
1052
 3517  F83824                		ACC08
1053
 3518  F83824  E2 20         		sep	#PMFLAG
1054
 3519                        		.LONGA	off
1055
  Tue Jul 17 11:00:16 2018                                                                                               Page   18
1056
 
1057
 
1058
 
1059
 
1060
 3520                        		.MNLIST
1061
 3521  F83826  06 41         		ASL	FACEXT		; shift a sinistra di 1 bit
1062
 3522  F83828                		ACC16
1063
 3523  F83828  C2 20         		rep	#PMFLAG
1064
 3524                        		.LONGA	on
1065
 3525                        		.MNLIST
1066
 3526  F8382A  26 42         		ROL	FAC+1
1067
 3527  F8382C  26 44         		ROL	FAC+3
1068
 3528  F8382E  26 46         		ROL	FAC+5
1069
 3529  F83830  26 48         		ROL	FAC+7
1070
 3530  F83832  10 EA         	?08:	bpl	?06		; MSB = 0 => continua shift
1071
 3531  F83834  C9 FF 7F      	?10:	cmp	#EXPINF		; test overflow
1072
 3532  F83837  B0 07         		bcs	?14		; overflow
1073
 3533  F83839  85 4A         		sta	FACExp		; salva nuovo esponente
1074
 3534  F8383B                	?12:	ACC08
1075
 3535  F8383B  E2 20         		sep	#PMFLAG
1076
 3536                        		.LONGA	off
1077
 3537                        		.MNLIST
1078
 3538  F8383D  4C FF 3B      		jmp	_feXAM
1079
 3539  F83840  4C 75 3B      	?14:	jmp	_feLDINF1
1080
 3540
1081
 3541                        	; Arrotonda FAC secondo i bit di guardia
1082
 3542                        	; Puo' generare overflow
1083
 3543  F83843                	_Round:
1084
 3544  F83843  20 FF 3B      		jsr	_feXAM
1085
 3545  F83846  B0 14         		bcs	?03		; FAC non valido
1086
 3546  F83848  F0 02         		BEQ	?01		; FAC = 0 -> esce
1087
 3547  F8384A  06 41         		ASL	FACEXT		; bit di guardia = 0
1088
 3548  F8384C  64 41         	?01:	stz	FACEXT
1089
 3549  F8384E  90 0C         		BCC	?03		; non necessita di arrotondamento
1090
 3550  F83850  20 8F 38      		JSR	_IncFACM	; incrementa mantissa
1091
 3551  F83853  D0 06         		bne	?02		; no overflow -- OK
1092
 3552  F83855  20 7E 37      		jsr	_IncEXP		; riporto MSB, incrementa esponente
1093
 3553  F83858  64 41         		stz	FACEXT
1094
 3554  F8385A  60            		rts			; flag come ritornato da _IncEXP
1095
 3555  F8385B  18            	?02:	clc
1096
 3556  F8385C  60            	?03:	RTS
1097
 3557
1098
 3558                        	; arrotanda FAC e in caso di eccezione scarta un indirizzo di ritorno
1099
 3559  F8385D                	_RoundSkp:
1100
 3560  F8385D  20 43 38      		JSR	_Round
1101
 3561  F83860  90 02         		BCC	?01
1102
 3562  F83862  68            		PLA
1103
 3563  F83863  68            		PLA
1104
 3564  F83864  60            	?01:	RTS
1105
 3565  F83865
1106
 3566                        	; Complemento a 2 di FAC
1107
 3567                        	; In:	FAC
1108
 3568                        	; Out:	FAC 2's
1109
 3569                        	;	ZF = 0 (non-zero), risultato OK
1110
 3570                        	;	ZF = 1 (zero), OVERFLOW Mantissa
1111
 3571                        	; Uso:	A
1112
 3572                        	; Note:
1113
 3573  F83865                	_NegateFAC:
1114
 3574  F83865  A5 40         		LDA	FACSGN
1115
 3575  F83867  49 FF         		EOR	#$FF
1116
 3576  F83869  85 40         		STA	FACSGN
1117
  Tue Jul 17 11:00:16 2018                                                                                               Page   19
1118
 
1119
 
1120
 
1121
 
1122
 3577
1123
 3578                        	; Complemento a 2 MANTISSA FAC
1124
 3579                        	; In:	FAC
1125
 3580                        	; Out:	MANTISSA FAC 2's
1126
 3581                        	;	ZF = 0 (non-zero), risultato OK
1127
 3582                        	;	ZF = 1 (zero), OVERFLOW Mantissa
1128
 3583                        	; Uso:	A, X
1129
 3584                        	; Note:
1130
 3585  F8386B                	_NegateFACM:
1131
 3586  F8386B                		CPU16
1132
 3587  F8386B  C2 30         		rep	#(PMFLAG.OR.PXFLAG)
1133
 3588                        		.LONGA	on
1134
 3589                        		.LONGI	on
1135
 3590                        		.MNLIST
1136
 3591  F8386D  A2 FF FF      		ldx	#$FFFF
1137
 3592  F83870  8A            		txa
1138
 3593  F83871  45 42         		eor	FAC+1
1139
 3594  F83873  85 42         		STA	FAC+1
1140
 3595  F83875  8A            		txa
1141
 3596  F83876  45 44         		eor	FAC+3
1142
 3597  F83878  85 44         		STA	FAC+3
1143
 3598  F8387A  8A            		txa
1144
 3599  F8387B  45 46         		eor	FAC+5
1145
 3600  F8387D  85 46         		STA	FAC+5
1146
 3601  F8387F  8A            		txa
1147
 3602  F83880  45 48         		eor	FAC+7
1148
 3603  F83882  85 48         		STA	FAC+7
1149
 3604  F83884                		CPU08
1150
 3605  F83884  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
1151
 3606                        		.LONGA	off
1152
 3607                        		.LONGI	off
1153
 3608                        		.MNLIST
1154
 3609  F83886  8A            		txa
1155
 3610  F83887  45 41         		eor	FACEXT
1156
 3611  F83889  85 41         		STA	FACEXT
1157
 3612  F8388B  E6 41         		INC	FACEXT
1158
 3613  F8388D  D0 12         		BNE	_RTS2
1159
 3614  F8388F
1160
 3615                        	; Incrementa MANTISSA FAC
1161
 3616                        	; In:	FAC
1162
 3617                        	; Out:	MANTISSA FAC + 1
1163
 3618                        	;	ZF = 0 (non-zero), risultato OK
1164
 3619                        	;	ZF = 1 (zero), OVERFLOW Mantissa
1165
 3620                        	; Uso:	A
1166
 3621                        	; Note:
1167
 3622  F8388F                	_IncFACM:
1168
 3623  F8388F                		ACC16
1169
 3624  F8388F  C2 20         		rep	#PMFLAG
1170
 3625                        		.LONGA	on
1171
 3626                        		.MNLIST
1172
 3627  F83891  E6 42         		INC	FAC+1
1173
 3628  F83893  D0 0A         		BNE	?02
1174
 3629  F83895  E6 44         		INC	FAC+3
1175
 3630  F83897  D0 06         		BNE	?02
1176
 3631  F83899  E6 46         		INC	FAC+5
1177
 3632  F8389B  D0 02         		BNE	?02
1178
 3633  F8389D  E6 48         		INC	FAC+7
1179
  Tue Jul 17 11:00:16 2018                                                                                               Page   20
1180
 
1181
 
1182
 
1183
 
1184
 3634  F8389F                	?02:	ACC08
1185
 3635  F8389F  E2 20         		sep	#PMFLAG
1186
 3636                        		.LONGA	off
1187
 3637                        		.MNLIST
1188
 3638  F838A1  60            	_RTS2:	RTS
1189
 3639
1190
 3640                        	; Esegue shift a destra di 8 bits della mantissa temporanea FOP
1191
 3641                        	; In:	A = -N (numero di bit residui da shiftare)
1192
 3642                        	; Out:	A = bits di guardia
1193
 3643                        	;	Y = 0
1194
 3644                        	;	CF = 0
1195
 3645                        	; Uso:	A,X,Y
1196
 3646                        	; Note:	Chiamata solo per shift a destra di 1 byte
1197
 3647  F838A2                	_RShiftFOP:
1198
 3648  F838A2  A2 31         		LDX	#(FOP-1)
1199
 3649
1200
 3650                        	; Esegue shift a destra di 8 bits della mantissa indicizzata da X
1201
 3651                        	; In:	A = -N (numero di bit residui da shiftare)
1202
 3652                        	;	X = puntatore - 1 alla mantissa
1203
 3653                        	; Uso:	A,X,Y
1204
 3654                        	; Note:	Chiamata solo per shift a destra di 1 byte
1205
 3655  F838A4                	_RShiftX8:
1206
 3656  F838A4  B4 01         		LDY	<1,X		; shifta a destra di 8 bit
1207
 3657  F838A6  84 41         		STY	FACEXT		; utilizzando i bits di guardia
1208
 3658  F838A8  B4 02         		LDY	<2,X
1209
 3659  F838AA  94 01         		STY	<1,X
1210
 3660  F838AC  B4 03         		LDY	<3,X
1211
 3661  F838AE  94 02         		STY	<2,X
1212
 3662  F838B0  B4 04         		LDY	<4,X
1213
 3663  F838B2  94 03         		STY	<3,X
1214
 3664  F838B4  B4 05         		LDY	<5,X
1215
 3665  F838B6  94 04         		STY	<4,X
1216
 3666  F838B8  B4 06         		LDY	<6,X
1217
 3667  F838BA  94 05         		STY	<5,X
1218
 3668  F838BC  B4 07         		LDY	<7,X
1219
 3669  F838BE  94 06         		STY	<6,X
1220
 3670  F838C0  B4 08         		LDY	<8,X
1221
 3671  F838C2  94 07         		STY	<7,X
1222
 3672  F838C4  A0 00         		LDY	#0		; byte MSB = 0
1223
 3673  F838C6  94 08         		STY	<8,X
1224
 3674  F838C8
1225
 3675                        		; ora shifta bit residui
1226
 3676
1227
 3677                        	; Esegue shift a destra di N bits della mantissa indicizzata da X
1228
 3678                        	; In:	A = -N (numero di bit da shiftare negativo)
1229
 3679                        	;	X = puntatore - 1 alla mantissa
1230
 3680                        	;	CF = 0
1231
 3681                        	; Out:	A = bits di guardia
1232
 3682                        	;	Y = 0
1233
 3683                        	;	CF = 0
1234
 3684                        	; Uso:	A,X,Y
1235
 3685                        	; Note:	main entry per shift a destra
1236
 3686  F838C8                	_RShiftXB:
1237
 3687  F838C8  69 08         		ADC	#$08		; numero residuo di bits
1238
 3688  F838CA  30 D8         		BMI	_RShiftX8	; CF = 0, N > 8, shifta byte per byte
1239
 3689  F838CC  F0 D6         		BEQ	_RShiftX8	; CF = 1, N = 8, shifta byte per byte
1240
 3690  F838CE
1241
  Tue Jul 17 11:00:16 2018                                                                                               Page   21
1242
 
1243
 
1244
 
1245
 
1246
 3691                        		; se A = F8 (-8) arriva qui con A = 9 e CF = 0
1247
 3692                        		; ae arriva qui allora N < 8, CF = 1 -- shift bit a bit
1248
 3693                        		; ripristina A
1249
 3694  F838CE  E9 08         		SBC	#$08		; se N < 8 => CF = 0, se N >= 0 => CF = 1
1250
 3695  F838D0  A8            		TAY			; shifta Y bits a destra
1251
 3696  F838D1  A5 41         		LDA	FACEXT
1252
 3697  F838D3  B0 12         		BCS	_RTS3		; fine shift
1253
 3698  F838D5
1254
 3699                        	; Esegue shift a destra di N (<8) bits della mantissa indicizzata da X
1255
 3700                        	; In:	Y = -N (numero di bit da shiftare negativo)
1256
 3701                        	;	X = puntatore - 1 alla mantissa
1257
 3702                        	;	A = bits di guardia
1258
 3703                        	; Out:	A = bits di guardia
1259
 3704                        	;	Y = 0
1260
 3705                        	;	CF = 0
1261
 3706                        	; Uso:	A,X,Y
1262
 3707                        	; Note:	Usare solo per shift a destra < 8 bits
1263
 3708  F838D5                	_RShiftXN:
1264
 3709  F838D5  EB            		xba			; B = bit di guardia
1265
 3710  F838D6                		ACC16
1266
 3711  F838D6  C2 20         		rep	#PMFLAG
1267
 3712                        		.LONGA	on
1268
 3713                        		.MNLIST
1269
 3714  F838D8  56 07         	?01:	lsr	<7,x		; MSB = 0
1270
 3715  F838DA  76 05         		ROR	<5,X
1271
 3716  F838DC  76 03         		ROR	<3,X
1272
 3717  F838DE  76 01         		ROR	<1,X
1273
 3718  F838E0  6A            		ROR	A		; aggiorna bit di guardia
1274
 3719  F838E1  C8            		INY
1275
 3720  F838E2  D0 F4         		BNE	?01		; bit shift loop
1276
 3721  F838E4                		ACC08
1277
 3722  F838E4  E2 20         		sep	#PMFLAG
1278
 3723                        		.LONGA	off
1279
 3724                        		.MNLIST
1280
 3725  F838E6  EB            		xba			; A = bit di guardia
1281
 3726  F838E7  18            	_RTS3:	CLC
1282
 3727  F838E8  60            		RTS
1283
 3728
1284
 3729                        	;-------------------------------------------------------------
1285
 3730                        	; IMPLEMENTAZIONE _feMUL
1286
 3731                        	;-------------------------------------------------------------
1287
 3732
1288
 3733
1289
 3734                        	; _feMULM: esegue prodotto di FAC e MEM e pone il risultato in FAC
1290
 3735                        	; In:	CY -> puntatore alla memoria
1291
 3736                        	;	FAC
1292
 3737                        	; Out:	FAC = MEM * FAC
1293
 3738                        	;	FPUST, per le eccezioni
1294
 3739                        	; Uso:	A,X,Y,FOP
1295
 3740                        	; Note:	Testare lo status in FPUST
1296
 3741  F838E9                	_feMULM:
1297
 3742  F838E9  20 98 3D      		JSR	_MovMem2A	; carica ARG da memoria
1298
 3743  F838EC
1299
 3744                        	; _feMUL: esegue prodotto di FAC e ARG e pone il risultato in FAC
1300
 3745                        	; In:	FAC, ARG
1301
 3746                        	; Out:	FAC = ARG * FAC
1302
 3747                        	;	FPUST, per le eccezioni
1303
  Tue Jul 17 11:00:16 2018                                                                                               Page   22
1304
 
1305
 
1306
 
1307
 
1308
 3748                        	; Uso:	A,X,Y,FOP
1309
 3749                        	; Note:	Testare lo status in FPUST
1310
 3750  F838EC                	_feMUL:
1311
 3751  F838EC  20 FF 3A      		JSR	multst		; test operandi FAC e ARG
1312
 3752  F838EF  38            	?15:	SEC			; depolarizza exp(FAC) - 1
1313
 3753  F838F0                		ACC16
1314
 3754  F838F0  C2 20         		rep	#PMFLAG
1315
 3755                        		.LONGA	on
1316
 3756                        		.MNLIST
1317
 3757  F838F2  A5 4A         		LDA	FACExp
1318
 3758  F838F4  E9 FF 3F      		SBC	#EXPBIAS
1319
 3759  F838F7  85 4A         		STA	FACExp
1320
 3760  F838F9                		ACC08
1321
 3761  F838F9  E2 20         		sep	#PMFLAG
1322
 3762                        		.LONGA	off
1323
 3763                        		.MNLIST
1324
 3764  F838FB  A2 80         		ldx	#$80		; flag MULT
1325
 3765  F838FD  20 A1 39      		JSR	_AddExponent
1326
 3766  F83900                		ACC16
1327
 3767  F83900  C2 20         		rep	#PMFLAG
1328
 3768                        		.LONGA	on
1329
 3769                        		.MNLIST
1330
 3770  F83902  64 32         		STZ	FOP		; clear area temporanea del risultato
1331
 3771  F83904  64 34         		STZ	FOP+2
1332
 3772  F83906  64 36         		STZ	FOP+4
1333
 3773  F83908  64 38         		STZ	FOP+6
1334
 3774  F8390A                		ACC08
1335
 3775  F8390A  E2 20         		sep	#PMFLAG
1336
 3776                        		.LONGA	off
1337
 3777                        		.MNLIST
1338
 3778  F8390C  64 3A         		STZ	FOP+8
1339
 3779  F8390E  A5 41         		LDA	FACEXT		; moltiplica ogni byte di FAC
1340
 3780  F83910  20 6A 39      		JSR	_MultA		; per la mantissa di ARG
1341
 3781  F83913  A5 42         		LDA	FAC+1
1342
 3782  F83915  20 6A 39      		JSR	_MultA
1343
 3783  F83918  A5 43         		LDA	FAC+2
1344
 3784  F8391A  20 6A 39      		JSR	_MultA
1345
 3785  F8391D  A5 44         		LDA	FAC+3
1346
 3786  F8391F  20 6A 39      		JSR	_MultA
1347
 3787  F83922  A5 45         		LDA	FAC+4
1348
 3788  F83924  20 6A 39      		JSR	_MultA
1349
 3789  F83927  A5 46         		LDA	FAC+5
1350
 3790  F83929  20 6A 39      		JSR	_MultA
1351
 3791  F8392C  A5 47         		LDA	FAC+6
1352
 3792  F8392E  20 6A 39      		JSR	_MultA
1353
 3793  F83931  A5 48         		LDA	FAC+7
1354
 3794  F83933  20 6A 39      		JSR	_MultA
1355
 3795  F83936  A5 49         		LDA	FAC+8
1356
 3796  F83938  20 6F 39      		JSR	_MultB
1357
 3797
1358
 3798  F8393B                	_CopyFOP:
1359
 3799  F8393B                		ACC16
1360
 3800  F8393B  C2 20         		rep	#PMFLAG
1361
 3801                        		.LONGA	on
1362
 3802                        		.MNLIST
1363
 3803  F8393D  A5 32         		LDA	FOP		; copia il risultato da POP a FAC
1364
 3804  F8393F  85 42         		STA	FAC+1
1365
  Tue Jul 17 11:00:16 2018                                                                                               Page   23
1366
 
1367
 
1368
 
1369
 
1370
 3805  F83941  A5 34         		LDA	FOP+2
1371
 3806  F83943  85 44         		STA	FAC+3
1372
 3807  F83945  A5 36         		LDA	FOP+4
1373
 3808  F83947  85 46         		STA	FAC+5
1374
 3809  F83949  A5 38         		LDA	FOP+6
1375
 3810  F8394B  85 48         		STA	FAC+7
1376
 3811  F8394D                		ACC08
1377
 3812  F8394D  E2 20         		sep	#PMFLAG
1378
 3813                        		.LONGA	off
1379
 3814                        		.MNLIST
1380
 3815  F8394F  A5 4E         		lda	FACUndf		; underflow ?
1381
 3816  F83951  F0 14         		beq	?10		; NO -- normalizza
1382
 3817  F83953  A2 41         		ldx	#FAC
1383
 3818  F83955  C9 F9         		CMP	#$F9		; test N < -7
1384
 3819  F83957  10 05         		BPL	?04		; N >= -7, shift bit x bit (CF = 1)
1385
 3820  F83959  20 C8 38      		JSR	_RShiftXB	; N < -7, shifta byte x byte (CF = 0)
1386
 3821                        		;BRA	?10		; FAC denormalizzato con exp = 0
1387
 3822  F8395C  80 06         		bra	?06
1388
 3823  F8395E  A8            	?04:	TAY			; Y = -N
1389
 3824  F8395F  A5 41         		LDA	FACEXT		; A = bit di guardia
1390
 3825  F83961  20 D5 38      		JSR	_RShiftXN	; shift bit x bit (CF = 0)
1391
 3826  F83964  4C FF 3B      	?06:	jmp	_feXAM
1392
 3827  F83967  4C D9 37      	?10:	JMP	_Normalize	; normalizza FAC
1393
 3828
1394
 3829                        	; moltiplica byte x mantissa
1395
 3830                        	; In:	A = byte
1396
 3831                        	;	ARG
1397
 3832                        	; Out:	FOP = A * ARG
1398
 3833                        	; Uso:	A,X,Y,FOP
1399
 3834  F8396A                	_MultA:
1400
 3835  F8396A  D0 03         		BNE	_MultB
1401
 3836  F8396C  4C A2 38      		JMP	_RShiftFOP	; se A = 0 shift a destra di 8 bit di FOP
1402
 3837  F8396F                	_MultB:
1403
 3838  F8396F  4A            		LSR	A
1404
 3839  F83970  09 80         		ORA	#$80
1405
 3840  F83972  A8            	?01:	TAY
1406
 3841  F83973                		ACC16
1407
 3842  F83973  C2 20         		rep	#PMFLAG
1408
 3843                        		.LONGA	on
1409
 3844                        		.MNLIST
1410
 3845  F83975  90 19         		BCC	?02
1411
 3846  F83977  18            		CLC
1412
 3847  F83978  A5 32         		LDA	FOP
1413
 3848  F8397A  65 52         		ADC	ARG+1
1414
 3849  F8397C  85 32         		STA	FOP
1415
 3850  F8397E  A5 34         		LDA	FOP+2
1416
 3851  F83980  65 54         		ADC	ARG+3
1417
 3852  F83982  85 34         		STA	FOP+2
1418
 3853  F83984  A5 36         		LDA	FOP+4
1419
 3854  F83986  65 56         		ADC	ARG+5
1420
 3855  F83988  85 36         		STA	FOP+4
1421
 3856  F8398A  A5 38         		LDA	FOP+6
1422
 3857  F8398C  65 58         		ADC	ARG+7
1423
 3858  F8398E  85 38         		STA	FOP+6
1424
 3859  F83990  66 38         	?02:	ROR	FOP+6
1425
 3860  F83992  66 36         		ROR	FOP+4
1426
 3861  F83994  66 34         		ROR	FOP+2
1427
  Tue Jul 17 11:00:16 2018                                                                                               Page   24
1428
 
1429
 
1430
 
1431
 
1432
 3862  F83996  66 32         		ROR	FOP
1433
 3863  F83998                		ACC08
1434
 3864  F83998  E2 20         		sep	#PMFLAG
1435
 3865                        		.LONGA	off
1436
 3866                        		.MNLIST
1437
 3867  F8399A  66 41         		ROR	FACEXT
1438
 3868  F8399C  98            		TYA
1439
 3869  F8399D  4A            		LSR	A
1440
 3870  F8399E  D0 D2         		BNE	?01
1441
 3871  F839A0  60            		RTS
1442
 3872
1443
 3873                        	; Imposta l'esponente di FAC per FMUL/FDIV
1444
 3874                        	; In:	FAC (con esponente depolarizzato), ARG
1445
 3875                        	;	Se chiamata da FDIV l'esponente di FAC deve
1446
 3876                        	;	essere cambiato di segno
1447
 3877                        	;	ACC16
1448
 3878                        	; Out:	exp(FAC) = exp(FAC) + exp(ARG)
1449
 3879                        	;	sgn(FAC) corretto
1450
 3880                        	; Uso:	A,X
1451
 3881                        	; Note:	Puo' generare overflow/underflow.
1452
 3882                        	;	In tal caso viene scartato direttamente
1453
 3883                        	;	l'indirizzo di ritorno e FMUL/FDIV terminano
1454
 3884                        	;	in modo prematuro.
1455
 3885                        	;
1456
 3886                        	;	NOTA -- si assume valido esponente polarizzato range $0000 - $7FFE
1457
 3887                        	;	I valori ammessi per l'esponente depolarizzato sono:
1458
 3888                        	;	exp+ -> $0000 - $3FFF (0,MAXPEXP)
1459
 3889                        	;	exp- -> $C001 - $FFFF (MINNEXP, -1) -- NO: C002..$FFFF
1460
 3890                        	;
1461
 3891                        	;	quindi la somma (signed) degli esponenti puo' assumere i
1462
 3892                        	;	valori seguenti:
1463
 3893                        	;
1464
 3894                        	;	(exp+) + (exp+) -> $00000 - $07FFE -> puo' causare overflow
1465
 3895                        	;	(exp+) + (exp-) -> $0C001 - $0FFFF - $10000 - $13FFE
1466
 3896                        	;	(exp-) + (exp+) -> $0C001 - $0FFFF - $10000 - $13FFE
1467
 3897                        	;	(exp-) + (exp-) -> $18002 - $1FFFE -> puo' causare underflow
1468
 3898                        	;
1469
 3899                        	;	Il nuovo esponente polarizzato si calcola ignorando il carry
1470
 3900                        	;	dalla somma signed precedente ed aggiungendo il bias $3FFF:
1471
 3901                        	;	(exp+) + (exp+) -> $03FFF - $0BFFD -> puo' causare overflow (CF = 0)
1472
 3902                        	;	(exp+) + (exp-) -> $00000 - $07FFD -> sempre corretto (CF = 0)
1473
 3903                        	;	(exp-) + (exp+) -> $00000 - $07FFD -> sempre corretto (CF = 0)
1474
 3904                        	;	(exp-) + (exp-) -> $0C001 - $0FFFF -> range $8002..$C000 (CF = 0)
1475
 3905                        	;	(exp-) + (exp-) -> $10000 - $13FFD -> range $C001..$FFFE (CF = 1)
1476
 3906                        	;
1477
 3907                        	;	per operazione MULT occorre incrementare di 1 esponente polarizzato
1478
 3908                        	;
1479
 3909                        	;	si puo' verificare OVERFLOW nel primo caso (exp >= EXPINF)
1480
 3910                        	;	si verifica UNDERFLOW nel quarto caso (exp in $C001..$FFFF)
1481
 3911                        	;	OVERFLOW va testato dopo operazione MULT/DIV e normalizzazione, dato
1482
 3912                        	;	che lo shift a sinistra della mantissa causa il decremento di exp.
1483
 3913                        	;	e quindi si potrebbe ottenere un numero finito normalizzato. Lo shift
1484
 3914                        	;	ruota la massimo 72 bit (compresi gli 8 bit di guardia) quindi se exp
1485
 3915                        	;	supera di 80 bit il max. siamo sicuramente in condizione di overflow.
1486
 3916                        	;	quindi si ha sicuramente OVERFLOW se exp >= $7FFE + $50 = $804E
1487
 3917                        	;	la condizone di UNDERFLOW e' piu' complicata: si puo' assumere che
1488
 3918                        	;	il numero venga azzerato fino a quando exp < -80 ovvero exp < $FFB0
1489
  Tue Jul 17 11:00:16 2018                                                                                               Page   25
1490
 
1491
 
1492
 
1493
 
1494
 3919                        	;	se exp >= FFB0 si puo' tentare di denormalizzare il risultato con
1495
 3920                        	;	una serie di shift a destra in modo da incrementare exp fino alla
1496
 3921                        	; 	condizione exp = 0 ed ottenere un underflow graduale
1497
 3922
1498
 3923  F839A1                	_AddExponent:
1499
 3924  F839A1  86 4D         		stx	FACMlt		; flag MULT
1500
 3925  F839A3  64 4E         		stz	FACUndf		; azzera shift underflow
1501
 3926  F839A5  A6 4C         		LDX	FACSCMP		; MULT/DIV: sgn(FAC) = confronto segni
1502
 3927  F839A7  86 40         		STX	FACSGN
1503
 3928  F839A9                		ACC16
1504
 3929  F839A9  C2 20         		rep	#PMFLAG
1505
 3930                        		.LONGA	on
1506
 3931                        		.MNLIST
1507
 3932  F839AB  38            		SEC			; depolarizza exp(ARG)
1508
 3933  F839AC  A5 5A         		LDA	ARGExp
1509
 3934  F839AE  E9 FF 3F      		SBC	#EXPBIAS
1510
 3935  F839B1  18            		clc
1511
 3936  F839B2  65 4A         		adc	FACExp		; C = nuovo esponente depolarizzato di FAC
1512
 3937  F839B4  18            		clc			; ignora carry
1513
 3938  F839B5  A6 4D         		ldx	FACMlt
1514
 3939  F839B7  10 01         		bpl	?02
1515
 3940  F839B9  38            		sec			; MULT richiede incremento esponente
1516
 3941  F839BA  69 FF 3F      	?02:	adc	#EXPBIAS	; polarizza exp FAC
1517
 3942  F839BD  85 4A         		sta	FACExp
1518
 3943  F839BF  B0 20         		bcs	?08		; OK
1519
 3944  F839C1  C9 FF 7F      		cmp	#EXPINF
1520
 3945  F839C4  90 1B         		bcc	?08		; OK
1521
 3946  F839C6  C9 00 C0      		cmp	#$C000
1522
 3947  F839C9  B0 08         		bcs	?04		; test underflow
1523
 3948  F839CB  C9 4E 80      		cmp	#$804E		; overflow immediato ?
1524
 3949  F839CE  90 11         		bcc	?08		; NO -- dopo normalizzazione
1525
 3950  F839D0  4C 5F 3B      		jmp	_ldinf0		; load INF ed esce
1526
 3951  F839D3  C9 B0 FF      	?04:	cmp	#$FFB0		; underflow immediato ?
1527
 3952  F839D6  B0 03         		bcs	?06		; NO -- dopo MULT/DIV
1528
 3953  F839D8  4C 69 3B      		jmp	_ldz1		; UNDERFLOW immediato: FAC = 0
1529
 3954  F839DB  AA            	?06:	tax			; C low = A => numero shift destra
1530
 3955  F839DC  CA            		dex
1531
 3956  F839DD  86 4E         		stx	FACUndf
1532
 3957  F839DF  64 4A         		stz	FACExp		; underflow graduale -- denormalizza
1533
 3958  F839E1                	?08:	ACC08
1534
 3959  F839E1  E2 20         		sep	#PMFLAG
1535
 3960                        		.LONGA	off
1536
 3961                        		.MNLIST
1537
 3962  F839E3  60            	_RTS5:	rts
1538
 3963  F839E4
1539
 3964                        	; _feMUL10: Funzione veloce che moltiplica FAC per 10
1540
 3965                        	; In:	FAC
1541
 3966                        	; Out:	FAC = FAC*10
1542
 3967                        	;	CF = 1 se overflow
1543
 3968                        	; Uso: 	A,X,Y
1544
 3969  F839E4                	_feMUL10:
1545
 3970  F839E4  20 FF 3B      		JSR	_feXAM		; esamina FAC
1546
 3971  F839E7  B0 FA         		bcs	_RTS5		; FAC non valido (C = 1)
1547
 3972  F839E9  F0 F8         		beq	_RTS5		; FAC = 0 -- esce (C = 0)
1548
 3973  F839EB  20 5D 38      		JSR	_RoundSkp	; arrotonda FAC ed esce in caso di errore
1549
 3974  F839EE  20 E1 3D      		JSR	_MovF2A		; copia FAC in ARG
1550
 3975  F839F1                		ACC16
1551
  Tue Jul 17 11:00:16 2018                                                                                               Page   26
1552
 
1553
 
1554
 
1555
 
1556
 3976  F839F1  C2 20         		rep	#PMFLAG
1557
 3977                        		.LONGA	on
1558
 3978                        		.MNLIST
1559
 3979  F839F3  A5 4A         		lda	FACExp
1560
 3980  F839F5  1A            		inc	a
1561
 3981  F839F6  1A            		inc	a		; FAC = FAC * 4
1562
 3982  F839F7  85 4A         		sta	FACExp
1563
 3983  F839F9  C9 FF 7F      		CMP	#EXPINF		; test overflow
1564
 3984  F839FC                		ACC08
1565
 3985  F839FC  E2 20         		sep	#PMFLAG
1566
 3986                        		.LONGA	off
1567
 3987                        		.MNLIST
1568
 3988  F839FE  B0 16         		bcs	?20		; overflow
1569
 3989  F83A00  20 04 37      		JSR	_feADD		; FAC = FAC + (FAC*4) = 5*FAC
1570
 3990  F83A03  B0 DE         		bcs	_RTS5		; errore
1571
 3991  F83A05                		ACC16
1572
 3992  F83A05  C2 20         		rep	#PMFLAG
1573
 3993                        		.LONGA	on
1574
 3994                        		.MNLIST
1575
 3995  F83A07  A5 4A         		lda	FACExp
1576
 3996  F83A09  1A            		inc	a		; FAC = 2 * (5 * FAC) = 10 * FAC
1577
 3997  F83A0A  85 4A         		sta	FACExp
1578
 3998  F83A0C  C9 FF 7F      		CMP	#EXPINF		; test overflow
1579
 3999  F83A0F                		ACC08
1580
 4000  F83A0F  E2 20         		sep	#PMFLAG
1581
 4001                        		.LONGA	off
1582
 4002                        		.MNLIST
1583
 4003  F83A11  B0 03         		bcs	?20		; overflow
1584
 4004  F83A13  4C D9 37      		jmp	_Normalize
1585
 4005  F83A16  4C 75 3B      	?20:	jmp	_feLDINF1	; FAC = INF con segno di FAC
1586
 4006
1587
 4007                        	;-------------------------------------------------------------
1588
 4008                        	; IMPLEMENTAZIONE _feDIV
1589
 4009                        	;-------------------------------------------------------------
1590
 4010
1591
 4011                        	; _feDIV10: esegue divisione di FAC per 10 e pone il risultato in FAC
1592
 4012                        	; In:	FAC
1593
 4013                        	; Out:	FAC = FAC/10
1594
 4014                        	;	FPUST, per le eccezioni
1595
 4015                        	; Uso:	A,X,Y,FOP
1596
 4016                        	; Note:	Testare lo status in FPUST
1597
 4017  F83A19                	_feDIV10:
1598
 4018  F83A19  A9 44         		LDA	#.HIGH.FCon1E1
1599
 4019  F83A1B  EB            		xba
1600
 4020  F83A1C  A9 B2         		LDA	#.LOW.FCon1E1		; LOAD = 10.0
1601
 4021  F83A1E  A0 F8         		LDY	#.SEG.FCon1E1
1602
 4022
1603
 4023                        	; _feDIVRM: esegue FAC / MEM -> FAC
1604
 4024                        	; In:	CY -> MEM
1605
 4025                        	;	FAC valido
1606
 4026                        	; Out:	FAC = FAC / MEM
1607
 4027                        	;	FPUST, per le eccezioni
1608
 4028                        	; Uso:	C,X,Y,FOP, ARG
1609
 4029                        	; Note:	Testare lo status in FPUST
1610
 4030  F83A20                	_feDIVRM:
1611
 4031  F83A20  85 60         		STA	PTR1			; salva puntatore mem
1612
 4032  F83A22  EB            		xba
1613
  Tue Jul 17 11:00:16 2018                                                                                               Page   27
1614
 
1615
 
1616
 
1617
 
1618
 4033  F83A23  85 61         		sta	PTR1+1
1619
 4034  F83A25  84 62         		STY	PTR1+2
1620
 4035  F83A27  20 5D 38      		JSR	_RoundSkp		; arrotonda FAC, esce se errore
1621
 4036  F83A2A  20 E1 3D      		JSR	_MovF2A			; copia FAC in ARG
1622
 4037  F83A2D  20 69 3D      		JSR	_MovMem2Fa		; FAC = MEM
1623
 4038
1624
 4039                        	; _feDIV: esegue divisione ARG / FAC e pone il risultato in FAC
1625
 4040                        	; In:	FAC, ARG
1626
 4041                        	; Out:	FAC = ARG/FAC
1627
 4042                        	;	FPUST, per le eccezioni
1628
 4043                        	; Uso:	A,X,Y,FOP
1629
 4044                        	; Note:	Testare lo status in FPUST
1630
 4045  F83A30                	_feDIV:
1631
 4046  F83A30  20 25 3B      		JSR	divtst		; test operandi FAC ed ARG
1632
 4047  F83A33  20 5D 38      	?12:	JSR	_RoundSkp	; arrotanda FAC ed esce in caso di eccezione
1633
 4048  F83A36                		ACC16
1634
 4049  F83A36  C2 20         		rep	#PMFLAG
1635
 4050                        		.LONGA	on
1636
 4051                        		.MNLIST
1637
 4052  F83A38  A5 4A         		LDA	FACExp		; depolarizza esponente
1638
 4053  F83A3A  38            		SEC			; e gli cambia segno
1639
 4054  F83A3B  E9 FF 3F      		SBC	#EXPBIAS
1640
 4055  F83A3E  49 FF FF      		EOR	#$FFFF
1641
 4056  F83A41  1A            		inc	a
1642
 4057  F83A42  85 4A         		sta	FACExp
1643
 4058  F83A44                		ACC08
1644
 4059  F83A44  E2 20         		sep	#PMFLAG
1645
 4060                        		.LONGA	off
1646
 4061                        		.MNLIST
1647
 4062  F83A46  A2 00         		ldx	#$00		; flag DIV
1648
 4063  F83A48  20 A1 39      		JSR	_AddExponent
1649
 4064
1650
 4065  F83A4B                	__fdiv__:
1651
 4066  F83A4B  A2 08         		ldx	#8
1652
 4067  F83A4D  A9 01         		LDA	#$01
1653
 4068  F83A4F  A4 59         	?01:	LDY	ARG+8
1654
 4069  F83A51  C4 49         		CPY	FAC+8
1655
 4070  F83A53  D0 28         		BNE	?02
1656
 4071  F83A55  A4 58         		LDY	ARG+7
1657
 4072  F83A57  C4 48         		CPY	FAC+7
1658
 4073  F83A59  D0 22         		BNE	?02
1659
 4074  F83A5B  A4 57         		LDY	ARG+6
1660
 4075  F83A5D  C4 47         		CPY	FAC+6
1661
 4076  F83A5F  D0 1C         		BNE	?02
1662
 4077  F83A61  A4 56         		LDY	ARG+5
1663
 4078  F83A63  C4 46         		CPY	FAC+5
1664
 4079  F83A65  D0 16         		BNE	?02
1665
 4080  F83A67  A4 55         		LDY	ARG+4
1666
 4081  F83A69  C4 45         		CPY	FAC+4
1667
 4082  F83A6B  D0 10         		BNE	?02
1668
 4083  F83A6D  A4 54         		LDY	ARG+3
1669
 4084  F83A6F  C4 44         		CPY	FAC+3
1670
 4085  F83A71  D0 0A         		BNE	?02
1671
 4086  F83A73  A4 53         		LDY	ARG+2
1672
 4087  F83A75  C4 43         		CPY	FAC+2
1673
 4088  F83A77  D0 04         		BNE	?02
1674
 4089  F83A79  A4 52         		LDY	ARG+1
1675
  Tue Jul 17 11:00:16 2018                                                                                               Page   28
1676
 
1677
 
1678
 
1679
 
1680
 4090  F83A7B  C4 42         		CPY	FAC+1
1681
 4091  F83A7D                	?02:
1682
 4092  F83A7D  08            	?02b:	PHP
1683
 4093  F83A7E  2A            		ROL	A
1684
 4094  F83A7F  90 09         		BCC	?03
1685
 4095  F83A81  CA            		dex
1686
 4096  F83A82  30 3F         		BMI	?07
1687
 4097  F83A84  95 32         		STA	<FOP,X
1688
 4098  F83A86  F0 37         		BEQ	?06
1689
 4099  F83A88  A9 01         		LDA	#$01
1690
 4100  F83A8A  28            	?03:	PLP
1691
 4101  F83A8B  B0 12         		BCS	?05
1692
 4102  F83A8D                	?04:	ACC16
1693
 4103  F83A8D  C2 20         		rep	#PMFLAG
1694
 4104                        		.LONGA	on
1695
 4105                        		.MNLIST
1696
 4106  F83A8F  06 52         		ASL	ARG+1
1697
 4107  F83A91  26 54         		ROL	ARG+3
1698
 4108  F83A93  26 56         		ROL	ARG+5
1699
 4109  F83A95  26 58         		ROL	ARG+7
1700
 4110  F83A97                		ACC08
1701
 4111  F83A97  E2 20         		sep	#PMFLAG
1702
 4112                        		.LONGA	off
1703
 4113                        		.MNLIST
1704
 4114  F83A99  B0 E2         		BCS	?02b
1705
 4115  F83A9B  30 B2         		BMI	?01
1706
 4116  F83A9D  10 DE         		BPL	?02b
1707
 4117  F83A9F  A8            	?05:	TAY
1708
 4118  F83AA0                		ACC16
1709
 4119  F83AA0  C2 20         		rep	#PMFLAG
1710
 4120                        		.LONGA	on
1711
 4121                        		.MNLIST
1712
 4122  F83AA2  A5 52         		LDA	ARG+1
1713
 4123  F83AA4  E5 42         		SBC	FAC+1
1714
 4124  F83AA6  85 52         		STA	ARG+1
1715
 4125  F83AA8  A5 54         		LDA	ARG+3
1716
 4126  F83AAA  E5 44         		SBC	FAC+3
1717
 4127  F83AAC  85 54         		STA	ARG+3
1718
 4128  F83AAE  A5 56         		LDA	ARG+5
1719
 4129  F83AB0  E5 46         		SBC	FAC+5
1720
 4130  F83AB2  85 56         		STA	ARG+5
1721
 4131  F83AB4  A5 58         		LDA	ARG+7
1722
 4132  F83AB6  E5 48         		SBC	FAC+7
1723
 4133  F83AB8  85 58         		STA	ARG+7
1724
 4134  F83ABA                		ACC08
1725
 4135  F83ABA  E2 20         		sep	#PMFLAG
1726
 4136                        		.LONGA	off
1727
 4137                        		.MNLIST
1728
 4138  F83ABC  98            		TYA
1729
 4139  F83ABD  80 CE         		BRA	?04
1730
 4140  F83ABF  A9 40         	?06:	LDA	#$40
1731
 4141  F83AC1  D0 C7         		BNE	?03
1732
 4142  F83AC3  0A            	?07:	ASL	A
1733
 4143  F83AC4  0A            		ASL	A
1734
 4144  F83AC5  0A            		ASL	A
1735
 4145  F83AC6  0A            		ASL	A
1736
 4146  F83AC7  0A            		ASL	A
1737
  Tue Jul 17 11:00:16 2018                                                                                               Page   29
1738
 
1739
 
1740
 
1741
 
1742
 4147  F83AC8  0A            		ASL	A
1743
 4148  F83AC9  85 41         		STA	FACEXT
1744
 4149  F83ACB  28            		PLP
1745
 4150  F83ACC  4C 3B 39      		JMP	_CopyFOP
1746
 4151
1747
 4152                        	;-------------------------------------------------------------
1748
 4153                        	; Test operandi FAC e ARG per operazioni ADD, MULT, DIV
1749
 4154                        	;-------------------------------------------------------------
1750
 4155
1751
 4156                        	; test preventivo su FAC ed ARG prima di _feADD
1752
 4157  F83ACF                	addtst:
1753
 4158  F83ACF  20 C8 3B      		jsr	_fe2TST		; test FAC ed ARG e setta confronto segni
1754
 4159  F83AD2  10 13         		bpl	?05		; FAC valido
1755
 4160  F83AD4  A6 40         		ldx	FACSGN		; esce con segno di FAC
1756
 4161  F83AD6  50 79         		bvc	_ldnan0		; FAC = NAN => RESULT = NAN (con segno di FAC)
1757
 4162  F83AD8  24 37         		BIT	ARGXM		; FAC = INF, necessario testare ARG
1758
 4163  F83ADA  30 03         		bmi	?03
1759
 4164  F83ADC  4C 5F 3B      		jmp	_ldinf0		; ARG valido -> (INF + X) -> FAC = INF
1760
 4165  F83ADF  50 70         	?03:	bvc	_ldnan0		; ARG = NAN -> FAC = NAN
1761
 4166  F83AE1  24 4C         		BIT	FACSCMP		; FAC = INF e ARG = INF: cfr. segni
1762
 4167  F83AE3  10 7A         		BPL	_ldinf0		; +INF+INF o -INF-INF -> FAC = INF
1763
 4168  F83AE5  30 6A         		bmi	_ldnan0		; +INF-INF o -INF+INF -> FAC = NAN
1764
 4169  F83AE7  24 37         	?05:	BIT	ARGXM		; FAC valido -- test ARG
1765
 4170  F83AE9  10 06         		BPL	?10		; ARG valido
1766
 4171  F83AEB  A6 50         		LDX	ARGSGN		; esce con segno di ARG
1767
 4172  F83AED  50 62         		BVC	_ldnan0		; ARG = NAN -> (X + NAN) -> FAC = NAN
1768
 4173  F83AEF  70 6E         		bvs	_ldinf0		; ARG = INF -> (X + INF) -> FAC = INF
1769
 4174  F83AF1  70 07         	?10:	bvs	_skpxam		; ARG = 0 => esce con FAC inalterato
1770
 4175  F83AF3  24 36         		bit	FACXM		; test FAC = 0
1771
 4176  F83AF5  50 2D         		bvc	_RTSA		; esegue ADD
1772
 4177  F83AF7  20 CE 3D      		jsr	_MovA2F		; FAC = 0 + ARG = ARG
1773
 4178  F83AFA
1774
 4179  F83AFA                	_skpxam:
1775
 4180  F83AFA  68            		pla
1776
 4181  F83AFB  68            		pla
1777
 4182  F83AFC  4C FF 3B      		jmp	_feXAM
1778
 4183
1779
 4184                        	; test preventivo su FAC ed ARG prima di _feMUL
1780
 4185  F83AFF                	multst:
1781
 4186  F83AFF  20 C8 3B      		JSR	_fe2TST		; test operandi FAC e ARG
1782
 4187  F83B02  10 0E         		BPL	?05		; FAC valido -- testare ARG
1783
 4188  F83B04  50 47         		bvc	_ldnan1		; FAC = NAN => RESULT = NAN
1784
 4189  F83B06  24 37         		BIT	ARGXM		; FAC = INF -- test ARG
1785
 4190  F83B08  10 04         		BPL	?03		; ARG valido
1786
 4191  F83B0A  70 4F         		BVS	_ldinf1		; ARG = INF -> (INF * INF) => FAC = INF
1787
 4192  F83B0C  50 3F         		BVC	_ldnan1		; ARG = NAN -> (INF * NAN) => FAC = NAN
1788
 4193  F83B0E  50 4B         	?03:	bvc	_ldinf1		; ARG <> 0  -> (INF * X) -> FAC = INF
1789
 4194  F83B10  70 3B         		bvs	_ldnan1		; ARG = 0   -> (INF * 0) -> FAC = NAN
1790
 4195  F83B12  24 37         	?05:	BIT	ARGXM		; FAC valido -- test ARG
1791
 4196  F83B14  10 08         		BPL	?10		; ARG valido
1792
 4197  F83B16  50 35         		BVC	_ldnan1		; ARG = NAN -> (X * NAN) -> FAC = NAN
1793
 4198  F83B18  24 36         		bit	FACXM		; ARG = INF -> necessario testare FAC
1794
 4199  F83B1A  50 3F         		bvc	_ldinf1		; FAC <> 0  -> (X * INF) -> FAC = INF
1795
 4200  F83B1C  70 2F         		bvs	_ldnan1		; FAC = 0   -> (0 * INF) -> FAC = NAN
1796
 4201  F83B1E  70 49         	?10:	bvs	_ldz1		; VF = 1 -> ARG = 0 -> (X * 0) -> FAC = 0
1797
 4202  F83B20  24 36         		bit	FACXM		; test flag zero FAC
1798
 4203  F83B22  70 45         		bvs	_ldz1		; VF = 1 -> FAC = 0 -> (0 * X) -> FAC = 0
1799
  Tue Jul 17 11:00:16 2018                                                                                               Page   30
1800
 
1801
 
1802
 
1803
 
1804
 4204  F83B24                	_RTSA:
1805
 4205  F83B24  60            		rts			; OK -- esegue MULT
1806
 4206
1807
 4207                        	; test preventivo su FAC ed ARG prima di _feDIV
1808
 4208  F83B25                	divtst:
1809
 4209  F83B25  20 C8 3B      		JSR	_fe2TST		; test operandi FAC ed ARG
1810
 4210  F83B28  10 08         		BPL	?05		; FAC valido
1811
 4211  F83B2A  50 21         		bvc	_ldnan1		; FAC = NAN => RESULT = NAN
1812
 4212  F83B2C  24 37         		BIT	ARGXM		; FAC = INF -- test ARG
1813
 4213  F83B2E  30 1D         		bmi	_ldnan1		; ARG = NAN/INF -> (NANINF / INF) -> FAC = NAN
1814
 4214  F83B30  10 37         		bpl	_ldz1		; ARG = X -> (X / INF) -> FAC = ZERO
1815
 4215  F83B32  24 37         	?05:	bit	ARGXM		; FAC valido -- test ARG
1816
 4216  F83B34  10 08         		bpl	?10		; ARG valido
1817
 4217  F83B36  50 15         		bvc	_ldnan1		; ARG = NAN -> (NAN / X) -> FAC = NAN
1818
 4218  F83B38  24 36         		bit	FACXM		; ARG = INF -- testare FAC = 0
1819
 4219  F83B3A  50 1F         		bvc	_ldinf1		; FAC <> 0  -> (INF / X) -> FAC = INF
1820
 4220  F83B3C  70 25         		bvs	_ldinfz		; FAC = 0 -> (INF / 0) -> FAC = INF e ZF = 1
1821
 4221  F83B3E  24 36         	?10:	bit	FACXM		; FAC ed ARG validi -- testare FAC = 0
1822
 4222  F83B40  50 06         		bvc	?14		; FAC non nullo
1823
 4223  F83B42  24 37         		bit	ARGXM		; FAC = 0 -- test ARG
1824
 4224  F83B44  50 1D         		bvc	_ldinfz		; ARG <> 0 -> (X / 0) -> FAC = INF, ZF = 1
1825
 4225  F83B46  70 0D         		bvs	_ldnanz		; ARG = 0 -> (0 / 0) -> FAC = NAN, ZF = 1
1826
 4226  F83B48  24 37         	?14:	bit	ARGXM		; FAC <> 0 -- test ARG = 0
1827
 4227  F83B4A  70 1D         		bvs	_ldz1		; ARG = 0 -> (0 / X) -> FAC = 0
1828
 4228  F83B4C  60            		rts
1829
 4229
1830
 4230  F83B4D                	_ldnan1:
1831
 4231  F83B4D  A6 4C         		ldx	FACSCMP		; segno risultato
1832
 4232  F83B4F  86 40         		stx	FACSGN
1833
 4233  F83B51                	_ldnan0:
1834
 4234  F83B51  7A            		ply			; scarta indirizzo di ritorno
1835
 4235  F83B52  7A            		ply
1836
 4236  F83B53  80 33         		bra	_feLDNAN1	; FAC = +/- NAN
1837
 4237
1838
 4238  F83B55                	_ldnanz:
1839
 4239  F83B55  A6 4C         		ldx	FACSCMP		; segno risultato
1840
 4240  F83B57  7A            		ply			; scarta indirizzo di ritorno
1841
 4241  F83B58  7A            		ply
1842
 4242  F83B59  80 25         		bra	_feLDNANZ	; FAC = +/- NAN, ZF = 1
1843
 4243  F83B5B
1844
 4244  F83B5B                	_ldinf1:
1845
 4245  F83B5B  A6 4C         		ldx	FACSCMP		; segno risultato
1846
 4246  F83B5D  86 40         		stx	FACSGN
1847
 4247  F83B5F                	_ldinf0:
1848
 4248  F83B5F  7A            		ply			; scarta indirizzo di ritorno
1849
 4249  F83B60  7A            		ply
1850
 4250  F83B61  80 12         		bra	_feLDINF1	; FAC = +/- INF
1851
 4251
1852
 4252  F83B63                	_ldinfz:
1853
 4253  F83B63  A6 4C         		ldx	FACSCMP		; segno risultato
1854
 4254  F83B65  7A            		ply			; scarta indirizzo di ritorno
1855
 4255  F83B66  7A            		ply
1856
 4256  F83B67  80 04         		bra	_feLDINFZ	; FAC = +/- INF, ZF = 1
1857
 4257
1858
 4258  F83B69                	_ldz1:
1859
 4259  F83B69  7A            		ply			; scarta indirizzo di ritorno
1860
 4260  F83B6A  7A            		ply
1861
  Tue Jul 17 11:00:16 2018                                                                                               Page   31
1862
 
1863
 
1864
 
1865
 
1866
 4261  F83B6B  80 43         		bra	_feLDZ		; FAC = +ZERO
1867
 4262  F83B6D
1868
 4263                        	;-------------------------------------------------------------
1869
 4264                        	; Load FAC/ARG con valori speciali
1870
 4265                        	;-------------------------------------------------------------
1871
 4266
1872
 4267                        	; _feLDINFZ: Imposta FAC = +/-INF e ZF
1873
 4268                        	; In:	X = segno
1874
 4269                        	; Out:	FAC = +/-INF
1875
 4270                        	;	Flag come da _feXAM + ZF
1876
 4271                        	; Uso:	A,Y,X
1877
 4272                        	; Note:	FACSGN settato, FACEXT azzerato
1878
 4273  F83B6D                	_feLDINFZ:
1879
 4274  F83B6D  86 40         		STX	FACSGN		; imposta segno FAC
1880
 4275
1881
 4276                        	; _feLDINF1Z: Imposta FAC = +/-INF e ZF
1882
 4277                        	; In:	FACSGN = segno
1883
 4278                        	; Out:	FAC = +/-INF
1884
 4279                        	;	Flag come da _feXAM + ZF
1885
 4280                        	; Uso:	A,Y,X
1886
 4281                        	; Note:	FACSGN settato, FACEXT azzerato
1887
 4282                        	;***************************************
1888
 4283  F83B6F                	_feLDINF1Z:
1889
 4284  F83B6F  A0 00         		ldy	#0		; ZF = 1, NF = 0
1890
 4285  F83B71  F0 04         		beq	_fldinf
1891
 4286  F83B73
1892
 4287                        	; _feLDINF: Imposta FAC = +/-INF
1893
 4288                        	; In:	X = segno
1894
 4289                        	; Out:	FAC = +/-INF
1895
 4290                        	;	Flag come da _feXAM
1896
 4291                        	; Uso:	A,Y,X
1897
 4292                        	; Note:	FACSGN settato, FACEXT azzerato
1898
 4293  F83B73                	_feLDINF:
1899
 4294  F83B73  86 40         		STX	FACSGN		; imposta segno FAC
1900
 4295
1901
 4296                        	; _feLDINF1: Imposta FAC = +/-INF
1902
 4297                        	; In:	FACSGN = segno
1903
 4298                        	; Out:	FAC = +/-INF
1904
 4299                        	;	Flag come da _feXAM
1905
 4300                        	; Uso:	A,Y,X
1906
 4301                        	; Note:	FACSGN settato, FACEXT azzerato
1907
 4302  F83B75                	_feLDINF1:
1908
 4303  F83B75  A0 01         		ldy	#1		; ZF = 0, NF = 0
1909
 4304
1910
 4305                        	; ingresso per settare +/- INF e ZF
1911
 4306  F83B77                	_fldinf:
1912
 4307  F83B77  E2 40         		sep	#PVFLAG		; V = 1 => segnala INF
1913
 4308  F83B79                		ACC16
1914
 4309  F83B79  C2 20         		rep	#PMFLAG
1915
 4310                        		.LONGA	on
1916
 4311                        		.MNLIST
1917
 4312  F83B7B  A9 00 80      		lda	#MANTINF
1918
 4313  F83B7E  80 10         		bra	_fldnv
1919
 4314
1920
 4315                        	; _feLDNANZ: Imposta FAC = +/-NAN e ZF = 1
1921
 4316                        	; In:	X = segno
1922
 4317                        	; Out:	FAC = +/-NAN
1923
  Tue Jul 17 11:00:16 2018                                                                                               Page   32
1924
 
1925
 
1926
 
1927
 
1928
 4318                        	;	CF = 1, VF = 0, ZF = 1
1929
 4319                        	; Uso:	A,Y,X
1930
 4320                        	; Note:	FACSGN settato, FACEXT azzerato
1931
 4321  F83B80                	_feLDNANZ:
1932
 4322  F83B80  86 40         		stx	FACSGN
1933
 4323  F83B82  A0 00         		ldy	#0		; ZF = 1, NF = 0
1934
 4324  F83B84  F0 04         		beq	_feLDNAN2
1935
 4325
1936
 4326                        	; _feLDNAN: Imposta FAC = +/-NAN
1937
 4327                        	; In:	X = segno
1938
 4328                        	; Out:	FAC = +/-NAN
1939
 4329                        	;	CF = 1, VF = 0, ZF = 0
1940
 4330                        	; Uso:	A,Y,X
1941
 4331                        	; Note:	FACSGN settato, FACEXT azzerato
1942
 4332  F83B86                	_feLDNAN:
1943
 4333  F83B86  86 40         		stx	FACSGN
1944
 4334  F83B88
1945
 4335                        	; _feLDNAN1: Imposta FAC = +/-NAN
1946
 4336                        	; In:	FACSgn
1947
 4337                        	; Out:	FAC = +/-NAN
1948
 4338                        	;	CF = 1, VF = 0, ZF = 0
1949
 4339                        	; Uso:	A,Y,X
1950
 4340                        	; Note:	FACSGN settato, FACEXT azzerato
1951
 4341                        	;****************************************
1952
 4342  F83B88                	_feLDNAN1:
1953
 4343  F83B88  A0 01         		ldy	#1		; ZF = 0, NF = 0
1954
 4344  F83B8A                	_feLDNAN2:
1955
 4345  F83B8A  B8            		clv			; V = 0 => segnala NAN
1956
 4346  F83B8B                		ACC16
1957
 4347  F83B8B  C2 20         		rep	#PMFLAG
1958
 4348                        		.LONGA	on
1959
 4349                        		.MNLIST
1960
 4350  F83B8D  A9 00 FF      		lda	#MANTNAN
1961
 4351
1962
 4352                        	; ingresso con ACC16
1963
 4353  F83B90                	_fldnv:
1964
 4354                        		LONGA	on
1965
 4355  F83B90  85 48         		sta	FAC+7
1966
 4356  F83B92  64 46         		stz	FAC+5
1967
 4357  F83B94  64 44         		stz	FAC+3
1968
 4358  F83B96  64 42         		stz	FAC+1
1969
 4359  F83B98  A9 FF 7F      		lda	#EXPINF
1970
 4360  F83B9B  85 4A         		sta	FACExp
1971
 4361  F83B9D                		ACC08
1972
 4362  F83B9D  E2 20         		sep	#PMFLAG
1973
 4363                        		.LONGA	off
1974
 4364                        		.MNLIST
1975
 4365  F83B9F  64 41         		stz	FACEXT
1976
 4366  F83BA1  38            		sec			; segnala errore
1977
 4367  F83BA2  98            		tya			; imposta ZF, NF = 0
1978
 4368  F83BA3  08            		php
1979
 4369  F83BA4  A6 40         		ldx	FACSGN
1980
 4370  F83BA6  10 06         		bpl	?10
1981
 4371  F83BA8  A3 01         		lda	$01,s		; imposta NF
1982
 4372  F83BAA  09 80         		ora	#$80
1983
 4373  F83BAC  83 01         		sta	$01,s
1984
 4374  F83BAE  28            	?10:	plp
1985
  Tue Jul 17 11:00:16 2018                                                                                               Page   33
1986
 
1987
 
1988
 
1989
 
1990
 4375  F83BAF  60            		rts
1991
 4376
1992
 4377                        	; _feLDZ - load ZERO in FAC
1993
 4378                        	; Out flag : CF = VF = NF = 0, ZF = 1
1994
 4379  F83BB0                	_feLDZ:
1995
 4380  F83BB0                		ACC16
1996
 4381  F83BB0  C2 20         		rep	#PMFLAG
1997
 4382                        		.LONGA	on
1998
 4383                        		.MNLIST
1999
 4384  F83BB2  A9 00 00      		lda	#0		; ZF = 1, NF = 0
2000
 4385  F83BB5  85 42         		sta	FAC+1
2001
 4386  F83BB7  85 44         		sta	FAC+3
2002
 4387  F83BB9  85 46         		sta	FAC+5
2003
 4388  F83BBB  85 48         		sta	FAC+7
2004
 4389  F83BBD  85 4A         		sta	FACExp
2005
 4390  F83BBF                		ACC08
2006
 4391  F83BBF  E2 20         		sep	#PMFLAG
2007
 4392                        		.LONGA	off
2008
 4393                        		.MNLIST
2009
 4394  F83BC1  85 40         		sta	FACSGN
2010
 4395  F83BC3  85 41         		sta	FACEXT
2011
 4396  F83BC5  18            		clc
2012
 4397  F83BC6  B8            		clv
2013
 4398  F83BC7  60            		rts
2014
 4399
2015
 4400                        	;-------------------------------------------------------------
2016
 4401                        	; ESAMINA REGISTRI FAC E ARG
2017
 4402                        	;----------------------------------- -------------------------
2018
 4403
2019
 4404                        	; Esamina FAC ed ARG per operazioni con 2 operandi
2020
 4405                        	; Lo status viene riportato nei bit 7 e 6 di FACXM e ARGXM
2021
 4406                        	; secondo il seguente schema:
2022
 4407                        	;	FACXM(7) -> FAC non valido (NAN o INF)
2023
 4408                        	;	FACXM(6) -> FAC = INF (se bit 7 = 1)
2024
 4409                        	;		 -> FAC = 0   (se bit 7 = 0)
2025
 4410                        	;	ARGXM(7) -> ARG non valido (NAN o INF)
2026
 4411                        	;	ARGXM(6) -> ARG = INF (se bit 7 = 1)
2027
 4412                        	;		 -> ARG = 0   (se bit 7 = 0)
2028
 4413                        	; Inoltre viene correttamente impostato il flag di
2029
 4414                        	; confronto dei segni FACSCMP.
2030
 4415                        	; In:	FAC, ARG
2031
 4416                        	; Out:	FACXM, ARGXM
2032
 4417                        	;	FLAG N, V come da 'bit FACXM'
2033
 4418                        	;	CF = 1 se FAC non valido (NAN o INF)
2034
 4419                        	; Uso:	A,X,FACXM,ARGXM
2035
 4420  F83BC8                	_fe2TST:
2036
 4421  F83BC8  A5 50         		LDA	ARGSGN		; imposta il flag confronto segni
2037
 4422  F83BCA  45 40         		EOR	FACSGN
2038
 4423  F83BCC  85 4C         		STA	FACSCMP		; negativo se segni discordi
2039
 4424  F83BCE  20 FB 3B      		jsr	_feXAMARG	; esamina ARG (A = 0)
2040
 4425  F83BD1  90 08         		bcc	?02		; ARG valido
2041
 4426  F83BD3  A9 80         		lda	#$80		; bit 7 -> non valido
2042
 4427  F83BD5  50 08         		bvc	?04		; NAN
2043
 4428  F83BD7  09 40         		ora	#$40		; flag INF
2044
 4429  F83BD9  80 04         		bra	?04
2045
 4430  F83BDB  D0 02         	?02:	bne	?04
2046
 4431  F83BDD  A9 40         		lda	#$40		; flag ZERO
2047
  Tue Jul 17 11:00:16 2018                                                                                               Page   34
2048
 
2049
 
2050
 
2051
 
2052
 4432  F83BDF  85 37         	?04:	sta	ARGXM
2053
 4433  F83BE1  20 FF 3B      		jsr	_feXAM		; esamina FAC (A = 0)
2054
 4434  F83BE4  90 08         		bcc	?06		; FaC valido
2055
 4435  F83BE6  A9 80         		lda	#$80		; bit 7 -> non valido
2056
 4436  F83BE8  50 08         		bvc	?08		; NAN
2057
 4437  F83BEA  09 40         		ora	#$40		; flag INF
2058
 4438  F83BEC  80 04         		bra	?08
2059
 4439  F83BEE  D0 02         	?06:	bne	?08
2060
 4440  F83BF0  A9 40         		lda	#$40		; flag ZERO
2061
 4441  F83BF2  85 36         	?08:	sta	FACXM
2062
 4442  F83BF4  24 36         		bit	FACXM		; ritorna flag C, N, V
2063
 4443  F83BF6  18            		clc			; valido
2064
 4444  F83BF7  10 01         		bpl	?18
2065
 4445  F83BF9  38            		sec			; non valido
2066
 4446  F83BFA  60            	?18:	rts
2067
 4447
2068
 4448                        	; _feXAM e _feXAMARG impostano i flag nel seguente modo
2069
 4449                        	;
2070
 4450                        	;	CF = 0 => registro valido
2071
 4451                        	;	NF = 1 => segno registro
2072
 4452                        	;	ZF = 1 => se registro nullo e valido
2073
 4453                        	;	VF = 1 => denormale
2074
 4454                        	;
2075
 4455                        	;	CF = 1 => registro non valido
2076
 4456                        	;	NF = 1 => segno registro
2077
 4457                        	;	VF = 0 => NAN se registro non valido
2078
 4458                        	;	VF = 1 => INF se registro non valido
2079
 4459                        	;	ZF = 0 => ignorare
2080
 4460  F83BFB
2081
 4461                        	; _feXAMARG: Esamina registro ARG
2082
 4462                        	; In:
2083
 4463                        	; Out:	P = ARG Status (C, N, V, Z)
2084
 4464                        	;	X -> indice a ARG-1
2085
 4465                        	;	A = 0
2086
 4466                        	; Usa:	A,X
2087
 4467  F83BFB                	_feXAMARG:
2088
 4468  F83BFB  A2 50         		LDX	#ARGSGN
2089
 4469  F83BFD  80 02         		BRA	_FXAM
2090
 4470
2091
 4471                        	; _feXAM: Esamina registro FAC
2092
 4472                        	; In:
2093
 4473                        	; Out:	P = FAC Status (C, N, V, Z)
2094
 4474                        	;	X -> indice a FAC-1
2095
 4475                        	;	A = 0
2096
 4476                        	; Usa:	A,X
2097
 4477  F83BFF                	_feXAM:
2098
 4478  F83BFF  A2 40         		LDX	#FACSGN
2099
 4479
2100
 4480                        	; _FXAM: Esamina registro FAC/ARG
2101
 4481                        	; In:	X -> indice a FAC-1 o ARG-1 (segno)
2102
 4482                        	; Out:	P = FAC/ARG Status (C, N, V, Z)
2103
 4483                        	;	A = 0
2104
 4484                        	;	X -> indice a FAC o ARG
2105
 4485                        	; Usa:	A,X
2106
 4486  F83C01                	_FXAM:
2107
 4487  F83C01  B8            		clv			; setta preventivamente V = 0
2108
 4488  F83C02                		ACC16
2109
  Tue Jul 17 11:00:16 2018                                                                                               Page   35
2110
 
2111
 
2112
 
2113
 
2114
 4489  F83C02  C2 20         		rep	#PMFLAG
2115
 4490                        		.LONGA	on
2116
 4491                        		.MNLIST
2117
 4492  F83C04  B5 0A         		LDA	<10,X		; test EXP
2118
 4493  F83C06  F0 12         		beq	?04		; exp = 0 -- denormal o ZERO
2119
 4494  F83C08  C9 FF 7F      		CMP	#EXPINF		; test INF/NAN
2120
 4495                        		; se CF = 0 => EXP valido -- numero valido non nullo
2121
 4496                        		; qui ZF = 0 e CF = 0 da confronto precedente
2122
 4497  F83C0B  90 1A         		bcc	?08		; C = V = Z = 0 => imposta N
2123
 4498                        		; se CF = 1 allora registro contiene INF o NAN
2124
 4499  F83C0D  B5 08         		lda	<8,x		; test mantissa NAN/INF
2125
 4500  F83C0F  C9 00 80      		CMP	#MANTINF
2126
 4501  F83C12  D0 02         		bne	?02		; NAN => V = 0
2127
 4502  F83C14  E2 40         		sep	#PVFLAG		; INF => V = 1
2128
 4503  F83C16  38            	?02:	sec			; CF = 1 => non valido
2129
 4504  F83C17  3A            		dec	a		; imposta ZF = 0 (A >= EXPINF)
2130
 4505  F83C18  B0 0D         		bcs	?08		; C, Z, V settati -- imposta N
2131
 4506                        		; ZERO o DENORMAL -- esamina mantissa
2132
 4507  F83C1A  B5 02         	?04:	lda	<2,x		; imposta ZF
2133
 4508  F83C1C  15 04         		ora	<4,x
2134
 4509  F83C1E  15 06         		ora	<6,x
2135
 4510  F83C20  15 08         		ora	<8,x		; ZF = 1 => FAC/ARG = 0
2136
 4511  F83C22  18            		clc			; valido
2137
 4512  F83C23  F0 02         		beq	?08		; ZERO => C = V = 0, Z = 1
2138
 4513  F83C25  E2 40         		sep	#PVFLAG		; denormal => C = Z = 0, V = 1
2139
 4514  F83C27                	?08:	ACC08
2140
 4515  F83C27  E2 20         		sep	#PMFLAG
2141
 4516                        		.LONGA	off
2142
 4517                        		.MNLIST
2143
 4518  F83C29  08            		php			; salva status: V, Z, C
2144
 4519  F83C2A  A3 01         		lda	$01,s		; clear NF nello stack
2145
 4520  F83C2C  29 7F         		and	#$7F
2146
 4521  F83C2E  83 01         		sta	$01,s
2147
 4522  F83C30  B5 00         		lda	<0,x		; segno
2148
 4523  F83C32  29 80         		and	#$80		; maschera bit 7
2149
 4524  F83C34  03 01         		ora	$01,s		; imposta NF nello stack
2150
 4525  F83C36  83 01         		sta	$01,s
2151
 4526  F83C38  A9 00         		lda	#0
2152
 4527  F83C3A  28            		plp			; ripristina flag
2153
 4528  F83C3B  60            		rts
2154
 4529  F83C3C
2155
 4530                        	;----------------------------------------------------------
2156
 4531                        	; implementazione _feCMP, _feCMPM, _feSGN, _feCHS, _feABS
2157
 4532                        	;----------------------------------------------------------
2158
 4533
2159
 4534                        	; _feCMP: Confronta FAC con ARG
2160
 4535                        	; In:	FAC, ARG (supposti validi)
2161
 4536                        	; Out:	A =  1 se FAC > ARG (ZF = 0, NF == 0)
2162
 4537                        	;	A =  0 se FAC = ARG (ZF = 1)
2163
 4538                        	;	A = -1 se FAC < ARG (ZF = 0, NF == 1)
2164
 4539                        	; Uso:	A,X
2165
 4540                        	; Note:	|INF| < |NAN|
2166
 4541  F83C3C                	_feCMP:
2167
 4542  F83C3C  20 FB 3B      		jsr	_feXAMARG	; test ARG = 0
2168
 4543  F83C3F  F0 35         		BEQ	_feSGN		; ARG = 0 -> ritorna sgn(FAC)
2169
 4544  F83C41  A5 50         		LDA	ARGSGN
2170
 4545  F83C43  45 40         		EOR	FACSGN
2171
  Tue Jul 17 11:00:16 2018                                                                                               Page   36
2172
 
2173
 
2174
 
2175
 
2176
 4546  F83C45  30 2F         		BMI	_feSGN		; Segni discordi: ritorna sgn(FAC)
2177
 4547  F83C47                		ACC16			; CONFRONTA ESPONENTI
2178
 4548  F83C47  C2 20         		rep	#PMFLAG
2179
 4549                        		.LONGA	on
2180
 4550                        		.MNLIST
2181
 4551  F83C49  A5 5A         		lda	ARGExp
2182
 4552  F83C4B  C5 4A         		cmp	FACExp
2183
 4553  F83C4D  90 3B         		BCC	_FSGN3		; FAC > ARG
2184
 4554  F83C4F  D0 39         		BNE	_FSGN3		; FAC < ARG (CF = 1)
2185
 4555  F83C51
2186
 4556                        		; gli esponenti sono uguali - confronto mantissa byte a byte
2187
 4557  F83C51  A5 58         		LDA	ARG+7		; MSB mantissa ARG
2188
 4558  F83C53  C5 48         		CMP	FAC+7
2189
 4559  F83C55  D0 33         		BNE	_FSGN3
2190
 4560  F83C57  A5 56         		LDA	ARG+5
2191
 4561  F83C59  C5 46         		CMP	FAC+5
2192
 4562  F83C5B  D0 2D         		BNE	_FSGN3
2193
 4563  F83C5D  A5 54         		LDA	ARG+3
2194
 4564  F83C5F  C5 44         		CMP	FAC+3
2195
 4565  F83C61  D0 27         		BNE	_FSGN3
2196
 4566  F83C63                		ACC08
2197
 4567  F83C63  E2 20         		sep	#PMFLAG
2198
 4568                        		.LONGA	off
2199
 4569                        		.MNLIST
2200
 4570  F83C65  A5 53         		LDA	ARG+2
2201
 4571  F83C67  C5 43         		CMP	FAC+2
2202
 4572  F83C69  D0 1F         		BNE	_FSGN3
2203
 4573  F83C6B  A9 7F         		LDA	#$7F		; bit di guardia
2204
 4574  F83C6D  C5 41         		CMP	FACEXT		; CF settato
2205
 4575  F83C6F  A5 52         		LDA	ARG+1
2206
 4576  F83C71  E5 42         		SBC	FAC+1
2207
 4577  F83C73  D0 15         		BNE	_FSGN3
2208
 4578  F83C75  60            		RTS			; FAC = ARG
2209
 4579  F83C76
2210
 4580                        	; _feSGN: funzione che ritorna il segno di FAC
2211
 4581                        	; In:	FAC (supposto valido)
2212
 4582                        	; Out:	A =  1 se FAC > 0 (ZF = 0, NF == 0)
2213
 4583                        	;	A =  0 se FAC = 0 (ZF = 1)
2214
 4584                        	;	A = -1 se FAC < 0 (ZF = 0, NF == 1)
2215
 4585                        	; Uso:	A, X
2216
 4586                        	; Note:	NAN e INF assunti come validi
2217
 4587  F83C76                	_feSGN:
2218
 4588  F83C76                		CPU08			; necessario !!!
2219
 4589  F83C76  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
2220
 4590                        		.LONGA	off
2221
 4591                        		.LONGI	off
2222
 4592                        		.MNLIST
2223
 4593  F83C78  20 FF 3B      		jsr	_feXAM		; test FAC = 0
2224
 4594  F83C7B  D0 03         		bne	_FSGN1
2225
 4595  F83C7D  A9 00         		lda	#0
2226
 4596  F83C7F  60            		rts
2227
 4597                        	_FSGN1:				; test segno FAC
2228
 4598  F83C80  A5 40         		LDA	FACSGN
2229
 4599                        	_FSGN2:				; test segno A
2230
 4600  F83C82  2A            		ROL	A
2231
 4601  F83C83  A9 FF         		LDA	#$FF
2232
 4602  F83C85  B0 02         		BCS	_RTS7
2233
  Tue Jul 17 11:00:16 2018                                                                                               Page   37
2234
 
2235
 
2236
 
2237
 
2238
 4603  F83C87  A9 01         		LDA	#$01
2239
 4604  F83C89                	_RTS7:
2240
 4605  F83C89  60            		RTS
2241
 4606  F83C8A                	_FSGN3:
2242
 4607  F83C8A                		CPU08			; necessario
2243
 4608  F83C8A  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
2244
 4609                        		.LONGA	off
2245
 4610                        		.LONGI	off
2246
 4611                        		.MNLIST
2247
 4612  F83C8C  A5 40         		LDA	FACSGN		; segno FAC
2248
 4613  F83C8E  90 F2         		BCC	_FSGN2		; FAC > Float MEM (o ARG)
2249
 4614  F83C90  49 FF         		EOR	#$FF		; inverte segno
2250
 4615  F83C92  80 EE         		BRA	_FSGN2		; FAC < Float MEM (o ARG)
2251
 4616
2252
 4617  F83C94
2253
 4618                        	; _feCMPM: Confronta FAC con MEM
2254
 4619                        	; In:	CY -> puntatore memoria MEM
2255
 4620                        	; Out:	A =  1 se FAC > MEM (ZF = 0, NF == 0)
2256
 4621                        	;	A =  0 se FAC = MEM (ZF = 1)
2257
 4622                        	;	A = -1 se FAC < MEM (ZF = 0, NF == 1)
2258
 4623                        	; Uso:	A, B,PTR1,Y,X
2259
 4624                        	; Note:	Nessuna eccezione se FAC e/o Float MEM non valid1
2260
 4625  F83C94                	_feCMPM:
2261
 4626  F83C94  85 60         		STA	PTR1		; puntatore memoria
2262
 4627  F83C96  EB            		xba
2263
 4628  F83C97  85 61         		STA	PTR1+1
2264
 4629  F83C99  84 62         		STY	PTR1+2
2265
 4630  F83C9B  A0 08         		LDY	#$08
2266
 4631  F83C9D                		CPU16
2267
 4632  F83C9D  C2 30         		rep	#(PMFLAG.OR.PXFLAG)
2268
 4633                        		.LONGA	on
2269
 4634                        		.LONGI	on
2270
 4635                        		.MNLIST
2271
 4636  F83C9F  B7 60         		lda	[PTR1],y	; EXP
2272
 4637  F83CA1  AA            		tax			; salva esponente in X
2273
 4638  F83CA2  29 FF 7F      		and	#$7FFF		; maschera segno
2274
 4639  F83CA5  88            		dey
2275
 4640  F83CA6  88            		dey
2276
 4641  F83CA7  17 60         	?01:	ora	[PTR1],y	; test zero
2277
 4642  F83CA9  88            		dey
2278
 4643  F83CAA  88            		dey
2279
 4644  F83CAB  10 FA         		bpl	?01
2280
 4645  F83CAD  A8            		tay
2281
 4646  F83CAE  F0 C6         		BEQ	_feSGN		; Float MEM = 0: ritorna sgn(FAC)
2282
 4647  F83CB0  8A            		txa			; segno
2283
 4648  F83CB1  EB            		xba			; A = segno
2284
 4649  F83CB2                		ACC08
2285
 4650  F83CB2  E2 20         		sep	#PMFLAG
2286
 4651                        		.LONGA	off
2287
 4652                        		.MNLIST
2288
 4653  F83CB4  45 40         		EOR	FACSGN
2289
 4654  F83CB6  30 BE         		BMI	_feSGN		; Segni discordi: ritorna sgn(FAC)
2290
 4655  F83CB8                		ACC16
2291
 4656  F83CB8  C2 20         		rep	#PMFLAG
2292
 4657                        		.LONGA	on
2293
 4658                        		.MNLIST
2294
 4659  F83CBA  8A            		txa
2295
  Tue Jul 17 11:00:16 2018                                                                                               Page   38
2296
 
2297
 
2298
 
2299
 
2300
 4660  F83CBB  29 FF 7F      		and	#$7FFF		; esponente
2301
 4661  F83CBE  C5 4A         		cmp	FACExp
2302
 4662  F83CC0  90 C8         		BCC	_FSGN3		; FAC > MEM
2303
 4663  F83CC2  D0 C6         		BNE	_FSGN3		; FAC < MEM (CF = 1)
2304
 4664                        		; gli esponenti sono uguali -- compare mantisse
2305
 4665  F83CC4                		INDEX08
2306
 4666  F83CC4  E2 10         		sep	#PXFLAG
2307
 4667                        		.LONGI	off
2308
 4668                        		.MNLIST
2309
 4669  F83CC6  A0 06         		ldy	#6
2310
 4670  F83CC8  B7 60         		lda	[PTR1],y	; MSB mantissa Float MEM
2311
 4671  F83CCA  C5 48         		CMP	FAC+7
2312
 4672  F83CCC  D0 BC         		BNE	_FSGN3
2313
 4673  F83CCE  88            		dey
2314
 4674  F83CCF  88            		dey
2315
 4675  F83CD0  B7 60         		lda	[PTR1],y
2316
 4676  F83CD2  C5 46         		CMP	FAC+5
2317
 4677  F83CD4  D0 B4         		BNE	_FSGN3
2318
 4678  F83CD6  88            		dey
2319
 4679  F83CD7  88            		dey
2320
 4680  F83CD8  B7 60         		lda	[PTR1],y
2321
 4681  F83CDA  C5 44         		CMP	FAC+3
2322
 4682  F83CDC  D0 AC         		BNE	_FSGN3
2323
 4683  F83CDE  88            		dey
2324
 4684  F83CDF                		CPU08
2325
 4685  F83CDF  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
2326
 4686                        		.LONGA	off
2327
 4687                        		.LONGI	off
2328
 4688                        		.MNLIST
2329
 4689  F83CE1  B7 60         		lda	[PTR1],y
2330
 4690  F83CE3  C5 43         		CMP	FAC+2
2331
 4691  F83CE5  D0 A3         		BNE	_FSGN3
2332
 4692  F83CE7  88            		dey
2333
 4693  F83CE8  A9 7F         		LDA	#$7F		; bit di guardia
2334
 4694  F83CEA  C5 41         		CMP	FACEXT		; CF settato
2335
 4695  F83CEC  B7 60         		lda	[PTR1],y
2336
 4696  F83CEE  E5 42         		SBC	FAC+1
2337
 4697  F83CF0  D0 98         		BNE	_FSGN3
2338
 4698  F83CF2  60            		RTS			; FAC = Float MEM
2339
 4699
2340
 4700                        	; _feCHS: cambia segno a FAC
2341
 4701                        	; In:	FAC supposto valido
2342
 4702                        	; Out:	FAC = -FAC
2343
 4703                        	; Uso:	A
2344
 4704                        	; Note: INF e NAN assunti come validi
2345
 4705  F83CF3                	_feCHS:
2346
 4706  F83CF3  20 FF 3B      		jsr	_feXAM
2347
 4707  F83CF6  F0 06         		BEQ	?01
2348
 4708  F83CF8  A5 40         		LDA	FACSGN
2349
 4709  F83CFA  49 FF         		EOR	#$FF
2350
 4710  F83CFC  85 40         		STA	FACSGN
2351
 4711  F83CFE  60            	?01:	RTS
2352
 4712
2353
 4713                        	; _feABS: rende assoluto FAC
2354
 4714                        	; In:	FAC supposto valido
2355
 4715                        	; Out:	FAC = |FAC|
2356
 4716                        	; Uso:
2357
  Tue Jul 17 11:00:16 2018                                                                                               Page   39
2358
 
2359
 
2360
 
2361
 
2362
 4717                        	; Note: Nessuna eccezione se FAC non valido
2363
 4718  F83CFF                	_feABS:
2364
 4719  F83CFF  64 40         		STZ	FACSGN
2365
 4720  F83D01  60            		RTS
2366
 4721
2367
 4722                        	;----------------------------------------------------------
2368
 4723                        	; Funzioni move memoria/fac/arg
2369
 4724                        	;----------------------------------------------------------
2370
 4725
2371
 4726                        	; _MovRF2Tmp: Arrotonda FAC e lo copia nel reg. temporaneo
2372
 4727                        	; In:	FAC valido
2373
 4728                        	; Out:	FAC arrotondato copiato nel reg. temporaneo
2374
 4729                        	; Note: FACEXT azzerato
2375
 4730  F83D02                	_MovRF2Tmp:
2376
 4731  F83D02  20 43 38      		JSR	_Round
2377
 4732  F83D05  64 41         		STZ	FACEXT
2378
 4733  F83D07  A2 0B         		LDX	#(FACSIZE+1)	; 12 bytes
2379
 4734  F83D09  B5 40         	?01:	lda	<FACSGN,x
2380
 4735  F83D0B  95 64         		sta	<FACTmp,x
2381
 4736  F83D0D  CA            		dex
2382
 4737  F83D0E  10 F9         		bpl	?01
2383
 4738  F83D10  60            		rts
2384
 4739
2385
 4740                        	; _MovTmp2A: Carica ARG da registro FAC temporaneo
2386
 4741                        	; In:	FACTmp valido
2387
 4742                        	; Out:	ARG caricato da memoria
2388
 4743                        	; Uso:	A, X
2389
 4744                        	; Note:	ARGSGN settato, ARGEXT azzerato
2390
 4745  F83D11                	_MovTmp2A:
2391
 4746  F83D11  A2 0B         		LDX	#(FACSIZE+1)
2392
 4747  F83D13  B5 64         	?01:	lda	<FACTmp,x
2393
 4748  F83D15  95 50         		sta	<ARGSGN,x
2394
 4749  F83D17  CA            		dex
2395
 4750  F83D18  10 F9         		bpl	?01
2396
 4751  F83D1A  64 51         		STZ	ARGEXT
2397
 4752  F83D1C  60            		rts
2398
 4753  F83D1D
2399
 4754                        	; _MovF2Mem: Copia FAC in memoria
2400
 4755                        	; In:	CY -> ptr memoria
2401
 4756                        	; Out:	FAC copiato in memoria
2402
 4757                        	; Uso:	C,Y,PTR1
2403
 4758                        	; Note: FACEXT azzerato
2404
 4759  F83D1D                	_MovF2Mem:
2405
 4760  F83D1D  85 60         		STA	PTR1
2406
 4761  F83D1F  EB            		xba
2407
 4762  F83D20  85 61         		STA	PTR1+1
2408
 4763  F83D22  84 62         		STY	PTR1+2
2409
 4764  F83D24  80 0A         		BRA	_FSTMEM
2410
 4765
2411
 4766                        	; _MovRF2Mem: Arrotonda FAC e lo copia in memoria
2412
 4767                        	; In:	CY -> ptr memoria
2413
 4768                        	; Out:	FAC arrotondato copiato in memoria
2414
 4769                        	; Uso:	C,Y,PTR1
2415
 4770                        	; Note: FACEXT azzerato
2416
 4771                        	;	Carica anche INF / NAN
2417
 4772  F83D26                	_MovRF2Mem:
2418
 4773  F83D26  85 60         		STA	PTR1
2419
  Tue Jul 17 11:00:16 2018                                                                                               Page   40
2420
 
2421
 
2422
 
2423
 
2424
 4774  F83D28  EB            		xba
2425
 4775  F83D29  85 61         		STA	PTR1+1
2426
 4776  F83D2B  84 62         		STY	PTR1+2
2427
 4777  F83D2D  20 43 38      		JSR	_Round
2428
 4778  F83D30                	_FSTMEM:
2429
 4779  F83D30  A0 00         		LDY	#0
2430
 4780  F83D32                		ACC16
2431
 4781  F83D32  C2 20         		rep	#PMFLAG
2432
 4782                        		.LONGA	on
2433
 4783                        		.MNLIST
2434
 4784  F83D34  A5 42         		LDA	FAC+1
2435
 4785  F83D36  97 60         		STA	[PTR1],Y
2436
 4786  F83D38  C8            		iny
2437
 4787  F83D39  C8            		iny
2438
 4788  F83D3A  A5 44         		LDA	FAC+3
2439
 4789  F83D3C  97 60         		STA	[PTR1],Y
2440
 4790  F83D3E  C8            		iny
2441
 4791  F83D3F  C8            		iny
2442
 4792  F83D40  A5 46         		LDA	FAC+5
2443
 4793  F83D42  97 60         		STA	[PTR1],Y
2444
 4794  F83D44  C8            		iny
2445
 4795  F83D45  C8            		iny
2446
 4796  F83D46  A5 48         		LDA	FAC+7
2447
 4797  F83D48  97 60         		STA	[PTR1],Y
2448
 4798  F83D4A  C8            		iny
2449
 4799  F83D4B  C8            		iny
2450
 4800  F83D4C                		ACC08
2451
 4801  F83D4C  E2 20         		sep	#PMFLAG
2452
 4802                        		.LONGA	off
2453
 4803                        		.MNLIST
2454
 4804  F83D4E  A5 40         		LDA	FACSGN
2455
 4805  F83D50  29 80         		AND	#$80
2456
 4806  F83D52  EB            		xba
2457
 4807  F83D53  A9 00         		lda	#0
2458
 4808  F83D55                		ACC16
2459
 4809  F83D55  C2 20         		rep	#PMFLAG
2460
 4810                        		.LONGA	on
2461
 4811                        		.MNLIST
2462
 4812  F83D57  05 4A         		ora	FACExp
2463
 4813  F83D59  97 60         		STA	[PTR1],Y
2464
 4814  F83D5B                		ACC08
2465
 4815  F83D5B  E2 20         		sep	#PMFLAG
2466
 4816                        		.LONGA	off
2467
 4817                        		.MNLIST
2468
 4818  F83D5D  A0 00         		ldy	#0
2469
 4819  F83D5F  84 41         		STY	FACEXT
2470
 4820  F83D61  60            		RTS
2471
 4821
2472
 4822                        	; _MovMem2F: Carica FAC da memoria
2473
 4823                        	; In:	CY -> ptr memoria
2474
 4824                        	; Out:	FAC caricato da memoria
2475
 4825                        	; Uso:	C,Y,PTR1
2476
 4826                        	; Note:	FACSGN settato, FACEXT azzerato
2477
 4827  F83D62                	_MovMem2F:
2478
 4828  F83D62  85 60         		STA	PTR1
2479
 4829  F83D64  EB            		xba
2480
 4830  F83D65  85 61         		sta	PTR1+1
2481
  Tue Jul 17 11:00:16 2018                                                                                               Page   41
2482
 
2483
 
2484
 
2485
 
2486
 4831  F83D67  84 62         		STY	PTR1+2
2487
 4832  F83D69                	_MovMem2Fa:
2488
 4833  F83D69  A0 00         		LDY	#0
2489
 4834  F83D6B                		ACC16
2490
 4835  F83D6B  C2 20         		rep	#PMFLAG
2491
 4836                        		.LONGA	on
2492
 4837                        		.MNLIST
2493
 4838  F83D6D  B7 60         		LDA	[PTR1],Y
2494
 4839  F83D6F  85 42         		STA	FAC+1
2495
 4840  F83D71  C8            		iny
2496
 4841  F83D72  C8            		iny
2497
 4842  F83D73  B7 60         		LDA	[PTR1],Y
2498
 4843  F83D75  85 44         		STA	FAC+3
2499
 4844  F83D77  C8            		iny
2500
 4845  F83D78  C8            		iny
2501
 4846  F83D79  B7 60         		LDA	[PTR1],Y
2502
 4847  F83D7B  85 46         		STA	FAC+5
2503
 4848  F83D7D  C8            		iny
2504
 4849  F83D7E  C8            		iny
2505
 4850  F83D7F  B7 60         		LDA	[PTR1],Y
2506
 4851  F83D81  85 48         		STA	FAC+7
2507
 4852  F83D83  C8            		iny
2508
 4853  F83D84  C8            		iny
2509
 4854  F83D85  B7 60         		LDA	[PTR1],Y
2510
 4855  F83D87  EB            		xba
2511
 4856  F83D88  A8            		tay			; Y = segno
2512
 4857  F83D89  EB            		xba
2513
 4858  F83D8A  29 FF 7F      		and	#$7FFF
2514
 4859  F83D8D  85 4A         		sta	FACExp
2515
 4860  F83D8F  84 40         		STY	FACSGN
2516
 4861  F83D91                		ACC08
2517
 4862  F83D91  E2 20         		sep	#PMFLAG
2518
 4863                        		.LONGA	off
2519
 4864                        		.MNLIST
2520
 4865  F83D93  A0 00         		ldy	#0
2521
 4866  F83D95  84 41         		STY	FACEXT
2522
 4867  F83D97  60            		RTS
2523
 4868
2524
 4869                        	; _MovMem2A: Carica ARG da memoria
2525
 4870                        	; In:	CY -> ptr memoria
2526
 4871                        	; Out:	ARG caricato da memoria
2527
 4872                        	; Uso:	C,Y,PTR1
2528
 4873                        	; Note:	ARGSGN settato, ARGEXT azzerato
2529
 4874  F83D98                	_MovMem2A:
2530
 4875  F83D98  85 60         		STA	PTR1
2531
 4876  F83D9A  EB            		xba
2532
 4877  F83D9B  85 61         		sta	PTR1+1
2533
 4878  F83D9D  84 62         		STY	PTR1+2
2534
 4879  F83D9F  A0 00         		LDY	#0
2535
 4880  F83DA1                		ACC16
2536
 4881  F83DA1  C2 20         		rep	#PMFLAG
2537
 4882                        		.LONGA	on
2538
 4883                        		.MNLIST
2539
 4884  F83DA3  B7 60         		LDA	[PTR1],Y
2540
 4885  F83DA5  85 52         		STA	ARG+1
2541
 4886  F83DA7  C8            		iny
2542
 4887  F83DA8  C8            		iny
2543
  Tue Jul 17 11:00:16 2018                                                                                               Page   42
2544
 
2545
 
2546
 
2547
 
2548
 4888  F83DA9  B7 60         		LDA	[PTR1],Y
2549
 4889  F83DAB  85 54         		STA	ARG+3
2550
 4890  F83DAD  C8            		iny
2551
 4891  F83DAE  C8            		iny
2552
 4892  F83DAF  B7 60         		LDA	[PTR1],Y
2553
 4893  F83DB1  85 56         		STA	ARG+5
2554
 4894  F83DB3  C8            		iny
2555
 4895  F83DB4  C8            		iny
2556
 4896  F83DB5  B7 60         		LDA	[PTR1],Y
2557
 4897  F83DB7  85 58         		STA	ARG+7
2558
 4898  F83DB9  C8            		iny
2559
 4899  F83DBA  C8            		iny
2560
 4900  F83DBB  B7 60         		LDA	[PTR1],Y
2561
 4901  F83DBD  EB            		xba
2562
 4902  F83DBE  A8            		tay			; Y = segno
2563
 4903  F83DBF  EB            		xba
2564
 4904  F83DC0  29 FF 7F      		and	#$7FFF
2565
 4905  F83DC3  85 5A         		sta	ARGExp
2566
 4906  F83DC5  84 50         		STY	ARGSGN
2567
 4907  F83DC7                		ACC08
2568
 4908  F83DC7  E2 20         		sep	#PMFLAG
2569
 4909                        		.LONGA	off
2570
 4910                        		.MNLIST
2571
 4911  F83DC9  A0 00         		ldy	#0
2572
 4912  F83DCB  84 51         		STY	ARGEXT
2573
 4913  F83DCD  60            		RTS
2574
 4914
2575
 4915                        	; _MovA2F:  Copia ARG in FAC
2576
 4916                        	; In:	ARG
2577
 4917                        	; Out:	ARG -> FAC
2578
 4918                        	; Uso:	A,X
2579
 4919                        	; Note:	FACSGN settato, FACEXT azzerato
2580
 4920  F83DCE                	_MovA2F:
2581
 4921  F83DCE  A5 50         		LDA	ARGSGN
2582
 4922  F83DD0
2583
 4923                        	; Copia ARG in FAC e setta il segno in A
2584
 4924  F83DD0                	_MovA2FS:
2585
 4925  F83DD0  85 40         		STA	FACSGN
2586
 4926  F83DD2  A2 0A         		LDX	#FACSIZE
2587
 4927  F83DD4  B5 51         	?01:	LDA	<ARG,X
2588
 4928  F83DD6  95 41         		STA	<FAC,X
2589
 4929  F83DD8  CA            		DEX
2590
 4930  F83DD9  D0 F9         		BNE	?01
2591
 4931  F83DDB  86 41         		STX	FACEXT
2592
 4932  F83DDD  60            		RTS
2593
 4933
2594
 4934                        	; _MovRndF2A: Arrotonda FAC e lo copia in ARG
2595
 4935                        	; In:	FAC
2596
 4936                        	; Out:	FAC arrotondato -> ARG
2597
 4937                        	; Uso:	A,X,Y
2598
 4938                        	; Note:	ARGSGN settato, FACEXT e ARGEXT azzerati
2599
 4939                        	;	PUO' GENERARE ECCEZIONI
2600
 4940  F83DDE                	_MovRndF2A:
2601
 4941  F83DDE  20 43 38      		JSR	_Round		; arrotonda FAC: può causare eccezioni
2602
 4942
2603
 4943                        	; _MovF2A: Copia FAC in ARG
2604
 4944                        	; In:	FAC
2605
  Tue Jul 17 11:00:16 2018                                                                                               Page   43
2606
 
2607
 
2608
 
2609
 
2610
 4945                        	; Out:	FAC -> ARG
2611
 4946                        	; Uso:	A,X,Y
2612
 4947                        	; Note:	ARGSGN settato, FACEXT e ARGEXT azzerati
2613
 4948  F83DE1                	_MovF2A:
2614
 4949  F83DE1  A5 40         		LDA	FACSGN
2615
 4950  F83DE3  85 50         		STA	ARGSGN
2616
 4951  F83DE5  A2 0A         		LDX	#FACSIZE
2617
 4952  F83DE7  B5 41         	?01:	LDA	<FAC,X
2618
 4953  F83DE9  95 51         		STA	<ARG,X
2619
 4954  F83DEB  CA            		DEX
2620
 4955  F83DEC  D0 F9         		BNE	?01
2621
 4956  F83DEE  86 41         		STX	FACEXT
2622
 4957  F83DF0  86 51         		STX	ARGEXT
2623
 4958  F83DF2  18            	_RTS6c:	clc
2624
 4959  F83DF3  60            	_RTS6:	RTS
2625
 4960
2626
 4961                        	;-------------------------------------------------------------
2627
 4962                        	; Calcola potenza di 10: FAC = FAC*(10^C)
2628
 4963                        	;-------------------------------------------------------------
2629
 4964
2630
 4965                        	; In	- C -> potenza di 10 (signed)
2631
 4966                        	;	- FAC valido
2632
 4967                        	;
2633
 4968                        	; Out	- FAC * (10 ^ FPExp)
2634
 4969                        	; USO: FPWTmp7, FPWTmp8, FPExp
2635
 4970  F83DF4                	_fePOW10:
2636
 4971  F83DF4                		ACC16
2637
 4972  F83DF4  C2 20         		rep	#PMFLAG
2638
 4973                        		.LONGA	on
2639
 4974                        		.MNLIST
2640
 4975  F83DF6  85 5E         		sta	FPExp
2641
 4976  F83DF8  A2 00         		ldx	#0
2642
 4977  F83DFA  24 5E         		bit	FPExp
2643
 4978  F83DFC  10 07         		bpl	?00		; C positivo
2644
 4979  F83DFE  8A            		txa			; C = 0
2645
 4980  F83DFF  CA            		dex			; C negativo
2646
 4981  F83E00  38            		sec
2647
 4982  F83E01  E5 5E         		sbc	FPExp		; complementa
2648
 4983  F83E03  85 5E         		sta	FPExp
2649
 4984  F83E05  86 3E         	?00:	stx	FPWTmp8		; flag segno C
2650
 4985  F83E07  C9 00 10      		cmp	#4096		; limite max
2651
 4986  F83E0A                		ACC08
2652
 4987  F83E0A  E2 20         		sep	#PMFLAG
2653
 4988                        		.LONGA	off
2654
 4989                        		.MNLIST
2655
 4990  F83E0C  90 28         		bcc	?04		; M < 4096
2656
 4991                        		; M = 4096
2657
 4992  F83E0E  A9 45         	?01:	LDA	#.HIGH.FCon1E4096
2658
 4993  F83E10  EB            		xba
2659
 4994  F83E11  A9 52         		LDA	#.LOW.FCon1E4096
2660
 4995  F83E13  A0 F8         		LDY	#.SEG.FCon1E4096
2661
 4996  F83E15  24 3E         		bit	FPWTmp8
2662
 4997  F83E17  30 07         		bmi	?02		; div
2663
 4998  F83E19  20 E9 38      		JSR	_feMULM		; FAC = FAC*10^4096
2664
 4999  F83E1C  B0 D5         		BCS	_RTS6		; eccezione -> esce
2665
 5000  F83E1E  90 05         		BCC	?03
2666
 5001  F83E20  20 20 3A      	?02:	JSR	_feDIVRM	; FAC = FAC/10^4096
2667
  Tue Jul 17 11:00:16 2018                                                                                               Page   44
2668
 
2669
 
2670
 
2671
 
2672
 5002  F83E23  B0 CE         		BCS	_RTS6		; eccezione -> esce
2673
 5003  F83E25  20 43 38      	?03:	jsr	_Round		; ****
2674
 5004  F83E28  B0 C9         		bcs	_RTS6		; ****
2675
 5005  F83E2A                		ACC16
2676
 5006  F83E2A  C2 20         		rep	#PMFLAG
2677
 5007                        		.LONGA	on
2678
 5008                        		.MNLIST
2679
 5009  F83E2C  38            		SEC			; M = M - 4096
2680
 5010  F83E2D  A5 5E         		lda	FPExp
2681
 5011  F83E2F  E9 00 10      		sbc	#4096
2682
 5012  F83E32  85 5E         		sta	FPExp
2683
 5013  F83E34                		ACC08
2684
 5014  F83E34  E2 20         		sep	#PMFLAG
2685
 5015                        		.LONGA	off
2686
 5016                        		.MNLIST
2687
 5017  F83E36  A5 5E         	?04:	LDA	FPExp		; ora M < 4096
2688
 5018  F83E38  05 5F         		ORA	FPExp+1
2689
 5019  F83E3A  F0 B6         		BEQ	_RTS6c		; se M = 0 esce con C = 0
2690
 5020  F83E3C  20 02 3D      		jsr	_MovRF2Tmp	; round FAC -> registro temporaneo
2691
 5021  F83E3F  B0 B2         	?04a:	BCS	_RTS6		; eccezione -> esce
2692
 5022  F83E41  A5 5E         		LDA	FPExp
2693
 5023  F83E43  29 07         		AND	#7		; calcola offset costanti 1e0 - 1e7
2694
 5024  F83E45  85 3F         		STA	FPWTmp8+1
2695
 5025  F83E47  0A            		ASL	A		; moltiplica x 10
2696
 5026  F83E48  0A            		ASL	A
2697
 5027  F83E49  18            		CLC
2698
 5028  F83E4A  65 3F         		ADC	FPWTmp8+1
2699
 5029  F83E4C  0A            		ASL	A
2700
 5030  F83E4D  18            		CLC
2701
 5031  F83E4E  69 A8         		ADC	#.LOW.FCon1E0
2702
 5032  F83E50  EB            		xba
2703
 5033  F83E51  A9 44         		LDA	#.HIGH.FCon1E0
2704
 5034  F83E53  90 01         		BCC	?05
2705
 5035  F83E55  1A            		INC	A
2706
 5036  F83E56  EB            	?05:	xba
2707
 5037  F83E57  A0 F8         		LDY	#.SEG.FCon1E0
2708
 5038  F83E59  20 62 3D      		JSR	_MovMem2F	; FAC = 1e0..1e7
2709
 5039  F83E5C                		ACC16
2710
 5040  F83E5C  C2 20         		rep	#PMFLAG
2711
 5041                        		.LONGA	on
2712
 5042                        		.MNLIST
2713
 5043  F83E5E  A5 5E         		lda	FPExp		; divide FPExp x 8
2714
 5044  F83E60  4A            		LSR	A
2715
 5045  F83E61  4A            		LSR	A
2716
 5046  F83E62  4A            		LSR	A
2717
 5047  F83E63  85 5E         		STA	FPExp
2718
 5048  F83E65  A9 F8 44      		LDA	#FCon1E8
2719
 5049  F83E68  85 3C         		STA	FPWTmp7		; indirizzo 1E8
2720
 5050  F83E6A                		ACC08
2721
 5051  F83E6A  E2 20         		sep	#PMFLAG
2722
 5052                        		.LONGA	off
2723
 5053                        		.MNLIST
2724
 5054  F83E6C  80 22         		BRA	?11
2725
 5055  F83E6E  46 5F         	?08:	LSR	FPExp+1		; divide x 2
2726
 5056  F83E70  66 5E         		ROR	FPExp
2727
 5057  F83E72  90 11         		BCC	?10
2728
 5058  F83E74  A5 3D         		LDA	FPWTmp7+1	; FAC = FAC * (1E8..1E4096)
2729
  Tue Jul 17 11:00:16 2018                                                                                               Page   45
2730
 
2731
 
2732
 
2733
 
2734
 5059  F83E76  EB            		xba
2735
 5060  F83E77  A5 3C         		LDA	FPWTmp7
2736
 5061  F83E79  A0 F8         		LDY	#.SEG.FCon1E0
2737
 5062  F83E7B  20 E9 38      		JSR	_feMULM
2738
 5063  F83E7E  B0 BF         		BCS	?04a		; eccezione -> esce
2739
 5064  F83E80
2740
 5065  F83E80  20 43 38      		jsr	_Round		; ****
2741
 5066  F83E83  B0 BA         		BCS	?04a		; ****
2742
 5067  F83E85
2743
 5068  F83E85  18            	?10:	CLC
2744
 5069  F83E86  A5 3C         		LDA	FPWTmp7
2745
 5070  F83E88  69 0A         		ADC	#10
2746
 5071  F83E8A  85 3C         		STA	FPWTmp7
2747
 5072  F83E8C  90 02         		BCC	?11
2748
 5073  F83E8E  E6 3D         		INC	FPWTmp7+1
2749
 5074  F83E90  A5 5E         	?11:	LDA	FPExp
2750
 5075  F83E92  05 5F         		ORA	FPExp+1
2751
 5076  F83E94  D0 D8         		BNE	?08
2752
 5077  F83E96  20 11 3D      		jsr	_MovTmp2A	; FAC temporaneo -> ARG
2753
 5078  F83E99  24 3E         		bit	FPWTmp8		; segno
2754
 5079  F83E9B  30 05         		bmi	?12
2755
 5080  F83E9D  20 EC 38      		jsr	_feMUL
2756
 5081  F83EA0  80 03         		bra	?14
2757
 5082  F83EA2  20 30 3A      	?12:	jsr	_feDIV
2758
 5083  F83EA5  4C 43 38      	?14:	jmp	_Round
2759
 5084
2760
 5085                        	;-------------------------------------------------------------
2761
 5086                        	; Scala FAC in modo che sia 1E18 <= FAC <= MAX UINT
2762
 5087                        	;-------------------------------------------------------------
2763
 5088
2764
 5089                        	; _feSCALE10 - scala FAC e calcola esponente decimale
2765
 5090                        	; In	- FAC positivo
2766
 5091                        	; Out	- 1E18  <= FAC <= MAX UINT
2767
 5092                        	;	  XVDec -> esponente decimale (signed)
2768
 5093                        	;	  Se FAC >= 1E19 XVDec va incrementato
2769
 5094                        	; NOTA - ARG, ACM, IARG distrutti
2770
 5095  F83EA8                	_feSCALE10:
2771
 5096                        		; si determina una stima per difetto dell'esponente decimale.
2772
 5097                        		; Per il calcolo approssimato si esegue la moltiplicazione (signed)
2773
 5098                        		; di [LOG10(2) * $10000] per esponente di FAC
2774
 5099  F83EA8                		ACC16
2775
 5100  F83EA8  C2 20         		rep	#PMFLAG
2776
 5101                        		.LONGA	on
2777
 5102                        		.MNLIST
2778
 5103  F83EAA  38            		sec			; depolarizzazione esponente
2779
 5104  F83EAB  A5 4A         		lda	FACExp
2780
 5105  F83EAD  E9 FF 3F      		sbc	#EXPBIAS
2781
 5106  F83EB0  85 18         		sta	ACM		; ACM, ACM+1 -> esponente
2782
 5107  F83EB2  A9 10 4D      		lda	#LOG2H		; LOG10(2) * $10000
2783
 5108  F83EB5  85 28         		sta	IARG
2784
 5109  F83EB7                		ACC08
2785
 5110  F83EB7  E2 20         		sep	#PMFLAG
2786
 5111                        		.LONGA	off
2787
 5112                        		.MNLIST
2788
 5113  F83EB9  20 A4 2A      		jsr	_iSMult16	; signed mult 16 x 16
2789
 5114  F83EBC
2790
 5115                        		; la stima dell'esponente si trova nei 16 bit alti del risultato
2791
  Tue Jul 17 11:00:16 2018                                                                                               Page   46
2792
 
2793
 
2794
 
2795
 
2796
 5116  F83EBC                		ACC16
2797
 5117  F83EBC  C2 20         		rep	#PMFLAG
2798
 5118                        		.LONGA	on
2799
 5119                        		.MNLIST
2800
 5120  F83EBE  A5 1A         		lda	ACM+2
2801
 5121  F83EC0  85 14         		sta	XVDec
2802
 5122  F83EC2
2803
 5123                        		; si calcola ora lo scalamento di FAC per fare in modo che sia
2804
 5124                        		; compreso tra 1E18 ed 1E19
2805
 5125  F83EC2  38            		sec
2806
 5126  F83EC3  A9 12 00      		lda	#MAXDIGITS-1
2807
 5127  F83EC6  E5 14         		sbc	XVDec
2808
 5128  F83EC8
2809
 5129                        		; C = potenza di 10 per scalare FAC
2810
 5130  F83EC8                		ACC08
2811
 5131  F83EC8  E2 20         		sep	#PMFLAG
2812
 5132                        		.LONGA	off
2813
 5133                        		.MNLIST
2814
 5134  F83ECA  20 F4 3D      		jsr	_fePOW10	; scala FAC e arrotonda
2815
 5135  F83ECD  A9 44         		lda	#.HIGH.FCon1E19
2816
 5136  F83ECF  EB            		xba
2817
 5137  F83ED0  A9 9E         		lda	#.LOW.FCon1E19	; confronta FAC con 1E19
2818
 5138  F83ED2  A0 F8         		ldy	#.SEG.FCon1E19
2819
 5139  F83ED4  20 94 3C      		jsr	_feCMPM
2820
 5140  F83ED7  30 18         		bmi	?40		; FAC < 1E19 => test FAC >= 1E18
2821
 5141  F83ED9                		ACC16
2822
 5142  F83ED9  C2 20         		rep	#PMFLAG
2823
 5143                        		.LONGA	on
2824
 5144                        		.MNLIST
2825
 5145  F83EDB  A5 4A         		lda	FACExp		; situazione in cui ci sono
2826
 5146  F83EDD  C9 3E 40      		cmp	#BIASQWORD	; 20 cifre significative
2827
 5147  F83EE0                		ACC08
2828
 5148  F83EE0  E2 20         		sep	#PMFLAG
2829
 5149                        		.LONGA	off
2830
 5150                        		.MNLIST
2831
 5151  F83EE2  F0 27         		beq	?50		; 1E19 <= FAC <= MAX UINT (20 digit)
2832
 5152  F83EE4  20 19 3A      		jsr	_feDIV10	; FAC > MAX UINT => FAC = FAC/10
2833
 5153  F83EE7  20 43 38      		jsr	_Round
2834
 5154  F83EEA                		ACC16
2835
 5155  F83EEA  C2 20         		rep	#PMFLAG
2836
 5156                        		.LONGA	on
2837
 5157                        		.MNLIST
2838
 5158  F83EEC  E6 14         		inc	XVDec		; incrementa esp. decimale
2839
 5159  F83EEE                		ACC08
2840
 5160  F83EEE  E2 20         		sep	#PMFLAG
2841
 5161                        		.LONGA	off
2842
 5162                        		.MNLIST
2843
 5163  F83EF0  60            		rts
2844
 5164  F83EF1  A9 44         	?40:	lda	#.HIGH.FCon1E18
2845
 5165  F83EF3  EB            		xba
2846
 5166  F83EF4  A9 94         		lda	#.LOW.FCon1E18	; confronta FAC con 1E18
2847
 5167  F83EF6  A0 F8         		ldy	#.SEG.FCon1E18
2848
 5168  F83EF8  20 94 3C      		jsr	_feCMPM
2849
 5169  F83EFB  10 0E         		bpl	?50		; FAC > 1E18
2850
 5170  F83EFD  F0 0C         		beq	?50		; FAC = 1E18
2851
 5171  F83EFF  20 E4 39      		jsr	_feMUL10	; FAC = FAC * 10
2852
 5172  F83F02  20 43 38      		jsr	_Round
2853
  Tue Jul 17 11:00:16 2018                                                                                               Page   47
2854
 
2855
 
2856
 
2857
 
2858
 5173  F83F05                		ACC16
2859
 5174  F83F05  C2 20         		rep	#PMFLAG
2860
 5175                        		.LONGA	on
2861
 5176                        		.MNLIST
2862
 5177  F83F07  C6 14         		dec	XVDec		; decrementa esp. decimale
2863
 5178  F83F09                		ACC08
2864
 5179  F83F09  E2 20         		sep	#PMFLAG
2865
 5180                        		.LONGA	off
2866
 5181                        		.MNLIST
2867
 5182  F83F0B  60            	?50:	rts
2868
 5183  F83F0C
2869
 5184                        	;-------------------------------------------------------------
2870
 5185                        	; CONVERSIONE DA FLOAT POINT NUMBER A INTEGER 64 BIT
2871
 5186                        	;-------------------------------------------------------------
2872
 5187
2873
 5188                        	; Converte FAC in UNSIGNED INTEGER 64 bit
2874
 5189                        	; In:	FAC
2875
 5190                        	; Out:	INTEGER con MSB in IARG+7, LSB in IARG
2876
 5191                        	;	Y = 0
2877
 5192                        	;	CF = 1 in caso di errore (overflow)
2878
 5193                        	; Uso:	A,X,Y - FAC distrutto
2879
 5194                        	; Note:	La conversione avviene mediante shift a destra fino
2880
 5195                        	;	a quando la parte frazionaria e' fuori mantissa
2881
 5196                        	;	L'esponente deve essere compreso tra $00 e $3F
2882
 5197  F83F0C                	_feFAC2I:
2883
 5198  F83F0C                		ACC16
2884
 5199  F83F0C  C2 20         		rep	#PMFLAG
2885
 5200                        		.LONGA	on
2886
 5201                        		.MNLIST
2887
 5202  F83F0E  64 28         		STZ	IARG		; azzera risultato
2888
 5203  F83F10  64 2A         		STZ	IARG+2
2889
 5204  F83F12  64 2C         		STZ	IARG+4
2890
 5205  F83F14  64 2E         		STZ	IARG+6
2891
 5206  F83F16  A5 4A         		lda	FACExp
2892
 5207  F83F18  F0 38         		beq	?10		; result = 0 -- OK (CF = 0)
2893
 5208  F83F1A  C9 FF 3F      		cmp	#EXPBIAS	; EXP < 0 => result = 0 (CF = 0)
2894
 5209  F83F1D  90 33         		bcc	?10
2895
 5210  F83F1F  C9 3F 40      		cmp	#BIASQWORD+1
2896
 5211  F83F22  B0 32         		bcs	?20		; EXP > $3F => overflow (CF = 1)
2897
 5212  F83F24  38            		SEC			; depolarizza esponente
2898
 5213  F83F25  E9 FF 3F      		SBC	#EXPBIAS
2899
 5214  F83F28                		ACC08			; B = 0, A = 00..3F
2900
 5215  F83F28  E2 20         		sep	#PMFLAG
2901
 5216                        		.LONGA	off
2902
 5217                        		.MNLIST
2903
 5218  F83F2A  E9 40         		SBC	#FACMBITS	; A = numero shift a destra (negativo)
2904
 5219  F83F2C  1A            		inc	a
2905
 5220  F83F2D  F0 11         		beq	?05		; no shift -- copia FAC in IARG
2906
 5221  F83F2F  A2 41         		LDX	#FAC		; puntatore FAC
2907
 5222  F83F31  C9 F9         		CMP	#$F9		; numero di shift a destra
2908
 5223  F83F33  10 05         		BPL	?02		; shift bit x bit
2909
 5224                        		; qui CF = 0
2910
 5225  F83F35  20 C8 38      		JSR	_RShiftXB	; shift byte x byte
2911
 5226  F83F38  80 06         		BRA	?05
2912
 5227  F83F3A  A8            	?02:	TAY
2913
 5228  F83F3B  F0 03         		BEQ	?05		; nessuno shift da effettuare
2914
 5229  F83F3D  20 D5 38      		JSR	_RShiftXN
2915
  Tue Jul 17 11:00:16 2018                                                                                               Page   48
2916
 
2917
 
2918
 
2919
 
2920
 5230  F83F40                	?05:	ACC16
2921
 5231  F83F40  C2 20         		rep	#PMFLAG
2922
 5232                        		.LONGA	on
2923
 5233                        		.MNLIST
2924
 5234  F83F42  A5 42         		lda	FACM
2925
 5235  F83F44  85 28         		sta	IARG
2926
 5236  F83F46  A5 44         		lda	FACM+2
2927
 5237  F83F48  85 2A         		sta	IARG+2
2928
 5238  F83F4A  A5 46         		lda	FACM+4
2929
 5239  F83F4C  85 2C         		sta	IARG+4
2930
 5240  F83F4E  A5 48         		lda	FACM+6
2931
 5241  F83F50  85 2E         		sta	IARG+6
2932
 5242  F83F52                	?10:	ACC08
2933
 5243  F83F52  E2 20         		sep	#PMFLAG
2934
 5244                        		.LONGA	off
2935
 5245                        		.MNLIST
2936
 5246  F83F54  18            		CLC
2937
 5247  F83F55  60            		RTS
2938
 5248  F83F56                	?20:	ACC08
2939
 5249  F83F56  E2 20         		sep	#PMFLAG
2940
 5250                        		.LONGA	off
2941
 5251                        		.MNLIST
2942
 5252  F83F58  38            		SEC
2943
 5253  F83F59  60            		RTS
2944
 5254
2945
 5255                        	;-------------------------------------------------------------
2946
 5256                        	; CONVERSIONE DA STRINGA A FLOATING POINT NUMBER
2947
 5257                        	;-------------------------------------------------------------
2948
 5258
2949
 5259  F83F5A                	_Str2Fl:
2950
 5260  F83F5A                		CPU08
2951
 5261  F83F5A  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
2952
 5262                        		.LONGA	off
2953
 5263                        		.LONGI	off
2954
 5264                        		.MNLIST
2955
 5265  F83F5C  C2 C3         		rep	#(PNFLAG.OR.PVFLAG.OR.PCFLAG.OR.PZFLAG)
2956
 5266  F83F5E  08            		php
2957
 5267  F83F5F  8B            		phb			; salva DBR
2958
 5268  F83F60  0B            		phd			; salva DPR
2959
 5269  F83F61  F4 00 02      		pea	#DP02ADDR	; imposta DPR a pag 2
2960
 5270  F83F64  2B            		pld
2961
 5271  F83F65  A0 00         		ldy	#0
2962
 5272  F83F67  5A            		phy
2963
 5273  F83F68  AB            		plb			; imposta DBR su banco 0
2964
 5274  F83F69
2965
 5275                        		; relativo stack: 01 -> DPR, 03 -> DBR, 04 -> P
2966
 5276
2967
 5277  F83F69                		ACC16
2968
 5278  F83F69  C2 20         		rep	#PMFLAG
2969
 5279                        		.LONGA	on
2970
 5280                        		.MNLIST
2971
 5281  F83F6B  85 60         		sta	PTR1		; long ptr stringa
2972
 5282  F83F6D  64 5E         		stz	FPExp
2973
 5283  F83F6F                		ACC08
2974
 5284  F83F6F  E2 20         		sep	#PMFLAG
2975
 5285                        		.LONGA	off
2976
 5286                        		.MNLIST
2977
  Tue Jul 17 11:00:16 2018                                                                                               Page   49
2978
 
2979
 
2980
 
2981
 
2982
 5287  F83F71  86 62         		stx	PTR1+2
2983
 5288  F83F73  20 B0 3B      		jsr	_feLDZ		; azzera FAC
2984
 5289  F83F76  64 63         		stz	FPFlag
2985
 5290  F83F78  64 4F         		stz	FPDCnt
2986
 5291  F83F7A  A0 FF         		LDY	#$FF
2987
 5292  F83F7C  C8            	?02:	INY
2988
 5293  F83F7D  C0 7F         		CPY	#MAXDECSTR
2989
 5294  F83F7F  90 03         		bcc	?02a
2990
 5295  F83F81  4C 0F 40      		jmp	?15		; fine stringa
2991
 5296  F83F84  B7 60         	?02a:	LDA	[PTR1],Y	; elimina spazi iniziali
2992
 5297  F83F86  D0 03         		bne	?02b
2993
 5298  F83F88  4C 0F 40      		jmp	?15		; fine stringa
2994
 5299  F83F8B  C9 20         	?02b:	CMP	#' '
2995
 5300  F83F8D  F0 ED         		BEQ	?02		; scarta spazio
2996
 5301  F83F8F  C9 2B         		CMP	#'+'
2997
 5302  F83F91  F0 08         		BEQ	?03		; scarta segno +
2998
 5303  F83F93  C9 2D         		CMP	#'-'
2999
 5304  F83F95  D0 09         		BNE	?04
3000
 5305  F83F97  A9 80         		lda	#$80
3001
 5306  F83F99  04 63         		tsb	FPFLAG		; FPFLAG[7] = segno - mantissa
3002
 5307  F83F9B  C8            	?03:	INY			; next char
3003
 5308  F83F9C  C0 7F         		CPY	#MAXDECSTR
3004
 5309  F83F9E  F0 6F         		BEQ	?15
3005
 5310  F83FA0  B7 60         	?04:	LDA	[PTR1],Y	; carica digit
3006
 5311  F83FA2  F0 6B         		BEQ	?15		; fine stringa
3007
 5312  F83FA4  38            		SEC			; next digit decimale
3008
 5313  F83FA5  E9 3A         		SBC	#('0'+10)
3009
 5314  F83FA7  18            		CLC
3010
 5315  F83FA8  69 0A         		ADC	#10
3011
 5316  F83FAA  90 1F         		BCC	?06		; no digit
3012
 5317  F83FAC  AA            		tax			; X = digit
3013
 5318  F83FAD  A9 20         		lda	#$20
3014
 5319  F83FAF  24 63         		bit	FPFLAG		; test bit 5
3015
 5320  F83FB1  D0 0C         		bne	?05		; processa digit esponente
3016
 5321  F83FB3  A9 10         		lda	#$10
3017
 5322  F83FB5  04 63         		tsb	FPFLAG		; FPFLAG[4] -> flag digit mantissa
3018
 5323  F83FB7  8A            		txa			; A = digit
3019
 5324  F83FB8  20 7D 40      		JSR	_AddDigit	; aggiunge digit a FAC
3020
 5325  F83FBB  90 DE         		bcc	?03		; ok, next char
3021
 5326  F83FBD  B0 47         		bcs	?12		; errore overflow, fine processo
3022
 5327                        	?05:	; processa digit esponente
3023
 5328  F83FBF  A9 04         		lda	#$04
3024
 5329  F83FC1  04 63         		tsb	FPFLAG		; FPFLAG[2] -> flag digit esponente
3025
 5330  F83FC3  8A            		txa			; A = digit
3026
 5331  F83FC4  20 9D 40      		JSR	_AddExpDigit
3027
 5332  F83FC7  90 D2         		BCC	?03		; ok, next exp digit
3028
 5333  F83FC9  B0 3B         		BCS	?12		; overflow esponente, fine processo
3029
 5334                        	?06:	; no digit: test per dot decimale o esponente
3030
 5335  F83FCB  69 30         		ADC	#'0'
3031
 5336  F83FCD  C9 2E         		CMP	#'.'
3032
 5337  F83FCF  D0 10         		BNE	?07
3033
 5338                        		; char corrente '.' -- se non vi sono digit precedenti -> errore
3034
 5339  F83FD1  A9 10         		lda	#$10
3035
 5340  F83FD3  24 63         		bit	FPFLAG		; test bit 4
3036
 5341  F83FD5  F0 3C         		BEQ	?20		; non vi sono digit precedenti -> errore
3037
 5342  F83FD7  24 63         		BIT	FPFLAG		; test dot gia' presente
3038
 5343  F83FD9  70 38         		BVS	?20		; dot gia' processato -> errore
3039
  Tue Jul 17 11:00:16 2018                                                                                               Page   50
3040
 
3041
 
3042
 
3043
 
3044
 5344  F83FDB  A9 40         		lda	#$40
3045
 5345  F83FDD  04 63         		tsb	FPFLAG		; set bit 6 -> dot
3046
 5346  F83FDF  80 BA         		bra	?03		; next char
3047
 5347  F83FE1  C9 45         	?07:	CMP	#'E'
3048
 5348  F83FE3  F0 04         		BEQ	?08		; -> esponente
3049
 5349  F83FE5  C9 65         		CMP	#'e'
3050
 5350  F83FE7  D0 2A         		BNE	?20		; carattere illegale -> errore
3051
 5351                        		; processa esponente decimale
3052
 5352  F83FE9  A9 10         	?08:	lda	#$10
3053
 5353  F83FEB  24 63         		bit	FPFLAG		; test bit 4
3054
 5354  F83FED  F0 24         		BEQ	?20		; non vi sono digit precedenti -> errore
3055
 5355  F83FEF  A9 20         		lda	#$20
3056
 5356  F83FF1  04 63         		tsb	FPFLAG		; FPFLAG[5] -> flag esponente
3057
 5357  F83FF3  C8            		INY			; next char
3058
 5358  F83FF4  B7 60         		LDA	[PTR1],y
3059
 5359  F83FF6  F0 17         		BEQ	?15		; fine stringa
3060
 5360  F83FF8  C9 2B         		CMP	#'+'
3061
 5361  F83FFA  F0 9F         		BEQ	?03		; scarta segno +
3062
 5362  F83FFC  C9 2D         		CMP	#'-'
3063
 5363  F83FFE  D0 A0         		BNE	?04		; processa stesso char
3064
 5364  F84000  A9 08         		lda	#$08
3065
 5365  F84002  04 63         		tsb	FPFLAG		; FPFLAG[3] = segno - esponente
3066
 5366  F84004  80 95         		BRA	?03
3067
 5367  F84006
3068
 5368                        	?12:	; processa errore di overflow
3069
 5369  F84006  84 3B         		STY	FPIndx		; salva indice stringa
3070
 5370  F84008  A6 63         		ldx	FPFLAG		; segno attuale per INF
3071
 5371  F8400A  20 73 3B      		JSR	_feLDINF	; FAC = +/- INF
3072
 5372  F8400D  80 58         		BRA	?99		; esce
3073
 5373  F8400F
3074
 5374                        		; entry fine stringa
3075
 5375  F8400F  A9 02         	?15:	lda	#$02
3076
 5376  F84011  04 63         		tsb	FPFLAG		; FPFLAG[1] -> flag fine stringa
3077
 5377  F84013
3078
 5378                        		; entry per fine prematura processo scansione
3079
 5379  F84013  84 3B         	?20:	STY	FPIndx		; salva indice Y
3080
 5380  F84015  A9 10         		lda	#$10
3081
 5381  F84017  24 63         		bit	FPFLAG		; test bit 4
3082
 5382  F84019  D0 05         		bne	?22		; OK mantissa presente
3083
 5383  F8401B  20 86 3B      	?21:	JSR	_feLDNAN	; numero non valido -> invalid
3084
 5384  F8401E  80 47         		BRA	?99		; esce
3085
 5385  F84020
3086
 5386  F84020  A9 20         	?22:	lda	#$20
3087
 5387  F84022  24 63         		bit	FPFLAG		; test bit 5
3088
 5388  F84024  F0 06         		beq	?25		; OK - no forma exp
3089
 5389  F84026  A9 04         		lda	#$04
3090
 5390  F84028  24 63         		bit	FPFLAG		; test bit 2
3091
 5391  F8402A  F0 EF         		beq	?21		; errore -- forma exp ma mancano digit exp
3092
 5392
3093
 5393                        	?25:	; sintatticamente la conversione sembra corretta
3094
 5394                        		; si verificano ora le condizioni di overflow
3095
 5395  F8402C                		ACC16
3096
 5396  F8402C  C2 20         		rep	#PMFLAG
3097
 5397                        		.LONGA	on
3098
 5398                        		.MNLIST
3099
 5399  F8402E  A5 5E         		lda	FPExp
3100
 5400  F84030  C9 87 13      		cmp	#EXP10LIM
3101
  Tue Jul 17 11:00:16 2018                                                                                               Page   51
3102
 
3103
 
3104
 
3105
 
3106
 5401  F84033                		ACC08
3107
 5402  F84033  E2 20         		sep	#PMFLAG
3108
 5403                        		.LONGA	off
3109
 5404                        		.MNLIST
3110
 5405  F84035  B0 CF         		bcs	?12		; overflow
3111
 5406  F84037  38            		SEC
3112
 5407  F84038  A9 00         		LDA	#0		; cambia segno al numero di digit decimali
3113
 5408  F8403A  E5 4F         		SBC	FPDCNT
3114
 5409  F8403C  85 38         		STA	FPWTmp5		; salva -N (cifre dopo il punto decimale)
3115
 5410  F8403E  A9 00         		LDA	#0
3116
 5411  F84040  E9 00         		SBC	#0
3117
 5412  F84042  85 39         		STA	FPWTmp5+1
3118
 5413  F84044  A9 08         	?27:	lda	#$08
3119
 5414  F84046  24 63         		bit	FPFLAG		; test bit 3
3120
 5415  F84048                		ACC16
3121
 5416  F84048  C2 20         		rep	#PMFLAG
3122
 5417                        		.LONGA	on
3123
 5418                        		.MNLIST
3124
 5419  F8404A  F0 08         		beq	?30		; exp positivo
3125
 5420  F8404C  38            		SEC
3126
 5421  F8404D  A9 00 00      		lda	#0
3127
 5422  F84050  E5 5E         		sbc	FPExp
3128
 5423  F84052  85 5E         		sta	FPExp		; esponente negativo, cambia segno
3129
 5424  F84054  18            	?30:	CLC
3130
 5425  F84055  A5 5E         		lda	FPExp
3131
 5426  F84057  65 38         		adc	FPWTmp5		; E = E + (-N)
3132
 5427  F84059                		ACC08
3133
 5428  F84059  E2 20         		sep	#PMFLAG
3134
 5429                        		.LONGA	off
3135
 5430                        		.MNLIST
3136
 5431  F8405B  20 F4 3D      		JSR	_fePOW10
3137
 5432  F8405E  B0 A6         		bcs	?12		; overflow
3138
 5433  F84060  A6 63         		ldx	FPFLAG
3139
 5434  F84062  86 40         		stx	FACSGN
3140
 5435  F84064  20 FF 3B      		jsr	_feXAM		; get flag FAC
3141
 5436  F84067  08            	?99:	php			; salva flag
3142
 5437  F84068  68            		pla			; A = flag
3143
 5438  F84069  29 C3         		and	#$C3		; maschera on N,V,C,Z
3144
 5439  F8406B  03 04         		ora	$04,s		; imposta N,V,C,Z nello stack
3145
 5440  F8406D  83 04         		sta	$04,s
3146
 5441  F8406F                		ACC16
3147
 5442  F8406F  C2 20         		rep	#PMFLAG
3148
 5443                        		.LONGA	on
3149
 5444                        		.MNLIST
3150
 5445  F84071  A5 60         		lda	PTR1
3151
 5446  F84073                		ACC08
3152
 5447  F84073  E2 20         		sep	#PMFLAG
3153
 5448                        		.LONGA	off
3154
 5449                        		.MNLIST
3155
 5450  F84075  A6 62         		ldx	PTR1+2		; CX => long ptr stringa
3156
 5451  F84077  A4 3B         		ldy	FPIndx		; Y = indice primo chr dove si arresta conv.
3157
 5452  F84079  2B            		pld			; restore DPR
3158
 5453  F8407A  AB            		plb			; restore DBR
3159
 5454  F8407B  28            		plp			; restore flag conversione
3160
 5455  F8407C  60            		RTS
3161
 5456
3162
 5457                        	; esegue FAC = A + (FAC * 10)
3163
  Tue Jul 17 11:00:16 2018                                                                                               Page   52
3164
 
3165
 
3166
 
3167
 
3168
 5458  F8407D                	_AddDigit:
3169
 5459  F8407D  5A            		PHY			; salva Y
3170
 5460  F8407E  48            		PHA			; salva A
3171
 5461  F8407F  24 63         		BIT	FPFLAG		; FPFLAG[6] -> dot decimale
3172
 5462  F84081  50 02         		BVC	?01
3173
 5463  F84083  E6 4F         		INC	FPDCNT		; incrementa contatore digit
3174
 5464  F84085  20 E4 39      	?01:	JSR	_feMUL10	; FAC = FAC * 10
3175
 5465  F84088  B0 10         		bcs	?04		; errore
3176
 5466  F8408A  20 DE 3D      		JSR	_MovRndF2A	; copia FAC arrotondato in ARG
3177
 5467  F8408D  B0 0B         		bcs	?04		; errore
3178
 5468  F8408F  68            		PLA			; ripristina A
3179
 5469  F84090  20 BF 40      		JSR	_Byte2FAC	; converte byte in float
3180
 5470  F84093  B0 03         		bcs	?02
3181
 5471  F84095  20 04 37      		JSR	_feADD		; FAC = (FAC * 10) + A
3182
 5472  F84098  7A            	?02:	PLY			; ripristina Y
3183
 5473  F84099  60            		RTS
3184
 5474  F8409A  68            	?04:	pla
3185
 5475  F8409B  7A            		ply
3186
 5476  F8409C  60            		rts
3187
 5477  F8409D
3188
 5478                        	; Aggiunge un digit all'esponente FPExp
3189
 5479                        	; In	- A = digit
3190
 5480                        	;	- FPExp = esponente
3191
 5481                        	;
3192
 5482                        	; Out	- FPExp = (FPExp * 10) + A
3193
 5483                        	; In caso di overflow -> CF = 1
3194
 5484  F8409D                	_AddExpDigit:
3195
 5485  F8409D  EB            		xba
3196
 5486  F8409E  A9 00         		lda	#0
3197
 5487  F840A0  EB            		xba			; B = 0
3198
 5488  F840A1                		ACC16
3199
 5489  F840A1  C2 20         		rep	#PMFLAG
3200
 5490                        		.LONGA	on
3201
 5491                        		.MNLIST
3202
 5492  F840A3  48            		PHA			; salva C
3203
 5493  F840A4  A5 5E         		LDA	FPExp		; salva FPExp
3204
 5494  F840A6  85 38         		STA	FPWTmp5
3205
 5495  F840A8  0A            		asl	a		; FPExp * 2
3206
 5496  F840A9  B0 0A         		bcs	?01
3207
 5497  F840AB  0A            		asl	a		; FPExp * 4
3208
 5498  F840AC  B0 07         		bcs	?01
3209
 5499  F840AE  65 38         		adc	FPWTmp5		; FPExp * 5
3210
 5500  F840B0  B0 03         		bcs	?01
3211
 5501  F840B2  0A            		asl	a		; FPExp * 10
3212
 5502  F840B3  85 5E         		sta	FPExp
3213
 5503  F840B5  68            	?01:	pla			; ripristina C
3214
 5504  F840B6  B0 04         		bcs	?02
3215
 5505  F840B8  65 5E         		adc	FPExp		; FPExp * 10 + A
3216
 5506  F840BA  85 5E         		sta	FPExp
3217
 5507  F840BC                	?02:	ACC08
3218
 5508  F840BC  E2 20         		sep	#PMFLAG
3219
 5509                        		.LONGA	off
3220
 5510                        		.MNLIST
3221
 5511  F840BE  60            		rts
3222
 5512
3223
 5513                        	; converte byte in floating point
3224
 5514                        	; In:	A = byte
3225
  Tue Jul 17 11:00:16 2018                                                                                               Page   53
3226
 
3227
 
3228
 
3229
 
3230
 5515                        	; Out:	FAC
3231
 5516                        	; Uso:	A,X,Y
3232
 5517  F840BF                	_Byte2FAC:
3233
 5518  F840BF  85 49         		STA	FAC+8
3234
 5519  F840C1  64 48         		STZ	FAC+7
3235
 5520  F840C3  64 41         		STZ	FACEXT
3236
 5521  F840C5  64 40         		STZ	FACSGN
3237
 5522  F840C7                		ACC16
3238
 5523  F840C7  C2 20         		rep	#PMFLAG
3239
 5524                        		.LONGA	on
3240
 5525                        		.MNLIST
3241
 5526  F840C9  64 46         		STZ	FAC+5
3242
 5527  F840CB  64 44         		STZ	FAC+3
3243
 5528  F840CD  64 42         		STZ	FAC+1
3244
 5529  F840CF  A9 06 40      		LDA	#BIASBYTE
3245
 5530  F840D2  85 4A         		STA	FACExp
3246
 5531  F840D4                		ACC08
3247
 5532  F840D4  E2 20         		sep	#PMFLAG
3248
 5533                        		.LONGA	off
3249
 5534                        		.MNLIST
3250
 5535  F840D6  4C D9 37      		JMP	_Normalize
3251
 5536
3252
 5537                        	;-------------------------------------------------------------
3253
 5538                        	; CONVERSIONE DA FLOAT POINT NUMBER A STRINGA DECIMALE
3254
 5539                        	;-------------------------------------------------------------
3255
 5540
3256
 5541                        	; _feFAC2S - converte FAC in stringa decimale
3257
 5542                        	; In	- FAC caricato o da operazione precedente
3258
 5543                        	;	  A<7> -> 0 (utilizzato per segno FAC)
3259
 5544                        	; 	  A<6> -> formato G				$40
3260
 5545                        	; 	  A<5> -> formato F (se <6> = 0)		$20
3261
 5546                        	; 	  A<4> -> formato alternativo #			$10
3262
 5547                        	; 	  A<3> -> CAPS formato (G, F, E)		$08
3263
 5548                        	; 	  A<2> -> formato a/A				$04
3264
 5549                        	; 	  A<1> -> blank se positivo			$02
3265
 5550                        	; 	  A<0> -> segno '+'/blank se positivo		$01
3266
 5551                        	;	  X -> precisione richiesta
3267
 5552                        	;	  DPR -> DP02ADDR (pagina 02)
3268
 5553                        	;	  DBR -> banco 0
3269
 5554                        	;
3270
 5555                        	; Out	- XCVTStr -> stringa decimale formattata
3271
 5556                        	;	  A = Y = lunghezza stringa
3272
 5557                        	;	  X = puntatore stringa
3273
 5558  F840D9                	_feFAC2S:
3274
 5559  F840D9  29 7F         		and	#$7F		; <7> -> segno FAC = 0
3275
 5560  F840DB  85 16         		sta	XVFlag		; salva flag
3276
 5561  F840DD  89 04         		bit	#$04
3277
 5562  F840DF  F0 03         		beq	?00
3278
 5563  F840E1  4C F5 43      		jmp	aform		; formato a/A
3279
 5564                        	?00:	; X = precisione
3280
 5565  F840E4  E0 30         		cpx	#XCVTMAXF+1	; limite preventivo alla precisione
3281
 5566  F840E6  90 02         		bcc	?01
3282
 5567  F840E8  A2 2F         		ldx	#XCVTMAXF
3283
 5568  F840EA  24 16         	?01:	bit 	XVFlag		; <6> -> VF test richiesta formato G
3284
 5569  F840EC  50 05         		bvc	?01b		; no G
3285
 5570  F840EE  9B            		txy
3286
 5571  F840EF  F0 08         		beq	?01c		; formato G -> se prec. = 0 -> prec = 1
3287
  Tue Jul 17 11:00:16 2018                                                                                               Page   54
3288
 
3289
 
3290
 
3291
 
3292
 5572  F840F1  D0 07         		bne	?01z		; store prec. formato G
3293
 5573  F840F3  A9 20         	?01b:	lda	#$20		; richiesto formato E ?
3294
 5574  F840F5  24 16         		bit	XVFlag
3295
 5575  F840F7  D0 01         		bne	?01z		; NO -- store prec
3296
 5576  F840F9  E8            	?01c:	inx			; formato E incrementa precisione
3297
 5577                        					; dato che ha sempre un digit prima del dot
3298
 5578  F840FA  86 0A         	?01z:	stx	FmtPrec		; precisione richiesta (provvisoria)
3299
 5579                        		; la precisione per il formato F puo' essere controllata solo
3300
 5580                        		; dopo che e' stato determinato il numero di decimali
3301
 5581  F840FC  24 40         		bit	FACSGN		; testo segno FAC
3302
 5582  F840FE  10 04         		bpl	?02		; positivo
3303
 5583  F84100  A9 80         		lda	#$80		; <7> -> segno FAC = 1
3304
 5584  F84102  04 16         		tsb	XVFlag		; imposta segno negativo
3305
 5585  F84104  64 40         	?02:	stz	FACSGN		; FAC = ABS(FAC)
3306
 5586  F84106  20 FF 3B      		jsr	_feXAM		; esamina FAC
3307
 5587  F84109  F0 44         		beq	?06		; zero
3308
 5588  F8410B  B0 04         		bcs	?03		; NAN/INF
3309
 5589  F8410D  70 40         		bvs	?06		; denormal => round to zero
3310
 5590  F8410F  50 65         		bvc	?16		; normale e valido
3311
 5591  F84111  08            	?03:	php			; salva V
3312
 5592  F84112  20 43 42      		jsr	storesgn
3313
 5593  F84115  BB            		tyx			; X = indice stringa XCVTStr
3314
 5594  F84116  A0 00         		ldy	#0
3315
 5595  F84118  A9 08         		lda	#$08		; test CAPS
3316
 5596  F8411A  24 16         		bit	XVFlag
3317
 5597  F8411C  D0 02         		bne	?04		; CAPS ON -> maiuscolo
3318
 5598  F8411E  A0 20         		ldy	#$20		; converte in minuscolo
3319
 5599  F84120  84 24         	?04:	sty	FPTmp1
3320
 5600  F84122  28            		plp			; ripristina V
3321
 5601  F84123  50 0B         		bvc	?04a		; NAN
3322
 5602  F84125  A9 46         		lda	#'F'		; store INF/inf
3323
 5603  F84127  85 25         		sta	FPTmp2
3324
 5604  F84129  A9 4E         		lda	#'N'
3325
 5605  F8412B  EB            		xba
3326
 5606  F8412C  A9 49         		lda	#'I'
3327
 5607  F8412E  80 09         		bra	?05
3328
 5608  F84130  A9 4E         	?04a:	lda	#'N'		; store NAN/nan
3329
 5609  F84132  85 25         		sta	FPTmp2
3330
 5610  F84134  A9 41         		lda	#'A'
3331
 5611  F84136  EB            		xba
3332
 5612  F84137  A9 4E         		lda	#'N'
3333
 5613  F84139  05 24         	?05:	ora	FPTmp1
3334
 5614  F8413B  95 86         		sta	<XCVTStr,x
3335
 5615  F8413D  E8            		inx
3336
 5616  F8413E  EB            		xba
3337
 5617  F8413F  05 24         		ora	FPTmp1
3338
 5618  F84141  95 86         		sta	<XCVTStr,x
3339
 5619  F84143  E8            		inx
3340
 5620  F84144  A5 25         		lda	FPTmp2
3341
 5621  F84146  05 24         		ora	FPTmp1
3342
 5622  F84148  95 86         		sta	<XCVTStr,x
3343
 5623  F8414A  E8            		inx
3344
 5624  F8414B  9B            		txy			; Y = lunghezza stringa
3345
 5625  F8414C  4C 3D 42      		jmp	?100		; termina stringa ed esce
3346
 5626  F8414F
3347
 5627                        		; zero o arrotondato a zero
3348
 5628  F8414F  A9 80         	?06:	lda	#$80		; <7> -> segno FAC = 0
3349
  Tue Jul 17 11:00:16 2018                                                                                               Page   55
3350
 
3351
 
3352
 
3353
 
3354
 5629  F84151  14 16         		trb	XVFlag		; ZERO solo POSITIVO
3355
 5630  F84153  24 16         		bit	XVFlag
3356
 5631  F84155  50 04         		bvc	?07		; no formato G
3357
 5632  F84157  A9 20         		lda	#$20		; forza formato F se G true
3358
 5633  F84159  04 16         		tsb	XVFlag
3359
 5634  F8415B  A2 14         	?07:	ldx	#MAXINTDGTS
3360
 5635  F8415D  E4 0A         		cpx	FmtPrec
3361
 5636  F8415F  90 04         		bcc	?07a
3362
 5637  F84161  F0 02         		beq	?07a
3363
 5638  F84163  A6 0A         		ldx	FmtPrec		; numero di '0'
3364
 5639  F84165  74 71         	?07a:	stz	FPUStr+1,x	; terminatore stringa
3365
 5640  F84167  CA            		dex
3366
 5641  F84168  A9 30         		lda	#'0'		; stringa di '0'
3367
 5642  F8416A  95 71         	?08:	sta	FPUStr+1,x
3368
 5643  F8416C  CA            		dex
3369
 5644  F8416D  10 FB         		bpl	?08
3370
 5645  F8416F  64 14         		stz	XVDec		; numero decimali
3371
 5646  F84171  64 15         		stz	XVDec+1
3372
 5647  F84173  4C 27 42      		jmp	?90		; converte
3373
 5648  F84176
3374
 5649                        		; numero float normale -- si scala FAC in modo che sia:
3375
 5650                        		; 1E18 <= FAC <= MAX UINT (19/20 cifre significative)
3376
 5651  F84176  20 A8 3E      	?16:	jsr	_feSCALE10
3377
 5652  F84179  20 0C 3F      		jsr	_feFAC2I	; converte in intero tra 1E18 e MAX UINT
3378
 5653  F8417C                		ACC16			; copia IARG in FOP
3379
 5654  F8417C  C2 20         		rep	#PMFLAG
3380
 5655                        		.LONGA	on
3381
 5656                        		.MNLIST
3382
 5657  F8417E  A5 28         		lda	IARG
3383
 5658  F84180  85 32         		sta	FOP
3384
 5659  F84182  A5 2A         		lda	IARG+2
3385
 5660  F84184  85 34         		sta	FOP+2
3386
 5661  F84186  A5 2C         		lda	IARG+4
3387
 5662  F84188  85 36         		sta	FOP+4
3388
 5663  F8418A  A5 2E         		lda	IARG+6
3389
 5664  F8418C  85 38         		sta	FOP+6
3390
 5665  F8418E                		ACC08
3391
 5666  F8418E  E2 20         		sep	#PMFLAG
3392
 5667                        		.LONGA	off
3393
 5668                        		.MNLIST
3394
 5669  F84190
3395
 5670                        		; a questo punto 1E18 <= IARG <= MAX UINT e si converte intero
3396
 5671                        		; in stringa decimale con 19/20 digits significativi
3397
 5672                        		; il punto decimale implicito si trova dopo il secondo digit
3398
 5673  F84190  20 6C 31      		jsr	_UI2Str		; punto decimale dopo secondo digit
3399
 5674                        		; A = lunghezza stringa (19 o 20)
3400
 5675                        		; Y = ptr primo digit
3401
 5676  F84193  C9 13         		cmp	#MAXDIGITS
3402
 5677  F84195  F0 08         		beq	?52		; 19 digit significativi
3403
 5678  F84197                		ACC16			; 20 digit significativi
3404
 5679  F84197  C2 20         		rep	#PMFLAG
3405
 5680                        		.LONGA	on
3406
 5681                        		.MNLIST
3407
 5682  F84199  E6 14         		inc	XVDec		; incrementa esponente decimale
3408
 5683  F8419B                		ACC08			; e il punto decimale sta dopo primo digit
3409
 5684  F8419B  E2 20         		sep	#PMFLAG
3410
 5685                        		.LONGA	off
3411
  Tue Jul 17 11:00:16 2018                                                                                               Page   56
3412
 
3413
 
3414
 
3415
 
3416
 5686                        		.MNLIST
3417
 5687  F8419D  80 11         		bra	?56
3418
 5688  F8419F  A2 00         	?52:	ldx	#0
3419
 5689  F841A1  B5 72         	?54:	lda	<FPUStr+2,x	; trasla indietro stringa di 19 digit
3420
 5690  F841A3  F0 05         		beq	?55		; terminatore #0
3421
 5691  F841A5  95 71         		sta	<FPUStr+1,x
3422
 5692  F841A7  E8            		inx
3423
 5693  F841A8  80 F7         		bra	?54
3424
 5694  F841AA  A9 30         	?55:	lda	#'0'		; aggiunge uno zero per avere 20 cifre
3425
 5695  F841AC  95 71         		sta	<FPUStr+1,x
3426
 5696  F841AE  74 72         		stz	<FPUStr+2,x	; termina stringa
3427
 5697                        	?56:	; a questo punto la conversione ha prodotto una stringa decimale base
3428
 5698                        		; di lunghezza fissa pari a 20 caratteri.
3429
 5699                        		; in base alla precisione e al formato richiesti occorre arrotondare
3430
 5700                        		; opportunamente il numero e decidere il formato corretto
3431
 5701  F841B0  A5 0A         		lda	FmtPrec		; estende FmtPrec a 16 bit
3432
 5702  F841B2  85 5C         		sta	FPWTmp
3433
 5703  F841B4  64 5D         		stz	FPWTmp+1
3434
 5704  F841B6  24 16         		bit 	XVFlag		; <6> -> VF test richiesta formato G
3435
 5705  F841B8  50 07         		bvc	?70		; no formato G
3436
 5706  F841BA  20 5D 42      		jsr	testg
3437
 5707  F841BD  B0 2B         		bcs	?80		; imposta formato E -- round con FmtPrec
3438
 5708  F841BF  90 17         		bcc	?72		; test max esponente positivo formato F
3439
 5709  F841C1  A9 20         	?70:	lda	#$20		; test formato F
3440
 5710  F841C3  24 16         		bit	XVFlag
3441
 5711  F841C5  F0 23         		beq	?80		; NO -- richiesto formato E, round con FmtPrec
3442
 5712  F841C7                		ACC16			; calcola digit round
3443
 5713  F841C7  C2 20         		rep	#PMFLAG
3444
 5714                        		.LONGA	on
3445
 5715                        		.MNLIST
3446
 5716  F841C9  18            		clc
3447
 5717  F841CA  A5 14         		lda	XVDec		; somma signed
3448
 5718  F841CC  65 5C         		adc	FPWTmp
3449
 5719  F841CE  1A            		inc	a		; se negativo round to zero
3450
 5720  F841CF  85 5C         		sta	FPWTmp
3451
 5721  F841D1                		ACC08
3452
 5722  F841D1  E2 20         		sep	#PMFLAG
3453
 5723                        		.LONGA	off
3454
 5724                        		.MNLIST
3455
 5725  F841D3  10 03         		bpl	?72		; check formato F
3456
 5726  F841D5  4C 4F 41      		jmp	?06		; Prec negtiva => round to zero
3457
 5727  F841D8                	?72:	ACC16			; test esponente + formato F
3458
 5728  F841D8  C2 20         		rep	#PMFLAG
3459
 5729                        		.LONGA	on
3460
 5730                        		.MNLIST
3461
 5731  F841DA  18            		clc			; OK --
3462
 5732  F841DB  A5 14         		lda	XVDec
3463
 5733  F841DD  30 03         		bmi	?74		; exp negativo -- ok
3464
 5734  F841DF  C9 24 00      		cmp	#MAXFDEC	; forza formato E
3465
 5735  F841E2                	?74:	ACC08			; se esponente maggiore di un limite fisso
3466
 5736  F841E2  E2 20         		sep	#PMFLAG
3467
 5737                        		.LONGA	off
3468
 5738                        		.MNLIST
3469
 5739  F841E4  90 04         		bcc	?80		; OK
3470
 5740  F841E6  A9 20         		lda	#$20		; clear flag formato F
3471
 5741  F841E8  14 16         		trb	XVFlag		; e forza formato F se Exp >= MAXFDEC
3472
 5742  F841EA
3473
  Tue Jul 17 11:00:16 2018                                                                                               Page   57
3474
 
3475
 
3476
 
3477
 
3478
 5743                        	?80:	; indice digit da arrotondare (X = 0 possibile solo per formato F)
3479
 5744                        		; per come e' stato costruito FPWTmp, esso e' a 8 bit
3480
 5745  F841EA  A6 5C         		ldx	FPWTmp		; 8 bit
3481
 5746  F841EC  E0 14         		cpx	#MAXINTDGTS	; round solo se necessario
3482
 5747  F841EE  B0 37         		bcs	?90		; no rounding
3483
 5748                        		; round alla cifra di indice X
3484
 5749  F841F0  A0 30         		ldy	#'0'
3485
 5750  F841F2  B5 71         		lda	<FPUStr+1,x
3486
 5751  F841F4  74 71         		stz	<FPUStr+1,x	; tronca stringa alla precisione richiesta
3487
 5752  F841F6  C9 35         		cmp	#'5'
3488
 5753  F841F8  90 2D         		bcc	?90		; no round
3489
 5754  F841FA  CA            	?82:	dex			; passa al digit precedente
3490
 5755  F841FB  30 0F         		bmi	?88		; oltre primo digit
3491
 5756  F841FD  B5 71         		lda	<FPUStr+1,x	; test digit precedente
3492
 5757  F841FF  1A            		inc	a		; round
3493
 5758  F84200  C9 3A         		cmp	#'9'+1
3494
 5759  F84202  90 04         		bcc	?84		; fine rounding
3495
 5760  F84204  94 71         		sty	<FPUStr+1,x	; zero finale
3496
 5761  F84206  B0 F2         		bcs	?82
3497
 5762  F84208  95 71         	?84:	sta	<FPUStr+1,x	; salva digit arrotondato
3498
 5763  F8420A  90 1B         		bcc	?90		; fine rounding
3499
 5764                        	?88:	; il rounding ha generato un riporto
3500
 5765  F8420C                		ACC16
3501
 5766  F8420C  C2 20         		rep	#PMFLAG
3502
 5767                        		.LONGA	on
3503
 5768                        		.MNLIST
3504
 5769  F8420E  E6 14         		inc	XVDec		; incrementa esponente decimale
3505
 5770  F84210                		ACC08
3506
 5771  F84210  E2 20         		sep	#PMFLAG
3507
 5772                        		.LONGA	off
3508
 5773                        		.MNLIST
3509
 5774  F84212  A9 31         		lda	#'1'
3510
 5775  F84214  85 71         		sta	<FPUStr+1	; store '1'
3511
 5776  F84216  24 16         		bit 	XVFlag		; <6> -> VF test richiesta formato G
3512
 5777  F84218  50 03         		bvc	?89		; no formato G
3513
 5778  F8421A  20 5D 42      		jsr	testg		; exp cambiato => testare limiti per F
3514
 5779  F8421D  A9 20         	?89:	lda	#$20		; test formato F
3515
 5780  F8421F  24 16         		bit	XVFlag
3516
 5781  F84221  F0 04         		beq	?90
3517
 5782                        		; nel formato F puo' accadere che l'indice di rounding sia zero
3518
 5783                        		; in questo caso l'indice va incrementato e la stringa terminata
3519
 5784  F84223  A6 5C         		ldx	FPWTmp
3520
 5785  F84225  74 72         		stz	<FPUStr+2,x	; termina sulla precisione richiesta
3521
 5786  F84227  20 43 42      	?90:	jsr	storesgn
3522
 5787  F8422A  84 3B         		sty	FPIndx		; store indice primo digit
3523
 5788  F8422C  A2 00         		ldx	#0
3524
 5789  F8422E  A9 20         		lda	#$20
3525
 5790  F84230  24 16         		bit	XVFlag
3526
 5791  F84232  F0 05         		beq	?92		; formato E
3527
 5792  F84234  20 7B 42      		jsr	fform		; formato F
3528
 5793  F84237  80 03         		bra	?94
3529
 5794  F84239  20 42 43      	?92:	jsr	eform
3530
 5795  F8423C  BB            	?94:	tyx
3531
 5796  F8423D  74 86         	?100:	stz	<XCVTStr,x	; termina stringa
3532
 5797  F8423F  98            		tya
3533
 5798  F84240  A2 86         		ldx	#XCVTStr
3534
 5799  F84242  60            		rts
3535
  Tue Jul 17 11:00:16 2018                                                                                               Page   58
3536
 
3537
 
3538
 
3539
 
3540
 5800
3541
 5801                        	; memorizza segno secondo i criteri di formattazione
3542
 5802  F84243                	storesgn:
3543
 5803  F84243  A0 00         		ldy	#0		; indice stringa XCVTStr
3544
 5804  F84245  A5 16         		lda	XVFlag		; test segno
3545
 5805  F84247  10 04         		bpl	?02		; positivo
3546
 5806  F84249  A9 2D         		lda	#'-'		; store '-'
3547
 5807  F8424B  D0 0B         		bne	?06
3548
 5808  F8424D  4A            	?02:	lsr	a		; CF -> flag segno positivo
3549
 5809  F8424E  90 0C         		bcc	?08		; no segno se positivo
3550
 5810  F84250  A2 2B         		ldx	#'+'		; assume '+'
3551
 5811  F84252  4A            		lsr	a		; CF -> flag blank
3552
 5812  F84253  90 02         		bcc	?04		; store '+'
3553
 5813  F84255  A2 20         		ldx	#' '		; store blank
3554
 5814  F84257  8A            	?04:	txa
3555
 5815  F84258  99 86 02      	?06:	sta	!DP02ADDR+XCVTStr,y
3556
 5816  F8425B  C8            		iny
3557
 5817  F8425C  60            	?08:	rts
3558
 5818
3559
 5819                        	; testa formato G/g per scegliere F se Exp >= FmtPrec
3560
 5820                        	; Out	- CF = 1 => formato E
3561
 5821                        	;	  CF = 0 => formato F
3562
 5822  F8425D                	testg:
3563
 5823  F8425D  A9 20         		lda	#$20		; <5> -> clear flag F
3564
 5824  F8425F  14 16         		trb	XVFlag		; imposta formato E
3565
 5825  F84261                		ACC16			; formato G sceglie automaticamente tra E e F
3566
 5826  F84261  C2 20         		rep	#PMFLAG
3567
 5827                        		.LONGA	on
3568
 5828                        		.MNLIST
3569
 5829  F84263  A5 14         		lda	XVDec
3570
 5830  F84265  30 04         		bmi	?60		; esponente decimale negativo
3571
 5831  F84267  C5 5C         		cmp	FPWTmp		; 16 bit compare
3572
 5832  F84269  80 07         		bra	?62		; C = 1 esponente >= precisione -> formato E
3573
 5833                        					; C = 0 esponente < precisione -> formato F
3574
 5834  F8426B  49 FF FF      	?60:	eor	#$FFFF		; esponente negativo
3575
 5835  F8426E  1A            		inc	a		; complementa a 2
3576
 5836  F8426F  C9 07 00      		cmp	#MAXFEXP	; esponente <= - max exp. neg. formato F ?
3577
 5837  F84272                	?62:	ACC08
3578
 5838  F84272  E2 20         		sep	#PMFLAG
3579
 5839                        		.LONGA	off
3580
 5840                        		.MNLIST
3581
 5841  F84274  B0 04         		bcs	?64		; imposta formato E -- round con FmtPrec
3582
 5842                        					; Exp < -MAXFEXP oppure Exp >= FmtPrec
3583
 5843                        		; _MAXFEXP <= Exp < FmtPrec => sgeglie formato F
3584
 5844  F84276  A9 20         		lda	#$20		; <5> -> flag F
3585
 5845  F84278  04 16         		tsb	XVFlag		; imposta formato F
3586
 5846  F8427A  60            	?64:	rts
3587
 5847
3588
 5848                        	; converte numero float secondo formato f,F
3589
 5849                        	; In	- X = 0 (indice FPUStr)
3590
 5850                        	;	  Y = indice corrente XCVTStr
3591
 5851                        	; NOTA - causa limiti imposti a FmtPrec sicuramente XVDec a 8 bit (signed)
3592
 5852  F8427B                	fform:
3593
 5853  F8427B  A5 14         		lda	XVDec
3594
 5854  F8427D  1A            		inc	a
3595
 5855  F8427E  A9 14         		lda	#MAXINTDGTS		; padding formato G con exp. negativo
3596
 5856  F84280  85 27         		sta	FPTmp4			; padding formato G con exp. positivo
3597
  Tue Jul 17 11:00:16 2018                                                                                               Page   59
3598
 
3599
 
3600
 
3601
 
3602
 5857  F84282  64 25         		stz	FPTmp2
3603
 5858  F84284  64 24         		stz	FPTmp1			; counter digit frazionari
3604
 5859  F84286  A6 14         		ldx	XVDec			; 8 bit
3605
 5860  F84288  10 22         		bpl	?06			; esp > 0 -> parte integrale
3606
 5861  F8428A  A9 80         		lda	#$80
3607
 5862  F8428C  85 25         		sta	FPTmp2			; flag solo parte frazionaria
3608
 5863  F8428E  A9 14         		lda	#MAXINTDGTS		; padding formato G con exp. negativo
3609
 5864  F84290  85 27         		sta	FPTmp4
3610
 5865  F84292  A9 30         		lda	#'0'
3611
 5866  F84294  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; inizia con '0.'
3612
 5867  F84297  C8            		iny
3613
 5868  F84298  A9 2E         		lda	#'.'
3614
 5869  F8429A  99 86 02      		sta	!DP02ADDR+XCVTStr,y
3615
 5870  F8429D  C8            		iny
3616
 5871  F8429E  A9 30         		lda	#'0'
3617
 5872  F842A0  E8            	?02:	inx				; inc. esponente negativo
3618
 5873  F842A1  F0 08         		beq	?04			; fine '0' iniziali
3619
 5874  F842A3  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; store '0' dopo '.'
3620
 5875  F842A6  E6 24         		inc	FPTmp1			; update cnt digit frazionari
3621
 5876  F842A8  C8            		iny
3622
 5877  F842A9  D0 F5         		bne	?02
3623
 5878  F842AB  CA            	?04:	dex
3624
 5879  F842AC  E8            	?06:	inx
3625
 5880  F842AD  86 14         		stx	XVDec
3626
 5881                        		; si emette parte integrale o frazionaria da stringa arrotondata
3627
 5882  F842AF  A2 00         		ldx	#0
3628
 5883  F842B1  B5 71         	?08:	lda	<FPUStr+1,x
3629
 5884  F842B3  F0 28         		beq	?20			; fine stringa
3630
 5885  F842B5  99 86 02      		sta	!DP02ADDR+XCVTStr,y
3631
 5886  F842B8  C8            		iny
3632
 5887  F842B9  E8            		inx
3633
 5888  F842BA  24 25         		bit	FPTmp2
3634
 5889  F842BC  10 04         		bpl	?09			; parte intera
3635
 5890  F842BE  E6 24         		inc	FPTmp1			; counter digit frazionari
3636
 5891  F842C0  80 EF         		bra	?08			; continua parte frazionaria
3637
 5892  F842C2  C6 14         	?09:	dec	XVDec			; se XVDec (8 bit) = 0 -> '.'
3638
 5893  F842C4  D0 EB         		bne	?08			; emette digit fino al '.'
3639
 5894  F842C6  A9 2E         		lda	#'.'
3640
 5895  F842C8  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; store '.'
3641
 5896  F842CB  C8            		iny
3642
 5897  F842CC  A9 40         		lda	#$40			; flag '.' nel mezzo
3643
 5898  F842CE  04 25         		tsb	FPTmp2
3644
 5899  F842D0  B5 71         	?10:	lda	<FPUStr+1,x
3645
 5900  F842D2  F0 09         		beq	?20			; fine stringa
3646
 5901  F842D4  99 86 02      		sta	!DP02ADDR+XCVTStr,y
3647
 5902  F842D7  E6 24         		inc	FPTmp1			; counter digit frazionari
3648
 5903  F842D9  C8            		iny
3649
 5904  F842DA  E8            		inx
3650
 5905  F842DB  D0 F3         		bne	?10
3651
 5906                        	?20:	; a questo punto sono state emesse tutte le cifre significative
3652
 5907                        		; dalla stringa decimale arrotondata
3653
 5908  F842DD  24 25         		bit	FPTmp2
3654
 5909  F842DF  30 13         		bmi	?30			; forma 0.0000ffff
3655
 5910  F842E1  70 11         		bvs	?30			; forma xxxx.ffff
3656
 5911                        		; sono state emesse solo cifre integrali e l'esponente non e' nullo
3657
 5912                        		; occorre emettere gli zeri fino ad annullare l'esponente
3658
 5913  F842E3  A6 14         		ldx	XVDec
3659
  Tue Jul 17 11:00:16 2018                                                                                               Page   60
3660
 
3661
 
3662
 
3663
 
3664
 5914  F842E5  A9 30         		lda	#'0'
3665
 5915  F842E7  99 86 02      	?22:	sta	!DP02ADDR+XCVTStr,y
3666
 5916  F842EA  C8            		iny
3667
 5917  F842EB  CA            		dex
3668
 5918  F842EC  D0 F9         		bne	?22
3669
 5919  F842EE  A9 2E         		lda	#'.'
3670
 5920  F842F0  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; store '.'
3671
 5921  F842F3  C8            		iny
3672
 5922                        	?30:	; a questo punto la stringa decimale FPUStr+1 arrotondata e' stata
3673
 5923                        		; formattata in XCVTStr secondo le specifiche di precisione richieste
3674
 5924                        		; nel caso del formato F sono state emesse FPTmp1 cifre frazionarie
3675
 5925                        		; quindi occorre paddare la stringa con (FmtPrec - FPTmp1) '0' finali
3676
 5926                        		; con il formato G sono state emesse MIN(FmtPrec, MAXINTDGTS) cifre
3677
 5927                        		; totali, quindi occorre paddare la stringa con (FmtPrec - MAXINTDGTS)
3678
 5928                        		; '0' finali.
3679
 5929  F842F4  64 26         		stz	FPTmp3			; counter padding '0' finali
3680
 5930  F842F6  38            		sec
3681
 5931  F842F7  A5 0A         		lda	FmtPrec			; precisione richiesta
3682
 5932  F842F9  24 16         		bit	XVFlag
3683
 5933  F842FB  50 04         		bvc	?34			; no formato G specificato
3684
 5934  F842FD  A6 27         		ldx	FPTmp4			; valore per formato G
3685
 5935  F842FF  86 24         		stx	FPTmp1
3686
 5936  F84301  E5 24         	?34:	sbc	FPTmp1
3687
 5937  F84303  F0 17         		beq	?40			; FmtPrec - FPTmp1 = 0 => no padding
3688
 5938  F84305  90 15         		bcc	?40			; FmtPrec - FPTmp1 < 0 => no padding
3689
 5939  F84307  AA            		tax				; X => padding -- qui anche CF = 1
3690
 5940  F84308  84 24         		sty	FPTmp1			; lunghezza attuale stringa
3691
 5941  F8430A  A9 2F         		lda	#XCVTMAXF		; max. len
3692
 5942  F8430C  E5 24         		sbc	FPTmp1			; A = bytes disponibili
3693
 5943  F8430E  F0 0C         		beq	?40			; no bytes disponibili
3694
 5944  F84310  90 0A         		bcc	?40			; no bytes disponibili
3695
 5945  F84312  85 24         		sta	FPTmp1			; # bytes disponibili
3696
 5946  F84314  E4 24         		cpx	FPTmp1			; determina padding disponibile
3697
 5947  F84316  90 02         		bcc	?36			; X = padding
3698
 5948  F84318  A6 24         		ldx	FPTmp1			; max. padding possibile
3699
 5949  F8431A  86 26         	?36:	stx	FPTmp3
3700
 5950                        	?40:	; a questo punto FPTmp3 contiene il numero di padding ed Y
3701
 5951                        		; la lunghezza attuale della stringa ed il prox. indice disponibile
3702
 5952                        		; se ultimo carattere emesso e' '.' e non ci sono altri digit da
3703
 5953                        		; emettere, il '.' finale va trimmato a meno che non sia stato
3704
 5954                        		; specificato il formato alternativo
3705
 5955  F8431C  A9 10         		lda	#$10			; test formato alternativo
3706
 5956  F8431E  24 16         		bit	XVFlag
3707
 5957  F84320  D0 12         		bne	?44			; formato alt => no trim
3708
 5958  F84322  88            		dey				; indice last char
3709
 5959  F84323  B9 86 02      		lda	!DP02ADDR+XCVTStr,y	; last char
3710
 5960  F84326  C9 2E         		cmp	#'.'			; last = '.' ?
3711
 5961  F84328  D0 04         		bne	?42			; no -- trimma se formato G
3712
 5962  F8432A  A6 26         		ldx	FPTmp3			; seguono '0' finali ?
3713
 5963  F8432C  F0 13         		beq	?50			; no -- trim '.' ed esce
3714
 5964  F8432E  C8            	?42:	iny				; ripristina indice Y
3715
 5965                        		; si trimmano gli '0' finali se formato G/g e no alt. form.
3716
 5966  F8432F  20 D6 43      		jsr	trimtrail
3717
 5967  F84332  B0 0D         		bcs	?50			; trim -> fine
3718
 5968                        	?44:	; a questo punto padding della stringa con '0' finali
3719
 5969  F84334  A6 26         		ldx	FPTmp3
3720
 5970  F84336  F0 09         		beq	?50			; no padding
3721
  Tue Jul 17 11:00:16 2018                                                                                               Page   61
3722
 
3723
 
3724
 
3725
 
3726
 5971  F84338  A9 30         		lda	#'0'
3727
 5972  F8433A  99 86 02      	?46:	sta	!DP02ADDR+XCVTStr,y	; store '0'
3728
 5973  F8433D  C8            		iny
3729
 5974  F8433E  CA            		dex
3730
 5975  F8433F  D0 F9         		bne	?46
3731
 5976  F84341  60            	?50:	rts
3732
 5977
3733
 5978                        	; converte numero float secondo formato e,E
3734
 5979                        	; In	- X = 0 (indice FPUStr+1)
3735
 5980                        	;	  Y = indice corrente XCVTStr (destinazione)
3736
 5981  F84342                	eform:
3737
 5982  F84342  B5 71         		lda	<FPUStr+1,x
3738
 5983  F84344  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; store primo digit
3739
 5984  F84347  E8            		inx
3740
 5985  F84348  C8            		iny
3741
 5986  F84349  A9 2E         		lda	#'.'			; dopo il primo digit segue il '.'
3742
 5987  F8434B  EB            		xba				; B = '.'
3743
 5988  F8434C  B5 71         		lda	<FPUStr+1,x		; segue secondo digit ?
3744
 5989  F8434E  D0 0D         		bne	?02			; si, secondo digit dopo '.'
3745
 5990  F84350
3746
 5991                        		; se non ci sono altri digit dopo il '.' allora non
3747
 5992                        		; viene emesso il '.' a meno che non sia specificato alt. form.
3748
 5993  F84350  A9 10         		lda	#$10			; test formato alt #
3749
 5994  F84352  24 16         		bit	XVFlag
3750
 5995  F84354  F0 37         		beq	?50			; no alt form # -> emette esponente
3751
 5996  F84356  EB            		xba
3752
 5997  F84357  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; store '.'
3753
 5998  F8435A  C8            		iny
3754
 5999  F8435B  80 30         		bra	?50			; emette esponente
3755
 6000  F8435D  E8            	?02:	inx
3756
 6001  F8435E  EB            		xba				; A = '.', B = secondo digit
3757
 6002  F8435F  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; store '.'
3758
 6003  F84362  C8            		iny
3759
 6004  F84363  EB            		xba				; A = secondo digit
3760
 6005  F84364  99 86 02      	?04:	sta	!DP02ADDR+XCVTStr,y	; store secondo digit e seguenti
3761
 6006  F84367  C8            		iny
3762
 6007  F84368  B5 71         		lda	<FPUStr+1,x
3763
 6008  F8436A  F0 03         		beq	?05			; fine stringa digit
3764
 6009  F8436C  E8            		inx
3765
 6010  F8436D  D0 F5         		bne	?04
3766
 6011  F8436F
3767
 6012                        	?05:	; copiata la stringa di cifre significative -- ora si trimmano gli
3768
 6013                        		; '0' finali se formato G/g e no alt. form.
3769
 6014  F8436F  20 D6 43      		jsr	trimtrail		; se trim non effettua padding
3770
 6015  F84372  B0 19         		bcs	?50			; trim -> emette esponente
3771
 6016  F84374
3772
 6017                        		; padding della stringa con '0' finali -- nel formato E vengono
3773
 6018                        		; emessi al max. MAXINTDGTS digit significativi e la stringa
3774
 6019                        		; XCVTStr ha posto per XCVTMAXE char complessivi prima dell'esponente
3775
 6020  F84374  A5 0A         		lda	FmtPrec
3776
 6021  F84376  C9 28         		cmp	#XCVTMAXE+1
3777
 6022  F84378  90 02         		bcc	?05a
3778
 6023  F8437A  A9 27         		lda	#XCVTMAXE		; al massimo XCVTMAXE digit
3779
 6024  F8437C  38            	?05a:	sec
3780
 6025  F8437D  E9 14         		sbc	#MAXINTDGTS		; padding
3781
 6026  F8437F  F0 0C         		beq	?50			; no padding
3782
 6027  F84381  90 0A         		bcc	?50			; no padding
3783
  Tue Jul 17 11:00:16 2018                                                                                               Page   62
3784
 
3785
 
3786
 
3787
 
3788
 6028  F84383  AA            		tax				; X = numero padding
3789
 6029  F84384  A9 30         		lda	#'0'
3790
 6030  F84386  99 86 02      	?06:	sta	!DP02ADDR+XCVTStr,y
3791
 6031  F84389  C8            		iny
3792
 6032  F8438A  CA            		dex
3793
 6033  F8438B  D0 F9         		bne	?06
3794
 6034  F8438D
3795
 6035                        	?50:	; emette esponente decimale
3796
 6036  F8438D  A2 45         		ldx	#'E'
3797
 6037  F8438F  A9 08         		lda	#$08			; test CAPS ON
3798
 6038  F84391  24 16         		bit	XVFlag
3799
 6039  F84393  D0 02         		bne	?52			; CAPS ON
3800
 6040  F84395  A2 65         		ldx	#'e'
3801
 6041  F84397  8A            	?52:	txa
3802
 6042  F84398  99 86 02      		sta	!DP02ADDR+XCVTStr,y
3803
 6043  F8439B  C8            		iny
3804
 6044  F8439C  A2 2B         		ldx	#'+'			; assume esponente positivo
3805
 6045  F8439E                		ACC16
3806
 6046  F8439E  C2 20         		rep	#PMFLAG
3807
 6047                        		.LONGA	on
3808
 6048                        		.MNLIST
3809
 6049  F843A0  A5 14         		lda	XVDec
3810
 6050  F843A2  10 06         		bpl	?54
3811
 6051  F843A4  A2 2D         		ldx	#'-'			; esponente positivo
3812
 6052  F843A6  49 FF FF      		eor	#$FFFF			; complementa esponente
3813
 6053  F843A9  1A            		inc	a
3814
 6054  F843AA  85 32         	?54:	sta	FOP			; prepara per conversione
3815
 6055  F843AC  64 34         		stz	FOP+2
3816
 6056  F843AE  64 36         		stz	FOP+4
3817
 6057  F843B0  64 38         		stz	FOP+6
3818
 6058  F843B2                		ACC08
3819
 6059  F843B2  E2 20         		sep	#PMFLAG
3820
 6060                        		.LONGA	off
3821
 6061                        		.MNLIST
3822
 6062  F843B4  8A            		txa
3823
 6063  F843B5  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; segno esponente
3824
 6064  F843B8  C8            		iny
3825
 6065  F843B9  5A            		phy
3826
 6066  F843BA  20 6C 31      		jsr	_UI2Str			; X = ptr ultimo digit
3827
 6067  F843BD  7A            		ply
3828
 6068  F843BE  CA            		dex				; esponente sempre a 4 digit
3829
 6069  F843BF  CA            		dex
3830
 6070  F843C0  CA            		dex				; ptr al primo di 4 digits
3831
 6071  F843C1                		ACC16
3832
 6072  F843C1  C2 20         		rep	#PMFLAG
3833
 6073                        		.LONGA	on
3834
 6074                        		.MNLIST
3835
 6075  F843C3  B5 00         		lda	<0,x
3836
 6076  F843C5  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; prima coppia digit esponente
3837
 6077  F843C8  E8            		inx
3838
 6078  F843C9  E8            		inx
3839
 6079  F843CA  C8            		iny
3840
 6080  F843CB  C8            		iny
3841
 6081  F843CC  B5 00         		lda	<0,x
3842
 6082  F843CE  99 86 02      		sta	!DP02ADDR+XCVTStr,y	; seconda coppia digit esponente
3843
 6083  F843D1                		ACC08
3844
 6084  F843D1  E2 20         		sep	#PMFLAG
3845
  Tue Jul 17 11:00:16 2018                                                                                               Page   63
3846
 
3847
 
3848
 
3849
 
3850
 6085                        		.LONGA	off
3851
 6086                        		.MNLIST
3852
 6087  F843D3  C8            		iny
3853
 6088  F843D4  C8            		iny				; Y = lunghezza stringa
3854
 6089  F843D5  60            		rts
3855
 6090  F843D6
3856
 6091                        	; trim '0' finali della stringa  -- solo se formato G/g e no alt. form.
3857
 6092                        	; In	- Y = indice attuale stringa destinazione
3858
 6093                        	;	  FPIndx = indice primo digit
3859
 6094                        	; Out	- Y = nuovo indice attuale stringa dest
3860
 6095                        	;	  CF = 1 se stringa trimmata, altrimenti CF = 0
3861
 6096  F843D6                	trimtrail:
3862
 6097  F843D6  24 16         		bit	XVFlag			; <6> -> gormato G/g
3863
 6098  F843D8  50 19         		bvc	?10			; no trim: esce con C = 0
3864
 6099  F843DA  A9 10         		lda	#$10			; test formato alt #
3865
 6100  F843DC  24 16         		bit	XVFlag
3866
 6101  F843DE  D0 13         		bne	?10			; alt form: no trim, esce con C = 0
3867
 6102  F843E0  88            	?02:	dey				; ultimo digit valido
3868
 6103  F843E1  C4 3B         		cpy	FPIndx			; indice sul primo digit ?
3869
 6104  F843E3  F0 0B         		beq	?08			; SI -- non rimuove mai
3870
 6105  F843E5  B9 86 02      		lda	!DP02ADDR+XCVTStr,y
3871
 6106  F843E8  C9 30         		cmp	#'0'
3872
 6107  F843EA  F0 F4         		beq	?02			; loop digit precedente
3873
 6108  F843EC  C9 2E         		cmp	#'.'			; Trim eventuale '.'
3874
 6109  F843EE  F0 01         		beq	?09
3875
 6110  F843F0  C8            	?08:	iny				; indice disponibile successivo
3876
 6111  F843F1  38            	?09:	sec				; trim
3877
 6112  F843F2  60            		rts
3878
 6113  F843F3  18            	?10:	clc				; no trim
3879
 6114  F843F4  60            		rts
3880
 6115
3881
 6116                        	; converte float in formato a/A
3882
 6117  F843F5                	aform:
3883
 6118  F843F5  86 0A         		stx	FmtPrec			; se = 0 stampa mantissa ordinaria
3884
 6119  F843F7  A2 06         		ldx	#$06			; valore da aggiungere per digit A..F
3885
 6120  F843F9  89 08         		bit	#$08
3886
 6121  F843FB  D0 02         		bne	?02			; HI CAPS
3887
 6122  F843FD  A2 26         		ldx	#$26			; valore da aggiungere per digit a..f
3888
 6123  F843FF  86 24         	?02:	stx	FPTmp1
3889
 6124  F84401  A5 40         		lda	FACSGN
3890
 6125  F84403  29 80         		and	#$80			; segno FAC
3891
 6126  F84405  05 16         		ora	XVFlag
3892
 6127  F84407  85 16         		sta	XVFlag
3893
 6128  F84409  20 43 42      		jsr	storesgn		; store segno in XCVTStr
3894
 6129  F8440C  A9 24         		lda	#'$'
3895
 6130  F8440E  99 86 02      		STA	!DP02ADDR+XCVTStr,Y
3896
 6131  F84411  C8            		INY
3897
 6132  F84412  A2 07         		ldx	#$07			; loop 8 bytes
3898
 6133  F84414  B5 42         	?10:	lda	<FACM,x
3899
 6134  F84416  20 1E 32      		jsr	Byte2Hex
3900
 6135  F84419  99 86 02      		STA	!DP02ADDR+XCVTStr,Y	; nibble H
3901
 6136  F8441C  C8            		INY
3902
 6137  F8441D  EB            		xba				; nibble L
3903
 6138  F8441E  99 86 02      		STA	!DP02ADDR+XCVTStr,Y
3904
 6139  F84421  C8            		INY
3905
 6140  F84422  CA            		DEX
3906
 6141  F84423  10 EF         		BPL	?10
3907
  Tue Jul 17 11:00:16 2018                                                                                               Page   64
3908
 
3909
 
3910
 
3911
 
3912
 6142  F84425  A2 70         		ldx	#'p'
3913
 6143  F84427  A9 08         		lda	#$08
3914
 6144  F84429  24 16         		bit	XVFlag
3915
 6145  F8442B  F0 02         		beq	?14
3916
 6146  F8442D  A2 50         		ldx	#'P'
3917
 6147  F8442F  8A            	?14:	txa
3918
 6148  F84430  99 86 02      		STA	!DP02ADDR+XCVTStr,Y
3919
 6149  F84433  C8            		INY
3920
 6150  F84434  64 25         		stz	FPTmp2
3921
 6151  F84436  64 26         		stz	FPTmp3
3922
 6152  F84438                		ACC16
3923
 6153  F84438  C2 20         		rep	#PMFLAG
3924
 6154                        		.LONGA	on
3925
 6155                        		.MNLIST
3926
 6156  F8443A  A5 4A         		lda	FACExp
3927
 6157  F8443C  85 14         		sta	XVDec
3928
 6158  F8443E  C9 FF 7F      		cmp	#EXPINF
3929
 6159  F84441                		ACC08
3930
 6160  F84441  E2 20         		sep	#PMFLAG
3931
 6161                        		.LONGA	off
3932
 6162                        		.MNLIST
3933
 6163  F84443  B0 33         		bcs	?26
3934
 6164  F84445  A5 16         		lda	XVFlag
3935
 6165  F84447  89 10         		bit	#$10
3936
 6166  F84449  F0 05         		beq	?20
3937
 6167  F8444B  38            		sec
3938
 6168  F8444C  A9 80         		lda	#$80
3939
 6169  F8444E  85 25         		sta	FPTmp2
3940
 6170  F84450                	?20:	ACC16
3941
 6171  F84450  C2 20         		rep	#PMFLAG
3942
 6172                        		.LONGA	on
3943
 6173                        		.MNLIST
3944
 6174  F84452  A5 4A         		lda	FACExp
3945
 6175  F84454  90 0E         		bcc	?22
3946
 6176  F84456  A2 00         		ldx	#0
3947
 6177  F84458  E9 FF 3F      		sbc	#EXPBIAS
3948
 6178  F8445B  B0 05         		bcs	?21			; positivo
3949
 6179  F8445D  49 FF FF      		eor	#$FFFF
3950
 6180  F84460  1A            		inc	a
3951
 6181  F84461  CA            		dex				; negativo
3952
 6182  F84462  86 26         	?21:	stx	FPTmp3
3953
 6183  F84464  85 14         	?22:	sta	XVDec
3954
 6184  F84466                		ACC08
3955
 6185  F84466  E2 20         		sep	#PMFLAG
3956
 6186                        		.LONGA	off
3957
 6187                        		.MNLIST
3958
 6188  F84468  24 25         		bit	FPTmp2
3959
 6189  F8446A  10 0C         		bpl	?26
3960
 6190  F8446C  A9 2B         		lda	#'+'
3961
 6191  F8446E  24 26         		bit	FPTmp3
3962
 6192  F84470  10 02         		bpl	?24
3963
 6193  F84472  A9 2D         		lda	#'-'
3964
 6194  F84474  99 86 02      	?24:	STA	!DP02ADDR+XCVTStr,Y
3965
 6195  F84477  C8            		INY
3966
 6196  F84478  A2 01         	?26:	ldx	#$01
3967
 6197  F8447A  B5 14         	?28:	lda	<XVDec,x
3968
 6198  F8447C  20 1E 32      		jsr	Byte2Hex
3969
  Tue Jul 17 11:00:16 2018                                                                                               Page   65
3970
 
3971
 
3972
 
3973
 
3974
 6199  F8447F  99 86 02      		STA	!DP02ADDR+XCVTStr,Y	; nibble H
3975
 6200  F84482  C8            		INY
3976
 6201  F84483  EB            		xba				; nibble L
3977
 6202  F84484  99 86 02      		STA	!DP02ADDR+XCVTStr,Y
3978
 6203  F84487  C8            		INY
3979
 6204  F84488  CA            		DEX
3980
 6205  F84489  10 EF         		BPL	?28
3981
 6206  F8448B  A9 00         		lda	#$00
3982
 6207  F8448D  99 86 02      		STA	!DP02ADDR+XCVTStr,Y
3983
 6208  F84490  98            		tya
3984
 6209  F84491  A2 86         		ldx	#XCVTStr
3985
 6210  F84493  60            		rts
3986
 6211
3987
 6212                        	;-------------------------------------------------------------
3988
 6213                        	; COSTANTI IN VIRGOLA MOBILE
3989
 6214                        	;-------------------------------------------------------------
3990
 6215
3991
 6216                        	;FCon05:	.BYTE	$3F,$FE,$80,$00,$00,$00,$00,$00,$00,$00	; 0.5
3992
 6217                        	;FConM05:	.BYTE	$BF,$FE,$80,$00,$00,$00,$00,$00,$00,$00	; -0.5
3993
 6218  F84494  00 00 40 76 3A 	FCon1E18	.DB	$00,$00,$40,$76,$3A,$6B,$0B,$DE,$3A,$40	; 1E18
3994
               6B 0B DE 3A 40
3995
 6219  F8449E  00 00 E8 89 04 	FCon1E19	.DB	$00,$00,$E8,$89,$04,$23,$C7,$8A,$3E,$40	; 1E19
3996
               23 C7 8A 3E 40
3997
 6220
3998
 6221                        	;FConINF:	.BYTE	$7F,$FF,$80,$00,$00,$00,$00,$00,$00,$00	; +INF
3999
 6222                        	;FConNAN:	.BYTE	$7F,$FF,$FF,$00,$00,$00,$00,$00,$00,$00	; +NAN
4000
 6223
4001
 6224  F844A8  00 00 00 00 00 	FCon1E0:	.DB	$00,$00,$00,$00,$00,$00,$00,$80,$FF,$3F	; 1
4002
               00 00 80 FF 3F
4003
 6225  F844B2  00 00 00 00 00 	FCon1E1:	.DB	$00,$00,$00,$00,$00,$00,$00,$A0,$02,$40	; 10
4004
               00 00 A0 02 40
4005
 6226  F844BC  00 00 00 00 00 	FCon1E2:	.DB	$00,$00,$00,$00,$00,$00,$00,$C8,$05,$40	; 100
4006
               00 00 C8 05 40
4007
 6227  F844C6  00 00 00 00 00 	FCon1E3:	.DB	$00,$00,$00,$00,$00,$00,$00,$FA,$08,$40 ; 1E3
4008
               00 00 FA 08 40
4009
 6228  F844D0  00 00 00 00 00 	FCon1E4:	.DB	$00,$00,$00,$00,$00,$00,$40,$9C,$0C,$40	; 1E4
4010
               00 40 9C 0C 40
4011
 6229  F844DA  00 00 00 00 00 	FCon1E5:	.DB	$00,$00,$00,$00,$00,$00,$50,$C3,$0F,$40	; 1E5
4012
               00 50 C3 0F 40
4013
 6230  F844E4  00 00 00 00 00 	FCon1E6:	.DB	$00,$00,$00,$00,$00,$00,$24,$F4,$12,$40	; 1E6
4014
               00 24 F4 12 40
4015
 6231  F844EE  00 00 00 00 00 	FCon1E7:	.DB	$00,$00,$00,$00,$00,$80,$96,$98,$16,$40	; 1E7
4016
               80 96 98 16 40
4017
 6232  F844F8  00 00 00 00 00 	FCon1E8:	.DB	$00,$00,$00,$00,$00,$20,$BC,$BE,$19,$40	; 1E8
4018
               20 BC BE 19 40
4019
 6233  F84502  00 00 00 04 BF 	FCon1E16:	.DB	$00,$00,$00,$04,$BF,$C9,$1B,$8E,$34,$40	; 1E16
4020
               C9 1B 8E 34 40
4021
 6234  F8450C  9E B5 70 2B A8 	FCon1E32:	.DB	$9E,$B5,$70,$2B,$A8,$AD,$C5,$9D,$69,$40	; 1E32
4022
               AD C5 9D 69 40
4023
 6235  F84516  D5 A6 CF FF 49 	FCon1E64:	.DB	$D5,$A6,$CF,$FF,$49,$1F,$78,$C2,$D3,$40	; 1E64
4024
               1F 78 C2 D3 40
4025
 6236  F84520  DF 8C E9 80 C9 	FCon1E128:	.DB	$DF,$8C,$E9,$80,$C9,$47,$BA,$93,$A8,$41	; 1E128
4026
               47 BA 93 A8 41
4027
 6237  F8452A  8C DE F9 9D FB 	FCon1E256:	.DB	$8C,$DE,$F9,$9D,$FB,$EB,$7E,$AA,$51,$43	; 1E256
4028
               EB 7E AA 51 43
4029
 6238  F84534  C2 91 0E A6 AE 	FCon1E512:	.DB	$C2,$91,$0E,$A6,$AE,$A0,$19,$E3,$A3,$46	; 1E512
4030
               A0 19 E3 A3 46
4031
  Tue Jul 17 11:00:16 2018                                                                                               Page   66
4032
 
4033
 
4034
 
4035
 
4036
 6239  F8453E  0F 0C 75 81 86 	FCon1E1024:	.DB	$0F,$0C,$75,$81,$86,$75,$76,$C9,$48,$4D	; 1E1024
4037
               75 76 C9 48 4D
4038
 6240  F84548  D7 5D 3D C5 5D 	FCon1E2048:	.DB	$D7,$5D,$3D,$C5,$5D,$3B,$8B,$9E,$92,$5A	; 1E2048
4039
               3B 8B 9E 92 5A
4040
 6241  F84552  79 97 20 8A 02 	FCon1E4096:	.DB	$79,$97,$20,$8A,$02,$52,$60,$C4,$25,$75	; 1E4096
4041
               52 60 C4 25 75
4042
 6242
4043
 6243                        	; -----------------------------------------------------
4044
 6244                        	;static  const   extend  e128  = {0x8CE0, 0x80E9, 0x47C9, 0x93BA, 0x41A8}; +1
4045
 6245                        	;static  const   extend  e256  = {0xDE8E, 0x9DF9, 0xEBFB, 0xAA7E, 0x4351}; +2
4046
 6246                        	;static  const   extend  e512  = {0x91C7, 0xA60E, 0xA0AE, 0xE319, 0x46A3}; +5
4047
 6247                        	;static  const   extend  e1024 = {0x0C17, 0x8175, 0x7586, 0xC976, 0x4D48}; +8
4048
 6248                        	;static  const   extend  e2048 = {0x5DE5, 0xC53D, 0x3B5D, 0x9E8B, 0x5A92}; +14
4049
 6249                        	;static  const   extend  e4096 = {0x979B, 0x8A20, 0x5202, 0xC460, 0x7525}; +34
4050
 6250
4051
 
4052
 
4053
             Lines Assembled : 5850                  Errors : 0
4054
 
4055
 
4056