简体   繁体   English

long long初始化和8字节平台

[英]long long initialization and 8 bytes plateform

I am suprised to discover that under MSVS2012 with x64 plateform as target under debug mode with optimization turn off, a long long initialization can't be done in one instruction : 我很惊讶地发现,在调试模式下关闭优化的调试模式下,以x64平台为目标的MSVS2012,无法在一条指令中进行long long初始化:

; long long l1 = 1;

    mov DWORD PTR _l1$[ebp], 1
    mov DWORD PTR _l1$[ebp+4], 0

As register are 8 bytes, I expected a instruction capable of doing it... is there one ? 因为寄存器是8个字节,所以我希望有一条指令能够执行此操作...是否有一个?

Trying this in a quick console mode project that targets x64 and looking in the Disassembly window: 在针对x64的快速控制台模式项目中尝试此操作,然后在“反汇编”窗口中查看:

    long long l1 = 1;
000000013F151035  mov         qword ptr [rsp],1

Same code when targeting x86: 定位x86时使用相同的代码:

    long long l1 = 1;
010213EE  mov         dword ptr [l1],1  
010213F5  mov         dword ptr [ebp-8],0  

Slam dunk, you are not actually looking at the x64 build of your program. 灌篮高手,您实际上并不是在看程序的x64构建。 Use Build + Configuration Manager to fix this. 使用Build + Configuration Manager修复此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM