mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Utilities to convert textual presentation of memory to bytes.
This commit is contained in:
parent
b8a4d37318
commit
23529181b2
2 changed files with 31 additions and 0 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2002-10-25 Mikhail Khodjaiants
|
||||||
|
* CDebugUtils.java: Added utilities to convert textual presentation of memory to bytes.
|
||||||
|
|
||||||
2002-10-25 Mikhail Khodjaiants
|
2002-10-25 Mikhail Khodjaiants
|
||||||
* IFormattedMemoryBlock.java: Replaced 'MEMORY_BYTES_PER_ROW_...' constants by 'MEMORY_NUMBER_OF_COLUMNS_...'.
|
* IFormattedMemoryBlock.java: Replaced 'MEMORY_BYTES_PER_ROW_...' constants by 'MEMORY_NUMBER_OF_COLUMNS_...'.
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,17 @@ public class CDebugUtils
|
||||||
charFromByte( (byte)(b & 0x0f) ) };
|
charFromByte( (byte)(b & 0x0f) ) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte textToByte( char[] text )
|
||||||
|
{
|
||||||
|
byte result = 0;
|
||||||
|
if ( text.length == 2 )
|
||||||
|
{
|
||||||
|
byte[] bytes = { charToByte( text[0] ), charToByte( text[1] ) };
|
||||||
|
result = (byte)((bytes[0] << 4) + bytes[1]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static char charFromByte( byte value )
|
public static char charFromByte( byte value )
|
||||||
{
|
{
|
||||||
if ( value >= 0x0 && value <= 0x9 )
|
if ( value >= 0x0 && value <= 0x9 )
|
||||||
|
@ -93,6 +104,23 @@ public class CDebugUtils
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte charToByte( char ch )
|
||||||
|
{
|
||||||
|
if ( Character.isDigit( ch ) )
|
||||||
|
{
|
||||||
|
return (byte)(ch - '0');
|
||||||
|
}
|
||||||
|
if ( ch >= 'a' && ch <= 'f' )
|
||||||
|
{
|
||||||
|
return (byte)(0xa + ch - 'a');
|
||||||
|
}
|
||||||
|
if ( ch >= 'A' && ch <= 'F' )
|
||||||
|
{
|
||||||
|
return (byte)(0xa + ch - 'A');
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static char bytesToChar( byte[] bytes )
|
public static char bytesToChar( byte[] bytes )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Reference in a new issue