Combining C code with assembly code in DSP applications
By Eran Belaish, CEVA
DSP DesignLine -- (12/10/07, 03:00:00 AM EST)
As DSP processors become more powerful and compiler optimization techniques improve, the once common trend of writing DSP applications solely in assembly has withered away. Today, almost every DSP application is comprised of a combination of both C code and assembly code. In critical functions, where performance is of the essence, DSP engineers continue to use highly optimized assembly code. Less critical functions, however, are now written in C, allowing easier maintenance and better portability. This combination of C and assembly code requires special tools and methodologies in the tool box of every DSP engineer.
It is well known that assembly coding has the advantage of better performance, while C coding is considered much easier and faster to write. To understand why this is so, let's take a closer look at the advantages and disadvantages of assembly coding compared to C coding:
Assembly Coding Pros:
- Assembly code can take advantage of a processor's unique instructions as well as various specialized hardware resources. On the other hand, C code is generic, and must support various hardware platforms. Thus, it is difficult for C to support platform-specific code.
- The assembly programmer is usually very familiar with the application and can make assumptions that are unavailable to the compiler.
- The assembly programmer can use human creativity; the compiler, advanced as it may be, is merely an automatic program.
- The assembly programmer has to handle time-consuming machine-level issues such as register allocation and instruction scheduling. With C code, these issues are taken care of by the compiler.
- Assembly coding requires specialized knowledge of the DSP architecture and its instruction set, whereas C coding only requires knowledge of the C language—which is rather common.
- With assembly code, it is extremely difficult and time consuming to port applications from one platform to another. Porting is relatively easy for C applications.
To read the full article, click here
Related Semiconductor IP
- Process/Voltage/Temperature Sensor with Self-calibration (Supply voltage 1.2V) - TSMC 3nm N3P
- USB 20Gbps Device Controller
- SM4 Cipher Engine
- Ultra-High-Speed Time-Interleaved 7-bit 64GSPS ADC on 3nm
- Fault Tolerant DDR2/DDR3/DDR4 Memory controller
Related White Papers
- Developing memory-efficient DSP apps without assembly code
- icyflex: an ultra-low power DSP core for portable applications
- Retargeting IP -> Design system compiles silicon straight from C code
- Achieving Better Code Optimization in DSP Designs
Latest White Papers
- Fault Injection in On-Chip Interconnects: A Comparative Study of Wishbone, AXI-Lite, and AXI
- eFPGA – Hidden Engine of Tomorrow’s High-Frequency Trading Systems
- aTENNuate: Optimized Real-time Speech Enhancement with Deep SSMs on RawAudio
- Combating the Memory Walls: Optimization Pathways for Long-Context Agentic LLM Inference
- Hardware Acceleration of Kolmogorov-Arnold Network (KAN) in Large-Scale Systems