How do I use a c header file in an assembly file? When I use: #include "xxx.h" I get the invalid line start error. Please help
What makes you think that you should be able to?
The assembler include a C Preprocessor
http://www.keil.com/support/man/docs/a51/a51_mp_c.htm
Make sure that your .H files don't use any of the exceptions that the assembler can't process
http://www.keil.com/support/man/docs/a51/a51_mp_exceptions.htm
Jon
That's A51 - does it also apply to ARM?
Oops. I've been reading too much.
It applies to the Keil Compilation tools but not to the RealView Compilation tools.
Take a look at this www.arm.com/.../1208.html The question is realview tool set for keil is "real"view?
Take a look at this www.arm.com/.../1208.html But it says it only applies to #include and #define - so you can't just go using any 'C' header willy-nilly in your assembler!
You are right. but it shouldn't generate that error. looks like the assember doesn't understand what # is
Hi Tong, Were you able to do the settings for the include files. I could get results from command prompt but could not find any options in the micro vision environment .
Thanks
Suvidh
"but it shouldn't generate that error."
Why not?
"looks like the assember doesn't understand what # is"
Quite possibly not - it understands what #define is, and what #include is, but nothing else. Therefore, any line that starts with a # that is not followed by "define" or "include" will produce an error - and "invalid line start" sounds like a perfectly good name for that error!
Is it possible that the invalid line start error message may be due to what's in the included file, rather than the fact that you're including a file via #include...?
After all, as others have pointed out, an assembler is supposed to process assembly language code, not C code.
The error is because the ARM RealView Assembler does not understand the #define directive. Look carefully at the documentation quoted above.
You must run this file though the C preprocessor first before trying to assemble the result through the ARM RealView Assembler.
Note that this is two separate steps; The ARM RealView assembler does not have a built-in C preprocessor.
The examples shown in the links show the assembly file being run through the ARM RealView Compiler using the -E switch. This just runs the C preprocessor on the assembler file. The output of the preprocessor is then piped to a resultant file. This resultant file should then be assembled by the ARM RealView Assembler to generate the final object file.
There does not appear to be an convenient way of doing this easily within the UV3 IDE.
Note that C header file that you include can only contain #defines. Any other C constructs will be included into the resultant file and will cause the assembly stage to fail as it won't understand them.
Hope that helps!
As Patrick Pointed out their seems to be no easy way to precompile assembly files and then assemble the output thorugh uV IDE. The only way I had found till now is running a batch file through uV IDE which will precompile and assemble the files.This is done by putiing on the option of run script before make in the options for target.
uVision works through the files in the Project file list in order.
So you could try something like this:
Put the headers at the top of the list, and define a "Custom Translation" that just pre-processes them to, say, .i files.
Then you also add the .i files, and set them as assembler source files.
Then the rest of your project files, as usual...
Not amazingly convenient, but should work...