Next: , Previous: Running the program, Up: Running the program


3.3.1 Non-interactive mode

To make mixvm work in non-interactive mode, use the -r flag. Thus, to run our hello.mix program, simply type

     mixvm -r hello <RET>

at your command prompt, and you will get the following output:

     MIXAL HELLO WORLD

Since our hello world program uses MIX's device number 19 as its output device (see Writing a source file), the output is redirected to the shell's standard output. Had you used any other MIX output devices (disks, drums, line printer, etc.), mixvm would have created a file named after the device used (e.g. disk4.dev) and written its output there1.

The virtual machine can also report the execution time of the program, according to the (virtual) time spent in each of the binary instructions (see Execution times). Printing of execution time statistics is activated with the -t flag; running

     mixvm -t -r hello <RET>

produces the following output:

     MIXAL HELLO WORLD
     ** Execution time: 11

Sometimes, you will prefer to store the results of your program in MIX registers rather than writing them to a device. In such cases, mixvm's -d flag is your friend: it makes mixvm to dump the contents of its registers and flags after executing the loaded program. For instance, typing the following command at your shell's prompt

     mixvm -d -r hello

you will obtain the following output:

     MIXAL HELLO WORLD
     rA: + 00 00 00 00 00 (0000000000)
     rX: + 00 00 00 00 00 (0000000000)
     rJ: + 00 00 (0000)
     rI1: + 00 00 (0000)     rI2: + 00 00 (0000)
     rI3: + 00 00 (0000)     rI4: + 00 00 (0000)
     rI5: + 00 00 (0000)     rI6: + 00 00 (0000)
     Overflow: F
     Cmp: E

which, in addition to the program's outputs and execution time, gives you the contents of the MIX registers and the values of the overflow toggle and comparison flag (admittedly, rather uninteresting in our sample).

As you can see, running programs non-interactively has many limitations. You cannot peek the virtual machine's memory contents, not to mention stepping through your program's instructions or setting breakpoints2. Enter interactive mode.


Footnotes

[1] The device files are stored, by default, in a directory called .mdk, which is created in your home directory the first time mixvm is run. You can change this default directory using the command devdir when running mixvm in interactive mode (see Configuration commands)

[2] The mixguile program allows you to execute arbitrary combinations of mixvm commands (using Scheme) non-interactively. See Scheme scripts.