[comp.sys.amiga.programmer] ARP and DICE - How to link??

nick@uni-paderborn.de (Martin Koch) (02/25/91)

Hello Amigos,

I would like to use the ArpFunctions in my C-Program.
I use the DICE-Compiler from Matt Dillon. But i am not
able, to link the a.lib (or also the arp.lib)(both link time
libraries) to the executable.
They are both in the Manxformat. Has anyone solved the Problem?

By the way. You can include arpbase.h if you
add the following lines.

#ifdef _DCC

#define NO_PRAGMAS 1
#define C_VARS

#endif _DCC

just after the #ifdef AZTEC_C block.


-- 
Bye ;-)
       //\      Martin Koch ---  email to: nick@uni-paderborn.de
      //__\
     //----\UGUP  --- Amiga User Group Uni Paderborn
  \\//      \miga --- You can't beat the feeling!
   Earth; planet 
          "Mostly Harmless!"   The Hitchhiker's Guide to the Galaxy         
-- 
Bye ;-)
       //\      Martin Koch ---  email to: nick@uni-paderborn.de
      //__\
     //----\UGUP  --- Amiga User Group Uni Paderborn

stephane@Chucla.CAM.ORG (Stephane Laroche) (02/26/91)

In article <1991Feb25.121623.16551@uni-paderborn.de> nick@uni-paderborn.de (Martin Koch) writes:
>Hello Amigos,
>
>I would like to use the ArpFunctions in my C-Program.
>I use the DICE-Compiler from Matt Dillon. But i am not
>able, to link the a.lib (or also the arp.lib)(both link time
>libraries) to the executable.
>They are both in the Manxformat. Has anyone solved the Problem?

You need to create a new link library that contains the glue code
for the ARP function.  I've started working on this but I didn't
have time to finish... yet.  Look at the lattice glue code from
the ARP distribution and AztecArp from Olaf Barthel which is on
Fish Disk #436.

For example, to use the ARP function Puts, assemble the following
code (taken from AztecArp) and link it with your C program:

_Puts:
	pea	(a6)
	move.l	_ArpBase,a6
	move.l	8(sp),a1
	jsr	-240(a6)
	move.l	(sp)+,a6
	rts

Someone should really make a complete DICE-compatible arp.lib for
us poor folks who are still using AmigaDos 1.3.  I know I would
if I had the time :-)

>	//\	 Martin Koch ---  email to: nick@uni-paderborn.de

--
 Stephane Laroche   | Email: stephane@Chucla.CAM.ORG
 +1 514 277-8605    |	     Montreal, Que.,  Canada

d87-jmf@sm.luth.se (Jim Malmlof) (02/27/91)

nick@uni-paderborn.de (Martin Koch) writes:

>Hello Amigos,

>I would like to use the ArpFunctions in my C-Program.
>I use the DICE-Compiler from Matt Dillon. But i am not
>able, to link the a.lib (or also the arp.lib)(both link time
>libraries) to the executable.
>They are both in the Manxformat. Has anyone solved the Problem?


	You will need to build a glue-library for the arpfunctions.
	In my ADOS 1.3 version of my editor project (modified mg) I
	have done a glue-library for the functions I needed. I have
	included the source below as a start. You can modify it to
	your needs. If anyone decides to make a whole glue-library of
	it I would appreciate a copy.

	/Jim.

>>> Source-code arp_diceglue.a ,assembled with devpac.

	OPT L+
*	
*	ARP V39 Glue routines for DICE V2.03.
*	Only a subset of all arp calls are implemented, especially those
*	needed for Mmg.
*
*	Author : Jim Malmlof
*	Date   : 900628

*	Comment: The glue routines are not effecient and could need a bit
*		 trimming. No of regs saved needed ? Perhaps you can movem.l
*		 all regs needed from stack ?

****************** Implemented calls ***************

	XDEF	_ArpAllocFreq
	XDEF	_ASyncRun
	XDEF	_SyncRun
	XDEF	_FileRequest
	XDEF	_BaseName
	XDEF	_StamptoStr
	XDEF	_ATackOn	; Real name is TackOn changed because of dlink.

	XREF	_ArpBase

