home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / misc / mcx11 / manual.doc < prev    next >
Encoding:
Text File  |  1990-04-11  |  126.3 KB  |  3,829 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.             
  9.             
  10.             
  11.             
  12.             
  13.             
  14.             
  15.                                        MCX11
  16.                                           
  17.                              MicroController eXecutive
  18.                                       for the
  19.                                  Motorola MC68HC11
  20.                                           
  21.                                     Version 1.3
  22.             
  23.             
  24.             
  25.             
  26.                                          by
  27.             
  28.                              A.T. Barrett & Associates
  29.                                  11501 Chimney Rock
  30.                                 Houston, Texas 77035
  31.                                    (713)728-9688
  32.             
  33.             
  34.                                     April 1990
  35.             
  36.             
  37.                                   Support Contact:
  38.                                           
  39.                                      Mike Wood
  40.                                      M/S OE319
  41.                                    Motorola, Inc.
  42.                            6501 William Cannon Drive West
  43.                                 Austin, Texas 78735
  44.                                    (512)891-2717
  45.             
  46.             
  47.             
  48.             Neither Motorola,  Inc. nor  A.T. Barrett & Associates makes
  49.             any warranty,  expressed or  implied, with  regard  to  this
  50.             material including  but not  limited to  merchantability  or
  51.             fitness for  a given  purpose.    The  information  in  this
  52.             document is  subject to  change without  notice and  neither
  53.             Motorola, Inc.  or A.T.  Barrett &  Associates  assumes  any
  54.             responsibility for  any errors which may appear herein.  Nor
  55.             shall Motorola,  Inc. or  A.T. Barrett & Associates bear any
  56.             liability  for   use   of   this   material   with   respect
  57.             compensatory,   special,   incidental,   consequential,   or
  58.             exemplary damages.
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                   MCX11 - MicroController eXecutive for the 68HC11
  71.                                           
  72.                                           
  73.                                   TABLE OF CONTENTS
  74.                                           
  75.             
  76.             Section 1  Introduction                               Page
  77.             
  78.             1.1  Background and Features........................... 1-1
  79.             1.2  MCX11 as a Software Component..................... 1-1
  80.             1.3  Target Environment................................ 1-2
  81.             1.4  Development Environment........................... 1-2
  82.             1.5  Manual Format..................................... 1-2
  83.             
  84.             Section 2  MCX11 Functional Overview
  85.             
  86.             2.1  What Is MCX11..................................... 2-1
  87.             2.2  Tasks............................................. 2-2
  88.             2.3  Multitasking...................................... 2-2
  89.             2.4  Priority and Scheduling........................... 2-2
  90.             2.5  Intertask Communication and Synchronization....... 2-3
  91.             2.6  Time based Functions.............................. 2-4
  92.             2.7  Interrupt Service................................. 2-4
  93.             
  94.             Section 3  MCX11 Control & Data Structures
  95.             
  96.             3.1 Tasks.............................................. 3-1
  97.             3.1.1 Task Identifier & Priority....................... 3-1
  98.             3.1.2 Task State Table................................. 3-2
  99.             3.1.3 Stack............................................ 3-3
  100.             3.2  Semaphores........................................ 3-3
  101.             3.3  Messages and Mailboxes............................ 3-5
  102.             3.4  Queues............................................ 3-7
  103.             3.5 Timers............................................. 3-8
  104.             
  105.             Section 4  Executive Service Requests (ESRs)
  106.             
  107.             4.1  Purpose........................................... 4-1
  108.             4.2  Semaphore ESRs.................................... 4-1
  109.             4.3  Message ESRs...................................... 4-2
  110.             4.4  Queue ESRs........................................ 4-2
  111.             4.5  Task Control ESRs................................. 4-2
  112.             4.6  Time Based ESRs................................... 4-2
  113.             
  114.             Section 5  Alphabetical Listing of ESRs
  115.             
  116.             5.1  .delay.  -  Delay a Task for a Period of Time..... 5-2
  117.             5.2  .dequeue.  -  Get an Entry from a FIFO Queue...... 5-4
  118.             5.3  .enqueue.  -  Insert Data into FIFO Queue......... 5-6
  119.             5.4  .execute.  -  Execute a Task...................... 5-9
  120.             5.5  .pend.  -  Force a Semaphore to a PENDING State.. 5-11
  121.             5.6  .purge.  -  Purge a Task's Timers................ 5-12
  122.             5.7  .receive.  -  Receive a Message.................. 5-14
  123.             5.8  .resume.  -  Resume a Task....................... 5-16
  124.             5.9  .send.  -  Send a Message to a Task.............. 5-17
  125.             5.10  .sendw.  -  Send a Message and Wait............. 5-19
  126.             5.11  .signal.  -  Signal a Semaphore................. 5-20
  127.  
  128.  
  129.  
  130.                                         Page i
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.                   MCX11 - MicroController eXecutive for the 68HC11
  138.                                           
  139.                                           
  140.                                   TABLE OF CONTENTS
  141.                                           
  142.             5.12  .suspend.  -  Suspend a Task.................... 5-22
  143.             5.13  .terminate.  -  Terminate a Task................ 5-23
  144.             5.14  .timer.  -  Start a Timer....................... 5-24
  145.             5.15  .wait.  -  Wait on Semaphore.................... 5-26
  146.             
  147.             Section 6  System Configuration
  148.             
  149.             6.1  System Configuration Concepts..................... 6-1
  150.             6.2  MCX11 System Table Memory Requirements............ 6-1
  151.             
  152.             Section 7  Device Driver & Interrupts
  153.             
  154.             7.1  Driver Concepts................................... 7-1
  155.             7.2  Interrupt Service................................. 7-1
  156.             7.2.1 Interrupt Processing Variables................... 7-2
  157.             7.2.2 Interrupt Processing Code........................ 7-4
  158.             
  159.             Section 8  Advanced Topics
  160.             
  161.             8.1  Other topics...................................... 8-1
  162.             
  163.             Appendix A  MCX11 Distributed Source Files............. A-1
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.                                        Page ii
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.                   MCX11 - MicroController eXecutive for the 68HC11
  205.  
  206.  
  207.  
  208.                                      SECTION 1
  209.                                           
  210.                                     INTRODUCTION
  211.                                           
  212.                                           
  213.             1.1  BACKGROUND AND FEATURES
  214.             
  215.             MCX11, the MicroController eXecutive for the MC68HC11, is an
  216.             efficient  software   framework   for   embedded   real-time
  217.             applications using  the Motorola  MC68HC11  microcontroller.
  218.             Motorola, Inc.  makes MCX11 available free of charge via the
  219.             Freeware Bulletin  Board System.   MCX11  is written  in the
  220.             AS11 assembly  language  which  is  also  available  on  the
  221.             Motorola Freeware BBS (512/891-3733).
  222.             
  223.             MCX11 provides  many features  which are designed to support
  224.             real-time applications.  These features include:
  225.             
  226.                 -     Multitasking for up to 126 tasks
  227.                 -     Pre-emptive task scheduling by priority
  228.                 -     Intertask communication and synchronization via
  229.                        semaphores, messages, and queues.
  230.                 -     Support for timed operations
  231.                 -     Fast context switch
  232.                 -     Very small RAM and ROM requirements
  233.                 -     Fifteen Executive Service Request functions
  234.             
  235.             
  236.             1.2  MCX11 AS A SOFTWARE COMPONENT
  237.             
  238.             MCX11 is  furnished in  AS11 source form and is downloadable
  239.             via  a   modem  connection  to  the  Freeware  BBS.  In  its
  240.             distribution  form,  it  is  not  executable.    It  may  be
  241.             assembled separately  or with  the application  programs and
  242.             any device  drivers peculiar  to the application.  MCX11 may
  243.             be treated as any other software library.  The user need not
  244.             know how  MCX11 performs  its functions internally.  Rather,
  245.             the user  need only  know what  functions of MCX11 to use to
  246.             achieve a  desired result.   Thus, MCX11 becomes much like a
  247.             large scale  integrated circuit  component in  the hardware.
  248.             Knowledge of what inputs produce what outputs is all that is
  249.             needed to  use  the  "chip"  successfully.  Unlike  a  chip,
  250.             however, MCX11  users are  provided with  the source code to
  251.             the kernel  so that  they can exercise complete control over
  252.             their applications.  With the  source code,  users may  even
  253.             wish to extend the functionality of MCX11 by the addition of
  254.             new services.
  255.             
  256.             This manual  is not meant as a tutorial on real-time kernels
  257.             in general.  It is  intended to  explain  the  "inputs"  and
  258.             "outputs" of  MCX11 as  a software  component of  the user's
  259.             application.  In  an  effort  to  assist  the  user  in  the
  260.  
  261.  
  262.  
  263.             Copyright (c) 1989         Page 1 - 1          Motorola, Inc.
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.                   MCX11 - MicroController eXecutive for the 68HC11
  271.  
  272.  
  273.  
  274.             successful employment  of MCX11,  this manual will cover the
  275.             following subjects:
  276.             
  277.                 -     basic concepts of MCX11 design
  278.                 -     interfaces to the MCX11 services
  279.                 -     system generation procedure
  280.                 -     assembly procedure for MCX11 and application
  281.                        source files
  282.                 -     procedure for merging MCX11 with the application
  283.                        object files
  284.             
  285.             1.3  TARGET ENVIRONMENT
  286.             
  287.             MCX11 is  designed to operate in an embedded processor, that
  288.             is, one whose functions are fixed within the application. No
  289.             assumptions are  made about  the configuration of the target
  290.             system.   It is the responsibility of the user to define the
  291.             target environment  and to insure that all necessary devices
  292.             have program support. No distinction is made between Single-
  293.             Chip Operating  mode or  Expanded Multiplexed Operating mode
  294.             in the design of MCX11. If there are special requirements in
  295.             the application for functions related to a certain operating
  296.             mode, it will be the responsibility of the user to add them.
  297.             
  298.             
  299.             1.4  DEVELOPMENT ENVIRONMENT
  300.             
  301.             MCX11 development  requires a  computer compatible  with the
  302.             IBM PC and having at least 256K bytes of RAM, 1 floppy disk,
  303.             a keyboard, and a video monitor, an RS-232 compatible serial
  304.             I/O port, a Centronics compatible parallel printer port, and
  305.             a printer (preferably one which is Epson compatible). A hard
  306.             disk  is   very  desirable   for  development   work.   This
  307.             configuration is  needed to run the AS11 cross assembler and
  308.             serve as a debug terminal to the target assuming MC68HC11EVM
  309.             Evaluation Module is being used. Consult the EVM User Manual
  310.             for specifics  on connection tp PC. Recommended software for
  311.             the  development  environment  besides  MS-DOS  includes  an
  312.             editor,  and   the  Kermit  communications  program  (public
  313.             domain).
  314.             
  315.             
  316.             1.5  MANUAL FORMAT
  317.             
  318.             Section 1 of this manual is simply an overview of MCX11.
  319.             
  320.             Section 2 gives the functional overview of MCX11.
  321.             
  322.             Section 3  details  the  organization  and  content  of  the
  323.             various MCX11 control and data structures.
  324.             
  325.  
  326.  
  327.  
  328.  
  329.             Copyright (c) 1989         Page 1 - 2          Motorola, Inc.
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.                   MCX11 - MicroController eXecutive for the 68HC11
  337.  
  338.  
  339.  
  340.             Section 4  gives a  description  of  the  Executive  Service
  341.             Requests (ESRs)  provided by  MCX11, subdivided  into  their
  342.             classes.
  343.             
  344.             Section 5  gives an  alphabetical presentation  of all MCX11
  345.             Executive Service Requests.
  346.             
  347.             Section 6  deals with  the configuration  and generation  of
  348.             MCX11 systems.
  349.             
  350.             Section 7  discusses device  drivers and  interuupt  service
  351.             routines.
  352.             
  353.             Section 8  presents technical information on advanced topics
  354.             related to the use of MCX11.
  355.             
  356.             Appendices  round   out  the  specifics  of  necessary  user
  357.             knowledge.
  358.             
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.             Copyright (c) 1989         Page 1 - 3          Motorola, Inc.
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.                   MCX11 - MicroController eXecutive for the 68HC11
  403.  
  404.  
  405.  
  406.                                      SECTION 2
  407.                                           
  408.                              MCX11 FUNCTIONAL OVERVIEW
  409.                                           
  410.             
  411.             2.1  WHAT IS MCX11
  412.             
  413.             A real-time  executive provides  a software framework within
  414.             which different  processes can  operate and  gain access  to
  415.             various system resources.  Real-time systems usually consist
  416.             of several  processes, or  tasks, which need to have control
  417.             of  the  system  resources  at  varying  times  due  to  the
  418.             occurrence of  external events.  These tasks  are at various
  419.             times  competing   for  system  resources  such  as  memory,
  420.             execution time, or peripheral devices. They range from being
  421.             compute bound  to I/O  bound. Tasks which are I/O or compute
  422.             bound   cannot be allowed to monopolize a system resource if
  423.             a more important function requires the same resource.  There
  424.             must be  a way  of interrupting the operation of the task of
  425.             lesser importance  and granting  the needed  resource to the
  426.             more important task.
  427.             
  428.             A multitasking   real-time  executive  promotes  an  orderly
  429.             transfer of  control from  one task  to  another  such  that
  430.             efficient usage  of the  computer's resources  is  achieved.
  431.             Orderly transfers  require that  the executive keep track of
  432.             the needed resources and the execution state of each task so
  433.             that they  can be  granted to  each task in a timely manner.
  434.             The key  word there is timely. A real-time system which does
  435.             not perform  a required  operation at  the correct  time has
  436.             failed. That  failure can have consequences which range from
  437.             the benign  to the catastrophic. Response time to a need for
  438.             executive services  and the  execution time of such services
  439.             must be  sufficiently fast  enough  so  that  no  need  goes
  440.             undetected.
  441.             
  442.             One way  to  achieve  timeliness  is  the  assignment  of  a
  443.             priority to  each task.  The priority of a task is then used
  444.             to determine  its place  within the sequence of execution of
  445.             all tasks.  Tasks of  low priority  may have their execution
  446.             pre-empted by  a task  of higher priority so that the latter
  447.             can perform some time critical function.
  448.             
  449.             An event  can be any stimulus which requires a reaction from
  450.             the executive  or a task. Examples of an event would include
  451.             a timer  interrupt, an alarm condition, or a keyboard input.
  452.             Events  may   originate  externally   to  the  processor  or
  453.             internally from  within the  software.  An  executive  which
  454.             responds to  these events  as  the  stimuli  for  allocating
  455.             resources is  said to  be event  driven. If response time to
  456.             any event   occurs  within a  period of  time which  can  be
  457.  
  458.  
  459.  
  460.  
  461.             Copyright (c) 1989         Page 2 - 1          Motorola, Inc.
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.                   MCX11 - MicroController eXecutive for the 68HC11
  469.  
  470.  
  471.  
  472.             accurately defined and guaranteed, the executive can be said
  473.             to be deterministic.
  474.             
  475.             By  these  definitions,  MCX11  is  a  deterministic,  event
  476.             driven, multitasking, real-time executive.
  477.             
  478.             
  479.             2.2  TASKS
  480.             
  481.             In MCX11, a task is a program module which exists to perform
  482.             a  defined  function  or  set  of  functions.    A  task  is
  483.             independent of  other tasks  but may establish relationships
  484.             with other tasks.  These relationships may exist in the form
  485.             of data  structures, input/output,  or other  constructs.  A
  486.             task executes when the MCX11 task dispatcher determines that
  487.             the resources  required by  the task are available.  Once it
  488.             begins running,  the task has control of all of the system's
  489.             resources.   But as  there are  other tasks in the system, a
  490.             running task  cannot  be  allowed  to  control  all  of  the
  491.             resources all  of the time.  Thus, MCX11 employs the concept
  492.             of multitasking.
  493.             
  494.             
  495.             2.3  MULTITASKING
  496.             
  497.             Multitasking appears  to  give  the  computer  the  apparent
  498.             ability to  be performing  multiple operations concurrently.
  499.             Obviously, the  computer cannot  be doing two or more things
  500.             at once  as it  is a  sequential machine.  However, with the
  501.             functions of the system segregated into different tasks, the
  502.             effect of  concurrency can  be achieved.   In  multitasking,
  503.             each task  once  given  operating  control  either  runs  to
  504.             completion, or to a point where it must wait for an event to
  505.             occur, for  a needed  resource to become available, or until
  506.             it is  interrupted.   Efficient use  of the  computer can be
  507.             obtained by  using the  time a task might otherwise wait for
  508.             an event to occur to run another task.
  509.             
  510.             This switching  from one  task to another forms the basis of
  511.             multitasking.  The result is the appearance of several tasks
  512.             being executed simultaneously.
  513.             
  514.             
  515.             2.4  PRIORITY AND SCHEDULING
  516.             
  517.             When several  tasks can  be competing  for the  resource  of
  518.             execution time,  the problem is to determine how to grant it
  519.             so that  each gets  access to  the system in time to perform
  520.             its function.  The solution  is to assign a priority to each
  521.             task indicative of its relative importance to other tasks in
  522.             the system.   MCX11 uses a fixed priority scheme in which up
  523.             to 126  tasks may  be defined.   Tasks  which have a need to
  524.  
  525.  
  526.  
  527.             Copyright (c) 1989         Page 2 - 2          Motorola, Inc.
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.                   MCX11 - MicroController eXecutive for the 68HC11
  535.  
  536.  
  537.  
  538.             respond rapidly  to events  are  assigned  high  priorities.
  539.             Those which perform functions that are not time critical are
  540.             assigned lower priorities.
  541.             
  542.             It is  the priority of each task that determines where it is
  543.             to run  in the  hierarchy of  tasks.   When a  task may  run
  544.             depends  on  what  is  happening  to  the  tasks  of  higher
  545.             priority.   Tasks are  granted execution  time in  a  strict
  546.             descending order  of priority.   While executing, a task may
  547.             be interrupted  by an  event which  causes a  task of higher
  548.             priority to be runnable.  The lower  priority task is placed
  549.             into a  temporary state  of suspension and execution control
  550.             is granted to the higher priority task.  Eventually, control
  551.             is returned to the interrupted task and it is resumed at the
  552.             point of  its interruption.   Thus,  when any  task is given
  553.             execution control,  no higher  priority task  can  be  in  a
  554.             runnable state.  This is a most important point to remember.
  555.             When all  tasks are  in  an  unrunnable  state,  control  is
  556.             granted to the null task.
  557.             
  558.             The null  task is  a do-nothing task which allows the system
  559.             to run in an idle mode while waiting for an event which will
  560.             resume or  start a  higher priority  task.  The null task is
  561.             always the  lowest priority task in the system and is always
  562.             runnable. It is an integral part of the kernel.
  563.             
  564.             
  565.             2.5  INTERTASK COMMUNICATION AND SYNCHRONIZATION
  566.             
  567.             MCX11 provides  an environment whereby two or more tasks can
  568.             communicate with one another.  The three major ways in which
  569.             this  is  done  are  through  the  mechanisms  of  semaphore
  570.             signalling, message  transmission, and  queues.  A semaphore
  571.             is actually  a flag  which contains  information  about  the
  572.             state of  the associated event.  Any event which is used for
  573.             task synchronization  will be  associated with  a particular
  574.             semaphore.   The occurrence  of  a  specific  event  can  be
  575.             signalled by manipulating the semaphore associated with that
  576.             event.
  577.             
  578.             Message transmission  involves the  logical transfer of data
  579.             packets from  one task  to another.   These data packets are
  580.             called "messages".   Messages  are sent  from one  task  and
  581.             placed in  the "mailbox"  of the receiving task in the order
  582.             of the  priorities of  the senders.   Messages may be of any
  583.             format recognizable  by the sender and receiver and data may
  584.             be passed  in either direction.  That is, it is possible for
  585.             two tasks to alternate the roles of sender and receiver.
  586.             
  587.             A third  technique whereby  two tasks  can  communicate  and
  588.             synchronize is  via  a  first-in-first-out  (FIFO)  queueing
  589.             mechanism.   The queueing  techniques used  by MCX11 involve
  590.  
  591.  
  592.  
  593.             Copyright (c) 1989         Page 2 - 3          Motorola, Inc.
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.                   MCX11 - MicroController eXecutive for the 68HC11
  601.  
  602.  
  603.  
  604.             the physical  transfer (copying)  of data  packets from  one
  605.             task to  another.   Task  synchronization  due  to  queueing
  606.             operations is automatically performed by MCX11.
  607.             
  608.             
  609.             2.6  TIME BASED FUNCTIONS
  610.             
  611.             An MCX11  system is  configured with an interval timer using
  612.             the Real  Time Interrupt (RTI) clock as a peripheral device.
  613.             The timer  permits  task  control  on  a  timed  basis.    A
  614.             generalized scheme  using  one-shot  and  cyclic  timers  in
  615.             conjunction with  semaphores is provided.  MCX11 efficiently
  616.             manages multiple  timers using  an ordered  linked  list  of
  617.             pending timer  events. A timer for an event is inserted into
  618.             the  linked   list  in   accordance  with  its  duration.  A
  619.             differential technique  is employed  so that  the timer with
  620.             the shortest  time to expiration is at the head of the list.
  621.             Timed  events  may  even  be  co-terminous.  Directives  for
  622.             scheduling and  cancelling timed events are an integral part
  623.             of the executive.
  624.             
  625.             
  626.             2.7  INTERRUPT SERVICE
  627.             
  628.             Support  for  a  generalized  interrupt  service  scheme  is
  629.             provided within  the MCX11  kernel. The   Interrupt  Service
  630.             Routine (ISR)  code, however,  is provided  by the User. The
  631.             rules for  writing interrupt  service routines that function
  632.             with  MCX11   are  quite   simple  and  require  only  minor
  633.             housekeeping  chores.   MCX11  also   provides  the   common
  634.             Interrupt Service  Exit function.  This logic is used by all
  635.             interrupts to  determine if  a context switch is in order as
  636.             the result  of the interrupt. If no task switch is required,
  637.             the  interrupted  task  is  resumed  at  the  point  of  the
  638.             interrupt. If,  however, a  task switch  is  in  order,  the
  639.             interrupted task's  context is saved, the new task's context
  640.             is loaded and control is given to it.
  641.             
  642.             
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.             Copyright (c) 1989         Page 2 - 4          Motorola, Inc.
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.                   MCX11 - MicroController eXecutive for the 68HC11
  667.  
  668.  
  669.  
  670.                                      SECTION 3
  671.                                           
  672.                           MCX11 CONTROL & DATA STRUCTURES
  673.                                           
  674.             
  675.             In order  to understand  how MCX11  works and  how to  build
  676.             real-time application  systems around it, it is necessary to
  677.             understand how its various control and data structures work.
  678.             This  section   describes   these   structures   and   their
  679.             interrelationships. The descriptions will include:
  680.             
  681.                  -    tasks
  682.                  -    semaphores
  683.                  -    messages and mailboxes
  684.                  -    queues
  685.                  -    timers
  686.             
  687.             The MCX11  executive services  which deal with these classes
  688.             of control  and data  structures  will  be  presented  in  a
  689.             subsequent section.
  690.             
  691.             
  692.             3.1 TASKS
  693.             
  694.             In a real-time application using MCX11, the functions of the
  695.             system are  assigned to  various tasks. MCX11 supports up to
  696.             126 tasks in a single system. The nature of each task is, of
  697.             course, application dependent and left to the imagination of
  698.             the system designer. However, there are attributes which all
  699.             tasks share. These include:
  700.             
  701.                  -    a task identifier
  702.                  -    a priority
  703.                  -    a task state table
  704.                  -    a stack
  705.                  -    a mailbox
  706.                  -    an entry point
  707.             
  708.             3.1.1 Task Identifier & Priority
  709.             
  710.             Each task is identified by a numerical identifier which is a
  711.             number from  1 - 126. The task identifier, or number, serves
  712.             as a  reference  during  executive  operations.  Task  1  is
  713.             executed before task 2 which is executed prior to task 3 and
  714.             so on.  Thus, the  task number  is inversely  related to the
  715.             task's execution  priority. The  lower the  task number, the
  716.             higher the  priority. MCX11  uses this  fixed task numbering
  717.             scheme because  it is low in overhead and quite adequate for
  718.             most applications.  The task  number permits a direct access
  719.             to the  task's state table without the need for linked lists
  720.             or other commonly used technique.
  721.             
  722.  
  723.  
  724.  
  725.            Copyright (c) 1989          Page 3 - 1          Motorola, Inc.
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.                   MCX11 - MicroController eXecutive for the 68HC11
  733.  
  734.  
  735.  
  736.             3.1.2 Task State Table
  737.             
  738.             The state  table is  commonly referred  to as a Task Control
  739.             Block (TCB).  A TCB  in MCX11  is contained  in two separate
  740.             sections in  order to  minimize the  use of system RAM. Only
  741.             those data about the execution state of the task are kept in
  742.             RAM. Static  information about the task is kept in ROM. Both
  743.             sets of  this TCB information are kept in arrays which allow
  744.             direct access  to the  data based  on the  task number. This
  745.             makes for very quick access without the commonly wasted time
  746.             of searching a linked list.
  747.             
  748.             The RAM portion of the TCB contains only volatile data about
  749.             the task and includes the following:
  750.             
  751.                  -    the execution state
  752.                  -    the stack pointer
  753.                  -    the first link in the task's mailbox
  754.             
  755.             Whenever the  MCX11 dispatcher  is looking  for  a  task  to
  756.             execute, it  examines the execution state variable to see if
  757.             the  task  is  runnable  or  not.  The  execution  state  is
  758.             contained in a single byte and a value of $00 indicates that
  759.             the task  is runnable.  Any other  content in the task state
  760.             and the task is blocked from running.
  761.             
  762.             The stack  pointer contains  the address of the current top-
  763.             of-stack.
  764.             
  765.             The first link in the task's mailbox contains the address of
  766.             the highest  priority message  waiting to be received by the
  767.             task. If no message is waiting, the pointer contains zero.
  768.             
  769.             The ROM part of the TCB contains:
  770.             
  771.                  -    the initial execution state
  772.                  -    the entry point
  773.                  -    the base address of the stack
  774.                  -    the address of the RAM part of the TCB
  775.             
  776.             The initial  execution state  is  specified  by  the  system
  777.             designer at  the time  of system configuration. This becomes
  778.             the initial  content of the execution state. By specifying a
  779.             value of  zero, the  task will be executed immediately after
  780.             initialization   in    accordance   with    its    priority.
  781.             Specification of a non-zero value will prevent the task from
  782.             automatically starting execution after initialization.
  783.             
  784.             The entry  point is  the address  where the task is to begin
  785.             execution.
  786.             
  787.  
  788.  
  789.  
  790.  
  791.            Copyright (c) 1989          Page 3 - 2          Motorola, Inc.
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.                   MCX11 - MicroController eXecutive for the 68HC11
  799.  
  800.  
  801.  
  802.             The base  address of  the stack  identifies that location in
  803.             RAM where the task's stack begins.
  804.             
  805.             The address of the RAM part of the TCB table is included for
  806.             completeness and  is sometimes  used to save time in setting
  807.             up the address of the RAM TCB area.
  808.             
  809.             3.1.3 Stack
  810.             
  811.             Each task must have a stack on which the context of the task
  812.             is saved  during those periods when the task is not actually
  813.             executing. The  base address  of the  stack is stored in the
  814.             ROM portion  of the  TCB. The  stack extends  from the  base
  815.             address downward  in memory, i.e. towards address $0000, for
  816.             a number  of bytes specified by the given stack size for the
  817.             task. The  size of  each task's  stack is  dependent on many
  818.             things such  as the  maximum  depth  of  nested  subroutines
  819.             calls, the  maximum  amount  of  working  space  needed  for
  820.             temporary variables,  and the  size of any stack frames used
  821.             by the  task. At  minimum, the  size of the stack must allow
  822.             for the  storage of  a complete  context which requires nine
  823.             (9) bytes.  If XIRQ  is to  be used  in the design, an extra
  824.             nine (9) bytes must be allocated to each task's stack due to
  825.             the possibility of stacking an IRQ followed by an XIRQ. This
  826.             is possible  because the  XIRQ  cannot  be  masked  and  can
  827.             interrupt an IRQ interrupt service routine at any point.
  828.             
  829.             In addition to the stacks needed by the tasks, there is also
  830.             the need  for a stack for MCX11. This system stack must have
  831.             sufficient space  to handle the maximum number of interrupts
  832.             possible  at  any  given  time,  less  one  interrupt.  Each
  833.             interrupt requires  nine bytes. MCX11 functions have a worst
  834.             case stack  requirement of  seven (7)  bytes  not  including
  835.             those bytes required for the system stack.
  836.             
  837.             The sum  of all  of the  stack requirements  should  not  be
  838.             allowed to exceed available RAM or there will be trouble.
  839.             
  840.             
  841.             3.2  SEMAPHORES
  842.             
  843.             Semaphores (event  flags) are  used to synchronize two tasks
  844.             to the  occurrence of  an asynchronous  event.  One task may
  845.             need to  wait for  the other to reach a certain point before
  846.             it can  continue.  Input/output operations are an example of
  847.             this type  of synchronization.   For instance, when an input
  848.             from an  external device  is desired by a task, it must wait
  849.             for the  input event  to occur.  When the input operation is
  850.             completed, the  device driver  signals that  the  event  has
  851.             occurred  which  indicates  the  data  is  available.    The
  852.             signalling  process  causes  the  waiting  task  to  resume,
  853.  
  854.  
  855.  
  856.  
  857.            Copyright (c) 1989          Page 3 - 3          Motorola, Inc.
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.                   MCX11 - MicroController eXecutive for the 68HC11
  865.  
  866.  
  867.  
  868.             presumably to process the input data. The synchronization of
  869.             the task with the event is done with the use of a semaphore.
  870.             
  871.             There are  several forms  that a  semaphore may  take in the
  872.             design of  a real-time kernel.  MCX11 uses a basic semaphore
  873.             construct that  is known to handle most events and is low in
  874.             overhead.  A   semaphore  is   referenced  by   a  numerical
  875.             identifier limited  to  a  value  from  1-255.  A  semaphore
  876.             identifier of  zero has  a special  meaning. There are three
  877.             different classes of semaphores used by MCX11 as follows:
  878.             
  879.                 -     Named semaphores
  880.                 -     Task semaphores
  881.                 -     Queue semaphores
  882.             
  883.             Named semaphores  are those  normally referenced by the user
  884.             in the  application code. Task and queue semaphores are used
  885.             by MCX11  internally for  the purpose  of orthogonality with
  886.             the semaphore  service functions. Task semaphores are always
  887.             referenced by the identifier of zero (0) which is translated
  888.             by MCX11  into the  proper number  for the  task  semaphore.
  889.             Queue semaphores should never be referenced by the user lest
  890.             undesirable results should occur.
  891.             
  892.             An MCX11  semaphore is a single byte (8 bits) which contains
  893.             a value  representing one  of the  three possible  states in
  894.             which it can exist.  These states are:
  895.             
  896.                 -     PENDING
  897.                 -     WAITING
  898.                 -     DONE
  899.             
  900.             A PENDING state indicates that the event associated with the
  901.             semaphore has  not yet  occurred and  is therefore  pending.
  902.             The WAITING  state shows that not only has the event not yet
  903.             occurred but  a task  is waiting for it to happen.  The DONE
  904.             state tells  that the  event has occurred.  MCX11 semaphores
  905.             have a  very  strict  state  transition  protocol  which  is
  906.             automatically managed  by  MCX11.    The  permissible  state
  907.             changes are shown below in Figure 3-1.
  908.             
  909.             
  910.                             +------- PENDING------- +
  911.                             |           ^           |
  912.                             |   |------ |           |
  913.                             v   |                   v
  914.                             DONE<--------------- WAITING
  915.             
  916.                                      Figure 3.1
  917.             
  918.             
  919.  
  920.  
  921.  
  922.  
  923.            Copyright (c) 1989          Page 3 - 4          Motorola, Inc.
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.                   MCX11 - MicroController eXecutive for the 68HC11
  931.  
  932.  
  933.  
  934.             If a  task attempts  to wait  on a semaphore which is in the
  935.             DONE state,  the  wait  does  not  occur  and  the  task  is
  936.             immediately resumed  (since the  desired event  has  already
  937.             happened)  and  the  semaphore  state  is  changed  back  to
  938.             PENDING.   If a  task attempts to wait on a semaphore in the
  939.             PENDING state,  the state  of the  semaphore is  changed  to
  940.             WAITING and  the task's  execution is  suspended  until  the
  941.             event occurs.  An attempt  to wait  on a  semaphore which is
  942.             already in the WAITING state can cause unpredictable results
  943.             and should  not be  attempted. It  should  be  considered  a
  944.             design error.
  945.             
  946.             If an  attempt is  made to  signal a semaphore which is in a
  947.             PENDING state,  the semaphore is placed into the DONE state.
  948.             As this  action does not concern any task, no further action
  949.             is taken.   However,  if a  signal is sent to a semaphore in
  950.             the WAITING state, the semaphore transitions to a DONE state
  951.             and the  task waiting  on the  event is made runnable again.
  952.             The semaphore  is then  automatically set  back to a PENDING
  953.             state by MCX11.
  954.             
  955.             
  956.             3.3  MESSAGES AND MAILBOXES
  957.             
  958.             Messages are  one of  the means by which data is transmitted
  959.             from a  sender to  a receiver task. Every task running under
  960.             MCX11  is  capable  of  being  both  a  message  sender  and
  961.             receiver. Each  task is  assigned a "mailbox" into which are
  962.             placed all  messages sent  to it. When a sender task sends a
  963.             message, it is put into the mailbox of the receiver task. If
  964.             two or more tasks are sending messages to a single receiver,
  965.             their messages  are put  into the mailbox in strict sequence
  966.             of their priorities, highest priority first.
  967.             
  968.             The content  of the  message is  not actually moved from the
  969.             sender to  the receiver  when it  is sent. Instead, messages
  970.             are linked  into a threaded list according to the priorities
  971.             of their  senders. When the receiver requests receipt of the
  972.             next  message,  its  address  is  returned.  This  technique
  973.             guarantees the receiver that the highest priority message is
  974.             received first.  It is  possible,  however,  to  temporarily
  975.             suspend this  order by requesting only those messages from a
  976.             particular sender.  This is  useful when it is desirable not
  977.             to mix  messages  on  a  shared  resource,  for  example,  a
  978.             printer.
  979.             
  980.             The mailbox  of a  task is  a threaded  (linked) list of all
  981.             messages sent  to but  not yet  received by  that task.  The
  982.             mailbox consists  of a pointer (link) to the message sent by
  983.             the highest  priority sender.  That message is linked to the
  984.             next highest  priority message  and it  in turn is linked to
  985.             the third  highest priority message, and so on until the end
  986.  
  987.  
  988.  
  989.            Copyright (c) 1989          Page 3 - 5          Motorola, Inc.
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.                   MCX11 - MicroController eXecutive for the 68HC11
  997.  
  998.  
  999.  
  1000.             of the  thread. The  last message  in a  task's mailbox will
  1001.             contain a NULL (value of zero) link.
  1002.             
  1003.             Messages may  be sent with or without waiting for a response
  1004.             from the  receiver. When  a task wants to send a message and
  1005.             wait until  the receiver  has processed the message, it will
  1006.             include a  semaphore number  as one  of the arguments in the
  1007.             MCX11   send  message  directive.  That  semaphore  is  then
  1008.             associated with  the event  of completed  processing of  the
  1009.             message. Once  the message is linked into the mailbox of the
  1010.             receiver task,  the sender  is put  into a WAIT state on the
  1011.             message processing complete event.
  1012.             
  1013.             The receiver  removes  the  message  from  the  mailbox  and
  1014.             processes it  according to  the content of the message body.
  1015.             When the  receiver no  longer needs  the data in the body of
  1016.             the message,  it signals  the semaphore  associated with the
  1017.             completion of  message processing   making  the sender  task
  1018.             runnable again  and, thereby,  allowing it  to continue  its
  1019.             operation.
  1020.             
  1021.             It should  be remembered  that the  body of  the message can
  1022.             also be  used by the receiver to send a response back to the
  1023.             sender. This  is a  very efficient  way of  passing data bi-
  1024.             directionally between two tasks with little overhead.
  1025.             
  1026.             If the  sending task  does not wish to wait on the action of
  1027.             the receiver  or if there is no response required, a message
  1028.             can be  sent without  waiting for  completion of processing.
  1029.             This makes  it  possible  for  a  sender  to  send  multiple
  1030.             messages to  a receiver,  or, simply do something else while
  1031.             the receiver  processes the  message. However, even though a
  1032.             message is  sent without  waiting for  the response,  it  is
  1033.             still possible   at  a later time for the sender to wait for
  1034.             the completion of processing event.
  1035.             
  1036.             If the  receiver has completed the use of the message by the
  1037.             time the  sender waits  for that  event,  the  sending  task
  1038.             continues operation  without interruption.  If the  receiver
  1039.             has not  yet completed processing of the message, the sender
  1040.             must wait  for the  event to  occur. When it does occur, the
  1041.             sender's operation is resumed.
  1042.             
  1043.             A message is a four-element structure set up in a contiguous
  1044.             area of  RAM. The  first three  elements of  the message are
  1045.             used by  MCX11 to  control the  transmission. The  user need
  1046.             only set up the content of the message body. The format of a
  1047.             MCX11 message is as follows:
  1048.             
  1049.                  -    Mailbox link (supplied by MCX11)
  1050.                  -    Task number of sender (supplied by                 
  1051.                       MCX11)
  1052.  
  1053.  
  1054.  
  1055.            Copyright (c) 1989          Page 3 - 6          Motorola, Inc.
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.                   MCX11 - MicroController eXecutive for the 68HC11
  1063.  
  1064.  
  1065.  
  1066.                  -    Message semaphore number (optional)
  1067.                  -    Message body (supplied by User)
  1068.             
  1069.             The first  element in  the message  provides the link to the
  1070.             next message, if any, in the mailbox.
  1071.             
  1072.             The second  element is  the task  number of the sender. This
  1073.             field is  included so that the receiver task can selectively
  1074.             receive only those messages from a specified task.
  1075.             
  1076.             The third  element  of  the  message  contains  an  optional
  1077.             message semaphore  number.   Typically, when  a sending task
  1078.             wants to  send a  message and  wait until  the receiver  has
  1079.             processed the  message, it will include a non-zero semaphore
  1080.             number as  one  of  the  calling  arguments  for  the  MCX11
  1081.             directive. The  sending task  will  then  suspend  execution
  1082.             until the  receiver task  completes the  processing  of  the
  1083.             message content.  When the receiver no longer needs the data
  1084.             in the body of the message, it signals the message semaphore
  1085.             to notify the sender that it may continue processing.
  1086.             .
  1087.             The last  element, the  body, of  the  message  may  contain
  1088.             whatever data  is required  by  the  receiver  task  and  in
  1089.             whatever format.  It may  be fixed  or variable in length as
  1090.             required.
  1091.             
  1092.             
  1093.             3.4  QUEUES
  1094.             
  1095.             MCX11  supports   first-in-first-out  (FIFO)  queues  having
  1096.             single or  multiple bytes per entry.  The queues can support
  1097.             multiple producer/single  consumer service  but are  usually
  1098.             employed in  only a  single producer/single  consumer  mode.
  1099.             Queues are  referenced via  a numerical  identifier which is
  1100.             unique to  each queue.   Queue  numbers are  assigned in the
  1101.             system generation  procedure.    MCX11  queues  differ  from
  1102.             messages in  that the  actual entry  data  rather  than  its
  1103.             address is  entered into or removed from the queue.  Another
  1104.             difference  is   that  the   queue  entries   represent  the
  1105.             chronological order  of processing.  Also, the priorities of
  1106.             the sender  or receiver are not considered as with messages.
  1107.             Queues are  usually used  to handle  data such  as character
  1108.             stream input/output or other data buffering.  Queues require
  1109.             more overhead  as they  move the data from the source to the
  1110.             queue  or   vice  versa  but  they  also  provide  automatic
  1111.             synchronization  between   the  queue's   producer  and  its
  1112.             consumer.   It is  recommended that  they not  be used where
  1113.             high throughput rates are required.
  1114.             
  1115.             A queue  consists of  two parts:   the  queue header and the
  1116.             queue body.   The  queue header  contains  that  information
  1117.             needed by the MCX11 internal routines to enable them to move
  1118.  
  1119.  
  1120.  
  1121.            Copyright (c) 1989          Page 3 - 7          Motorola, Inc.
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.                   MCX11 - MicroController eXecutive for the 68HC11
  1129.  
  1130.  
  1131.  
  1132.             data into  and out of the queues properly.  The organization
  1133.             of the queue header consists of the following elements:
  1134.             
  1135.                 -     Width, queue entry size (in bytes)
  1136.                 -     Depth, maximum length (in entries)
  1137.                 -     Current size of the queue (in entries)
  1138.                 -     Put index (in bytes; MCX11 internal use)
  1139.                 -     Address of queue body
  1140.                 -     Queue not empty semaphore number
  1141.                 -     Active semaphore number
  1142.             
  1143.             The first  three elements  are  defined  during  the  system
  1144.             generation process.   The  Current Size  and the  Put  Index
  1145.             fields are initialized to zero (empty). Both of these fields
  1146.             are  maintained  internally  by  the  MCX11  queue  handling
  1147.             routines. They should never be manipulated by a user task.
  1148.             
  1149.             Semaphores are used to signal internal events such as queue-
  1150.             not- empty  or   queue-not-full. The  semaphores  for  these
  1151.             events are allocated as a consecutive pair during the system
  1152.             initialization process.  The queue-not-full semaphore number
  1153.             is equal to the number of the queue-not-empty semaphore plus
  1154.             one. A  queue can have a semaphore active only for those two
  1155.             mutually exclusive  events. Consequently only the queue-not-
  1156.             empty semaphore  number requires  definition  in  the  queue
  1157.             header.
  1158.             
  1159.             The active  semaphore number  field in  the queue  header is
  1160.             used to  contain the number of the semaphore associated with
  1161.             one of  the two possible events. If the queue is empty and a
  1162.             task attempts to remove an entry, the active semaphore field
  1163.             in the  queue header  is set  to contain  the number  of the
  1164.             queue-not-empty semaphore. Conversely, if a task attempts to
  1165.             put an  entry into a queue which is already full, the active
  1166.             semaphore field  is set  to contain the number of the queue-
  1167.             not-full semaphore.
  1168.             
  1169.             By use  of these  semaphores, it  is possible  to send  data
  1170.             between tasks  asynchronously but without the worry of over-
  1171.             running the queue.
  1172.             
  1173.             
  1174.             3.5 TIMERS
  1175.             
  1176.             In the descriptions of time based functions to follow in the
  1177.             succeeding sections,  it will be important to understand the
  1178.             conventions used  by MCX11.  All timers in MCX11 are 16-bits
  1179.             long. The  two time units used internally by MCX11 are ticks
  1180.             and tocks.   A  tick gives  the amount of time between clock
  1181.             generated system  interrupts, or  equivalently,  the  period
  1182.             between clock interrupt service requests.
  1183.             
  1184.  
  1185.  
  1186.  
  1187.            Copyright (c) 1989          Page 3 - 8          Motorola, Inc.
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.                   MCX11 - MicroController eXecutive for the 68HC11
  1195.  
  1196.  
  1197.  
  1198.             A tock  is an  integral number of ticks and is the time unit
  1199.             used by  all of  the time dependent functions in MCX11.  The
  1200.             tick frequency  of the  RTI clock  is set  during the system
  1201.             initialization process but was determined, as was the number
  1202.             of ticks  per tock,  by the  system  designer  during  MCX11
  1203.             system configuration.
  1204.             
  1205.             As an  example, suppose  the hardware clock is configured to
  1206.             cause interrupts every 25 milliseconds and that 0.25 seconds
  1207.             (250 milliseconds)  is the time most convenient interval for
  1208.             timing events  in the application. In order to determine the
  1209.             number of ticks per tock, simply divide the desired duration
  1210.             of the  tock (250  ms) by  the duration  of a  tick (25 ms).
  1211.             Thus, in this case, 1 tock = 10 ticks.
  1212.             
  1213.             Timer values  are defined  as  the  number  of  clock  tocks
  1214.             required to  form the  needed amount  of time.   If  a timer
  1215.             value is  positive, it  is used  only once (one-shot timer).
  1216.             However, if  the value  is negative,  it is used as a cyclic
  1217.             timer having  a period  equal to  the 2's  complement value.
  1218.             For example,  if a  clock tock  equals 250  milliseconds,  a
  1219.             timer value  of 20  would produce  a once-only  period of  5
  1220.             seconds.   If the  timer were  -20, the  period is  still  5
  1221.             seconds but the timer is cyclic.
  1222.             
  1223.             All timed  event operations  and data structures are handled
  1224.             by MCX11. A task should not attempt to manipulate any of the
  1225.             timer related control or data structures.
  1226.             
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.            Copyright (c) 1989          Page 3 - 9          Motorola, Inc.
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.                   MCX11 - MicroController eXecutive for the 68HC11
  1261.  
  1262.  
  1263.  
  1264.                                      SECTION 4
  1265.                                           
  1266.                          EXECUTIVE SERVICE REQUESTS (ESRS)
  1267.                                           
  1268.             
  1269.             4.1  PURPOSE
  1270.             
  1271.             Executive Service  Requests (ESRs)  are the functions that a
  1272.             real-time kernel  performs and  serve to give it its flavor.
  1273.             This  section   will  describe  the  classes  of  the  MCX11
  1274.             directives.  The directives are divided into five classes as
  1275.             follows:
  1276.             
  1277.                 -     Semaphores
  1278.                 -     Messages
  1279.                 -     Queues
  1280.                 -     Task control
  1281.                 -     Time based
  1282.             
  1283.             A brief  functional description of each ESR within the class
  1284.             is given  along with their respective calling arguments. The
  1285.             calling arguments  needed  for  each  ESR  appear  below  in
  1286.             parentheses. Where  two or more arguments are required, they
  1287.             are separated  by commas.  These are  not the actual calling
  1288.             sequences but  are for  purposes of explanation only. Actual
  1289.             calling sequences are given in Section 5.
  1290.             
  1291.             In the  paragraphs below,  the ESR function name is enclosed
  1292.             within two  periods. This  will be  the convention  used for
  1293.             MCX11 to denote an ESR. The following abbreviations are used
  1294.             below for the arguments:
  1295.             
  1296.                 -     SEMA      Semaphore number
  1297.                 -     TASK      Task number
  1298.                 -     QUEUE     Queue number
  1299.                 -     TOCK      Timer value
  1300.                 -     PNTR      Address pointer or data value
  1301.                 -     MSG       Message address
  1302.             
  1303.             4.2  SEMAPHORE ESRS
  1304.             
  1305.             A complete  set of  directives for  managing  semaphores  is
  1306.             provided by MCX11.
  1307.             
  1308.             
  1309.             .wait. (SEMA)       wait for a specific sema to be signalled
  1310.             .signal. (SEMA)     signal semaphore
  1311.             .pend. (SEMA)       reset semaphore state to PENDing
  1312.             
  1313.             
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.             Copyright (c) 1989         Page 4 - 1          Motorola, Inc.
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.                   MCX11 - MicroController eXecutive for the 68HC11
  1327.  
  1328.  
  1329.  
  1330.             4.3  MESSAGE ESRS
  1331.             
  1332.             The message directives provide a means of transferring large
  1333.             amounts of  data between  tasks with  minimal overhead since
  1334.             only pointers  (addresses)  are  passed.    Message  receipt
  1335.             acknowledgement is  also provided  for task synchronization.
  1336.             The format  of a  MCX11 message  and function prototypes are
  1337.             noted.
  1338.             
  1339.             .send. (MSG,TASK)        send message to a task
  1340.             .sendw. (MSG,TASK,SEMA)  send & wait acknowledgement
  1341.             .receive. (TASK)         receive message
  1342.             
  1343.             
  1344.             4.4  QUEUE ESRS
  1345.             
  1346.             Queue directives  provide a  means of  passing multiple byte
  1347.             packets of  information between  tasks with  automatic  task
  1348.             synchronization of queue full and empty conditions.
  1349.             
  1350.             .dequeue. (QUEUE,PNTR)  remove entry from queue
  1351.             .enqueue. (QUEUE,PNTR)  insert entry into queue
  1352.             
  1353.             
  1354.             4.5  TASK CONTROL ESRS
  1355.             
  1356.             The task  control directives provided by MCX11 allow for low
  1357.             level  complete   control  of  tasks  and  their  respective
  1358.             interactions.
  1359.             
  1360.             .resume. (TASK)         resume specific task
  1361.             .suspend. (TASK)        suspend specific task
  1362.             .terminate. (TASK)      terminate specific task
  1363.             .execute. (TASK)        execute task from starting point
  1364.             
  1365.             
  1366.             4.6  TIME BASED ESRS
  1367.             
  1368.             The time based directives provide for the synchronization of
  1369.             tasks with  timed events.   In  addition, a generalized time
  1370.             based  semaphore   scheme  for   more  advanced  time  based
  1371.             requirements is provided.
  1372.             
  1373.             .delay. (TASK,SEMA,TOCK)  delay task
  1374.             .timer. (TASK,SEMA,TOCK)  schedule timer for task/sema
  1375.             .purge. (TASK,SEMA,PNTR)  purge timer for task/sema
  1376.             
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.             Copyright (c) 1989         Page 4 - 2          Motorola, Inc.
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.                   MCX11 - MicroController eXecutive for the 68HC11
  1393.  
  1394.  
  1395.  
  1396.                                      SECTION 5
  1397.                                           
  1398.                             ALPHABETICAL LISTING OF ESRs
  1399.                                           
  1400.             
  1401.             In  the   pages  to  follow,  each  ESR  will  be  shown  in
  1402.             alphabetical order.   Each  ESR will  be given in a standard
  1403.             format:
  1404.             
  1405.             Name - brief functional description
  1406.             
  1407.             CLASS
  1408.             
  1409.                  One of the five ESR classes of which it is a member.
  1410.                  
  1411.             SYNOPSIS
  1412.             
  1413.                  The prototype  declaration including  argument  typing.
  1414.                  The decimal  value of  the function code is enclosed in
  1415.                  brackets [xx].
  1416.             
  1417.             DESCRIPTION
  1418.             
  1419.                  A description  of what  the ESR  does, data types used,
  1420.                  etc.
  1421.                  
  1422.             CALLING SEQUENCE
  1423.             
  1424.                  The formal  AS11 calling  sequence  for  the  ESR.  The
  1425.                  following notations will be used:
  1426.                  
  1427.                       ACCA = Accumulator A, 8 bits
  1428.                       ACCB = Accumulator B, 8 bits
  1429.                       IX = Index register X, 16 bits
  1430.                  
  1431.             RETURN VALUE
  1432.             
  1433.                  A description of the return values from the ESR.
  1434.                  
  1435.             EXAMPLE
  1436.             
  1437.                  One or  more typical ESR uses.  The examples assume the
  1438.                  syntax of AS11 cross assembler.
  1439.                  
  1440.             SEE ALSO
  1441.             
  1442.                  List  of   related  ESRs  that  could  be  examined  in
  1443.                  conjunction with the current ESR.
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.             Copyright (c) 1989         Page 5 - 1          Motorola, Inc.
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.                   MCX11 - MicroController eXecutive for the 68HC11
  1459.  
  1460.  
  1461.  
  1462.             5.1  .delay.  -  DELAY A TASK FOR A PERIOD OF TIME
  1463.             
  1464.             CLASS
  1465.             
  1466.                  Timer
  1467.             
  1468.             SYNOPSIS
  1469.             
  1470.                  .delay. (TASK,SEMA,TOCK)       [13]
  1471.             
  1472.             DESCRIPTION
  1473.             
  1474.                  The delay  directive places  the specified  task into a
  1475.                  Wait state  for the  period defined  by the TOCK value.
  1476.                  TASK is  a task  number in the range of 1-126. Or, TASK
  1477.                  may be 0 if the reference is to SELF. Thus, a task need
  1478.                  not know  its own  task number  to schedule a delay for
  1479.                  itself. SEMA  is the  semaphore number  associated with
  1480.                  the  expiration  of  the  timer.  It  may  be  a  named
  1481.                  semaphore if  its number  > 0.  Or, it  may be the task
  1482.                  semaphore of  the calling task if it is specified as 0.
  1483.                  TOCK is  a 16-bit timer. If TOCK is > 0, the timer is a
  1484.                  one-shot. If  TOCK <  0, the  timer is  cyclic. Caution
  1485.                  should be  exercised when  scheduling delays  for other
  1486.                  tasks.
  1487.             
  1488.             CALLING SEQUENCE
  1489.             
  1490.                  ACCA = Task number (0 if SELF)
  1491.                  ACCB = Semaphore number (0 if Task's semaphore)
  1492.                  IX = Number of clock tocks to delay
  1493.                  swi
  1494.                   FCB  .delay.
  1495.                  return
  1496.             
  1497.             RETURN VALUE
  1498.             
  1499.                  None. Registers unchanged.
  1500.             
  1501.             EXAMPLE
  1502.             
  1503.                  Assume that  the RTI  is used  as the time base using a
  1504.                  2**23 crystal  and the  clock TICK  is  defined  to  be
  1505.                  15.625 msec.  Further assume that there are 8 TICKS per
  1506.                  TOCK so  that a TOCK is 125 msec. If a 2.5 sec delay is
  1507.                  desired for  the calling  task using a named semaphore,
  1508.                  TIMEOUT, the request would appear as:
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.             Copyright (c) 1989         Page 5 - 2          Motorola, Inc.
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.                   MCX11 - MicroController eXecutive for the 68HC11
  1525.  
  1526.  
  1527.  
  1528.                  
  1529.                  TOCK      equ   8
  1530.                  TOCKTIME  equ   1000/8         TOCKTIME = 125 msec
  1531.                  TIMEOUT   equ   3              Named semaphore #3
  1532.                            .
  1533.                            :
  1534.                            clra                 Task is self (ACCA=0)
  1535.                            ldab  #TIMEOUT       Semaphore = TIMEOUT
  1536.                            ldx  #2500/TOCKTIME  Timer = 20 TOCKS
  1537.                            swi
  1538.                             FCB  .delay.
  1539.                            .                    Point of continuation
  1540.                  
  1541.                  The requesting  task would  be put into a WAIT state on
  1542.                  semaphore TIMEOUT  while the  2.5 sec  clock runs down.
  1543.                  When it  expires, TIMEOUT  would be  signalled and  the
  1544.                  task would  continue at  the instruction  following the
  1545.                  FCB declaration.
  1546.             
  1547.             SEE ALSO
  1548.             
  1549.                  .timer., .purge.
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.             Copyright (c) 1989         Page 5 - 3          Motorola, Inc.
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.                   MCX11 - MicroController eXecutive for the 68HC11
  1591.  
  1592.  
  1593.  
  1594.             5.2  .dequeue.  -  GET AN ENTRY FROM A FIFO QUEUE
  1595.             
  1596.             CLASS
  1597.             
  1598.                  Queue
  1599.             
  1600.             SYNOPSIS
  1601.             
  1602.                  .dequeue. (QUEUE,PNTR)       [7]
  1603.             
  1604.             DESCRIPTION
  1605.             
  1606.                  Dequeue is  used to get an entry from a FIFO queue. The
  1607.                  number of bytes in the entry is determined by the Width
  1608.                  entry in  the Queue  Header. If the queue is empty, the
  1609.                  calling task  is placed into an EVENT WAIT state on the
  1610.                  queue-not-empty semaphore.   If the queue is not empty,
  1611.                  the oldest  entry in  the queue is removed and returned
  1612.                  to the  calling task. If the size of the queue entry is
  1613.                  greater than two bytes, the returned data is in the RAM
  1614.                  area beginning at the address specified by PNTR. If the
  1615.                  queue entry  is one  or two  bytes, PNTR is ignored and
  1616.                  the entry is returned in one or two registers.
  1617.             
  1618.             CALLING SEQUENCE
  1619.             
  1620.                  ACCA= Queue number
  1621.                  IX = Destination address of queue entry if size > 2
  1622.                  swi
  1623.                   FCB .dequeue.
  1624.                  return
  1625.             
  1626.             RETURN VALUE
  1627.             
  1628.                  If queue entry size = 1, ACCA= queue entry
  1629.                  If queue  entry size = 2, ACCA = byte 1 of queue entry,
  1630.                                       and ACCB = byte 2 of queue entry
  1631.                  Other registers unchanged
  1632.             
  1633.             EXAMPLE
  1634.             
  1635.                  Example #1:
  1636.                  
  1637.                  There  exists   a  FIFO  queue,  DBLQ,  containing  two
  1638.                  character entries.  The queue  currently contains  four
  1639.                  entries as follows:
  1640.                  
  1641.                            ab
  1642.                            DE
  1643.                            Mc
  1644.                            xY
  1645.                  
  1646.  
  1647.  
  1648.  
  1649.             Copyright (c) 1989         Page 5 - 4          Motorola, Inc.
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.                   MCX11 - MicroController eXecutive for the 68HC11
  1657.  
  1658.  
  1659.  
  1660.                  A task  is programmed to remove the oldest entry in the
  1661.                  queue and  return it  for  subsequent  processing.  The
  1662.                  entry is dequeued by:
  1663.                  
  1664.                  DBLQ      equ  4              Queue #4
  1665.                            .
  1666.                            :
  1667.                            ldaa  #DBLQ         ACCA = queue # 4
  1668.                            swi
  1669.                             FCB  .dequeue.
  1670.                            .                   Point of continuation
  1671.                  
  1672.                  At the  instruction following the FCB declaration, ACCA
  1673.                  and ACCB will contain the two characters, ab. The queue
  1674.                  will now contain the three entries:
  1675.                  
  1676.                            DE
  1677.                            Mc
  1678.                            xY
  1679.                  
  1680.                  Example #2:
  1681.                  
  1682.                  Another queue  exists, QUADQ,  which contains four byte
  1683.                  entries and  is currently  empty. The request to get an
  1684.                  entry from the queue would appear as:
  1685.                  
  1686.                  QUADQ     equ   5             Queue #5
  1687.                            .
  1688.                            :
  1689.                            ldaa  #QUADQ        ACCA = queue # 5
  1690.                            ldx   #destn        IX = destination address
  1691.                            swi
  1692.                             FCB  .dequeue.
  1693.                            .                   Point of continuation
  1694.                            :
  1695.                  destn     ZMB   4             Where the entry is placed
  1696.                            :
  1697.                  
  1698.                  Since there  are no entries available to dequeue, MCX11
  1699.                  puts the  task into  a  WAIT  state  on  the  NOT_EMPTY
  1700.                  semaphore associated  with  queue  #5.  The  task  will
  1701.                  remain in  that state  until another task puts a 4-byte
  1702.                  entry into  QUADQ. When  that happens, the waiting task
  1703.                  is put  into the RUN state. The entry is removed and is
  1704.                  stored at the specified destination address, destn, and
  1705.                  the task continues at the instruction following the FCB
  1706.                  declaration.
  1707.             
  1708.             SEE ALSO
  1709.             
  1710.                  .enqueue.
  1711.  
  1712.  
  1713.  
  1714.  
  1715.             Copyright (c) 1989         Page 5 - 5          Motorola, Inc.
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.                   MCX11 - MicroController eXecutive for the 68HC11
  1723.  
  1724.  
  1725.  
  1726.             5.3  .enqueue.  -  INSERT DATA INTO FIFO QUEUE
  1727.             
  1728.             CLASS
  1729.             
  1730.                  Queue
  1731.             
  1732.             SYNOPSIS
  1733.             
  1734.                  .enqueue. (QUEUE,PNTR)     [8]
  1735.             
  1736.             DESCRIPTION
  1737.             
  1738.                  Enqueue inserts  an entry  into a  FIFO queue.   If the
  1739.                  queue is  full, the calling task is set to a WAIT state
  1740.                  on the queue NOT FULL condition.  When the queue is not
  1741.                  full, the  entry is  inserted into  the queue.  If  the
  1742.                  width of  the queue  entry is greater than 2 bytes, the
  1743.                  data to  be put  into the queue is found at the address
  1744.                  specified by  the contents of register IX. If the width
  1745.                  is 1  byte, the  actual data to be enqueued is found in
  1746.                  bits 8-15 of IX. If the width is equal to 2 bytes, then
  1747.                  byte 1  of the  entry is  found in bits 8-15 of IX, and
  1748.                  byte 2 is in bits 0-7 of IX.
  1749.             
  1750.             CALLING SEQUENCE
  1751.             
  1752.                  ACCA= Queue number
  1753.                  IX = Source address of entry to be enqueued if size > 2
  1754.                       Or, IX8-15 = byte to be enqueued if size = 1
  1755.                       Or, IX8-15 = byte 1 and IX0-7 = byte 2 if size = 2
  1756.                  swi
  1757.                   FCB .enqueue.
  1758.                  return
  1759.             
  1760.             RETURN VALUE
  1761.             
  1762.                  None. Registers unchanged.
  1763.             
  1764.             EXAMPLE
  1765.             
  1766.                  Example #1:
  1767.                  
  1768.                  Using the  2-byte queue,  DBLQ, defined  above, a  task
  1769.                  wants to  put an  entry into  it. Assume that the queue
  1770.                  contents are the three entries:
  1771.                  
  1772.                            DE
  1773.                            Mc
  1774.                            xY
  1775.                  
  1776.                  The queue  entry size  is two  bytes which  permits the
  1777.                  entry to  be passed  to the  queue routine  in ACCA and
  1778.  
  1779.  
  1780.  
  1781.             Copyright (c) 1989         Page 5 - 6          Motorola, Inc.
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.                   MCX11 - MicroController eXecutive for the 68HC11
  1789.  
  1790.  
  1791.  
  1792.                  ACCB. The  request to  put a  two-byte entry,  LW, into
  1793.                  DBLQ is:
  1794.                  
  1795.                            ldaa  #DBLQ         ACCA = queue # 4
  1796.                            ldx   #"LW"         IX = "LW"
  1797.                            swi
  1798.                             FCB  .enqueue.
  1799.                            .                   Point of continuation
  1800.                  
  1801.                  Since the  queue has content, no task is waiting for an
  1802.                  entry to  dequeue; therefore, the entry is put into the
  1803.                  queue following  the "xY"  entry and the task continues
  1804.                  at the  instruction following  the FCB. The new content
  1805.                  of DBLQ is:
  1806.                  
  1807.                            DE
  1808.                            Mc
  1809.                            xY
  1810.                            LW
  1811.                  
  1812.                  
  1813.                  Example #2:
  1814.                  
  1815.                  Using the  queue, QUADQ,  previously  defined  but  now
  1816.                  containing three entries:
  1817.                  
  1818.                            abcd
  1819.                            EFGH
  1820.                            iJkL
  1821.                  
  1822.                  A request  to put  a new entry into the queue, MnOp, is
  1823.                  given by:
  1824.                  
  1825.                            ldaa  #QUADQ        ACCA = queue # 5
  1826.                            ldx   #srcadr       IX = source address
  1827.                            swi
  1828.                             FCB  .enqueue.
  1829.                            .                   Point of continuation
  1830.                            :
  1831.                  srcadr    FCC   "MnOp"
  1832.                            :
  1833.                  
  1834.                  Since the entry size is four bytes, IX must contain the
  1835.                  address of  the entry  to be enqueued. After continuing
  1836.                  at the instruction following the FCB declaration, QUADQ
  1837.                  contains:
  1838.                  
  1839.                            abcd
  1840.                            EFGH
  1841.                            IjKl
  1842.                            MnOp
  1843.             
  1844.  
  1845.  
  1846.  
  1847.             Copyright (c) 1989         Page 5 - 7          Motorola, Inc.
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.                   MCX11 - MicroController eXecutive for the 68HC11
  1855.  
  1856.  
  1857.  
  1858.             SEE ALSO
  1859.             
  1860.                  .dequeue.
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.             Copyright (c) 1989         Page 5 - 8          Motorola, Inc.
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.                   MCX11 - MicroController eXecutive for the 68HC11
  1921.  
  1922.  
  1923.  
  1924.             5.4  .execute.  -  EXECUTE A TASK
  1925.             
  1926.             CLASS
  1927.             
  1928.                  Task control
  1929.             
  1930.             SYNOPSIS
  1931.             
  1932.                  .execute. (TASK)     [12]
  1933.             
  1934.             DESCRIPTION
  1935.             
  1936.                  The execute  task directive is used to start or restart
  1937.                  a task from its beginning. The program counter (PC) and
  1938.                  stack pointer  (SP) are  initialized to  their starting
  1939.                  values and the specified task is made runnable.  If the
  1940.                  new task is of higher priority than the current task, a
  1941.                  context switch is performed and the new task runs, else
  1942.                  control is  returned to  the  caller.  The  task  being
  1943.                  started cannot be SELF (task number argument = 0).
  1944.             
  1945.             CALLING SEQUENCE
  1946.             
  1947.                  ACCA= Task number
  1948.                  swi
  1949.                   FCB .execute.
  1950.                  return
  1951.             
  1952.             RETURN VALUE
  1953.             
  1954.                  None. Registers unchanged.
  1955.             
  1956.             EXAMPLE
  1957.             
  1958.                  The current task wishes to cause task number 6 to begin
  1959.                  execution at  its starting  point.  Task  number  6  is
  1960.                  currently IDLE. The request appears as:
  1961.                  
  1962.                  TASK6     equ   6             Task #6
  1963.                            .
  1964.                            :
  1965.                            ldaa  #TASK6        ACCA = task # 6
  1966.                            swi
  1967.                             FCB  .execute.
  1968.                            .                   Point of continuation
  1969.                  
  1970.                  If TASK6  is of  higher priority, then the current task
  1971.                  is interrupted,  but still  runnable, and TASK6 is made
  1972.                  the current task. The task which scheduled TASK6 is not
  1973.                  given control  again until  all other  higher  priority
  1974.                  tasks, including  TASK6, are not runnable. When it does
  1975.                  continue, it will do so following the FCB declaration.
  1976.  
  1977.  
  1978.  
  1979.             Copyright (c) 1989         Page 5 - 9          Motorola, Inc.
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.                   MCX11 - MicroController eXecutive for the 68HC11
  1987.  
  1988.  
  1989.  
  1990.                  
  1991.                  If TASK6 is of lower priority that the current task, no
  1992.                  context switch occurs and the current task continues at
  1993.                  the instruction following the FCB declaration.
  1994.             
  1995.             SEE ALSO
  1996.             
  1997.                  .terminate.
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.             Copyright (c) 1989         Page 5 - 10          Motorola, Inc.
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.                   MCX11 - MicroController eXecutive for the 68HC11
  2053.  
  2054.  
  2055.  
  2056.             5.5  .pend.  -  FORCE A SEMAPHORE TO A PENDING STATE
  2057.             
  2058.             CLASS
  2059.             
  2060.                  Semaphore
  2061.             
  2062.             SYNOPSIS
  2063.             
  2064.                  .pend. (SEMA)       [3]
  2065.             
  2066.             DESCRIPTION
  2067.             
  2068.                  To understand  the use  of the  pend directive,  recall
  2069.                  that the  WAIT directive  will return  control  to  the
  2070.                  calling task  immediately if  the task requests to wait
  2071.                  on a semaphore found to already be in a DONE state.  In
  2072.                  this  sense,   semaphores  keep   a  history  of  their
  2073.                  associated events,  even if  no task  is waiting at the
  2074.                  time  of   the  signal.     If   a  task  needs  to  go
  2075.                  unconditionally into a Event Wait state on a semaphore,
  2076.                  a call should first be made to PEND followed closely by
  2077.                  a WAIT directive.
  2078.             
  2079.             CALLING SEQUENCE
  2080.             
  2081.                  ACCB = Semaphore number
  2082.                  swi
  2083.                   FCB .pend.
  2084.                  return
  2085.             
  2086.             RETURN VALUE
  2087.             
  2088.                  None. Registers unchanged.
  2089.             
  2090.             EXAMPLE
  2091.             
  2092.                  The current  task is  going to  make use of a semaphore
  2093.                  and wants  to be  certain of its state prior to use. It
  2094.                  forces the  semaphore into  a PENDing  condition by the
  2095.                  following request:
  2096.                  
  2097.                  NEWSEMA   equ   14            Semaphore #14
  2098.                            .
  2099.                            :
  2100.                            ldab  #NEWSEMA      ACCB = semaphore # 14
  2101.                            swi
  2102.                             FCB  .pend.
  2103.                            .                   Point of continuation
  2104.             
  2105.             SEE ALSO
  2106.             
  2107.                  .wait.
  2108.  
  2109.  
  2110.  
  2111.             Copyright (c) 1989         Page 5 - 11          Motorola, Inc.
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.                   MCX11 - MicroController eXecutive for the 68HC11
  2119.  
  2120.  
  2121.  
  2122.             5.6  .purge.  -  PURGE A TASK'S TIMERS
  2123.             
  2124.             CLASS
  2125.             
  2126.                  Timer
  2127.             
  2128.             SYNOPSIS
  2129.             
  2130.                  .purge. (TASK,SEMA,PNTR)      [15]
  2131.             
  2132.             DESCRIPTION
  2133.             
  2134.                  The purge  timer directive is used to remove all active
  2135.                  timers for  the specified  task or semaphore number.  A
  2136.                  specification of a zero semaphore number will purge all
  2137.                  semaphore timers for the given task.  When the purge is
  2138.                  completed, the current task is resumed.
  2139.             
  2140.             CALLING SEQUENCE
  2141.             
  2142.                  ACCA = Task number (0 if SELF)
  2143.                  ACCB = Semaphore number (0 if task semaphore)
  2144.                  IX0-7 = Switch: 0 = purge all timers for given task
  2145.                                 >0 = purge time for given task & sema
  2146.                  swi
  2147.                   FCB .purge.
  2148.                  return
  2149.             
  2150.             RETURN VALUE
  2151.             
  2152.                  None. Registers unchanged.
  2153.             
  2154.             EXAMPLE
  2155.             
  2156.                  The most common use of this ESR is for the current task
  2157.                  to get  rid of  one or  all of its active timers. Since
  2158.                  timers are  associated with semaphores, the combination
  2159.                  of task  number and  semaphore number  is sufficient to
  2160.                  identify a  timer uniquely.  The request  to purge  the
  2161.                  current task's timer associated with the task semaphore
  2162.                  appears as:
  2163.                  
  2164.                            clra                ACCA = 0 means SELF
  2165.                            clrb                ACCB = 0 means task sema
  2166.                            ldx   #1            Only purge one timer
  2167.                            swi
  2168.                             FCB  .purge.
  2169.                            .                   Point of continuation
  2170.                  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.             Copyright (c) 1989         Page 5 - 12          Motorola, Inc.
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.                   MCX11 - MicroController eXecutive for the 68HC11
  2185.  
  2186.  
  2187.  
  2188.                  If all  timers for a task are to be purged, the request
  2189.                  appears as:
  2190.                  
  2191.                            clra                ACCA = 0 means SELF
  2192.                            ldx   #0            Purge all timers
  2193.                            swi
  2194.                             FCB  .purge.
  2195.                            .                   Point of continuation
  2196.             
  2197.             SEE ALSO
  2198.             
  2199.                  .timer., .terminate.
  2200.             
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.             Copyright (c) 1989         Page 5 - 13          Motorola, Inc.
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.                   MCX11 - MicroController eXecutive for the 68HC11
  2251.  
  2252.  
  2253.  
  2254.             5.7  .receive.  -  RECEIVE A MESSAGE
  2255.             
  2256.             CLASS
  2257.             
  2258.                  Message
  2259.             
  2260.             SYNOPSIS
  2261.             
  2262.                  .receive. (TASK)       [6]
  2263.             
  2264.             DESCRIPTION
  2265.             
  2266.                  The receive message directive is used to fetch messages
  2267.                  from a  calling task's  mailbox.   Because the messages
  2268.                  are placed  in the mailbox in the order of the sender's
  2269.                  priority, they  are processed in the same sequence.  If
  2270.                  the receiving  task specifies  a non-zero  task number,
  2271.                  the first  message from  that task  will  be  returned.
  2272.                  With a  zero task  number, the  first  message  in  the
  2273.                  mailbox is  returned.   If there are no messages in the
  2274.                  mailbox, the  task's context  is saved, and the task is
  2275.                  put into  a Message  WAIT state.  When the next message
  2276.                  is sent  to the task it will be resumed and the attempt
  2277.                  to receive a message will be reissued.
  2278.             
  2279.             CALLING SEQUENCE
  2280.             
  2281.                  ACCA =  Task number  if messages from specific task are
  2282.                         wanted. Or, ACCA = 0 if highest priority message
  2283.                         is wanted.
  2284.                  swi
  2285.                   FCB .receive.
  2286.                  return
  2287.             
  2288.             RETURN VALUE
  2289.             
  2290.                  Register  IX  contains  the  address  of  the  received
  2291.                  message. Other registers unchanged.
  2292.             
  2293.             EXAMPLE
  2294.             
  2295.                  Example #1:
  2296.                  
  2297.                  The current  task is  a server which operates only when
  2298.                  another task  sends it  a  message  instructing  it  to
  2299.                  perform  some   function.  The   server  task  receives
  2300.                  messages by making a request such as:
  2301.                  
  2302.                            clra                0 = next message
  2303.                            swi
  2304.                             FCB  .receive.
  2305.                            .                   Point of continuation
  2306.  
  2307.  
  2308.  
  2309.             Copyright (c) 1989         Page 5 - 14          Motorola, Inc.
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.                   MCX11 - MicroController eXecutive for the 68HC11
  2317.  
  2318.  
  2319.  
  2320.                  
  2321.                  The server  task will  not continue  unless there  is a
  2322.                  message waiting  in its  mailbox. It will be put into a
  2323.                  WAIT state  until such  time as another task sends it a
  2324.                  message. No  waiting occurs  if a message is already in
  2325.                  the mailbox  at the  time  of  the  request.  When  the
  2326.                  message is available, its address is returned in the IX
  2327.                  register.
  2328.                  
  2329.                  Example #2:
  2330.                  
  2331.                  If the server wants to receive only those messages from
  2332.                  a specific  task, and  the task's number is to be found
  2333.                  in a variable named 'attach', the request is:
  2334.                  
  2335.                            ldaa  attach        variable contains task #
  2336.                            swi
  2337.                             FCB  .receive.
  2338.                            .                   Point of continuation
  2339.                            :
  2340.                  attach    ZMB   1
  2341.                  
  2342.                  The server  task will now only listen for messages from
  2343.                  the task  whose number is in the variable 'attach'. All
  2344.                  other messages  will  remain  in  the  mailbox  of  the
  2345.                  server. The  server will  continue  only  when  it  has
  2346.                  received a message from the specific task.
  2347.             
  2348.             SEE ALSO
  2349.             
  2350.                  .send., .sendw.
  2351.             
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.             Copyright (c) 1989         Page 5 - 15          Motorola, Inc.
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.                   MCX11 - MicroController eXecutive for the 68HC11
  2383.  
  2384.  
  2385.  
  2386.             5.8  .resume.  -  RESUME A TASK
  2387.             
  2388.             CLASS
  2389.             
  2390.                  Task control
  2391.             
  2392.             SYNOPSIS
  2393.             
  2394.                  .resume. (TASK)       [9]
  2395.             
  2396.             DESCRIPTION
  2397.             
  2398.                  The resume  directive clears  the suspended  state of a
  2399.                  task caused  by a  suspend directive.   If  the resumed
  2400.                  task is  made runnable  and is  higher priority, a task
  2401.                  switch is performed.  Otherwise, control is returned to
  2402.                  the calling task.
  2403.             
  2404.             CALLING SEQUENCE
  2405.             
  2406.                  ACCA = Task number
  2407.                  swi
  2408.                   FCB .resume.
  2409.                  return
  2410.             
  2411.             RETURN VALUE
  2412.             
  2413.                  None. Registers unchanged.
  2414.             
  2415.             EXAMPLE
  2416.             
  2417.                  A task  which has  been  previously  suspended  may  be
  2418.                  resumed from the point of suspension only by a .resume.
  2419.                  request from another task. The request appears as:
  2420.                  
  2421.                  TASK6     equ   6             Task #6
  2422.                            .
  2423.                            :
  2424.                            ldaa  #TASK6        ACCA = task # 6
  2425.                            swi
  2426.                             FCB  .resume.
  2427.                            .                   Point of continuation
  2428.                  
  2429.                  Upon resuming  the given  task, a  context  switch  may
  2430.                  occur if  the resumed  task is  of higher priority than
  2431.                  the task  making the request. If not, no context switch
  2432.                  occurs.  The   requesting   task   continues   at   the
  2433.                  instruction following the FCB.
  2434.             
  2435.             SEE ALSO
  2436.             
  2437.                  .suspend.
  2438.  
  2439.  
  2440.  
  2441.             Copyright (c) 1989         Page 5 - 16          Motorola, Inc.
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.                   MCX11 - MicroController eXecutive for the 68HC11
  2449.  
  2450.  
  2451.  
  2452.             5.9  .send.  -  SEND A MESSAGE TO A TASK
  2453.             
  2454.             CLASS
  2455.             
  2456.                  Message
  2457.             
  2458.             SYNOPSIS
  2459.             
  2460.                  .send. (MSG,TASK)       [4]
  2461.             
  2462.             DESCRIPTION
  2463.             
  2464.                  The send  message directive  inserts a message into the
  2465.                  target task's  mailbox in  the  order  of  the  sending
  2466.                  task's priority.   If  the receiving task is waiting to
  2467.                  receive a  message and  is of  higher priority than the
  2468.                  sender, a  task switch  is performed.  If the receiving
  2469.                  task is  of lower  priority and  waiting on  a message,
  2470.                  then the  receiving task is marked runnable but control
  2471.                  is  returned  on  a  message,  the  message  is  simply
  2472.                  inserted to his mailbox for later receipt.
  2473.             
  2474.             CALLING SEQUENCE
  2475.             
  2476.                  ACCA = Task number of the receiver
  2477.                  ACCB = Semaphore number (task semaphore number = 0)
  2478.                  IX = Message address
  2479.                  swi
  2480.                   FCB .send.
  2481.                  return
  2482.             
  2483.             RETURN VALUE
  2484.             
  2485.                  None.  ACCB   will  contain  the  number  of  the  task
  2486.                  semaphore if  ACCB was  = 0  at time  of swi. All other
  2487.                  registers unchanged.
  2488.             
  2489.             EXAMPLE
  2490.             
  2491.                  A task wishing to send a message to a receiver task can
  2492.                  do so by the following code:
  2493.                  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.             Copyright (c) 1989         Page 5 - 17          Motorola, Inc.
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.                   MCX11 - MicroController eXecutive for the 68HC11
  2515.  
  2516.  
  2517.  
  2518.                  RCVRTSK   equ   12            Receiving task = task #12
  2519.                  MSGSEMA   equ   7             Use sema #7 for Message
  2520.                            .
  2521.                            :
  2522.                            ldaa  #RCVRTSK      ACCA = receiver task #
  2523.                            ldab  #MSGSEMA      ACCB = Message semaphore
  2524.                            ldx   #msgadr       IX = Address of message
  2525.                            swi
  2526.                             FCB  .send.
  2527.                            .                   Point of continuation
  2528.                            :
  2529.                  msgadr    ZMB   4             Message overhead
  2530.                            FCC   "THIS IS THE MESSAGE BODY"
  2531.                  
  2532.                  The message  located at  'msgadr' will  be put into the
  2533.                  mailbox of RCVRTSK. Processing in the sending task will
  2534.                  resume   at   the   instruction   following   the   FCB
  2535.                  declaration.
  2536.             
  2537.             SEE ALSO
  2538.             
  2539.                  .receive., .sendw.
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.             Copyright (c) 1989         Page 5 - 18          Motorola, Inc.
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.                   MCX11 - MicroController eXecutive for the 68HC11
  2581.  
  2582.  
  2583.  
  2584.             5.10  .sendw.  -  SEND A MESSAGE AND WAIT
  2585.             
  2586.             CLASS
  2587.             
  2588.                  Message
  2589.             
  2590.             SYNOPSIS
  2591.             
  2592.                  .sendw. (MSG,TASK,SEMA)       [5]
  2593.             
  2594.             DESCRIPTION
  2595.             
  2596.                  The send  message and  wait directive is similar to the
  2597.                  send message directive described above, except that the
  2598.                  sending task  is always  put into a Event Wait state on
  2599.                  the message  semaphore.  This allows the receiving task
  2600.                  to signal  the sender  when the  message processing  is
  2601.                  complete and/or  that there  is data  returned  in  the
  2602.                  message area.
  2603.             
  2604.             CALLING SEQUENCE
  2605.             
  2606.                  ACCA = Task number of the receiver
  2607.                  ACCB = Semaphore number (task semaphore number = 0)
  2608.                  IX = Message address
  2609.                  swi
  2610.                   FCB .sendw.
  2611.                  return
  2612.             
  2613.             RETURN VALUE
  2614.             
  2615.                  None.  ACCB   will  contain  the  number  of  the  task
  2616.                  semaphore if  ACCB was  = 0  at time  of swi. All other
  2617.                  registers unchanged.
  2618.             
  2619.             EXAMPLE
  2620.             
  2621.                  The example  is the  same as for .send. except that the
  2622.                  ESR request  will be  .sendw. Another difference is the
  2623.                  WAIT state  into which the sending task is placed until
  2624.                  the receiving task signals the message semaphore. Until
  2625.                  that signal  is received,  the sending task proceeds no
  2626.                  further.  When   the  receiver   signals  the   message
  2627.                  semaphore,  the  sending  task  will  continue  at  the
  2628.                  instruction following the FCB.
  2629.             
  2630.             SEE ALSO
  2631.             
  2632.                  .send., .receive.
  2633.             
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.             Copyright (c) 1989         Page 5 - 19          Motorola, Inc.
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.                   MCX11 - MicroController eXecutive for the 68HC11
  2647.  
  2648.  
  2649.  
  2650.             5.11  .signal.  -  SIGNAL A SEMAPHORE
  2651.             
  2652.             CLASS
  2653.             
  2654.                  Semaphore
  2655.             
  2656.             SYNOPSIS
  2657.             
  2658.                  .signal. (SEMA)       [2]
  2659.             
  2660.             DESCRIPTION
  2661.             
  2662.                  The signal  semaphore directive  sets the  state  of  a
  2663.                  specified semaphore  to DONE.    If  the  semaphore  is
  2664.                  currently in  a WAIT state, the Event Wait state of the
  2665.                  waiting task  is removed,  and  the  semaphore  is  set
  2666.                  PENDing.   If the  waiting task becomes runnable and is
  2667.                  of  higher  priority  than  the  signalling  task,  the
  2668.                  context of  the current  task is  saved, and  a context
  2669.                  switch is performed.
  2670.                  
  2671.                  If the  state of  the semaphore  was either  PENDing or
  2672.                  DONE, the semaphore is placed in the DONE state and the
  2673.                  current task is resumed following the signal ESR.
  2674.             
  2675.             CALLING SEQUENCE
  2676.             
  2677.                  ACCB = Semaphore number
  2678.                  swi
  2679.                   FCB .signal.
  2680.                  return
  2681.             
  2682.             RETURN VALUE
  2683.             
  2684.                  None. Registers unchanged.
  2685.             
  2686.             EXAMPLE
  2687.             
  2688.                  Assume that  the current  task  wishes  to  signal  the
  2689.                  occurrence  of   a  particular   event.  The  event  is
  2690.                  associated with  a named  semaphore, EVNTSEMA. The task
  2691.                  signals the semaphore by the following procedure:
  2692.                  
  2693.                  EVNTSEMA  equ   15            Named semaphore #15
  2694.                            .
  2695.                            :
  2696.                            ldab  #EVNTSEMA     ACCB = semaphore # 15
  2697.                            swi
  2698.                             FCB  .signal.
  2699.                            .                   Point of continuation
  2700.                  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.             Copyright (c) 1989         Page 5 - 20          Motorola, Inc.
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.                   MCX11 - MicroController eXecutive for the 68HC11
  2713.  
  2714.  
  2715.  
  2716.                  Depending on  the  state  of  semaphore  EVNTSEMA,  the
  2717.                  signal may  or may  not cause  a  context  switch.  The
  2718.                  signalling  task   will  continue   processing  at  the
  2719.                  instruction following the FCB declaration.
  2720.             
  2721.             SEE ALSO
  2722.             
  2723.                  .pend., .wait.
  2724.             
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.             Copyright (c) 1989         Page 5 - 21          Motorola, Inc.
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.                   MCX11 - MicroController eXecutive for the 68HC11
  2779.  
  2780.  
  2781.  
  2782.             5.12  .suspend.  -  SUSPEND A TASK
  2783.             
  2784.             CLASS
  2785.             
  2786.                  Task control
  2787.             
  2788.             SYNOPSIS
  2789.             
  2790.                  .suspend. (TASK)       [10]
  2791.             
  2792.             DESCRIPTION
  2793.             
  2794.                  The suspend  directive causes  the specified task to be
  2795.                  placed into  a suspended  state.   The suspended  state
  2796.                  will remain  in force  until it is removed by a resume,
  2797.                  execute, or  reset  directive.    A  task  may  suspend
  2798.                  itself.  Task 0 indicates the SELF task.
  2799.             
  2800.             CALLING SEQUENCE
  2801.             
  2802.                  ACCA = Task number (this may be SELF [0])
  2803.                  swi
  2804.                   FCB .suspend.
  2805.                  return
  2806.             
  2807.             RETURN VALUE
  2808.             
  2809.                  None. Registers unchanged.
  2810.             
  2811.             EXAMPLE
  2812.             
  2813.                  The current  task wants  to suspend  itself until  some
  2814.                  indeterminate point  in the  future. To do so, it makes
  2815.                  the following request:
  2816.                  
  2817.                            clra                ACCA = 0 means SELF
  2818.                            swi
  2819.                             FCB .suspend.
  2820.                            .                   Point of continuation
  2821.                  
  2822.                  The task  remains in a suspended state until resumed by
  2823.                  a .resume.  ESR issued from another task. At that time,
  2824.                  the resumed  task  will  continue  at  the  instruction
  2825.                  following the FCB declaration.
  2826.             
  2827.             SEE ALSO
  2828.             
  2829.                  .resume.
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.             Copyright (c) 1989         Page 5 - 22          Motorola, Inc.
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.                   MCX11 - MicroController eXecutive for the 68HC11
  2845.  
  2846.  
  2847.  
  2848.             5.13  .terminate.  -  TERMINATE A TASK
  2849.             
  2850.             CLASS
  2851.             
  2852.                  Task control
  2853.             
  2854.             SYNOPSIS
  2855.             
  2856.                  .terminate. (TASK)       [11]
  2857.             
  2858.             DESCRIPTION
  2859.             
  2860.                  The terminate  directive is  used to terminate a task's
  2861.                  operation.   During termination,  the task's  state  is
  2862.                  cleared and  the task  state is set to Terminated.  The
  2863.                  timer queue  is searched  and all active timers for the
  2864.                  task are  purged.   Also, all  messages pending for the
  2865.                  task are  removed.   A task  number of 0 indicates self
  2866.                  termination.   In all  cases, the highest priority task
  2867.                  will execute next.
  2868.             
  2869.             CALLING SEQUENCE
  2870.             
  2871.                  ACCA = Task number (may be = 0 if terminating SELF)
  2872.                  swi
  2873.                   .terminate.
  2874.                  return
  2875.             
  2876.             RETURN VALUE
  2877.             
  2878.                  None.  Registers   unchanged.  Returns   only  if   not
  2879.                  terminating SELF.
  2880.             
  2881.             EXAMPLE
  2882.             
  2883.                  The current  task commits suicide by terminating itself
  2884.                  with the following procedure:
  2885.                  
  2886.                            clra                ACCA = 0 means SELF
  2887.                            swi
  2888.                             FCB .terminate.
  2889.                  
  2890.                  There is  no point of continuation following a suicide.
  2891.                  If another  task is terminated by the current task, the
  2892.                  current  task   will   continue   processing   at   the
  2893.                  instruction following the FCB declaration.
  2894.             
  2895.             SEE ALSO
  2896.             
  2897.                  .purge.
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.             Copyright (c) 1989         Page 5 - 23          Motorola, Inc.
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.                   MCX11 - MicroController eXecutive for the 68HC11
  2911.  
  2912.  
  2913.  
  2914.             5.14  .timer.  -  START A TIMER
  2915.             
  2916.             CLASS
  2917.             
  2918.                  Timer
  2919.             
  2920.             SYNOPSIS
  2921.             
  2922.                  .timer. (TASK,SEMA,TOCK)       [14]
  2923.             
  2924.             DESCRIPTION
  2925.             
  2926.                  The timer  directive inserts  an entry of the specified
  2927.                  time duration  into the  timer queue.  The timer can be
  2928.                  cyclic or  one-shot.   Cyclic timers are indicated by a
  2929.                  negative  duration  while  one-shots  are  of  positive
  2930.                  duration.   Further  options  allow  the  timer  to  be
  2931.                  associated either  with a  specified task  number (0  =
  2932.                  SELF) or  a semaphore  number.    After  the  timer  is
  2933.                  inserted,  the  current  task  is  resumed.    See  the
  2934.                  Advanced Topic  section for task versus semaphore-based
  2935.                  timers.
  2936.             
  2937.             CALLING SEQUENCE
  2938.             
  2939.                  ACCA = Task number (0 if SELF)
  2940.                  ACCB = Semaphore number (0 if task's semaphore)
  2941.                  IX = Number of clock tocks in timer. If > 0, timer is a
  2942.                       one-shot. If < 0, timer is cyclic.
  2943.                  swi
  2944.                   FCB .timer.
  2945.                  return
  2946.             
  2947.             RETURN VALUE
  2948.             
  2949.                  None. ACCA will contain the current task number if ACCA
  2950.                  was = 0 at swi. Other registers unchanged.
  2951.             
  2952.             EXAMPLE
  2953.             
  2954.                  Example #1:
  2955.                  
  2956.                  Assume that the current task wants to set up a one-shot
  2957.                  timer of 5 seconds. Also assume that the RTI is used as
  2958.                  the time  base using a 2**23 crystal and the clock TICK
  2959.                  is defined  to be 15.625 msec. Furthermore, there are 8
  2960.                  TICKS per TOCK so that a TOCK is 125 msec. The setup of
  2961.                  a 5  second timer  associated with  a named  semaphore,
  2962.                  TIMEOUT, would appear as:
  2963.                  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.             Copyright (c) 1989         Page 5 - 24          Motorola, Inc.
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.                   MCX11 - MicroController eXecutive for the 68HC11
  2977.  
  2978.  
  2979.  
  2980.                  TOCK      equ   8
  2981.                  TOCKTIME  equ   1000/8         TOCKTIME = 125 msec
  2982.                  TIMEOUT   equ   3              Named semaphore #3
  2983.                            .
  2984.                            :
  2985.                            clra                 Task is self (ACCA=0)
  2986.                            ldab  #TIMEOUT       Semaphore = TIMEOUT
  2987.                            ldx  #5000/TOCKTIME  Timer = 40 TOCKS
  2988.                            swi
  2989.                             FCB  .timer.
  2990.                            .                    Point of continuation
  2991.                  
  2992.                  The current  task would continue processing immediately
  2993.                  after the  ESR is finished because the .timer. ESR does
  2994.                  not cause the requestor to be put into a WAIT state nor
  2995.                  is there  a  context  switch  possible.  The  task  may
  2996.                  attempt to  wait on  the timer  semaphore at some later
  2997.                  time.
  2998.             
  2999.             SEE ALSO
  3000.             
  3001.                  .purge.
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.  
  3035.             Copyright (c) 1989         Page 5 - 25          Motorola, Inc.
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.                   MCX11 - MicroController eXecutive for the 68HC11
  3043.  
  3044.  
  3045.  
  3046.             5.15  .wait.  -  WAIT ON SEMAPHORE
  3047.             
  3048.             CLASS
  3049.             
  3050.                  Semaphore
  3051.             
  3052.             SYNOPSIS
  3053.             
  3054.                  .wait. (SEMA)       [1]
  3055.             
  3056.             DESCRIPTION
  3057.             
  3058.                  The wait  directive is a fundamental function in MCX11.
  3059.                  It is used to make a task wait for a specified event to
  3060.                  occur.   The event  must be  associated with  the given
  3061.                  semaphore.   If the  semaphore is  found  to  be  in  a
  3062.                  PENDing state,  the task  is placed  into an Event Wait
  3063.                  state and  the semaphore is changed to WAITing, and the
  3064.                  context of the current task is saved.  If the semaphore
  3065.                  is in a DONE state, no wait occurs and the task resumes
  3066.                  immediately.   Upon task resumption, the wait directive
  3067.                  returns  the   semaphore  number  of  the  event  which
  3068.                  occurred.
  3069.             
  3070.             CALLING SEQUENCE
  3071.             
  3072.                  ACCB = Semaphore number
  3073.                  swi
  3074.                   FCB .wait.
  3075.                  return
  3076.             
  3077.             RETURN VALUE
  3078.             
  3079.                  None. Registers unchanged.
  3080.             
  3081.             EXAMPLE
  3082.             
  3083.                  The current task wants to wait on a timer semaphore set
  3084.                  up by  a previous  .timer. request.  The semaphore is a
  3085.                  named semaphore, TIMEOUT. The procedure would appear as
  3086.                  follows:
  3087.                  
  3088.                  TIMEOUT   equ   3             Semaphore #3
  3089.                            .
  3090.                            :
  3091.                            ldab  #TIMEOUT      ACCB = semaphore # 3
  3092.                            swi
  3093.                             FCB  .wait.
  3094.                            .                   Point of continuation
  3095.                  
  3096.                  The current  task is put into a WAIT state on semaphore
  3097.                  TIMEOUT as  a result of this request. It will remain in
  3098.  
  3099.  
  3100.  
  3101.             Copyright (c) 1989         Page 5 - 26          Motorola, Inc.
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.                   MCX11 - MicroController eXecutive for the 68HC11
  3109.  
  3110.  
  3111.  
  3112.                  this state  until another task, in this case, the clock
  3113.                  driver, signals  TIMEOUT  that  the  timer  period  has
  3114.                  elapsed.  The   task  would   then  continue   at   the
  3115.                  instruction following the FCB.
  3116.             
  3117.             SEE ALSO
  3118.             
  3119.                  .pend., .signal.
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.             Copyright (c) 1989         Page 5 - 27          Motorola, Inc.
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.                  MCX11 - MicroController eXecutive for the MC68HC11
  3175.  
  3176.  
  3177.  
  3178.                                      SECTION 6
  3179.                                           
  3180.                                 SYSTEM CONFIGURATION
  3181.                                           
  3182.             
  3183.             6.1  SYSTEM CONFIGURATION CONCEPTS
  3184.             
  3185.             Another configuration  concept central  to the  operation of
  3186.             MCX11 is  that of  pre-definition.   Most real  time systems
  3187.             used  in   embedded  operations   have   a   fairly   static
  3188.             configuration.   That is to say, the equipment configuration
  3189.             is not  subject to  frequent changes nor is the basic system
  3190.             functionality.  Consequently, the system designer can define
  3191.             the operating  environment  so  that  the  operating  system
  3192.             dynamics are  avoided to  the greatest  degree possible.  In
  3193.             other words,  the number of tasks concurrently executing may
  3194.             change but  the relative  priorities of  tasks remain fixed.
  3195.             Thus task  priorities can  be pre-assigned.   The  amount of
  3196.             free memory  can be  computed  and  established,  number  of
  3197.             queues and  their  sizes,  and  the  number  of  timers  and
  3198.             semaphores are  all defined prior to runtime.  The result is
  3199.             that MCX11  works in an established environment which yields
  3200.             the effect   of  less system  overhead,  smaller  code,  and
  3201.             faster execution;  all three being  desirable in a real time
  3202.             system.
  3203.             
  3204.             In order  to define  a  MCX11  system  configuration  it  is
  3205.             necessary to  configure those  data and  control  structures
  3206.             with  the   application  specific  information  which  MCX11
  3207.             requires. The  configuration is done by creating AS11 source
  3208.             code files  which define the necessary information needed to
  3209.             assemble with  MCX11 source  code  to  define  a  particular
  3210.             configuration.  The   following  paragraphs   describe   the
  3211.             techniques.
  3212.             
  3213.             
  3214.             6.2  MCX11 SYSTEM TABLE MEMORY REQUIREMENTS
  3215.             
  3216.             MCX11 system  tables must  necessarily reside  in an area of
  3217.             RAM.  This section is included to assist the system designer
  3218.             in determining  the amount of ROM and RAM required for MCX11
  3219.             tables. The  amount of  RAM and ROM may be computed from the
  3220.             equations below  given the  following  system  configuration
  3221.             information:
  3222.             
  3223.                  NTASKS    The number of tasks
  3224.                  NNAMSEM   The number of named semaphores
  3225.                  NQUEUES   The number of queues
  3226.                  NTIMERS   The number of timers
  3227.             
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.             Copyright (c) 1989         Page 6 - 1          Motorola, Inc.
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.                  MCX11 - MicroController eXecutive for the MC68HC11
  3241.  
  3242.  
  3243.  
  3244.             The symbols above are used by MCX11 and should be considered
  3245.             reserved symbols.  These numbers  are obviously exclusive of
  3246.             any RAM and ROM requirements of the application tasks.
  3247.             
  3248.             Tasks
  3249.             
  3250.                  A Task  Control Block  occupies 5  bytes of  RAM and  7
  3251.                  bytes of ROM.
  3252.                  
  3253.                       TASK bytes (RAM) = NTASKS * 5 + 5
  3254.                       TASK bytes (ROM) = NTASKS * 7
  3255.             
  3256.             Semaphores
  3257.             
  3258.                  Each semaphore  requires 1  byte of  RAM.  Total system
  3259.                  area required  for semaphore  control is  the number of
  3260.                  named semaphores  + the  number of  tasks + 2 times the
  3261.                  number of queues.
  3262.                  
  3263.                       SEMA bytes (RAM) = NNAMSEM + NTASKS + 2 * NQUEUES
  3264.             
  3265.             
  3266.             Queues
  3267.             
  3268.                  Each queue  consists of  a queue  header and  the queue
  3269.                  body.   Each queue header requires 3 bytes of RAM and 6
  3270.                  bytes of ROM.  Each defined queue body requires an area
  3271.                  of RAM  defined by the product of its Width (W) and its
  3272.                  Depth (D).
  3273.                  
  3274.                       QUEUE bytes (RAM) = NQUEUES * 3 + Sum(Wi * Di),
  3275.                                           where Wi is the width and Di
  3276.                                           is the depth of the ith queue,
  3277.                                           and i ranges from 1 - NQUEUES.
  3278.                  
  3279.                       QUEUE bytes (ROM) = NQUEUES * 6
  3280.             
  3281.             
  3282.             Clock
  3283.             
  3284.                  Timers require  8 bytes  of RAM  each.   The total area
  3285.                  required for  timer control  and storage is the product
  3286.                  of 8 and the number of defined timers.
  3287.                  
  3288.                       TIMER bytes (RAM) = NTIMERS * 8
  3289.             
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.             Copyright (c) 1989         Page 6 - 2          Motorola, Inc.
  3300.  
  3301.  
  3302.  
  3303.  
  3304.  
  3305.  
  3306.                  MCX11 - MicroController eXecutive for the MC68HC11
  3307.  
  3308.  
  3309.  
  3310.                                      SECTION 7
  3311.                                           
  3312.                              DEVICE DRIVER & INTERRUPTS
  3313.                                           
  3314.             
  3315.             7.1  DRIVER CONCEPTS
  3316.             
  3317.             Device  drivers   are  program   modules  which  provide  an
  3318.             organized software  interface between  a physical device and
  3319.             the application programs using the device.  The intent is to
  3320.             mask the  specifics of  the device's  hardware peculiarities
  3321.             from the application software.  By doing so, the application
  3322.             code need  only conform  to the  protocol which  the  device
  3323.             driver expects  in order to perform a function.  Each device
  3324.             driver may  have a  protocol unique to its function, i.e., a
  3325.             disk driver  has different  functional requirements  from an
  3326.             analog-to-digital converter.
  3327.             
  3328.             In order  to accommodate the wide range of devices which are
  3329.             found in  real-time systems, the device drivers in MCX11 are
  3330.             structured as  tasks.   As a  task, a  device driver has the
  3331.             most flexible  environment with  complete access  to  system
  3332.             resources via  the Executive  Service Requests.  Actually, a
  3333.             device driver  usually consists  of two  parts:   the driver
  3334.             task, and  the interrupt  service routine (ISR).  The latter
  3335.             is used when the device can cause an interrupt to signal the
  3336.             completion of a function or the availability of the device.
  3337.             
  3338.             An ISR  exists to  handle an exception in the normal flow of
  3339.             processing.   The general  philosophy of MCX11 drivers is to
  3340.             minimize the time spent in the interrupt service routine and
  3341.             let the  task portion  handle the  real work  of the driver.
  3342.             This design  concept places  no restrictions on the designer
  3343.             for either  the ISR or the task functionality. The structure
  3344.             of the  ISR is  explained more  completely in  the following
  3345.             section.
  3346.             
  3347.             
  3348.             7.2  INTERRUPT SERVICE
  3349.             
  3350.             The  classic   interrupt   processing   philosophy   is   to
  3351.             acknowledge the  interrupt and  save the  current  processor
  3352.             context.   Then a branch is made to a software routine where
  3353.             the code  services the  specific interrupt  and performs any
  3354.             required operations.  When the  interrupt service routine is
  3355.             complete, control  of the  main program  is resumed  at  the
  3356.             point of  interruption.   MCX11 uses  a modified  version of
  3357.             that sequence.
  3358.             
  3359.             The  MC68HC11  microcontroller  always  pushes  the  current
  3360.             processor context of nine (9) bytes on the active stack when
  3361.             an interrupt  occurs. That having been done, it acknowledges
  3362.  
  3363.  
  3364.  
  3365.             Copyright (c) 1989         Page 7 - 1          Motorola, Inc.
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.                  MCX11 - MicroController eXecutive for the MC68HC11
  3373.  
  3374.  
  3375.  
  3376.             the interrupt  and vectors automatically to the specific ISR
  3377.             written for  that event.  The user must initialize each two-
  3378.             byte interrupt  vector location  specific to his application
  3379.             as part of the initialization code.
  3380.             
  3381.             MCX11  presets   the  vector  locations  for  the  following
  3382.             interrupts. All  others not  specifically  reserved  by  the
  3383.             MC68HC11 are available to the user.
  3384.             
  3385.                     Event               Address
  3386.                  
  3387.                  Clock (RTI)          $FFF0-$FFF1
  3388.                  MCX11 ESR request    $FFF6-$FFF7
  3389.                  Power On/Reset       $FFFE-$FFFF
  3390.             
  3391.             MCX11 uses a modified version of the classical ISR approach.
  3392.             The sequence is the same until the return to the interrupted
  3393.             program is  made at  the  end  of  the  ISR.  In  MCX11,  an
  3394.             interrupt may  be the  event for which a task is waiting. If
  3395.             so, a  notification of  the event's occurrence must be given
  3396.             to the  task. But  the possibility  exists that  the waiting
  3397.             task has  a  higher  priority  than  the  interrupted  task.
  3398.             Notification of  the event should remove the wait state from
  3399.             the higher  priority task  thus making it runnable, assuming
  3400.             it is not otherwise blocked.
  3401.             
  3402.             At that  point, a  decision has  to be  made as  to  how  to
  3403.             continue. Whichever  task is  of higher  priority,  the  one
  3404.             interrupted or the one which was waiting, it will be the one
  3405.             to resume  processing. If  it is  the interrupted  task,  it
  3406.             resumes at  the point  of interruption  as  in  the  classic
  3407.             sequence. If  the latter  task  is  of  higher  priority,  a
  3408.             context switch  is performed in which it is made the current
  3409.             task. Its  processor context  is restored from its stack and
  3410.             the task  resumes at  the location  following the  ESR which
  3411.             caused it to wait. The interrupted task remains runnable and
  3412.             will continue at the point of its interruption at some later
  3413.             time when it becomes the highest priority runnable task.
  3414.             
  3415.             MCX11 provides  a common  exit routine  to  which  all  ISRs
  3416.             should branch  if there  is the  possibility  of  a  context
  3417.             switch as  the  result  of  the  interrupt.  The  function's
  3418.             primary responsibility is to signal a specified semaphore of
  3419.             the occurrence  of an  event and  to dispatch control to the
  3420.             highest priority  task which is runnable after the interrupt
  3421.             has been serviced.
  3422.             
  3423.             
  3424.             7.2.1 Interrupt Processing Variables
  3425.             
  3426.             In order  for MCX11 interrupt servicing to operate properly,
  3427.             it is  necessary to  observe a  few rules of the road. There
  3428.  
  3429.  
  3430.  
  3431.             Copyright (c) 1989         Page 7 - 2          Motorola, Inc.
  3432.  
  3433.  
  3434.  
  3435.  
  3436.  
  3437.  
  3438.                  MCX11 - MicroController eXecutive for the MC68HC11
  3439.  
  3440.  
  3441.  
  3442.             are some  system variables  which are  used during interrupt
  3443.             processing in  the ISR  and in  the common ISR exit routine.
  3444.             These variables  must be used only in the ISR and should not
  3445.             be used  elsewhere. A  listing of  the variables and a brief
  3446.             description of  them follows. Their addresses are also given
  3447.             as a  displacement from the base address of the MCX11 system
  3448.             variables, MCXVAR.  MCXVAR may be located at any RAM address
  3449.             but must  be predefined  and assembled with the MCX11 kernel
  3450.             code.
  3451.             
  3452.             intlvl   (address MCXVAR+11)
  3453.             
  3454.                  This byte  variable is  a  counter  of  the  number  of
  3455.                  interrupts stacked  but not  yet processed  completely.
  3456.                  When an  interrupt occurs in a task, intlvl will always
  3457.                  contain a value of zero. The ISR code must increment it
  3458.                  by 1  to indicate  that an ISR is in process. If a task
  3459.                  calls the  MCX11 kernel,  intlvl is  incremented  to  a
  3460.                  value of 1. If an interrupt were to occur while control
  3461.                  is in  the MCX11 kernel, intlvl would be incremented to
  3462.                  2 by the ISR, etc.
  3463.                  
  3464.                  MCX11  allows  the  existence  of  interruptible  ISRs;
  3465.                  therefore, intlvl can assume any value up to the number
  3466.                  of possible interrupts in the system. As interrupts are
  3467.                  processed by  the common  ISR  exit  logic,  intlvl  is
  3468.                  decremented. A  resumption of  processing at  the  task
  3469.                  level can  only occur  when the  decremented  value  of
  3470.                  intlvl becomes  zero.  Otherwise,  the  non-zero  value
  3471.                  indicates the  existence of an interrupt which has been
  3472.                  incompletely serviced.  In that  case, the  common  ISR
  3473.                  exit logic  returns control  to the interrupted ISR and
  3474.                  resumes  processing   at  that   point.  Thus,   nested
  3475.                  interrupts and  re-entrant ISRs  are  handled  cleanly,
  3476.                  quickly, and automatically by MCX11.
  3477.                  
  3478.             curtsk  (address MCXVAR+5)
  3479.                  
  3480.                  This byte  variable contains  the number of the current
  3481.                  task. It  is to be considered a READ-ONLY variable. The
  3482.                  user should  NEVER write to this variable. It is needed
  3483.                  during  ISR   processing  to  determine  if  the  MCX11
  3484.                  Dispatcher was interrupted.
  3485.                  
  3486.             curtcb  (address MCXVAR+6)
  3487.                  
  3488.                  This  2-byte  variable  contains  the  address  of  the
  3489.                  current  task's  Task  Control  Block  (TCB).  The  TCB
  3490.                  contains an  entry for  the task's stack pointer. MCX11
  3491.                  interrupt  processing   requires  that  the  ISR  which
  3492.                  increments intlvl  to a  value of  1 must also save the
  3493.  
  3494.  
  3495.  
  3496.  
  3497.             Copyright (c) 1989         Page 7 - 3          Motorola, Inc.
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.  
  3504.                  MCX11 - MicroController eXecutive for the MC68HC11
  3505.  
  3506.  
  3507.  
  3508.                  current task's  stack pointer in its TCB. The variable,
  3509.                  curtcb, is READ-ONLY.
  3510.             
  3511.             
  3512.             7.2.2 Interrupt Processing Code
  3513.             
  3514.             All ISRs  which have  the capability  of causing  a  context
  3515.             switch should  incorporate the  following routine as in-line
  3516.             code in  the ISR.  If the  ISR is  to be  allowed to  enable
  3517.             interrupts, this code should precede the CLI instruction. As
  3518.             a rule  it should  occur early  in the  ISR  but  there  are
  3519.             exceptions. (Refer  to the  MCX11 clock  driver's ISR, whose
  3520.             entry address  has the  symbol rtiisr, for a good example of
  3521.             an exception to the rule.)
  3522.             
  3523.             Note that the label, notlvl0, used in the code segment below
  3524.             will need  to be changed for each ISR. The symbols ACTSP and
  3525.             SYSTACK are  not variables  and should not be changed. ACTSP
  3526.             is equated to the value of 1 and represents the displacement
  3527.             into the  TCB where  the task's  stack  pointer  is  stored.
  3528.             SYSTACK is the location of the base of the System Stack area
  3529.             and is defined in the System Configuration source code file,
  3530.             SYSTEM.AS.
  3531.             
  3532.             
  3533.                            tst   intlvl    Test for task level interrupt
  3534.                            bne   notlvl0   Branch if not task level int
  3535.                            tst   curtsk    See if Dispatcher interrupted
  3536.                            beq   notlvl0   Branch if so
  3537.                            ldx   curtcb    Get task's TCB address
  3538.                            sts   ACTSP,x   Save task's stack pointer
  3539.                            lds   #SYSTACK  Change to System Stack
  3540.                  notlvl0   inc   intlvl    Increment the interrupt level
  3541.                  
  3542.                  After this  point, the  CLI instruction may be inserted
  3543.                  if desired.
  3544.             
  3545.             
  3546.             The interrupt  service code  follows. An important factor in
  3547.             interrupt  processing  throughput  is  the  length  of  time
  3548.             interrupts are  disabled during  the  ISR.    In  all  ISRs,
  3549.             interrupts must  be disabled long enough to perform the code
  3550.             segment above and only then should interrupts be re-enabled.
  3551.             Ideally,  interrupt   routines  should   be  performed  with
  3552.             interrupts enabled to allow other interrupts to be serviced.
  3553.             
  3554.             The exit  from the  ISR routine is via a branch to the MCX11
  3555.             common Interrupt Service Routine Exit routine located at the
  3556.             address having  the symbol,  isrrtn. This routine allows for
  3557.             optionally signalling  a semaphore  during the exit process.
  3558.             The ISR  may wish  to signal  a  semaphore  that  the  event
  3559.             associated with  the interrupt  has occurred.  To do so, the
  3560.  
  3561.  
  3562.  
  3563.             Copyright (c) 1989         Page 7 - 4          Motorola, Inc.
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.  
  3570.                  MCX11 - MicroController eXecutive for the MC68HC11
  3571.  
  3572.  
  3573.  
  3574.             ISR simply  puts the number of the semaphore to be signalled
  3575.             into the  B-Accumulator and the executes a branch to isrrtn.
  3576.             From there  on, the  further processing  of the interrupt is
  3577.             performed automatically  by MCX11. As an example, assume the
  3578.             ISR wants  to signal a semaphore and that the label used for
  3579.             the semaphore  is EVNTSEMA. Then the concluding code segment
  3580.             in the ISR is
  3581.             
  3582.             
  3583.                            ldab  #EVNTSEMA   Load ACCB with semaphore #
  3584.                            jmp   isrrtn      Jump to exit logic.
  3585.             
  3586.             
  3587.             If no  semaphore is to be signalled during the exit routine,
  3588.             the ISR  should make  sure that the B-Accumulator is cleared
  3589.             before branching to isrrtn.
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.             Copyright (c) 1989         Page 7 - 5          Motorola, Inc.
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.                  MCX11 - MicroController eXecutive for the MC68HC11
  3637.  
  3638.  
  3639.  
  3640.                                      SECTION 8
  3641.                                           
  3642.                                   ADVANCED TOPICS
  3643.                                           
  3644.             
  3645.             8.1  OTHER TOPICS
  3646.             
  3647.             Other topics  of interest  will be  added to this section as
  3648.             they are researched and documented.
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.             Copyright (c) 1989         Page 8 - 1          Motorola, Inc.
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.                  MCX11 - MicroController eXecutive for the MC68HC11
  3703.  
  3704.  
  3705.  
  3706.                                      APPENDIX A
  3707.                                           
  3708.                            MCX11 DISTRIBUTED SOURCE FILES
  3709.                                           
  3710.             
  3711.             MCX11 is  distributed as  a collection of files. Those files
  3712.             and their purposes are briefly described below.
  3713.             
  3714.             CLKDRVR.AS
  3715.             
  3716.             The AS11  source code  of  the  RTI  clock  driver  and  RTI
  3717.             Interrupt Service Routine.
  3718.             
  3719.             ESREQU.AS
  3720.             
  3721.             These are  just the  equates for  MCX11  ESRs  included  for
  3722.             completeness.
  3723.             
  3724.             MCX.AS
  3725.             
  3726.             This is the AS11 source code of the MCX11 kernel. Unless you
  3727.             are expanding  the functions  of  the  kernel  or  fixing  a
  3728.             reported bug, this file probably won't change too much.
  3729.             
  3730.             SYSTEM.AS
  3731.             
  3732.             This AS11 source code file contains the application specific
  3733.             information and  should be  studied very  closely.  It  also
  3734.             contains initialization  code  which  may  be  necessary  to
  3735.             change to meet the needs of a given application. The file is
  3736.             pre-configured  with   the  specifications  needed  for  the
  3737.             demonstration programs in file TEST.AS.
  3738.             
  3739.             TEST.AS
  3740.             
  3741.             This is  an AS11  source code  file containing 4 tasks which
  3742.             demonstrate the  use of all of the MCX11 ESRs. It doesn't do
  3743.             anything practical except to give the user a limited look at
  3744.             how to accomplish certain operations.
  3745.             
  3746.             VECTORS.AS
  3747.             
  3748.             AS11 source  code containing  all of  the  vectors  used  by
  3749.             MCX11.  This  file  may  need  to  be  edited  for  a  given
  3750.             application.
  3751.             
  3752.             ASSEMBLE.BAT
  3753.             
  3754.             A MS-DOS  Batch file  used to  assemble MCX11  and the  TEST
  3755.             programs. It also produces a listing file.
  3756.             
  3757.             MANUAL.DOC
  3758.  
  3759.  
  3760.  
  3761.             Copyright (c) 1989         Page A - 1          Motorola, Inc.
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768.                  MCX11 - MicroController eXecutive for the MC68HC11
  3769.  
  3770.  
  3771.  
  3772.             
  3773.             The MCX11 User's Manual is contained in this file. It can be
  3774.             printed out directly to any ASCII compatible printer.
  3775.             
  3776.             README.DOC
  3777.             
  3778.             Some notes about getting started with MCX11.
  3779.             
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.             Copyright (c) 1989         Page A - 2          Motorola, Inc.
  3828.  
  3829.  
  3830.  
  3831.