The First Encounter
The First Encounter
What Is ARM?
Advanced RISC Machine
First RISC microprocessor
for commercial use
Market-leader for low-power
and cost-sensitive embedded applications
Features
Architectural simplicity
which allows
Very small implementations
which result in
Very low power consumption
ARM Architecture
Typical RISC architecture:
Large uniform register file
Load/store architecture
Simple addressing modes
Uniform and fixed-length instruction fields
Pipeline Organization
Increases speed
most instructions executed in single cycle
Versions:
6-stage (ARM10TDMI)
10
Fetch
i+1
Decode
Execute
Fetch
Decode
Execute
i+2
Fetch
Decode
Execute
cycle
t+1
t+2
t+3
11t+4
Stages:
Fetch
Decode
Execute
Buffer/data
Write-back
12
13
Operating Modes
Seven operating modes:
User
Privileged:
System (version 4 and above)
FIQ
IRQ
Abort
exception modes
Undefined
Supervisor
14
Normal program
execution mode
System resources
unavailable
Mode changed
by exception only
Exception modes:
Entered
upon exception
Full access
to system resources
Mode changed freely
15
Exceptions
Exception
Mode
Priority
IV Address
Reset
Supervisor
0x00000000
Undefined instruction
Undefined
0x00000004
Software interrupt
Supervisor
0x00000008
Prefetch Abort
Abort
0x0000000C
Data Abort
Abort
0x00000010
Interrupt
IRQ
0x00000018
Fast interrupt
FIQ
0x0000001C
ARM Registers
31 general-purpose 32-bit registers
16 visible, R0 R15
Others speed up the exception process
17
Hardware
R14 Link Register (LR):
optionally holds return address
for branch instructions
R15 Program Counter (PC)
Software
R13 - Stack Pointer (SP)
18
(PC + 4) LR
CPSR SPSR_mod
PC IV address
FIQ
Supervisor
Abort
IRQ
Undefined
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15 (PC)
R0
R1
R2
R3
R4
R5
R6
R7_fiq
R8_fiq
R9_fiq
R10_fiq
R11_fiq
R12_fiq
R13_fiq
R14_fiq
R15 (PC)
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13_svc
R14_svc
R15 (PC)
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13_abt
R14_abt
R15 (PC)
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13_irq
R14_irq
R15 (PC)
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13_und
R14_und
R15 (PC)
CPSR
CPSR
SPSR_fiq
CPSR
SPSR_svc
CPSR
SPSR_abt
CPSR
SPSR_irq
CPSR
SPSR_und
20
Instruction Set
Two instruction sets:
ARM
Standard 32-bit instruction set
THUMB
16-bit compressed form
Code density better than most CISC
Dynamic decompression in pipeline
21
Load/Store architecture
Conditional execution
22
16 condition codes:
EQ
equal
MI
negative
HI
unsigned
higher
GT
signed greater
than
NE
not equal
PL
positive or
zero
LS
unsigned
lower or same
LE
signed less
than or equal
CS
unsigned
higher or
same
VS
overflow
GE
signed greater
than or equal
AL
always
CC
unsigned
lower
VC
no overflow
LT
signed less
than
23NV
special
purpose
Data transfer
instructions
Branching instructions
Software interrupt
instructions
24
MOV, MVN
Comparison operations:
+
Data processing instructions
+
Barrel shifter
=
Powerful tools for efficient coded programs
27
if (z==1) R1=R2+(R3*4)
compiles to
EQADDS R1,R2,R3, LSL #2
( SINGLE INSTRUCTION ! )
28
Load Word
STR
Store Word
LDRH
STRH
LDRSH
LDRB
Load Byte
STRB
LDRSB
Store Byte
29
LDM
R0
Mi
Mi+1
Mi+2
R1
R2
Mi+14
Mi+15
R14
STM
R15
30
Swap Instruction
Exchanges a word
between registers
Two cycles
but
single atomic action
Support for RT
semaphores
R0
R1
R2
R7
R8
R15
31
R0
R1
MRS
R7
CPSR
SPSR
MSR
R8
R14
R15
Only in privileged
modes
32
Multiply Instructions
Integer multiplication (32-bit result)
Long integer multiplication (64-bit result)
Built in Multiply Accumulate Unit (MAC)
Multiply and accumulate instructions add product
to running total
33
Multiply Instructions
Instructions:
MUL
Multiply
32-bit result
MULA
Multiply accumulate
32-bit result
UMULL
Unsigned multiply
64-bit result
UMLAL
64-bit result
SMULL
Signed multiply
64-bit result
SMLAL
64-bit result
34
Software Interrupt
SWI instruction
28 27
Cond
24 23
Opcode
0
Ordinal
35
Branching Instructions
Branch (B):
jumps forwards/backwards
up to 32 MB
Branch link (BL):
same + saves (PC+4) in LR
Suitable for function call/return
Condition codes for conditional branches
36
37
interworking (combining
compiler supported
38
No condition codes
Access to R0 R8 restricted to
40
41
Summary
Adoption of ARM technology
has increased efficiency and lowered costs
ARM is the worlds leading architecture today
42
References
www.arm.com
ARM Limited ARM Architecture Reference Manual,
Addison Wesley, June 2000
Trevor Martin The Insiders Guide To The Philips ARM7Based Microcontrollers, Hitex (UK) Ltd., February 2005
Steve Furber ARM System-On-Chip Architecture
edition), Addison Wesley, March 2000
43
(2nd
The End
Authors:
Nemanja Perovic, [email protected]
Prof. Dr. Veljko Milutinovic, [email protected]
44