标题: 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 ;定义当前程序模块的目标模块名