jmce - 1_02

jmce.intel.i8080
Class I8080

java.lang.Object
  extended by jmce.sim.AbstractHardware
      extended by jmce.sim.cpu.AbstractCPU
          extended by jmce.intel.i8080.I8080
All Implemented Interfaces:
java.lang.Runnable, I8080Constants, BreakPointListener, CPU, Hardware, InterruptManager
Direct Known Subclasses:
Imsai, Z80

public class I8080
extends AbstractCPU
implements I8080Constants

Intel 8080 Standard.

Required memory

Emulated register : A,F,BC,DE,HL,PC,SP

The 8080 inplementation is tested using the child class Z80 with Yaze ZEXDOC Z80 exerciser.

For better rediability the mnemonics used on the disassembler are the Z80 mnemonics and not the original Intel 8080.

Version:
1.01
Author:
Mario Viara

Field Summary
 int A
          8080 register
 int BC
          8080 register
protected static int[] booleanTable
           
 int DE
          8080 register
 int F
          8080 register
 int HL
          8080 register
 boolean iff1
          Interrupt enable flag register.
 boolean iff2
          Interrupt enable flag register.
protected static boolean[] parityTable
          Table with PV flag on accumulator
 int PC
          8080 register
 int SP
          8080 register
 
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
I8080()
          Default constructor
I8080(java.lang.String name)
          Costructor with specified name.
 
Method Summary
protected  int adc16(int a, int b, int c)
          16 bit addition with carry
 void adc8(int b, int c)
          Add 8 bit with carry.
 int add16(int a, int b)
          16 bit addition
 void add8(int b)
          8 bit addition
 int af()
          Return the AF register
protected  void af(int v)
          Set the value of AF register.
 void and(int value)
          Logical and
protected  void b(int v)
          Set the value of B register
protected  void c(int v)
          Set the value of C register
 void ccf()
          Complement Carry Flag
 void cp(int v)
          Compare value with accumulator.
 void cpl()
          Complement accumulator.
protected  void d(int v)
          Set the value of D register.
 void daa()
          Decimal Adjust after addition.
 int dec(int value)
          8 Bit decrement
protected  void e(int v)
          Set the value of E register.
protected  void f(int value)
          Set the value of F register.
 int fireISR(Interrupt isr)
          This function must be overridden from sub class that implements interrupt.
 int fireNMI(Interrupt isr)
          This function must be overridden from sub class that implements NMI interrupt.
protected  boolean FLAG_3()
          Return the undocumented bit 3 of flag.
protected  void FLAG_3(boolean value)
          Set the undocumented bit 3 of flag.
protected  boolean FLAG_5()
          Return the undocumented bit 5 of flag.
protected  void FLAG_5(boolean value)
          Set the undocumented bit 5 of flag.
protected  boolean FLAG_C()
          Return the value of CF
protected  void FLAG_C(boolean value)
          Set the value of CF
protected  boolean FLAG_H()
          Return the HF flag.
protected  void FLAG_H(boolean value)
          Set the HF flag.
protected  boolean FLAG_N()
          Return the NF flag.
protected  void FLAG_N(boolean value)
          Set the NF flag.
protected  boolean FLAG_S()
          Return the SF flag.
protected  void FLAG_S(boolean value)
          Set the SF flag.
protected  boolean FLAG_V()
          Return the status of PV flag.
protected  void FLAG_V(boolean value)
          Set the PV flag.
protected  boolean FLAG_Z()
          Return the statu of the ZF
protected  void FLAG_Z(boolean value)
          Set the ZF flag.
 java.lang.String getCCC(int opcode)
           
 boolean getFlagCCC(int opcode)
           
 int getPortHI()
          Return the 8 High bit for I/O operations.
 java.lang.String getPP(int opcode)
           
 java.lang.String getQQ(int opcode)
           
 java.lang.String getRRR(int opcode)
           
 int getValuePP(int opcode)
           
 int getValueQQ(int opcode)
           
 int getValueRRR(int opcode)
           
 int getWord(int a)
          Read one word (16 bit) from the main memory.
protected  void h(int v)
          Set the value of H register
protected  int in(int portLOW, int portHI)
          Read a I/O port.
 int inc(int value)
          8 Bit increment
 void init(Hardware parent)
          Initialize the hardware.
protected  void initMemories()
          Initialize all required memories.
protected  void initOpcodeDecoder()
           
protected  void initOpcodes()
           
protected  void initPeripherals()
          Initialize all peripherals.
protected  void initRegisters()
          Initialize all standard intel 8080 register.
 boolean isInterruptEnabled()
          Return the status of the interrupt enable
