Embedded Systems

Programming Embedded Systems in Assembly Language vs. High-Level Language

Embedded Systems Programming -Assembly language vs high-level language
Embedded Systems Photo by Thomas Jensen on Unsplash

Assembly Language Programming

Assembly language programming of an embedded system has the following advantages:

  • The machine codes are compact, processor and memory sensitive. This is due to the fact that, the codes for declaring the conditions, rules and data type do not exist. The system thus needs a smaller memory. Excess memory required does not depend on the programmer data type selection and rule declarations.
  • Since the assembly codes are sensitive to the process, memory, ports and devices hardware. It gives a precise control of the processor internal devices and the complete use of the processor-specific features in its instruction set and its addressing modes.
  • The program is not compiler specific and library functions dependent.
  • Device driver codes may require only a few assembly instructions. A case in point is a small embedded system like a timer device in a microwave oven. Assembly codes for this system can be compact and precise.

High-Level Language Programming

High-level programming languages like C, C++, Java, and Python are often used in place of Assembly language for programming of microprocessors. They have advantages when compared to Assembly language of being easier to use and that the same program (e.g. C code) can be used with different microprocessors; all that is needed is that the appropriate compiler is used to translate the given high-level program into the relevant machine language for the microprocessor concerned. Assembly language is typically different for different microprocessors; every microcontroller brand and family has its own specific instruction set that provides access to the resources available on the chip.

Some of the key advantages of high-level languages over assembly language include:

  • High-level program facilitates data type declarations. These data type declarations provide programming ease.
  • High-level program development cycle is short even for complex systems since we use methods in Java and routines in C/C++, standard library functions, employ modular programming technique, and use top-down or object-oriented design (OOP) design approach.
  • High-level program facilitates ‘type checking’ making the program less prone to error.
  • High-level program facilitates use of control structures [e.g. while, do-while, break and for] and conditional statements [e.g. if, if-else, else-if and switch-case] to specify the program flow by simple statements.
  • High-level program has portability of non-processor-specific codes. Hence, when the hardware changes, only the modules for the interrupt service routines (ISRs) of device drivers and device management, initialization and program-locator modules and initial boot-up record data need modifications.

Related: What is an Embedded System?

Even though high-level programming languages like Java, C++ and Python can be used for programming embedded systems, C has always be the preferred language by most embedded systems programmers for a number of reasons:

  • It has a feature of embedding assembly code using inline assembly. C is a language between low (assembly) and high-level languages. Inserting the assembly language in between is called in-line assembly. Therefore, a direct hardware control is also feasible by inline assembly language and the complex part of the program can be in high-level language.
  • Readily available modules in C compilers for the embedded system and library codes that can directly port into the system programmer codes.

Also Read:

Share
John Mulindi

John Mulindi is an Industrial Instrumentation and Control Professional with a wide range of experience in electrical and electronics, process measurement, control systems and automation. In free time he spends time reading, taking adventure walks and watching football.

View Comments

Recent Posts

What to Expect from PCB Assembly Services in China

The importance of printed circuit board (PCB) technology has escalated throughout the years with the…

22 hours ago

Magneto-Optic Current Sensors for High Voltage, High Power Transmission Lines

One of the key challenges in measuring the electrical current in high voltage, high power…

3 days ago

How the Wiegand Effect is used in Sensing Instruments

The Concept behind Wiegand Effect Based Sensors   The Wiegand effect technology employs the unique…

5 days ago

Piezoelectric Accelerometer: Principle of Operation & Applications

An accelerometer is a sensor that is designed to measure acceleration or rate of change…

6 days ago

The USB-6009 Data Acquisition Card Features

The USB-6009 is a small external data acquisition and control device manufactured by National Instruments…

1 week ago

How X-Y Tables are used in Position Control Applications

X-Y tables are utilized as components in many systems where reprogrammable position control is desired.…

1 week ago