2017-06-09 09:02 AM
I used to hear that one might as well make function parameter ints or the native size as chars and shorts would be promoted before going on the stack.
But now we have fast variables, etc. Does it still make a difference?
Thanks,
jh
2017-06-09 11:44 AM
Well, all these compiler optimisations can be observed in debugger mode assembly window.
For speed, there are many factors to look into such as core pipeline, interrupt vectors in RAM, ISR in RAM, flash wait states, etc...
For reentrancy, I like function passing a struct pointer to try to stick to a single passing parameter as much as possible, and returning a u32 quantity.
2017-06-09 03:53 PM
Check ARM ABI
Basically the first four parameter words pass in registers R0..R3 which are 32-bit, and you can get a 32 or 64-bit result in R0,R1. Additional parameter words will be stacked, local/auto variable will either be on the stack or in registers. If you generate an address-of, then the variable will need to be in memory.
The compiler manages working registers and pushes/preserves R4..Rx, pushes LR if you call any other subroutines.