Simple Programming Assignment –
Write a Java program with a GUI that reads in an arithmetic statement consisting of integers, the operators “+” and “-,”, and parentheses and outputs a regular LMC assembly language program to a file that can then be assembled by the LMC assembler and run on the LMC. For example, if the input statement is
5 + (3 – 6) + 2
your program will produce the following LMC assembly language program (or something equivalent):
.LMC
LOAD NUM1
SUB NUM2
STO TEMP1
LOAD NUM3
ADD TEMP1
ADD NUM4
PRINT
STOP
.DC NUM1 003
.DC NUM2 006
.DC TEMP1 000
.DC NUM3 005
.DC NUM4 002
.END
Remember that the arithmetic operators are processed from the left side of the statement to the right side, and that expressions inside parentheses are always evaluated first. You may assume that all of the integer values are positive and that the input statement will always be syntactically correct (i.e., no unrecognized operators, no ill-formatted numbers, no mismatched parentheses, etc.) You must be able to specify a filename to which your LMC assembly language program will be stored, so that it can be assembled and executed in the LMC for testing.
* GUI should only include text areas for inputting the arithmetic expression, entering the filename desired, and outputting the LMC Assembly Code. One button is needed just for compilng. Thats it!