diff options
Diffstat (limited to 'C/BraIA64.c')
-rw-r--r-- | C/BraIA64.c | 57 |
1 files changed, 9 insertions, 48 deletions
diff --git a/C/BraIA64.c b/C/BraIA64.c index d1dbc62..9dfe3e2 100644 --- a/C/BraIA64.c +++ b/C/BraIA64.c | |||
@@ -1,53 +1,14 @@ | |||
1 | /* BraIA64.c -- Converter for IA-64 code | 1 | /* BraIA64.c -- Converter for IA-64 code |
2 | 2017-01-26 : Igor Pavlov : Public domain */ | 2 | 2023-02-20 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
5 | 5 | ||
6 | #include "CpuArch.h" | 6 | // the code was moved to Bra.c |
7 | #include "Bra.h" | ||
8 | 7 | ||
9 | SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) | 8 | #ifdef _MSC_VER |
10 | { | 9 | #pragma warning(disable : 4206) // nonstandard extension used : translation unit is empty |
11 | SizeT i; | 10 | #endif |
12 | if (size < 16) | 11 | |
13 | return 0; | 12 | #if defined(__clang__) |
14 | size -= 16; | 13 | #pragma GCC diagnostic ignored "-Wempty-translation-unit" |
15 | i = 0; | 14 | #endif |
16 | do | ||
17 | { | ||
18 | unsigned m = ((UInt32)0x334B0000 >> (data[i] & 0x1E)) & 3; | ||
19 | if (m) | ||
20 | { | ||
21 | m++; | ||
22 | do | ||
23 | { | ||
24 | Byte *p = data + (i + (size_t)m * 5 - 8); | ||
25 | if (((p[3] >> m) & 15) == 5 | ||
26 | && (((p[-1] | ((UInt32)p[0] << 8)) >> m) & 0x70) == 0) | ||
27 | { | ||
28 | unsigned raw = GetUi32(p); | ||
29 | unsigned v = raw >> m; | ||
30 | v = (v & 0xFFFFF) | ((v & (1 << 23)) >> 3); | ||
31 | |||
32 | v <<= 4; | ||
33 | if (encoding) | ||
34 | v += ip + (UInt32)i; | ||
35 | else | ||
36 | v -= ip + (UInt32)i; | ||
37 | v >>= 4; | ||
38 | |||
39 | v &= 0x1FFFFF; | ||
40 | v += 0x700000; | ||
41 | v &= 0x8FFFFF; | ||
42 | raw &= ~((UInt32)0x8FFFFF << m); | ||
43 | raw |= (v << m); | ||
44 | SetUi32(p, raw); | ||
45 | } | ||
46 | } | ||
47 | while (++m <= 4); | ||
48 | } | ||
49 | i += 16; | ||
50 | } | ||
51 | while (i <= size); | ||
52 | return i; | ||
53 | } | ||