Preprocessor - Macros (Assembler)

Standard (no parameter validation)

Declaration
Parameter using in the macro

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
Parameter using in the macro

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