单片机成长之路(51基础篇) - 018 keil51的STARTUP.A51

Posted jikexianfeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单片机成长之路(51基础篇) - 018 keil51的STARTUP.A51相关的知识,希望对你有一定的参考价值。

STARTUP.A51原始文件:

  1 $NOMOD51;Ax51宏汇编器控制命令,禁止预定义的8051。使编译器不使能预定义的;8051符号,避免产生重复定义的错误。
  2 ;------------------------------------------------------------------------------
  3 ;  This file is part of the C51 Compiler package
  4 ;  Copyright (c) 1988-2005 Keil Elektronik GmbH and Keil Software, Inc.
  5 ;  Version 8.01
  6 ;
  7 ;  *** <<< Use Configuration Wizard in Context Menu >>> ***
  8 ;------------------------------------------------------------------------------
  9 ;  STARTUP.A51:  This code is executed after processor reset.
 10 ;
 11 ;  To translate this file use A51 with the following invocation:
 12 ;
 13 ;     A51 STARTUP.A51
 14 ;
 15 ;  To link the modified STARTUP.OBJ file to your application use the following
 16 ;  Lx51 invocation:
 17 ;
 18 ;     Lx51 your object file list, STARTUP.OBJ  controls
 19 ;
 20 ;------------------------------------------------------------------------------
 21 ;
 22 ;  User-defined <h> Power-On Initialization of Memory
 23 ;
 24 ;  With the following EQU statements the initialization of memory
 25 ;  at processor reset can be defined:
 26 ;
 27 ; <o> IDATALEN: IDATA memory size <0x0-0x100>
 28 ;     <i> Note: The absolute start-address of IDATA memory is always 0
 29 ;     <i>       The IDATA space overlaps physically the DATA and BIT areas.
 30 IDATALEN        EQU     80H
 31 ;
 32 ; <o> XDATASTART: XDATA memory start address <0x0-0xFFFF> 
 33 ;     <i> The absolute start address of XDATA memory
 34 XDATASTART      EQU     0     
 35 ;
 36 ; <o> XDATALEN: XDATA memory size <0x0-0xFFFF> 
 37 ;     <i> The length of XDATA memory in bytes.
 38 XDATALEN        EQU     0      
 39 ;
 40 ; <o> PDATASTART: PDATA memory start address <0x0-0xFFFF> 
 41 ;     <i> The absolute start address of PDATA memory
 42 PDATASTART      EQU     0H
 43 ;
 44 ; <o> PDATALEN: PDATA memory size <0x0-0xFF> 
 45 ;     <i> The length of PDATA memory in bytes.
 46 PDATALEN        EQU     0H
 47 ;
 48 ;</h>
 49 ;------------------------------------------------------------------------------
 50 ;
 51 ;<h> Reentrant Stack Initialization
 52 ;
 53 ;  The following EQU statements define the stack pointer for reentrant
 54 ;  functions and initialized it:
 55 ;
 56 ; <h> Stack Space for reentrant functions in the SMALL model.
 57 ;  <q> IBPSTACK: Enable SMALL model reentrant stack
 58 ;     <i> Stack space for reentrant functions in the SMALL model.
 59 IBPSTACK        EQU     0       ; set to 1 if small reentrant is used.
 60 ;  <o> IBPSTACKTOP: End address of SMALL model stack <0x0-0xFF>
 61 ;     <i> Set the top of the stack to the highest location.
 62 IBPSTACKTOP     EQU     0xFF +1     ; default 0FFH+1  
 63 ; </h>
 64 ;
 65 ; <h> Stack Space for reentrant functions in the LARGE model.      
 66 ;  <q> XBPSTACK: Enable LARGE model reentrant stack
 67 ;     <i> Stack space for reentrant functions in the LARGE model.
 68 XBPSTACK        EQU     0       ; set to 1 if large reentrant is used.
 69 ;  <o> XBPSTACKTOP: End address of LARGE model stack <0x0-0xFFFF>
 70 ;     <i> Set the top of the stack to the highest location.
 71 XBPSTACKTOP     EQU     0xFFFF +1   ; default 0FFFFH+1 
 72 ; </h>
 73 ;
 74 ; <h> Stack Space for reentrant functions in the COMPACT model.    
 75 ;  <q> PBPSTACK: Enable COMPACT model reentrant stack
 76 ;     <i> Stack space for reentrant functions in the COMPACT model.
 77 PBPSTACK        EQU     0       ; set to 1 if compact reentrant is used.
 78 ;
 79 ;   <o> PBPSTACKTOP: End address of COMPACT model stack <0x0-0xFFFF>
 80 ;     <i> Set the top of the stack to the highest location.
 81 PBPSTACKTOP     EQU     0xFF +1     ; default 0FFH+1  
 82 ; </h>
 83 ;</h>
 84 ;------------------------------------------------------------------------------
 85 ;
 86 ;  Memory Page for Using the Compact Model with 64 KByte xdata RAM
 87 ;  <e>Compact Model Page Definition
 88 ;
 89 ;  <i>Define the XDATA page used for PDATA variables. 
 90 ;  <i>PPAGE must conform with the PPAGE set in the linker invocation.
 91 ;
 92 ; Enable pdata memory page initalization
 93 PPAGEENABLE     EQU     0       ; set to 1 if pdata object are used.
 94 ;
 95 ; <o> PPAGE number <0x0-0xFF> 
 96 ; <i> uppermost 256-byte address of the page used for PDATA variables.
 97 PPAGE           EQU     0
 98 ;
 99 ; <o> SFR address which supplies uppermost address byte <0x0-0xFF> 
