tools.processor
Class Processor

java.lang.Object
  extended by tools.processor.Processor
Direct Known Subclasses:
Processor_6809

public class Processor
extends java.lang.Object

This class encapsulates all the information about a single processor. This is the base information for specific CPUs defined in "ProcessorCPU.java" files where CPU is the processor's name.


Field Summary
protected  ProcessorFamily family
           
protected  java.lang.String name
           
protected  java.util.List<Opcode> opcodes
           
 
Constructor Summary
Processor(ProcessorFamily family, org.jdom.Element info, org.jdom.Element familyInfo)
          This parses the generic processor info common to all processors.
 
Method Summary
 Opcode findOpcode(java.lang.String comp, java.util.Map<java.lang.String,OpcodeParameterInfo> params, java.util.List<java.lang.String> as)
          This method finds the opcode for the given mnemonic text string.
 java.util.List<Opcode> findPossibleOpcodes(int[] binary, int start, int length)
          This method looks at the processor's opcode list and returns all that potentially match the given binary stream.
 ProcessorFamily getFamily()
           
 java.lang.String getName()
           
protected  void parseProcessorOpcodes(org.jdom.Element familyInfo)
          This method parses the processor's opcode list from the family's master list of opcodes.
 java.lang.String preprocessOpcode(java.lang.String comp, java.util.List<java.lang.Integer> starts)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

family

protected ProcessorFamily family

opcodes

protected java.util.List<Opcode> opcodes
Constructor Detail

Processor

public Processor(ProcessorFamily family,
                 org.jdom.Element info,
                 org.jdom.Element familyInfo)
This parses the generic processor info common to all processors.

Parameters:
family - the processor's family
info - the processor's info structure
familyInfo - the XML element for the family (might be some processor-specifics in there)
Method Detail

parseProcessorOpcodes

protected void parseProcessorOpcodes(org.jdom.Element familyInfo)
This method parses the processor's opcode list from the family's master list of opcodes. If the family opcode belongs with this processor then the XML entry will have a "mCPU" attribute with the mnemonic text. This is just the "default" behavior, or course. Specific processors may use the family XML how ever they want.

Parameters:
familyInfo -

findPossibleOpcodes

public java.util.List<Opcode> findPossibleOpcodes(int[] binary,
                                                  int start,
                                                  int length)
This method looks at the processor's opcode list and returns all that potentially match the given binary stream. A disassembler would call this method with longer and longer binary streams until just one (or none) opcodes match. This really belongs in a processor-specific disassembler implementation, but for simplicity we will keep it here.

Parameters:
binary - the array of binary data
start - the starting point of the binary stream to decode
length - the number of bytes in the stream
Returns:
the list of opcodes that match the stream

getFamily

public ProcessorFamily getFamily()

getName

public java.lang.String getName()

preprocessOpcode

public java.lang.String preprocessOpcode(java.lang.String comp,
                                         java.util.List<java.lang.Integer> starts)

findOpcode

public Opcode findOpcode(java.lang.String comp,
                         java.util.Map<java.lang.String,OpcodeParameterInfo> params,
                         java.util.List<java.lang.String> as)
This method finds the opcode for the given mnemonic text string. This is the core work of assembly a program from an input file. The method is here so it can be overridden with processor-specifics if needed.

Parameters:
comp - the input line with defines substituted in and extraneous white-space collapsed
params - a return map containing fill-in data for the second pass
as - a list of mnemonic sets to use (or null to use all in the family)
Returns:
the opcode or null if no match (the dataMap is also a return)