Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | - | 1 | Tue Jul 17 11:00:17 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\vprint.asm |
||
13 | Output Filename : obj\F8\vprint.obj |
||
14 | Listing Has Been Relocated |
||
15 | |||
16 | |||
17 | 2642 .LIST on |
||
18 | 2643 |
||
19 | 2644 F8FFB1 .INCLUDE inc\dirp02.inc |
||
20 | 2645 ;---------------------------------------------------------- |
||
21 | 2646 ; DIRP02.ASM |
||
22 | 2647 ; PROGETTO: B1601 |
||
23 | 2648 ; |
||
24 | 2649 ; Variabili in Direct Page $02 |
||
25 | 2650 ;---------------------------------------------------------- |
||
26 | 2651 |
||
27 | 2652 ; sezione COMMON -- questo permette di includere il file in piu' file |
||
28 | 2653 |
||
29 | 2654 DIRP02: .SECTION page0, ref_only, common ;Direct-Page 02 |
||
30 | 2655 |
||
31 | 2656 000000 .ABSOLUTE ;; inizia sempre da $00 |
||
32 | 2657 000000 .ORG 0x00 |
||
33 | 2658 000000 |
||
34 | 2659 ; variabili usate nella funzione _vprintl e famiglia funzioni di formattazione |
||
35 | 2660 000000 0000 FmtParm .DW ;; ptr array parametri banco 0 |
||
36 | 2661 000002 FmtLPFmt LP ;; long ptr stringa szFmt |
||
37 | 2662 000005 FmtLPPut LP ;; long ptr funzione 'putter' |
||
38 | 2663 000008 00 FmtSpec .DB ;; indice '%' corrente in szFmt |
||
39 | 2664 000009 00 FmtWidth .DB ;; campo width |
||
40 | 2665 00000A 00 FmtPrec .DB ;; campo precision |
||
41 | 2666 00000B 00 FmtFlag .DB ;; flag formattazione |
||
42 | 2667 00000C 00 FmtSgn .DB ;; segno positivo (se 0 -> no segno) |
||
43 | 2668 00000D 00 VStoreF .DB ;; flag modo store |
||
44 | 2669 00000E 00 FmtMod .DB ;; flag modificatori |
||
45 | 2670 00000F 00 FmtDst .DB ;; ptr stringa szDst banco 0 |
||
46 | 2671 |
||
47 | 2672 000010 0000 FmtCnt .DW ;; contatore caratteri |
||
48 | 2673 000012 0000 FmtGMax .DW ;; max. len stringa globale |
||
49 | 2674 000014 |
||
50 | 2675 000014 0000 XVDec .DW ; esponente decimale (signed) |
||
51 | 2676 000016 00 XVFlag .DB ; flag per conversioni numeriche |
||
52 | 2677 000017 |
||
53 | 2678 000017 00 ACMCmps .DB ; flag compare segno e tipo (intero) |
||
54 | 2679 |
||
55 | 2680 000018 ACM DQ ; accumulatore #1 integer 64 bit |
||
56 | 2681 000020 00 ACMSize .DB ; size |
||
57 | 2682 000021 00 ACMSgn .DB ; <7>:segno, <6>:tipo signed |
||
58 | 2683 000022 00 ACMMinSize .DB ; minima dimensione richiesta per ACM |
||
59 | 2684 000023 00 IARGMinSize .DB |
||
60 | 2685 |
||
61 | 2686 000024 00 FPTmp1 .DB ; byte temporaneo |
||
62 | 2687 000025 00 FPTmp2 .DB ; byte temporaneo |
||
63 | Tue Jul 17 11:00:17 2018 Page 2 |
||
64 | |||
65 | |||
66 | |||
67 | |||
68 | 2688 000026 00 FPTmp3 .DB ; byte temporaneo |
||
69 | 2689 000027 00 FPTmp4 .DB ; byte temporaneo |
||
70 | 2690 |
||
71 | 2691 000028 IARG DQ ; accumulatore #2 integer 64 bit |
||
72 | 2692 000030 00 IARGSize .DB ; size |
||
73 | 2693 000031 00 IARGSgn .DB ; <7>:segno, <6>:tipo signed |
||
74 | 2694 |
||
75 | 2695 000032 FOP DS 9 ; temporaneo per FDIV/FMULT/integer MULT/DIV |
||
76 | 2696 ; conversione integer -> string |
||
77 | 2697 00003B 00 FPIndx .DB ; byte generico indice |
||
78 | 2698 00003C 0000 FPWTmp7 .DW ; word temporanea |
||
79 | 2699 00003E 0000 FPWTmp8 .DW ; word temporanea |
||
80 | 2700 |
||
81 | 2701 ; variabili temporanee sovrapposte a FOP |
||
82 | 2702 000036 FACXM .EQU FOP+4 ; byte temporaneo |
||
83 | 2703 000037 ARGXM .EQU FOP+5 ; byte temporaneo |
||
84 | 2704 000038 FPWTmp5 .EQU FOP+6 ; word temporanea |
||
85 | 2705 00003A FPTmp6 .EQU FOP+8 ; byte temporaneo |
||
86 | 2706 |
||
87 | 2707 ; Floating Point Accumulator #1 - FAC |
||
88 | 2708 000040 00 FACSGN .DB ; FAC mantissa sign |
||
89 | 2709 000041 00 FACEXT .DB ; FAC 8 bit extension (rounding) |
||
90 | 2710 000042 FACM DQ ; FAC Mantissa (64 bit) |
||
91 | 2711 00004A 0000 FACExp .DW ; FAC Exponent |
||
92 | 2712 00004A FACEXPL .EQU FACExp ; FAC Exponent Low |
||
93 | 2713 00004B FACEXPH .EQU FACExp+1 ; FAC Exponent Hi |
||
94 | 2714 |
||
95 | 2715 00004C 00 FACSCMP .DB ; Sign Comparison Result: FAC vs ARG |
||
96 | 2716 00004D 00 FACMlt .DB ; flag MULT |
||
97 | 2717 00004E 00 FACUndf .DB ; conteggio shift per underflow |
||
98 | 2718 00004F 00 FPDCnt .DB ; contatore per inserzione punto decimale |
||
99 | 2719 000050 |
||
100 | 2720 ; Floating Point Accumulator #2 - ARG |
||
101 | 2721 000050 00 ARGSGN .DB ; ARG mantissa sign |
||
102 | 2722 000051 00 ARGEXT .DB ; ARG 8 bit extension (rounding) |
||
103 | 2723 000052 ARGM DQ ; ARG Mantissa (64 bit) |
||
104 | 2724 00005A 0000 ARGExp .DW ; ARG Exponent |
||
105 | 2725 00005A ARGEXPL .EQU ARGExp ; ARG Exponent Low |
||
106 | 2726 00005B ARGEXPH .EQU ARGExp+1 ; ARG Exponent Hi |
||
107 | 2727 |
||
108 | 2728 ; numero bytes FAC |
||
109 | 2729 00000A FACSIZE .EQU (FACEXPH - FACEXT) |
||
110 | 2730 000008 MANTSIZE .EQU (FACSIZE - 2) |
||
111 | 2731 000040 FACMBITS .EQU (MANTSIZE * 8) |
||
112 | 2732 000041 FAC .EQU FACEXT |
||
113 | 2733 000051 ARG .EQU ARGEXT |
||
114 | 2734 |
||
115 | 2735 00005C 0000 FPWTmp .DW |
||
116 | 2736 00005E 0000 FPExp .DW ; esponente conversioni str/float |
||
117 | 2737 000060 FPLPtr LP ; long ptr operazioni move |
||
118 | 2738 000063 00 FPFlag .DB ; flag generico operazioni FPU |
||
119 | 2739 000064 FACTmp .DS 12 ; registro FAC temporaneo (con sgn ed ext) |
||
120 | 2740 |
||
121 | 2741 ; buffer per conversione da int/float a string (20 digit + 2) |
||
122 | 2742 000016 FPSTRSIZE .EQU 22 |
||
123 | 2743 000070 FPUStr .DS FPSTRSIZE |
||
124 | 2744 |
||
125 | Tue Jul 17 11:00:17 2018 Page 3 |
||
126 | |||
127 | |||
128 | |||
129 | |||
130 | 2745 ; buffer per formattazione int/float |
||
131 | 2746 000030 XFSTRSIZE .EQU 48 |
||
132 | 2747 000086 XCVTStr .DS XFSTRSIZE |
||
133 | 2748 0000B5 XCVTStrEnd .EQU ($ - 1) |
||
134 | 2749 |
||
135 | 2750 0000B6 DUMMY100 .DS 22 |
||
136 | 2751 |
||
137 | 2752 000060 PTR1 .EQU FPLPtr ; long ptr operazioni 'move' |
||
138 | 2753 000063 FPFLAG .EQU FPFlag |
||
139 | 2754 00004F FPDCNT .EQU FPDCnt |
||
140 | 2755 0000CC |
||
141 | 2756 0000CC .RELATIVE |
||
142 | 2757 |
||
143 | 2758 .ENDS |
||
144 | 2759 |
||
145 | 2760 FFFFB0 MAXMANTSHIFT .EQU (-(FACMBITS + 16)) ; max. shift divisione mant. |
||
146 | 2761 00002F XCVTMAXF .EQU (XFSTRSIZE - 1) ; max. caratteri formato F |
||
147 | 2762 000027 XCVTMAXE .EQU (XCVTMAXF - 8) ; max. caratteri formato E |
||
148 | 2763 00002E XCVTMAXI .EQU (XFSTRSIZE - 2) ; max. caratteri stringa int. |
||
149 | 2764 |
||
150 | 2765 F8FFB1 |
||
151 | 2766 |
||
152 | 2767 |
||
153 | 2768 000008 FMINPREC .EQU 8 ; minimum float precision (if unspecified) |
||
154 | 2769 000205 GLPPUT .EQU DP02ADDR+FmtLPPut ; long pointer to putter function |
||
155 | 2770 |
||
156 | 2771 F8FFB1 |
||
157 | 2772 ;---------------------------------------------------------- |
||
158 | 2773 |
||
159 | 2774 ; spec's class |
||
160 | 2775 000000 _dc .EQU 0 ;/* don't care */ |
||
161 | 2776 000001 _si .EQU 1 ;/* sign fill +/- */ |
||
162 | 2777 000002 _af .EQU 2 ;/* alternate form */ |
||
163 | 2778 000003 _ar .EQU 3 ;/* format (width or precision) by argument */ |
||
164 | 2779 000004 _lj .EQU 4 ;/* left justify */ |
||
165 | 2780 000005 _pr .EQU 5 ;/* precision */ |
||
166 | 2781 000006 _nu .EQU 6 ;/* numeral */ |
||
167 | 2782 000007 _lo .EQU 7 ;/* long */ |
||
168 | 2783 000008 _sh .EQU 8 ;/* short */ |
||
169 | 2784 000009 _SH .EQU 9 ;/* byte */ |
||
170 | 2785 00000A _fz .EQU 10 ;/* fill zeros */ |
||
171 | 2786 00000B _de .EQU 11 ;/* decimal */ |
||
172 | 2787 00000C _un .EQU 12 ;/* unsigned decimal */ |
||
173 | 2788 00000D _he .EQU 13 ;/* hexadecimal */ |
||
174 | 2789 00000E _pt .EQU 14 ;/* pointer */ |
||
175 | 2790 00000F _HE .EQU 15 ;/* HEXADECIMAL */ |
||
176 | 2791 000010 _PT .EQU 16 ;/* POINTER */ |
||
177 | 2792 000011 _ch .EQU 17 ;/* char */ |
||
178 | 2793 000012 _st .EQU 18 ;/* string */ |
||
179 | 2794 000013 _ff .EQU 19 ;/* float %f/F */ |
||
180 | 2795 000014 _fe .EQU 20 ;/* float %e */ |
||
181 | 2796 000015 _fg .EQU 21 ;/* float %g */ |
||
182 | 2797 000016 _FE .EQU 22 ;/* float %E */ |
||
183 | 2798 000017 _FG .EQU 23 ;/* float %G */ |
||
184 | 2799 000018 _tg .EQU 24 ;/* thousand group */ |
||
185 | 2800 000019 _bc .EQU 25 ;/* BCD float numbers */ |
||
186 | 2801 00001A _PS .EQU 26 ;/* pascal/basic string */ |
||
187 | Tue Jul 17 11:00:17 2018 Page 4 |
||
188 | |||
189 | |||
190 | |||
191 | |||
192 | 2802 00001B _xf .EQU 27 ;/* hex float */ |
||
193 | 2803 00001C _XF .EQU 28 ;/* HEX FLOAT */ |
||
194 | 2804 |
||
195 | 2805 ; FmtFlag flag |
||
196 | 2806 000080 F_ALTFMT .EQU $80 |
||
197 | 2807 000040 F_LEFTJ .EQU $40 |
||
198 | 2808 000020 F_FILLZ .EQU $20 |
||
199 | 2809 000010 F_GROUP .EQU $10 |
||
200 | 2810 000008 F_WIDTH .EQU $08 |
||
201 | 2811 000004 F_PREC .EQU $04 |
||
202 | 2812 |
||
203 | 2813 ; FmtMod modifier's flag |
||
204 | 2814 000080 F2_PSSTRING .EQU $80 |
||
205 | 2815 000040 F2_BCD .EQU $40 |
||
206 | 2816 000020 F2_LONG .EQU $20 |
||
207 | 2817 000010 F2_SHORT .EQU $10 |
||
208 | 2818 000008 F2_BYTE .EQU $08 |
||
209 | 2819 000004 F2_CAPS .EQU $04 |
||
210 | 2820 000001 F2_SIGNED .EQU $01 |
||
211 | 2821 |
||
212 | 2822 000078 MASKMOD .EQU (F2_LONG.OR.F2_SHORT.OR.F2_BYTE.OR.F2_BCD) |
||
213 | 2823 ; modifier mask '%c' |
||
214 | 2824 0000F8 MASKCHAR .EQU (MASKMOD.OR.F2_PSSTRING) |
||
215 | 2825 ; modifier mask '%s' |
||
216 | 2826 000078 MASKSTR .EQU (MASKMOD) |
||
217 | 2827 ; modifier mask '%p' |
||
218 | 2828 0000F8 MASKPTR .EQU (MASKCHAR) |
||
219 | 2829 ; modifier mask float numbers |
||
220 | 2830 0000B8 MASKFLOAT .EQU (F2_LONG.OR.F2_SHORT.OR.F2_BYTE.OR.F2_PSSTRING) |
||
221 | 2831 ; modifier mask integer |
||
222 | 2832 0000C0 MASKINTG .EQU (F2_BCD.OR.F2_PSSTRING) |
||
223 | 2833 |
||
224 | 2834 ; conversion function index |
||
225 | 2835 000000 T_CHAR .EQU 0 |
||
226 | 2836 000002 T_STR .EQU (1 * 2) |
||
227 | 2837 000004 T_PTR .EQU (2 * 2) |
||
228 | 2838 000006 T_INT .EQU (3 * 2) |
||
229 | 2839 000008 T_HEX .EQU (4 * 2) |
||
230 | 2840 00000A T_FLOAT .EQU (5 * 2) |
||
231 | 2841 |
||
232 | 2842 ; current stage while scan format |
||
233 | 2843 000000 FLAGSTAGE .EQU 0 |
||
234 | 2844 000001 FILLZSTAGE .EQU 1 |
||
235 | 2845 000002 WIDESTAGE .EQU 2 |
||
236 | 2846 000003 DOTSTAGE .EQU 3 |
||
237 | 2847 000004 PRECSTAGE .EQU 4 |
||
238 | 2848 000005 MODSTAGE .EQU 5 |
||
239 | 2849 |
||
240 | 2850 ; aux var's |
||
241 | 2851 00003C PADCHR .EQU FPWTmp7 ; char per padding ('0' o ' ') |
||
242 | 2852 00003D PFXCHR .EQU FPWTmp7+1 ; prefisso stringa (segno o '$') |
||
243 | 2853 00003E NPADL .EQU FPWTmp8 ; numero char padding a sinistra |
||
244 | 2854 00003F NPADR .EQU FPWTmp8+1 ; numero char padding a destra |
||
245 | 2855 00005C STRLEN .EQU FPWTmp ; lunghezza stringa da copiare |
||
246 | 2856 00005D PFXFLAG .EQU FPWTmp+1 ; flag prefix segno/'$' |
||
247 | 2857 000063 FMTTMP .EQU FPFlag ; temporaneo durante scanning formato |
||
248 | 2858 |
||
249 | Tue Jul 17 11:00:17 2018 Page 5 |
||
250 | |||
251 | |||
252 | |||
253 | |||
254 | 2859 |
||
255 | 2860 ;--------------------------------------------------------------------------- |
||
256 | 2861 ; code segment |
||
257 | 2862 ;--------------------------------------------------------------------------- |
||
258 | 2863 |
||
259 | 2864 .CODEF8 |
||
260 | 2865 .EXTERN _Int2Str, _feFAC2S, _MovMem2Fa |
||
261 | 2866 F82133 |
||
262 | 2867 .GLOBAL sys_bprintf, sys_bsprintf, sys_bsprintf2, sys_bvprintf |
||
263 | 2868 |
||
264 | 2869 ;--------------------------------------------------------------------------- |
||
265 | 2870 ; system call interface |
||
266 | 2871 ;--------------------------------------------------------------------------- |
||
267 | 2872 |
||
268 | 2873 ; _bprintf: format string and send to text default device,usually console |
||
269 | 2874 ; this function act like c-function printf() |
||
270 | 2875 ; |
||
271 | 2876 ; prototype: _bprintf(count, format, ...) |
||
272 | 2877 ; |
||
273 | 2878 ; count =bytes count of all passed param's (count too) |
||
274 | 2879 ; format =long pointer to format string |
||
275 | 2880 ; ... =param's list (like in format string) |
||
276 | 2881 ; |
||
277 | 2882 ; param's passed in reverse order in stack |
||
278 | 2883 ; |
||
279 | 2884 ; all register's are preserved |
||
280 | 2885 F82133 sys_bprintf: |
||
281 | 2886 F82133 A3 13 lda STKPRMS,s ; count bytes params |
||
282 | 2887 F82135 83 04 sta STKCNT,s |
||
283 | 2888 F82137 CPU16CLC ; 16 bit + CLC |
||
284 | 2889 F82137 C2 31 rep #(PMFLAG.OR.PXFLAG.OR.PCFLAG) |
||
285 | 2890 .LONGA on |
||
286 | 2891 .LONGI on |
||
287 | 2892 .MNLIST |
||
288 | 2893 F82139 3B tsc |
||
289 | 2894 F8213A 69 14 00 adc #STKPRMS+1 |
||
290 | 2895 F8213D AA tax ; frame stack parametri |
||
291 | 2896 F8213E A9 00 02 lda #DP02ADDR |
||
292 | 2897 F82141 5B tcd ; imposta DPR => pagina 02 |
||
293 | 2898 F82142 64 12 stz FmtGMax ; non usa stringa globale |
||
294 | 2899 F82144 64 05 stz FmtLPPut ; non usa putter globale |
||
295 | 2900 F82146 BD 00 00 lda !0,x ; carica puntatore stringa di formato |
||
296 | 2901 F82149 85 02 sta FmtLPFmt |
||
297 | 2902 F8214B E8 inx |
||
298 | 2903 F8214C E8 inx |
||
299 | 2904 F8214D ACC08 |
||
300 | 2905 F8214D E2 20 sep #PMFLAG |
||
301 | 2906 .LONGA off |
||
302 | 2907 .MNLIST |
||
303 | 2908 F8214F 64 07 stz FmtLPPut+2 ; non usa putter globale |
||
304 | 2909 F82151 BD 00 00 lda !0,x |
||
305 | 2910 F82154 85 04 sta FmtLPFmt+2 |
||
306 | 2911 F82156 E8 inx |
||
307 | 2912 F82157 86 00 stx FmtParm ; salva frame stack parametri |
||
308 | 2913 F82159 CPU08 |
||
309 | 2914 F82159 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
310 | 2915 .LONGA off |
||
311 | Tue Jul 17 11:00:17 2018 Page 6 |
||
312 | |||
313 | |||
314 | |||
315 | |||
316 | 2916 .LONGI off |
||
317 | 2917 .MNLIST |
||
318 | 2918 F8215B A9 80 lda #$80 ; call putter locale |
||
319 | 2919 F8215D 20 2E 22 jsr _vprinter |
||
320 | 2920 F82160 18 clc |
||
321 | 2921 F82161 6B rtl |
||
322 | 2922 |
||
323 | 2923 ; _bsprintf2: format string and put result in a local string |
||
324 | 2924 ; this function act like c-function sprintf() |
||
325 | 2925 ; |
||
326 | 2926 ; prototype: _bsprintf2(count, format, ...) |
||
327 | 2927 ; |
||
328 | 2928 ; count =bytes count of all passed param's (count too) |
||
329 | 2929 ; format =long pointer to format string |
||
330 | 2930 ; ... =param's list (like in format string) |
||
331 | 2931 ; |
||
332 | 2932 ; param's passed in reverse order in stack |
||
333 | 2933 ; |
||
334 | 2934 ; out: C =offset of result local string |
||
335 | 2935 ; X =bank that hold result local string |
||
336 | 2936 ; |
||
337 | 2937 ; local string is limited to 255 bytes |
||
338 | 2938 F82162 sys_bsprintf2: |
||
339 | 2939 F82162 A3 13 lda STKPRMS,s ; count bytes params |
||
340 | 2940 F82164 83 04 sta STKCNT,s |
||
341 | 2941 F82166 CPU16CLC ; 16 bit + CLC |
||
342 | 2942 F82166 C2 31 rep #(PMFLAG.OR.PXFLAG.OR.PCFLAG) |
||
343 | 2943 .LONGA on |
||
344 | 2944 .LONGI on |
||
345 | 2945 .MNLIST |
||
346 | 2946 F82168 3B tsc |
||
347 | 2947 F82169 69 14 00 adc #STKPRMS+1 |
||
348 | 2948 F8216C AA tax ; frame stack parametri |
||
349 | 2949 F8216D A9 00 02 lda #DP02ADDR |
||
350 | 2950 F82170 5B tcd ; imposta DPR => pagina 02 |
||
351 | 2951 F82171 64 12 stz FmtGMax ; non usa stringa globale |
||
352 | 2952 F82173 64 05 stz FmtLPPut ; non usa putter globale |
||
353 | 2953 F82175 BD 00 00 lda !0,x ; carica puntatore stringa di formato |
||
354 | 2954 F82178 85 02 sta FmtLPFmt |
||
355 | 2955 F8217A E8 inx |
||
356 | 2956 F8217B E8 inx |
||
357 | 2957 F8217C ACC08 |
||
358 | 2958 F8217C E2 20 sep #PMFLAG |
||
359 | 2959 .LONGA off |
||
360 | 2960 .MNLIST |
||
361 | 2961 F8217E 64 07 stz FmtLPPut+2 ; non usa putter globale |
||
362 | 2962 F82180 BD 00 00 lda !0,x |
||
363 | 2963 F82183 85 04 sta FmtLPFmt+2 |
||
364 | 2964 F82185 E8 inx |
||
365 | 2965 F82186 86 00 stx FmtParm ; salva frame stack parametri |
||
366 | 2966 F82188 CPU08 |
||
367 | 2967 F82188 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
368 | 2968 .LONGA off |
||
369 | 2969 .LONGI off |
||
370 | 2970 .MNLIST |
||
371 | 2971 F8218A A9 00 lda #$00 ; local string |
||
372 | 2972 F8218C 20 2E 22 jsr _vprinter |
||
373 | Tue Jul 17 11:00:17 2018 Page 7 |
||
374 | |||
375 | |||
376 | |||
377 | |||
378 | 2973 F8218F ACC16 |
||
379 | 2974 F8218F C2 20 rep #PMFLAG |
||
380 | 2975 .LONGA on |
||
381 | 2976 .MNLIST |
||
382 | 2977 F82191 A9 00 E0 lda #LVPBUF ; buffer locale |
||
383 | 2978 F82194 83 0D sta STKCR,s |
||
384 | 2979 F82196 A9 00 00 lda #^LVPBUF |
||
385 | 2980 F82199 83 0B sta STKXR,s |
||
386 | 2981 F8219B ACC08 |
||
387 | 2982 F8219B E2 20 sep #PMFLAG |
||
388 | 2983 .LONGA off |
||
389 | 2984 .MNLIST |
||
390 | 2985 F8219D 18 clc |
||
391 | 2986 F8219E 6B rtl |
||
392 | 2987 |
||
393 | 2988 ; _bsprintf: format string and put result in a global string |
||
394 | 2989 ; this function act like c-function sprintf() |
||
395 | 2990 ; |
||
396 | 2991 ; prototype: _bsprintf(count, format, dest, size, ...) |
||
397 | 2992 ; |
||
398 | 2993 ; count =bytes count of all passed param's (count too) |
||
399 | 2994 ; format =long pointer to format string |
||
400 | 2995 ; dest =long pointer to destination string |
||
401 | 2996 ; size = size of destination buffer |
||
402 | 2997 ; ... =param's list (like in format string) |
||
403 | 2998 ; |
||
404 | 2999 ; param's passed in reverse order in stack |
||
405 | 3000 ; |
||
406 | 3001 ; out: C =count of bytes needs for destination string not |
||
407 | 3002 ; including the #0 terminator |
||
408 | 3003 ; |
||
409 | 3004 ; if dest=NULL, function just compute the needs number of bytes |
||
410 | 3005 ; dest must have room at least for C+1 bytes |
||
411 | 3006 F8219F sys_bsprintf: |
||
412 | 3007 F8219F A3 13 lda STKPRMS,s ; count bytes params |
||
413 | 3008 F821A1 83 04 sta STKCNT,s |
||
414 | 3009 F821A3 CPU16CLC ; 16 bit + CLC |
||
415 | 3010 F821A3 C2 31 rep #(PMFLAG.OR.PXFLAG.OR.PCFLAG) |
||
416 | 3011 .LONGA on |
||
417 | 3012 .LONGI on |
||
418 | 3013 .MNLIST |
||
419 | 3014 F821A5 3B tsc |
||
420 | 3015 F821A6 69 14 00 adc #STKPRMS+1 |
||
421 | 3016 F821A9 AA tax ; frame stack parametri |
||
422 | 3017 F821AA A9 00 02 lda #DP02ADDR |
||
423 | 3018 F821AD 5B tcd ; imposta DPR => pagina 02 |
||
424 | 3019 F821AE BD 00 00 lda !0,x ; carica puntatore stringa di formato |
||
425 | 3020 F821B1 85 02 sta FmtLPFmt |
||
426 | 3021 F821B3 E8 inx |
||
427 | 3022 F821B4 E8 inx |
||
428 | 3023 F821B5 ACC08 |
||
429 | 3024 F821B5 E2 20 sep #PMFLAG |
||
430 | 3025 .LONGA off |
||
431 | 3026 .MNLIST |
||
432 | 3027 F821B7 BD 00 00 lda !0,x |
||
433 | 3028 F821BA 85 04 sta FmtLPFmt+2 |
||
434 | 3029 F821BC E8 inx |
||
435 | Tue Jul 17 11:00:17 2018 Page 8 |
||
436 | |||
437 | |||
438 | |||
439 | |||
440 | 3030 F821BD ACC16 |
||
441 | 3031 F821BD C2 20 rep #PMFLAG |
||
442 | 3032 .LONGA on |
||
443 | 3033 .MNLIST |
||
444 | 3034 F821BF BD 00 00 lda !0,x ; carica puntatore stringa destinazione |
||
445 | 3035 F821C2 85 05 sta FmtLPPut |
||
446 | 3036 F821C4 E8 inx |
||
447 | 3037 F821C5 E8 inx |
||
448 | 3038 F821C6 ACC08 |
||
449 | 3039 F821C6 E2 20 sep #PMFLAG |
||
450 | 3040 .LONGA off |
||
451 | 3041 .MNLIST |
||
452 | 3042 F821C8 BD 00 00 lda !0,x |
||
453 | 3043 F821CB 85 07 sta FmtLPPut+2 |
||
454 | 3044 F821CD E8 inx |
||
455 | 3045 F821CE ACC16 |
||
456 | 3046 F821CE C2 20 rep #PMFLAG |
||
457 | 3047 .LONGA on |
||
458 | 3048 .MNLIST |
||
459 | 3049 F821D0 BD 00 00 lda !0,x |
||
460 | 3050 F821D3 85 12 sta FmtGMax ; carica size stringa destinazione |
||
461 | 3051 F821D5 E8 inx |
||
462 | 3052 F821D6 E8 inx |
||
463 | 3053 F821D7 86 00 stx FmtParm ; salva frame stack parametri |
||
464 | 3054 F821D9 CPU08 |
||
465 | 3055 F821D9 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
466 | 3056 .LONGA off |
||
467 | 3057 .LONGI off |
||
468 | 3058 .MNLIST |
||
469 | 3059 F821DB A9 40 lda #$40 ; stringa globale |
||
470 | 3060 F821DD 20 2E 22 jsr _vprinter |
||
471 | 3061 F821E0 ACC16 |
||
472 | 3062 F821E0 C2 20 rep #PMFLAG |
||
473 | 3063 .LONGA on |
||
474 | 3064 .MNLIST |
||
475 | 3065 F821E2 A5 10 lda FmtCnt ; numero caratteri |
||
476 | 3066 F821E4 83 0D sta STKCR,s |
||
477 | 3067 F821E6 ACC08 |
||
478 | 3068 F821E6 E2 20 sep #PMFLAG |
||
479 | 3069 .LONGA off |
||
480 | 3070 .MNLIST |
||
481 | 3071 F821E8 18 clc |
||
482 | 3072 F821E9 6B rtl |
||
483 | 3073 |
||
484 | 3074 ; _bvprintf: format string and send result to an user-defined "putter" |
||
485 | 3075 ; function; this function act like c-function fprintf() |
||
486 | 3076 ; |
||
487 | 3077 ; prototype: _bvprintf(count, format, putter...) |
||
488 | 3078 ; |
||
489 | 3079 ; count =bytes count of all passed param's (count too) |
||
490 | 3080 ; format =long pointer to format string |
||
491 | 3081 ; putter =long pointer to user-dfined putter function |
||
492 | 3082 ; ... =param's list (like in format string) |
||
493 | 3083 ; |
||
494 | 3084 ; param's passed in reverse order in stack |
||
495 | 3085 ; |
||
496 | 3086 ; out: C =count of bytes needs sent to user-defined putter, not |
||
497 | Tue Jul 17 11:00:17 2018 Page 9 |
||
498 | |||
499 | |||
500 | |||
501 | |||
502 | 3087 ; including the #0 terminator |
||
503 | 3088 ; |
||
504 | 3089 ; the user-defined putter will end with an "rtl" instruction |
||
505 | 3090 F821EA sys_bvprintf: |
||
506 | 3091 F821EA A3 13 lda STKPRMS,s ; count bytes params |
||
507 | 3092 F821EC 83 04 sta STKCNT,s |
||
508 | 3093 F821EE CPU16CLC ; 16 bit + CLC |
||
509 | 3094 F821EE C2 31 rep #(PMFLAG.OR.PXFLAG.OR.PCFLAG) |
||
510 | 3095 .LONGA on |
||
511 | 3096 .LONGI on |
||
512 | 3097 .MNLIST |
||
513 | 3098 F821F0 3B tsc |
||
514 | 3099 F821F1 69 14 00 adc #STKPRMS+1 |
||
515 | 3100 F821F4 AA tax ; frame stack parametri |
||
516 | 3101 F821F5 A9 00 02 lda #DP02ADDR |
||
517 | 3102 F821F8 5B tcd ; imposta DPR => pagina 02 |
||
518 | 3103 F821F9 64 12 stz FmtGMax |
||
519 | 3104 F821FB BD 00 00 lda !0,x ; carica puntatore stringa di formato |
||
520 | 3105 F821FE 85 02 sta FmtLPFmt |
||
521 | 3106 F82200 E8 inx |
||
522 | 3107 F82201 E8 inx |
||
523 | 3108 F82202 ACC08 |
||
524 | 3109 F82202 E2 20 sep #PMFLAG |
||
525 | 3110 .LONGA off |
||
526 | 3111 .MNLIST |
||
527 | 3112 F82204 BD 00 00 lda !0,x |
||
528 | 3113 F82207 85 04 sta FmtLPFmt+2 |
||
529 | 3114 F82209 E8 inx |
||
530 | 3115 F8220A ACC16 |
||
531 | 3116 F8220A C2 20 rep #PMFLAG |
||
532 | 3117 .LONGA on |
||
533 | 3118 .MNLIST |
||
534 | 3119 F8220C BD 00 00 lda !0,x ; carica puntatore stringa destinazione |
||
535 | 3120 F8220F 85 05 sta FmtLPPut |
||
536 | 3121 F82211 E8 inx |
||
537 | 3122 F82212 E8 inx |
||
538 | 3123 F82213 ACC08 |
||
539 | 3124 F82213 E2 20 sep #PMFLAG |
||
540 | 3125 .LONGA off |
||
541 | 3126 .MNLIST |
||
542 | 3127 F82215 BD 00 00 lda !0,x |
||
543 | 3128 F82218 85 07 sta FmtLPPut+2 |
||
544 | 3129 F8221A E8 inx |
||
545 | 3130 F8221B 86 00 stx FmtParm ; salva frame stack parametri |
||
546 | 3131 F8221D CPU08 |
||
547 | 3132 F8221D E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
548 | 3133 .LONGA off |
||
549 | 3134 .LONGI off |
||
550 | 3135 .MNLIST |
||
551 | 3136 F8221F A9 C0 lda #$C0 ; putter globale |
||
552 | 3137 F82221 20 2E 22 jsr _vprinter |
||
553 | 3138 F82224 ACC16 |
||
554 | 3139 F82224 C2 20 rep #PMFLAG |
||
555 | 3140 .LONGA on |
||
556 | 3141 .MNLIST |
||
557 | 3142 F82226 A5 10 lda FmtCnt ; numero caratteri |
||
558 | 3143 F82228 83 0D sta STKCR,s |
||
559 | Tue Jul 17 11:00:17 2018 Page 10 |
||
560 | |||
561 | |||
562 | |||
563 | |||
564 | 3144 F8222A ACC08 |
||
565 | 3145 F8222A E2 20 sep #PMFLAG |
||
566 | 3146 .LONGA off |
||
567 | 3147 .MNLIST |
||
568 | 3148 F8222C 18 clc |
||
569 | 3149 F8222D 6B rtl |
||
570 | 3150 |
||
571 | 3151 ; funzione locale di formattazione stringa |
||
572 | |||
573 | |||
574 | |||
575 | |||
576 | |||
577 | |||
578 | |||
579 | |||
580 | |||
581 | |||
582 | |||
583 | |||
584 | |||
585 | |||
586 | |||
587 | |||
588 | |||
589 | 3152 ; In - FmtLPFmt = long ptr stringa formato (szFmt) |
||
590 | 3153 ; FmtParm = ptr array parametri nel banco 0 |
||
591 | |||
592 | |||
593 | |||
594 | |||
595 | |||
596 | 3154 ; FmtLPPut = long ptr alla funzione 'putter' o a stringa globale |
||
597 | 3155 ; FmtGMax = max. lunghezza stringa globale (escluso NULL) |
||
598 | 3156 ; A => flag funzione <7> => 0 -> store stringa / 1 -> store putter |
||
599 | 3157 ; <6> => 0 -> locale / globale |
||
600 | 3158 ; DBR = 0 (banco 0) |
||
601 | 3159 ; DPR = 2 (pagina 02) |
||
602 | 3160 ; |
||
603 | 3161 ; Out - store locale => LVPBUF stringa formattata max. 255 car. (szDst) |
||
604 | 3162 ; store globale => stringa FmtLPPut formattata (max $FFFF car.) |
||
605 | 3163 ; putter locale => formattazione inviata al device TEXT corrente |
||
606 | 3164 ; putter globale => formattazione inviata a funzione putter |
||
607 | 3165 F8222E _vprinter: |
||
608 | 3166 .LONGA off |
||
609 | 3167 .LONGI off |
||
610 | 3168 F8222E |
||
611 | 3169 F8222E A0 00 ldy #0 ; azzera contatore caratteri |
||
612 | 3170 F82230 84 10 sty FmtCnt |
||
613 | 3171 F82232 84 11 sty FmtCnt+1 |
||
614 | 3172 F82234 84 0F sty FmtDst ; azzera indice stringa locale |
||
615 | 3173 F82236 85 0D sta VStoreF ; flag store |
||
616 | 3174 F82238 |
||
617 | 3175 ; LOOP scanning formato |
||
618 | 3176 F82238 B7 02 ?10: lda [FmtLPFmt],y ; next char |
||
619 | 3177 F8223A F0 57 beq ?60 ; fine stringa - EXIT |
||
620 | 3178 ;bne ?11 |
||
621 | Tue Jul 17 11:00:17 2018 Page 11 |
||
622 | |||
623 | |||
624 | |||
625 | |||
626 | 3179 ;jmp ?60 |
||
627 | 3180 F8223C C9 25 ?11: cmp #'%' |
||
628 | 3181 F8223E F0 06 beq ?14 ; specificatore formato |
||
629 | 3182 F82240 C8 ?12: iny ; ptr next char |
||
630 | 3183 F82241 20 09 23 jsr _store ; store char in szDst |
||
631 | 3184 F82244 80 F2 bra ?10 ; loop |
||
632 | 3185 F82246 84 08 ?14: sty FmtSpec ; indice carattere '%' (per ABANDON) |
||
633 | 3186 F82248 C8 iny |
||
634 | 3187 F82249 B7 02 lda [FmtLPFmt],y ; next char dopo specificatore |
||
635 | 3188 F8224B C9 25 cmp #'%' |
||
636 | 3189 F8224D F0 F1 beq ?12 ; '%%' -> store '%' e loop |
||
637 | 3190 |
||
638 | 3191 ; analizza specificatore di formato dopo '%' |
||
639 | 3192 F8224F A9 00 lda #0 ; A = stage = 0 (flag stage) |
||
640 | 3193 F82251 85 0C sta FmtSgn |
||
641 | 3194 F82253 85 0B sta FmtFlag |
||
642 | 3195 F82255 85 0E sta FmtMod |
||
643 | 3196 F82257 85 09 sta FmtWidth |
||
644 | 3197 F82259 85 0A sta FmtPrec |
||
645 | 3198 F8225B 80 01 bra ?21 ; reload |
||
646 | 3199 F8225D |
||
647 | 3200 ; LOOP scanning specificatore formato |
||
648 | 3201 F8225D C8 ?20: iny |
||
649 | 3202 |
||
650 | 3203 ; A = stage - Y = ptr corrente formato |
||
651 | 3204 F8225E EB ?21: xba ; B = stage |
||
652 | 3205 F8225F B7 02 lda [FmtLPFmt],y ; A = next char dopo specificatore |
||
653 | 3206 F82261 F0 24 beq ?50 ; fine stringa - ABANDON |
||
654 | 3207 F82263 85 63 sta FMTTMP ; salva char |
||
655 | 3208 F82265 38 sec |
||
656 | 3209 F82266 E9 20 sbc #' ' ; scala char to 0..5F |
||
657 | 3210 F82268 90 1D bcc ?50 ; char illegale a questo stadio |
||
658 | 3211 F8226A C9 60 cmp #(128 - ' ') |
||
659 | 3212 F8226C B0 19 bcs ?50 ; char illegale a questo stadio |
||
660 | 3213 F8226E AA tax ; X = indice 0..5F |
||
661 | 3214 F8226F BF 0E 27 F8 lda >CLASSCHR,x ; A = class char |
||
662 | 3215 F82273 0A asl a |
||
663 | 3216 F82274 AA tax ; indice funzione |
||
664 | 3217 F82275 A5 63 lda FMTTMP ; cur char |
||
665 | 3218 F82277 EB xba ; B = cur char, A = stage, ZF valido |
||
666 | 3219 F82278 FC 6E 27 jsr (SCANTBL,x) ; scanning formato |
||
667 | 3220 F8227B B0 0A ?20a: bcs ?50 ; errore formato - ABANDON |
||
668 | 3221 F8227D 50 DE bvc ?20 ; loop - scanning formato corrente |
||
669 | 3222 F8227F |
||
670 | 3223 ; a questo punto si assume che lo specificatore di formato sia stato |
||
671 | 3224 ; scannerizzato correttamente e che X contenga l'indice alla tabella |
||
672 | 3225 ; di conversione CVTTBL |
||
673 | 3226 F8227F 5A phy ; salva Y |
||
674 | 3227 F82280 FC A8 27 jsr (CVTTBL,x) ; funzione di conversione |
||
675 | 3228 F82283 7A ?20b: ply ; ripristina Y |
||
676 | 3229 F82284 C8 iny ; next char |
||
677 | 3230 F82285 80 B1 bra ?10 ; loop - next formato |
||
678 | 3231 F82287 |
||
679 | 3232 ; ABANDON - causa errore specificatore di formato si suppone che i |
||
680 | 3233 ; parametri non siano piu' allineati con il formato |
||
681 | 3234 ; viene quindi copiato letteralmente il resto di szFmt a partire |
||
682 | 3235 ; dal carattere '%' dove si e' verificato il disallineamento, fino |
||
683 | Tue Jul 17 11:00:17 2018 Page 12 |
||
684 | |||
685 | |||
686 | |||
687 | |||
688 | 3236 ; alla fine della stringa szFmt |
||
689 | 3237 F82287 A4 08 ?50: ldy FmtSpec ; indice al carattere '%' |
||
690 | 3238 F82289 B7 02 ?52: lda [FmtLPFmt],y ; copia da szFmt a szDst |
||
691 | 3239 F8228B F0 06 beq ?60 ; fino a fine stringa |
||
692 | 3240 F8228D C8 iny |
||
693 | 3241 F8228E 20 09 23 jsr _store |
||
694 | 3242 F82291 80 F6 bra ?52 |
||
695 | 3243 F82293 |
||
696 | 3244 ; EXIT |
||
697 | 3245 ; la funzione memorizza il terminatore #0 per indicare la fine |
||
698 | 3246 ; o chiama il putter per effettuare il flush del buffer |
||
699 | 3247 F82293 24 0D ?60: bit VStoreF |
||
700 | 3248 F82295 30 13 bmi ?64 ; chiama flusher locale/globale |
||
701 | 3249 F82297 70 06 bvs ?62 ; termina stringa globale |
||
702 | 3250 F82299 A6 0F ldx FmtDst ; indice stringa locale |
||
703 | 3251 F8229B 9E 00 E0 stz !LVPBUF,x ; store NULL at X = FmtDst |
||
704 | 3252 F8229E 60 rts |
||
705 | 3253 F8229F ?62: INDEX16 |
||
706 | 3254 F8229F C2 10 rep #PXFLAG |
||
707 | 3255 .LONGI on |
||
708 | 3256 .MNLIST |
||
709 | 3257 F822A1 A4 10 ldy FmtCnt |
||
710 | 3258 F822A3 A9 00 lda #0 |
||
711 | 3259 F822A5 97 05 sta [FmtLPPut],y ; store NULL in stringa globale |
||
712 | 3260 F822A7 INDEX08 |
||
713 | 3261 F822A7 E2 10 sep #PXFLAG |
||
714 | 3262 .LONGI off |
||
715 | 3263 .MNLIST |
||
716 | 3264 F822A9 60 rts |
||
717 | 3265 F822AA 50 04 ?64: bvc _lflush ; termina putter locale |
||
718 | 3266 F822AC A9 00 lda #0 ; termina putter globale |
||
719 | 3267 F822AE 80 16 bra _gput |
||
720 | 3268 F822B0 |
||
721 | 3269 ;---------------------------------------------------------------------------- |
||
722 | 3270 ; FUNZIONI STORE/FLUSH |
||
723 | 3271 ;---------------------------------------------------------------------------- |
||
724 | 3272 |
||
725 | 3273 ; termina putter locale |
||
726 | 3274 F822B0 _lflush: |
||
727 | 3275 F822B0 A6 0F ldx FmtDst ; indice attuale buffer locale |
||
728 | 3276 |
||
729 | 3277 ; invia buffer locale al device selezionato |
||
730 | 3278 F822B2 _lflush2: |
||
731 | 3279 F822B2 9E 00 E0 stz !LVPBUF,x ; termina stringa |
||
732 | 3280 F822B5 8A txa |
||
733 | 3281 F822B6 F0 0B beq ?02 ; buffer vuoto |
||
734 | 3282 F822B8 ACC16 |
||
735 | 3283 F822B8 C2 20 rep #PMFLAG |
||
736 | 3284 .LONGA on |
||
737 | 3285 .MNLIST |
||
738 | 3286 F822BA A9 00 E0 lda #LVPBUF ; CX = long ptr al buffer |
||
739 | 3287 F822BD ACC08 |
||
740 | 3288 F822BD E2 20 sep #PMFLAG |
||
741 | 3289 .LONGA off |
||
742 | 3290 .MNLIST |
||
743 | 3291 F822BF A2 00 ldx #0 ; banco 0 |
||
744 | 3292 F822C1 TXTSTROUT ; preserva A,X,Y |
||
745 | Tue Jul 17 11:00:17 2018 Page 13 |
||
746 | |||
747 | |||
748 | |||
749 | |||
750 | 3293 F822C1 02 04 cop $04 |
||
751 | 3294 .MNLIST |
||
752 | 3295 F822C3 60 ?02: rts |
||
753 | 3296 |
||
754 | 3297 ; funzione putter locale/globale |
||
755 | 3298 F822C4 _putter: |
||
756 | 3299 F822C4 50 2E bvc _lput ; putter locale |
||
757 | 3300 F822C6 |
||
758 | 3301 ; putter globale -- char NULL indica END-OF-FILE |
||
759 | 3302 F822C6 _gput: |
||
760 | 3303 F822C6 85 4F sta FPDCnt |
||
761 | 3304 F822C8 84 3B sty FPIndx |
||
762 | 3305 F822CA 4B phk |
||
763 | 3306 F822CB F4 EE 22 pea #?02-1 ; salva ind. return => ?02 |
||
764 | 3307 F822CE |
||
765 | 3308 F822CE 48 pha |
||
766 | 3309 F822CF ACC16 |
||
767 | 3310 F822CF C2 20 rep #PMFLAG |
||
768 | 3311 .LONGA on |
||
769 | 3312 .MNLIST |
||
770 | 3313 F822D1 AD 05 02 lda !GLPPUT |
||
771 | 3314 F822D4 8F E9 22 F8 sta >?04+1 |
||
772 | 3315 F822D8 ACC08 |
||
773 | 3316 F822D8 E2 20 sep #PMFLAG |
||
774 | 3317 .LONGA off |
||
775 | 3318 .MNLIST |
||
776 | 3319 F822DA AD 07 02 lda !GLPPUT+2 |
||
777 | 3320 F822DD 8F EB 22 F8 sta >?04+3 |
||
778 | 3321 F822E1 68 pla |
||
779 | 3322 F822E2 C9 00 cmp #0 |
||
780 | 3323 F822E4 D0 02 bne ?04 |
||
781 | 3324 F822E6 EA nop |
||
782 | 3325 F822E7 EA nop |
||
783 | 3326 F822E8 5C 00 FF 80 ?04: jml $80FF00 |
||
784 | 3327 F822EC |
||
785 | 3328 F822EC DC 05 02 jml [GLPPUT] ; deve terminare con RTL |
||
786 | 3329 F822EF A4 3B ?02: ldy FPIndx |
||
787 | 3330 F822F1 A5 4F lda FPDCnt |
||
788 | 3331 F822F3 60 rts |
||
789 | 3332 F822F4 |
||
790 | 3333 ; funzione putter locale |
||
791 | 3334 F822F4 _lput: |
||
792 | 3335 F822F4 20 15 23 jsr _lstor ; bufferizza in stringa locale |
||
793 | 3336 F822F7 D0 0F bne ?02 ; buffer non pieno |
||
794 | 3337 F822F9 85 4F sta FPDCnt ; salva char |
||
795 | 3338 F822FB 20 B2 22 jsr _lflush2 ; flush buffer |
||
796 | 3339 F822FE A2 00 ldx #0 |
||
797 | 3340 F82300 A5 4F lda FPDCnt ; memorizza char attuale |
||
798 | 3341 F82302 9D 00 E0 sta !LVPBUF,x ; store at X = 0 |
||
799 | 3342 F82305 E8 inx |
||
800 | 3343 F82306 86 0F stx FmtDst |
||
801 | 3344 F82308 60 ?02: rts |
||
802 | 3345 |
||
803 | 3346 ; store char in stringa locale/globale o invia carattere al 'putter' |
||
804 | 3347 F82309 _store: |
||
805 | 3348 F82309 ACC16 |
||
806 | 3349 F82309 C2 20 rep #PMFLAG |
||
807 | Tue Jul 17 11:00:17 2018 Page 14 |
||
808 | |||
809 | |||
810 | |||
811 | |||
812 | 3350 .LONGA on |
||
813 | 3351 .MNLIST |
||
814 | 3352 F8230B E6 10 inc FmtCnt ; update numero bytes (16 bit) |
||
815 | 3353 F8230D ACC08 |
||
816 | 3354 F8230D E2 20 sep #PMFLAG |
||
817 | 3355 .LONGA off |
||
818 | 3356 .MNLIST |
||
819 | 3357 F8230F 24 0D bit VStoreF |
||
820 | 3358 F82311 30 B1 bmi _putter ; chiama putter locale/globale |
||
821 | 3359 F82313 70 0D bvs _gstor ; store in stringa globale |
||
822 | 3360 |
||
823 | 3361 ; store char in stringa locale |
||
824 | 3362 F82315 _lstor: |
||
825 | 3363 F82315 A6 0F ldx FmtDst ; indice stringa locale |
||
826 | 3364 F82317 E0 FF cpx #$FF ; test overflow |
||
827 | 3365 F82319 F0 06 beq ?02 ; no store (FmtDst = $FF) |
||
828 | 3366 F8231B 9D 00 E0 sta !LVPBUF,x ; store at X = FmtDst |
||
829 | 3367 F8231E E8 inx |
||
830 | 3368 F8231F 86 0F stx FmtDst |
||
831 | 3369 F82321 60 ?02: rts |
||
832 | 3370 |
||
833 | 3371 ; store char in stringa globale |
||
834 | 3372 F82322 _gstor: |
||
835 | 3373 F82322 84 3B sty FPIndx ; salva Y |
||
836 | 3374 F82324 INDEX16 |
||
837 | 3375 F82324 C2 10 rep #PXFLAG |
||
838 | 3376 .LONGI on |
||
839 | 3377 .MNLIST |
||
840 | 3378 F82326 A4 10 ldy FmtCnt |
||
841 | 3379 F82328 88 dey ; indice attuale stringa globale |
||
842 | 3380 F82329 C4 12 cpy FmtGMax ; overflow stringa ? |
||
843 | 3381 F8232B B0 02 bcs ?02 ; si -- no store |
||
844 | 3382 F8232D 97 05 sta [FmtLPPut],y ; store in stringa globale |
||
845 | 3383 F8232F ?02: INDEX08 |
||
846 | 3384 F8232F E2 10 sep #PXFLAG |
||
847 | 3385 .LONGI off |
||
848 | 3386 .MNLIST |
||
849 | 3387 F82331 A4 3B ldy FPIndx |
||
850 | 3388 F82333 60 rts |
||
851 | 3389 |
||
852 | 3390 ;---------------------------------------------------------------------------- |
||
853 | 3391 ; FUNZIONI DI CONVERSIONE (FORMATTAZIONE) |
||
854 | 3392 ;---------------------------------------------------------------------------- |
||
855 | 3393 |
||
856 | 3394 ; preleva integer dai parametri e lo copia in ACM |
||
857 | 3395 F82334 getint: |
||
858 | 3396 F82334 A0 01 ldy #1 |
||
859 | 3397 F82336 A5 0E lda FmtMod |
||
860 | 3398 F82338 89 08 bit #F2_BYTE |
||
861 | 3399 F8233A D0 0D bne ?02 ; byte -> size = 1 |
||
862 | 3400 F8233C C8 iny |
||
863 | 3401 F8233D 89 10 bit #F2_SHORT |
||
864 | 3402 F8233F D0 08 bne ?02 ; word -> size = 2 |
||
865 | 3403 F82341 A0 08 ldy #8 |
||
866 | 3404 F82343 89 20 bit #F2_LONG |
||
867 | 3405 F82345 D0 02 bne ?02 ; quad -> size = 8 |
||
868 | 3406 F82347 A0 04 ldy #4 ; dword -> size = 4 |
||
869 | Tue Jul 17 11:00:17 2018 Page 15 |
||
870 | |||
871 | |||
872 | |||
873 | |||
874 | 3407 F82349 84 20 ?02: sty ACMSize ; size |
||
875 | 3408 F8234B 64 21 stz ACMSgn ; unsigned per il momento |
||
876 | 3409 F8234D INDEX16 |
||
877 | 3410 F8234D C2 10 rep #PXFLAG |
||
878 | 3411 .LONGI on |
||
879 | 3412 .MNLIST |
||
880 | 3413 F8234F A6 00 ldx FmtParm ; indice parametri |
||
881 | 3414 F82351 BD 00 00 lda !0,x ; get byte |
||
882 | 3415 F82354 85 18 sta <ACM |
||
883 | 3416 F82356 E8 inx |
||
884 | 3417 F82357 88 dey |
||
885 | 3418 F82358 F0 24 beq ?06 ; size = 1 (byte) |
||
886 | 3419 F8235A BD 00 00 lda !0,x ; get byte |
||
887 | 3420 F8235D 85 19 sta <ACM+1 |
||
888 | 3421 F8235F E8 inx |
||
889 | 3422 F82360 88 dey |
||
890 | 3423 F82361 F0 1B beq ?06 ; size = 2 (word) |
||
891 | 3424 F82363 ACC16 |
||
892 | 3425 F82363 C2 20 rep #PMFLAG |
||
893 | 3426 .LONGA on |
||
894 | 3427 .MNLIST |
||
895 | 3428 F82365 BD 00 00 lda !0,x ; get word |
||
896 | 3429 F82368 85 1A sta <ACM+2 |
||
897 | 3430 F8236A E8 inx |
||
898 | 3431 F8236B E8 inx |
||
899 | 3432 F8236C 88 dey |
||
900 | 3433 F8236D 88 dey |
||
901 | 3434 F8236E F0 0E beq ?06 ; size = 4 (dword) |
||
902 | 3435 F82370 BD 00 00 lda !0,x ; get word |
||
903 | 3436 F82373 85 1C sta <ACM+4 |
||
904 | 3437 F82375 E8 inx |
||
905 | 3438 F82376 E8 inx |
||
906 | 3439 F82377 BD 00 00 lda !0,x ; get word |
||
907 | 3440 F8237A 85 1E sta <ACM+6 ; size = 8 (quad) |
||
908 | 3441 F8237C E8 inx |
||
909 | 3442 F8237D E8 inx |
||
910 | 3443 F8237E 86 00 ?06: stx FmtParm ; aggiorna indice array parametri |
||
911 | 3444 F82380 CPU08 |
||
912 | 3445 F82380 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
913 | 3446 .LONGA off |
||
914 | 3447 .LONGI off |
||
915 | 3448 .MNLIST |
||
916 | 3449 F82382 60 rts |
||
917 | 3450 |
||
918 | 3451 F82383 DoFloat: |
||
919 | 3452 F82383 A5 0B lda FmtFlag |
||
920 | 3453 F82385 89 04 bit #F_PREC |
||
921 | 3454 F82387 D0 0C bne ?01 ; specificata la precision |
||
922 | 3455 F82389 A2 08 ldx #FMINPREC ; imposta minima precisione |
||
923 | 3456 F8238B A5 16 lda XVFlag |
||
924 | 3457 F8238D 89 04 bit #$04 |
||
925 | 3458 F8238F F0 02 beq ?00 ; no formato a/A |
||
926 | 3459 F82391 A2 00 ldx #0 ; minima precisone formato a/A = 0 |
||
927 | 3460 F82393 86 0A ?00: stx FmtPrec |
||
928 | 3461 F82395 A5 0E ?01: lda FmtMod |
||
929 | 3462 F82397 89 04 bit #F2_CAPS |
||
930 | 3463 F82399 F0 04 beq ?02 |
||
931 | Tue Jul 17 11:00:17 2018 Page 16 |
||
932 | |||
933 | |||
934 | |||
935 | |||
936 | 3464 F8239B A9 08 lda #$08 ; flag CAPS |
||
937 | 3465 F8239D 04 16 tsb XVFlag |
||
938 | 3466 F8239F 24 0B ?02: bit FmtFlag |
||
939 | 3467 F823A1 10 04 bpl ?04 ; no formato alt. |
||
940 | 3468 F823A3 A9 10 lda #$10 ; flag formato alt |
||
941 | 3469 F823A5 04 16 tsb XVFlag |
||
942 | 3470 F823A7 A6 0C ?04: ldx FmtSgn ; segno ? |
||
943 | 3471 F823A9 F0 0C beq ?08 ; no |
||
944 | 3472 F823AB A9 01 lda #$01 ; flag segno |
||
945 | 3473 F823AD E0 2B cpx #'+' |
||
946 | 3474 F823AF F0 02 beq ?06 ; usa '+' |
||
947 | 3475 F823B1 09 02 ora #$02 ; usa ' ' |
||
948 | 3476 F823B3 05 16 ?06: ora XVFlag |
||
949 | 3477 F823B5 85 16 sta XVFlag |
||
950 | 3478 F823B7 ?08: INDEX16 |
||
951 | 3479 F823B7 C2 10 rep #PXFLAG |
||
952 | 3480 .LONGI on |
||
953 | 3481 .MNLIST |
||
954 | 3482 F823B9 A6 00 ldx FmtParm ; indice parametri |
||
955 | 3483 F823BB BD 00 00 lda !0,x ; get long pointer |
||
956 | 3484 F823BE 85 60 sta PTR1 |
||
957 | 3485 F823C0 E8 inx |
||
958 | 3486 F823C1 BD 00 00 lda !0,x |
||
959 | 3487 F823C4 85 61 sta PTR1+1 |
||
960 | 3488 F823C6 E8 inx |
||
961 | 3489 F823C7 BD 00 00 lda !0,x |
||
962 | 3490 F823CA 85 62 sta PTR1+2 |
||
963 | 3491 F823CC E8 inx |
||
964 | 3492 F823CD 86 00 stx FmtParm ; aggiorna indice array parametri |
||
965 | 3493 F823CF INDEX08 |
||
966 | 3494 F823CF E2 10 sep #PXFLAG |
||
967 | 3495 .LONGI off |
||
968 | 3496 .MNLIST |
||
969 | 3497 F823D1 A9 80 lda #F_ALTFMT |
||
970 | 3498 F823D3 14 0B trb FmtFlag ; ignora formato alt. nel futuro |
||
971 | 3499 F823D5 24 0E bit FmtMod |
||
972 | 3500 F823D7 50 0D bvc ?20 ; binary float |
||
973 | 3501 F823D9 20 69 3D jsr _MovMem2Fa |
||
974 | 3502 F823DC A5 16 lda XVFlag |
||
975 | 3503 F823DE A6 0A ldx FmtPrec |
||
976 | 3504 F823E0 20 D9 40 jsr _feFAC2S ; BCD float |
||
977 | 3505 F823E3 4C 6C 24 jmp DoNum |
||
978 | 3506 F823E6 20 69 3D ?20: jsr _MovMem2Fa ; binary float |
||
979 | 3507 F823E9 A5 16 lda XVFlag |
||
980 | 3508 F823EB A6 0A ldx FmtPrec |
||
981 | 3509 F823ED 20 D9 40 jsr _feFAC2S |
||
982 | 3510 F823F0 4C 6C 24 jmp DoNum |
||
983 | 3511 |
||
984 | 3512 ; formattazione long pointer p,P |
||
985 | 3513 F823F3 DoPtr: |
||
986 | 3514 F823F3 A0 03 ldy #3 |
||
987 | 3515 F823F5 84 20 sty ACMSize ; size = 3 |
||
988 | 3516 F823F7 64 21 stz ACMSgn ; unsigned |
||
989 | 3517 F823F9 INDEX16 |
||
990 | 3518 F823F9 C2 10 rep #PXFLAG |
||
991 | 3519 .LONGI on |
||
992 | 3520 .MNLIST |
||
993 | Tue Jul 17 11:00:17 2018 Page 17 |
||
994 | |||
995 | |||
996 | |||
997 | |||
998 | 3521 F823FB A6 00 ldx FmtParm ; indice parametri |
||
999 | 3522 F823FD BD 00 00 lda !0,x ; get byte |
||
1000 | 3523 F82400 85 18 sta <ACM |
||
1001 | 3524 F82402 E8 inx |
||
1002 | 3525 F82403 BD 00 00 lda !0,x ; get byte |
||
1003 | 3526 F82406 85 19 sta <ACM+1 |
||
1004 | 3527 F82408 E8 inx |
||
1005 | 3528 F82409 BD 00 00 lda !0,x ; get byte |
||
1006 | 3529 F8240C 85 1A sta <ACM+2 |
||
1007 | 3530 F8240E E8 inx |
||
1008 | 3531 F8240F 86 00 stx FmtParm ; aggiorna indice array parametri |
||
1009 | 3532 F82411 INDEX08 |
||
1010 | 3533 F82411 E2 10 sep #PXFLAG |
||
1011 | 3534 .LONGI off |
||
1012 | 3535 .MNLIST |
||
1013 | 3536 F82413 A0 00 ldy #0 ; flag hex minuscolo |
||
1014 | 3537 F82415 A5 0E lda FmtMod |
||
1015 | 3538 F82417 89 04 bit #F2_CAPS |
||
1016 | 3539 F82419 F0 02 beq ?02 |
||
1017 | 3540 F8241B A0 40 ldy #$40 ; flag hex maiuscolo |
||
1018 | 3541 F8241D 98 ?02: tya |
||
1019 | 3542 F8241E 09 10 ora #$10 ; flag formato ptr |
||
1020 | 3543 F82420 A2 06 ldx #6 ; precision = 6 |
||
1021 | 3544 F82422 80 45 bra DoInt3 |
||
1022 | 3545 F82424 |
||
1023 | 3546 ; formattazione interi decimali i,d,u |
||
1024 | 3547 F82424 DoInt: |
||
1025 | 3548 F82424 20 34 23 jsr getint ; preleva integer |
||
1026 | 3549 F82427 A0 80 ldy #$80 ; flag decimale |
||
1027 | 3550 F82429 A5 0B lda FmtFlag |
||
1028 | 3551 F8242B 89 10 bit #F_GROUP |
||
1029 | 3552 F8242D F0 02 beq ?08 ; no group |
||
1030 | 3553 F8242F A0 C0 ldy #$C0 ; flag decimale + group |
||
1031 | 3554 F82431 A5 0E ?08: lda FmtMod |
||
1032 | 3555 F82433 4A lsr a ; CF = 1 => signed |
||
1033 | 3556 F82434 90 25 bcc DoInt2 ; unsigned |
||
1034 | 3557 F82436 A6 20 ldx <ACMSize |
||
1035 | 3558 F82438 CA dex |
||
1036 | 3559 F82439 B5 18 lda <ACM,x ; MSB |
||
1037 | 3560 F8243B 29 80 and #$80 ; maschera segno |
||
1038 | 3561 F8243D 09 40 ora #$40 ; tipo signed |
||
1039 | 3562 F8243F 85 21 sta ACMSgn |
||
1040 | 3563 F82441 A6 0C ldx FmtSgn ; segno ? |
||
1041 | 3564 F82443 F0 16 beq DoInt2 ; no |
||
1042 | 3565 F82445 C8 iny ; flag segno |
||
1043 | 3566 F82446 E0 2B cpx #'+' |
||
1044 | 3567 F82448 F0 11 beq DoInt2 ; usa '+' |
||
1045 | 3568 F8244A C8 iny |
||
1046 | 3569 F8244B C8 iny ; usa ' ' |
||
1047 | 3570 F8244C 80 0D bra DoInt2 |
||
1048 | 3571 F8244E |
||
1049 | 3572 ; formattazione interi esadecimali x,X |
||
1050 | 3573 F8244E DoHex: |
||
1051 | 3574 F8244E 20 34 23 jsr getint ; preleva integer |
||
1052 | 3575 F82451 A0 00 ldy #0 ; flag hex minuscolo |
||
1053 | 3576 F82453 A5 0E lda FmtMod |
||
1054 | 3577 F82455 89 04 bit #F2_CAPS |
||
1055 | Tue Jul 17 11:00:17 2018 Page 18 |
||
1056 | |||
1057 | |||
1058 | |||
1059 | |||
1060 | 3578 F82457 F0 02 beq DoInt2 |
||
1061 | 3579 F82459 A0 40 ldy #$40 ; flag hex maiuscolo |
||
1062 | 3580 |
||
1063 | 3581 F8245B DoInt2: |
||
1064 | 3582 F8245B A2 01 ldx #1 ; default precision |
||
1065 | 3583 F8245D A5 0B lda FmtFlag |
||
1066 | 3584 F8245F 89 04 bit #F_PREC |
||
1067 | 3585 F82461 F0 05 beq ?14 |
||
1068 | 3586 F82463 A6 0A ldx FmtPrec |
||
1069 | 3587 F82465 D0 01 bne ?14 |
||
1070 | 3588 F82467 E8 inx ; minima precision = 1 |
||
1071 | 3589 F82468 98 ?14: tya ; A = flag |
||
1072 | 3590 |
||
1073 | 3591 F82469 DoInt3: |
||
1074 | 3592 F82469 20 80 30 jsr _Int2Str ; A = Y = len -- X = ptr stringa |
||
1075 | 3593 F8246C |
||
1076 | 3594 F8246C DoNum: |
||
1077 | 3595 F8246C 64 5D stz PFXFLAG ; flag store segno / '$' |
||
1078 | 3596 F8246E 24 0B bit FmtFlag |
||
1079 | 3597 F82470 10 04 bpl ?04 ; solo p/P/x/X ammettono prefisso |
||
1080 | 3598 F82472 A9 24 lda #'$' ; prefisso alt. form. |
||
1081 | 3599 F82474 80 16 bra ?08 |
||
1082 | 3600 F82476 A5 0E ?04: lda FmtMod |
||
1083 | 3601 F82478 89 01 bit #F2_SIGNED |
||
1084 | 3602 F8247A F0 22 beq ?20 ; unsigned -- no strip segno |
||
1085 | 3603 F8247C B5 00 lda <0,x ; segno prima del digit |
||
1086 | 3604 F8247E C9 2B cmp #'+' |
||
1087 | 3605 F82480 F0 08 beq ?06 |
||
1088 | 3606 F82482 C9 2D cmp #'-' |
||
1089 | 3607 F82484 F0 04 beq ?06 |
||
1090 | 3608 F82486 C9 20 cmp #' ' |
||
1091 | 3609 F82488 D0 14 bne ?20 ; nessun segno prima del digit |
||
1092 | 3610 F8248A E8 ?06: inx ; sposta ptr. al primo digit |
||
1093 | 3611 F8248B 88 dey ; lunghezza stringa originale - 1 |
||
1094 | 3612 F8248C 85 3D ?08: sta PFXCHR ; segno numero o prefisso '$' |
||
1095 | 3613 F8248E |
||
1096 | 3614 ; ora il segno del numero e' stato strippato o il prefisso e' stato |
||
1097 | 3615 ; fissato ed occorre stabilire se esso va emesso come primo |
||
1098 | 3616 ; carattere oppure no. |
||
1099 | 3617 ; Se e' stato specificato il campo width con allineamento di default |
||
1100 | 3618 ; a destra ed il padding a sinistra viene effettuato con '0' allora |
||
1101 | 3619 ; il segno/prefisso va emesso come primo carattere, altrimenti va |
||
1102 | 3620 ; emesso prima della stringa numerica. Dato che il padding a destra |
||
1103 | 3621 ; avviene sempre con blank, il prefisso/segno va emesso come primo |
||
1104 | 3622 ; carattere se F_FILLZ e F_WIDTH sono entrambi settati. |
||
1105 | 3623 F8248E |
||
1106 | 3624 F8248E A5 0B lda FmtFlag |
||
1107 | 3625 F82490 29 28 and #(F_FILLZ.OR.F_WIDTH) ; specificato width con padding '0' ? |
||
1108 | 3626 F82492 C9 28 cmp #(F_FILLZ.OR.F_WIDTH) |
||
1109 | 3627 F82494 F0 04 beq ?10 ; si - emette segno/prefisso per primo |
||
1110 | 3628 F82496 A9 40 lda #$40 ; no - emette segno/prefisso dopo |
||
1111 | 3629 F82498 D0 02 bne ?12 |
||
1112 | 3630 F8249A A9 80 ?10: lda #$80 ; per primo |
||
1113 | 3631 F8249C 85 5D ?12: sta PFXFLAG |
||
1114 | 3632 F8249E 86 60 ?20: stx PTR1 ; store puntatore |
||
1115 | 3633 F824A0 A9 02 lda #>DP02ADDR |
||
1116 | 3634 F824A2 85 61 sta PTR1+1 |
||
1117 | Tue Jul 17 11:00:17 2018 Page 19 |
||
1118 | |||
1119 | |||
1120 | |||
1121 | |||
1122 | 3635 F824A4 64 62 stz PTR1+2 ; banco 0 |
||
1123 | 3636 F824A6 4C 29 25 jmp fmtstr |
||
1124 | 3637 F824A9 |
||
1125 | 3638 ; formattazione '%c' -- tipo char |
||
1126 | 3639 F824A9 DoChar: |
||
1127 | 3640 F824A9 INDEX16 |
||
1128 | 3641 F824A9 C2 10 rep #PXFLAG |
||
1129 | 3642 .LONGI on |
||
1130 | 3643 .MNLIST |
||
1131 | 3644 F824AB A6 00 ldx FmtParm ; indice parametri |
||
1132 | 3645 F824AD BD 00 00 lda !0,x ; get char |
||
1133 | 3646 F824B0 E8 inx |
||
1134 | 3647 F824B1 86 00 stx FmtParm ; aggiorna indice array parametri |
||
1135 | 3648 F824B3 INDEX08 |
||
1136 | 3649 F824B3 E2 10 sep #PXFLAG |
||
1137 | 3650 .LONGI off |
||
1138 | 3651 .MNLIST |
||
1139 | 3652 F824B5 85 70 sta FPUStr ; stringa temporanea |
||
1140 | 3653 F824B7 64 71 stz FPUStr+1 ; di 1 carattere |
||
1141 | 3654 F824B9 A9 70 lda #FPUStr |
||
1142 | 3655 F824BB 85 60 sta PTR1 ; ptr stringa da copiare |
||
1143 | 3656 F824BD A9 02 lda #>DP02ADDR |
||
1144 | 3657 F824BF 85 61 sta PTR1+1 |
||
1145 | 3658 F824C1 64 62 stz PTR1+2 ; banco 0 |
||
1146 | 3659 F824C3 A0 01 ldy #1 ; lunghezza = 1 |
||
1147 | 3660 F824C5 80 60 bra clrpfx |
||
1148 | 3661 F824C7 |
||
1149 | 3662 ; formattazione '%s' -- tipo stringa |
||
1150 | 3663 F824C7 DoStr: |
||
1151 | 3664 F824C7 A0 00 ldy #0 |
||
1152 | 3665 F824C9 INDEX16 |
||
1153 | 3666 F824C9 C2 10 rep #PXFLAG |
||
1154 | 3667 .LONGI on |
||
1155 | 3668 .MNLIST |
||
1156 | 3669 F824CB A6 00 ldx FmtParm ; indice parametri |
||
1157 | 3670 F824CD BD 00 00 lda !0,x ; get long ptr |
||
1158 | 3671 F824D0 85 60 sta PTR1 |
||
1159 | 3672 F824D2 E8 inx |
||
1160 | 3673 F824D3 BD 00 00 lda !0,x ; get long ptr |
||
1161 | 3674 F824D6 85 61 sta PTR1+1 |
||
1162 | 3675 F824D8 E8 inx |
||
1163 | 3676 F824D9 BD 00 00 lda !0,x ; get long ptr |
||
1164 | 3677 F824DC 85 62 sta PTR1+2 |
||
1165 | 3678 F824DE E8 inx |
||
1166 | 3679 F824DF 86 00 stx FmtParm ; aggiorna indice array parametri |
||
1167 | 3680 F824E1 05 61 ora PTR1+1 ; test ptr NULL |
||
1168 | 3681 F824E3 05 60 ora PTR1 |
||
1169 | 3682 F824E5 D0 0E bne ?00 ; ptr != NULL |
||
1170 | 3683 F824E7 A9 B4 lda #<NULLSTR ; copia stringa di default "(null)" |
||
1171 | 3684 F824E9 85 60 sta PTR1 |
||
1172 | 3685 F824EB A9 27 lda #>NULLSTR |
||
1173 | 3686 F824ED 85 61 sta PTR1+1 |
||
1174 | 3687 F824EF A9 F8 lda #^NULLSTR ; oppure .HIGH8. |
||
1175 | 3688 F824F1 85 62 sta PTR1+2 |
||
1176 | 3689 F824F3 80 15 bra ?01 |
||
1177 | 3690 F824F5 A5 0E ?00: lda FmtMod |
||
1178 | 3691 F824F7 89 80 bit #F2_PSSTRING |
||
1179 | Tue Jul 17 11:00:17 2018 Page 20 |
||
1180 | |||
1181 | |||
1182 | |||
1183 | |||
1184 | 3692 F824F9 F0 0F beq ?01 ; stringa stile C |
||
1185 | 3693 F824FB A7 60 lda [PTR1] ; lunghezza stringa pascal/basic |
||
1186 | 3694 F824FD A8 tay |
||
1187 | 3695 F824FE ACC16 ; char stringa pascal dopo lunghezza |
||
1188 | 3696 F824FE C2 20 rep #PMFLAG |
||
1189 | 3697 .LONGA on |
||
1190 | 3698 .MNLIST |
||
1191 | 3699 F82500 E6 60 inc PTR1 |
||
1192 | 3700 F82502 ACC08 |
||
1193 | 3701 F82502 E2 20 sep #PMFLAG |
||
1194 | 3702 .LONGA off |
||
1195 | 3703 .MNLIST |
||
1196 | 3704 F82504 D0 13 bne ?03 |
||
1197 | 3705 F82506 E6 62 inc PTR1+2 |
||
1198 | 3706 F82508 80 0F bra ?03 |
||
1199 | 3707 F8250A B7 60 ?01: lda [PTR1],y ; calcola lunghezza stringa stile C |
||
1200 | 3708 F8250C F0 03 beq ?02 |
||
1201 | 3709 F8250E C8 iny |
||
1202 | 3710 F8250F D0 F9 bne ?01 |
||
1203 | 3711 F82511 C0 00 01 ?02: cpy #$0100 ; max. 255 caratteri |
||
1204 | 3712 F82514 90 03 bcc ?03 |
||
1205 | 3713 F82516 A0 FF 00 ldy #$00FF |
||
1206 | 3714 F82519 ?03: INDEX08 ; Y = lunghezza stringa |
||
1207 | 3715 F82519 E2 10 sep #PXFLAG |
||
1208 | 3716 .LONGI off |
||
1209 | 3717 .MNLIST |
||
1210 | 3718 F8251B A5 0B lda FmtFlag ; test 'precision' |
||
1211 | 3719 F8251D 89 04 bit #F_PREC |
||
1212 | 3720 F8251F F0 06 beq clrpfx ; no precision specificata |
||
1213 | 3721 F82521 C4 0A cpy FmtPrec ; Len >= precision ? |
||
1214 | 3722 F82523 90 02 bcc clrpfx ; NO |
||
1215 | 3723 F82525 A4 0A ldy FmtPrec ; SI -> Len = precision |
||
1216 | 3724 ; precision puo' troncare la stringa |
||
1217 | 3725 F82527 clrpfx: |
||
1218 | 3726 F82527 64 5D stz PFXFLAG |
||
1219 | 3727 F82529 |
||
1220 | 3728 ; formatta stringa |
||
1221 | 3729 F82529 fmtstr: |
||
1222 | 3730 F82529 84 5C sty STRLEN ; salva lunghezza stringa da copiare |
||
1223 | 3731 F8252B 64 3E stz NPADL ; no padding a sinistra |
||
1224 | 3732 F8252D 64 3F stz NPADR ; no padding a destra |
||
1225 | 3733 F8252F A5 5D lda PFXFLAG ; occorre memorizzare prefix/segno ? |
||
1226 | 3734 F82531 29 C0 and #$C0 |
||
1227 | 3735 F82533 F0 01 beq ?02 ; NO |
||
1228 | 3736 F82535 C8 iny ; conteggia 1 byte in + |
||
1229 | 3737 F82536 84 27 ?02: sty FPTmp4 ; lunghezza reale stringa |
||
1230 | 3738 F82538 A5 0B lda FmtFlag |
||
1231 | 3739 F8253A 89 08 bit #F_WIDTH |
||
1232 | 3740 F8253C F0 22 beq ?18 ; no padding sx/dx |
||
1233 | 3741 F8253E A5 09 lda FmtWidth |
||
1234 | 3742 F82540 F0 1E beq ?18 ; width = 0 => no padding |
||
1235 | 3743 F82542 38 sec |
||
1236 | 3744 F82543 E5 27 sbc FPTmp4 |
||
1237 | 3745 F82545 F0 19 beq ?18 ; width = len => no padding |
||
1238 | 3746 F82547 90 17 bcc ?18 ; width < len => no padding |
||
1239 | 3747 F82549 AA tax ; X = width - len => padding |
||
1240 | 3748 F8254A A5 0B lda FmtFlag |
||
1241 | Tue Jul 17 11:00:17 2018 Page 21 |
||
1242 | |||
1243 | |||
1244 | |||
1245 | |||
1246 | 3749 F8254C 89 40 bit #F_LEFTJ |
||
1247 | 3750 F8254E F0 04 beq ?04 ; allineameno a destra (default) |
||
1248 | 3751 F82550 86 3F stx NPADR ; allinea a sinistra => padding a dx |
||
1249 | 3752 F82552 80 08 bra ?06 ; padding a dx sempre con blank |
||
1250 | 3753 F82554 86 3E ?04: stx NPADL ; allinea a dx => padding a sx |
||
1251 | 3754 F82556 A2 30 ldx #'0' ; pad con '0' ? |
||
1252 | 3755 F82558 89 20 bit #F_FILLZ |
||
1253 | 3756 F8255A D0 02 bne ?08 ; SI |
||
1254 | 3757 F8255C A2 20 ?06: ldx #' ' ; NO -- padding con blank |
||
1255 | 3758 F8255E 86 3C ?08: stx PADCHR |
||
1256 | 3759 F82560 24 5D ?18: bit PFXFLAG ; segno o prefisso '$' come primo ? |
||
1257 | 3760 F82562 10 05 bpl ?20 ; NO |
||
1258 | 3761 F82564 A5 3D lda PFXCHR ; store segno/prefix |
||
1259 | 3762 F82566 20 09 23 jsr _store |
||
1260 | 3763 F82569 A4 3E ?20: ldy NPADL ; numero char padding a sinistra |
||
1261 | 3764 F8256B F0 08 beq ?24 ; no padding a sinistra |
||
1262 | 3765 F8256D A5 3C lda PADCHR ; carattere di padding |
||
1263 | 3766 F8256F 20 09 23 ?22: jsr _store |
||
1264 | 3767 F82572 88 dey |
||
1265 | 3768 F82573 D0 FA bne ?22 |
||
1266 | 3769 F82575 24 5D ?24: bit PFXFLAG ; segno o prefisso '$' adesso ? |
||
1267 | 3770 F82577 50 05 bvc ?26 ; NO |
||
1268 | 3771 F82579 A5 3D lda PFXCHR ; store segno/prefix |
||
1269 | 3772 F8257B 20 09 23 jsr _store |
||
1270 | 3773 F8257E A4 5C ?26: ldy STRLEN ; copia la stringa |
||
1271 | 3774 F82580 F0 0C beq ?30 ; non ci sono char da copiare |
||
1272 | 3775 F82582 A0 00 ldy #0 |
||
1273 | 3776 F82584 B7 60 ?28: lda [PTR1],y ; copia byte a byte |
||
1274 | 3777 F82586 20 09 23 jsr _store |
||
1275 | 3778 F82589 C8 iny |
||
1276 | 3779 F8258A C6 5C dec STRLEN |
||
1277 | 3780 F8258C D0 F6 bne ?28 |
||
1278 | 3781 F8258E A4 3F ?30: ldy NPADR ; numero char padding a destra |
||
1279 | 3782 F82590 F0 08 beq ?34 ; no padding a destra |
||
1280 | 3783 F82592 A5 3C lda PADCHR ; carattere di padding |
||
1281 | 3784 F82594 20 09 23 ?32: jsr _store |
||
1282 | 3785 F82597 88 dey |
||
1283 | 3786 F82598 D0 FA bne ?32 |
||
1284 | 3787 F8259A 60 ?34: rts |
||
1285 | 3788 F8259B |
||
1286 | 3789 ;---------------------------------------------------------------------------- |
||
1287 | 3790 ; FUNZIONI SCANNING SPECIFICATORE DI FORMATO |
||
1288 | 3791 ; |
||
1289 | 3792 ; In - B = cur char, A = stage (e flag N,Z) |
||
1290 | 3793 ; |
||
1291 | 3794 ; Out - CF = 0 -> OK, A = stage, VF = 0 -> continua scanning |
||
1292 | 3795 ; VF = 1 -> fine scanning, X -> indice funzione conversione |
||
1293 | 3796 ; CF = 1 -> formato errato |
||
1294 | 3797 ;---------------------------------------------------------------------------- |
||
1295 | 3798 |
||
1296 | 3799 ; case ' ' or '+' -- valido solo nello stato stage = 0 |
||
1297 | 3800 F8259B case_si: |
||
1298 | 3801 F8259B D0 64 bne case_dc ; abandon |
||
1299 | 3802 F8259D A6 0C ldx FmtSgn |
||
1300 | 3803 F8259F E0 2B cpx #'+' |
||
1301 | 3804 F825A1 F0 04 beq ?04 ; ignora ' ' se '+' gia' specificato |
||
1302 | 3805 F825A3 EB xba ; A = cur char - B = stage |
||
1303 | Tue Jul 17 11:00:17 2018 Page 22 |
||
1304 | |||
1305 | |||
1306 | |||
1307 | |||
1308 | 3806 F825A4 85 0C sta FmtSgn |
||
1309 | 3807 F825A6 EB xba ; A = stage |
||
1310 | 3808 F825A7 ?04: |
||
1311 | 3809 F825A7 18 retok: clc ; OK |
||
1312 | 3810 F825A8 B8 clv ; continua scanning |
||
1313 | 3811 F825A9 60 rts |
||
1314 | 3812 |
||
1315 | 3813 ; case digit '0' - padding a sinistra con '0' invece di ' ' |
||
1316 | 3814 ; '0' o e' il primo digit del campo width, oppure e' un digit successivo |
||
1317 | 3815 ; che fa parte del campo width o del campo precision |
||
1318 | 3816 F825AA case_fz: |
||
1319 | 3817 ; il flag Z e' valido -- indica se stage = 0 |
||
1320 | 3818 F825AA D0 57 bne case_nu ; digit fa parte di width/precision ? |
||
1321 | 3819 F825AC AA tax ; X = stage |
||
1322 | 3820 F825AD A9 40 lda #F_LEFTJ |
||
1323 | 3821 F825AF 24 0B bit FmtFlag ; ignora padding '0' se left just. |
||
1324 | 3822 F825B1 F0 03 beq ?01 |
||
1325 | 3823 F825B3 8A txa ; A = stage |
||
1326 | 3824 F825B4 D0 F1 bne retok |
||
1327 | 3825 F825B6 A9 20 ?01: lda #F_FILLZ ; padding '0' |
||
1328 | 3826 F825B8 E8 inx ; X = 1 -> padding stage |
||
1329 | 3827 F825B9 80 0C bra setflag ; dopo deve seguire campo width |
||
1330 | 3828 |
||
1331 | 3829 ; case '-' -- valido solo nello stato stage = 0 |
||
1332 | 3830 F825BB case_lj: |
||
1333 | 3831 F825BB D0 44 bne case_dc ; abandon |
||
1334 | 3832 F825BD AA tax ; X = stage |
||
1335 | 3833 F825BE A9 40 lda #F_LEFTJ ; flag allineamento a sx |
||
1336 | 3834 F825C0 80 05 bra setflag |
||
1337 | 3835 F825C2 |
||
1338 | 3836 ; case '#' -- valido solo nello stato stage = 0 |
||
1339 | 3837 F825C2 case_af: |
||
1340 | 3838 F825C2 D0 3D bne case_dc ; abandon |
||
1341 | 3839 F825C4 AA tax ; X = stage |
||
1342 | 3840 F825C5 A9 80 lda #F_ALTFMT ; flag formato alt. |
||
1343 | 3841 F825C7 setflag: |
||
1344 | 3842 F825C7 04 0B tsb FmtFlag |
||
1345 | 3843 F825C9 8A txa ; A = stage |
||
1346 | 3844 F825CA 18 clc ; OK |
||
1347 | 3845 F825CB B8 clv ; continua scanning |
||
1348 | 3846 F825CC 60 rts |
||
1349 | 3847 |
||
1350 | 3848 ; case ',' -- valido solo nello stato stage = 0 |
||
1351 | 3849 F825CD case_tg: |
||
1352 | 3850 F825CD D0 32 bne case_dc ; abandon |
||
1353 | 3851 F825CF AA tax ; X = stage |
||
1354 | 3852 F825D0 A9 10 lda #F_GROUP ; flag group&thousand |
||
1355 | 3853 F825D2 80 F3 bra setflag |
||
1356 | 3854 F825D4 |
||
1357 | 3855 ; case '*' - argomento per width o precision |
||
1358 | 3856 F825D4 case_ar: |
||
1359 | 3857 F825D4 EB xba ; salva stage |
||
1360 | 3858 F825D5 INDEX16 |
||
1361 | 3859 F825D5 C2 10 rep #PXFLAG |
||
1362 | 3860 .LONGI on |
||
1363 | 3861 .MNLIST |
||
1364 | 3862 F825D7 A6 00 ldx FmtParm ; indice parametro byte |
||
1365 | Tue Jul 17 11:00:17 2018 Page 23 |
||
1366 | |||
1367 | |||
1368 | |||
1369 | |||
1370 | 3863 F825D9 BD 00 00 lda !0,x |
||
1371 | 3864 F825DC E8 inx |
||
1372 | 3865 F825DD 86 00 stx FmtParm ; next param |
||
1373 | 3866 F825DF INDEX08 |
||
1374 | 3867 F825DF E2 10 sep #PXFLAG |
||
1375 | 3868 .LONGI off |
||
1376 | 3869 .MNLIST |
||
1377 | 3870 F825E1 AA tax ; X = param |
||
1378 | 3871 F825E2 EB xba ; A = stage |
||
1379 | 3872 F825E3 C9 02 cmp #WIDESTAGE |
||
1380 | 3873 F825E5 B0 0B bcs ?04 ; campo precision ? |
||
1381 | 3874 F825E7 86 09 stx FmtWidth ; store width |
||
1382 | 3875 F825E9 A9 08 lda #F_WIDTH |
||
1383 | 3876 F825EB 04 0B tsb FmtFlag ; imposta flag campo 'width' |
||
1384 | 3877 F825ED A9 03 lda #DOTSTAGE ; next: campo precisione |
||
1385 | 3878 F825EF 18 clc ; OK |
||
1386 | 3879 F825F0 B8 clv ; continua scanning |
||
1387 | 3880 F825F1 60 rts |
||
1388 | 3881 F825F2 C9 04 ?04: cmp #PRECSTAGE |
||
1389 | 3882 F825F4 D0 0B bne case_dc ; abandon |
||
1390 | 3883 F825F6 86 0A stx FmtPrec ; store precision |
||
1391 | 3884 F825F8 AA tax ; X = stage |
||
1392 | 3885 F825F9 A9 04 lda #F_PREC |
||
1393 | 3886 F825FB 04 0B tsb FmtFlag ; imposta flag campo 'precision' |
||
1394 | 3887 F825FD 8A txa ; A = stage (mantiene stesso stage) |
||
1395 | 3888 F825FE 18 clc ; OK |
||
1396 | 3889 F825FF B8 clv ; continua scanning |
||
1397 | 3890 F82600 60 rts |
||
1398 | 3891 F82601 |
||
1399 | 3892 ; caratteri illegali - abbandona conversione |
||
1400 | 3893 F82601 case_dc: |
||
1401 | 3894 F82601 38 sec ; flag abandon |
||
1402 | 3895 F82602 60 rts |
||
1403 | 3896 |
||
1404 | 3897 ; case '0'..'9' - digit che fanno parte o di 'width' o di 'precision' |
||
1405 | 3898 ; FmtWidth e FmtPrec sono inizializzati a ZERO quindi si somma il digit |
||
1406 | 3899 ; direttamente al valore corrente |
||
1407 | 3900 F82603 case_nu: |
||
1408 | 3901 F82603 AA tax ; X = stage |
||
1409 | 3902 F82604 EB xba ; A = char '0'..'9' |
||
1410 | 3903 F82605 38 sec |
||
1411 | 3904 F82606 E9 30 sbc #'0' ; scala a 0..9 |
||
1412 | 3905 F82608 E0 03 cpx #WIDESTAGE+1 ; parte di specifica width ? |
||
1413 | 3906 F8260A B0 25 bcs ?10 ; no - parte di specifica precision |
||
1414 | 3907 F8260C AA tax ; X = number 0..9 |
||
1415 | 3908 F8260D A5 09 lda FmtWidth |
||
1416 | 3909 F8260F 86 09 stx FmtWidth |
||
1417 | 3910 F82611 F0 15 beq ?04 ; old width = 0 |
||
1418 | 3911 F82613 0A asl a ; width * 2 |
||
1419 | 3912 F82614 B0 3E bcs ?20 ; overflow |
||
1420 | 3913 F82616 85 63 sta FMTTMP |
||
1421 | 3914 F82618 0A asl a |
||
1422 | 3915 F82619 B0 39 bcs ?20 ; overflow |
||
1423 | 3916 F8261B 0A asl a ; width * 8 |
||
1424 | 3917 F8261C B0 36 bcs ?20 ; overflow |
||
1425 | 3918 F8261E 65 63 adc FMTTMP ; width * 10 |
||
1426 | 3919 F82620 B0 32 bcs ?20 ; overflow |
||
1427 | Tue Jul 17 11:00:17 2018 Page 24 |
||
1428 | |||
1429 | |||
1430 | |||
1431 | |||
1432 | 3920 F82622 65 09 adc FmtWidth ; (width * 10) + number |
||
1433 | 3921 F82624 B0 2E bcs ?20 ; overflow |
||
1434 | 3922 F82626 85 09 sta FmtWidth |
||
1435 | 3923 F82628 A9 08 ?04: lda #F_WIDTH |
||
1436 | 3924 F8262A 04 0B tsb FmtFlag ; imposta flag campo 'width' |
||
1437 | 3925 F8262C A9 02 lda #WIDESTAGE ; current stage: campo numerico 'width' |
||
1438 | 3926 F8262E 18 clc ; OK |
||
1439 | 3927 F8262F B8 clv ; continua scanning |
||
1440 | 3928 F82630 60 rts |
||
1441 | 3929 F82631 E0 04 ?10: cpx #PRECSTAGE ; stage precision ? |
||
1442 | 3930 F82633 D0 CC bne case_dc ; no -- abandon |
||
1443 | 3931 F82635 AA tax ; X = number 0..9 |
||
1444 | 3932 F82636 A5 0A lda FmtPrec |
||
1445 | 3933 F82638 86 0A stx FmtPrec |
||
1446 | 3934 F8263A F0 15 beq ?14 ; old prec = 0 |
||
1447 | 3935 F8263C 0A asl a ; prec * 2 |
||
1448 | 3936 F8263D B0 15 bcs ?20 ; overflow |
||
1449 | 3937 F8263F 85 63 sta FMTTMP |
||
1450 | 3938 F82641 0A asl a |
||
1451 | 3939 F82642 B0 10 bcs ?20 ; overflow |
||
1452 | 3940 F82644 0A asl a ; prec * 8 |
||
1453 | 3941 F82645 B0 0D bcs ?20 ; overflow |
||
1454 | 3942 F82647 65 63 adc FMTTMP ; prec * 10 |
||
1455 | 3943 F82649 B0 09 bcs ?20 ; overflow |
||
1456 | 3944 F8264B 65 0A adc FmtPrec ; (prec * 10) + number |
||
1457 | 3945 F8264D B0 05 bcs ?20 ; overflow |
||
1458 | 3946 F8264F 85 0A sta FmtPrec |
||
1459 | 3947 F82651 EB ?14: xba ; mantiene stesso stadio |
||
1460 | 3948 F82652 18 clc ; OK |
||
1461 | 3949 F82653 B8 clv ; continua scanning |
||
1462 | 3950 F82654 60 ?20: rts |
||
1463 | 3951 |
||
1464 | 3952 ; case '.' -- valido solo se stato corrente < precstage |
||
1465 | 3953 F82655 case_pr: |
||
1466 | 3954 F82655 C9 04 cmp #PRECSTAGE |
||
1467 | 3955 F82657 B0 08 bcs ?01 ; abandon |
||
1468 | 3956 F82659 A9 04 lda #F_PREC |
||
1469 | 3957 F8265B 04 0B tsb FmtFlag ; imposta flag campo precision |
||
1470 | 3958 F8265D A9 04 lda #PRECSTAGE ; imposta stato corrente = precstage |
||
1471 | 3959 F8265F 18 clc ; OK |
||
1472 | 3960 F82660 B8 clv ; continua scanning |
||
1473 | 3961 F82661 60 ?01: rts |
||
1474 | 3962 |
||
1475 | 3963 ;============================================================================ |
||
1476 | 3964 ; modificatori -- impostano lo stato MODSTAGE (dopo sono ammessi solo i tipi) |
||
1477 | 3965 |
||
1478 | 3966 ; case 'l' -- modificatore 'long' |
||
1479 | 3967 F82662 case_lo: |
||
1480 | 3968 F82662 A2 20 ldx #F2_LONG |
||
1481 | 3969 F82664 80 0E bra setmod |
||
1482 | 3970 |
||
1483 | 3971 ; case 'h' -- modificatore 'short' |
||
1484 | 3972 F82666 case_sh: |
||
1485 | 3973 F82666 A2 10 ldx #F2_SHORT |
||
1486 | 3974 F82668 80 0A bra setmod |
||
1487 | 3975 |
||
1488 | 3976 ; case 'b' -- modificatore 'byte' |
||
1489 | Tue Jul 17 11:00:17 2018 Page 25 |
||
1490 | |||
1491 | |||
1492 | |||
1493 | |||
1494 | 3977 F8266A case_SH: |
||
1495 | 3978 F8266A A2 08 ldx #F2_BYTE |
||
1496 | 3979 F8266C 80 06 bra setmod |
||
1497 | 3980 |
||
1498 | 3981 ; case 'D' -- modificatore BCD float number |
||
1499 | 3982 F8266E case_bc: |
||
1500 | 3983 F8266E A2 40 ldx #F2_BCD |
||
1501 | 3984 F82670 80 02 bra setmod |
||
1502 | 3985 F82672 |
||
1503 | 3986 ; case 'B' -- modificatore stringa pascal/basic |
||
1504 | 3987 F82672 case_PS: |
||
1505 | 3988 F82672 A2 80 ldx #F2_PSSTRING |
||
1506 | 3989 |
||
1507 | 3990 F82674 setmod: |
||
1508 | 3991 F82674 C9 05 cmp #MODSTAGE |
||
1509 | 3992 F82676 B0 07 bcs ?10 ; abandon |
||
1510 | 3993 F82678 8A txa |
||
1511 | 3994 F82679 04 0E tsb FmtMod |
||
1512 | 3995 F8267B A9 05 lda #MODSTAGE ; stadio finale specificatore |
||
1513 | 3996 F8267D 18 clc ; OK |
||
1514 | 3997 F8267E B8 clv ; continua scanning |
||
1515 | 3998 F8267F 60 ?10: rts |
||
1516 | 3999 F82680 |
||
1517 | 4000 ;============================================================================ |
||
1518 | 4001 ; specificatori di tipo -- qualsiasi tipo a qualsiasi stadio termina |
||
1519 | 4002 ; lo scanning |
||
1520 | 4003 |
||
1521 | 4004 ; case 'P' -- pointer HEX |
||
1522 | 4005 F82680 case_PT: |
||
1523 | 4006 F82680 A9 04 lda #F2_CAPS ; set CAPS |
||
1524 | 4007 F82682 04 0E tsb FmtMod |
||
1525 | 4008 |
||
1526 | 4009 ; case 'p' -- pointer hex |
||
1527 | 4010 F82684 case_pt: |
||
1528 | 4011 F82684 A9 01 lda #F2_SIGNED |
||
1529 | 4012 F82686 14 0E trb FmtMod ; clear flag signed |
||
1530 | 4013 F82688 A9 20 lda #F_FILLZ ; ignora padding a sx. con '0' |
||
1531 | 4014 F8268A 14 0B trb FmtFlag |
||
1532 | 4015 F8268C A2 04 ldx #T_PTR ; indice funzione conversione |
||
1533 | 4016 F8268E A9 F8 lda #MASKPTR ; maschera modificatori non ammessi |
||
1534 | 4017 F82690 80 72 bra tsttype |
||
1535 | 4018 F82692 |
||
1536 | 4019 ; case 'X' -- unsigned HEX |
||
1537 | 4020 F82692 case_HE: |
||
1538 | 4021 F82692 A9 04 lda #F2_CAPS |
||
1539 | 4022 F82694 04 0E tsb FmtMod |
||
1540 | 4023 F82696 |
||
1541 | 4024 ; case 'x' -- unsigned hex |
||
1542 | 4025 F82696 case_he: |
||
1543 | 4026 F82696 A9 01 lda #F2_SIGNED |
||
1544 | 4027 F82698 14 0E trb FmtMod ; clear flag signed |
||
1545 | 4028 F8269A A5 0B lda FmtFlag |
||
1546 | 4029 F8269C 89 04 bit #F_PREC |
||
1547 | 4030 F8269E F0 04 beq ?02 |
||
1548 | 4031 F826A0 A9 20 lda #F_FILLZ ; ignora padding a sx. con '0' |
||
1549 | 4032 F826A2 14 0B trb FmtFlag ; se specificata precision |
||
1550 | 4033 F826A4 A2 08 ?02: ldx #T_HEX ; indice funzione conversione |
||
1551 | Tue Jul 17 11:00:17 2018 Page 26 |
||
1552 | |||
1553 | |||
1554 | |||
1555 | |||
1556 | 4034 F826A6 A9 C0 lda #MASKINTG ; maschera modificatori non ammessi |
||
1557 | 4035 F826A8 80 5A bra tsttype |
||
1558 | 4036 |
||
1559 | 4037 ; case 'd', 'i' -- signed integer |
||
1560 | 4038 F826AA case_de: |
||
1561 | 4039 F826AA A9 01 lda #F2_SIGNED |
||
1562 | 4040 F826AC 04 0E tsb FmtMod ; set flag signed |
||
1563 | 4041 F826AE 80 04 bra case_i |
||
1564 | 4042 |
||
1565 | 4043 ; case 'u' -- unsigned integer |
||
1566 | 4044 F826B0 case_un: |
||
1567 | 4045 F826B0 A9 01 lda #F2_SIGNED |
||
1568 | 4046 F826B2 14 0E trb FmtMod ; clear flag signed |
||
1569 | 4047 |
||
1570 | 4048 ; parte comune per gli interi decimali |
||
1571 | 4049 F826B4 case_i: |
||
1572 | 4050 F826B4 A5 0B lda FmtFlag |
||
1573 | 4051 F826B6 89 04 bit #F_PREC |
||
1574 | 4052 F826B8 F0 04 beq ?02 |
||
1575 | 4053 F826BA A9 20 lda #F_FILLZ ; ignora padding a sx. con '0' |
||
1576 | 4054 F826BC 14 0B trb FmtFlag ; se specificata precision |
||
1577 | 4055 F826BE A9 80 ?02: lda #F_ALTFMT |
||
1578 | 4056 F826C0 14 0B trb FmtFlag ; decimale ignora formato alternativo |
||
1579 | 4057 F826C2 A2 06 ldx #T_INT ; indice funzione conversione |
||
1580 | 4058 F826C4 A9 C0 lda #MASKINTG ; maschera modificatori non ammessi |
||
1581 | 4059 F826C6 80 3C bra tsttype |
||
1582 | 4060 |
||
1583 | 4061 ; case 'c' -- char |
||
1584 | 4062 F826C8 case_ch: |
||
1585 | 4063 F826C8 A9 84 lda #(F_ALTFMT.OR.F_PREC) ; ignora precision e formato alt. |
||
1586 | 4064 F826CA 14 0B trb FmtFlag |
||
1587 | 4065 F826CC A2 00 ldx #T_CHAR ; indice funzione conversione |
||
1588 | 4066 F826CE A9 F8 lda #MASKCHAR ; maschera modificatori non ammessi |
||
1589 | 4067 F826D0 80 32 bra tsttype |
||
1590 | 4068 F826D2 |
||
1591 | 4069 ; case 's' -- string |
||
1592 | 4070 F826D2 case_st: |
||
1593 | 4071 F826D2 A9 80 lda #F_ALTFMT ; ignora formato alt. |
||
1594 | 4072 F826D4 14 0B trb FmtFlag |
||
1595 | 4073 F826D6 A2 02 ldx #T_STR ; indice funzione conversione |
||
1596 | 4074 F826D8 A9 78 lda #MASKSTR ; maschera modificatori non ammessi |
||
1597 | 4075 F826DA 80 28 bra tsttype |
||
1598 | 4076 |
||
1599 | 4077 ; case 'E' -- float formato EXP |
||
1600 | 4078 F826DC case_FE: |
||
1601 | 4079 F826DC A9 04 lda #F2_CAPS |
||
1602 | 4080 F826DE 04 0E tsb FmtMod |
||
1603 | 4081 |
||
1604 | 4082 ; case 'e' -- float formato exp |
||
1605 | 4083 F826E0 case_fe: |
||
1606 | 4084 F826E0 A9 00 lda #$00 ; flag formato e/E |
||
1607 | 4085 F826E2 80 16 bra case_f |
||
1608 | 4086 F826E4 |
||
1609 | 4087 ; case 'G' -- float formato G |
||
1610 | 4088 F826E4 case_FG: |
||
1611 | 4089 F826E4 A9 04 lda #F2_CAPS |
||
1612 | 4090 F826E6 04 0E tsb FmtMod |
||
1613 | Tue Jul 17 11:00:17 2018 Page 27 |
||
1614 | |||
1615 | |||
1616 | |||
1617 | |||
1618 | 4091 |
||
1619 | 4092 ; case 'g' -- float formato g |
||
1620 | 4093 F826E8 case_fg: |
||
1621 | 4094 F826E8 A9 40 lda #$40 ; flag formato g/G |
||
1622 | 4095 F826EA 80 0E bra case_f |
||
1623 | 4096 F826EC |
||
1624 | 4097 ; case 'A' -- float formato A |
||
1625 | 4098 F826EC case_XF: |
||
1626 | 4099 F826EC A9 04 lda #F2_CAPS |
||
1627 | 4100 F826EE 04 0E tsb FmtMod |
||
1628 | 4101 |
||
1629 | 4102 ; case 'a' -- float formato a |
||
1630 | 4103 F826F0 case_xf: |
||
1631 | 4104 F826F0 A9 20 lda #F_FILLZ ; formato a/A no padding a sx con '0' |
||
1632 | 4105 F826F2 14 0B trb FmtFlag |
||
1633 | 4106 F826F4 A9 04 lda #$04 ; flag formato a/A |
||
1634 | 4107 F826F6 80 02 bra case_f |
||
1635 | 4108 |
||
1636 | 4109 ; case 'f', 'F' -- float formato decimale |
||
1637 | 4110 F826F8 case_ff: |
||
1638 | 4111 F826F8 A9 20 lda #$20 ; flag formato f/F |
||
1639 | 4112 |
||
1640 | 4113 ; parte comune ai numeri float |
||
1641 | 4114 F826FA case_f: |
||
1642 | 4115 ; i numeri float possono avere padding a sx con '0' anche se viene |
||
1643 | 4116 ; specificata la precision |
||
1644 | 4117 F826FA 85 16 sta XVFlag ; flag formattazione |
||
1645 | 4118 F826FC A9 01 lda #F2_SIGNED |
||
1646 | 4119 F826FE 04 0E tsb FmtMod ; set flag signed |
||
1647 | 4120 F82700 A2 0A ldx #T_FLOAT ; indice funzione conversione |
||
1648 | 4121 F82702 A9 B8 lda #MASKFLOAT ; maschera modificatori non ammessi |
||
1649 | 4122 |
||
1650 | 4123 ; testa modificatore tipo |
||
1651 | 4124 F82704 tsttype: |
||
1652 | 4125 F82704 24 0E bit FmtMod ; test modificatori non ammessi |
||
1653 | 4126 F82706 F0 02 beq ?04 ; OK |
||
1654 | 4127 F82708 38 sec ; abandon |
||
1655 | 4128 F82709 60 rts |
||
1656 | 4129 F8270A E2 40 ?04: sep #PVFLAG ; set V = 1 -- fine scanning |
||
1657 | 4130 F8270C 18 clc ; OK -> conversione |
||
1658 | 4131 F8270D 60 rts |
||
1659 | 4132 F8270E |
||
1660 | 4133 ;---------------------------------------------------------------------------- |
||
1661 | 4134 ; COSTANTI |
||
1662 | 4135 ;---------------------------------------------------------------------------- |
||
1663 | 4136 |
||
1664 | 4137 ; tabella classi caratteri di conversione (carattere >= 32 e < 128) |
||
1665 | 4138 F8270E CLASSCHR: |
||
1666 | 4139 |
||
1667 | 4140 ; SP ! " # $ % & ' ( ) * + , - . / |
||
1668 | 4141 F8270E 01 00 00 02 00 .DB _si,_dc,_dc,_af,_dc,_dc,_dc,_dc,_dc,_dc,_ar,_si,_tg,_lj,_pr,_dc |
||
1669 | 00 00 00 00 00 |
||
1670 | 03 01 18 04 05 |
||
1671 | 00 |
||
1672 | 4142 |
||
1673 | 4143 ; 0 1 2 3 4 5 6 7 8 9 : ; < = > ? |
||
1674 | 4144 F8271E 0A 06 06 06 06 .DB _fz,_nu,_nu,_nu,_nu,_nu,_nu,_nu,_nu,_nu,_dc,_dc,_dc,_dc,_dc,_dc |
||
1675 | Tue Jul 17 11:00:17 2018 Page 28 |
||
1676 | |||
1677 | |||
1678 | |||
1679 | |||
1680 | 06 06 06 06 06 |
||
1681 | 00 00 00 00 00 |
||
1682 | 00 |
||
1683 | 4145 |
||
1684 | 4146 ; _ A B C D E F G H I J K L M N O |
||
1685 | 4147 F8272E 00 1C 1A 00 19 .DB _dc,_XF,_PS,_dc,_bc,_FE,_ff,_FG,_dc,_dc,_dc,_dc,_dc,_dc,_dc,_dc |
||
1686 | 16 13 17 00 00 |
||
1687 | 00 00 00 00 00 |
||
1688 | 00 |
||
1689 | 4148 |
||
1690 | 4149 ; P Q R S T U V W X Y Z [ \ ] ^ _ |
||
1691 | 4150 F8273E 10 00 00 00 00 .DB _PT,_dc,_dc,_dc,_dc,_dc,_dc,_dc,_HE,_dc,_dc,_dc,_dc,_dc,_dc,_dc |
||
1692 | 00 00 00 0F 00 |
||
1693 | 00 00 00 00 00 |
||
1694 | 00 |
||
1695 | 4151 |
||
1696 | 4152 ; ` a b c d e f g h i j k l m n o |
||
1697 | 4153 F8274E 00 1B 09 11 0B .DB _dc,_xf,_SH,_ch,_de,_fe,_ff,_fg,_sh,_de,_dc,_dc,_lo,_dc,_dc,_dc |
||
1698 | 14 13 15 08 0B |
||
1699 | 00 00 07 00 00 |
||
1700 | 00 |
||
1701 | 4154 |
||
1702 | 4155 ; p q r s t u v w x y z { | } ~ DEL |
||
1703 | 4156 F8275E 0E 00 00 12 00 .DB _pt,_dc,_dc,_st,_dc,_un,_dc,_dc,_he,_dc,_dc,_dc,_dc,_dc,_dc,_dc |
||
1704 | 0C 00 00 0D 00 |
||
1705 | 00 00 00 00 00 |
||
1706 | 00 |
||
1707 | 4157 |
||
1708 | 4158 ; tabella funzioni scanning formato |
||
1709 | 4159 F8276E SCANTBL: |
||
1710 | 4160 F8276E 0126 9B25 C225 .DW case_dc, case_si, case_af, case_ar |
||
1711 | D425 |
||
1712 | 4161 F82776 BB25 5526 0326 .DW case_lj, case_pr, case_nu, case_lo |
||
1713 | 6226 |
||
1714 | 4162 F8277E 6626 6A26 AA25 .DW case_sh, case_SH, case_fz, case_de |
||
1715 | AA26 |
||
1716 | 4163 F82786 B026 9626 8426 .DW case_un, case_he, case_pt, case_HE |
||
1717 | 9226 |
||
1718 | 4164 F8278E 8026 C826 D226 .DW case_PT, case_ch, case_st, case_ff |
||
1719 | F826 |
||
1720 | 4165 F82796 E026 E826 DC26 .DW case_fe, case_fg, case_FE, case_FG |
||
1721 | E426 |
||
1722 | 4166 F8279E CD25 6E26 7226 .DW case_tg, case_bc, case_PS, case_xf |
||
1723 | F026 |
||
1724 | 4167 F827A6 EC26 .DW case_XF |
||
1725 | 4168 F827A8 |
||
1726 | 4169 ; tabella funzioni di conversione |
||
1727 | 4170 F827A8 CVTTBL: |
||
1728 | 4171 F827A8 A924 C724 F323 .DW DoChar, DoStr, DoPtr, DoInt, DoHex, DoFloat |
||
1729 | 2424 4E24 8323 |
||
1730 | 4172 F827B4 |
||
1731 | 4173 F827B4 NULLSTR: |
||
1732 | 4174 F827B4 28 6E 75 6C 6C .DB "(null)", 0 |
||
1733 | 29 00 |
||
1734 | |||
1735 | |||
1736 | Lines Assembled : 4009 Errors : 0 |
||
1737 | |||
1738 | |||
1739 |