This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C headers in assembly

Note: This was originally posted on 5th April 2011 at http://forums.arm.com

Hello!

I am facing a problem while including a C header in the assembly.

My assembly code is as follows -

#include "header01.h"

.syntax unified
.text
.thumb

/* uint8 mycode_func(void) */
.global mycode_func
.func mycode_func, mycode_func
.type mycode_func, %function
.thumb_func
mycode_func:
mov R0, #MY_CONSTANT
.endfunc

header01.h has -
#define MY_CONSTANT 10

This code gives an error - undefined symbol MY_CONSTANT.

If I change  mov R0, #MY_CONSTANT to  mov R0, 10, it works well.

What do I need to do to get this to work?

Thanks in advance!!
Parents
  • Note: This was originally posted on 5th April 2011 at http://forums.arm.com

    You need to have the assembler run the preprocessor over the input file first.  I think the usual way to get this done by GNU tools is to name the file 'foo.S' instead of 'foo.s'.  Possibly you need to build it using gcc, for example: 'gcc -c foo.S'.  There's probably also an option to the assembler to force the preprocessing.
Reply
  • Note: This was originally posted on 5th April 2011 at http://forums.arm.com

    You need to have the assembler run the preprocessor over the input file first.  I think the usual way to get this done by GNU tools is to name the file 'foo.S' instead of 'foo.s'.  Possibly you need to build it using gcc, for example: 'gcc -c foo.S'.  There's probably also an option to the assembler to force the preprocessing.
Children
No data