title: ARM Assembly Local Labels
body: <p>I'm currently reading a <a href="http://wiki.osdev.org/Raspberry_Pi_Bare_Bones" rel="noreferrer">tutorial</a> on Raspberry Pi OS development and was wondering about the way local labels are used in this code snippet (GCC ARM Assembly):</p>
  
  <pre><code>    ...
      b       2f
  1:
      stmia   r4!, {r5-r8}
  2:
      cmp     r4, r9
      blo     1b
      ...
  </code></pre>
  
  <p>If you use <code>1:</code> as a label you have to specify either <code>f</code> or <code>b</code> after the jump instruction to make the assembler know in which direction the jump is aimed. As far as I know you could also use this:</p>
  
  <pre><code>    ...
      b       .2
  .1:
      stmia   r4!, {r5-r8}
  .2:
      cmp     r4, r9
      blo     .1
      ...
  </code></pre>
  
  <p>I think this option is a lot less confusing (local labels are also marked with a dot in x86 assembly), because there is no additional letter after the label reference. I have tested the resulting machine code and it's the same. So my questions:</p>
  
  <ul>
  <li><p>Why would you use the one variant over the other?</p></li>
  <li><p>Why is it necessary to specify the direction of the jump with either <code>f</code> or <code>b</code>?</p></li>
  </ul>