37
μ
PD17068
3.4 ADDRESS STACK OPERATION
3.4.1 Subroutine Call Instruction (“CALL addr” or “CALL @AR”) and Return Instruction (“RET” or “RETSK”)
When a subroutine call instruction is executed, the value of the stack pointer is decremented by one, after
which the return address is stored in the address stack register specified with the stack pointer.
When a return instruction is executed, the contents (return address) of the address stack register specified
with the stack pointer are read back into the program counter, after which the value of the stack pointer is
incremented by one.
3.4.2 Table Reference Instruction (“MOVT DBF, @AR”)
When a table reference instruction is executed, the value of the stack pointer is decremented by one, after
which the return address is stored in the address stack register specified with the stack pointer.
Next, the contents of the program memory address specified with the address register are read into the
data buffer. Finally, the contents (return address) of the address stack register specified with the stack pointer
are read back into the program counter, after which the value of the stack pointer is incremented by one.
3.4.3 Interrupt Reception and Return Instruction (“RETI”)
When an interrupt is received, the value of the stack pointer is decremented by one, after which the return
address is stored in the address stack register specified with the stack pointer.
When a return instruction is executed, the contents (return address) of the address stack register specified
with the stack pointer are read back into the program counter, after which the value of the stack pointer is
incremented by one.
3.4.4 Address Stack Manipulation Instructions (“PUSH AR”, “POP AR”)
When a PUSH instruction is executed, the value of the stack pointer is decremented by one, after which
the contents of the address register are transferred to the address stack register specified with the stack
pointer.
When a POP instruction is executed, the contents of the address stack register specified with the stack
pointer are transferred to the address register, after which the value of the stack pointer is incremented by
one.
3.4.5 System Call Instruction (“SYSCAL entry”) and Return Instruction (“RET” or “RETSK”)
When a “SYSCAL entry” instruction is executed, the value of the stack pointer is decremented by one, after
which the return address and the value of the segment register are stored in the address stack register specified
with the stack pointer.
When a return instruction is executed, the contents of the address stack register specified with the stack
pointer are restored into the program counter and segment register, after which the value of the stack pointer
is incremented by one.
3.5 NOTES ON USE OF ADDRESS STACK
3.5.1 Nesting Level
When the stack pointer contains 0CH, it specifies address stack register ASR12, whose value is undefined.
If the user attempts to use subroutine calls or interrupts that exceed 12 levels, without stack manipulation,
the program will resume from an undefined address. Therefore, do not attempt such an operation.