From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e9b3af563ee9322a X-Google-Attributes: gid103376,public From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) Subject: Re: Interrupt Calls Date: 1997/11/12 Message-ID: <879298443.76snx@jvdsys.nextjk.stuyts.nl>#1/1 X-Deja-AN: 288727779 References: <01bcee03$8908d020$cd3663c3@default> Distribution: world Organization: *JerryWare HQ*, Leiden, Holland Newsgroups: comp.lang.ada Date: 1997-11-12T00:00:00+00:00 List-Id: 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