Rev 12 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 12 | Rev 30 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | (************************************************************* |
3 | (************************************************************* |
4 | 4 | ||
5 | BitOps.pas |
5 | BitOps.pas |
6 | Bit- Byte- and Nibbleoperations |
6 | Bit- Byte- and Nibbleoperations |
7 | 64 Bit Edition; Rev 21 March 2010 |
7 | 64 Bit Edition; Rev 05 July 2010 |
8 | 8 | ||
9 | (C) 2010 ViaThinkSoft [www.viathinksoft.com] |
9 | (C) 2010 ViaThinkSoft [www.viathinksoft.com] |
10 | Developed by Daniel Marschall [www.daniel-marschall.de] |
10 | Developed by Daniel Marschall [www.daniel-marschall.de] |
11 | 11 | ||
12 | *************************************************************) |
12 | *************************************************************) |
Line 75... | Line 75... | ||
75 | 75 | ||
76 | // Getting and setting of a bit in a byte |
76 | // Getting and setting of a bit in a byte |
77 | function GetByteBit(AByte: Byte; ABitPos: T8BitPos): TBit; |
77 | function GetByteBit(AByte: Byte; ABitPos: T8BitPos): TBit; |
78 | function SetByteBit(AByte: Byte; ABitPos: T8BitPos; ANewBit: TBit): Byte; |
78 | function SetByteBit(AByte: Byte; ABitPos: T8BitPos; ANewBit: TBit): Byte; |
79 | 79 | ||
- | 80 | // Getting and setting of a bit in a AnsiChar |
|
- | 81 | function GetAnsiCharBit(AChar: AnsiChar; ABitPos: T8BitPos): TBit; |
|
- | 82 | function SetAnsiCharBit(AChar: AnsiChar; ABitPos: T8BitPos; ANewBit: TBit): Byte; |
|
- | 83 | ||
80 | // Logical operations for the 8 bit arrays. |
84 | // Logical operations for the 8 bit arrays. |
81 | function ByteBitArrayShr(ABitArray: TByteBitArray; |
85 | function ByteBitArrayShr(ABitArray: TByteBitArray; |
82 | AVal: Longword): TByteBitArray; |
86 | AVal: Longword): TByteBitArray; |
83 | function ByteBitArrayShl(ABitArray: TByteBitArray; |
87 | function ByteBitArrayShl(ABitArray: TByteBitArray; |
84 | AVal: Longword): TByteBitArray; |
88 | AVal: Longword): TByteBitArray; |
Line 527... | Line 531... | ||
527 | // result := AByte or Math.Power(2, ABitPos); |
531 | // result := AByte or Math.Power(2, ABitPos); |
528 | result := AByte or SingleBitArray[ABitPos]; |
532 | result := AByte or SingleBitArray[ABitPos]; |
529 | end; |
533 | end; |
530 | end; |
534 | end; |
531 | 535 | ||
- | 536 | function GetAnsiCharBit(AChar: AnsiChar; ABitPos: T8BitPos): TBit; |
|
- | 537 | begin |
|
- | 538 | result := GetByteBit(Ord(AChar), ABitPos); |
|
- | 539 | end; |
|
- | 540 | ||
- | 541 | function SetAnsiCharBit(AChar: AnsiChar; ABitPos: T8BitPos; ANewBit: TBit): Byte; |
|
- | 542 | begin |
|
- | 543 | result := SetByteBit(Ord(AChar), ABitPos, ANewBit); |
|
- | 544 | end; |
|
- | 545 | ||
532 | function GetNibbleBit(ANibble: Nibble; ABitPos: T4BitPos): TBit; |
546 | function GetNibbleBit(ANibble: Nibble; ABitPos: T4BitPos): TBit; |
533 | begin |
547 | begin |
534 | result := GetByteBit(ANibble, ABitPos); |
548 | result := GetByteBit(ANibble, ABitPos); |
535 | end; |
549 | end; |
536 | 550 |