programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: Calling external procedure

From: Mike Ghan <mikeghan_at_logix-controls.com>
Date: Mon, 21 Jul 2003 08:48:35 -0700

I'm curious, what is the intended interface language to this
interface?

It is possible the procedure name is a variation of the published
name. For example, a procedure with the documented name of FooBar may
require FooBarA for an ASCII interface or FooBarW for a Unicode
interface. I work with a DLL that had the stack frame size as part of
the name (FooBar with 3 parameters was FooBar12).

The trick with a generic Forth procedure calling definition would be
the overhead/complexity of building and tearing down variable sized
stack frames. For speed, SwiftForth DLL interface definitions compile
specific code for each sized stack frame.

Mike

-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of chuck_at_sanna.com
Sent: Monday, July 21, 2003 8:05 AM
To: sftalk_at_forth.com
Subject: [sftalk] Re: Calling external procedure

Wow, it works as is. Thanks Mike!

No way I could have come up with a CODE solution.

I expected that SwiftForth would have a built-in solution for this
sort of
thing.

Something on the order of FUNCTION: but for a given address instead of
searching DLL's.

On Mon, 21 Jul 2003, Mike Ghan wrote:

> Chuck,
>
> Try this (untested - may need tweaking)
>
> \ Expects 2 parameters on Forth Data Stack
> CODE CALL-FUNC2 ( n1 n2 addr -- n3_see-below )
> 2 CELLS [EBP] EDX LEA
> EDX PUSH \ Save Forth Environment
> ESI PUSH
> EDI PUSH
> \ Next we build our C stack frame
> 0 [EBP] PUSH \ first parameter
> 4 [EBP] PUSH \ second parameter
> 3 CELLS # EBP ADD
> EBX CALL \ Call DLL Procedure
> 2 ( #cells ) CELLS # ESP ADD \ Discard C stack frame
> EDI POP \ Restore Forth Environment
> ESI POP
> EBP POP
> EAX EBX MOV \ Use this if proc returns data
> \ POP(EBX) \ Use this if no return data
> RET END-CODE
>
> Let us know if this works.
>
> Mike
>
> -----Original Message-----
> From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
> Behalf
> Of Chuck Carlson
> Sent: Sunday, July 20, 2003 9:43 PM
> To: sftalk_at_forth.com
> Subject: [sftalk] Calling external procedure
>
>
> Hello,
> I'm trying to call a procedure in a DLL. The procedure is not
> imported via CIMPORT though. The address of this procedure is
> obtained as follows:
>
> library AARDVARK.DLL
> 1 cimport: aa_load_function
> Z" aa_find_devices" aa_load_function
>
> Now I've got the address of function aa_find_devices(int a,int b) on
> the stack but I don't know how to call it and I have to pass 2 args
to
> it as well.
>
> What's the next step?
>
> Thanks,
>
> Chuck
>
> --------------------------------------------------------------------

--
> sftalk_at_forth.com      The SwiftForth programming discussion email
list
> To unsubscribe, send subject "unsubscribe" to
sftalk-request_at_forth.com
> For list command help, send subject "help" to
sftalk-request_at_forth.com
> Message archives are located at http://www.forth.com/archive/sftalk
> --------------------------------------------------------------------
--
> This list is a forum for SwiftForth users.  For product support and
> bug
> reports, please send email to support_at_forth.com
> --------------------------------------------------------------------
--
>
>
>
> --------------------------------------------------------------------
--
> sftalk_at_forth.com      The SwiftForth programming discussion email
list
> To unsubscribe, send subject "unsubscribe" to
sftalk-request_at_forth.com
> For list command help, send subject "help" to
sftalk-request_at_forth.com
> Message archives are located at http://www.forth.com/archive/sftalk
> --------------------------------------------------------------------
--
> This list is a forum for SwiftForth users.  For product support and
bug
> reports, please send email to support_at_forth.com
> --------------------------------------------------------------------
--
>
>
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users.  For product support and
bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users.  For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Jul 21 2003 - 08:51:02 PDT

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:33 PST