Can't build Processor Expert generated inline assembly code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't build Processor Expert generated inline assembly code

3,383 Views
codenoob
Contributor II

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.

0 Kudos
Reply
5 Replies

1,613 Views
vfilip
NXP Employee
NXP Employee

Hello,

it is probably misunderstanding of PEx concept of compiler support. The generated code is compiler specific according to selected compiler on Build Options tab in CPU component. In case it works for you under Keil I assume you have selected this compiler on Build Options tab (details attached). In case you need to change the Compiler please just change it accordingly in CPU component and re-generate the code.

best regards

Vojtech Filip

Processor Expert Support Team


0 Kudos
Reply

1,613 Views
litao
Contributor I

May I ask you a question?

when I  use MKL25Z128VLK4 to develop code of Assembler

I don't know the Assembly Language Syntax

Do you know which document to describe how to write the correct Assembly Language about Arm cortex-M0+

0 Kudos
Reply

1,613 Views
JimDon
Senior Contributor III

This is it:

DDI0419C_arm_architecture_v6m_reference_manual.pdf

Just google that and download it.

FWIW : ARM specifically states that ARM is not designed for ASM programming, and it is a bit odd, but doable.

Section A6.3 Lists all the instructions - note that GCC is a bit different.

Also use the disassembler

0 Kudos
Reply

1,613 Views
BlackNight
NXP Employee
NXP Employee

Have a look here:

ARM GCC Inline Assembler Cookbook

Or simply 'google' with

gcc inline assembly arm syntax

:-)

0 Kudos
Reply

1,613 Views
codenoob
Contributor II

Thanks Vojtech. I fixed my program after your advice.

0 Kudos
Reply