|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.hu.cs.titokone.Processor
This class represents the processor. It can be told to run for one command cycle at a time.
Field Summary | |
private static java.lang.String |
ADDRESS_OUT_OF_BOUNDS_MESSAGE
|
private static java.lang.String |
BAD_ACCESS_MODE_MESSAGE
|
private static java.lang.String |
BRANCH_BAD_ACCESS_MODE_MESSAGE
|
static int |
CRT
CRT-device |
private static java.lang.String |
DIVISION_BY_ZERO_MESSAGE
|
private static java.lang.String |
INTEGER_OVERFLOW_MESSAGE
|
private static java.lang.String |
INVALID_DEVICE_MESSAGE
|
private static java.lang.String |
INVALID_OPCODE_MESSAGE
|
static int |
KBD
KBD-device |
private java.lang.Integer |
kbdData
The stdinData and kbdData fields stores buffer data to be read with the IN operation. |
private static java.lang.String |
NO_KDB_DATA_MESSAGE
|
private static java.lang.String |
NO_STDIN_DATA_MESSAGE
|
static int |
OS_CODE_AREA
When SVC call is made PC points to this place. |
private RandomAccessMemory |
ram
This field represents the memory of computer. |
private Registers |
regs
This field represents the registers of computer. |
private RunDebugger |
runDebugger
Rundebugger |
private boolean[] |
sr
state register array. |
private int |
status
Is program running. |
static int |
STDIN
STDIN-device |
private java.lang.Integer |
stdinData
The stdinData and kbdData fields stores buffer data to be read with the IN operation. |
static int |
STDOUT
STDOUT-device |
private static java.lang.String |
STORE_BAD_ACCESS_MODE_MESSAGE
|
Fields inherited from interface fi.hu.cs.ttk91.TTK91Cpu |
CU_IR, CU_PC, CU_PC_CURRENT, CU_SR, CU_TR, REG_FP, REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7, REG_SP, STATUS_ABNORMAL_EXIT, STATUS_STILL_RUNNING, STATUS_SVC_SD |
Constructor Summary | |
Processor(int memsize)
Creates new processor, memory and registers. |
Method Summary | |
private void |
alu(int opcode,
int Rj,
int param)
ALU-operations. |
private void |
branch(int opcode,
int Rj,
int M,
int ADDR,
int param)
Branching. |
private void |
comp(int Rj,
int param)
Compare-method manipulates status register. |
void |
eraseMemory()
Method erases memorylines from memory. |
TTK91Memory |
getMemory()
Returns the memory attached to the processor. |
MemoryLine |
getMemoryLine(int row)
Returns queried memory line. |
int |
getStatus()
Method returns the current value of Processor. |
int |
getValueOf(int registerID)
Returns the value of given registerID. |
private boolean |
isOverflow(long value)
Tests if given long value is acceptable int value. |
void |
keyboardInput(int kbdInput)
This method adds a line of keyboard data to a buffer the Processor can read it from during its next command cycle (or previous cycle repeated). |
void |
memoryInput(int rowNumber,
MemoryLine inputLine)
Method for loading MemoryLines to Processor, Loader classes uses this for loading application to processor. |
private void |
nop()
|
void |
runInit(int initSP,
int initFP)
Initializes processor with new program set FP and SP, PC = 0 and return RunInfo |
RunInfo |
runLine()
Process next instruction. |
private void |
setNewPC(int newPC)
|
private void |
stack(int opcode,
int Rj,
int Ri,
int param)
Stack. |
void |
stdinInput(int stdinInput)
This method adds a line of stdin data to a buffer the Processor can read it from during its next command cycle (or previous cycle repeated). |
private void |
subr(int opcode,
int Rj,
int ADDR,
int param)
Subroutine. |
private void |
svc(int Rj,
int param)
Supervisor call. |
private void |
transfer(int opcode,
int Rj,
int M,
int ADDR,
int param)
Transfer-operations. |
private void |
writeToMemory(int row,
int value)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int OS_CODE_AREA
private static final java.lang.String INVALID_OPCODE_MESSAGE
private static final java.lang.String ADDRESS_OUT_OF_BOUNDS_MESSAGE
private static final java.lang.String BAD_ACCESS_MODE_MESSAGE
private static final java.lang.String BRANCH_BAD_ACCESS_MODE_MESSAGE
private static final java.lang.String STORE_BAD_ACCESS_MODE_MESSAGE
private static final java.lang.String NO_KDB_DATA_MESSAGE
private static final java.lang.String NO_STDIN_DATA_MESSAGE
private static final java.lang.String INVALID_DEVICE_MESSAGE
private static final java.lang.String INTEGER_OVERFLOW_MESSAGE
private static final java.lang.String DIVISION_BY_ZERO_MESSAGE
public static final int CRT
public static final int KBD
public static final int STDIN
public static final int STDOUT
private RandomAccessMemory ram
private Registers regs
private int status
private RunDebugger runDebugger
private boolean[] sr
private java.lang.Integer stdinData
private java.lang.Integer kbdData
Constructor Detail |
public Processor(int memsize)
memsize
- creates new computer with given size of memory.
Proper values are power of two (from 512 to 64k).Method Detail |
public TTK91Memory getMemory()
public int getValueOf(int registerID)
getValueOf
in interface TTK91Cpu
registerID
- Identifying number of the register.
public MemoryLine getMemoryLine(int row)
row
- Number of the row in processor's memory.
public int getStatus()
getStatus
in interface TTK91Cpu
public void eraseMemory()
public void memoryInput(int rowNumber, MemoryLine inputLine) throws TTK91AddressOutOfBounds
java.lang.IllegalArgumentException
- If inputLine is null.
TTK91AddressOutOfBounds
- If the rownumber is either below 0 or
beyond the memory size.public void keyboardInput(int kbdInput)
kbdInput
- An int to be "read from the keyboard".public void stdinInput(int stdinInput)
stdinInput
- An int to be "read from STDIN (file)".public void runInit(int initSP, int initFP)
public RunInfo runLine() throws TTK91RuntimeException
TTK91RuntimeException
private void transfer(int opcode, int Rj, int M, int ADDR, int param) throws TTK91BadAccessMode, TTK91AddressOutOfBounds, TTK91NoKbdData, TTK91NoStdInData, TTK91InvalidDevice
TTK91BadAccessMode
TTK91AddressOutOfBounds
TTK91NoKbdData
TTK91NoStdInData
TTK91InvalidDevice
private void alu(int opcode, int Rj, int param) throws TTK91IntegerOverflow, TTK91DivisionByZero
TTK91IntegerOverflow
TTK91DivisionByZero
private void comp(int Rj, int param)
Rj
- First value to compare (register index).param
- Second value.private void branch(int opcode, int Rj, int M, int ADDR, int param) throws TTK91BadAccessMode
TTK91BadAccessMode
private void stack(int opcode, int Rj, int Ri, int param) throws TTK91AddressOutOfBounds
TTK91AddressOutOfBounds
private void subr(int opcode, int Rj, int ADDR, int param) throws TTK91AddressOutOfBounds
TTK91AddressOutOfBounds
private void svc(int Rj, int param) throws TTK91AddressOutOfBounds, TTK91NoKbdData
TTK91AddressOutOfBounds
TTK91NoKbdData
private void nop()
private void writeToMemory(int row, int value) throws TTK91AddressOutOfBounds
TTK91AddressOutOfBounds
private void setNewPC(int newPC)
private boolean isOverflow(long value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |