use Hardware::Simulator::MIX;
my $mix = new Hardware::Simulator::MIX;
while (!$mix->is_halted()) {
$mix->step();
}
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.
$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)
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.
$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.
$mix->get_current_time() returns the current mix running time in time units since the last reset.
get_reg($reg_name)
is_halted()
reset()
read_mem($loc)
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.
step()
Chaoji Li
Please feel free to send a email to me if you have any question.
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.