ARM Processor 19.03.25
ARM Processor 19.03.25
◼ Introduction
Architecture
Programmers Model
Instruction Set
TM
1 1
History of ARM
• ARM (Acorn RISC Machine) started as a new, powerful, CPU design for the
replacement of the 8-bit 6502 in Acorn Computers (Cambridge, UK, 1985)
• First models had only a 26-bit program counter, limiting the memory space
to 64 MB (not too much by today standards, but a lot at that time).
• 1990 spin-off: ARM renamed Advanced RISC Machines
• ARM now focuses on Embedded CPU cores
• IP licensing: Almost every silicon manufacturer sells some microcontroller
with an ARM core. Some even compete with their own designs.
• Processing power with low current consumption
• Good MIPS/Watt figure
• Ideal for portable devices
• Compact memories: 16-bit opcodes (Thumb)
• New cores with added features
• Harvard architecture (ARM9, ARM11, Cortex)
• Floating point arithmetic
• Vector computing (VFP, NEON)
• Java language (Jazelle)
TM
2 2
RISC Architecture
vs CISC Architecture
RISC CISC
It stands for Reduced Instruction Set It stands for Complex Instruction Set
Computer. Computer.
It is a microprocessor architecture that uses This offers hundreds of instructions of
small instruction set of uniform length. different sizes to the users.
These simple instructions are executed in This architecture has a set of special
one clock cycle. purpose circuits which help execute the
instructions at a high speed.
These chips are relatively simple to design. These chips are complex to design.
Examples of RISC chips include SPARC, Examples of CISC include Intel architecture,
POWER PC. AMD.
TM
3 3
RISC Architecture
vs CISC Architecture
RISC CISC
It has less number of instructions. It has more number of instructions.
Simple addressing formats are supported. The instructions interact with memory using
complex addressing modes.
Registers are used for procedure arguments The stack is used for procedure arguments
and return addresses. and return addresses.
TM
4 4
Facts
• 32-bit CPU
• 3-operand instructions (typical): ADD Rd,Rn,Operand2
• RISC design…
• Few, simple, instructions
• Load/store architecture (instructions operate on registers, not memory)
• Large register set
• Pipelined execution
• … Although with some CISC touches…
• Multiplication and Load/Store Multiple are complex instructions (many cycles
longer than regular, RISC, instructions)
• … And some very specific details
• No stack. Link register instead
• PC as a regular register
• Conditional execution of all instructions
• Flags altered or not by data processing instructions (selectable)
• Concurrent shifts/rotations (at the same time of other processing)
• …
TM
5 5
Agenda
Introduction
◼ Architecture
Programmers Model
Instruction Set
TM
6 6
Topologies
Von Neumann Harvard
ARM9s
ARM7s and newers
and olders
Inst. Data
AHB
bus
I D
Cache Cache
MEMORY
& I/O
Bus Interface
AHB
Memory-mapped I/O: bus
PC bus
PC
REGISTER
ALU bus BANK
Control Lines
INSTRUCCTION
DECODER
Multiplier
A bus
B bus
SHIFT
A.L.U.
Instruction Reg.
Thumb to
ARM
Write Data Reg. Read Data Reg.
translator
D[31:0]
Agenda
Introduction
Architecture
◼ Programmers Model
Instruction Set
TM
9 9
Data Sizes and Instruction Sets
TM
10 10
Processor Modes
◼ The ARM has seven operating modes:
TM
11 11
The Registers
TM
12 12
Special Registers
◼ SP (R13): Stack Pointer. There is no stack in the ARM architecture. Even so,
R13 is usually reserved as a pointer for the program-managed stack
◼ CPSR : Current Program Status Register. Holds the visible status register
◼ SPSR : Saved Program Status Register. Holds a copy of the previous status
register while executing exception or interrupt routines
- It is copied back to CPSR on the return from the exception or interrupt
- No SPSR available in User or System modes
TM
13 13
Program Status Registers
31 28 27 24 23 16 15 8 7 6 5 4 0
N Z C V undefined I F T mode
f s x c
TM
14 14
Register Organization Summary
User,
FIQ IRQ SVC Undef Abort
SYS
r0
r1
User
r2 mode
r3 r0-r7,
r4 r15, User User User User
r5 and mode mode mode mode
cpsr r0-r12, r0-r12, r0-r12, r0-r12,
r6
r15, r15, r15, r15,
r7 and and and and
r8 r8 cpsr cpsr cpsr cpsr
r9 r9
r10 r10
r11 r11
r12 r12
r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp)
r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr)
r15 (pc)
cpsr
spsr spsr spsr spsr spsr
TM
15 15
Addressing Modes
TM
16 16
Load/Store Addressing
❑ Register
LDR R0, [R1, R2] ; Load the word data from mem[R1+R2] -> R0
❑ Scaled register
LDR R0, [R1, R2, LSL #2] ; Load the word data from mem[R1+4*R2]
to R0
TM
17 17
Addressing modes
• Pre-index addressing
▪ without a writeback (STRB R0, [R1, #4])
▪ with a writeback (STRB R0, [R1, #4]!)
(c) Post-indexing
Data Processing Addressing
TM
21 21
Branch Instruction Addressing
TM
22 22
Load/Store Multiple Addressing
Load Multiple instructions load a subset (possibly all) of the general- purpose
registers from memory.
The list of registers for the load or store is specified in a 16-bit field in the
instruction with each bit corresponding to one of the 16 registers.
Four addressing modes are used : increment after, increment before, decrement
after, and decrement before.
TM
23 23
Load/Store Multiple Addressing
suffix meaning
IA increase after
IB increase before
DA decrease after
DB decrease before
TM
24 24
Load/Store Multiple Addressing
TM
25 25
ARM Assembly Language
Programming
❏ Outline:
TM
26 26
The ARM instruction set
TM
27 27
The ARM instruction set
TM
28 28
Data processing instructions
TM
29 29
Data processing instructions
1. Arithmetic Instructions :
TM
30 30
Data processing instructions
❏ Arithmetic operations:
ADD r0, r1, r2 ; r0 := r1 + r2
ADC r0, r1, r2 ; r0 := r1 + r2 + C
SUB r0, r1, r2 ; r0 := r1 - r2
SBC r0, r1, r2 ; r0 := r1 - r2 + C - 1
RSB r0, r1, r2 ; r0 := r2 - r1
RSC r0, r1, r2 ; r0 := r2 - r1 + C - 1
TM
31 31
Data processing instructions
2. Logical Instructions :
TM
32 32
Data processing instructions
TM
33 33
Data processing instructions
3. Move Instructions :
TM
34 34
Data processing instructions
MOV r0, r2 ; r0 := r2
MVN r0, r2 ; r0 := not r2
TM
35 35
Data processing instructions
4. Compare Instructions :
TM
36 36
Data processing instructions
❍ Comparison operations:
CMP r1, r2 ; set cc on r1 - r2
❍ These instructions just affect the condition codes (N, Z, C, V) in the CPSR
TM
37 37
Data processing instructions
❏ Immediate operands
TM
38 38
Data processing instructions
Barrel Shifter
TM
39 39
Data processing instructions
Barrel Shifter
TM
40 40
Data processing instructions
Barrel Shifter
TM
41 41
Data processing instructions
❏ Shifted register operands
TM
42 42
Data processing instructions
Barrel Shifter
TM
43 43
Data processing instructions
TM
44 44
Data processing instructions
6. Multiplication Instructions :
Barrel Shifter
TM
45 45
Data processing instructions
❏ Multiplication
TM
46 46
The ARM instruction set
TM
47 47
Data transfer instructions
TM
48 48
Data transfer instructions
TM
49 49
Data transfer instructions
❏ Addressing memory
TM
50 50
Data transfer instructions
TM
51 51
Data transfer instructions
TM
52 52
Data transfer instructions
TM
53 53
Data transfer instructions
TM
54 54
Data transfer instructions
; r2 := mem[r1+4]
; r5 := mem[r1+8]
– the {…} list may contain any or all of r0 - r15
– the lowest register always uses the lowest address, and so on, in
increasing order
– it doesn’t matter how the registers are ordered in {…}
TM
55 55
The ARM instruction set
TM
56 56
Control flow instructions
TM
57 57
Control flow instructions
❍ Note: data ops and loads can also change the PC!
TM
58 58
Control flow instructions
❏ Conditional branches
TM
59 59
Branch
conditions
Branch Interpretation Normal uses
B BAL Unconditio Always take this branch
nal Always Always take this branch
– Note that the shift can be combined with other operations too.