I have an assembler program consisting of several partial programs.
I know that labels have to be declared as "global" so that other partial programs can see them:
label: LDR R0,[R1]
can only be seen by the same partial program
but
.global label
label: LDR R0,[R1]
can be seen by all the partial programs.
I can't seem to get the same thing to work for constants:
.equ v_charge,2400
sets the constant v_charge to 2400.
If I put it in its own file and .include the file in all the partial programs that need it, then it works, but as a line of code in a partial program it is only available to its local program
I would expect that .global v_charge would make it available to the other partial programs, but it doesn't.
What is the correct syntax?
The standard way of doing this is to place them in an (assembler) include file, and include that file into each assembler file where it is needed.
use
.include “file.h”
That seems to work apart from one thing:
If ever you edit "file.h" the new version only takes effect in the sub-programs that have recently been edited. If the program is complied with some sub-programs the same as the previous compilation, then those sub-programs retain the old version of file.h.
That's annoying!
Thanks Alexis and Con Verse. I tried a few options and the include file is the only thing I could get to work.
. . . but (on a point of semantics) I'm never sure whether it should be .h or .inc
I do know that the standard LPCXpresso editor seems to think every line is a syntax error and underlines it in orange, and that's mildly irritating!
Hi Ian,
I analyzed the disassembly view trying to declare a global constant to other files and it looks like the compiler put the value from the constant in the assembly instruction, ignoring the label. I suspect this can't be done.
Best Regards,
Alexis Andalon