jfrace.cpu
Class MC6502

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

public class MC6502
extends java.lang.Object
implements CPU

The 6502 microprocessor.

Author:
Franz-Josef Elmer

Field Summary
static int A
          Index of register A (accumulator).
static int B_POS
          Bit position of the break flag.
static int C_POS
          Bit position of the carry flag.
static int D_POS
          Bit position of the decimal mode flag.
static int I_POS
          Bit position of the interrupt disable flag.
static int N_POS
          Bit position of the negative flag.
static int P
          Index of register P (processor status).
static int PC
          Index of register PC (pogram counter).
static int S
          Index of register S (stack pointer).
static int V_POS
          Bit position of the overflow flag.
static int X
          Index of register X (index register).
static int Y
          Index of register X (index register).
static int Z_POS
          Bit position of the zero flag.
 
Constructor Summary
MC6502()
           
 
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 "6502".
 int getNumberOfBits()
          Return 8.
 int getNumberOfRegisters()
          Return 6.
 Register getProgramCounter()
          Return the program counter.
 Register getRegister(int index)
          Return a register.
 void interrupt(long interrupt)
          Not implemented.
 int next()
          Proceed one opcode further.
 void reset()
          Reset the hardware.
 void setAddressSpace(AddressSpace addressSpace)
          Set the address space.
 void setRegisterValue(int index, int value)
          Set the value of a register.
 boolean supportsDisassembling()
          Disassembling is supported.
 java.lang.String toString()
          Return the state of the CPU as a well-formed string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

A

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

X

public static final int X
Index of register X (index register).

Y

public static final int Y
Index of register X (index register).

S

public static final int S
Index of register S (stack pointer).

P

public static final int P
Index of register P (processor status).

PC

public static final int PC
Index of register PC (pogram counter).

N_POS

public static final int N_POS
Bit position of the negative flag.

V_POS

public static final int V_POS
Bit position of the overflow flag.

B_POS

public static final int B_POS
Bit position of the break flag.

D_POS

public static final int D_POS
Bit position of the decimal mode flag.

I_POS

public static final int I_POS
Bit position of the interrupt disable flag.

Z_POS

public static final int Z_POS
Bit position of the zero flag.

C_POS

public static final int C_POS
Bit position of the carry flag.
Constructor Detail

MC6502

public MC6502()
Method Detail

toString

public java.lang.String toString()
Return the state of the CPU as a well-formed string.
Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()
Return "6502".
Specified by:
getName in interface CPU

getNumberOfBits

public int getNumberOfBits()
Return 8.
Specified by:
getNumberOfBits in interface Hardware

getNumberOfRegisters

public int getNumberOfRegisters()
Return 6.
Specified by:
getNumberOfRegisters in interface CPU

getRegister

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

getProgramCounter

public Register getProgramCounter()
Description copied from interface: CPU
Return the program counter. The program counter is a special register.
Specified by:
getProgramCounter in interface CPU

setRegisterValue

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

setAddressSpace

public void setAddressSpace(AddressSpace addressSpace)
Description copied from interface: CPU
Set the address space.
Specified by:
setAddressSpace in interface CPU

getAddressSpace

public AddressSpace getAddressSpace()
Description copied from interface: CPU
Get the address space.
Specified by:
getAddressSpace in interface CPU

reset

public void reset()
Description copied from interface: Hardware
Reset the hardware. After reseting this hardware will be in a well-defined state.
Specified by:
reset in interface Hardware

interrupt

public void interrupt(long interrupt)
Not implemented.
Specified by:
interrupt in interface CPU
Following copied from interface: jfrace.CPU
Parameters:
interrupt - Bit pattern of the interrupt. The meaning of the bits depend on the implementation.

getErrorDescription

public java.lang.String getErrorDescription()
Description copied from interface: CPU
Return error description. The meaning of the error code depends on the implementation. This method should be called when CPU.next() returns -1.
Specified by:
getErrorDescription in interface CPU

next

public int next()
Description copied from interface: CPU
Proceed one opcode further. Return the number of clock cycles.
Specified by:
next in interface CPU
Following copied from interface: jfrace.CPU
Returns:
-1 if an error occured.

supportsDisassembling

public boolean supportsDisassembling()
Disassembling is supported.
Specified by:
supportsDisassembling in interface CPU

disassemble

public int disassemble(java.lang.StringBuffer sb,
                       int address)
Description copied from interface: CPU
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.
Specified by:
disassemble in interface CPU
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.