From 8d67cdf201c6c1ce4f6a2528e4c591a07faad1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 4 Jul 2021 18:52:11 +0300 Subject: [PATCH] Always do disk reads one sector at a time PCem emulating IBM PC 5150 seems to have a bug where int 0x13/2 will report it read zero sectors regardless of how many sectors it actually read. --- bootsect.asm | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/bootsect.asm b/bootsect.asm index 6847bd6..146d86b 100644 --- a/bootsect.asm +++ b/bootsect.asm @@ -282,35 +282,21 @@ loadsectors: and al, 0xC0 or cl, al - ; Copy number of sectors to still read to ax and cap at 127 - pop ax - push ax - cmp al, 127 - jbe .read - mov al, 127 + mov ah, 2 + mov al, 1 + mov dl, [drivenumber] + int 0x13 + ; TODO: Handle reset & retry + jnc .noerror + .noerror: - .read: - mov ah, 2 - mov dl, [drivenumber] - int 0x13 - - ; Decrement cx by the number of sectors read pop cx - xor ah, ah - sub cx, ax + pop ax - ; Increment bx by the number of sectors read times 512 - xor dx, dx - mov dh, al - shl dx, 1 - add bx, dx + inc ax + add bx, 512 - ; Increment ax by the number of sectors read - pop dx - add ax, dx - - test cx, cx - jnz .loop + loop .loop pop dx pop cx