关于scasb指令
我用delphi写了一段查找字符位置的内联汇编代码,如下:程序代码:
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;调用:
i:=CharPos('e', 'hello word'); ShowMessage(IntToStr(i));结果却返回-1,请问问题出在哪了?