Starting from:
$35

$29

Programming Project Solution

In this project, you will implement a simple compiler called COMP that generates A86 code for a sequence of expressions and assignment statements that involve +,* and power operations. Expressions will be infix expressions:




Operation
Meaning
a + b
Addition
a * b
Multiplication
pow(a,n)
Power, an






You can assume all values and results of operations will be 32 bit values. An example of COMP usage is given below:







COMP compiler




Suppose the file example.co contains:




x1 = 1abcd




y = 16




x = x1*y*pow(2,0)

y = (x+1)*3

x

y




%comp example.co




example.asm was generated.




%a86 example.asm

%example

1abcd0

503673







Please note the following:




 
You can assume all numbers are non-negative integers.




 
You can assume that an undefined variable has value 0.




 
All constants are written in hexadecimal format. The leading digit of a hexadecimal constant is always a numeric digit, (for example: hexadecimal number abcd is written as 0abcd).

 
All variables and expressions are 32 bit.




 
You can have paranthesized expressions. Pow operation can accept expressions.




Grading




Your project will be graded according to the following criteria:




Documentation (written document describing
12%
how you implemented your project)


Comments in your code
8%
Implementation and tests
80%



Late Submission






If the project is submitted
late, the following penalties will be applied:

0 < hours late <= 24 :


25%

24 < hours late <=
48 :
50%

48 < hours late <=
72
:
75%

hours late
72
:
100%

More products