[Coco] 6809 Push/Pull

Dave Philipsen dave at davebiz.com
Sun Jun 7 08:38:11 EDT 2020


Some people like to code that way for visualization. Personally, I keep everything in the same order on both pushes and pulls but it’s a personal preference and makes no difference to the CPU. 

Another thing that people probably don’t think about is that the 16-bit registers (X,Y,U,PC) are pushed and pulled one byte at a time. So, in reality you are pushing PCL, PCH, UL, UH, YL, YH, XL, XH, DP, B (DL), A (DH), CC.  It really helps to understand this especially if you want to access the contents of those registers after they’ve been pushed on the stack. 


-Dave Philipsen

> On Jun 6, 2020, at 1:48 PM, Jim OKeefe <jimokeefe39 at gmail.com> wrote:
> 
> What got me thinking and why i asked the question originally was while
> looking for some code in Color Basic Unravelled i came across
> 
> PSHS X,B,A
> bla
> bla
> bla
> PULS A,B,X,PC
> 
> I knew the PC was a return but why reverse the order of X B and A.  I
> looked for other examples in the book and found the same thing.  It appears
> that this format was used through out the book. That's when i freaked out.
> I thought how could my code not be crashing like crazy and asked the list
> the original question,  lol. After seeing Art's answer i said to myself,
> "i knew that".  Memory is a cruel maiden indeed.
> 
> Thank you all for a good discussion.
> 
> Jim
> 
>> On Sat, Jun 6, 2020, 12:58 PM Dave Philipsen <dave at davebiz.com> wrote:
>> 
>> Well, for its intended usage of pushing/pulling registers to the stack,
>> it's the way you want it to be. For instance, it's easy to see why the
>> PC should be the first pushed and last pulled. It's also easy to see why
>> B should be pushed before A.
>> 
>> I'm sure you could find some obscure corner cases where you might want
>> it to do otherwise. But the way it's done is the most logical way and
>> you'd have a hard time convincing me it should be done any other way.
>> 
>> 
>> Dave
>> 
>> 
>>> On 6/6/2020 7:32 AM, Bill Gunshannon wrote:
>>> On 6/6/20 7:40 AM, Dave Philipsen wrote:
>>>> Which is the only way that makes any sense, pull in the opposite
>>>> order that you pushed. Any other way would not make sense.
>>>> 
>>> 
>>> Depends on what you are trying to do.  :-)
>>> 
>>> bill
>>> 
>>> 
>> 
>> --
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>> 
>> 
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>> 
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco



More information about the Coco mailing list