|
|
11.10.2 Branch (to a) (around a) Branch
Many times compilers produce code that branches to another branch. Consider the
following embedded CASE statements and the branches produced by a simple code
generator:
Line Source |
Output Code |
|
|
50 WHILE a DO |
50: |
51 BEGIN |
|
... |
|
61 CASE i OF |
|
62 0: IF b THEN |
|
63 x:=1; |
|
64 ELSE |
64: BRANCH 66 |
65 x:=2; |
|
66 {end case i=0} |
66: BRANCH 142 |
67 l: |
|
... |
|
81 4: CASE j OF |
|
... |
|
89 2: IF b THEN |
|
90 x:=0; |
|
91 ELSE |
91: BRANCH 93 |
92 x:=1; |
|
93 {end case j=2} |
93: BRANCH 121 |
... |
|
120 end; {case j} |
|
121 {end case i=4} |
121: BRANCH 142 |
... |
|
141 end; {case i} |
|
142 end; {while a} |
142: BRANCH 50 |
Just looking at the BRANCHes, we see:
50:
64: BRANCH 66
66: BRANCH 142
91: BRANCH 93
93: BRANCH 121
121: BRANCH 142
142: BRANCH 50
If we fully eliminated the indirect jumps, it would look like this:
50:
64: BRANCH 50
66: BRANCH 50
91: BRANCH 50
93: BRANCH 50
121: BRANCH 50
142: BRANCH 50
|