protected  void l(int v)
          Set the value of L register
 void or(int value)
          Logical or
 void out(int portLow, int portHI, int value)
          Output one byte to the specfied port.
 int pc()
          Return the register used as program counter
 void pc(int pc)
          Set the program counter.
 int pop()
          Pop a WORD (16 bit) from the stack and return it.
protected  void push(int value)
          Push a WORD (16 bit) on the stack.
protected  void resetRegisters()
          Reset all register to default value.
 int rl(int value)
          9 bit left rotation
 void rla()
           
protected  int rlc(int value)
          8 bit left rotation
 void rlca()
           
protected  int rr(int value)
          9 bit right rotate.
 void rra()
           
 int rrc(int value)
          8 bit right rotate
 void rrca()
           
 int sbc16(int a, int b, int c)
          16 bit sub with carry
 void sbc8(int b, int c)
          Sub 8 bit with carry
 void scf()
          Set carry flag
 void setValuePP(int opcode, int value)
           
 void setValueQQ(int opcode, int value)
           
 void setValueRRR(int opcode, int value)
           
 void setWord(int a, int v)
          Set one word (16 bit) in the main memory
 void sub8(int b)
          Sub 8 bit
 void xor(int value)
          Logical 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

A

public int A
8080 register


F

public int F
8080 register


BC

public int BC
8080 register


DE

public int DE
8080 register


HL

public int HL
8080 register


PC

public int PC
8080 register


SP

public int SP
8080 register


iff1

public boolean iff1
Interrupt enable flag register. Interrupt are enable only when the 2 flag (iff1,iff2) are both true.


iff2

public boolean iff2
Interrupt enable flag register. Interrupt are enable only when the 2 flag (iff1,iff2) are both true.


parityTable

protected static final boolean[] parityTable
Table with PV flag on accumulator


booleanTable

protected static int[] booleanTable
Constructor Detail

I8080

public I8080()
Default constructor


I8080

public I8080(java.lang.String name)
Costructor with specified name.

Set all requested value for the intel 8080 cpu.

Method Detail

setWord

public final void setWord(int a,
                          int v)
                   throws SIMException
Description copied from interface: CPU
Set one word (16 bit) in the main memory

Specified by:
setWord in interface CPU
Parameters:
a - - Address
v - - value
Throws:
SIMException

getWord

public final int getWord(int a)
                  throws SIMException
Description copied from interface: CPU
Read one word (16 bit) from the main memory.

Specified by:
getWord in interface CPU
Parameters:
a - - Address
Returns:
The word at the specified address.
Throws:
SIMException

pc

public final void pc(int pc)
Description copied from interface: CPU
Set the program counter.

Specified by:
pc in interface CPU
Parameters:
pc - - New value for the program counter.

pc

public final int pc()
Description copied from interface: CPU
Return the register used as program counter

Specified by:
pc in interface CPU
Returns:
- Program counter.

FLAG_C

protected final boolean FLAG_C()
Return the value of CF


FLAG_C

protected final void FLAG_C(boolean value)
Set the value of CF


FLAG_Z

protected final boolean FLAG_Z()
Return the statu of the ZF


FLAG_V

protected final boolean FLAG_V()
Return the status of PV flag.


FLAG_S

protected final boolean FLAG_S()
Return the SF flag.


FLAG_H

protected final boolean FLAG_H()
Return the HF flag.


FLAG_Z

protected final void FLAG_Z(boolean value)
Set the ZF flag.


FLAG_S

protected final void FLAG_S(boolean value)
Set the SF flag.


FLAG_H

protected void FLAG_H(boolean value)
Set the HF flag.


FLAG_V

protected final void FLAG_V(boolean value)
Set the PV flag.


FLAG_N

protected final boolean FLAG_N()
Return the NF flag.


FLAG_N

protected final void FLAG_N(boolean value)
Set the NF flag.


FLAG_3

protected final boolean FLAG_3()
Return the undocumented bit 3 of flag.


FLAG_5

protected final boolean FLAG_5()
Return the undocumented bit 5 of flag.


FLAG_5

protected final void FLAG_5(boolean value)
Set the undocumented bit 5 of flag.


FLAG_3

protected final void FLAG_3(boolean value)
Set the undocumented bit 3 of flag.


initMemories

protected void initMemories()
Initialize all required memories.

Add the MAIN_MEMORY and the IO_MEMORY if sub class override this method to change the type of memory must first add the required memories and then call the parent method.


initRegisters

protected void initRegisters()
Initialize all standard intel 8080 register.


h

protected final void h(int v)
Set the value of H register


l

protected final void l(int v)
Set the value of L register


b

protected final void b(int v)
Set the value of B register


c

protected final void c(int v)
Set the value of C register


d

protected final void d(int v)
Set the value of D register.


e

