|
- 不知道有没有人用后边三种方式
- __attribute__((noinline))void swap1(int *a, int *b)
- {
- int tmp;
- tmp = *a;
- *a = *b;
- *b = tmp;
- }
- __attribute__((noinline))void swap2(int *a, int *b)
- {
- *a = *a + *b;
- *b = *a - *b;
- *a = *a - *b;
- }
- __attribute__((noinline))void swap3(int *a, int *b)
- {
- (*a) ^= (*b) ^= (*a) ^= *b;
- }
- __attribute__((noinline))void swap4(int *a, int *b)
- {
- *a = *a + *b - (*b = *a);
- }
复制代码- __tagsym$noinline
- swap1
- 0x00006550: e5913000 .0.. LDR r3,[r1,#0]
- 0x00006554: e5902000 . .. LDR r2,[r0,#0]
- 0x00006558: e5803000 .0.. STR r3,[r0,#0]
- 0x0000655c: e5812000 . .. STR r2,[r1,#0]
- 0x00006560: e12fff1e ../. BX lr
- i.swap2
- __tagsym$noinline
- swap2
- 0x00006564: e5902000 . .. LDR r2,[r0,#0]
- 0x00006568: e5913000 .0.. LDR r3,[r1,#0]
- 0x0000656c: e0822003 . .. ADD r2,r2,r3
- 0x00006570: e5802000 . .. STR r2,[r0,#0]
- 0x00006574: e5913000 .0.. LDR r3,[r1,#0]
- 0x00006578: e0422003 . B. SUB r2,r2,r3
- 0x0000657c: e5812000 . .. STR r2,[r1,#0]
- 0x00006580: e5901000 .... LDR r1,[r0,#0]
- 0x00006584: e0411002 ..A. SUB r1,r1,r2
- 0x00006588: e5801000 .... STR r1,[r0,#0]
- 0x0000658c: e12fff1e ../. BX lr
- i.swap3
- __tagsym$noinline
- swap3
- 0x00006590: e5902000 . .. LDR r2,[r0,#0]
- 0x00006594: e5913000 .0.. LDR r3,[r1,#0]
- 0x00006598: e0222003 . ". EOR r2,r2,r3
- 0x0000659c: e5802000 . .. STR r2,[r0,#0]
- 0x000065a0: e5913000 .0.. LDR r3,[r1,#0]
- 0x000065a4: e0222003 . ". EOR r2,r2,r3
- 0x000065a8: e5812000 . .. STR r2,[r1,#0]
- 0x000065ac: e5901000 .... LDR r1,[r0,#0]
- 0x000065b0: e0211002 ..!. EOR r1,r1,r2
- 0x000065b4: e5801000 .... STR r1,[r0,#0]
- 0x000065b8: e12fff1e ../. BX lr
- i.swap4
- __tagsym$noinline
- swap4
- 0x000065bc: e5902000 . .. LDR r2,[r0,#0]
- 0x000065c0: e5913000 .0.. LDR r3,[r1,#0]
- 0x000065c4: e5812000 . .. STR r2,[r1,#0]
- 0x000065c8: e0833002 .0.. ADD r3,r3,r2
- 0x000065cc: e0431002 ..C. SUB r1,r3,r2
- 0x000065d0: e5801000 .... STR r1,[r0,#0]
- 0x000065d4: e12fff1e ../. BX lr
复制代码
|
赞赏
-
2
查看全部赞赏
-
|