SlideShare a Scribd company logo
1 of 17
11
Lecture 9
ARM Instruction Set
(& ARM Based Microcontrollers)
22
In this lecture
 ARM Instruction Set
 ARM Based Microcontrollers
33
Load-Store Instructions
 Transfer data between memory and processor
registers
 Three types :
 Single-register transfer
 Multiple-register transfer
 Swap
44
Single Register Data Transfer
 Used for moving a single data item
 Several types:
LDR STR Word
LDRB STRB Byte
LDRH STRH Halfword
LDRSB Signed byte load
LDRSH Signed halfword load
 Syntax:
 LDR{<cond>}{<size>} Rd, <address>
 STR{<cond>}{<size>} Rd, <address>
55
Single Register Data Transfer…cntd
 Addressing Modes:
 Preindexed with write back
E.g. LDR r0, [r1,#4]! (r0 ←[r1+4]) then r1 = r1+4)
 Preindexed addressing
E.g. LDR r0, [r1,#4] (r0 ←[r1+4], r1 does not change)
 Postindexed addressing
E.g. LDR r0, [r1], #4 (r0←[r1] then r1 = r1 +4)
66
Multiple Register Data Transfer
 Syntax:
<LDM|STM>{<cond>}<addressing_mode> Rb{!}, <register list>
 Rb = Base register
 Four addressing modes:
LDMIA / STMIA (Load multiple/ store multiple, increment after)
 E.g. LDMIA r0, {r1-r3} (r1←[r0], r2←[r0+4], r3←[r0+8])
LDMIB / STMIB increment before
 E.g. LDMIB r0, {r1-r3} (r1←[r0+4], r2←[r0+8], r3←[r0+12])
LDMDA / STMDA decrement after
 E.g. LDMDA r0, {r1-r3} (r3←[r0], r2←[r0-4], r1←[r0-8])
LDMDB / STMDB decrement before
 E.g. LDMDB r0, {r1-r3} (r3←[r0-4], r2←[r0-8], r1←[r0-12])
77
Software Interrupt Instruction(SWI)
 Causes a software interrupt exception
 The SWI handler can examine the SWI number to decide
what operation has been requested
 By using the SWI mechanism, an operating system can
implement a set of privileged operations which applications
running in user mode can request
 Syntax:
 SWI{<cond>} <SWI number>
2831 2427 0
Cond 1 1 1 1 SWI number (ignored by processor)
23
Condition Field
88
 Branch : B{<cond>} label
 Label is a 24 bit offset
 The processor core shifts the offset field left by 2 positions, sign-
extends it and adds it to the PC (PC←PC+(offset<<2))
 This gives ± 32 Mbyte range
 Branch with Link : BL{<cond>} subroutine_label
 Similar to Branch, but overrides LR (link register) with a return address
 It can be used to call subroutines. To return from the subroutine restore
the value of PC from LR
 E.g. BL subroutine ; branch to subroutine, LR←PC+4
…
subroutine:
<subroutine code>
MOV PC, LR ; restore PC (return)
Branch instructions
99
Thumb
 Thumb is a 16-bit instruction set
 Optimized for code density from C code (~65% of ARM code size)
 Improved performance from narrow memory
 Subset of the functionality of the ARM instruction set
015
31 0
ADDS r2,r2,#1
ADD r2,#1
32-bit ARM Instruction
16-bit Thumb Instruction
For most instructions generated by compiler:
 Conditional execution is not used
 Source and destination registers identical
 Constants are of limited size
 Inline barrel shifter not used
1010
ARM Based Microcontrollers
(LPC2148)
1111
LPC2148
 Based on ARM7TDMI-S
 512KB on-chip flash memory (non-
volatile memory)
 32KB on-chip SRAM
 Several peripherals
 Up to 60MHz CPU clock
 Operating voltage range: 3.0V-3.6V
 64 pins
1212
LPC2148 – Block Diagram
ARM7TDMI-S
512KB
FLASH
32KB
SRAM
Interrupt
Controller
ARM7 Local Bus
AHB
Peripherals
 GPIO
 A/D Converters
 D/A Converters
 PWM
 Capture/Compare
 Real Time Clock
 UART
 SPI
 I2
C
 USB
 The microcontroller can be seen as an ARM based system
APB
1313
 Flash memory
 Non-volatile
 Used to store code and data
 Can be programed using JTAG interface using In System Programming
(ISP), or by means of In Application Programming (IAP)
 Minimum of 100,000 erase/write cycles
 Static RAM
 Volatile
 Can be used to store code and data
 Peripherals (Input/Outpt)
 Each peripheral has registers used to communicate with the ARM core
LPC2148 – Block Diagram…cntd
1414
 The microcontroller has a 4GB address space (PC is 32 bits)
 Peripheral registers are also addressed as memory locations
Memory Mapping
AHB Peripherals
APB Peripherals
32KB SRAM
512kB Flash
0x00000000
0x0007FFFF
0x40000000
0x40007FFF
0xE000000
0xF000000
0xFFFFFFFF
0.0GB
1GB
3.5GB
4GB
1515
 Peripherals are controlled by writing into or reading from the
appropriate registers
 Which registers to write to or to read from are given on the
device (LPC2148) datasheet /user manual
 E.g. LPC2148 has two General Purpose I/O (GPIO) ports
(PORT0 and PORT1)
 To configure a pin on PORT0 as an input or as an output, write
appropriate values to register IO0DIR (address of 0xE0028008)
 To set (make logical 1) a pin on PORT0, set the appropriate bit on
register IO0SET (address 0xE0028004)
 To read the value of a pin on PORT0, read appropriate bit on register
IO0PIN (address of 0xE0028000)
Peripherals
1616
Hardware and Software Tools for Labs
 LPC2148 Education Board
 IAR for ARM
 Proteus
1717
More Readings
 ARM System Developer’s Guide (chapters 3)
 LPC214x User Manual

More Related Content

What's hot

ARM Architecture Instruction Set
ARM Architecture Instruction SetARM Architecture Instruction Set
ARM Architecture Instruction Set
Dwight Sabio
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copy
mkazree
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
mkazree
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction set
aviban
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
Ashim Saha
 

What's hot (20)

ARM Architecture Instruction Set
ARM Architecture Instruction SetARM Architecture Instruction Set
ARM Architecture Instruction Set
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copy
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVR
 
Lecture4
Lecture4Lecture4
Lecture4
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture II
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
 
ARM stacks, subroutines, Cortex M3, LPC 214X
ARM  stacks, subroutines, Cortex M3, LPC 214XARM  stacks, subroutines, Cortex M3, LPC 214X
ARM stacks, subroutines, Cortex M3, LPC 214X
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
ARM instruction set
ARM instruction  setARM instruction  set
ARM instruction set
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
 
8051 Addressing Modes
8051 Addressing Modes8051 Addressing Modes
8051 Addressing Modes
 
ARM instruction set
ARM instruction  setARM instruction  set
ARM instruction set
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction set
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Microcontroller pic 16f877 addressing modes instructions and programming
Microcontroller pic 16f877 addressing modes instructions and programmingMicrocontroller pic 16f877 addressing modes instructions and programming
Microcontroller pic 16f877 addressing modes instructions and programming
 
Viva
VivaViva
Viva
 
MICROPROCESSOR INPUT OUTPUT OPERATIONS
MICROPROCESSOR INPUT OUTPUT OPERATIONSMICROPROCESSOR INPUT OUTPUT OPERATIONS
MICROPROCESSOR INPUT OUTPUT OPERATIONS
 

Viewers also liked

Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Richard Labelle
 

Viewers also liked (20)

Arm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speedArm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speed
 
480 sensors
480 sensors480 sensors
480 sensors
 
Lecture8
Lecture8Lecture8
Lecture8
 
Ppt
PptPpt
Ppt
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
Lecture 3.1- Measurements (HP)
Lecture 3.1- Measurements (HP)Lecture 3.1- Measurements (HP)
Lecture 3.1- Measurements (HP)
 
Lecture 01 Measurements
Lecture 01 MeasurementsLecture 01 Measurements
Lecture 01 Measurements
 
NOVEL METHODOLOGY OF THE ULTRA SONIC BEAM IN LINEAR ARRAY TRANSDUCER FOR HIGH...
NOVEL METHODOLOGY OF THE ULTRA SONIC BEAM IN LINEAR ARRAY TRANSDUCER FOR HIGH...NOVEL METHODOLOGY OF THE ULTRA SONIC BEAM IN LINEAR ARRAY TRANSDUCER FOR HIGH...
NOVEL METHODOLOGY OF THE ULTRA SONIC BEAM IN LINEAR ARRAY TRANSDUCER FOR HIGH...
 
Lecture 3.1- Measurements (P)
Lecture 3.1- Measurements (P)Lecture 3.1- Measurements (P)
Lecture 3.1- Measurements (P)
 
an advance approach to divert trafiic at busy signals using rfid technolgy
an advance approach to divert trafiic at busy signals using rfid technolgyan advance approach to divert trafiic at busy signals using rfid technolgy
an advance approach to divert trafiic at busy signals using rfid technolgy
 
Lecture1
Lecture1Lecture1
Lecture1
 
Transducer main
Transducer mainTransducer main
Transducer main
 
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
 
Lecture1 measurement & intrumentation
Lecture1 measurement & intrumentationLecture1 measurement & intrumentation
Lecture1 measurement & intrumentation
 
Measurements lecture 1
Measurements lecture 1Measurements lecture 1
Measurements lecture 1
 
Measurements and Instrumentation - Electrical and electronics instruments
Measurements and Instrumentation - Electrical and electronics instrumentsMeasurements and Instrumentation - Electrical and electronics instruments
Measurements and Instrumentation - Electrical and electronics instruments
 
1 Day Arm 2007
1 Day Arm 20071 Day Arm 2007
1 Day Arm 2007
 
Nephelometry
NephelometryNephelometry
Nephelometry
 
Lecture 07
Lecture 07Lecture 07
Lecture 07
 
Smart City #ITUWORLD
Smart City #ITUWORLDSmart City #ITUWORLD
Smart City #ITUWORLD
 

Similar to Lecture9

Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
John Williams
 
Arm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_armArm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_arm
Prashant Ahire
 
Intel x86 Architecture
Intel x86 ArchitectureIntel x86 Architecture
Intel x86 Architecture
ChangWoo Min
 

Similar to Lecture9 (20)

Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
 
Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
 
ARM_2.ppt
ARM_2.pptARM_2.ppt
ARM_2.ppt
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
 
amba.ppt
amba.pptamba.ppt
amba.ppt
 
amba.ppt
amba.pptamba.ppt
amba.ppt
 
amba.ppt
amba.pptamba.ppt
amba.ppt
 
amba (1).ppt
amba (1).pptamba (1).ppt
amba (1).ppt
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
 
Intel µp instruction encoding and decoding
Intel µp instruction encoding and decodingIntel µp instruction encoding and decoding
Intel µp instruction encoding and decoding
 
LPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.pptLPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.ppt
 
Unit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptxUnit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptx
 
arm-intro.ppt
arm-intro.pptarm-intro.ppt
arm-intro.ppt
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
 
Arm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_armArm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_arm
 
heuring_jordan_----------ch02(1) (1).pptx
heuring_jordan_----------ch02(1) (1).pptxheuring_jordan_----------ch02(1) (1).pptx
heuring_jordan_----------ch02(1) (1).pptx
 
Intel x86 Architecture
Intel x86 ArchitectureIntel x86 Architecture
Intel x86 Architecture
 
Assignment
AssignmentAssignment
Assignment
 
GCC for ARMv8 Aarch64
GCC for ARMv8 Aarch64GCC for ARMv8 Aarch64
GCC for ARMv8 Aarch64
 

More from misgina Mengesha (13)

Lecture6
Lecture6Lecture6
Lecture6
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
Lecture3
Lecture3Lecture3
Lecture3
 
Lecture2
Lecture2Lecture2
Lecture2
 
Sprabq8
Sprabq8Sprabq8
Sprabq8
 
Sensors2006
Sensors2006Sensors2006
Sensors2006
 
Sensors31
Sensors31Sensors31
Sensors31
 
Sensing for robotics and control s set13
Sensing for robotics and control s set13Sensing for robotics and control s set13
Sensing for robotics and control s set13
 
Introduction to sensors
Introduction to sensorsIntroduction to sensors
Introduction to sensors
 
Cn3 sensors and transducers-12
Cn3 sensors and transducers-12Cn3 sensors and transducers-12
Cn3 sensors and transducers-12
 
Cn3 sensors and transducers-1
Cn3 sensors and transducers-1Cn3 sensors and transducers-1
Cn3 sensors and transducers-1
 
Wwwwww
WwwwwwWwwwww
Wwwwww
 

Lecture9

  • 1. 11 Lecture 9 ARM Instruction Set (& ARM Based Microcontrollers)
  • 2. 22 In this lecture  ARM Instruction Set  ARM Based Microcontrollers
  • 3. 33 Load-Store Instructions  Transfer data between memory and processor registers  Three types :  Single-register transfer  Multiple-register transfer  Swap
  • 4. 44 Single Register Data Transfer  Used for moving a single data item  Several types: LDR STR Word LDRB STRB Byte LDRH STRH Halfword LDRSB Signed byte load LDRSH Signed halfword load  Syntax:  LDR{<cond>}{<size>} Rd, <address>  STR{<cond>}{<size>} Rd, <address>
  • 5. 55 Single Register Data Transfer…cntd  Addressing Modes:  Preindexed with write back E.g. LDR r0, [r1,#4]! (r0 ←[r1+4]) then r1 = r1+4)  Preindexed addressing E.g. LDR r0, [r1,#4] (r0 ←[r1+4], r1 does not change)  Postindexed addressing E.g. LDR r0, [r1], #4 (r0←[r1] then r1 = r1 +4)
  • 6. 66 Multiple Register Data Transfer  Syntax: <LDM|STM>{<cond>}<addressing_mode> Rb{!}, <register list>  Rb = Base register  Four addressing modes: LDMIA / STMIA (Load multiple/ store multiple, increment after)  E.g. LDMIA r0, {r1-r3} (r1←[r0], r2←[r0+4], r3←[r0+8]) LDMIB / STMIB increment before  E.g. LDMIB r0, {r1-r3} (r1←[r0+4], r2←[r0+8], r3←[r0+12]) LDMDA / STMDA decrement after  E.g. LDMDA r0, {r1-r3} (r3←[r0], r2←[r0-4], r1←[r0-8]) LDMDB / STMDB decrement before  E.g. LDMDB r0, {r1-r3} (r3←[r0-4], r2←[r0-8], r1←[r0-12])
  • 7. 77 Software Interrupt Instruction(SWI)  Causes a software interrupt exception  The SWI handler can examine the SWI number to decide what operation has been requested  By using the SWI mechanism, an operating system can implement a set of privileged operations which applications running in user mode can request  Syntax:  SWI{<cond>} <SWI number> 2831 2427 0 Cond 1 1 1 1 SWI number (ignored by processor) 23 Condition Field
  • 8. 88  Branch : B{<cond>} label  Label is a 24 bit offset  The processor core shifts the offset field left by 2 positions, sign- extends it and adds it to the PC (PC←PC+(offset<<2))  This gives ± 32 Mbyte range  Branch with Link : BL{<cond>} subroutine_label  Similar to Branch, but overrides LR (link register) with a return address  It can be used to call subroutines. To return from the subroutine restore the value of PC from LR  E.g. BL subroutine ; branch to subroutine, LR←PC+4 … subroutine: <subroutine code> MOV PC, LR ; restore PC (return) Branch instructions
  • 9. 99 Thumb  Thumb is a 16-bit instruction set  Optimized for code density from C code (~65% of ARM code size)  Improved performance from narrow memory  Subset of the functionality of the ARM instruction set 015 31 0 ADDS r2,r2,#1 ADD r2,#1 32-bit ARM Instruction 16-bit Thumb Instruction For most instructions generated by compiler:  Conditional execution is not used  Source and destination registers identical  Constants are of limited size  Inline barrel shifter not used
  • 11. 1111 LPC2148  Based on ARM7TDMI-S  512KB on-chip flash memory (non- volatile memory)  32KB on-chip SRAM  Several peripherals  Up to 60MHz CPU clock  Operating voltage range: 3.0V-3.6V  64 pins
  • 12. 1212 LPC2148 – Block Diagram ARM7TDMI-S 512KB FLASH 32KB SRAM Interrupt Controller ARM7 Local Bus AHB Peripherals  GPIO  A/D Converters  D/A Converters  PWM  Capture/Compare  Real Time Clock  UART  SPI  I2 C  USB  The microcontroller can be seen as an ARM based system APB
  • 13. 1313  Flash memory  Non-volatile  Used to store code and data  Can be programed using JTAG interface using In System Programming (ISP), or by means of In Application Programming (IAP)  Minimum of 100,000 erase/write cycles  Static RAM  Volatile  Can be used to store code and data  Peripherals (Input/Outpt)  Each peripheral has registers used to communicate with the ARM core LPC2148 – Block Diagram…cntd
  • 14. 1414  The microcontroller has a 4GB address space (PC is 32 bits)  Peripheral registers are also addressed as memory locations Memory Mapping AHB Peripherals APB Peripherals 32KB SRAM 512kB Flash 0x00000000 0x0007FFFF 0x40000000 0x40007FFF 0xE000000 0xF000000 0xFFFFFFFF 0.0GB 1GB 3.5GB 4GB
  • 15. 1515  Peripherals are controlled by writing into or reading from the appropriate registers  Which registers to write to or to read from are given on the device (LPC2148) datasheet /user manual  E.g. LPC2148 has two General Purpose I/O (GPIO) ports (PORT0 and PORT1)  To configure a pin on PORT0 as an input or as an output, write appropriate values to register IO0DIR (address of 0xE0028008)  To set (make logical 1) a pin on PORT0, set the appropriate bit on register IO0SET (address 0xE0028004)  To read the value of a pin on PORT0, read appropriate bit on register IO0PIN (address of 0xE0028000) Peripherals
  • 16. 1616 Hardware and Software Tools for Labs  LPC2148 Education Board  IAR for ARM  Proteus
  • 17. 1717 More Readings  ARM System Developer’s Guide (chapters 3)  LPC214x User Manual