本帖最后由 tiger84 于 2010-3-24 20:52 编辑
我用的是TI的5402在做试验,MP/MC = 0,OVLY=1.
碰到如下2个CMD问题,总是找不到答案,还盼兄弟们能解惑。
1,.cinit 按照TI的说明书上说的,它是“表显示初始化全局和静态变量”,存储类型是ROM和RAM均可,最好放在PAGE0。
当CMD如下时
MEMORY {
PAGE 0:
RESEVE: org 00h len = 0x80
PAGE 0:
PROG1: org = 0x0100 len = 0x1200
PAGE 0:
/* VECT段的值不能改 */
VECT: org = 0x0080, len = 0x80
PAGE 1:
RESEVE1: org 00h len = 0x1300
PAGE 1:
DARAM2: org = 0x1300 len = 0x200
PAGE 1:
DARAM1: org = 0x1500 len = 0x2b00
}
SECTIONS{
.text : > PROG1 PAGE 0
.cinit : > PROG1 PAGE 0
.switch: > PROG1 PAGE 0
.vectors:> VECT PAGE 0
.const: > DARAM1 PAGE 1
.bss : > DARAM1 PAGE 1
.stack : > DARAM2 PAGE 1
.system: > DARAM2 PAGE 1
.data : > DARAM2 PAGE 1
}
生成的MAP文件如下:
MEMORY CONFIGURATION
name origin length used attr fill
---------------------- -------- --------- -------- ---- --------
PAGE 0: RESEVE 00000000 00000080 00000000 RWIX
VECT 00000080 00000080 00000080 RWIX
PROG1 00000100 00001200 00000213 RWIX
PAGE 1: RESEVE1 00000000 00001300 00000000 RWIX
DARAM2 00001300 00000200 00000200 RWIX
DARAM1 00001500 00002b00 00000027 RWIX
SECTION ALLOCATION MAP
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.vectors 0 00000080 00000080
00000080 00000080 CVECTORS.obj (.vectors)
.switch 0 00000100 00000000 UNINITIALIZED
.text 0 00000100 00000203
00000100 0000004a rts.lib : boot.obj (.text)
0000014a 00000052 : exit.obj (.text)
0000019c 00000007 : _lock.obj (.text)
000001a3 00000129 main.obj (.text)
000002cc 00000037 rts.lib : idiv.obj (.text)
.cinit 0 00000303 00000010
00000303 00000009 rts.lib : exit.obj (.cinit)
0000030c 00000006 : _lock.obj (.cinit)
00000312 00000001 --HOLE-- [fill = 0]
.data 1 00001300 00000000 UNINITIALIZED
.system 1 00001300 00000000 UNINITIALIZED
.stack 1 00001300 00000200 UNINITIALIZED
.const 1 00001500 00000000 UNINITIALIZED
.bss 1 00001500 00000027 UNINITIALIZED
00001500 00000023 rts.lib : exit.obj (.bss)
00001523 00000002 : _lock.obj (.bss)
00001525 00000002 main.obj (.bss)
这个比较好理解,我也基本上没有疑问。
为了更好理解CMD,通过MAP文件,发现PAGE0里面的PROG1只有0x213个字节,而在5402的程序空间从0x0080到0x3fff是DARAM(MP/MC=0,OVLY=1),在只有我把PAGE0里面的PROG1改成如下:(0x3fff - 0x213 + 1 = 0x3ded)
PROG1: org = 0x3ded len = 0x1200
生成的MAP
MEMORY CONFIGURATION
name origin length used attr fill
---------------------- -------- --------- -------- ---- --------
PAGE 0: RESEVE 00000000 00000080 00000000 RWIX
VECT 00000080 00000080 00000080 RWIX
PROG1 00003ded 00001200 00000213 RWIX
PAGE 1: RESEVE1 00000000 00001300 00000000 RWIX
DARAM2 00001300 00000200 00000200 RWIX
DARAM1 00001500 00002b00 00000027 RWIX
SECTION ALLOCATION MAP
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.vectors 0 00000080 00000080
00000080 00000080 CVECTORS.obj (.vectors)
.switch 0 00003ded 00000000 UNINITIALIZED
.text 0 00003ded 00000203
00003ded 0000004a rts.lib : boot.obj (.text)
00003e37 00000052 : exit.obj (.text)
00003e89 00000007 : _lock.obj (.text)
00003e90 00000129 main.obj (.text)
00003fb9 00000037 rts.lib : idiv.obj (.text)
.cinit 0 00003ff0 00000010
00003ff0 00000009 rts.lib : exit.obj (.cinit)
00003ff9 00000006 : _lock.obj (.cinit)
00003fff 00000001 --HOLE-- [fill = 0]
.data 1 00001300 00000000 UNINITIALIZED
.system 1 00001300 00000000 UNINITIALIZED
.stack 1 00001300 00000200 UNINITIALIZED
.const 1 00001500 00000000 UNINITIALIZED
.bss 1 00001500 00000027 UNINITIALIZED
00001500 00000023 rts.lib : exit.obj (.bss)
00001523 00000002 : _lock.obj (.bss)
00001525 00000002 main.obj (.bss)
这样也挺好理解的。
抱着随便试一试的心理,
我又改了下
PROG1: org = 0x3dee len = 0x1200
理论上来说,应该会出现问题。
没想到,我一编译,没问题,load ,运行,竟然也可以,看下MAP文件
MEMORY CONFIGURATION
name origin length used attr fill
---------------------- -------- --------- -------- ---- --------
PAGE 0: RESEVE 00000000 00000080 00000000 RWIX
VECT 00000080 00000080 00000080 RWIX
PROG1 00003dee 00001200 00000213 RWIX
PAGE 1: RESEVE1 00000000 00001300 00000000 RWIX
DARAM2 00001300 00000200 00000200 RWIX
DARAM1 00001500 00002b00 00000027 RWIX
SECTION ALLOCATION MAP
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.vectors 0 00000080 00000080
00000080 00000080 CVECTORS.obj (.vectors)
.switch 0 00003dee 00000000 UNINITIALIZED
.text 0 00003dee 00000203
00003dee 0000004a rts.lib : boot.obj (.text)
00003e38 00000052 : exit.obj (.text)
00003e8a 00000007 : _lock.obj (.text)
00003e91 00000129 main.obj (.text)
00003fba 00000037 rts.lib : idiv.obj (.text)
.cinit 0 00003ff1 00000010
00003ff1 00000009 rts.lib : exit.obj (.cinit)
00003ffa 00000006 : _lock.obj (.cinit)
00004000 00000001 --HOLE-- [fill = 0]
.data 1 00001300 00000000 UNINITIALIZED
.system 1 00001300 00000000 UNINITIALIZED
.stack 1 00001300 00000200 UNINITIALIZED
.const 1 00001500 00000000 UNINITIALIZED
.bss 1 00001500 00000027 UNINITIALIZED
00001500 00000023 rts.lib : exit.obj (.bss)
00001523 00000002 : _lock.obj (.bss)
00001525 00000002 main.obj (.bss)
看下这几句
.cinit 0 00003ff1 00000010
00003ff1 00000009 rts.lib : exit.obj (.cinit)
00003ffa 00000006 : _lock.obj (.cinit)
00004000 00000001 --HOLE-- [fill = 0]
空间已经超过了0x3fff。
我的疑问就是在这里了,.cinit到底占用了哪里? |