Blitz (62/119)

From:Sami Näätänen
Date:19 Jun 2001 at 00:03:30
Subject:Re: Libcall & AHI

On 2001.06.19 02:14 Thilo Köhler wrote:
> Hi all !
>
> I have some problems to access the AHI library functions.
> As you can not include the AHI library funtions into
> Blitz like normal shared libraries via .fd files,
> I have to call them manually. For that, you
> receive a pointer to the AHI library base from the ahi.device
> and you can store it into a Blitz variable. Now I want to call some
> functions. For this reason I wrote some small code
> that encapsules the invoking process.
> Some of the functions of the AHI library work well,
> others crash with "privileg violation".
> Is it my fault or some problem with Blitz ?
>
> Please have a look at the code if it is
> correct or if I have done something stupid.

Well I don't know is the way you are doing things how good, but the way
you jsr:ed to library function certainly is incorrect.
When you jsr to library function you MUST have a6 loaded with the
library base address, because the library expects to find this address
and uses it for relative addressing.

So the jump to the function call should look something like this.

jsr functionoffset(a6) ; where a6 is loaded with the library base, which
you got from the openlibrary call.

You could use jsr (Rx.w,a6) and put the offset to Rx (but only if the
register Rx is not a parameter to the function you are calling).

I think best way would be to make small wrapper functions for each
library function (like fdconvert).

There are some fansy asm things you could do though, but if you haven't
coded with assembler then it's better to do the wrappers, because it's
much faster (unless you want to learn more about asm...).

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie