# hw8 - i = 0; sum = 0; while (i < 10) { a[i] = a[i] + 1;...

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. 2. *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

## This note was uploaded on 10/29/2010 for the course CS 198:415 taught by Professor Kremer,u. during the Spring '10 term at Rutgers.

### Page1 / 2

hw8 - i = 0; sum = 0; while (i < 10) { a[i] = a[i] + 1;...

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

View Full Document
Ask a homework question - tutors are online