Skip to content
Robin Hänni edited this page Jun 25, 2017 · 3 revisions

LALWE macros

Macros look exactly like any other instruction. However, they are treated differently by the assembler. Instead of being translated to an OP-Code, they give the assembler information about the following code or instruct it to do something special. The following list contains all the macros available in LALWE.

Define

The "define" macro defines an identifier for a variable. If it is used in the main program space, the identifier is considered global and if it is used inside a function definition, the identifier is considered local and therefore only valid in the scope of the function.
Syntax: define <identifier>

Label

The colon (:) is used to define a label. labels refer to the address of the instruction after their definition and are internally treated like an absolute value (= the address of the instruction) when used in the code. Usually, labels are used in conjunction with a jump instruction, however, they may be used with any other mnemonic that demands an argument too.
Syntax: :<identifier>

Function and endfunction

The two macros "function" and "endfunction" are used together to define a subroutine. Every instruction between the two macros is in the scope of the function (i.e. can access local variables and parameters). Be sure to include a "ret" instruction to return from the function, otherwise the processor will just continue to execute whatever lies after the function in RAM.
Syntax:

function <identifier:functionname> [<identifier:parameter1>[ <identifier:parameter2>[ ...]]]
...
endfunction

Entrypoint

The entrypoint macro is a convenience macro and enables you to specify the instruction following the macro to be the first executed. You could alternatively achieve this by putting a "jmp" right at the beginning of your program.
Syntax:

entrypoint
...

See also...

Identifier syntax

Clone this wiki locally