MPCA Basics
MPCA Basics
1.1 INTRODUCTION
Characteristic of RISC
Simpler instruction, hence simple instruction decoding.
Instruction comes undersize of one word.
Instruction takes a single clock cycle to get executed.
More number of general-purpose registers.
Simple Addressing Modes.
Less Data types.
Pipeline can be achieved.
1
3. Registers:—RISC machines have a large general-purpose register set. Any
register can contain either data or an address. In contrast, CISC processors
have dedicated registers for specific purposes.
4. Load-store architecture:—the processor operates on data held in registers.
Separate load and store instructions transfer data between the register bank
and external memory In contrast, with a CISC design the data processing
operations can act on memory directly.
Characteristic of CISC
Complex instruction, hence complex instruction decoding.
Instructions are larger than one-word size.
Instruction may take more than a single clock cycle to get executed.
Less number of general-purpose registers as operation get performed in
memory itself.
Complex Addressing Modes.
More Data types.
2
2. Thumb-2 Technology –
Thumb-2 Technology was introduced in 2003 and was used to create
variable length instruction set. It extends 16-bit instructions of initial Thumb
technology to 32-bit instructions. It has better performance than previously
used Thumb technology.
3. One cycle execution time –
ARM processor is optimised for each instruction on CPU. Each instruction is
of fixed length that allows time for fetching future instructions before
executing present instruction. ARM has CPI (Clock per Instruction) of one
cycle.
4. Pipelining –
Processing of instructions is done in parallel using pipelines. Instructions are
broken down and decoded in one pipeline stage. The pipeline advances one
step at a time to increase throughput (rate of processing).
5. Large number of registers –
Large number of registers are used in ARM processor to prevent large
amount of memory interactions. Registers contain data and addresses.
These act as local memory store for all operations.
3
ARM is based upon RISC Architecture with enhancements to meet
requirements of embedded applications
A large uniform register file
Load-store architecture
Fixed length instructions
32-bit processor
Good speed/Good Power
High code density
4
1.4 REGISTER BANK
5
The ARM Register Set
In all ARM processors, the following registers are available and accessible in
any processor mode:
13 general-purpose register R0-R12.
One Stack Pointer (SP)
One Link Register (LR).
One Program Counter (PC).
One Current Program Status Register (CPSR).
ARM processors, with the exception of ARMv6-M and ARMv7-M based
processors, have a total of 37 registers, with 3 additional registers if the
Security Extensions are implemented, and in ARMv7-A only, 3 more if the
Virtualization Extensions are implemented.
6
Mode Changing
7
When the processor is executing in Thumb state:
All instructions are 16 bits wide
All instructions must be halfword aligned
Therefore the pc value is stored in bits [31:1] with bit [0] undefined (as
instruction cannot be byte aligned)
When the processor is executing in Jazelle state:
All instructions are 8 bits wide
Processor performs a word access to read 4 instructions at once
8
ARM Memory Organization
Can be configured as
Little Endian
Big Endian
Addresses are for each byte
Figure 6Figure 1
ARM instruction Format
9
ARM Data Types
10
1.6 DATA PROCESSING INSTRUCTION VARIANTS
11
Most data processing instructions can process one of their operands using the
barrel shifter.
General rules:
All operands are 32-bit, coming from registers or literals.
The result, if any, is 32-bit and placed in a register (with the exception of
long multiply which produces a 64-bit result)
3-address format
If you use the S suffix on a data processing instruction, then it updates the flags
in the CPSR.
These instructions only work on registers, NOT memory.
Comparisons set flags only - they do not specify Rd
Data movement does not specify Rn
Second operand is sent to the ALU via barrel shifter.
Suffix S on data processing instructions updates flags in CPSR
Operands are 32-bit wide
32-bit result placed in register
Long multiply instruction produces 64-bit result
The data processing instructions manipulate data within registers. They are
Move instructions
Arithmetic instructions
Logical instructions
Comparison instructions
Multiply instructions
The data processing operations may be classified as logical or arithmetic. The
logical operations (AND, EOR, TST, TEQ, ORR, MOV, BIC, MVN) perform the
logical action on all corresponding bits of the operand or operands to produce
the result. If the S bit is set (and Rd is not R15, see below) the V flag in the
CPSR will be unaffected, the C flag will be set to the carry out from the barrel
shifter (or preserved when the shift operation is LSL #0), the Z flag will be set if
and only if the result is all zeros, and the N flag will be set to the logical value
of bit 31 of the result.
The data processing instruction is only executed if the condition is true. The
instruction produces a result by performing a specified arithmetic or logical
operation on one or two operands. The first operand is always a register
(Rn).The second operand may be a shifted register (Rm) or a rotated 8 bit
immediate value (Imm) according to the value of the I bit in the instruction.
12
The condition codes in the CPSR may be preserved or updated as a result of
this instruction, according to the value of the S bit in the instruction.
Certain operations (TST, TEQ, CMP, CMN) do not write the result to Rd. They
are used only to perform tests and to set the condition codes on the result and
always have the S bit set.
Data Processing Instructions - Examples
1. MOVCS R0, R1 @ if carry is set @ then R0:=R1
2. MOVS R0, #0 @ R0:=0 @ Z=1, N=0 @ C, V unaffected
3. ADDS r0, r1, r2, LSL #3 ; r0=r1+ (r2*8), flags change
4. CMP r0, #5 ; if r0 == 5, set Z flag
5. ADDEQ r1, r2, r3 ; If Z=1, r1=r2+r3 else skip
6. AND r0, r0, #0x1 ; status of bottom bit of r0
7. BIC r0, r1, r2 ; 1 in r2 bits clears r1 bits
8. CMN r0, #6400 ; flags change on r0+6400, r0 is same
Register movement
MOV R0, R2 @ R0 = R2
MVN R0, R2 @ R0=~R2
Addressing modes
• Register operands ADD R0, R1, R2
• Immediate operands a literal
ADD R3, R3, #1 @ R3:=R3+1
AND R8, R7, #0xff @ R8=R7 [7:0]
Shifted register operands
One operand to ALU is routed through the Barrel shifter. Thus, the operand
can be modified before it is used. Useful for fast multiplication and dealing
with lists, table and other complex data structure.
Some instructions (e.g. MUL, CLZ, QADD) do not read barrel shifter.
13
Move Instructions:
Move and logical operations update the carry flag C, negative flag N, and zero
flag Z. The carry flag is set from the result of the barrel shift as the last bit
shifted out. The N flag is set to bit 31 of the result. The Z flag is set if the result
is zero.
It copies N into a destination register Rd, where N is a register or
immediate value.
This instruction is useful for setting initial values and transferring data
between registers.
Syntax: <instruction> {<cond>} {S} Rd, N
Figure 3 MOV
Figure andand
8 MOV MVNMVN
MOV Rd, N
Rd: destination register, N: can be an immediate value or source register
Example: MOV r7, r5
MVN Rd, N; Move into Rd not of the 32-bit value from source
The second operand N for all data processing instructions is a register Rm or a
constant preceded by #.
Example: This example shows a simple move instruction.
The MOV instruction takes the contents of register r5 and copies them into
register r7, in this case, taking thevalue 5, and overwriting the value 8 in
register r7.
PRE MOV r7, r5; let r5 = 5
POST r5 = 5, r7= 5
14
Using the Barrel Shifter:
In above example we showed a MOV instruction where N is a simple register.
But N can be more than just a register or immediate value; it can also be a
register Rm that has been pre-processed by the barrel shifter prior to being
used by a data processing instruction.
Data processing instructions are processed within the arithmetic logic
unit (ALU).
A unique and powerful feature of the ARM processor is the ability to
shift the 32-bit binary pattern in one ofthe source registers left or right
by a specific number of positions before it enters the ALU.
Pre-processing or shift occurs within the cycle time of the instruction.
This is particularly useful for loading constants into a register and
achieving fast multiplies or division by a power of 2.
Enables shifting 32-bit operand in one of the source registers left or right
by a specific number of positions within the cycle time of instruction
Facilitate fast multiply, division and increases code density
The below figure shows the data flow between the ALU and the barrel shifter.
15
Example: Apply a logical shift left (LSL) to register Rm before moving it to the
destination register. The MOV instruction copies the shift operator result N
into register Rd. N represents the result of the LSL operation.
PRE r5 = 5 r7 = 8
MOV r7, r5, LSL #2 ; let r7 = r5*4 = (r5 << 2)
POST r5 = 5 r7 = 20
The example multiplies register r5 by four and then places the result into
register r7.
The five different shift operations that you can use within the barrel shifter are
summarized in below table.
Figure10
Figure 5 Barrel Shifter related Shift Operations
The below table lists the syntax for the different barrel shift operations
available on data processing instructions. The second operand N can be an
immediate constant proceeded by #, a register value Rm, or the value of Rm
processed by a shift.
16
Example: This example of a MOVS instruction shifts register r1 left by one
bit. This multiplies register r1 by a value 21. As you can see, the C flag is
updated in the cpsr because the S suffix is present in the instruction
mnemonic.
PRE cpsr = nzcvqiFt_USER r0 = 0x00000000 r1 = 0x80000004
MOVS r0, r1, LSL #1
POST cpsr = nzCvqiFt_USER r0 = 0x00000008 r1 = 0x80000004
17
Example: This reverse subtract instruction (RSB) subtracts r1 from the constant
value #0, writing the result to r0. This instruction use to negate numbers.
PRE r0 = 0x00000000 r1 = 0x00000077
RSB r0, r1, #0; Rd = 0x0 - r1
POST r0 = -r1 = 0xffffff89
Example: The SUBS instruction is useful for decrementing loop counters. In this
example we subtract the immediate value one from the value one stored in
register r1. The result value zero is written to register r1. The cpsr is updated
with the ZC flags being set.
PRE cpsr = nzcviFt_USER r1 = 0x00000001
SUBS r1, r1, #1
POST cpsr = nZCviFt_USER r1 = 0x00000000
18
Example: Shows a logical OR operation between registers r1 and r2. r0 holds
the result.
PRE r0 = 0x00000000 r1 = 0x02040608, r2 = 0x10305070
ORR r0, r1, r2
POST r0 = 0x12345678
Example: Shows a more complicated logical instruction called BIC, which
carries out a logical bit clear.
PRE r1 = 0b1111 r2 = 0b0101
BIC r0, r1, r2
POST r0 = 0b1010 ; This is equivalent to Rd = Rn AND NOT (N)
R2 contains a binary pattern where every binary 1 in r2 clears a corresponding
bit location in register r1 .Useful in manipulating status flags and interrupt
masks.
The logical instructions update the cpsr flags only if the S suffix is present.
These instructions can use barrel- shifted second operands in the same way as
the arithmetic instructions.
Comparison Instructions:
The comparison instructions are used to compare or test a register with a 32-
bit value. They update the cpsr flag bits according to the result, but do not
affect other registers. For these instructions no needs to apply the S suffix for
update the flags.
Enables comparison of 32 bit values
Updates CPSR flags but do not affect other registers
Examples
CMP r0, r9 ;–Flags set as a result of r0 - r9
TEQ r0, r9 ;–Flags set as a result r0 ex-or r9
TST r0, r9 ;–Flags set as a result of r0 & r9
19
Example: This example shows a CMP comparison instruction. You can see that
both registers, r0 and r9, are equal before executing the instruction. The value
of the z flag prior to execution is 0 and is represented by a lowercase z. After
execution the z flag changes to 1 or an uppercase Z. This change indicates
equality.
PRE cpsr = nzcviFt_USER r0 = 4; r9 = 4
CMP r0, r9 POST cpsr = nZcviFt_USER
The CMP is effectively a subtract instruction with the result discarded.
TST instruction is a logical AND operation
TEQ is a logical exclusive OR operation.
For each, the results are discarded but the condition bits are updated in the
cpsr.
Multiply Instructions:
There are 2 classes of multiply - producing 32-bit and 64-bit results
32-bit versions on an ARM7TDMI will execute in 2 - 5 cycles
MUL r0, r1, r2 ; r0 = r1 * r2
MLA r0, r1, r2, r3 ; r0 = (r1 * r2) + r3
64-bit multiply instructions offer both signed and unsigned versions. For this
instruction there are 2 destination registers
[U|S]MULL r4, r5, r2, r3 ; r5:r4 = r2 * r3
[U|S]MLAL r4, r5, r2, r3 ; r5:r4 = (r2 * r3) + r5:r4
Most ARM cores do not offer integer divide instructions. Division operations
will be performed by C library routines or inline shifts
The multiply instructions multiply the contents of a pair of registers and,
depending upon the instruction, accumulate the results in with another
register. The long multiply accumulate onto a pair of registers representing a
64-bit value. The final result is placed in a destination register or a pair of
registers.
20
Example: This example shows a simple multiply instruction that multiplies
registers r1 and r2 together and places the result into register r0.
PRE r0 = 0x00000000 r1 = 0x00000002, r2 = 0x00000002
MUL r0, r1, r2; r0 = r1*r2
POST r0 = 0x00000004 r1 = 0x00000002r2 = 0x00000002
The long multiply instructions (SMLAL, SMULL, UMLAL, and UMULL) produce a
64-bit result.
The result is too large to fit a single 32-bit register so the result is placed in two
registers labeled RdLo and RdHi. RdLo holds the lower 32 bits of the 64-bit
result, and RdHi holds the higher 32 bits of the 64-bit result.
Example: Shows an example of a long unsigned multiply instruction. The
instruction multiplies registers r2 and r3 and places the result into register r0
and r1. Register r0 contains the lower 32 bits, and register r1 contains the
higher 32 bits of the 64-bit result.
PRE r0 = 0x00000000 r1 = 0x00000000
r2 = 0xf0000002 r3 = 0x00000002
UMULL r0, r1, r2, r3; [r1, r0] = r2*r3
POST r0 = 0xe0000004; = RdLo r1 = 0x00000001; = RdHi
1.7 BRANCH INSTRUCTION
21
Branch has a condition associated with it and executed if condition codes have
the correct value
Branch and Exchange (BX)-This instruction is only executed if the condition is
true. This instruction performs a branch by copying the contents of a general
register, Rn, into the program counter, PC. The branch causes a pipeline flush
and refill from the address specified by Rn. This instruction also permits the
instruction set to be exchanged. When the instruction is executed, the value of
Rn[0] determines whether the instruction stream will be decoded as ARM or
THUMB instructions.
Branch and Branch with Link (B, BL)-The instruction is only executed if the
condition is true. Branch instructions contain a signed 2’s complement 24 bit
offset. This is shifted left two bits, sign extended to 32 bits, and added to the
PC. The instruction can therefore specify a branch of +/- 32Mbytes. The branch
offset must take account of the prefetch operation, which causes the PC to be
2 words (8 bytes) ahead of the current instruction.
Branches beyond +/- 32Mbytes must use an offset or absolute destination
which has been previously loaded into a register. In this case the PC should be
manually saved in R14 if a Branch with Link type operation is required.
The link bit Branch with Link (BL) writes the old PC into the link register (R14)
of the current bank. The PC value written into R14 is adjusted to allow for the
prefetch, and contains the address of the instruction following the branch and
link instruction.
Note that the CPSR is not saved with the PC and R14 [1:0] are always cleared.
To return from a routine called by Branch with Link use MOV PC,R14 if the link
register is still valid or LDM Rn!,{..PC} if the link register has been saved onto a
stack pointed to by Rn.
22
Features of Conditional Execution instructions
Almost all ARM instructions have a condition field which allows it to be
executed conditionally. Improves execution speed and offers high code density
23
Illustration:
24
Subroutines
•Called from main program using ‘BL’ instruction
•The instruction places PC-4 in LR and addr of subroutine in PC
•Last instruction in subroutine is MOV PC, LR or BX LR
•If not a leaf routine (nested subroutine):
Store LR in stack using STMxx r13, {……, r14} at entry
Restore LR from stack using LDMxx r13, {…, r14} before exit
The following program fragment implements ‘is the value of ‘A’ 1 or 5 or 8?’
Let the value of ‘A’ be in register r0.
TEQ r0, #1 ; if r0 == 0, then Z = 1
TEQNE r0, #5; if Z! = 1 & if r0==5, then Z=1
TEQNE r0, # 8 ; if Z != 1 & if r0==8, then Z=1
BNE error; if Z! = 1 branch to report error
Load-Store Instructions
Load-store instructions transfer data between memory and processor
registers. There are three types of load-store instructions:
Single register transfer
Data types supported are signed and unsigned words (32 bits), half-word,
bytes
Multiple-register transfer
Transfer multiple registers between memory and the processor in a single
instruction
Swap
Swaps content of a memory location with the contents of a register
25
Single-Register Transfer:
Transfers boundary aligned Word/HW/Byte between memory & register
LDR and STR instructions
Address of memory loc. is given by Base Addr. +/- Offset
Addressing modes: method of providing offset
Register addressing – A register contains offset
These instructions are used for moving a single data item in and out of a
register.
The data types supported are signed and unsigned words (32-bit), half
words (16-bit), and bytes.
26
Example: LDR r0, [r1]
STR r0, [r1]
The first instruction loads a word from the address stored in register r1 and
places it into register r0.The second instruction goes the other way by storing
the contents of register r0 to the address contained in register r1.Register r1 is
called the base address register.
Immediate addressing – Immediate constant is offset
Scaled addressing – Offset in a register is scaled using shift operation
Syntax: <opcode> {<condition>}{<type>}Rd,[Rn{,<offset>}]
<type> - H, HS, B, BS
Rd – source/destination register
Rn – Base address
<offset> - ‘Rm’ or # (0-4095) or ‘Rm, <shift>#n’
27
The ARM instruction set provides different modes for addressing memory.
These modes incorporate one of the indexing methods:
Preindexed:
<opcode> {<cond>}{<type>}Rd,[Rn{,<offset>]
Preindexed with write back (note the exclamation symbol)
<opcode> {<cond>}{<type>}Rd,[Rn{,<offset>]!
Postindexed
<opcode> {<cond>}Rd,[Rn],<offset>
Preindex with write back: It calculates an address from a base register plus
address offset and then updates that address base register with the new
address.
Preindex: It calculates an address from a base register plus address offset but
does not update the address base register.
Postindex: It only updates the address base register after the address is used.
Note: The pre-index mode is useful for accessing an element in a data
structure. The post index and pre index with write back modes are useful for
traversing an array.
The offset address can provide in the instructions in different types. They are
Immediate: It means the address is calculated using the base address register
and a 12-bit offset encoded in the instruction.
28
Register: It means the address is calculated using the base address register and
a specific register’s contents.
Scaled: It means the address is calculated using the base address register and a
barrel shift operation.
Example: Index addressing modes
PRE r0 = 0x00000000 r1 = 0x00090000
mem32 [0x00009000] = 0x01010101, mem32 [0x00009004] = 0x02020202
Preindexing with write back: LDR r0, [r1, #4]!
POST (1) r0 = 0x02020202 r1 = 0x00009004
Preindexing:LDR r0, [r1, #4] POST (2) r0 = 0x02020202, r1 = 0x00009000
Postindexing: LDR r0, [r1], #4
POST (3) r0 = 0x01010101 r1 = 0x00009004
Table below shows the addressing modes available for load and store of a 32-
bit word or an unsigned byte.
A signed offset or register is denoted by “+/−”, identifying that it is
either a positive or negative offset from the base address register Rn.
The base address register is a pointer to a byte in memory, and the
offset specifies a number of bytes.
29
Table below provides an example of the different variations of the LDR
instruction.
Table below shows the addressing modes available on load and store
instructions using 16-bit half word orsigned byte data.
There are no STRSB or STRSH instructions since STRH store both a signed and
unsigned half word; similarly STRB stores signed and unsigned bytes. Table
below shows the variations for STRH instructions.
30
Indexing methods – Examples
31
Any subset of current bank of registers can be transferred to memory or
fetched from memory
LDM
SDM
The base register Rn determines source or destination address
More efficient for moving blocks of memory and saving and restoring context
and stack. These instructions can increase interrupt latency. Instruction
executions are not interrupted by ARM
Stack Processing
A stack is implemented as a linear data structure which grows up (ascending)
or down (descending) .Stack pointer hold the address of the current top of the
stack.
Modes of Stack Operation
ARM multiple register transfer instructions support
Full ascending: grows up, SP points to the highest address containing a valid
item
Empty ascending: grows up, SP points to the first empty location above
stack
Full descending: grows down, SP points to the lowest address containing a
valid data
Empty descending: grows down, SP points to the first location below the
stack
32
Some Stack Instructions
Full Ascending
LDMFA: translates to LDMIA (POP)
STMFA: translates to STMIB (PUSH)
SP points to last item in stack
Empty Descending
LDMED: translates to LDMIB (POP)
STMED: translates to STMIA (PUSH)
SP points to first unused location
Addressing Modes
LDMIA|IB|DA|DB ex: LDMIA Rn! , {r1-r3}
STMIA|IB|DA|DB
Stack Example
Table below shows the different addressing modes for the load-store multiple
instructions.
33
Here N is the number of registers in the list of registers. The base register Rn
determines the source or destination address for a load store multiple
instruction. This register can be optionally updated following the transfer when
register Rn is followed by the ‘!’ character.
Example: Register r0 is the base register Rn and is followed by! indicating that
the register is updated after the instruction is executed.
PRE mem32 [0x80018] = 0x03
mem32 [0x80014] = 0x02
mem32 [0x80010] = 0x01
r0 = 0x00080010 r1 = 0x00000000, r2 = 0x00000000
34
Program Status Register Instructions
•Instructions to read/write from/to CPSR or SPSR
•Instructions: MRS, MSR
Syntaxes:
MRS{<cond>} Rd,<CPSR|SPSR>
MSR{<cond>} <CPSR|SPSR>,Rm
MSR{<cond>} <CPSR|SPSR>_<fields>,Rm
MSR{<cond>} <CPSR|SPSR>_<fields>,#immediate
•Modifying CPSR, SPSR: Read, Modify and Write back technique
35
Figure 28 SWI Instruction
All ARM instructions are conditionally executed, which means that their
execution may or may not take place depending on the values of the N, Z, C
and V flags in the CPSR. The condition encoding is shown in Figure 29.
36
If a NOP is required it is suggested that MOV R0, R0 be used. The assembler
treats the absence of a condition code as though always had been specified.
The other condition codes have meanings as detailed in Figure 30.
For instance code 0000 (EQual) causes the instruction to be executed only if
the Z flag is set. This would correspond to the case where a compare (CMP)
instruction had found the two operands to be equal. If the two operands were
different, the compare instruction would have cleared the Z flag and the
instruction will not be executed.
The branch offset must take account of the prefetch operation, which causes
the PC to be 2 words (8 bytes) ahead of the current instruction. Branches
beyond +/- 32Mbytes must use an offset or absolute destination that has been
previously loaded into a register. In this case the PC should be manually saved
in R14 if a Branch with Link type operation is required.
37
The link bit
Branch with Link (BL) writes the old PC into the link register (R14) of the
current bank. The PC value written into R14 is adjusted to allow for the
prefetch, and contains the address of the instruction following the branch and
link instruction. Note that the CPSR is not saved with the PC. To return from a
routine called by Branch with Link use MOV PC,R14 if the link register is still
valid or LDM Rn!,{..PC} if the link register has been saved onto a stack pointed
to by Rn.
Data processing
The instruction is only executed if the condition is true. The instruction
encoding is shown in Figure 32.The instruction produces a result by performing
a specified arithmetic or logical operation on one or two operands. The first
operand is always a register (Rn). The second operand may be a shifted
register (Rm). The condition codes in the CPSR may be preserved or updated
as a result of this instruction, according to the value of the S bit in the
instruction. Certain operations (TST, TEQ, CMP, CMN) do not write the result to
Rd. They are used only to perform tests and to set the condition codes on
the result and always have the S bit set.
38
Figure 32 Data Processing Instructions
Shifts
When the second operand is specified to be a shifted register, the Shift field in
the instruction controls the operation of the barrel shifter. This field indicates
the type of shift to be performed (logical left or right, arithmetic right or rotate
right). The amount by which the register should be shifted may be contained in
an immediate field in the instruction, or in the bottom byte of another register
(other than R15). The encoding for the different shift types is shown in Figure
33.
39
Assembler
OpCode Action
Mnemonic
40
Figure 33 ARM Shift Operations
Writing to R15
When Rd is a register other than R15, the condition code flags in the CPSR may
be updated from the ALU flags as described above.
When Rd is R15 and the S flag in the instruction is not set the result of the
operation is placed in R15 and the CPSR is unaffected.
When Rd is R15 and the S flag is set the result of the operation is placed in R15
and the SPSR corresponding to the current mode is moved to the CPSR. This
allows state changes that atomically restore both PC and CPSR. This form of
instruction shall not be used in User mode.
41
Figure 34 PSR Transfer
42
1.13 Instruction Encoding-Data Transfer Instructions
The instruction is only executed if the condition is true. The various conditions
are defined at the beginning of this chapter. The instruction encoding is shown
in Figure 36. The single data transfer instructions are used to load or store
single bytes or words of data. The memory address used in the transfer is
calculated by adding an offset to a base register.
43
Use of R15
When using R15 as the base register you must remember it contains address 8
bytes on from the address of the current instruction. When R15 is the source
register (Rd) of a register store (STR) instruction, the stored value will be
address of the instruction plus 8.
44
Software interrupts (SWI)
The instruction is only executed if the condition is true. The various conditions
are defined at the beginning of this chapter. The instruction encoding is shown
in Figure 38.
The software interrupt instruction is used to enter Supervisor mode in a
controlled manner. The instruction causes the software interrupt trap to be
taken, which effects the mode change. The PC is then forced to a fixed value
(0x08) and the CPSR is saved in SPSR_svc.
45