#include <stdio.h>
void my_strcpy(char *src,const char *dst)
{
char ch;
__asm__ __volatile__(
"loop:/n/t"
"ldrb %2,[%0],#1/n/t"
"strb %2,[%1],#1/n/t"
"cmp %2,#0/n/t"
"bne loop"
:
:"r"(src),"r"(dst),"r"(ch)
);
}
int main(void)
{
const char *a="Hello world!";
char b[20];
__asm__ __volatile__(
"mov r0,%0/n/t"
"mov r1,%1/n/t"
"bl my_strcpy/n/t"
:
:"r"(a),"r"(b)
);
printf("Original string:%s/n",a);
printf("Copied string:%s/n",b);
return 0;
}
arm-linux-gcc-4.3.2 strcpy.c