Re: [stella] question about the stack's use of ram

Subject: Re: [stella] question about the stack's use of ram
From: Christopher Tumber <christophertumber@xxxxxxxxxx>
Date: Sat, 03 Jan 2004 22:07:00 -0500
Paul wrote:

>Yeah, a lot of times you can use JMP's instead of JSR's.  In Marble Craze I only have 2 bytes for the stack.

Double yeah. I pretty much try to avoid using JSR completely, and only do so when absolutely needed (really large subroutines that get re-used a lot). RAM management is really one of the keys to getting the most out of the 2600 and as it is you're likely to be going merging variables and bitflags (etc) into as few bytes at possible as the RAM crunch comes. JSR's can really gobble it up, particularly if you're used using nested or looped subroutines (ie: in high level languages). So I ty to deliberately avoid such "bad habits" (which wouldn't be bad habits elsewhere, but there you go...) Since stack use for JSR's tend to be very a temporary need, you can help things a bit by using your stack area for any temporary variables as well. But then you have to be carefully about which temp variables your subroutines use.

Space Instigators uses no stack, while Fade Out only uses a 2 byte stack.

As far as using the stack for variable/data storage, it's pretty rare for me to use it in that way because there's generally no real advantage to PHA/PLA over STA/LDA except for very specific uses (ie: sorting). Unlike later CPU's where you can really make up time/space by efficient stack use (ie: CPU's with multiple stack pointers which can also push/pull multiple registers on/off the stack(s) to allow really quick movement of data from buffer to buffer.)




Chris...

----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread