0% found this document useful (0 votes)
2 views29 pages

Iot&a Unit-2

The document provides an overview of the elements of IoT, focusing on hardware components such as Arduino and Raspberry Pi, their features, advantages, disadvantages, and applications. It details the architecture and functionality of ARM processors, including the Cortex-A, Cortex-R, and Cortex-M families, highlighting their use in various applications. Additionally, it compares Arduino and Raspberry Pi, emphasizing their differences in architecture, processing capabilities, and use cases.

Uploaded by

rajigalla318
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views29 pages

Iot&a Unit-2

The document provides an overview of the elements of IoT, focusing on hardware components such as Arduino and Raspberry Pi, their features, advantages, disadvantages, and applications. It details the architecture and functionality of ARM processors, including the Cortex-A, Cortex-R, and Cortex-M families, highlighting their use in various applications. Additionally, it compares Arduino and Raspberry Pi, emphasizing their differences in architecture, processing capabilities, and use cases.

Uploaded by

rajigalla318
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIT-2

Elements of IoT

Elements of IoT:
• Hardware Components-Arduino
• Raspberry Pi
• ARM Cortex-A class processor
• Embedded Devices – ARM Cortex-M class processor
• Arm Cortex-M0 Processor Architecture, Block Diagram
• Cortex-M0 Processor Instruction Set
• ARM and Thumb Instruction Set
Arduino

Introduction of Arduino

 Arduino is an open-source platform used for building electronics projects.

 Arduino consists of both a physical programmable circuit board (often referred to


as a microcontroller) and a piece of software, or IDE (Integrated Development
Environment) that runs on your computer, used to write and upload computer
code to the physical board.

Example: Arduino boards are able to read inputs like light on a sensor, a finger on a button,
or a Twitter message - and turn it into an output such as activating a motor, turning on an
LED, publishing something online.

Features of Arduino:

 Arduino programming is a simplified version of C++, which makes the learning


process easy.

 Arduino can read analog and digital input signals.

 Both hardware and software platforms are easy to use and implement.

 Arduino does not need an extra board or piece to load new code.

 The Arduino IDE is used to control the functions of boards. It further sends the set
of specifications to the microcontroller.

Block Diagram of Arduino:


Block Diagram of Arduino:

Hardware Structure of Arduino:


Part-1

USB(Universal Serial Bus):

o The function of this port is to programme the board or to upload the programme.

o The one end of USB cable is connected to the laptop and another to this port.

o With help of Arduino software and USB cable, one can upload the programme on the
board.

Crystal Oscillator: Keeps track of time and regulates processor frequency.

Voltage Regulator: Regulates and stabilizes the input and output voltages.

Part-2

Reset Pin: can be used to reset the Arduino Uno

RX and TX LEDs: Receive (RX) and Transmit (TX) LEDs, blink when sending or receiving
serial data respectively.
Digital I/O pins: Arduino Uno Consist of 14 Digital Pins Where Output Components like:
LED, LCD, Relay etc., are connected.

AREF(Analog Reference) pins: can be used to set an external reference voltage as the upper
limit for the analog pins

Part-3

Power indicator LED: indicates the power status of the board

Microcontroller (ATMega328): Microcontroller is the main component of Arduino UNO.

The Arduino Uno board is a microcontroller based on the ATmega328.

ICSP pin (In-Circuit Serial Programming): These pins are used to code and boot an Arduino
from an external source.

• ATmega328 is an 8-bit, 28-Pin AVR Microcontroller, manufactured by Microchip,


follows RISC Architecture and has a flash-type program memory of 32KB.

• Atmega328 is the microcontroller, used in basic Arduino boards i.e Arduino UNO,
Arduino Pro Mini and Arduino Nano

• It has an EEPROM memory of 1KB and its SRAM memory is 2KB.


• It has 8 Pins for ADC operations, which all combine to form PortA ( PA0 - PA7 ).

• It also has 3 built-in Timers, two of them are 8 Bit timers while the third one is 16-Bit
Timer.

• It operates ranging from 3.3V to 5.5V but normally we use 5V as a standard.

