=== 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** * Raivo Sell, Ph. D., ING-PAED IGIP **Riga Technical University** * Agris Nikitenko, Ph. D., Eng. * Karlis Berkolds, M. sc., Eng. * Eriks Klavins, M. sc., Eng. **Silesian University of Technology** * Piotr Czekalski, Ph. D., Eng. * Krzysztof Tokarz, Ph. D., Eng. * Godlove Suila Kuaban, Ph. D., Eng. **Western Norway University of Applied Sciences** * Add data === 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: * embedded systems - constrained devices, * mobile and mobile-like devices - based on ARM architecture, * PCs and servers - based on Intel and AMD x86 and in particular 64-bit (x86_64) architecture. 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). {{ :en:multiasm:curriculum:logo_400.png?200 | Multiasm Project Logo}} === Project Information === This content was implemented under the following project: * Cooperation Partnerships in higher education, 2023, MultiASM: A novel approach for energy-efficient, high performance and compact programming for next-generation EU software engineers: 2023-1-PL01-KA220-HED-000152401. **Consortium Partners**\\ * Silesian University of Technology, Gliwice, Poland (Coordinator), * Riga Technical University, Riga, Latvia, * Western Norway University, Forde, Norway, * ITT Group, Tallinn, Estonia. {{ :en:multiasm:curriculum:pasek_z_logami_1000px.jpg?400 | 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 [[https://en.wikipedia.org/wiki/Creative_Commons_license|Creative Commons Licence]] and is free for non-commercial use.
{{ en:iot-open:ccbync.png?100 |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: * The first chapter introduces students to computer platforms and their architectures. Assembler programming is very close to the hardware, and understanding those concepts is necessary to write code successfully and effectively. * The second chapter discusses programming in assemblers for constrained devices that usually do not have operating systems but are bare-metal programmed. As it is impossible to review all assemblers and platforms, the one discussed in detail in this chapter is the most popular: AVR (ATMEL) microcontrollers (e.g. Arduino Uno development board). * The third chapter discusses assembler programming for the future of most devices: ARM architecture. This architecture is perhaps the most popular worldwide as it applies to mobile phones, edge and fog-class devices, and recently to the growing number of implementations in notebooks, desktops, and even workstations (e.g., Apple's M series). Practical examples use Raspberry Pi version 5. * The last, fourth chapter describes in-depth assembler programming for PCs in its 64-bit version for Intel and AMD CPUs, including their CISC capabilities, such as SIMD instruction sets and their applications. Practical examples present (among others) the merging of the assembler code with .NET frontends under Windows. The following chapters present the contents of the coursebook: * [[en:multiasm:cs]] * [[en:multiasm:paiot]] * [[en:multiasm:paarm]] * [[en:multiasm:papc]] ====== 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 =====