de.cau.cs.kieler.krep.evalbench.program
Interface IAssembler

All Known Implementing Classes:
KepAssembler, KitAssembler, KlpAssembler, LstAssembler

public interface IAssembler

Interface for assemblers that transform assembler files into binary object code.

Rating yellow
(2010-02-05) review by cmot, msp

Method Summary
 int adr2row(int i)
          compute at which line in the assembler code a absolute pc is displayed.
 void assemble(String name, InputStream program)
          Assemble a given program string and generated object code in readable hex coded format and instruction array.
 void assemble(String name, String program)
          Assemble a given program string and return object code information in readable hex coded format.
 String canExecute(IConfig c)
          Check whether the Assembler can be executed on the current processor This should check, whether the correct processor (KEP/KReP) is used, and whether it has enough resources, like number of signals, etc.
 LinkedList<Signal> getInputs()
          After a program has been assembled, a list of input signals can be extracted.
 String[][] getInstructions()
          After a program has been assembled, an array with the contained instructions can be extracted.
 String getName()
           
 String[] getObj(IConfig c)
          After a program has been assembled, an array with the contained object-code can be extracted.
 LinkedList<Signal> getOutputs()
          After a program has been assembled, a list of output signals can be extracted.
 HashMap<String,Integer> getSignalIndex()
           
 int getTickLen()
           
 int size()
          The number of instructions in the program.
 

Method Detail

getName

String getName()
Returns:
the human readable name of the assembler

assemble

void assemble(String name,
              String program)
              throws ParseException
Assemble a given program string and return object code information in readable hex coded format. In the returned array each string represents an instruction.

Parameters:
name - Name of the program
program - assembler program
Throws:
ParseException - when the input string has an invalid format

assemble

void assemble(String name,
              InputStream program)
              throws ParseException
Assemble a given program string and generated object code in readable hex coded format and instruction array.

Parameters:
name - Name of the program
program - assembler program
Throws:
ParseException - when the input string has an invalid format

getInputs

LinkedList<Signal> getInputs()
After a program has been assembled, a list of input signals can be extracted.

Returns:
list of input signals of the last assembled program

getOutputs

LinkedList<Signal> getOutputs()
After a program has been assembled, a list of output signals can be extracted.

Returns:
list of output signals of the last assembled program

getInstructions

String[][] getInstructions()
After a program has been assembled, an array with the contained instructions can be extracted. Each array element is a triple of strings; the first string contains the instruction index; the second one contains a label name, e.g. "loop0:", or an empty string if there is no label for that instruction. The third string contains the readable assembler instruction code.

Returns:
array with instructions (nr., label, code)

getObj

String[] getObj(IConfig c)
After a program has been assembled, an array with the contained object-code can be extracted.

Parameters:
c - configuration of the current processor
Returns:
array with hex-code

canExecute

String canExecute(IConfig c)
Check whether the Assembler can be executed on the current processor This should check, whether the correct processor (KEP/KReP) is used, and whether it has enough resources, like number of signals, etc.

Parameters:
c - the configuration
Returns:
null if processor can execute this program. Otherwise a detailed message why the execution is not possible is returned.

getSignalIndex

HashMap<String,Integer> getSignalIndex()
Returns:
mapping to get signal index for each valid signal in the program

adr2row

int adr2row(int i)
compute at which line in the assembler code a absolute pc is displayed. This takes label into account.

Parameters:
i - absolute address in memory
Returns:
the line in the source code

size

int size()
The number of instructions in the program. This value is only available after the assembling took place.

Returns:
size of the program in instructions.

getTickLen

int getTickLen()
Returns:
maximal number of instructions in one tick for this program