I ADuCM360, how can I jump to a function in C?
Let’s assume you organise that your function is placed at 0x4000, you want C code that will generate assembly code that will do an indirect jump to 0x4000.
Indirect jumps on the Cortex architecture require the bit zero to be set to 0x1 – selecting thumb mode (other ARMs support ARM and thumb mode).
Let’s assume that the function you want to call looks like this.
int MyFunc(unsigned char A,unsigned long B,unsigned long C)
return A + B + C;
You can create a function pointer type like this.
typedef int (*pfRdCallBack) (unsigned char ,unsigned long,unsigned long);
Create a variable of this type and assign it the appropriate address.
pfRdCallBack pFunc1 = (pfRdCallBack)0x4001;
pfRdCallBack pFunc2 = MyFunc;
and call it like this.
iTest1 = pFunc1(1,2,3);
iTest2 = pFunc2(1,2,3);
Please provide more details on what you mean.
Now I want do something like this:
if( Condition is true)
Jump to FunctionA;
Jump to FunctionB;
I need jump to a section if the condition is true.
I read that in IAR, I can use #pragma section to put a function in a section but how can I jump to it?
I must be missing something ; why can't you just call the function as you would normally ?
Because I want to set this function in a specified location so later both bootloader and main application code can jump to this section and run this section.
Thank you. Now in the linker map, I found the function is located in address 0x00000801. Do I still need to add 0x01 to it or I can jump to it directly.
pfRdCallBack pFunc1 = (pfRdCallBack)0x00000801;
You can call it directly with that value.
Retrieving data ...