












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Three Address Statement Types, Assignment statement, Arithmetic operation, Logical operation, Unary minus, Copy statement, Unconditional jump are basic concepts discussed of course.
Typology: Slides
1 / 20
This page cannot be seen from the preview
Don't miss anything!













2
Three-Address Statement Types
Prior to proceeding with flow- of-control construct, here are the types of three-Address statements that we will use
4
Three-Address Statement Types
Assignment statement
x = op y
where op is a unary operation, e.g., unary minus, logical negation, shift operators
5
Three-Address Statement Types
Copy statement
x = y
where value of y is assigned to x
7
Three-Address Statement Types
Conditional jump
if x relop y goto L
where relop is <, =, >=, etc. If x stands in relation relop to y , execute statement with label L , next otherwise
8
Three-Address Statement Types
Indexed assignment
a) x = y[i] b) x[i] = y In a), set x to value in location i memory units beyond location y.
10
Array of Quadruples
Label Target Op Arg1 Arg L1 if_lt c d L2 goto L1: x (^) + y z L3 goto L2: x – y z L3: nop
11
We associate with a boolean expression E two labels; E.true and E.false
The control flows to E.true if the expression evaluates to true, to E.false otherwise
13
to E.true to E.false E.true:
E.false:
E.code
S 1 .code .......
S → if E then S 1
14
Syntax-directed translation for S → if E then S (^1)
E.true = newlabel() E.false = S.next S 1 .next = S.next S.code = E.code || gen(E.true ‘:’) || S 1 .code
inherited attribute
16
Suppose E is a < b. E.code is
if a < b goto E.true goto E.false
We will discuss semantic rules for boolean expressions shortly
17
S → if E then S 1 else S 2
to E.true to E.false E.true:
E.false:
E.code S 1 .code
.......
goto S.next S 2 .code S.next:
19
while E do S 1
to E.true to E.false E.true:
E.false:
E.code S 1 .code
.......
goto S.begin
S.begin:
20
S → while E do S (^1)
S.begin = newlabel() E.true = newlabel() E.false = S.next S 1 .next = S.begin S.code = gen(S.begin ‘:’) || E.code || gen(E.true ‘:’) || S 1 .code || gen(‘goto’ S.begin)