• Its excellent features include cost-efficiency, low power dissipation, programming


lock for security purposes, real timer counter with separate oscillator.

Part-4

Reset button: This is used to start the programme again which is once uploaded.

3.3V pin: can be used as a 3.3V output

5V pin: can be used as a 5V output

GND pin: can be used to ground the circuit (having 3 GND pins)

Vin pin: can be used to supply power to the board

Analog pins(A0-A5): Arduino Uno Consist of 6 Analog Pins, these Pins are usually used to
connect sensor like: IR Sensor, RF Sensor these all sensor have analog value that’s why they
are connected to analog pins, most of the input components are connected here.

Advantages of Arduino:

 Arduino has been used for a long time in electronic projects and it has been the
favourite board of beginners in the electronic world.

 Arduino is super easy to learn. Any beginner can learn Arduino with little or no
knowledge of programming.

 Arduino boards are available at low cost. To start building our first program, we just
need an Arduino board as its development tool IDE is freely available.

 Arduino is an open-source community with many online supports available on


Arduino forum.

 Arduino is not only limited to Windows it is also available across multiple


platforms like Linux and macOS.

 Many Arduino libraries are available to control external sensors, modules, and
motors.

Disadvantages of Arduino:

 Arduino boards are limited to run only a single program at a time.


 Microcontrollers used in most Arduino boards are not ready to give their full
performance.

 Arduino boards are mostly programmed in C or C++ language. Arduino lacks


support for some very famous languages like Java, Python and JavaScript.

 One of the main features which Arduino lacks is it has limited memory storage.

Applications of Arduino

• DIY(Do it yourself) Electronics Projects

• Robotics

• Home Automation

• Education

• Gaming Controllers

Raspberry Pi
Feature of Raspberry Pi:

 Raspberry Pi is a small single-board computer (SBC).

 It was established by the Raspberry pi foundation from the UK.

 It is a credit card-sized computer that can be plugged into a monitor.

 It acts as a minicomputer by connecting the keyboard, mouse, and display.

 Raspberry Pi has an ARM processor and 512MB of RAM.

 Raspberry Pi is popularly used for real time Image/Video Processing, IoT based
applications and Robotics applications.

 It has been ready for public usage since 2012 with the idea of making a low-cost
educational microcomputer for students and children.

 The raspberry pi comes in two models, model A and model B. The main difference
between model A and model B is USB port.

 Model A board will consume less power and that does not include an Ethernet port.
But, the model B board includes an Ethernet port and designed in China.
Block Diagram of Raspberry Pi

Processor: Raspberry Pi uses Broadcom BCM2835 system on chip which is an ARM


(Advanced Reduced Instruction Set Computer Machine) processor and Video core Graphics
Processing Unit (GPU). It is the heart of the Raspberry Pi which controls the operations of all
the connected devices and handles all the required computations.

HDMI: High-Definition Multimedia Interface is used for transmitting video or digital


audio data to a computer monitor or to digital TV. This HDMI port helps Raspberry Pi to
connect its signals to any digital device such as a monitor digital TV or display through an
HDMI cable.

Display: Display Serial Interface (DSI) is used for connecting LCD to Raspberry Pi using 15-
pin ribbon cables. DSI provides a high-resolution display interface that is specifically used
for sending video data.

Ethernet: The ethernet connector allows access to the wired network, it is available only
on the model B of Raspberry Pi.

USB ports: This is a common port available for various peripherals such as a mouse,
keyboard, or any other I/P device. With the help of a USB port, the system can be
expanded by connecting more peripherals.

Power supply: A micro-USB power connector is available onto which a 5V power supply
can be connected.

GPIO ports: General Purpose Input Output ports are available on Raspberry Pi which
allows the user to interface various I/P devices.
SD card: The SD card slot is available on Raspberry Pi. An SD card with an operating
system installed is required for booting the device.

Camera module: Camera Serial Interface (CSI) connects the Broadcom processor to the
Pi camera.
Different model Raspberry pi s

Different models of Raspberry Pi:

o Pi 1 Model B (2012)

o Pi 1 Model A (2013)

