beautypg.com

8 macro expansion, Macro expansion – Motorola HC12 User Manual

Page 207

background image

Macros

Macro Expansion

MCUez HC12 Assembler

User’s Manual

MOTOROLA

Macros

207

This macro is called in the application:

clear temporary

clear data

The two macro calls of

clear

are expanded this way:

clear temporary

LDX temporary

LDAB #16

_00001LOOP:CLR 0,X

INX

DECB

BNE _00001LOOP

clear data

LDX data

LDAB #16

_00002LOOP:CLR 0,X

INX

DECB

BNE _00002LOOP

9.8 Macro Expansion

When the assembler reads a statement in a source program that calls a
previously defined macro, it processes the call as described here.

The symbol table is searched for the macro name. If it is not in the symbol table,
an undefined symbol error message is issued.

The rest of the line is scanned for arguments. Any argument in the macro call is
saved as a literal or null value in one of the 35 possible parameter fields. When
the number of arguments in the call is less than the number of parameters used
in the macro, the arguments that have not been defined at invocation time are
initialized with ““ (empty string).

Starting with the line following the

MACRO

directive, each line of the macro

body is saved and is associated with the named macro. Each line is retrieved in
turn, with parameter designators replaced by argument strings or
assembler-generated label strings.

Once the macro is expanded, the source lines are evaluated and object code is
produced.