Chapter 11 Writing Macro Control Statements

Usage example

A source file is shown below. The macro add_adr has one dummy parameter. The dummy parameter is used as the operand of an add machine language instruction within the macro body. Take note whether a macro name is the same as a machine language instruction.

The macro is called with var1 and var2 as parameters.

var1

equ

0x10

var2

equ

var1+2

add_adr

macro

adr

 

add

adr, A0

 

endm

 

_CODE

section

CODE, PUBLIC, 2

main

add_adr

var1

 

 

add_adr

var2

 

end

 

Reference:

By adding the Lm option when the assembler is started, you can suppress the output of mnemonics of macros expanded by the assembler.

210 Macro Calls and Expansion

Page 222
Image 222
Panasonic MN1030 user manual Var1 Equ 0x10 Var2 Var1+2 Addadr Macro Adr Adr, A0 Endm