Session 17 Lab Assignment
Introduction to the TM Simulator
Instructions
Next session, we will begin programming in TM and learning how to generate TM code. This assignment asks you to familiarize yourself with the TM simulator so that you are ready run the code we write and generate.
The assignment requires you to compile and run a C program.
If you do not have Linux or Unix running on your own computer,
+ you can do this work on
student.cs.uni.edu. If you need any help, please
let me know.
... and do not have suitable tools available on your Windows installation.
Representing Semantic Actions in a Program
Perform these steps in order.
- Download and unzip the TM virtual machine from the Target Language section of the compiler page.
- Read the README file in that directory, which describes the simulator files, two example TM files, and how to compile and run the simulator.
-
Compile
the basic TM simulator
and use it to run
factorial.tm,
as described in the README file. Here is what these two
steps look like (what you type is in bold):
$ gcc tm.c -o tm $ ./tm factorial.tm TM simulation (enter h for help)... Enter command: g Enter value for IN instruction: 10 OUT instruction prints: 3628800 HALT: 0,0,0 Halted Enter command: q Simulation done. $
-
Compile
the CLI version of the TM simulator
and use it to run
the CLI version of the factorial program.
Here is what these two steps look like (what you type is in
bold):
$ gcc tm-cli.c -o tm-cli $ ./tm-cli factorial-cli.tm 10 TM simulation (enter h for help)... Enter command: g OUT instruction prints: 3628800 HALT: 0,0,0 Halted Enter command: q Simulation done. $
- Browse the section The TM Simulator on the TM specification page, to familiarize yourself with the key ideas of the virtual machine.