UMBC CMSC431, Compiler Design Principles, Fall 2009


Project 1

Due: Monday, September 21, 2009, 12:00pm (noon)


Objective

This project is a warm-up exercise that familiarizes the students with flex and bison. The project will also re-acquaint the students with C and assembly language programming.


Assignment

The Lex & Yacc book gives us lex and yacc programs that evaluate arithmetic expressions with the operations +, -, * and /. The resulting program is an interpreter rather than a compiler since it directly evaluates the expression rather than translating the expression to a lower-level program. Your assignment is to modify these lex and yacc programs into a compiler that produces an assembly language program. When this assembly language program is itself compiled and executed, it must produce the output given by the original program.

We will use a very simple strategy to generate assembly language code for arithmetic expressions. We just assume that the operands are placed on the stack. The result of each operation is also placed on the stack. For example, here's an assembly language program that computes the expression "3 + 4 * 5 / 3": p1example.asm.


Submitting Your Project

We will use CVS (Concurrent Version System) for project submission. Detailed instructions are here. Basically, you want to log into GL and type the command: cvs -d /afs/umbc.edu/users/c/h/chang/pub/cs431f09/Proj1 checkout -d MyProj1 user1 with user1 replaced by your own username. This creates a subdirectory "MyProj1" in your current directory and copies the files distributed for this project in that directory. (Feel free to use a different name for the subdirectory.) The command above checks out the files, when you submit, you check in the files with: cvs commit See the instructions for commands to add and update the files.


What to turn in

By the due date and time, the CVS repository for your project should have updated versions of the flex and bison programs. Please update the Makefile to reflect any changes you have made. (The expectation is that a person grading the project can compile your program just by typing "make".) Also, include 3 examples of compiled expressions of varying degrees of complexity. Please do not check in any object code files (e.g., *.o and a.out).


Last Modified: 22 Jul 2024 11:27:42 EDT by Richard Chang
to Fall 2009 CMSC 431 Homepage