From f152732d04c19149d1449e242edd2dc1b7d08cb0 Mon Sep 17 00:00:00 2001 From: Brian Palmer Date: Wed, 21 May 2003 20:28:13 +0000 Subject: [PATCH] Lot's of fixes for the FAT12/16 boot sector code. svn path=/trunk/; revision=4737 --- freeldr/bootsect/fat.asm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/freeldr/bootsect/fat.asm b/freeldr/bootsect/fat.asm index 389de0576a1..16196230c56 100644 --- a/freeldr/bootsect/fat.asm +++ b/freeldr/bootsect/fat.asm @@ -144,6 +144,7 @@ CalcDriveSize: ; DX:AX now has the number of the starting sector of the root directory ; Now calculate the size of the root directory + xor dx,dx mov ax,0020h ; Size of dir entry mul si ; Times the number of entries mov bx,[BYTE bp+BytesPerSector] @@ -257,7 +258,7 @@ ReadCluster: add ax,[BYTE bp-DataAreaStartLow] ; Add start of data area adc dx,[BYTE bp-DataAreaStartHigh] ; Now we have DX:AX with the logical start sector of OSLOADER.SYS xor bx,bx ; We will load it to [ES:0000], ES loaded before function call - mov cl,BYTE [BYTE bp+SectsPerCluster] + ;mov cl,BYTE [BYTE bp+SectsPerCluster]; Sectors per cluster still in CX ;call ReadSectors ;ret @@ -277,12 +278,14 @@ ReadSectors: adc dx,byte 0 cmp dx,WORD [BYTE bp-BiosCHSDriveSizeHigh] ; Check if they are reading a sector within CHS range - jb ReadSectorsCHS ; Yes - go to the old CHS routine + ja ReadSectorsLBA ; No - go to the LBA routine + jb ReadSectorsCHS ; Yes - go to the old CHS routine cmp ax,WORD [BYTE bp-BiosCHSDriveSizeLow] ; Check if they are reading a sector within CHS range jbe ReadSectorsCHS ; Yes - go to the old CHS routine ReadSectorsLBA: popa +ReadSectorsLBALoop: pusha ; Save logical sector number & sector count o32 push byte 0 @@ -323,11 +326,13 @@ ReadSectorsLBA: inc ax ; Increment Sector to Read adc dx,byte 0 - mov dx,es - add dx,byte 20h ; Increment read buffer for next sector - mov es,dx + push bx + mov bx,es + add bx,byte 20h ; Increment read buffer for next sector + mov es,bx + pop bx - loop ReadSectorsLBA ; Read next sector + loop ReadSectorsLBALoop ; Read next sector ret