The B instruction in ARM is used to jump to a different part of the program without any condition. It changes the flow of execution by updating the program counter to a new address.
The 24-bit signed offset in the B instruction is shifted left by 2 bits (because instructions are 4 bytes), giving a range of ±32 MB (2^23 * 4 bytes).
B label, what happens to the program counter (PC) after this instruction executes?The B instruction updates the PC to the target label's address, causing the CPU to continue execution from that new location.
The BL (Branch with Link) instruction branches to a target address and saves the return address in the link register (LR), enabling function calls. The B instruction just branches without saving return info.
The offset field is limited to 24 bits. If the encoded offset is invalid or out of range, the CPU interprets the bits as a signed value, causing it to branch to an unintended address, which can lead to unpredictable program behavior.