|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 1933 (0x78d)
Types: TextFile
Names: »B«
└─⟦bad92a95e⟧ Bits:30000535 8mm tape, Rational 1000, RPC 1_0_2
└─⟦bb34fe6e2⟧ »DATA«
└─⟦15d8b76c6⟧
└─⟦this⟧
package body Utils is
function ">=" (L, R : Byte_Defs.Byte) return Boolean renames Byte_Defs.">=";
function To_Unsigned_Byte (B : Byte_Defs.Byte) return Unsigned_Byte is
begin
if B >= 0 then
return Unsigned_Byte (B);
else
return Unsigned_Byte (B) + 256;
end if;
end To_Unsigned_Byte;
function To_Signed_Byte (B : Unsigned_Byte) return Byte_Defs.Byte is
begin
if B < 128 then
return Byte_Defs.Byte (B);
else
return Byte_Defs.Byte (B - 256);
end if;
end To_Signed_Byte;
function Byte_String_To_Integer
(Bs : Byte_Defs.Byte_String) return Integer is
Normalized : constant Byte_Defs.Byte_String (1 .. Bs'Length) := Bs;
Result : Integer := 0;
Shifter : Integer := 0;
begin
for I in reverse Normalized'Range loop
Result := Result + Integer (To_Unsigned_Byte (Normalized (I))) *
(2 ** Shifter);
Shifter := Shifter + 8;
end loop;
return Result;
end Byte_String_To_Integer;
function Byte_String_To_String (Bs : Byte_Defs.Byte_String) return String is
S : String (1 .. Bs'Length);
Bs_Zero : constant Integer := Bs'First - 1;
function "mod" (L, R : Byte_Defs.Byte) return Byte_Defs.Byte
renames Byte_Defs."mod";
begin
for I in S'Range loop
S (I) := Character'Val
(To_Unsigned_Byte (Bs (Bs_Zero + I)) mod 128);
end loop;
return S;
end Byte_String_To_String;
function String_To_Byte_String (S : String) return Byte_Defs.Byte_String is
Bs : Byte_Defs.Byte_String (S'First .. S'Last);
begin
for I in S'Range loop
Bs (I) := To_Signed_Byte (Character'Pos (S (I)));
end loop;
return Bs;
end String_To_Byte_String;
end Utils;