Date : Tue, 24 Nov 2009 16:04:55 +0000
From : bbcmicro@... (Ian Stocks)
Subject: Quine
Mick Champion wrote:
> Ian Stocks wrote:
>> Mick Champion wrote:
>>
>>> Sorry, I should have done PLP there as opposed to PLA. So if I wanted to
>>> save A and its flags and do something else
>>>
>>> PHA
>>> PHP
>>> //do other code
>>> PLA
>>> PLP
>>>
>>> ?
>>>
>> Nope, think of a stack of plates, the last one you pushed onto the pile
>> will be the first one you pop off the pile. So the push and pop need to
>> be nested.
>>
>> PHA
>> PHP
>> //do other code
>> PLP
>> PLA
>>
> Got you! So a dodgy sub-routine could plant something else in the stack
> and cause problems if it then leaves it there.
Possibly, but remember the return address is also pushed and popped on
to the stack for a subroutine call. So your code would have to work
quite hard to leave data on the stack as well as a valid return address.
Probably just find your RTS goes somewhere unintended.
Ian.