Delayed Branches
7-10
Example 7–6. Incorrectly Placed Delayed Branches
B1:
BD
L1
NOP
NOP
B2:
B
L2
; This branch is incorrectly placed.
NOP
NOP
NOP
.
.
.
For faster execution, it might still be advantageous to use a delayed branch
followed by NOP instructions by trading increased program size for faster
speed. This is shown in Example 7–7 where a NOP takes the place of the third
unused instruction after the delayed branch.
Example 7–7. Delayed Branch Execution
*
TITLE DELAYED BRANCH EXECUTION
.
.
.
.
LDF* +AR1(5),R2
; Load contents of memory to R2
BGED
SKIP
; If loaded number >=0, branch
; (delayed)
LDFN
R2,R1
; If loaded number <0, load it to R1
SUBF
3.0,R1
; Subtract 3 from R1
NOP
; Dummy operation to complete delayed
; branch
MPYF
1.5,R1
; Continue here if loaded number <0
.
.
.
SKIP
LDF
R1,R3
; Continue here if loaded number >=0