小编Bec*_*hma的帖子

这个装配怎么可能?

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选项来获得更短的汇编代码

c x86 assembly gcc

5
推荐指数
1
解决办法
248
查看次数

标签 统计

assembly ×1

c ×1

gcc ×1

x86 ×1