I'm working on a STM32l475 micro-controller which runs a Cortex-M4 processor and ARM/Thumb instruction sets. I see (from objdump
) that there are beq.n
and bne.n
instructions generated in the binary of an ARM program (I added the -mthumb
flag when compile the program). However, I don't find these branch instructions in the latest ARMv7-M manual.
Can anyone tell me the reason? And what are the instructions available in the manual that are equivalent to these two branch instructions?
beq
and bne
are conditional branches; in other words, they are conditional versions of the unconditional branch b
. eq
and ne
are two different condition codes; they are described in section A7.3. beq
means branch if equal and bne
means branch if not equal.
The b
branch instruction has two different encodings in Thumb mode. The encoding you're seeing is probably encoding T1 described in section A7.7.12:
B<c> <label>
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 1 0 1 [-<cond>--] [--------imm8---------]
In this encoding, the condition code (like eq
or ne
) is encoded directly into the instruction, in bits 8-11. The disassembly from objdump displays the condition code in place of <c>
above. So using the condition code table in section A7.3, you would encode beq
as 11010000[imm8]
.