title: LDR - Literal pool - ARM
body: <p>I know how to load an immediate value using the LDR instruction in ARM.</p>
  
  <p>For example:</p>
  
  <p><code>LDR R0,=0x0804c088</code>
  This instruction loads the value (<code>0x0804c088</code>) to the register <code>r0</code>. When I try to access the address it is stored in using <code>x/x $r0</code> using <code>gdb</code>. I get the message: <code>Cannot access memory at address</code>0x0804c088<code></code>. But that is not the address, it is the value stored in that register and the address is a <code>PC</code> relative address which is stored in the literal pool.</p>
  
  <p>What is the mistake that I doing there? did I understand something wrong there?</p>
  
  <p>Moreover, How should I set the literal pool, can you give me an example please?</p>
  
  <p>@Carl Norum: Here is the code.</p>
  
  <pre><code>__asm__("LDR R0,=0x0804c088");
  __asm__("LDR R1,[PC, #34];");
  </code></pre>
  
  <p>O/p from gdb</p>
  
  <pre><code>(gdb) info registers
  r0             0x804c088        134529160
  r1             0xf2c00300       4072669952
  r2             0x0      0
  r3             0x1      1
  r4             0x8961   35169
  r5             0x0      0
  r6             0x0      0
  r7             0xbe8f4b74       3197062004
  r8             0x0      0
  r9             0xef99   61337
  r10            0xf00d   61453
  r11            0x0      0
  r12            0x0      0
  sp             0xbe8f4b74       0xbe8f4b74
  lr             0x89a7   35239
  pc             0x8a62   0x8a62 &lt;test46+34&gt;
  cpsr           0x60000030       1610612784
  (gdb) x/x $r0
  0x804c088:      Cannot access memory at address 0x804c088
  (gdb) p/x$r0
  $1 = 0x804c088
  (gdb) p/x $r1
  $2 = 0xf2c00300
  (gdb) x/x $r1
  0xf2c00300:     Cannot access memory at address 0xf2c00300
  (gdb) x/x $r15
  0x8a62 &lt;test46+34&gt;:     0x1022f8df
  </code></pre>