国产成人av人人爽人人澡-亚洲国产日韩欧美一区-好吊日视频这里只有精品-日本高清精品视频在线

你好!歡迎來到深圳市穎特新科技有限公司!
語言
當(dāng)前位置:首頁 >> 技術(shù)中心 >> 單片機(jī)入門 >> 單片機(jī)STARTUP.A51詳解

單片機(jī)STARTUP.A51詳解

關(guān)鍵字:單片機(jī) 作者:admin 來源: 發(fā)布時(shí)間:2019-07-31  瀏覽:151

 Startup code:?jiǎn)?dòng)代碼。在Keil中,啟動(dòng)代碼在復(fù)位目標(biāo)系統(tǒng)后立即被執(zhí)行。啟動(dòng)代碼主要實(shí)現(xiàn)以下功能:

(1) 清除內(nèi)部數(shù)據(jù)存儲(chǔ)器

(2) 清除外部數(shù)據(jù)存儲(chǔ)器

(3) 清除外部頁存儲(chǔ)器

(4) 初始化small模式下的可重入棧和指針

(5) 初始化large模式下的可重入棧和指針

(6) 初始化compact模式下的可重入棧和指針

(7) 初始化8051硬件棧指針

(8) 傳遞初始化全局變量的控制命令或者在沒有初始化全局變量時(shí)給main函數(shù)傳遞命令。

在每一個(gè)啟動(dòng)文件中,提供了可供用戶自己修改有來控制程序執(zhí)行的匯編常量。見表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 PPAGE should 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.

上面這些只是標(biāo)號(hào),如果愿意,自己可以換成其他的名字。這樣寫意義更直觀。

$NOMOD51

;不使用預(yù)先定義的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.

;代碼在處理器復(fù)位后執(zhí)行

; 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文件到實(shí)際的應(yīng)用

; Lx51 your object file list, STARTUP.OBJ controls

;

;------------------------------------------------------------------------------

;

; User-defined Power-On Initialization of Memory

;用戶自定義上電初始化內(nèi)存

; With the following EQU statements the initialization of memory

; at processor reset can be defined:

;在處理器復(fù)位時(shí)通過EQU來初始化內(nèi)存

; IDATALEN: IDATA memory size <0x0-0x100>

;IDATALEN:IDATA存儲(chǔ)區(qū)的大小<0-256>,可以根據(jù)自己的選擇修改

; Note: The absolute start-address of IDATA memory is always 0

; The IDATA space overlaps physically the DATA and BIT areas.

;IDATA絕對(duì)的起始地址總是0

;IDATA空間涵蓋物理上的DATA和BIT區(qū)

;需用0來初始化idata區(qū)的字節(jié)數(shù)

IDATALEN EQU 80H

;

; XDATASTART: XDATA memory start address <0x0-0xFFFF>

; The absolute start address of XDATA memory

;XDATA存儲(chǔ)區(qū)的起始地址,XDATA內(nèi)存的絕對(duì)起始地址。

XDATASTART EQU 0

;指定初始的XDATA地址清0

; XDATALEN: XDATA memory size <0x0-0xFFFF>

; The length of XDATA memory in bytes.

;XDATA空間的長度,以字節(jié)為單位

XDATALEN EQU 0

;說明xdata的字節(jié)數(shù)清0,該值默認(rèn)為0

; PDATASTART: PDATA memory start address <0x0-0xFFFF>

; The absolute start address of PDATA memory

PDATASTART EQU 0H

;

; PDATALEN: PDATA memory size <0x0-0xFF>

; The length of PDATA memory in bytes.

PDATALEN EQU 0H

;

;

;------------------------------------------------------------------------------

;

; Reentrant Stack Initialization

;重入棧的初始化

; The following EQU statements define the stack pointer for reentrant

; functions and initialized it:

;EQU語句定義了重入函數(shù)的棧指針并初始化

; Stack Space for reentrant functions in the SMALL model.

;SMALL模式下的重入函數(shù)棧

; IBPSTACK: Enable SMALL model reentrant stack

; IBPSTACK = 1使能模擬棧

; Stack space for reentrant functions in the SMALL model.

IBPSTACK EQU 0 ; set to 1 if small reentrant is used.

; IBPSTACKTOP: End address of SMALL model stack <0x0-0xFF>

; IBPSTACKTOP:棧的結(jié)束地址<0x0-0xFF>

; Set the top of the stack to the highest location.

;設(shè)置為最高地址(向下生長的)

;默認(rèn)FFH+1(其實(shí)就是0,使用時(shí)進(jìn)行操作(+0xFF)使其變?yōu)?xFF)

IBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1

;

;下面是LARGE模式下的模擬棧,和SMALL相同不做特別說明