o Pi 1 Model B+ (2014)

o Pi 1 Model A+ (2014)
o Pi 2 Model B (2015)

o Pi Zero (2015)

o Pi 3 Model B (2016)

o Pi Zero W (2017)

Advantages of Raspberry Pi:


 High-performance computing
 Low cost
 Large community support
 Compact Size
 Low Power Consumption

Disadvantages of Raspberry Pi:


 Limited Processing Power
 Limited RAM
 Medium Storage
 Networking Limitations
 Not Suitable for High-End Computing

Applications of Raspberry Pi:


 Home Automation
 Media Center
 Robotics
 Education
 Learning Programming
 Web Server

Differences Between Arduino and Raspberry Pi

S No. Arduino Raspberry Pi

Control unit of the Arduino is from the The control unit of Raspberry Pi is
1. ATMEGA family. from the ARM family.

Arduino is based on a microcontroller. Raspberry Pi is based on a


2. microprocessor.
It is designed to control the electrical Raspberry Pi computes data and
components connected to the circuit board in produces valuable outputs, and
a system. controls components in a system
3. based on the outcome of its
computation.

Arduino boards have a simple hardware and Raspberry Pi boards have a


software structure. complex architecture of hardware
4.
and software.

CPU architecture: 8 bit. CPU architecture: 64 bit.


5.

It uses very little RAM- 2 KB. Raspberry Pi requires more RAM-


6. 1 GB.

While Raspberry Pi clocks a


7. It clocks a processing speed of 16 MHz
processing speed of 1.4 GHz.

8. It is cheaper in cost. Raspberry Pi is expensive.

Its logic level is 5V. Its logic level is 3.3V.


9.

It does not have internet support. It has inbuilt Ethernet port and
10. Wi-Fi support.

It has higher current drive strength. It has lower current drive strength.
11.

Some of the applications of


Some of the applications of Arduino are
Raspberry Pi are Stop motion
12. traffic light, countdown timer, Weighing
cameras, Robot Controllers, Game
machines, etc.
Servers.
ARM Processor
Introduction

 The ARM processor stands for Advance RISC Machine.

 It is one of the extensive and most licensed processor cores in the world.

 The first ARM processor was developed in the year 1978 by Cambridge
University, and the first ARM RISC processor was produced by the Acorn Group of
Computers in the year 1985.

 These processors are specifically used in portable devices like digital cameras,
mobile phones, home networking modules and wireless communication
technologies and other embedded systems due to the benefits, such as low power
consumption, reasonable performance, etc.

There are 3 subfamilies within the ARM cortex family:

• Cortex-A (Application Processor cores)

• Cortex-R (Real Time Application cores)

Cortex-M (Microcontroller Cores)

 The Cortex-A stands for Application which will help in performance-intensive


applications such as Android, Linux and many other applications related to handsets,
tablets, desktops and laptops.

 The Cortex-R stands for the Real-time application which is used in the safety-
critical applications and where we need real-time responses of the system such as
Automotive, medical, defense, avionics and server-side technologies where data
related operations are executed.

 The Cortex-M stands for the Microcontroller which is used in most of our daily life
applications also starting from the automation to DSP applications, sensors, smart
displays, IoT applications and many more. The cortex-M series is an ocean of
possibilities with a large number of probabilities and configurations.

The main features of ARM Processor:

1. Multiprocessing Systems: ARM processors are designed to be used in cases of


multiprocessing systems where more than one processor is used to process
information. The First AMP processor introduced by the name of ARMv6K could
support 4 CPUs along with its hardware.

2. Memory Management: ARM processor has a management section. This includes


Memory Management Unit and Memory Protection Unit. These management systems
become very important in managing memory efficiently.
3. Thumb-2 Technology: Thumb-2 Technology was introduced in 2003 and was used
to create variable-length instruction sets. It extends the 16-bit instructions of initial
Thumb technology to 32-bit instructions.

4. Pipelining: Processing of instructions is done in parallel using pipelines. Instructions


are broken down and decoded in one pipeline stage. The channel advances one step at
a time to increase throughput (rate of processing).

