Rhai scripting

FantASM embeds the Rhai scripting engine, so you can run real code at assembly time — for computed data, build logic, and custom directives that go beyond what plain expressions allow.

rhai() in expressions

The rhai() function evaluates a Rhai expression during assembly and returns its value. Use it anywhere an expression is valid:

value   = rhai("40 * 40 + 7")

This is useful for generating tables or deriving constants with logic that would be awkward in assembler arithmetic alone.

The !rhai directive

The !rhai directive runs a Rhai script block as part of assembly, letting you script build steps and define custom behaviour.

!rhai {
    // Rhai runs here at assembly time
}

Note: the scripting surface (available functions, how scripts emit data, and the exact !rhai block syntax) is still being documented. This page will be expanded with the full Rhai API and worked examples.