aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/lib/memset.S
blob: 2aa48f24ed1e48974680b5354ede86e826d5f0a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Copyright 2002 Andi Kleen, SuSE Labs */
/*
 * ISO C memset - set a memory block to a byte value.
 *	
 * rdi   destination
 * rsi   value (char) 
 * rdx   count (bytes) 
 * 
 * rax   original destination
 */	
 	.globl __memset
	.globl memset
	.p2align 4
memset:	
__memset:
	movq %rdi,%r9
	movl %edx,%r8d
	andl $7,%r8d		
	movl %edx,%ecx
	shrl $3,%ecx		
	/* expand byte value  */
	movzbl %sil,%esi
	movabs $0x0101010101010101,%rax
	mulq   %rsi		/* with rax, clobbers rdx */
	rep
	stosq	
	movl %r8d,%ecx
	rep
	stosb
	movq %r9,%rax
	ret