constants in assembler

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

constants in assembler

1,160 次查看
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.

标签 (1)
0 项奖励
回复
4 回复数

1,067 次查看
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 项奖励
回复

1,067 次查看
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 项奖励
回复

1,067 次查看
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 项奖励
回复

1,067 次查看
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 项奖励
回复