This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

locating arguments

Hello,


I would like to know how the keil compiler locate the arguments of a function.

1) it pass it via the stack?
2) it declares a places in the memory space, and in this case how he choose the memory space that it will use?


Thank You
Kaoru

Parents
  • I understand but i want to be sure that from a compilation to another, we will have exactly the same type of passing parameter.
    that he will not put it to the xdata because he need R7 (the register that is used rigth now) or that he will change the register.

    Do you have an idea to solve my problem?

Reply
  • I understand but i want to be sure that from a compilation to another, we will have exactly the same type of passing parameter.
    that he will not put it to the xdata because he need R7 (the register that is used rigth now) or that he will change the register.

    Do you have an idea to solve my problem?

Children
  • The NOREGPARMS compiler directive disables parameter passing in registers.

    However, it doesn't disable the use of registers.

    Not using registers would be silly.

    Jon

  • "i want to be sure that from a compilation to another, we will have exactly the same type of passing parameter."

    Of course it will!
    The compiler has to stick to its own calling convention (that's why it's called a "convention"), otherwise it would never know how to handle a given function call!

    The calling convention is described in the Manual

  • I have 4 function of the type

    void funct(unsigned char)

    three of them are not optimized and the compiler put the parameters in the external memory. And only one of them is optimized by passing parameter in the register.
    For the three first functions, at the compilation, it will change the place of the parameter.
    Am i correct?
    Is there a mean to locate the parameter somewhere in the xdata?

    As those four functions are a part of a same level. i want them to be similar in the way of passing parameters. Like this i will have the same technology use for a same level.

    Do you think it is possible to do that by passing parameters in those functions?

    thank you
    Kaoru

  • Are some of them "leaf" functions, and some not?

  • Use NOREGPARMS and the compiler puts ALL ARGUMENTS IN MEMORY and NONE IN REGISTERS.

    Jon

  • I am sorry I don't understand what is "leaf"...
    The only difference between the function is the moment that i use the parameter. In the function that is compiled by passing parameter in the register, the variable is used just after the declarations. But for the other the variable is used in the middle of the function.

    the NOREGPARAMS is a good idea but as i want that the compilation is always the same, i have to locate those arguments. Can you tell me if it is possible? I tried to do it without success.

    Thank you
    Kaoru

  • i have to locate those arguments. Can you tell me if it is possible?

    If I understand you, you want to locate the arguments to several functions to the same address. For example:

    int func_a (int arg_a, int arg_b, int arg_c);
    int func_b (int arg_a, int arg_b, int arg_c);
    int func_c (int arg_a, int arg_b, int arg_c);
    

    func_a, func_b, and func_c should all have their arguments stored at the same address x.

    If that's the case, there is no way to automatically do that with the compiler.

    You can, however, do it manually with little or no overhead. Simply declare global variables that represent the function arguments. For example:

    int arg_a, arg_b, arg_c;
    
    int func_a (void);
    int func_b (void);
    int func_c (void);
    

    Then, you can "load" the arguments externally and you can access the arguments inside func_a, func_b, and func_c.

    Jon