code optimization in embedded systems

Also other points to consider if you still want to use registers is - Keep as many operands as possible in registers itself to maximise the execution speed of software programs. But, remember to take care of Register Spilling :):)

Register spilling occurs where there are more local variables than number of registers available with the machine . In this scenario, the compiler will be transferring the spilling variables from registers to memory. This causes an access from memory and hence it will be slower in access than register.

Karthik Balaguru

Reply to
karthikbalaguru
Loading thread data ...

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

Reply to
karthikbalaguru

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.