Professional Documents
Culture Documents
By : SUMEET SAURAV
Features of ARM11
bandwidth and size requirements by up to 35%. ARM Jazelle technology for efficient embedded Java execution. ARM DSP extensions. SIMD (Single Instruction Multiple Data) media processing extensions deliver up to 2x performance for video processing
(ARM1176JZ-S and ARM1176JZF-S processors) Thumb-2 technology (ARM1156(F)-S only) for enhanced performance, energy efficiency and code density Low power consumption. 0.21 mW/MHz (65G) including cache controllers Energy saving power-down modes address static leakage currents in advanced processes High performance integer processor. 8-stage integer pipeline delivers high clock frequency (9 stages for ARM1156T2(F)-S) Separate load-store and arithmetic pipelines Branch Prediction and Return Stack High performance memory system design
Supports 4-64k cache sizes. Optional tightly coupled memories with DMA for multi-media
applications.
High-performance 64-bit memory system speeds data access
ARM ARCHITECTURE:INTRODUCTION
The ARM is a Reduced Instruction Set Computer(RISC). o a large uniform register file. o a load/store architecture, where data-processing
instruction decode.
shifter in most data-processing instructions to maximize the use of an ALU and a shifter
Auto-increment and auto-decrement addressing modes to
throughput.
Conditional execution of almost all instructions to
ARM processors to achieve a good balance of high performance, small code size, low power consumption, and small silicon area.
ARM REGISTERS
ARM has 31 general-purpose 32-bit registers. At any
Counter(PC).
General-purpose registers
The general-purpose registers R0 to R15 can be split into
three groups. These groups differ in the way they are banked and in their special-purpose uses:
The unbanked registers, R0 to R7
means that each of them refers to the same 32-bit physical register in all processor modes.
no special uses implied by the architecture, and can be used wherever an instruction allows a generalpurpose register to be specified.
purpose registers to produce various special-case effects. These are instruction-specific and so are described in the individual instruction descriptions.
There are also many instruction-specific restrictions on the
use of R15. these are also noted in the individual instruction descriptions. Usually, the instruction is UNPREDICTABLE if R15 is used in a manner that breaks these restrictions. If an instruction description neither describes a special-case effect when R15 is used nor places restrictions on its use, R15 is used to read or write the Program Counter(PC).
all processor modes. It contains condition code flags, interrupt disable bits, the current processor mode, and other status and control information. Each exception mode also has a Saved Program Status Register(SPSR), that is used to preserve the value of the CPSR when the associated exception occurs.
STATUS REGISTERS
All processor state other than the general-purpose register contents is
held in status registers. The current operating processor status is in the Current Program Status Register(CPSR). The CPSR holds:
four condition code flags (Negative, Zero, Carry and Overflow).
one sticky (Q) flag (ARMv5 and above only). This encodes whether
saturation has occurred in saturated arithmetic instructions, or signed overflow in some specific multiply accumulate instructions.
four GE (Greater than or Equal) flags (ARMv6 and above only).
These encode the following conditions separately for each operation in parallel instructions: whether the results of signed operations were non-negative whether unsigned operations produced a carry or a borrow.
Four GE (Greater than or Equal) flags (ARMv6 and above only). These encode the following conditions separately for each operation in parallel instructions: whether the results of signed operations were non-negative whether unsigned operations produced a carry or a borrow.
Each exception mode also has
a Saved Program Status Register(SPSR) which holds the CPSR of the task immediately before the exception occurred. The CPSR and the SPSRs are accessed with special instructions.
executed if the N, Z, C and V flags in the CPSR satisfy a condition specified in the instruction. If the flags do not satisfy this condition, the instruction acts as a NOP: that is, execution advances to the next instruction as normal. Prior to ARMv5, all ARM instructions could be conditionally executed. A few instructions have been introduced subsequently which can onlybe executed unconditionall
Almost all ARM instructions contain a 4-bit condition field. One value of this field specifies that the instruction is executed unconditionally. Fourteen other values specify conditional execution of the
Branch instructions
The Branch with Link (BL) instruction preserves the
address of the instruction after the branch (the return address) in the LR (R14). The Branch and Exchange (BX) instruction copies the contents of a general-purpose register Rm to the PC (like a MOV PC,Rm instruction), with the additional functionality that if bit[0] of the transferred value is1, the processor shifts to Thumb state. In ARMv5 and above, there are also two types of Branch with Link and Exchange (BLX) instruction:
instruction. This instruction behaves like a BX instruction, and additionally writes the address of the next instruction into the LR. This provides a more efficient interworking subroutine call than a sequence of MOV LR,PC followed by BX Rm.
backwards or forwards by up to 32MB and writing a return link to the LR, but shifts to Thumb state rather than staying in ARM state as BL does.
target address, and provide both conditional and unconditional changes to program flow. BL also stores a return address in the link register, R14 (also known as LR).
Syntax
B{L}{<cond>} <target address> 1. Sign-extending the 24-bit signed (two's complement) immediate to 30 bits. 2.Shifting the result left two bits to form a 32-bit value. 3. Adding this to the contents of the PC, which contains the address of the branch instruction plus 8 bytes.
and preserves the address of the instruction following the branch in the link register (R14). Execution of Thumb instructions begins at the target address.
o Syntax
BLX <target_addr> 1.Sign-extending the 24-bit signed (two's complement) immediate to 30 bits. 2. Shifting the result left two bits to form a 32-bit value 3.Setting bit[1] of the result of step 2 to the H bit 4.Adding the result of step 3 to the contents of the PC, which contains the address of the branch instruction plus 8.
executed conditionally. Bit[24] :This bit is used as bit[1] of the target address.
instruction set, at an address specified in a register. It sets the CPSR T bit to bit[0] of Rm. This selects the instruction set to be used in the subroutine. The branch target address is the value of register Rm, with its bit[0] forced to zero. It sets R14 to a return address. To return from the subroutine, use a BX R14instruction, or store R14 on the stack and reload the stored value into the PC.
with an optional switch to Thumb state. Syntax BX{<cond>} <Rm> Here <Rm> Holds the value of the branch target address. Bit[0] of Rm is 0 to select a target ARM instruction, or 1 to select a target Thumb instruction.
Jazelle state if Jazelle is available and enabled. Otherwise BXJ behaves exactly as BX Syntax BXJ{<cond>} <Rm>
Data-processing instructions
The data-processing instructions perform calculations on
the general-purpose registers. There are five types of data-processing instructions: Arithmetic/logic instructions
Comparison instructions Single Instruction Multiple Data (SIMD) instructions Multiply instructions.
Arithmetic/logic instructions
These perform an arithmetic or logical operation
on up to two source operands, and write the result to a destination register. They can also optionally update the condition code flags, based on the result. Of the two source operands: one is always a register the other has two basic forms: an immediate value a register value, optionally shifted.
CONTINUED..
o If the operand is a shifted register, the shift amount can
be either an immediate value or the value of another register. o Five types of shift can be specified. o Every arithmetic/logic instruction can therefore perform an arithmetic/logic operation and a shift operation. As a result, ARM does not have dedicated shift instructions.
o The Program Counter(PC) is a general-purpose register,
and therefore arithmetic/logic instructions can write their results directly to the PC. This allows easy implementation of a variety of jump instructions.
Comparison instruction
The comparison instructions use the same instruction
format as the arithmetic/logic instructions. These perform an arithmetic or logical operation on two source operands, but do not write the result to a register. They always update the condition flags, based on the result. The source operands of comparison instructions take the same forms as those of arithmetic/logic instructions, including the ability to incorporate a shift operation.
two parallel 16-bit numbers, or fourparallel 8-bit numbers. They can be treated as signed or unsigned.The operations can optionally be saturating, wrap around, or the results can be halved to avoid overflow. These instructions are available in ARMv6.
Multiply instructions
There are several classes of multiply instructions,
introduced at different times into the architecture. See Multiply instructionson page A3-10 for details. Miscellaneous Data Processing instructions These include Count Leading Zeros (CLZ) and Unsigned Sum of AbsoluteDifferences with optional Accumulate (USAD8and USADA8)
Instruction Encoding
I bit Distinguishes between the immediate and
register forms of <shifter_operand>. S bit Signifies that the instruction updates the condition codes. Rn Specifies the first source operand register. Rd Specifies the destination register. shifter_operand Specifies the second source operand.
register. The second value can be either an immediate value or a value from a register, and can be shifted before the addition.
ADCcan optionally update the condition code flags, based on the result.
instruction updates the CPSR. If Sis omitted, the S bit is set to 0 and the CPSR is not changed by the instruction. Two types of CPSR update can occur when Sis specified:
If <Rd>is not R15, the N and Z flags are set according to the result of the addition, and
the C and V flags are set according to whether the addition generated a carry (unsigned overflow) and a signed overflow, respectively. The rest of the CPSR is unchanged.
If <Rd>is R15, the SPSR of the current mode is copied to the CPSR. This form of the
instruction is UNPREDICTABLE if executed in User mode or System mode, because these modes do not have an SPSR.
register. The second value can be either an immediate value or a value from a register, and can be shifted before the addition. ADDcan optionally update the condition code flags, based on the result. Syntax ADD{<cond>}{S} <Rd>, <Rn>, <shifter_operand>
value comes from a register. The second value can be either an immediate value or a value from a register, and can be shifted before the AND operation. AND can optionally update the condition code flags, based on the result. Syntax AND{<cond>}{S} <Rd>, <Rn>, <shifter_operand>
complement of a second value. The first value comes from a register. The second value can be either an immediate value or a value from a register, and can be shifted before the BIC operation. BIC can optionally update the condition code flags, based on the result. Syntax BIC{<cond>}{S} <Rd>, <Rn>, <shifter_operand>
complement of a second value. The first value comes from a register. The second value can be either an immediate value or a value from a register, and can be shifted before the comparison. CMN updates the condition flags, based on the result of adding the two values. Syntax CMN{<cond>} <Rn>, <shifter_operand>
from a register. The second value can be either an immediate value or a value from a register, and can be shifted before the comparison. CMP updates the condition flags, based on the result of subtracting the second value from the first. Syntax CMP{<cond>} <Rn>, <shifter_operand>
values. The first value comes from a register. The second value can be either an immediate value or a value from a register, and can be shifted before the exclusive OR operation. EORcan optionally update the condition code flags, based on the result. Syntax EOR{<cond>}{S} <Rd>, <Rn>, <shifter_operand>
instructions, ARMv6 introduces a set of parallel addition and subtraction instructions. There are six basic instructions. ADD16 :Adds the top half words of two registers to form the top half word of the result. Adds the bottom half words of the same two registers to form the bottom half word of the result. ADDSUBX Does the following: 1. Exchanges half words of the second operand register. 2. Adds top half words and subtracts bottom half words.
1. Exchanges half words of the second operand register. 2. Subtracts top half words and adds bottom half words. SUB16 :Subtracts the top half word of the first operand register from the top half word of the second operand register to form the top half word of the result. Subtracts the bottom half word of the second operand registers from the bottom half word of the first operand register to form the bottom half word of the result.
ADD8 : Adds each byte of the second operand register to
the corresponding byte of the first operand ,register to form the corresponding byte of the result. SUB8 :Subtracts each byte of the second operand register from the corresponding byte of the first operand register to form the corresponding byte of the result.
EXTENDED INSTRUCTIONS
ARMv6 and above provide several instructions for unpacking data
by sign or zero extending bytes to halfwords or words, and halfwords to words. There are six basic instructions: XTAB16 Extend bits[23:16] and bits[7:0] of one register to 16 bits, and add corresponding halfwords to the values in another register. XTAB Extend bits[7:0] of one register to 32 bits, and add to the value in another register. XTAH Extend bits[15:0] of one register to 32 bits, and add to the value in another register. XTB16 Extend bits[23:16] and bits[7:0] to 16 bits each. XTB Extend bits[7:0] to 32 bits. XTH Extend bits[15:0] to 32 bits.
least significant, halfword of its first operand with the top (most significant) halfwordof its shifted second operand. The shift is a left shift, by any amount from 0 to 31.
PKHTB (Pack Halfword Top Bottom) combines the top,
most significant, halfword of its first operand with the bottom (least significant) halfword of its shifted second operand. The shift is an arithmetic right shift, by any amount from 1 to 32.
32-bit register. REV16 (Byte-Reverse Packed Halfword) reverses the byte order in each 16-bit halfword of a 32-bit register.
REVSH (Byte-Reverse Signed Halfword) reverses the
byte order in the lower 16-bit halfword of a 32-bit register, and sign extends the result to 32-bits.
SEL (Select) selects each byte of its result from either its
first operand or its second operand, according to the values of the GE flags. The GE flags record the results of parallel additions or subtractions.
signed range.. SSAT16 Saturates two 16-bit signed values to a signed range. USAT (Unsigned Saturate) saturates a signed value to an unsigned range.. USAT16 Saturates two signed 16-bit values to an unsigned range.
which load or store the value of a single register, or a pair of registers, from or to memory:
The first type can load or store a 32-bit word or an 8-bit
unsigned byte.
The second type can load or store a 16-bit unsigned halfword,
and can load and sign extend a 16-bit halfword or an 8-bit byte. In ARMv5TE and above, it can also load or store a pair of 32-bit words.
Addressing modes
In both types of instruction, the addressing mode is formed
registers (including the PC, which allows PC-relative addressing for position-independent code). The offset takes one of three formats: Immediate :The offset is an unsigned number that can be added to or subtracted from the base register
the PC), that can be added to or subtracted from the base register. Scaled register :The offset is a general-purpose register (not the PC) shifted by an immediate value, then added to or subtracted from the base register. The same shift operations used for data-processing instructions can be used(Logical Shift Left, Logical Shift Right, Arithmetic Shift Right and Rotate Right), but Logical Shift Left is the most useful as it allows an array indexed to be scaled by the size of each array element.
instructions
Load instructions load a single value from memory and
write it to a general-purpose register. Store instructions read a value from a general-purpose register and store it to memory. These instructions have a single instruction format: LDR|STR{<cond>}{B}{T} Rd, <addressing_mode> I, P, U, W Are bits that distinguish between different types of <addressing_mode>. L bit Distinguishes between a Load (L==1)and a Store instruction (L==0). B bit Distinguishes between an unsigned byte(B==1) and a word (B==0) access.
0x100
Some common areas include: Media instruction space Multiply instruction extension space Control and DSP instruction extension space Load/store instruction extension space Architecturally Undefined Instruction space Coprocessor instruction extension space Unconditional instruction extension space
instruction extension space: opcode[27:24] == 0b0000 opcode[7:4] == 0b1001 opcode[31:28] != 0b1111 /* Only required for version 5 and above */
instruction space. opcode[27:26] == 0b00 opcode[24:23] == 0b10 opcode[20] == 0 opcode[31:28] != 0b1111 /* Only required for version 5 and above */ and not: opcode[25] == 0 opcode[7] == 1 opcode[4] == 1
instruction extension space: opcode[27:25] == 0b000 opcode[7] == 1 opcode[4] == 1 opcode[31:28] != 0b1111 /* Only required for version 5 and above */ and not: opcode[24] == 0 opcode[6:5] == 0
of the CPSR or an SPSR to or from a general-purpose register. Writing to the CPSR can: set the values of the condition code flags set the values of the interrupt enable bits set the processor mode and state alter the endianness of Load and Store operations.
their use is deprecated in ARMv6. It is recommended that all software migrates to using the load and store register exclusive instructions.
Coprocessor instructions
There are three types of coprocessor instructions: Data-processing instructions :These start a coprocessor-
to or from memory. The address of the transfer is calculated by the ARM processor.
Register transfer instructions :These allow a coprocessor
Exception-generating instructions
Two types of instruction are designed to cause specific exceptions to
occur. Software interrupt instructions SWI instructions cause a software interrupt exception to occur. These are normally used to make calls to an operating system, to request an OSdefined service. The exception entry caused by a SWI instruction also changes to a privileged processor mode. This allows an unprivileged task to gain access to privileged functions, but only in ways permitted by the OS. Software breakpoint instructions BKPT instructions cause an abort exception to occur. If suitable debugger software is installed on the abort vector, an abort exception generated in this fashion is treated as a breakpoint. If debug hardware is present in the system, it can instead treat a BKPT instruction directly as a breakpoint, preventing the abort exception from occurring.
are collectively known as the condition code flags, often referred to as flags. The condition code flags in the CPSR can be tested by most instructions to determine whether the instruction is to be executed. The condition code flags are usually modified by: Execution of a comparison instruction (CMN, CMP, TEQor TST). Execution of some other arithmetic, logical or move instruction, where the destination register of the instruction is not R15.