Package com.jugubell.bproccli.utils
Class Utils
java.lang.Object
com.jugubell.bproccli.utils.Utils
Static class utility class for various tasks
- Author:
- Jugurtha Bellagh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PathTypeGets the path type according to the custom path types defined in the enumerationPathTypestatic PathTypestatic StringcleanLabel(String str) Cleans the label by removing the ':'static StringgetDataAddress(String data) Returns the address of a given data declaration annotated with .data syntax UsestrimAddress(String)to trim the address.static intgetDataAddressInt(String data) Returns the address in integer of a given data declaration annotated with .data syntax.static StringgetDataData(String data) Returns the data of a given data declaration annotated with .data syntax UsestrimAddress(String)to trim the data.static StringgetLabelFromJmp(String str) Gets the pointed label by the JMP instructionhexFile2binFile(List<String> file) Converts a file hex content to a binary format.static booleanis12bitsHexData(String hex) Checks if a string a 12 bits hexadecimal number Accepts prefix: 0x, 0X Accepts suffix: h, Hstatic booleanis16bitsHexData(String hex) Checks if a string a 16 bits hexadecimal number Accepts prefix: 0x, 0X Accepts suffix: h, Hstatic booleanisIndirect(String str) Checks if an address is in indirect mode by checking ig the address is wrapped in [] Only 12bits address allowed It usesis12bitsHexData(String)static booleanisValidHexNumber(String str) Method checking a validity of a string as hexadecimal numberstatic booleanChecks if the system is not Windows for use inLogwithConsoleColorstatic StringtrimAddress(String address) Trims and address from suffix, prefix, and indirect [] annotation
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
isValidHexNumber
Method checking a validity of a string as hexadecimal number- Parameters:
str- hex number asString- Returns:
- boolean true if hex number is valid
-
isIndirect
Checks if an address is in indirect mode by checking ig the address is wrapped in [] Only 12bits address allowed It usesis12bitsHexData(String)- Parameters:
str- address asString- Returns:
- boolean true if it is wrapped in []
-
is16bitsHexData
Checks if a string a 16 bits hexadecimal number Accepts prefix: 0x, 0X Accepts suffix: h, H- Parameters:
hex- the hexadecimal number- Returns:
- boolean true if it is a 16 bits hexadecimal number
-
is12bitsHexData
Checks if a string a 12 bits hexadecimal number Accepts prefix: 0x, 0X Accepts suffix: h, H- Parameters:
hex- the hexadecimal number- Returns:
- boolean true if it is a 12 bits hexadecimal number
-
getDataAddress
Returns the address of a given data declaration annotated with .data syntax UsestrimAddress(String)to trim the address.- Parameters:
data- the data line asString- Returns:
- the address as
String
-
getDataData
Returns the data of a given data declaration annotated with .data syntax UsestrimAddress(String)to trim the data.- Parameters:
data- the data line asString- Returns:
- the data as
String
-
trimAddress
Trims and address from suffix, prefix, and indirect [] annotation- Parameters:
address- the address to be trimmed asString- Returns:
- trimmed address as
String
-
getDataAddressInt
Returns the address in integer of a given data declaration annotated with .data syntax. UsesgetDataAddress(String)to get a clean address then converts it to an integer.- Parameters:
data- the data line asString- Returns:
- address in
int
-
cleanLabel
Cleans the label by removing the ':'- Parameters:
str- the label asString- Returns:
- clean label as
String
-
getLabelFromJmp
Gets the pointed label by the JMP instruction- Parameters:
str- the code line of the JMP instruction- Returns:
- the uppercased label as
String
-
checkPath
Gets the path type according to the custom path types defined in the enumerationPathType- Parameters:
pth- path to be checked asString- Returns:
- the path type as
PathType
-
checkPath
-
hexFile2binFile
Converts a file hex content to a binary format. Every line of the file content should be a hexadecimal number.- Parameters:
file- asListofString- Returns:
- a
ListofStringin binary format
-
supportsColor
public static boolean supportsColor()Checks if the system is not Windows for use inLogwithConsoleColor- Returns:
- boolean false if the system is Windows
-