-
Notifications
You must be signed in to change notification settings - Fork 0
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.
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>
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 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>
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
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
...
LALWE - Learn Assembly Languages With Ease by Robin Hänni