Subversion Repositories MB01 Project

Rev

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

  Tue Jul 17 11:00:21 2018                                                                                               Page    1







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

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


 2603                           .LIST           on
 2604                           
 2605  F8FFB1                           .INCLUDE inc\dirp00.inc
 2606                           ;----------------------------------------------------------
 2607                           ; DIRP00.ASM
 2608                           ; PROGETTO: B1601
 2609                           ;
 2610                           ; Variabili in Direct Page $00
 2611                           ;----------------------------------------------------------
 2612                           
 2613                           ; sezione COMMON -- questo permette di includere il file in piu' file
 2614                           
 2615                           .LIST on
 2616                           
 2617                           DIRP00: .SECTION page0, ref_only, common        ;Direct-Page 00
 2618                           
 2619  000000                           .ABSOLUTE               ;; inizia sempre da $00
 2620  000000                           .ORG            0x00
 2621  000000                           
 2622  000000  0000             JiffyClk        .DW                     ; contatore 10ms 32 bit
 2623  000002  0000                             .DW
 2624  000004                   SysTmr          .DS     SYSTMRCNT       ; system timer 0 (10ms)
 2625  000008                   SysTMF          .DS     SYSTMRCNT       ; flag timer (80 -> start)
 2626  00000C  00               Bnk0Flag        .DB                     ; <7>: flag test RAM banco 0 ok
 2627                                                                   ; <6>: flag warm reset
 2628  00000D  00               RTCFlag         .DB
 2629                           
 2630  00000E                   diskstat        .DS     2       ; flag device on ata bus #0 & #1
 2631                                                           ; <7>: device ready
 2632                                                           ; <6>: compact flash device (C.F.)
 2633                                                           ; <5>: device identification ok
 2634                                                           ; <4>: MBR loaded
 2635                                                           ; <3>: valid signature in MBR
 2636                                                           ; <2>: first partition found&active
 2637                                                           ; <1>:
 2638                                                           ; <0>: valid partition flag
 2639                           
 2640                                                           ; <7>: device ready
 2641                                                           ; <6>: USB device
 2642                                                           ; <5>: compact flash device (C.F.)
 2643                                                           ; <4>: device identification ok
 2644                                                           ; <3>: MBR loaded
 2645                                                           ; <2>: first partition found&active
 2646                                                           ; <1>: always 1
 2647                                                           ; <0>: valid partition flag
 2648  000010                                                   
  Tue Jul 17 11:00:21 2018                                                                                               Page    2




 2649                           
 2650          00000E           atadev          .EQU    diskstat
 2651                           
 2652  000010                   usbdev          .DS     2       ; flag flash disk on usb bus #0
 2653                                                           ; <7>: device plugged and ready
 2654                                                           ; <6>: always 1 
 2655                                                           ; <5>: device identification ok
 2656                                                           ; <4>: MBR loaded
 2657                                                           ; <3>: valid signature in MBR
 2658                                                           ; <2>: first partition found&active
 2659                                                           ; <1>:
 2660                                                           ; <0>: valid partition flag
 2661                           
 2662  000012                   diskmax         .DS     16      ; disk max. sector's
 2663          000012           atasec          .EQU    diskmax
 2664          00001A           usbsec          .EQU    diskmax+8
 2665                           
 2666                           
 2667  000022                   atambr          .DS     8       ; data for first partition found in mbr
 2668                                                           ; first 3 bytes for start sector of partition
 2669                                                           ; last byte for partition type
 2670  00002A                   usbmbr          .DS     8
 2671                           
 2672  000032                   ataprt          .DS     8       ; total sec's of first partition
 2673  00003A                   usbprt          .DS     8       ; total sec's of first partition
 2674                           
 2675                           
 2676  000042  00               usb0ch          .DB     ; usb0 (ch375/ch376) flag
 2677                                                   ; <7>: module on
 2678                                                   ; <6>: ch376 flag
 2679                                                   ; <5:0>: chip version
 2680                           
 2681  000043  00               usb0st          .DB     ; usb0 status
 2682                                                   ; <7>: usb0 host mode ok
 2683                                                   ; <6>: flash disk attached flag
 2684                                                   ; <5>: usb device attached
 2685                           
 2686  000044  00               fdcdrv          .DB             ; phisycal drive status (drive #0)
 2687                                                           ; <7>: disk format established in bit 0&1 
 2688                                                           ; <6>: double step seek done
 2689                                                           ; <5>: trust format bit's (set after ok r/w)
 2690                                                           ; <4>: write protect bit (if disk in drive)
 2691                                                           ; <3>: don't care
 2692                                                           ; <2>: don't care                               
 2693                                                           ; <1>: HD disk if set else DD disk
 2694                                                           ; <0>: CBM format if set else IBM format
 2695                           
 2696  000045  00               vdrive          .DB             ; virtual drive status (ram disk, drive #1)
 2697                                                           ; <7>: disk format established in bit 0&1 
 2698                                                           ; <6>: change disk simulation (after format)
 2699                                                           ; <5>: don't care
 2700                                                           ; <4>: write protect bit (under sw control)
 2701                                                           ; <3>: don't care
 2702                                                           ; <2>: don't care                               
 2703                                                           ; <1>: HD disk if set else DD disk
 2704                                                           ; <0>: CBM format if set else IBM format
 2705                           
  Tue Jul 17 11:00:21 2018                                                                                               Page    3




 2706  000046  00               fdcctl          .DB             ; fdc controller status
 2707                                                           ; <7>: drive is attached
 2708                                                           ; <6>: drive need recalibration (restore)
 2709                                                           ; <5>: FDC controller ok
 2710                                                           ; <4>: motor on
 2711                                                           ; <3>: dma is active
 2712                                                           ; <2>: dma chip ok (post routine)
 2713                                                           ; <1>: clock rate (1=HD,0=DD)
 2714                                                           ; <0>: disk ready
 2715                           
 2716  000047  00               fdctrk          .DB             ; fd: current seek track
 2717  000048  00               fdcerr          .DB             ; fd: last error code
 2718  000049  00               ataerr          .DB             ; ata: last error code
 2719  00004A  00               ataxer          .DB             ; ata: last extended error code
 2720                           
 2721  00004B  00               CtrlBrk         .DB             ; flag CTRL+BREAK (NMI)
 2722                           
 2723  00004C  0000             MemTop          .DW             ; top memoria RAM
 2724  00004E  00                               .DB             ; banco top mem
 2725                           
 2726  00004F  00               DflTxtIn        .DB             ; device di default text input 
 2727  000050  00               DflTxtOut       .DB             ; device di default text output
 2728                           
 2729  000051                   COPPtr          LP              ; long pointer for COP decoding
 2730  000054  00               COPIdx          .DB             ; COP signature/index
 2731                           
 2732  000055  00               BiosEnt         .DB             ; flag accesso a bios setup
 2733                           
 2734                           ; variabili utilizzate da ACIA
 2735  000056                   spwrk           .DS     $30
 2736                           
 2737                           ; bios mem
 2738  000086  0000             nsize           .DW     ; dimensione blocco da allocare
 2739                           ;bsize          .DW     ; dimensione vera blocco free
 2740  000088  0000             splitsz         .DW     ; dimensione blocco splittato
 2741  00008A  0000             bfree           .DW     ; puntatore blocco free
 2742  00008C  0000             hdrptr          .DW     ; puntatore header heap
 2743                           
 2744  00008E  0000             pbrklv          .DW     ; current break level of current process
 2745  000090  0000             pbrkmin         .DW     ; minimum breal level of current process
 2746  000092  0000             pbrkmax         .DW     ; maximum breal level of current process
 2747  000094                           
 2748                           ; bios temp. work area
 2749  000094                   bwrktmp         .DS     $28
 2750                           
 2751  0000BC  00               coptmp          .DB     ; temp. used while cop
 2752                           
 2753  0000BD  00               tstser          .DB     ; check ser/usb test board post
 2754                                                   ; <7>: VIA2 ok
 2755                                                   ; <6>: PICRAM ok
 2756                                                   ; <1>: UART 16C550 ok
 2757                                                   ; <0>: R65C51 ok
 2758                           
 2759                           
 2760                           ;crc16          .DW
 2761                           
 2762  0000BD                           .RELATIVE
  Tue Jul 17 11:00:21 2018                                                                                               Page    4




 2763                           
 2764                                   .ENDS
 2765                           
 2766          [01]             .IFDEF          _ACIA_INC_
 2767                                   .INCLUDE INC\SP.INC
 2768          [00]             .ENDIF
 2769                           
 2793                           .LIST on
 2794                           
 2795                           ;---------------------------------------------------------------------------
 2796                           
 2797          000020           HPLMAX          .EQU    32              ; Max. subdirectory level
 2798                           
 2799          000200           BCBCNT          .EQU    $200            ; BCB's struct's count #
 2800          000C00           BCBXBNK         .EQU    $0C00           ; starting BCB x-mem buffer #
 2801          000040           DMACNT          .EQU    64
 2802                           
 2803          0000E0           FAT0X           .EQU    $E0             ; x-mem bank for fat table of ata #0
 2804          0000F0           FAT1X           .EQU    $F0             ; x-mem bank for fat table of ata #1
 2805                           
 2806  F8FFB1                           .INCLUDE INC\LDT.INC
 2807                           ; LDT.INC
 2808                           
 2809          [01]             .IFNDEF         __LDT_INC__
 2810          000001           __LDT_INC__     .SET    1
 2811                           
 2812                           .LIST on
 2813                           ;---------------------------------------------------------------------------
 2814                           ; Logical Drive Table (LDT) -- page 0 offset's
 2815                           ;---------------------------------------------------------------------------
 2816                           
 2817  F8FFB1                    STRUCT         LDT
 2818                           _LDT    .SECTION page0,common,ref_only,offset 0 ;LDT Struct
 2819                                           ;.ABSOLUTE
 2820                                           ;.ORG   0
 2821                                   .MNLIST
 2822  000000  00               ldt_fg1         .DB             ; logical volume flag's
 2823                                                           ; <7>: device ready (fdc drive or ata device)
 2824                                                           ; <6>: if=1->HD/CF else->FD
 2825                                                           ; <1:0>: phisycal device number
 2826                           
 2827  000001  00               ldt_fg2         .DB             ; <7>: valid volume (fat volume or cbm disk)
 2828                                                           ; <6>: if=1->FAT else->CBM (FD only)
 2829                                                           ; <5>: disk format checked
 2830                                                           ; <1:0>: disk format (fdc only)
 2831                           
 2832  000002  0000             ldt_root        .DW             ; lba of root dir
 2833  000004  0000             ldt_fat1        .DW             ; lba of fat1 table
 2834  000006  0000             ldt_fat2        .DW             ; lba of fat2 table
 2835  000008  0000             ldt_cls         .DW             ; lba of first data cluster
 2836  00000A  0000             ldt_max         .DW             ; max usable cluster + 1
 2837  00000C  0000             ldt_rent        .DW             ; root dir. max. entries
 2838  00000E  0000             ldt_cent        .DW             ; max. entries in dir. cluster
 2839  000010  0000             ldt_eoc         .DW             ; end of cluster chain marker
 2840  000012  0000             ldt_free        .DW             ; count of free cluster's
 2841  000014  0000             ldt_nxt         .DW             ; next free cluster
 2842  000016  0000             ldt_fsiz        .DW             ; fat table size
  Tue Jul 17 11:00:21 2018                                                                                               Page    5




 2843                           
 2844  000018  00               ldt_csiz        .DB             ; cluster size (1,2,4,8,16,32,64)
 2845  000019  00               ldt_cshf        .DB             ; cluster shift (0,1,2,3,4,5,6)
 2846  00001A  00               ldt_rsiz        .DB             ; root dir. size (sector's)
 2847  00001B  00               ldt_mcls        .DB             ; mask for clust. module: 00,01,03,07,0F,1F,3F
 2848  00001C  0000             ldt_cdlp        .DW             ; current working dir list pointer
 2849  00001E  0000             ldt_cdcls       .DW             ; current working dir start cluster
 2850  000020  00               ldt_cdlvl       .DB             ; current working dir level count
 2851                           
 2852  000021  00               ldt_ptype       .DB
 2853  000022  0000 0000        ldt_pstart      .LWORD
 2854  000026  0000 0000        ldt_psize       .LWORD
 2855                           
 2856          000022           ldt_fp          .EQU    ldt_pstart      ; fat table buffer long pointer
 2857          000025           ldt_fbuf        .EQU    ldt_pstart+3            ; fat table: x-mem base bank/dma buffer 
 2858                           
 2859          000026           ldt_pbr         .EQU    ldt_psize               ; long pointer to PBR cache buffer
 2860          000029           ldt_fmt         .EQU    ldt_psize+3
 2861                           
 2862  00002A                    ESTRUCT        LDT
 2863  00002A                   LDTSIZE .DS     0
 2864                                           ;.RELATIVE
 2865                                           .ENDS
 2866                                   .MNLIST 
 2867                           
 2868          [00]             .ENDIF
 2869                           
 2870  F8FFB1                           
 2871                           ;---------------------------------------------------------------------------
 2872                           ; Hierarchical Path List (HPL) -- 16 bit offset's
 2873                           ;---------------------------------------------------------------------------
 2874                           
 2875  F8FFB1                    LSTRUCT        HPL
 2876                           _HPL    .SECTION common,ref_only,offset 0       ;HPL Struct
 2877                                   .MNLIST
 2878  000000  0000             hpl_cls         .DW             ; parent cluster
 2879  000002  0000             hpl_ix          .DW             ; entry index in parent cluster
 2880  000004                   hpl_fcb         .DS     11      ; fcb name
 2881  00000F  00               hpl_lst         .DB             ; unused
 2882  000010                    ESTRUCT        HPL
 2883  000010                   HPLSIZE .DS     0
 2884                                           ;.RELATIVE
 2885                                           .ENDS
 2886                                   .MNLIST 
 2887                           
 2888                           ;--------------------------------------------------------------------------- 
 2889                           ; Buffer Control Block (BCB) -- 16 bit offset's
 2890                           ;---------------------------------------------------------------------------
 2891                           
 2892  F8FFB1                    LSTRUCT        BCB
 2893                           _BCB    .SECTION common,ref_only,offset 0       ;BCB Struct
 2894                                   .MNLIST
 2895  000000  0000             bcb_next        .DW                     ; next logical linked BCB 
 2896  000002  00               bcb_drv         .DB                     ; logical drive
 2897  000003  00               bcb_sec         .DB                     ; sector offset
 2898  000004  0000             bcb_cls         .DW                     ; cluster
 2899  000006  0000             bcb_lba         .DW                     ; sector lba address
  Tue Jul 17 11:00:21 2018                                                                                               Page    6




 2900  000008  0000             bcb_lbah        .DW                     ; lba high
 2901          000008           bcb_head        .EQU    bcb_lbah        ; floppy head
 2902  00000A  0000             bcb_buf         .DW                     ; x-mem buffer number
 2903          00000A           bcb_trk         .EQU    bcb_buf         ; floppy track(low) & sector(hi)
 2904  00000C  0000             bcb_ptr         .DW                     ; buffer pointer
 2905  00000E  0000             bcb_xbnk        .DW                     ; buffer pointer hi & x-mem bank
 2906          00000E           bcb_dma         .EQU    bcb_xbnk        ; buffer pointer hi & dma buffer
 2907  000010                    ESTRUCT        BCB
 2908  000010                   BCBSIZE .DS     0
 2909                                           ;.RELATIVE
 2910                                           .ENDS
 2911                                   .MNLIST 
 2912                           
 2913                           ;--------------------------------------------------------------------------- 
 2914                           ; hash Control Block (BCB) -- 16 bit offset's
 2915                           ;---------------------------------------------------------------------------
 2916                           
 2917  F8FFB1                    LSTRUCT        HCB
 2918                           _HCB    .SECTION common,ref_only,offset 0       ;HCB Struct
 2919                                   .MNLIST
 2920  000000  0000             hcb_next        .DW             ; pointer to next HCB
 2921  000002  0000             hcb_cls         .DW             ; cluster number
 2922  000004  0000             hcb_seq         .DW             ; sequence number + logical drive number
 2923  000006  0000             hcb_cnt         .DW             ; number of hashed entries
 2924  000008                   hcb_data        .DS     0        ; hash buffer data
 2925  000008                    ESTRUCT        HCB
 2926  000008                   HCBSIZE .DS     0
 2927                                           ;.RELATIVE
 2928                                           .ENDS
 2929                                   .MNLIST 
 2930                           
 2931                           ;---------------------------------------------------------------------------  
 2932                           ; TOS Working Segment
 2933                           ;--------------------------------------------------------------------------- 
 2934                           
 2935          000001           WKB             .EQU    .SEG.TOSSEG     ; TOS working bank
 2936                           
 2937          010000           TS              .SET    TOSSEG
 2938          01FFFF           TE              .SET    TOSSEG + $FFFF
 2939          018C00           TO0             .SET    $018C00
 2940          019E00           TO1             .SET    TOSWKM
 2941                           
 2942                           .comment @
 2943                           _TOS0:  .SECTION ref_only, common, offset TO0, range TS TE ;FAT Struct's
 2944                           _TOS0_START     .DS     0
 2945                           
 2946                           _pbr0           .DS     512
 2947                           _pbr1           .DS     512
 2948                           _pbr2           .DS     512
 2949                           _pbr3           .DS     512
 2950                           
 2951                           _TOS0_END       .DS     0
 2952                           TOS0SIZ         .EQU    (_TOS0_END - _TOS0_START)
 2953                           .ENDS
 2954                           @
 2955                           
 2956                           _TOS1:  .SECTION ref_only, common, offset TO1, range TS TE ;FAT Struct's
  Tue Jul 17 11:00:21 2018                                                                                               Page    7




 2957  019E00                   _TOS1_START     .DS     0
 2958                           
 2959                           ; current working directory HPL  
 2960  019E00                   cwdl0           .DS     (HPLSIZE*HPLMAX)
 2961  01A000                   cwdl1           .DS     (HPLSIZE*HPLMAX)
 2962  01A200                   cwdl2           .DS     (HPLSIZE*HPLMAX)
 2963  01A400                   cwdl3           .DS     (HPLSIZE*HPLMAX)
 2964                           
 2965                           ; current building path HPL
 2966  01A600                   cbpl            .DS     (HPLSIZE*HPLMAX)
 2967          01A600           HPL_CLS         .EQU    hpl_cls+cbpl
 2968          01A602           HPL_IX          .EQU    hpl_ix+cbpl
 2969          01A604           HPL_FCB         .EQU    hpl_fcb+cbpl
 2970                           
 2971                           ; BCB list's
 2972  01A800                   bcbstart        .DS     (BCBCNT*BCBSIZE)
 2973  01C800                   bcbend          .DS     0
 2974  01C800                   dmastart        .DS     (DMACNT*BCBSIZE)
 2975  01CC00                   dmaend          .DS     0
 2976  01CC00                   dma0s           .DS     (17*BCBSIZE)
 2977  01CD10                   dma1s           .DS     (17*BCBSIZE)
 2978                           
 2979  01CE20                   _TOS1_END       .DS     0
 2980          003020           TOS1SIZ         .EQU    (_TOS1_END - _TOS1_START)
 2981                           .ENDS
 2982                           
 2983                           ;---------------------------------------------------------------------------  
 2984                           ; HCB Segment
 2985                           ;--------------------------------------------------------------------------- 
 2986                           
 2987          000004           HCBBNK          .EQU    .SEG.HCBSEG
 2988          040000           HS              .SET    HCBSEG
 2989          04FFFF           HE              .SET    HCBSEG + $FFFF
 2990          040000           HO              .SET    HCBSEG
 2991                           
 2992                           _HCBS:  .SECTION ref_only, common, offset HO, range HS HE       ;HCB's List
 2993  040000                   hcb_bnk         .DS     8
 2994  040008                   hcbstart        .DS     0
 2995                           .ENDS
 2996                           
 2997                           ;.comment @
 2998                           ;---------------------------------------------------------------------------
 2999                           ; direct page for LDT var's 
 3000                           ;---------------------------------------------------------------------------
 3001                           
 3002                           ; P0OS
 3003                           DPOS:   .SECTION page0, common, ref_only, offset 0      ;OS Main D.P.
 3004                           
 3005                           ;sysbuf         .DS     2       ; floppy track 0 cache buffer
 3006  000000  00               defhsec         .DB             ; default hidden sector's in fdisk
 3007  000001  00                               .DB
 3008  000002  0000             cmdstk          .DW             ; saved stack on TOS command's
 3009  000004                   bpath           .DS     80
 3010                           
 3011  000054                   bpath1          .DS     0
 3012                           .ENDS
 3013                           ;@
  Tue Jul 17 11:00:21 2018                                                                                               Page    8




 3014                           
 3015                           ; P0LDT
 3016                           DPLDT:  .SECTION page0, common, ref_only, offset 0      ;LDT D.P.
 3017                           
 3018  000000                   ldt0            .DS     LDTSIZE
 3019  00002A                   ldt1            .DS     LDTSIZE
 3020  000054                   ldt2            .DS     LDTSIZE
 3021  00007E                   ldt3            .DS     LDTSIZE
 3022  0000A8                   ldt4            .DS     LDTSIZE
 3023                           
 3024  0000D2                   ldtp            .DS     6       ; pointer to LDT's in DPLDT page
 3025                           
 3026  0000D8                   sysbuf          .DS     4       ; floppy track 0 cache buffer
 3027                           
 3028                           .ENDS
 3029                           
 3030                           ;---------------------------------------------------------------------------
 3031                           ; direct page for FAT var's 
 3032                           ;---------------------------------------------------------------------------
 3033                           
 3034                           ; P0FAT
 3035                           DPFAT:  .SECTION page0, common, ref_only, offset 0      ;FAT D.P.
 3036                           
 3037  000000  0000             ostos           .DW             ; saved top of stack
 3038  000002  00               ioerr           .DB             ; i/o error
 3039  000003  00               ioerr2          .DB             ; extended i/o error
 3040  000004  0000             hcbroot         .DW             ; HCB struct's list
 3041  000006  0000             hcblst          .DW             ; the last one HCB
 3042  000008  00               hsiz            .DB             ; how many sector's an HCB can hold
 3043  000009  00               hlog2           .DB             ; shift count related to hsiz
 3044  00000A  0000             bcbroot         .DW             ; BCB buffer's list
 3045  00000C  0000             bcblst          .DW             ; the last one BCB
 3046  00000E  0000             dmaroot         .DW             ; dma BCB buffer's list
 3047  000010  0000             dmalst          .DW             ; the last one dma BCB
 3048  000012  0000             dmabcb          .DW             ; BCB list for floppy root, cluster#2,#3&#4
 3049  000014  00               fspt            .DB             ; sector per track (floppy)
 3050  000015  00               pdrive          .DB             ; phisycal drive number
 3051  000016  00               bplvl           .DB             ; subdir level while build path
 3052  000017  00               defdrv          .DB             ; default drive
 3053                           
 3054                           ; the first block of ldt_ var's is copied from the LDT struct
 3055  000018  00               ldtfg1          .DB             ; logical volume flag's
 3056                                                           ; <7>: device ready (fdc drive or ata device)
 3057                                                           ; <6>: if=1->HD/CF else->FD
 3058                                                           ; <0>: phisycal device number
 3059                           
 3060  000019  00               ldtfg2          .DB             ; <7>: valid volume (fat volume or cbm disk)
 3061                                                           ; <6>: if=1->FAT else->CBM (FD only)
 3062                                                           ; <5>: disk format checked
 3063                                                           ; <1:0>: disk format (fdc only)
 3064                           
 3065  00001A                   ldtfp           LP              ; fat table buffer long pointer
 3066  00001D  00               ldtfbuf         .DB             ; fat table: x-mem base bank/dma buffer
 3067                           
 3068  00001E  0000             ldtroot         .DW             ; lba of root dir
 3069  000020  0000             ldtfat1         .DW             ; lba of fat1 table
 3070  000022  0000             ldtfat2         .DW             ; lba of fat2 table
  Tue Jul 17 11:00:21 2018                                                                                               Page    9




 3071  000024  0000             ldtcls          .DW             ; lba of first data cluster
 3072  000026  0000             ldtmax          .DW             ; max usable cluster + 1
 3073  000028  00               ldtcsiz         .DB             ; cluster size (1,2,4,8,16,32,64)
 3074  000029  00               ldtcshf         .DB             ; cluster shift (0,1,2,3,4,5,6)
 3075  00002A  00               ldtfsiz         .DB             ; fat table size (if 0 -> 256)
 3076  00002B  00               ldtrsiz         .DB             ; root dir. size (sector's)
 3077  00002C  0000             ldtrent         .DW             ; root dir. max. entries
 3078  00002E  0000             ldtcent         .DW             ; max. entries in dir. cluster
 3079  000030  0000             ldteoc          .DW             ; end of cluster chain marker
 3080  000032  00               ldtmcls         .DB             ; mask for clust. module: 00,01,03,07,0F,1F,3F
 3081  000033  00               ldtfmt          .DB             ; floppy disk format (0,1,2, FF if ata device)
 3082  000034  0000             ldtcdlp         .DW             ; current working dir list pointer
 3083  000036  0000             ldtcdcls        .DW             ; current working dir start cluster
 3084  000038  0000             ldtfree         .DW             ; count of free cluster's
 3085  00003A  0000             ldtnxt          .DW             ; next free cluster
 3086  00003C  00               ldtcdlvl        .DB             ; current working dir level count
 3087  00003D                   ldtpbr          LP              ; long pointer to PBR cache buffer
 3088                           
 3089  000040  0000             chdcls          .DW             ; last accessed chained dir. cluster
 3090  000042  0000             clsofs          .DW             ; cluster's offset from start of chain
 3091                           
 3092                           ; not change order of the 2 following var's: will be accessed as 16 bit var
 3093  000044  00               entofs          .DB             ; entry offset from start of sector
 3094  000045  00               secofs          .DB             ; sector's offset from start of cluster
 3095                           
 3096  000046  0000             dircls          .DW             ; directory cluster 
 3097  000048  0000             dcnt            .DW             ; directory entry counter 
 3098  00004A  0000             lba             .DW             ; lba sector address
 3099  00004C  0000             lbah            .DW             ; lba is 24 bit's only
 3100  00004E  0000             xbuf            .DW             ; x-mem buffer transfer number
 3101                           
 3102          00004C           fhead           .EQU    lbah    ; fd head
 3103          00004E           ftrack          .EQU    xbuf    ; fd track
 3104          00004F           fsec            .EQU    xbuf+1  ; fd sector
 3105                           
 3106  000050  00               dfcbtyp         .DB             ; FCB type to search 
 3107  000051  00               dfcbatt         .DB             ; attribute of found FCB
 3108                           
 3109  000052  00               curdrv          .DB             ; current logical drive
 3110  000053                   fcbs            .DS     11      ; file control block name
 3111                           
 3112                           ;dcmask         .DW             ; mask to start of cluster
 3113                                                           ; FFF0, FFE0, FFC0, FF80, FF00, FE00
 3114                           
 3115  00005E  0000             fcbp            .DW             ; FCB buffer long pointer
 3116  000060  0000                             .DW             ; low=fcbp+2, high=x-mem bank or dma buffer
 3117          000061           dmabuf          .EQU    fcbp+3  ; dma buffer #
 3118          000061           xmbank          .EQU    fcbp+3  ; x-mem bank #
 3119                           
 3120                           ; temp area
 3121  000062  00               hcbseq          .DB
 3122  000063  00               hcbdrv          .DB
 3123  000064  0000             bcbcls          .DW
 3124  000066  00               bcbdrv          .DB
 3125  000067  00               bcbsec          .DB
 3126                           
 3127  000068  0000             thash           .DW
  Tue Jul 17 11:00:21 2018                                                                                               Page   10




 3128          000068           hcbrec  .EQU    thash
 3129          000068           wtmp    .EQU    thash
 3130                           
 3131  00006A  0000             hlast           .DW
 3132  00006C  0000             hcbcls          .DW
 3133  00006E  0000             hcbx            .DW
 3134  000070  0000             hcby            .DW
 3135          00006A           tmpp    .EQU    hlast   ; temp. long pointer
 3136          00006E           tmpx    .EQU    hcbx
 3137          00006F           wild    .EQU    hcbx+1
 3138          000070           fsiz    .EQU    hcby
 3139          000071           fptr    .EQU    hcby+1
 3140          00006E           ldrv    .EQU    hcbx
 3141          00006F           tmpldt  .EQU    hcbx+1
 3142                           
 3143  000072  0000             fhash           .DW
 3144  000074  0000             fcbofs          .DW
 3145  000076  00               bcbload         .DB
 3146  000077  00               xstart          .DB
 3147  000078  00               xend            .DB
 3148  000079  00               seccnt          .DB
 3149  00007A  00               maxseq          .DB
 3150  00007B  00               dsiz            .DB
 3151                           
 3152  00007C  00               haswld          .DB
 3153  00007D  00               strix           .DB
 3154  00007E                   pathp           LP              ; long pointer to path string
 3155                           
 3156                           ; TEMP
 3157  000081  0000             quot            .DW
 3158  000083  0000             dvsor           .DW
 3159  000085  0000             troot           .DW
 3160  000087  0000             tlst            .DW
 3161  000089  0000             bdmask          .DW
 3162  00008B  0000             bcmask          .DW
 3163                           
 3164  00008D  00               hcbuse          .DB
 3165                           
 3166                           .ENDS
 3167                           
 3172                           .LIST on
 3173                           
 3174                           ; P0OS
 3175                           ; page 0 (LDT var's) local var's 
 3176                           _FSTMP: .SECTION page0, ref_only, offset bpath
 3177          000004           FSTMP_START     .EQU    $
 3178                           
 3179  000004  0000 0000        maxsec          .LWORD          ; ata device max sector's
 3180  000008  0000 0000        hidsec          .LWORD          ; hidden sectors
 3181  00000C  0000 0000        totsec          .LWORD          ; partition size in sector's
 3182  000010  0000             maxcnt          .DW             ; max. cluster's count
 3183  000012  0000             first           .DW             ; relative first data sector
 3184                           
 3185          000012           totrsv          .EQU    first
 3186          000004           bcbbnk          .EQU    maxsec
 3187          000006           hcbsiz          .EQU    maxsec+2
 3188          000010           hcbrem          .EQU    maxcnt
  Tue Jul 17 11:00:21 2018                                                                                               Page   11




 3189          000004           tbdrv           .EQU    maxsec
 3190          000006           tbcls           .EQU    maxsec+2
 3191          000008           tblba           .EQU    hidsec
 3192          00000A           tbhead          .EQU    hidsec+2
 3193          00000C           tbtrk           .EQU    totsec
 3194          00000E           tbptr           .EQU    totsec+2
 3195          000010           tbdma           .EQU    maxcnt
 3196          000004           fdopt           .EQU    maxsec
 3197          000005           fdarg           .EQU    maxsec+1
 3198          000006           fdlbl           .EQU    maxsec+2
 3199                           
 3200  000014  0000             clscnt          .DW             ; cluster's count #
 3201  000016  0000             rsvsec          .DW             ; reserved sector's
 3202  000018  0000             fatsiz          .DW             ; FAT16 fat table size
 3203  00001A  0000             rootsiz         .DW             ; root directory size
 3204  00001C  0000             rootent         .DW             ; root dir. max. entries
 3205  00001E  0000             clsent          .DW             ; sub-diectory max. entries
 3206  000020  0000             root            .DW             ; root dir start
 3207  000022  0000             fat1            .DW             ; fat1 table start
 3208  000024  0000             fat2            .DW             ; fat 2 table start
 3209  000026  0000             start           .DW             ; first data sector
 3210  000028  0000             maxcls          .DW             ; last usable cluster+1
 3211  00002A  0000             xfatb           .DW             ; x-mem fat table buffer
 3212                           
 3213          00002A           fdix            .EQU    xfatb   ; floppy disk index DD/HD
 3214          00002B           media           .EQU    xfatb+1 ; floppy disk media field
 3215                           
 3216  00002C  0000             flba            .DW             ; low 16 bit lba
 3217  00002E  0000             freecnt         .DW             ; free cluster's count
 3218  000030  0000             freecls         .DW             ; first free cluster
 3219                           
 3220          00002E           remsec          .EQU    freecnt
 3221                           
 3222  000032                   pbrp            LP              ; PBR pointer
 3223  000035  00               clssiz          .DB             ; cluster size
 3224  000036  00               clsshf          .DB             ; cluster shift
 3225  000037  00               clsmod          .DB
 3226  000038  00               xbnk            .DB             ; x-mem bank
 3227  000039  00               lunit           .DB             ; unity letter
 3228  00003A                   tp              LP              ; fat cache pointer
 3229  00003D  00               fdfmt           .DB             ; floppy format
 3230  00003E  00               pdev            .DB             ; phisycal device
 3231  00003F  00               ldev            .DB             ; logical device
 3232  000040  00               ldtcur          .DB             ; current LDT ptr
 3233  000041  00               lflag           .DB             ; flag load fat table
 3234  000042  00               rtcsec          .DB             ; seconds
 3235  000043  00               rtcmin          .DB             ; minutes
 3236                           
 3237          000042           badcls          .EQU    rtcsec
 3238                           
 3239  000044  00               rtchour         .DB             ; hours
 3240  000045  00               rtcday          .DB             ; day of month
 3241  000046  00               rtcmonth        .DB             ; month
 3242  000047  00               rtcyear         .DB             ; year
 3243  000048  0000             ctime           .DW             ; compact time
 3244  00004A  0000             cdate           .DW
 3245  00004C                   tlp             LP
  Tue Jul 17 11:00:21 2018                                                                                               Page   12




 3246  00004F  00               fd2ix           .DB
 3247                           
 3248          00004F           nulptr          .EQU    fd2ix   ; flag null ptr
 3249                           
 3250  000050  00               rootbnk         .DB
 3251                           
 3252          000050           getfmt          .EQU    rootbnk ; get format from floppy disk
 3253                           
 3254  000051  00               fatbnk          .DB
 3255  000052  00               clsbnk          .DB
 3256  000053  00               sec100          .DB             ; tenths of seconds for ctime (ms stamp)
 3257                           
 3258          000050           FSTMP_SIZ       .EQU    ($-FSTMP_START)
 3259                                   .ENDS
 3263                           .LIST on
 3264                           
 3265                           ;---------------------------------------------------------------------------
 3266                           ; code segment -- bank $F9
 3267                           ;---------------------------------------------------------------------------
 3268                           
 3269                                   .CODEF9
 3270                                   .EXTERN cbmfs_cmd, cbmfs_err    ; fscbm.asm
 3271                                   .EXTERN lhdfmt, shpart, lfdisk  ; fsint.asm
 3272                                   .EXTERN prslbl                  ; fatdir.asm
 3273                                   .EXTERN _getopt                 ; FA/getopt.asm
 3274                           
 3275                                   .LONGA  off
 3276                                   .LONGI  off
 3277                           
 3278                           ;---------------------------------------------------------------------------
 3279                           ; System interface -- built in command's
 3280                           ;---------------------------------------------------------------------------
 3281                           
 3282          000013           lpCmd   .SET    STKPRMS
 3283                           
 3284  F9001D                   tos_cmd:
 3285                                   .GLOBAL tos_cmd
 3286                           
 3287  F9001D  A3 12                    lda     STKPBR,s        ; bank where was executed cop instruction
 3288  F9001F  85 53                    sta     COPPtr+2
 3289  F90021                           ACC16                   ; retrieve function number
 3290  F90021  C2 20                    rep     #PMFLAG
 3291                                   .LONGA  on
 3292                                   .MNLIST
 3293  F90023  A3 10                    lda     STKPCL,s        ; pointer to byte after signature
 3294  F90025  85 51                    sta     COPPtr
 3295  F90027  1A                       inc     a               ; update return address
 3296  F90028  83 10                    sta     STKPCL,s
 3297  F9002A  A7 51                    lda     [COPPtr]        ; byte after signature: function number #
 3298  F9002C  AA                       tax                     ; X=function number
 3299  F9002D  A9 00 42                 lda     #P0OS           ; set dpr
 3300  F90030  5B                       tcd
 3301  F90031  3B                       tsc                     ; save stack pointer
 3302  F90032  85 02                    sta     cmdstk
 3303  F90034  A3 13                    lda     lpCmd,s
 3304  F90036  85 4C                    sta     tlp
 3305  F90038                           ACC08
  Tue Jul 17 11:00:21 2018                                                                                               Page   13




 3306  F90038  E2 20                    sep     #PMFLAG
 3307                                   .LONGA  off
 3308                                   .MNLIST
 3309  F9003A  A3 15                    lda     lpCmd+2,s
 3310  F9003C  85 4E                    sta     tlp+2
 3311  F9003E  E0 02                    cpx     #MAXCMDS
 3312  F90040  B0 08                    bcs     ?10             ; invalid function
 3313  F90042  8A                       txa
 3314  F90043  0A                       asl     a
 3315  F90044  AA                       tax                     ; function index
 3316  F90045  FC EF 02                 jsr     (CMDJMP,x)
 3317  F90048  80 0B                    bra     ?15
 3318  F9004A  DA               ?10:    phx
 3319  F9004B  4B                       phk
 3320  F9004C  F4 58 00                 pea     #!?20
 3321  F9004F  A9 05                    lda     #5
 3322  F90051  48                       pha
 3323  F90052                           BPRINTF
 3324  F90052  02 11                    cop     $11
 3325                                   .MNLIST
 3326  F90054  38                       sec
 3327  F90055  A9 01            ?15:    lda     #1              ; return always 1 if error
 3328  F90057  6B                       rtl
 3329                           
 3330  F90058  69 6E 76 61 6C   ?20:    .DB     'invalid shell function number (%bu).', 13, 0
               69 64 20 73 68 
               65 6C 6C 20 66 
               75 6E 63 74 69 
               6F 6E 20 6E 75 
               6D 62 65 72 20 
               28 25 62 75 29 
               2E 0D 00 
 3331                           
 3332                           ; fdisk command
 3333                           ;
 3334                           ;       fdisk [-s] X:           ; show partition on drive X
 3335                           ;       fdisk -d X:             ; delete partition on drive X
 3336                           ;       fdisk -c [-llabel] X:   ; create partition on drive X and format it
 3337                           ;
 3338  F9007E                   fdisk:
 3339  F9007E  20 EF 01                 jsr     fdskopt         ; get option (A=drive)
 3340  F90081  B0 10                    bcs     ?10
 3341  F90083  A4 04                    ldy     fdopt
 3342  F90085  D0 03                    bne     ?02
 3343  F90087  4C C1 16                 jmp     shpart          ; show partition
 3344  F9008A  88               ?02:    dey
 3345  F9008B  F0 06                    beq     ?04             ; delete partition
 3346  F9008D  A4 06                    ldy     fdlbl           ; flag label
 3347  F9008F  AA                       tax                     ; drive
 3348  F90090  4C EB 0E                 jmp     lfdisk          ; create & format
 3349  F90093                   ?04:
 3350  F90093  60               ?10:    rts
 3351                           
 3352                           ; format logical drive
 3353                           ;
 3354                           ;       param's (5 bytes)
 3355                           ;
  Tue Jul 17 11:00:21 2018                                                                                               Page   14




 3356                           ;               bDrive          logical drive number
 3357                           ;               bFmt            format (0,1 or 2) + quick flag (bit 7)
 3358                           ;               lpLabel         long ptr to label string (volume name)
 3359                           ;
 3360                           ; param's offset
 3361          000015           lpLabel .SET    STKPRMS + 2
 3362          000018           bFmt    .SET    STKPRMS + 5
 3363          000019           bDrive  .SET    STKPRMS + 6
 3364                           
 3365  F90094                   format:
 3366  F90094  A3 19                    lda     bDrive,s
 3367  F90096  20 9A 01                 jsr     chkdrv          ; valid drive number?
 3368  F90099  85 3F                    sta     ldev            ; logical drive
 3369  F9009B  A8                       tay
 3370  F9009C  A3 18                    lda     bFmt,s
 3371  F9009E  85 41                    sta     lflag           ; quick format flag
 3372  F900A0  29 03                    and     #3
 3373  F900A2  C9 03                    cmp     #3
 3374  F900A4  D0 02                    bne     ?04
 3375  F900A6  A9 02                    lda     #2              ; force dos HD format
 3376  F900A8  85 3D            ?04:    sta     fdfmt
 3377  F900AA  B6 D2                    ldx     ldtp,y
 3378  F900AC  86 40                    stx     ldtcur          ; LDT ptr
 3379  F900AE  20 81 01                 jsr     chkrdy          ; drive is ready?       
 3380  F900B1                           ACC16
 3381  F900B1  C2 20                    rep     #PMFLAG
 3382                                   .LONGA  on
 3383                                   .MNLIST
 3384  F900B3  A3 15                    lda     lpLabel,s       ; get label string pointer
 3385  F900B5  8D 7E 41                 sta     !P0FAT+pathp
 3386  F900B8  85 4C                    sta     tlp
 3387  F900BA                           ACC08
 3388  F900BA  E2 20                    sep     #PMFLAG
 3389                                   .LONGA  off
 3390                                   .MNLIST
 3391  F900BC  A0 00                    ldy     #0
 3392  F900BE  A3 17                    lda     lpLabel+2,s
 3393  F900C0  85 4E                    sta     tlp+2           ; test null ptr
 3394  F900C2  8D 80 41                 sta     !P0FAT+pathp+2
 3395  F900C5  05 4D                    ora     tlp+1
 3396  F900C7  05 4C                    ora     tlp
 3397  F900C9  F0 01                    beq     ?06             ; no label
 3398  F900CB  88                       dey                     ; Y=$FF
 3399  F900CC  84 4F            ?06:    sty     nulptr          ; flag null ptr
 3400  F900CE  34 00                    bit     ldt_fg1,x       ; test fixed disk/floppy disk
 3401  F900D0  70 13                    bvs     ?12             ; fixed disk
 3402  F900D2  20 67 01                 jsr     tstfd           ; test floppy disk format
 3403  F900D5  A5 50                    lda     getfmt          ; here X=phisycal drive
 3404  F900D7  30 04                    bmi     ?08             ; can't use quick format
 3405  F900D9  C5 3D                    cmp     fdfmt           ; compare with requested format
 3406  F900DB  F0 02                    beq     ?10             ; we can use quick format
 3407  F900DD  64 41            ?08:    stz     lflag           ; standard full fd format
 3408  F900DF  A5 3D            ?10:    lda     fdfmt
 3409  F900E1  C9 01                    cmp     #1
 3410                                   ;bne    ?12             ; ibm-dos format
 3411  F900E3  F0 23                    beq     cbmfmt          ; cbm format
 3412  F900E5  98               ?12:    tya
  Tue Jul 17 11:00:21 2018                                                                                               Page   15




 3413  F900E6  F0 12                    beq     ?16             ; no volume name specified
 3414  F900E8  0B                       phd
 3415  F900E9  F4 00 41                 pea     #P0FAT
 3416  F900EC  2B                       pld
 3417  F900ED  20 96 1E                 jsr     prslbl          ; parse label string
 3418  F900F0  2B                       pld
 3419  F900F1  90 07                    bcc     ?16
 3420  F900F3  F0 03                    beq     ?14             ; empty string
 3421  F900F5  4C CB 01                 jmp     invlbl          ; invalid label
 3422  F900F8  64 4F            ?14:    stz     nulptr          ; like if not string given
 3423  F900FA  A6 40            ?16:    ldx     ldtcur
 3424  F900FC  34 00                    bit     ldt_fg1,x       ; test fixed disk/floppy disk
 3425  F900FE  50 07                    bvc     ?18             ; floppy disk
 3426  F90100  A6 3E                    ldx     pdev
 3427  F90102  A4 4F                    ldy     nulptr
 3428  F90104  4C 56 0F                 jmp     lhdfmt
 3429  F90107  60               ?18:    rts
 3430                           
 3431                           ; format cbm diskette (X=phisycal drive) 
 3432  F90108                   cbmfmt:
 3433  F90108  A5 4F                    lda     nulptr
 3434  F9010A  F0 32                    beq     nolbl           ; cbm format need a volume name
 3435  F9010C  A9 51                    lda     #'Q'            ; send command "Qx:...." (quick format)
 3436  F9010E  85 04                    sta     bpath
 3437  F90110  8A                       txa
 3438  F90111  09 30                    ora     #'0'
 3439  F90113  85 05                    sta     bpath+1
 3440  F90115  A9 3A                    lda     #':'
 3441  F90117  85 06                    sta     bpath+2
 3442  F90119  A0 00                    ldy     #0
 3443  F9011B  A2 03                    ldx     #3
 3444  F9011D  B7 4C            ?02:    lda     [tlp],y
 3445  F9011F  95 04                    sta     bpath,x
 3446  F90121  F0 08                    beq     ?04
 3447  F90123  C8                       iny
 3448  F90124  E8                       inx
 3449  F90125  E0 20                    cpx     #32             ; max. 32 char's
 3450  F90127  90 F4                    bcc     ?02
 3451  F90129  74 04                    stz     bpath,x         ; trunc
 3452  F9012B  A9 04            ?04:    lda     #bpath          ; address of command string
 3453  F9012D  A2 42                    ldx     #>P0OS
 3454  F9012F  A0 00                    ldy     #0
 3455  F90131  20 F6 2E                 jsr     cbmfs_cmd       ; cbm quick format
 3456  F90134  B0 01                    bcs     cbmerr
 3457  F90136  60                       rts
 3458  F90137                           
 3459                           ;---------------------------------------------------------------------------
 3460                           ; check routines & error handling
 3461                           ;---------------------------------------------------------------------------
 3462                           
 3463                           ; report cbm emulator error
 3464  F90137                   cbmerr:
 3465  F90137  20 12 2F                 jsr     cbmfs_err       ; return error string pointer (C,X)
 3466  F9013A                           SCNSTROUT               ; print error string
 3467  F9013A  02 03                    cop     $03
 3468                                   .MNLIST
 3469  F9013C  80 7D                    bra     cmderr
  Tue Jul 17 11:00:21 2018                                                                                               Page   16




 3470                           
 3471                           ; no label/disk name specified error
 3472  F9013E                   nolbl:
 3473  F9013E                           SCNPRINT
 3474  F9013E  02 01                    cop     $01
 3475                                   .MNLIST
 3476  F90140  6E 6F 20 6C 61           .DB     'no label nor cbm disk name specified', 0
               62 65 6C 20 6E 
               6F 72 20 63 62 
               6D 20 64 69 73 
               6B 20 6E 61 6D 
               65 20 73 70 65 
               63 69 66 69 65 
               64 00 
 3477  F90165  80 54                    bra     cmderr
 3478                           
 3479                           ; test floppy disk and get format (X=LDT pointer)
 3480                           ; return X=phisycal drive
 3481  F90167                   tstfd:
 3482  F90167  B5 00                    lda     ldt_fg1,x
 3483  F90169  29 01                    and     #1
 3484  F9016B  AA                       tax                     ; phisycal drive
 3485  F9016C                           FDCTST                  ; check media inside drive
 3486  F9016C  02 30                    cop     $30
 3487  F9016E  03                       .DB     $03
 3488                                   .MNLIST
 3489  F9016F  90 04                    bcc     ?02             ; media ready
 3490  F90171  C0 11                    cpy     #FDC_CHANGE     ; check error code
 3491  F90173  D0 10                    bne     notrdy          ; disk not ready
 3492  F90175  A0 FF            ?02:    ldy     #$FF
 3493  F90177  84 50                    sty     getfmt          ; invalid disk format
 3494  F90179                           FDCGETFMT               ; try to get media format
 3495  F90179  02 30                    cop     $30
 3496  F9017B  04                       .DB     $04
 3497                                   .MNLIST
 3498  F9017C  B0 02                    bcs     ?04             ; unformatted disk or unknow disk format
 3499  F9017E  84 50                    sty     getfmt          ; current disk format
 3500  F90180  60               ?04:    rts
 3501                           
 3502                           ; check drive ready (X=LDT pinter)
 3503  F90181                   chkrdy:
 3504  F90181  34 00                    bit     ldt_fg1,x
 3505  F90183  30 14                    bmi     noer
 3506  F90185                   notrdy: SCNPRINT
 3507  F90185  02 01                    cop     $01
 3508                                   .MNLIST
 3509  F90187  64 72 69 76 65           .DB     'drive not ready', 0
               20 6E 6F 74 20 
               72 65 61 64 79 
               00 
 3510  F90197  80 22                    bra     cmderr
 3511                           
 3512  F90199  60               noer:   rts
 3513  F9019A                           
 3514                           ; check drive number (A=drive #)
 3515  F9019A                   chkdrv:
 3516  F9019A  C9 04                    cmp     #MAXDRV
  Tue Jul 17 11:00:21 2018                                                                                               Page   17




 3517  F9019C  90 FB                    bcc     noer
 3518  F9019E  18                       clc
 3519  F9019F  F0 F8                    beq     noer            ; usb #0 device
 3520  F901A1                   invdrv: SCNPRINT
 3521  F901A1  02 01                    cop     $01
 3522                                   .MNLIST
 3523  F901A3  69 6E 76 61 6C           .DB     'invalid drive specified', 0
               69 64 20 64 72 
               69 76 65 20 73 
               70 65 63 69 66 
               69 65 64 00 
 3524  F901BB                   cmderr:
 3525  F901BB                           SCNPRINT
 3526  F901BB  02 01                    cop     $01
 3527                                   .MNLIST
 3528  F901BD  2E 0D 00                 .DB     '.', 13, 0
 3529  F901C0                           ACC16CLC
 3530  F901C0  C2 21                    rep     #(PMFLAG.OR.PCFLAG)
 3531                                   .LONGA  on
 3532                                   .MNLIST
 3533  F901C2  A5 02                    lda     cmdstk          ; recover stack
 3534  F901C4  1B                       tcs
 3535  F901C5                           ACC08
 3536  F901C5  E2 20                    sep     #PMFLAG
 3537                                   .LONGA  off
 3538                                   .MNLIST
 3539  F901C7  A9 01                    lda     #1
 3540  F901C9  38                       sec
 3541  F901CA  6B                       rtl                     ; return to caller
 3542                           
 3543                           ; invalid label
 3544  F901CB                   invlbl:
 3545  F901CB                           SCNPRINT
 3546  F901CB  02 01                    cop     $01
 3547                                   .MNLIST
 3548  F901CD  69 6E 76 61 6C           .DB     'invalid label', 0
               69 64 20 6C 61 
               62 65 6C 00 
 3549  F901DB  80 DE                    bra     cmderr
 3550                           
 3551                           ; missing drive
 3552  F901DD                   nodrv:
 3553  F901DD                           SCNPRINT
 3554  F901DD  02 01                    cop     $01
 3555                                   .MNLIST
 3556  F901DF  6D 69 73 73 69           .DB     'missing drive', 0
               6E 67 20 64 72 
               69 76 65 00 
 3557  F901ED  80 CC                    bra     cmderr
 3558                           
 3559                           ; parse command line for 'fdisk' command
 3560  F901EF                   fdskopt:
 3561  F901EF  64 04                    stz     fdopt
 3562  F901F1  64 05                    stz     fdarg
 3563  F901F3  64 06                    stz     fdlbl
 3564  F901F5  A2 80                    ldx     #$80
 3565  F901F7  DA                       phx                     ; flag
  Tue Jul 17 11:00:21 2018                                                                                               Page   18




 3566  F901F8  A6 4E                    ldx     tlp+2           ; command line
 3567  F901FA  DA                       phx
 3568  F901FB  D4 4C                    pei     (tlp)
 3569  F901FD  4B                       phk                     ; option string
 3570  F901FE  F4 A3 02                 pea     #!?100          
 3571  F90201  F4 00 00                 pea     #0              ; result
 3572  F90204  F4 00 00                 pea     #0
 3573  F90207  22 09 00 FA      ?10:    jsl     _getopt         ; get opttion's loop
 3574  F9020B  B0 48                    bcs     ?20             ; error
 3575  F9020D  AA                       tax                     ; option char
 3576  F9020E  F0 45                    beq     ?20             ; end of command line
 3577  F90210  30 31                    bmi     ?18             ; no option argument
 3578  F90212  C9 73                    cmp     #'s'
 3579  F90214  D0 04                    bne     ?12
 3580  F90216  64 04                    stz     fdopt           ; show
 3581  F90218  80 ED                    bra     ?10
 3582  F9021A  C9 64            ?12:    cmp     #'d'
 3583  F9021C  D0 06                    bne     ?14
 3584  F9021E  A9 01                    lda     #1
 3585  F90220  85 04                    sta     fdopt           ; delete
 3586  F90222  80 E3                    bra     ?10
 3587  F90224  C9 63            ?14:    cmp     #'c'
 3588  F90226  D0 06                    bne     ?16
 3589  F90228  A9 02                    lda     #2
 3590  F9022A  85 04                    sta     fdopt           ; create
 3591  F9022C  80 D9                    bra     ?10
 3592  F9022E  A3 01            ?16:    lda     $01,s           ; argument for 'l' option
 3593  F90230  8D 7E 41                 sta     !P0FAT+pathp
 3594  F90233  A3 02                    lda     $02,s           ; store argument pointer
 3595  F90235  8D 7F 41                 sta     !P0FAT+pathp+1
 3596  F90238  A3 03                    lda     $03,s
 3597  F9023A  8D 80 41                 sta     !P0FAT+pathp+2
 3598  F9023D  A9 FF                    lda     #$FF
 3599  F9023F  85 06                    sta     fdlbl   
 3600  F90241  80 C4                    bra     ?10
 3601  F90243  A3 01            ?18:    lda     $01,s           ; argument without option
 3602  F90245  85 4C                    sta     tlp
 3603  F90247  A3 02                    lda     $02,s           ; store argument pointer
 3604  F90249  85 4D                    sta     tlp+1
 3605  F9024B  A3 03                    lda     $03,s
 3606  F9024D  85 4E                    sta     tlp+2
 3607  F9024F  A9 80                    lda     #$80
 3608  F90251  85 05                    sta     fdarg
 3609  F90253  80 B2                    bra     ?10
 3610  F90255  08               ?20:    php                     ; clean stack
 3611  F90256  FA                       plx                     ; save carry
 3612  F90257                           ACC16CLC
 3613  F90257  C2 21                    rep     #(PMFLAG.OR.PCFLAG)
 3614                                   .LONGA  on
 3615                                   .MNLIST
 3616  F90259  3B                       tsc
 3617  F9025A  69 0B 00                 adc     #11
 3618  F9025D  1B                       tcs
 3619  F9025E                           ACC08
 3620  F9025E  E2 20                    sep     #PMFLAG
 3621                                   .LONGA  off
 3622                                   .MNLIST
  Tue Jul 17 11:00:21 2018                                                                                               Page   19




 3623  F90260  8A                       txa
 3624  F90261  4A                       lsr     a               ; test carry
 3625  F90262  B0 2F                    bcs     ?30             ; exit
 3626  F90264  24 05                    bit     fdarg
 3627  F90266  30 03                    bmi     ?21
 3628  F90268  4C DD 01                 jmp     nodrv
 3629  F9026B  20 CB 02         ?21:    jsr     drvarg
 3630  F9026E  C9 02                    cmp     #ATADRV
 3631  F90270  90 22                    bcc     ?40
 3632  F90272  A4 04                    ldy     fdopt
 3633  F90274  C0 02                    cpy     #2
 3634  F90276  D0 1A                    bne     ?26
 3635  F90278  24 06                    bit     fdlbl
 3636  F9027A  10 16                    bpl     ?26
 3637  F9027C  85 3F                    sta     ldev
 3638  F9027E  0B                       phd
 3639  F9027F  F4 00 41                 pea     #P0FAT
 3640  F90282  2B                       pld
 3641  F90283  20 96 1E                 jsr     prslbl          ; parse label string
 3642  F90286  2B                       pld
 3643  F90287  90 07                    bcc     ?24
 3644  F90289  F0 03                    beq     ?22             ; empty string
 3645  F9028B  4C CB 01                 jmp     invlbl          ; invalid label
 3646  F9028E  64 06            ?22:    stz     fdlbl           ; like if not string given
 3647  F90290  A5 3F            ?24:    lda     ldev    
 3648  F90292  18               ?26:    clc
 3649  F90293  60               ?30:    rts
 3650  F90294  69 41            ?40:    adc     #'A'    
 3651  F90296  48                       pha
 3652  F90297  4B                       phk
 3653  F90298  F4 AC 02                 pea     #!?110
 3654  F9029B  A9 05                    lda     #5
 3655  F9029D  48                       pha
 3656  F9029E                           BPRINTF
 3657  F9029E  02 11                    cop     $11
 3658                                   .MNLIST
 3659  F902A0  4C BB 01                 jmp     cmderr
 3660                           
 3661  F902A3  73 20 63 20 64   ?100:   .DB     's c d l:', 0
               20 6C 3A 00 
 3662  F902AC  64 72 69 76 65   ?110:   .DB     'drive <%c> is not a fixed disk', 0
               20 3C 25 63 3E 
               20 69 73 20 6E 
               6F 74 20 61 20 
               66 69 78 65 64 
               20 64 69 73 6B 
               00 
 3663                           
 3664                           ; check if drive argument is valid
 3665  F902CB                   drvarg:
 3666  F902CB  A0 01                    ldy     #1
 3667  F902CD  B7 4C                    lda     [tlp],y
 3668  F902CF  C9 3A                    cmp     #':'
 3669  F902D1  D0 19                    bne     ?20
 3670  F902D3  C8                       iny
 3671  F902D4  B7 4C                    lda     [tlp],y
 3672  F902D6  D0 14                    bne     ?20
  Tue Jul 17 11:00:21 2018                                                                                               Page   20




 3673  F902D8  A7 4C                    lda     [tlp]
 3674  F902DA  C9 61                    cmp     #'a'
 3675  F902DC  90 06                    bcc     ?08
 3676  F902DE  C9 7B                    cmp     #'z'+1
 3677  F902E0  B0 03                    bcs     ?10
 3678  F902E2  29 DF                    and     #$DF
 3679  F902E4  38               ?08:    sec
 3680  F902E5  E9 41            ?10:    sbc     #'A'
 3681  F902E7  90 03                    bcc     ?20
 3682  F902E9  4C 9A 01                 jmp     chkdrv
 3683  F902EC  4C A1 01         ?20:    jmp     invdrv
 3684                           
 3685                           ;---------------------------------------------------------------------------
 3686                           ; Tables
 3687                           ;---------------------------------------------------------------------------
 3688                           
 3689                           ; command's jump table
 3690  F902EF                   CMDJMP:
 3691  F902EF  7E00 9400                .DW     fdisk, format
 3692                           
 3693          000002           MAXCMDS         .EQU    ($ - CMDJMP)/2


             Lines Assembled : 3606                  Errors : 0