comp.lang.ada
 help / color / mirror / Atom feed
From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk)
Subject: Re: Interrupt Calls
Date: 1997/11/12
Date: 1997-11-12T00:00:00+00:00	[thread overview]
Message-ID: <879298443.76snx@jvdsys.nextjk.stuyts.nl> (raw)
In-Reply-To: 01bcee03$8908d020$cd3663c3@default


In article <01bcee03$8908d020$cd3663c3@default> thepalmers@lineone.net writes:

>      here is an interesting example of how to use INT 21, as it make use
>of  GNAT's ability to call C programs easily.

As long as you are using GNAT/DOS, why not simplify things, and write
the whole program in Ada ?


-- ************************************************
-- * dos_int.ads - execute realmode DOS interrups *
-- ************************************************

with Interfaces;

package DOS_Int is

   ---------------------------------------------
   -- NAME:    Dpmi_Regs                      --
   --                                         --
   -- PURPOSE: Simplified processor registers --
   ---------------------------------------------
   type Dpmi_Regs is
      record
         Di     : Interfaces.Unsigned_16;
         Di_Hi  : Interfaces.Unsigned_16;
         Si     : Interfaces.Unsigned_16;
         Si_Hi  : Interfaces.Unsigned_16;
         Bp     : Interfaces.Unsigned_16;
         Bp_Hi  : Interfaces.Unsigned_16;
         Res    : Interfaces.Unsigned_16;
         Res_Hi : Interfaces.Unsigned_16;
         Bx     : Interfaces.Unsigned_16;
         Bx_Hi  : Interfaces.Unsigned_16;
         Dx     : Interfaces.Unsigned_16;
         Dx_Hi  : Interfaces.Unsigned_16;
         Cx     : Interfaces.Unsigned_16;
         Cx_Hi  : Interfaces.Unsigned_16;
         Ax     : Interfaces.Unsigned_16;
         Ax_Hi  : Interfaces.Unsigned_16;
         Flags  : Interfaces.Unsigned_16;
         Es     : Interfaces.Unsigned_16;
         Ds     : Interfaces.Unsigned_16;
         Fs     : Interfaces.Unsigned_16;
         Gs     : Interfaces.Unsigned_16;
         Ip     : Interfaces.Unsigned_16;
         Cs     : Interfaces.Unsigned_16;
         Sp     : Interfaces.Unsigned_16;
         Ss     : Interfaces.Unsigned_16;
      end record;

   --------------------------------------------------
   -- NAME:    Dpmi_Int                            --
   --                                              --
   -- PURPOSE: Call a real-mode interrupt          --
   --                                              --
   -- INPUTS:  Vector - Interrupt number           --
   --          Regs   - Processor registers        --
   --                                              --
   -- OUTPUTS: Regs - Modified processor registers --
   --------------------------------------------------
   procedure Dpmi_Int(Vector : in     Interfaces.Unsigned_16;
                      Regs   : in out Dpmi_Regs);

private

   pragma Convention(C, Dpmi_Regs);
   pragma Import(C, Dpmi_Int, "__dpmi_int");

end DOS_Int;


-- ***************************************************
-- * test.adb - shows calling realmode DOS interrups *
-- ***************************************************

with DOS_Int; use DOS_Int;

with Interfaces;  use Interfaces;
with Ada.Text_IO; use Ada.Text_IO;

procedure Test is

   DOS_Drive          : constant Unsigned_16 := 16#0003#;
   DOS_Get_Disk_Space : constant Unsigned_16 := 16#3600#;
   DOS_Interrupt      : constant Unsigned_16 := 16#0021#;

   Regs : Dpmi_Regs;

begin

   Regs.Dx := Dos_Drive;
   Regs.Ax := DOS_Get_Disk_Space;
   Dpmi_Int (DOS_Interrupt, Regs);

   Put_Line ("Number Available Of Clusters:" & Regs.Bx'Img);
   Put_Line ("Number Of Byte per Sector:   " & Regs.Cx'Img);
   Put_Line ("Number Of Cluster per Drive: " & Regs.Dx'Img);

end Test;

--

-- Jerry van Dijk | Leiden, Holland
-- Consultant     | Team Ada
-- Ordina Finance | jdijk@acm.org




  parent reply	other threads:[~1997-11-12  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-08  0:00 Interrupt Calls Chad R. Meiners
1997-11-10  0:00 ` Jerry van Dijk
1997-11-11  0:00   ` Chad R. Meiners
1997-11-12  0:00     ` Jerry van Dijk
1997-11-10  0:00 ` Laura & Mike Palmer
1997-11-11  0:00   ` Jerry van Dijk
1997-11-12  0:00   ` Jerry van Dijk [this message]
     [not found]     ` <01bcf06a$ba1d1900$933e63c3@default>
1997-11-21  0:00       ` Chad R. Meiners
1997-11-21  0:00         ` Larry Coon
1997-11-22  0:00           ` Jerry van Dijk
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox