Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/libc/386/memset.s

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


	TEXT	memset(SB),$0

	CLD
	MOVL	p+0(FP), DI
	MOVBLZX	c+4(FP), AX
	MOVL	n+8(FP), BX
/*
 * if not enough bytes, just set bytes
 */
	CMPL	BX, $9
	JLS	c3
/*
 * build word in AX
 */
	MOVB	AL, AH
	MOVL	AX, CX
	SHLL	$16, CX
	ORL	CX, AX
/*
 * set whole longs
 */
c1:
	MOVL	BX, CX
	SHRL	$2, CX
	ANDL	$3, BX
	REP;	STOSL
/*
 * set the rest, by bytes
 */
c3:
	MOVL	BX, CX
	REP;	STOSB
ret:
	MOVL	p+0(FP),AX
	RET

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.