Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
	TEXT	memccpy(SB),$0
2
 
3
	MOVL	n+12(FP), CX
4
	CMPL	CX, $0
5
	JEQ	none
6
	MOVL	p2+4(FP), DI
7
	MOVBLZX	c+8(FP), AX
8
	CLD
9
/*
10
 * find the character in the second string
11
 */
12
 
13
	REPN;	SCASB
14
	JEQ	found
15
 
16
/*
17
 * if not found, set count to 'n'
18
 */
19
none:
20
	MOVL	$0, AX
21
	MOVL	n+12(FP), BX
22
	JMP	memcpy
23
 
24
/*
25
 * if found, set count to bytes thru character
26
 */
27
found:
28
	MOVL	DI, AX
29
	SUBL	p2+4(FP), AX
30
	MOVL	AX, BX
31
	ADDL	p1+0(FP), AX
32
 
33
/*
34
 * copy the memory
35
 */
36
 
37
memcpy:
38
	MOVL	p1+0(FP), DI
39
	MOVL	p2+4(FP), SI
40
/*
41
 * copy whole longs
42
 */
43
	MOVL	BX, CX
44
	SHRL	$2, CX
45
	REP;	MOVSL
46
/*
47
 * copy the rest, by bytes
48
 */
49
	ANDL	$3, BX
50
	MOVL	BX, CX
51
	REP;	MOVSB
52
 
53
	RET