code: 9ferno

ref: c44aabebe17d7bc8e6173e2b3d1a6e7b4f5edaf5
dir: /libkern/strchr-386.s/

View raw version
	TEXT	strchr(SB),$0
/*
 * look for null
 */
	MOVL	p+0(FP), DI
	MOVL	$-1, CX
	MOVL	$0, AX
	CLD

	REPN;	SCASB

/*
 * look for real char
 */
	MOVL	DI, CX
	MOVL	p+0(FP), DI
	SUBL	DI, CX
	MOVBLZX	c+4(FP), AX

	REPN;	SCASB

	JEQ	found
	MOVL	$0, AX
	RET

found:
	MOVL	DI, AX
	SUBL	$1, AX
	RET