Preprocessor - Macros (Assembler)
Standard (no parameter validation)
Declaration
- Macro Identifier
- (Assembler code/Macro calls)
- EndMacro
Parameter using in the macro
- @0 = Parameter1
- @1 = Parameter2
- [..]
Example (Standard)
This declares a macro with 4 parameters.
.macro Add16 add @0,@2 adc @1,@3 .endmacro
Call in the assembler source:
Add16 ZL,ZH,_HA0,_HA1
Extended (validated, named parameters)
When using a parameter naming in a macro, the number of parameters to the call is compared and an error message when difference.
Declaration
- Macro Identifier[(parameter1, parameter2, ..)]
- (Assembler code/Macro calls)
- EndMacro
Parameter using in the macro
- @parameter1 = Parameter1
- @parameter2 = Parameter2
- [..]
Example (Extended)
This declares a macro with 4 parameters.
.macro Add16(dReg0,dReg1,sReg0,sReg1) add @dReg0,@sReg0 adc @dReg1,@sReg1 .endmacro
Call in the assembler source:
Add16(ZL,ZH,_HA0,_HA1) ;with or without brackets