新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > Delphi:高效的哈希函数程序

Delphi:高效的哈希函数程序

作者:时间:2012-09-13来源:网络收藏


//begin
// Result := (Result * 131) + PByte(buf)^;
// Inc(PByte(buf));
// Dec(count);
//end;
end;
function DJBHash(buf: Pointer; count: Integer) : Cardinal; assembler;
asm
PUSHEDI
PUSHEBX
XOR EBX, EBX
MOV ECX, EAX
MOV EAX, 5381
@LOOP:
TESTEDX, EDX
JZ @EXIT
MOV EDI, EAX
SHL EDI, 5
ADD EAX, EDI
MOV BL, [ECX]
ADD EAX, EBX
INC ECX
DEC EDX
JMP @LOOP
@EXIT:
POP EBX
POP EDI
//----------------------------
// Pascal:
//
//Result := 5381;
//while count > 0 do
//begin
// Result := ((Result shl 5) + Result) + PByte(buf)^;
// Inc(PByte(buf));
// Dec(count);
//end;
end;

本文引用地址:http://www.eepw.com.cn/article/170867.htm

上一页 1 2 下一页

评论


相关推荐

技术专区

关闭