{$mode ObjFPC}
{$ModeSwitch AdvancedRecords}
{$ifdef ENDIAN_BIG}
{$fatal}
{$endif}
interface
const Bit0 = 1 SHL 0; Bits0 = Bit0 - 1;
const Bit1 = 1 SHL 1; Bits1 = Bit1 - 1; type u1 = 0..Bits0; i1 = -Bit0 ..Bits0;
const Bit2 = 1 SHL 2; Bits2 = Bit2 - 1; type u2 = 0..Bits1; i2 = -Bit1 ..Bits1;
const Bit3 = 1 SHL 3; Bits3 = Bit3 - 1; type u3 = 0..Bits2; i3 = -Bit2 ..Bits2;
const Bit4 = 1 SHL 4; Bits4 = Bit4 - 1; type u4 = 0..Bits3; i4 = -Bit3 ..Bits3;
const Bit5 = 1 SHL 5; Bits5 = Bit5 - 1; type u5 = 0..Bits4; i5 = -Bit4 ..Bits4;
const Bit6 = 1 SHL 6; Bits6 = Bit6 - 1; type u6 = 0..Bits5; i6 = -Bit5 ..Bits5;
const Bit7 = 1 SHL 7; Bits7 = Bit7 - 1; type u7 = 0..Bits6; i7 = -Bit6 ..Bits6;
const Bit8 = 1 SHL 8; Bits8 = Bit8 - 1; type u8 = 0..Bits8; i8 = -Bit7 ..Bits7;
const Bit9 = 1 SHL 9; Bits9 = Bit9 - 1; type u9 = 0..Bits9; i9 = -Bit8 ..Bits8;
const Bit10 = 1 SHL 10; Bits10 = Bit10 - 1; type u10 = 0..Bits10; i10 = -Bit9 ..Bits9;
const Bit11 = 1 SHL 11; Bits11 = Bit11 - 1; type u11 = 0..Bits11; i11 = -Bit10..Bits10;
const Bit12 = 1 SHL 12; Bits12 = Bit12 - 1; type u12 = 0..Bits12; i12 = -Bit11..Bits11;
const Bit13 = 1 SHL 13; Bits13 = Bit13 - 1; type u13 = 0..Bits13; i13 = -Bit12..Bits12;
const Bit14 = 1 SHL 14; Bits14 = Bit14 - 1; type u14 = 0..Bits14; i14 = -Bit13..Bits13;
const Bit15 = 1 SHL 15; Bits15 = Bit15 - 1; type u15 = 0..Bits15; i15 = -Bit14..Bits14;
const Bit16 = 1 SHL 16; Bits16 = Bit16 - 1; type u16 = 0..Bits16; i16 = -Bit15..Bits15;
const Bit17 = 1 SHL 17; Bits17 = Bit17 - 1; type u17 = 0..Bits17; i17 = -Bit16..Bits16;
const Bit18 = 1 SHL 18; Bits18 = Bit18 - 1; type u18 = 0..Bits18; i18 = -Bit17..Bits17;
const Bit19 = 1 SHL 19; Bits19 = Bit19 - 1; type u19 = 0..Bits19; i19 = -Bit18..Bits18;
const Bit20 = 1 SHL 20; Bits20 = Bit20 - 1; type u20 = 0..Bits20; i20 = -Bit19..Bits19;
const Bit21 = 1 SHL 21; Bits21 = Bit21 - 1; type u21 = 0..Bits21; i21 = -Bit20..Bits20;
const Bit22 = 1 SHL 22; Bits22 = Bit22 - 1; type u22 = 0..Bits22; i22 = -Bit21..Bits21;
const Bit23 = 1 SHL 23; Bits23 = Bit23 - 1; type u23 = 0..Bits23; i23 = -Bit22..Bits22;
const Bit24 = 1 SHL 24; Bits24 = Bit24 - 1; type u24 = 0..Bits24; i24 = -Bit23..Bits23;
const Bit25 = 1 SHL 25; Bits25 = Bit25 - 1; type u25 = 0..Bits25; i25 = -Bit24..Bits24;
const Bit26 = 1 SHL 26; Bits26 = Bit26 - 1; type u26 = 0..Bits26; i26 = -Bit25..Bits25;
const Bit27 = 1 SHL 27; Bits27 = Bit27 - 1; type u27 = 0..Bits27; i27 = -Bit26..Bits26;
const Bit28 = 1 SHL 28; Bits28 = Bit28 - 1; type u28 = 0..Bits28; i28 = -Bit27..Bits27;
const Bit29 = 1 SHL 29; Bits29 = Bit29 - 1; type u29 = 0..Bits29; i29 = -Bit28..Bits28;
const Bit30 = 1 SHL 30; Bits30 = Bit30 - 1; type u30 = 0..Bits30; i30 = -Bit29..Bits29;
const Bit31 = 1 SHL 31; Bits31 = Bit31 - 1; type u31 = 0..Bits31; i31 = -Bit30..Bits30;
const Bit32 = 1 SHL 32; Bits32 = Bit32 - 1; type u32 = 0..Bits32; i32 = -Bit31..Bits31; uint = u32; int = int32;
type
Int24 = packed record
L : u16;
H : u8;
class operator :=(const Value : i32) : Int24; inline;
end;
implementation
type
u32_record = packed record
case uint of
0: (b0, b1, b2, b3 : u8 );
1: (w0, w1 : u16);
2: (d0 : u32);
end;
class operator Int24.:=(const Value : i32) : Int24; inline;
var
v : u32_record absolute Value;
begin
Assert( v.b3 in [$00, $FF]);
Result.L := v.w0;
Result.H := v.b2;
end;
var
tmp_i24 : Int24;
begin
tmp_i24 := -5;
end.