ref: c0371f6c589f18cf9a9ccfe11332732e7c057aac
parent: 2cc71373f4ade25f562ea9b4713fa01efd422b7f
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sun May 5 21:15:46 EDT 2013
pbs: allow 9bootfat start cluster beyond 0xFFFF pbs failed to load (silently loading garbage) 9BOOTFAT from start cluster beyond FFFF because we ignored the low word from the directory entry. now taking the high 16 bit of the directory's start cluster into account.
--- a/sys/src/boot/pc/pbs.s
+++ b/sys/src/boot/pc/pbs.s
@@ -156,43 +156,47 @@
_found:
CLR(rBX)
-
LW(_rootsize(SB), rAX) /* calculate and save Xrootsz */
LWI(0x20, rCX)
MUL(rCX)
LW(_sectsize(SB), rCX)
- PUSHR(rCX)
DEC(rCX)
ADD(rCX, rAX)
ADC(rBX, rDX)
- POPR(rCX) /* _sectsize(SB) */
+ INC(rCX)
DIV(rCX)
PUSHR(rAX) /* Xrootsz */
- LXW(0x1a, xSI, rAX) /* starting sector address */
- DEC(rAX) /* that's just the way it is */
- DEC(rAX)
- LB(_clustsize(SB), rCL)
- CLRB(rCH)
+ CLR(rCX)
+ LXW(0x1a, xSI, rAX) /* start cluster low */
+ LXW(0x14, xSI, rBX) /* start cluster high */
+ SUBI(2, rAX) /* cluster -= 2 */
+ SBB(rCX, rBX)
+
+ LB(_clustsize(SB), rCL) /* convert to sectors (AX:DX) */
+ IMUL(rCX, rBX)
MUL(rCX)
+ ADD(rBX, rDX)
+
LW(_volid(SB), rCX) /* Xrootlo */
ADD(rCX, rAX)
LW(_volid+2(SB), rCX) /* Xroothi */
ADC(rCX, rDX)
+
+ CLR(rBX)
POPR(rCX) /* Xrootsz */
ADD(rCX, rAX)
ADC(rBX, rDX)
- PUSHR(rAX) /* calculate how many sectors to read */
+ PUSHR(rAX) /* calculate how many sectors to read (CX) */
PUSHR(rDX)
LXW(0x1c, xSI, rAX)
LXW(0x1e, xSI, rDX)
LW(_sectsize(SB), rCX)
- PUSHR(rCX)
DEC(rCX)
ADD(rCX, rAX)
ADC(rBX, rDX)
- POPR(rCX) /* _sectsize(SB) */
+ INC(rCX)
DIV(rCX)
MW(rAX, rCX)
POPR(rBX)
--- a/sys/src/boot/pc/x16.h
+++ b/sys/src/boot/pc/x16.h
@@ -117,6 +117,7 @@
BYTE $i;
#define SHRBI(i, r) OPrr(0xC0, 0x05, r); /* r>>i -> r */ \
BYTE $i;
+#define SBB(r0, r1) OPrr(0x19, r0, r1) /* r1-r0 -> r1 */
#define SUB(r0, r1) OPrr(0x29, r0, r1) /* r1-r0 -> r1 */
#define SUBI(i, r) OP(0x81, 0x03, 0x05, r);/* r-i -> r */ \
WORD $i;
--
⑨