1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
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 -->
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">
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">
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
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">
29 <!--Navigation Panel-->
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
44 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
46 <B> Next:</B> <A NAME="tex2html599"
47 HREF="node24.html">3.5 Parameters & 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   <B> <A NAME="tex2html595"
53 HREF="node1.html">Contents</A></B>
54   <B> <A NAME="tex2html597"
55 HREF="node61.html">Index</A></B>
58 <!--End of Navigation Panel-->
60 <H2><A NAME="SECTION00044000000000000000">
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.
72 Pointer declaration examples:
76 <TT>/* pointer physically in xternal ram pointing to object
77 in internal ram */ </TT>
79 <TT>data unsigned char * xdata p;</TT>
82 <TT>/* pointer physically in code rom pointing to data in xdata
85 <TT>xdata unsigned char * code p;</TT>
88 <TT>/* pointer physically in code space pointing to data in
89 code space */ </TT>
91 <TT>code unsigned char * code p;</TT>
94 <TT>/* the folowing is a generic pointer physically located
95 in xdata space */</TT>
97 <TT>char * xdata p;</TT>
101 Well you get the idea.
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>
110 <TT><I>unsigned char _xdata *ucxdp; /* pointer to data
111 in external ram */ </I></TT>
113 <TT><I>unsigned char _data *ucdp ; /* pointer to data
114 in internal ram */ </I></TT>
116 <TT><I>unsigned char _code *uccp ; /* pointer to data
117 in R/O code space */</I></TT>
119 <TT><I>unsigned char _idata *uccp; /* pointer to upper
120 128 bytes of ram */</I></TT>
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
130 <TT>unsigned char _generic *ucgp;</TT>
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.
143 <!--Navigation Panel-->
144 <A NAME="tex2html598"
146 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
147 <A NAME="tex2html592"
149 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
150 <A NAME="tex2html586"
152 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
153 <A NAME="tex2html594"
155 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
156 <A NAME="tex2html596"
158 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
160 <B> Next:</B> <A NAME="tex2html599"
161 HREF="node24.html">3.5 Parameters & 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   <B> <A NAME="tex2html595"
167 HREF="node1.html">Contents</A></B>
168   <B> <A NAME="tex2html597"
169 HREF="node61.html">Index</A></B>
170 <!--End of Navigation Panel-->
173 <BR><I>2001-07-13</I>