From: | Thilo Köhler |
Date: | 19 Jun 2001 at 00:14:45 |
Subject: | Libcall & AHI |
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.
;_____________________________________ BEGIN:
*NEWTYPE*.registers
a.l[8]
d.l[8]
*End* *NEWTYPE*
*DEFTYPE*.registers registers
*Function*.l libcall {libbase.l,offset.l}
*SHARED* registers
*If* libbase><*False* *AND* offset>0
registers\a[6] = libbase - offset ; store the right function address
in (pseudo)a6
*GetReg* a0,®isters\a[0] ; get the pointer to our pseudo
registers
*MOVEM*.l a0-a6/d1-d7,-(a7) ; save all registers except d0
*MOVE*.l 60(a0),d7 ; fill the registers ...
*MOVE*.l 56(a0),d6
*MOVE*.l 52(a0),d5
*MOVE*.l 48(a0),d4
*MOVE*.l 44(a0),d3
*MOVE*.l 40(a0),d2
*MOVE*.l 36(a0),d1
*MOVE*.l 32(a0),d0
; MOVE.l 28(a0),a7 ; uh, not a good idea !
*MOVE*.l 24(a0),a6
*MOVE*.l 20(a0),a5
*MOVE*.l 16(a0),a4
*MOVE*.l 12(a0),a3
*MOVE*.l 8(a0),a2
*MOVE*.l 4(a0),a1
*MOVE*.l (a0),a0 ; ... and finally a0
*JSR* (a6) ; and jump to the library
function !
*MOVEM*.l (a7)+,a0-a6/d1-d7 ; restore all registers except d0
*MOVE*.l d0,32(a0) ; save the result
*Else*
error {"Libcall with libbase=0 or invalid offset !"}
*End* *If*
*Function Return* registers\d[0]
*End Function*
*Statement* libcall_datreg {d0.l,d1.l,d2.l,d3.l,d4.l,d5.l}
*SHARED* registers
registers\d[0] = d0
registers\d[1] = d1
registers\d[2] = d2
registers\d[3] = d3
registers\d[4] = d4
registers\d[5] = d5
*End Function*
*Statement* libcall_addreg {a0.l,a1.l,a2.l,a3.l,a4.l,a5.l}
*SHARED* registers
registers\a[0] = a0
registers\a[1] = a1
registers\a[2] = a2
registers\a[3] = a3
registers\a[4] = a4
registers\a[5] = a5
*End Function*
;__________________________________________ END
A call would look like this:
libcall_addreg {123456,0,0,0,0,0} ; fill pseudo-registers with some data
libcall_datreg {1,2,3,0,0,0}
result.l = libcall {mylibbase.l, offset.l} ; and make a call
Anyone an idea ?
It is very important for me to get this thing done, because
it is a main thing in my project "HD-Rec" which has eaten up
a lot of time now and is close to be finished.
(http://www.hd-rec.online.de/index_no_banner.html)
Ciao,
Thilo
---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie