Hi!

21-Мар-2004 12:36 [EMAIL PROTECTED] (Bart Oldeman) wrote to
[EMAIL PROTECTED]:
> X-Spam-Report: Spam detection software, running on the system 
> "externalmx-1.sourceforge.net", has
>       pts rule name              description
>       0.6 DATE_IN_PAST_06_12     Date: is 6 to 12 hours before Received: date

>       memmgr.c task.c
> Log Message:
> Eliminated long2para and avoided use of "long"s in DosExeLoader, using
> paragraphs to measure size instead. Saves ~130 bytes together.

     Ha! At last. How long I told about this?

>  COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
> +    image_size = ExeHeader.exPages * 32 - ExeHeader.exHeaderSize;


    image_size = ExeHeader.exPages * (512u/16u) - ExeHeader.exHeaderSize;

> @@ -660,33 +658,32 @@
>        if (exe_size > 0 && (ExeHeader.exMinAlloc == 0) &&
> (ExeHeader.exMaxAlloc == 0))

      if (exe_size > 0 && (ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0)

> -        start_seg = start_seg + mp->m_size - (UWORD)((image_size + 15) / 16);
> +        start_seg += mp->m_size - image_size;

     For BC, "start_seg += a - b;" isn't equal to "start_seg = start_seg + a
- b;". First is equal to "mov ax,a/sub ax,a/add start_seg,ax", second is
equal to "add start_seg,a/sub start_seg,b".

     Same for any standard compliant compiler, because first expression is
equal to "start_seg = start_seg + (a-b)", whereas standard says, that
expression in parentesis should be evaluated first.

> +    int nBytesRead, toRead = CHUNK;
> +    seg sp = start_seg;
> +
> +    while (toRead == CHUNK)
>      {
> +      if (exe_size < CHUNK/16)
> +        toRead = exe_size*16;
> +      nBytesRead = (int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ);
> +      if (nBytesRead < toRead)
>          break;
> +      sp += CHUNK/16;
> +      exe_size -= CHUNK/16;
>      }

    seg sp = start_seg;
    for (;;) {
      unsigned toRead = CHUNK;
      if (exe_size < CHUNK/16)
        toRead = exe_size*16;
      if ((int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ) != toRead ||
          exe_size <= CHUNK / 16u)
        break;
      sp += CHUNK / 16u;
      exe_size -= CHUNK / 16u;
    }




-------------------------------------------------------
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