SaveRegs	REG	d2-d7/a2-a6

****************** Start of code *******************

	section		arpglue,code

	INCLUDE		"INCLUDE:libraries/arp_lib.i"

; ArpAllocFreq()

_ArpAllocFreq
	movem.l		SaveRegs,-(sp)		;Save regs
	move.l		_ArpBase,a6		;Get arpbase
	jsr		_LVOArpAllocFreq(a6)	;Call arp
	movem.l		(sp)+,SaveRegs		;Restore regs
	rts					;return

; ASyncRun(command,arg,pcb)

_ASyncRun

	move.l		4(sp),a0		;Command
	move.l		8(sp),a1		;Arg
	move.l		12(sp),a2		;pcb
	movem.l		SaveRegs,-(sp)		;Save regs
	move.l		_ArpBase,a6		;Get arpbase
	jsr		_LVOASyncRun(a6)	;Call arp
	movem.l		(sp)+,SaveRegs		;Restore regs
	rts					;return

; SyncRun(filename,args,input,output)

_SyncRun
	move.l		4(sp),a0		;filename
	move.l		8(sp),a1		;Args
	move.l		12(sp),d0		;input
	move.l		16(sp),d1		;output
	movem.l		SaveRegs,-(sp)		;Save regs
	move.l		_ArpBase,a6		;Get arpbase
	jsr		_LVOSyncRun(a6)		;Call arp
	movem.l		(sp)+,SaveRegs		;Restore regs
	rts					;return

; FileRequest(filereq)

_FileRequest
	move.l		4(sp),a0		;filereq
	movem.l		SaveRegs,-(sp)		;Save regs
	move.l		_ArpBase,a6		;Get arpbase
	jsr		_LVOFileRequest(a6)	;Call arp
	movem.l		(sp)+,SaveRegs		;Restore regs
	rts					;return

; BaseName(PathName);

_BaseName
	move.l		4(sp),a0		;BaseName
	movem.l		SaveRegs,-(sp)		;Save regs
	move.l		_ArpBase,a6		;Get arpbase
	jsr		_LVOBaseName(a6)	;Call arp
	movem.l		(sp)+,SaveRegs		;Restore regs
	rts					;return

; StamptoStr(DateTime)

_StamptoStr
	move.l		4(sp),a0		;DateTime
	movem.l		SaveRegs,-(sp)		;Save regs
	move.l		_ArpBase,a6		;Get arpbase
	jsr		_LVOStamptoStr(a6)	;Call arp
	movem.l		(sp)+,SaveRegs		;Restore regs
	rts					;return

; ATackOn(PathName,FileName)

_ATackOn
	move.l		4(sp),a0		;PathName
	move.l		8(sp),a1		;Filename
	movem.l		SaveRegs,-(sp)		;Save regs
	move.l		_ArpBase,a6		;Get arpbase
	jsr		_LVOTackOn(a6)		;Call arp
	movem.l		(sp)+,SaveRegs		;Restore regs
	rts

	END

>>> End of source code.
---
   _______  
   | -=- |    Jim Malmlof
   | -=- |    Internet : d87-jmf@sm.luth.se		
   |     |    UUCP     : {uunet,mcvax}!sunic.se!sm.luth.se!d87-jmf    //
   |     |    University of Lulea,Sweden.                            // 
   |     |    Finagle's first law:		                 \\ //  Amiga
   /_____\    If a program works, something has gone wrong.       \X/ A500 Tower
	

estdwha@warwick.ac.uk (CrisP) (03/02/91)

