AREA SCopy, CODE, READONLY
EXPORT strcopy
strcopy
; r0 points to destination string
; r1 points to source string
LDRB r2, [r1],#1 ; load byte and update address
STRB r2, [r0],#1 ; store byte and update address;
CMP r2, #0 ; check for zero terminator
BNE strcopy ; keep going if not
MOV pc,lr ; Return
END
其实就是一个字符串拷贝函数,C 语言表示如下:
strcopy( char *sp1, char *sp2 )
{
while( *sp2 != '\0' )
{
*sp1 = *sp2;
sp1++;
sp2++;
}
}
strcopy( char *sp1, char *sp2 )
{
while( *sp2 != '\0' )
{
*sp1 = *sp2;
sp1++;
sp2++;
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2008-12-01
strcpy(char * dest,const char * src)
{
assert(dest!=NULL && src!=NULL);
while((*dest++=*src++)!='\0');
}
{
assert(dest!=NULL && src!=NULL);
while((*dest++=*src++)!='\0');
}
第2个回答 2008-12-01
一楼说的不错。