EmbDev.net

Forum: ARM programming with GCC/GNU tools asm inside .cpp file


Author: Dustin Sr (dbrazeau)
Posted on:

Rate this post
0 useful
not useful
I have a .cpp file that has some asm in it, e.g. asm(" asm source line
");, and in the "asm source line" I'm trying to use a symbol that is
defined/equ in a .inc file.  When I try to compile the cpp file it says
that the symbol is undefined.  How do I include an asm .inc file when
the asm code is enbedded in a .cpp file.

Thanks
dbrazeau

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Dustin Sr wrote:
> I have a .cpp file that has some asm in it, e.g. asm(" asm source line
> ");, and in the "asm source line" I'm trying to use a symbol that is
> defined/equ in a .inc file.  When I try to compile the cpp file it says
> that the symbol is undefined.  How do I include an asm .inc file when
> the asm code is enbedded in a .cpp file.

This might be a name-mangling/name-decoration issue. But I have not
tested inline-assembler and C++ with the GNU arm-cross-toolchain so far
and at least for me it's difficult to help without a test-example to
reproduce the issue. Please create a minimal but complete example
(source, linker-script, makefile) and attach it to a message to this
forum. Maybe just an extern "c" for the "symbol" will do. As a
workaround you can create c-source (not C++) with a functions that
"wraps" the inline-assembler, use extern "c" to include the function and
call it from the C++-function/method. Another workaround would be a
"pure" assembler-function.

Martin Thomas

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.