This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to define global absolute constants



Hi,

I need to define global constants that are visible for both .asm and .c files.

I have resolved this using the .set + .global directives:

__NO .set 0

__YES .set 1

.global __NO, __YES

Then, I reference these constants in C:

extern unsigned int _NO;

extern unsigned int _YES;

#define NO ((UINT)(&_NO))

#define YES ((UINT)(&_YES))

This way, I use the constants as if they were defined in C.  I have checed the assembly code generated from the C code, and everything is correct.

 

The only problem is that the compiler shows the following warning each time I assign one of these constants to a 16-bit variable:

warning: integer conversion resulted in truncation

 

I guess this is because the constant is considered to have more than 16 bits.  So, Is there a way to define a constant globally (visible for .asm and .C files) and avoid this warning?

 

Thanks in advance,

  Miguel