BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / linux / linux-2.6 / scripts / squashfs / lzma / C / 7zip / Compress / Branch / BranchARMThumb.c
blob6d0f5ba1aa2c13808c569f615e38f14ab6b4477c
1 // BranchARMThumb.c
3 #include "BranchARMThumb.h"
5 UInt32 ARMThumb_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
7 UInt32 i;
8 for (i = 0; i + 4 <= size; i += 2)
10 if ((data[i + 1] & 0xF8) == 0xF0 &&
11 (data[i + 3] & 0xF8) == 0xF8)
13 UInt32 src =
14 ((data[i + 1] & 0x7) << 19) |
15 (data[i + 0] << 11) |
16 ((data[i + 3] & 0x7) << 8) |
17 (data[i + 2]);
19 src <<= 1;
20 UInt32 dest;
21 if (encoding)
22 dest = nowPos + i + 4 + src;
23 else
24 dest = src - (nowPos + i + 4);
25 dest >>= 1;
27 data[i + 1] = 0xF0 | ((dest >> 19) & 0x7);
28 data[i + 0] = (dest >> 11);
29 data[i + 3] = 0xF8 | ((dest >> 8) & 0x7);
30 data[i + 2] = (dest);
31 i += 2;
34 return i;