[lkml]   [1996]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Ideas for reducing memory copying and zeroing times (fwd)
From: "Ulrich Windl" <>
> 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

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 <>
"Beware the storm that gathers here!" (The Prophet's Song)

 \ /
  Last update: 2005-03-22 13:37    [W:0.048 / U:18.864 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site