In article <stephane.3564@Chucla.CAM.ORG> stephane@Chucla.CAM.ORG (Stephane Laroche) writes:
>In article <1991Feb25.121623.16551@uni-paderborn.de> nick@uni-paderborn.de (Martin Koch) writes:
>>Hello Amigos,
>>
>>I would like to use the ArpFunctions in my C-Program.
>>I use the DICE-Compiler from Matt Dillon. But i am not
>>able, to link the a.lib (or also the arp.lib)(both link time
>>libraries) to the executable.
>>They are both in the Manxformat. Has anyone solved the Problem?
>
>You need to create a new link library that contains the glue code
>for the ARP function.  I've started working on this but I didn't
>have time to finish... yet.  Look at the lattice glue code from
>the ARP distribution and AztecArp from Olaf Barthel which is on
>Fish Disk #436.
>
>For example, to use the ARP function Puts, assemble the following
>code (taken from AztecArp) and link it with your C program:
>
>_Puts:
>	pea	(a6)
>	move.l	_ArpBase,a6
>	move.l	8(sp),a1
>	jsr	-240(a6)
>	move.l	(sp)+,a6
>	rts
>
>Someone should really make a complete DICE-compatible arp.lib for
>us poor folks who are still using AmigaDos 1.3.  I know I would
>if I had the time :-)
>

With Dice2.06 there is a little program call fdtolib that can create the such
a .lib file from the .fd file. I have already created myself a amigs.lib from
.fd files. And am working an arp.lib. But I have forseen a problem with the
PrintF() and simular functions. In the Arp library you pass the mutiple
undefined parameters as a pointer to an array. It would be nice to pass them
as seperate parameters. I know that fdtolib creates the glue code needed from
the .fd file. I know that it then uses das to assemble it. But what I can't
work out is what it does from there.

~ CrisP.

>>	//\	 Martin Koch ---  email to: nick@uni-paderborn.de
>
>--
> Stephane Laroche   | Email: stephane@Chucla.CAM.ORG
> +1 514 277-8605    |	     Montreal, Que.,  Canada


-- 
--------------------------------------------------------------------
crisp@uk.ac.warwick.cs   |   I didn't do it. Nobody saw me do it.
estdwha@uk.ac.warwick.cu | You can't prove anything. - Bart Simpson.
--------------------------------------------------------------------

dillon@overload.Berkeley.CA.US (Matthew Dillon) (03/04/91)

In article <B+A&R&_@warwick.ac.uk> estdwha@warwick.ac.uk (CrisP) writes:
>
>With Dice2.06 there is a little program call fdtolib that can create the such
>a .lib file from the .fd file. I have already created myself a amigs.lib from
>.fd files. And am working an arp.lib. But I have forseen a problem with the
>PrintF() and simular functions. In the Arp library you pass the mutiple
>undefined parameters as a pointer to an array. It would be nice to pass them
>as seperate parameters. I know that fdtolib creates the glue code needed from
>the .fd file. I know that it then uses das to assemble it. But what I can't
>work out is what it does from there.
>
>~ CrisP.
>--
>--------------------------------------------------------------------
>crisp@uk.ac.warwick.cs   |   I didn't do it. Nobody saw me do it.
>estdwha@uk.ac.warwick.cu | You can't prove anything. - Bart Simpson.
>--------------------------------------------------------------------

    It simply JOINs the object modules together to make the library,
    that's all you need to do.  It also generates a special assembly
    file during scanning that exports all the LVOs, assembles and
    join's that as well.

					-Matt
--

    Matthew Dillon	    dillon@Overload.Berkeley.CA.US
    891 Regal Rd.	    uunet.uu.net!overload!dillon
    Berkeley, Ca. 94708
    USA

estdwha@warwick.ac.uk (CrisP) (03/06/91)

In article <dillon.4593@overload.Berkeley.CA.US> dillon@overload.Berkeley.CA.US (Matthew Dillon) writes:
>In article <B+A&R&_@warwick.ac.uk> estdwha@warwick.ac.uk (CrisP) writes:
>>
[ Stuff I wrote about fdtolib an arp Printf and FPrintf deleted. ]
>
>    It simply JOINs the object modules together to make the library,
>    that's all you need to do.  It also generates a special assembly
>    file during scanning that exports all the LVOs, assembles and
>    join's that as well.
>
>					-Matt

