Hi!

22-Мар-2004 14:23 [EMAIL PROTECTED] (Bart Oldeman) wrote to
[EMAIL PROTECTED]:

BO> add_far is only used at a few select places where we want to have the
BO> offset part as low as possible. Nothing to do with structures but
BO> everything to do with potentially large file reads, with "read chunk,
BO> update pointer" loops.
BO> Quite possibly Arkady's approach minimizing normalizations has merit but
BO> then each add_far caller needs to be checked if it needs to manually
BO> normalize the pointer afterwards.

     Then rename "add_far" into "normalize_ptr" and remove misleading. Also,
I may offer next code to always perform normalization: (BTW, is "protection"
from wrapping HMA pointer into IVT by replacing wrapping into start of HMA
worth of code?)

void FAR *normalize_ptr (void FAR *fp, unsigned add)
{
  unsigned ofs = add + FP_OFF (fp);
  seg/*_t*/ s = FP_SEG (fp);
  if (ofs < FP_OFF (fp))        /* arithmetic overflow? */
    s += 0x1000;                /* add carry */
  return MK_FP ((ofs >> 4) + s, 0xF & ofs);
}

BO> But for now, because it's not called very often, the time it takes is very
BO> small in comparison with the BIOS calls following, and normalization doesn't
BO> hurt, I haven't changed it.




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel

Reply via email to