Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
818 serge 1
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
2
##include
3
#  .file "memset.s"
4
	.text
5
        .global _memset
6
	.align	4
7
_memset:
8
	pushl	%ebp
9
	movl	%esp,%ebp
10
	pushl	%edi
11
	movl	8(%ebp),%edi
12
	movl	12(%ebp),%eax
13
	movl	16(%ebp),%ecx
14
	cld
15
 
16
	# We will handle memsets of <= 15 bytes one byte at a time.
17
	# This avoids some extra overhead for small memsets, and
18
	# knowing we are setting > 15 bytes eliminates some annoying
19
	# checks in the "long move" case.
20
	cmpl	$15,%ecx
21
	jle	L3
22
 
23
	# Otherwise, tile the byte value out into %eax.
24
	# 0x41 -> 0x41414141, etc.
25
	movb	%al,%ah
26
	movl	%eax,%edx
27
	sall	$16,%eax
28
	movw	%dx,%ax
29
	jmp	L2
30
 
31
	# Handle any cruft necessary to get %edi long-aligned.
32
L1:	stosb
33
	decl	%ecx
34
L2:	testl	$3,%edi
35
	jnz	L1
36
 
37
	# Now slam out all of the longs.
38
	movl	%ecx,%edx
39
	shrl	$2,%ecx
40
	rep
41
	stosl
42
 
43
	# Finally, handle any trailing cruft.  We know the high three bytes
44
	# of %ecx must be zero, so just put the "slop count" in the low byte.
45
	movb	%dl,%cl
46
	andb	$3,%cl
47
L3:	rep
48
	stosb
49
	popl	%edi
50
	movl	8(%ebp),%eax
51
	leave
52
	ret