Keil Logo

C166: USING MACROS WITH IN-LINE ASSEMBLY


Information in this article applies to:

  • C166 Version 5

QUESTION

I have defined the following macro that should generate an ATOMIC instruction that will block interrupts for n instructions.

#define DisableIRQ(n) __asm { atomic #n }

However, the macro does not work. The pound character ('#') is the stringize macro operator which converts n into a string. Is there a way to avoid this?

ANSWER

Yes. Put n inside parentheses. For example:

#define DisableIRQ(n) __asm { atomic #(n) }

The parentheses prevent string conversion.

MORE INFORMATION

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.