100 ; <i> most 8051 variants use P2 as uppermost address byte
101 PPAGE_SFR       DATA    0A0H
102 ;
103 ; </e>
104 ;------------------------------------------------------------------------------
105 
106 ; Standard SFR Symbols 
107 ACC     DATA    0E0H
108 B       DATA    0F0H
109 SP      DATA    81H
110 DPL     DATA    82H
111 DPH     DATA    83H
112 
113                 NAME    ?C_STARTUP
114 
115 
116 ?C_C51STARTUP   SEGMENT   CODE
117 ?STACK          SEGMENT   IDATA
118 
119                 RSEG    ?STACK
120                 DS      1
121 
122                 EXTRN CODE (?C_START)
123                 PUBLIC  ?C_STARTUP
124 
125                 CSEG    AT      0
126                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ?C_STARTUP:     LJMP    STARTUP1
127 
128                 RSEG    ?C_C51STARTUP
129 
130 STARTUP1:
131 
132 IF IDATALEN <> 0
133                 MOV     R0,#IDATALEN - 1
134                 CLR     A
135 IDATALOOP:      MOV     @R0,A
136                 DJNZ    R0,IDATALOOP
137 ENDIF
138 
139 IF XDATALEN <> 0
140                 MOV     DPTR,#XDATASTART
141                 MOV     R7,#LOW (XDATALEN)
142   IF (LOW (XDATALEN)) <> 0
143                 MOV     R6,#(HIGH (XDATALEN)) +1
144   ELSE
145                 MOV     R6,#HIGH (XDATALEN)
146   ENDIF
147                 CLR     A
148 XDATALOOP:      MOVX    @DPTR,A
149                 INC     DPTR
150                 DJNZ    R7,XDATALOOP
151                 DJNZ    R6,XDATALOOP
152 ENDIF
153 
154 IF PPAGEENABLE <> 0
155                 MOV     PPAGE_SFR,#PPAGE
156 ENDIF
157 
158 IF PDATALEN <> 0
159                 MOV     R0,#LOW (PDATASTART)
160                 MOV     R7,#LOW (PDATALEN)
161                 CLR     A
162 PDATALOOP:      MOVX    @R0,A
163                 INC     R0
164                 DJNZ    R7,PDATALOOP
165 ENDIF
166 
167 IF IBPSTACK <> 0
168 EXTRN DATA (?C_IBP)
169 
170                 MOV     ?C_IBP,#LOW IBPSTACKTOP
171 ENDIF
172 
173 IF XBPSTACK <> 0
174 EXTRN DATA (?C_XBP)
175 
176                 MOV     ?C_XBP,#HIGH XBPSTACKTOP
177                 MOV     ?C_XBP+1,#LOW XBPSTACKTOP
178 ENDIF
179 
180 IF PBPSTACK <> 0
181 EXTRN DATA (?C_PBP)
182                 MOV     ?C_PBP,#LOW PBPSTACKTOP
183 ENDIF
184 
185                 MOV     SP,#?STACK-1
186 
187 ; This code is required if you use L51_BANK.A51 with Banking Mode 4
188 ;<h> Code Banking
189 ; <q> Select Bank 0 for L51_BANK.A51 Mode 4
190 #if 0   
191 ;     <i> Initialize bank mechanism to code bank 0 when using L51_BANK.A51 with Banking Mode 4.
192 EXTRN CODE (?B_SWITCH0)
193                 CALL    ?B_SWITCH0      ; init bank mechanism to code bank 0
194 #endif
195 ;</h>
196                 LJMP    ?C_START
197 
198                 END

 

以上是关于单片机成长之路(51基础篇) - 018 keil51的STARTUP.A51的主要内容,如果未能解决你的问题,请参考以下文章

单片机成长之路(51基础篇) - 016 常见总线类型

单片机成长之路(51基础篇) - 015 关于sdcc的多文件编译范例二

单片机成长之路(51基础篇) - 008 C51 的标示符和关键字

单片机成长之路(51基础篇) - 006 在Linux下搭建51单片机的开发烧写环境

单片机成长之路(51基础篇) - 020 51单片机寄存器功能一览表

单片机成长之路(51基础篇)- 002 STC单片机冷启动和复位有什么区别