Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!pasteur!cory.Berkeley.EDU!fadden From: fadden@cory.Berkeley.EDU (Andy McFadden) Newsgroups: comp.sys.apple2 Subject: Re: Orca/C & M Questions Message-ID: <13780@pasteur.Berkeley.EDU> Date: 22 May 91 01:07:26 GMT References: <1991May21.001049.30942@kuhub.cc.ukans.edu> <1991May21.202948.3268@ux1.cso.uiuc.edu> <1991May21.170310.30961@kuhub.cc.ukans.edu> Sender: news@pasteur.Berkeley.EDU Reply-To: fadden@cory.Berkeley.EDU Lines: 66 In article <1991May21.170310.30961@kuhub.cc.ukans.edu> 2hnemarrow@kuhub.cc.ukans.edu writes: >None of that helped much. Like I said, I'm using an ML library. I've done >this before, but I can't seem to repeat it. What I have now is the following: [snip] >I have no problems with the ML part. It's C I've had little experience with. The generic approach: 1) Write the C routines. 2) Decide what your assembly code should do, and then write a C function that looks like this: foo(arg1, arg2, arg3) int arg1, arg2; long arg3; (substitute appropriate args/types) { arg1 = 1; arg2 = 2; arg3 = 3L; } 3) Compile it. 4) DUMPOBJ +D foo.root 5) Copy down all the TSC and SBC stuff at the start and end, and write down which DP locations are used by which variables (you can tell by looking at the assignment statements). Oh, you may also want to slide some temp variables in there... just make some local variables and assign stuff to them so you can get their addresses. 6) Create the ML subroutine, with OBJCASE ON. Type in all the TSC stuff for the prolog and epilog, and use EQU for the arguments and/or local variables. You're set. 7) Return values are in the accumulator (or Acc/X-reg for long words)... at least that's how APW C works. I do this all the time in APW C... When you say you are "using an ML library", it sounds like you have a bunch of routines that are already written, and want to call them from C. If you want to pass arguments, they have to follow C or Pascal calling conventions (declaring the ML routine as, for example, "extern pascal int foo()" for Pascal... the same set of stuff applies for Pascal routines, but the arguments will be handled differently (only your compiler knows for sure :-) )). That's all I can say based on what you've told us. You'll have to be more specific if this isn't working (i.e., what errors are you getting? Where are things failing? Does it compile? Link? Execute incorrectly?) > <| > | > / \ > <| ,| |,<| > <| | | | | <| ><| | / \/' |/ \ | <| > | / \ /\| | |/ \ | >/\ _| / _--_ \/ \ >| / \ | >|_________| |__________| Lemme guess... King Lerch's castle? ;-} >2hnemarrow@kuhub.cc.ukans.edu -- fadden@cory.berkeley.edu (Andy McFadden) ..!ucbvax!cory!fadden fadden@hermes.berkeley.edu (when cory throws up)