From cbf99598c397af8eb2610a44ae01139df9bab286 Mon Sep 17 00:00:00 2001 From: Joshua-Riek Date: Sat, 3 Dec 2022 19:57:33 -0500 Subject: [PATCH] bugfix for larger disks --- src/boot12.asm | 10 +++++++++- src/boot16.asm | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/boot12.asm b/src/boot12.asm index 23db9f1..b2bd0ca 100644 --- a/src/boot12.asm +++ b/src/boot12.asm @@ -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 @@ -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 diff --git a/src/boot16.asm b/src/boot16.asm index c6d3e89..b11ff84 100644 --- a/src/boot16.asm +++ b/src/boot16.asm @@ -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 @@ -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