启动文件STARTUP.A51中包含目标板启动代码,可在每个project中加入这个文件,只要复位,则该文件立即执行,其功能包括:l 定义内部RAM大小、外部RAM大小、可重入堆栈位置l 清除内部、外部或者以此页为单元的外部存储器l 按存储模式初使化重入堆栈及堆栈指针l 初始化8051硬件堆栈指针l 向main( )函数交权开发人员可修改以下数据从而对系统初始化 常数名 意义IDATALEN 待清内部RAM长度XDATA START 指定待清外部RAM起始地址XDATALEN 待清外部RAM长度IBPSTACK 是否小模式重入堆栈指针需初始化标志,1为需要。缺省为0IBPSTACKTOP 指定小模式重入堆栈顶部地址XBPSTACK 是否大模式重入堆栈指针需初始化标志,缺省为0XBPSTACKTOP 指定大模式重入堆栈顶部地址PBPSTACK 是否Compact重入堆栈指针,需初始化标志,缺省为0PBPSTACKTOP 指定Compact模式重入堆栈顶部地址PPAGEENABLE P2初始化允许开关PPAGE 指定P2值PDATASTART 待清外部RAM页首址PDATALEN 待清外部RAM页长度提示:如果要初始化P2作为紧凑模式高端地址,必须:PPAGEENAGLE=1,PPAGE为P2值,例如指定某页1000H-10FFH,则PPAGE=10H,而且连接时必须如下:L51 PDATA(1080H),其中1080H是1000H-10FFH中的任一个值。以下是STARTUP.A51代码片断,红色是经常可能需要修改的地方:;------------------------------------------------------------------------------; This file is part of the C51 Compiler package; Copyright KEIL ELEKTRONIK GmbH 1990;------------------------------------------------------------------------------; STARTUP.A51: This code is executed after processor reset.;; To translate this file use A51 with the following invocation:;; A51 STARTUP.A51;; To link the modified STARTUP.OBJ file to your application use the following; L51 invocation:;; L51 , STARTUP.OBJ ;;------------------------------------------------------------------------------;; User-defined Power-On Initialization of Memory;; With the following EQU statements the initialization of memory; at processor reset can be defined:;; ; the absolute start-address of IDATA memory is always 0IDATALEN EQU 80H ; the length of IDATA memory in bytes.;XDATASTART EQU 0H ; the absolute start-address of XDATA memoryXDATALEN EQU 0H ; the length of XDATA memory in bytes.;PDATASTART EQU 0H ; the absolute start-address of PDATA memoryPDATALEN EQU 0H ; the length of PDATA memory in bytes.;; Notes: The IDATA space overlaps physically the DATA and BIT areas of the; 8051 CPU. At minimum the memory space occupied from the C51 ; run-time routines must be set to zero.;------------------------------------------------------------------------------;; Reentrant Stack Initilization;; The following EQU statements define the stack pointer for reentrant; functions and initialized it:;; Stack Space for reentrant functions in the SMALL model.IBPSTACK EQU 0 ; set to 1 if small reentrant is used.IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highest location+1.;; Stack Space for reentrant functions in the LARGE model. XBPSTACK EQU 0 ; set to 1 if large reentrant is used.XBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.;; Stack Space for reentrant functions in the COMPACT model. PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.;;------------------------------------------------------------------------------;; Page Definition for Using the Compact Model with 64 KByte xdata RAM;; The following EQU statements define the xdata page used for pdata; variables. The EQU PPAGE must conform with the PPAGE control used; in the linker invocation.;PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.PPAGE EQU 0 ; define PPAGE number.;;------------------------------------------------------------------------------