In message <199711041505.IAA114916@huey.cadvision.com> PICLIST@MITVMA.MIT.EDU writes: > Hello everybody; > > Would someone be kind enough to recommend which C compiler they feel is > best to learn C with. I'm sorry if this question seems like which is best, > but specifically which is best to learn on. I have used assembly for > several years and recently had the opportunity to have coffee with Matt > Bonner, who suggested that C would save me substantial time on some of my > projects. So now I'm preparing to invest in a compiler. > [snips] I recently decided to learn C for PICs, and have been having a look at what are probably the three main C compilers for the PIC: CCS, Bytecraft and HiTech. The CCS compiler is the cheapest at about $100, followed by Bytecraft and then HiTech. The particular architecture of the PIC make for some compromises in the ansi C standard and all three compilers have compromised in different ways. Things I like/dislike about them: o The CCS compiler (re-)uses memory well, based on the calling structure of your code. o Both the Bytecraft and Hitech compilers insert code to switch to register bank 0 when I don't think they need to. This tends to bloat the code. (I understand there is a compl#ile time switch to turn this off though). o The CCS compiler has a whole load of libraries which on the surface seem very useful. eg rs232 transmit and receive, i2c read and write, LCD display. However, I am not fully happy with the code produced. I am always looking at the listing thinking that I would have done that differently, or that there must surely be a quicker way of doing that than that. Also, they are not bug free. I have spent hours this week trying to get the 24c04 library going. I could have written it in assembler in less time and had tighter code. The other compilers may have similar libraries. o The CCS code generator seems less than optimal. For example, the code: byte a, b, c, d; a=b=c=d=0; should get compiled to 4 clrf's. It actually gets compiled to 1 clrf and 3 pairs of movfw, movwfs. Also, the very first instruction saving optimisation I worked out when I first started using PICs: using goto $+1 instead of two NOPs isn't implemented in the delay_us() function. So, delay_us(4) uses 4 nops instead of 2 goto's. (At 4MHz of course). Ok, so I could make my own delay routine to do this, but this appears throughout the libraries and I'd have to change all of them too. (I've just realised how frustrated I am with it). The demo versions of the Bytecraft and HiTech compilers are worth getting hold of as you can generate real code and see how it differs from the assembler you would have written. Both of these seem to produce neat code if you ignore the code bloat mentioned earlier. From where I stand, the CCS compiler would be fine for hobbyists and for non-demanding applications, but for professional use I would suggest that you save you money and go for one of the other two compilers. Regards, Mike Watson