First page Back Continue Last page Overview Graphics

Reentrant Subroutine Example


This subroutine allocates 5 bytes within the stack frame for storage of local values. The stack pointer is decremented by five. Up to five bytes of local data can be saved and modified. The value in the stack pointer is copied into index register X to access the frame. If this subroutine is interrupted and called during the interrupt sequence, local storage space within a new stack frame will be allocated.

The LEAS instruction (load stack pointer with effective address) increments the stack pointer to create storage space. The TSX instruction (transfer from stack pointer to index register X) loads the contents of the stack pointer into the X register. This becomes the frame pointer.

The next slide shows the subroutine termination.