Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!anaconda.cis.ohio-state.edu!meekins From: meekins@anaconda.cis.ohio-state.edu (Tim Meekins) Newsgroups: comp.sys.apple2 Subject: Re: ML subroutines (passing parameters in ML) Message-ID: <114343@tut.cis.ohio-state.edu> Date: 29 Apr 91 23:17:21 GMT References: <3397@kluge.fiu.edu> <13845@ucrmath.ucr.edu> <1991Apr29.203359.250@...!asuvax!gtephx> Sender: news@tut.cis.ohio-state.edu Organization: The Ohio State University, Department of Computer and Information Science Lines: 22 In article <1991Apr29.203359.250@...!asuvax!gtephx> campbellb@...!asuvax!gtephx (Brian Campbell) writes: >I thought that the 65816 had a stack addressing mode that allows one to >"random" access values on the stack (which is not present >on the 6502). It looks like this: (i,S) which I take to mean, access the >word at offset i relative to the Stack pointer. So an immediate value of 0, >means access the last word pushed, 2 means access the previous word pushed, >etc. I've not had any experience with this mode -- but am I right or wrong? >(Of course, it would access a byte with the m flag = 1). >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. -- +---------------------------S-U-P-P-O-R-T-----------------------------------+ |/ Tim Meekins <<>> Snail Mail: <<>> Apple II \| |> meekins@cis.ohio-state.edu <<>> 8372 Morris Rd. <<>> Forever! <| |\ timm@pro-tcc.cts.com <<>> Hilliard, OH 43026 <<>> /|