comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Create a procedure with multiple arguments ...
Date: Mon, 7 Jan 2008 21:23:13 -0800
Date: 2008-01-07T21:23:13-08:00	[thread overview]
Message-ID: <dcGdnaFTjL-1lR7anZ2dnUVZ_smnnZ2d@comcast.com> (raw)
In-Reply-To: f1400d6d-97a4-4803-946d-b44bc96a15cf@1g2000hsl.googlegroups.com

<kug1977@web.de> wrote in message 
news:f1400d6d-97a4-4803-946d-b44bc96a15cf@1g2000hsl.googlegroups.com...
> Hi @ all,
>
> I'm a beginner in Ada and have the following problem:
>
> - I'm using GNAT 4.3 on a MacOS X 10.4. and develop on the
> OpenFirmware Interface.
> - To connect to the Firmware, the IEEE 1275 define an Procedure call-
> methode(), which can have up multiple arguments. IEEE 1275 define call-
> method as followed:
>
> IN: [string] method, ihandle, stack-arg1, ..., stack-argP
> OUT: catch-result, stack-result1, ..., stack-resultQ
> Pushes two less than N-args items, stack-arg1, ..., stack-argP, onto
> the Forth data stack, with stack-arg1 on top of the stack, and
> executes the package method named method in the instance ihandle as
> with $call-method, guarded by catch. Pops the result returned by catch
> into catch-result. If that result is nonzero, restore the depth of the
> Forth data stack to its depth prior to the execution of call-method.

I don't know much about the OpenFirmware interface (other than what I just 
read on Wikipedia) but it appears to be a regular Forth interpreter, and I 
do know something about Forth.  I am guessing that the procedure call you're 
describing is for a C binding to interact with the interpreter.  With a C 
binding it makes sense to set things up with variable argument lists, but it 
won't work that way with Ada.

Have you tried looking into interfacing directly with the interpreter?  Or 
is that where you found the information you are describing.  I would expect 
a direct interface to the forth interpreter to send a string containging a 
sequence of tokens separated by spaces to the interpreter and receive a 
string containing a similar sequence as output.  If that is the case then 
the interface becomes a simple procedure call with an input string and an 
output string.

Regards,
Steve
(The Duck)

> If that result is zero, pops up to one less than N-returns items,
> stack-result1,  ..., stack-resultQ, from the Forth data stack into the
> returned values portion of the argument array, with stack-result1
> corresponding to the top of the stack.
> N-args and N-returns are stored in the argument array and may be
> different for different calls to
> call-method. If the number of items X left on the Forth data stack as
> a result of the execution of
> method is less than N-returns, only stack-result1 ... stack-resultX
> are modified; other elements of the returned values portion of the
> argument array are unaffected. If X is more than N-returns, additional
> items are popped from the Forth data stack after setting stack-
> result1 ... stack-resultQ so that, in all cases, the execution of call-
> method results in no net change to the depth of the Forth data stack.
>
> In C, this is written as followed: static void *of_call(const char
> *service, int nargs, int nret, ...), but how can I write such a thing
> in Ada?
>
> Any help would be appreciated ... best regards
> Kay-Uwe 





  parent reply	other threads:[~2008-01-08  5:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-04 20:28 Create a procedure with multiple arguments kug1977
2008-01-07 10:26 ` Stephen Leake
2008-01-07 21:09   ` kug1977
2008-01-08  5:23 ` Steve [this message]
2008-01-08 15:22   ` kug1977
replies disabled

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