全ての式は、(下位)32bit precisionで評価されます。
式は、数値と、どんな内部・外部のシンボルのcombinationを含むことができます。
Expressions that cannot be evaluated at assembly time are stored inside the object file for evaluation by the linker.
Expressions referencing imported symbols must always be evaluated by the linker.
多くの場合、アランブラは式の結果の値のサイズについて知らなければならない。
これは普通のケースで、解決が得られる為に、絶対メモリかゼロページへの参照を生成しなければならない。
この場合、アセンブラーは式の結果についていくらかの仮定を作ります。:
注意:
もし、アセンブリ時にアセンブラが式を評価できない場合、
リンカーが評価し、結果がわかるとすぐにレンジエラーをチェックします。
ブール式のコンテクストでは、0でないどんな数値もtrueとし、それ以外の数値はfalseとします。
ブール式の結果は、真(true)の場合1, 偽(false)の場合は0となります。
ヴァージョン2.x(x > 0)ではブール演算の優先度は最下位です。
.AND
と.OR
演算子は、ショートカット演算子です。
これは、もし式の結果が知れている場合、左方の評価後、右方は評価されません。
Sometimes an expression must evaluate to a constant without looking at any further input.
One such example is the .IF
command that decides if parts of the code are assembled or not.
An expression used in the .IF
command cannot reference a symbol defined later,
because the decision about the .IF
must be made at the point when it is read.
If the expression used in such a context contains only constant numerical values, there is no problem.
When unresolvable symbols are involved it may get harder for the assembler to determine if the expression is actually constant,
and it is even possible to create expressions that aren't recognized as constant.
Simplifying the expressions will often help.
In cases where the result of the expression is not needed immediately, the assembler will delay evaluation until all input is read, at which point all symbols are known. So using arbitrary complex constant expressions is no problem in most cases.
Operator | Description | Precedence |
Built-in string functions | 0 | |
Built-in pseudo-variables | 1 | |
Built-in pseudo-functions | 1 | |
+ | Unary 正 | 1 |
- | Unary 負 | 1 |
~ .BITNOT | Unary ビット単位の否定 | 1 |
< .LOBYTE | Unary 下位バイト 演算子 | 1 |
> .HIBYTE | Unary 上位バイト 演算子 | 1 |
^ .BANKBYTE | Unary バンクバイト 演算子 | 1 |
* | 乗算 | 2 |
/ | 除算 | 2 |
.MOD | 余剰演算子 | 2 |
& .BITAND | ビット単位の論理積 | 2 |
^ .BITXOR | ビット単位の排他的論理輪 | 2 |
<< .SHL | 右シフト演算子 | 2 |
>> .SHR | 左シフト演算子 | 2 |
+ | 加算 | 3 |
- | 減算 | 3 |
| .BITOR | ビット単位の論理輪 | 3 |
= | 比較演算子 (equal) | 4 |
<> | 比較演算子 (not equal) | 4 |
< | 比較演算子 (小なり) | 4 |
> | 比較演算子 (大なり) | 4 |
<= | 比較演算子 (小なりイコール) | 4 |
>= | 比較演算子 (大なりイコール) | 4 |
&& .AND | 論理積 | 5 |
.XOR | 排他的論理輪 | 5 |
|| .OR | 論理和 | 6 |
! .NOT | 否定 | 7 |
To force a specific order of evaluation, parentheses may be used, as usual.