All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class duckMachine.architecture.Machine

java.lang.Object
   |
   +----duckMachine.architecture.Machine

public class Machine
extends Object
implements MachineI
A simple hardware machine with a memory, a processor, and an IO unit. The machine can perform three operations: load a program to memory, run a program, and step through a program. The last two operations are parametrized by an instruction visitor.


Constructor Index

 o Machine()
 o Machine(InputStream, OutputStream)
 o Machine(int)
 o Machine(int, InputStream, OutputStream)

Method Index

 o getIO()
 o getMem()
 o getProc()
 o load(Enumeration)
Accepts a list of words together with the addresses in which they should be loaded.
 o run(InsVisitor)
Accepts an object that visits all the instructions from the current one until it encounters a HALT instruction.
 o step(InsVisitor)
Accepts an object that visits the current instruction.

Constructors

 o Machine
 public Machine()
 o Machine
 public Machine(int memorySize)
 o Machine
 public Machine(InputStream istream,
                OutputStream ostream)
 o Machine
 public Machine(int memorySize,
                InputStream istream,
                OutputStream ostream)

Methods

 o getMem
 public MemoryI getMem()
 o getProc
 public ProcessorI getProc()
 o getIO
 public ioUnitI getIO()
 o step
 public void step(InsVisitor iv) throws MachineE
Accepts an object that visits the current instruction.

Throws: MachineE
If an error occurs during the execution of the instruction.
 o run
 public void run(InsVisitor v) throws MachineE
Accepts an object that visits all the instructions from the current one until it encounters a HALT instruction.

Throws: MachineE
If an error occurs during the execution of one of the instructions.
 o load
 public void load(Enumeration loadableWords) throws MemoryE
Accepts a list of words together with the addresses in which they should be loaded. Writes the words into the appropriate memory addresses, and writes the address of the first instruction in the PC.

Throws: MemoryE
If attempt to store a word in an out-of-range address.

All Packages  Class Hierarchy  This Package  Previous  Next  Index