User’s Manual
C166S V1 SubSystem
Central Processing Unit
User’s Manual
3-67
V 1.6, 2001-08
internal stack, this circular stack mechanism only requires moving that portion of stack
data that is to be re-used (i.e. the upper part of the defined stack area) instead of the
whole stack area. Stack data that remain in the lower part of the internal stack need not
be moved by the distance of the space being flushed or filled, as the stack pointer
automatically wraps around to the beginning of the freed part of the stack area.
Note: This circular stack technique is applicable for stack sizes of 32 to 512 words
(STKSZ = 000
B
to 100
B
). It does not work with option STKSZ = 111
B
, which uses
the complete DPRAM for system stack; in this case, the address transformation
mechanism is deactivated.
When a boundary is reached, the stack underflow or overflow trap is entered. Inside the
trap handler a predetermined portion of the internal stack is moved to or from the external
stack. The amount of data transferred is determined by the average stack space required
by routines and the frequency of calls, traps, interrupts, and returns. In most cases, this
will be approximately 1/4 to 1/10 the size of the internal stack. Once the transfer is
complete, the boundary pointers are updated to reflect the newly allocated space on the
internal stack. Thus, the user is free to write code without concern for the internal stack
limits. Only the execution time required by the trap routines affects user programs.
The following procedure initializes the controller for usage of the circular stack
mechanism:
1. Specify the size of the physical system stack area within the DPRAM (bitfield STKSZ
in register SYSCON).
2. Define two pointers that specify the upper and lower boundary of the external stack.
These values are then tested in the stack underflow and overflow trap routines when
moving data.
3. Set STKOV to the limit of the defined internal stack area plus six words (for the
reserved space to store two interrupt entries).
The internal stack will now fill until the overflow pointer is reached. After entry into the
overflow trap procedure, the top of the stack will be copied to the external memory. The
internal pointers will then be modified to reflect the newly-allocated space. After exiting
the trap procedure, the internal stack will wrap around to the top of the internal stack, and
continue to grow until the new value of the stack overflow pointer is reached.
When the underflow pointer is reached, while the stack is emptied, the bottom of stack
is reloaded from the external memory, and the internal pointers are adjusted accordingly.
Содержание C166S V1 SubSystem
Страница 10: ...User s Manual C166S V1 SubSystem User s Manual I 6 V 1 6 2001 08...
Страница 16: ...User s Manual C166S V1 SubSystem Introduction User s Manual 1 6 V 1 6 2001 08...
Страница 126: ...User s Manual C166S V1 SubSystem Central Processing Unit User s Manual 3 96 V 1 6 2001 08...
Страница 178: ...User s Manual C166S V1 SubSystem Memory Organization User s Manual 4 52 V 1 6 2001 08...
Страница 206: ...User s Manual C166S V1 SubSystem Instruction Set User s Manual 5 28 V 1 6 2001 08...
Страница 306: ...User s Manual C166S V1 SubSystem Detailed Instruction Set User s Manual 6 100 V 1 6 2001 08...
Страница 362: ...User s Manual C166S V1 SubSystem The External Bus Interface User s Manual 8 40 V 1 6 2001 08...
Страница 452: ...User s Manual C166S V1 SubSystem General Purpose Timer Unit User s Manual 12 44 V 1 6 2001 08...
Страница 454: ...User s Manual C166S V1 SubSystem Instruction Index User s Manual 13 2 V 1 6 2001 08...
Страница 459: ......