<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > Delphi:高效的哈希函數(shù)

          Delphi:高效的哈希函數(shù)

          作者: 時(shí)間:2011-06-10 來(lái)源:網(wǎng)絡(luò) 收藏

          view plaincopy to clipboardprint?
          01.function BKDRHash(buf: Pointer; count: Integer) : Cardinal; assembler;
          02.asm
          03. PUSHEBX;
          04. XOR EBX, EBX
          05. MOV ECX, EAX
          06. XOR EAX, EAX
          07.@LOOP:
          08. TESTEDX, EDX
          09. JZ @EXIT
          10. MOV BL,[ECX]
          11. IMULEAX, 131
          12. ADD EAX, EBX
          13. INC ECX
          14. DEC EDX
          15. JMP @LOOP
          16.@EXIT:
          17. POP EBX
          18.//----------------------------
          19.// Pascal:
          20.//
          21.//Result := 0;
          22.//while count > 0 do
          23.//begin
          24.// Result := (Result * 131) + PByte(buf)^;
          25.// Inc(PByte(buf));
          26.// Dec(count);
          27.//end;
          28.end;
          29.function DJBHash(buf: Pointer; count: Integer) : Cardinal; assembler;
          30.asm
          31. PUSHEDI
          32. PUSHEBX
          33. XOR EBX, EBX
          34. MOV ECX, EAX
          35. MOV EAX, 5381
          36.@LOOP:
          37. TESTEDX, EDX
          38. JZ @EXIT
          39. MOV EDI, EAX
          40. SHL EDI, 5
          41. ADD EAX, EDI
          42. MOV BL, [ECX]
          43. ADD EAX, EBX
          44. INC ECX
          45. DEC EDX
          46. JMP @LOOP
          47.@EXIT:
          48. POP EBX
          49. POP EDI
          50.//----------------------------
          51.// Pascal:
          52.//
          53.//Result := 5381;
          54.//while count > 0 do
          55.//begin
          56.// Result := ((Result shl 5) + Result) + PByte(buf)^;
          57.// Inc(PByte(buf));
          58.// Dec(count);
          59.//end;
          60.end;
          function BKDRHash(buf: Pointer; count: Integer) : Cardinal; assembler;
          asm
          PUSHEBX;
          XOR EBX, EBX
          MOV ECX, EAX
          XOR EAX, EAX
          @LOOP:
          TESTEDX, EDX
          JZ @EXIT
          MOV BL,[ECX]
          IMULEAX, 131
          ADD EAX, EBX
          INC ECX
          DEC EDX
          JMP @LOOP
          @EXIT:
          POP EBX
          //----------------------------
          // Pascal:
          //
          //Result := 0;
          //while count > 0 do


          上一頁(yè) 1 2 下一頁(yè)

          關(guān)鍵詞: 函數(shù) 哈希 高效 Delphi:

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();