6 Stack and Subroutines
6 Stack and Subroutines
• CALL 2050H
– The program sequence is transferred to the
address specified by the operand. Before the
transfer, the address of the next instruction to
CALL(the contents of the program counter) is
pushed on the stack.
THE CALL INSTRUCTION
Mem Add Hexcode Mnemonics
2010 CD CALL2050H
2011 50
2012 20
The address in the program counter (2013H) is placed on
the stack as follows:
Stack pointer is decremented to 2098H
MSB is stored 2097 13
Stack pointer is again decremented 2098 20
SP 2099
LSB is stored
Call address (2050H) is temporarily stored in internal WZ
registers placed on the bus for fetch cycle.
CONDITIONAL CALLS
Instruction Code Description Condition for CALL
When the instruction RET is executed, When the instruction POP is executed,
the stack pointer is incremented by two. the stack pointer is incremented by two.
In addition to the unconditional CALL There are no conditional PUSH and POP
and RET instructions, there are eight instructions.
conditional CALL and RETURN
instructions.
POP Rp
NEXT:
Interrupts