;   ***************************************************************
;   * Copyright (C) 2005, Embed Inc (http://www.embedinc.com)     *
;   *                                                             *
;   * Permission to copy this file is granted as long as this     *
;   * copyright notice is included in its entirety at the         *
;   * beginning of the file, whether the file is copied in whole  *
;   * or in part and regardless of whether other information is   *
;   * added to the copy.                                          *
;   *                                                             *
;   * The contents of this file may be used in any way,           *
;   * commercial or otherwise.  This file is provided "as is",    *
;   * and Embed Inc makes no claims of suitability for a          *
;   * particular purpose nor assumes any liability resulting from *
;   * its use.                                                    *
;   ***************************************************************
;
;   This module contains the main application routine that is run after the
;   system is initialized.
;
/include "qq2.ins.aspic"

         extern_flags        ;declare global flag bits EXTERN

;*******************************************************************************
;
;   Configuration constants.
;
lbank    equ     0           ;register bank for the local state of this module
;
;   Derived constants.
;
lbankadr equ     bankadr(lbank) ;address within local state register bank

;*******************************************************************************
;
;   Global state.  All this state is assumed to be in the GBANK register bank by
;   other modules.
;
         defram  gbankadr


;*******************************************************************************
;
;   Local state.
;
         defram  lbankadr


.main    code
;*******************************************************************************
;
;   Routine MAIN
;
;   This entry point is jumped to from the INIT module, once system
;   initialization is complete.
;
         glbent  main

;**********
;
;   Initialize the state managed by this module.
;


;**********
;
;   Main application loop.  Back here to look for something to do.  Whenever
;   something is found that needs handling, a handler routine is jumped to.  All
;   handler routines jump back to LOOP_MAIN when done.  This means events are
;   checked in priority order, with high priority events checked earlier.
;
         glbent  loop_main

         gcall   task_yield  ;give all other tasks a chance to run


;
;   Go back and check all events again.
;
         jump    loop_main

         end