edu.cornell.cs.sam.core.instructions
Class SamInstruction

java.lang.Object
  extended by edu.cornell.cs.sam.core.instructions.SamInstruction
All Implemented Interfaces:
Instruction, java.io.Serializable
Direct Known Subclasses:
SAM_ADD, SAM_ADDF, SAM_AND, SAM_BITAND, SAM_BITNAND, SAM_BITNOR, SAM_BITNOT, SAM_BITOR, SAM_BITXOR, SAM_CMP, SAM_CMPF, SAM_DIV, SAM_DIVF, SAM_DUP, SAM_EQUAL, SAM_FREE, SAM_FTOI, SAM_FTOIR, SAM_GREATER, SAM_ISNEG, SAM_ISNIL, SAM_ISPOS, SAM_ITOF, SAM_JSRIND, SAM_JUMPIND, SAM_LESS, SAM_LINK, SAM_LSHIFTIND, SAM_MALLOC, SAM_MOD, SAM_NAND, SAM_NOR, SAM_OR, SAM_POPFBR, SAM_POPSP, SAM_PUSHFBR, SAM_PUSHIND, SAM_PUSHSP, SAM_READ, SAM_READCH, SAM_READF, SAM_READSTR, SAM_RSHIFTIND, SAM_RST, SAM_SKIP, SAM_STOP, SAM_STOREIND, SAM_SUB, SAM_SUBF, SAM_SWAP, SAM_TIMES, SAM_TIMESF, SAM_UNLINK, SAM_WRITE, SAM_WRITECH, SAM_WRITEF, SAM_WRITESTR, SAM_XOR, SamCharInstruction, SamFloatInstruction, SamIntInstruction, SamStringInstruction

public abstract class SamInstruction
extends java.lang.Object
implements Instruction, java.io.Serializable

Base class for all SamInstructions Defines common features such as shortcut variables and methods, toString(), name, cpu/mem access, and an abstract exec().

See Also:
Serialized Form

Field Summary
protected  Processor cpu
           
protected static int FBR
           
protected static int HALT
           
protected  Memory mem
           
protected  java.lang.String name
           
protected static int PC
           
protected  Program prog
           
protected static int SP
           
protected  Sys sys
           
protected  Video video
           
 
Constructor Summary
SamInstruction()
           
 
Method Summary
abstract  void exec()
          Executes the instruction
 java.lang.String getName()
          Gets the name of this instruction
 Program getProgram()
          Gets the program that this instruction is part of
 Sys getSystem()
          Gets the System object of this instruction
 void setProgram(Program p)
          Sets the program that this instruction is part of
 void setSystem(Sys sys)
          Sets the System object for this instruction
 java.lang.String toString()
          Prints out the text that represents this SaM instruction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name

prog

protected transient Program prog

cpu

protected transient Processor cpu

mem

protected transient Memory mem

video

protected transient Video video

sys

protected transient Sys sys

PC

protected static final int PC
See Also:
Constant Field Values

SP

protected static final int SP
See Also:
Constant Field Values

HALT

protected static final int HALT
See Also:
Constant Field Values

FBR

protected static final int FBR
See Also:
Constant Field Values
Constructor Detail

SamInstruction

public SamInstruction()
Method Detail

toString

public java.lang.String toString()
Description copied from interface: Instruction
Prints out the text that represents this SaM instruction

Specified by:
toString in interface Instruction
Overrides:
toString in class java.lang.Object
Returns:
The string representation of this instruction

getName

public java.lang.String getName()
Description copied from interface: Instruction
Gets the name of this instruction

Specified by:
getName in interface Instruction
Returns:
The SaM name of this instruction

setSystem

public void setSystem(Sys sys)
Description copied from interface: Instruction
Sets the System object for this instruction

Specified by:
setSystem in interface Instruction
Parameters:
sys - The system object for this instruction

getSystem

public Sys getSystem()
Description copied from interface: Instruction
Gets the System object of this instruction

Specified by:
getSystem in interface Instruction
Returns:
The system object for this instruction

setProgram

public void setProgram(Program p)
Description copied from interface: Instruction
Sets the program that this instruction is part of

Specified by:
setProgram in interface Instruction
Parameters:
p - The program containing this instruction

getProgram

public Program getProgram()
Description copied from interface: Instruction
Gets the program that this instruction is part of

Specified by:
getProgram in interface Instruction
Returns:
The program containing this instruction

exec

public abstract void exec()
                   throws SystemException
Description copied from interface: Instruction
Executes the instruction

Specified by:
exec in interface Instruction
Throws:
SystemException - if there is a runtime error