See the assignment turn-in page (last modified on 4 March 2002) for instructions on turning in your assignment.
r0
through r7
; addresses in primary store are
referenced by the names of the associated variables (which are assumed to be
different from the register names).
A simple VLIW instruction is either a move instruction or an operator instructions. All simple instructions execute in one clock tick. A move instruction has the form
move
dst src
and moves the value stored in src to the location given by dst. Both src and dst can be either memory addresses or registers, with the restriction that both cannot be memory addresses; that is at least one must be a register.
An operator instruction has the form
where opr is one of the usual operators add
, sub
and so on
and both src and dst are registers. The effect of an operator
instruction is to compute
=
dst op src
Each operator has its own functional unit; that is, the add
operator uses
the addition functional unit, the division operator uses the division
functional unit and so on.
The translation from high-level language statements to simple VLIW instructions
is straightforward. For example, the high-level statement
can be translated into the sequence of simple VLIW instructions
move r0 b move r1 c add r1 r0 move a r1
A sequence of VLIW instructions can be optimized by packing several simple instructions into a single composite instruction. A composite instruction is formed from a set of simple instructions by listing the simple instructions on a line separated by semicolons; the order of the simple instructions in the line doesn't matter. For example, the two simple-instruction sequence
move r0 b move r1 c
can be packed into the single composite instruction
move r0 b ; move r1 c
A composite instruction also executes in one clock tick, but it executes all its component simple instructions in parallel because of the many functional units available in the CPU.
Your program should optimize code subject to the following constraints:
std::isspace()
, excluding the line-ending newline).
A block consists of one or more simple statements. Each simple statement appears in a single line, and a single line contains exactly one simple statement.
Operators can be any of the standard C++ binary operators except for the
short-circuit operators &&
and ||
; see Appendix A of Deitel and
Deitel for details.
If your program detects an error in an input block, it should produce an informative error message as the corresponding output block and go on to the next input block.
This page last modified on 16 October 2002.