5. A large number of Registers: A large number of registers are used in ARM


processors to prevent large amounts of memory interactions.

The ARM cortex is a complicated microcontroller within the ARM family that has ARMv7
design.

There are 3 subfamilies within the ARM cortex family:

 Cortex-A (Application Processor cores)

 Cortex-R (Real Time Application cores)

 Cortex-M (Microcontroller Cores)

ARM Cortex-A Class Processor:


 The ARM Cortex-A class processors are a family of microprocessor cores designed
by ARM Holdings, a semiconductor intellectual property (IP) company.

 Cortex-A stands for Application processor cores which are widely used in
performance-intensive applications.

 They are used in a large variety of smart phones, notebooks, tablets, eBook readers,
smart television sets, and digital set top boxes for digital televisions.

Architecture of ARM Cortex-A Class Processor


NVIC-Nested Vector Interrupt Controller

WIC – Wakeup Interrupt Controller

DAP- Debug Access Port

ETM - Embedded Trace Macrocell (The ETM is an optional debug component that enables
reconstruction of program execution)

NVIC (Nested Vector Interrupt Controller)

 A NVIC is used to manage the interrupts from multiple interrupt sources. NVIC is
closely integrated with the processor core to achieve low-latency interrupt processing
and efficient processing of late-arriving interrupts.

Wake Up Interrupt Control (WIC):

 When an interrupt request is detected, the WIC informs the power management to
power up the system so that the NVIC and the processor core can then handle the rest
of the interrupt processing.

Debug Access Port(DAP):

 The debug access port contains various functional blocks to handle debug control,
program breakpoints, and data watchpoints.

 When a debug event occurs, it can put the processor core in a halted state so that
embedded developers can examine the status of the processor at that point.

A flash patch in an Arm Cortex-M processor, specifically utilizing the Flash Patch and
Breakpoint (FPB) unit, is a hardware feature that allows for modifying or redirecting the
execution of code or data in flash memory at runtime,

A Data Watch point in ARM processors is a debugging feature that allows developers to
monitor changes to specific memory locations or variables, halting execution when a
specified access (read, write, or read/write) occurs at that data address, unlike breakpoints
which halt on instruction execution.

Key features and characteristics of ARM Cortex-A class processors

High Performance: Cortex-A processors are designed to deliver high levels of performance,
making them suitable for applications that require significant computing power.

Multicore Support: Many Cortex-A processors are designed to support multiple cores,
allowing for parallel processing and improved overall performance.
Advanced Power Management: Cortex-A processors typically incorporate advanced power
management features to optimize energy consumption without sacrificing performance.

Out-of-Order Execution: Cortex-A processors often employ out-of-order execution, a


feature that allows the processor to execute instructions that are not strictly in sequential
order.

64-bit Architecture: Many recent Cortex-A processors feature a 64-bit architecture, enabling
them to address larger amounts of memory and handle more complex computations.

ARM Cortex- A Class processor families

Cortex-A series offers a wide range of cores starting from Cortex-A5 to Cortex-A77, each
core is designed in a way to fit into a wide range of applications.

A few of Cortex-A series are explained as follows.

Cortex A5:

o The Cortex A5 is the smallest processor of the A-range, but it can still demonstrate
multicore performance.

o It is compatible with A9 and A15 processors.

Cortex-A7:

o Targeted at low-power and cost-sensitive applications.

o Used in entry-level smartphones, IoT devices, and other embedded systems.

Cortex-A9:

o Higher performance compared to Cortex-A7.

o Used in mid-range smartphones, tablets, and various embedded devices.

Cortex-A15:

o Designed for higher performance and introduced features like out-of-order execution.

o Utilized in high-end smartphones, tablets, and some server applications.

Cortex-A53:

o Part of the ARMv8-A architecture, supporting 64-bit processing.


o Designed for energy efficiency and used in a wide range of devices, including
smartphones, set-top boxes, and networking equipment.

Cortex-A57:

o 64-bit processor with higher performance compared to Cortex-A15.

o The ARM Cortex-A57, a high-performance 64-bit processor implementing


