- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi StrLenWide 汇编统计字符串长度
function StrLenWide(const Str: PWideChar): Cardinal;
asm
{Check the first byte}
cmp word ptr [eax], 0
je @ZeroLength
{Get the negative of the string start in edx}
mov edx, eax
neg edx
@ScanLoop:
mov cx, [eax]
add eax, 2
test cx, cx
jnz @ScanLoop
lea eax, [eax + edx - 2]
shr eax, 1
ret
@ZeroLength:
xor eax, eax
end;