1 /* Bra.c -- Converters for RISC code
2 2017-04-04 : Igor Pavlov : Public domain */
9 SizeT
ARM_Convert(Byte
*data
, SizeT size
, UInt32 ip
, int encoding
)
31 UInt32 v
= GetUi32(p
- 4);
33 v
+= ip
+ (UInt32
)(p
- data
);
52 UInt32 v
= GetUi32(p
- 4);
54 v
-= ip
+ (UInt32
)(p
- data
);
64 SizeT
ARMT_Convert(Byte
*data
, SizeT size
, UInt32 ip
, int encoding
)
70 lim
= data
+ size
- 4;
86 if ((b3
& b1
) >= 0xF8)
92 + (((UInt32
)p
[1] & 0x7) << 8)
93 + (((UInt32
)p
[-2] << 11))
98 UInt32 cur
= (ip
+ (UInt32
)(p
- data
)) >> 1;
102 p
[-4] = (Byte
)(v
>> 11);
103 p
[-3] = (Byte
)(0xF0 | ((v
>> 19) & 0x7));
105 p
[-1] = (Byte
)(0xF8 | (v
>> 8));
121 if ((b3
& b1
) >= 0xF8)
127 + (((UInt32
)p
[1] & 0x7) << 8)
128 + (((UInt32
)p
[-2] << 11))
133 UInt32 cur
= (ip
+ (UInt32
)(p
- data
)) >> 1;
138 SetUi16(p - 4, (UInt16)(((v >> 11) & 0x7FF) | 0xF000));
139 SetUi16(p - 2, (UInt16)(v | 0xF800));
142 p
[-4] = (Byte
)(v
>> 11);
143 p
[-3] = (Byte
)(0xF0 | ((v
>> 19) & 0x7));
145 p
[-1] = (Byte
)(0xF8 | (v
>> 8));
151 SizeT
PPC_Convert(Byte
*data
, SizeT size
, UInt32 ip
, int encoding
)
167 /* if ((v & 0xFC000003) == 0x48000001) */
168 if ((p
[-4] & 0xFC) == 0x48 && (p
[-1] & 3) == 1)
172 UInt32 v
= GetBe32(p
- 4);
174 v
+= ip
+ (UInt32
)(p
- data
);
176 v
-= ip
+ (UInt32
)(p
- data
);
185 SizeT
SPARC_Convert(Byte
*data
, SizeT size
, UInt32 ip
, int encoding
)
203 m = v + ((UInt32)5 << 29);
204 m ^= (UInt32)7 << 29;
205 m += (UInt32)1 << 22;
206 if ((m & ((UInt32)0x1FF << 23)) == 0)
210 if ((p
[-4] == 0x40 && (p
[-3] & 0xC0) == 0) ||
211 (p
[-4] == 0x7F && (p
[-3] >= 0xC0)))
215 UInt32 v
= GetBe32(p
- 4);
218 v
+= ip
+ (UInt32
)(p
- data
);
220 v
-= ip
+ (UInt32
)(p
- data
);
223 v
-= (UInt32
)1 << 24;