12.07.2015 Views

MAXQ Core Assembly Guide - Maxim

MAXQ Core Assembly Guide - Maxim

MAXQ Core Assembly Guide - Maxim

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>MAXQ</strong> <strong>Core</strong> <strong>Assembly</strong> <strong>Guide</strong>Defining MacrosMacros are used to repeat frequently-occuring sections of code without the overhead of calling a subroutine. Eachtime a macro is called in a source file, all of the macro code is inserted at that point. Macros are defined using theMACRO directive, with syntax as shown below. MACRO [PARAM] [ [[ ,] ...]][LOCAL [[ ,] ...]ENDMA macro definition consists of the following components.• The macro is the identifier that will be used when calling the macro. It must follow the standardidentifier rules and may not be an identifier which is also used as a label, equate, or define.• The parameter list, which is optional, defines one or more parameters which are passed when the macro iscalled. The values for these parameters are inserted into the body of the macro.• The local identifier list, which is optional, defines one or more local identifiers which can be used as labelswithin the body of the macro. Each time the macro is called, these identifiers take unique values in order toavoid conflicts with identifiers in previous expansions of the macro.• The macro code itself appears after the parameter list (if any) and the local identifier list (if any). Macro codemay contain equates, defines, and nested macro calls, which are all processed normally. However, macrocode may not contain macro definitions. Comments within the macro body are retained each time the macro isexpanded.• Macro definitions must end with the ENDM directive.A Simple Macro ExampleThe simplest form of macro is one which contains no parameters or local identifiers. The following source file,when processed by Macro, expands into the preprocessed file shown below.source filedelay macronopnopnopnopendmdelay; Start of macro definition; Start of macro code; End of macro code; End of macro definition; Call delay macroendMacro output file; BEGIN Macro delaynopnopnopnop; End Macro delay; Start of macro code; End of macro codeendVersion 1.2 38 of 43 March 7, 2007

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

Saved successfully!

Ooh no, something went wrong!