まさかローテートになっていようとは・・・・
コンパイラや処理系によっても結果は違ってくるのかな。
こんなのではまってしまいました。修業が足りない。
unsigned char Year[2];
Year[0] = 0x20;
Year[1] = 0x18;
printf("year=%x\n", Year[0]<<8 + Year[1]);
(http://chimera.roma1.infn.it/SP/COMMON/ ... 9-1990.pdf)N1570 6.5.7 Bitwise shift operatorsの3 さんが書きました: The integer promotions are performed on each of the operands. The type of the result is
that of the promoted left operand. If the value of the right operand is negative or is
greater than or equal to the width of the promoted left operand, the behavior is undefined.
(http://www.open-std.org/jtc1/sc22/wg21/ ... /n3337.pdf)N3337 5.8 Shift operatorsの1 さんが書きました: The operands shall be of integral or unscoped enumeration type and integral promotions are performed.
The type of the result is that of the promoted left operand. The behavior is undefined if the right operand
is negative, or greater than or equal to the length in bits of the promoted left operand.
x86系で32bit以上のシフトをするときの問題 - 間違いだらけの備忘録IA-32アーキテクチャにおける互換性
8086は、シフトカウントをマスクしません。しかし、(インテル® 286プロセッサ以降の)その他のすべての
IA-32プロセッサは、シフトカウントを5ビットにマスクするので、最大カウントは31になります。このマスク設定は
(仮想8086モードを含め)全ての動作モードで行われ、命令の最大実行時間を減らしています
386になってから、多ビットシフトのハードウェアが導入されて、
ようやくシフトが"軽い"命令になったわけ。
で、たしか、386からだと思うけど、clレジスタに32以上の数値を指定しても、
下位ビットだけがマスクされて、実際には31ビット以下のシフトしか
行われないようになったわけ。