Registriert seit: 25. Jun 2003
Ort: Thüringen
2.950 Beiträge
|
Re: Findfirst/Findnext in Assembler
16. Sep 2003, 12:27
Delphi-Quellcode:
function SwapBytes(Value: Cardinal): Cardinal;
asm
BSWAP EAX
end;
function SwapBytes(Value: Cardinal): Cardinal;
begin
Result := (Value shr 24) or
(Value shr 8) and $0000FF00 or
(Value shl 8) and $00FF0000 or
(Value shl 24)
end;
function CountBits(Value: Cardinal): Integer;
begin
Result := 0;
while Value <> 0 do
begin
if Odd(Value) then Inc(Result);
Value := Value shr 1;
end;
end;
function CountBits(Value: Cardinal): Integer;
asm
MOV EDX,EAX
SHR EDX,1
AND EDX,055555555h
SUB EAX,EDX
MOV EDX,EAX
AND EAX,033333333h
SHR EDX,2
AND EDX,033333333h
ADD EAX,EDX
MOV EDX,EAX
SHR EDX,4
ADD EAX,EDX
AND EAX,00F0F0F0Fh
MOV EDX,EAX
SHR EDX,8
ADD EAX,EDX
MOV EDX,EAX
SHR EDX,16
ADD EAX,EDX
AND EAX,0FFh
end;
|
|
Zitat
|