Use the string operator # to convert tokens to strings. However, since the gating operator can only be applied to macro parameters, you need to add additional macro layers:
#define PRE 0xF1 #define SR0 0B0000 #define SR1 0B0001 #define SR2 0B0010 #define SR3 0B0011 #define VIOTA(A0) VIOTA_HELPER1(PRE, A0) #define VIOTA_HELPER1(PRE, A0) VIOTA_HELPER2(PRE, A0) #define VIOTA_HELPER2(PRE, A0) asm(".byte" #PRE ", " #A0) int main(void) { VIOTA(SR1); return 0; }
After pre-processing, this expands to this:
int main(void) { asm(".byte " "0xF1" ", " "0B0001"); return 0; }
String constants are concatenated at compile time, so this is equivalent to asm(".byte 0xF1, 0B0001"); .
source share