How can you compare C and Assembly? All you can do is compare a certain C compiler (and\or programmer) with a certain Assembly compiler (and\or programmer). It all depends on situation. The compiler(\programmer) and project would have more influence than the language in most cases. If you're doing DSP and you use a good C compiler with highly optimised assembly DSP routines then it could easily be faster than your code cause someone spent a lot of time writing good asm routines and they knew the architecture and the problem better than you. In general you CAN optimise assembly more than C in all cases but are you better at optimising assembly than the people who wrote the C compiler? Tom. -----Original Message----- From: Quitt, Walter [mailto:wquitt@MICROJOIN.COM] Sent: Thursday, April 13, 2000 10:05 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: Question: C vs Asm Wait till you fill (max) your part up (out)! Trying to minimize implemented and working code is not simple. One project is at 14K lines of ASM code (14 KLOCs) in a 16K part. I even moved some constant overlay tables and LCD screens to serial EEPROM. YES, for programming in the SMALL or simple stuff, C is GREAT. But real-time, speed critical stuff is real hard to do well in C. Sorry, that's MHO after years of doing real-time code and now for the last 2+ years almost full time on PICs. BTW: Using the BANKSEL and PAGESEL directives allows you to write (basically) totally relocatable (modular/reusable) code pieces in MPASM. So you can have C drivers calling the ASM fast/tight ASM routines. There's something to be gained there, I think. Therefore, almost no worries about those pesky banks. Also, from a maintenance standpoint poorly written or documented C can be just as hard (or easy) to work with as similar ASM. Been there and certainly done that! BTW: I do both C and ASM. "It is left as an exercise for the reader to determine which I like more!" Hint: I don't even know, I just like to see the moving machines and blinking lights...... Walt... -----Original Message----- From: Erik Reikes [mailto:ereikes@XSILOGY.COM] Sent: Wednesday, April 12, 2000 4:47 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: Question: C vs Asm In the PIC projects I write I use C almost exclusively. The reason for this for me is ease of code reuse, ease of readability, and its just plain old easier to write in. I never have to worry about code page bits, ram bank bits, local variables, etc. etc. Also, I have ported a number of complicated functions written for other platforms quite easily to the PIC. The detriments are slightly larger code size which I mitigate by being careful about how and what C statements I use and when. Now for the PIC, a C compiler really just ends up being a really excellent Macro Assembler, but the benefits are huge. I wouldn't recommend to anyone starting out to start writing programs exclusively in ASM. Its very important to know the PIC ASM commands, but that is primarily just for verification when something doesn't work right, and when occasionally you must write something very time intensive. My estimates for the medium sized project that I am working on currently that C is costing me about 25% of my code space. A lot of this is due to sheer laziness because we have a ton of extra space currently. The gain in time spent implementing and debugging, however, is well over 90%. As in I believe it would take 10x as long to develop and debug this program in straight assembler. YMMV Erik Reikes Senior Software Engineer Xsilogy, Inc. ereikes@xsilogy.com ph : (858) 535-5113 fax : (858) 535-5163 cell : (858) 663-1206