Path: utzoo!attcan!uunet!cbmvax!ditto From: ditto@cbmvax.UUCP (Michael "Ford" Ditto) Newsgroups: comp.sys.amiga.tech Subject: Re: Parameters to Librhcr Summary: Use whatever calling sequence you (and the caller) like. Message-ID: <4457@cbmvax.UUCP> Date: 10 Aug 88 00:59:39 GMT References: <3716@hcr.UUCP> Reply-To: ditto@cbmvax.UUCP (Michael "Ford" Ditto) Organization: Commodore Technology, West Chester, PA Lines: 40 In article <3716@hcr.UUCP> edwin@hcr.UUCP (Edwin Hoogerbeets) writes: >I am working on interfacing C routines to Amiga shared librhcr, and I >need some help. [ describes function's paramters in C calling conventions ] >However, if I have the routine _foo in my library, in which registers >can I expect the Exec to put the parameters to _foo when calling it in >the library? The reason I want to know this is so that I may push these >values on to the stack again to call a C routine. Exec doesn't do anything at all to the paramters to a library function. In fact, Exec never even gets control during a library call: the calling program just does a "jsr offset(basereg)" directly to the code (offset defines which function in the library to call, basereg is a register that points to the base of the library). In other words, you, the designer of the library, determine the calling conventions of each routine in the library. If you want to just use C conventions all the way, go ahead, but you will still need a "stub" interface so that your compiler can jsr to _functionname which will do something like "move yourlibbase,basereg; jmp offset(basereg)". >I have looked in the RKM's and found nothing specific about that, but >from observation it seems that pointers are in the a[0|1] registers and >values go in the d[0|1] registers. What happens if there are more than 4 >parameters? This is a sort of "convention" which makes it easier to remember the calling sequences of library function... if your function will only be called from C, and you will be providing the "stubs" for other programmers to use, then it really doesn't matter what conventions you choose. -- -=] Ford [=- . . (In Real Life: Mike Ditto) . : , ford@kenobi.cts.com This space under construction, ...!ucsd!elgar!ford pardon our dust. ditto@cbmvax.commodore.com