XA User Guide 2-11 3/24/97
With these two features, a simple monitor debugger routine can allow a user to single step
through a program, or to run a program at full speed, stopping only when execution reaches a
breakpoint, in either case viewing the CPU state before continuing.
2.4 Task Management
Several features of the XA have been included to facilitate multi-tasking. Multi-tasking can be
thought of as running several programs at once on the same processor, with a supervisory
program determining when each program, or task, runs, and for how long. Since each task shares
the same CPU, the system resources required by each must be kept separate and the CPU state
restored when switching execution from one task to another. The problem is much simpler for a
microcontroller than it is for a microprocessor, because the code executed by a microcontroller
always comes from the same source: the designers of the system it runs on. Thus, this code can
be considered to be basically trustworthy and extreme measures to prevent misbehavior are not
necessary. The emphasis in the XA design is to protect against simple accidents.
The first step in supporting multi-tasking is to provide two execution contexts, one for the basic
tasks –on the XA termed “user mode”– and one for the supervisory program –"system mode.". A
program running in system mode has access to all of the processor’s resources and can set up and
launch tasks.
Code running in system and user mode use different stack pointers, the System Stack Pointer
(SSP) and the User Stack Pointer (USP) respectively. The system stack is always located in the
first 64K data memory segment, where it can take advantage of the fast on-chip RAM. The user
stack is located within each task’s local data segment, identified by the DS register. The fact that
user mode code uses a different stack than system mode code prevents tasks from accidentally
destroying data on the system stack and in other task spaces.
Additional protection mechanisms are provided in the form of control bits and registers that are
only writable by system mode code. For instance the DS register, that identifies the local data
segment for user mode code, is only writable in the system mode. While tasks can still write to
the other segment register, the ES register, they cannot write to memory via the ES register
unless specifically allowed to do so by the system. The data memory segmentation scheme thus
prevents tasks from accessing data memory in unpredictable ways.
Other protected features include enabling of the Trace Mode and alteration of the Interrupt Mask.
The 4 register banks are a feature that can be useful in small multi-tasking systems by using each
bank for a different task, including one for system code. This means less CPU state that must be
saved during task switching.