Subversion Repositories MB01 Project

Rev

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

  Tue Jul 17 11:00:19 2018                                                                                               Page    1







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

                       Input  Filename : src\F9\fdir.asm
                       Output Filename : obj\F9\fdir.obj
                       Listing Has Been Relocated                               


 2473                                   .LIST on
 2474                           
 2475                           ;---------------------------------------------------------------------------
 2476                           ; direct-page working area for filesystem managment
 2477                           ;---------------------------------------------------------------------------
 2478                           
 2479                           DPFSW:  .SECTION page0, ref_only, common        ;Direct Page f.s. working area
 2480                           
 2481  000000                           .ABSOLUTE               ;; start always at $00
 2482  000000                           .ORG            0x00
 2483                           
 2484                           ;---------------------------------------------------------------------------
 2485                           ; this section is copied from the PDT of selected drive
 2486                           ; note: in the LBA address we assume that the MSB 4 bit are all '0'
 2487  000000  00               fdrvfg          .DB             ; <7>: H.D. (1) / F.D. (0)
 2488                                                           ; <6>: 1440k (1) / 720k (0) if <7> = 1
 2489  000001  00               ffsfg           .DB             ; <7>: FAT (1) / CBM (0)
 2490  000002  00               fclusiz         .DB             ; cluster size in # sector's (1,2,4,8,10,20,40)
 2491  000003  00               fclush          .DB             ; shift cluster (0,1,2,3,4,5,6)
 2492  000004  00               fatsiz          .DB             ; FAT table size in # sector's (0 = 256 sect.)
 2493  000005  00               frootsiz        .DB             ; root directory size in # sector's
 2494  000006  0000             frootent        .DW             ; root directory # entries
 2495  000008                   ffat1lba        .DS     3       ; LBA of FAT 1 starting
 2496  00000B                   ffat2lba        .DS     3       ; LBA of FAT 2 starting
 2497  00000E                   frootlba        .DS     3       ; LBA of root directory starting
 2498  000011                   fclulba         .DS     3       ; LBA of first cluster (cluster #2)
 2499  000014  0000             fclucnt         .DW             ; # of cluster's in FAT volume
 2500  000016  0000             fclufree        .DW             ; the count of free cluster's
 2501  000018  0000             fclunxt         .DW             ; the next free cluster #
 2502  00001A  0000             fcdclu          .DW             ; cluster # where starting c.d.
 2503  00001C  0000             fcdparent       .DW             ; cluster # parent of the c.d.
 2504  00001E  0000             fcdparx         .DW             ; index entry on parent cluster of c.d.
 2505  000020  00               fcdlen          .DB             ; lenght of current directory string
 2506                                                           ; c.d. string start with '/', w/o trailing '/' 
 2507  000021  00               fcdlst          .DB             ; index of last '/' in c.d. string
 2508                           
 2509                           ;---------------------------------------------------------------------------
 2510                           
 2511  000022                   FPathStr        .DS     2
 2512                           
 2513  000024                   fpaths          .DS     78      ; path string (without starting 'X:')
 2514  000072  00               fdrive          .DB             ; the drive used in current operation
 2515  000073  00               fdefdrv         .DB             ; default drive (the one currently selected)
 2516  000074  00               fexpfg          .DB             ; <7>: fexpand file name (1) / directory (0)
 2517                                                           ; <6>: local calls to fexpand (1)
 2518  000075  00               devfg           .DB             ; <7>: specified a device name in path
  Tue Jul 17 11:00:19 2018                                                                                               Page    2




 2519  000076  00               devidx          .DB             ; index of device
 2520  000077  00               haswild         .DB             ; <7>: path contain wildcards
 2521  000078  00               fdrvlst         .DB             ; last operative drive ($FF mean invalid)
 2522  000079                   fpdtp           LP              ; long pointer to PDT of fdrive
 2523  00007C  00               storfg          .DB
 2524  00007D  00               wildfg          .DB
 2525  00007E  00               dotfg           .DB
 2526  00007F  00               maxcnt          .DB
 2527  000080  00               cnt             .DB
 2528  000081  00               cnt1            .DB
 2529  000082  00               cntx            .DB
 2530  000083                   LPtr1           LP
 2531  000086                   LPtr2           LP
 2532  000089  00               FDirIdx         .DB
 2533                           ;FPathStr       .DS     2
 2534  00008A                   CDLen           .DS     6
 2535  000090  00               lstidx          .DB
 2536  000091  00               FEndDir         .DB
 2537  000092                   tmpfcb          .DS     16
 2538  0000A2                   LPtr3           LP
 2539                           
 2540  0000A5                           .RELATIVE
 2541                           
 2542                                   .ENDS
 2543                           
 2544                           ;---------------------------------------------------------------------------
 2545                           
 2609                           .LIST           on
 2610                           
 2611                                   ;.INCLUDE inc\sys_fs2.inc
 2612                           
 2613                           .LIST on
 2614                           
 2615                                   .CODEF9
 2616                                   ;.GLOBAL _chkfat
 2617                                   ;.EXTERN _ATARead
 2618  F9609D                           
 2619                                   .LONGA  off
 2620                                   .LONGI  off
 2621                           
 2622                           
 2623          000005           LSTDRIVE .EQU   $05
 2624          00004D           MFATPATH .EQU   77
 2625                           
 2626                                   .GLOBAL _truenam
 2627  F9609D                   _truenam:
 2628                                   ;phd
 2629                                   ;phb
 2630                                   ;pea    #DP05ADDR
 2631                                   ;pld
 2632  F9609D  85 83                    sta     LPtr1
 2633  F9609F  EB                       xba
 2634  F960A0  85 84                    sta     LPtr1+1
 2635  F960A2  86 85                    stx     LPtr1+2
 2636  F960A4  84 74                    sty     fexpfg
 2637                                   ;tya
 2638                                   ;and    #$7F
  Tue Jul 17 11:00:19 2018                                                                                               Page    3




 2639                                   ;sta    FDefDrv
 2640  F960A6                           
 2641  F960A6  A2 00                    ldx     #0
 2642  F960A8  9B                       txy
 2643  F960A9  B7 83            ?1000:  lda     [LPtr1],y
 2644  F960AB  9F 00 00 20              sta     $200000,x
 2645  F960AF  C9 00                    cmp     #0
 2646  F960B1  F0 04                    beq     ?1001
 2647  F960B3  E8                       inx
 2648  F960B4  C8                       iny
 2649  F960B5  D0 F2                    bne     ?1000
 2650  F960B7  A9 00            ?1001:  lda     #$00
 2651  F960B9  EB                       xba
 2652  F960BA  A9 00                    lda     #$00
 2653  F960BC  A2 20                    ldx     #$20
 2654  F960BE                           
 2655                                   ;jsr    _ftrim
 2656  F960BE  85 83                    sta     LPtr1
 2657  F960C0  EB                       xba
 2658  F960C1  85 84                    sta     LPtr1+1
 2659  F960C3  86 85                    stx     LPtr1+2
 2660  F960C5  20 E8 60                 jsr     ?02
 2661                                   ;jsr    _frest
 2662  F960C8  A6 89                    ldx     FDirIdx
 2663  F960CA  E8                       inx
 2664  F960CB  74 24                    stz     fpaths,x
 2665  F960CD  B0 18                    bcs     ?1002
 2666  F960CF  24 75                    bit     devfg
 2667  F960D1  30 14                    bmi     ?1002
 2668  F960D3  A6 90                    ldx     lstidx
 2669  F960D5  CA                       dex
 2670  F960D6  86 91                    stx     FEndDir
 2671  F960D8  F0 0D                    beq     ?1002
 2672  F960DA  CA                       dex
 2673  F960DB  24 74                    bit     fexpfg                  ; check the directory length
 2674  F960DD  30 02                    bmi     ?1001a                  ; if file name request
 2675  F960DF  A6 89                    ldx     FDirIdx
 2676  F960E1  E0 40            ?1001a: cpx     #$40
 2677  F960E3  90 02                    bcc     ?1002
 2678  F960E5  A9 23                    lda     #EINVPATH
 2679                           ?1002:  ;tay
 2680                                   ;ldx    #$00
 2681                                   ;lda    #$05
 2682                                   ;xba
 2683                                   ;lda    #FPathStr
 2684                                   ;plb
 2685                                   ;pld
 2686  F960E7  60                       rts
 2687                           
 2688  F960E8                   ?02:
 2689  F960E8  64 77                    stz     haswild
 2690  F960EA  64 75                    stz     devfg
 2691  F960EC  A5 73                    lda     fdefdrv
 2692  F960EE  18                       clc
 2693  F960EF  69 41                    adc     #'A'
 2694  F960F1  85 22                    sta     FPathStr
 2695  F960F3  A9 3A                    lda     #':'
  Tue Jul 17 11:00:19 2018                                                                                               Page    4




 2696  F960F5  85 23                    sta     FPathStr+1
 2697  F960F7  64 24                    stz     fpaths
 2698  F960F9  A9 FF                    lda     #$FF
 2699  F960FB  85 89                    sta     FDirIdx                 ; empty string
 2700  F960FD  A7 83                    lda     [LPtr1]                 ; first char
 2701  F960FF  F0 31                    beq     ?14                     ; null string -> error
 2702  F96101  EB                       xba                             ; B = first char
 2703  F96102  A0 01                    ldy     #1
 2704  F96104  B7 83                    lda     [LPtr1],y               ; 2nd char
 2705  F96106  C9 3A                    cmp     #':'                    ; check 'X:' at starting string
 2706  F96108  D0 1A                    bne     ?10                     ; no drive specified - use default 
 2707  F9610A  EB                       xba                             ; A = drive letter
 2708  F9610B  C9 61                    cmp     #'a'
 2709  F9610D  90 06                    bcc     ?04
 2710  F9610F  C9 7B                    cmp     #'z'+1
 2711  F96111  B0 0E                    bcs     ?08                     ; invalid drive
 2712  F96113  29 DF                    and     #$DF                    ; up case letter drive
 2713  F96115  E9 40            ?04:    sbc     #'A'-1                  ; here always CF = 0
 2714  F96117  90 07                    bcc     ?06                     ; invalid drive number
 2715  F96119  C9 06                    cmp     #LSTDRIVE+1             ; drive number <= LAST DRIVE ?
 2716  F9611B  B0 04                    bcs     ?08                     ; invalid drive
 2717  F9611D  C8                       iny                             ; bump pointer (3nd char, Y = 2)
 2718  F9611E  90 08                    bcc     ?12                     ; store drive number
 2719  F96120  38               ?06:    sec                             ; error flag
 2720  F96121  A9 0F            ?08:    lda     #ENODEV                 ; invalid drive error
 2721  F96123  60                       rts
 2722  F96124  A5 73            ?10:    lda     fdefdrv                 ; use default drive
 2723  F96126  18                       clc
 2724  F96127  88                       dey                             ; pointer = 0
 2725  F96128  85 72            ?12:    sta     fdrive                  ; store drive number
 2726  F9612A  69 41                    adc     #'A'
 2727  F9612C  85 22                    sta     FPathStr
 2728  F9612E  B7 83                    lda     [LPtr1],y               ; first or 3nd char (Y = 0 or Y = 2)
 2729  F96130  D0 04                    bne     ?16                     ; can't be NULL
 2730  F96132  A9 23            ?14:    lda     #EINVPATH               ; invalid path format
 2731  F96134  38                       sec
 2732  F96135  60                       rts
 2733  F96136  C9 2F            ?16:    cmp     #'/'                    ; string start with root dir. ?
 2734  F96138  F0 04                    beq     ?18                     ; absolute path
 2735  F9613A  C9 5C                    cmp     #'\'
 2736  F9613C  D0 0F                    bne     ?20                     ; relative path
 2737  F9613E  C8               ?18:    iny                             ; pointer to char after '/' Y=3 or 1
 2738  F9613F  B7 83                    lda     [LPtr1],y               ; skip consecutive '/' or '\'
 2739  F96141  C9 2F                    cmp     #'/'
 2740  F96143  F0 F9                    beq     ?18
 2741  F96145  C9 5C                    cmp     #'\'
 2742  F96147  F0 F5                    beq     ?18
 2743  F96149  A2 00                    ldx     #0                      ; index of fpaths
 2744  F9614B  F0 03                    beq     ?22                     ; store '/'
 2745  F9614D                           
 2746                           ?20:    ; copy in fpaths the current directory of the drive fdrive
 2747  F9614D  20 24 63                 jsr     ?250
 2748  F96150                           
 2749                           ; if src start with "path"      Y= 0
 2750                           ; if src start with "/path"     Y= 1
 2751                           ; if src start with "X:path"    Y= 2
 2752                           ; if src start with "X:/path"   Y= 3
  Tue Jul 17 11:00:19 2018                                                                                               Page    5




 2753  F96150  18               ?22:    clc
 2754  F96151                           CPU16                           ; adjust pointer
 2755  F96151  C2 30                    rep     #(PMFLAG.OR.PXFLAG)
 2756                                   .LONGA  on
 2757                                   .LONGI  on
 2758                                   .MNLIST
 2759  F96153  98                       tya                             ; Y can be 0,1,2 or 3
 2760  F96154  65 83                    adc     LPtr1                   ; now LPtr1 point to first char
 2761  F96156  85 83                    sta     LPtr1                   ; of the path
 2762  F96158                           CPU08
 2763  F96158  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 2764                                   .LONGA  off
 2765                                   .LONGI  off
 2766                                   .MNLIST
 2767  F9615A  90 02                    bcc     ?24
 2768  F9615C  E6 85                    inc     LPtr1+2
 2769  F9615E  A9 2F            ?24:    lda     #'/'                    ; the last '/' of path 
 2770  F96160  95 24                    sta     fpaths,x
 2771  F96162  86 89                    stx     FDirIdx                 ; current index
 2772  F96164  A7 83                    lda     [LPtr1]
 2773  F96166  D0 06                    bne     ?25                     ; not only root directory in source
 2774  F96168  24 74                    bit     fexpfg                  ; filename ?
 2775  F9616A  30 C6                    bmi     ?14                     ; yes -- error
 2776  F9616C  18                       clc                             ; root directory ending scan
 2777  F9616D  60                       rts
 2778  F9616E                           
 2779                           ?25:    ; now search the last subcomponent - search last '/' or last '\'
 2780  F9616E  A0 00                    ldy     #0                      ; scan string from beginning
 2781  F96170  BB                       tyx                             ; sub-component lenght
 2782  F96171  B7 83            ?26:    lda     [LPtr1],y
 2783  F96173  F0 05                    beq     ?28                     ; end string
 2784  F96175  C8                       iny
 2785  F96176  D0 F9                    bne     ?26                     ; loop -- find end of string
 2786  F96178  F0 B8                    beq     ?14                     ; error -- string too long 
 2787  F9617A  E8               ?28:    inx     
 2788  F9617B  88                       dey                             ; scan source for '/' or '\'
 2789  F9617C  30 0A                    bmi     ?30                     ; reached string beginning
 2790  F9617E  B7 83                    lda     [LPtr1],y
 2791  F96180  C9 2F                    cmp     #'/'
 2792  F96182  F0 04                    beq     ?30
 2793  F96184  C9 5C                    cmp     #'\'
 2794  F96186  D0 F2                    bne     ?28                     ; scan source string
 2795  F96188  CA               ?30:    dex                             ; last sub-component lenght
 2796  F96189  F0 A7                    beq     ?14                     ; string ending with '/' - error
 2797  F9618B  84 90                    sty     lstidx                  ; pointer to last '/'
 2798  F9618D  C8                       iny
 2799  F9618E  F0 42                    beq     ?60                     ; exist last sub-component only
 2800  F96190                           
 2801                                   ; sub-components scan - Y point always at first char after '/'
 2802  F96190  A0 00                    ldy     #0                      ; start with source string begin
 2803  F96192  C4 90            ?40:    cpy     lstidx
 2804  F96194  B0 39                    bcs     ?58                     ; end (remain last sub-component)
 2805  F96196  B7 83                    lda     [LPtr1],y               ; skip consecutive '/'
 2806  F96198  C8                       iny
 2807  F96199  C9 2F                    cmp     #'/'
 2808  F9619B  F0 F5                    beq     ?40
 2809  F9619D  C9 5C                    cmp     #'\'
  Tue Jul 17 11:00:19 2018                                                                                               Page    6




 2810  F9619F  F0 F1                    beq     ?40
 2811  F961A1  C9 2E            ?44:    cmp     #'.'                    ; check './'
 2812  F961A3  D0 22                    bne     ?50                     ; parse sub-component
 2813  F961A5  B7 83                    lda     [LPtr1],y               ; next char
 2814  F961A7  C8                       iny
 2815  F961A8  C9 2F                    cmp     #'/'
 2816  F961AA  F0 E6                    beq     ?40                     ; skip './' entry
 2817  F961AC  C9 5C                    cmp     #'\'
 2818  F961AE  F0 E2                    beq     ?40
 2819  F961B0  C9 2E                    cmp     #'.'                    ; check '../' entry
 2820  F961B2  D0 0B                    bne     ?46                     ; malformed path
 2821  F961B4  B7 83                    lda     [LPtr1],y               ; next char     
 2822  F961B6  C8                       iny
 2823  F961B7  C9 2F                    cmp     #'/'
 2824  F961B9  F0 07                    beq     ?48                     ; handle '../' entry
 2825  F961BB  C9 5C                    cmp     #'\'
 2826  F961BD  F0 03                    beq     ?48                     ; handle '../' entry
 2827  F961BF  4C 32 61         ?46:    jmp     ?14                     ; error - malformed path
 2828  F961C2  20 C4 62         ?48:    jsr     ?200                    ; handle '../'entry
 2829  F961C5  80 CB                    bra     ?40
 2830  F961C7  64 7D            ?50:    stz     wildfg                  ; no wildcards allowed
 2831  F961C9  88                       dey                             ; point to first char of the sub-comp
 2832  F961CA  20 EC 61                 jsr     ?100                    ; parse sub-component
 2833  F961CD  80 C3                    bra     ?40                     ; next su-component
 2834  F961CF  A4 90            ?58:    ldy     lstidx                  ; this point to last '/'
 2835  F961D1  C8                       iny                             ; point to first char after '/'
 2836  F961D2  A9 80            ?60:    lda     #$80
 2837  F961D4  85 7D                    sta     wildfg
 2838  F961D6  A6 89                    ldx     FDirIdx
 2839  F961D8  E8                       inx
 2840  F961D9  86 90                    stx     lstidx                  ; point to last sub-component
 2841  F961DB  20 D5 62                 jsr     ?220                    ; parse last sub-component
 2842  F961DE  18                       clc
 2843  F961DF  60                       rts
 2844                           
 2845                                   ; terminate sub-component with '/'
 2846  F961E0  A9 2F            ?90:    lda     #'/'                    ; store '/'
 2847  F961E2  64 7C            ?92:    stz     storfg                  ; don't store in tmpfcb 
 2848  F961E4  20 A5 62                 jsr     ?130                    ; store char A
 2849  F961E7  20 5D 63         ?94:    jsr     ?360                    ; check device name
 2850  F961EA  18                       clc                             ; no error      
 2851  F961EB  60                       rts
 2852  F961EC                                   
 2853                           ?100:   ; parse sub-component - Y point to first char of the sub-component
 2854  F961EC  A9 80                    lda     #$80
 2855  F961EE  85 7C                    sta     storfg                  ; store name part in tmpfcb
 2856  F961F0  64 7E                    stz     dotfg                   ; dot flag
 2857  F961F2  64 82                    stz     cntx                    ; tmpfcb current index
 2858  F961F4  A9 20                    lda     #' '                    ; fill an empty tmpfcb
 2859  F961F6  A2 07                    ldx     #7
 2860  F961F8  95 92            ?101:   sta     tmpfcb,x
 2861  F961FA  CA                       dex
 2862  F961FB  10 FB                    bpl     ?101
 2863  F961FD  A9 08                    lda     #8                      ; max. name lenght
 2864  F961FF  85 7F            ?102:   sta     maxcnt                  ; max lenght name/ext
 2865  F96201  64 80                    stz     cnt                     ; chars counter
 2866  F96203  B7 83            ?104:   lda     [LPtr1],y               ; scan string
  Tue Jul 17 11:00:19 2018                                                                                               Page    7




 2867  F96205  F0 E0                    beq     ?94                     ; end string
 2868  F96207  C8                       iny
 2869  F96208  C9 2F                    cmp     #'/'
 2870  F9620A  F0 D6                    beq     ?92                     ; end sub-component
 2871  F9620C  C9 5C                    cmp     #'\'
 2872  F9620E  F0 D0                    beq     ?90                     ; end sub-component
 2873  F96210  C9 2E                    cmp     #'.'
 2874  F96212  D0 28                    bne     ?106                    ; no dot char
 2875  F96214  24 7E                    bit     dotfg                   ; bit 7 mean dot already scanned
 2876  F96216  10 03                    bpl     ?105                    ; ok -- first dot
 2877  F96218  4C 9F 62                 jmp     ?125                    ; multiple dot - error
 2878  F9621B  A2 80            ?105:   ldx     #$80
 2879  F9621D  86 7E                    stx     dotfg                   ; signal dot already scanned
 2880  F9621F  64 7C                    stz     storfg                  ; don't store extension in tmpfcb
 2881  F96221  A6 80                    ldx     cnt                     ; sub-component cannot start with dot
 2882  F96223  F0 7A                    beq     ?125                    ; start with dot - error\
 2883  F96225  AA                       tax
 2884  F96226  B7 83                    lda     [LPtr1],y               ; check char after dot
 2885  F96228  F0 BD                    beq     ?94                     ; ignore trailing dot
 2886  F9622A  C8                       iny
 2887  F9622B  C9 2F                    cmp     #'/'
 2888  F9622D  F0 B3                    beq     ?92                     ; end sub-component
 2889  F9622F  C9 5C                    cmp     #'\'
 2890  F96231  F0 AD                    beq     ?90                     ; end sub-component
 2891  F96233  88                       dey
 2892  F96234  8A                       txa
 2893  F96235  20 A5 62                 jsr     ?130                    ; store dot
 2894  F96238  A9 03                    lda     #3                      ; max. ext lenght
 2895  F9623A  80 C3                    bra     ?102                    ; scan ext
 2896  F9623C  24 7D            ?106:   bit     wildfg                  ; after a '*' expect the '.' or
 2897  F9623E  70 5F                    bvs     ?125                    ; '/' or '\' or NULL
 2898  F96240  C9 3F                    cmp     #'?'
 2899  F96242  D0 0A                    bne     ?108
 2900  F96244  24 7D                    bit     wildfg                  ; bit 7 mean '?' allowed
 2901  F96246  10 57                    bpl     ?125                    ; wildcards not allowed - error
 2902  F96248  A2 80                    ldx     #$80
 2903  F9624A  86 77                    stx     haswild                 ; flag path contain wild chars
 2904  F9624C  80 2D                    bra     ?117                    ; store '?'
 2905  F9624E  C9 2A            ?108:   cmp     #'*'
 2906  F96250  D0 21                    bne     ?116
 2907  F96252  24 7D                    bit     wildfg
 2908  F96254  10 49                    bpl     ?125                    ; wildcards not allowed
 2909  F96256  A2 80                    ldx     #$80
 2910  F96258  86 77                    stx     haswild                 ; flag path contain wild chars
 2911  F9625A  38                       sec
 2912  F9625B  A5 7F                    lda     maxcnt
 2913  F9625D  E5 80                    sbc     cnt                     ; how much char ?
 2914  F9625F  90 3E                    bcc     ?125                    ; error
 2915  F96261  F0 A0                    beq     ?104
 2916  F96263  85 81                    sta     cnt1
 2917  F96265  A9 3F                    lda     #'?'                    ; convert in right numbers of '?'
 2918  F96267  20 A5 62         ?114:   jsr     ?130
 2919  F9626A  C6 81                    dec     cnt1
 2920  F9626C  D0 F9                    bne     ?114
 2921  F9626E  20 49 63                 jsr     ?350                    ; ignore all after '*'
 2922  F96271  80 90                    bra     ?104                    ; loop
 2923  F96273  C9 7F            ?116:   cmp     #$7F                    ; only standard ASCII
  Tue Jul 17 11:00:19 2018                                                                                               Page    8




 2924  F96275  B0 29                    bcs     ?126
 2925  F96277  C9 20                    cmp     #' '
 2926  F96279  90 24                    bcc     ?125
 2927  F9627B  A6 80            ?117:   ldx     cnt                     ; test max. 8 chars for fname
 2928  F9627D  E4 7F                    cpx     maxcnt                  ; 3 chars for ext
 2929  F9627F  B0 1F                    bcs     ?126                    ; fname or ext too long - error
 2930  F96281  E8                       inx                             ; update counter
 2931  F96282  86 80                    stx     cnt
 2932  F96284  A2 0B                    ldx     #NDCHCNT                ; ready to store char in fpaths
 2933  F96286  DF B8 63 F9      ?118:   cmp     >NDIRCHRS,x             ; test for illegals chars
 2934  F9628A  F0 13                    beq     ?125                    ; illegal char - error
 2935  F9628C  CA                       dex
 2936  F9628D  10 F7                    bpl     ?118
 2937  F9628F  C9 61                    cmp     #'a'                    ; up case char
 2938  F96291  90 06                    bcc     ?120
 2939  F96293  C9 7B                    cmp     #'z'+1
 2940  F96295  B0 02                    bcs     ?120
 2941  F96297  29 DF                    and     #$DF                    ; up-case
 2942  F96299  20 A5 62         ?120:   jsr     ?130                    ; store
 2943  F9629C  4C 03 62                 jmp     ?104                    ; loop
 2944  F9629F  38               ?125:   sec                             ; error
 2945  F962A0  68               ?126:   pla                             ; skip return
 2946  F962A1  68                       pla
 2947  F962A2  A9 23                    lda     #EINVPATH
 2948  F962A4  60                       rts
 2949                           
 2950                           ?130:   ; store char in fpaths and update index
 2951                                   ; store the name part only in tmpfcb for check device name
 2952                                   ; full path 79 chars max - subctract 2 bytes for drive letter -> 77
 2953  F962A5  24 7C                    bit     storfg
 2954  F962A7  10 0B                    bpl     ?132                    ; not store char in tmpfcb
 2955  F962A9  A6 82                    ldx     cntx                    ; index
 2956  F962AB  E0 08                    cpx     #8                      ; max. 8 chars
 2957  F962AD  B0 05                    bcs     ?132
 2958  F962AF  95 92                    sta     tmpfcb,x                ; store
 2959  F962B1  E8                       inx
 2960  F962B2  86 82                    stx     cntx
 2961  F962B4  A6 89            ?132:   ldx     FDirIdx
 2962  F962B6  E8                       inx                             ; update index
 2963  F962B7  E0 4D                    cpx     #MFATPATH               ; check index range (0..76)
 2964  F962B9  B0 05                    bcs     ?134                    ; no room to store - error
 2965  F962BB  86 89                    stx     FDirIdx                 ; here CF = 0
 2966  F962BD  95 24                    sta     fpaths,x                ; store char
 2967  F962BF  60                       rts                             ; CF = 0
 2968  F962C0  68               ?134:   pla                             ; here CF = 1
 2969  F962C1  68                       pla                             ; skip return
 2970  F962C2  80 DC                    bra     ?126
 2971  F962C4                           
 2972                           ?200:   ; handle '../' entry
 2973  F962C4  A6 89                    ldx     FDirIdx                 ; current index
 2974  F962C6  F0 D7                    beq     ?125                    ; already in root - error
 2975  F962C8  CA                       dex
 2976  F962C9  B5 24            ?202:   lda     fpaths,x
 2977  F962CB  C9 2F                    cmp     #'/'
 2978  F962CD  F0 03                    beq     ?204
 2979  F962CF  CA                       dex
 2980  F962D0  D0 F7                    bne     ?202
  Tue Jul 17 11:00:19 2018                                                                                               Page    9




 2981                           ?204:   ;txa
 2982                                   ;beq    ?125
 2983                                   ;dex
 2984  F962D2  86 89                    stx     FDirIdx
 2985  F962D4  60               ?206:   rts
 2986  F962D5                    
 2987                           ?220:   ; parse the last sub-component -- Y = actual pointer to source
 2988  F962D5  B7 83                    lda     [LPtr1],y               ; check first char
 2989  F962D7  C9 2E                    cmp     #'.'                    ; begin with '.' ?
 2990  F962D9  D0 46                    bne     ?240                    ; no -- parse
 2991  F962DB  24 74                    bit     fexpfg                  ; is a file name ?
 2992  F962DD  30 C0                    bmi     ?125                    ; yes -- error
 2993  F962DF  C8                       iny
 2994  F962E0  A6 89                    ldx     FDirIdx                 ; actual pointer to path
 2995  F962E2  B7 83                    lda     [LPtr1],y               ; check 2nd char
 2996  F962E4  D0 07                    bne     ?222                    ; not a '.' entry
 2997  F962E6  8A                       txa
 2998  F962E7  F0 EB                    beq     ?206                    ; root directory -- ok
 2999  F962E9  64 80                    stz     cnt                     ; mean to handle '.' entry
 3000  F962EB  80 10                    bra     ?224
 3001  F962ED  C9 2E            ?222:   cmp     #'.'                    ; '..' entry ?
 3002  F962EF  D0 AE                    bne     ?125                    ; no -- error
 3003  F962F1  C8                       iny
 3004  F962F2  B7 83                    lda     [LPtr1],y               ; check 3nd char
 3005  F962F4  D0 A9                    bne     ?125                    ; will be 0 -- error
 3006  F962F6  8A                       txa
 3007  F962F7  F0 A6                    beq     ?125                    ; already in root -- error
 3008  F962F9  A9 80                    lda     #$80
 3009  F962FB  85 80                    sta     cnt                     ; mean to handle '..' entry
 3010  F962FD  CA               ?224:   dex                             ; for now the end of path
 3011  F962FE  86 89                    stx     FDirIdx                 ; pointer to last char of path
 3012  F96300  E8                       inx
 3013  F96301  CA               ?226:   dex                             ; find previous sub-component
 3014  F96302  B5 24                    lda     fpaths,x
 3015  F96304  C9 2F                    cmp     #'/'
 3016  F96306  D0 F9                    bne     ?226
 3017  F96308  9B                       txy
 3018  F96309  E8                       inx
 3019  F9630A  86 90                    stx     lstidx                  ; this become the last sub-component
 3020  F9630C  24 80                    bit     cnt                     ; handle '.' entry ?
 3021  F9630E  10 10                    bpl     ?230                    ; yes -- end parse
 3022  F96310  BB                       tyx
 3023  F96311  F0 0B                    beq     ?229                    ; root directory
 3024  F96313  88                       dey                             ; before the final '/'
 3025  F96314  CA               ?228:   dex                             ; find previous sub-component
 3026  F96315  B5 24                    lda     fpaths,x
 3027  F96317  C9 2F                    cmp     #'/'
 3028  F96319  D0 F9                    bne     ?228
 3029  F9631B  E8                       inx
 3030  F9631C  86 90                    stx     lstidx                  ; this become the last sub-component
 3031  F9631E  84 89            ?229:   sty     FDirIdx                 ; pointer to last path char
 3032  F96320  60               ?230:   rts             
 3033  F96321  4C EC 61         ?240:   jmp     ?100                    ; parse normal
 3034  F96324                           
 3035                           ?250:   ; copy in fpaths the current directory of the drive fdrive
 3036  F96324  98                       tya                             ; save Y in B (Y = 0 or Y = 2)
 3037  F96325  EB                       xba
  Tue Jul 17 11:00:19 2018                                                                                               Page   10




 3038  F96326  A6 72                    ldx     fdrive
 3039  F96328  BF B0 63 F9              lda     >CDPTRL,x               ; pointer of the current directory
 3040  F9632C  85 86                    sta     LPtr2
 3041  F9632E  BF B4 63 F9              lda     >CDPTRH,x
 3042  F96332  85 87                    sta     LPtr2+1
 3043  F96334  A9 01                    lda     #^DEFDIR0
 3044  F96336  85 88                    sta     LPtr2+2
 3045  F96338  B4 8A                    ldy     CDLen,x                 ; Y = len - 1
 3046  F9633A  BB                       tyx                             ; X = index fpaths
 3047  F9633B  F0 09                    beq     ?254                    ; root directory
 3048  F9633D  E8                       inx                             ; index next char
 3049  F9633E  B7 86            ?252:   lda     [LPtr2],y               ; copy directory
 3050  F96340  99 24 05                 sta     FSWP0+fpaths,y
 3051  F96343  88                       dey
 3052  F96344  10 F8                    bpl     ?252
 3053  F96346  EB               ?254:   xba                             ; restore Y
 3054  F96347  A8                       tay
 3055  F96348  60                       rts
 3056                           
 3057                           ?350:   ; search final '/', or '\', or end of string, or '.'
 3058  F96349  B7 83                    lda     [LPtr1],y
 3059  F9634B  F0 0F                    beq     ?352
 3060  F9634D  C9 2F                    cmp     #'/'
 3061  F9634F  F0 0B                    beq     ?352
 3062  F96351  C9 5C                    cmp     #'\'
 3063  F96353  F0 07                    beq     ?352
 3064  F96355  C9 2E                    cmp     #'.'
 3065  F96357  F0 03                    beq     ?352
 3066  F96359  C8                       iny
 3067  F9635A  80 ED                    bra     ?350
 3068  F9635C  60               ?352:   rts
 3069                           
 3070                           ?360:   ; check if file name = device name (ignore extension)
 3071  F9635D                           ACC16
 3072  F9635D  C2 20                    rep     #PMFLAG
 3073                                   .LONGA  on
 3074                                   .MNLIST
 3075  F9635F  A9 C4 63                 lda     #DEVSTR                 ; pointer to device name array
 3076  F96362  85 A2                    sta     LPtr3
 3077  F96364                           ACC08
 3078  F96364  E2 20                    sep     #PMFLAG
 3079                                   .LONGA  off
 3080                                   .MNLIST
 3081  F96366  A9 F9                    lda     #^DEVSTR
 3082  F96368  85 A4                    sta     LPtr3+2
 3083  F9636A  64 76                    stz     devidx                  ; device name index
 3084  F9636C  5A                       phy                             ; save Y
 3085  F9636D  A2 07            ?362:   ldx     #7                      ; device name 8 chars
 3086  F9636F  9B                       txy
 3087  F96370  B5 92            ?364:   lda     tmpfcb,x                ; compare tmpfcb with device name
 3088  F96372  D7 A2                    cmp     [LPtr3],y
 3089  F96374  D0 27                    bne     ?370                    ; unmatch
 3090  F96376  CA                       dex
 3091  F96377  88                       dey
 3092  F96378  10 F6                    bpl     ?364                    ; loop
 3093  F9637A  E8                       inx
 3094  F9637B  C8                       iny                             ; copy device name in path
  Tue Jul 17 11:00:19 2018                                                                                               Page   11




 3095  F9637C  A9 2F                    lda     #'/'
 3096  F9637E  85 24                    sta     fpaths
 3097  F96380  E8                       inx
 3098  F96381  B7 A2            ?366:   lda     [LPtr3],y
 3099  F96383  C9 20                    cmp     #' '                    ; first blank terminate string
 3100  F96385  F0 08                    beq     ?368
 3101  F96387  95 24                    sta     fpaths,x
 3102  F96389  E8                       inx
 3103  F9638A  C8                       iny
 3104  F9638B  C0 08                    cpy     #8
 3105  F9638D  90 F2                    bcc     ?366                    ; loop 8 chars
 3106  F9638F  CA               ?368:   dex                             ; update index
 3107  F96390  86 89                    stx     FDirIdx
 3108  F96392  7A                       ply                             ; recover Y
 3109  F96393  68                       pla                             ; skip 2 return address
 3110  F96394  68                       pla
 3111  F96395  68                       pla
 3112  F96396  68                       pla
 3113  F96397  A9 80                    lda     #$80
 3114  F96399  85 75                    sta     devfg                   ; set device name flag
 3115  F9639B  18                       clc
 3116  F9639C  60                       rts                             ; terminate parsing and exit
 3117  F9639D  A9 08            ?370:   lda     #8                      ; update array pointer
 3118  F9639F  18                       clc
 3119  F963A0  65 A2                    adc     LPtr3
 3120  F963A2  85 A2                    sta     LPtr3
 3121  F963A4  90 02                    bcc     ?372
 3122  F963A6  E6 A3                    inc     LPtr3+1
 3123  F963A8  E6 76            ?372:   inc     devidx                  ; update device name array index
 3124  F963AA  A7 A2                    lda     [LPtr3]
 3125  F963AC  D0 BF                    bne     ?362                    ; loop next device name
 3126  F963AE  7A                       ply                             ; recover Y
 3127  F963AF  60                       rts
 3128                           
 3129  F963B0                           
 3130  F963B0                   CDPTRL:
 3131  F963B0  00 40 80 C0              .DB     <DEFDIR0, <DEFDIR1, <DEFDIR2, <DEFDIR3
 3132  F963B4                           
 3133  F963B4                   CDPTRH:
 3134  F963B4  9C 9C 9C 9C              .DB     >DEFDIR0, >DEFDIR1, >DEFDIR2, >DEFDIR3
 3135                           
 3136  F963B8                   NDIRCHRS:
 3137  F963B8  22 5B 5D 3A 7C           .DB     '"[]:|<>+=;, '
               3C 3E 2B 3D 3B 
               2C 20 
 3138          00000B           NDCHCNT .EQU    $ - NDIRCHRS - 1
 3139                           
 3140  F963C4                   DEVSTR:
 3141  F963C4  4B 45 59 42 44           .DB     'KEYBD$  '      ; Keyboard
               24 20 20 
 3142  F963CC  53 43 52 45 45           .DB     'SCREEN$ '      ; Display
               4E 24 20 
 3143  F963D4  43 4F 4E 20 20           .DB     'CON     '      ; Keyboard and display
               20 20 20 
 3144  F963DC  50 52 4E 20 20           .DB     'PRN     '      ; System list device, usually a parallel port
               20 20 20 
 3145  F963E4  4C 53 54 20 20           .DB     'LST     '      ; System list device, usually a parallel port
  Tue Jul 17 11:00:19 2018                                                                                               Page   12




               20 20 20 
 3146  F963EC  4C 50 54 31 20           .DB     'LPT1    '      ; First parallel printer port
               20 20 20 
 3147  F963F4  4C 50 54 32 20           .DB     'LPT2    '      ; Second parallel printer port
               20 20 20 
 3148  F963FC  4C 50 54 33 20           .DB     'LPT3    '      ; Third parallel printer port
               20 20 20 
 3149  F96404  41 55 58 20 20           .DB     'AUX     '      ; Auxiliary device, usually a serial port
               20 20 20 
 3150  F9640C  43 4F 4D 31 20           .DB     'COM1    '      ; First serial communications port
               20 20 20 
 3151  F96414  43 4F 4D 32 20           .DB     'COM2    '      ; Second serial communications port
               20 20 20 
 3152  F9641C  43 4F 4D 33 20           .DB     'COM3    '      ; Third serial communications port
               20 20 20 
 3153  F96424  43 4F 4D 34 20           .DB     'COM4    '      ; Fourth serial communications port
               20 20 20 
 3154  F9642C  4E 55 4C 20 20           .DB     'NUL     '      ; Bit-bucket device
               20 20 20 
 3155  F96434  24 49 44 4C 45           .DB     '$IDLE$  '      ; Bit-bucket device
               24 20 20 
 3156  F9643C  43 4C 4F 43 4B           .DB     'CLOCK$  '      ; System real-time clock
               24 20 20 
 3157  F96444  43 4C 4F 43 4B           .DB     'CLOCK   '      ; System real-time clock
               20 20 20 
 3158  F9644C  43 4F 4E 46 49           .DB     'CONFIG$ '
               47 24 20 
 3159  F96454  43 4F 4E 53 4F           .DB     'CONSOLE$'
               4C 45 24 
 3160  F9645C  00                       .DB     0
 3161                           
 3162                           ; --- TEST ---
 3163                                   .GLOBAL dummydir
 3164  F9645D                   dummydir:
 3165  F9645D  0B                       phd
 3166  F9645E  F4 00 05                 pea     #FSWP0
 3167  F96461  2B                       pld
 3168  F96462  A2 00                    ldx     #0
 3169  F96464  86 73                    stx     fdefdrv
 3170  F96466  BF B0 64 F9      ?01:    lda     >TEST1,x
 3171  F9646A  F0 07                    beq     ?02
 3172  F9646C  9F 00 9C 01              sta     >DEFDIR0,x
 3173  F96470  E8                       inx
 3174  F96471  D0 F3                    bne     ?01
 3175  F96473  CA               ?02:    dex     
 3176  F96474  86 8A                    stx     CDLen
 3177  F96476  A2 00                    ldx     #0
 3178  F96478  BF B2 64 F9      ?03:    lda     >TEST2,x
 3179  F9647C  F0 07                    beq     ?04
 3180  F9647E  9F 40 9C 01              sta     >DEFDIR1,x
 3181  F96482  E8                       inx
 3182  F96483  D0 F3                    bne     ?03
 3183  F96485  CA               ?04:    dex     
 3184  F96486  86 8B                    stx     CDLen+1
 3185  F96488  A2 00                    ldx     #0
 3186  F9648A  BF BF 64 F9      ?05:    lda     >TEST3,x
 3187  F9648E  F0 07                    beq     ?06
  Tue Jul 17 11:00:19 2018                                                                                               Page   13




 3188  F96490  9F 80 9C 01              sta     >DEFDIR2,x
 3189  F96494  E8                       inx
 3190  F96495  D0 F3                    bne     ?05
 3191  F96497  CA               ?06:    dex     
 3192  F96498  86 8C                    stx     CDLen+2
 3193  F9649A  A2 00                    ldx     #0
 3194  F9649C  BF C6 64 F9      ?07:    lda     >TEST4,x
 3195  F964A0  F0 07                    beq     ?08
 3196  F964A2  9F C0 9C 01              sta     >DEFDIR3,x
 3197  F964A6  E8                       inx
 3198  F964A7  D0 F3                    bne     ?07
 3199  F964A9  CA               ?08:    dex     
 3200  F964AA  86 8D                    stx     CDLen+3
 3201  F964AC  A2 00                    ldx     #0
 3202  F964AE  2B                       pld
 3203  F964AF  6B                       rtl
 3204  F964B0                           
 3205  F964B0                   TEST1:
 3206  F964B0  2F 00                    .DB     '/', 0
 3207  F964B2                   TEST2:
 3208  F964B2  2F 50 41 54 48           .DB     '/PATH1/PATH2', 0
               31 2F 50 41 54 
               48 32 00 
 3209  F964BF                   TEST3:
 3210  F964BF  2F 50 41 54 48           .DB     '/PATH1', 0
               31 00 
 3211  F964C6                   TEST4:
 3212  F964C6  2F 50 41 54 48           .DB     '/PATH1/PATH2/PATH3', 0
               31 2F 50 41 54 
               48 32 2F 50 41 
               54 48 33 00 
 3213  F964D9                   TEST5:
 3214  F964D9  2F 50 41 54 48           .DB     '/PATH1/PATH2/PATH3/PATH4', 0
               31 2F 50 41 54 
               48 32 2F 50 41 
               54 48 33 2F 50 
               41 54 48 34 00 
 3215  F964F2                   TEST6:
 3216  F964F2  2F 50 41 54 48           .DB     '/PATH1/PATH2/PATH3/PATH4/PATH5', 0
               31 2F 50 41 54 
               48 32 2F 50 41 
               54 48 33 2F 50 
               41 54 48 34 2F 
               50 41 54 48 35 
               00 
 3217                           


             Lines Assembled : 3194                  Errors : 0