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


    Possibly you need to build it using gcc, for example: 'gcc -c foo.S'.

    That's what I used to compile this. All explained in a chapter titled "Preprocessing" in the documentation: http://sourceware.org/binutils/docs-2.21/as/Preprocessing.html#Preprocessing
    It should be added perhaps, that the error handling is less than optimal. Due to GCC/binutils' goal of supporting as many as possible different architectures and ancient assembler dialects it happens that the "#include" directive doesn't trigger an error, which might have made things more obvious.

    There's probably also an option to the assembler to force the preprocessing.

    None that I am aware of.

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


    Possibly you need to build it using gcc, for example: 'gcc -c foo.S'.

    That's what I used to compile this. All explained in a chapter titled "Preprocessing" in the documentation: http://sourceware.org/binutils/docs-2.21/as/Preprocessing.html#Preprocessing
    It should be added perhaps, that the error handling is less than optimal. Due to GCC/binutils' goal of supporting as many as possible different architectures and ancient assembler dialects it happens that the "#include" directive doesn't trigger an error, which might have made things more obvious.

    There's probably also an option to the assembler to force the preprocessing.

    None that I am aware of.

    Regards
    Marcus
Children
No data
More questions in this forum