jmce - 1_02

jmce.zilog.z80
Class Z80

java.lang.Object
  extended by jmce.sim.AbstractHardware
      extended by jmce.sim.cpu.AbstractCPU
          extended by jmce.intel.i8080.I8080
              extended by jmce.zilog.z80.Z80
All Implemented Interfaces:
java.lang.Runnable, I8080Constants, BreakPointListener, CPU, Hardware, InterruptManager
Direct Known Subclasses:
Altair, P2000T, Spectrum, Yaze, Z80Pack

public class Z80
extends I8080

Standard Zilog Z80 cpu implementation.

Implements all documented and not documented instruction set. Implemented registers other then i8080:

Tested using Z80 'Z80 instruction set exerciser' from Frank D. Cringle.

The mnemonic for JP xx where xx is one index register are changed from the original Z80 for example the JP (HL) is JP HL because is more correct the jump is made to the address set in the register and not in the memory location where the register is set.

Version:
1.01
Author:
Mario Viara

Field Summary
 int I
           
 int IX
           
 int IY
           
 int R
           
 
Fields inherited from class jmce.intel.i8080.I8080
A, BC, booleanTable, DE, F, HL, iff1, iff2, parityTable, PC, SP
 
Fields inherited from class jmce.sim.cpu.AbstractCPU
interrupts, io, memory, NS100MS, NS1MS
 
Fields inherited from interface jmce.intel.i8080.I8080Constants
FLAG_3, FLAG_5, FLAG_C, FLAG_H, FLAG_N, FLAG_PV, FLAG_S, FLAG_Z
 
Fields inherited from interface jmce.sim.CPU
BIG_ENDIAN, IO_MEMORY, LITTLE_ENDIAN, MAIN_MEMORY
 
Constructor Summary
Z80()
          Default constructor.
Z80(java.lang.String name)
          Constructor with the cpu name specified.
 
Method Summary
 int bit(int value, int bit)
          Check the status of one bit.
 void cpd()
          CPD Compare A with (HL) and decrement HL and BC
 void cpi()
          CPI compare a with (HL) and increment HL and decrement BC
 void cpSpecial(int v)
          Special version of compare used by CPD and CPI is like the normal compare but the C and V flag are untouched.
 void ex_af_af1()
          Change the AF with AF1 register
 void exx()
          Exchange the bank of Z80 register BC,DE,HL
 int I()
          Return the value of the I register.
 int im()
          Return the interrupt mode.
 void im(int n)
          Set the interrupt mode.
 void ind()
          IND Input from the port C store the value at (HL) and decrement the HL register.
 void ini()
          INI Input from the port C store the value at (HL) and increment the HL pair register.
protected  void initOpcodes()
          Initialize the Z80 opcodes
protected  void initRegisters()
          Initialize all standard intel 8080 register.
 void ldd()
           
 void ldi()
           
 void outd()
           
 void outi()
           
 int res(int value, int bit)
          Reset one bit.
protected  void resetRegisters()
          Reset all register to default value.
 int set(int value, int bit)
          Set one bit.
 int sla(int value)
           
 int sll(int value)
           
 int sra(int value)
           
 int srl(int value)
           
 
Methods inherited from class jmce.intel.i8080.I8080
adc16, adc8, add16, add8, af, af, and, b, c, ccf, cp, cpl, d, daa, dec, e, f, fireISR, fireNMI, FLAG_3, FLAG_3, FLAG_5, FLAG_5, FLAG_C, FLAG_C, FLAG_H, FLAG_H, FLAG_N, FLAG_N, FLAG_S, FLAG_S, FLAG_V, FLAG_V, FLAG_Z, FLAG_Z, getCCC, getFlagCCC, getPortHI, getPP, getQQ, getRRR, getValuePP, getValueQQ, getValueRRR, getWord, h, in, inc, init, initMemories, initOpcodeDecoder, initPeripherals, isInterruptEnabled, l, or, out, pc, pc, pop, push, rl, rla, rlc, rlca, rr, rra, rrc, rrca, sbc16, sbc8, scf, setValuePP, setValueQQ, setValueRRR, setWord, sub8, xor
 
