0% found this document useful (0 votes)
22 views

Intro To Embedded Systems

This document discusses embedded C and compares it to assembly language. Embedded C is a specialized form of C tailored for embedded systems with limited resources. It allows direct hardware access and control while being more portable, readable, and maintainable than assembly. Assembly is faster and more efficient but also lower-level, non-portable, difficult to learn, debug, and maintain. For most embedded applications, C is preferred over assembly due to its balance of performance and productivity.

Uploaded by

Adhiraj Kaushik
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Intro To Embedded Systems

This document discusses embedded C and compares it to assembly language. Embedded C is a specialized form of C tailored for embedded systems with limited resources. It allows direct hardware access and control while being more portable, readable, and maintainable than assembly. Assembly is faster and more efficient but also lower-level, non-portable, difficult to learn, debug, and maintain. For most embedded applications, C is preferred over assembly due to its balance of performance and productivity.

Uploaded by

Adhiraj Kaushik
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Assembly , C and Embedded C

Introduction

Dr. A. Nayeemulla Khan


What is Embedded C?
• A specialized form of the C programming
language tailored for developing software for embedded
systems.

• An embedded system is a combination of computer


hardware and software—and perhaps additional parts,
either mechanical or electronic—designed to perform a
dedicated function.

• These Embedded systems often have limited resources in


terms of memory, processing power, and sometimes even
energy.
GPS VS Embedded System

• Design: A microcontroller serves as the primary


processing component for the majority of its design.
• Basic: A computer system that has been designed to carry
out one or more defined tasks is known as an embedded
system.
• Memory: It employs semiconductor memories but
doesn’t need additional memory sources like CDs or hard
drives. It has a type of memory called flash memory.
• Operation System: The operating system, which is
mostly an RTOS (Real Time Operating System), and
other software take up little memory.
GPS VS Embedded System

• System Hardware: Microcontrollers are used in


embedded systems because they combine a CPU,
memory unit, and I/O interface on a single IC chip.

• Cost: Compared to a computer, it is less expensive.

• Storage Capacity: Compared to computers, embedded


devices have a smaller memory capacity.
Need for Embedded C Programming
• In early days of embedded systems, code was all written
in assembly language and that was the only option as
memory was extremely limited .

• The tight control of this limited memory was essential


and assembly provided that control.

• Later, processors became more powerful (16-bit and 32-


bit devices became viable), memory becomes cheaper and
denser and application complexity has increased
developed by large teams of programmers.
Need for Embedded C Programming
• There was no mechanism to find what the program was
doing. LED, switches etc., were used to check the correct
execution of program.

• The specific reasons for why is C the most preferred


language for Embedded Systems.
 Processor independent
 Portability
 Performance
 Bit manipulation
 Memory management
Need for Embedded C Programming
Processor independent

•C language is not specific to any microprocessor/micro-


controller or any system.

•It can work on various hardware configuration.

•C doesn’t require same set of hardware to run a program.

•C language is platform independent whereas the


applications written in C are not. Hence the concept “Write
once Compile anywhere” came.
Need for Embedded C Programming
Processor independent

•C language is not specific to any microprocessor/micro-


controller or any system.

•It can work on various hardware configuration.

•C doesn’t require same set of hardware to run a program.

•C language is platform independent whereas the


applications written in C are not. Hence the concept “Write
once Compile anywhere” came.
Need for Embedded C Programming
Portability

Portability of a language is mainly important when an


application program must be moved to other operating
systems.

Code developed in C is more portable and user can compile


it on other platforms with least modifications.

A program can be written in one machine and can be run on


other machines.
Need for Embedded C Programming
Performance

C code gets compiled into raw binary executable which can


be directly loaded into memory and executed.

C provides optimized machine instructions for the given


input, which increases the performance of the embedded
system.

Most of the high-level languages rely on libraries, hence


they require more memory which is a major challenge in
embedded systems but not in C.
Need for Embedded C Programming
Bit Manipulation

C is more flexible, structured language that provides “low


level bit wise data manipulation” using the bit-wise
operators.

Using bit-wise operators, one could play with available bits,


which comes handy when it comes to Embedded Systems
(Ex: Handling registers).
Need for Embedded C Programming
Memory Management
It provides direct memory control without sacrificing
benefits of high-level languages.

Memory an be directly accessed using pointers and perform


various operations using them.

When memory requirement is not known, it can be allocated


dynamically and when memory requirement is known, we
can allocate the memory statically. This is one of the main
reasons for why is C the most preferred language for
embedded systems.
Assembly vs Embedded C Language

Parameter Assembly language Embedded C


Execution time Faster(Less execution Slower(More execution
time required) time required)
Time for coding More time is required Less time required for
for coding coding and code is more
efficient
Hex file size less More
Debugging Not so easy Easy
Level of
Low-level High-level
Abstraction
Complex; uses Simplified; uses
Syntax
mnemonics keywords
Assembly vs Embedded C Language
Parameter Assembly Language C Language
Difficult to read and Easier to read and
Readability
understand understand
Not portable; hardware- Portable; can run on
Portability
specific multiple platforms
Memory Manual; a programmer Automatic; garbage
management must manage memory collection is supported
Less efficient but
Very efficient; can optimize
Performance generally easier to write
for specific hardware
and debug

Low-level system High-level system


Applications programming; embedded programming; application
systems development
Pros and Cons - Assembly Language
Advantages
•Speed: Assembly language is fast and efficient since it is
written directly for the computer’s hardware. It allows the
programmer to control the computer’s resources and optimize
the code to run as fast as possible.
•Direct access to hardware: Assembly language allows
direct access to hardware, which can be helpful in low-level
programming operations, such as manipulating memory or
controlling hardware devices.
•Memory Efficiency: Assembly language is much more
memory efficient than higher-level programming languages
since it allows for precise control over the use of registers and
memory.
Pros and Cons - Assembly Language
Advantages
•Small code size: Assembly language produces small
executable files since it does not require external libraries or
run-time environments.
Disadvantages
•Steep Learning Curve: Assembly language is much more
challenging to learn than higher-level programming languages
since it requires a deep understanding of computer
architecture and low-level operations.
•Time-consuming: Assembly language programming is a
time-consuming process as even small changes in the code
require recompilation, and debugging can be tricky since there
are no high-level abstractions.
Pros and Cons - Assembly Language
Disadvantages

•Platform Dependent: Assembly language is specific to a


particular computer architecture, and programs written in
assembly language cannot be easily ported to other
platforms.

•Maintenance and Debugging: Assembly language is


challenging to maintain and debug, especially when dealing
with large code bases. This is due to the lack of high-level
abstractions, making understanding and modifying code
challenging.
Pros and Cons - C Language

Advantages
•Portability: C code can be easily ported to different
platforms and operating systems since it is a high-level
programming language.
•Efficiency: C code is efficient in terms of both memory
usage and speed of execution, which makes it suitable for
developing high-performance applications and systems.
•Extensive community and resources: C has a large
community of developers, and there are a vast number of
resources, libraries, and tools available that can be used for
C programming.
Pros and Cons - C Language
Advantages
•Structured programming: C supports structured
programming, which makes it easier to organize and
modularization code, making it more maintainable and
easier to understand.

Disadvantages
•Low-level programming: While C is a high-level
language, it is still considered a low-level programming
language compared to other modern languages like Python
or Java. As a result, it requires a good understanding of
computer architecture and memory management.
Pros and Cons - C Language
Disadvantages

•Memory management: C requires manual memory


management, which can be challenging and prone to errors
if incorrectly handled. Improper memory management can
lead to issues, such as segmentation faults and memory
leaks.

•No automatic garbage collection: Unlike modern


programming languages like Java and Python, C does not
have automated garbage collection, so the programmer must
explicitly manage memory allocation and deallocation.
C or Assembly Language?
• C is a high-level language that is portable, easier to learn,
and widely used in many applications. Assembly
language provides direct control over hardware resources
and is highly efficient, making it ideal for system
programming and embedded systems.

• The choice between these languages depends on the


project’s specific requirements, and often a combination
of both is used.

• Assembly language is mainly used by system


programmers, device driver developers, and firmware
engineers who require low-level access and precise
control over hardware resources.
C or Assembly Language?

• C and Assembly languages are often used in projects


requiring high-level and low-level programming.

• C can be used to write higher-level constructs and


functions, while Assembly language can be used for
lower-level tasks that require direct access to hardware
resources.

• Inline assembly can be used within a C program to


include assembly language and C code.
C vs Embedded C
• C is a high-level and general-purpose programming
language used in developing several applications like
hardware drivers, operating systems, and more.

• This language was invented by Dennis Ritchie in 1972 in


Bell Labs.

• C is a very popular general-purpose and structural


programming language that follows POP (procedural
oriented programming).
C vs Embedded C
• The extension of the C programming language is known
as embedded C.

• It is generally utilised for creating microcontroller-based


applications.

• Talking about the extension it is I/O fixed-point


arithmetic operations, hardware addressing, accessing
address spaces, and more.
C vs Embedded C
C Embedded C
It is a structural and general purpose Embedded C is generally used to
programming language used by the develop microcontroller-based
developers to build desktop-based applications.
applications.
C is a high-level programming Embedded C is just the extension
language. variant of the C language.
This programming language is On the other hand, embedded C
hardware independent. language is truly hardware dependent.
The compilers in C language are OS The compilers in embedded C are OS
dependent. independent.
Here, the traditional or standard Here, we need a specific compiler that
compilers are used to run the can help in generating micro-controller
program. based results.
Famous compilers used in C are Intel Famous compilers used in embedded C
C++, Borland turbo C, and more. are BiPOM Electronic, Green Hill
Software and more.

You might also like