Skip to content

Commit

Permalink
bugfix for larger disks
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Riek committed Dec 4, 2022
1 parent 2cb1f71 commit cbf9959
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/boot12.asm
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@ readClusters:
mul bx
xchg cx, ax

push cx
mov cl, 4
shl dx, cl
mov bx, es
add bh, dl
mov es, bx
pop cx

clc
add di, cx ; Add to the pointer offset
jnc .clusterLoop
Expand Down Expand Up @@ -456,7 +464,7 @@ error:
; Bootloader varables below
;---------------------------------------------------

errorMsg db "Disk/File error", 0 ; Error reading disk or file was not found
errorMsg db "Error!", 0 ; Error reading disk or file was not found

userData dw 0 ; Start of the data sectors
drive db 0 ; Boot drive number
Expand Down
16 changes: 12 additions & 4 deletions src/boot16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,20 @@ readClusters:

xchg cx, ax
xor dx, dx
xor bh, bh ; Bytes per cluster = (bytes per sector * sectors per cluster)
mov ax, word [bytesPerSector]
mov bl, byte [sectorsPerCluster]
xor bh, bh ; Calculate the size in bytes per cluster
mov ax, word [bytesPerSector] ; So, take the bytes per sector
mov bl, byte [sectorsPerCluster] ; and mul that by the sectors per cluster
mul bx
xchg cx, ax

push cx
mov cl, 4
shl dx, cl
mov bx, es
add bh, dl
mov es, bx
pop cx

clc
add di, cx ; Add to the pointer offset
jnc .clusterLoop
Expand Down Expand Up @@ -452,7 +460,7 @@ error:
; Bootloader varables below
;---------------------------------------------------

errorMsg db "Disk/File error", 0 ; Error reading disk or file was not found
errorMsg db "Error!", 0 ; Error reading disk or file was not found

userData dw 0 ; Start of the data sectors
drive db 0 ; Boot drive number
Expand Down

0 comments on commit cbf9959

Please sign in to comment.