Re: Ideas for reducing memory copying and zeroing times (fwd)

Michael Riepe (riepe@ifwsn4.ifw.uni-hannover.de)
Fri, 19 Apr 1996 04:16:53 +0200


From: "Ulrich Windl" <Ulrich.Windl@rz.uni-regensburg.de>
> Just to throw in my thoughts:
> Of course it's better to avoid zeroing pages than to seek for a fast
> zeroing routine.
> I'm wondering if for the 486+ there's something faster than
> mov eax,0
> rep stosd.
> For the 8086 a fully unrolled page clear like
> rept 2048
> mov [bx],ax
> inc ax
> endm
> would have been faster (I think stosw wasn't too fast). Having

I guess the fastest (and shortest) way to do that on an 80x86 is:

xorl %eax,%eax
leal 4096(page_start),%esp
<repeat 1024 times>
pushl %eax
<end repeat>

Of course you will have to turn interrupts off while doing this, and
you have to save and restore %esp - but it's twice as fast as your
move-and-increment procedure (assuming that push, mov and increment
operations each take 1 clock cycle - that's what my i486 documentation
says) and takes only 1024+ bytes of code space. Your code takes at
least(?) 4 bytes of code per word cleared, assuming 32-bit protected
mode:

xorl %eax,%eax
xorl %ecx,%ecx
leal 0(page_start),%ebx
<repeat 1024 times>
movl %eax,(%ebx,%ecx,4) ! 3 bytes
incl %ecx ! 1 byte
<end repeat>

-- 
 Michael "Tired" Riepe <riepe@ifwsn4.ifw.uni-hannover.de>
 "Beware the storm that gathers here!" (The Prophet's Song)