Asm programming vs C programming
This is an article for people who are just starting to work with micro controllers and want to find out more what they should do.
I'm also a beginner at this moment but i'm trying to get better, and this post and other describe my steps so you can learn from my mistakes in programming and electronics.
So you want to program a micro controller, maybe a pic16f84 (that's what i use) and you don't know what to use assembler or c, well i hope that after reading this article you will be able to make a choice.
Both languages have advantages and disadvantages, you will have to see what works best in your case, it's not a basic rule and those are just guide lines that will help you see what programming language works best for you.
Now, lets start with the assembler. This is good if you want to make really small programs, like turning leds on, counting, a pwm controll. Because you are a beginner now it's very hard for you to make complex programs, but it's good to use the assembler because you can learn stuff about the arhitecture of the microcontroller and learns stuff about how it's working. Also an other advantage it's that you can see exactly what's happening there and if you want to do some timing this perfect because you know exaclty how many clock cycles takes every operation. And in the finall a very important matter is the size of the program, the programs written directly in assembler language are much smaller than the programs written in C.
The C language. First off all you will have to find a compiler for your micro controller (if you use pic16f84 i suggest the hi-tech compiler, works really good). When you have the compiler you will have to see what features it has (data types, functions, etc). Developing in C for micro controllers it's really easy, in general developing in C is about 10 times faster than in assembler, so it's good if you want to make something really fast, also is good if you want to make complex programs. A big disadvantage is the size of the code, the code generated by the compiler is usually much bigger than the one written directly in assembler and if you use a micro controller with a few program memory that is a serious problem, for example pic16f84 has 4K of program memory, a clock program i wrote has 1.8K, so if you want to add some other features you can't add very many.
So here is a short comparison:
- development time is much much shorter using C
- the size of the program is bigger if you use C
- you can do more accurate timings using assembler
- you can learn more by using assembler instead of C
- you don't need a compiler if you use asm (mplab does everything)
- it's hard to do complicated programs in asm.
Now the decision is yours you can try to do the same thing using both languages, and do some tests to see which one fits you best.
Here are some files attached :
The examples above are just for you to make an idea about how a program should look. If you take those and burn them on the 16f84 micro controller they will work, but maybe they won't do exactly what you expect form them because i'm still testing using those programs.
Happy codding !!
Related posts:

September 5th, 2010 at 11:27 am
Buy:Lipothin.SleepWell.Amoxicillin.Acomplia.Wellbutrin SR.Zetia.Lasix.Prozac.Advair.Seroquel.Aricept.Ventolin.Benicar.Nymphomax.Female Cialis.Buspar.Lipitor.Cozaar.Zocor.Female Pink Viagra….