|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cornell.cs.sam.core.SamProcessor
public class SamProcessor
Implementation of a SaM Processor
Field Summary | |
---|---|
static int |
REGISTERS
|
Fields inherited from interface edu.cornell.cs.sam.core.Processor |
---|
FBR, HALT, PC, SP |
Constructor Summary | |
---|---|
SamProcessor(Sys sys)
|
Method Summary | |
---|---|
int |
dec(int reg)
Decrements the register and returns the new value. |
int |
get(int reg)
Returns the register value requested |
Program |
getProgram()
Returns the program that is currently in memory to be executed |
int[] |
getRegisters()
Returns a new copy of the register array. |
Sys |
getSystem()
Returns the system object of this processor |
int |
inc(int reg)
Increments the register and returns the new value. |
void |
init()
Initializes all registers to their initial state |
void |
load(Program prog)
Loads the program that the processor must execute |
void |
run()
Execute the whole program. |
void |
set(int reg,
int value)
Set value of the register |
void |
step()
Executes one instruction. |
void |
verify(int reg,
int value)
Verifies if the value is valid for this registers and throws an exception if not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int REGISTERS
Constructor Detail |
---|
public SamProcessor(Sys sys)
Method Detail |
---|
public Sys getSystem()
Processor
getSystem
in interface Processor
public void load(Program prog) throws SystemException
Processor
load
in interface Processor
prog
- The program to execute
SystemException
- if the program was not loaded successfullypublic Program getProgram()
Processor
getProgram
in interface Processor
public void step() throws SystemException
Processor
step
in interface Processor
SystemException
- if there is an error during executionpublic void run() throws SystemException
Processor
run
in interface Processor
SystemException
- if there is an error during executionpublic void init()
Processor
init
in interface Processor
public int get(int reg)
Processor
get
in interface Processor
reg
- The register to query
public int[] getRegisters()
Processor
getRegisters
in interface Processor
public void set(int reg, int value) throws SystemException
Processor
set
in interface Processor
reg
- The register to setvalue
- The value to which to set the register
SystemException
- if the register value is invalidpublic int inc(int reg) throws SystemException
Processor
inc
in interface Processor
reg
- The register to increment
SystemException
- if the resulting register value is invalidpublic int dec(int reg) throws SystemException
Processor
dec
in interface Processor
reg
- The register to decrement
SystemException
- if the resulting register value is invalidpublic void verify(int reg, int value) throws SystemException
Processor
verify
in interface Processor
reg
- The register to verifyvalue
- The value to verify
SystemException
- if the value is invalid for this register
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |