Skip to content

Commit 6370b94

Browse files
simonpcookcmuellner
authored andcommitted
Rewrite the far branches section
During the latest Toolchain SIG meeting it was raised that this section does not make its intent and behavior clear enough. This rewords the prose to explain what is going on in more detail.
1 parent e609ecc commit 6370b94

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/asm-manual.adoc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,10 @@ as seen by `objdump`:
809809

810810
== Far Branches
811811

812-
The assembler will convert conditional branches into far branches when
813-
necessary, via inserting a short branch with inverted conditions past an
814-
unconditional jump. For example
812+
When a conditional branch cannot reach a destination, the assembler will replace
813+
these with far branches which use the longer offset available to unconditional
814+
jumps to reach the destination. This is done by inserting a short branch with
815+
inverted conditions past an unconditional jump. For example:
815816

816817
[source, asm]
817818
----
@@ -823,7 +824,12 @@ target:
823824
bne a0, a1, target
824825
----
825826

826-
ends up as
827+
This example uses a series of `nop`s to separate the final instruction from the
828+
branch target `target` such that the second `bne` instruction cannot reach it
829+
with its offset. As such a unconditional branch to the target is added and the
830+
original instruction replaced with a conditional branch with inverted conditions
831+
to jump over this new instruction. Consequently, the final assembled binary
832+
contains the following:
827833

828834
[source, asm]
829835
----

0 commit comments

Comments
 (0)