📄 cpbits.pas
字号:
{$I CPDIR.INC}
unit cpbits;
{*
Byte-size bitmasks
2/8/91
*}
interface
type
BITLIST = array[0..7] of byte;
const
BITS = 8;
BITMASK:BITLIST = ($0001,$0002,$0004,$0008,
$0010,$0020,$0040,$0080);
NULL_MASK = $0000;
FULL_MASK = $00FF;
function BitIsOn (ithBit, flag:byte):Boolean;
procedure BitOn (ithBit:byte; var flag:byte);
procedure BitOff (ithBit:byte; var flag:byte);
implementation
function BitIsOn (ithBit, flag:byte):Boolean;
{ True if ith bit in flag is on }
begin
BitIsOn := (flag AND BITMASK[ithBit] = BITMASK[ithBit]);
end;
procedure BitOn (ithBit:byte; var flag:byte);
{ Switch on the ith bit in flag }
begin
flag := flag OR BITMASK[ithBit];
end;
procedure BitOff (ithBit:byte; var flag:byte);
{ Switch off the ith bit in flag }
begin
flag := flag AND NOT BITMASK[ithBit];
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -