G
go2u
Unregistered / Unconfirmed
GUEST, unregistred user!
function StrCopy(Dest: PChar; const Source: PChar): PChar;<br>asm<br> PUSH EDI<br> PUSH ESI<br> MOV ESI,EAX<br> MOV EDI,EDX<br> MOV ECX,0FFFFFFFFH<br> XOR AL,AL<br> REPNE SCASB<br> NOT ECX<br> MOV EDI,ESI<br> MOV ESI,EDX<br> MOV EDX,ECX<br> MOV EAX,EDI<br> SHR ECX,2<br> REP MOVSD<br> MOV ECX,EDX<br> AND ECX,3<br> REP MOVSB<br> POP ESI<br> POP EDI<br>end;<br><br>function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: Cardinal): PChar; assembler;<br>asm<br> PUSH EDI<br> PUSH ESI<br> PUSH EBX<br> MOV ESI,EAX<br> MOV EDI,EDX<br> MOV EBX,ECX<br> XOR AL,AL<br> TEST ECX,ECX<br> JZ @@1<br> REPNE SCASB<br> JNE @@1<br> INC ECX<br>@@1: SUB EBX,ECX<br> MOV EDI,ESI<br> MOV ESI,EDX<br> MOV EDX,EDI<br> MOV ECX,EBX<br> SHR ECX,2<br> REP MOVSD<br> MOV ECX,EBX<br> AND ECX,3<br> REP MOVSB<br> STOSB<br> MOV EAX,EDX<br> POP EBX<br> POP ESI<br> POP EDI<br>end;<br><br>这两个函数,复制字符串时遇到NULL(#0)就停止复制了,请汇编高手改改。使复制遇到NULL也不停止复制,直到复制完成StrCopy ,或者到指定长度才停止复制StrLCopy。