author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
7 //
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
10 //
11 // Contributors:
12 //
13 // Description:
14 // e32test\misc\cpumeter.cia
15 //
16 //
18 #include <e32test.h>
19 #include <e32hal.h>
20 #include <u32std.h>
22 extern TUint32 NopCount;
23 extern TUint MaxCycles;
25 #if defined(__CPU_ARM)
26 __NAKED__ TInt CountNops(TAny*)
27 {
28 __SWITCH_TO_ARM;
29 asm("ldr r0, __NopCount ");
30 asm("mov r1, #0 ");
32 asm("loop: ");
33 asm("mov r0, r0 ");
34 asm("mov r0, r0 ");
35 asm("mov r0, r0 ");
36 asm("mov r0, r0 ");
37 asm("mov r0, r0 ");
38 asm("mov r0, r0 ");
39 asm("mov r0, r0 ");
40 asm("mov r0, r0 ");
41 asm("mov r0, r0 ");
42 asm("mov r0, r0 ");
43 asm("mov r0, r0 ");
44 asm("mov r0, r0 ");
45 asm("mov r0, r0 ");
46 asm("mov r0, r0 ");
47 asm("mov r0, r0 ");
48 asm("mov r0, r0 ");
49 asm("mov r0, r0 ");
50 asm("mov r0, r0 ");
51 asm("mov r0, r0 ");
52 asm("mov r0, r0 ");
53 asm("mov r0, r0 ");
54 asm("mov r0, r0 ");
55 asm("mov r0, r0 ");
56 asm("mov r0, r0 ");
57 asm("mov r0, r0 ");
58 asm("mov r0, r0 ");
59 asm("mov r0, r0 ");
60 asm("mov r0, r0 ");
61 asm("mov r0, r0 ");
62 asm("mov r0, r0 ");
63 asm("mov r0, r0 ");
64 asm("mov r0, r0 ");
65 asm("mov r0, r0 ");
66 asm("mov r0, r0 ");
67 asm("mov r0, r0 ");
68 asm("mov r0, r0 ");
69 asm("mov r0, r0 ");
70 asm("mov r0, r0 ");
71 asm("mov r0, r0 ");
72 asm("mov r0, r0 ");
73 asm("mov r0, r0 ");
74 asm("mov r0, r0 ");
75 asm("mov r0, r0 ");
76 asm("mov r0, r0 ");
77 asm("mov r0, r0 ");
78 asm("mov r0, r0 ");
79 asm("mov r0, r0 ");
80 asm("mov r0, r0 ");
81 asm("mov r0, r0 ");
82 asm("mov r0, r0 ");
83 asm("mov r0, r0 ");
84 asm("mov r0, r0 ");
85 asm("mov r0, r0 ");
86 asm("mov r0, r0 ");
87 asm("mov r0, r0 ");
88 asm("mov r0, r0 ");
89 asm("mov r0, r0 ");
90 asm("mov r0, r0 ");
91 asm("mov r0, r0 ");
92 asm("mov r0, r0 ");
93 asm("mov r0, r0 ");
94 asm("mov r0, r0 ");
95 asm("mov r0, r0 ");
96 asm("mov r0, r0 ");
97 asm("add r1, r1, #71 ");
98 asm("str r1, [r0] ");
99 asm("b loop ");
101 asm("mov r0, #0 ");
102 __JUMP(,lr);
104 asm("__NopCount: ");
105 asm(".word NopCount ");
106 __END_ARM;
107 }
108 #elif defined(__CPU_X86)
109 __NAKED__ TInt CountNops(TAny*)
110 {
111 #ifdef __WINS__
112 __asm lea edx, NopCount
113 __asm mov eax, 0
114 noploop:
115 __asm inc eax
116 __asm inc eax
117 __asm inc eax
118 __asm inc eax
119 __asm inc eax
120 __asm inc eax
121 __asm inc eax
122 __asm inc eax
123 __asm inc eax
124 __asm inc eax
125 __asm inc eax
126 __asm inc eax
127 __asm inc eax
128 __asm inc eax
129 __asm inc eax
130 __asm inc eax
131 __asm inc eax
132 __asm inc eax
133 __asm inc eax
134 __asm inc eax
135 __asm inc eax
136 __asm inc eax
137 __asm inc eax
138 __asm inc eax
139 __asm inc eax
140 __asm inc eax
141 __asm inc eax
142 __asm inc eax
143 __asm inc eax
144 __asm inc eax
145 __asm inc eax
146 __asm inc eax
147 __asm inc eax
148 __asm inc eax
149 __asm inc eax
150 __asm inc eax
151 __asm inc eax
152 __asm inc eax
153 __asm inc eax
154 __asm inc eax
155 __asm inc eax
156 __asm inc eax
157 __asm inc eax
158 __asm inc eax
159 __asm inc eax
160 __asm inc eax
161 __asm inc eax
162 __asm inc eax
163 __asm inc eax
164 __asm inc eax
165 __asm inc eax
166 __asm inc eax
167 __asm inc eax
168 __asm inc eax
169 __asm inc eax
170 __asm inc eax
171 __asm inc eax
172 __asm inc eax
173 __asm inc eax
174 __asm inc eax
175 __asm inc eax
176 __asm inc eax
177 __asm inc eax
178 __asm inc eax
179 __asm add eax, 3
180 __asm mov [edx], eax
181 __asm jmp noploop
182 #else
183 asm("mov edx, %a0": : "i"(&NopCount));
184 asm("mov eax, 0");
185 asm("noploop:");
186 asm("inc eax");
187 asm("inc eax");
188 asm("inc eax");
189 asm("inc eax");
190 asm("inc eax");
191 asm("inc eax");
192 asm("inc eax");
193 asm("inc eax");
194 asm("inc eax");
195 asm("inc eax");
196 asm("inc eax");
197 asm("inc eax");
198 asm("inc eax");
199 asm("inc eax");
200 asm("inc eax");
201 asm("inc eax");
202 asm("inc eax");
203 asm("inc eax");
204 asm("inc eax");
205 asm("inc eax");
206 asm("inc eax");
207 asm("inc eax");
208 asm("inc eax");
209 asm("inc eax");
210 asm("inc eax");
211 asm("inc eax");
212 asm("inc eax");
213 asm("inc eax");
214 asm("inc eax");
215 asm("inc eax");
216 asm("inc eax");
217 asm("inc eax");
218 asm("inc eax");
219 asm("inc eax");
220 asm("inc eax");
221 asm("inc eax");
222 asm("inc eax");
223 asm("inc eax");
224 asm("inc eax");
225 asm("inc eax");
226 asm("inc eax");
227 asm("inc eax");
228 asm("inc eax");
229 asm("inc eax");
230 asm("inc eax");
231 asm("inc eax");
232 asm("inc eax");
233 asm("inc eax");
234 asm("inc eax");
235 asm("inc eax");
236 asm("inc eax");
237 asm("inc eax");
238 asm("inc eax");
239 asm("inc eax");
240 asm("inc eax");
241 asm("inc eax");
242 asm("inc eax");
243 asm("inc eax");
244 asm("inc eax");
245 asm("inc eax");
246 asm("inc eax");
247 asm("inc eax");
248 asm("inc eax");
249 asm("inc eax");
250 asm("add eax, 3");
251 asm("mov [edx], eax");
252 asm("jmp noploop");
253 #endif
254 }
255 #endif