; Stack Space for reentrant functions in the LARGE model.

; XBPSTACK: Enable LARGE model reentrant stack

; Stack space for reentrant functions in the LARGE model.

XBPSTACK EQU 0 ; set to 1 if large reentrant is used.

; XBPSTACKTOP: End address of LARGE model stack <0x0-0xFFFF>

; Set the top of the stack to the highest location.

XBPSTACKTOP EQU 0xFFFF +1 ; default 0FFFFH+1

;

;COMPACT模式下

; Stack Space for reentrant functions in the COMPACT model.

; PBPSTACK: Enable COMPACT model reentrant stack

; Stack space for reentrant functions in the COMPACT model.

PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.

;

; PBPSTACKTOP: End address of COMPACT model stack <0x0-0xFFFF>

; Set the top of the stack to the highest location.

PBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1

;

;

;------------------------------------------------------------------------------

;COMPACT模式下64K xdata的頁存儲(chǔ)器

; Memory Page for Using the Compact Model with 64 KByte xdata RAM

; Compact Model Page Definition

;通過PDATA變量定義XDATA頁

; Define the XDATA page used for PDATA variables.

; PPAGE must conform with the PPAGE set in the linker invocation.

;PPAGE必須與鏈接器引用設(shè)置一致

; Enable pdata memory page initalization

PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.

;設(shè)置1使能

; PPAGE number <0x0-0xFF>

; uppermost 256-byte address of the page used for PDATA variables.

;頁號(hào),PDATA變量高256字節(jié)地址(高8位地址)

PPAGE EQU 0

;

; SFR address which supplies uppermost address byte <0x0-0xFF>

; most 8051 variants use P2 as uppermost address byte

;提供高字節(jié)地址的SFR的地址(高8位地址的存放位置),一般的8051單片機(jī)用P2口

PPAGE_SFR DATA 0A0H

;

;

;------------------------------------------------------------------------------

; Standard SFR Symbols

;使用偽指令DATA為寄存器分配地址或者為響應(yīng)的地址起一個(gè)別名

ACC DATA 0E0H

B DATA 0F0H

SP DATA 81H

DPL DATA 82H

DPH DATA 83H

NAME ?C_STARTUP ;定義當(dāng)前模塊的目標(biāo)模塊名

;NAME:

; NAME (modulename)

;NAME為輸出文件定義一個(gè)模塊名稱(modulename),如果在文件中沒有特定的

; (modulename),默認(rèn)的應(yīng)用第一個(gè)輸入文件的名稱。

?C_C51STARTUP SEGMENT CODE

;定義一個(gè)代碼段,名稱?C_C51STARTUP

?STACK SEGMENT IDATA ;堆棧

RSEG ?STACK ;RSEG選擇一個(gè)先前聲明的可重定位的段

DS 1 ;為堆棧預(yù)留一個(gè)低階的存儲(chǔ)空間

EXTRN CODE (?C_START) ;當(dāng)前源文件中用的代碼段存儲(chǔ)區(qū)的符號(hào)?C_START,在其他的目標(biāo)模塊中定義

PUBLIC ?C_STARTUP ;聲明可以用于其他目標(biāo)模塊的全局符號(hào)?C_STARTUP,用于和C相連接在.src文件中可以看到這個(gè)符號(hào)

CSEG AT 0 ;選擇代碼存儲(chǔ)區(qū)內(nèi)的一個(gè)絕對(duì)段,匯編從上面命令中的地址0開始執(zhí)行這個(gè)段。

?C_STARTUP: LJMP STARTUP1 ;芯片上電復(fù)位后,執(zhí)行的第一句就是該句,該句往下是開始執(zhí)行啟動(dòng)代碼

RSEG ?C_C51STARTUP ;選擇代碼段?C_C51STARTUP

STARTUP1: IF IDATALEN <> 0 ;如果IDATALEN不為0,則將長度-1送R0

MOV R0,#IDATALEN - 1

CLR A

IDATALOOP: MOV @R0,A ;將IDATA區(qū)清0

DJNZ R0,IDATALOOP

ENDIF

IF XDATALEN <> 0 ;如果有外部數(shù)據(jù)存儲(chǔ)區(qū)

MOV DPTR,#XDATASTART ;起始地址送DPTR

MOV R7,#LOW (XDATALEN) ;長度低8為送R7

IF (LOW (XDATALEN)) <> 0 ;低8位不為0

MOV R6,#(HIGH (XDATALEN)) +1 ;高8位+1送R6,下面清0用

ELSE

MOV R6,#HIGH (XDATALEN)

ENDIF

CLR A ;清0

XDATALOOP: MOVX @DPTR,A

INC DPTR

