jfrace
Interface CPU

All Superinterfaces:
Hardware
All Known Implementing Classes:
Intel8080, FJE5, MC6502

public interface CPU
extends Hardware

Interface for a central processing unit (CPU).

Author:
Franz-Josef Elmer

Method Summary
 int disassemble(java.lang.StringBuffer sb, int address)
          Disassemble the next op-code at the given address and append it to the given string buffer.
 AddressSpace getAddressSpace()
          Get the address space.
 java.lang.String getErrorDescription()
          Return error description.
 java.lang.String getName()
          Return the name of the CPU which is emulated.
 int getNumberOfRegisters()
          Return the number of registers.
 Register getProgramCounter()
          Return the program counter.
 Register getRegister(int index)
          Return a register.
 void interrupt(long interrupt)
          Interrupt the CPU at the next call of next().
 int next()
          Proceed one opcode further.
 void setAddressSpace(AddressSpace addressSpace)
          Set the address space.
 void setRegisterValue(int index, int value)
          Set the value of a register.
 boolean supportsDisassembling()
          Return true if disassembling is supported.
 
Methods inherited from interface jfrace.Hardware
getNumberOfBits, reset
 

Method Detail

getName

public java.lang.String getName()
Return the name of the CPU which is emulated.

getNumberOfRegisters

public int getNumberOfRegisters()
Return the number of registers.

getRegister

public Register getRegister(int index)
Return a register.
Parameters:
index - Index of the register.
Returns:
null if no register exists for the given index.

getProgramCounter

public Register getProgramCounter()
Return the program counter. The program counter is a special register.

setRegisterValue

public void setRegisterValue(int index,
                             int value)
Set the value of a register.
Parameters:
index - Index of the register.
value - New value.

setAddressSpace

public void setAddressSpace(AddressSpace addressSpace)
Set the address space.

getAddressSpace

public AddressSpace getAddressSpace()
Get the address space.

interrupt

public void interrupt(long interrupt)
Interrupt the CPU at the next call of next().
Parameters:
interrupt - Bit pattern of the interrupt. The meaning of the bits depend on the implementation.

getErrorDescription

public java.lang.String getErrorDescription()
Return error description. The meaning of the error code depends on the implementation. This method should be called when next() returns -1.

next

public int next()
Proceed one opcode further. Return the number of clock cycles.
Returns:
-1 if an error occured.

supportsDisassembling

public boolean supportsDisassembling()
Return true if disassembling is supported.

disassemble

public int disassemble(java.lang.StringBuffer sb,
                       int address)
Disassemble the next op-code at the given address and append it to the given string buffer. If disassembling isn't supported -1 will be returned.
Parameters:
sb - String buffer.
address - Address of op-code.
Returns:
number of addressable units of the op-code at address.