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.