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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// TITLE("memccpy")
//++
//
// Copyright (c) 1994 IBM Corporation
//
// Module Name:
//
// memccpy.s
//
// Routine Description:
//
// Copies bytes from src to dest until count bytes have been
// copied, or up to and including the character c, whichever
// comes first.
//
// Author:
//
// Jeff Simon (jhs) 02-Aug-1994
//
// Environment:
//
// User or Kernel mode.
//
// Revision History:
//
// Includes
#include <kxppc.h>
//
// Arguments:
//
// SRC1 (r.3) - A pointer to the memory destination
//
// SRC1 (r.4) - A pointer to the memory source
//
// CHAR (r.5) - A character to stop copy
//
// LNGTH (r.6) - Max number of comparison in bytes
//
// Return Value:
//
// NULL if search character is not found or not copied
// ptr to byte immediately after search character ...
// ... if character found AND copied
//
// void * _CALLTYPE1 _memccpyc (
// void * dest,
// const void * src,
// int c,
// unsigned count
// )
//
LEAF_ENTRY(_memccpy)
addi r7,r6,1 # incr count, artificial
mtctr r7 # move count to ctr
bdz L..7A # if 0, finish up
lbz r8,0(r4) # read 1st char
subi r3,r3,1 # prep r3 for update form
L..3:
stbu r8,1(r3) # copy char
cmp 0x0,0x0,r8,r5 # compare to char c
beq L..5 # found char c, say goodbye
bdz L..7A # count 0, say goodbye
lbzu r8,1(r4) # read next char
b L..3 # do another
L..5:
addi r3,r3,1 # ret r3+1
b L..7 # all done, one exit pt.
L..7A:
addi r3,r0,0 # return null
L..7:
LEAF_EXIT(_memccpy)
|