BL (immediate)

A32: branch, branch with link, and block data transfer

fixed bit field field the encoding fixes should be

A1

313029282726252423222120191817161514131211109876543210
cond1011imm24

xxxx1011xxxxxxxxxxxxxxxxxxxxxxxx
cond != 1111

Decode Sail

if ConditionPassed() then {
    assert(cond != 0b1111);
    let imm32 : bits(32) = SignExtend(imm24 @ 0b00, 32);
    let targetInstrSet : InstrSet = InstrSet_A32;
    execute_aarch32_instrs_BL_i_Op_A_txt(imm32, targetInstrSet)
};
()

A2

313029282726252423222120191817161514131211109876543210
1111101Himm24

1111101xxxxxxxxxxxxxxxxxxxxxxxxx

Decode Sail

if ConditionPassed() then {
    let imm32 : bits(32) = SignExtend((imm24 @ H) @ 0b0, 32);
    let targetInstrSet : InstrSet = InstrSet_T32;
    execute_aarch32_instrs_BL_i_Op_A_txt(imm32, targetInstrSet)
};
()

Operation Sail

if CurrentInstrSet() == InstrSet_A32 then {
    LR_write() = PC_read__1() - 4
} else {
    LR_write() = PC_read__1()[31 .. 1] @ 0b1
};
targetAddress : bits(32) = undefined;
if targetInstrSet == InstrSet_A32 then {
    targetAddress = Align(PC_read__1(), 4) + imm32
} else {
    targetAddress = PC_read__1() + imm32
};
SelectInstrSet(targetInstrSet);
BranchWritePC(targetAddress, BranchType_DIRCALL)

Made from ScarletNX's Sail at 166ad3910f80. sail-arm's definitions are Arm's ASL in Sail (BSD 3-Clause Clear, license); ScarletNX's fixups are GPL-3.0-or-later.