Table of Contents

Authors

IOT-OPEN.EU Reloaded Consortium partners proudly present the 2nd edition of the Introduction to the IoT book. The complete list of contributors is listed below.

ITT Group

Riga Technical University

Silesian University of Technology

Western Norway University of Applied Sciences

Preface

This book is intended to provide comprehensive information about low-level programming in the assembler language for a wide range of computer systems, including:

The book also contains an introductory chapter on general computer architectures and their components.

While low-level assembler programming was once considered outdated, it is now back, and this is because of the need for efficient and compact code to save energy and resources, thus promoting a green approach to programming. It is also essential for cutting-edge algorithms that require high performance while using constrained resources. Assembler is a base for all other programming languages and hardware platforms, and so is needed when developing new hardware, compilers and tools. It is crucial, in particular, in the context of the announced switch from chip manufacturing in Asia towards EU-based technologies.

We (the Authors) assume that persons willing to study this content possess some general knowledge about IT technologies, e.g., understand what an embedded system is and the essential components of computer systems, such as RAM, CPU, DMA, I/O, and interrupts and knows the general concept of software development with programming languages, C/C++ best (but not obligatory).

 
 Multiasm Project Logo

Project Information

This content was implemented under the following project:

Consortium Partners

 Consortium Partner's Logos

Erasmus+ Disclaimer
This project has been funded with support from the European Commission.
This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may be made of the information contained therein.

Copyright Notice
This content was created by the MultiASM Consortium 2023–2026.
The content is copyrighted and distributed under CC BY-NC Creative Commons Licence and is free for non-commercial use.

CC BY-NC

In case of commercial use, please get in touch with MultiASM Consortium representative.

Introduction

The old, somehow abandoned Assembler programming comes to light again: “machine code to machine code and assembler to the assembler.” In the context of rebasing electronics, particularly developing new CPUs in Europe, engineers and software developers need to familiarise themselves with this niche, still omnipresent technology: every code you write, compile, and execute goes directly or indirectly to the machine code.
Besides developing new products and the related need for compilers and tools, the assembler language is essential to generating compact, rapid implementations of algorithms: it gives software developers a powerful tool of absolute control over the hardware, mainly the CPU.

Assembler programming applies to the selected and specific groups of tasks and algorithms.
Using pure assembler to implement, e.g., a user interface, is possible but does not make sense.
Nowadays, assembler programming is commonly integrated with high-level languages, and it is a part of the application's code responsible for rapid and efficient data processing without higher-level language overheads. This applies even to applications that do not run directly on the hardware but rather use virtual environments and frameworks (either interpreted or hybrid) such as Java, .NET languages, and Python.

It is a rule of thumb that the simpler and more constrained the device is, the closer the developer is to the hardware. An excellent example of this rule is development for an ESP32 chip: it has 2 cores that can easily handle Python apps, but when it comes to its energy-saving modes when only ultra-low power coprocessor is running, the only programming language available is assembler, it is compact enough to run in very constrained environments, using microampers of current and fitting dozen of bytes.

This book is divided into four main chapters:

Computer Architectures

Overall View on Computer Architecture: Processor, Memory, IO, Buses

Von Neumann vs Harvard Architectures, Mixed Architectures

Components of Processor: Registers, ALU, Bus Control, Instruction Decoder

CISC, RISC

Processor Taxonomies, SISD, SIMD, MIMD

Memory, Types and Their Functions

Peripherals

Instruction Execution Process

Modern Processors: Pipeline, Superscalar, Branch Prediction, Hyperthreading

Fundamentals of Addressing Modes

Fundamentals of Data Encoding, Big Endian, Little Endian

Interrupt Controller, Interrupts

DMA

Programming in Assembler for IoT and Embedded Systems

Evolution of the Hardware

Specific Elements of AVR Architecture

Registers

Data Types and Encoding

Addressing Modes

Instruction Encoding

Instruction Set

Best Practices on Structural Programming

3 Levels of Programming: C++, Libraries, Assembler

Software Tools for AVR

Hardware Debugging

Energy Efficiency

Programming in Assembler for Mobiles and ARM

Overview of ARM and Mobile Device Architecture

ARM Assembly Language Specifics

Registers

Data Types and Encoding

Addressing Modes

Basic Instructions and Operations

Procedures and Functions Call Standards

Compatibility for Compilers and OSes

Peripheral Management in RPi

Advanced Assembly Programming

Vectorisation

Assembly Code Optimisation

Energy Efficient Coding: Sleep Modes, Hibernate

Cross-Platform Development

Energy Efficient Coding: Sleep Modes, Hibernate

Programming in Assembler for PC

Evolution of x86 Processors

Specific Elements of the x86 and x64 Architectures

Register Set

Data Types and Encoding

x64 Addressing: Addressing Modes in Instructions

Principles of Instructions Encoding

Instruction Set of x86 - Essentials

Procedures, Functions and Calls in Windows and Linux

Compatibility with HLL Compilers (C++, C#) and Operating Systems

FPU

MMX

Macros

Code Examples

Energy Efficient Programming

Interrupts

Optimisation