protected final void e(int v)
Set the value of E register.


f

protected final void f(int value)
Set the value of F register.


af

public final int af()
Return the AF register


af

protected final void af(int v)
Set the value of AF register.


isInterruptEnabled

public final boolean isInterruptEnabled()
Description copied from interface: CPU
Return the status of the interrupt enable

Specified by:
isInterruptEnabled in interface CPU

initPeripherals

protected void initPeripherals()
                        throws SIMException
Initialize all peripherals.

This method do nothing because the Intel 8080 do not have any internal peripheral.

Throws:
SIMException

init

public void init(Hardware parent)
          throws SIMException
Description copied from interface: Hardware
Initialize the hardware. This method must be called before any use of the interface. Only set ... / get ... method are allowed to be called before the intialization.

Specified by:
init in interface Hardware
Overrides:
init in class AbstractCPU
Parameters:
parent - Parent of this hardware.
Throws:
SIMException

push

protected final void push(int value)
                   throws SIMException
Push a WORD (16 bit) on the stack.

Throws:
SIMException

pop

public final int pop()
              throws SIMException
Pop a WORD (16 bit) from the stack and return it.

Throws:
SIMException

getPortHI

public final int getPortHI()
Return the 8 High bit for I/O operations.


out

public final void out(int portLow,
                      int portHI,
                      int value)
               throws SIMException
Output one byte to the specfied port.

Parameters:
portLow - - 8 Bit low port address.
portHI - - 8 Bit hi port address.
value - - Value to write.
Throws:
SIMException

in

protected final int in(int portLOW,
                       int portHI)
                throws SIMException
Read a I/O port.

Parameters:
portLOW - - 8 Bit low port address.
portHI - - 8 Bit port high address.
Returns:
The value read from the specified port.
Throws:
SIMException

daa

public final void daa()
Decimal Adjust after addition.


rl

public final int rl(int value)
9 bit left rotation


rlc

protected final int rlc(int value)
8 bit left rotation


rr

protected final int rr(int value)
9 bit right rotate.


rla

public final void rla()

rra

public final void rra()

rlca

public final void rlca()

rrca

public final void rrca()

rrc

public final int rrc(int value)
8 bit right rotate


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 AbstractCPU
Throws:
SIMException

or

public final void or(int value)
Logical or


scf

public final void scf()
Set carry flag


ccf

public final void ccf()
Complement Carry Flag


cpl

public final void cpl()
Complement accumulator.


xor

public final void xor(int value)
Logical xor


and

public final void and(int value)
Logical and


add8

public final void add8(int b)
8 bit addition


adc8

public final void adc8(int b,
                       int c)
Add 8 bit with carry.


sub8

public final void sub8(int b)
Sub 8 bit


sbc8

public final void sbc8(int b,
                       int c)
Sub 8 bit with carry


cp

public final void cp(int v)
Compare value with accumulator.


inc

public final int inc(int value)
8 Bit increment


dec

public final int dec(int value)
8 Bit decrement


sbc16

public final int sbc16(int a,
                       int b,
                       int c)
16 bit sub with carry


add16

public final int add16(int a,
                       int b)
16 bit addition


adc16

protected final int adc16(int a,
                          int b,
                          int c)
16 bit addition with carry


setValuePP

public final void setValuePP(int opcode,
                             int value)

getFlagCCC

public final boolean getFlagCCC(int opcode)

getCCC

public java.lang.String getCCC(int opcode)

setValueQQ

public final void setValueQQ(int opcode,
                             int value)

getPP

public java.lang.String getPP(int opcode)

getValuePP

public final int getValuePP(int opcode)

getQQ

public java.lang.String getQQ(int opcode)

getValueQQ

public final int getValueQQ(int opcode)

getRRR

public java.lang.String getRRR(int opcode)

getValueRRR

public final int getValueRRR(int opcode)
                      throws SIMException
Throws:
SIMException

setValueRRR

public final void setValueRRR(int opcode,
                              int value)
                       throws SIMException
Throws:
SIMException

initOpcodeDecoder

protected void initOpcodeDecoder()

initOpcodes

protected void initOpcodes()

fireISR

public int fireISR(Interrupt isr)
            throws SIMException
Description copied from class: AbstractCPU
This function must be overridden from sub class that implements interrupt.

Specified by:
fireISR in interface CPU
Overrides:
fireISR in class AbstractCPU
Throws:
SIMException

fireNMI

public int fireNMI(Interrupt isr)
            throws SIMException
Description copied from class: AbstractCPU
This function must be overridden from sub class that implements NMI interrupt.

Specified by:
fireNMI in interface CPU
Overrides:
fireNMI in class AbstractCPU
Throws:
SIMException

jmce - 1_02