the ARMv8-A architecture, is commonly used in [Link]
configurations by pairing it with lower-power, lower-performance ARM cores like the
Cortex-A53 to achieve a balance between performance and energy efficiency in
mobile devices.

Cortex-A72:

o An evolution of the Cortex-A57 with improved performance and power efficiency.

o Used in high-performance smartphones and other devices.

Cortex-A77:

o Further enhancements in performance, energy efficiency, and AI capabilities.

o Targeted at premium smartphones and other devices requiring high computational


power.

ARM Cortex M- Class Processor


ARM Cortex-M class processor:

 The ARM Cortex-M class processors are a family of group of 32-bit RISC ARM
cores designed by ARM Holdings, a semiconductor intellectual property (IP)
company.

 These processors are specifically made for use in microcontrollers and embedded
systems, offering a balance between performance, power efficiency, and simplicity.

 The Cortex-M processors are widely used in various applications, including Internet
of Things (IoT) devices, automotive systems, industrial control systems, and
consumer electronics.

Key characteristics and features of ARM Cortex-M class processors:

Reduced Instruction Set Computing (RISC) Architecture:


Cortex-M processors follow the RISC architecture philosophy, emphasizing a simple and
streamlined set of instructions.

Low Power Consumption:

Cortex-M processors are designed to minimize power consumption while providing adequate
performance for embedded applications.

Harvard Architecture:

Cortex-M processors typically feature a Harvard architecture with separate instruction and
data buses. This architecture allows simultaneous access to instructions and data, improving
overall throughput.

Thumb and Thumb-2 Instruction Sets:

The Cortex-M processors support the Thumb instruction set, which is a compressed 16-bit
instruction set designed to reduce code size. Additionally, later versions of Cortex-M
processors support the Thumb-2 instruction set, which includes a mix of 16-bit and 32-bit
instructions for improved code density and performance.

Interrupt Handling and Real-Time Operation:

Cortex-M processors include features for efficient interrupt handling, making them well-
suited for real-time applications.

Applications of Cortex-M class processor:

 Internet of Things (IoT) Devices

 Embedded Systems

 Automotive Systems

 Medical Devices

 Smart Home Devices

 Communication Devices

 Industrial Control Systems

ARM Cortex M0- Class Processor


Key Points:

It is the smallest ARM processor.

It is very low power and energy efficient

It is a 32-bit processor.
The Key characteristics of M0 processor:

Processor pipeline: The Cortex-M0 processor has a three-stage pipeline (fetch, decode, and
execute)

Memory addressing: 32-bit addressing supporting up to 4 GB memory space

Interrupt Handling: The processors include a built-in interrupt controller called the Nested
Vectored Interrupt Controller (NVIC). This unit handles interrupt prioritization and masking
functions.

ARCHITECTURE OF M0 PROCESSOR:

Wake Up Interrupt Control (WIC):

 When an interrupt request is detected, the WIC informs the power management to
power up the system so that the NVIC and the processor core can then handle the rest
of the interrupt processing.

NVIC (Nested Vector Interrupt Controller)

 A NVIC is used to manage the interrupts from multiple interrupt sources. NVIC is
closely integrated with the processor core to achieve low-latency interrupt processing
and efficient processing of late-arriving interrupts.

Debug Subsystem:
 The debug subsystem contains various functional blocks to handle debug control,
program breakpoints, and data watchpoints.

 When a debug event occurs, it can put the processor core in a halted state so that
embedded developers can examine the status of the processor at that point.

JTAG or Serial Wire interface:

 The JTAG or Serial Wire interface units provide access to the bus system and
debugging functionalities.

 The JTAG protocol is a popular 4-pin (5-pin if including a reset signal)


communication protocol commonly used for IC and PCB testing.

Internal Bus System

 The internal bus system, data path in the processor core, and the AHB (Advanced
High-Performance Bus)-Lite bus interface is all 32-bit wide. AHB-Lite is an on-chip
bus protocol used in many ARM processors.

 This bus protocol is part of the AMBA (Advanced Microcontroller Bus Architecture)
specification, which is a bus architecture developed by ARM and widely used in the
IC design industry.

