Module #1: Setup
; The following "$" commands must be included in every module
$NOMOD51 ; Omit assembler predefined registers.
$INCLUDE(reg515.inc) ; Include 515/535 microcontroller definitions.
NAME SETUP ; Optional parameter; if no name is provided,
; the filename will be used by default.
EXTRN CODE (MAIN_LOOP,SERINIT)
EXTRN CODE (LCDINIT,KPD) ; Makes subroutine MAIN_LOOP in the
; main.a51 module available to module
; setup.a51 .
;***********************************************************************************
ST_ADDR equ 8000h ; Set program starting address at 8000h.
CSEG AT ST_ADDR ; Places beginning of code at in a fixed memory
; location specified by ST_ADDR = 8000h.
; This is referred to as an
; "absolute code segment", and cannot be relocated.
BEGIN:
LJMP START ; Jump to start of program.
ST_SEG SEGMENT CODE ; Reserve RAM space for 80535 initialization
; code segment, ST_SEG. Again, since this is a
; "generic segment", it is relocatable.
RSEG ST_SEG ; Places the code segement containing
; START 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.
; Place code for initializations specific to the fundamental operation of the
; EMAC MicroPac 80535 microcontroller board here.
START:
CLR PSW.4 ; Selects register bank 0.
CLR PSW.3 ; PSW bits 3 and 4 dictate register bank.
MOV SP,#60h ; Initialize stack pointer to 60h. Note that
; the stack pointer could be initialized
; to any value between 20h and 7Fh. However, the programmer must
; ensure (1) stack has enough space to expand adequately, and
; (2) does not overwrite user data.
MOV IEN0,#0 ; Disable all interrupts.
SETB P5.5 ; Activates the external reset line.
CLR P5.5 ; De-activates the external reset line.
SETB P5.0 ; Make A16 of 128K RAM; system can use only
; the high 128K of the RAM space.
; Note that A16 MUST BE SET, with no exceptions.
CLR P5.2 ; Disable EEPROM by setting the EEPROM
; clock to its low level.
CLR P5.1 ; Enable memory mapped input/output (MMIO)
; to enable the keypad and LCD panel.
; Add other initialization code here specific to the operation of interrupts,
; keypad, LCD, serial port, A/D, etc..
SETB EAL ; Enable all interrupts
CALL SERINIT
CALL LCDINIT ; initialize LCD display
; this is possible because subroutine LCDINIT
; has been made public and has been defined
; as external code in module lcd.a51
;CALL KPD
MOV R0,#2Fh ; Clear a block of RAM (for example only).
CLR_RAM:
MOV @R0,#0
DEC R0
CJNE R0,#1Fh,CLR_RAM
LJMP MAIN_LOOP ; Transfer control to MAIN_LOOP code in
; module main.a51.
END