jfrace.cpu
Class Z80

java.lang.Object
  |
  +--jfrace.cpu.Intel8080
        |
        +--jfrace.cpu.Z80
All Implemented Interfaces:
AddressSpaceListener, CPU, Hardware

public class Z80
extends Intel8080

Implements an emulation of Zilog's Z80 8-bit processor. All the restrictions of Intel8080 hold also for this Z80 implementation.

Author:
Franz-Josef Elmer

Field Summary
static int As
          Index of register A' (accumulator).
static int Bs
          Index of register B'.
static int Cs
          Index of register C'.
static int Ds
          Index of register D'.
static int Es
          Index of register E'.
static int Fs
          Index of register F' (flags).
static int Hs
          Index of register H'.
static int I
          Index of register I.
static int IX
          Index of register IX.
static int IY
          Index of register IY.
static int Ls
          Index of register L'.
static int R
          Index of register R.
static int SUB_MASK
          Mask for the substraction flag.
static int SUB_POS
          Bit position of the substraction flag.
 
Fields inherited from class jfrace.cpu.Intel8080
A, ACI, ADC, ADD, ADD_MASK, ADI, ANA, ANI, as, AUX_CARRY_MASK, AUX_CARRY_POS, B, C, CALL, CARRY_MASK, CARRY_POS, Cc, CMA, CMC, CMP, CONDITION_NAMES, CPI, D, DAA, DAD, DATA_REGISTER_NAMES, DCR, DCX, DI, E, EI, errorDescription, F, H, HLT, IN, INR, INR_MASK, interruptEnabled, INX, Jc, JMP, L, LDA, LDAX, LHLD, LXI, memory, MOV, MVI, NOP, NULL_BYTE, OP_CODE_TYPE, ORA, ORI, OUT, PARITY_MASK, PARITY_POS, PC, PCHL, POP, portBiasAddress, programCounter, PUSH, RAL, RAR, Rc, REGISTER_PAIR_NAMES, REGISTER_PAIR_NAMES2, registers, RET, RLC, ROT_MASK, RRC, RST, SBB, SBI, SHLD, SIGN_MASK, SIGN_POS, SP, SPHL, STA, stackPointer, STAX, STC, SUB, SUI, UDEF, XCHG, XRA, XRI, XTHL, ZERO_MASK, ZERO_POS
 
Constructor Summary
Z80()
           
 
Method Summary
protected  void addToAccu(byte operand, int carry, int flagMask)
          Add operand and carry bit to accumulator and set the flags.
 int disassemble(java.lang.StringBuffer sb, int address)
          Return disassemble instruction in standard Zilog Z80 assembler syntax.
protected  int disassembleUDEF(byte opCode, java.lang.StringBuffer sb, int address)
           
 java.lang.String getName()
          Return "Zilog Z80".
 int getNumberOfRegisters()
          Return 22.
 Register getRegister(int index)
          Return a register.
 int next()
          Proceed one opcode.
protected  boolean processINRorDCR(byte opCode, int increment)
          Process INR and DCR commands.
protected  boolean processUDEF(byte opCode)
          Process an op-code which is undefined for Intel 8080.
 void reset()
          Reset the CPU.
 void setRegisterValue(int index, int value)
          Set the value of a register.
protected  void subtractFromAccu(byte operand, int carry, int flagMask)
          Subtract operand and carry from accumulator and set the flags.
 java.lang.String toString()
          Show register states like CP/M DDTZ.
 
Methods inherited from class jfrace.cpu.Intel8080
calculateParityFlag, checkCondition, disassembleByte, disassembleWord, getAddressSpace, getErrorDescription, getNumberOfBits, getPortBiasAddress, getProgramCounter, getRegisterPair, getWord, hardwareMoved, interrupt, popFromStack, processHLT, pushOnStack, readByte, setAccuAndFlags, setAddressSpace, setPortBiasAddress, setRegisterPair, storeByte, supportsDisassembling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

As

public static final int As
Index of register A' (accumulator).

Fs

public static final int Fs
Index of register F' (flags).

Bs

public static final int Bs
Index of register B'.

Cs

public static final int Cs
Index of register C'.

Ds

public static final int Ds
Index of register D'.

Es

public static final int Es
Index of register E'.

Hs

public static final int Hs
Index of register H'.

Ls

public static final int Ls
Index of register L'.

IX

public static final int IX
Index of register IX.

IY

public static final int IY
Index of register IY.

I

public static final int I
Index of register I.

R

public static final int R
Index of register R.

SUB_POS

public static final int SUB_POS
Bit position of the substraction flag.

SUB_MASK

public static final int SUB_MASK
Mask for the substraction flag.
Constructor Detail

Z80

public Z80()
Method Detail

toString

public java.lang.String toString()
Show register states like CP/M DDTZ.
Overrides:
toString in class Intel8080

getName

public java.lang.String getName()
Return "Zilog Z80".
Overrides:
getName in class Intel8080

getNumberOfRegisters

public int getNumberOfRegisters()
Return 22.
Overrides:
getNumberOfRegisters in class Intel8080

getRegister

public Register getRegister(int index)
Description copied from interface: CPU
Return a register.
Overrides:
getRegister in class Intel8080
Following copied from interface: jfrace.CPU
Parameters:
index - Index of the register.
Returns:
null if no register exists for the given index.

setRegisterValue

public void setRegisterValue(int index,
                             int value)
Description copied from interface: CPU
Set the value of a register.
Overrides:
setRegisterValue in class Intel8080
Following copied from interface: jfrace.CPU
Parameters:
index - Index of the register.
value - New value.

reset

public void reset()
Description copied from class: Intel8080
Reset the CPU. The internal state will be set into a well-defined initial state.
Overrides:
reset in class Intel8080

next

public int next()
Description copied from class: Intel8080
Proceed one opcode.
Overrides:
next in class Intel8080
Following copied from class: jfrace.cpu.Intel8080
Returns:
always 1 excepted in the case of an error.

processINRorDCR

protected boolean processINRorDCR(byte opCode,
                                  int increment)
Description copied from class: Intel8080
Process INR and DCR commands.
Overrides:
processINRorDCR in class Intel8080

addToAccu

protected void addToAccu(byte operand,
                         int carry,
                         int flagMask)
Description copied from class: Intel8080
Add operand and carry bit to accumulator and set the flags.
Overrides:
addToAccu in class Intel8080

subtractFromAccu

protected void subtractFromAccu(byte operand,
                                int carry,
                                int flagMask)
Description copied from class: Intel8080
Subtract operand and carry from accumulator and set the flags.
Overrides:
subtractFromAccu in class Intel8080

processUDEF

protected boolean processUDEF(byte opCode)
Process an op-code which is undefined for Intel 8080.
Overrides:
processUDEF in class Intel8080

disassembleUDEF

protected int disassembleUDEF(byte opCode,
                              java.lang.StringBuffer sb,
                              int address)
Overrides:
disassembleUDEF in class Intel8080

disassemble

public int disassemble(java.lang.StringBuffer sb,
                       int address)
Return disassemble instruction in standard Zilog Z80 assembler syntax.
Overrides:
disassemble in class Intel8080
Following copied from interface: jfrace.CPU
Parameters:
sb - String buffer.
address - Address of op-code.
Returns:
number of addressable units of the op-code at address.