; ***************************************************************
; * Copyright (C) 2002, 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 "hos.inc"
extern cmd_byte ;event routine to process one byte from the host
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 with local state register bank
;
;***********************************************************************
;
; Local state.
;
.bank#v(lbank) udata
.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
;
; Check for an input byte is available from the host.
;
dbankif gbankadr
btfss flag_sin
goto no_sin
gjump cmd_byte ;process the input byte
no_sin dbankis gbankadr
;
; Nothing was found that needed handling. Go back and check everything
; again.
;
goto loop_main
end