Reshaped doc's
[fw/sdcc] / doc / sdccman.html / node23.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
3 <!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
4 original version by:  Nikos Drakos, CBLU, University of Leeds
5 * revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
6 * with significant contributions from:
7   Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8 <HTML>
9 <HEAD>
10 <TITLE>3.4 Pointers</TITLE>
11 <META NAME="description" CONTENT="3.4 Pointers">
12 <META NAME="keywords" CONTENT="sdccman">
13 <META NAME="resource-type" CONTENT="document">
14 <META NAME="distribution" CONTENT="global">
15
16 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
17 <META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
18 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
19
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
21
22 <LINK REL="next" HREF="node24.html">
23 <LINK REL="previous" HREF="node22.html">
24 <LINK REL="up" HREF="node19.html">
25 <LINK REL="next" HREF="node24.html">
26 </HEAD>
27
28 <BODY >
29 <!--Navigation Panel-->
30 <A NAME="tex2html598"
31  HREF="node24.html">
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
33 <A NAME="tex2html592"
34  HREF="node19.html">
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
36 <A NAME="tex2html586"
37  HREF="node22.html">
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
39 <A NAME="tex2html594"
40  HREF="node1.html">
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
42 <A NAME="tex2html596"
43  HREF="node61.html">
44 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
45 <BR>
46 <B> Next:</B> <A NAME="tex2html599"
47  HREF="node24.html">3.5 Parameters &amp; Local</A>
48 <B> Up:</B> <A NAME="tex2html593"
49  HREF="node19.html">3. Using SDCC</A>
50 <B> Previous:</B> <A NAME="tex2html587"
51  HREF="node22.html">3.3 MCS51/DS390 Storage Class</A>
52  &nbsp <B>  <A NAME="tex2html595"
53  HREF="node1.html">Contents</A></B> 
54  &nbsp <B>  <A NAME="tex2html597"
55  HREF="node61.html">Index</A></B> 
56 <BR>
57 <BR>
58 <!--End of Navigation Panel-->
59
60 <H2><A NAME="SECTION00044000000000000000">
61 3.4 Pointers</A>
62 </H2>
63
64 <P>
65 SDCC allows (via language extensions) pointers to explicitly point
66 to any of the memory spaces of the 8051. In addition to the explicit
67 pointers, the compiler also allows a <I>_generic</I> class of pointers
68 which can be used to point to any of the memory spaces.
69 <BR>
70
71 <BR>
72 Pointer declaration examples:
73 <BR>
74
75 <BR>
76 <TT>/* pointer physically in xternal ram pointing to object
77 in internal ram */ </TT>&nbsp;
78 <BR>
79 <TT>data unsigned char * xdata p;</TT>&nbsp;
80 <BR>&nbsp;
81 <BR>
82 <TT>/* pointer physically in code rom pointing to data in xdata
83 space */ </TT>&nbsp;
84 <BR>
85 <TT>xdata unsigned char * code p;</TT>&nbsp;
86 <BR>&nbsp;
87 <BR>
88 <TT>/* pointer physically in code space pointing to data in
89 code space */ </TT>&nbsp;
90 <BR>
91 <TT>code unsigned char * code p;</TT>&nbsp;
92 <BR>&nbsp;
93 <BR>
94 <TT>/* the folowing is a generic pointer physically located
95 in xdata space */</TT>&nbsp;
96 <BR>
97 <TT>char * xdata p;</TT>
98 <BR>
99
100 <BR>
101 Well you get the idea. 
102 <BR>
103
104 <BR>
105 <I>For compatibility with the previous version of the compiler,
106 the following syntax for pointer declaration is still supported but
107 will disappear int the near future. </I>
108 <BR>
109 <BR>
110 <TT><I>unsigned char _xdata *ucxdp; /* pointer to data
111 in external ram */ </I></TT>&nbsp;
112 <BR>
113 <TT><I>unsigned char _data &nbsp;*ucdp ; /* pointer to data
114 in internal ram */ </I></TT>&nbsp;
115 <BR>
116 <TT><I>unsigned char _code &nbsp;*uccp ; /* pointer to data
117 in R/O code space */</I></TT>&nbsp;
118 <BR>
119 <TT><I>unsigned char _idata *uccp; &nbsp;/* pointer to upper
120 128 bytes of ram */</I></TT>
121 <BR>
122
123 <BR>
124 All unqualified pointers are treated as 3-byte (4-byte for the ds390)
125 <I>generic</I> pointers. These type of pointers can also to be explicitly
126 declared.
127 <BR>
128
129 <BR>
130 <TT>unsigned char _generic *ucgp;</TT>
131 <BR>
132
133 <BR>
134 The highest order byte of the <I>generic</I> pointers contains the
135 data space information. Assembler support routines are called whenever
136 data is stored or retrieved using <I>generic</I> pointers. These are
137 useful for developing reusable library routines. Explicitly specifying
138 the pointer type will generate the most efficient code. Pointers declared
139 using a mixture of OLD and NEW style could have unpredictable results.
140
141 <P>
142 <HR>
143 <!--Navigation Panel-->
144 <A NAME="tex2html598"
145  HREF="node24.html">
146 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
147 <A NAME="tex2html592"
148  HREF="node19.html">
149 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
150 <A NAME="tex2html586"
151  HREF="node22.html">
152 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
153 <A NAME="tex2html594"
154  HREF="node1.html">
155 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
156 <A NAME="tex2html596"
157  HREF="node61.html">
158 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
159 <BR>
160 <B> Next:</B> <A NAME="tex2html599"
161  HREF="node24.html">3.5 Parameters &amp; Local</A>
162 <B> Up:</B> <A NAME="tex2html593"
163  HREF="node19.html">3. Using SDCC</A>
164 <B> Previous:</B> <A NAME="tex2html587"
165  HREF="node22.html">3.3 MCS51/DS390 Storage Class</A>
166  &nbsp <B>  <A NAME="tex2html595"
167  HREF="node1.html">Contents</A></B> 
168  &nbsp <B>  <A NAME="tex2html597"
169  HREF="node61.html">Index</A></B> 
170 <!--End of Navigation Panel-->
171 <ADDRESS>
172 <I>Johan Knol</I>
173 <BR><I>2001-07-13</I>
174 </ADDRESS>
175 </BODY>
176 </HTML>