Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!ncar!asuvax!mcdphx!hrc!gtephx!campbellb From: campbellb@...!asuvax!gtephx (Brian Campbell) Newsgroups: comp.sys.apple2 Subject: Re: ML subroutines (passing parameters in ML) Message-ID: <1991May2.153346.1783@...!asuvax!gtephx> Date: 2 May 91 15:33:46 GMT References: <3397@kluge.fiu.edu> <13845@ucrmath.ucr.edu> <114343@tut.cis.ohio-state.edu> Organization: gte Lines: 18 In article <114343@tut.cis.ohio-state.edu>, meekins@anaconda.cis.ohio-state.edu (Tim Meekins) writes: > In article <1991Apr29.203359.250@...!asuvax!gtephx> campbellb@...!asuvax!gtephx (Brian Campbell) writes: > >BTW, if all of this is true, in a assembly routine, to by-pass the JSL > >return address, would you typically use offsets of 3,5,7... to get word > >parameters n,n-1,n-2,... where n is the number of data words pushed? > > You've almost got it. The stack pointer points to where the next byte will > go, NOT where the last byte is. To access the last byte pushed, use 1,s, > NOT 0,s. Other than that, I believe you're on track. Also, if you map > the DP to the stack (TCS,TCD), loading from Direct Page location $01 will > access the last byte pushed. Therefore, (1,s), (2,s), and (3,s) point to the RTL address, and offsets of 4,6,8,... will point to parameters n,n-1,n-2,... A handy way to access parameters, if they are simple word values. If they are pointers, then you would have to move them into a direct page to use (zaddr) or [zaddr] addressing modes to get to the data. The DP method can be more convenient (unless you also need to frequently access a DP page as "registers"). BTW, don't you mean TSC?