|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uk.co.javagear.Z80
public final class Z80
Zilog Z80 CPU Emulation.
For generic Z80 use the following need to be implemented correctly:
Field Summary | |
---|---|
private Accumulator |
a
Accumulator. |
private Registers |
bc
Loop counter. |
private int[] |
daa
Pre-calculated result for DAA instruction. |
private Registers |
de
General purpose. |
private boolean |
EI_inst
Previous instruction was EI. |
private Flag |
f
Flag register. |
private boolean |
halt
Halt instruction. |
private Registers |
hl
General purpose. |
private int |
i
Interrupt page address register. |
private boolean |
iff1
Interrupt flip-flop 1. |
private boolean |
iff2
Interrupt flip-flop 2. |
private int |
im
Interrupt Mode (0,1,2). |
private InterruptLine |
irq
Pointer to Z80 interrupt line. |
private Registers |
ix
Index page address register. |
private Registers |
iy
Index page address register. |
private Memory |
mem
Pointer to system memory. |
private short[] |
opcbstates
|
private short[] |
opddstates
|
private short[] |
opedstates
|
private short[] |
opindexcbstates
|
private short[] |
opstates
|
private int |
pc
Program counter. |
private Ports |
port
Pointer to Z80 ports. |
private Refresh |
r
Memory refresh register. |
private int |
sp
Stack pointer. |
private int |
tstates
T states. |
Constructor Summary | |
---|---|
Z80(Memory m,
Ports p,
InterruptLine i)
Z80 Constructor. |
Method Summary | |
---|---|
private void |
bit(int value,
int b)
CB BIT - Test Bit. |
private void |
call(boolean condition)
Call. |
private void |
ccf()
CCF - Complement Carry Flag. |
private void |
consoledebug()
Output contents of Z80 registers to console for debugging purposes. |
private int |
d()
Get Offset Value from memory for index operations. |
private void |
daa()
DAA - Decimal Adjust Accumulator adds 6 to left and/or right nibble. |
boolean |
debug(int cycles)
Run Z80 for a single instruction (debugging purposes). |
private void |
dechl(int offset)
DEC (HL) - Decrement memory location. |
private void |
doCB(int opcode)
Execute CB prefixed opcode. |
void |
doED(int opcode)
Execute ED Prefixed Opcode. |
private void |
doIndexCB(Registers index)
Execute DDCB/FDCB Prefixed Opcode. |
private void |
doIndexOp(int opcode,
Registers index)
Execute DD/FD Prefixed Index Opcode. |
private void |
doOp(int opcode)
Execute opcode. |
void |
exall()
Exchange registers with shadow registers. |
private void |
generateDAATable()
Pre-calculate DAA Table. |
int |
getA()
Get value of accumulator. |
int |
getB()
Get value of B register. |
boolean |
getBit3()
Get state of bit 3 flag. |
boolean |
getBit5()
Get state of bit 5 flag. |
int |
getC()
Get value of C register. |
boolean |
getCarry()
Get state of the carry flag. |
int |
getD()
Get value of D register. |
int |
getE()
Get value of E register. |
int |
getF()
Get value of flag register. |
int |
getH()
Get value of H register. |
boolean |
getHc()
Get state of halfcarry flag. |
int |
getIX()
Get value of IX register. |
int |
getIY()
Get value of IY register. |
int |
getL()
Get value of L register. |
java.lang.String |
getMnu()
Return mnemonic of next opcode for debugging purposes. |
boolean |
getNegative()
Get State of Negative Flag. |
java.lang.String |
getOp()
Return next opcode for debugging purposes. |
boolean |
getParity()
Get state of parity flag. |
int |
getPC()
Get value of the program counter. |
int |
getR()
Get value of the Refresh register. |
boolean |
getSign()
Get state of sign flag. |
int |
getSP()
Get value of the stack pointer. |
boolean |
getZero()
Get state of zero flag. |
private void |
inchl(int offset)
INC (HL) - increment memory location. |
void |
interrupt()
Normal interrupt routine. |
private void |
jp(boolean condition)
Jump. |
private void |
jr(boolean condition)
Jump relative. |
void |
nmi()
Generate Non Maskable Interrupt (NMI). |
private int |
pop()
Pop value off stack. |
private void |
push(int value)
Push value onto stack. |
private int |
res(int value,
int b)
CB RES - Reset Bit. |
void |
reset()
Reset Z80. |
private void |
ret(boolean condition)
Return. |
private int |
rl(int value)
CB RL - Rotate Left. |
private int |
rlc(int value)
CB RLC - Rotate Left Carry. |
private int |
rr(int value)
CB RR - Rotate Right. |
private int |
rrc(int value)
CB RRC - Rotate Right Carry. |
void |
run(int cycles)
Run Z80. |
void |
setA(int reg)
Set accumulator. |
void |
setBC(int reg)
Set BC register pair. |
private int |
setBit(int value,
int b)
CB SET - Set Bit On. |
void |
setDE(int reg)
Set DE register pair. |
void |
setF(int reg)
Set flag register. |
void |
setHL(int reg)
Set HL register pair. |
void |
setI(int reg)
Set interrupt register. |
void |
setIFF2(boolean flag)
Set interrupt flip-flop 2. |
void |
setIM(int mode)
Set interrupt mode. |
void |
setIX(int reg)
Set IX register pair. |
void |
setIY(int reg)
Set IY register pair. |
void |
setR(int reg)
Set refresh register. |
void |
setSP(int value)
Set stack pointer. |
private int |
sla(int value)
CB SLA - Shift Left Arithmetic. |
private int |
sll(int value)
CB SLL - Logical Left Shift. |
private int |
sra(int value)
CB SRA - Shift Right Arithmetic. |
private int |
srl(int value)
CB SRL - Logical Shift Right. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int pc
private int sp
private int im
private boolean iff1
private boolean iff2
private boolean halt
private boolean EI_inst
private InterruptLine irq
private Memory mem
private Ports port
private Flag f
private Accumulator a
private Registers bc
private Registers de
private Registers hl
private Registers ix
private Registers iy
private Refresh r
private int i
private int[] daa
private int tstates
private final short[] opstates
private final short[] opcbstates
private final short[] opddstates
private final short[] opindexcbstates
private final short[] opedstates
Constructor Detail |
---|
public Z80(Memory m, Ports p, InterruptLine i)
m
- pointer to system memory.p
- pointer to Z80's ports.i
- pointer to Z80's interrupt line.Method Detail |
---|
public void reset()
public void setA(int reg)
reg
- value to set register withpublic void setF(int reg)
reg
- value to set register with.public void setI(int reg)
reg
- value to set register with.public void setR(int reg)
reg
- value to set register with.public void setBC(int reg)
reg
- value to set register with.public void setDE(int reg)
reg
- value to set register with.public void setHL(int reg)
reg
- value to set register with.public void setIX(int reg)
reg
- value to set register with.public void setIY(int reg)
reg
- value to set register with.public void setSP(int value)
value
- value to set stack pointer withpublic void setIM(int mode)
mode
- interrupt mode 0 - 2.public void setIFF2(boolean flag)
flag
- true
is On, false
is Off.public void exall()
public int getA()
public int getF()
public int getB()
public int getC()
public int getD()
public int getE()
public int getH()
public int getL()
public int getR()
public int getIX()
public int getIY()
public int getPC()
public int getSP()
public boolean getCarry()
true
if set.public boolean getNegative()
true
if set.public boolean getParity()
true
if set.public boolean getBit3()
true
if set.public boolean getHc()
true
if set.public boolean getBit5()
true
if set.public boolean getZero()
true
if set.public boolean getSign()
true
if set.public java.lang.String getOp()
String
containing opcode bytes.public java.lang.String getMnu()
String
containing opcode bytes.public boolean debug(int cycles)
cycles
- machine cycles to run for in total.
true
if cycles elapsed.private void consoledebug()
public void run(int cycles)
cycles
- machine cycles to run for in total.public void nmi()
public void interrupt()
private void doOp(int opcode)
opcode
- opcode hex valueprivate void jp(boolean condition)
condition
- if true
jump will be taken.private void jr(boolean condition)
condition
- if true
jump will be taken.private void call(boolean condition)
condition
- if true
call will be taken.private void ret(boolean condition)
condition
- if true
return will be taken.private void push(int value)
value
- value to pushprivate int pop()
private void inchl(int offset)
offset
- memory offset to increment.private void dechl(int offset)
offset
- memory offset to increment.private void ccf()
private void daa()
private void doCB(int opcode)
opcode
- opcode hex valueprivate int rlc(int value)
value
- value to adjust.
private int rrc(int value)
value
- value to adjust.
private int rl(int value)
value
- value to adjust.
private int rr(int value)
value
- value to adjust.
private int sla(int value)
value
- value to adjust.
private int sra(int value)
value
- value to adjust.
private int sll(int value)
value
- value to adjust.
private int srl(int value)
value
- value to adjust.
private int setBit(int value, int b)
value
- value to adjust.b
- bit to turn on.
private int res(int value, int b)
value
- value to adjust.b
- bit to turn off.
private void bit(int value, int b)
value
- value to test.b
- bit of value to test.private void doIndexOp(int opcode, Registers index)
opcode
- opcode hex value.index
- index register to use.private int d()
private void doIndexCB(Registers index)
index
- Index Register To Use.public void doED(int opcode)
opcode
- Opcode hex value.private void generateDAATable()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |