ARM Technical Support Knowledge Articles

USING MACROS WITH IN-LINE ASSEMBLY

Applies to: C166 C Compiler

Answer


Information in this article applies to:


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

Article last edited on: 2005-07-15 09:36:04

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential