AnsweredAssumed Answered

Can't build Processor Expert generated inline assembly code

Question asked by codenoob on Mar 12, 2013
Latest reply on Mar 22, 2013 by Jim Donelson

I am trying to use Processor Expert to generate project and develop it under Keil. But I can't get the generated code compiled by either GCC compiler or ARM compiler. What compilers should I use, or is there a special configuration I should do to make them compilable? I am not very familiar with inline assembly code....

 

I am quite new to this area. I would appreciate any help.

 

For example, this piece of code, which simply waits for 10 CPU cycles,

 

  /* This function will wait 10 CPU cycles (including call overhead). */
  asm {
                                             /* NOTE: this is not really accurate, as not sure yet about the cycle counts */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
    nop                                      /* assuming one cycle for nop */
  }

 

ARM compiler complains

./Generated_Code/WAIT1.c(51): error:  #20: identifier "asm" is undefined

While GCC compiler complains

./Generated_Code/WAIT1.c(51): error: expected '(' before '{' token

./Generated_Code/WAIT1.c(53): error: unknown type name 'nop'

./Generated_Code/WAIT1.c(55): error: expected '=', ',', ';', 'asm' or '__attribute__' before 'nop'

 

And this piece of code

__asm void Cpu_EnterCritical(volatile uint8_t *SR_reg) {
  PUSH {R0,R1}
  MRS R1, PRIMASK
  CPSID i
  STRB R1, [R0]
  POP {R0,R1}
  BX  LR
  ALIGN 4
}

 

gives this error in GCC compiler

./Generated_Code/Cpu.c(132): error: expected '(' before 'void'

ARM compiler didn't complain anything, but it might just be that it halted before it.

 

 

 

 

Outcomes