小编whi*_*ear的帖子

与其他宽度不同,为什么短(16 位)变量将值移动到寄存器并存储该值?

int main()
{
00211000  push        ebp  
00211001  mov         ebp,esp  
00211003  sub         esp,10h  
    char charVar1;
    short shortVar1;
    int intVar1;
    long longVar1;
    
    charVar1 = 11;
00211006  mov         byte ptr [charVar1],0Bh  

    shortVar1 = 11;
0021100A  mov         eax,0Bh  
0021100F  mov         word ptr [shortVar1],ax  

    intVar1 = 11;
00211013  mov         dword ptr [intVar1],0Bh 
 
    longVar1 = 11;
0021101A  mov         dword ptr [longVar1],0Bh  
}
Run Code Online (Sandbox Code Playgroud)

其他数据类型不通过寄存器,但只有短类型通过寄存器。怎么了?

c x86 assembly cpu-architecture micro-optimization

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

标签 统计

assembly ×1

c ×1

cpu-architecture ×1

micro-optimization ×1

x86 ×1