Module #2: Main
; main.a51 (Module #2)
;
; The following "$" commands must be included in every module
$NOMOD51 ; Omit assembler predefined registers.
$INCLUDE(reg515.inc) ; Include 515/535 microcontroller definitions.
NAME MAIN ; Optional parameter; if no name is provided,
; the filename will be used by default.
PUBLIC MAIN_LOOP ; Lets other modules access this section of code
; from "public domain" utilizing the EXTRN command.
EXTRN CODE (LCDOUT, DISPMENU, KPD, ALERT, ALERTMENU)
;EXTRN CODE (LOAD, SAVE)
; Makes subroutines LCDINIT and LCDOUT in the
; lcd.a51 module available to module main.a51 .
;***********************************************************************************
MAIN SEGMENT CODE ; Reserve RAM space for the generic code
; segment, MAIN. The name segment name is referred
; to by the following RSEG directive.
RSEG MAIN ; Selects the MAIN code segement, and makes it
; "active" at this point in assembled code.
; The selected segment remains "active" until
; a different segment is specified.
USING 0 ; Indicates to the assembler that register
; bank 0 will be used, but does not actually
; select register bank 0 .
; The module main.a51 should be used primarily to call subroutines in the
; various modules in the project, as opposed to incorporating detailed functions
; within module main.a51 (i.e., main.a51 should be relatively short).
MAIN_LOOP:
CALL DISPMENU
CALL KPD
CJNE A,#31h,SV
CALL ALERTMENU ;ALERT
SV:
CJNE A,#32h,LD
;CALL SAVE
LD:
;CALL LOAD
;CALL LCDOUT ; The call to LCDOUT is possible because
; subroutine LCDOUT has been made public, and
; has been defined as external code in
; module lcd.a51 .
LOOP:
JMP LOOP ; Infinite loop.
END