10 Problem - Introduction to Compilers - Final Examination - Fall 2001 | CMSC 430, Exams of Computer Science

Material Type: Exam; Professor: Zelkowitz; Class: INTRO TO COMPILERS; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 02/13/2009

koofers-user-sgi-1
koofers-user-sgi-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CMSC430FINAL
December14,20018-10am
Donotturnthepageuntiltoldtodoso.
Answerallquestionsinexambook.
pf3

Partial preview of the text

Download 10 Problem - Introduction to Compilers - Final Examination - Fall 2001 | CMSC 430 and more Exams Computer Science in PDF only on Docsity!

CMSC 430 FINAL

December 14, 2001 8-10am

Do not turn the page until told to do so.

Answer all questions in exam book.

1 [10]. Show that the following grammar is LALR(1). Give the parsing table.

S  X1 | YZ X  0X | 2 Y  0Y | 2 Z  Z3 | 3

2 [10]. Consider the regular expression: 001 | 10

(a) Give the deterministic finite state automaton that recognizes the same set. (b) Give the regular grammar that accepts the same set.

For problems 3 to 7, assume the following machine architecture:

Instruction Meaning Exec time load reg,memory Load memory contents into register

store reg,memory Store register contents at memory

add reg1,reg2,reg3 reg3 = reg1+reg2 1 sub reg1,reg2,reg3 reg3 = reg1-reg2 1 jpos reg,address Jump to address if reg contents>

jneg reg,address Jump to address if reg contents < 0

jump address Jump to address 2 Nop Do nothing 1

  • An instruction can start each cycle if the operands are available.
  • Each instruction is 4 bytes long
  • The machine has 4 registers: R0 .. R3.

3 [10]. Consider the flowchart following this question. (Note, if you know how to do question 4, you’ll save time doing 4 first and then doing 3.)

(a) What does it mean that each oval represents variables that are live along that arc (i.e., what does liveness mean)?

(b) Fill in the values for ovals I1 through I5. The output liveness property for I6 is already given as the variable D.

4 [10]. Use the fixed point theorem for lattices to derive the liveness properties for question 3. Show all work. (Note, you’ll save some time if you do this question and simply write in your answers for question 3.)

5[10]. Use register coloring to assign registers for each variable or temporary in the program of question 3. Show all work, including the interference graph.

6 [10]. Consider the statements:

A = B+C; D = C+E; E = A+D; F = B+C; G = C+E;