blob: bc47dbbebd1e16dca4a82c1c4d460d9f2f54d9a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/* Default sections */
int a; /* small data */
const double b = 2.718; /* ro small data */
int c[4]; /* large data */
const char d[12]; /* ro large data */
double g(void) { return a + b; }
/* Custom sections */
#pragma section MYCODE ".mycode" ".mycode" standard RX
#pragma section MYDATA ".mydata_i" ".mydata_u" far-absolute RW
#pragma section MYCONST ".myconst" ".myconst" far-absolute R
#pragma section MYSDA ".mysda_i" ".mysda_u" near-data RW
#pragma use_section MYDATA x, y
int x;
double y = 3.14;
#pragma use_section MYCONST z
char z[4] = { 'a', 'b', 'c', 'd' };
#pragma use_section MYSDA u
int u;
#pragma use_section MYCODE f
int f(int n)
{
x += n;
u -= n;
return z[n];
}
/* Redefining some standard sections */
#pragma section SCONST ".myconst" ".myconst" far-absolute R
#pragma section CONST ".myconst" ".myconst" far-absolute R
#pragma section DATA ".mysda_i" ".mysda_u" near-data RW
#pragma section CODE ".mycode" ".mycode" standard RX
const double v = 1.414;
int w[10];
const char t[5][5] = { 1, 2, 3 };
double h(int n)
{
w[0] --;
w[n] ++;
return v;
}
|