Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!uxa.cso.uiuc.edu!jb10320 From: jb10320@uxa.cso.uiuc.edu (Jawaid Bazyar) Newsgroups: comp.sys.apple2 Subject: Re: Orca/C & M Questions Message-ID: <1991May21.202948.3268@ux1.cso.uiuc.edu> Date: 21 May 91 20:29:48 GMT Article-I.D.: ux1.1991May21.202948.3268 References: <1991May21.001049.30942@kuhub.cc.ukans.edu> Sender: usenet@ux1.cso.uiuc.edu (News) Organization: University of Illinois at Urbana Lines: 57 2hnemarrow@kuhub.cc.ukans.edu writes: >Another question: >I am trying to make Orca/M talk to Orca/C. What do I do to C to make this >work. Specifically, how do I make C call a subroutine x in a library y written >in Orca/M. The ML part is ok, I'm sure. >Note: >1. Yes, I have the manuals. >2. Yes, I have read them. >3. No, they weren't very helpful. They made perfect sense to me (of course I'm just a nerd, what can I say?) >4. Assuming we are passing parameters. >5. Yes, I know I need header files and all that stuff. >6. I need specific examples. It's not so much what you have to do to C, but what you have to do to your assembly routine. There are two things you can do. 1) set up your Orca/M routine to look just like a C function. 2) just jsl to the Orca/M routine (can't pass parameters though) So, since you said we're passing parameters, you need to do something like the following. You've got the Orca/C manual, so open up and follow along :-) The parameters to the routine are pushed onto the stack. (Page 67 for the Orca/C 1.1 version manual). After the parameters are pushed, a JSL is made to the routine. According to the diagram, you parameters start at stack offset 4. Now to make you code work a little better, we'll set the direct page to point to your parameters. tsc put stack pointer in accumulator phd save old value of direct page tcd set direct page to accum (i.e., the stack) So now lda [4] will get the value stored at the pointer Z, and lda 8 will get the value of the parameter 'a'. One thing that might be tripping you up (depending on the version of the assembler, I think) is that the assembler converts all it's labels to all uppercase. So the C example on page 68 should actually read extern int REVERSE(int parm); It really is pretty simple. If you have further questions, just ask! (Now writing a Tool Set can get hairy...) -- Jawaid Bazyar | "Twenty seven faces- with their eyes turned to Graduated!/Comp Engineering | the sky. I have got a camera, and an airtight bazyar@cs.uiuc.edu | alibi.." Apple II Forever! | I need a job... Be privileged to pay me! :-)