============= ULM Simulator [TOC] ============= The ULM simulator is written in C++. The following steps are required for using it: - Use the `wget` command to download the C++ source code `wget http://www.mathematik.uni-ulm.de/~lehn/ulm.cc` - Compile it with the GNU C++ compiler: `g++ -Wall -std=c++11 -o ulm ulm.cc` - Test the ULM simulator: - File `example.ulm` contains a program in machine code for the ULM. You can get it with: `wget http://www.mathematik.uni-ulm.de/~lehn/example.ulm` - With the following command you can start the ULM with the code from `example.ulm` loaded into memory: `ulm example.ulm` Demo for downloading and compiling the ULM simulator ==================================================== ---- SHELL(path=session01,hide) ------------------ rm -rf demo1 mkdir demo1 -------------------------------------------------- ---- SHELL(path=session01/demo1) ----------------- wget http://www.mathematik.uni-ulm.de/~lehn/ulm.cc g++ -Wall -std=c++11 -o ulm ulm.cc ls -------------------------------------------------- File format for a program in machine code ========================================= - The code must be represented as a sequence of hex digits - Spaces and newlines in the file are ignored - The character `#` is ignored as well as all following characters until the next newline. This is used for having human readable comments embedded in the machine code. Here the content of the example program: :import: session01/demo/example.ulm Demo for testing the simulator ============================== First download the demo (in case you haven't done already): ---- SHELL(path=session01/demo2) ---------------------- wget http://www.mathematik.uni-ulm.de/~lehn/example.ulm ------------------------------------------------------- Then simple run the simulator `ulm` as follows: `ulm example.ulm` *By default the simulator runs in interactive mode.* So it only executes an instruction if you hit the enter-key. *With the option `-r` (run) you can run the code in non-interactive mode.* For example: ---- SHELL(path=session01/demo2) ----------------- ulm -r example.ulm -------------------------------------------------- Exercise ======== Download the following code with `wget http://www.mathematik.uni-ulm.de/~lehn/exercise1.ulm`: :import: session01/demo/exercise1.ulm Add brief comments to each line that describes what the machine instruction is supposed to do. Exercise ======== You should have simulated by hand what happens when you run `exercise1.ulm` on the ULM. Validate your result with the simulator. Exercise ======== What does the program compute? Describe its algorithm with a graph. :navigate: up -> doc:index next -> doc:session01/page02