xref: /plan9-contrib/sys/src/libc/amd64/memset.s (revision 272efad760864ee41cfe633b56aea9b4f5cf3ae7)
1	TEXT	memset(SB),$0
2
3	CLD
4	MOVQ	RARG, DI
5	MOVBLZX	c+8(FP), AX
6	MOVL	n+16(FP), BX
7/*
8 * if not enough bytes, just set bytes
9 */
10	CMPL	BX, $9
11	JLS	c3
12/*
13 * if not aligned, just set bytes
14 */
15	MOVQ	RARG, CX
16	ANDL	$3,CX
17	JNE	c3
18/*
19 * build word in AX
20 */
21	MOVB	AL, AH
22	MOVL	AX, CX
23	SHLL	$16, CX
24	ORL	CX, AX
25/*
26 * set whole longs
27 */
28c1:
29	MOVQ	BX, CX
30	SHRQ	$2, CX
31	ANDL	$3, BX
32	REP;	STOSL
33/*
34 * set the rest, by bytes
35 */
36c3:
37	MOVL	BX, CX
38	REP;	STOSB
39ret:
40	MOVQ	RARG,AX
41	RET
42