Instruction Set of M0 Processor


 The ARM Cortex-M0 processor features a reduced instruction set designed
specifically for microcontroller applications.

1. Data Processing Instructions

2. Shift and Rotate Instructions

3. Load/Store Instructions

4. Branch Instructions

5. Status Register Access Instructions

6. Memory Access Instructions.

1. Data Processing Instructions:

[Link]– Add two registers / Register and an immediate value

Ex: ADD rd, rn / ADD rd, imm

[Link] –Subtract two registers / Register and an immediate value

Ex: SUB rd, rn / SUB rd, imm


[Link]- Multiply two registers

Ex: MUL rd, rn

[Link]– Add two registers / Register and an immediate value with carry

Ex: ADC rd, rn / ADC rd, imm

[Link]– Subtract two registers / Register and an immediate value with barrow

Ex: SBC rd, rn / SBC rd, imm

[Link]– Bitwise AND operation on registers / Register and immediate

Ex: AND rd, rn / AND rd, imm

7. ORR – Bitwise OR operation on registers/ Register and immediate

Ex: OR rd, rn / OR rd, imm

8. EOR – Bitwise XOR operation on registers/ Register and immediate

Ex: EOR rd, rn / EOR rd, imm

9. MOV – Move to copy register contents

Ex: MOV rd,rn

The instruction MOV rd, rn is an assembly language instruction that copies the value from
one register (rn) to another register (rd).

10. CMP – Compare two registers or register vs immediate to set status flags

Ex: CMP rn, rm

11. CMN- Compare Negative

Ex: CMN rn, rm

Shift/ Rotate Instructions

1. LSL – Logical Shift Left

Ex: LSLS rd, rm

2. LSR – Logical Shift Right

Ex: LSRS rd, rm

3. ASL – Arithmetic Shift Left

Ex: ASL rd, rm


4. ASR – Arithmetic Shift Right

Ex: ASR rd, rm

Load/ Store Instructions

[Link] – Load word or half-word from memory into register or

Ex: LDR rd, [rn, imm]

LDRH rd, [rn, imm]

[Link] – Store register contents into memory word or half-word

Ex: STR rd, [rn, imm]

STRH rd, [rn, imm]

Branch Instructions

B: Branch

BL: Branch with Link (used for subroutine calls)

BX: Branch and Exchange instruction set

BLX: Branch with Link and Exchange instruction set

POP: Pop Registers from the Stack

PUSH: Push Registers onto the Stack

CPSIE: Enable Interrupts

CPSID: Disable Interrupts

Status Register Access

1. MRS – Move PSR (Program Status Register) contents to general purpose register

2. MSR – Move general purpose register contents to PSR

Memory Access Instructions

1. LDREX/STREX – Locked read/write to synchronize access to shared resources

2. LDM/STM – Unprivileged variants to protect regions

3. LDRT/STRT – Unprivileged access to system control space


EXPLANATION OF ABOVE INSTRUCTIONS:

The ARM instruction ADD rd, rn adds the value in register rn to itself and stores the result
in register rd.

The ADD rd, imm instruction is used in assembly languages, to add an immediate value to a
register and store the result in another register.

The instruction SUB rd, rn is an ARM assembly instruction that performs a subtraction. It
subtracts the value in register rn from the value in register rd, and stores the result back into
register rd.

The SUB rd, imm assembly instruction subtracts an immediate value from a register and
stores the result in another register.

The instruction MUL rd, rn is an ARM assembly language instruction that performs a
multiplication operation. It multiplies the value in register rn by the value in another
unspecified register. The result of this multiplication is then stored in register rd.

The instruction MUL rd, rn is an ARM assembly language instruction that performs a
multiplication operation. It multiplies the value in register rn by the value in register rm (not
specified in the query but implied by the usage of MUL rd, rn, rm in most documentation)
and stores the least significant 32 bits of the result in register rd

The basic syntax is ADC Rd, Rn, Rm where Rd is the destination register, Rn is the first
source register, and Rm is the second source register.

