这里代码比较多 我分楼层贴出来 大家看的时候连着看就行
;/*!
; \file startup_gd32e10x.s
; \brief start up file
;
; \version 2017-12-26, V1.0.0, firmware for GD32E10x
;*/
;
;/*
; Copyright (c) 2017, GigaDevice Semiconductor Inc.
;
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without modification,
;are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
; 2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
; 3. Neither the name of the copyright holder nor the names of its contributors
; may be used to endorse or promote products derived from this software without
; specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
;OF SUCH DAMAGE.
;*/
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
; 定义栈的大小
Stack_Size EQU 0x00000400
;定义名字为STACK的独立区域,其实就是栈区,栈区没有初始化,可读可写,并且以2^3=8字节对齐
AREA STACK, NOINIT, READWRITE, ALIGN=3
;申请了Stack_Size的空间,也就是0x400 大概 1024的栈空间。(SPACE申请一片内存空间但是不赋值)
Stack_Mem SPACE Stack_Size
;这里的__initial_sp定了一个标签(label),代码当前指令的地址,后面会用DCD赋值,但是赋值什么呢?
;初始化栈顶指针,指向堆栈顶,因为栈是向下增长的,所以栈顶在最下面,堆是向上增长的,所以这里也是堆顶?
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
;定义堆的大小
Heap_Size EQU 0x00000400
AREA HEAP, NOINIT, READWRITE, ALIGN=3
;定义_heap_base标签,后面会赋值?
__heap_base
Heap_Mem SPACE Heap_Size
;定义__heap_limit标签,后面会赋值?
__heap_limit
;Preserve意思是保留维持,这里的PRESERVE8是字节对齐的关键字,指定当前文件保持堆栈8字节对齐
PRESERVE8
; 告诉编译器使用THUMB指令集,THUMB 必须位于使用新语法的任何Thumb代码之前
THUMB
; /* reset Vector Mapped to at Address 0 */
;复位段,只包含数据,只读,没搞明白这个东西,这个确实是复位段,但是复位段有什么作用,还是只是起了名字而已
AREA RESET, DATA, READONLY
; EXPORT 命令声明一个符号,可由链接器用于解释各个目标和库文件中的符号引用,相当于声明了一个全局变量。 GLOBAL 于 EXPORT相同
;为什么引号EXPORT __Vectors ???
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
|