diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 41fa836..dfe34b3 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1804,7 +1804,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) update_pointers: ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; - buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); + buffer = add_far(buffer, xfr_cnt); if (mode == XFR_WRITE) { if (fnp->f_offset > fnp->f_dir.dir_size) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 94c3265..c2486a0 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -83,22 +83,23 @@ seg far2para(VOID FAR * p) /* * Add a displacement to a far pointer and return the result normalized. */ -VOID FAR * add_far(VOID FAR * fp, ULONG off) +void FAR * add_far(void FAR * fp, unsigned off) { - UWORD off2; + unsigned segment, offset; if (FP_SEG(fp) == 0xffff) - return ((BYTE FAR *) fp) + FP_OFF(off); + return ((char FAR *) fp) + off; #ifndef I86 if (FP_SEG(fp) == 0) - return ((BYTE FAR *) fp) + FP_OFF(off); + return ((char FAR *) fp) + off; #endif - off += FP_OFF(fp); - off2 = ((UWORD)(off >> 16) << 12) + ((UWORD) off >> 4); - - return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf); + offset = off + FP_OFF(fp); + segment = FP_SEG(fp) + (offset >> 4); + if (offset < off) /* forward carry without using a long */ + segment += 0x1000; + return MK_FP(segment, offset & 0xf); } /* diff --git a/kernel/proto.h b/kernel/proto.h index 25dbd0d..fc62a74 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -230,7 +230,7 @@ COUNT DosDevIOctl(lregs * r); /* memmgr.c */ seg far2para(VOID FAR * p); seg long2para(ULONG size); -VOID FAR *add_far(VOID FAR * fp, ULONG off); +void FAR *add_far(void FAR * fp, unsigned off); VOID FAR *adjust_far(const void FAR * fp); COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize);