开发者

I need to call the functions by directly by giving function base address to PC with parameters......how?

开发者 https://www.devze.com 2023-02-26 09:18 出处:网络
void fun1(int x) { display(x); display(x+1); display(2*x); } void fun2(int x) { display(x*3); display(x+3); display(x-1);
    void fun1(int x)
{
    display(x);
    display(x+1);
    display(2*x);
}

void fun2(int x)
{
    display(x*3);
    display(x+3);
    display(x-1);
}
void fun3(int x)
{
    display(开发者_如何学Cx+2);
    display(x+5);
}
.
.
.
.
function_ptr[]={fun1,fun2,fun3,.......fun20};
int st=0;// to indicate the function count
int main()
{
    GLCD_init(); 

   //comment here


}

comment is as

after GLCD initialisation i have to call above functions.So, now my problem is...take a condition..if st=3 then i have to execute fun2,fun3,fun4,fun5 ..with condition statements i can..but with the help of st value i have call those functions directly..for that i am using assembly language so that we can give our function address to PC directly...here i am facing a problem with passing parameters..once we made a call to function by giving the base address of that perticular function to PC...how can i pass the parameters to those functions with along with the direct call...


This depends completely on your system: some system pass the parameters register only, some in stack, some mix (e.g. only small or first values in regs).

See as reference Arm Procedure Call Standard

If you are unsure how your system handle it, just dissassemble a procedure call to one of your functions, to see how it is done.

0

精彩评论

暂无评论...
验证码 换一张
取 消