Reputation: 2251
code as following:
\#define CS 0x18
asm ("pushl CS"
);
or something as an input argument:
asm("pushl %0 \n\t"
:"m"(CS) \
)
can the macro CS be used in the above inline asm code?
Upvotes: 0
Views: 3394
Reputation: 173
or build one inside the x86 asm
call macro1 ;from anywhere in asm code
.macro1
do stuff
ret
Upvotes: -1
Reputation: 16441
CS can be used in the second example, not the first.
Macros are substituted before the compiler/assembler work, so they work regardless of C or assembly.
But macros are not expanded in strings, so the first example won't work.
If you want to make the first example work, use stringization:
#define STR1(x) #x
#define STR(x) STR1(x)
asm ("pushl " STR(CS));
This expands STR(CS)
to "0x18"
and concatenates it with "pushl "
.
Upvotes: 2