GBDKライブラリドキュメント
GBDK libraries documentation |
||
---|---|---|
前
Prev |
2章
ターゲットとしてのGameboy
Chapter 2.The Gameboy as a Target |
次
Next |
lccは、式中のいかなる引数も不必要な促進を引き起こすことができるデフォルトで符号付きであると仮定します。
促進はオペレーションの結果がオーバフローするとコンパイラが信じる場所です。したがって、それは、サイズの上の変数を促進し、オペレーションを実行し、次に、適切なサイズにそれを降格します。
例えば次の中で:
lcc assumes that any parameters in an expression are signed by default which can cause unnecessary promotion.Promotion is where the compiler believes that the result of an operation will overflow and so it promotes the variable up a size, performs the operation and then demotes it back to the proper size.For example in:
UBYTE i, j = 0; i = j+0x80;コンパイラは、引数が符号付きであると仮定します。また、0x80が最も大きな8ビットの有符号数字0x7fより大きなとともに、それは16ビットまで促進されます。 オペレーションはそのとき実行されます、結果、切り詰められた。
これは、引数が引きずるUを加えることにより符号なしであるとコンパイラに明示的に伝えることによって解決できます。
上記のコードのよりよいバージョンは:
This can be solved by explicitly telling the compiler that the argument is unsigned by adding a trailing U.A better version of the above code is:
UBYTE i, j = 0; i = j+0x80U;
関数中のオペレーションの順序の変更はさらに促進を止めるかもしれません。
??why
Changing the order of operations in a function can also stop promotion.??why??
前
Prev |
ホーム
Home |
次
Next |
変数のサイズ
Size of variables |
上
Up |
グローバル変数の使用
Using global variables |