# hw3sol2 - CS 6353 Compiler Construction, Homework #3 1....

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Dragon book, second edition, Exercise 8.4.2. Consider the following program. for (i=2; i<=n; i++) a[i] = TRUE; count = 0; s = sqrt (n); for (i=2; i<=s; i++) if (a[i]) { count++; for (j=2*i; j<=n; j = j+1) a[j] = FALSE; } (a) Translate the program into three address code as defined in Section 8.2, dragon book. (1) i := 2; (2) if (!(i <= n)) goto (6); (3) a[i] := TRUE; (4) i := i + 1; (5) goto (2); (6) count := 0; (7) s := sqrt(n); (8) i := 2; (9) if (!(i <= s)) goto (19); (10) if(!a[i]) goto (17); (11) count := count + 1; (12) j := 2*i; (13) if (!(j <= n)) goto (17); (14) a[j] := FALSE; (15) j := j + 1; (16) goto (13); (17) i := i + 1; (18) goto (9); (19) exit (b) Identify all basic blocks in your three address code. B1: 1
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/25/2012 for the course CS 6413 taught by Professor Ye during the Spring '07 term at University of Texas at Dallas, Richardson.

### Page1 / 18

hw3sol2 - CS 6353 Compiler Construction, Homework #3 1....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online