Why C instead ASM

ASM is a specific language also referred as low level programming language. It is a mnemonics to a machine codes. It usually takes long time to develop embedded programs in ASM language. Today even modern 8 bit microcontrollers are powerful and complex as they were long time ago. The program memory of tiny chips are reaching megabytes, they pack lots of peripherals and interfaces. Hardware code is becoming more complex, functionality grows up. This is one of the main reasons of using higher level programming languages like C.

By using C language you do not have to go into details how processor works at hardware level. You don’t have to think about hardware logic how bytes are shifted between registers. It is better to leave t

Another advantage of C language against ASM is portability. If you work with embedded system architecture and decide to move to other, and your previous program were written in ASM, then you are stuck to rewriting this code from scratch. Using C written programs you can re-compile code for different microcontrollers without significant modifications of code. This way your new project code upgrade becomes easy task.

C or other high level programming language makes it easy to save specific hardware routines in to libraries which are convenient to reuse in other projects, constantly update them for better compatibility and performance. C libraries ensure that your application can be recompiled for different MCU’s by selecting different settings and other parameters.

The most important benefit of using high level programming language like C is that you can focus on algorithm design and spend less time on coding. You can write, understand and maintain embedded code faster and easier as one C language line can stand for multiple ASM code lines.

In other hand, ASM language can also be used in critical parts of code where you want total control on timing and memory access, but again C compilers are improving and sometimes program written in C may be more efficient then written in ASM. It always depends more on developer than a programming language. The days when ASM was preferred for performance and code size are long gone. Now it is all about productivity and portability of code. If you are still deciding where to start, better stick to C and move on to high level of coding.

One Comment:

  1. This is a post updated and imported from winavr.scienceprog.com

Leave a Reply

Your email address will not be published. Required fields are marked *