Nigel Goodwin said:You appear to be missing the point?, it's not about the language, it's about the underlying hardware - assembler forces you to understand the hardware, C doesn't, and it makes it difficult to program effectively without that knowledge.
Fine, you could study the hardware and understand it from a C point of view, but I would suggest that is more difficult than learning a small amount of assembler in the first place?.
You see some absolutely horrible code written in C and BASIC, simply because the writers don't have a clue about the hardware.
Hi,saiello said:If you feel comfortable writing in 'C' and things work for you then fine. ........................... Even of you insisted that you only wanted to write in 'C', it would be of great benefit to at least have some understanding of assembler not only because it can help to locate sources of problems but allow you to write more efficient 'C'. It goes without saying that a full understanding of both is the best scenario!
philba said:No, I am not missing the point. C doesn't prevent you from learning the important features of the chip and it is, in many ways, easier to learn it with C because you can focus on just the specific feature rather than all the stumbling blocks of PIC architecture. You can just as easily learn PWM, capture compare, timers, ADCs and so on.
And, I will continue to point out that people should really know both languages as a good engineer uses all the tool available.
philba said:Well, clearly, we disagree that asm is the only way to do it.
As I've said all along, you need to understand the hardware, assembly forces this on you - C doesn't.
philba said:A focused student can use either plus the datasheet to learn the features of the chip.
agent420 said:Also, it seems to me that as assembly is more closely tied to hardware, higher level languages are more 'generic'... Learned programming ability might be more easily applied to other platforms. If there are hardware differences between chips, or the desire to use another company's product, programming in assembly would require more research into hardware and instruction changes. I used to be somewhat profficient in Vic-20 and C64 6502 assembly back in the day, but that didn't mean I could write a functioning program on an Apple or Atari. However, a Basic program could be run on all those, as well as a Z80 Sinclair, with only slight modification.
agent420 said:I agree with your comments, and when it comes down to pure performance, nothing is faster than well coded assembly. But if I had to guess, I'd say the vast majority of ucontroller projects at the hobbiest level hardly approach the maximum capabilities todays chips provide. As with any rule, I'm sure there are exceptions, but 99% would probably perform their intended tasks acceptably when coded with a good quality compiler.
My experience has been nearly the opposite. You can quite easily understand the chip hardware and registers, and still create horrible asm code; wasting cycles, branching all over the place and ending up with a lot of redundant code that could have been streamlined. And some really neat asm effeciency tricks like self modifying code have little to do with the underlying architecture at all.Nigel Goodwin said:But my objections to PIC C compilers isn't about the code or speed, it's about not knowing how to actually write the programs. Because C doesn't force you to understand the hardware many people don't bother - and it shows in their poor programming. A small knowledge of assembler would provide the hardware understanding required - as would studying the hardware from a C point of view, but that doesn't seem to be freely available?.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?