2 ;------------------------------------------------------------------------------
3 ; This file is part of the C51 Compiler package
4 ; Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
5 ;------------------------------------------------------------------------------
6 ; STARTUP.A51: This code is executed after processor reset.
8 ; To translate this file use A51 with the following invocation:
12 ; To link the modified STARTUP.OBJ file to your application use the following
15 ; BL51 <your object file list>, STARTUP.OBJ <controls>
17 ;------------------------------------------------------------------------------
19 ; User-defined Power-On Initialization of Memory
21 ; With the following EQU statements the initialization of memory
22 ; at processor reset can be defined:
24 ; ; the absolute start-address of IDATA memory is always 0
25 IDATALEN EQU 80H ; the length of IDATA memory in bytes.
27 XDATASTART EQU 0H ; the absolute start-address of XDATA memory
28 XDATALEN EQU 400H ; the length of XDATA memory in bytes.
30 PDATASTART EQU 0H ; the absolute start-address of PDATA memory
31 PDATALEN EQU 0H ; the length of PDATA memory in bytes.
33 ; Notes: The IDATA space overlaps physically the DATA and BIT areas of the
34 ; 8051 CPU. At minimum the memory space occupied from the C51
35 ; run-time routines must be set to zero.
36 ;------------------------------------------------------------------------------
38 ; Reentrant Stack Initilization
40 ; The following EQU statements define the stack pointer for reentrant
41 ; functions and initialized it:
43 ; Stack Space for reentrant functions in the SMALL model.
44 IBPSTACK EQU 0 ; set to 1 if small reentrant is used.
45 IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highest location+1.
47 ; Stack Space for reentrant functions in the LARGE model.
48 XBPSTACK EQU 0 ; set to 1 if large reentrant is used.
49 XBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.
51 ; Stack Space for reentrant functions in the COMPACT model.
52 PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.
53 PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.
55 ;------------------------------------------------------------------------------
57 ; Page Definition for Using the Compact Model with 64 KByte xdata RAM
59 ; The following EQU statements define the xdata page used for pdata
60 ; variables. The EQU PPAGE must conform with the PPAGE control used
61 ; in the linker invocation.
63 PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.
65 PPAGE EQU 0 ; define PPAGE number.
67 PPAGE_SFR DATA 0A0H ; SFR that supplies uppermost address byte
68 ; (most 8051 variants use P2 as uppermost address byte)
70 ;------------------------------------------------------------------------------
72 ; Standard SFR Symbols
82 ?C_C51STARTUP SEGMENT CODE
92 ?C_STARTUP: LJMP STARTUP1
107 MOV R7,#LOW (XDATALEN)
108 IF (LOW (XDATALEN)) <> 0
109 MOV R6,#(HIGH (XDATALEN)) +1
111 MOV R6,#HIGH (XDATALEN)
114 XDATALOOP: MOVX @DPTR,A
125 MOV R0,#LOW (PDATASTART)
126 MOV R7,#LOW (PDATALEN)
128 PDATALOOP: MOVX @R0,A
136 MOV ?C_IBP,#LOW IBPSTACKTOP
142 MOV ?C_XBP,#HIGH XBPSTACKTOP
143 MOV ?C_XBP+1,#LOW XBPSTACKTOP
148 MOV ?C_PBP,#LOW PBPSTACKTOP
152 ; This code is required if you use L51_BANK.A51 with Banking Mode 4
153 ; EXTRN CODE (?B_SWITCH0)
154 ; CALL ?B_SWITCH0 ; init bank mechanism to code bank 0