Interface with C

Alan Grover awgrover@umich.edu
Mon, 8 Jun 1998 09:31:15 -0500


At 2:55 PM -0500 6/6/98, Ana Maria Abrao wrote:
>Dear Alan.
>
>My home page has detailed instructions to link Clean with C and and with
>DLL libraries. Since I work with Windows 95, the instructions are for
>this platform. However, I checked the Clean interface in the MacIntosh.
>The interface is exactly like the one runing in Windows 95. In the task
>menu, you will find entry Opttions/LinkOptions, like in PC. Therefore, I
>believe that the method to link Clean to C is the same both in both
>machines. Could you check that for me? By the way, my home page is at
>
>	http://www.deene.ufu.br/clean/clean1.html
>
>Greetings.
>
>Ana Abrao & Antonio Costa.

Certainly there is a place to specify the libraries you want to link to.
But the "code" keyword and the way you specify the interface is not quite
clear to me. Here is an example from the existing interfaces for the Mac:

SizeWindow :: !WindowPtr !Int !Int !Bool !*Toolbox -> *Toolbox;
SizeWindow theWindow w h fUpdate t = code
(theWindow=D0,w=D1,h=D2,fUpdate=D3,t=U)(z=Z){
	call	.SizeWindow
};

For you non-Mac people, Toolbox is an environment for the Mac API. I've
deduced that the "code" associates the arguments with the PowerPC registers
as appropriate for the  call. The "t" and "z" aren't part of the real
SizeWindow function. I haven't spent enough time to figure out what "t=U"
and "z=Z" is for (oh, "t" is the Toolbox). Also, I don't have the
references that tell what registers are used for what. Also, I do not know
the calling conventions on the PPC (I used to know them for the 68k), so I
don't know how to call my own C routines.

Here is a slightly more interesting one, showing some inline assembly:

NewWindow :: !Ptr !Rect !{#Char} !Bool !Int !WindowPtr !Bool !Int !*Toolbox
-> (!WindowPtr,!*Toolbox);
NewWindow wStorage (left,top,right,bottom) title visible procID behind
goAwayFlag refCon t
= code (right=W,bottom=W,left=W,top=W,wStorage=D0,title=O0D1SD2,visible=D3,
		  procID=D4,behind=D5,goAwayFlag=D6,refCon=D7,t=U)
(window_pointer=D0,z=I8Z)
{
	instruction	0x7CC600D0	|	neg	r6,r6
	instruction	0x7D2900D0	|	neg	r9,r9
	call	.NewWindow
};

What the heck is that "00D1SD2"?

---
"Alan Grover, Technical Pb" awgrover@umich.edu
+1 (743) 647-5778
Project Leader
Health Media Research Lab, Cancer Center
5D04 North Ingalls Building, Mail Stop 0471
300 North Ingalls
Ann Arbor, MI 48109-0471