libc.obj:
- Formatted by clang-format (WebKit-style). - Removed unnecessary errno linux. - Added KOS error codes. - String functions have been replaced with more optimal ones for x86. - Changed wrappers for 70 sysfunction. git-svn-id: svn://kolibrios.org@9765 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
51
programs/develop/ktcc/trunk/libc.obj/source/string/memset.s
Executable file
51
programs/develop/ktcc/trunk/libc.obj/source/string/memset.s
Executable file
@@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
.text
|
||||
.align 4
|
||||
.global memset
|
||||
|
||||
memset:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
pushl %edi
|
||||
movl 8(%ebp),%edi
|
||||
movl 12(%ebp),%eax
|
||||
movl 16(%ebp),%ecx
|
||||
cld
|
||||
|
||||
# We will handle memsets of <= 15 bytes one byte at a time.
|
||||
# This avoids some extra overhead for small memsets, and
|
||||
# knowing we are setting > 15 bytes eliminates some annoying
|
||||
# checks in the "long move" case.
|
||||
cmpl $15,%ecx
|
||||
jle memset.L3
|
||||
|
||||
# Otherwise, tile the byte value out into %eax.
|
||||
# 0x41 -> 0x41414141, etc.
|
||||
movb %al,%ah
|
||||
movl %eax,%edx
|
||||
sall $16,%eax
|
||||
movw %dx,%ax
|
||||
jmp memset.L2
|
||||
|
||||
# Handle any cruft necessary to get %edi long-aligned.
|
||||
memset.L1: stosb
|
||||
decl %ecx
|
||||
memset.L2: testl $3,%edi
|
||||
jnz memset.L1
|
||||
|
||||
# Now slam out all of the longs.
|
||||
movl %ecx,%edx
|
||||
shrl $2,%ecx
|
||||
rep
|
||||
stosl
|
||||
|
||||
# Finally, handle any trailing cruft. We know the high three bytes
|
||||
# of %ecx must be zero, so just put the "slop count" in the low byte.
|
||||
movb %dl,%cl
|
||||
andb $3,%cl
|
||||
memset.L3: rep
|
||||
stosb
|
||||
popl %edi
|
||||
movl 8(%ebp),%eax
|
||||
leave
|
||||
ret
|
||||
Reference in New Issue
Block a user