registers used for passing parameters and returning

I am writing an application in which I need to mix C and assembly.
I need to write the most optimized code for which I need the answer to the following questions
1) When passing parameters, is there any predetermined method in which the parameters will be passed? Like for eg. param1 will be passed thorugh r6, parameter 2 will be assed thorugh r7 etc?
2) When returning from a function is there any standard fixed way of returning like , say the return value is always in register r7 ?

If these things are predetermined then I can do a lot of speed optimizations in my code

Will appreciate if you could help.

Thank you.
Regards
Gaurav

Parents
  • To add to the list of questions
    I am not able to find the link between registers and C variables when mixing C and assembly.
    For example if I want to mov the value in a register to a variable
    and say I have declared the variable like
    void func()
    { char c;
    #pragma asm call assemblyfunc
    ;Now I want to move the value in register r7 to the ;variable c
    ;I wud do mov variable_c_allocation_name, r7
    }

    Now the question is what will be variable_c_allocation_name?

    Is there any standard naming convetion that keil compiler uses.
    I see that variable c would be named something like
    c?040 or or c?141 etc.
    What does the numbers 0, 4, 0, stand for?

    Regards,
    Gaurav

Reply
  • To add to the list of questions
    I am not able to find the link between registers and C variables when mixing C and assembly.
    For example if I want to mov the value in a register to a variable
    and say I have declared the variable like
    void func()
    { char c;
    #pragma asm call assemblyfunc
    ;Now I want to move the value in register r7 to the ;variable c
    ;I wud do mov variable_c_allocation_name, r7
    }

    Now the question is what will be variable_c_allocation_name?

    Is there any standard naming convetion that keil compiler uses.
    I see that variable c would be named something like
    c?040 or or c?141 etc.
    What does the numbers 0, 4, 0, stand for?

    Regards,
    Gaurav

Children
No data
More questions in this forum