Arm PPT
Arm PPT
In this lecture
Introduction
ARM Programmer’s Model
ARM Instruction Set
ARM Ltd
Founded in November 1990
Spun out of Acorn Computers
E.g.
Samsung galaxy S4 ----- ARM Cortex-A15/Cortex-A7
IPhone 4 -------- ARM Cortex-A8
Ipad mini ------- ARM Cortex-A9
Introduction…cntd
ARM is a Reduced Instruction Set Computer (RISC)
A large uniform register file
A load/store architecture
Simple addressing modes
Uniform and fixed-length instruction fields
instruction
Mode Description
Supervisor Entered on reset and when a Supervisor call
(SVC) instruction (SVC) is executed
Exception modes
cpsr
spsr spsr spsr spsr spsr
039v12 16
Instruction Set
Different types of instructions
Data processing instructions
Load-store instructions
Branch instructions
Software interrupt instruction
Program status register instructions
039v12 17
Data Processing Instructions
Consist of :
Arithmetic: ADD ADC SUB SBC RSB RSC
Logical: AND ORR EOR BIC
Comparisons:CMP CMN TST TEQ
Data movement: MOV MVN
Syntax:
By default, data processing instructions do not affect the condition code flags but the
flags can be optionally set by using “S”. CMP does not need “S”.
loop
…
SUBS r1,r1,#1 decrement r1 and set flags
BNE loop
if Z flag clear then branch
Condition Codes
The possible condition codes are listed below
Note AL is the default and does not need to be specified
Suffix Description Flags tested
EQ Equal Z=1
NE Not equal Z=0
CS/HS Unsigned higher or same C=1
CC/LO Unsigned lower C=0
MI Minus N=1
PL Positive or Zero N=0
VS Overflow V=1
VC No overflow V=0
HI Unsigned higher C=1 & Z=0
LS Unsigned lower or same C=0 or Z=1
GE Greater or equal N=V
LT Less than N!=V
GT Greater than Z=0 & N=V
LE Less than or equal Z=1 or N=!V
AL Always
Conditional Execution Examples
C source code ARM instructions
unconditional conditional
if (r0 == 0) CMP r0, #0 CMP r0, #0
{ BNE else ADDEQ r1, r1, #1
r1 = r1 + 1; ADD r1, r1, #1 ADDNE r2, r2, #1
} B end ...
else else
{ ADD r2, r2, #1
r2 = r2 + 1; end
} ...
5 instructions 3 instructions
5 words 3 words
5 or 6 cycles 3 cycles
More
Examples
Use a sequence of several conditional instructions
if (a==0) func(1);
CMP r0,#0
MOVEQ r0,#1
BLEQ func
Set the flags, then use various condition codes
if (a==0) x=0;
if (a>0) x=1;
CMP r0,#0
MOVEQ r1,#0
MOVGT r1,#1
Use conditional compare instructions
if (a==4 || a==10) x=0;
CMP r0,#4
CMPNE r0,#10
MOVEQ r1,#0
The Barrel Shifter
LSL : Logical Left Shift ASR: Arithmetic Right Shift
CF Destination 0 Destination CF
Destination CF
another register.
Barrel
Shifter Used for multiplication by
constant
(r0 = r1+r1*8 = 9*r1)
e.g.
MOV r0,r1,LSL#2 (r0 = r1*4)
ALU
ADD r0, r1, r1, LSL#3
Result