Date : Tue, 24 Nov 2009 17:11:00 +0100
From : anders.carlsson@... (Anders Carlsson)
Subject: Quine
Mick Champion wrote:
> So a dodgy sub-routine could plant something else in the stack
> and cause problems if it then leaves it there.
Yes indeed. I would think several of us have been there. Another cause may
be re-entrant JSR calls into a piece of code that either pushes or pops from
the stack without the intention to do so. A bit of nonsense code:
.entry
INX
STA &nnnn,X
PHA
LDA &mmmm,X
....
CMP #pp
BNE cont
JSR entry
.cont
PLA
It may be a good time to mention the stack pointer which can be transferred
to the X register with TSX and back again with TXS. In that way, you can
manually change the pointer without popping a lot of values.
Best regards
--
Anders Carlsson