tools.code
Class CU

java.lang.Object
  extended by tools.code.CU

public final class CU
extends java.lang.Object

This class contains lots of tool functions for dealing with assembly code.


Method Summary
static java.lang.String collapseWhiteSpace(java.lang.String s)
          This static method collapses multiple white spaces into one white space.
static int findEndOfExpression(java.lang.String text, int start)
          This method locates the end of a token run.
static int findEndOfSymbol(java.lang.String text, int start)
           
static java.lang.String fourDigitHex(int value)
          This static method returns the given value as a 4 digit hex number.
static java.lang.String getDataString(int[] data)
          This method produces a string of hex bytes for the given byte array.
static boolean isFourDigitHex(java.lang.String s)
          This method checks that the string starts with a four digit hex number.
static boolean isTwoDigitHex(java.lang.String s, int start)
          This static method checks to see if there is a two-digit hex value at the given location in the target string.
static java.lang.String leadingZero(java.lang.String s, int len)
          This static method pads a string with leading zeros.
static java.lang.String padTo(java.lang.String s, int len)
          This static method pads the given string to the given length by appending white-space to the end.
static int parseIntValue(java.lang.String s)
          This method parses an integer value from the given string accounting for base specification.
static java.lang.String removeWhiteSpace(java.lang.String text, java.util.List<java.lang.Integer> starts)
          This method removes unneeded whitespace in a line of code.
static java.lang.String replaceAll(java.lang.String source, java.lang.String key, java.lang.String value)
          This static method replaces all "key" in "source" with "value".
static int signedNumber(int bits, int value)
          This static method converts an N-bit signed value to a true java signed value.
static java.lang.String twoDigitHex(int value)
          This static method returns the given value as a 2 digit hex number.
static java.lang.String twoOrFourDigitHex(int value)
          This static method returns the given value as a 2 digit or 4 digit hex number (4 if greater than 255).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

removeWhiteSpace

public static java.lang.String removeWhiteSpace(java.lang.String text,
                                                java.util.List<java.lang.Integer> starts)
This method removes unneeded whitespace in a line of code. Whitespace before and after symbols is not needed.

Parameters:
text - the input text
starts - where each character in the return string started in the original string
Returns:
the compacted space

findEndOfExpression

public static int findEndOfExpression(java.lang.String text,
                                      int start)
This method locates the end of a token run. The returned value is one past the last character of the run (one past the end of the string if the run is at the end of the string)

Parameters:
text - the text to search
start - the starting position of the token to find the end
Returns:
the position one past the end of the token

findEndOfSymbol

public static int findEndOfSymbol(java.lang.String text,
                                  int start)

isTwoDigitHex

public static boolean isTwoDigitHex(java.lang.String s,
                                    int start)
This static method checks to see if there is a two-digit hex value at the given location in the target string. A space may follow or the end of the string.

Parameters:
s - target string
start - starting point in the string
Returns:
length of number or -1 if not valid

isFourDigitHex

public static boolean isFourDigitHex(java.lang.String s)
This method checks that the string starts with a four digit hex number.

Parameters:
s - the target string
Returns:
true if the string starts with 4 digitis of hex

fourDigitHex

public static java.lang.String fourDigitHex(int value)
This static method returns the given value as a 4 digit hex number.

Parameters:
value - the value to convert
Returns:
4 digit hex representation

twoDigitHex

public static java.lang.String twoDigitHex(int value)
This static method returns the given value as a 2 digit hex number.

Parameters:
value - the value to convert
Returns:
2 digit hex representation

twoOrFourDigitHex

public static java.lang.String twoOrFourDigitHex(int value)
This static method returns the given value as a 2 digit or 4 digit hex number (4 if greater than 255).

Parameters:
value - the value to convert
Returns:
2 or 4 digit hex representation

replaceAll

public static java.lang.String replaceAll(java.lang.String source,
                                          java.lang.String key,
                                          java.lang.String value)
This static method replaces all "key" in "source" with "value".

Parameters:
source - the string to substitute into
key - the target text to replace
value - the text to replace with
Returns:
the resulting string

padTo

public static java.lang.String padTo(java.lang.String s,
                                     int len)
This static method pads the given string to the given length by appending white-space to the end.

Parameters:
s - the string to pad
len - the required length
Returns:
the padded string

leadingZero

public static java.lang.String leadingZero(java.lang.String s,
                                           int len)
This static method pads a string with leading zeros.

Parameters:
s - the string to pad
len - the length of the string to pad to
Returns:
the padded string

collapseWhiteSpace

public static java.lang.String collapseWhiteSpace(java.lang.String s)
This static method collapses multiple white spaces into one white space. Tabs are also collapsed into white space.

Parameters:
s - the string to process
Returns:
the cleaned string

signedNumber

public static int signedNumber(int bits,
                               int value)
This static method converts an N-bit signed value to a true java signed value.

Parameters:
bits - number of bits in the value
value - the signed value
Returns:
the true java signed value

getDataString

public static java.lang.String getDataString(int[] data)
This method produces a string of hex bytes for the given byte array.

Parameters:
data - the byte array
Returns:
the string representation

parseIntValue

public static int parseIntValue(java.lang.String s)
This method parses an integer value from the given string accounting for base specification.

Parameters:
s - the string to parse
Returns:
the int value