Expressions & special values
Anywhere a number is expected, FantASM accepts an expression — constants, labels, literals and arithmetic are all evaluated at assembly time.
buffer_end = buffer + SIZE
half = value / 2
flags = A_BIT | B_BITSpecial values
These read the assembler’s current state and can be used inside any expression:
| Value | Meaning |
|---|---|
$, asmpc | The current program counter. |
codesize | The current assembly address relative to the start. |
bank | The current memory bank number. |
page | The current memory page number. |
tstates | Accumulated T-state count since the start of assembly. |
here:
jr $ ; jump to self
length = $ - message ; size of the data aboveSizeof
SIZEOF(<label>) returns the size of a structure or an included binary:
sprite: incbin "sprite.bin"
sprite_len = SIZEOF(sprite)Rhai in expressions
FantASM embeds the Rhai scripting engine. The rhai() function evaluates a Rhai expression at assembly time and returns its value, for computation that goes beyond plain arithmetic:
value = rhai("40 * 40 + 7")See Rhai scripting for build logic and custom directives.