High level languages have constructs like if-then, if-then-else, while-do, do-while, and even functions definition, function calling.
Assembly language does not have any of these high level forms directly but they can all be had with an equivalent pattern using assembly's if-goto-label form.
Also in assembly language, labels do not execute or change the flow of control. Only branch instructions can change the flow of control, so otherwise just sequential execution. Normal sequential control flow will automatically go right through a label since they don't actually exist in the machine code.
Note that in high level languages, we also have sequential execution, here though of language statements not assembly instructions.
For example, the if-then-else statement may be in a larger context like:
if ( condition ) { <then-part...> } else { <else-part...> }
<some following statement...>
And here no matter whether the then-part or the else-part executes, upon completion of the if-statement we expect the following statement to execute next.
We expect the same from an if-then-else in assembly, that (1) only one of the then-part or else-part executes, and (2) that after the whole if statement is done (whether by running the then-part or the else-part) the next sequential statement after is whats run after.
The pattern for if-then-else such as this:
if ( <condition...> ) {
<then-part...>
}
else {
<else-part...>
}
Translated to if-goto-label looks like this:
if <condition...> is not true goto elsePart;
<then-part...>
goto endOfIf; // this skips around the else part to go on to the next
// statement at the same level of and sequentially after the if
elsePart:
<else-part...>
endOfIf:
Yes, this pattern ends with a label! But that label is more logically part of the if-then-else translation into if-goto-label, rather than having to do with the code following the if statement.
Let's also note that in this translation pattern, whereas the then-part does need to finish with a goto endOfIf; (because when the then-part executes we must preclude the else-part), yet the else-part does not, since it will fall through the label by sequential execution, and that's where we expect the code for the next sequential statement to be located. (When the else-part executes, the then-part has already been skipped by the condition's branching. Thus, only either the then-part or else the else-part will execute.)
For each separate if-statement we have, we need to use its own unique labels for its translation to if-goto-label form. (Some assembly languages have some features to reduce the number of new labels needed by these patterns.) However, given that these patterns both nest and follow logically.
There are many possible variation, though the above is common. We can reverse the order of then and else parts, if we also reverse the condition test (test for true instead of not true).
We can move the then part and the else part far away from each other, and then you might need the goto endOfIf after both the then part and the elsePart (or could eliminate one or the other).
Such is the flexibility of assembly that high level languages don't have (thankfully!).
BRK, but rather another jump to skip the following LDA. Basically, as most instructions execute one after another,BCSskips over the "else" code path; but the "else" code path at its end typically has to skip over the "then" code path.