/export/home/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Hardware-Simulator-MIX/blib/lib/Hardware/Simulator/MIX.pm


SYNOPSIS


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


DESCRIPTION

This implementation includes the GO button and the default loader is the answer to Exercise 1.3 #26.

For detailed architecture information, search MIX in wikipedia.


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
    timeunit                5   (microseconds)


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

$mix->get_cmp_flag() returns an integer. If the returned value is negative, the flag is "L"; if the return value is positive, the flag is "G"; if the return value is 0, the flag is "E".

$mix->get_overflow() return 0 if there is no overflow. return 1 if overflow happen.

Flags may be updated after execute new instruction.

Status

$mix->get_current_time() returns the current mix running time in time units since the last reset.


METHODS

$mix->get_reg($reg_name)
$mix->is_halted()
$mix->reset()
$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->step()
$mix->set_reg($reg_name, $wref)
$mix->write_mem($loc, $wref, $l, $r)


AUTHOR

Chaoji Li

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


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

    perl mixasm.pl <yourprogram>

This command will generate a .crd file which is a card deck to feed into the mixsim.pl. Typical usage:

    perl mixsim.pl --cardreader=<yourprogram.crd>

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.