From b6177096849df9f62c76da16725c7d01c25c46b6 Mon Sep 17 00:00:00 2001 From: Nero <41307858+nero@users.noreply.github.com> Date: Fri, 19 Mar 2021 19:26:38 +0000 Subject: [PATCH] Fix rootdir.asm re-using potentially wrong DS --- kernel/fcb.asm | 2 ++ kernel/rootdir.asm | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/fcb.asm b/kernel/fcb.asm index a2625a9..e6764ae 100644 --- a/kernel/fcb.asm +++ b/kernel/fcb.asm @@ -33,6 +33,8 @@ fcbdrv push ds inc dl mov [si], dl ; 1-based .log dec dl + mov ax, cs + mov ds, ax call logdrv ; 0-based pop dx pop ds diff --git a/kernel/rootdir.asm b/kernel/rootdir.asm index 21876a9..4432b04 100644 --- a/kernel/rootdir.asm +++ b/kernel/rootdir.asm @@ -46,7 +46,7 @@ fndnxt mov bp, sp mov ax, [es:di+FCBSIZ] inc word [es:di+FCBSIZ] ; bail out if we are at end of dir - cmp ax, [bpb+BPBRDE] + cmp ax, [cs:bpb+BPBRDE] jnc .err ; load entry and first byte push ds @@ -58,7 +58,7 @@ fndnxt mov bp, sp test byte [cs:di+0x0B], 0xDA jnz .loop ; bail out if end of dir - mov al, [di] + mov al, [cs:di] cmp al, 0 je .err ; next if deleted entry @@ -85,11 +85,13 @@ fndnxt mov bp, sp movsb ; copy filename push ds + push si mov ax, cs mov ds, ax mov si, bx mov cx, 11 rep movsb + pop si pop ds ; done! xor ax, ax @@ -103,7 +105,8 @@ open call fndfst test al, al jnz .ret ; read start cluster - mov ax, [cs:bx+26] + mov ax, [cs:bx+0x1A] + mov bx, dx mov [ds:bx+FCBCLUS], ax ; reset record number mov byte [ds:bx+FCBRN], 0