Quote:
|
Originally Posted by KenWittlief
actaully, the SW we are creating for these machines is realtime embedded code
remember that the C compiler will convert your code into assembly code, and from that into machine code
breaking your code up into many little functions makes it look nice, but it actually takes longer for it to run, and takes up more code space, because the function calls are actully jumps in assembly code
its shorter and faster to have sequential code all in one routine that simply falls through to the next statement.
not that we really have to be concerned with optimizing our code for size or speed.
well wait, I have seen some people posting that they have used up all the available code space this year - so maybe some of us got a little carried away with the functions :^)
|
On processors without big pipelines (x86, etc have big pipes, especially Intels), function calls are relatively cheap, especially for FIRST robots. The big thing you have to watch out for is stack space, as the PIC can only natively handle 16 nested function calls. There are ways around this limit (like writing your own stack handler), but they tend to be messy and ridiculously hard to debug in addition to being a pain in the neck to write if you've never done it before. Anyways, just be careful that you don't have calls 16-levels deep and everything should be just fine.