|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jfrace.cpu.Intel8080
Emulation of the 8-bit microprocessor Intel 8080.
The 256 port addresses are mapped as a block to the
AddressSpace
.
The first address (i.e. the address of port 0)
is defined by the method
setPortBiasAddress
.
In order to increase the performance of memory reading and
writing the 65536 bytes of memory will not be accessed via
the AddressSpace
but directly on the
byte
array. This memory is obtained from
the first RAM added
to the AddressSpace
.
Note: Currently interrupts are not supported. The method
next
returns always 1 and not the correct number
of clock cycles.
Field Summary | |
static int |
A
Index of register A (accumulator). |
protected static short |
ACI
|
protected static short |
ADC
|
protected static short |
ADD
|
protected static int |
ADD_MASK
Combined flag mask for ADD/SUB operations. |
protected static short |
ADI
|
protected static short |
ANA
|
protected static short |
ANI
|
protected AddressSpace |
as
|
static int |
AUX_CARRY_MASK
Mask for the auxiliary carry flag. |
static int |
AUX_CARRY_POS
Bit position of the auxiliary carry flag. |
static int |
B
Index of register B . |
static int |
C
Index of register C . |
protected static short |
CALL
|
static int |
CARRY_MASK
Mask for the carry flag. |
static int |
CARRY_POS
Bit position of the carry flag. |
protected static short |
Cc
|
protected static short |
CMA
|
protected static short |
CMC
|
protected static short |
CMP
|
protected static java.lang.String[] |
CONDITION_NAMES
|
protected static short |
CPI
|
static int |
D
Index of register D . |
protected static short |
DAA
|
protected static short |
DAD
|
protected static java.lang.String[] |
DATA_REGISTER_NAMES
|
protected static short |
DCR
|
protected static short |
DCX
|
protected static short |
DI
|
static int |
E
Index of register E . |
protected static short |
EI
|
protected java.lang.String |
errorDescription
|
static int |
F
Index of register F (flags). |
static int |
H
Index of register H . |
protected static short |
HLT
|
protected static short |
IN
|
protected static short |
INR
|
protected static int |
INR_MASK
Combined flag mask for INR/DCR operations. |
protected boolean |
interruptEnabled
|
protected static short |
INX
|
protected static short |
Jc
|
protected static short |
JMP
|
static int |
L
Index of register L . |
protected static short |
LDA
|
protected static short |
LDAX
|
protected static short |
LHLD
|
protected static short |
LXI
|
protected byte[] |
memory
|
protected static short |
MOV
|
protected static short |
MVI
|
protected static short |
NOP
|
protected static byte |
NULL_BYTE
|
protected static short[] |
OP_CODE_TYPE
Mapping op-code to instruction type. |
protected static short |
ORA
|
protected static short |
ORI
|
protected static short |
OUT
|
static int |
PARITY_MASK
Mask for the parity flag. |
static int |
PARITY_POS
Bit position of the parity flag. |
static int |
PC
Index of register PC (program counter). |
protected static short |
PCHL
|
protected static short |
POP
|
protected int |
portBiasAddress
|
protected int |
programCounter
|
protected static short |
PUSH
|
protected static short |
RAL
|
protected static short |
RAR
|
protected static short |
Rc
|
protected static java.lang.String[] |
REGISTER_PAIR_NAMES
|
protected static java.lang.String[] |
REGISTER_PAIR_NAMES2
|
protected byte[] |
registers
|
protected static short |
RET
|
protected static short |
RLC
|
protected static int |
ROT_MASK
Combined flag mask for ROT operations. |
protected static short |
RRC
|
protected static short |
RST
|
protected static short |
SBB
|
protected static short |
SBI
|
protected static short |
SHLD
|
static int |
SIGN_MASK
Mask for the sign flag. |
static int |
SIGN_POS
Bit position of the sign flag. |
static int |
SP
Index of register SP (stack pointer). |
protected static short |
SPHL
|
protected static short |
STA
|
protected int |
stackPointer
|
protected static short |
STAX
|
protected static short |
STC
|
protected static short |
SUB
|
protected static short |
SUI
|
protected static short |
UDEF
|
protected static short |
XCHG
|
protected static short |
XRA
|
protected static short |
XRI
|
protected static short |
XTHL
|
static int |
ZERO_MASK
Mask for the zero flag. |
static int |
ZERO_POS
Bit position of the zero flag. |
Constructor Summary | |
Intel8080()
Default constructor. |
Method Summary | |
protected void |
addToAccu(byte operand,
int carry,
int flagMask)
Add operand and carry bit to accumulator and set the flags. |
protected int |
calculateParityFlag(int accu)
Calculate the parity flag. |
protected boolean |
checkCondition(byte opCode)
Check condition coded in the bits 3-5 of the op-code. |
int |
disassemble(java.lang.StringBuffer sb,
int address)
Return disassemble instruction in standard Intel 8080 assembler syntax. |
protected int |
disassembleByte(java.lang.StringBuffer sb,
int address)
|
protected int |
disassembleUDEF(byte opCode,
java.lang.StringBuffer sb,
int address)
|
protected int |
disassembleWord(java.lang.StringBuffer sb,
int address)
|
AddressSpace |
getAddressSpace()
Get the address space. |
java.lang.String |
getErrorDescription()
Return error description. |
java.lang.String |
getName()
Return "Intel 8080". |
int |
getNumberOfBits()
Return 8. |
int |
getNumberOfRegisters()
Return 10. |
int |
getPortBiasAddress()
Return the bias address for ports. |
Register |
getProgramCounter()
Return the program counter. |
Register |
getRegister(int index)
Return a register. |
protected int |
getRegisterPair(byte opCode,
boolean isPopPushPair)
Get the value of a register pair. |
protected int |
getWord(int address)
Obtain a 16-bit word from the memory. |
void |
hardwareMoved(AddressSpaceEvent event)
When a RAM is added to the
AddressSpace of the CPU the
memory byte array is taken from it in order to
improve reading/writing performance to the memory. |
void |
interrupt(long interrupt)
Interrupts are not supported. |
int |
next()
Proceed one opcode. |
protected int |
popFromStack()
Pop a 16-bit word from the stack. |
protected boolean |
processHLT()
|
protected boolean |
processINRorDCR(byte opCode,
int increment)
Process INR and DCR commands. |
protected boolean |
processUDEF(byte opCode)
Process an undefined op-code. |
protected void |
pushOnStack(int word)
Push a 16-bit word onto the stack. |
protected byte |
readByte(int address)
Read the byte from a register or from memory. |
void |
reset()
Reset the CPU. |
protected void |
setAccuAndFlags(int accu,
int flags)
Set accumulator and flags after a bit wise. |
void |
setAddressSpace(AddressSpace addressSpace)
Set the address space. |
void |
setPortBiasAddress(int address)
Set the bias address for ports. |
protected void |
setRegisterPair(byte opCode,
int value,
boolean isPopPushPair)
Set the value of a register pair. |
void |
setRegisterValue(int index,
int value)
Set the value of a register. |
protected void |
storeByte(int address,
byte value)
Store a byte in a register or in memory. |
protected void |
subtractFromAccu(byte operand,
int carry,
int flagMask)
Subtract operand and carry from accumulator and set the flags. |
boolean |
supportsDisassembling()
Return true . |
java.lang.String |
toString()
Show register states like CP/M DDT. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int A
A
(accumulator).public static final int F
F
(flags).public static final int B
B
.public static final int C
C
.public static final int D
D
.public static final int E
E
.public static final int H
H
.public static final int L
L
.public static final int SP
SP
(stack pointer).public static final int PC
PC
(program counter).public static final int SIGN_POS
public static final int ZERO_POS
public static final int AUX_CARRY_POS
public static final int PARITY_POS
public static final int CARRY_POS
public static final int SIGN_MASK
public static final int ZERO_MASK
public static final int AUX_CARRY_MASK
public static final int PARITY_MASK
public static final int CARRY_MASK
protected static final int ADD_MASK
protected static final int INR_MASK
protected static final int ROT_MASK
protected static final java.lang.String[] DATA_REGISTER_NAMES
protected static final java.lang.String[] REGISTER_PAIR_NAMES
protected static final java.lang.String[] REGISTER_PAIR_NAMES2
protected static final java.lang.String[] CONDITION_NAMES
protected static final short UDEF
protected static final short ACI
protected static final short ADC
protected static final short ADD
protected static final short ADI
protected static final short ANA
protected static final short ANI
protected static final short CALL
protected static final short Cc
protected static final short CMA
protected static final short CMC
protected static final short CMP
protected static final short CPI
protected static final short DAA
protected static final short DAD
protected static final short DCR
protected static final short DCX
protected static final short DI
protected static final short EI
protected static final short HLT
protected static final short IN
protected static final short INR
protected static final short INX
protected static final short Jc
protected static final short JMP
protected static final short LDA
protected static final short LDAX
protected static final short LHLD
protected static final short LXI
protected static final short MOV
protected static final short MVI
protected static final short NOP
protected static final short ORA
protected static final short ORI
protected static final short OUT
protected static final short PCHL
protected static final short POP
protected static final short PUSH
protected static final short RAL
protected static final short RAR
protected static final short Rc
protected static final short RET
protected static final short RLC
protected static final short RRC
protected static final short RST
protected static final short SBB
protected static final short SBI
protected static final short SHLD
protected static final short SPHL
protected static final short STA
protected static final short STAX
protected static final short STC
protected static final short SUB
protected static final short SUI
protected static final short XCHG
protected static final short XRA
protected static final short XRI
protected static final short XTHL
protected static final short[] OP_CODE_TYPE
protected static final byte NULL_BYTE
protected java.lang.String errorDescription
protected byte[] registers
protected int stackPointer
protected int programCounter
protected boolean interruptEnabled
protected AddressSpace as
protected byte[] memory
protected int portBiasAddress
Constructor Detail |
public Intel8080()
Method Detail |
public int getPortBiasAddress()
public void setPortBiasAddress(int address)
address
- bias address.public java.lang.String toString()
toString
in class java.lang.Object
protected boolean processUDEF(byte opCode)
false
.
May be overwritten in subclasses.protected boolean processINRorDCR(byte opCode, int increment)
INR
and DCR
commands.protected boolean processHLT()
protected int disassembleUDEF(byte opCode, java.lang.StringBuffer sb, int address)
protected int disassembleByte(java.lang.StringBuffer sb, int address)
protected int disassembleWord(java.lang.StringBuffer sb, int address)
protected byte readByte(int address)
Register | Address code |
---|---|
B | 0 |
C | 1 |
D | 2 |
E | 3 |
H | 4 |
L | 5 |
Memory | 6 |
A | 7 |
HL
.address
- address code.protected void storeByte(int address, byte value)
Register | Address code |
---|---|
B | 0 |
C | 1 |
D | 2 |
E | 3 |
H | 4 |
L | 5 |
Memory | 6 |
A | 7 |
HL
.address
- address code.value
- value to be stored.protected int getRegisterPair(byte opCode, boolean isPopPushPair)
Op-code pattern | Register pair |
---|---|
xx00xxxx | BC |
xx01xxxx | DE |
xx10xxxx | HL |
xx11xxxx | AF if isPopPushPair == true SP if isPopPushPair == false |
opCode
- op-code.isPopPushPair
- true
if a register pair is
meant for a POP
or
PUSH
command.protected void setRegisterPair(byte opCode, int value, boolean isPopPushPair)
Op-code pattern | Register pair |
---|---|
xx00xxxx | BC |
xx01xxxx | DE |
xx10xxxx | HL |
xx11xxxx | AF if isPopPushPair == true SP if isPopPushPair == false |
opCode
- op-code.value
- value of the pair..isPopPushPair
- true
if a register pair is
meant for a POP
or
PUSH
command.protected int getWord(int address)
address
- memory address.protected void pushOnStack(int word)
stackPointer - 1
and the low byte in stackPointer - 2
.
The stack pointer will be decreased by two.word
- word to be push onto the stack.protected int popFromStack()
stackPointer
and the high byte in stackPointer + 1
.
The stack pointer will be increased by two.protected boolean checkCondition(byte opCode)
Op-code pattern | Condition |
---|---|
xx000xxx NZ |
zeroFlag == false |
xx001xxx Z |
zeroFlag == true |
xx010xxx NC |
carryFlag == false |
xx011xxx C |
carryFlag == true |
xx100xxx PO |
parityFlag == false |
xx101xxx PE |
parityFlag == true |
xx110xxx P |
signFlag == false |
xx111xxx M |
signFlag == true |
opCode
- op-code.true
if the condition is fulfilled.protected void addToAccu(byte operand, int carry, int flagMask)
protected void subtractFromAccu(byte operand, int carry, int flagMask)
protected void setAccuAndFlags(int accu, int flags)
accu
- result of the bit wise operation.flags
- initial flags set.protected int calculateParityFlag(int accu)
PARITY_MASK
if there is an even number of bits set in the lowest order
byte of accu
.PARITY_MASK
if an even number bits
of the accumulator have the value 1. Otherwise 0 is
returned.public void hardwareMoved(AddressSpaceEvent event)
RAM
is added to the
AddressSpace
of the CPU the
memory byte array is taken from it in order to
improve reading/writing performance to the memory.hardwareMoved
in interface AddressSpaceListener
jfrace.AddressSpaceListener
event
- Event holding the details.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)
RAM
. If one found it takes
the corresponding memory array.setAddressSpace
in interface CPU
public AddressSpace getAddressSpace()
CPU
getAddressSpace
in interface CPU
public void reset()
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()
next()
return false
.getErrorDescription
in interface CPU
public int next()
next
in interface CPU
public boolean supportsDisassembling()
true
.supportsDisassembling
in interface CPU
public int disassemble(java.lang.StringBuffer sb, int address)
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 |