memory #- generated by the linker
……………… #- 接下来的表由连接器自动产生
……………… #- RO: Read-only = the code
……………… #- RO:只读属性=代码
__user_initial_stackheap #- RW: Read Write = the data
LDR r0,=bottom_of_heap #- pre-initialized and zero-initialized
; LDR r1,=StackUsr #- RW:读写属性=预先初始化的和
LDR r2,=top_of_heap #- 用0初始化的
LDR r3,=bottom_of_Stacks #- ZI: Zero-Initialized.
MOV pc,lr #- ZI:用0初始化的为初始化的变量
……………… #- Pre-initialization values are located.
AREA Heap, DATA, NOINIT #- after the code area in the image
bottom_of_heap SPACE 1 #- 预先初始化的变量定位在代码之后
AREA StackBottom, DATA, NOINIT #- Zero-initialized datas are mapped
bottom_of_Stacks SPACE 1 #- after the pre-initialized.
AREA HeapTop, DATA, NOINIT #- 清零的变量映射在预先初始化的变
top_of_heap #- 量之后
AREA Stacks, DATA, NOINIT #- Note on the Data position :
StackUsr #-注意数据区位置
……………………… #- If using the ARMSDT, when no
; scatter file部分 #- -rw-base option is used for the linker, the
ROM_LOAD 0x80000000 #- data area is mapped after the code. You
{ #- can map the data either in internal SRAM
ROM_EXEC 0x80000000 #- ( -rw-base=0x40 or 0x34) or in external
{ #- SRAM ( -rw-base=0x2000000 ).
Startup.o (vectors, +First) #- 如果使用ARMSDRT,当链接选项采
* (+RO) #- 用no -rw-base option选项数据区映射
} #- 在代码区之后,有可以映射数据区无
IRAM 0x40000000 #- 论在内部SRAM( -rw-base=0x40 or
{ #- 0x34)或外部SRAM
Startup.o (MyStacks) #- ( -rw-base=0x2000000 )
} #- Note also that to improve the code
STACKS_BOTTOM +0 UNINIT #- density, the pre_initialized data must
{ #- be limited to a minimum.
Startup.o (StackBottom) #- 也应该注意 为了改善代码密度,预先
} #- 初始化的变量必须尽可能的少
STACKS 0x40004000 UNINIT IMPORT |Image$$RW$$Base|
{ ;Base of RAM to initialise
Startup.o (Stacks) IMPORT |Image$$ZI$$Base|
} ; Base and limit of area
ERAM 0x80040000 IMPORT |Image$$ZI$$Limit|
{ ; to zero initialise
* (+RW,+ZI) ldr r0, =|Image$$RO$$Limit|
} ; Get pointer to ROM data
HEAP +0 UNINIT ldr r1, =|Image$$RW$$Base|
{ ; and RAM copy
Startup.o (Heap) ldr r3, =|Image$$ZI$$Base|
} ; Zero init base => top of initialised data
HEAP_BOTTOM 0x80080000 UNINIT cmp r0, r1
{ ; Check that they are different
Startup.o (HeapTop) beq NoRW
} LoopRw cmp r1, r3
} ; Copy init data
ldrcc r2, [r0], #4
strcc r2, [r1], #4
bcc LoopRw
NoRW ldr r1, =|Image$$ZI$$Limit|
; Top of zero init segment
mov r2, #0
LoopZI cmp r3, r1
; Zero init
strcc r2, [r3], #4
bcc LoopZI
关于lpc的__user_initial_stackheap 参见7月7日学习笔记4(c启动代码总结之对周启动代码的部分解释),对于选择不同的C变量(库)初始化,关键在于前者选用了ADS并且使用了scatter file分散加载机制,而后者使用了SDT并且采用链接选项而不是分散加载,对于教复杂的开发来说还是选用前者方式比较合适