The PICs I am working on have limited (1Mhz to 4Mhz clock) cycles, and I am wondering if C is going to waste a substantial amount of time executing. Has anyone ever had experience with both and could share some thoughts on the comparison?
C
The PICs I am working on have limited (1Mhz to 4Mhz clock) cycles, and I am wondering if C is going to waste a substantial amount of time executing. Has anyone ever had experience with both and could share some thoughts on the comparison?
C
You can't put numbers on it easily but well tuned assembler will usually outperform C for speed or code size or even both. However you should remmeber that the algorithm is often much more significant - for example a ripple sort in assembler will be nowhere near as fast as a quick sort in C.
C outperforms assembler (in my experience at least 10:1) in terms of time to write/test/sign off code.
Your best bet is almost always to write the application in C and use assembler for the bits you need to improve (this can be less true with very limited processors like the the original architecture 8 bit PICs).
You do not need to write your own maths routines in assembler unless you want - a million people have doen it already:
http://www.piclist.com/techref/microchip/math/div/index.htm
(just one example - there are many).
You can't put numbers on it easily but well tuned assembler will usually outperform C for speed or code size or even both. However you should remmeber that the algorithm is often much more significant - for example a ripple sort in assembler will be nowhere near as fast as a quick sort in C.
C outperforms assembler (in my experience at least 10:1) in terms of time to write/test/sign off code.
Your best bet is almost always to write the application in C and use assembler for the bits you need to improve (this can be less true with very limited processors like the the original architecture 8 bit PICs).
You do not need to write your own maths routines in assembler unless you want - a million people have doen it already:
http://www.piclist.com/techref/microchip/math/div/index.htm
(just one example - there are many).
Thanks Michael. Based on your post I'm going to try the C approach on my next few programs.
I'd love to see an actual comparison of clock cycles used in programs doing the same function in both C and assembly.
In fact, I will program my next routine in both, and post my results.
Cabe