Instruction Cycle Operations
ARM7TDMI Data Sheet
ARM DDI 0029E
10-3
O
10.3 THUMB Branch with Link
A THUMB Branch with Link operation consists of two consecutive THUMB
instructions, see
·
5.19 Format 19: long branch with link
on page 5-40.
The first instruction acts like a simple data operation, taking a single cycle to add the
PC to the upper part of the offset, storing the result in Register 14 (LR).
The second instruction acts in a similar fashion to the ARM Branch with Link
instruction, thus its first cycle calculates the final branch destination whilst performing
a prefetch from the current PC.
The second cycle of the second instruction performs a fetch from the branch
destination and the return address is stored in R14.
The third cycle of the second instruction performs a fetch from the destination +2,
refilling the instruction pipeline and R14 is modified (2 subtracted from it) to simplify
the return to
MOV PC, R14
. This makes the
PUSH {..,LR} ; POP {..,PC}
type
of subroutine work correctly.
The cycle timings of the complete operation are shown in
·
Table 10-2: THUMB Long
Branch with Link
pc
is the address of the first instruction of the operation.
10.4 Branch and Exchange (BX)
A Branch and Exchange operation takes 3 cycles and is similar to a Branch.
In the first cycle, the branch destination and the new core state are extracted from the
register source, whilst performing a prefetch from the current PC. This prefetch is
performed in all cases, since by the time the decision to take the branch has been
reached, it is already too late to prevent the prefetch.
During the second cycle, a fetch is performed from the branch destination using the
new instruction width, dependent on the state that has been selected.
The third cycle performs a fetch from the destination +2 or +4 dependent on the new
specified state, refilling the instruction pipeline. The cycle timings are shown in
·
Table
10-3: Branch and Exchange instruction cycle operations
on page 10-4.
Cycle
Address
MAS[1:0]
nRW
Data
nMREQ
SEQ
nOPC
1
pc + 4
1
0
(pc + 4)
0
1
0
2
pc + 6
1
0
(pc + 6)
0
0
0
3
alu
1
0
(alu)
0
1
0
4
alu + 2
1
0
(alu + 2)
0
1
0
alu + 4
Table 10-2: THUMB Long Branch with Link