1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#define isrc r0
22#define max r1
23
24#define end r2
25#define tmp1 r3
26
27#define obo r6
28#define start r7
29#define mod8 r8
30#define dbuf r15:14
31#define dcmp r13:12
32
33
34
35
36
37
38
39#define fname __strnlen_user
40
41 .text
42 .global fname
43 .type fname, @function
44 .p2align 5
45fname:
46 {
47 mod8 = and(isrc,
48 end = add(isrc,max);
49 start = isrc;
50 }
51 {
52 P0 = cmp.eq(mod8,
53 mod8 = and(end,
54 dcmp =
55 if (P0.new) jump:t dw_loop;
56 }
57
58alignment_loop:
59fail_1: {
60 tmp1 = memb(start++
61 }
62 {
63 P0 = cmp.eq(tmp1,
64 if (P0.new) jump:nt exit_found;
65 P1 = cmp.gtu(end,start);
66 mod8 = and(start,
67 }
68 {
69 if (!P1) jump exit_error;
70 P0 = cmp.eq(mod8,
71 }
72 {
73 if (!P0) jump alignment_loop;
74 }
75
76
77
78dw_loop:
79fail_2: {
80 dbuf = memd(start);
81 obo = add(start,
82 }
83 {
84 P0 = vcmpb.eq(dbuf,dcmp);
85 }
86 {
87 tmp1 = P0;
88 P0 = cmp.gtu(end,start);
89 }
90 {
91 tmp1 = ct0(tmp1);
92 mod8 = and(end,
93 if (!P0) jump end_check;
94 }
95 {
96 P0 = cmp.eq(tmp1,
97 if (!P0.new) jump:nt exit_found;
98 if (!P0.new) start = add(obo,tmp1);
99 }
100 {
101 start = add(start,
102 jump dw_loop;
103 }
104
105
106end_check:
107 {
108 P0 = cmp.gt(tmp1,mod8);
109 if (P0.new) jump:nt exit_error;
110 start = add(obo,tmp1);
111 }
112
113exit_found:
114 {
115 R0 = sub(start,isrc);
116 jumpr R31;
117 }
118
119exit_error:
120 {
121 R0 = add(max,
122 jumpr R31;
123 }
124
125
126 .falign
127fix_1:
128 {
129 R0 =
130 jumpr R31;
131 }
132
133 .size fname,.-fname
134
135
136.section __ex_table,"a"
137.long fail_1,fix_1
138.long fail_2,fix_1
139.previous
140