The strange thing was that it deleted the files after it assembled them.
What I did to finaly create my arp.lib file was copy arp_lib.fd into t:
and das, dlib, memacs and fdtolib into ram:. I renamed das to as. Deleted
all the ##privates that were in arp_lib.fd as not to interfer with glue code
( As I had none. ). And I wrote the following script.

Emacs $
as $

I called the script das.

I was suppriesed that it didn't take forever. :-)

What I would like to know is: How did it manage to execute the script?
I didn't think scripts were implemented in AmigaDOS until 1.3.
I can understand them executing from my shell but not from within a program
expecting an executable.

~ CrisP.

-- 
--------------------------------------------------------------------
crisp@uk.ac.warwick.cs   |   I didn't do it. Nobody saw me do it.
estdwha@uk.ac.warwick.cu | You can't prove anything. - Bart Simpson.
--------------------------------------------------------------------

bhgs@gpu.utcs.utoronto.ca (R. Holdom) (03/07/91)

In article <B+A&R&_@warwick.ac.uk> estdwha@warwick.ac.uk (CrisP) writes:
  (stuff deleted)
>
>With Dice2.06 there is a little program call fdtolib that can create the such
>a .lib file from the .fd file. I have already created myself a amigs.lib from
>.fd files. And am working an arp.lib. But I have forseen a problem with the
>PrintF() and simular functions. In the Arp library you pass the mutiple
>undefined parameters as a pointer to an array. It would be nice to pass them
>as seperate parameters. I know that fdtolib creates the glue code needed from
>the .fd file. I know that it then uses das to assemble it. But what I can't
>work out is what it does from there.
>
>~ CrisP.

   (more stuff deleted)

Just this mourning I was doing this very thing.  fdtolib works fine for
all of the simple function calls (ie no Printf's and stuff that don't return
a second value via IoErr()) For the rest, the arp guys have already done
the job for us.  In the programers package (the one with the documentation)
there is a file called LatticeGlue.a which was designed to work with
Lattice (as you may have guessed) but which suits our needs fine.
The only thing I had to modify was they have the line:
		xref	_ArpBase
but this causes the assembler (at least the one I used) to make this
symbol by refferenced from the pc register, instead of a4, as we want.
So i just put the line:
		section		"",data
right before the above line and everything was fine. I also took out
the stuff for making the choice between Near and Far memory models,
since we want the near one.  I assembled the file using the Lattice
assembler from Lattice C 4.0.1, since Matt's is still somewhat
anemic(sp?).  Then I just joined the two files, and everything is
fine. 

   If anyone is interested, it probably wouldn't be too hard to
make a file that Matt's assembler could handle.  So send me a note
and I'll try it.

                                Jon Spencer.

dillon@overload.Berkeley.CA.US (Matthew Dillon) (03/08/91)

In article <1991Mar6.213253.27365@gpu.utcs.utoronto.ca> bhgs@gpu.utcs.utoronto.ca (R. Holdom) writes:
>right before the above line and everything was fine. I also took out
>the stuff for making the choice between Near and Far memory models,
>since we want the near one.  I assembled the file using the Lattice
>assembler from Lattice C 4.0.1, since Matt's is still somewhat
>anemic(sp?).  Then I just joined the two files, and everything is
>fine.
>
>   If anyone is interested, it probably wouldn't be too hard to
>make a file that Matt's assembler could handle.  So send me a note
>and I'll try it.
>
>				 Jon Spencer.

    DAS is designed to assemble output from DC1 and not really to assemble
    user programs.  It does not support INCLUDE directives or MACROs.

    DAS does support the near and far data models, however, and works
    similar to the way the new SAS/C assembler does it.  Basically:

	    xref    _Fubar

	    move.l  _Fubar,D0		; absolute    (large-data)
	    move.l  _Fubar(A4),D0       ; a4-relative (small-data)

    And, of course, PC-relative too (all the 68000 addressing modes and
    most of the 020/030 addressing modes)

					-Matt

--

    Matthew Dillon	    dillon@Overload.Berkeley.CA.US
    891 Regal Rd.	    uunet.uu.net!overload!dillon
    Berkeley, Ca. 94708
    USA