Subversion Repositories MB01 Project

Rev

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

  Thu Feb 11 16:56:28 2016                                                                                               Page    1







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

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


 2132                           .LIST           on
 2133                           
 2134  F8FF66                           .INCLUDE inc\dirp00.inc
 2135                           ;----------------------------------------------------------
 2136                           ; DIRP00.ASM
 2137                           ; PROGETTO: B1601
 2138                           ;
 2139                           ; Variabili in Direct Page $00
 2140                           ;----------------------------------------------------------
 2141                           
 2142                           ; sezione COMMON -- questo permette di includere il file in piu' file
 2143                           
 2144                           .LIST on
 2145                           
 2146                           DIRP00: .SECTION page0, ref_only, common        ;Direct-Page 00
 2147                           
 2148  000000                           .ABSOLUTE               ;; inizia sempre da $00
 2149  000000                           .ORG            0x00
 2150  000000                           
 2151  000000  0000             JiffyClk        .DW                     ; contatore 10ms 32 bit
 2152  000002  0000                             .DW
 2153  000004                   SysTmr          .DS     SYSTMRCNT       ; system timer 0 (10ms)
 2154  000008                   SysTMF          .DS     SYSTMRCNT       ; flag timer (80 -> start)
 2155  00000C  00               Bnk0Flag        .DB                     ; <7>: flag test RAM banco 0 ok
 2156                                                                   ; <6>: flag warm reset
 2157  00000D  00               RTCFlag         .DB
 2158                           
 2159  00000E                   atadev          .DS     2       ; flag device on ata bus #0 & #1
 2160                                                           ; <7>: device ready
 2161                                                           ; <6>: compact flash devide (C.F.)
 2162                                                           ; <5>: device identification ok
 2163                                                           ; <4>: MBR loaded
 2164                                                           ; <3>: valid signature in MBR
 2165                                                           ; <2>: first partition found&active
 2166                                                           ; <1>:
 2167                                                           ; <0>: valid partition flag
 2168                           
 2169  000010                   atasec          .DS     8       ; max. user sectors on ata device
 2170  000018                   atambr          .DS     8       ; data for first partition found in mbr
 2171                                                           ; first 3 bytes for start sector of partition
 2172                                                           ; last byte for partition type
 2173                           
 2174  000020  00               fdcdrv          .DB             ; phisycal drive status (drive #0)
 2175                                                           ; <7>: disk format established in bit 0&1 
 2176                                                           ; <6>: double step seek done
 2177                                                           ; <5>: trust format bit's (set after ok r/w)
  Thu Feb 11 16:56:28 2016                                                                                               Page    2




 2178                                                           ; <4>: write protect bit (if disk in drive)
 2179                                                           ; <3>: don't care
 2180                                                           ; <2>: don't care                               
 2181                                                           ; <1>: HD disk if set else DD disk
 2182                                                           ; <0>: CBM format if set else IBM format
 2183                           
 2184  000021  00               vdrive          .DB             ; virtual drive status (ram disk, drive #1)
 2185                                                           ; <7>: disk format established in bit 0&1 
 2186                                                           ; <6>: change disk simulation (after format)
 2187                                                           ; <5>: don't care
 2188                                                           ; <4>: write protect bit (under sw control)
 2189                                                           ; <3>: don't care
 2190                                                           ; <2>: don't care                               
 2191                                                           ; <1>: HD disk if set else DD disk
 2192                                                           ; <0>: CBM format if set else IBM format
 2193                           
 2194  000022  00               fdcctl          .DB             ; fdc controller status
 2195                                                           ; <7>: drive is attached
 2196                                                           ; <6>: drive need recalibration (restore)
 2197                                                           ; <5>: FDC controller ok
 2198                                                           ; <4>: motor on
 2199                                                           ; <3>: dma is active
 2200                                                           ; <2>: dma chip ok (post routine)
 2201                                                           ; <1>: clock rate (1=HD,0=DD)
 2202                                                           ; <0>: disk ready
 2203                           
 2204  000023  00               fdctrk          .DB             ; fd: current seek track
 2205  000024  00               fdcerr          .DB             ; fd: last error code
 2206  000025  00               ataerr          .DB             ; ata: last error code
 2207  000026  00               ataxer          .DB             ; ata: last extended error code
 2208                           
 2209  000027  00               CtrlBrk         .DB             ; flag CTRL+BREAK (NMI)
 2210                           
 2211  000028  0000             MemTop          .DW             ; top memoria RAM
 2212  00002A  00                               .DB             ; banco top mem
 2213                           
 2214  00002B  00               DflTxtIn        .DB             ; device di default text input 
 2215  00002C  00               DflTxtOut       .DB             ; device di default text output
 2216                           
 2217  00002D                   COPPtr          LP              ; long pointer for COP decoding
 2218  000030  00               COPIdx          .DB             ; COP signature/index
 2219                           
 2220                           ; variabili utilizzate da ACIA
 2221  000031  00               ACIAFlag        .DB
 2222                           
 2223  000032  00               ACIArxe_1       .DB             ; flag errore   7: errore RX (scarta dato)
 2224                                                           ;               6: overflow buffer RX
 2225                                                           ;               5: disconnessione remota
 2226                                                           ;               2: framing error
 2227                                                           ;               1: parity error
 2228                                                           ;               0: overrun error
 2229  000033  00               ACIArxe_2       .DB
 2230                           
 2231  000034  00               ACIAhsk_1       .DB             ; handshake     7: handshake attivo
 2232                                                           ;               6: handshake hardware (RTS,CTS)
 2233  000035  00               ACIAhsk_2       .DB
 2234                           
  Thu Feb 11 16:56:28 2016                                                                                               Page    3




 2235  000036  00               ACIAPause_1     .DB             ; flag pausa    7: pausa remota (XOFF/RTS=1)
 2236                                                           ;               6: pausa locale (XON/CTS=1)
 2237  000037  00               ACIAPause_2     .DB
 2238                           
 2239  000038  00               ACIAdsrt_1      .DB             ; status transizioni DSR, CTS, DCD
 2240                                                           ; 7: DSRT, 6: CTST, 5: DCDT
 2241  000039  00               ACIAdsrt_2      .DB
 2242                           
 2243  00003A  00               ACIAdsrl_1      .DB             ; status livello linee DSR, CTS, DCD, DTR, RTS
 2244                                                           ; 7: DSRLVL, 6: CTSLVL, 5: DCDLVL
 2245                                                           ; 1:DTRLVL, 0:RTSLVL
 2246  00003B  00               ACIAdsrl_2      .DB
 2247                           
 2248  00003C  00               ACIArem_1       .DB             ; byte OR registro formato per pausa remota
 2249  00003D  00               ACIArem_2       .DB
 2250                           
 2251  00003E  00               ACIAmsk_1       .DB             ; maschera AND per test disconnessione
 2252                                                           ; $80 per test DSR - $20 per test DCD
 2253  00003F  00               ACIAmsk_2       .DB
 2254                           
 2255  000040  00               ACIAcsr_1       .DB             ; control status durante IRQ
 2256  000041  00               ACIAcsr_2       .DB
 2257  000042  00               ACIAfr_1        .DB             ; copia registro di formato
 2258  000043  00               ACIAfr_2        .DB
 2259  000044  00               ACIAOut_1       .DB             ; trasmissione XON/XOFF
 2260  000045  00               ACIAOut_2       .DB
 2261                           
 2262  000046  0000             ACIAICnt_1      .DW             ; numero bytes in coda RX 1
 2263  000048  0000             ACIAIHead_1     .DW             ; puntatore testa buffer RX 1
 2264  00004A  0000             ACIAITail_1     .DW             ; puntatore coda buffer RX 1
 2265  00004C  0000             ACIAOCnt_1      .DW             ; numero bytes in coda TX 1
 2266  00004E  0000             ACIAOHead_1     .DW             ; puntatore testa buffer TX 1
 2267  000050  0000             ACIAOTail_1     .DW             ; puntatore coda buffer TX 1
 2268                           
 2269  000052  0000             ACIAICnt_2      .DW             ; numero bytes in coda RX 2
 2270  000054  0000             ACIAIHead_2     .DW             ; puntatore testa buffer RX 2
 2271  000056  0000             ACIAITail_2     .DW             ; puntatore coda buffer RX 2
 2272  000058  0000             ACIAOCnt_2      .DW             ; numero bytes in coda TX 2
 2273  00005A  0000             ACIAOHead_2     .DW             ; puntatore testa buffer TX 2
 2274  00005C  0000             ACIAOTail_2     .DW             ; puntatore coda buffer TX 2
 2275                           
 2276                           ; bios mem
 2277  00005E  0000             nsize           .DW     ; dimensione blocco da allocare
 2278                           ;bsize          .DW     ; dimensione vera blocco free
 2279  000060  0000             splitsz         .DW     ; dimensione blocco splittato
 2280  000062  0000             bfree           .DW     ; puntatore blocco free
 2281  000064  0000             hdrptr          .DW     ; puntatore header heap
 2282                           
 2283  000066  0000             pbrklv          .DW     ; current break level of current process
 2284  000068  0000             pbrkmin         .DW     ; minimum breal level of current process
 2285  00006A  0000             pbrkmax         .DW     ; maximum breal level of current process
 2286                           
 2287  00006C  00               ACIATmp         .DB
 2288  00006D  00                               .DB
 2289  00006E                           
 2290                           ; ata/fdc work var's
 2291  00006E                   wrktmp          .DS     $28
  Thu Feb 11 16:56:28 2016                                                                                               Page    4




 2292                           
 2293                           ; logical volume's flag
 2294                           ; vol0:phisycal drive, vol1: virtual disk, vol2: ata #0, vol3: ata #1
 2295  000096                   volfg1          .DS     4       ; <7>: ready (fdc drive or ata device)
 2296                                                           ; <6>: valid (fat volume or cbm disk)
 2297                                                           ; <0>: device #
 2298                           
 2299  00009A                   volfg2          .DS     4       ; <7>: ata device (else fdc disk)
 2300                                                           ; <6>: fat volume (else cbm disk)
 2301                                                           ; <1>: fdc only: HD disk if set else DD disk
 2302                           
 2303  00009E  0000             xmin            .DW
 2304  0000A0  0000             xrov            .DW     ; next x-mem buffer free index
 2305  0000A2  0000             xcnt            .DW     ; how much x-mem buffer will allocate
 2306  0000A4  0000             xcls            .DW
 2307  0000A6  0000             xsecd           .DW
 2308                           
 2309  0000A8  0000             xbfree          .DW
 2310  0000AA  0000             xbfg            .DW
 2311                           ;xbmin          .DW
 2312  0000AC  0000             xbtmp           .DW
 2313                           ;xbcnt          .DW
 2314  0000AE  0000             xbidx2          .DW
 2315                           
 2316  0000B0  00               RTCsec          .DB
 2317  0000B1  00               RTCmin          .DB
 2318  0000B2  00               RTChour         .DB
 2319  0000B3  00               RTCdofw         .DB             ; day of week
 2320  0000B4  00               RTCday          .DB
 2321  0000B5  00               RTCmonth        .DB
 2322  0000B6  00               RTCyear         .DB
 2323  0000B7  00               RTCctry         .DB             ; century
 2324                           
 2325  0000B8  0000             CTime           .DW
 2326  0000BA  0000             CDate           .DW
 2327                           
 2328  0000BC  00               BiosEnt         .DB             ; flag accesso a bios setup
 2329                           
 2330  0000BC                           .RELATIVE
 2331                           
 2332                                   .ENDS
 2333                           
 2357                           .LIST on
 2358                           
 2359                           ;---------------------------------------------------------------------------
 2360                           
 2361          000010           CDSSIZ  .EQU    16      ; Current Directory Structure Size
 2362          000020           CDSMAX  .EQU    32      ; Max. subdirectory level
 2363          000008           HCBSIZ  .EQU    8       ; Hash Control Block Size
 2364          000100           HCBMAX  .EQU    256     ; Max. number of HCB structs
 2365          000800           HCBLIM  .EQU    (HCBSIZ*HCBMAX)
 2366          000010           DHTSIZ  .EQU    16      ; Directory Hash Table Size
 2367          000100           DHTBLK  .EQU    DHTSIZ*16       ; 16 entry in one DHT
 2368          001000           DHTMAX  .EQU    (DHTSIZ*HCBMAX)
 2369                           
 2370          000B40           XBSTART .EQU    $0B40           ; first x-mem buffer
 2371          000FFF           XBLST   .EQU    $0FFF           ; last x-mem buffer
  Thu Feb 11 16:56:28 2016                                                                                               Page    5




 2372          0004C0           XBCNT   .EQU    XBLST+1-XBSTART ; x-mem buffer's count
 2373          000980           BS      .EQU    XBCNT*2         ; word array size
 2374                           
 2375                           ; segment for store buffer array handler
 2376                           _XBUF:  .SECTION ref_only, common, offset XMEMBUF, range $010000 $01FFFF ;XBUF
 2377  019400                   vxcls           .DS     BS      ; cluster/lba low
 2378  019D80                   vxsec           .DS     BS      ; sector/lba high + device
 2379                           .ENDS
 2380                           
 2381                           ; Segment for store CDS, HCB, RHT struct's
 2382                           _FATS:  .SECTION ref_only, common, offset FATSOFS, range FATSST FATSEND ;FAT Struct's
 2383  01C000                   _FATS_START     .DS     0
 2384                           ; CDS for logical device 0 
 2385  01C000                   cds_0           .DS     0
 2386  01C000  0000             cds_cls         .DW             ; first cluster of dir. entry
 2387  01C002  0000             cds_idx         .DW             ; index entry on parent cluster
 2388  01C004                   cds_nam         .DS     11      ; directory name
 2389  01C00F  00               cds_fill        .DB             ; unused byte
 2390  01C010                                   
 2391  01C010                                   .DS     (CDSSIZ*(CDSMAX-1))
 2392                           ; CDS for logical device 1
 2393  01C200                   cds_1           .DS     (CDSSIZ*CDSMAX)
 2394                           ; CDS for logical device 2
 2395  01C400                   cds_2           .DS     (CDSSIZ*CDSMAX)
 2396                           ; CDS for logical device 3
 2397  01C600                   cds_3           .DS     (CDSSIZ*CDSMAX)
 2398                           
 2399                           ; HCB struct. 
 2400  01C800                   hcb_0           .DS     0        ; HCB start
 2401  01C800  0000             hcb_cls         .DW             ; cluster
 2402  01C802  00               hcb_dev         .DB             ; device
 2403  01C803  00               hcb_sec         .DB             ; sector of cluster
 2404  01C804  0000             hcb_prnt        .DW             ; parent cluster
 2405  01C806  0000             hcb_dhtp        .DW             ; pointer to DHT struct's
 2406  01C808                                   .DS     (HCBSIZ*(HCBMAX-1))
 2407                           
 2408                           ; Root hash Table for 4 logical devices
 2409  01D000                   rht_hash0       .DS     512*2   ; hard disk (512 entry max.)
 2410  01D400                   rht_hash1       .DS     512*2
 2411  01D800                   rht_hash2       .DS     224*2   ; floppy disk (224 entry max.)
 2412  01D9C0                   rht_hash3       .DS     224*2
 2413                           
 2414  01DB80                   _FATS_END       .DS     0
 2415          001B80           FATSSIZ         .EQU    (_FATS_END-_FATS_START)
 2416                           .ENDS
 2417                           
 2418                           _DHTS:  .SECTION ref_only, common, offset DHTSST, range DHTSST DHTSEND  ;DHT Struct's
 2419  040000                   dht_0           .DS     0
 2420  040000  0000             dht_hash        .DW             ; hash of file name
 2421  040002  0000             dht_cls         .DW             ; first cluster of file
 2422  040004                   dht_nam         .DS     11      ; file name
 2423  04000F  00               dht_attr        .DB             ; file attribute
 2424  040010                                   .DS     (DHTSIZ*(DHTMAX-1))
 2425                           .ENDS
 2426                           
 2427                           ;---------------------------------------------------------------------------
 2428                           ; DCB struct (Device Control Block) contain var's related to FAT 
  Thu Feb 11 16:56:28 2016                                                                                               Page    6




 2429                           ;---------------------------------------------------------------------------
 2430                           
 2431  F8FF66                    STRUCT         DCB
 2432                           _DCB    .SECTION page0,common,ref_only,offset 0 ;DCB Struct
 2433                                           ;.ABSOLUTE
 2434                                           ;.ORG   0
 2435                                   .MNLIST
 2436  000000  0000             dcb_root        .DW             ; lba of root dir
 2437  000002  0000             dcb_fat1        .DW             ; lba of fat1 table
 2438  000004  0000             dcb_fat2        .DW             ; lba of fat2 table
 2439  000006  0000             dcb_cls         .DW             ; lba of first data cluster
 2440  000008  0000             dcb_max         .DW             ; max usable cluster + 1
 2441  00000A  00               dcb_csiz        .DB             ; cluster size (1,2,4,8,16,32,64)
 2442  00000B  00               dcb_cshf        .DB             ; cluster shift (0,1,2,3,4,5,6)
 2443  00000C  00               dcb_fsiz        .DB             ; fat table size (if 0 -> 256)
 2444  00000D  00               dcb_rsiz        .DB             ; root dir size
 2445  00000E  0000             dcb_rent        .DW             ; root dir. max. entry
 2446  000010  0000             dcb_rbuf        .DW             ; root dir cache buffer#
 2447  000012  0000             dcb_fbuf        .DW             ; fat table cache buffer#
 2448  000014  0000             dcb_free        .DW             ; count of free cluster's
 2449  000016  0000             dcb_nxt         .DW             ; next free cluster
 2450  000018  00               dcb_fg1         .DB
 2451  000019  00               dcb_fg2         .DB
 2452  00001A  0000             dcb_rhtp        .DW             ; pointer to RHT hash table
 2453  00001C  0000             dcb_cdsp        .DW             ; pointer to CDS struct
 2454                           
 2455                           ;dcb_cdc                .DW             ; starting cluster of current directory
 2456                           ;dcb_cdp                .DW             ; parent cluster of c.d. (where is entry)
 2457                           ;dcb_cds                .DB             ; sec. of c.d. entry in parent cluster
 2458                           ;dcb_cdx                .DB             ; index of c.d. entry in parent cluster/sector
 2459                           ;dcb_hroot      .DW             ; hdt root pointer
 2460                           ;dcb_hcd                .DW             ; hdt cur dir pointer
 2461  00001E                    ESTRUCT        DCB
 2462  00001E                   DCBSIZE .DS     0
 2463                                           ;.RELATIVE
 2464                                           .ENDS
 2465                                   .MNLIST 
 2466                           
 2467                           ;---------------------------------------------------------------------------
 2468                           ; direct page for DCB var's 
 2469                           ;---------------------------------------------------------------------------
 2470                           
 2471                           DPDCB:  .SECTION page0, common, ref_only, offset 0      ;DCB D.P.
 2472                           
 2473  000000                   fdt_0           .DS     DCBSIZE
 2474  00001E                   fdt_1           .DS     DCBSIZE
 2475  00003C                   fdt_2           .DS     DCBSIZE
 2476  00005A                   fdt_3           .DS     DCBSIZE
 2477                           
 2478  000078  0000             xbmin           .DW     ; minimum index
 2479  00007A  0000             xbrov           .DW     ; next x-mem buffer
 2480  00007C  0000             xbcnt           .DW     ; how much x-mem buffer will allocate
 2481  00007E  0000             xbcls           .DW     ; buffer cluster
 2482  000080  0000             xbsec           .DW     ; buffer sector+device
 2483                           
 2484                           .ENDS
 2485                           
  Thu Feb 11 16:56:28 2016                                                                                               Page    7




 2486                           ;---------------------------------------------------------------------------
 2487                           ; direct page for FAT var's 
 2488                           ;---------------------------------------------------------------------------
 2489                           
 2490                           DPFAT:  .SECTION page0, common, ref_only, offset 0      ;FAT D.P.
 2491                           
 2492  000000  0000             fat_root        .DW             ; lba of root dir
 2493  000002  0000             fat_fat1        .DW             ; lba of fat1 table
 2494  000004  0000             fat_fat2        .DW             ; lba of fat2 table
 2495  000006  0000             fat_cls         .DW             ; lba of first data cluster
 2496  000008  0000             fat_max         .DW             ; max usable cluster + 1
 2497  00000A  00               fat_csiz        .DB             ; cluster size (1,2,4,8,16,32,64)
 2498  00000B  00               fat_cshf        .DB             ; cluster shift (0,1,2,3,4,5,6)
 2499  00000C  00               fat_fsiz        .DB             ; fat table size (if 0 -> 256)
 2500  00000D  00               fat_rsiz        .DB             ; root dir size
 2501  00000E  0000             fat_rbuf        .DW             ; root dir cache buffer#
 2502  000010  0000             fat_fbuf        .DW             ; fat table cache buffer#
 2503  000012  0000             fat_free        .DW             ; count of free cluster's
 2504  000014  0000             fat_nxt         .DW             ; next free cluster
 2505  000016  00               fat_fg1         .DB
 2506  000017  00               fat_fg2         .DB
 2507  000018  0000             fat_cdc         .DW             ; starting cluster of current directory
 2508  00001A  0000             fat_cdp         .DW             ; parent cluster of c.d. (where is entry)
 2509  00001C  00               fat_cds         .DB             ; sec. of c.d. entry in parent cluster
 2510  00001D  00               fat_cdx         .DB             ; index of c.d. entry in parent cluster/sector
 2511                           
 2512                           ;hdtfree                .DW             ; hdt free list
 2513                           ;hdtp           .DW             ; cur. HDT pointer
 2514                           ;hdtprev                .DW             ; prev. HDT pointer
 2515                           ;hdthip         .DW             ; the more big pointer
 2516                           ;hdthsh         .DW             ; hash calc
 2517                           ;hdtscl         .DW             ; cluster to search
 2518                           ;curcls         .DW             ; current cluster
 2519                           ;parcls         .DW             ; parent cluster
 2520                           ;filcls         .DW             ; first file cluster
 2521                           ;dsecent                .DB             ; directory sec. entry
 2522                           ;didxent                .DB             ; directory index in sec
 2523                           ;curdev         .DB             ; current logical device
 2524                           ;hdtflag                .DB             ; HDT device+fkag
 2525                           
 2526  00001E                   fcbs            .DS     32      ; current file control block
 2527                           
 2528  00003E  0000             fhash           .DW             ; hash of file name
 2529  000040  0000             hcbcls          .DW             ; cluster to search/store in HCB
 2530  000042  00               hcbdev          .DB             ; device to search/store in HCB
 2531  000043  00               hcbsec          .DB             ; sector/cls to search/store in HCB
 2532  000044  0000             hcbprnt         .DW             ; parent cluster to search/store in HCB
 2533  000046  0000             hcbrov          .DW             ; next available HCB
 2534  000048  0000             hcbp            .DW             ; search HCB pointer
 2535  00004A  0000             hcbfp           .DW             ; HCB of found entry
 2536  00004C  0000             hcbt1           .DW             ; HCB temp
 2537  00004E  0000             hcbt2           .DW             ; HCB temp
 2538  000050  0000             dhtp            .DW             ; pointer to DHT struct
 2539  000052  0000             dhtidx          .DW             ; index of match DHT
 2540  000054  0000             dhtcls          .DW             ; cluster to store in DHT ($FFFF if lfn entry)
 2541  000056  00               dhtattr         .DB             ; attribute from matching DHT
 2542  000057  00               btmp            .DB             ; temp
  Thu Feb 11 16:56:28 2016                                                                                               Page    8




 2543  000058  0000             delcls          .DW             ; deleted/empty entry cluster
 2544  00005A  00               deldev          .DB             ; deleted/empty entry device
 2545  00005B  00               delsec          .DB             ; deleted/empty entry sector
 2546  00005C  0000             delidx          .DW             ; deleted/empty entry index
 2547  00005E  0000             deldht          .DW             ; deleted/empty entry DHT 
 2548                           
 2549  000060                   dirp            LP
 2550                           
 2551                           .ENDS
 2552                           
 2553                           
 2554                           .LIST on
 2555                           
 2556                           ;---------------------------------------------------------------------------
 2557                           ; code segment -- bank $F9
 2558                           ;---------------------------------------------------------------------------
 2559                           
 2560                                   .CODEF9
 2561                           
 2562                                   .LONGA  off
 2563                                   .LONGI  off
 2564                           
 2565                           ; get a new x-mem buffer
 2566                           ; param's in register's & stack
 2567                           ; in:   A=starting sector of cluster
 2568                           ;       X=logical device
 2569                           ;       Y=number of buffer's to allocate
 2570                           ;       SR+3=cluster number (word)
 2571                           ; out:  SR+3=buffer # (word)
 2572                           ; use:  all
 2573  F905BB                   xgetbuf:
 2574                                   ;lda    hdt_next
 2575  F905BB  85 A6                    sta     xsecd           ; save lba high
 2576  F905BD  86 A7                    stx     xsecd+1         ; save logical device
 2577  F905BF  84 A2                    sty     xcnt            ; buffer's count#
 2578  F905C1  64 A3                    stz     xcnt+1
 2579  F905C3  8B                       phb                     ; save data bank
 2580  F905C4  A9 01                    lda     #^vxcls
 2581  F905C6  48                       pha
 2582  F905C7  AB                       plb                     ; set data bank to array
 2583  F905C8  A9 80                    lda     #$80
 2584  F905CA  04 A7                    tsb     xsecd+1         ; mark as in use
 2585  F905CC                           CPU16CLC
 2586  F905CC  C2 31                    rep     #(PMFLAG.OR.PXFLAG.OR.PCFLAG)
 2587                                   .LONGA  on
 2588                                   .LONGI  on
 2589                                   .MNLIST
 2590  F905CE  A3 03                    lda     $03,s
 2591  F905D0  85 A4                    sta     xcls            ; save cluster#
 2592  F905D2  A5 A0                    lda     xrov            ; current first available index
 2593  F905D4  AA                       tax
 2594  F905D5  A8                       tay
 2595  F905D6  65 A2                    adc     xcnt            ; next available index
 2596  F905D8  C9 C0 04                 cmp     #XBCNT          ; over limit?
 2597  F905DB  90 07                    bcc     ?10             ; no
 2598  F905DD  A5 9E                    lda     xmin            ; start from beginning
 2599  F905DF  AA                       tax
  Thu Feb 11 16:56:28 2016                                                                                               Page    9




 2600  F905E0  A8                       tay
 2601  F905E1  18                       clc
 2602  F905E2  65 A2                    adc     xcnt
 2603  F905E4  85 A0            ?10:    sta     xrov            ; update next available index
 2604  F905E6  8A                       txa
 2605  F905E7  0A                       asl     a
 2606  F905E8  AA                       tax                     ; array index
 2607  F905E9  98                       tya
 2608  F905EA  18                       clc
 2609  F905EB  69 40 0B                 adc     #XBSTART
 2610  F905EE  83 03                    sta     $03,s           ; return buffer#
 2611  F905F0  80 2D                    bra     xget
 2612  F905F2                           
 2613                           ; get a new reserved x-mem buffer for root dir & fat's tables
 2614                           ; this routine will be called before to allocate standard buffer's
 2615                           ; param's in register's & stack
 2616                           ; in:   A=lba high
 2617                           ;       X=logical device
 2618                           ;       SR+5=number of buffer's to allocate (word)
 2619                           ;       SR+3=lba low (word)
 2620                           ; out:  SR+5=buffer # (word)
 2621                           ; use:  all
 2622  F905F2                   xrsvbuf:
 2623  F905F2  85 A6                    sta     xsecd           ; save lba high
 2624  F905F4  86 A7                    stx     xsecd+1         ; save logical device
 2625  F905F6  8B                       phb                     ; save data bank
 2626  F905F7  A9 01 00                 lda     #^vxcls
 2627  F905FA  48                       pha
 2628  F905FB  AB                       plb                     ; set data bank to array
 2629  F905FC  A9 80 00                 lda     #$80
 2630  F905FF  04 A7                    tsb     xsecd+1         ; mark as in use
 2631  F90601                           CPU16CLC
 2632  F90601  C2 31                    rep     #(PMFLAG.OR.PXFLAG.OR.PCFLAG)
 2633                                   .LONGA  on
 2634                                   .LONGI  on
 2635                                   .MNLIST
 2636  F90603  A3 03                    lda     $03,s
 2637  F90605  85 A4                    sta     xcls            ; save starting lba
 2638  F90607  A3 05                    lda     $05,s
 2639  F90609  85 A2                    sta     xcnt
 2640  F9060B  A5 A0                    lda     xrov            ; current first available index
 2641  F9060D  AA                       tax
 2642  F9060E  A8                       tay
 2643  F9060F  65 A2                    adc     xcnt            ; next available index
 2644  F90611  85 9E                    sta     xmin            ; raise min. available index
 2645  F90613  85 A0                    sta     xrov            ; update next available index
 2646  F90615  8A                       txa
 2647  F90616  0A                       asl     a
 2648  F90617  AA                       tax                     ; array index
 2649  F90618  98                       tya
 2650  F90619  18                       clc
 2651  F9061A  69 40 0B                 adc     #XBSTART
 2652  F9061D  83 05                    sta     $05,s           ; return buffer#
 2653  F9061F                   xget:
 2654  F9061F  A5 A4                    lda     xcls
 2655  F90621  9D 00 94                 sta     !vxcls,x        ; store starting lba low
 2656  F90624  A5 A6                    lda     xsecd
  Thu Feb 11 16:56:28 2016                                                                                               Page   10




 2657  F90626  9D 80 9D                 sta     !vxsec,x        ; store lba high + logical device
 2658  F90629  A4 A2                    ldy     xcnt
 2659  F9062B  88               ?10:    dey
 2660  F9062C  F0 14                    beq     ?30
 2661  F9062E  E8                       inx
 2662  F9062F  E8                       inx
 2663  F90630  E6 A4                    inc     xcls
 2664  F90632  D0 02                    bne     ?20
 2665  F90634  E6 A6                    inc     xsecd
 2666  F90636  A5 A4            ?20:    lda     xcls
 2667  F90638  9D 00 94                 sta     !vxcls,x        ; store lba low
 2668  F9063B  A5 A6                    lda     xsecd
 2669  F9063D  9D 80 9D                 sta     !vxsec,x        ; store lba high + device
 2670  F90640  80 E9                    bra     ?10
 2671  F90642                   ?30:    CPU08
 2672  F90642  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 2673                                   .LONGA  off
 2674                                   .LONGI  off
 2675                                   .MNLIST
 2676  F90644  60                       rts
 2677                           


             Lines Assembled : 2645                  Errors : 0