Methods inherited from class jmce.sim.cpu.AbstractCPU
abort, addCycleListener, addDecoder, addExceptionListener, addExecBreakPoint, addInterrupt, addIOReadListener, addIOReadListener, addIOWriteListener, addIOWriteListener, addLoader, addMemoryWriteListener, addOffset, addReadBreakPoint, addRegister, addResetListener, addTimerCycle, addTimerMs, addTraceListener, addWriteBreakPoint, bit0, bit7, breakPointEvent, createRuntime, decodeAt, destroy, dumpStatistics, dumpStatistics, dumpTitle, dumpValue, dumpValue, fetch, formatFrequence, getBreakPointAt, getBreakPointCount, getByte, getCallListener, getClock, getClockPerCycle, getCycle, getCycleMillis, getDecoderAt, getDecoderCount, getEndian, getExceptionListenerAt, getExceptionListenerCount, getExecStatistics, getInterruptCount, getInterruptCounter, getInterruptName, getIOByte, getLenghtAt, getMemory, getMemoryAt, getMemoryCount, getMemoryForName, getOpcodeAt, getOpcodes, getRealTime, getRegisterAt, getRegisterCount, getRegisterForName, getResetAddress, getUsage, getUsageDesc, getWordBig, getWordLittle, halt, idle, isBigEndian, isLittleEndian, isRunning, load, load, notifyInterrupt, removeBreakPoint, removeBreakPoint, removeExceptionListener, removeTraceListener, reset, run, run0, setByte, setCallListener, setClock, setClockPerCycle, setEndian, setIO, setIOByte, setMemory, setOpcode, setRealTime, setResetAddress, setStatusLine, setTill, start, step, step0, stepNoBreak, stop
 
Methods inherited from class jmce.sim.AbstractHardware
addHardware, createFrame, getHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareForName, getHardwareInstances, getHardwareTree, getName, getParent, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmce.sim.Hardware
addHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareInstances, getHardwareTree, getName, getParent, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName
 

Field Detail

IX

public int IX

IY

public int IY

I

public int I

R

public int R
Constructor Detail

Z80

public Z80()
Default constructor.


Z80

public Z80(java.lang.String name)
Constructor with the cpu name specified.

Method Detail

initRegisters

protected void initRegisters()
Description copied from class: I8080
Initialize all standard intel 8080 register.

Overrides:
initRegisters in class I8080

I

public final int I()
Return the value of the I register.

Since:
1.01

srl

public final int srl(int value)

sll

public final int sll(int value)

sra

public final int sra(int value)

sla

public final int sla(int value)

res

public final int res(int value,
                     int bit)
Reset one bit.

Parameters:
value - - value
bit - - Number of the bit.
Returns:
the value with then bit bit set to 0.

set

public final int set(int value,
                     int bit)
Set one bit.


bit

public final int bit(int value,
                     int bit)
Check the status of one bit.


ex_af_af1

public final void ex_af_af1()
Change the AF with AF1 register


im

public final int im()
Return the interrupt mode.

Since:
1.01

im

public final void im(int n)
Set the interrupt mode.


exx

public final void exx()
Exchange the bank of Z80 register BC,DE,HL


resetRegisters

protected void resetRegisters()
                       throws SIMException
Description copied from class: AbstractCPU
Reset all register to default value. Sub class can override this method to reset additional non conventional register. This method is called during reset().

Overrides:
resetRegisters in class I8080
Throws:
SIMException

cpSpecial

public final void cpSpecial(int v)
Special version of compare used by CPD and CPI is like the normal compare but the C and V flag are untouched.


cpi

public void cpi()
         throws SIMException
CPI compare a with (HL) and increment HL and decrement BC

Throws:
SIMException

cpd

public void cpd()
         throws SIMException
CPD Compare A with (HL) and decrement HL and BC

Throws:
SIMException

ind

public void ind()
         throws SIMException
IND Input from the port C store the value at (HL) and decrement the HL register.

Throws:
SIMException

ini

public void ini()
         throws SIMException
INI Input from the port C store the value at (HL) and increment the HL pair register.

Throws:
SIMException

outd

public void outd()
          throws SIMException
Throws:
SIMException

outi

public void outi()
          throws SIMException
Throws:
SIMException

ldi

public void ldi()
         throws SIMException
Throws:
SIMException

ldd

public void ldd()
         throws SIMException
Throws:
SIMException

initOpcodes

protected void initOpcodes()
Initialize the Z80 opcodes

Overrides:
initOpcodes in class I8080

jmce - 1_02