constants in assembler

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

constants in assembler

484 Views
ianbenton
Senior Contributor I

I want to define a constant called "mains_on" to be equal to 208, so I write 

.equ mains_on,208 @ mains on at 208 Volts

and MUCXpresso underlines it in orange and tells me it is a syntax error. (It is part of a large table of constants that have their own file)

It does this regardless of whether I put it in a file called .h or .inc, but the resulting file works

If I type

#define mains_on 208 // mains on at 208 Volts

like it would be in C, it no longer tells me that it is a syntax error, but it doesn't work. 

If I put the file in the src directory instead of the inc directory, then it likes neither .equ nor #define, one gives "syntax error" and the other says "no whitespace after macro definition"

.This isn't a major problem, but it is annoying to have every line of my table of constants underlined in orange and labelled as a syntax error - could someone please tell me which format MCUXpresso is happy with, and where it would prefer the file to be stored.

Labels (1)
0 Kudos
4 Replies

391 Views
converse
Senior Contributor V

You need to place assembler in a file with a .s file extension. While the compiler can detect that it is 'compiling' C or assembler, the IDE cannot - it works on file extensions. So, if you have assembler in .c/.h the IDE will try to parse as C and hence you will get the error you are seeing.

0 Kudos

391 Views
BlackNight
NXP Employee
NXP Employee

in addition to that, see Assembly Files in Eclipse CDT Projects | MCU on Eclipse  how this is configured. as Con Verse said: you need to put assembly code into *.s files (keep in mind with above article that this is case sensitive).

I hope this helps,

Erich

0 Kudos

391 Views
ianbenton
Senior Contributor I

Yes, all the assembly is in a .s file, but I have a separate file of constant definitions that upsets the editor (i.e. it if were C it would be the .h file full of #define statements). I would have normally expected it to be called .inc, but the editor doesn't like that. You are correct that it prefers it to be called .s and the editor is happy with that, even with it in the "inc" directory 

0 Kudos

391 Views
converse
Senior Contributor V

The location of the file is irrelevant. You can tell the editor that a .inc file is an assembler file by following the instructions in Erichs post.

0 Kudos