#include <stdio.h>
unsigned int f(unsigned int a)
{
return a * 8;
}
int main()
{
return 0;
}
#if 0
启用/Ox, 编译器会把"*8"的运算指令拆解为3条加法指令。
#endif
#if 0
/*
* intel
*/
0000000000001129 <f>:
1129: f3 0f 1e fa endbr64
112d: 55 push %rbp
112e: 48 89 e5 mov %rsp,%rbp
1131: 89 7d fc mov %edi,-0x4(%rbp)
1134: 8b 45 fc mov -0x4(%rbp),%eax
1137: c1 e0 03 shl $0x3,%eax
113a: 5d pop %rbp
113b: c3 retq
000000000000113c <main>:
113c: f3 0f 1e fa endbr64
1140: 55 push %rbp
1141: 48 89 e5 mov %rsp,%rbp
1144: b8 00 00 00 00 mov $0x0,%eax
1149: 5d pop %rbp
114a: c3 retq
114b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
/*
* arm
*/
000000000040051c <f>:
40051c: d10043ff sub sp, sp, #0x10
400520: b9000fe0 str w0, [sp, #12]
400524: b9400fe0 ldr w0, [sp, #12]
400528: 531d7000 lsl w0, w0, #3
40052c: 910043ff add sp, sp, #0x10
400530: d65f03c0 ret
0000000000400534 <main>:
400534: 52800000 mov w0, #0x0 // #0
400538: d65f03c0 ret
40053c: 00000000 .inst 0x00000000 ; undefined
#endif