5959// F AT table so th at we can still load freeldr.sys
6060// even if it is fragmented.
6161
62-
6362FatHelperEntryPoint:
6463 / * First save AX - the start cluster of freeldr.sys * /
6564 push ax
@@ -75,7 +74,7 @@ FatHelperEntryPoint:
7574
7675 // AX has start cluster of freeldr.sys
7776 mov bx , FREELDR_BASE / 16
78- mov es , bx
77+ mov es , bx
7978
8079LoadFile:
8180 push ax
@@ -90,17 +89,17 @@ LoadFile2:
9089LoadFile3:
9190 jae LoadFile_Done // If so continue , if not then read then next one
9291 push ax
93- xor bx , bx // Load ROSLDR starting at 0000 : 8000h
92+ xor bx , bx // Load ROSLDR starting at 0000 : F800h
9493 push es
9594 call word ptr [ bp - ReadClusterOffset ]
9695 pop es
9796
98- xor bx , bx
97+ xor bx , bx
9998 mov bl , [ bp + SectsPerCluster ]
100- shl bx , 5 // BX = BX * 512 / 16
101- mov ax , es // Increment the load address by
102- add ax , bx // The size of a cluster
103- mov es , ax
99+ shl bx , 5 // BX = BX * 512 / 16
100+ mov ax , es // Increment the load address by
101+ add ax , bx // The size of a cluster
102+ mov es , ax
104103
105104 call IsFat12
106105 pop ax
@@ -119,7 +118,7 @@ LoadFile_Done:
119118 mov dl , byte ptr [ bp + BootDrive ] // Load the boot drive into DL
120119 mov dh , byte ptr ds : [ BootPartition ] // Load the boot partition into DH
121120
122- / * continue where other bootsectors start * /
121+ / * Continue where other bootsectors start * /
123122 jmp start
124123
125124
@@ -158,20 +157,20 @@ GetFatEntry16:
158157// On entry AX has cluster number
159158// On return AX has F AT entry for th at cluster
160159GetFatEntry12:
161- push ax
162- mov cx , ax
163- shr ax , 1
164- add ax , cx // AX = AX * 1 . 5 ( AX = AX + ( AX / 2 )) ( since FAT12 entries are 12 bits)
160+ push ax // Save original cluster number
161+ mov cx , ax
162+ shr ax , 1
163+ add ax , cx // AX = AX * 1 . 5 ( AX = AX + ( AX / 2 )) , since FAT12 entries are 12 bits
165164
166165 mov bx , HEX( 7000 )
167166 mov es , bx
168167 mov bx , ax // Put F AT entry offset into BX
169168 mov ax , es : [ bx ] // Get F AT entry
170169 pop cx // Get cluster number from stack
171- and cx , 1
170+ and cx , 1
172171 jz UseLow12Bits
173172 and ax , HEX(0fff0)
174- shr ax , 4
173+ shr ax , 4
175174 jmp GetFatEntry12_Done
176175
177176UseLow12Bits:
@@ -185,13 +184,11 @@ GetFatEntry12_Done:
185184// Returns CF = 1 if this is a FAT12 file system
186185// Otherwise CF = 0 for FAT16
187186IsFat12:
188-
189187 mov ebx , dword ptr [ bp - DataAreaStartLow ]
190188 // EBX now has the number of the starting sector of the data area
191- // starting from the beginning of the disk , so subtrace hidden sectors
189+ // starting from the beginning of the disk , so subtract hidden sectors
192190 sub ebx , dword ptr [ bp + HiddenSectors ]
193191
194-
195192 xor eax , eax
196193 mov ax , word ptr [ bp + TotalSectors ]
197194 cmp ax , 0
@@ -201,15 +198,15 @@ IsFat12:
201198 // EAX now contains the number of sectors on the volume
202199
203200IsFat12_2:
204- sub eax , ebx // Subtract data area start sector
205- xor edx , edx // from total sectors of volume
201+ sub eax , ebx // Subtract data area start sector
202+ xor edx , edx // from total sectors of volume
206203
207204 // EDX : EAX now contains the number of data sectors on the volume
208205 movzx ebx , byte ptr [ bp + SectsPerCluster ]
209206 div ebx
210207 // EAX now has the number of clusters on the volume
211208 stc
212- cmp eax , 4085
209+ cmp eax , 4085
213210 jb IsFat12_Done
214211 clc
215212
@@ -222,4 +219,3 @@ msgLoading:
222219
223220 .org 510 // Pad to 510 bytes
224221 . word HEX(0aa55) // BootSector signature
225-
0 commit comments