text stringlengths 0 234 |
|---|
Function Definition: function To_Bits is new Ada.Unchecked_Conversion (Address, Bits); |
Function Body: LE : constant := Standard'Default_Bit_Order; |
-- Static constant set to 0 for big-endian, 1 for little-endian |
-- The following is an array of masks used to mask the final byte, either |
-- at the high end (big-endian case) or the low end (little-endian case). |
Masks : constant array (1 .. 7) of Packed_Byte := ( |
(1 - LE) * 2#1000_0000# + LE * 2#0000_0001#, |
(1 - LE) * 2#1100_0000# + LE * 2#0000_0011#, |
(1 - LE) * 2#1110_0000# + LE * 2#0000_0111#, |
(1 - LE) * 2#1111_0000# + LE * 2#0000_1111#, |
(1 - LE) * 2#1111_1000# + LE * 2#0001_1111#, |
(1 - LE) * 2#1111_1100# + LE * 2#0011_1111#, |
(1 - LE) * 2#1111_1110# + LE * 2#0111_1111#); |
----------------------- |
-- Local Subprograms -- |
----------------------- |
procedure Raise_Error; |
-- Raise Constraint_Error, complaining about unequal lengths |
------------- |
-- Bit_And -- |
------------- |
procedure Bit_And |
(Left : Address; |
Llen : Natural; |
Right : Address; |
Rlen : Natural; |
Result : Address) |
is |
-- LeftB : constant Bits := To_Bits (Left); |
-- RightB : constant Bits := To_Bits (Right); |
-- ResultB : constant Bits := To_Bits (Result); |
-- pragma Unreferenced (Llen); |
pragma Unreferenced (Rlen); |
begin |
-- for the time being we don't provide dynamic range checks |
-- if Llen /= Rlen then |
-- Raise_Error; |
-- end if; |
-- this routine is called only for 1, 2, or 4 byte lengths. |
-- The Rlen/Llen parameter is either, 8, 16, or 32. |
if Llen = 8 then |
declare |
use Interfaces; |
Left_Byte : Unsigned_8; |
for Left_Byte'Address use Left; |
Right_Byte : Unsigned_8; |
for Right_Byte'Address use Right; |
Result_Byte : Unsigned_8; |
for Result_Byte'Address use Result; |
begin |
Result_Byte := Left_Byte and Right_Byte; |
Function Definition: function To_Bits is new Ada.Unchecked_Conversion (Address, Bits); |
Function Body: LE : constant := Standard'Default_Bit_Order; |
-- Static constant set to 0 for big-endian, 1 for little-endian |
-- The following is an array of masks used to mask the final byte, either |
-- at the high end (big-endian case) or the low end (little-endian case). |
Masks : constant array (1 .. 7) of Packed_Byte := ( |
(1 - LE) * 2#1000_0000# + LE * 2#0000_0001#, |
(1 - LE) * 2#1100_0000# + LE * 2#0000_0011#, |
(1 - LE) * 2#1110_0000# + LE * 2#0000_0111#, |
(1 - LE) * 2#1111_0000# + LE * 2#0000_1111#, |
(1 - LE) * 2#1111_1000# + LE * 2#0001_1111#, |
(1 - LE) * 2#1111_1100# + LE * 2#0011_1111#, |
(1 - LE) * 2#1111_1110# + LE * 2#0111_1111#); |
----------------------- |
-- Local Subprograms -- |
----------------------- |
procedure Raise_Error; |
-- Raise Constraint_Error, complaining about unequal lengths |
------------- |
-- Bit_And -- |
------------- |
procedure Bit_And |
(Left : Address; |
Llen : Natural; |
Right : Address; |
Rlen : Natural; |
Result : Address) |
is |
-- LeftB : constant Bits := To_Bits (Left); |
-- RightB : constant Bits := To_Bits (Right); |
-- ResultB : constant Bits := To_Bits (Result); |
-- pragma Unreferenced (Llen); |
pragma Unreferenced (Rlen); |
begin |
-- for the time being we don't provide dynamic range checks |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.