

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Zelkowitz; Class: INTRO TO COMPILERS; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


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
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;