Formatting.

This commit is contained in:
Christian Speckner 2024-07-11 21:35:05 +02:00
parent bfaeea96f6
commit 4f4f4d5a0d
1 changed files with 14 additions and 14 deletions

View File

@ -38,21 +38,21 @@ Int32 elfUtil::decode_B_BL(uInt32 opcode)
return offset;
}
uInt32 elfUtil::encode_B_BL(Int32 offset, bool link)
{
// nomenclature follows Thumb32 BL / B.W encoding in Arm Architecture Reference
uInt32 elfUtil::encode_B_BL(Int32 offset, bool link)
{
// nomenclature follows Thumb32 BL / B.W encoding in Arm Architecture Reference
offset >>= 1;
offset >>= 1;
uInt8 s = (offset >> 23) & 0x01;
uInt8 j2 = ((~offset >> 22) ^ s) & 0x01;
uInt8 j1 = ((~offset >> 21) ^ s) & 0x01;
uInt32 imm11 = offset & 0x7ff;
uInt32 imm10 = (offset >> 11) & 0x3ff;
uInt8 s = (offset >> 23) & 0x01;
uInt8 j2 = ((~offset >> 22) ^ s) & 0x01;
uInt8 j1 = ((~offset >> 21) ^ s) & 0x01;
uInt32 imm11 = offset & 0x7ff;
uInt32 imm10 = (offset >> 11) & 0x3ff;
uInt16 hw1 = 0xf000 | (s << 10) | imm10;
uInt16 hw2 = 0x9000 | (j1 << 13) | (j2 << 11) | imm11;
if (link) hw2 |= 0x4000;
uInt16 hw1 = 0xf000 | (s << 10) | imm10;
uInt16 hw2 = 0x9000 | (j1 << 13) | (j2 << 11) | imm11;
if (link) hw2 |= 0x4000;
return hw1 | (hw2 << 16);
}
return hw1 | (hw2 << 16);
}