/********************************************\
| 欢迎转载, 但请保留作者姓名和原文链接, 祝您进步并共勉! |
\********************************************/
常用C函的汇编实现(注: AT&T汇编)
作者: Jerry Cat
时间: 2006/06/07
链接: http://www.cppblog.com/jerysun0818/archive/2006/06/07/8253.html
//字符串拷贝
void strcpy(const char *src, char *dest)
{
char ch;
__asm
{
loop:
ldrb ch, [src], #1
strb ch, [dest], #1
cmp ch, #0
bne loop
}
}
//int转字符串
void I2S(int isource, char* desstr)
{
char ch, i=sizeof(isource)*2, temp = 0, is =0;
if(isource==0)
{
*desstr = '0';
*(desstr+1)=0;
return;
}
if(isource<0)
{
*desstr='-';
desstr++;
isource=-isource;
}
desstr--;
__asm
{
loop:
mov ch, #'0'
add ch, ch, isource, lsr#28
mov isource, isource, lsl#4
sub temp,ch, #'0'
orr is, temp, is
cmp is, #0
beq loop1
mov is, #0xFF
strb ch, [desstr,#1]!
loop1:
sub i, i, #1
cmp i, #0
bne loop
}
*(++desstr) = 0;
}
posted on 2006-06-07 18:11
Jerry Cat 阅读(551)
评论(0) 编辑 收藏 引用