--------------------------------
-- Ivan Levashew aka OCTAGRAM --
--              Barnaul, 2010 --
--------------------------------

with Turbo_Private.Bits, System, System.Storage_Elements,
  Turbo_Private.Memory.Move, Turbo_Private.Memory.Fill_Byte;

package Turbo.Memory is
   pragma Preelaborate;

   -----------------
   -- Conversions --
   -----------------

   function "+" (Item : Integer_Addr) return System.Storage_Elements.Storage_Offset
     renames Turbo_Private.Bits."+";
   function "+" (Item : System.Storage_Elements.Storage_Offset) return Integer_Addr
     renames Turbo_Private.Bits."+";

   function "+" (Item : Unsigned_Addr) return System.Address
     renames Turbo_Private.Bits."+";
   function "+" (Item : System.Address) return Unsigned_Addr
     renames Turbo_Private.Bits."+";

   function "+" (Item : Unsigned_Addr) return System.Storage_Elements.Integer_Address
     renames Turbo_Private.Bits."+";
   function "+" (Item : System.Storage_Elements.Integer_Address) return Unsigned_Addr
     renames Turbo_Private.Bits."+";

   function "+" (Item : System.Address) return System.Storage_Elements.Integer_Address
     renames Turbo_Private.Bits."+";
   function "+" (Item : System.Storage_Elements.Integer_Address) return System.Address
     renames Turbo_Private.Bits."+";

   ----------------
   -- Arithmetic --
   ----------------

-- Q: Why did I commented out this API?
-- A: Because I don't use it
-- A: Because things like X'Address + 7 become ambiguous
-- A: Because it's easy to recreate using "+"es if needed

--    function "+" (Left : System.Address; Right : Integer_Addr)
--      return System.Address renames Turbo_Private.Bits."+";
--    function "+" (Left : Integer_Addr; Right : System.Address)
--      return System.Address renames Turbo_Private.Bits."+";
--    function "-" (Left : System.Address; Right : Integer_Addr)
--      return System.Address renames Turbo_Private.Bits."-";
--    function "-" (Left, Right : System.Address)
--      return Integer_Addr renames Turbo_Private.Bits."-";
--    function "mod" (Left : System.Address; Right : Integer_Addr)
--      return Integer_Addr renames Turbo_Private.Bits."mod";

   -----------------

   function "+" (Left : System.Address; Right : Unsigned_Addr)
     return System.Address renames Turbo_Private.Bits."+";
   function "+" (Left : Unsigned_Addr; Right : System.Address)
     return System.Address renames Turbo_Private.Bits."+";
   function "-" (Left : System.Address; Right : Unsigned_Addr)
     return System.Address renames Turbo_Private.Bits."-";
   function "-" (Left, Right : System.Address)
     return Unsigned_Addr renames Turbo_Private.Bits."-";
   function "mod" (Left : System.Address; Right : Unsigned_Addr)
     return Unsigned_Addr renames Turbo_Private.Bits."mod";

   --------------------------------
   -- Memory contents operations --
   --------------------------------

   procedure Move (Source, Target : System.Address; Amount : Unsigned_Addr)
     renames Turbo_Private.Memory.Move;

   procedure Fill_Byte (Target : System.Address; Amount : Unsigned_Addr;
     Item : Interfaces.Unsigned_8) renames Turbo_Private.Memory.Fill_Byte;

end Turbo.Memory;
