Is it possible to get the value of a #defined integer symbol to be inserted verbatim into a string literal that is part of an assembly section in GCC (AVR Studio)?
I want the "LEDS" to be replaced by 48 within the string literal inside the asm() block below.
#define LEDS 48 //I only want ONE mention of this number in the source
int x = LEDS; //I'm using the value directly too
void DrawFrame()
{
asm(
"ldi R27, 0x00 \n\t"
"ldi R26, 0x00 \n\t"
"ldi R18, LEDS \n\t" //<-- substitution needed here
...
}
But I want the compiler/assembler (after the preprocessor has done it's job) to see this...
#define LEDS 48 //I only want ONE mention of this number in the source
int x = LEDS; //I'm using the value directly too
void DrawFrame()
{
asm(
"ldi R27, 0x00 \n\t"
"ldi R26, 0x00 \n\t"
"ldi R18, 48 \n\t" //<-- substitution needed here
...
}
So far I have tried all the macro tricks I can think of (#stringification, arg substitution and even #including files with various combinations of values and double quotes and whatnot).
I'm not at all familiar with the magic of inlining AVR assembly code into AVR Studio's GCC compiler.
I'm trying to avoid having multiple occurrences of the "48" literal in my source, if the preprocessor can perform this substitution for me that would be great.
Edit: This is for a microcontroller firmware project - and just to make life interesting, there is almost no spare room for new code to be added.