# HG changeset patch # User Pascal Bellard # Date 1683984881 0 # Node ID 82f370bad6b50eaa1086ded0f53ea86c108dc1c7 # Parent c45b858c787a6a74d83640210847b39b887e3a40 BootProg: fix boot16.asm (again) diff -r c45b858c787a -r 82f370bad6b5 BootProg/stuff/boot16.asm --- a/BootProg/stuff/boot16.asm Sat May 13 11:12:29 2023 +0100 +++ b/BootProg/stuff/boot16.asm Sat May 13 13:34:41 2023 +0000 @@ -23,7 +23,7 @@ ;; and waits for a key to be pressed, then executes the Int 19h ;; ;; instruction and lets the BIOS continue bootstrap. ;; ;; ;; -;; - cpu 8086 is supported ;; +;; - cpu 8088 is supported ;; ;; ;; ;; ;; ;; Known Limitation: ;; @@ -31,7 +31,7 @@ ;; - Need a up to date field bpbHiddenSectors to work in a partition ; ;; ;; most formatters don't update it correcly in extended partitions. ;; ;; ;; -;; - Partition must fit in the first 8GB disk of the for CHS reads. ;; +;; - Partition must fit in the first 8GB of the disk for CHS reads. ;; ;; (or 2TB for LBA reads). ;; ;; ;; ;; ;; @@ -96,7 +96,7 @@ NullEntryCheck equ 1 ; +2 bytes ReadRetry equ 1 ; +9/+13 bytes LBAsupport equ 1 ; +18 bytes -CHSsanityCheck equ 1 ; +12/+16 bytes +CHSsanityCheck equ 1 ; +10/+14 bytes GeometryCheck equ 1 ; +20 bytes CheckAttrib equ 0 ; +6 bytes WaitForKey equ 0 ; +5 bytes @@ -342,6 +342,9 @@ FAT16 equ 1 TINYFAT16 equ 1 ; < 4072 clusters fat16 support push di ; up to 2 * 635K / BytesPerCluster = 2540 bytes +%if FAT12 != 1 && FAT16 != 1 + %error "FAT12 and/or FAT16 must be set" +%endif %if FAT12 == 1 mov cl, 12 %else @@ -598,7 +601,6 @@ dec bx push di %endif - mov si, sp xchg ax, cx ; save low LBA xchg ax, dx ; get high LBA @@ -606,10 +608,8 @@ idiv word [bx(bpbSectorsPerTrack)] ; up to 8GB disks %if CHSsanityCheck != 0 - inc ax cmp ax, [bx(bpbHeadsPerCylinder)] - ja CHSoverflow - dec ax + jnc CHSoverflow %endif xchg ax, cx ; restore low LBA, save high LBA / SPT idiv word [bx(bpbSectorsPerTrack)] @@ -632,13 +632,10 @@ ; dh = head no. %if CHSsanityCheck != 0 - %if LBAsupport != 0 - or ah, [si+8+3] ; 8GB max, last cylinder 1023 - %else - or ah, [si+2+3] ; 8GB max, last cylinder 1023 - %endif + sub ah, 1 ; set C if cylinder < 1024 (8GB max) +CHSoverflow: %endif -CHSoverflow: + mov si, sp %if CHSsanityCheck != 0 && (ReadRetry != 0 || LBAsupport != 0) pushf %endif @@ -651,24 +648,21 @@ int 13h ; extended read sectors (DL, DS:SI) jnc ReadSectorNextSegment %endif + mov ax, 201h ; al = sector count = 1 + ; ah = 2 = read function no. %if CHSsanityCheck != 0 %if ReadRetry != 0 || LBAsupport != 0 popf pushf %endif - jne SkipCHS + jnc SkipCHS %endif - - mov ax, 201h ; al = sector count = 1 - ; ah = 2 = read function no. int 13h ; read sectors (AL, CX, DX, ES:BX) - jnc ReadSectorNextSegment SkipCHS: %if ReadRetry != 0 cbw ; ah = 0 = reset function int 13h ; reset drive (DL) - dec di jnz ReadSectorRetry ; up to 15 extra attempt %endif diff -r c45b858c787a -r 82f370bad6b5 BootProg/stuff/boot32.asm --- a/BootProg/stuff/boot32.asm Sat May 13 11:12:29 2023 +0100 +++ b/BootProg/stuff/boot32.asm Sat May 13 13:34:41 2023 +0000 @@ -90,7 +90,7 @@ ExtraBootSector equ 1 ClusterMask equ 1 ; +9 bytes NullEntryCheck equ 1 ; +5 bytes -CheckAttrib equ 1 ; +6 bytes +CheckAttrib equ 0 ; +6 bytes NonMirroredFATs equ 1 ; +20 bytes ReadRetry equ 1 ; +6/7 bytes LBA48bits equ 1 ; +10 bytes @@ -601,12 +601,12 @@ jnc ReadSuccess ; CF = 0 if no error %if CHSsupport != 0 + mov ax, 201h ; al = sector count = 1 + ; ah = 2 = read function no. %if CHSsanityCheck != 0 cmp eax, 0FFFFh ; max cylinder = 1023 ja SkipCHS %endif - mov ax, 201h ; al = sector count = 1 - ; ah = 2 = read function no. int 13h ; read sectors (AL, CX, DX, ES:BX) jnc ReadSuccess ; CF = 0 if no error