From 1bb536c383b297207aa74faeb34e5d1741cc2fd4 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 8 Aug 2021 14:37:07 -0400 Subject: [PATCH] LONG SEEK actually use lower 32 bits of 64 bit value (not 16 bits) --- hdr/portab.h | 7 +++++++ kernel/inthndlr.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index a364d25..b1764c8 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -317,6 +317,13 @@ typedef signed long LONG; #define LONG long #endif +#if USHRT_MAX == 0xFFFF +# define loword(v) ((unsigned short)(v)) +#else +# define loword(v) (0xFFFF & (unsigned)(v)) +#endif +#define hiword(v) loword ((v) >> 16u) + #define MK_UWORD(hib,lob) (((UWORD)(hib) << 8u) | (UBYTE)(lob)) #define MK_ULONG(hiw,low) (((ULONG)(hiw) << 16u) | (UWORD)(low)) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 49beeee..5f5668e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -2207,11 +2207,12 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs FAR *pr) case 0x42: /* 64-bit move file pointer */ { /* r.(DS:DX) points to 64-bit file position instead of r.(CX:DX) being 32-bit file position */ - UWORD FAR *filepos = MK_FP(r.DS, r.DX); + UDWORD FAR *filepos = MK_FP(r.DS, r.DX); if (*(filepos+1) != 0) /* we currently only handle lower 32 bits, upper 32 bits must be 0 */ goto error_invalid; r.BP = (UWORD)r.CL; - r.CX = *filepos; + r.CX = hiword(*filepos); + r.DX = loword(*filepos); /* fall through to 32-bit move file pointer (0x28) */ } case 0x28: /* move file pointer */