title: How read coprocessor registers in ARM architecture
body: <p>I'm trying to read CP15 coprocessor in the following System-on-chip</p>
  
  <p>Cortex A7 - ARMv7-A</p>
  
  <p>Below my snippet</p>
  
  <pre><code>void main (void)
  {
      unsigned int reg_value = 0;
      asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r"(reg_value) );
      printf("reg_value: %d", reg_value);
  }
  </code></pre>
  
  <p>I don't know if this is the correct way to read the coprocessor register but its compilation is completed without errors.
  The problem is arisen during its execution (the code is executed in root):</p>
  
  <pre><code>Illegal instruction
  </code></pre>
  
  <p>If I use gdb I obtain the following result:</p>
  
  <pre><code>   0x000086a0 &lt;+16&gt;:    str r3, [r11, #-40] ; 0x28
  =&gt; 0x000086a4 &lt;+20&gt;:    mrc 15, 0, r3, cr0, cr0, {0}
     0x000086a8 &lt;+24&gt;:    str r3, [r11, #-40] ; 0x28
  </code></pre>
  
  <p>Why I'm not able to read coprocessor registers? What's wrong with my code?</p>