wok diff BootProg/stuff/boot16.asm @ rev 25458

Update some web_site
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Sep 27 16:21:52 2022 +0000 (21 months ago)
parents ad0bc3efbf37
children 81fc994927a6
line diff
     1.1 --- a/BootProg/stuff/boot16.asm	Fri Sep 23 08:28:09 2022 +0000
     1.2 +++ b/BootProg/stuff/boot16.asm	Tue Sep 27 16:21:52 2022 +0000
     1.3 @@ -84,11 +84,12 @@
     1.4  
     1.5  %define bx(label)       bx+label-boot
     1.6  %define si(label)       si+label-boot
     1.7 -NullEntryCheck          equ     1               ; +3 bytes
     1.8 +NullEntryCheck          equ     1               ; +2 bytes
     1.9  ReadRetry               equ     1               ; +9 bytes
    1.10  LBAsupport              equ     1               ; +16 bytes
    1.11  Over2GB                 equ     1               ; +5 bytes
    1.12  GeometryCheck           equ     1               ; +18 bytes
    1.13 +SectorOf512Bytes        equ     1               ; -4/-6 bytes
    1.14  
    1.15  [BITS 16]
    1.16  [CPU 8086]
    1.17 @@ -134,8 +135,8 @@
    1.18  bsUnused                DB      0               ; 0x25
    1.19  bsExtBootSignature      DB      0               ; 0x26
    1.20  bsSerialNumber          DD      0               ; 0x27
    1.21 -bsVolumeLabel           DB      "NO NAME    "   ; 0x2B
    1.22 -bsFileSystem            DB      "FAT12   "      ; 0x36
    1.23 +bsVolumeLabel  times 11 DB      " "             ; 0x2B "NO NAME    "
    1.24 +bsFileSystem   times 8  DB      " "             ; 0x36 "FAT12   " or "FAT16   "
    1.25  
    1.26  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.27  ;; Boot sector code starts here ;;
    1.28 @@ -223,26 +224,32 @@
    1.29          push    es
    1.30  
    1.31          mul     bx                      ; dx:ax = 0 = LBA (LBA are relative to FAT)
    1.32 -        mov     cx, word [bx(bpbSectorsPerFAT)]
    1.33 +        mov     di, word [bx(bpbSectorsPerFAT)]
    1.34  
    1.35 -        call    ReadCXSectors           ; read fat and clear ax & cx; bp = SectorsPerFAT
    1.36 +        call    ReadDISectors           ; read fat; clear ax, cx, di; bp = SectorsPerFAT
    1.37  
    1.38  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.39  ;; load the root directory in ;;
    1.40  ;; its entirety (16KB max)    ;;
    1.41  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.42  
    1.43 +%if SectorOf512Bytes != 0
    1.44 +        mov     di, word [bx(bpbRootEntries)]
    1.45 +        mov     cl, 4
    1.46 +        shr     di, cl                  ; di = root directory size in sectors
    1.47 +%else
    1.48          mov     al, 32
    1.49  
    1.50          mul     word [bx(bpbRootEntries)]
    1.51          div     word [bx(bpbBytesPerSector)]
    1.52 -        xchg    ax, cx                  ; cx = root directory size in sectors, clear ax
    1.53 +        xchg    ax, di                  ; di = root directory size in sectors, clear ah
    1.54 +%endif
    1.55  
    1.56          mov     al, [bpbNumberOfFATs]
    1.57 -        mul     bp                      ; [bx(bpbSectorsPerFAT)], set by ReadCXSectors
    1.58 +        mul     bp                      ; [bx(bpbSectorsPerFAT)], set by ReadDISectors
    1.59  
    1.60          push    es                      ; read root directory
    1.61 -        call    ReadCXSectors           ; clear ax, cx & di; bp = first data sector
    1.62 +        call    ReadDISectors           ; clear ax, cx, di; bp = first data sector
    1.63          pop     es
    1.64  
    1.65  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.66 @@ -267,14 +274,16 @@
    1.67          pop     di
    1.68          je      FindNameFound
    1.69  %if NullEntryCheck != 0
    1.70 -        scasb
    1.71 -        je      FindNameFailed          ; end of root directory (NULL entry found)
    1.72 -        add     di, byte 31
    1.73 +        scasb				; Z == NC
    1.74 +        cmc
    1.75 +        lea     di, [di+31]
    1.76 +        dec     word [bx(bpbRootEntries)]
    1.77 +        ja      FindNameCycle           ; next root entry
    1.78  %else
    1.79          add     di, byte 32
    1.80 -%endif
    1.81          dec     word [bx(bpbRootEntries)]
    1.82          jnz     FindNameCycle           ; next root entry
    1.83 +%endif
    1.84  
    1.85  FindNameFailed:
    1.86          call    Error
    1.87 @@ -304,9 +313,9 @@
    1.88  ;;         CH = 0             ;;
    1.89  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    1.90  
    1.91 -FAT12   	equ       1
    1.92 -FAT16   	equ       1
    1.93 -TINYFAT16   	equ       1
    1.94 +FAT12          equ       1
    1.95 +FAT16          equ       1
    1.96 +TINYFAT16      equ       1
    1.97          push    di                      ; up to 2 * 635K / BytesPerCluster = 2540 bytes
    1.98  %if FAT12 == 1
    1.99          mov     cl, 12
   1.100 @@ -323,10 +332,11 @@
   1.101          mov     dx, 0FFF6h
   1.102    %if TINYFAT16 == 1
   1.103          test    [bx(bsFileSystem+4)], cl ; FAT12 or FAT16 ? clear C
   1.104 +        jne     ReadClusterFat16
   1.105    %else
   1.106          cmp     [bx(bpbSectorsPerFAT)], cx ; 1..12 = FAT12, 16..256 = FAT16
   1.107 +        ja      ReadClusterFat16
   1.108    %endif
   1.109 -        jne     ReadClusterFat16
   1.110          mov     dh, 0Fh
   1.111   %endif
   1.112  %endif
   1.113 @@ -388,9 +398,9 @@
   1.114          add     ax, bp                  ; LBA for cluster data
   1.115          adc     dx, bx                  ; dx:ax = LBA
   1.116  
   1.117 -        call    ReadSector              ; clear ax, restore dx
   1.118 +        call    ReadSectors             ; clear ax, restore dx
   1.119  
   1.120 -        jne     ReadClusters
   1.121 +        jne     ReadClusters            ; until end of file
   1.122  
   1.123          pop     bp                      ; ImageLoadSeg
   1.124  
   1.125 @@ -470,14 +480,52 @@
   1.126  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.127          retf
   1.128  
   1.129 -ReadCXSectors:
   1.130 -        mov     bp, cx
   1.131 +;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.132 +;; Error Messaging Code ;;
   1.133 +;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.134 +
   1.135 +Error:
   1.136 +        pop     si
   1.137 +
   1.138 +PutStr:
   1.139 +        mov     ah, 0Eh
   1.140 +        mov     bl, 7
   1.141 +        lodsb
   1.142 +        int     10h
   1.143 +        cmp     al, "."
   1.144 +        jne     PutStr
   1.145 +
   1.146 +        cbw
   1.147 +        int     16h                     ; wait for a key...
   1.148 +        int     19h                     ; bootstrap
   1.149 +
   1.150 +Stop:
   1.151 +        hlt
   1.152 +        jmp     short Stop
   1.153 +
   1.154 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.155 +;; Read sectors using BIOS Int 13h     ;;
   1.156 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.157 +;; Input:  DX:AX = LBA relative to FAT ;;
   1.158 +;;         BX    = 0                   ;;
   1.159 +;;         DI    = sector count        ;;
   1.160 +;;         ES:BX -> buffer address     ;;
   1.161 +;; Output: ES:BX -> next address       ;;
   1.162 +;;         BX    = 0                   ;;
   1.163 +;;         CX    = 0                   ;;
   1.164 +;;         DI    = 0                   ;;
   1.165 +;;         DL    = drive number        ;;
   1.166 +;;         DX:BP = next LBA from FAT   ;;
   1.167 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.168 +
   1.169 +ReadDISectors:
   1.170 +        mov     bp, di
   1.171          add     bp, ax                  ; adjust LBA for cluster data
   1.172  
   1.173 -        mov     di, cx                  ; no file size limit
   1.174 +        mov     cx, di                  ; no cluster size limit
   1.175  
   1.176  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.177 -;; Reads sectors using BIOS Int 13h    ;;
   1.178 +;; Read sectors using BIOS Int 13h     ;;
   1.179  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.180  ;; Input:  DX:AX = LBA relative to FAT ;;
   1.181  ;;         BX    = 0                   ;;
   1.182 @@ -490,7 +538,7 @@
   1.183  ;;         DL    = drive number        ;;
   1.184  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.185  
   1.186 -ReadSector:
   1.187 +ReadSectors:
   1.188          add     ax, [bx(bpbHiddenSectors)]
   1.189          adc     dx, [bx(bpbHiddenSectors)+2]
   1.190          add     ax, [bx(bpbReservedSectors)]
   1.191 @@ -538,10 +586,11 @@
   1.192          idiv    word [bx(bpbHeadsPerCylinder)]
   1.193                  ; ax = (LBA / SPT) / HPC = cylinder
   1.194                  ; dx = (LBA / SPT) % HPC = head
   1.195 -        mov     ch, al
   1.196 +
   1.197 +        xchg    ch, al                  ; clear al
   1.198                  ; ch = LSB 0...7 of cylinder no.
   1.199 -        mov     al, 64
   1.200 -        mul     ah
   1.201 +        shr     ax, 1
   1.202 +        shr     ax, 1
   1.203          or      cl, al
   1.204                  ; cl = MSB 8...9 of cylinder no. + sector no.
   1.205          mov     dh, dl
   1.206 @@ -577,14 +626,22 @@
   1.207  
   1.208  %if LBAsupport != 0
   1.209          pop     ax                      ; al = 16
   1.210 + %if SectorOf512Bytes != 0
   1.211 +        add     word [si+6], byte 32    ; adjust segment for next sector
   1.212 + %else
   1.213          mul     byte [bx(bpbBytesPerSector)+1] ;  = (bpbBytesPerSector/256)*16
   1.214 +        add     [si+6], ax              ; adjust segment for next sector
   1.215 + %endif
   1.216          pop     cx                      ; sector count = 1
   1.217          pop     bx
   1.218 -        add     [si+6], ax              ; adjust segment for next sector
   1.219  %else
   1.220 + %if SectorOf512Bytes != 0
   1.221 +        add     word [si], byte 32      ; adjust segment for next sector
   1.222 + %else
   1.223          mov     al, 16
   1.224          mul     byte [bx(bpbBytesPerSector)+1] ;  = (bpbBytesPerSector/256)*16
   1.225          add     [si], ax                ; adjust segment for next sector
   1.226 + %endif
   1.227  %endif
   1.228          pop     es                      ; es:0 updated
   1.229          pop     ax
   1.230 @@ -611,30 +668,7 @@
   1.231  ;; Fill free space with zeroes ;;
   1.232  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.233  
   1.234 -                times (512-13-20-($-$$)) db 0
   1.235 -
   1.236 -;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.237 -;; Error Messaging Code ;;
   1.238 -;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.239 -
   1.240 -Error:
   1.241 -        pop     si
   1.242 -
   1.243 -PutStr:
   1.244 -        mov     ah, 0Eh
   1.245 -        mov     bl, 7
   1.246 -        lodsb
   1.247 -        int     10h
   1.248 -        cmp     al, "."
   1.249 -        jne     PutStr
   1.250 -
   1.251 -        cbw
   1.252 -        int     16h                     ; wait for a key...
   1.253 -        int     19h                     ; bootstrap
   1.254 -
   1.255 -Stop:
   1.256 -        hlt
   1.257 -        jmp     short Stop
   1.258 +                times (512-13-($-$$)) db 0
   1.259  
   1.260  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   1.261  ;; Name of the file to load and run ;;