NAME

Hardware::Simulator::MIX - Knuth's famous virtual machine

SYNOPSIS

use Hardware::Simulator::MIX;

my $mix = new Hardware::Simulator::MIX;
while (!$mix->is_halted()) {
    $mix->step();
}

DESCRIPTION

Number system. Memory word. Field specification. Architecture. char set.

CONSTRUCTOR

$mix = Hardware::Simulator::MIX->new(%options);

This method constructs a new Hardware::Simulator::MIX object and returns it. Key/value pair arguments may be provided to set up the initial state. The following options correspond to attribute methods described below:

KEY                     DEFAULT
-----------             --------------------
max_byte                64

MACHINE STATE

Registers

Accessing registers:

$mix->{reg_name}

It is a reference to a MIX word. Available registers are listed below:

REGNAME                FORMAT
-----------            -----------------------
rA                     [?, ?, ?, ?, ?, ?]
rX                     [?, ?, ?, ?, ?, ?]
rI1                    [?, 0, 0, 0, ?, ?]
rI1                    [?, 0, 0, 0, ?, ?]
rI2                    [?, 0, 0, 0, ?, ?]
rI3                    [?, 0, 0, 0, ?, ?]
rI4                    [?, 0, 0, 0, ?, ?]
rI5                    [?, 0, 0, 0, ?, ?]
rI6                    [?, 0, 0, 0, ?, ?]
rI6                    [?, 0, 0, 0, ?, ?]
rJ                     [?, 0, 0, 0, ?, ?]
pc                     Integer in 0..3999

Note: the names are case sensitive.

Memory
Flags
Status

METHODS

$mix->is_halted()
$mix->reset()
$mix->step()
$mix->read_mem($loc)
$mix->read_mem($loc, $l)
$mix->read_mem($loc, $l, $r)

Return a MIX word from memory. $loc must be among 0 to 3999. If field spec $l and $r are missing, they are 0 and 5; If $r is missing, it is same as $l.

$mix->write_mem($loc, $wref, $l, $r)
$mix->set_reg($reg_name, $wref)
$mix->get_reg($reg_name)

AUTHOR

Chaoji Li<lichaoji@ict.ac.cn>

Please feel free to send a email to me if you have any question.

BUGS

SEE ALSO

The package also includes a mixasm.pl which assembles MIXAL programs. Usage:

perl mixasm.pl <srcfile.mixal>

Again, there is a mixsim.pl which is a command line interface to control MIX machine. Usage:

perl mixsim.pl

Then type 'h' at the command line so you can see a list of commands. You can load a MIX program into the machine and see it run.

COPYRIGHT