[Coco] Pop PC with empty stack?

Gene Heskett gene.heskett at verizon.net
Tue Apr 6 10:37:39 EDT 2010


On Tuesday 06 April 2010, Lothan wrote:
>I'm hoping someone can help refresh my memory on the internals of OS-9.
> Specifically, I'm seeing this code:
>
> PSHS Y
> ...
> PSHS X
> ...
> LDA ,-X
> CMPA #$30
> BCS L016C
> CMPA #$39
> BHI L016C
>...
>L016C LDD 2,U
> PULS X
> PULS Y,PC
>
>That it's popping X and Y from the stack makes perfect sense because those
> two registers were pushed onto the stack previously. At this point the
> stack should be empty, so what happens when it attempts to pop PC from
> the stack? Is this effectively the same as OS9 F$Exit?
>
No, that is the shorthand way to do an RTS, saving an instruction fetch 
cycle in the process.  The stack, in general, is never 'empty' and the last 
2 bytes that will fetch to the pc are the return address that it got there 
from.

>--
>Coco mailing list
>Coco at maltedmedia.com
>http://five.pairlist.net/mailman/listinfo/coco
>


-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

Inara: "This is just a moment in time.  Step aside and let it happen."
				--Episode #13, "Heart of Gold"



More information about the Coco mailing list