assembler functions in MCUXpresso

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

assembler functions in MCUXpresso

2,693 次查看
drsmith_yorku
Contributor III

I'm trying to adapt some teaching material (ARM university program) for the KL25Z that contains assembler functions in it.  While it probably worked in Keil, it's giving me syntax errors in MCUXpresso (10.2).  MCUXpresso generates a syntax error on the first line of the function (__asm void...). Is there a recommended way to write assembler functions like this using MCUXpresso?

#include <MKL25Z4.H>
__asm void my_strcpy(const char *src, char *dst)
{
   [not including contents of the function]
 
     BX    lr    ; Else return from subroutine
}
__asm void my_capitalize(char *str)
{
   [not including contents of the function]
      BX    lr    ; Else return from subroutine
}
int main(void)
{
    const char a[] = "Hello world!";
    char b[20];
  my_strcpy (a, b);
  my_capitalize(b);
 
  while (1)
   ;
}
2 回复数

2,267 次查看
BlackNight
NXP Employee
NXP Employee

MCUXpresso uses the standard GNU assembler syntax, see

ARM GCC Inline Assembler Cookbook 

Your example would be written something like this:

void my_strcpy(const char *src, char *dst)
{
  // [not including contents of the function]
    __asm volatile(
       "BX    lr\n" //    ; Else return from subroutine
     );
}

I hope this helps,

Erich

2,267 次查看
drsmith_yorku
Contributor III

Thanks Erich!

That's a great reference.  I'll be referring to that a lot, I think!

all the best,

James

0 项奖励
回复