Subversion Repositories MB01 Project

Rev

Blame | Last modification | View Log | Download | RSS feed

  Tue Jul 17 11:00:17 2018                                                                                               Page    1







          2500 A.D. 65816 Macro Assembler #26960 - Version 5.02g
          -----------------------------------------------------

                       Input  Filename : src\F8\vprint.asm
                       Output Filename : obj\F8\vprint.obj
                       Listing Has Been Relocated                               


 2642                           .LIST           on
 2643                           
 2644  F8FFB1                           .INCLUDE inc\dirp02.inc
 2645                           ;----------------------------------------------------------
 2646                           ; DIRP02.ASM
 2647                           ; PROGETTO: B1601
 2648                           ;
 2649                           ; Variabili in Direct Page $02
 2650                           ;----------------------------------------------------------
 2651                           
 2652                           ; sezione COMMON -- questo permette di includere il file in piu' file
 2653                           
 2654                           DIRP02: .SECTION page0, ref_only, common        ;Direct-Page 02
 2655                           
 2656  000000                           .ABSOLUTE               ;; inizia sempre da $00
 2657  000000                           .ORG            0x00
 2658  000000                           
 2659                           ; variabili usate nella funzione _vprintl e famiglia funzioni di formattazione
 2660  000000  0000             FmtParm         .DW             ;; ptr array parametri banco 0
 2661  000002                   FmtLPFmt        LP              ;; long ptr stringa szFmt
 2662  000005                   FmtLPPut        LP              ;; long ptr funzione 'putter'
 2663  000008  00               FmtSpec         .DB             ;; indice '%' corrente in szFmt
 2664  000009  00               FmtWidth        .DB             ;; campo width
 2665  00000A  00               FmtPrec         .DB             ;; campo precision
 2666  00000B  00               FmtFlag         .DB             ;; flag formattazione
 2667  00000C  00               FmtSgn          .DB             ;; segno positivo (se 0 -> no segno)
 2668  00000D  00               VStoreF         .DB             ;; flag modo store 
 2669  00000E  00               FmtMod          .DB             ;; flag modificatori
 2670  00000F  00               FmtDst          .DB             ;; ptr stringa szDst banco 0
 2671                           
 2672  000010  0000             FmtCnt          .DW             ;; contatore caratteri
 2673  000012  0000             FmtGMax         .DW             ;; max. len stringa globale
 2674  000014                                   
 2675  000014  0000             XVDec           .DW             ; esponente decimale (signed)
 2676  000016  00               XVFlag          .DB             ; flag per conversioni numeriche
 2677  000017                                                   
 2678  000017  00               ACMCmps         .DB             ; flag compare segno e tipo (intero)
 2679                           
 2680  000018                   ACM             DQ              ; accumulatore #1 integer 64 bit
 2681  000020  00               ACMSize         .DB             ; size
 2682  000021  00               ACMSgn          .DB             ; <7>:segno, <6>:tipo signed 
 2683  000022  00               ACMMinSize      .DB             ; minima dimensione richiesta per ACM
 2684  000023  00               IARGMinSize     .DB
 2685                           
 2686  000024  00               FPTmp1          .DB             ; byte temporaneo
 2687  000025  00               FPTmp2          .DB             ; byte temporaneo
  Tue Jul 17 11:00:17 2018                                                                                               Page    2




 2688  000026  00               FPTmp3          .DB             ; byte temporaneo
 2689  000027  00               FPTmp4          .DB             ; byte temporaneo
 2690                           
 2691  000028                   IARG            DQ              ; accumulatore #2 integer 64 bit
 2692  000030  00               IARGSize        .DB             ; size
 2693  000031  00               IARGSgn         .DB             ; <7>:segno, <6>:tipo signed 
 2694                           
 2695  000032                   FOP             DS      9       ; temporaneo per FDIV/FMULT/integer MULT/DIV
 2696                                                           ; conversione integer -> string
 2697  00003B  00               FPIndx          .DB             ; byte generico indice
 2698  00003C  0000             FPWTmp7         .DW             ; word temporanea
 2699  00003E  0000             FPWTmp8         .DW             ; word temporanea
 2700                           
 2701                           ; variabili temporanee sovrapposte a FOP
 2702          000036           FACXM           .EQU    FOP+4   ; byte temporaneo
 2703          000037           ARGXM           .EQU    FOP+5   ; byte temporaneo
 2704          000038           FPWTmp5         .EQU    FOP+6   ; word temporanea
 2705          00003A           FPTmp6          .EQU    FOP+8   ; byte temporaneo
 2706                           
 2707                           ; Floating Point Accumulator #1 - FAC
 2708  000040  00               FACSGN          .DB             ; FAC mantissa sign
 2709  000041  00               FACEXT          .DB             ; FAC 8 bit extension (rounding)
 2710  000042                   FACM            DQ              ; FAC Mantissa (64 bit)
 2711  00004A  0000             FACExp          .DW             ; FAC Exponent
 2712          00004A           FACEXPL         .EQU    FACExp          ; FAC Exponent Low
 2713          00004B           FACEXPH         .EQU    FACExp+1        ; FAC Exponent Hi
 2714                           
 2715  00004C  00               FACSCMP         .DB             ; Sign Comparison Result: FAC vs ARG
 2716  00004D  00               FACMlt          .DB             ; flag MULT
 2717  00004E  00               FACUndf         .DB             ; conteggio shift per underflow
 2718  00004F  00               FPDCnt          .DB             ; contatore per inserzione punto decimale
 2719  000050                                   
 2720                           ; Floating Point Accumulator #2 - ARG
 2721  000050  00               ARGSGN          .DB             ; ARG mantissa sign
 2722  000051  00               ARGEXT          .DB             ; ARG 8 bit extension (rounding)
 2723  000052                   ARGM            DQ              ; ARG Mantissa (64 bit)
 2724  00005A  0000             ARGExp          .DW             ; ARG Exponent
 2725          00005A           ARGEXPL         .EQU    ARGExp          ; ARG Exponent Low
 2726          00005B           ARGEXPH         .EQU    ARGExp+1        ; ARG Exponent Hi
 2727                           
 2728                           ; numero bytes FAC
 2729          00000A           FACSIZE         .EQU    (FACEXPH - FACEXT)
 2730          000008           MANTSIZE        .EQU    (FACSIZE - 2)
 2731          000040           FACMBITS        .EQU    (MANTSIZE * 8)
 2732          000041           FAC             .EQU    FACEXT
 2733          000051           ARG             .EQU    ARGEXT
 2734                           
 2735  00005C  0000             FPWTmp          .DW
 2736  00005E  0000             FPExp           .DW             ; esponente conversioni str/float
 2737  000060                   FPLPtr          LP              ; long ptr operazioni move
 2738  000063  00               FPFlag          .DB             ; flag generico operazioni FPU
 2739  000064                   FACTmp          .DS     12      ; registro FAC temporaneo (con sgn ed ext)
 2740                           
 2741                           ; buffer per conversione da int/float a string (20 digit + 2)
 2742          000016           FPSTRSIZE       .EQU    22
 2743  000070                   FPUStr          .DS     FPSTRSIZE
 2744                           
  Tue Jul 17 11:00:17 2018                                                                                               Page    3




 2745                           ; buffer per formattazione int/float
 2746          000030           XFSTRSIZE       .EQU    48
 2747  000086                   XCVTStr         .DS     XFSTRSIZE
 2748          0000B5           XCVTStrEnd      .EQU    ($ - 1)
 2749                           
 2750  0000B6                   DUMMY100        .DS     22
 2751                           
 2752          000060           PTR1    .EQU    FPLPtr          ; long ptr operazioni 'move'
 2753          000063           FPFLAG  .EQU    FPFlag
 2754          00004F           FPDCNT  .EQU    FPDCnt
 2755  0000CC                           
 2756  0000CC                           .RELATIVE
 2757                           
 2758                                   .ENDS
 2759                           
 2760          FFFFB0           MAXMANTSHIFT    .EQU    (-(FACMBITS + 16))      ; max. shift divisione mant.
 2761          00002F           XCVTMAXF        .EQU    (XFSTRSIZE - 1)         ; max. caratteri formato F
 2762          000027           XCVTMAXE        .EQU    (XCVTMAXF -  8)         ; max. caratteri formato E
 2763          00002E           XCVTMAXI        .EQU    (XFSTRSIZE - 2)         ; max. caratteri stringa int.
 2764                           
 2765  F8FFB1                           
 2766                           
 2767                           
 2768          000008           FMINPREC        .EQU    8       ; minimum float precision (if unspecified)
 2769          000205           GLPPUT          .EQU    DP02ADDR+FmtLPPut       ; long pointer to putter function
 2770                           
 2771  F8FFB1                           
 2772                           ;----------------------------------------------------------
 2773                           
 2774                           ; spec's class
 2775          000000           _dc     .EQU    0        ;/* don't care           */
 2776          000001           _si     .EQU    1       ;/* sign fill +/-        */
 2777          000002           _af     .EQU    2       ;/* alternate form       */
 2778          000003           _ar     .EQU    3       ;/* format (width or precision) by argument */
 2779          000004           _lj     .EQU    4       ;/* left justify         */
 2780          000005           _pr     .EQU    5       ;/* precision            */
 2781          000006           _nu     .EQU    6       ;/* numeral              */
 2782          000007           _lo     .EQU    7       ;/* long                 */
 2783          000008           _sh     .EQU    8       ;/* short                */
 2784          000009           _SH     .EQU    9       ;/* byte                 */
 2785          00000A           _fz     .EQU    10      ;/* fill zeros           */
 2786          00000B           _de     .EQU    11      ;/* decimal              */
 2787          00000C           _un     .EQU    12      ;/* unsigned decimal     */
 2788          00000D           _he     .EQU    13      ;/* hexadecimal          */
 2789          00000E           _pt     .EQU    14      ;/* pointer              */
 2790          00000F           _HE     .EQU    15      ;/* HEXADECIMAL          */
 2791          000010           _PT     .EQU    16      ;/* POINTER              */
 2792          000011           _ch     .EQU    17      ;/* char                 */
 2793          000012           _st     .EQU    18      ;/* string               */
 2794          000013           _ff     .EQU    19      ;/* float %f/F           */
 2795          000014           _fe     .EQU    20      ;/* float %e             */
 2796          000015           _fg     .EQU    21      ;/* float %g             */
 2797          000016           _FE     .EQU    22      ;/* float %E             */
 2798          000017           _FG     .EQU    23      ;/* float %G             */
 2799          000018           _tg     .EQU    24      ;/* thousand group       */
 2800          000019           _bc     .EQU    25      ;/* BCD float numbers    */
 2801          00001A           _PS     .EQU    26      ;/* pascal/basic string  */
  Tue Jul 17 11:00:17 2018                                                                                               Page    4




 2802          00001B           _xf     .EQU    27      ;/* hex float            */
 2803          00001C           _XF     .EQU    28      ;/* HEX FLOAT            */
 2804                           
 2805                           ; FmtFlag flag
 2806          000080           F_ALTFMT        .EQU    $80
 2807          000040           F_LEFTJ         .EQU    $40
 2808          000020           F_FILLZ         .EQU    $20
 2809          000010           F_GROUP         .EQU    $10
 2810          000008           F_WIDTH         .EQU    $08
 2811          000004           F_PREC          .EQU    $04
 2812                           
 2813                           ; FmtMod modifier's flag
 2814          000080           F2_PSSTRING     .EQU    $80
 2815          000040           F2_BCD          .EQU    $40
 2816          000020           F2_LONG         .EQU    $20
 2817          000010           F2_SHORT        .EQU    $10
 2818          000008           F2_BYTE         .EQU    $08
 2819          000004           F2_CAPS         .EQU    $04
 2820          000001           F2_SIGNED       .EQU    $01
 2821                           
 2822          000078           MASKMOD         .EQU    (F2_LONG.OR.F2_SHORT.OR.F2_BYTE.OR.F2_BCD)
 2823                           ; modifier mask '%c'
 2824          0000F8           MASKCHAR        .EQU    (MASKMOD.OR.F2_PSSTRING)
 2825                           ; modifier mask '%s'
 2826          000078           MASKSTR         .EQU    (MASKMOD)
 2827                           ; modifier mask '%p'
 2828          0000F8           MASKPTR         .EQU    (MASKCHAR)
 2829                           ; modifier mask float numbers
 2830          0000B8           MASKFLOAT       .EQU    (F2_LONG.OR.F2_SHORT.OR.F2_BYTE.OR.F2_PSSTRING)
 2831                           ; modifier mask integer
 2832          0000C0           MASKINTG        .EQU    (F2_BCD.OR.F2_PSSTRING)
 2833                           
 2834                           ; conversion function index 
 2835          000000           T_CHAR          .EQU    0
 2836          000002           T_STR           .EQU    (1 * 2)
 2837          000004           T_PTR           .EQU    (2 * 2)
 2838          000006           T_INT           .EQU    (3 * 2)
 2839          000008           T_HEX           .EQU    (4 * 2)
 2840          00000A           T_FLOAT         .EQU    (5 * 2)
 2841                           
 2842                           ; current stage while scan format
 2843          000000           FLAGSTAGE       .EQU    0
 2844          000001           FILLZSTAGE      .EQU    1
 2845          000002           WIDESTAGE       .EQU    2
 2846          000003           DOTSTAGE        .EQU    3
 2847          000004           PRECSTAGE       .EQU    4
 2848          000005           MODSTAGE        .EQU    5
 2849                           
 2850                           ; aux var's
 2851          00003C           PADCHR          .EQU    FPWTmp7         ; char per padding ('0' o ' ')
 2852          00003D           PFXCHR          .EQU    FPWTmp7+1       ; prefisso stringa (segno o '$')
 2853          00003E           NPADL           .EQU    FPWTmp8         ; numero char padding a sinistra
 2854          00003F           NPADR           .EQU    FPWTmp8+1       ; numero char padding a destra
 2855          00005C           STRLEN          .EQU    FPWTmp          ; lunghezza stringa da copiare
 2856          00005D           PFXFLAG         .EQU    FPWTmp+1        ; flag prefix segno/'$'
 2857          000063           FMTTMP          .EQU    FPFlag          ; temporaneo durante scanning formato
 2858                           
  Tue Jul 17 11:00:17 2018                                                                                               Page    5




 2859                           
 2860                           ;---------------------------------------------------------------------------
 2861                           ; code segment
 2862                           ;---------------------------------------------------------------------------
 2863                           
 2864                                   .CODEF8
 2865                                   .EXTERN _Int2Str, _feFAC2S, _MovMem2Fa
 2866  F82133                           
 2867                                   .GLOBAL sys_bprintf, sys_bsprintf, sys_bsprintf2, sys_bvprintf
 2868                           
 2869                           ;---------------------------------------------------------------------------
 2870                           ; system call interface
 2871                           ;---------------------------------------------------------------------------
 2872                           
 2873                           ; _bprintf:     format string and send to text default device,usually console
 2874                           ;               this function act like c-function printf()
 2875                           ;
 2876                           ; prototype:    _bprintf(count, format, ...)
 2877                           ;
 2878                           ;               count   =bytes count of all passed param's (count too)
 2879                           ;               format  =long pointer to format string
 2880                           ;               ...     =param's list (like in format string)
 2881                           ;
 2882                           ;               param's passed in reverse order in stack
 2883                           ;
 2884                           ;               all register's are preserved
 2885  F82133                   sys_bprintf:
 2886  F82133  A3 13                    lda     STKPRMS,s       ; count bytes params
 2887  F82135  83 04                    sta     STKCNT,s
 2888  F82137                           CPU16CLC                ; 16 bit + CLC
 2889  F82137  C2 31                    rep     #(PMFLAG.OR.PXFLAG.OR.PCFLAG)
 2890                                   .LONGA  on
 2891                                   .LONGI  on
 2892                                   .MNLIST
 2893  F82139  3B                       tsc
 2894  F8213A  69 14 00                 adc     #STKPRMS+1
 2895  F8213D  AA                       tax                     ; frame stack parametri
 2896  F8213E  A9 00 02                 lda     #DP02ADDR
 2897  F82141  5B                       tcd                     ; imposta DPR => pagina 02
 2898  F82142  64 12                    stz     FmtGMax         ; non usa stringa globale
 2899  F82144  64 05                    stz     FmtLPPut        ; non usa putter globale
 2900  F82146  BD 00 00                 lda     !0,x            ; carica puntatore stringa di formato
 2901  F82149  85 02                    sta     FmtLPFmt
 2902  F8214B  E8                       inx
 2903  F8214C  E8                       inx     
 2904  F8214D                           ACC08
 2905  F8214D  E2 20                    sep     #PMFLAG
 2906                                   .LONGA  off
 2907                                   .MNLIST
 2908  F8214F  64 07                    stz     FmtLPPut+2      ; non usa putter globale                        
 2909  F82151  BD 00 00                 lda     !0,x
 2910  F82154  85 04                    sta     FmtLPFmt+2
 2911  F82156  E8                       inx
 2912  F82157  86 00                    stx     FmtParm         ; salva frame stack parametri   
 2913  F82159                           CPU08
 2914  F82159  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 2915                                   .LONGA  off
  Tue Jul 17 11:00:17 2018                                                                                               Page    6




 2916                                   .LONGI  off
 2917                                   .MNLIST
 2918  F8215B  A9 80                    lda     #$80            ; call putter locale 
 2919  F8215D  20 2E 22                 jsr     _vprinter
 2920  F82160  18                       clc
 2921  F82161  6B                       rtl
 2922                           
 2923                           ; _bsprintf2:   format string and put result in a local string
 2924                           ;               this function act like c-function sprintf()
 2925                           ;
 2926                           ; prototype:    _bsprintf2(count, format, ...)
 2927                           ;
 2928                           ;               count   =bytes count of all passed param's (count too)
 2929                           ;               format  =long pointer to format string
 2930                           ;               ...     =param's list (like in format string)
 2931                           ;
 2932                           ;               param's passed in reverse order in stack
 2933                           ;
 2934                           ; out:          C       =offset of result local string
 2935                           ;               X       =bank that hold result local string
 2936                           ;
 2937                           ;               local string is limited to 255 bytes
 2938  F82162                   sys_bsprintf2:
 2939  F82162  A3 13                    lda     STKPRMS,s       ; count bytes params
 2940  F82164  83 04                    sta     STKCNT,s
 2941  F82166                           CPU16CLC                ; 16 bit + CLC
 2942  F82166  C2 31                    rep     #(PMFLAG.OR.PXFLAG.OR.PCFLAG)
 2943                                   .LONGA  on
 2944                                   .LONGI  on
 2945                                   .MNLIST
 2946  F82168  3B                       tsc
 2947  F82169  69 14 00                 adc     #STKPRMS+1
 2948  F8216C  AA                       tax                     ; frame stack parametri
 2949  F8216D  A9 00 02                 lda     #DP02ADDR
 2950  F82170  5B                       tcd                     ; imposta DPR => pagina 02
 2951  F82171  64 12                    stz     FmtGMax         ; non usa stringa globale
 2952  F82173  64 05                    stz     FmtLPPut        ; non usa putter globale
 2953  F82175  BD 00 00                 lda     !0,x            ; carica puntatore stringa di formato
 2954  F82178  85 02                    sta     FmtLPFmt
 2955  F8217A  E8                       inx
 2956  F8217B  E8                       inx     
 2957  F8217C                           ACC08
 2958  F8217C  E2 20                    sep     #PMFLAG
 2959                                   .LONGA  off
 2960                                   .MNLIST
 2961  F8217E  64 07                    stz     FmtLPPut+2      ; non usa putter globale                        
 2962  F82180  BD 00 00                 lda     !0,x
 2963  F82183  85 04                    sta     FmtLPFmt+2
 2964  F82185  E8                       inx
 2965  F82186  86 00                    stx     FmtParm         ; salva frame stack parametri   
 2966  F82188                           CPU08
 2967  F82188  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 2968                                   .LONGA  off
 2969                                   .LONGI  off
 2970                                   .MNLIST
 2971  F8218A  A9 00                    lda     #$00            ; local string 
 2972  F8218C  20 2E 22                 jsr     _vprinter
  Tue Jul 17 11:00:17 2018                                                                                               Page    7




 2973  F8218F                           ACC16
 2974  F8218F  C2 20                    rep     #PMFLAG
 2975                                   .LONGA  on
 2976                                   .MNLIST
 2977  F82191  A9 00 E0                 lda     #LVPBUF         ; buffer locale
 2978  F82194  83 0D                    sta     STKCR,s
 2979  F82196  A9 00 00                 lda     #^LVPBUF
 2980  F82199  83 0B                    sta     STKXR,s
 2981  F8219B                           ACC08
 2982  F8219B  E2 20                    sep     #PMFLAG
 2983                                   .LONGA  off
 2984                                   .MNLIST
 2985  F8219D  18                       clc
 2986  F8219E  6B                       rtl
 2987                           
 2988                           ; _bsprintf:    format string and put result in a global string
 2989                           ;               this function act like c-function sprintf()
 2990                           ;
 2991                           ; prototype:    _bsprintf(count, format, dest, size, ...)
 2992                           ;
 2993                           ;               count   =bytes count of all passed param's (count too)
 2994                           ;               format  =long pointer to format string
 2995                           ;               dest    =long pointer to destination string
 2996                           ;               size    = size of destination buffer
 2997                           ;               ...     =param's list (like in format string)
 2998                           ;
 2999                           ;               param's passed in reverse order in stack
 3000                           ;
 3001                           ; out:          C       =count of bytes needs for destination string not
 3002                           ;                        including the #0 terminator
 3003                           ;
 3004                           ;               if dest=NULL, function just compute the needs number of bytes
 3005                           ;               dest must have room at least for C+1 bytes
 3006  F8219F                   sys_bsprintf:
 3007  F8219F  A3 13                    lda     STKPRMS,s       ; count bytes params
 3008  F821A1  83 04                    sta     STKCNT,s
 3009  F821A3                           CPU16CLC                ; 16 bit + CLC
 3010  F821A3  C2 31                    rep     #(PMFLAG.OR.PXFLAG.OR.PCFLAG)
 3011                                   .LONGA  on
 3012                                   .LONGI  on
 3013                                   .MNLIST
 3014  F821A5  3B                       tsc
 3015  F821A6  69 14 00                 adc     #STKPRMS+1
 3016  F821A9  AA                       tax                     ; frame stack parametri
 3017  F821AA  A9 00 02                 lda     #DP02ADDR
 3018  F821AD  5B                       tcd                     ; imposta DPR => pagina 02
 3019  F821AE  BD 00 00                 lda     !0,x            ; carica puntatore stringa di formato
 3020  F821B1  85 02                    sta     FmtLPFmt
 3021  F821B3  E8                       inx
 3022  F821B4  E8                       inx     
 3023  F821B5                           ACC08
 3024  F821B5  E2 20                    sep     #PMFLAG
 3025                                   .LONGA  off
 3026                                   .MNLIST
 3027  F821B7  BD 00 00                 lda     !0,x
 3028  F821BA  85 04                    sta     FmtLPFmt+2
 3029  F821BC  E8                       inx
  Tue Jul 17 11:00:17 2018                                                                                               Page    8




 3030  F821BD                           ACC16
 3031  F821BD  C2 20                    rep     #PMFLAG
 3032                                   .LONGA  on
 3033                                   .MNLIST
 3034  F821BF  BD 00 00                 lda     !0,x            ; carica puntatore stringa destinazione
 3035  F821C2  85 05                    sta     FmtLPPut
 3036  F821C4  E8                       inx
 3037  F821C5  E8                       inx
 3038  F821C6                           ACC08
 3039  F821C6  E2 20                    sep     #PMFLAG
 3040                                   .LONGA  off
 3041                                   .MNLIST
 3042  F821C8  BD 00 00                 lda     !0,x
 3043  F821CB  85 07                    sta     FmtLPPut+2
 3044  F821CD  E8                       inx
 3045  F821CE                           ACC16
 3046  F821CE  C2 20                    rep     #PMFLAG
 3047                                   .LONGA  on
 3048                                   .MNLIST
 3049  F821D0  BD 00 00                 lda     !0,x
 3050  F821D3  85 12                    sta     FmtGMax         ; carica size stringa destinazione
 3051  F821D5  E8                       inx
 3052  F821D6  E8                       inx     
 3053  F821D7  86 00                    stx     FmtParm         ; salva frame stack parametri
 3054  F821D9                           CPU08
 3055  F821D9  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 3056                                   .LONGA  off
 3057                                   .LONGI  off
 3058                                   .MNLIST
 3059  F821DB  A9 40                    lda     #$40            ; stringa globale 
 3060  F821DD  20 2E 22                 jsr     _vprinter
 3061  F821E0                           ACC16
 3062  F821E0  C2 20                    rep     #PMFLAG
 3063                                   .LONGA  on
 3064                                   .MNLIST
 3065  F821E2  A5 10                    lda     FmtCnt          ; numero caratteri
 3066  F821E4  83 0D                    sta     STKCR,s
 3067  F821E6                           ACC08
 3068  F821E6  E2 20                    sep     #PMFLAG
 3069                                   .LONGA  off
 3070                                   .MNLIST
 3071  F821E8  18                       clc
 3072  F821E9  6B                       rtl
 3073                           
 3074                           ; _bvprintf:    format string and send result to an user-defined "putter"
 3075                           ;               function; this function act like c-function fprintf()
 3076                           ;
 3077                           ; prototype:    _bvprintf(count, format, putter...)
 3078                           ;
 3079                           ;               count   =bytes count of all passed param's (count too)
 3080                           ;               format  =long pointer to format string
 3081                           ;               putter  =long pointer to user-dfined putter function
 3082                           ;               ...     =param's list (like in format string)
 3083                           ;
 3084                           ;               param's passed in reverse order in stack
 3085                           ;
 3086                           ; out:          C       =count of bytes needs sent to user-defined putter, not
  Tue Jul 17 11:00:17 2018                                                                                               Page    9




 3087                           ;                        including the #0 terminator
 3088                           ;
 3089                           ;               the user-defined putter will end with an "rtl" instruction
 3090  F821EA                   sys_bvprintf:
 3091  F821EA  A3 13                    lda     STKPRMS,s       ; count bytes params
 3092  F821EC  83 04                    sta     STKCNT,s
 3093  F821EE                           CPU16CLC                ; 16 bit + CLC
 3094  F821EE  C2 31                    rep     #(PMFLAG.OR.PXFLAG.OR.PCFLAG)
 3095                                   .LONGA  on
 3096                                   .LONGI  on
 3097                                   .MNLIST
 3098  F821F0  3B                       tsc
 3099  F821F1  69 14 00                 adc     #STKPRMS+1
 3100  F821F4  AA                       tax                     ; frame stack parametri
 3101  F821F5  A9 00 02                 lda     #DP02ADDR
 3102  F821F8  5B                       tcd                     ; imposta DPR => pagina 02
 3103  F821F9  64 12                    stz     FmtGMax
 3104  F821FB  BD 00 00                 lda     !0,x            ; carica puntatore stringa di formato
 3105  F821FE  85 02                    sta     FmtLPFmt
 3106  F82200  E8                       inx
 3107  F82201  E8                       inx     
 3108  F82202                           ACC08
 3109  F82202  E2 20                    sep     #PMFLAG
 3110                                   .LONGA  off
 3111                                   .MNLIST
 3112  F82204  BD 00 00                 lda     !0,x
 3113  F82207  85 04                    sta     FmtLPFmt+2
 3114  F82209  E8                       inx
 3115  F8220A                           ACC16
 3116  F8220A  C2 20                    rep     #PMFLAG
 3117                                   .LONGA  on
 3118                                   .MNLIST
 3119  F8220C  BD 00 00                 lda     !0,x            ; carica puntatore stringa destinazione
 3120  F8220F  85 05                    sta     FmtLPPut
 3121  F82211  E8                       inx
 3122  F82212  E8                       inx
 3123  F82213                           ACC08
 3124  F82213  E2 20                    sep     #PMFLAG
 3125                                   .LONGA  off
 3126                                   .MNLIST
 3127  F82215  BD 00 00                 lda     !0,x
 3128  F82218  85 07                    sta     FmtLPPut+2
 3129  F8221A  E8                       inx
 3130  F8221B  86 00                    stx     FmtParm         ; salva frame stack parametri
 3131  F8221D                           CPU08
 3132  F8221D  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 3133                                   .LONGA  off
 3134                                   .LONGI  off
 3135                                   .MNLIST
 3136  F8221F  A9 C0                    lda     #$C0            ; putter globale 
 3137  F82221  20 2E 22                 jsr     _vprinter
 3138  F82224                           ACC16
 3139  F82224  C2 20                    rep     #PMFLAG
 3140                                   .LONGA  on
 3141                                   .MNLIST
 3142  F82226  A5 10                    lda     FmtCnt          ; numero caratteri
 3143  F82228  83 0D                    sta     STKCR,s
  Tue Jul 17 11:00:17 2018                                                                                               Page   10




 3144  F8222A                           ACC08
 3145  F8222A  E2 20                    sep     #PMFLAG
 3146                                   .LONGA  off
 3147                                   .MNLIST
 3148  F8222C  18                       clc
 3149  F8222D  6B                       rtl
 3150                           
 3151                           ; funzione locale di formattazione stringa                                                                              
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                
 3152                           ; In    - FmtLPFmt = long ptr stringa formato (szFmt)
 3153                           ;         FmtParm = ptr array parametri nel banco 0                                                                     
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                        
 3154                           ;         FmtLPPut = long ptr alla funzione 'putter' o a stringa globale
 3155                           ;         FmtGMax = max. lunghezza stringa globale (escluso NULL)
 3156                           ;         A => flag funzione    <7> => 0 -> store stringa / 1 -> store putter
 3157                           ;                               <6> => 0 -> locale / globale 
 3158                           ;         DBR = 0 (banco 0)
 3159                           ;         DPR = 2 (pagina 02)
 3160                           ;
 3161                           ; Out   - store locale => LVPBUF stringa formattata max. 255 car. (szDst)
 3162                           ;         store globale => stringa FmtLPPut formattata (max $FFFF car.)
 3163                           ;         putter locale => formattazione inviata al device TEXT corrente
 3164                           ;         putter globale => formattazione inviata a funzione putter
 3165  F8222E                   _vprinter:
 3166                                   .LONGA  off
 3167                                   .LONGI  off
 3168  F8222E                           
 3169  F8222E  A0 00                    ldy     #0                      ; azzera contatore caratteri
 3170  F82230  84 10                    sty     FmtCnt
 3171  F82232  84 11                    sty     FmtCnt+1
 3172  F82234  84 0F                    sty     FmtDst                  ; azzera indice stringa locale
 3173  F82236  85 0D                    sta     VStoreF                 ; flag store
 3174  F82238                           
 3175                                   ; LOOP scanning formato
 3176  F82238  B7 02            ?10:    lda     [FmtLPFmt],y            ; next char
 3177  F8223A  F0 57                    beq     ?60                     ; fine stringa - EXIT
 3178                                   ;bne    ?11
  Tue Jul 17 11:00:17 2018                                                                                               Page   11




 3179                                   ;jmp    ?60
 3180  F8223C  C9 25            ?11:    cmp     #'%'
 3181  F8223E  F0 06                    beq     ?14                     ; specificatore formato
 3182  F82240  C8               ?12:    iny                             ; ptr next char
 3183  F82241  20 09 23                 jsr     _store                  ; store char in szDst
 3184  F82244  80 F2                    bra     ?10                     ; loop
 3185  F82246  84 08            ?14:    sty     FmtSpec                 ; indice carattere '%' (per ABANDON)
 3186  F82248  C8                       iny
 3187  F82249  B7 02                    lda     [FmtLPFmt],y            ; next char dopo specificatore
 3188  F8224B  C9 25                    cmp     #'%'
 3189  F8224D  F0 F1                    beq     ?12                     ; '%%' -> store '%' e loop
 3190                           
 3191                                   ; analizza specificatore di formato dopo '%'
 3192  F8224F  A9 00                    lda     #0                      ; A = stage = 0 (flag stage)
 3193  F82251  85 0C                    sta     FmtSgn
 3194  F82253  85 0B                    sta     FmtFlag
 3195  F82255  85 0E                    sta     FmtMod  
 3196  F82257  85 09                    sta     FmtWidth
 3197  F82259  85 0A                    sta     FmtPrec
 3198  F8225B  80 01                    bra     ?21                     ; reload
 3199  F8225D                           
 3200                                   ; LOOP scanning specificatore formato
 3201  F8225D  C8               ?20:    iny
 3202                           
 3203                                   ; A = stage - Y = ptr corrente formato
 3204  F8225E  EB               ?21:    xba                             ; B = stage
 3205  F8225F  B7 02                    lda     [FmtLPFmt],y            ; A = next char dopo specificatore
 3206  F82261  F0 24                    beq     ?50                     ; fine stringa - ABANDON
 3207  F82263  85 63                    sta     FMTTMP                  ; salva char
 3208  F82265  38                       sec
 3209  F82266  E9 20                    sbc     #' '                    ; scala char to 0..5F
 3210  F82268  90 1D                    bcc     ?50                     ; char illegale a questo stadio
 3211  F8226A  C9 60                    cmp     #(128 - ' ')
 3212  F8226C  B0 19                    bcs     ?50                     ; char illegale a questo stadio
 3213  F8226E  AA                       tax                             ; X = indice 0..5F
 3214  F8226F  BF 0E 27 F8              lda     >CLASSCHR,x             ; A = class char
 3215  F82273  0A                       asl     a
 3216  F82274  AA                       tax                             ; indice funzione
 3217  F82275  A5 63                    lda     FMTTMP                  ; cur char
 3218  F82277  EB                       xba                             ; B = cur char, A = stage, ZF valido
 3219  F82278  FC 6E 27                 jsr     (SCANTBL,x)             ; scanning formato
 3220  F8227B  B0 0A            ?20a:   bcs     ?50                     ; errore formato - ABANDON
 3221  F8227D  50 DE                    bvc     ?20                     ; loop - scanning formato corrente
 3222  F8227F                           
 3223                                   ; a questo punto si assume che lo specificatore di formato sia stato
 3224                                   ; scannerizzato correttamente e che X contenga l'indice alla tabella
 3225                                   ; di conversione CVTTBL
 3226  F8227F  5A                       phy                             ; salva Y
 3227  F82280  FC A8 27                 jsr     (CVTTBL,x)              ; funzione di conversione
 3228  F82283  7A               ?20b:   ply                             ; ripristina Y
 3229  F82284  C8                       iny                             ; next char
 3230  F82285  80 B1                    bra     ?10                     ; loop - next formato
 3231  F82287                           
 3232                                   ; ABANDON - causa errore specificatore di formato si suppone che i
 3233                                   ; parametri non siano piu' allineati con il formato
 3234                                   ; viene quindi copiato letteralmente il resto di szFmt a partire
 3235                                   ; dal carattere '%' dove si e' verificato il disallineamento, fino
  Tue Jul 17 11:00:17 2018                                                                                               Page   12




 3236                                   ; alla fine della stringa szFmt
 3237  F82287  A4 08            ?50:    ldy     FmtSpec                 ; indice al carattere '%'
 3238  F82289  B7 02            ?52:    lda     [FmtLPFmt],y            ; copia da szFmt a szDst
 3239  F8228B  F0 06                    beq     ?60                     ; fino a fine stringa
 3240  F8228D  C8                       iny
 3241  F8228E  20 09 23                 jsr     _store
 3242  F82291  80 F6                    bra     ?52
 3243  F82293                           
 3244                                   ; EXIT
 3245                                   ; la funzione memorizza il terminatore #0 per indicare la fine
 3246                                   ; o chiama il putter per effettuare il flush del buffer
 3247  F82293  24 0D            ?60:    bit     VStoreF
 3248  F82295  30 13                    bmi     ?64                     ; chiama flusher locale/globale
 3249  F82297  70 06                    bvs     ?62                     ; termina stringa globale
 3250  F82299  A6 0F                    ldx     FmtDst                  ; indice stringa locale 
 3251  F8229B  9E 00 E0                 stz     !LVPBUF,x               ; store NULL at X = FmtDst
 3252  F8229E  60                       rts
 3253  F8229F                   ?62:    INDEX16
 3254  F8229F  C2 10                    rep     #PXFLAG
 3255                                   .LONGI  on
 3256                                   .MNLIST
 3257  F822A1  A4 10                    ldy     FmtCnt
 3258  F822A3  A9 00                    lda     #0
 3259  F822A5  97 05                    sta     [FmtLPPut],y            ; store NULL in stringa globale
 3260  F822A7                           INDEX08
 3261  F822A7  E2 10                    sep     #PXFLAG
 3262                                   .LONGI  off
 3263                                   .MNLIST
 3264  F822A9  60                       rts
 3265  F822AA  50 04            ?64:    bvc     _lflush                 ; termina putter locale
 3266  F822AC  A9 00                    lda     #0                      ; termina putter globale
 3267  F822AE  80 16                    bra     _gput
 3268  F822B0                           
 3269                           ;----------------------------------------------------------------------------
 3270                           ; FUNZIONI STORE/FLUSH
 3271                           ;----------------------------------------------------------------------------
 3272                           
 3273                           ; termina putter locale
 3274  F822B0                   _lflush:
 3275  F822B0  A6 0F                    ldx     FmtDst                  ; indice attuale buffer locale
 3276                           
 3277                           ; invia buffer locale al device selezionato     
 3278  F822B2                   _lflush2:
 3279  F822B2  9E 00 E0                 stz     !LVPBUF,x               ; termina stringa
 3280  F822B5  8A                       txa
 3281  F822B6  F0 0B                    beq     ?02                     ; buffer vuoto
 3282  F822B8                           ACC16
 3283  F822B8  C2 20                    rep     #PMFLAG
 3284                                   .LONGA  on
 3285                                   .MNLIST
 3286  F822BA  A9 00 E0                 lda     #LVPBUF                 ; CX = long ptr al buffer
 3287  F822BD                           ACC08
 3288  F822BD  E2 20                    sep     #PMFLAG
 3289                                   .LONGA  off
 3290                                   .MNLIST
 3291  F822BF  A2 00                    ldx     #0                      ; banco 0
 3292  F822C1                           TXTSTROUT               ; preserva A,X,Y
  Tue Jul 17 11:00:17 2018                                                                                               Page   13




 3293  F822C1  02 04                    cop     $04
 3294                                   .MNLIST
 3295  F822C3  60               ?02:    rts     
 3296                           
 3297                           ; funzione putter locale/globale
 3298  F822C4                   _putter:
 3299  F822C4  50 2E                    bvc     _lput                   ; putter locale
 3300  F822C6                           
 3301                           ; putter globale -- char NULL indica END-OF-FILE
 3302  F822C6                   _gput:
 3303  F822C6  85 4F                    sta     FPDCnt
 3304  F822C8  84 3B                    sty     FPIndx
 3305  F822CA  4B                       phk
 3306  F822CB  F4 EE 22                 pea     #?02-1                  ; salva ind. return => ?02
 3307  F822CE                           
 3308  F822CE  48                       pha
 3309  F822CF                           ACC16
 3310  F822CF  C2 20                    rep     #PMFLAG
 3311                                   .LONGA  on
 3312                                   .MNLIST
 3313  F822D1  AD 05 02                 lda     !GLPPUT
 3314  F822D4  8F E9 22 F8              sta     >?04+1
 3315  F822D8                           ACC08
 3316  F822D8  E2 20                    sep     #PMFLAG
 3317                                   .LONGA  off
 3318                                   .MNLIST
 3319  F822DA  AD 07 02                 lda     !GLPPUT+2
 3320  F822DD  8F EB 22 F8              sta     >?04+3
 3321  F822E1  68                       pla
 3322  F822E2  C9 00                    cmp     #0
 3323  F822E4  D0 02                    bne     ?04
 3324  F822E6  EA                       nop
 3325  F822E7  EA                       nop
 3326  F822E8  5C 00 FF 80      ?04:    jml     $80FF00
 3327  F822EC                           
 3328  F822EC  DC 05 02                 jml     [GLPPUT]                ; deve terminare con RTL
 3329  F822EF  A4 3B            ?02:    ldy     FPIndx
 3330  F822F1  A5 4F                    lda     FPDCnt
 3331  F822F3  60                       rts
 3332  F822F4                                   
 3333                           ; funzione putter locale
 3334  F822F4                   _lput:
 3335  F822F4  20 15 23                 jsr     _lstor                  ; bufferizza in stringa locale
 3336  F822F7  D0 0F                    bne     ?02                     ; buffer non pieno
 3337  F822F9  85 4F                    sta     FPDCnt                  ; salva char    
 3338  F822FB  20 B2 22                 jsr     _lflush2                ; flush buffer
 3339  F822FE  A2 00                    ldx     #0
 3340  F82300  A5 4F                    lda     FPDCnt                  ; memorizza char attuale
 3341  F82302  9D 00 E0                 sta     !LVPBUF,x               ; store at X = 0
 3342  F82305  E8                       inx
 3343  F82306  86 0F                    stx     FmtDst
 3344  F82308  60               ?02:    rts
 3345                           
 3346                           ; store char in stringa locale/globale o invia carattere al 'putter'
 3347  F82309                   _store:
 3348  F82309                           ACC16
 3349  F82309  C2 20                    rep     #PMFLAG
  Tue Jul 17 11:00:17 2018                                                                                               Page   14




 3350                                   .LONGA  on
 3351                                   .MNLIST
 3352  F8230B  E6 10                    inc     FmtCnt                  ; update numero bytes (16 bit)
 3353  F8230D                           ACC08
 3354  F8230D  E2 20                    sep     #PMFLAG
 3355                                   .LONGA  off
 3356                                   .MNLIST
 3357  F8230F  24 0D                    bit     VStoreF
 3358  F82311  30 B1                    bmi     _putter                 ; chiama putter locale/globale
 3359  F82313  70 0D                    bvs     _gstor                  ; store in stringa globale
 3360                           
 3361                           ; store char in stringa locale
 3362  F82315                   _lstor:
 3363  F82315  A6 0F                    ldx     FmtDst                  ; indice stringa locale
 3364  F82317  E0 FF                    cpx     #$FF                    ; test overflow
 3365  F82319  F0 06                    beq     ?02                     ; no store (FmtDst = $FF)
 3366  F8231B  9D 00 E0                 sta     !LVPBUF,x               ; store at X = FmtDst
 3367  F8231E  E8                       inx
 3368  F8231F  86 0F                    stx     FmtDst
 3369  F82321  60               ?02:    rts
 3370                           
 3371                           ; store char in stringa globale
 3372  F82322                   _gstor:
 3373  F82322  84 3B                    sty     FPIndx                  ; salva Y
 3374  F82324                           INDEX16
 3375  F82324  C2 10                    rep     #PXFLAG
 3376                                   .LONGI  on
 3377                                   .MNLIST
 3378  F82326  A4 10                    ldy     FmtCnt
 3379  F82328  88                       dey                             ; indice attuale stringa globale
 3380  F82329  C4 12                    cpy     FmtGMax                 ; overflow stringa ?
 3381  F8232B  B0 02                    bcs     ?02                     ; si -- no store
 3382  F8232D  97 05                    sta     [FmtLPPut],y            ; store in stringa globale
 3383  F8232F                   ?02:    INDEX08
 3384  F8232F  E2 10                    sep     #PXFLAG
 3385                                   .LONGI  off
 3386                                   .MNLIST
 3387  F82331  A4 3B                    ldy     FPIndx
 3388  F82333  60                       rts
 3389                           
 3390                           ;----------------------------------------------------------------------------
 3391                           ; FUNZIONI DI CONVERSIONE (FORMATTAZIONE)
 3392                           ;----------------------------------------------------------------------------
 3393                           
 3394                           ; preleva integer dai parametri e lo copia in ACM
 3395  F82334                   getint:
 3396  F82334  A0 01                    ldy     #1
 3397  F82336  A5 0E                    lda     FmtMod
 3398  F82338  89 08                    bit     #F2_BYTE
 3399  F8233A  D0 0D                    bne     ?02                     ; byte -> size = 1
 3400  F8233C  C8                       iny
 3401  F8233D  89 10                    bit     #F2_SHORT
 3402  F8233F  D0 08                    bne     ?02                     ; word -> size = 2
 3403  F82341  A0 08                    ldy     #8
 3404  F82343  89 20                    bit     #F2_LONG
 3405  F82345  D0 02                    bne     ?02                     ; quad -> size = 8
 3406  F82347  A0 04                    ldy     #4                      ; dword -> size = 4
  Tue Jul 17 11:00:17 2018                                                                                               Page   15




 3407  F82349  84 20            ?02:    sty     ACMSize                 ; size
 3408  F8234B  64 21                    stz     ACMSgn                  ; unsigned per il momento
 3409  F8234D                           INDEX16
 3410  F8234D  C2 10                    rep     #PXFLAG
 3411                                   .LONGI  on
 3412                                   .MNLIST
 3413  F8234F  A6 00                    ldx     FmtParm                 ; indice parametri
 3414  F82351  BD 00 00                 lda     !0,x                    ; get byte
 3415  F82354  85 18                    sta     <ACM
 3416  F82356  E8                       inx
 3417  F82357  88                       dey
 3418  F82358  F0 24                    beq     ?06                     ; size = 1 (byte)
 3419  F8235A  BD 00 00                 lda     !0,x                    ; get byte
 3420  F8235D  85 19                    sta     <ACM+1
 3421  F8235F  E8                       inx
 3422  F82360  88                       dey
 3423  F82361  F0 1B                    beq     ?06                     ; size = 2 (word)
 3424  F82363                           ACC16
 3425  F82363  C2 20                    rep     #PMFLAG
 3426                                   .LONGA  on
 3427                                   .MNLIST
 3428  F82365  BD 00 00                 lda     !0,x                    ; get word
 3429  F82368  85 1A                    sta     <ACM+2
 3430  F8236A  E8                       inx
 3431  F8236B  E8                       inx
 3432  F8236C  88                       dey
 3433  F8236D  88                       dey
 3434  F8236E  F0 0E                    beq     ?06                     ; size = 4 (dword)
 3435  F82370  BD 00 00                 lda     !0,x                    ; get word
 3436  F82373  85 1C                    sta     <ACM+4
 3437  F82375  E8                       inx
 3438  F82376  E8                       inx
 3439  F82377  BD 00 00                 lda     !0,x                    ; get word
 3440  F8237A  85 1E                    sta     <ACM+6                  ; size = 8 (quad)
 3441  F8237C  E8                       inx
 3442  F8237D  E8                       inx     
 3443  F8237E  86 00            ?06:    stx     FmtParm                 ; aggiorna indice array parametri
 3444  F82380                           CPU08
 3445  F82380  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 3446                                   .LONGA  off
 3447                                   .LONGI  off
 3448                                   .MNLIST
 3449  F82382  60                       rts
 3450                           
 3451  F82383                   DoFloat:
 3452  F82383  A5 0B                    lda     FmtFlag
 3453  F82385  89 04                    bit     #F_PREC
 3454  F82387  D0 0C                    bne     ?01                     ; specificata la precision
 3455  F82389  A2 08                    ldx     #FMINPREC               ; imposta minima precisione
 3456  F8238B  A5 16                    lda     XVFlag
 3457  F8238D  89 04                    bit     #$04
 3458  F8238F  F0 02                    beq     ?00                     ; no formato a/A
 3459  F82391  A2 00                    ldx     #0                      ; minima precisone formato a/A = 0
 3460  F82393  86 0A            ?00:    stx     FmtPrec
 3461  F82395  A5 0E            ?01:    lda     FmtMod
 3462  F82397  89 04                    bit     #F2_CAPS
 3463  F82399  F0 04                    beq     ?02
  Tue Jul 17 11:00:17 2018                                                                                               Page   16




 3464  F8239B  A9 08                    lda     #$08                    ; flag CAPS
 3465  F8239D  04 16                    tsb     XVFlag
 3466  F8239F  24 0B            ?02:    bit     FmtFlag
 3467  F823A1  10 04                    bpl     ?04                     ; no formato alt.
 3468  F823A3  A9 10                    lda     #$10                    ; flag formato alt
 3469  F823A5  04 16                    tsb     XVFlag
 3470  F823A7  A6 0C            ?04:    ldx     FmtSgn                  ; segno ?
 3471  F823A9  F0 0C                    beq     ?08                     ; no
 3472  F823AB  A9 01                    lda     #$01                    ; flag segno
 3473  F823AD  E0 2B                    cpx     #'+'
 3474  F823AF  F0 02                    beq     ?06                     ; usa '+'
 3475  F823B1  09 02                    ora     #$02                    ; usa ' '
 3476  F823B3  05 16            ?06:    ora     XVFlag
 3477  F823B5  85 16                    sta     XVFlag
 3478  F823B7                   ?08:    INDEX16
 3479  F823B7  C2 10                    rep     #PXFLAG
 3480                                   .LONGI  on
 3481                                   .MNLIST
 3482  F823B9  A6 00                    ldx     FmtParm                 ; indice parametri
 3483  F823BB  BD 00 00                 lda     !0,x                    ; get long pointer
 3484  F823BE  85 60                    sta     PTR1
 3485  F823C0  E8                       inx
 3486  F823C1  BD 00 00                 lda     !0,x
 3487  F823C4  85 61                    sta     PTR1+1
 3488  F823C6  E8                       inx
 3489  F823C7  BD 00 00                 lda     !0,x
 3490  F823CA  85 62                    sta     PTR1+2
 3491  F823CC  E8                       inx     
 3492  F823CD  86 00                    stx     FmtParm                 ; aggiorna indice array parametri
 3493  F823CF                           INDEX08
 3494  F823CF  E2 10                    sep     #PXFLAG
 3495                                   .LONGI  off
 3496                                   .MNLIST
 3497  F823D1  A9 80                    lda     #F_ALTFMT
 3498  F823D3  14 0B                    trb     FmtFlag                 ; ignora formato alt. nel futuro
 3499  F823D5  24 0E                    bit     FmtMod
 3500  F823D7  50 0D                    bvc     ?20                     ; binary float
 3501  F823D9  20 69 3D                 jsr     _MovMem2Fa
 3502  F823DC  A5 16                    lda     XVFlag
 3503  F823DE  A6 0A                    ldx     FmtPrec
 3504  F823E0  20 D9 40                 jsr     _feFAC2S                ; BCD float
 3505  F823E3  4C 6C 24                 jmp     DoNum
 3506  F823E6  20 69 3D         ?20:    jsr     _MovMem2Fa              ; binary float  
 3507  F823E9  A5 16                    lda     XVFlag
 3508  F823EB  A6 0A                    ldx     FmtPrec
 3509  F823ED  20 D9 40                 jsr     _feFAC2S
 3510  F823F0  4C 6C 24                 jmp     DoNum
 3511                           
 3512                           ; formattazione long pointer p,P
 3513  F823F3                   DoPtr:
 3514  F823F3  A0 03                    ldy     #3                      
 3515  F823F5  84 20                    sty     ACMSize                 ; size = 3
 3516  F823F7  64 21                    stz     ACMSgn                  ; unsigned
 3517  F823F9                           INDEX16
 3518  F823F9  C2 10                    rep     #PXFLAG
 3519                                   .LONGI  on
 3520                                   .MNLIST
  Tue Jul 17 11:00:17 2018                                                                                               Page   17




 3521  F823FB  A6 00                    ldx     FmtParm                 ; indice parametri
 3522  F823FD  BD 00 00                 lda     !0,x                    ; get byte
 3523  F82400  85 18                    sta     <ACM
 3524  F82402  E8                       inx
 3525  F82403  BD 00 00                 lda     !0,x                    ; get byte
 3526  F82406  85 19                    sta     <ACM+1
 3527  F82408  E8                       inx
 3528  F82409  BD 00 00                 lda     !0,x                    ; get byte
 3529  F8240C  85 1A                    sta     <ACM+2
 3530  F8240E  E8                       inx
 3531  F8240F  86 00                    stx     FmtParm                 ; aggiorna indice array parametri
 3532  F82411                           INDEX08
 3533  F82411  E2 10                    sep     #PXFLAG
 3534                                   .LONGI  off
 3535                                   .MNLIST
 3536  F82413  A0 00                    ldy     #0                      ; flag hex minuscolo
 3537  F82415  A5 0E                    lda     FmtMod
 3538  F82417  89 04                    bit     #F2_CAPS
 3539  F82419  F0 02                    beq     ?02
 3540  F8241B  A0 40                    ldy     #$40                    ; flag hex maiuscolo
 3541  F8241D  98               ?02:    tya
 3542  F8241E  09 10                    ora     #$10                    ; flag formato ptr
 3543  F82420  A2 06                    ldx     #6                      ; precision = 6
 3544  F82422  80 45                    bra     DoInt3  
 3545  F82424                           
 3546                           ; formattazione interi decimali i,d,u
 3547  F82424                   DoInt:
 3548  F82424  20 34 23                 jsr     getint                  ; preleva integer
 3549  F82427  A0 80                    ldy     #$80                    ; flag decimale
 3550  F82429  A5 0B                    lda     FmtFlag
 3551  F8242B  89 10                    bit     #F_GROUP
 3552  F8242D  F0 02                    beq     ?08                     ; no group
 3553  F8242F  A0 C0                    ldy     #$C0                    ; flag decimale + group
 3554  F82431  A5 0E            ?08:    lda     FmtMod
 3555  F82433  4A                       lsr     a                       ; CF = 1 => signed
 3556  F82434  90 25                    bcc     DoInt2                  ; unsigned
 3557  F82436  A6 20                    ldx     <ACMSize
 3558  F82438  CA                       dex
 3559  F82439  B5 18                    lda     <ACM,x                  ; MSB
 3560  F8243B  29 80                    and     #$80                    ; maschera segno
 3561  F8243D  09 40                    ora     #$40                    ; tipo signed
 3562  F8243F  85 21                    sta     ACMSgn
 3563  F82441  A6 0C                    ldx     FmtSgn                  ; segno ?
 3564  F82443  F0 16                    beq     DoInt2                  ; no
 3565  F82445  C8                       iny                             ; flag segno
 3566  F82446  E0 2B                    cpx     #'+'
 3567  F82448  F0 11                    beq     DoInt2                  ; usa '+'
 3568  F8244A  C8                       iny
 3569  F8244B  C8                       iny                             ; usa ' '
 3570  F8244C  80 0D                    bra     DoInt2
 3571  F8244E                           
 3572                           ; formattazione interi esadecimali x,X
 3573  F8244E                   DoHex:
 3574  F8244E  20 34 23                 jsr     getint                  ; preleva integer
 3575  F82451  A0 00                    ldy     #0                      ; flag hex minuscolo
 3576  F82453  A5 0E                    lda     FmtMod
 3577  F82455  89 04                    bit     #F2_CAPS
  Tue Jul 17 11:00:17 2018                                                                                               Page   18




 3578  F82457  F0 02                    beq     DoInt2
 3579  F82459  A0 40                    ldy     #$40                    ; flag hex maiuscolo
 3580                           
 3581  F8245B                   DoInt2:
 3582  F8245B  A2 01                    ldx     #1                      ; default precision
 3583  F8245D  A5 0B                    lda     FmtFlag
 3584  F8245F  89 04                    bit     #F_PREC
 3585  F82461  F0 05                    beq     ?14
 3586  F82463  A6 0A                    ldx     FmtPrec
 3587  F82465  D0 01                    bne     ?14
 3588  F82467  E8                       inx                             ; minima precision = 1
 3589  F82468  98               ?14:    tya                             ; A = flag
 3590                           
 3591  F82469                   DoInt3:
 3592  F82469  20 80 30                 jsr     _Int2Str                ; A = Y = len -- X = ptr stringa
 3593  F8246C                           
 3594  F8246C                   DoNum:
 3595  F8246C  64 5D                    stz     PFXFLAG                 ; flag store segno / '$'
 3596  F8246E  24 0B                    bit     FmtFlag
 3597  F82470  10 04                    bpl     ?04                     ; solo p/P/x/X ammettono prefisso
 3598  F82472  A9 24                    lda     #'$'                    ; prefisso alt. form.
 3599  F82474  80 16                    bra     ?08
 3600  F82476  A5 0E            ?04:    lda     FmtMod
 3601  F82478  89 01                    bit     #F2_SIGNED
 3602  F8247A  F0 22                    beq     ?20                     ; unsigned -- no strip segno
 3603  F8247C  B5 00                    lda     <0,x                    ; segno prima del digit
 3604  F8247E  C9 2B                    cmp     #'+'
 3605  F82480  F0 08                    beq     ?06
 3606  F82482  C9 2D                    cmp     #'-'
 3607  F82484  F0 04                    beq     ?06
 3608  F82486  C9 20                    cmp     #' '
 3609  F82488  D0 14                    bne     ?20                     ; nessun segno prima del digit
 3610  F8248A  E8               ?06:    inx                             ; sposta ptr. al primo digit
 3611  F8248B  88                       dey                             ; lunghezza stringa originale - 1
 3612  F8248C  85 3D            ?08:    sta     PFXCHR                  ; segno numero o prefisso '$'
 3613  F8248E                           
 3614                                   ; ora il segno del numero e' stato strippato o il prefisso e' stato
 3615                                   ; fissato ed occorre stabilire se esso va emesso come primo
 3616                                   ; carattere oppure no.
 3617                                   ; Se e' stato specificato il campo width con allineamento di default
 3618                                   ; a destra ed il padding a sinistra viene effettuato con '0' allora
 3619                                   ; il segno/prefisso va emesso come primo carattere, altrimenti va
 3620                                   ; emesso prima della stringa numerica. Dato che il padding a destra
 3621                                   ; avviene sempre con blank, il prefisso/segno va emesso come primo
 3622                                   ; carattere se F_FILLZ e F_WIDTH sono entrambi settati.
 3623  F8248E                           
 3624  F8248E  A5 0B                    lda     FmtFlag
 3625  F82490  29 28                    and     #(F_FILLZ.OR.F_WIDTH)   ; specificato width con padding '0' ?
 3626  F82492  C9 28                    cmp     #(F_FILLZ.OR.F_WIDTH)
 3627  F82494  F0 04                    beq     ?10                     ; si - emette segno/prefisso per primo
 3628  F82496  A9 40                    lda     #$40                    ; no - emette segno/prefisso dopo
 3629  F82498  D0 02                    bne     ?12
 3630  F8249A  A9 80            ?10:    lda     #$80                    ; per primo
 3631  F8249C  85 5D            ?12:    sta     PFXFLAG
 3632  F8249E  86 60            ?20:    stx     PTR1                    ; store puntatore
 3633  F824A0  A9 02                    lda     #>DP02ADDR
 3634  F824A2  85 61                    sta     PTR1+1
  Tue Jul 17 11:00:17 2018                                                                                               Page   19




 3635  F824A4  64 62                    stz     PTR1+2                  ; banco 0
 3636  F824A6  4C 29 25                 jmp     fmtstr  
 3637  F824A9                           
 3638                           ; formattazione '%c' -- tipo char
 3639  F824A9                   DoChar:
 3640  F824A9                           INDEX16
 3641  F824A9  C2 10                    rep     #PXFLAG
 3642                                   .LONGI  on
 3643                                   .MNLIST
 3644  F824AB  A6 00                    ldx     FmtParm                 ; indice parametri
 3645  F824AD  BD 00 00                 lda     !0,x                    ; get char
 3646  F824B0  E8                       inx
 3647  F824B1  86 00                    stx     FmtParm                 ; aggiorna indice array parametri
 3648  F824B3                           INDEX08
 3649  F824B3  E2 10                    sep     #PXFLAG
 3650                                   .LONGI  off
 3651                                   .MNLIST
 3652  F824B5  85 70                    sta     FPUStr                  ; stringa temporanea
 3653  F824B7  64 71                    stz     FPUStr+1                ; di 1 carattere
 3654  F824B9  A9 70                    lda     #FPUStr
 3655  F824BB  85 60                    sta     PTR1                    ; ptr stringa da copiare
 3656  F824BD  A9 02                    lda     #>DP02ADDR
 3657  F824BF  85 61                    sta     PTR1+1
 3658  F824C1  64 62                    stz     PTR1+2                  ; banco 0
 3659  F824C3  A0 01                    ldy     #1                      ; lunghezza = 1
 3660  F824C5  80 60                    bra     clrpfx
 3661  F824C7                           
 3662                           ; formattazione '%s' -- tipo stringa
 3663  F824C7                   DoStr:
 3664  F824C7  A0 00                    ldy     #0
 3665  F824C9                           INDEX16
 3666  F824C9  C2 10                    rep     #PXFLAG
 3667                                   .LONGI  on
 3668                                   .MNLIST
 3669  F824CB  A6 00                    ldx     FmtParm                 ; indice parametri
 3670  F824CD  BD 00 00                 lda     !0,x                    ; get long ptr
 3671  F824D0  85 60                    sta     PTR1
 3672  F824D2  E8                       inx
 3673  F824D3  BD 00 00                 lda     !0,x                    ; get long ptr
 3674  F824D6  85 61                    sta     PTR1+1
 3675  F824D8  E8                       inx
 3676  F824D9  BD 00 00                 lda     !0,x                    ; get long ptr
 3677  F824DC  85 62                    sta     PTR1+2
 3678  F824DE  E8                       inx
 3679  F824DF  86 00                    stx     FmtParm                 ; aggiorna indice array parametri
 3680  F824E1  05 61                    ora     PTR1+1                  ; test ptr NULL
 3681  F824E3  05 60                    ora     PTR1
 3682  F824E5  D0 0E                    bne     ?00                     ; ptr != NULL
 3683  F824E7  A9 B4                    lda     #<NULLSTR               ; copia stringa di default "(null)"
 3684  F824E9  85 60                    sta     PTR1
 3685  F824EB  A9 27                    lda     #>NULLSTR
 3686  F824ED  85 61                    sta     PTR1+1
 3687  F824EF  A9 F8                    lda     #^NULLSTR               ; oppure .HIGH8.
 3688  F824F1  85 62                    sta     PTR1+2
 3689  F824F3  80 15                    bra     ?01
 3690  F824F5  A5 0E            ?00:    lda     FmtMod
 3691  F824F7  89 80                    bit     #F2_PSSTRING
  Tue Jul 17 11:00:17 2018                                                                                               Page   20




 3692  F824F9  F0 0F                    beq     ?01                     ; stringa stile C
 3693  F824FB  A7 60                    lda     [PTR1]                  ; lunghezza stringa pascal/basic
 3694  F824FD  A8                       tay
 3695  F824FE                           ACC16                           ; char stringa pascal dopo lunghezza
 3696  F824FE  C2 20                    rep     #PMFLAG
 3697                                   .LONGA  on
 3698                                   .MNLIST
 3699  F82500  E6 60                    inc     PTR1
 3700  F82502                           ACC08
 3701  F82502  E2 20                    sep     #PMFLAG
 3702                                   .LONGA  off
 3703                                   .MNLIST
 3704  F82504  D0 13                    bne     ?03
 3705  F82506  E6 62                    inc     PTR1+2
 3706  F82508  80 0F                    bra     ?03
 3707  F8250A  B7 60            ?01:    lda     [PTR1],y                ; calcola lunghezza stringa stile C
 3708  F8250C  F0 03                    beq     ?02
 3709  F8250E  C8                       iny
 3710  F8250F  D0 F9                    bne     ?01
 3711  F82511  C0 00 01         ?02:    cpy     #$0100                  ; max. 255 caratteri
 3712  F82514  90 03                    bcc     ?03
 3713  F82516  A0 FF 00                 ldy     #$00FF
 3714  F82519                   ?03:    INDEX08                         ; Y = lunghezza stringa
 3715  F82519  E2 10                    sep     #PXFLAG
 3716                                   .LONGI  off
 3717                                   .MNLIST
 3718  F8251B  A5 0B                    lda     FmtFlag                 ; test 'precision'
 3719  F8251D  89 04                    bit     #F_PREC
 3720  F8251F  F0 06                    beq     clrpfx                  ; no precision specificata
 3721  F82521  C4 0A                    cpy     FmtPrec                 ; Len >= precision ?
 3722  F82523  90 02                    bcc     clrpfx                  ; NO
 3723  F82525  A4 0A                    ldy     FmtPrec                 ; SI -> Len = precision
 3724                                                                   ; precision puo' troncare la stringa    
 3725  F82527                   clrpfx:
 3726  F82527  64 5D                    stz     PFXFLAG
 3727  F82529                           
 3728                           ; formatta stringa
 3729  F82529                   fmtstr:
 3730  F82529  84 5C                    sty     STRLEN                  ; salva lunghezza stringa da copiare
 3731  F8252B  64 3E                    stz     NPADL                   ; no padding a sinistra
 3732  F8252D  64 3F                    stz     NPADR                   ; no padding a destra
 3733  F8252F  A5 5D                    lda     PFXFLAG                 ; occorre memorizzare prefix/segno ?
 3734  F82531  29 C0                    and     #$C0
 3735  F82533  F0 01                    beq     ?02                     ; NO
 3736  F82535  C8                       iny                             ; conteggia 1 byte in +
 3737  F82536  84 27            ?02:    sty     FPTmp4                  ; lunghezza reale stringa
 3738  F82538  A5 0B                    lda     FmtFlag
 3739  F8253A  89 08                    bit     #F_WIDTH
 3740  F8253C  F0 22                    beq     ?18                     ; no padding sx/dx
 3741  F8253E  A5 09                    lda     FmtWidth
 3742  F82540  F0 1E                    beq     ?18                     ; width = 0 => no padding 
 3743  F82542  38                       sec
 3744  F82543  E5 27                    sbc     FPTmp4
 3745  F82545  F0 19                    beq     ?18                     ; width = len => no padding
 3746  F82547  90 17                    bcc     ?18                     ; width < len => no padding
 3747  F82549  AA                       tax                             ; X = width - len => padding
 3748  F8254A  A5 0B                    lda     FmtFlag
  Tue Jul 17 11:00:17 2018                                                                                               Page   21




 3749  F8254C  89 40                    bit     #F_LEFTJ
 3750  F8254E  F0 04                    beq     ?04                     ; allineameno a destra (default)
 3751  F82550  86 3F                    stx     NPADR                   ; allinea a sinistra => padding a dx                    
 3752  F82552  80 08                    bra     ?06                     ; padding a dx sempre con blank
 3753  F82554  86 3E            ?04:    stx     NPADL                   ; allinea a dx => padding a sx
 3754  F82556  A2 30                    ldx     #'0'                     ; pad con '0' ?
 3755  F82558  89 20                    bit     #F_FILLZ
 3756  F8255A  D0 02                    bne     ?08                     ; SI
 3757  F8255C  A2 20            ?06:    ldx     #' '                    ; NO -- padding con blank
 3758  F8255E  86 3C            ?08:    stx     PADCHR
 3759  F82560  24 5D            ?18:    bit     PFXFLAG                 ; segno o prefisso '$' come primo ?
 3760  F82562  10 05                    bpl     ?20                     ; NO
 3761  F82564  A5 3D                    lda     PFXCHR                  ; store segno/prefix
 3762  F82566  20 09 23                 jsr     _store
 3763  F82569  A4 3E            ?20:    ldy     NPADL                   ; numero char padding a sinistra
 3764  F8256B  F0 08                    beq     ?24                     ; no padding a sinistra
 3765  F8256D  A5 3C                    lda     PADCHR                  ; carattere di padding
 3766  F8256F  20 09 23         ?22:    jsr     _store
 3767  F82572  88                       dey
 3768  F82573  D0 FA                    bne     ?22
 3769  F82575  24 5D            ?24:    bit     PFXFLAG                 ; segno o prefisso '$' adesso ?
 3770  F82577  50 05                    bvc     ?26                     ; NO
 3771  F82579  A5 3D                    lda     PFXCHR                  ; store segno/prefix
 3772  F8257B  20 09 23                 jsr     _store
 3773  F8257E  A4 5C            ?26:    ldy     STRLEN                  ; copia la stringa 
 3774  F82580  F0 0C                    beq     ?30                     ; non ci sono char da copiare
 3775  F82582  A0 00                    ldy     #0
 3776  F82584  B7 60            ?28:    lda     [PTR1],y                ; copia byte a byte
 3777  F82586  20 09 23                 jsr     _store
 3778  F82589  C8                       iny
 3779  F8258A  C6 5C                    dec     STRLEN
 3780  F8258C  D0 F6                    bne     ?28
 3781  F8258E  A4 3F            ?30:    ldy     NPADR                   ; numero char padding a destra
 3782  F82590  F0 08                    beq     ?34                     ; no padding a destra
 3783  F82592  A5 3C                    lda     PADCHR                  ; carattere di padding
 3784  F82594  20 09 23         ?32:    jsr     _store
 3785  F82597  88                       dey
 3786  F82598  D0 FA                    bne     ?32
 3787  F8259A  60               ?34:    rts
 3788  F8259B                           
 3789                           ;----------------------------------------------------------------------------
 3790                           ; FUNZIONI SCANNING SPECIFICATORE DI FORMATO 
 3791                           ; 
 3792                           ; In    - B = cur char, A = stage (e flag N,Z)
 3793                           ;
 3794                           ; Out   - CF = 0 -> OK, A = stage, VF = 0 -> continua scanning
 3795                           ;              VF = 1 -> fine scanning, X -> indice funzione conversione
 3796                           ;         CF = 1 -> formato errato
 3797                           ;----------------------------------------------------------------------------
 3798                           
 3799                           ; case ' ' or '+' -- valido solo nello stato stage = 0
 3800  F8259B                   case_si:
 3801  F8259B  D0 64                    bne     case_dc                 ; abandon
 3802  F8259D  A6 0C                    ldx     FmtSgn
 3803  F8259F  E0 2B                    cpx     #'+'
 3804  F825A1  F0 04                    beq     ?04                     ; ignora ' ' se '+' gia' specificato
 3805  F825A3  EB                       xba                             ; A = cur char - B = stage
  Tue Jul 17 11:00:17 2018                                                                                               Page   22




 3806  F825A4  85 0C                    sta     FmtSgn
 3807  F825A6  EB                       xba                             ; A = stage
 3808  F825A7                   ?04:
 3809  F825A7  18               retok:  clc                             ; OK
 3810  F825A8  B8                       clv                             ; continua scanning
 3811  F825A9  60                       rts
 3812                           
 3813                           ; case digit '0' - padding a sinistra con '0' invece di ' '
 3814                           ; '0' o e' il primo digit del campo width, oppure e' un digit successivo
 3815                           ; che fa parte del campo width o del campo precision
 3816  F825AA                   case_fz:
 3817                                   ; il flag Z e' valido -- indica se stage = 0
 3818  F825AA  D0 57                    bne     case_nu                 ; digit fa parte di width/precision ?
 3819  F825AC  AA                       tax                             ; X = stage
 3820  F825AD  A9 40                    lda     #F_LEFTJ
 3821  F825AF  24 0B                    bit     FmtFlag                 ; ignora padding '0' se left just.
 3822  F825B1  F0 03                    beq     ?01
 3823  F825B3  8A                       txa                             ; A = stage
 3824  F825B4  D0 F1                    bne     retok
 3825  F825B6  A9 20            ?01:    lda     #F_FILLZ                ; padding '0'
 3826  F825B8  E8                       inx                             ; X = 1 -> padding stage
 3827  F825B9  80 0C                    bra     setflag                 ; dopo deve seguire campo width
 3828                           
 3829                           ; case '-'  -- valido solo nello stato stage = 0
 3830  F825BB                   case_lj:
 3831  F825BB  D0 44                    bne     case_dc                 ; abandon
 3832  F825BD  AA                       tax                             ; X = stage
 3833  F825BE  A9 40                    lda     #F_LEFTJ                ; flag allineamento a sx
 3834  F825C0  80 05                    bra     setflag
 3835  F825C2                           
 3836                           ; case '#' -- valido solo nello stato stage = 0
 3837  F825C2                   case_af:
 3838  F825C2  D0 3D                    bne     case_dc                 ; abandon
 3839  F825C4  AA                       tax                             ; X = stage
 3840  F825C5  A9 80                    lda     #F_ALTFMT               ; flag formato alt. 
 3841  F825C7                   setflag:
 3842  F825C7  04 0B                    tsb     FmtFlag
 3843  F825C9  8A                       txa                             ; A = stage
 3844  F825CA  18                       clc                             ; OK
 3845  F825CB  B8                       clv                             ; continua scanning
 3846  F825CC  60                       rts
 3847                           
 3848                           ; case ',' -- valido solo nello stato stage = 0
 3849  F825CD                   case_tg:
 3850  F825CD  D0 32                    bne     case_dc                 ; abandon
 3851  F825CF  AA                       tax                             ; X = stage
 3852  F825D0  A9 10                    lda     #F_GROUP                ; flag group&thousand 
 3853  F825D2  80 F3                    bra     setflag
 3854  F825D4                           
 3855                           ; case '*' - argomento per width o precision
 3856  F825D4                   case_ar:
 3857  F825D4  EB                       xba                             ; salva stage
 3858  F825D5                           INDEX16
 3859  F825D5  C2 10                    rep     #PXFLAG
 3860                                   .LONGI  on
 3861                                   .MNLIST
 3862  F825D7  A6 00                    ldx     FmtParm                 ; indice parametro byte
  Tue Jul 17 11:00:17 2018                                                                                               Page   23




 3863  F825D9  BD 00 00                 lda     !0,x
 3864  F825DC  E8                       inx
 3865  F825DD  86 00                    stx     FmtParm                 ; next param
 3866  F825DF                           INDEX08
 3867  F825DF  E2 10                    sep     #PXFLAG
 3868                                   .LONGI  off
 3869                                   .MNLIST
 3870  F825E1  AA                       tax                             ; X = param
 3871  F825E2  EB                       xba                             ; A = stage
 3872  F825E3  C9 02                    cmp     #WIDESTAGE
 3873  F825E5  B0 0B                    bcs     ?04                     ; campo precision ?
 3874  F825E7  86 09                    stx     FmtWidth                ; store width
 3875  F825E9  A9 08                    lda     #F_WIDTH
 3876  F825EB  04 0B                    tsb     FmtFlag                 ; imposta flag campo 'width'
 3877  F825ED  A9 03                    lda     #DOTSTAGE               ; next: campo precisione
 3878  F825EF  18                       clc                             ; OK
 3879  F825F0  B8                       clv                             ; continua scanning
 3880  F825F1  60                       rts
 3881  F825F2  C9 04            ?04:    cmp     #PRECSTAGE
 3882  F825F4  D0 0B                    bne     case_dc                 ; abandon
 3883  F825F6  86 0A                    stx     FmtPrec                 ; store precision
 3884  F825F8  AA                       tax                             ; X = stage
 3885  F825F9  A9 04                    lda     #F_PREC
 3886  F825FB  04 0B                    tsb     FmtFlag                 ; imposta flag campo 'precision'
 3887  F825FD  8A                       txa                             ; A = stage (mantiene stesso stage)
 3888  F825FE  18                       clc                             ; OK
 3889  F825FF  B8                       clv                             ; continua scanning
 3890  F82600  60                       rts     
 3891  F82601                           
 3892                           ; caratteri illegali - abbandona conversione
 3893  F82601                   case_dc:
 3894  F82601  38                       sec                             ; flag abandon
 3895  F82602  60                       rts
 3896                           
 3897                           ; case '0'..'9' - digit che fanno parte o di 'width' o di 'precision'
 3898                           ; FmtWidth e FmtPrec sono inizializzati a ZERO quindi si somma il digit
 3899                           ; direttamente al valore corrente
 3900  F82603                   case_nu:
 3901  F82603  AA                       tax                             ; X = stage
 3902  F82604  EB                       xba                             ; A = char '0'..'9'
 3903  F82605  38                       sec
 3904  F82606  E9 30                    sbc     #'0'                     ; scala a 0..9
 3905  F82608  E0 03                    cpx     #WIDESTAGE+1            ; parte di specifica width ?
 3906  F8260A  B0 25                    bcs     ?10                     ; no - parte di specifica precision
 3907  F8260C  AA                       tax                             ; X = number 0..9
 3908  F8260D  A5 09                    lda     FmtWidth
 3909  F8260F  86 09                    stx     FmtWidth
 3910  F82611  F0 15                    beq     ?04                     ; old width = 0 
 3911  F82613  0A                       asl     a                       ; width * 2
 3912  F82614  B0 3E                    bcs     ?20                     ; overflow
 3913  F82616  85 63                    sta     FMTTMP
 3914  F82618  0A                       asl     a
 3915  F82619  B0 39                    bcs     ?20                     ; overflow
 3916  F8261B  0A                       asl     a                       ; width * 8
 3917  F8261C  B0 36                    bcs     ?20                     ; overflow
 3918  F8261E  65 63                    adc     FMTTMP                  ; width * 10
 3919  F82620  B0 32                    bcs     ?20                     ; overflow
  Tue Jul 17 11:00:17 2018                                                                                               Page   24




 3920  F82622  65 09                    adc     FmtWidth                ; (width * 10) + number
 3921  F82624  B0 2E                    bcs     ?20                     ; overflow
 3922  F82626  85 09                    sta     FmtWidth
 3923  F82628  A9 08            ?04:    lda     #F_WIDTH
 3924  F8262A  04 0B                    tsb     FmtFlag                 ; imposta flag campo 'width'
 3925  F8262C  A9 02                    lda     #WIDESTAGE              ; current stage: campo numerico 'width'
 3926  F8262E  18                       clc                             ; OK
 3927  F8262F  B8                       clv                             ; continua scanning
 3928  F82630  60                       rts
 3929  F82631  E0 04            ?10:    cpx     #PRECSTAGE              ; stage precision ? 
 3930  F82633  D0 CC                    bne     case_dc                 ; no -- abandon
 3931  F82635  AA                       tax                             ; X = number 0..9
 3932  F82636  A5 0A                    lda     FmtPrec
 3933  F82638  86 0A                    stx     FmtPrec
 3934  F8263A  F0 15                    beq     ?14                     ; old prec = 0 
 3935  F8263C  0A                       asl     a                       ; prec * 2
 3936  F8263D  B0 15                    bcs     ?20                     ; overflow
 3937  F8263F  85 63                    sta     FMTTMP
 3938  F82641  0A                       asl     a
 3939  F82642  B0 10                    bcs     ?20                     ; overflow
 3940  F82644  0A                       asl     a                       ; prec * 8
 3941  F82645  B0 0D                    bcs     ?20                     ; overflow
 3942  F82647  65 63                    adc     FMTTMP                  ; prec * 10
 3943  F82649  B0 09                    bcs     ?20                     ; overflow
 3944  F8264B  65 0A                    adc     FmtPrec                 ; (prec * 10) + number
 3945  F8264D  B0 05                    bcs     ?20                     ; overflow
 3946  F8264F  85 0A                    sta     FmtPrec
 3947  F82651  EB               ?14:    xba                             ; mantiene stesso stadio
 3948  F82652  18                       clc                             ; OK
 3949  F82653  B8                       clv                             ; continua scanning
 3950  F82654  60               ?20:    rts
 3951                           
 3952                           ; case '.' -- valido solo se stato corrente < precstage
 3953  F82655                   case_pr:
 3954  F82655  C9 04                    cmp     #PRECSTAGE
 3955  F82657  B0 08                    bcs     ?01                     ; abandon
 3956  F82659  A9 04                    lda     #F_PREC
 3957  F8265B  04 0B                    tsb     FmtFlag                 ; imposta flag campo precision
 3958  F8265D  A9 04                    lda     #PRECSTAGE              ; imposta stato corrente = precstage
 3959  F8265F  18                       clc                             ; OK
 3960  F82660  B8                       clv                             ; continua scanning
 3961  F82661  60               ?01:    rts
 3962                           
 3963                           ;============================================================================
 3964                           ; modificatori -- impostano lo stato MODSTAGE (dopo sono ammessi solo i tipi)
 3965                           
 3966                           ; case 'l' -- modificatore 'long'
 3967  F82662                   case_lo:
 3968  F82662  A2 20                    ldx     #F2_LONG
 3969  F82664  80 0E                    bra     setmod
 3970                           
 3971                           ; case 'h' -- modificatore 'short'
 3972  F82666                   case_sh:
 3973  F82666  A2 10                    ldx     #F2_SHORT
 3974  F82668  80 0A                    bra     setmod
 3975                           
 3976                           ; case 'b' -- modificatore 'byte'
  Tue Jul 17 11:00:17 2018                                                                                               Page   25




 3977  F8266A                   case_SH:
 3978  F8266A  A2 08                    ldx     #F2_BYTE
 3979  F8266C  80 06                    bra     setmod
 3980                           
 3981                           ; case 'D' -- modificatore BCD float number
 3982  F8266E                   case_bc:
 3983  F8266E  A2 40                    ldx     #F2_BCD
 3984  F82670  80 02                    bra     setmod
 3985  F82672                           
 3986                           ; case 'B' -- modificatore stringa pascal/basic
 3987  F82672                   case_PS:
 3988  F82672  A2 80                    ldx     #F2_PSSTRING
 3989                           
 3990  F82674                   setmod:
 3991  F82674  C9 05                    cmp     #MODSTAGE
 3992  F82676  B0 07                    bcs     ?10                     ; abandon
 3993  F82678  8A                       txa
 3994  F82679  04 0E                    tsb     FmtMod  
 3995  F8267B  A9 05                    lda     #MODSTAGE               ; stadio finale specificatore
 3996  F8267D  18                       clc     ; OK
 3997  F8267E  B8                       clv     ; continua scanning
 3998  F8267F  60               ?10:    rts
 3999  F82680                           
 4000                           ;============================================================================
 4001                           ; specificatori di tipo -- qualsiasi tipo a qualsiasi stadio termina
 4002                           ; lo scanning 
 4003                           
 4004                           ; case 'P' -- pointer HEX
 4005  F82680                   case_PT:
 4006  F82680  A9 04                    lda     #F2_CAPS                ; set CAPS
 4007  F82682  04 0E                    tsb     FmtMod
 4008                           
 4009                           ; case 'p' -- pointer hex
 4010  F82684                   case_pt:
 4011  F82684  A9 01                    lda     #F2_SIGNED
 4012  F82686  14 0E                    trb     FmtMod                  ; clear flag signed
 4013  F82688  A9 20                    lda     #F_FILLZ                ; ignora padding a sx. con '0'
 4014  F8268A  14 0B                    trb     FmtFlag
 4015  F8268C  A2 04                    ldx     #T_PTR                  ; indice funzione conversione
 4016  F8268E  A9 F8                    lda     #MASKPTR                ; maschera modificatori non ammessi
 4017  F82690  80 72                    bra     tsttype
 4018  F82692                           
 4019                           ; case 'X' -- unsigned HEX
 4020  F82692                   case_HE:
 4021  F82692  A9 04                    lda     #F2_CAPS
 4022  F82694  04 0E                    tsb     FmtMod
 4023  F82696                           
 4024                           ; case 'x' -- unsigned hex
 4025  F82696                   case_he:
 4026  F82696  A9 01                    lda     #F2_SIGNED
 4027  F82698  14 0E                    trb     FmtMod                  ; clear flag signed
 4028  F8269A  A5 0B                    lda     FmtFlag
 4029  F8269C  89 04                    bit     #F_PREC
 4030  F8269E  F0 04                    beq     ?02
 4031  F826A0  A9 20                    lda     #F_FILLZ                ; ignora padding a sx. con '0'
 4032  F826A2  14 0B                    trb     FmtFlag                 ; se specificata precision
 4033  F826A4  A2 08            ?02:    ldx     #T_HEX                  ; indice funzione conversione
  Tue Jul 17 11:00:17 2018                                                                                               Page   26




 4034  F826A6  A9 C0                    lda     #MASKINTG               ; maschera modificatori non ammessi
 4035  F826A8  80 5A                    bra     tsttype
 4036                           
 4037                           ; case 'd', 'i' -- signed integer
 4038  F826AA                   case_de:
 4039  F826AA  A9 01                    lda     #F2_SIGNED
 4040  F826AC  04 0E                    tsb     FmtMod                  ; set flag signed
 4041  F826AE  80 04                    bra     case_i
 4042                           
 4043                           ; case 'u' -- unsigned integer
 4044  F826B0                   case_un:
 4045  F826B0  A9 01                    lda     #F2_SIGNED
 4046  F826B2  14 0E                    trb     FmtMod                  ; clear flag signed
 4047                           
 4048                           ; parte comune per gli interi decimali
 4049  F826B4                   case_i:
 4050  F826B4  A5 0B                    lda     FmtFlag
 4051  F826B6  89 04                    bit     #F_PREC
 4052  F826B8  F0 04                    beq     ?02
 4053  F826BA  A9 20                    lda     #F_FILLZ                ; ignora padding a sx. con '0'
 4054  F826BC  14 0B                    trb     FmtFlag                 ; se specificata precision
 4055  F826BE  A9 80            ?02:    lda     #F_ALTFMT
 4056  F826C0  14 0B                    trb     FmtFlag                 ; decimale ignora formato alternativo
 4057  F826C2  A2 06                    ldx     #T_INT                  ; indice funzione conversione
 4058  F826C4  A9 C0                    lda     #MASKINTG               ; maschera modificatori non ammessi
 4059  F826C6  80 3C                    bra     tsttype
 4060                           
 4061                           ; case 'c' -- char
 4062  F826C8                   case_ch:
 4063  F826C8  A9 84                    lda     #(F_ALTFMT.OR.F_PREC)   ; ignora precision e formato alt.
 4064  F826CA  14 0B                    trb     FmtFlag
 4065  F826CC  A2 00                    ldx     #T_CHAR                 ; indice funzione conversione
 4066  F826CE  A9 F8                    lda     #MASKCHAR               ; maschera modificatori non ammessi
 4067  F826D0  80 32                    bra     tsttype
 4068  F826D2                           
 4069                           ; case 's' -- string
 4070  F826D2                   case_st:
 4071  F826D2  A9 80                    lda     #F_ALTFMT               ; ignora formato alt.
 4072  F826D4  14 0B                    trb     FmtFlag
 4073  F826D6  A2 02                    ldx     #T_STR                  ; indice funzione conversione
 4074  F826D8  A9 78                    lda     #MASKSTR                ; maschera modificatori non ammessi
 4075  F826DA  80 28                    bra     tsttype
 4076                           
 4077                           ; case 'E' -- float formato EXP
 4078  F826DC                   case_FE:
 4079  F826DC  A9 04                    lda     #F2_CAPS
 4080  F826DE  04 0E                    tsb     FmtMod
 4081                           
 4082                           ; case 'e' -- float formato exp
 4083  F826E0                   case_fe:
 4084  F826E0  A9 00                    lda     #$00                    ; flag formato e/E
 4085  F826E2  80 16                    bra     case_f
 4086  F826E4                           
 4087                           ; case 'G' -- float formato G
 4088  F826E4                   case_FG:
 4089  F826E4  A9 04                    lda     #F2_CAPS
 4090  F826E6  04 0E                    tsb     FmtMod
  Tue Jul 17 11:00:17 2018                                                                                               Page   27




 4091                           
 4092                           ; case 'g' -- float formato g
 4093  F826E8                   case_fg:
 4094  F826E8  A9 40                    lda     #$40                    ; flag formato g/G
 4095  F826EA  80 0E                    bra     case_f
 4096  F826EC                           
 4097                           ; case 'A' -- float formato A
 4098  F826EC                   case_XF:
 4099  F826EC  A9 04                    lda     #F2_CAPS
 4100  F826EE  04 0E                    tsb     FmtMod
 4101                           
 4102                           ; case 'a' -- float formato a
 4103  F826F0                   case_xf:
 4104  F826F0  A9 20                    lda     #F_FILLZ                ; formato a/A no padding a sx con '0'
 4105  F826F2  14 0B                    trb     FmtFlag
 4106  F826F4  A9 04                    lda     #$04                    ; flag formato a/A
 4107  F826F6  80 02                    bra     case_f
 4108                           
 4109                           ; case 'f', 'F' -- float formato decimale
 4110  F826F8                   case_ff:
 4111  F826F8  A9 20                    lda     #$20                    ; flag formato f/F
 4112                           
 4113                           ; parte comune ai numeri float
 4114  F826FA                   case_f:
 4115                                   ; i numeri float possono avere padding a sx con '0' anche se viene
 4116                                   ; specificata la precision
 4117  F826FA  85 16                    sta     XVFlag                  ; flag formattazione
 4118  F826FC  A9 01                    lda     #F2_SIGNED
 4119  F826FE  04 0E                    tsb     FmtMod                  ; set flag signed       
 4120  F82700  A2 0A                    ldx     #T_FLOAT                ; indice funzione conversione   
 4121  F82702  A9 B8                    lda     #MASKFLOAT              ; maschera modificatori non ammessi
 4122                           
 4123                           ; testa modificatore tipo
 4124  F82704                   tsttype:
 4125  F82704  24 0E                    bit     FmtMod                  ; test modificatori non ammessi
 4126  F82706  F0 02                    beq     ?04                     ; OK
 4127  F82708  38                       sec                             ; abandon
 4128  F82709  60                       rts
 4129  F8270A  E2 40            ?04:    sep     #PVFLAG                 ; set V = 1 -- fine scanning 
 4130  F8270C  18                       clc                             ; OK  -> conversione
 4131  F8270D  60                       rts
 4132  F8270E                                   
 4133                           ;----------------------------------------------------------------------------
 4134                           ; COSTANTI
 4135                           ;----------------------------------------------------------------------------
 4136                           
 4137                           ; tabella classi caratteri di conversione (carattere >= 32 e < 128)
 4138  F8270E                   CLASSCHR:
 4139                           
 4140                           ;            SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
 4141  F8270E  01 00 00 02 00           .DB _si,_dc,_dc,_af,_dc,_dc,_dc,_dc,_dc,_dc,_ar,_si,_tg,_lj,_pr,_dc
               00 00 00 00 00 
               03 01 18 04 05 
               00 
 4142                           
 4143                           ;             0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
 4144  F8271E  0A 06 06 06 06           .DB _fz,_nu,_nu,_nu,_nu,_nu,_nu,_nu,_nu,_nu,_dc,_dc,_dc,_dc,_dc,_dc
  Tue Jul 17 11:00:17 2018                                                                                               Page   28




               06 06 06 06 06 
               00 00 00 00 00 
               00 
 4145                           
 4146                           ;             _   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
 4147  F8272E  00 1C 1A 00 19           .DB _dc,_XF,_PS,_dc,_bc,_FE,_ff,_FG,_dc,_dc,_dc,_dc,_dc,_dc,_dc,_dc
               16 13 17 00 00 
               00 00 00 00 00 
               00 
 4148                           
 4149                           ;             P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _ 
 4150  F8273E  10 00 00 00 00           .DB _PT,_dc,_dc,_dc,_dc,_dc,_dc,_dc,_HE,_dc,_dc,_dc,_dc,_dc,_dc,_dc
               00 00 00 0F 00 
               00 00 00 00 00 
               00 
 4151                           
 4152                           ;             `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
 4153  F8274E  00 1B 09 11 0B           .DB _dc,_xf,_SH,_ch,_de,_fe,_ff,_fg,_sh,_de,_dc,_dc,_lo,_dc,_dc,_dc
               14 13 15 08 0B 
               00 00 07 00 00 
               00 
 4154                           
 4155                           ;             p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~ DEL 
 4156  F8275E  0E 00 00 12 00           .DB _pt,_dc,_dc,_st,_dc,_un,_dc,_dc,_he,_dc,_dc,_dc,_dc,_dc,_dc,_dc
               0C 00 00 0D 00 
               00 00 00 00 00 
               00 
 4157                           
 4158                           ; tabella funzioni scanning formato
 4159  F8276E                   SCANTBL:
 4160  F8276E  0126 9B25 C225           .DW     case_dc, case_si, case_af, case_ar
               D425 
 4161  F82776  BB25 5526 0326           .DW     case_lj, case_pr, case_nu, case_lo
               6226 
 4162  F8277E  6626 6A26 AA25           .DW     case_sh, case_SH, case_fz, case_de
               AA26 
 4163  F82786  B026 9626 8426           .DW     case_un, case_he, case_pt, case_HE
               9226 
 4164  F8278E  8026 C826 D226           .DW     case_PT, case_ch, case_st, case_ff
               F826 
 4165  F82796  E026 E826 DC26           .DW     case_fe, case_fg, case_FE, case_FG
               E426 
 4166  F8279E  CD25 6E26 7226           .DW     case_tg, case_bc, case_PS, case_xf
               F026 
 4167  F827A6  EC26                     .DW     case_XF
 4168  F827A8                           
 4169                           ; tabella funzioni di conversione
 4170  F827A8                   CVTTBL:
 4171  F827A8  A924 C724 F323           .DW     DoChar, DoStr, DoPtr, DoInt, DoHex, DoFloat
               2424 4E24 8323 
 4172  F827B4                           
 4173  F827B4                   NULLSTR:
 4174  F827B4  28 6E 75 6C 6C           .DB     "(null)", 0
               29 00 


             Lines Assembled : 4009                  Errors : 0