Related articles |
---|
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) meekins@crl.com (1994-02-02) |
Newsgroups: | comp.compilers |
From: | meekins@crl.com (Tim Meekins) |
Keywords: | architecture |
Organization: | CRL Dialup Internet Access |
References: | 94-02-015 |
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!
>bob.mercier@cypress.west.sun.com
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
tsc
sec
sbc #space-1
tcs
phd
tcd
at this point, you can use straight direct page access for local
variables and the passed parameters
lda <parm1
sta <local1
the following code will exit...x&y are untouched for returning values
lda <space
sta <end-3
lda <space+1
sta <end-2
pld
tsc
clc
adc #end-4
tcs
rtl
here's how we'd call it:
pea 1 ;parm2
pea 23 ;parm1
jsl proc
and we're done...the stack is already cleaned up for us
-tim
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.