Next: Debugging, Previous: Non-interactive mode, Up: Running the program
To enter the MIX virtual machine interactive mode, simply type
mixvm <RET>
at your shell command prompt. This command enters the
mixvm
command shell. You will be presented the following command
prompt:
MIX >
The virtual machine is initialised and ready to accept your
commands. The mixvm
command shell uses GNU's readline, so that
you have at your disposal command completion (using <TAB>) and
history functionality, as well as other line editing shortcuts common to
all utilities using this library (for a complete description of
readline's line editing usage, see Command Line Editing.)
Usually, the first thing you will want to do is loading a compiled MIX
program into memory. This is acomplished by the load
command,
which takes as an argument the name of the .mix file to be
loaded. Thus, typing
MIX > load hello <RET> Program loaded. Start address: 3000 MIX >
will load hello.mix into the virtual machine's memory
and set the program counter to the address of the first instruction. You
can obtain the contents of the program counter using the command
pc
:
MIX > pc Current address: 3000 MIX >
After loading it, you are ready to run the program, using, as you surely
have guessed, the run
command:
MIX > run Running ... MIXAL HELLO WORLD ... done Elapsed time: 11 /Total program time: 11 (Total uptime: 11) MIX >
Note that now the timing statistics are richer. You obtain the
elapsed execution time (i.e., the time spent executing instructions
since the last breakpoint), the total execution time for the program up
to now (which in our case coincides with the elapsed time, since there
were no breakpoints), and the total uptime for the virtual machine (you
can load and run more than one program in the same
session)1. After
running the program, the program counter will point to the address after
the one containing the HLT
instruction. In our case, asking the
value of the program counter after executing the program will give us
MIX > pc Current address: 3002 MIX >
You can check the contents of a memory cell giving its address
as an argument of the command pmem
, like this
MIX > pmem 3001 3001: + 00 00 00 02 05 (0000000133) MIX >
and convince yourself that address 3001 contains the binary
representation of the instruction HLT
. An address range of the
form FROM-TO can also be used as the argument of pmem
:
MIX > pmem 3000-3006 3000: + 46 58 00 19 37 (0786957541) 3001: + 00 00 00 02 05 (0000000133) 3002: + 14 09 27 01 13 (0237350989) 3003: + 00 08 05 13 13 (0002118477) 3004: + 16 00 26 16 19 (0268542995) 3005: + 13 04 00 00 00 (0219152384) 3006: + 00 00 00 00 00 (0000000000) MIX >
In a similar manner, you can look at the contents of the MIX registers and flags. For instance, to ask for the contents of the A register you can type
MIX > preg A rA: + 00 00 00 00 00 (0000000000) MIX >
Use the comand help
to obtain a list of all available commands,
and help COMMAND
for help on a specific command, e.g.
MIX > help run run Run loaded or given MIX code file. Usage: run [FILENAME] MIX >
For a complete list of commands available at the MIX propmt, See mixvm. In the following subsection, you will find a quick tour over commands useful for debugging your programs.
[1] Printing of timing statistics can be disabled using
the command timing
(see Configuration commands).