The current contents of the Program Counter (PC) are pushed onto the top of the external memory stack. The operands nn are then loaded to the PC to point to the address in mem- ory at which the first op code of a subroutine is to be fetched. At the end of the subroutine, a RETurn instruction can be used to return to the original program flow by popping the top of the stack back to the PC. The push is accomplished by first decrementing the current contents of the Stack Pointer (register pair SP), loading the high-order byte of the PC con- tents to the memory address now pointed to by the SP; then decrementing SP again, and loading the low-order byte of the PC contents to the top of stack. Because this process is a 3-byte instruction, the Program Counter was incremented by three before the push is executed.
The Program Counter contains 1A47h, the Stack Pointer contains 3002h, and memory locations contain the following data. Location Contents 1A47h CDh IA48h 35h 1A49h 21h If an instruction fetch sequence begins, the 3-byte instruction CD 3521h is fetched to the CPU for execution. The mnemonic equivalent of this instruction is CALL 2135h. Upon the execution of this instruction, memory address 3001h contains 1Ah, address 3000h contains 4Ah, the Stack Pointer contains 3000h, and the Program Counter contains 2135h, thereby pointing to the address of the first op code of the next subroutine to be executed.