APA format 1 page long 3 references  1 from walden university and please use one from the references belowThis is for a MSN degreeOur team´s selected setting is Suncrest Home Care and Hospice locate

KINGDOM OF SAUDI ARABIA | JAZAN UNIVERSITY

COLLEGE OF COMPUTER SCIENCE & INFORMATION TECHNOLOGY

ASSIGNMENT II - 2018-2019

Academic Year

2018-19 (1439-40 H)

Semester

Spring

Course with code

Theory of Compilers (COMP 433)

Section

2303

Type of Assignment

Problem Assignment

Marks

10

Date of Announcement

03-03-2019

Deadline

03-04-2019

ASSIGNMENT PROBLEM STATEMENT

  1. Generate 3AC code for the following code segments:

a)

if(x+y*z>x*y+z)

a+0;

b)

fact(x)
f int f=1;
for (i=2, i >=x, i++)
f
f=f*i;
return f;

  1. Implement the statement a=b*-c+b*-c into following Intermediate code representation.

  1. Quadruple

  2. Indirect Triples


  1. For the given boolean expression (a + b c) + d + (a + b c) − d + e draw the DAG


  1. Construct the DAG for the following Block:


L0:T0=b+c

L1:T1=t0*d

L2:a=T1

L3: T2=f*a

L4 :e=T2

L5:T3 =b+c

L6 :T4=T3*e

L7:F=T4

L8:T5=b+c

L9:T6=T5/d

L10:g=T6

  1. Divide the following code segment into basic blocks, draw a control flow graph.


(1)P := 0

(2) I := 1

(3) P := P + I

(4) IF P <= 60 GOTO (7)

(5) P := 0

(6) I := 5

(7) T1 := I * 2

(8) I := T1 + 1

(9) IF I <= 20 GOTO (3)

(10) K := P * 3


  1. Show all the steps required to parse the input string (( a,a ),a,a )

  1. Consider the fragment of source code. Identify leader, basic block and draw a control flow graph.

sum=0;

for(i=0;i<=10;i++)

sum=sum+a[t1];

  1. Write the steps in code generation algorithm and generate target code for the following source language statements.

a) x=a+b+c*d

b) a= (a + b) + (a * b) * (a - b)

  1. Optimize and develop this code by eliminating common sub expression, performing reduction in strength.


(1) prod:=0

(2) i:=1

(3) t1:=4*i

(4) t2:a[t1]

(5) t3=4*i

(6) t4=b[t3]

(7) t5:=t2*t4

(8)t6:=prod+t5

(9)prod:=t6

(10) t7=i+1

(11)i:=t7

(12)if i<=20 goto (3)


10. Explain in detail about the following:

a) Elements in Activation Record

b) Static Allocation vs Dynamic Allocation vs Heap Allocation


Name of the Course teacher

Ms. Sameena Shaik

Signature

NOTE:

  1. Submit assignment within due date. Marks will be deducted for late submission.

  2. Marks will be given on basis of submitted assignment.

  3. Only soft copy assignments will be accepted (No handwritten). Assignment will be accepted through BLACKBOARD portal.

  4. The students are open to search from internet or from text book.