From TEFFTA@TSENGR.dnet.ge.com Tue Jul 28 14:30:37 1992 Received: from calvin.sfasu.edu by umaxc.weeg.uiowa.edu (5.61.jnf/920629) on Tue, 28 Jul 92 14:30:35 -0500 id AA03012 with SMTP Received: from aitgw.ge.com by calvin.sfasu.EDU with SMTP (5.59/25-eef) id AA10796; Tue, 28 Jul 92 13:42:56 CDT Return-Path: Received: from TSENGR.dnet.ge.com by aitgw.ge.com (5.65/GE Gateway 1.5) id AA21410; Tue, 28 Jul 92 14:49:46 -0400 Message-Id: <9207281849.AA21410@aitgw.ge.com> Received: from TSENGR.dnet.ge.com by AITGW.dnet.ge.com (utk-mail11d v1.5) with MAIL-11; Tue, 28 Jul 92 14:49:56 EDT Date: Tue, 28 Jul 92 14:49:56 EDT From: Andrew Tefft X-To: AITGW::"daye@jacobs.CS.ORST.EDU" X-Cc: aitgw::"hyperc-l@calvin.sfasu.edu" Subject: RE: ProDOS To: hyperc-l@calvin.sfasu.edu, daye@jacobs.CS.ORST.EDU Status: R Can't recommend anything on Prodos (I would suggest staying away from the "inner workings" except for the Global Page and the MLI anyway, since no other entry points are guaranteed not to change), but on passing parameters to assembly language, here's the quick & dirty scoop: Let's say you call a function from c called func(a,b,c). The entry point in assembly would then be _func. The parameters start at sp (defined in regs65.ah) and work up from there. Each parameter is two bytes. Ints and chars pass their values; other types actually pass their address. Chars that are passed are in the low byte of the parameter, and the high byte is 0. Everything is low-byte first. Obviously you need to know what types of data will be passed to the function. There also is no way of telling how many parms actually got passed to the function, besides looking for unreasonable values. Parameters occur in order -- the first parm (a in this example) is at [sp] and [sp]+1, b is at [sp]+2 and [sp]+3, and so on. The quickest way to access the parameters is as follows: ldy #0 lda [sp],y ; low byte, first parm (store it somewhere) iny lda [sp],y ; high byte, first parm (blah) iny lda [sp],y ; low byte, second parm iny iny ; let's say the second parm was a char, so we skip a byte lda [sp],y ; low byte, third parm (and so on). You *don't* adjust sp; the parameters get removed when the function returns. There is also a setup routine. I think you load y with the number of parameters to get less one (might be the number of parameter *bytes* to get less one) and call setup. This copies the parms to zero page starting at 0x00... but I never saw the utility in this. I personally prefer to copy the parameters manually to wherever I need them -- addresses go into zero page for indirect addressing, ints and chars usually go into storage locations in the function. The function then returns a value (if desired) by storing it in r1 (two bytes, low byte first); the actual value for an int or a char (for chars the high byte should be set to 0), the address for other types. Then just exit your routine via an rts. [r1 is also defined in regs65.ah]