-
Notifications
You must be signed in to change notification settings - Fork 8
/
TestArm.c
69 lines (48 loc) · 1.29 KB
/
TestArm.c
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
#include <stdio.h>
static __attribute__((always_inline)) void Junk_code_001() {
#ifdef __aarch64__
__asm__ __volatile__ ("b 0xc\n"
".long 12345678\n"
".long 12345678\n"
);
#elif __arm__
// __asm__ __volatile__ (
// "movw r0, #1001 \t\n"
// "movw r12, #2020 \t\n"
// "add r0, r0, r12 \t\n"
// "bx lr" );
#endif
}
static __attribute__((always_inline)) void Junk_code_002() {
#ifdef __aarch64__
__asm__ __volatile__(
"mov x8,#0x1\n"
"adr x9, #0x10\n"
"mul x8, x9, x8\n"
".long 0x12345678\n"
"br x8\n"
);
#endif
}
static __attribute__((always_inline)) void Junk_code_003() {
#ifdef __aarch64__
__asm__ __volatile__(
"adr x8,#0xc\n"
"mov x30,x8\n"
"ret\n" );
#endif
}
static __attribute__((always_inline))
int count_bits(int x)
{
register int xx=x;
xx=xx-((xx>>1)&0x55555555);
xx=(xx&0x33333333)+((xx>>2)&0x33333333);
Junk_code_001();
xx=(xx+(xx>>4))&0x0f0f0f0f;
xx=xx+(xx>>8);
return (xx+(xx>>16)) & 0xff;
}
void __attribute__((constructor)) init_function_001(void){
count_bits(222);
}