![]() |
#2
东海一鱼2010-09-24 17:28
|

function CharPos(src:char; str:pchar):Integer;
var
n:Integer;
Label
Find,NotFind;
begin
n:=Length(str);
asm
cld;
lea edi, str;
mov al,src;
mov ecx,n;
repnz scasb;
jz Find;
mov result,-1;
jmp NotFind;
Find:
mov result,ecx;
NotFind:
end;
end;
调用:var
n:Integer;
Label
Find,NotFind;
begin
n:=Length(str);
asm
cld;
lea edi, str;
mov al,src;
mov ecx,n;
repnz scasb;
jz Find;
mov result,-1;
jmp NotFind;
Find:
mov result,ecx;
NotFind:
end;
end;
i:=CharPos('e', 'hello word');
ShowMessage(IntToStr(i));
结果却返回-1,请问问题出在哪了?ShowMessage(IntToStr(i));