Add with Carry(ADC) : The ADC rd, rn instruction performs an add with carry operation in
ARM assembly language. It adds the value in register rn to the value in another register
(implied or specified, depending on the specific instruction variant) and also includes the
carry flag's value in the addition. The result of this addition is then stored in the destination
register rd.

Subtract with carry (SBC): The SBC rd, rn instruction in ARM assembly represents
"Subtract with Carry" and performs a subtraction operation on two registers, taking into
account the carry flag. Specifically, it subtracts the value in register rn and the complement of
the carry flag from the value in register rd, storing the result in rd.

The instruction can be expressed as: rd = rd - rn - !carry

In ARM assembly, "AND rd, rn" typically represents a bitwise AND operation where the
result is stored in register rd, and the operands are rn and an immediate value or another
register. Specifically, rd is the destination register, and rn is one of the source registers in the
operation.

The instruction MOV rd, rn is a data processing instruction in assembly language that copies
the value from a source register rn to a destination register rd
The instruction CMP rn, rm is a ARM assembly language instruction that compares the value
in register rn with the value in register rm. It subtracts the value of rm from rn and updates
the condition flags in the CPSR (Current Program Status Register) based on the result, but
discards the result of the subtraction.

CMN rn, rm : The instruction compares the value in register "rn" with the value in register
"rm" by performing an addition, but discards the result.

The LSLS rd, rm instruction in ARM assembly performs a logical left shift on the value in
register rm and stores the result in register rd, updating the condition flags based on the result.

Ex: If rm contains the value 0x00000003 (binary 00000000 00000000 00000000 00000011)
and rd is specified as r0 then after the LSLS r0, rm instruction, r0 will contain the
value 0x0000000C (binary 00000000 00000000 00000000 00001100). The N flag (Negative)
and Z flag (Zero) in the CPSR will be updated based on the result.

The assembly instruction LSRS rd, rm, rs performs a logical right shift operation on the value
in register rm and stores the result in register rd. The shift amount is determined by the least
significant byte of register rs

Ex: register rm contains the value -----0b11001100 (decimal 204) and

register rs contains -----0b00000010 (decimal 2), then

The value in rm (0b11001100) is logically shifted right by 2 bits.

The result (0b00110011, decimal 51) is stored in register rd.

The ARM instruction ASLS Rd, Rm, #sh or ASLS Rd, Rd, Rs refers to an Arithmetic Shift
Left (ASL) operation in the Thumb instruction set, specifically with the S suffix indicating
that the condition code flags will be updated.
Load Register (LDR): The ARM assembly instruction LDR dr, [rn, imm] is used to load a
word (32 bits) from memory into a register. dr represents the destination register, rn is the
base register, and imm is an immediate offset. The memory address is calculated by adding
the value in rn to the immediate value imm

[rn, imm]:This is the addressing mode. It specifies how the memory address is calculated.

rn: This is the base register. The value in this register is used as the starting point for
calculating the memory address.

imm: This is an immediate offset. It is a constant value that is added to the base register's
value to form the final memory address.

Load Register Halfword(LDRH):The LDRH rd, [rn, imm] instruction in ARM


assembly loads a halfword (16 bits) from memory into a register.

LDRH: This is the instruction mnemonic, indicating a Load Register Halfword operation.

rd: This is the destination register where the loaded halfword will be stored. It's a general-
purpose register.

[rn, imm]: This specifies the memory address calculation.

rn: This is the base register. The value in this register is used as the base address.

imm: This is a signed immediate value (an offset) that is added to the base address.

Store Register(STR) : The instruction STR rd, [rn, imm] is an ARM assembly language
instruction that stores the value from a register rd into memory. The memory address is
calculated by adding an immediate offset imm to the value in register rn.

Branch Instructions

Unconditional Branch (B):


 The B instruction provides a simple jump to a specified address or label within the
program.

 It's used for direct jumps, such as to the beginning of a loop or to skip over a section
of code.

Branch with Link (BL): The BL instruction is used for subroutine calls (also known as
function calls). It not only jumps to the specified address but also stores the address of the
instruction immediately following the BL instruction in the Link Register (LR or R14).

