11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

HI-TECH C Assembly LanguageMacro Assemblermacro is used, the macro name should be used in the same manner as a machine opcode, followedby a list of arguments to be substituted for the formal parameters.For example:;macro: storem;args: arg1 - the NAME of the source variable; arg2 - the literal value to load;descr: Loads two registers with the value in the variable:ldtwo MACRO arg1,arg2mov #&arg2, w0mov w0,&arg1ENDMWhen used, this macro will expand to the 2 instructions in the body of the macro, with the formalparameters substituted by the arguments. Thus:expands to:storem tempvar,2mov #2,w0mov w0,tempvarA point to note in the above example: the & character is used to permit the concatenation of macroparameters with other text, but is removed in the actual expansion.A comment may be suppressed within the expansion of a macro (thus saving space in the macrostorage) by opening the comment with a double semicolon, ;;.When invoking a macro, the argument list must be comma-separated. If it is desired to include acomma (or other delimiter such as a space) in an argument then angle brackets < and > may be usedto quote the argument. In addition the exclamation mark, ! may be used to quote a single character.The character immediately following the exclamation mark will be passed into the macro argumenteven if it is normally a comment indicator.If an argument is preceded by a percent sign %, that argument will be evaluated as an expressionand passed as a decimal number, rather than as a string. This is useful if evaluation of the argumentinside the macro body would yield a different result.The nul operator may be used within a macro to test a macro argument, for example:82IF nul arg3 ; argument was not supplied....ELSE; argument was supplied...ENDIF

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

Saved successfully!

Ooh no, something went wrong!