The destination operand can be a register or a memory location. The count operand can be an immediate value or the CL register. The count is masked to 5 bits (or 6 bits if in 64-bit mode and REX.W is used). The count range is limited to 0 to 31 (or 63 if 64-bit mode and REX.W is used). A special opcode encoding is provided for a count of 1.--<<[Intel]Instruction Set Reference, A-Z (Volume 2)>>
1《3 左移三位 结果为1000 是8
iColors 是什么类型?
也就是SHL 1,32机器指令的执行等同于SHL 1,0(32的mask低5位就是0),所以表达式等价于Colors = 1 << 0 结果为1iColors = 1<<32在编译时编译器帮你计算1<<32的结果为0,所以iColors 编译后初始化为0
均是错误的, 超过int本身的宽度或者等于宽度,是未定义行为, 移位是错误的。改成:INT64 iColors=(INT64)(1)<<(32);试试, 可以获得你的计算机的色彩色。貌似是理论色彩啊
can be an immediate value or the CL register. The count is masked to 5 bits (or 6 bits
if in 64-bit mode and REX.W is used). The count range is limited to 0 to 31 (or 63 if
64-bit mode and REX.W is used). A special opcode encoding is provided for a count
of 1.--<<[Intel]Instruction Set Reference, A-Z (Volume 2)>>
说明这种指令最多可以31次移位
超过int本身的宽度或者等于宽度,是未定义行为, 移位是错误的。
请问2楼:这个是不是只针对变量,而不针对常量?
请问3楼:现在可以出正确结果了。INT 64是指什么? 8 个字节长的整形,它的取值范围是?