This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C v/s Assembly

What are the merits and demerits of using C over assembly language for mcu programming.

thank you

ece

Parents
  • You produce code faster using C.

    You will get a lot fewer hard-to-find errors with C. The compiler notices uninitialized variables etc.

    The code is easier to move to a different processor, since C is universally available. Only specific language extensions to take advantage of the architecture or code that manipulates bits in the processor will be non-portable or require some rewrites if changing to a different processor.

    It is easier to rewrite the code to extend (or change) it's behaviour since the compiler and the language encapsulation will often catch partial rewrites.

    It is easier for another developer to look at the code and understand it, or to be able to take over.

    It is easier to debug. A higher-level language means that more can happen for each line when single-stepping. A single multiply or division in C can require a lot of assembler instructions if the processor doesn't have hardware instructions for multiply or divide.

    The code may be a bit bigger/slower - but only if you have reasonably good knowledge of assembly for the specific processor. A lousy assembler programmer will loose to a compiler.

Reply
  • You produce code faster using C.

    You will get a lot fewer hard-to-find errors with C. The compiler notices uninitialized variables etc.

    The code is easier to move to a different processor, since C is universally available. Only specific language extensions to take advantage of the architecture or code that manipulates bits in the processor will be non-portable or require some rewrites if changing to a different processor.

    It is easier to rewrite the code to extend (or change) it's behaviour since the compiler and the language encapsulation will often catch partial rewrites.

    It is easier for another developer to look at the code and understand it, or to be able to take over.

    It is easier to debug. A higher-level language means that more can happen for each line when single-stepping. A single multiply or division in C can require a lot of assembler instructions if the processor doesn't have hardware instructions for multiply or divide.

    The code may be a bit bigger/slower - but only if you have reasonably good knowledge of assembly for the specific processor. A lousy assembler programmer will loose to a compiler.

Children