ESBSame Function
Returns True if two structures have the same bytes for the first Size Words.

Unit
QESBPCSSystem

Declaration
Function ESBSame(const Obj1, Obj2; const Size: LongWord): Boolean;

Description
Uses fast dword compares. BASM.

Parameters
Obj1 First Object.
Obj2 Second Object.
Size Number of bytes to compare starting from the beginning of each object.

Category
Memory Operations

Implementation

function ESBSame (const Obj1, Obj2; const Size: LongWord): Boolean;
asm
	push 	esi			// Preserve ESI
	push 	edi			// Preserve EDI

	mov		esi, eax		// Move DWord from Obj1 into ESI
	mov		edi, edx		// Move DWord from Obj2 into EDI

	mov		eax, ecx		// Store Initial Size in EAX

	sar		ecx, 2		// Count DIV 4 gives numer of Dwords
	js   	@@False
	repe 	cmpsd		// compare as dwords
	jnz  	@@False 		// if Not Zero, then False

	mov 		ecx, eax		// Compare mod 3 bytes
	and  	ecx, 03
	repe 	cmpsb		// compare as bytes
	jnz  	@@False		// if Not Zero, then False

@@True:
	mov  	al, True		// else True
	jmp  	@@Done

@@False:
	mov  	al, False

@@Done:
	pop		edi			// Restore EDI
	pop		esi			// Restore ESI
End;


HTML generated by Time2HELP
http://www.time2help.com