ReverseBits Routines
Reverses the Bit List, ie Bit 15 swap Bit 0, Bit 14 swap Bit1, etc.

Unit
QESBPCSSystem

Overloaded Variants
Procedure ReverseBits(var BitList: TESBBitList);
Procedure ReverseBits(var BitList: TESBLongBitList);

Declaration
Procedure ReverseBits(var BitList: TESBBitList);

Parameters
BitList BitList to process.

Category
Memory Operations

Implementation

procedure ReverseBits (var BitList: TESBBitList);
asm
	push	esi		// Preserve ESI
	mov 	dx, [eax] // DX <- BitList
	mov 	esi, eax	// Move addr BitList into ESI
	mov	cx, 16	// 16 iterations needed for a word
@@Loop:
	shr	dx, 1	// move least significant bit into CF
	adc	ax, ax	// ax := 2 * ax + carry bit
	dec	cx
	jnz 	@@Loop
	mov	[esi], ax	// AX -> BitList
	pop	esi		// Restore ESI
End;

Declaration
Procedure ReverseBits(var BitList: TESBLongBitList);

Implementation

procedure ReverseBits (var BitList: TESBLongBitList);
asm
	push	esi		// Preserve ESI
	mov 	dx, [eax] // DX <- BitList
	mov 	esi, eax	// Move addr BitList into ESI
	mov	cx, 16	// 16 iterations needed for a word
@@Loop:
	shr	dx, 1	// move least significant bit into CF
	adc	ax, ax	// ax := 2 * ax + carry bit
	dec	cx
	jnz 	@@Loop
	mov	[esi], ax	// AX -> BitList
	pop	esi		// Restore ESI
End;


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