wok-6.x diff BootProg/stuff/boot16.asm @ rev 25453

BootProg/boot16.asm: too small fat16 support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Sep 17 08:17:46 2022 +0000 (21 months ago)
parents e3609bca2577
children 78727b04c002
line diff
     1.1 --- a/BootProg/stuff/boot16.asm	Thu Sep 15 10:06:54 2022 +0000
     1.2 +++ b/BootProg/stuff/boot16.asm	Sat Sep 17 08:17:46 2022 +0000
     1.3 @@ -306,28 +306,24 @@
     1.4  
     1.5  FAT12   	equ       1
     1.6  FAT16   	equ       1
     1.7 -        push    di                      ; up to 2 * 635K / BytesPerCluster bytes
     1.8 +        push    di                      ; up to 2 * 635K / BytesPerCluster = 2540 bytes
     1.9  %if FAT12 == 1
    1.10 -        mov     cl, 12
    1.11 +        mov     cl, 4
    1.12  %endif
    1.13  ClusterLoop:
    1.14          mov     [di], si
    1.15 -
    1.16          add     si, si                  ; si = cluster * 2
    1.17  %if FAT16 == 1
    1.18          mov     ax, es                  ; ax = FAT segment = ImageLoadSeg
    1.19          jnc     First64k
    1.20          mov     ah, (1000h+ImageLoadSeg)>>8 ; adjust segment for 2nd part of FAT16
    1.21  First64k:
    1.22 + %if FAT12 == 1
    1.23          mov     dx, 0FFF8h
    1.24 -%else
    1.25 -        mov     dx, 0FF8h
    1.26 -%endif
    1.27 -
    1.28 -%if FAT12 == 1 && FAT16 == 1
    1.29 -        cmp     [bx(bpbSectorsPerFAT)], cx ; 1..12 = FAT12, 16..256 = FAT16
    1.30 -        ja      ReadClusterFat16
    1.31 +        test    [bx(bsFileSystem+4)], cl ; FAT12 or FAT16 ? clear C
    1.32 +        jne     ReadClusterFat16
    1.33          mov     dh, 0Fh
    1.34 + %endif
    1.35  %endif
    1.36  %if FAT12 == 1
    1.37          add     si, [di]
    1.38 @@ -340,16 +336,25 @@
    1.39          lodsw                           ; ax = next cluster
    1.40          pop     ds
    1.41  %else
    1.42 -        lodsw                           ; ax = next cluster
    1.43 +        es lodsw
    1.44  %endif
    1.45  %if FAT12 == 1
    1.46          jnc     ReadClusterEven
    1.47 -        rol     ax, cl
    1.48 +        shr     ax, cl
    1.49  ReadClusterEven:
    1.50  %endif
    1.51          scasw                           ; di += 2
    1.52 +%if FAT12 == 1 && FAT16 == 1
    1.53          and     ah, dh                  ; mask cluster value
    1.54          cmp     ax, dx
    1.55 +%else
    1.56 + %if FAT12 == 1
    1.57 +        and     ah, 0Fh                 ; mask cluster value
    1.58 +        cmp     ax, 0FF8h
    1.59 + %else
    1.60 +        cmp     ax, 0FFF8h
    1.61 + %endif
    1.62 +%endif
    1.63  
    1.64          xchg    ax, si
    1.65          jc      ClusterLoop