dspl.backend.x86
Class X86AsmFormatter

java.lang.Object
  extended by dspl.backend.x86.X86AsmFormatter

public class X86AsmFormatter
extends java.lang.Object

Utility class for various common formatting operations required by the various x86***InstructionProcessors

Author:
David

Constructor Summary
X86AsmFormatter()
           
 
Method Summary
static java.lang.String getAddInstruction(Variable v)
          Returns the appriopriate add instruction based on the variable's size
static java.lang.String getArrayElement(Variable v, java.lang.String index)
          Returns the string representation of an element within an array.
static java.lang.String getConstantRepresentation(int x)
          Returns representation that should be used in an x86 assmebly file for an integer constant
Created originally for getting representation for array sizes which is used in loops.
static java.lang.String getDivideInstruction(Variable v)
          Returns the appriopriate divide instruction based on the variable's type
static java.lang.String getInstr(java.lang.String inst, Variable v)
          Returns a string representing the instruction for inst + (b/w/l), depending on size of v
static java.lang.String getMoveInstruction(int size)
           
static java.lang.String getMoveInstruction(Variable v)
          Returns the apprioprate move instruction based on the variable's size
static java.lang.String getMultiplyInstruction(Variable v)
          Returns the appriopriate multiply instruction based on the variable's type
static java.lang.String getSizePostfix(Variable v)
          Returns the appriopriate size postfix (b,w, or l) for (1,2, or 4) byte sized data type
static java.lang.String getSubtractInstruction(Variable v)
          Returns the appriopriate subtract instruction based on the variable's type
static java.lang.String getVariableRepresentation(Variable v)
          Returns the representation that should be used for the variable in assmebly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

X86AsmFormatter

public X86AsmFormatter()
Method Detail

getVariableRepresentation

public static java.lang.String getVariableRepresentation(Variable v)
Returns the representation that should be used for the variable in assmebly

The intent on adding this it allow for the future possibility of supporting the different ASM representations for assembly
Also to allow for changes in exactly how a variable's location, as it should be referenced within the asm file to change.

For example, if variables stored on the stack are supported, an additional field might be added to variable to store it's stack offset (i.e. "-4(%ebp)")

Parameters:
v -
Returns:

getConstantRepresentation

public static java.lang.String getConstantRepresentation(int x)
Returns representation that should be used in an x86 assmebly file for an integer constant
Created originally for getting representation for array sizes which is used in loops.

Parameters:
x -
Returns:

getArrayElement

public static java.lang.String getArrayElement(Variable v,
                                               java.lang.String index)
Returns the string representation of an element within an array. Uses the from arrayIdentifier(,index,sizeType)

Parameters:
v -
index -
Returns:

getMoveInstruction

public static java.lang.String getMoveInstruction(Variable v)
Returns the apprioprate move instruction based on the variable's size

1 byte = movb 2 bytes = movw 4 bytes = movl

Parameters:
v -
Returns:

getMoveInstruction

public static java.lang.String getMoveInstruction(int size)

getAddInstruction

public static java.lang.String getAddInstruction(Variable v)
Returns the appriopriate add instruction based on the variable's size

1 byte = addb 2 bytes = addw 4 bytes = addl

Parameters:
v -
Returns:

getInstr

public static java.lang.String getInstr(java.lang.String inst,
                                        Variable v)
Returns a string representing the instruction for inst + (b/w/l), depending on size of v

Parameters:
inst -
v -
Returns:
the post-fixed instruction String correspinding to the size of Variable v

getSizePostfix

public static java.lang.String getSizePostfix(Variable v)
Returns the appriopriate size postfix (b,w, or l) for (1,2, or 4) byte sized data type

Parameters:
v -
Returns:

getMultiplyInstruction

public static java.lang.String getMultiplyInstruction(Variable v)
Returns the appriopriate multiply instruction based on the variable's type

This instruction is only valid for int/byte (signed) or uint/ubyte (unsigned).

Parameters:
v -
Returns:

getSubtractInstruction

public static java.lang.String getSubtractInstruction(Variable v)
Returns the appriopriate subtract instruction based on the variable's type

This instruction is only valid for int/byte (signed) or uint/ubyte (unsigned).

Parameters:
v -
Returns:

getDivideInstruction

public static java.lang.String getDivideInstruction(Variable v)
Returns the appriopriate divide instruction based on the variable's type

This instruction is only valid for int/byte (signed) or uint/ubyte (unsigned).

Parameters:
v -
Returns: