|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jfrace.cpu.FJE5
A simple 5-bit CPU. It has the following registers:
A |
5-bit accumulator |
I |
5-bit index register. It defines the higher order bits of a 10-bit address in instructions with a bias. |
SP |
10-bit stack pointer |
PC |
10-bit program counter |
Here is the list of operations:
Assembler-Operation | Machine-code | Meaning |
---|---|---|
NOP | 00000 |
No operation.PC <- PC + 1 |
XAI | 00001 |
Exchange accumulator with index register.A <-> I PC <- PC + 1 |
LDA value |
00010 value |
Load accumulator with valueA <- valuePC <- PC + 2 |
LDI value |
00011 value |
Load index register with valueI <- valuePC <- PC + 2 |
LDAI bias |
00100 bias |
Load accumulator indirectly from the location build by
the index register and the bias.
A <- (32*I+ bias) PC <- PC + 2 |
LDAD bias |
00101 bias |
Load accumulator double indirectly.
A <- (32*(32*I+ bias)+(32 *I+bias+1)) PC <- PC + 2 |
STAI bias |
00110 bias |
Store accumulator indirectly to a location build by
the index register and the bias.
(32*I+ bias) <- A PC <- PC + 2 |
STAD bias |
00111 bias |
Store accumulator double indirectly.
(32*(32*I+ bias)+(32 *I+bias+1)) <- A PC <- PC + 2 |
PUSH | 01000 |
Push accumulator and index register on stack(SP-1) <- A PC <- PC + 1 |
POP | 01001 |
Pop accumulator and index register from stackI <- (SP) PC <- PC + 1 |
CALL address |
01010 address-high address-low |
Call a subroutine. Push the program counter on stack.(SP-1) <- (PC + 3) low(SP-2) <- (PC + 3) highSP <- SP - 2 address-high + address-low |
RET | 01011 |
Return from subroutine. Pop the program counter from the stackPC <- 32 * (SP) + (SP+1) |
LDS value |
01100 value-high value-low |
Load stack pointerSP <- 32 * value-high + value-lowPC <- PC + 3 |
JP address |
01101 address-high address-low |
Jump to addressPC <- 32 * address-high + address-low |
JPZ address |
01110 address-high address-low |
Jump to address if accumulator equals zero if A == 0: PC <- 32 * address-high + address-lowif A != 0: PC <- PC + 3 |
JPNZ address |
01111 address-high address-low |
Jump to address if accumulator not equals zero if A != 0: PC <- 32 * address-high + address-lowif A == 0: PC <- PC + 3 |
ADD bias |
10000 bias |
Add to accumulator a value from the location build by
the index register and the bias.
A <- A + (32*I+ bias) PC <- PC + 2 |
SUB bias |
10010 bias |
Subtract from accumulator a value from the location build by
the index register and the bias.
A <- A - (32*I+ bias) PC <- PC + 2 |
AND bias |
10100 bias |
Logically AND to accumulator a value from the location build by
the index register and the bias.
A <- A AND (32*I+ bias) PC <- PC + 2 |
OR bias |
10110 bias |
Logically OR to accumulator a value from the location build by
the index register and the bias.
A <- A OR (32*I+ bias) PC <- PC + 2 |
XOR bias |
11000 bias |
Logicall XOR to accumulator a value from the location build by
the index register and the bias.
A <- A XOR (32*I+ bias) PC <- PC + 2 |
SARA | 11010 |
Shift arithmetically right accumulator. The uppermost bit
will be shifted from the left into the accumulator.
Corresponds to a division by two of a signed number.A <- A >> 1 |
SLRA | 11100 |
Shift logically right accumulator. A zero bit
will be shifted from the left into the accumulator. Corresponds to a division by two of an unsigned number. A <- A >>> 1 |
SLA | 11110 |
Shift left accumulator. A zero bit
will be shifted from the right into the accumulator.
Corresponds to a multiplication with 2.A <- A << 1 |
HALT | 11111 |
Stops exceution. Program counter will not be incremented. |
Field Summary | |
static int |
A
Index of register A (accumulator). |
static int |
I
Index of register I (index register). |
static int |
PC
Index of register PC (pogram counter). |
static int |
READ_DATA
Activity mask: Data read |
static int |
READ_PRG
Activity mask: Program read |
static int |
SP
Index of register SP (stack pointer). |
static int |
WRITE_DATA
Activity mask: Data write |
Constructor Summary | |
FJE5()
|
Method Summary | |
int |
disassemble(java.lang.StringBuffer sb,
int address)
Disassemble the next op-code at the given address and append it to the given string buffer. |
int |
getActivityAddress(int index)
Return the activity address for a given index. |
AddressSpace |
getAddressSpace()
Get the address space. |
java.lang.String |
getErrorDescription()
Return error description. |
java.lang.String |
getName()
Return "FJE5". |
int |
getNumberOfBits()
Return 5. |
int |
getNumberOfRegisters()
Return 4. |
Register |
getProgramCounter()
Return the program counter. |
Register |
getRegister(int index)
Return a register. |
void |
interrupt(long interrupt)
Not implemented. |
int |
next()
Proceed one opcode further. |
void |
reset()
Reset the hardware. |
void |
setAddressSpace(AddressSpace addressSpace)
Set the address space. |
void |
setRegisterValue(int index,
int value)
Set the value of a register. |
boolean |
supportsDisassembling()
Disassembling is supported. |
java.lang.String |
toString()
Return the state of the CPU as a well-formed string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int READ_PRG
public static final int READ_DATA
public static final int WRITE_DATA
public static final int A
A
(accumulator).public static final int I
I
(index register).public static final int SP
SP
(stack pointer).public static final int PC
PC
(pogram counter).Constructor Detail |
public FJE5()
Method Detail |
public int getActivityAddress(int index)
READ_PRG
,
READ_DATA
, or WRITE_DATA
).
There are up to five activity address stored during the
execution of the next()
method.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getName()
getName
in interface CPU
public int getNumberOfBits()
getNumberOfBits
in interface Hardware
public int getNumberOfRegisters()
getNumberOfRegisters
in interface CPU
public Register getRegister(int index)
CPU
getRegister
in interface CPU
jfrace.CPU
index
- Index of the register.null
if no register exists for the
given index.public Register getProgramCounter()
CPU
getProgramCounter
in interface CPU
public void setRegisterValue(int index, int value)
CPU
setRegisterValue
in interface CPU
jfrace.CPU
index
- Index of the register.value
- New value.public void setAddressSpace(AddressSpace addressSpace)
CPU
setAddressSpace
in interface CPU
public AddressSpace getAddressSpace()
CPU
getAddressSpace
in interface CPU
public void reset()
Hardware
reset
in interface Hardware
public void interrupt(long interrupt)
interrupt
in interface CPU
jfrace.CPU
interrupt
- Bit pattern of the interrupt. The meaning of
the bits depend on the implementation.public java.lang.String getErrorDescription()
CPU
CPU.next()
returns -1
.getErrorDescription
in interface CPU
public int next()
CPU
next
in interface CPU
jfrace.CPU
-1
if an error occured.public boolean supportsDisassembling()
supportsDisassembling
in interface CPU
public int disassemble(java.lang.StringBuffer sb, int address)
CPU
disassemble
in interface CPU
jfrace.CPU
sb
- String buffer.address
- Address of op-code.address
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |