Skip to content

Commit a00a81f

Browse files
HBeluscabinarymaster
authored andcommitted
[BOOTSECT] FAT bootsectors: Use movzx in judicious places
1 parent 72bd9ef commit a00a81f

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

boot/freeldr/bootsect/fat.S

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ CalcDriveSize:
149149

150150

151151
// Now we must find our way to the first sector of the root directory
152-
xor ax, ax
153152
xor cx, cx
154-
mov al, byte ptr BP_REL(NumberOfFats) // Number of fats
153+
movzx ax, byte ptr BP_REL(NumberOfFats) // Number of fats
155154
mul word ptr BP_REL(SectorsPerFat) // Times sectors per fat
156155
add ax, word ptr BP_REL(HiddenSectors)
157156
adc dx, word ptr BP_REL(HiddenSectors+2) // Add the number of hidden sectors
@@ -271,18 +270,16 @@ ReadCluster:
271270
// StartSector = ((Cluster - 2) * SectorsPerCluster) + ReservedSectors + HiddenSectors;
272271
dec ax // Adjust start cluster by 2
273272
dec ax // Because the data area starts on cluster 2
274-
xor ch, ch
275-
mov cl, byte ptr BP_REL(SectsPerCluster)
273+
movzx cx, byte ptr BP_REL(SectsPerCluster)
276274
mul cx // Times sectors per cluster
277275
add ax, [bp-DataAreaStartLow] // Add start of data area
278276
adc dx, [bp-DataAreaStartHigh] // Now we have DX:AX with the logical start sector of FREELDR.SYS
279277
xor bx, bx // We will load it to [ES:0000], ES loaded before function call
280-
// mov cl,BYTE [BYTE bp+SectsPerCluster]// Sectors per cluster still in CX
278+
// movzx cx, byte ptr BP_REL(SectsPerCluster) // Sectors per cluster still in CX
281279
// call ReadSectors
282280
// ret
283281

284282

285-
286283
// Reads logical sectors into [ES:BX]
287284
// DX:AX has logical sector number to read
288285
// CX has number of sectors to read

boot/freeldr/bootsect/fat32.S

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ ContinueSearch:
341341

342342
// Now we have to find our way through the root directory to
343343
// The FREELDR.SYS file
344-
xor bx,bx
345-
mov bl, byte ptr BP_REL(SectsPerCluster)
344+
movzx bx, byte ptr BP_REL(SectsPerCluster)
346345
shl bx, 4 // BX = BX * 512 / 32
347346
mov ax, HEX(2000) // We loaded at 2000:0000
348347
mov es, ax
@@ -406,8 +405,7 @@ LoadFile:
406405
call ReadCluster
407406
pop es
408407

409-
xor bx, bx
410-
mov bl, byte ptr BP_REL(SectsPerCluster)
408+
movzx bx, byte ptr BP_REL(SectsPerCluster)
411409
shl bx, 5 // BX = BX * 512 / 16
412410
mov ax, es // Increment the load address by
413411
add ax, bx // The size of a cluster
@@ -495,7 +493,6 @@ FatSectorInCache: // This variable tells us which
495493
// Reads cluster number in EAX into [ES:0000]
496494
ReadCluster:
497495
// StartSector = ((Cluster - 2) * SectorsPerCluster) + ReservedSectors + HiddenSectors;
498-
499496
dec eax
500497
dec eax
501498
xor edx, edx

boot/freeldr/bootsect/pc98/fat12fdd.S

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,8 @@ VideoTestDone:
161161
*
162162
* LBA = NumberOfFats * SectorsPerFat + HiddenSectors + ReservedSectors
163163
*/
164-
xor ax, ax
165164
xor cx, cx
166-
mov al, byte ptr BP_REL(NumberOfFats) // Number of fats
165+
movzx ax, byte ptr BP_REL(NumberOfFats) // Number of fats
167166
mul word ptr BP_REL(SectorsPerFat) // Times sectors per fat
168167
add ax, word ptr BP_REL(HiddenSectors)
169168
adc dx, word ptr BP_REL(HiddenSectors + 2) // Add the number of hidden sectors
@@ -272,8 +271,7 @@ ReadCluster:
272271
*/
273272
dec ax // Adjust start cluster by 2
274273
dec ax // Because the data area starts on cluster 2
275-
xor ch, ch
276-
mov cl, byte ptr BP_REL(SectsPerCluster)
274+
movzx cx, byte ptr BP_REL(SectsPerCluster)
277275
mul cx // Times sectors per cluster
278276
add ax, [bp - DataAreaStartLow] // Add start of data area
279277
adc dx, [bp - DataAreaStartHigh] // Now we have DX:AX with the logical start sector of FREELDR.SYS

0 commit comments

Comments
 (0)