Andes Workshop
http://forum.andestech.com/

_SDA_BASE_相關問題
http://forum.andestech.com/viewtopic.php?f=16&t=166
Page 1 of 1

Author:  cindy [ Mon Oct 03, 2011 5:48 pm ]
Post subject:  _SDA_BASE_相關問題

_SDA_BASE_

(1) 它是由linker自動產生的。
(2) 它只是一個constant pointer,不佔空間,也不一定在data區裡。
取值是使用_SDA_BASE_加一個offset,可以減少取global data的指令數。
(3) 如果user希望這個值固定,linker script裡可以指定它的值。
語法:PROVIDE (_SDA_BASE_= 0x1000);
0x1000是想要的位址。
下面是example:
Attachment:
Hello.rar [31.44 KiB]
Downloaded 1326 times

如圖,可以看到_SDA_BASE_如linker script裡設定的位址。
Attachment:
sda.gif
sda.gif [ 6.7 KiB | Viewed 17792 times ]

Author:  Hubert Chung [ Fri Nov 17, 2017 12:55 pm ]
Post subject:  Re: _SDA_BASE_相關問題

The value of _SDA_BASE_ can be change in the sag file via "var" like following
Quote:
VAR _ILM_BASE = 0x00600000 ; ILM base address
VAR _DLM_BASE = 0x00700000 ; DLM base address
VAR _ILM_SIZE = 0x00010000 ; 64Kb
VAR _DLM_SIZE = 0x00010000 ; 64Kb
VAR _SDA_BASE_ = 0x4000

This only change the value of _SDA_BASE_, the .data section still at the same location. Therefore, the offsets get larger comparing to pointing to the middle of the global variables.
Here is my experiment.
---------------------------
The experiment using demo-printf. Add three global variables int a=1, b=2, c=3. Print them.
---------------------------
    Using default _SDA_BASE_:
You can see the .data section is still located at 0x15c0
Quote:
3 .rodata 0000037c 0000122c 0000122c 0000222c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .data 00000018 000015c0 000015c0 000025c0 2**2
CONTENTS, ALLOC, LOAD, DATA
5 .bss 00000010 000015d8 000015d8 000025d8 2**2
ALLOC


The _SDA_BASE_ is assigned with 000015d0
Quote:
00000220 g F .text 00000038 _start
000015d0 w .data 00000000 _SDA_BASE_
00000262 g F .text 00000002 __null_function


The disassembly codes are
Quote:
printf("a=%d\n\r", a);
348: 3c 1d ff fe lwi.gp $r1,[+#-8]
34c: 44 00 12 fc movi $r0,#0x12fc
350: f8 0a ifcall9 364 <main+0x36>
printf("b=%d\n\r", b);
352: 3c 1d ff fd lwi.gp $r1,[+#-12]
356: 44 00 13 04 movi $r0,#0x1304
35a: f8 05 ifcall9 364 <main+0x36>
printf("c=%d\n\r", c);
35c: 3c 1d ff fc lwi.gp $r1,[+#-16]
360: 44 00 13 0c movi $r0,#0x130c
364: 49 00 00 52 jal 408 <printf>

The offsets are small.
---------------------------
    Use var _SDA_BASE=0x4000:
You can see the .data section is still located at 0x15c0
Quote:
3 .rodata 0000037c 0000122c 0000122c 0000222c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .data 00000018 000015c0 000015c0 000025c0 2**2
CONTENTS, ALLOC, LOAD, DATA
5 .bss 00000010 000015d8 000015d8 000025d8 2**2
ALLOC

The _SDA_BASE_ is at 0x4000
Quote:
00000220 g F .text 00000038 _start
00004000 g *ABS* 00000000 _SDA_BASE_
00000262 g F .text 00000002 __null_function


The disassembly codes are
Quote:
printf("a=%d\n\r", a);
348: 3c 1d f5 72 lwi.gp $r1,[+#-10808]
34c: 44 00 12 fc movi $r0,#0x12fc
350: f8 0a ifcall9 364 <main+0x36>
printf("b=%d\n\r", b);
352: 3c 1d f5 71 lwi.gp $r1,[+#-10812]
356: 44 00 13 04 movi $r0,#0x1304
35a: f8 05 ifcall9 364 <main+0x36>
printf("c=%d\n\r", c);
35c: 3c 1d f5 70 lwi.gp $r1,[+#-10816]
360: 44 00 13 0c movi $r0,#0x130c
364: 49 00 00 52 jal 408 <printf>


The experiment case is the data section is small. Changing _SDA_BASE_ only increases the complexity of offset and gets nothing improved.
But if the variable section (more than 512k) is large, moving the _SDA_BASE_ to the most frequently used data will increase the efficiency of the code in run time. Because it replaces 2 instructions into 1 instruction via gp.

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/