1{ %skiptarget=android } 2{ %cpu=i386 } 3{ %OPT=-Cg- } 4 5{ Source provided for Free Pascal Bug Report 5015 } 6{ Submitted by "Zeljan Rikalo" on 2006-04-15 } 7{ e-mail: zeljko@holobit.net } 8program test; 9 10{$mode delphi} 11 12const 13 14 BitMaskTable: Array[0..31] of LongWord = 15 ($00000001, $00000002, $00000004, $00000008, 16 $00000010, $00000020, $00000040, $00000080, 17 $00000100, $00000200, $00000400, $00000800, 18 $00001000, $00002000, $00004000, $00008000, 19 $00010000, $00020000, $00040000, $00080000, 20 $00100000, $00200000, $00400000, $00800000, 21 $01000000, $02000000, $04000000, $08000000, 22 $10000000, $20000000, $40000000, $80000000); 23 24 BitsPerByte = 8; 25 BitsPerWord = 16; 26 BitsPerLongWord = 32; 27 BytesPerCardinal = Sizeof(Cardinal); 28 BitsPerCardinal = BytesPerCardinal * 8; 29 30 31function SetBit(const Value, BitIndex: LongWord): LongWord; 32asm 33 {$IFOPT R+} 34 CMP BitIndex, BitsPerLongWord 35 JAE @Fin 36 {$ENDIF} 37 OR EAX, DWORD PTR [BitIndex * 4 + BitMaskTable] 38 @Fin: 39end; 40 41begin 42 43end. 44