Csd Lec1 Arm Intro
Csd Lec1 Arm Intro
2
Korea Univ
ARM Brief
• ARM architecture was first developed in the 1980s by Acorn
• As of 2013, Arm architecture is the most widely used 32-bit ISA in terms of
quantity produced
• Softbank, a Japanese company, surprised the technology world with the arm
acquisition in 2016 at $31.4 billion
Source: Wikipedia
3
https://www.anandtech.com/show/16584/arm-announces-armv9-architecture Korea Univ
Vision (as of 2018)
4
Korea Univ
ARM Partners
5
Source: 2008 Embedded SW Insight Conference
Korea Univ
ARM (as of 2008)
6
Source: 2008 Embedded SW Insight Conference
Korea Univ
ARM Processor Portfolio
Galaxy S2, S3
(2011, 2012)
Galaxy S
iPhone 4
(2010)
~1990s ~2000s
7
Source: 2008 Embedded SW Insight Conference
Korea Univ
Product Code
• T: Thumb
• T2: Thumb-2 Enhancement
• D: Debug
• M: Multiplier
• I: Embedded ICE (In-Circuit Emulation)
• E: Enhanced DSP Extension
• J: Jazelle
Direct execution of 8-bit Java bytecode in
hardware
• S: Synthesizable core
• Z: Should be TrustZone?
8
Korea Univ
ARMv5, v6, v7, v8
9
www.arm.com Korea Univ
ARM Cortex Series
Unparalleled Applicability
Cortex-A8
• ARM Cortex-R family: x1-4
Cortex-A5
Embedded processors for Real-time
1-2
Cortex-R7
1-2
signal processing, control Cortex-R5
applications Cortex-R4
Cortex-M4
SC300
• ARM Cortex-M family: Cortex-M3
Microcontroller-oriented processors Cortex-M1
SC000
for MCU, ASSP, and SoC applications
MCU: Microcontroller Unit Cortex-M0
ASSP: Application Specific Standard Product 12k gates...
SoC: System-on-chip
10
Source: ARM Processor Portfolio 2011
Korea Univ
Cortex-A Portfolio
Galaxy S6 Edge
Galaxy S4, S5
(2015)
(2013, 2014)
11
https://www.arm.com/files/pdf/ARM-Cortex-Portfolio-2114.pdf
Korea Univ
Cortex-R & Cortex-M Portfolio
32-bit
architecture
2011 2016
32-bit
architecture
12
https://www.arm.com/files/pdf/ARM-Cortex-Portfolio-2114.pdf
Wikipedia
Korea Univ
ARMv8-A & ARMv7-A
ARMv8 ARMv7
13
www.arm.com Korea Univ
ARM Processor Selector
14
www.arm.com Korea Univ
ARM Processor Brief
15
Korea Univ
Abstraction
16
Korea Univ
Abstraction in Computer
Core0 Core1
Hardware
implementatio
n
L2 Cache
17
Korea Univ
A Memory Hierarchy
DDR3 HDD
18
Korea Univ
A Memory Hierarchy
On-Chip Components
Secondary
CPU Core Storage
L1I Main
(Instr )
Re L3 Memory (Disk)
g L2 (DRAM)
L1D
Fil (Data)
e
Cost: highest
lowest
19
Korea Univ
Typical and Essential
Instructions
• CPU provides many instructions
It would be time-consuming to study all the
instructions CPU provides
There are essential and common instructions
• Instruction categories
Data processing instructions
• Arithmetic and Logical (Integer)
Memory access instructions
• Load and Store
Branch instructions
20
Korea Univ
High-level Code to Binary (x86)
%gcc –g simple_sub.c -o simple_sub Instructions
%objdump –SD -Mintel simple_sub
int mysub(int op1, int op2) { (human-
readable)
#include <stdio.h> 8048429: 55 push ebp
addres 804842a: 89 e5 mov ebp,esp
s 804842c: 83 ec 10 sub esp,0x10
#define A 3
int myres;
#define B 5
myres = op1 - op2;
int main() {
printf("%d - %d = %d", C Compiler 804842f: 8b 45 0c mov eax,DWORD PTR
[ebp+0xc]
A, B, mysub(A, B));
8048432: 8b 55 08 mov edx,DWORD PTR
return 0; [ebp+0x8]
} 8048435: 89 d1 mov ecx,edx
8048437: 29 c1 sub ecx,eax
int mysub(int op1, int 8048439: 89 c8 mov eax,ecx
op2) { 804843b: 89 45 fc mov DWORD PTR [ebp-
0x4],eax
int myres;
myres = op1 - op2; return myres;
return myres; Representation in 804843e: 8b 45 fc mov eax,DWORD PTR [ebp-
} hexadecimal 0x4]
simple_sub (machine-readable)
}
.c
218048441: c9 leave
8048442: c3 ret
Korea Univ
Levels of Program Code (ARM)
• High-level language program (in C)
24
Korea Univ
ARM Registers
25
Source: ARMv7 Architecture Reference Manual Korea Univ
ARM Registers
• Unbanked registers: R0 ~ R7
Each of them refers to the same 32-bit
physical register in all processor modes.
They are completely general-purpose
registers, with no special uses implied
by the architecture
26
Korea Univ
R13, R14, and R15
• Some registers in ARM are used for special
purposes
R15 == PC (Program Counter)
• x86 uses a terminology called IP (Instruction Pointer)
R14 == LR (Link Register)
R13 == SP (Stack Pointer)
27
Korea Univ
CPSR
28
Korea Univ
CPSR in ARM
29
Korea Univ
CPSR bits
30
Korea Univ
CPSR bits
http://esca.korea.ac.kr/teaching/cose321_CSD/labs/DDI0406C_C_armv7AR_architecture_reference_manual.pdf
32
Korea Univ
Interrupt
34
Korea Univ
Supervisor Call in ARM
35
https://en.wikipedia.org/wiki/System_call
Korea Univ
Exception Vectors in ARM
36
RAZ: Read As Zero Korea Univ
Backup Slides
37
Korea Univ
ARM (www.arm.com)
38
Korea Univ
ARM
39
Source: 2008 Embedded SW Insight Conference
Korea Univ
ARM Processor Portfolio (Cont.)
Galaxy S6 Edge
Galaxy S4, S5 (2015)
(2013, 2014)
40
Korea Univ
Exception Vectors in ARM
41
RAZ: Read As Zero Korea Univ
ARM Registers
• ARM has 31 general purpose registers and 6 status
registers (32-bit each)
42
Korea Univ
Levels of Program Code (x86)
Code with
High-level Machine Code
Language a = 3;
c7 45 f0 03 00 00 00 movl $0x3,-0x10(%ebp)
int main()
b = 9;
{
c7 45 f4 09 00 00 00 movl $0x9,-0xc(%ebp)
int a, b, c; C Compiler
a = 3;
c = a + b;
b = 9;
8b 55 f4 mov -0xc(%ebp),%edx
c = a + b;
8b 45 f0 mov -0x10(%ebp),%eax
return c;
01 d0 add %edx,%eax
}
89 45 f8 mov %eax,-0x8(%ebp)
Representation in Instructions
hexadecimal (human-
(machine- readable)
readable)
43
Korea Univ