int sarl_n(int x, char n){
x <<= 2;
x >>= n;
return x;
Run Code Online (Sandbox Code Playgroud)
}
当我用"gcc -m32 -S sarl_n.c"组装时,它会发出以下代码:
.cfi_startproc
movl 4(%esp), %eax
movsbl 8(%esp), %ecx
sall $2, %eax
sarl %cl, %eax #This is the part which I don't understand
ret
.cfi_endproc
Run Code Online (Sandbox Code Playgroud)
为什么gcc使用"迷你寄存器" %cl而不是大注册%ecx?
编辑:我使用O2选项来获得更短的汇编代码