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

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

View Full Document Right Arrow Icon
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:
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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 offset address @a. • scalar variable i has offset address @i, and scalar variable sum has offset address @sum...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern