C调用ARM字符串拷贝

纯arm拷贝 

AREA StrCopy, CODE, READONLY
 ENTRY
start
 LDR r1, =srcstr
 LDR r0, =dststr
 BL strcopy
stop
 MOV r0, #0x18
 LDR r1, =0x20026
 SWI 0x123456


strcopy
 LDRB r2, [r1],#1
 STRB r2, [r0],#1
 CMP r2, #0
 BNE strcopy
 MOV pc,lr
 AREA Strings, DATA, READWRITE
srcstr DCB "so",0
dststr DCB "de",0
 END

 

C调用ARM拷贝

main.c

  extern void stringcopy(char string1[],char string2[]);
  void __main (void)
  {
 char string1[100]="qiuzhangzhi";
 char string2[200]="";
 stringcopy(string1,string2);
 
  }

 

stringcopy.s

 export stringcopy
 AREA stringcopy, CODE, READONLY
 ENTRY
start
 LDRB r2, [r0],#1
 STRB r2, [r1],#1
 CMP  r2, #0
 BNE start
 MOV pc,lr
 end
 

 

Init.s

 EXTERN __main
 AREA stringcopy,code,readonly
 entry
 b __main
 end

你可能感兴趣的:(ARM)