Long initialization and 8 byte form

I am surprised to find that in MSVS2012 with the x64 table as the target in debug mode with optimization, turn off, long long initialization cannot be performed in one instruction:

 ; long long l1 = 1; mov DWORD PTR _l1$[ebp], 1 mov DWORD PTR _l1$[ebp+4], 0 

As the register is 8 bytes, I was expecting instructions capable of doing this ... is there one?

+4
source share
1 answer

Try this in a project with a quick console mode that targets x64 and looks in the "Disassembly" window:

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

Same code when targeting x86:

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

Slam dunk, you don’t really look at the x64 build of your program. Use "Build + Configuration Manager" to fix this.

+2
source

Source: https://habr.com/ru/post/1447231/


All Articles