-
-
Notifications
You must be signed in to change notification settings - Fork 57
Functions
Lorenzi edited this page Jan 22, 2022
·
3 revisions
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)
- Getting started
- Defining mnemonics β #ruledef, #subruledef
- Declaring labels and constants
- Setting the minimum addressable unit β #bits
- Outputting data blocks β #d
- Working with banks β #bankdef, #bank
- Address manipulation directives β #addr, #align, #res
- Splitting your code into multiple files β #include, #once
- Advanced mnemonics, cascading, and deferred resolution β assert()
- Available expression operators and functions β incbin(), incbinstr(), inchexstr()
- Functions β #fn
- Conditional Compilation β #if, #elif, #else