Functions - hlorenzi/customasm GitHub Wiki
Declaring functions with #fn
From v0.11.14 onwards
Functions can be called from any
expression context with simple syntax. This is different from
#ruledef rules, which need to be wrapped into an asm block
in order to be resolved. Furthermore, functions currently only
receive untyped values, and can't take token arguments.
The syntax for declaring functions is:
#fn name(param1, param2, param3) => expression
As usual, you may expand the expression part into a block,
and the last expression in the block is automatically returned:
#fn name(param1, param2, param3) =>
{
expressions
}
For example, the following code will output 0x01:
#fn add1(value) => value + 1
#d8 add1(0)