From fdbe157c18008904b0aa696da8dab3f1db4a8691 Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Fri, 10 Oct 2025 19:05:23 +0200 Subject: [PATCH] Fix CHS sector-by-sector read loop --- boot/bootsect/espboot.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/boot/bootsect/espboot.S b/boot/bootsect/espboot.S index 83e86df..0b09b19 100644 --- a/boot/bootsect/espboot.S +++ b/boot/bootsect/espboot.S @@ -121,7 +121,7 @@ VerifyBiosParameterBlock: ja FsError ReadExtraCode: - /* Read second VBR sector with extra boot code */ + /* Read second VBR sector with extra boot code (1 sector starting from sector 2) */ movl HiddenSectors - Start(%bp), %eax addl $0x02, %eax movw $0x01, %cx @@ -151,6 +151,10 @@ ReadSectors: ReadCHS: /* Read sectors using CHS */ + popal + +CHSLoop: + /* Read sector by sector using CHS */ pushw %cx pushal xorl %edx, %edx @@ -176,7 +180,7 @@ ReadCHS: movw %es, %dx addw $0x20, %dx movw %dx, %es - loop ReadCHS + loop CHSLoop popw %es ret