DJNZ R7,XDATALOOP

DJNZ R6,XDATALOOP

ENDIF

IF PPAGEENABLE <> 0 ;使能外部頁編址

MOV PPAGE_SFR,#PPAGE ;頁號(hào)送SFR

ENDIF

IF PDATALEN <> 0 ;0-FF之間

MOV R0,#LOW (PDATASTART)

MOV R7,#LOW (PDATALEN)

CLR A

PDATALOOP: MOVX @R0,A ;清0

INC R0

DJNZ R7,PDATALOOP

ENDIF

IF IBPSTACK <> 0 ;使能SMALL模式下的模擬棧

EXTRN DATA (?C_IBP) ;使用其他目標(biāo)模塊中定義的?C_IBP(模擬棧指針)

;(.M51文件中)

MOV ?C_IBP,#LOW IBPSTACKTOP ;模擬棧指針指向棧頂

ENDIF

IF XBPSTACK <> 0 ;Large模式下使能模擬棧

EXTRN DATA (?C_XBP)

;棧指針指向棧頂

MOV ?C_XBP,#HIGH XBPSTACKTOP

MOV ?C_XBP+1,#LOW XBPSTACKTOP

ENDIF

IF PBPSTACK <> 0 ;COMPACT模式下的模擬棧

EXTRN DATA (?C_PBP)

MOV ?C_PBP,#LOW PBPSTACKTOP ;指向棧頂

ENDIF

MOV SP,#?STACK-1 ;硬件棧SP賦值

;硬件棧與模擬棧相區(qū)別,硬件棧是向上的,模擬棧是向下的

;在M51中可以看到具體的?STACK的值

;模擬棧的指針指向所在模式下,存儲(chǔ)區(qū)最大地址+1(0xFF+1或0xFFFF+1)

;硬件棧初始化指向棧底-1;

;因?yàn)镃51中棧操作是先操作棧指針(加或減),然后在寫數(shù)

; This code is required if you use L51_BANK.A51 with Banking Mode 4

; Code Banking

; Select Bank 0 for L51_BANK.A51 Mode 4

#if 0

; Initialize bank mechanism to code bank 0 when using L51_BANK.A51 with Banking Mode 4.

EXTRN CODE (?B_SWITCH0)

CALL ?B_SWITCH0 ; init bank mechanism to code bank 0

#endif

;

LJMP ?C_START ;執(zhí)行main函數(shù)

END

;該文件中的一些符號(hào)的值的大小,可以在M51中看到,此外,可以通過系統(tǒng)上電復(fù)位后反

;匯編程序看到詳細(xì)的執(zhí)行過程

;文件中的一些命令可以查閱KeilC幫助文檔

編輯:admin  最后修改時(shí)間:2019-09-03

聯(lián)系方式

0755-82591179

傳真:0755-82591176

郵箱:vicky@yingtexin.net

地址:深圳市龍華區(qū)民治街道民治大道973萬眾潤豐創(chuàng)業(yè)園A棟2樓A08

Copyright © 2014-2023 穎特新科技有限公司 All Rights Reserved.  粵ICP備14043402號(hào)-4

国产传媒精品视频一区| 久久精品久久久精品久久| 五月婷婷综合缴情六月| 麻豆剧果冻传媒一二三区| 色婷婷国产精品视频一区二区保健 | 黄色片一区二区三区高清| 国产一区二区精品丝袜| 色综合视频一区二区观看| 国产成人精品在线一区二区三区| 免费观看在线午夜视频| 三级理论午夜福利在线看| 日韩精品人妻少妇一区二区| 亚洲视频一区自拍偷拍另类| 美女被啪的视频在线观看| 欧美高潮喷吹一区二区| 成人精品亚洲欧美日韩| 国产日韩欧美专区一区| 亚洲综合色在线视频香蕉视频| 色婷婷丁香激情五月天| 成人午夜在线视频观看| 噜噜中文字幕一区二区| 亚洲精品一区三区三区| 久久国产亚洲精品赲碰热| 黄色国产一区二区三区| 隔壁的日本人妻中文字幕版| 国产内射一级一片内射高清视频| 东京热男人的天堂久久综合| 精品一区二区三区不卡少妇av| 日本一二三区不卡免费| 亚洲第一香蕉视频在线| 国产情侣激情在线对白| 正在播放国产又粗又长| 国产美女精品午夜福利视频| 偷拍偷窥女厕一区二区视频| 日本国产欧美精品视频| 伊人国产精选免费观看在线视频| 国内午夜精品视频在线观看| 欧美日韩中国性生活视频| 高潮少妇高潮久久精品99| 婷婷激情五月天丁香社区| 中文字幕欧美精品人妻一区|