Class DecodingStrategy


  • public class DecodingStrategy
    extends java.lang.Object
    Constant-decoding strategies. It is used in Edigen specification files for decoding numbers then used in disassembler.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] absolute​(byte[] value)
      Make the absolute value from the number stored in two's complement.
      static byte[] reverseBits​(byte[] value)
      Reverses bits in each byte.
      static byte[] reverseBytes​(byte[] value)
      Reverses the bytes.
      static byte[] shiftLeft​(byte[] value)
      Shift the byte array to the left.
      static byte[] shiftRight​(byte[] value)
      Shift the byte array to the right.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DecodingStrategy

        public DecodingStrategy()
    • Method Detail

      • reverseBytes

        public static byte[] reverseBytes​(byte[] value)
        Reverses the bytes.
        Parameters:
        value - array of bytes
        Returns:
        reversed array of bytes
      • reverseBits

        public static byte[] reverseBits​(byte[] value)
        Reverses bits in each byte. However, order of bytes is kept.
        Parameters:
        value - array of bytes
        Returns:
        array of bytes with bits reversed
      • absolute

        public static byte[] absolute​(byte[] value)
        Make the absolute value from the number stored in two's complement. If the number is already positive, it is kept as-is.
        Parameters:
        value - array of bytes representing the two's complement number
        Returns:
        absolute value (two's complement is removed) - the negative sign is lost
      • shiftLeft

        public static byte[] shiftLeft​(byte[] value)
        Shift the byte array to the left. It is assumed that the bytes are stored as big-endian. The shifting operation does as follows: If we have bytes [0x1, 0x2] (memory positions [0]=0x1, [1]=0x2), then the result will be [0x2, 0x4].
        Parameters:
        value - array of bytes
        Returns:
        byte array shifted by 1 bit to the left
      • shiftRight

        public static byte[] shiftRight​(byte[] value)
        Shift the byte array to the right. It is assumed that the bytes are stored as big-endian. The shifting operation does as follows: If we have bytes [0x1, 0x2] (memory positions [0]=0x1, [1]=0x2), then the result will be [0x0, 0x81].
        Parameters:
        value - array of bytes
        Returns:
        byte array shifted by 1 bit to the right