This question already has an answer here:
- How to use a global variable in gcc inline assembly 3 answers
I'm trying to compile following asm code inside a C++ file, but it like GCC can't find the variables used in the asm part.
DWORD d_eaxSave, d_ebxSave, d_ecxSave, d_edxSave, d_esiSave, d_ediSave, d_espSave, d_ebpSave;
#define ASM_UNPREFIXED_INTEL_START ".intel_syntax noprefix\n\t"
#define SAVE_REGISTERS() __asm__ (ASM_UNPREFIXED_INTEL_START \
"mov d_eaxSave, eax\n\t" \
"mov d_ebxSave, ebx\n\t" \
"mov d_ecxSave, ecx\n\t" \
"mov d_edxSave, edx\n\t" \
"mov d_esiSave, esi\n\t" \
"mov d_ediSave, edi\n\t" \
"mov d_espSave, esp\n\t" \
"mov d_ebpSave, ebp");
But when I try to compile, GCC gives me the following errors :
undefined reference to `d_eaxSave'
undefined reference to `d_ebxSave'
undefined reference to `d_ecxSave'
undefined reference to `d_edxSave'
undefined reference to `d_esiSave'
undefined reference to `d_ediSave'
undefined reference to `d_espSave'
undefined reference to `d_ebpSave'
What can I do to get rid of those erros, please ?