assembler functions in MCUXpresso

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

assembler functions in MCUXpresso

3,042件の閲覧回数
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,616件の閲覧回数
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,616件の閲覧回数
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 件の賞賛
返信