Académique Documents
Professionnel Documents
Culture Documents
ARM7TDMI Microprocessor
Objectives
To understand 16-bit Thumb mode operation of ARM Processor.
To understand the features of Thumb mode operation and how
Thumb instructions decompress to ARM Mode.
To know the technique of switching between ARM and Thumb
mode of operations.
To know the similarities and differences between ARM and
Thumb mode of operation
To understand exception handling and branching in Thumb
mode.
To understand operation of data processing instructions and data
transfer instructions in Thumb mode.
Thumb applications
In a typical embedded system:
use ARM code in 32-bit on-chip memory for small speedcritical routines
use Thumb code in 16-bit off-chip memory for large noncritical control routines
Note:
Switching between ARM and Thumb States of Execution
Using BX Instruction
Thumb applications
DATA TYPES
Byte (8-bit):
placed on any byte boundary.
Half-word (16-bit):
aligned to two-byte boundaries.
Word (32-bit):
aligned to four- byte boundaries.
Features
ARM7TDMI core
Mode Switching
FIQ
Supervisor
Abort
IRQ
Undefined
r0
r0
r0
r0
r0
r0
r1
r1
r1
r1
r1
r1
r2
r2
r2
r2
r2
r2
r3
r3
r3
r3
r3
r3
r4
r4
r4
r4
r4
r4
r5
r5
r5
r5
r5
r5
r6
r6
r6
r6
r6
r6
r7
r7
r7
r7
r7
r7
SP
SP_FIQ
SP_SVC
SP_ABT
SP_IRQ
SP_UND
LR
LR_ FIQ
LR_ SVC
LR_ ABT
LR_ IRQ
LR_ UND
PC_ FIQ
PC_ SVC
PC_ ABT
PC_ IRQ
PC_ UND
PC
CPSR
CPSR
CPSR
sprsr_fiq
SPSR_FIQ
SPSR_SVC
SPSR_ABT
CPSR
sprsr_fiq
SPSR_IRQ
CPSR
SPSR
_UND
sprsr_fiq
ARM-Thumb Similarities
Load-store architecture
Support 8-bit byte, 16-bit half-word and 32 bit word data types
with aligned boundaries
32 bit unsegmented memory.
ARM-Thumb differences
Thumb exception
Thumb Branching
1
1
8 7
Condition
8-Bit Offset
B <label>
1 1 1 0 0
11 Bit
Offset
BL <label>
1
11 Bit Offset
BX Rm
0 1
1 1
Rm
Features
Different format for each case
Offset is reduced to 11bit and 8 bit
Offset is shifted left by 1-bit (to give half-word alignment)
and sign-extended to 32 bits.
BL is more subtle to give 22-bit offset using link register
for temporary storage
No direct mapping to ARM instructions as Thumb require
half-word aligned offsets.
BL Instruction
To allow for a reasonably large offset to the target subroutine
each of these two instructions is automatically translated
by the assembler into a sequence of two 16 bit thumb
instructions
1. H = 10
LR := PC + (sign-extended offset shifted left 12 places);
2.
H = 11
PC := LR + (offset shifted left 1 place)
3.
1 1 0 1 1 1 1 1
8 Bit Immediate
Data Processing
Instruction formats
<op>
<op>
<op>
<op>
<op>
Rd, Rn, Rm
Rd, Rn, # <imm3>
Rd|Rn, Rm|Rs
Rd, Rn, #<sh 5>
Rd, #<imm 8>
Instructions
MOV
MVN
CMP
CMP
CMN
TST
Rd, #<imm8>
Rd, Rm
Rn, #<imm8>
Rn, Rm
Rn, Rm
Rn, Rm
Instruction
ADD
ADD
ADD
ADC
SUB
SUB
SUB
SBC
NEG
Instruction
Instruction
AND
EOR
ORR
BIC
MUL
Rd, Rm
Rd, Rm
Rd, Rm
Rd, Rm
Rd, Rm
ADD Rd, Rm
(1 or 2 Hi registers)
CMP Rn, Rm
(1 or 2 Hi registers)
MOV Rd, Rm
(1 or 2 Hi registers)
ADD Rd, PC, #<imm8>
ADD Rd, SP, #<imm8>
ADD SP, SP, #<imm7>
SUB SP, SP, #<imm7>
Except others donot set condition code bits
LDR|STR
LDR|STR
LDRB|STRB
LDRB|STRB
LDRH|STRH
LDRH|STRH
* Signed operands:
Stack Mode
POP|PUSH { <reg list> {, R}}
R13 (sp) is used as base register
Uses Full Descending Stack
In addition any subset of Ro-R7 registers LR (lr) may be
included in PUSH instruction and PC (pc)may be included in
POP instruction
Thumb-ARM Decompression
Translation from 16-bit Thumb instruction to 32-bit ARM
instruction
Condition bits changed to always
Lookup to translate major and minor opcodes
Zero extending 3-bit register specifiers to give 4-bit
specifiers
Zero extending immediate values
Implicit S(affecting condition codes) should be explicitly
specified.
Thumb 2-address format must be mapped to ARM 3address format
Properties
Thumb code requires 70% of space of ARM code
Thumb code uses 40% more instructions than the ARM
code
With 32-bit memory ARM code is 40% faster
With 16-bit memory Thumb code is 45% faster than ARM
code
Thumb code uses 30% less external memory power than
ARM code.
Summary