|
S1
S2
bra L // Branch without delay
S3 // S3 is NOT executed
S4
...
L: S10
S11
|
Assembler programs written under the no delay branch assumption will not execute correctly when the branch instruction has a delay effect !!!
|
|
|
|
|
|
|
|
|
How to run the program:
|
|
s1
s2
s3
cmp ...
bcc Label // Conditional branch
nop // NOP instruction in "delay slot"
s4
s5
Label: t1
t2
....
|
Seq. when branch is taken: s1 s2 s3 cmp bcc nop t1 t2 .... Seq. when branch not taken: s1 s2 s3 cmp bcc nop s4 s5 t1 t2 .... |
1. Replace the nop instruction by
Copying the target instruction of the branch (= t1)
2. Move the target instruction of the branch (= t1)
above the branch label
|
Example:
|
|
|
|
|
|
Explanation:
|
bcc,a Label
E.g.: blt,a label
|
1. Replace the nop instruction by
Copying the target instruction of the branch (= t1)
2. Move the target instruction of the branch (= t1)
above the branch label
3. Replace the branch by its annulling version
|
Example:
|
|
|
How to run the program:
|