新浪博客

STARTUP.A51详解

2012-04-20 16:24阅读:
转自:http://blog.csdn.net/zhbsniper/article/details/7184865 接下来几篇都是这里的
Startup code:启动代码。在Keil中,启动代码在复位目标系统后立即被执行。启动代码主要实现以下功能:
(1) 清除内部数据存储器
(2) 清除外部数据存储器
(3) 清除外部页存储器
(4) 初始化small模式下的可重入栈和指针
(5) 初始化large模式下的可重入栈和指针
(6) 初始化compact模式下的可重入栈和指针
(7) 初始化8051硬件栈指针
(8) 传递初始化全局变量的控制命令或者在没有初始化全局变量时给main函数传递命令。
在每一个启动文件中,提供了可供用户自己修改有来控制程序执行的汇编常量。见表1
表1
Name
Description
IDATALEN
Specifies the number of bytes of idata to clear to 0. The default is 80h because most 8051 derivatives contain at least 128 bytes of internal data memory. Use a value of 100h for the 8052 and other derivatives that have 256 bytes of internal data memory.
XDATASTART
Specifies the initial xdata address to clear to 0.
XDATALEN
Indicates the number of bytes of xdata to clear to 0. The default is 0.
PDATASTART
Specifies the initial pdata address to clear to 0.
PDATALEN
Specifies the number of bytes of pdata to clear to 0. The default is 0.
IBPSTACK
Specifies whether or not the small model reentrant stack pointer (?C_IBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.
IBPSTACKTOP
Specifies the top of the small model reentrant stack. The default is 0xFF in idata memory.
The Cx51 Compiler does not check to see if the stack area available satisfies the requirements of the application. It is your responsibility to perform such a test.
XBPSTACK
Specifies whether or not the large model reentrant stack pointer (?C_XBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.
XBPSTACKTOP
Specifies the top of the large model reentrant stack. The default is 0xFFFF in xdata memory.
The Cx51 Compiler does not check to see if the stack area available satisfies the requirements of the application. It is your responsibility to perform such a test.
PBPSTACK
Specifies whether the compact model reentrant stack pointer (?C_PBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.
PBPSTACKTOP
Specifies the top of the compact model reentrant stack. The default is 0xFF in pdata memory.
The Cx51 Compiler does not check to see if the stack area available satisfies the requirements of the application. It is your responsibility to perform such a test.
PPAGEENABLE
Enables (a value of 1) or disables (a value of 0) Port 2 initialization for pdata memory access. The default is 0. pdata addressing uses Port 2 for the upper address (or page) byte.
PPAGE
Specifies the value to write to Port 2 of the 8051 for pdata memory access. This value represents the xdata memory page to use for pdata. This is the upper 8 bits of the absolute address range to use for pdata. For example, if the pdata area begins at address 1000h (page 10h) in xdata memory, PPAGEENABLE should be set to 1, and PPAGEshould be set to 10h. You must specify the starting pdata address to use to the BL51 Linker using the PDATA directive. For example:
BL51 input modules PDATA (1050H)
Neither the BL51 Linker nor the Cx51 Compiler checks to see if the PDATA directive and the PPAGE startup constant are correctly specified. You must ensure that these parameters contain suitable values.
上面这些只是标号,如果愿意,自己可以换成其他的名字。这样写意义更直观。

$NOMOD51
;不使用预先定义的SFR,The NOMOD51 directive suppresses pre-definition of 8051 SFR
;names. This directive must be used when a customer-specific SFR definition file is included.
;------------------------------------------------------------------------------
; This file is part of the C51 Compiler package
; Copyright (c) 1988-2005 Keil Elektronik GmbH and Keil Software, Inc.
; Version 8.01
;
; *** <<< Use Configuration Wizard in Context Menu >>> ***
;------------------------------------------------------------------------------
; STARTUP.A51: This code is executed after processor reset.
;代码在处理器复位后执行
; To translate this file use A51 with the following invocation:
;通过A51用下面的命令传递该文件
; A51 STARTUP.A51
;
; To link the modified STARTUP.OBJ file to your application use the following
; Lx51 invocation:
;利用下面Lx51命令来链接修改的STARTUP.OBJ文件到实际的应用
; Lx51 your object file list, STARTUP.OBJ controls
;
;------------------------------------------------------------------------------
;
; User-defined <h> Power-On Initialization of Memory
;用户自定义上电初始化内存
; With the following EQU statements the initialization of memory
; at processor reset can be defined:
;在处理器复位时通过EQU来初始化内存
; <o> IDATALEN: IDATA memory size <0x0-0x100>
;IDATALEN:IDATA存储区的大小<0-256>,可以根据自己的选择修改
; <i> Note: The absolute start-address of IDATA memory is always 0
; <i> The IDATA space overlaps physically the DATA and BIT areas.
;IDATA绝对的起始地址总是0
;IDATA空间涵盖物理上的DATA和BIT区
;需用0来初始化idata区的字节数
IDATALEN EQU 80H
;
; <o> XDATASTART: XDATA memory start address <0x0-0xFFFF>
; <i> The absolute start address of XDATA memory
;XDATA存储区的起始地址,XDATA内存的绝对起始地址。
XDATASTART EQU 0
;指定初始的XDATA地址清0
; <o> XDATALEN: XDATA memory size <0x0-0xFFFF>
; <i> The length of XDATA memory in bytes.
;XDATA空间的长度,以字节为单位
XDATALEN EQU 0
;说明xdata的字节数清0,该值默认为0
; <o> PDATASTART: PDATA memory start address <0x0-0xFFFF>
; <i> The absolute start address of PDATA memory
PDATASTART EQU 0H
;
; <o> PDATALEN: PDATA memory size <0x0-0xFF>
; <i> The length of PDATA memory in bytes.
PDATALEN EQU 0H
;
;</h>
;------------------------------------------------------------------------------
;
;<h> Reentrant Stack Initialization
;重入栈的初始化
; The following EQU statements define the stack pointer for reentrant
; functions and initialized it:
;EQU语句定义了重入函数的栈指针并初始化
; <h> Stack Space for reentrant functions in the SMALL model.
;SMALL模式下的重入函数栈
; <q> IBPSTACK: Enable SMALL model reentrant stack
; IBPSTACK = 1使能模拟栈
; <i> Stack space for reentrant functions in the SMALL model.
IBPSTACK

我的更多文章

下载客户端阅读体验更佳

APP专享