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.
-
Machine()
-
-
Machine(InputStream, OutputStream)
-
-
Machine(int)
-
-
Machine(int, InputStream, OutputStream)
-
-
getIO()
-
-
getMem()
-
-
getProc()
-
-
load(Enumeration)
- Accepts a list of words together with the addresses in which
they should be loaded.
-
run(InsVisitor)
- Accepts an object that visits all the instructions from the current
one until it encounters a HALT instruction.
-
step(InsVisitor)
- Accepts an object that visits the current instruction.
Machine
public Machine()
Machine
public Machine(int memorySize)
Machine
public Machine(InputStream istream,
OutputStream ostream)
Machine
public Machine(int memorySize,
InputStream istream,
OutputStream ostream)
getMem
public MemoryI getMem()
getProc
public ProcessorI getProc()
getIO
public ioUnitI getIO()
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.
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.
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