You have a test program you will compile. To see a listing of that program; the trace of the compile; and three address code click here . The following are excerpts from that code that illustrate some of the code generated for conditionals and jumps.
THIS : INTEGER; THAT : REAL; S1 -> "if" C CondGoToMark "then" S1 GoToMark "else" S1 IF THIS > THAT THEN THIS := THIS ELSE THAT := THIS; 6 @temp4 := intoReal(this) 7 @temp5 := @temp4>that 8 if not @temp5 then goto 11 9 this := this 10 GoTo 13 11 @temp7 := intoReal(this) 12 that := @temp6 13 @temp8 := this+thinDiscuss the CondGoToMark code
S1 -> "while" Mark C CondGoToMark "do" S1 WHILE THIS <= THAT DO THAT := THIS; 17 @temp10 := intoReal(this) 18 @temp11 := @temp10<=that 19 if not @temp11 then goto 23 20 @temp12 := intoReal(this) 21 that := @temp12 22 GoTo 17
1 i := n 2 if i < 2 then goto 32 3 jmax := 1 4 j := 2 5 if j > i then goto 16 6 T1 := j - 1 7 T2 := T1 * 4 8 T3 := x[T2] 9 T4 := jmax - 1 10 T5 := T4 * 4 11 T6 := x[T5] 12 if T3 <= T6 then goto 14 13 jmax := j 14 j := j + 1 15 goto 5 16 if i = jmax then goto 30 17 T7 := i - 1 18 T8 := T7 * 4 19 T9 := x[T8] 20 temp := T9 21 T10 := jmax - 1 22 T11 := T10 * 4 23 T12 := x[T11] 24 T13 := i - 1 25 T14 := T13 * 4 26 x[T14] := T12 27 T15 := jmax - 1 28 T16 := temp 30 i := i -1 31 goto 2 32 return
| 1 i := n | B1 (Start of procedure) |
| 2 if i < 2 then goto B11 | B2 (Target of goto line 31) |
| 3 jmax := 1 4 j := 2 | B3 (Follows conditional ) |
| 5 if j > i then goto B8 | B4 (Target of goto line 15) |
| 6 T1 := j - 1
7 T2 := T1 * 4 8 T3 := x[T2] 9 T4 := jmax - 1 10 T5 := T4 * 4 11 T6 := x[T5] 12 i T3 <= T6 then goto B7 |
B5 (Follows a conditional branch) |
| 13 jmax := j | B6 (Follows a conditional branch) |
| 14 j := j + 1 15 goto B4 |
B7 (Target of goto Line 12) |
| 16 if i = jmax then goto B10 | B8 (Target of goto Line 5) |
| 17 T7 := i - 1
18 T8 := T7 * 4 19 T9 := x[T8] 20 temp := T9 21 T10 := jmax - 1 22 T11 := T10 * 4 23 T12 := x[T11] 24 T13 := i - 1 25 T14 := T13 * 4 26 x[T14] := T12 27 T15 := jmax - 1 28 T16 := temp |
B9 (Follows conditional branch) |
| 30 i := i -1 31 goto 2 |
B10 (Target of goto Line 16) |
| 32 return | B11 (Target of goto Line 2) |