RE: [stella] Stack pointer. Some questions

Subject: RE: [stella] Stack pointer. Some questions
From: Christopher Tumber <christophertumber@xxxxxxxxxx>
Date: Mon, 10 May 2004 13:25:43 -0400
Paul wrote:

>I often use the stack pointer for storage in a tight kernel (using TSX/TXS).  It's handy when you need to save the value of X temporarily, and can often shave off a few cycles.  Just make sure that if you use the stack in your program, that you save the stack pointer value beforehand and restore it afterwards.

Really? Can you give a practical example?

I've always considered it too awkward to be of real use:

TXS
TSX

4 cycles

STX $ZeroPage
LDX $ZeroPage

6 cycles

Savings = 2 cycles

However,

TSX
STX $ZeroPage
...
TXS
...
TSX
...
LDX $ZeroPage
TXS

14 cycles

Unless your swapping out of X is really timing critical but you can spare the cycles required to save/restore the stack. Or you've got a stack free program. Or you have no scratch RAM available.

Hmmm...


Chris...

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


Current Thread