Module 1
Module 1
ARCHITECTURE
Unit 1
An Overview of Computing Systems: History of Computers, The Computing Device,
The ARM7TDMI Programmers’ Model: Introduction, Data types, Processor Modes,
Registers, Program Status Registers, The vector Table.
Assembler Rules and Directives: Structure of Assembly Language Modules, Registers,
Directives, and Macros.
Loads, Stores, and Addressing: LODS and STORES instructions, Operand Addressing,
ENDIANNES
Text Book-1: 1.1 to 1.3; 2.1 to 2.6; 4; 5.3, 5.4, 5.5
History of RISC
• The history of Reduced Instruction Set Computers (RISC) actually goes back quite a
few years in the annals of computing research. Arguably, some early work in the field
was done in the late 1960s and early 1970s by IBM, Control Data Corporation and
Data General.
• In 1981 and 1982, David Patterson and Carlo Séquin, both at the University of
California, Berkeley, investigated the possibility of building a proces sor with fewer
instructions
• Their goal was to create a very simple architecture, one that broke with traditional
design techniques used in Complex Instruction Set Computers (CISCs), e.g., using
microcode (defined below) in the processor; using instructions that had different
lengths; supporting complex, multi-cycle instructions, etc.
What is RISC?
RISC, or Reduced Instruction Set Computer is a type of microprocessor architecture that
utilizes a small, highly-optimized set of instructions, rather than a more specialized set of
instructions often found in other types of architectures.
History
The first RISC projects came from IBM, Stanford, and UC-Berkeley in the late 70s and early
80s. The IBM 801, Stanford MIPS, and Berkeley RISC 1 and 2 were all designed with a
similar philosophy which has become known as RISC. Certain design features have been
characteristic of most RISC processors:
o one cycle execution time: RISC processors have a CPI (clock per instruction) of one
cycle. This is due to the optimization of each instruction on the CPU and a technique
called PIPELINING
o pipelining: a technique that allows for simultaneous execution of parts, or stages, of
instructions to more efficiently process instructions;
o large number of registers: the RISC design philosophy generally incorporates a larger
number of registers to prevent in large amounts of interactions with memory
1. Single-cycle execution: Unlike processors of its time, which often required multiple
cycles for instructions, this system executed all instructions in a single cycle,
streamlining programming.
2. Fixed instruction format: All instructions were of the same size and had a fixed format,
simplifying decoding and reducing the complexity of hardware design.
3. Absence of microcode: Unlike many processors, this system didn't utilize microcode,
which simplified validation and debugging processes.
4. Explicit data access: Data retrieval from external memory required explicit Load and
Store instructions, contrasting with the single-instruction memory operations in other
architectures.
5. Simplified instruction set: The processor featured a small number of instructions,
making decoding easier and requiring fewer bits for encoding operations. 6. Increased
program size: Due to the simplicity of operations, program size was expected to increase
compared to older architectures, but this was offset by boosting processor frequency.
7. Trade-off with complexity: While easier for programmers, the design complexity
increased, especially with respect to hardware design and validation.
WHY ARM?
1. The processor still had no caches (on-chip, localized memory) or memory management unit
(MMU),
2. multiply and multiply-accumulate instructions were added to increase performance,
3. More registers for handling interrupts were added to the architecture,
4. This microprocessor achieved a typical clock speed of 12 MHz in a 2-micron process
Origins with Acorn Computers: ARM Holdings PLC traces its roots back to Acorn
Computers, a UK-based company known for producing desktop PCs, notably the BBC
Micro, popular in educational markets.
Development of ARM1: In 1983, Acorn decided to design its own microprocessor instead of
using existing architectures like the Motorola 68000. Steve Furber and Sophie Wilson joined
the design team, with VLSI Technology producing the first samples.
Introduction of ARM1: The ARM1, utilizing less than 25,000 transistors, was fabricated in
1985. Remarkably, it functioned correctly upon arrival, a rarity at that time.
Processor Speed: Unlike today's processors running at gigahertz speeds, the ARM1 operated
at a modest 4 MHz due to technological limitations of the era.
Evolution to ARM2: Subsequent revisions led to the ARM2, featuring enhancements such
as multiply instructions and increased clock speed, making it suitable for use in the
Archimedes desktop PC.
Application in Archimedes Desktop PC: Acorn incorporated the ARM2 into its
Archimedes desktop PC, while VLSI Technology marketed it as the VL86C010 processor
chip set, bundled with various controllers.
The Creation of ARM LTd
1. Introduction of ARM3: In response to evolving desktop architectures in 1989, ARM
developed the ARM3, featuring a 4K unified cache, to compete with the Motorola
68000 and x86 families.
2. Shift towards Embedded Processors: While Acorn faced challenges with the
dominance of IBM PC, VLSI Technology found success in marketing ARM
processors for embedded systems, attracting companies like Apple for their personal
digital assistants (PDAs).
3. Formation of Advanced RISC Machines Ltd. (ARM Ltd.): Apple's interest in a
processor for their PDAs led to the creation of ARM Ltd., with Apple and Acorn
Group as stakeholders, adopting a unique business model of licensing processor
designs to other companies.
4. Evolution to ARM6: The ARM6, introduced after architectural extensions, included
32-bit addressing and supported both big- and little-endian memory formats, paving
the way for further innovations in processor design.
5. Introduction of ARM7: Introduced in 1993, the ARM7 lacked some features but set
the stage for its successor, the ARM7TDMI, which incorporated new hardware for
external debugging and introduced the Thumb instruction set for enhanced
performance in embedded systems.
6. Expansion and Adoption: ARM7TDMI's compact design, low power consumption,
and rich instruction set made it popular in embedded systems, especially in the
burgeoning cell phone industry, laying the groundwork for subsequent processor
designs.
7. Continued Advancements: Throughout the 1990s, ARM made continual
improvements to its architecture with the introduction of ARM8, ARM9, and ARM10
processor cores, along with derivatives, marking significant milestones in the
evolution of ARM processors.
8. Expansion into Other Markets: Agreements with companies like Digital Equipment
Corporation led to the creation of StrongARM and subsequent versions produced by Intel
under the brand XScale, showcasing ARM's expansion beyond its original scope.
ARM Today
ARM's Growth and Expansion:
1. Proliferation of ARM-Based Devices: By 2002, ARM processors were powering
around 1.3 billion devices, particularly in cell phones dominated by Nokia, with TI as
a major silicon supplier alongside other partners like Philips and Qualcomm.
2. Diversification Beyond Processor Cores: ARM expanded its focus beyond
processor cores, acquiring companies like Adelante Technologies, Axys Design
Automation, Artisan Components, Keil Software, Falanx, and SOISIC to offer
comprehensive solutions including DSP processors, hardware tools, standard cell
libraries, and 3D graphics accelerators.
3. Rapid Growth and Adoption: Over six years, ARM experienced rapid growth,
aiming to facilitate the design of complete system-on-chip architectures using ARM
technology, resulting in billions of ARM processors being shipped across various
applications.
4. Underappreciated Presence in Finished Products: Despite ARM's widespread
adoption, its presence in finished products often goes unnoticed by average
consumers, with silicon vendors receiving more attention. For instance, Nokia cell
phone users might not realize that ARM provided part of the design alongside TI's
silicon.
• Grouping of Bits: Bits are often grouped into units of eight, called bytes, or larger
units depending on the device manufacturer.
• Data Sizes: Different processors have different definitions for data sizes. For
example:
• Byte: 8 bits
• Halfword: 16 bits
• Word: 32 bits
• Instruction Length: While the length of instructions doesn't matter initially, later
we'll learn that instructions can be either 16 or 32 bits long. This means:
• Data Operations: Most data operations like ADD are performed on word quantities,
but we'll also work with smaller, 16-bit values later on.
Processor Modes
Version 4T cores support seven processor modes: User, FIQ, IRQ, Supervisor, Abort,
Undefined, and System, as shown in Figure 2.1. It is possible to make mode changes under
software control, but most are normally caused by external conditions or exceptions. Most
application programs will execute in User mode. The other modes are known as privileged
modes, and they provide a way to service exceptions or to access protected resources, such as
bits that disable sections of the core, e.g., a branch predictor or the caches, should the
processor have either of these.
Modes of Operation:
Interrupt Handling:
• ARM7TDMI supports two types: Fast Interrupt (FIQ) mode and Interrupt Request
(IRQ) mode.
• FIQ mode handles urgent interrupts, while IRQ mode handles lower priority
interrupts.
Abort Mode:
• Used for recovering from exceptional conditions, such as invalid memory access. •
Also supports virtual memory systems, often used by operating systems like Linux.
Undefined Mode:
• Programmers or the operating system must determine how to recover from such
errors.
Registers
• 30 general-purpose registers
•6 status registers
• Bankedregisters are swapped during mode changes to save machine state quickly
during interrupts.
• The Program Counter holds the address of the instruction being fetched. •
• Eachprivileged mode (except System mode) has a Saved Program Status Register
(SPSR).
• Control bits include interrupt disable bits and a state indicator bit (Thumb/ARM). •
• For example, when an interrupt (IRQ) occurs, the processor changes the Program
Counter to a designated address and begins fetching instructions from there.
• Many processors, including the Cortex-M4, have addresses at these vector locations
in memory, while the ARM7TDMI processor places instructions here.
• The Reset exception vector, located at address 0x0 in memory, is essential as the
machine fetches from this address immediately after reset.
• Development tools often provide startup files for microcontrollers, including startup
code, initialization routines, and exception vector assignments.
• Thecode includes directives for the assembler and an instruction to put the processor
in an infinite loop.
• Labels represent memory addresses and are optional but must be unique.
• Instructions,
directives, and pseudo-instructions must be preceded by
whitespace.
• ARM7TDMI instructions come from the ARM version 4T instruction set, while
Cortex-M4 uses Thumb-2 instructions from the v7-M instruction set.
• Directives and pseudo-instructions offer additional functionality and flexibility.
• In Keil tools, the first semicolon on a line marks the beginning of a comment,
unless within a string constant.
• Keil supports constants in the format n_xxx, where n is a base between 2 and
9, and xxx is a number in that base.
• Character constants are enclosed in single quotes, while string constants are
enclosed in double quotes.
• Standard C escape sequences can be used within string constants, interpreted
differently by various assemblers.
• Keil tools allow single character constants and string constants with escape
sequences.
• Code Composer Studio tools use .string directive for string constants but do
not interpret escape characters.
• To include escape characters and add a NUL character, use the .cstring
directive.
• Keil tools have case rules for commands, allowing either uppercase or
lowercase but not a mix.
Keil tools
Predefined Registers
Most assemblers provide predefined register names for readability in code. • The
• Syntax: .
.asg "character string", substitution
symbol
• Example usage: .
.asg R13,
STACKPTR
• Equating a Symbol to a Numeric Constant (Keil
Tools):
• Syntax: or .
• Memory allocation directives like DCB, DCW, and DCD are used to define
data contents.
• Allocating Memory and Specifying Contents (Code Composer
Studio):
• CCS provides directives like .byte, .half, .int, etc., for initializing memory with
different data types.
• Ending a Source
File:
E .e
N n
D d
KEIL tools
1. Register Name Definition
The RN directive defines a register name for a specified register.
Syntax name RN expr
where:
name name to be assigned to the register. name cannot be the
same as any of the predefined names.
expr evaluates to a register number from 0 to
Usage
• Use RN to allocate convenient names to registers, to help you to remember what you
use each register for. Be careful to avoid conflicting uses of the same register under
different names.
Example
regname RN 11 ; defines regname for
register 11
sqr4 RN r6 ; defines sqr4 for
register 6
2. Equating symbol to a numeric constant
• syntax is ENTRY
• Your program must have at least one ENTRY point for a program
• Example
• Strings, floating-point constants, and even addresses can be stored in memory as data
using various directives.
• Keil Tools
• DCB, actually defines the initial runtime contents of memory. The syntax is •
{label} DCB expr{,expr}…
• where expr is either a numeric expression that evaluates to an
integer in the range −128 to 255, or a quoted string, where the
characters of the string are stored consecutively in memory.
• Since the DCB directive affects memory at the byte level, you should use an ALIGN
directive afterward if any instructions follow to ensure that the instruction is aligned
correctly in memory.
6. Aligning Data or Code to Appropriate Boundaries
The ALIGN directive aligns the current location to a specified boundary by padding with
zeros. The syntax is
ALIGN {expr{,offset}}
where expr is a numeric expression evaluating any power of two from 20 to 231, and
offset can be any numeric expression. The current location is aligned to the next
address of the form
offset + n * expr
If expr is not specified, ALIGN sets the current location to the next word (four byte)
boundary.
AREA Example, CODE, READONLY
start LDR r6, = label1
; code
MOV pc,lr
label1 DCB 1 ; pc now misaligned
ALIGN ; ensures that subroutine1 addresses
subroutine1 MOV r5, #0x5 ; the following instruction
Macros:
Macros in assembly language serve a similar purpose to functions in higher-level languages.
They allow developers to define a set of instructions or operations once and then invoke them
multiple times by name throughout the code. This abstraction saves time and effort by
eliminating the need to rewrite the same sequence of instructions repeatedly.
Advantages and Disadvantages:
• Advantages:
• Disadvantages:
• Parameters: Can be defined within the macro definition to accept arguments passed
during invocation.
Example:
Suppose you have a sequence of instructions that performs a specific computation and is
repeated at multiple places in your code. Instead of copying and pasting this sequence each
time, you can define a macro to encapsulate these instructions. Then, whenever you need to
execute this sequence, you simply invoke the macro by its name, providing any necessary
arguments.
The MACRO directive marks the start of the definition of a macro. Macro expansion
terminates at the MEND directive.
Syntax Two directives are used to define a macro. The syntax is: MACRO
{$label} macroname{$cond} {$parameter{,$parameter}...}
; code
MEND
where:
$label is a parameter that is substituted with a symbol given when the macro is
invoked.
The symbol is usually a label.
macroname is the name of the macro. It must not begin with an instruction or
directive name.
$cond is a special parameter designed to contain a condition code. Values other
than valid condition codes are permitted.
$parameter is a parameter that is substituted when the macro is invoked. A default
value for a parameter can be set using this format:
$parameter="default value"
Double quotes must be used if there are any spaces within, or at either end of,
the
default value.
• where $label is a parameter that is substituted with a symbol given when the macro is
invoked.
• The symbol is usually a label.
• The macro name must not begin with an instruction or directive name.
• The parameter $cond is a special parameter designed to contain a condition code;
however, values other than valid condition codes are permitted.
• The term $parameter is substituted when the macro is invoked.
• Within the macro body, parameters such as $label, $parameter, or $cond can be used
in the same way as other variables. They are given new values each time the macro is
invoked.
Parameters must begin with $ to distinguish them from ordinary symbols. Any number of
parameters can be used. The $label field is optional, and the macro itself defines the locations
of any labels
Assembler Operators:
Assembler operators are primitive operations applied to data before its use in an instruction.
These operators are not part of the instruction set but are used to manipulate data efficiently.
Types of Operators:
• Binary Operators: Operate on two values and are more commonly used.
Example:
Binary operators, such as shifting, rotating, and bitwise logical operations, are particularly
useful for bit manipulation tasks. For instance, to set a specific bit in a register, you can use
the bitwise OR operator to combine the register value with a bitmask representing the desired
bit.
2. Base Register and Offset: The addressing mode typically involves a base register
and an optional offset. For example:
LDR r9, [r12, r8, LSL #2]
2. Effective Address: The effective address is the final memory address calculated
based on the base register, offset, and any additional shifts or operations. It's denoted
as ea<operands>.
3. Addressing Modes:
• Halfword and byte loads/stores handle data in specific parts of the register
(LSB for loads, and LSB for stores).
OPERAND ADDRESSING
1. Format of Pre-indexed :
Addressing
phpCopy
code
<con
d>
<R
d>
•: Optional condition code.
•: Destination (for stores) or source (for loads) register.
•: Base register.
<R
n>
<offse
t>
• The offset is added to the value in the base register () to calculate the
effective address. n>
<R
• If the specifier is used, the effective address is written back to the base
register.
• Without , the base register retains its original value after the instruction.
3. Offset :
Options
4. Exampl :
es
• Examples include storing and loading data with various offset calculations:
• STR r3, [r0, r5, LSL
#3]
•
LDR r6, [r0, r1, ROR
• #6]!
• LDR r0, [r1, #-
• 8]
1. Format of Post-indexed :
Addressing
phpCopy
code
<R
n>
<offse
t>
: Optional condition code.
: Destination (for stores) or source (for loads) register.
: Base register.
: Offset added to the base register after the data transfer.
2. Operati :
on
3. Incrementing :
Usefulness
• Useful
for stepping through tables or lists, as the base address is automatically
updated.
4. Exampl :
es
• Examples include storing and loading data with automatic base register
updates:
<r
r 5>
then . 2
5. Flexibili :
ty
ENDIANNESS
• Coined by Danny Cohen in 1981, likening the debate over bit and byte
ordering to conflicts in literary works like Gulliver's Travels and Alice's
Adventures in Wonderland.
• Endianness in ARM:
• Little-endian stores the least significant byte at the lowest address, while big
endian stores the most significant byte there.
• Example Scenario:
• Little-endian: 0x0000BABE.
• Big-endian: 0x0000FACE.
Programming Considerations:
• Tools like Keil and Code Composer Studio may reorder data for clarity.