Integer and Boolean expressions


An expression can be composed of many things. Expressions are always evaluated using signed 32-bit math.

The most basic expression is just a single number.


Numeric Formats

xAsm has a number of numeric formats.

The last one, Gameboy graphics, is quite interesting and useful. The values are actually pixel values and it converts the "chunky" data to "planar" data as used in the Gameboy.

DW   `01012323
Admittedly an expression with just a single number is quite boring. To spice things up a bit there's a few operators you can use to perform calculations between numbers.


Operators

A great number of operators you can use in expressions are available (listed in order of precedence):
Operators
Operator Meaning
( ) Precedence override
FUNC() Functioncall
~ + - Unary not/plus/minus
* / % Multiply/divide/modulo
<< >> Shift left/right
& | ^ Binary and/or/xor
+ - Add/subtract
!= == <= >= < > Boolean comparison
&& || Boolean and/or
! Unary Boolean not

The result of the boolean operators is zero if when FALSE and non-zero when TRUE. Thus it is legal to use an integer as the condition for IF blocks. You can use symbols instead of numbers in your expression if you wish.

An expression is said to be constant when it doesn't change its value during linking. This basically means that you can't use labels in those expressions. The instructions in the macro-language all require expressions that are constant

See also:



Last updated 21 June 1997 by Carsten Sorensen