Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[arm-gnu] Inline Assembly routine


  • To: arm-gnu@xxxxxxxxxxxxxxxx, arm-gnu-help@xxxxxxxxxxxxxxxx
  • Subject: [arm-gnu] Inline Assembly routine
  • From: Rachit shah <rachit81@xxxxxxxxx>
  • Date: Fri, 19 Jun 2009 15:50:41 +0530

Hello,



I have created sample code for Inline assembly routine as per attachment. I
am checking this sample code on OMAP3530.



When I tried to write “MOV pc, lr” or “BX lr” to come out from routine then
it’s not working ( I have written comment in attached file).

It’s working fine if I use “return;” syntax.



I am compiling with  "arm-none-linux-gnueabi-gcc  test.c"  option so is it
require to add more option?



What will be reason of this? What is other way to do this?






Thanks,
Rachit Shah
+91 99250 28064
#include <stdio.h>
void my_strcpy(const char *src,const char *dst){
asm(
"loop:\n\t"
"LDRB r3,[r0],#1\n\t"
"STRB r3,[r1],#1\n\t"
"CMP r3, #0\n\t"
"BNE loop\n\t"
/*"MOV pc, lr\n\t"*/ /*when this used instead of "return;" statement,this is not working, program didn't come out from execution*/
/*"BX lr\n\t"*//*when this used instead of "return;" statement,this is not working,program didn't give output just came out from execution*/
);
return;//this will work
}
int main(void){
const char *a = "Hello world!";
char b[20];
printf("Original string:%s\n",a);
my_strcpy(a,b);
printf("Copied string:%s\n",b);
return 0;
}