title: What is the difference between =label (equals sign) and [label] (brackets) in ARMv6 assembly?
body: <p>I'm following along with the <a href="http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok05.html" rel="noreferrer">Baking Pi</a> course from Cambridge University, in which a simple operating system is built in the ARMv6 instruction set, targeting the Raspberry Pi.</p>
  
  <p>We've been using two ways of loading data into registers via the <code>ldr</code> instruction so far and I realize now that I'm using them together, I don't fully understand what they both do.</p>
  
  <p>So I've used things like <code>ldr r0,=0x20200000</code>, which I actually understood as "read the data stored at the memory location 0x20200000 into register r0.</p>
  
  <p>Then I've used things like:</p>
  
  <pre><code>ldr r0,[r1,#4]
  </code></pre>
  
  <p>Which I've understood as being "read the data stored at the memory address pointed to by r1, at an offset of 4 bytes, into register r0".</p>
  
  <p>Then I encounter this:</p>
  
  <pre><code>ldr r0,=pattern
  ldr r0,[r0]
  </code></pre>
  
  <p><code>pattern</code> here is a <code>.int</code> in the <code>.data</code> section (a bitmap representing a sequence of on/off states for an LED). I realize upon reading this, that my previous understanding of <code>=foo</code> must be wrong, otherwise both of the above instructions would do the same thing.</p>
  
  <p>Is the <code>=x</code> syntax basically more like a pointer in C, while the <code>[x]</code> syntax is as if the memory that is being pointed to by <code>x</code> is actually read?</p>
  
  <p>Let's say <code>ptr</code> in the C below is an <code>int*</code>, do my comments thinking about equivalent assembly (conceptually, not literally) make any sense?</p>
  
  <pre><code>r0 = ptr;     /* equivalent to: ldr r0,=ptr     */
  r0 = *ptr;    /* equivalent to: ldr r0,[ptr]    */
  r0 = *(ptr+4) /* equivalent to: ldr r0,[ptr,#4] */
  </code></pre>