| Datenblatt-Suchmaschine für elektronische Bauteile |
|
AN3350 Datenblatt(PDF) 67 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN3350 Datenblatt(HTML) 67 Page - STMicroelectronics |
|
67 / 185 page ![]() AN3350 Working with the assembler Doc ID 018512 Rev 2 67/185 Operators, however, may require a specific kind or number of tokens as operands. Operations experiencing bad input will either evaluate to the zero token (the %str(X) operation tests its argument as a single-string token) or will create an error (the #include directive expects its argument to be a single string). 10.5.1 Preprocessor macros Macros, regular and multi-lined, enable the definition and use of named segments of text. A macro invocation is also named 'a call'. It is necessary to define macros in the code prior to invocation. Code expansion is done during the call (and not while preprocessing the definition). 10.5.2 Regular (single-line) macros A single-line macro is defined on a single line of code using the #define directive: #define macroName[optionalArgs] definition ● macroName is a case-sensitive, valid identifier. ● optionalArgs is an optional comma-separated list of unique identifiers enclosed by parentheses. When a macro has arguments, parentheses must immediately follow the name - no white space is allowed. ● definition is an arbitrary combination of tokens intended to replace the call. For example: #define START_OF_FUNC 0x1b3f This example defines START_OF_FUNC as a macro with no arguments. The assembler replaces the identifier START_OF_FUNC with the number 0x1b3f wherever the identifier appears in the code. To substitute the value of an argument within a definition, the argument's name must be placed in the substituting code. For example: #define param(offset,word_size) offset + 4 * word_size This example code replaces the call param(MY_START, 11) with MY_START + 4 * 11. Note: The token sequence 4 * 11 does not evaluate to 44 at compile time. To evaluate an expression at compile time, use %eval: expression evaluation. Note: If you define macros with numerical calculations, we recommend that you enclose each argument occurrence (or even the entire definition) with parentheses. Doing so prevents unwanted side effects during evaluation. For instance, the previous example definition would be better defined as: #define param(offset,word_size) ((offset) + 4 * (word_size)) It is possible to nest macros by defining them inside of other macros. Macro expansion normally occurs during invocation and not during compilation (you can use the #xdefine directive to expand macros during compilation instead). For example, in the following two lines, the assembler expands the BBB macro to 100 + 200 regardless of the order of definition. #define AAA 100 #define BBB AAA + 200 |
|
Link URL |
| War ALLDATASHEET hilfreich? [ DONATE ] |
Über Alldatasheet | Werbung | Kontakt | Privatsphäre und Datenschutz | Link zum Datenblatt | Linktausch | Hersteller All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |