Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Which language is better for uC, Assembler or C?

Status
Not open for further replies.
Re: C or Assembly

If you very good know the CPU, you can make code in C only a bit slower than in assembly language.
Also, working with C, you can easy migrate to other CPU.

I'm using assembly language only in DSP processors.
 

C or Assembly

I can only see 3 reasons for programming in assembler on a uC (Assuming you have a decent c compiler thar generates efficient code).

1 : You want to make some critical interrupt/timing routines that require 100% cycle accuracy.

2 : You want to squeeze every last cycle out of the uC

3 : You dont have much Flash so every byte of code counts

Well there might be a 4 ....
4 : Most c compilers require that the uC have some ram

But with a good c compiler , you can create almost as fast and efficient code as in assembler.

And it is mych easier to port to another architecture.

/Bingo
 

Re: C or Assembly

You forgot to add that C Compilers are usually not free.
 

Re: C or Assembly

in my opinion if you want to be good designer you should now both of them...
C saves your time and sometimes assembly is inevitable.....
 

C or Assembly

@checkmate

Mine are
AVR-GCC for Atmels :)
ARM-GCC Toolchain for ARM

@olemp
I would have to agree with you , using C is not an "Excuse" for learning assembler , in fact you might even have to look at a C compilers output listing , as they arent error free.

And you will probably run into at least my
1 and 2 reasons stated above during some of your programming.

But i still tend to do like 80..90% of the code in C.

/Bingo
 

C or Assembly

I don't think that assembler is much better than C in terms of program speed/size. Novadays compilers are very good in optimizing, for example Keil C51 is extremely good - not every good programmer can achieve the same. The same is right for usual PC - Intel's compilers provide very good optimization for specified target processor.

Ace-X.
 

C or Assembly

usually, if you have time-sensitive code, you should use assembly. if not, you have better to use C.
There has a balance between your workload and efficiency
 

C or Assembly

In time cricis and limited memory size application, ASM is suitable. Otherwise C is preferable. C is much easier for develpment, mentainance and porting. And a good understanding of ASM is the fundation of high quality of C, especially in MCU programming.
 

Re: assembler or C???

Everyone seems to be mentioning the fact that ASM gives you better control over code timing. While this is true for routines that need to be accurate down to the CPU clock cycle, many timing critical routines such as comms, etc, can be achieved accurately in C by making use of the microcontrollers timers and some nice tight ISRs.

If you know what your doing ASM is great, but don't reach for it when you don't have to. Thats IMHO anyway.

oddbudman
 

assembler or C???

I think you should spiit two processes for studying mcu.
at the beginning, you should understand the principle of mcu completely, and ASM is the best choice, which can make you master the characteristic of mcu.
after you have mastered these, you can try on C for it can improve the efficiency of the design.
of course, if your design emphasizes the working speed, you have better to choose the asm.
Combining C and asm is a not bad idea.
 

Re: assembler or C???

oddbudman said:
Everyone seems to be mentioning the fact that ASM gives you better control over code timing. While this is true for routines that need to be accurate down to the CPU clock cycle, many timing critical routines such as comms, etc, can be achieved accurately in C by making use of the microcontrollers timers and some nice tight ISRs.

If you know what your doing ASM is great, but don't reach for it when you don't have to. Thats IMHO anyway.

oddbudman

No. You will never know how the machine codes are generated from a C statement(s). For example x = (y << 4) & 0xab;

Of course you may try to look into the listing generated. But in this way, it makes no different to me if I code in ASM. Or maybe it would take more efforts than write your code in ASM.
 

Re: C or Assembly

vale said:
In time cricis and limited memory size application, ASM is suitable. Otherwise C is preferable. C is much easier for develpment, mentainance and porting. And a good understanding of ASM is the fundation of high quality of C, especially in MCU programming.

Totally agree in this one. The only reason for me to use C is when porting has become an issue.
 

Re: assembler or C???

in my opinion,assembler is better.
assembler is more close to hardware.
C is high level language in addition to assembler.
 

assembler or C???

i think c is very efficent for embedded programming. but if you want to order full hardware functions you have to use inline asemmbly
 

Re: assembler or C???

hi all ;

if you want to be able to use all feuters of MCU in the best way , only ASM can be used , it means if you need speed , low program memory and .... which are really important in some projects especially econemic productes , the ASM is the best ,
i think each programmer should first ASM , because then you would learn all basics and reason of many problems and limits in MCU ,

however writting a code usnig C is easier sometimes, but the program would need more memory space and would run slower than same ASM written code.
 

assembler or C???

if possible,you should use c to write the code.
 

assembler or C???

I think C programming is not only easy and quickly way to develop any application, exspectialy in complex work, but also it make your life easier when you have to change microcontroller series or change manufacture.
 

Re: assembler or C???

C code is the NORM ... for doing embedded systems But there are cases where because you have to respond quickly or efficiently is better to go with assembler .
Though this days the cpu are getting so fast that you can afford a lot en inefficiency in the execution While gaining efficiency in the accomplishement of the project .There was a time where i would code in assambler because i couldn't afford the compiler or I couldn't write C( 15 years ago) .Then every time i needed to go back to change a thing it was a BIG PROBLEM just to read myself .I even commented all the line .So C is definitly a way to go but some inline assembler helps from time to time !
 

Re: assembler or C???

It's chances to project which you make.C programming simple then assembley because some macros was written Compilers manufacturer.But sometimes you need to care global and local variables and sometimes a variable is changes your
reluctantly.But assembly language is the chip manufacturer's.Now c programming is in.Assembly is out.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top