汇编与C语言混合编制实验

//汇编与C语言混合编制实验
//c程序
#include <stdio.h>
void strcopy(char *src,const char *dst)
{
 int ch;

__asm
{
 loop:
  LDRB ch,[src],#1;将src中的字数据写入到变量ch中,并将新地址src+1写入src中。
  STRB ch,[dst],#1
  CMP  ch,#0;
  BNE  loop
}
}

int main(void)
{
 const char *a="Hello world!";
 char b[20];

 __asm
 {
  MOV  R0,a//地址赋值
  MOV  R1,b//数组地址赋值
  BL  strcopy,{R0,R1}//带返回跳转指令
 }

 printf("The original string is %s\n",a);
 printf("The copied string is %s\n",b);
 return 0;
}

 

posted @ 2011-12-07 22:18  [无名]  阅读(329)  评论(0编辑  收藏  举报