標題: STARTUP.A51文件的理解 [打印本頁] 作者: geige 時間: 2015-7-26 01:38 標題: STARTUP.A51文件的理解 $NOMOD51 ;Ax51宏匯編器控制命令,禁止預定義的8051。使編譯器不使能預定義的;8051符號,避免產生重復定義的錯誤。
;------------------------------------------------------------------------------
; This file is part of the C51 Compilerpackage
; Copyright (c) 1988-2002 Keil Elektronik GmbHand Keil Software, Inc.
;------------------------------------------------------------------------------
; STARTUP.A51: This code isexecuted after processor reset.
;
; To translate this file use A51 with thefollowing invocation:
;
; A51 STARTUP.A51
;
; To link the modified STARTUP.OBJ file to yourapplication use the following
; BL51 invocation:
;
; BL51 , STARTUP.OBJ
; BL51是Keil使用的鏈接器(Linker),這是命令行的使用格式,一般不用,使用IDE環境,
;用project管理,有相應的按鈕可以實現該功能.
;------------------------------------------------------------------------------
;
; User-defined Power-On Initialization of Memory--- 初始化RAM單元
;
; With the following EQU statements theinitialization of memory---用下面的EQU聲明初
;始化ram單元
; at processor reset can be defined:
;
; ; the absolute start-address of IDATA memory is always 0
IDATALEN EQU 80H ; the lengthof IDATA memory in bytes.--根據你選用的芯片可以適
;當 的修改這些值 。IDATALEN 只是一個標號,EQU只是做宏一樣的替換,類似于C語;言中的#define uint (unsigned int),以上的代碼使得程序以后在碰到IDATALEN時替換;成80H
XDATASTART EQU 0H ; the absolute start-address of XDATA memory--以下
;兩項根據目標系統的外設配置和連接自己修改
XDATALEN EQU 0H ; the length of XDATA memory in bytes.
PDATASTART EQU 0H ; the absolute start-address of PDATA memory
PDATALEN EQU 0H ; the length of PDATA memory in bytes.
;
; Notes: The IDATA spaceoverlaps 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 StackInitilization --注意:再入堆棧的方向區別于芯片自帶的堆棧的生長方
;式,自頂向下生長的!而SP是是自底向上的!
; --且再入堆棧是由編譯器自己管理的,一般不必去關心,只是在有再入函數的時候,根據
;函數的存儲器模式使用相應的RAM空間做為再入堆棧。
; The following EQU statements define the stackpointer for reentrant
; functions and initialized it:
;Keil C默認情況不是用堆棧來傳遞參數的,所以造成函數不可重入,Keil要求用戶顯示聲
;明函數是否具有可重入屬性,以便為C函數調用初始化棧。
; Stack Space for reentrant functions in theSMALL model.
IBPSTACK EQU 0 ; set to 1 if small reentrant is used.
IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highestlocation+1.
;
; Stack Space for reentrant functions in theLARGEmodel.
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 theCOMPACTmodel.
PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.
PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.
;不同內存模式下的堆棧。Keil 編譯器中有三種模式設置:
;Small:所有的變量都放在內部RAM區
;Compact:所有變量在默認情況下都會放在外部RAM的低256字節中(可由R0尋址)
;Large:所有變量都放在外部RAM中(DPTR尋址)
;這是由51處理器繁多的尋址模式導致的,不同的尋址模式有不同的效率
;
;------------------------------------------------------------------------------
;
; Page Definition for Using the Compact Modelwith 64 KByte xdata RAM
;
; The following EQU statements define the xdatapage used for pdata
; variables. The EQU PPAGE must conform with thePPAGE control used
; in the linker invocation.
;
PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.
;
PPAGE EQU 0 ; define PPAGE number.
;
PPAGE_SFR DATA 0A0H ; SFRthat supplies uppermost address byte
; (most 8051 variants use P2 as uppermost address byte)很多的外部頁面尋址以P2
;口為高位地址的數值,有使用外部頁面RAM的情況
; 對PPAGEENABLE 設置為1 ,根據硬件連接修改PPAGE的值。
;------------------------------------------------------------------------------
; Standard SFR Symbols ---標準的SFR符號
ACC DATA 0E0H;關鍵字DATAA51偽指令定義單片機內部數據存儲器字節地址的符號
B DATA 0F0H
SP DATA 81H
DPL DATA 82H
DPH DATA 83H
NAME ?C_STARTUP ;定義當前程序模塊的目標模塊名