Use assembly language. SCAS instruction with REP prefix should help a lot.
See http://home.comcast.net/~fbui/intel/s.html#scas or search Google.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


----- Original Message ----- 
From: "Ross Levis" <[EMAIL PROTECTED]>
To: "Delphi Discussion List" <[email protected]>
Sent: Thursday, November 03, 2005 11:54 AM
Subject: Test memory block


> I'm looking for the fastest way to test if a block of memory is all 
> zeros or not.  This needs to be as fast as possible since it is being 
> tested many times a second.
> 
> The memory block can be any length.  Assuming Buffer is a pointer to a 
> block of memory, and BufferSize is the length of the block, I'm 
> currently doing it like this.
> 
> type
>   TBufferArray = array[0..0] of Byte;
>   PBufferArray = ^TBufferArray;
> ....
>   var
>      BufArray: BufferArray;
>      i: Integer;
>   begin
>     BufArray := Buffer;
>     Result := False;
>     for i := 0 to BufferSize-1 do
>       if Buffer[i] <> 0 then Exit;
>     Result := True;
> 
> 
> This is reasonably quick but I'm wondering if there is a faster way that 
> does not need to increment an integer many times.
> 
> Thanks,
> Ross. 
> 
> _______________________________________________
> Delphi mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to