#include <stdio.h>
unsigned int f(unsigned int a)
{
return a * 4;
}
void main()
{}
#if 0
编译器通常会把"*2""/2"的运算指令处理为位移运算指令。
*4 就是把被乘数左移2位,再把位移产生的空缺位添上0的运算。
#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 02 shl $0x2,%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: 90 nop
1145: 5d pop %rbp
1146: c3 retq
1147: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1)
114e: 00 00
/*
* arm
*/
000000000040051c <f>:
40051c: d10043ff sub sp, sp, #0x10
400520: b9000fe0 str w0, [sp, #12]
400524: b9400fe0 ldr w0, [sp, #12]
400528: 531e7400 lsl w0, w0, #2
40052c: 910043ff add sp, sp, #0x10
400530: d65f03c0 ret
0000000000400534 <main>:
400534: d503201f nop
400538: d65f03c0 ret
40053c: 00000000 .inst 0x00000000 ; undefined
#endif