13.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Assembly Language3.10. Macro OperationsMacros provide a shorthand method <strong>for</strong> inserting a repeated pattern of code or group of instructions.Youcan define the pattern as a macro, and then call the macro at the points in the program where the patternwould repeat.Some patterns contain variable entries which change <strong>for</strong> each repetition of the pattern. Others are subjectto conditional assembly.When a macro is called, the assembler executes the macro and replaces the call by the resulting in-linesource statements. 'In-line' means that all replacements act as if they are on the same line as the macrocall. The generated statements may contain substitutable arguments. The statements produced by amacro can be any processor instruction, almost any assembler directive, or any previously-defined macro.Source statements resulting from a macro call are subject to the same conditions and restrictions as anyother statements.Macros can be nested. The assembler processes nested macros when the outer macro is expanded.3.10.1. Defining a MacroThe first step in using a macro is to define it.The definition of a macro consists of three parts:• Header, which assigns a name to the macro and defines the arguments (.MACRO directive).• Body, which contains the code or instructions to be inserted when the macro is called.• Terminator, which indicates the end of the macro definition (.ENDM directive).A macro definition takes the following <strong>for</strong>m:macro_name .MACRO [argument[,argument]...]...macro_definition_statements....ENDMFor more in<strong>for</strong>mation on the definition see the description of the .MACRO directive.3.10.2. Calling a MacroTo invoke a macro, construct a source statement with the following <strong>for</strong>mat:[label] macro_name [argument[,argument]...] [; comment]where,labelmacro_nameAn optional label that corresponds to the value of the location counterat the start of the macro expansion.The name of the macro. This may not start in the first column.137

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!