F0 7D 00 C8 00 ->11110000 01111101 00000000 11001000 00000000
First 4 bits 1111=15 means, next 30 bits are used to store 2 values,15 bits each, a=000001111101000=1000,b=000001100开发者_运维技巧100000=800 (Signed-bit value)
1111000001111101000000001100100000 is paded with '000000' so it'll be 5 bytes.
How to make such a delphi procedure to change the value a & b,
procedure setBit(a,b:Integer);
I guess you use LSB storage order.
Try this:
procedure SetBit(const a,b: cardinal; var dest);
var d: Int64 absolute dest;
begin
d := $F000000000+(Int64(a) shl 21)+b shl 6;
end;
It will change the 8 bytes value pointed by dest, storing the data into the first 5 bytes.
The easiest way to set a bit is to use the assembler instruction BTS. Something alike (not tested)
procedure SetBit(var L; bit: Longint);
asm
BTS [EAX], EDX
end;
should work. See http://www.intel.com/Assets/PDF/manual/253666.pdf
精彩评论