title: Inline assembly statements in C code and extended ASM for ARM Cortex architectures
body: <p>I am trying to compile the following two pieces of code with <strong>ARM Compiler 5</strong> for a Cortex A microprocessor:</p>
  <p><strong>Part 1</strong>:</p>
  <pre><code>static inline void cp15_write_sctlr(uint32_t value)
  {
      asm(&quot;mcr p15, 0, %0, c1, c0, 0&quot; :: &quot;r&quot;(value));
  }
  
  static inline uint32_t cp15_read_actlr(void)
  {
      uint32_t actlr;
      asm(&quot;mrc p15, 0, %0, c1, c0, 1&quot; : &quot;=r&quot;(actlr));
      return actlr;
  }
  </code></pre>
  <p><strong>Part 2</strong>:</p>
  <pre><code>static inline void dmb(void)
  {
      asm(&quot;dmb&quot; ::: &quot;memory&quot;);
  }
  
  static inline void dsb(void)
  {
      asm(&quot;dsb&quot; ::: &quot;memory&quot;);
  }
  
  static inline void isb(void)
  {
      asm(&quot;isb&quot; ::: &quot;memory&quot;);
  }
  </code></pre>
  <p>In both cases I get compile errors. See below, as an example.</p>
  <pre><code>line 64: Error:  #18: expected a &quot;)&quot;
      asm(&quot;dsb&quot; ::: &quot;memory&quot;);
  </code></pre>
  <p>Are the error caused by the compiler version (ARM compiler 5), which does not support Extended Asm?</p>
  <p>If I re-write the code in <strong>Part 1</strong> as follows, I do not get any error. Is the following code equivalent to that in Part 1?</p>
  <pre><code>static inline void cp15_write_sctlr(uint32_t value)
  {
      __asm
      {
          MCR p15, 0, value, c1, c0, 0
      }
  }
  
  static inline uint32_t cp15_read_actlr(void)
  {
      uint32_t actlr;
      __asm
      {
          MRC p15, 0, actlr, c1, c0, 1
      }
      return actlr;
  }
  </code></pre>
  <p>How could I rewrite the code in Part 2, if the compiler does not support extended Asm?
  I have in mind the following, but I am not sure it is the same.</p>
  <pre><code>static inline void dmb(void)
  {
      __schedule_barrier();
      __asm(&quot;dmb&quot;);
      __schedule_barrier();
  }
  
  static inline void dsb(void)
  {
      __schedule_barrier();
      __asm(&quot;dsb&quot;);
      __schedule_barrier();
  }
  
  static inline void isb(void)
  {
      __schedule_barrier();
      __asm(&quot;isb&quot;);
      __schedule_barrier();
  }
  </code></pre>
  <p>Any help would be really appreciated.</p>