|Calling seguence for 65816 (Was: 8/16 bit compilers) mercier@pongo.West.Sun.COM (1994-02-02)|
|Re: Calling seguence for 65816 (Was: 8/16 bit compilers) email@example.com (1994-02-02)|
|From:||firstname.lastname@example.org (Tim Meekins)|
|Organization:||CRL Dialup Internet Access|
|Date:||Wed, 2 Feb 1994 10:45:09 GMT|
mercier@pongo.West.Sun.COM (Bob Mercier) writes:
>I'm working on a tiny compiler for the 65816 and was trying to work out a
>decent calling sequence for function calls.
>I assumed native mode (16 bit X, Y and A) and wanted to be able to access
>more than 256 bytes of local variables so I didn't use d,s.
>If you can think of anything shorter that will allow easy access to more
>than 256 bytes of locals and recursive functions, please let me know!
Here's a better way of doing for good performance:
local1 equ 1 ;local variable
local2 equ local1+2 ;local variable
space equ local2+2 ;how much space to reserve for locals
parm1 equ space+3 ;this is the first passed parameter
parm2 equ parm1+2 ;this is another parameter
end equ parm2+2 ;total stack used
at this point, you can use straight direct page access for local
variables and the passed parameters
the following code will exit...x&y are untouched for returning values
here's how we'd call it:
pea 1 ;parm2
pea 23 ;parm1
and we're done...the stack is already cleaned up for us
Return to the
Search the comp.compilers archives again.