On 21 Oct 2004 at 1:45, James Hunkins wrote:
1) how can I make an executable piece of code generated with C68 into
an Executable thing that I can load into memory and link into the thing
list
When making FiFi, I had such a problem quite some time ago. What I
wanted was for the user to be able to load FiFi via LRESPR (instead
of exec) and then have the thing set up all by itself.
I've included the assembler file to do that, perhaps you can adjust it
and prepend it your code?
However, I don't know to what extent C68 writes truly relocatable
code, or needs some kind of relocator to be run as the first part of it
(??) which would really be a big problem for things that aren't
executed as such (??).
2) how would I pass parameters to it?
This could have been a problem.
IIRC, the normal keywords to execute things don't allow you pass
parameters to them.
The way to do it would be to set up a job and pass it the parameters
on the stack, in the normal way done by EX etc...
Again, a long time ago I wrote something like that (EXEP), perhaps it
is of use to you - appended.
3) do I have to generate separate data space for each instance of an
executable being used or would the normal C variables be isolated from
different calls to the same executable code.
I don't know the C compiler well enough for that; but I don't think it will
have separate vars for the programs - they would all share the same
variables. That can be good or bad, depending on what you want . If
in doubt, go for a separate dataspace.
Hope this helps
Wolfgang
(NB - I make no guarantee that the code works, even though the fifi
one has been in use for ages IIRC EXEP also worked OK).
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
File information ---
File: thing.asm
Date: 21 Oct 2004, 14:55
Size: 2476 bytes.
Type: Program-source
***
*
* syntax: EXEP thingname$ [{,#chan,#chan.}][;options$]
* optionalchannel
* optionaloptions$
* NOTE the separators: , or ;
* same for EXEP_W
* syntax: result= EXEPF(thingname$ {,#chan,#chan.}{;options$})
* optionalchannel
* optionaloptions$
* same for EXEPF_W
* result is the error passed back...
* these will EXEcute the thing, passing it the parameters on stack
*
* #chan MUST be preceded by the #
*
*
* v. 1.03 1996 Apr 01 13:15:41
*
* W. Lenerz 1992
*
***
section file_bas
xrefuse_thg
xreffree_thg
xrefget_thvect
xrefdo_vect
xrefget_str
xrefget_str2
xrefrt_int ; returns integer
xrefgu_achp
xrefgu_rchp
XDEFfexw
XDEFfexf
XDEFfexfw
XDEFfex
fexfw BSR.S fexw
BRA.S fexf2
fexfBSR.S fex ; do the work now
fexf2 MOVE.W D0,D4 ; return parameter
JMP rt_int ; return an integer
fexwMOVEQ #-1,D7
BRA.S fex2
fex MOVEQ #0,D7
fex2MOVEQ #0,D5 ; preset no channel
CMP.L A3,A5
BEQ fxbp
MOVEM.L A3/A5,-(A7) ; keep pointer to prameters
MOVEQ #6,D4 ; D4 will hold bytes to add
loop1 ADDQ.L #8,A3
CMP.L A3,A5 ; only one param (thing name) ?
BEQ.S nothing ; yes -...
MOVE.B -7(A6,A3.L),D1 ; type byte
ANDI.B #%0111,D1 ; filter separator
MOVE.B D1,D2 ; keep
CMP.B #%0001,D1 ; was separator ','?
BNE.S opt_string ; no, so must be options string-...
BTST#7,1(A6,A3.L) ; yes was ',' so was it preceded by #?
BEQ fxbp2 ; no, so error!
ADDQ.W #4,D4 ; one more channel
BRA.S loop1 ; find out how many bytes we need
opt_string CMP.B#%0010,D2 ; was separator ';'?
BNE fxbp2 ; no! error-...
nothing MOVEQ #100,D0
BSR gu_achp
BNE fexout2 ; leave if error
MOVE.L (A7),A3 ; ptr to pram
MOVEQ #100,D0 ; max length of thing name
BSR get_str ; get this string (thing name) now
MOVE.L A0,A5 ; A5 = my space
thex1 BSR use_thg ; try to use this thing
BNE free_sp2