code optimization in embedded systems

Nov 15, 2007 121 Replies

While using C functions, Take care while passing parameters to functions with more arguments. Passing parameters is an interesting part of optimisation. If the function has more number of arguments, then both the caller and callee have to access and use the stack for some arguments. The compiler can pass all the arguments in registers if the functions are with 4 / less arguments. (Dependent on the architecture). But, if more than 4 / supported set of arguments (w.r.t register w.r.t that particular architecture) then that will decrease the speed(increase the operation time). In that case, you have to opt for passing using structures. Pass a structure pointer instead of passing large number of arguments.

Karthik Balaguru

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required