_asm directive in KDS

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

_asm directive in KDS

1,309 次查看
frankbannon
Contributor II

Hi everyone,

 

I am a noob with KDS and Kinetis MCU's.

I imported "hello world" examples for the FRDMKL26Z board and I am compiling.  I get a build error with the auto generated "Statup.c" code.  The complier is expecting an add'l "(" in the ASM directive, see below.

It appears that the statup.c code was imported from Keil and not specific to KDS and KDS doesn't like the syntax.  Any thoughts?

 

 

__asm void __thumb_startup(void)

 

{

 

  IMPORT __init_hardware

 

  IMPORT __main

 

  LDR R0, =__init_hardware

 

  BLX R0

 

  LDR R0, =__main

 

  BX R0

 

  ALIGN 4

 

}

 

标签 (1)
标记 (2)
3 回复数

1,112 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Frank,

the syntax is for ARM C compiler.

__asm void __thumb_startup(void)

{ <assembly code>}

  if use GNU C compiler, use this syntax, for example:

__asm (

        "mov    r0,%0\n\t"

        "cmp    r0,#0\n\t"

        "beq    skip_sp\n\t"

        "mov    sp,r0\n\t"

        "sub    sp,#4\n\t"

        "mov    r0,#0\n\t"

        "mvn    r0,r0\n\t"

        "str    r0,[sp,#0]\n\t"

        "add    sp,#4\n\t"

        "skip_sp:\n\t"

        ::"r"(addr));


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,112 次查看
ivadorazinova
NXP Employee
NXP Employee

Hi Frank Bannon,


please, where you get the example Hello World for KL26Z?

Do you work with KSDK V1.1 ?


Best Regards,

Iva

0 项奖励
回复

1,112 次查看
frankbannon
Contributor II

Iva,

I am using KDS2.0

I got the example code from the FRDMKL26 sample code.  It is a CW project.

Frank

0 项奖励
回复