[comp.sys.amiga.programmer] How are registers assigned to C functions args ?

lzago@eso.org (Lorenzo Zago) (06/10/91)

I am trying to write a shared library callable both in AmigaBasic and C.
Because I am very poor in assembler I wish to write all the library 
functions in C.
I am using LibTool from Jeff Glatt and I modify the generated library 
assembler code to push the arguments so that they can be "seen" also when 
calling from AmigaBasic.
Everything is fine as long as the arguments of all my library functions
are "long"s and the function just does simple aritmetics. In these cases
it appears that my arguments are found in registers d0,d1,d2,etc.

However, when in my library functions there is a call to an Intuition
function, I find that an argument, say a window pointer, is now in a0.
In order to modify correctly the code generated by LibTool and to write
the correct .fd file (also required to get the .bmap file for AmigaBasic)
I need to identify, or better, to define which registers are actually used.

Can anyone help ?      Thanks in advance.

Lorenzo Zago                         Uucp: lzago@eso.uucp or eso!lzago
ESO - European Southern Observatory  Earn: lzago@dgaeso51
Karl Schwarzschild Str. 2            Span: esom1::lza
D-8046 Garching bei Muenchen         Internet: user%eso.uucp@EU.net
Germany	(West)                       Internet: user@eso.org (not sure yet)
Tel:	+49 89 320 06 0
Fax:	+49 89 320 23 62
--------------------------------------------------------------------------

carolyn@cbmvax.commodore.com (Carolyn Scheppner - CATS) (06/14/91)

In article <1991Jun10.080025.27797@eso.org> lzago@eso.org (Lorenzo Zago) writes:
>I am trying to write a shared library callable both in AmigaBasic and C.
>Because I am very poor in assembler I wish to write all the library 
>functions in C.
>[]
>However, when in my library functions there is a call to an Intuition
>function, I find that an argument, say a window pointer, is now in a0.
>In order to modify correctly the code generated by LibTool and to write
>the correct .fd file (also required to get the .bmap file for AmigaBasic)
>I need to identify, or better, to define which registers are actually used.


Read the Intro in the RKM Libs and Devs

All system library functions expect longs.

All system library functions, unless specifically documented
  otherwise in their autodoc, trash a0, a1, and d1, and return their
  result in d0 (or trash d0 if they  have no result).

All system library functions expect A6 to contain their library base.

-- 
==========================================================================
 Carolyn Scheppner -- Tech. Mgr. CATS - Commodore Amiga Technical Support
 PHONE 215-431-9180 {uunet,rutgers}!cbmvax!carolyn  carolyn@commodore.com

 Reentrant code - the only way to fly. 
==========================================================================