# hw8 - i = 0 sum = 0 while(i< 10 a[i = a[i 1 sum = sum a[i...

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

CS 415 Compilers: Problem Set 7 Due date: Wednesday, April 21, 2010, before recitation Problem 1 – Type Systems Assume a type system with the following inference rules Rule A 1 : E e : integer E & e : pointer ( integer ) Rule A 2 : E e : pointer ( integer ) E ‘ * e : integer Assuming that variable a is of type integer, use the inference rules to determine the types of the following expressions. Note: if a proof does not exist, the type system reports a type error. 1. &a 2. *a 3. *&a 4. &&a Problem 2 – Code Generation for Expressions EaC, problem 2(b), page 751. Problem 3 – Code Generation Assume that the following “high-level” code:

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i = 0; sum = 0; while (i < 10) { a[i] = a[i] + 1; sum = sum + a[i]; i = i + 1; } print sum; Show the corresponding ILOC code, using a register-register model. You have to assume that array references may be aliased, but can assume that scalars are not aliased. Note: • virtual addresses are byte addresses; all data types are integer (4 bytes) • 1024, our “segment base address”, is stored in register r • array variable a has oﬀset address @a. • scalar variable i has oﬀset address @i, and scalar variable sum has oﬀset address @sum...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern