Hi!

10-Апр-2004 14:18 [EMAIL PROTECTED] (Bart Oldeman) wrote to
[EMAIL PROTECTED]:

> in kernel.asm. Use std for the memory move: helps if there's overlap
> (PCs with a very low amount of RAM).
> +++ inithma.c 10 Apr 2004 14:18:24 -0000      1.24
> -  else
> -  {
> -    /* might overlap */
> -    for (i = len, s = HMASource, d = HMADest; i != 0; i--)
> -      d[i] = s[i];
> +    fmemcpy(HMADest, HMASource, len);
> +  /* else it's the very first relocation: handled by kernel.asm */

     _Standard_ memcpy() _doesn't_ handles memory overlapping. This does
_only_ memmove().

> +++ kernel.asm        10 Apr 2004 14:18:24 -0000      1.48
> +%ifdef WATCOM
> +             mov     cx,dx
> +             shr     cx,4
> +             add     ax,cx

     This is _not_ 8086 code (unless NASM begins to be smart enough, as
TASM, to replace this by four SHR CX,1). I think, this code may look so:

%ifdef WATCOM
        mov     si,dx
        mov     cl,4
        shr     si,cl
        add     ax,si

> +%endif

> -             xor     di,di
> -             mov     cx,1 + init_end wrt INIT_TEXT
> +             mov     cx,-2 + init_end wrt INIT_TEXT
> +             mov     si,cx
> +             mov     di,cx
> +             shr     cx,1
> +             inc     cx

     Unlike original code, new code doesn't "rounds up" CX value (for
example, 3 bytes into 2 words). I think, it may look so:

        mov     si,-2 + init_end wrt INIT_TEXT + 1
         and    si,not 1        ; round up at word boundary
        mov     di,si
        lea     cx,[si+2]       ; length in bytes...
         shr    cx,1            ; ...to length in words

> +             mov     cx,dx           ; cx = __InitTextStart wrt HMA_TEXT
> +             shr     dx,4
> +
> +             sub     ax,dx
> +             mov     ds,ax           ; ds = HMA_TEXT
> +             mov     ax,es
> +             sub     ax,dx
> +             mov     es,ax           ; es = new HMA_TEXT
> +
> +             mov     si,cx
> +             dec     si
> +             dec     si
> +             mov     di,si
>               shr     cx,1
> -             cld
>               rep     movsw

     Same as above: SI, DI and CX are not aligned. On the other side, DS and
ES are shifted back by (not rounded up) __InitTextStart/16, so, I suggest,
this value should be used for calculation:

        mov     cl,4
        shr     dx,cl   ; =__InitTextStart wrt HMA_TEXT / 16
        sub     ax,dx
        ...
        mov     es,ax
        mov     si,dx
        dec     cx      ; cl=3
        shl     si,cl
        mov     cx,si   ; =__InitTextStart wrt HMA_TEXT / 16 * 8
        dec     si
        shl     si,1    ; =__InitTextStart wrt HMA_TEXT / 16 * 16 - 2
        mov     di,si
rep     movsw




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