We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All,
I have a label, say "XXX" in the startup assembly code.
Later if I want to jump to label "XXX" in the inline assembly by using
__asm{ B XXX }
The ARMCC compile in Keil MDK complains "the label XXX is referred but not defined".
How should I work around this problem? Thanks a lot.
Best regards Teddy
Hi Teddy,
You need to define the label in the same function that it's called from as far as I can tell.
For more information - check the user manual: http://infocenter.arm.com/help/topic/com.arm.doc.dui0472j/DUI0472J_armcc_user_guide.pdf#page=302
Hope this helps,
Joe
Would you not just define as 'extern'?
Dear Joe,
Thanks a lot for your reply!
I am aware of the solution you referred. However, in my case, the problem is that the label, to which the inline assembly code intends to jump to, is not defined within the same function.
Image that you have some startup code written in assembly, which eventually jumps to C code "main". After that in the C code, you would like to jump back to a certain label in the startup code. Right now, I work around by defining a assembly function in the startup code and call this function, then jumps to any label I want. I was just wondering if there is better solution than this sort of "indirect jumping".
Dear Ronan,
I have tried. It seems that declare a label as "extern" is not possible.
My apologies - I see you are using the inline assembler, this is very limited in functionality (and support for this is deprecated).
A better solution is to use the embedded assembler, which works something like (I'm writing this remotely without access to my tools...):
extern void bar(); __asm foo() { BL bar BX LR }
Hi Ronan,
Something in your code I dont clearly understand.
If the function bar is defined in the external assembly code, then your function foo shouldnt be necessary anymore. Because you can simply call bar in the C code.
Yes my example was trivial, just to show how you can reference the symbol. Of course you would add other code to this to do something meaningful.