‘C’ generates an object code that is extremely fast and compact, but it is not as fast as the object code generated by a good programmer using assembly language.
The time needed to write a program in assembly language is much more than the time taken in Higher Level Languages like C. However, there are special cases where a function is coded in assembly language to reduce execution time.
Example: The Floating Point math package must be coded in assembly language as it is used frequently and its execution speed will have great effect on the overall speed of the program that uses it.
There are also occasions when some hardware devices need exact timing and then it is necessary to write assembly level programs to meet such strict timing restrictions.
In addition, certain instructions cannot be executed in Higher Level Languages like C. Example: C does not have an instruction for performing bit-wise rotation operation.
Thus in spite of C being very powerful, routines must be written in assembly language to :
- Increase the speed and efficiency of the routine.
- Perform Machine specific functions not available in Microsoft C or in Turbo C.
- Use third party routines.