The BLX instruction in ARM architecture stands for "Branch with Link and Exchange
instruction set." It is a crucial instruction used for calling subroutines and managing
transitions between the ARM (A32) and Thumb (T32) instruction sets.

POP: The POP instruction retrieves data from the top of the stack and places it into a
designated register. The stack pointer is adjusted accordingly to reflect the removal of data.

PUSH: The PUSH instruction saves data (registers, etc.) onto the stack.

In ARM processors, the MRS instruction (Move to Register from Special register) is used to
transfer the contents of a special program status register (PSR) into a general-purpose
register.

The primary function of MSR is to transfer data from a general-purpose register to a special
register.

Load-Exclusive (LDREX): Loads a value from memory and marks the memory location as
exclusively accessed by the current processor.

In ARM processors, LDM (Load Multiple) and STM (Store Multiple) are instructions that
allow for efficient transfer of multiple registers to or from memory with a single instruction.

In ARM processors, LDRT and STRT are instructions used for loading and storing data
from memory, respectively.
NOTE: The CPSR (Current Program Status Register) T bit, or Thumb bit, determines
the processor's current execution state. When T=1, the processor is in Thumb state, using 16-
bit instructions, and when T=0, it's in ARM state, using 32-bit instructions.

ARM and Thumb Instruction Set


The Thumb instruction set is a subset of the ARM instruction set architecture (ISA) designed
to improve code density and reduce memory usage, particularly in memory-constrained
environments such as embedded systems and mobile devices.

Here are the key aspects of the Thumb instruction set:

16-bit Instructions: Unlike the 32-bit instructions in the ARM instruction set, Thumb
instructions are 16 bits long. This reduction in instruction size allows more instructions to fit
into the same amount of memory, thereby increasing code density.

Reduced Instruction Set: The Thumb instruction set includes a subset of the instructions
available in the ARM instruction set. While the Thumb instruction set sacrifices some
functionality compared to ARM instructions, it still provides a wide range of operations
necessary for typical application tasks.

Limited Addressing Modes: Thumb instructions typically use a reduced set of addressing
modes compared to ARM instructions. This simplification helps in reducing the complexity
of the instruction set and achieving higher code density.

Thumb-2 Extension: In addition to the original Thumb instruction set, ARM introduced
Thumb-2, which extends the Thumb instruction set with additional 32-bit instructions.
Thumb-2 combines the benefits of both Thumb and ARM instruction sets, providing
improved code density while retaining the flexibility and functionality of the ARM
architecture.

Examples of Thumb Instruction set

Move (MOV):

MOV Rd, Rs: Moves the value from register Rs to register Rd.

Example: MOV R0, R1 copies the value from register R1 to register R0.

Add (ADD):

ADD Rd, Rs, Rn: Adds the values from registers Rs and Rn and stores the result in register
Rd.

Example: ADD R2, R3, R4 adds the values from registers R3 and R4 and stores the result in
register R2.

Subtract (SUB):

SUB Rd, Rs, Rn: Subtracts the value of register Rn from the value of register Rs and stores
the result in register Rd.

Example: SUB R5, R6, R7 subtracts the value of register R7 from the value of register R6
and stores the result in register R5.

Load (LDR):

LDR Rd, [Rn, #offset]: Loads a word from memory at the address specified by the sum of
the value in register Rn and the offset, and stores it in register Rd.

Example: LDR R0, [R1, #4] loads a word from memory at the address stored in R1 plus 4
bytes and stores it in R0.

Store (STR):

STR Rd, [Rn, #offset]: Stores the value in register Rd into memory at the address specified
by the sum of the value in register Rn and the offset.

Example: STR R2, [R3, #-8] stores the value in R2 into memory at the address stored in R3
minus 8 bytes.

Branch (B):

B label: Unconditionally branches to the instruction at the specified label.

Example: B loop branches to the instruction labeled "loop".

Conditional Branch (Bcc):


Bcc label: Conditionally branches to the instruction at the specified label based on the
condition code (cc).

Example: BNE error handler branches to the instruction labelled "error handler" if the
previous comparison resulted in a non-equal condition.

You might also like