computer
Class Instruction

java.lang.Object
  extended by computer.Instruction
All Implemented Interfaces:
Code

public class Instruction
extends java.lang.Object
implements Code

Represents an instruction cell in the memory of the toy computer. An instruction has an opcode and an operand. T he operand might not be used by every instruction

Author:
jbergin

Field Summary
private  int opcode
           
private  int operand
           
 
Constructor Summary
Instruction(int operation, int onWhat)
          Create an insctuction cell that may be placed in the memory of a toy computer
 
Method Summary
 int opcode()
          Retrieve the opcode of this instruction
 int operand()
          Retrieve the operand of this instruction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

opcode

private int opcode

operand

private int operand
Constructor Detail

Instruction

public Instruction(int operation,
                   int onWhat)
Create an insctuction cell that may be placed in the memory of a toy computer

Parameters:
operation - the opcode
onWhat - the operand
Method Detail

opcode

public int opcode()
Retrieve the opcode of this instruction

Returns:
the instruction code itself in integer form

operand

public int operand()
Retrieve the operand of this instruction. It will likely be 0 if the opcode doesn't use any operand

Returns:
the operand, which is always an address in the memory of the toy computer.