title: How can we check the register value in inline-assembly in c?
body: <p>I'd like to simple inline assembly experiment in uVision with STM32F as the below code.</p>
  
  <p>But I'v got a some problem with error message when I compile it.</p>
  
  <pre><code>unsigned int bar(unsigned int r0)
  
  {
    unsigned int r1;
    unsigned int r4 = 1234;
  __asm
  {
  
  
      MOVS  r0,#0
      LDR   r1,[r0]     ; Get initial MSP value
      MOV   SP, r1
      LDR   r1,[r0, #4] ; Get initial PC value
      BX    r1
  }
  
    return(r1);
  
  }
  </code></pre>
  
  <p>I've got the below error messages when I compile it as the below.</p>
  
  <pre><code>*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
  Build target 'STM32F429_439xx'
  compiling main.c...
  ../main.c(79): error:  #3061: unrecognized instruction opcode
                                  LDR   r1,[r0]     ; Get initial MSP value
  ../main.c(80): error:  #20: identifier "SP" is undefined
                                  MOV   SP, r1
  ../main.c(81): error:  #3061: unrecognized instruction opcode
                                  LDR   r1,[r0, #4] ; Get initial PC value
  ../main.c(82): error:  #1084: This instruction not permitted in inline assembler
                                  BX    r1
  ../main.c(71): warning:  #177-D: variable "r4"  was declared but never referenced
      unsigned int r4 = 1234;
  ../main.c(82): error:  #114: label "r1"  was referenced but not defined
                                  BX    r1
  ../main.c: 1 warning, 5 errors
  "STM32F429_439xx\STM32F429_439xx.axf" - 5 Error(s), 1 Warning(s).
  Target not created.
  Build Time Elapsed:  00:00:01
  </code></pre>
  
  <p>What am I supposed to do to resolve this problem?</p>