You will also have opportunity to demonstrate that your symbol table printing method works.
Type in and run the following program and store it in a file named "test".
PUSH #4 WRTS HLT
An executable version of the microMachine, called "labexecute," can be found at
/students/sross/public/labexecute
Copy labexecute to the directory where you have saved file "test". Run the virtual machine on this program by typing
labexecute test
at the command prompt.
You will repeat this process as you do the hand translations of the programs below in completing this laboratory exercise.
You can also find a version of the microMachine that you can use as you want as you finish the project on our resources page by following the mircoMachine link. This version includes the source code (so that you can compile and install it on any machine you desire) and directions for doing this. In the near future we hope to have a visual version of the micromachine for your use.
program Program1; var A : integer;begin A := 1; Write(A) end.
program Program2;var Apples : integer; Fred ; integer; X : integer;begin Apples := 0; X := 10; Fred := Apples + Apples * X; Write(Apples, X, Fred) end.
program Program3;var A : integer; B : integer; C : integer;begin Read(A, B, C); A := 3*A*A*A + 5*B*B - C; Write(A, B, C); end.
Run each of the above programs through your current compiler. Insert a call to print the symbol table in your parser at the point where the keyword begin is matched. Print the symbol tables printed by your compiler. If your compiler is capable of constructing symbol tables for procedures and functions as well, you can include a sample program and symbol table printout for a program of your choosing that includes procedures and functions to demonstrate how cool your compiler is.