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
.
它移动 int a
的最低字节,因为这是static_cast<char>
给你的。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.