Board index » delphi » Aligned 32-bit move() and fillchar() replacement

Aligned 32-bit move() and fillchar() replacement

Ok, here is a version of move() and fillchar() that align the source first.
They should be only used with large counts.

procedure move32(var src,dest;count:word); assembler;
asm
        mov     dx,ds
        les     di,dest
        lds     si,src
        mov     ax,count
        mov     cx,4
        sub     cx,di
        and     cx,3            ;{ CX <- (4-DI) % 4, # of align bytes}
        sub     ax,cx
        jle     @LEB
        rep     movsb           ;{ Copy pre-amble bytes.}
        mov     cx, ax
        and     ax, 3           ;{ Retain # of end bytes in AX.}
        shr     cx, 2
        db 66h; rep movsw                      
@LEB:   add     cx, ax
        rep     movsb           ;{ Copy final bytes.}
        mov     ds,dx
end;

procedure fillchar32(var x;count:word;value:byte); assembler;
asm
        mov     al,value
        mov     ah,al
        mov     dx,count
        mov     bx,ax
        db 66h; shl ax,16
        les     di,x
        mov     ax,bx
        mov     cx,di
        add     cx,3
        not     cx
        and     cx,3
        sub     dx,cx
        rep     stosb
        mov     cx,dx
        shr     cx,2
        db 66h; rep stosw
        mov     cx,dx
        and     cx,3
        rep     stosb
end;

Both Move32() and fillchar32() have been tested, and just looking at the
instruction ordering, it is very non-optimized for the pentium.

--TCA of NewOrder
newor...@carina.unm.edu
http://www.nmt.edu/~surface

 

Re:Aligned 32-bit move() and fillchar() replacement


On 8 Sep 1995, NewOrder Demo Group wrote:

Quote
> Ok, here is a version of move() and fillchar() that align the source first.
> They should be only used with large counts.

> [snip]

> Both Move32() and fillchar32() have been tested, and just looking at the
> instruction ordering, it is very non-optimized for the pentium.

se on hyv'a'! :) and since most of my counts are large anyway... (what do
you mean by large, i.e. 256 or higher?)

-----------------\------------------------------------------------------------
Quantum Porcupine \-\  People kept on telling me to get on with it and write
a.k.a. Joshua Shagam > my damn .sig file.  Well I finally got around to it
jsha...@nmsu.edu /--/  since I finally got SIG of it all.
----------------/-------------------------------------------------------------
  Missing Link / Puuttuva Lenkki

Other Threads