assembler functions in MCUXpresso

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

assembler functions in MCUXpresso

1,724 Views
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 Replies

1,298 Views
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

1,298 Views
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 Kudos