Skip to content

Commit cbf9959

Browse files
committed
bugfix for larger disks
1 parent 2cb1f71 commit cbf9959

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/boot12.asm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ readClusters:
296296
mul bx
297297
xchg cx, ax
298298

299+
push cx
300+
mov cl, 4
301+
shl dx, cl
302+
mov bx, es
303+
add bh, dl
304+
mov es, bx
305+
pop cx
306+
299307
clc
300308
add di, cx ; Add to the pointer offset
301309
jnc .clusterLoop
@@ -456,7 +464,7 @@ error:
456464
; Bootloader varables below
457465
;---------------------------------------------------
458466

459-
errorMsg db "Disk/File error", 0 ; Error reading disk or file was not found
467+
errorMsg db "Error!", 0 ; Error reading disk or file was not found
460468

461469
userData dw 0 ; Start of the data sectors
462470
drive db 0 ; Boot drive number

src/boot16.asm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,20 @@ readClusters:
287287

288288
xchg cx, ax
289289
xor dx, dx
290-
xor bh, bh ; Bytes per cluster = (bytes per sector * sectors per cluster)
291-
mov ax, word [bytesPerSector]
292-
mov bl, byte [sectorsPerCluster]
290+
xor bh, bh ; Calculate the size in bytes per cluster
291+
mov ax, word [bytesPerSector] ; So, take the bytes per sector
292+
mov bl, byte [sectorsPerCluster] ; and mul that by the sectors per cluster
293293
mul bx
294294
xchg cx, ax
295295

296+
push cx
297+
mov cl, 4
298+
shl dx, cl
299+
mov bx, es
300+
add bh, dl
301+
mov es, bx
302+
pop cx
303+
296304
clc
297305
add di, cx ; Add to the pointer offset
298306
jnc .clusterLoop
@@ -452,7 +460,7 @@ error:
452460
; Bootloader varables below
453461
;---------------------------------------------------
454462

455-
errorMsg db "Disk/File error", 0 ; Error reading disk or file was not found
463+
errorMsg db "Error!", 0 ; Error reading disk or file was not found
456464

457465
userData dw 0 ; Start of the data sectors
458466
drive db 0 ; Boot drive number

0 commit comments

Comments
 (0)