127: int a = 2815;
00007FF78B5126EE mov dword ptr [a],0AFFh
128:
129: short c = static_cast<char>(a);
00007FF78B5126F5 movsx ax,byte ptr [a]
00007FF78B5126FA mov word ptr [c],ax
In my environment an int
takes 4 byte and a short takes 2, so in the movsx
instruction, why there is a byte not a word? Hope someone can help me!
A char
is one byte. The static_cast
casts a
to a char
. One byte. Hence, the one-byte value of the char
-cast variable a
is moved into ax
.