CS210
Fall2007
Programming Project 2
Date: Tuesday, October 23, 2007.
Due: Wednesday, November 7, 2007.
Work in groups of 2-3 students to:
1. Build a complete Stack class, using a linked list implementation as
described in class. Include all safety functions to replace compiler generated
defaults (i.e. copy constructor, destructor and operator =). Assemble the files
into Stack.h and Stack.cpp.
2. Write a program that utilizes the above Stack class to generate
machine instructions in assembly code for evaluating postfix expressions using
one accumulator register and the following instructions:
LOAD x : Place the value of x in the
accumulator register.
STORE x: Store the contents of the accumulator register into the variable x.
ADD x: Add the value of x to the contents of the accumulator register.
SUB x: Subtract the value of x from the contents of the accumulator register.
MULT x: Multiply the contents of the accumulator register by the value of x.
DIV x: Divide the contents of the accumulator register by the value of x.
Were the postfix expression is an input to the program. For example, the
postfix expression a b c
+ * d
e * - should give the following
sequence of instructions:
LOAD b
ADD c
STORE temp1
LOAD a
MULT temp1
STORE temp2
LOAD d
MULT e
STORE temp3
LOAD temp2
SUB temp3
STORE temp4
where each tempi is a temporary variable.