comp.lang.ada
 help / color / mirror / Atom feed
From: edm@vrdxhq.verdix.com (Ed Matthews)
Subject: Re: how do I do pointers to functions i
Date: 6 Dec 89 13:44:43 GMT	[thread overview]
Message-ID: <24077@vrdxhq.verdix.com> (raw)
In-Reply-To: 20600024@inmet

In article <20600024@inmet> stt@inmet.inmet.com writes:
>
>However, we have found that with most compilers we need to drop into
>assembler to call a procedure given only its address.
>This usually only requires a couple of lines of assembler.
>For example:
>
>    procedure Call_Ada_Proc(
>      Param : Integer;
>      Proc : System.Address
>    );
>    pragma Interface(Assembler, Call_Ada_Proc);

The Verdix VADS compiler is an exception to the above.  You can use a
machine code insertion to do the same thing.  We use this trick when
passing function pointers to C code.

with Machine_Code;
with System;
procedure Call(
    Function_Ptr : in System.Address;
    Param        : in Integer_32) is

    procedure Do_Call(Param : in Integer_32) is
        use Machine_Code;
    begin
        -------------------------------------------
        -- Stack is set up correctly so just do  --
        -- a branch to the start of the function --
        -------------------------------------------
        Code_1'(JMP, Function_Ptr'Ref);
	---------------------------------------------------------
	-- JMP is an enumeration literal of type OP_CODE from  --
	-- package Machine_Code.  The 'Ref attribute generates --
	-- a reference to an Ada object.                       --
	---------------------------------------------------------
    end Do_Call;

begin
    Do_Call(Param);
end Call;
-- 

Ed Matthews                                                edm@verdix.com
Verdix Corporation Headquarters                            (703) 378-7600
Chantilly, Virginia

      reply	other threads:[~1989-12-06 13:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1989-12-04  6:40 how do I do pointers to functions in Ada Michael Hunter
1989-12-04 15:39 ` how do I do pointers to functions i stt
1989-12-06 13:44   ` Ed Matthews [this message]
replies disabled

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