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
79
80
81
82
83
84
85
86
87
88
|
TEXT memset(SB),$0
/*
* performance:
* (tba)
*/
MOVW R7, 0(FP)
MOVW n+8(FP), R9 /* R9 is count */
MOVW p+0(FP), R10 /* R10 is pointer */
MOVW c+4(FP), R11 /* R11 is char */
ADD R9,R10, R12 /* R12 is end pointer */
/*
* if not at least 4 chars,
* dont even mess around.
* 3 chars to guarantee any
* rounding up to a word
* boundary and 4 characters
* to get at least maybe one
* full word store.
*/
SUBCC $4,R9, R0
BL out
/*
* turn R11 into a word of characters
*/
AND $0xff, R11
SLL $8,R11, R7
OR R7, R11
SLL $16,R11, R7
OR R7, R11
/*
* store one byte at a time until pointer
* is alligned on a word boundary
*/
l1:
ANDCC $3,R10, R0
BE l2
MOVB R11, 0(R10)
ADD $1, R10
JMP l1
/*
* turn R9 into end pointer-15
* store 16 at a time while theres room
*/
l2:
ADD $-15,R12, R9
SUBCC R10,R9, R0
BLEU l4
l3:
MOVW R11, 0(R10)
MOVW R11, 4(R10)
ADD $16, R10
SUBCC R10,R9, R0
MOVW R11, -8(R10)
MOVW R11, -4(R10)
BGU l3
/*
* turn R9 into end pointer-3
* store 4 at a time while theres room
*/
l4:
ADD $-3,R12, R9
l5:
SUBCC R10,R9, R0
BLEU out
MOVW R11, 0(R10)
ADD $4, R10
JMP l5
/*
* last loop, store byte at a time
*/
out:
SUBCC R10,R12, R0
BLEU ret
MOVB R11, 0(R10)
ADD $1, R10
JMP out
ret:
MOVW s1+0(FP), R7
RETURN
|