1 | <HTML>
|
---|
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
---|
3 | <!-- Created on December, 17 2017 by texi2html 1.64 -->
|
---|
4 | <!--
|
---|
5 | Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
|
---|
6 | Karl Berry <karl@freefriends.org>
|
---|
7 | Olaf Bachmann <obachman@mathematik.uni-kl.de>
|
---|
8 | and many others.
|
---|
9 | Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
|
---|
10 | Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
|
---|
11 |
|
---|
12 | -->
|
---|
13 | <HEAD>
|
---|
14 | <TITLE>Tiny C Compiler Reference Documentation: </TITLE>
|
---|
15 |
|
---|
16 | <META NAME="description" CONTENT="Tiny C Compiler Reference Documentation: ">
|
---|
17 | <META NAME="keywords" CONTENT="Tiny C Compiler Reference Documentation: ">
|
---|
18 | <META NAME="resource-type" CONTENT="document">
|
---|
19 | <META NAME="distribution" CONTENT="global">
|
---|
20 | <META NAME="Generator" CONTENT="texi2html 1.64">
|
---|
21 |
|
---|
22 | </HEAD>
|
---|
23 |
|
---|
24 | <BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
|
---|
25 |
|
---|
26 | <A NAME="SEC_Top"></A>
|
---|
27 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
28 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
29 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
30 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
31 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
32 | </TR></TABLE>
|
---|
33 | <H1>Tiny C Compiler Reference Documentation</H1></P><P>
|
---|
34 |
|
---|
35 | This manual documents version 0.9.27
|
---|
36 | of the Tiny C Compiler.
|
---|
37 | </P><P>
|
---|
38 |
|
---|
39 | <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
|
---|
40 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC1">1. Introduction</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Introduction to tcc.</TD></TR>
|
---|
41 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC2">2. Command line invocation</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Invocation of tcc (command line, options).</TD></TR>
|
---|
42 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC5">3. C language support</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">ANSI C and extensions.</TD></TR>
|
---|
43 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Assembler syntax.</TD></TR>
|
---|
44 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Output file generation and supported targets.</TD></TR>
|
---|
45 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Automatic bounds-checking of C code.</TD></TR>
|
---|
46 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">The libtcc library.</TD></TR>
|
---|
47 | <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC23">8. Developer's guide</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Guide for Developers.</TD></TR>
|
---|
48 | </TABLE></BLOCKQUOTE>
|
---|
49 | <P>
|
---|
50 |
|
---|
51 | <HR SIZE=1>
|
---|
52 | <A NAME="SEC1"></A>
|
---|
53 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
54 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> < </A>]</TD>
|
---|
55 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> > </A>]</TD>
|
---|
56 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD>
|
---|
57 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
58 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> >> </A>]</TD>
|
---|
59 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
60 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
61 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
62 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
63 | </TR></TABLE>
|
---|
64 | <A NAME="Introduction"></A>
|
---|
65 | <H1> 1. Introduction </H1>
|
---|
66 | <!--docid::SEC1::-->
|
---|
67 | <P>
|
---|
68 |
|
---|
69 | TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
|
---|
70 | compilers, it is meant to be self-relying: you do not need an
|
---|
71 | external assembler or linker because TCC does that for you.
|
---|
72 | </P><P>
|
---|
73 |
|
---|
74 | TCC compiles so <EM>fast</EM> that even for big projects <CODE>Makefile</CODE>s may
|
---|
75 | not be necessary.
|
---|
76 | </P><P>
|
---|
77 |
|
---|
78 | TCC not only supports ANSI C, but also most of the new ISO C99
|
---|
79 | standard and many GNUC extensions including inline assembly.
|
---|
80 | </P><P>
|
---|
81 |
|
---|
82 | TCC can also be used to make <EM>C scripts</EM>, i.e. pieces of C source
|
---|
83 | that you run as a Perl or Python script. Compilation is so fast that
|
---|
84 | your script will be as fast as if it was an executable.
|
---|
85 | </P><P>
|
---|
86 |
|
---|
87 | TCC can also automatically generate memory and bound checks
|
---|
88 | (see section <A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>) while allowing all C pointers operations. TCC can do
|
---|
89 | these checks even if non patched libraries are used.
|
---|
90 | </P><P>
|
---|
91 |
|
---|
92 | With <CODE>libtcc</CODE>, you can use TCC as a backend for dynamic code
|
---|
93 | generation (see section <A HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>).
|
---|
94 | </P><P>
|
---|
95 |
|
---|
96 | TCC mainly supports the i386 target on Linux and Windows. There are alpha
|
---|
97 | ports for the ARM (<CODE>arm-tcc</CODE>) and the TMS320C67xx targets
|
---|
98 | (<CODE>c67-tcc</CODE>). More information about the ARM port is available at
|
---|
99 | <A HREF="http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html">http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html</A>.
|
---|
100 | </P><P>
|
---|
101 |
|
---|
102 | For usage on Windows, see also <A HREF="tcc-win32.txt">tcc-win32.txt</A>.
|
---|
103 | </P><P>
|
---|
104 |
|
---|
105 | <A NAME="Invoke"></A>
|
---|
106 | <HR SIZE="6">
|
---|
107 | <A NAME="SEC2"></A>
|
---|
108 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
109 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> < </A>]</TD>
|
---|
110 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC3"> > </A>]</TD>
|
---|
111 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> << </A>]</TD>
|
---|
112 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
113 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> >> </A>]</TD>
|
---|
114 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
115 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
116 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
117 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
118 | </TR></TABLE>
|
---|
119 | <H1> 2. Command line invocation </H1>
|
---|
120 | <!--docid::SEC2::-->
|
---|
121 | <P>
|
---|
122 |
|
---|
123 | <HR SIZE="6">
|
---|
124 | <A NAME="SEC3"></A>
|
---|
125 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
126 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> < </A>]</TD>
|
---|
127 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC4"> > </A>]</TD>
|
---|
128 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> << </A>]</TD>
|
---|
129 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> Up </A>]</TD>
|
---|
130 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> >> </A>]</TD>
|
---|
131 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
132 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
133 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
134 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
135 | </TR></TABLE>
|
---|
136 | <H2> 2.1 Quick start </H2>
|
---|
137 | <!--docid::SEC3::-->
|
---|
138 | <P>
|
---|
139 |
|
---|
140 | <TABLE><tr><td> </td><td class=example><pre>usage: tcc [options] [<VAR>infile1</VAR> <VAR>infile2</VAR><small>...</small>] [<SAMP>`-run'</SAMP> <VAR>infile</VAR> <VAR>args</VAR><small>...</small>]
|
---|
141 | </pre></td></tr></table></P><P>
|
---|
142 |
|
---|
143 | TCC options are a very much like gcc options. The main difference is that TCC
|
---|
144 | can also execute directly the resulting program and give it runtime
|
---|
145 | arguments.
|
---|
146 | </P><P>
|
---|
147 |
|
---|
148 | Here are some examples to understand the logic:
|
---|
149 | </P><P>
|
---|
150 |
|
---|
151 | <DL COMPACT>
|
---|
152 | <DT><CODE><SAMP>`tcc -run a.c'</SAMP></CODE>
|
---|
153 | <DD>Compile <TT>`a.c'</TT> and execute it directly
|
---|
154 | <P>
|
---|
155 |
|
---|
156 | <DT><CODE><SAMP>`tcc -run a.c arg1'</SAMP></CODE>
|
---|
157 | <DD>Compile a.c and execute it directly. arg1 is given as first argument to
|
---|
158 | the <CODE>main()</CODE> of a.c.
|
---|
159 | <P>
|
---|
160 |
|
---|
161 | <DT><CODE><SAMP>`tcc a.c -run b.c arg1'</SAMP></CODE>
|
---|
162 | <DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them together and execute them. arg1 is given
|
---|
163 | as first argument to the <CODE>main()</CODE> of the resulting program.
|
---|
164 | <P>
|
---|
165 |
|
---|
166 | <DT><CODE><SAMP>`tcc -o myprog a.c b.c'</SAMP></CODE>
|
---|
167 | <DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them and generate the executable <TT>`myprog'</TT>.
|
---|
168 | <P>
|
---|
169 |
|
---|
170 | <DT><CODE><SAMP>`tcc -o myprog a.o b.o'</SAMP></CODE>
|
---|
171 | <DD>link <TT>`a.o'</TT> and <TT>`b.o'</TT> together and generate the executable <TT>`myprog'</TT>.
|
---|
172 | <P>
|
---|
173 |
|
---|
174 | <DT><CODE><SAMP>`tcc -c a.c'</SAMP></CODE>
|
---|
175 | <DD>Compile <TT>`a.c'</TT> and generate object file <TT>`a.o'</TT>.
|
---|
176 | <P>
|
---|
177 |
|
---|
178 | <DT><CODE><SAMP>`tcc -c asmfile.S'</SAMP></CODE>
|
---|
179 | <DD>Preprocess with C preprocess and assemble <TT>`asmfile.S'</TT> and generate
|
---|
180 | object file <TT>`asmfile.o'</TT>.
|
---|
181 | <P>
|
---|
182 |
|
---|
183 | <DT><CODE><SAMP>`tcc -c asmfile.s'</SAMP></CODE>
|
---|
184 | <DD>Assemble (but not preprocess) <TT>`asmfile.s'</TT> and generate object file
|
---|
185 | <TT>`asmfile.o'</TT>.
|
---|
186 | <P>
|
---|
187 |
|
---|
188 | <DT><CODE><SAMP>`tcc -r -o ab.o a.c b.c'</SAMP></CODE>
|
---|
189 | <DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them together and generate the object file <TT>`ab.o'</TT>.
|
---|
190 | <P>
|
---|
191 |
|
---|
192 | </DL>
|
---|
193 | <P>
|
---|
194 |
|
---|
195 | Scripting:
|
---|
196 | </P><P>
|
---|
197 |
|
---|
198 | TCC can be invoked from <EM>scripts</EM>, just as shell scripts. You just
|
---|
199 | need to add <CODE>#!/usr/local/bin/tcc -run</CODE> at the start of your C source:
|
---|
200 | </P><P>
|
---|
201 |
|
---|
202 | <TABLE><tr><td> </td><td class=example><pre>#!/usr/local/bin/tcc -run
|
---|
203 | #include <stdio.h>
|
---|
204 |
|
---|
205 | int main()
|
---|
206 | {
|
---|
207 | printf("Hello World\n");
|
---|
208 | return 0;
|
---|
209 | }
|
---|
210 | </pre></td></tr></table></P><P>
|
---|
211 |
|
---|
212 | TCC can read C source code from <EM>standard input</EM> when <SAMP>`-'</SAMP> is used in
|
---|
213 | place of <SAMP>`infile'</SAMP>. Example:
|
---|
214 | </P><P>
|
---|
215 |
|
---|
216 | <TABLE><tr><td> </td><td class=example><pre>echo 'main(){puts("hello");}' | tcc -run -
|
---|
217 | </pre></td></tr></table></P><P>
|
---|
218 |
|
---|
219 | <HR SIZE="6">
|
---|
220 | <A NAME="SEC4"></A>
|
---|
221 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
222 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC3"> < </A>]</TD>
|
---|
223 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> > </A>]</TD>
|
---|
224 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> << </A>]</TD>
|
---|
225 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> Up </A>]</TD>
|
---|
226 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> >> </A>]</TD>
|
---|
227 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
228 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
229 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
230 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
231 | </TR></TABLE>
|
---|
232 | <H2> 2.2 Option summary </H2>
|
---|
233 | <!--docid::SEC4::-->
|
---|
234 | <P>
|
---|
235 |
|
---|
236 | General Options:
|
---|
237 | </P><P>
|
---|
238 |
|
---|
239 | <DL COMPACT>
|
---|
240 | <DT><SAMP>`-c'</SAMP>
|
---|
241 | <DD>Generate an object file.
|
---|
242 | <P>
|
---|
243 |
|
---|
244 | <DT><SAMP>`-o outfile'</SAMP>
|
---|
245 | <DD>Put object file, executable, or dll into output file <TT>`outfile'</TT>.
|
---|
246 | <P>
|
---|
247 |
|
---|
248 | <DT><SAMP>`-run source [args...]'</SAMP>
|
---|
249 | <DD>Compile file <VAR>source</VAR> and run it with the command line arguments
|
---|
250 | <VAR>args</VAR>. In order to be able to give more than one argument to a
|
---|
251 | script, several TCC options can be given <EM>after</EM> the
|
---|
252 | <SAMP>`-run'</SAMP> option, separated by spaces:
|
---|
253 | <TABLE><tr><td> </td><td class=example><pre>tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
|
---|
254 | </pre></td></tr></table>In a script, it gives the following header:
|
---|
255 | <TABLE><tr><td> </td><td class=example><pre>#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
|
---|
256 | </pre></td></tr></table><P>
|
---|
257 |
|
---|
258 | <DT><SAMP>`-v'</SAMP>
|
---|
259 | <DD>Display TCC version.
|
---|
260 | <P>
|
---|
261 |
|
---|
262 | <DT><SAMP>`-vv'</SAMP>
|
---|
263 | <DD>Show included files. As sole argument, print search dirs. -vvv shows tries too.
|
---|
264 | <P>
|
---|
265 |
|
---|
266 | <DT><SAMP>`-bench'</SAMP>
|
---|
267 | <DD>Display compilation statistics.
|
---|
268 | <P>
|
---|
269 |
|
---|
270 | </DL>
|
---|
271 | <P>
|
---|
272 |
|
---|
273 | Preprocessor options:
|
---|
274 | </P><P>
|
---|
275 |
|
---|
276 | <DL COMPACT>
|
---|
277 | <DT><SAMP>`-Idir'</SAMP>
|
---|
278 | <DD>Specify an additional include path. Include paths are searched in the
|
---|
279 | order they are specified.
|
---|
280 | <P>
|
---|
281 |
|
---|
282 | System include paths are always searched after. The default system
|
---|
283 | include paths are: <TT>`/usr/local/include'</TT>, <TT>`/usr/include'</TT>
|
---|
284 | and <TT>`PREFIX/lib/tcc/include'</TT>. (<TT>`PREFIX'</TT> is usually
|
---|
285 | <TT>`/usr'</TT> or <TT>`/usr/local'</TT>).
|
---|
286 | </P><P>
|
---|
287 |
|
---|
288 | <DT><SAMP>`-Dsym[=val]'</SAMP>
|
---|
289 | <DD>Define preprocessor symbol <SAMP>`sym'</SAMP> to
|
---|
290 | val. If val is not present, its value is <SAMP>`1'</SAMP>. Function-like macros can
|
---|
291 | also be defined: <SAMP>`-DF(a)=a+1'</SAMP>
|
---|
292 | <P>
|
---|
293 |
|
---|
294 | <DT><SAMP>`-Usym'</SAMP>
|
---|
295 | <DD>Undefine preprocessor symbol <SAMP>`sym'</SAMP>.
|
---|
296 | <P>
|
---|
297 |
|
---|
298 | <DT><SAMP>`-E'</SAMP>
|
---|
299 | <DD>Preprocess only, to stdout or file (with -o).
|
---|
300 | <P>
|
---|
301 |
|
---|
302 | </DL>
|
---|
303 | <P>
|
---|
304 |
|
---|
305 | Compilation flags:
|
---|
306 | </P><P>
|
---|
307 |
|
---|
308 | Note: each of the following options has a negative form beginning with
|
---|
309 | <SAMP>`-fno-'</SAMP>.
|
---|
310 | </P><P>
|
---|
311 |
|
---|
312 | <DL COMPACT>
|
---|
313 | <DT><SAMP>`-funsigned-char'</SAMP>
|
---|
314 | <DD>Let the <CODE>char</CODE> type be unsigned.
|
---|
315 | <P>
|
---|
316 |
|
---|
317 | <DT><SAMP>`-fsigned-char'</SAMP>
|
---|
318 | <DD>Let the <CODE>char</CODE> type be signed.
|
---|
319 | <P>
|
---|
320 |
|
---|
321 | <DT><SAMP>`-fno-common'</SAMP>
|
---|
322 | <DD>Do not generate common symbols for uninitialized data.
|
---|
323 | <P>
|
---|
324 |
|
---|
325 | <DT><SAMP>`-fleading-underscore'</SAMP>
|
---|
326 | <DD>Add a leading underscore at the beginning of each C symbol.
|
---|
327 | <P>
|
---|
328 |
|
---|
329 | <DT><SAMP>`-fms-extensions'</SAMP>
|
---|
330 | <DD>Allow a MS C compiler extensions to the language. Currently this
|
---|
331 | assumes a nested named structure declaration without an identifier
|
---|
332 | behaves like an unnamed one.
|
---|
333 | <P>
|
---|
334 |
|
---|
335 | <DT><SAMP>`-fdollars-in-identifiers'</SAMP>
|
---|
336 | <DD>Allow dollar signs in identifiers
|
---|
337 | <P>
|
---|
338 |
|
---|
339 | </DL>
|
---|
340 | <P>
|
---|
341 |
|
---|
342 | Warning options:
|
---|
343 | </P><P>
|
---|
344 |
|
---|
345 | <DL COMPACT>
|
---|
346 | <DT><SAMP>`-w'</SAMP>
|
---|
347 | <DD>Disable all warnings.
|
---|
348 | <P>
|
---|
349 |
|
---|
350 | </DL>
|
---|
351 | <P>
|
---|
352 |
|
---|
353 | Note: each of the following warning options has a negative form beginning with
|
---|
354 | <SAMP>`-Wno-'</SAMP>.
|
---|
355 | </P><P>
|
---|
356 |
|
---|
357 | <DL COMPACT>
|
---|
358 | <DT><SAMP>`-Wimplicit-function-declaration'</SAMP>
|
---|
359 | <DD>Warn about implicit function declaration.
|
---|
360 | <P>
|
---|
361 |
|
---|
362 | <DT><SAMP>`-Wunsupported'</SAMP>
|
---|
363 | <DD>Warn about unsupported GCC features that are ignored by TCC.
|
---|
364 | <P>
|
---|
365 |
|
---|
366 | <DT><SAMP>`-Wwrite-strings'</SAMP>
|
---|
367 | <DD>Make string constants be of type <CODE>const char *</CODE> instead of <CODE>char
|
---|
368 | *</CODE>.
|
---|
369 | <P>
|
---|
370 |
|
---|
371 | <DT><SAMP>`-Werror'</SAMP>
|
---|
372 | <DD>Abort compilation if warnings are issued.
|
---|
373 | <P>
|
---|
374 |
|
---|
375 | <DT><SAMP>`-Wall'</SAMP>
|
---|
376 | <DD>Activate all warnings, except <SAMP>`-Werror'</SAMP>, <SAMP>`-Wunusupported'</SAMP> and
|
---|
377 | <SAMP>`-Wwrite-strings'</SAMP>.
|
---|
378 | <P>
|
---|
379 |
|
---|
380 | </DL>
|
---|
381 | <P>
|
---|
382 |
|
---|
383 | Linker options:
|
---|
384 | </P><P>
|
---|
385 |
|
---|
386 | <DL COMPACT>
|
---|
387 | <DT><SAMP>`-Ldir'</SAMP>
|
---|
388 | <DD>Specify an additional static library path for the <SAMP>`-l'</SAMP> option. The
|
---|
389 | default library paths are <TT>`/usr/local/lib'</TT>, <TT>`/usr/lib'</TT> and <TT>`/lib'</TT>.
|
---|
390 | <P>
|
---|
391 |
|
---|
392 | <DT><SAMP>`-lxxx'</SAMP>
|
---|
393 | <DD>Link your program with dynamic library libxxx.so or static library
|
---|
394 | libxxx.a. The library is searched in the paths specified by the
|
---|
395 | <SAMP>`-L'</SAMP> option and <CODE>LIBRARY_PATH</CODE> variable.
|
---|
396 | <P>
|
---|
397 |
|
---|
398 | <DT><SAMP>`-Bdir'</SAMP>
|
---|
399 | <DD>Set the path where the tcc internal libraries (and include files) can be
|
---|
400 | found (default is <TT>`PREFIX/lib/tcc'</TT>).
|
---|
401 | <P>
|
---|
402 |
|
---|
403 | <DT><SAMP>`-shared'</SAMP>
|
---|
404 | <DD>Generate a shared library instead of an executable.
|
---|
405 | <P>
|
---|
406 |
|
---|
407 | <DT><SAMP>`-soname name'</SAMP>
|
---|
408 | <DD>set name for shared library to be used at runtime
|
---|
409 | <P>
|
---|
410 |
|
---|
411 | <DT><SAMP>`-static'</SAMP>
|
---|
412 | <DD>Generate a statically linked executable (default is a shared linked
|
---|
413 | executable).
|
---|
414 | <P>
|
---|
415 |
|
---|
416 | <DT><SAMP>`-rdynamic'</SAMP>
|
---|
417 | <DD>Export global symbols to the dynamic linker. It is useful when a library
|
---|
418 | opened with <CODE>dlopen()</CODE> needs to access executable symbols.
|
---|
419 | <P>
|
---|
420 |
|
---|
421 | <DT><SAMP>`-r'</SAMP>
|
---|
422 | <DD>Generate an object file combining all input files.
|
---|
423 | <P>
|
---|
424 |
|
---|
425 | <DT><SAMP>`-Wl,-rpath=path'</SAMP>
|
---|
426 | <DD>Put custom search path for dynamic libraries into executable.
|
---|
427 | <P>
|
---|
428 |
|
---|
429 | <DT><SAMP>`-Wl,--enable-new-dtags'</SAMP>
|
---|
430 | <DD>When putting a custom search path for dynamic libraries into the executable,
|
---|
431 | create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH.
|
---|
432 | <P>
|
---|
433 |
|
---|
434 | <DT><SAMP>`-Wl,--oformat=fmt'</SAMP>
|
---|
435 | <DD>Use <VAR>fmt</VAR> as output format. The supported output formats are:
|
---|
436 | <DL COMPACT>
|
---|
437 | <DT><CODE>elf32-i386</CODE>
|
---|
438 | <DD>ELF output format (default)
|
---|
439 | <DT><CODE>binary</CODE>
|
---|
440 | <DD>Binary image (only for executable output)
|
---|
441 | <DT><CODE>coff</CODE>
|
---|
442 | <DD>COFF output format (only for executable output for TMS320C67xx target)
|
---|
443 | </DL>
|
---|
444 | <P>
|
---|
445 |
|
---|
446 | <DT><SAMP>`-Wl,-subsystem=console/gui/wince/...'</SAMP>
|
---|
447 | <DD>Set type for PE (Windows) executables.
|
---|
448 | <P>
|
---|
449 |
|
---|
450 | <DT><SAMP>`-Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]'</SAMP>
|
---|
451 | <DD>Modify executable layout.
|
---|
452 | <P>
|
---|
453 |
|
---|
454 | <DT><SAMP>`-Wl,-Bsymbolic'</SAMP>
|
---|
455 | <DD>Set DT_SYMBOLIC tag.
|
---|
456 | <P>
|
---|
457 |
|
---|
458 | <DT><SAMP>`-Wl,-(no-)whole-archive'</SAMP>
|
---|
459 | <DD>Turn on/off linking of all objects in archives.
|
---|
460 | <P>
|
---|
461 |
|
---|
462 | </DL>
|
---|
463 | <P>
|
---|
464 |
|
---|
465 | Debugger options:
|
---|
466 | </P><P>
|
---|
467 |
|
---|
468 | <DL COMPACT>
|
---|
469 | <DT><SAMP>`-g'</SAMP>
|
---|
470 | <DD>Generate run time debug information so that you get clear run time
|
---|
471 | error messages: <CODE> test.c:68: in function 'test5()': dereferencing
|
---|
472 | invalid pointer</CODE> instead of the laconic <CODE>Segmentation
|
---|
473 | fault</CODE>.
|
---|
474 | <P>
|
---|
475 |
|
---|
476 | <DT><SAMP>`-b'</SAMP>
|
---|
477 | <DD>Generate additional support code to check
|
---|
478 | memory allocations and array/pointer bounds. <SAMP>`-g'</SAMP> is implied. Note
|
---|
479 | that the generated code is slower and bigger in this case.
|
---|
480 | <P>
|
---|
481 |
|
---|
482 | Note: <SAMP>`-b'</SAMP> is only available on i386 when using libtcc for the moment.
|
---|
483 | </P><P>
|
---|
484 |
|
---|
485 | <DT><SAMP>`-bt N'</SAMP>
|
---|
486 | <DD>Display N callers in stack traces. This is useful with <SAMP>`-g'</SAMP> or
|
---|
487 | <SAMP>`-b'</SAMP>.
|
---|
488 | <P>
|
---|
489 |
|
---|
490 | </DL>
|
---|
491 | <P>
|
---|
492 |
|
---|
493 | Misc options:
|
---|
494 | </P><P>
|
---|
495 |
|
---|
496 | <DL COMPACT>
|
---|
497 | <DT><SAMP>`-MD'</SAMP>
|
---|
498 | <DD>Generate makefile fragment with dependencies.
|
---|
499 | <P>
|
---|
500 |
|
---|
501 | <DT><SAMP>`-MF depfile'</SAMP>
|
---|
502 | <DD>Use <TT>`depfile'</TT> as output for -MD.
|
---|
503 | <P>
|
---|
504 |
|
---|
505 | <DT><SAMP>`-print-search-dirs'</SAMP>
|
---|
506 | <DD>Print the configured installation directory and a list of library
|
---|
507 | and include directories tcc will search.
|
---|
508 | <P>
|
---|
509 |
|
---|
510 | <DT><SAMP>`-dumpversion'</SAMP>
|
---|
511 | <DD>Print version.
|
---|
512 | <P>
|
---|
513 |
|
---|
514 | </DL>
|
---|
515 | <P>
|
---|
516 |
|
---|
517 | Target specific options:
|
---|
518 | </P><P>
|
---|
519 |
|
---|
520 | <DL COMPACT>
|
---|
521 | <DT><SAMP>`-mms-bitfields'</SAMP>
|
---|
522 | <DD>Use an algorithm for bitfield alignment consistent with MSVC. Default is
|
---|
523 | gcc's algorithm.
|
---|
524 | <P>
|
---|
525 |
|
---|
526 | <DT><SAMP>`-mfloat-abi (ARM only)'</SAMP>
|
---|
527 | <DD>Select the float ABI. Possible values: <CODE>softfp</CODE> and <CODE>hard</CODE>
|
---|
528 | <P>
|
---|
529 |
|
---|
530 | <DT><SAMP>`-mno-sse'</SAMP>
|
---|
531 | <DD>Do not use sse registers on x86_64
|
---|
532 | <P>
|
---|
533 |
|
---|
534 | <DT><SAMP>`-m32, -m64'</SAMP>
|
---|
535 | <DD>Pass command line to the i386/x86_64 cross compiler.
|
---|
536 | <P>
|
---|
537 |
|
---|
538 | </DL>
|
---|
539 | <P>
|
---|
540 |
|
---|
541 | Note: GCC options <SAMP>`-Ox'</SAMP>, <SAMP>`-fx'</SAMP> and <SAMP>`-mx'</SAMP> are
|
---|
542 | ignored.
|
---|
543 | </P><P>
|
---|
544 |
|
---|
545 | Environment variables that affect how tcc operates.
|
---|
546 | </P><P>
|
---|
547 |
|
---|
548 | <DL COMPACT>
|
---|
549 |
|
---|
550 | <DT><SAMP>`CPATH'</SAMP>
|
---|
551 | <DD><DT><SAMP>`C_INCLUDE_PATH'</SAMP>
|
---|
552 | <DD>A colon-separated list of directories searched for include files,
|
---|
553 | directories given with <SAMP>`-I'</SAMP> are searched first.
|
---|
554 | <P>
|
---|
555 |
|
---|
556 | <DT><SAMP>`LIBRARY_PATH'</SAMP>
|
---|
557 | <DD>A colon-separated list of directories searched for libraries for the
|
---|
558 | <SAMP>`-l'</SAMP> option, directories given with <SAMP>`-L'</SAMP> are searched first.
|
---|
559 | <P>
|
---|
560 |
|
---|
561 | </DL>
|
---|
562 | <P>
|
---|
563 |
|
---|
564 | <A NAME="Clang"></A>
|
---|
565 | <HR SIZE="6">
|
---|
566 | <A NAME="SEC5"></A>
|
---|
567 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
568 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC4"> < </A>]</TD>
|
---|
569 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> > </A>]</TD>
|
---|
570 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> << </A>]</TD>
|
---|
571 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
572 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> >> </A>]</TD>
|
---|
573 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
574 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
575 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
576 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
577 | </TR></TABLE>
|
---|
578 | <H1> 3. C language support </H1>
|
---|
579 | <!--docid::SEC5::-->
|
---|
580 | <P>
|
---|
581 |
|
---|
582 | <HR SIZE="6">
|
---|
583 | <A NAME="SEC6"></A>
|
---|
584 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
585 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> < </A>]</TD>
|
---|
586 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> > </A>]</TD>
|
---|
587 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> << </A>]</TD>
|
---|
588 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
|
---|
589 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> >> </A>]</TD>
|
---|
590 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
591 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
592 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
593 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
594 | </TR></TABLE>
|
---|
595 | <H2> 3.1 ANSI C </H2>
|
---|
596 | <!--docid::SEC6::-->
|
---|
597 | <P>
|
---|
598 |
|
---|
599 | TCC implements all the ANSI C standard, including structure bit fields
|
---|
600 | and floating point numbers (<CODE>long double</CODE>, <CODE>double</CODE>, and
|
---|
601 | <CODE>float</CODE> fully supported).
|
---|
602 | </P><P>
|
---|
603 |
|
---|
604 | <HR SIZE="6">
|
---|
605 | <A NAME="SEC7"></A>
|
---|
606 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
607 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> < </A>]</TD>
|
---|
608 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> > </A>]</TD>
|
---|
609 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> << </A>]</TD>
|
---|
610 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
|
---|
611 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> >> </A>]</TD>
|
---|
612 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
613 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
614 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
615 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
616 | </TR></TABLE>
|
---|
617 | <H2> 3.2 ISOC99 extensions </H2>
|
---|
618 | <!--docid::SEC7::-->
|
---|
619 | <P>
|
---|
620 |
|
---|
621 | TCC implements many features of the new C standard: ISO C99. Currently
|
---|
622 | missing items are: complex and imaginary numbers.
|
---|
623 | </P><P>
|
---|
624 |
|
---|
625 | Currently implemented ISOC99 features:
|
---|
626 | </P><P>
|
---|
627 |
|
---|
628 | <UL>
|
---|
629 |
|
---|
630 | <LI>variable length arrays.
|
---|
631 | <P>
|
---|
632 |
|
---|
633 | <LI>64 bit <CODE>long long</CODE> types are fully supported.
|
---|
634 | <P>
|
---|
635 |
|
---|
636 | <LI>The boolean type <CODE>_Bool</CODE> is supported.
|
---|
637 | <P>
|
---|
638 |
|
---|
639 | <LI><CODE>__func__</CODE> is a string variable containing the current
|
---|
640 | function name.
|
---|
641 | <P>
|
---|
642 |
|
---|
643 | <LI>Variadic macros: <CODE>__VA_ARGS__</CODE> can be used for
|
---|
644 | function-like macros:
|
---|
645 | <TABLE><tr><td> </td><td class=example><pre> #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)
|
---|
646 | </pre></td></tr></table><P>
|
---|
647 |
|
---|
648 | <CODE>dprintf</CODE> can then be used with a variable number of parameters.
|
---|
649 | </P><P>
|
---|
650 |
|
---|
651 | <LI>Declarations can appear anywhere in a block (as in C++).
|
---|
652 | <P>
|
---|
653 |
|
---|
654 | <LI>Array and struct/union elements can be initialized in any order by
|
---|
655 | using designators:
|
---|
656 | <TABLE><tr><td> </td><td class=example><pre> struct { int x, y; } st[10] = { [0].x = 1, [0].y = 2 };
|
---|
657 |
|
---|
658 | int tab[10] = { 1, 2, [5] = 5, [9] = 9};
|
---|
659 | </pre></td></tr></table>
|
---|
660 | <LI>Compound initializers are supported:
|
---|
661 | <TABLE><tr><td> </td><td class=example><pre> int *p = (int []){ 1, 2, 3 };
|
---|
662 | </pre></td></tr></table>to initialize a pointer pointing to an initialized array. The same
|
---|
663 | works for structures and strings.
|
---|
664 | <P>
|
---|
665 |
|
---|
666 | <LI>Hexadecimal floating point constants are supported:
|
---|
667 | <TABLE><tr><td> </td><td class=example><pre> double d = 0x1234p10;
|
---|
668 | </pre></td></tr></table><P>
|
---|
669 |
|
---|
670 | is the same as writing
|
---|
671 | <TABLE><tr><td> </td><td class=example><pre> double d = 4771840.0;
|
---|
672 | </pre></td></tr></table></P><P>
|
---|
673 |
|
---|
674 | <LI><CODE>inline</CODE> keyword is ignored.
|
---|
675 | <P>
|
---|
676 |
|
---|
677 | <LI><CODE>restrict</CODE> keyword is ignored.
|
---|
678 | </UL>
|
---|
679 | <P>
|
---|
680 |
|
---|
681 | <HR SIZE="6">
|
---|
682 | <A NAME="SEC8"></A>
|
---|
683 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
684 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> < </A>]</TD>
|
---|
685 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> > </A>]</TD>
|
---|
686 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> << </A>]</TD>
|
---|
687 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
|
---|
688 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> >> </A>]</TD>
|
---|
689 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
690 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
691 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
692 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
693 | </TR></TABLE>
|
---|
694 | <H2> 3.3 GNU C extensions </H2>
|
---|
695 | <!--docid::SEC8::-->
|
---|
696 | <P>
|
---|
697 |
|
---|
698 | TCC implements some GNU C extensions:
|
---|
699 | </P><P>
|
---|
700 |
|
---|
701 | <UL>
|
---|
702 |
|
---|
703 | <LI>array designators can be used without '=':
|
---|
704 | <TABLE><tr><td> </td><td class=example><pre> int a[10] = { [0] 1, [5] 2, 3, 4 };
|
---|
705 | </pre></td></tr></table><P>
|
---|
706 |
|
---|
707 | <LI>Structure field designators can be a label:
|
---|
708 | <TABLE><tr><td> </td><td class=example><pre> struct { int x, y; } st = { x: 1, y: 1};
|
---|
709 | </pre></td></tr></table>instead of
|
---|
710 | <TABLE><tr><td> </td><td class=example><pre> struct { int x, y; } st = { .x = 1, .y = 1};
|
---|
711 | </pre></td></tr></table><P>
|
---|
712 |
|
---|
713 | <LI><CODE>\e</CODE> is ASCII character 27.
|
---|
714 | <P>
|
---|
715 |
|
---|
716 | <LI>case ranges : ranges can be used in <CODE>case</CODE>s:
|
---|
717 | <TABLE><tr><td> </td><td class=example><pre> switch(a) {
|
---|
718 | case 1 <small>...</small> 9:
|
---|
719 | printf("range 1 to 9\n");
|
---|
720 | break;
|
---|
721 | default:
|
---|
722 | printf("unexpected\n");
|
---|
723 | break;
|
---|
724 | }
|
---|
725 | </pre></td></tr></table><P>
|
---|
726 |
|
---|
727 | <A NAME="IDX1"></A>
|
---|
728 | <A NAME="IDX2"></A>
|
---|
729 | <A NAME="IDX3"></A>
|
---|
730 | <A NAME="IDX4"></A>
|
---|
731 | <A NAME="IDX5"></A>
|
---|
732 | <A NAME="IDX6"></A>
|
---|
733 | <A NAME="IDX7"></A>
|
---|
734 | <A NAME="IDX8"></A>
|
---|
735 | </P><P>
|
---|
736 |
|
---|
737 | <LI>The keyword <CODE>__attribute__</CODE> is handled to specify variable or
|
---|
738 | function attributes. The following attributes are supported:
|
---|
739 | <UL>
|
---|
740 |
|
---|
741 | <LI><CODE>aligned(n)</CODE>: align a variable or a structure field to n bytes
|
---|
742 | (must be a power of two).
|
---|
743 | <P>
|
---|
744 |
|
---|
745 | <LI><CODE>packed</CODE>: force alignment of a variable or a structure field to
|
---|
746 | 1.
|
---|
747 | <P>
|
---|
748 |
|
---|
749 | <LI><CODE>section(name)</CODE>: generate function or data in assembly section
|
---|
750 | name (name is a string containing the section name) instead of the default
|
---|
751 | section.
|
---|
752 | <P>
|
---|
753 |
|
---|
754 | <LI><CODE>unused</CODE>: specify that the variable or the function is unused.
|
---|
755 | <P>
|
---|
756 |
|
---|
757 | <LI><CODE>cdecl</CODE>: use standard C calling convention (default).
|
---|
758 | <P>
|
---|
759 |
|
---|
760 | <LI><CODE>stdcall</CODE>: use Pascal-like calling convention.
|
---|
761 | <P>
|
---|
762 |
|
---|
763 | <LI><CODE>regparm(n)</CODE>: use fast i386 calling convention. <VAR>n</VAR> must be
|
---|
764 | between 1 and 3. The first <VAR>n</VAR> function parameters are respectively put in
|
---|
765 | registers <CODE>%eax</CODE>, <CODE>%edx</CODE> and <CODE>%ecx</CODE>.
|
---|
766 | <P>
|
---|
767 |
|
---|
768 | <LI><CODE>dllexport</CODE>: export function from dll/executable (win32 only)
|
---|
769 | <P>
|
---|
770 |
|
---|
771 | </UL>
|
---|
772 | <P>
|
---|
773 |
|
---|
774 | Here are some examples:
|
---|
775 | <TABLE><tr><td> </td><td class=example><pre> int a __attribute__ ((aligned(8), section(".mysection")));
|
---|
776 | </pre></td></tr></table></P><P>
|
---|
777 |
|
---|
778 | align variable <CODE>a</CODE> to 8 bytes and put it in section <CODE>.mysection</CODE>.
|
---|
779 | </P><P>
|
---|
780 |
|
---|
781 | <TABLE><tr><td> </td><td class=example><pre> int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
|
---|
782 | {
|
---|
783 | return a + b;
|
---|
784 | }
|
---|
785 | </pre></td></tr></table></P><P>
|
---|
786 |
|
---|
787 | generate function <CODE>my_add</CODE> in section <CODE>.mycodesection</CODE>.
|
---|
788 | </P><P>
|
---|
789 |
|
---|
790 | <LI>GNU style variadic macros:
|
---|
791 | <TABLE><tr><td> </td><td class=example><pre> #define dprintf(fmt, args<small>...</small>) printf(fmt, ## args)
|
---|
792 |
|
---|
793 | dprintf("no arg\n");
|
---|
794 | dprintf("one arg %d\n", 1);
|
---|
795 | </pre></td></tr></table><P>
|
---|
796 |
|
---|
797 | <LI><CODE>__FUNCTION__</CODE> is interpreted as C99 <CODE>__func__</CODE>
|
---|
798 | (so it has not exactly the same semantics as string literal GNUC
|
---|
799 | where it is a string literal).
|
---|
800 | <P>
|
---|
801 |
|
---|
802 | <LI>The <CODE>__alignof__</CODE> keyword can be used as <CODE>sizeof</CODE>
|
---|
803 | to get the alignment of a type or an expression.
|
---|
804 | <P>
|
---|
805 |
|
---|
806 | <LI>The <CODE>typeof(x)</CODE> returns the type of <CODE>x</CODE>.
|
---|
807 | <CODE>x</CODE> is an expression or a type.
|
---|
808 | <P>
|
---|
809 |
|
---|
810 | <LI>Computed gotos: <CODE>&&label</CODE> returns a pointer of type
|
---|
811 | <CODE>void *</CODE> on the goto label <CODE>label</CODE>. <CODE>goto *expr</CODE> can be
|
---|
812 | used to jump on the pointer resulting from <CODE>expr</CODE>.
|
---|
813 | <P>
|
---|
814 |
|
---|
815 | <LI>Inline assembly with asm instruction:
|
---|
816 | <A NAME="IDX9"></A>
|
---|
817 | <A NAME="IDX10"></A>
|
---|
818 | <A NAME="IDX11"></A>
|
---|
819 | <TABLE><tr><td> </td><td class=example><pre>static inline void * my_memcpy(void * to, const void * from, size_t n)
|
---|
820 | {
|
---|
821 | int d0, d1, d2;
|
---|
822 | __asm__ __volatile__(
|
---|
823 | "rep ; movsl\n\t"
|
---|
824 | "testb $2,%b4\n\t"
|
---|
825 | "je 1f\n\t"
|
---|
826 | "movsw\n"
|
---|
827 | "1:\ttestb $1,%b4\n\t"
|
---|
828 | "je 2f\n\t"
|
---|
829 | "movsb\n"
|
---|
830 | "2:"
|
---|
831 | : "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
---|
832 | :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
|
---|
833 | : "memory");
|
---|
834 | return (to);
|
---|
835 | }
|
---|
836 | </pre></td></tr></table><P>
|
---|
837 |
|
---|
838 | <A NAME="IDX12"></A>
|
---|
839 | TCC includes its own x86 inline assembler with a <CODE>gas</CODE>-like (GNU
|
---|
840 | assembler) syntax. No intermediate files are generated. GCC 3.x named
|
---|
841 | operands are supported.
|
---|
842 | </P><P>
|
---|
843 |
|
---|
844 | <LI><CODE>__builtin_types_compatible_p()</CODE> and <CODE>__builtin_constant_p()</CODE>
|
---|
845 | are supported.
|
---|
846 | <P>
|
---|
847 |
|
---|
848 | <LI><CODE>#pragma pack</CODE> is supported for win32 compatibility.
|
---|
849 | <P>
|
---|
850 |
|
---|
851 | </UL>
|
---|
852 | <P>
|
---|
853 |
|
---|
854 | <HR SIZE="6">
|
---|
855 | <A NAME="SEC9"></A>
|
---|
856 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
857 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> < </A>]</TD>
|
---|
858 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> > </A>]</TD>
|
---|
859 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> << </A>]</TD>
|
---|
860 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
|
---|
861 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> >> </A>]</TD>
|
---|
862 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
863 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
864 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
865 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
866 | </TR></TABLE>
|
---|
867 | <H2> 3.4 TinyCC extensions </H2>
|
---|
868 | <!--docid::SEC9::-->
|
---|
869 | <P>
|
---|
870 |
|
---|
871 | <UL>
|
---|
872 |
|
---|
873 | <LI><CODE>__TINYC__</CODE> is a predefined macro to indicate that you use TCC.
|
---|
874 | <P>
|
---|
875 |
|
---|
876 | <LI><CODE>#!</CODE> at the start of a line is ignored to allow scripting.
|
---|
877 | <P>
|
---|
878 |
|
---|
879 | <LI>Binary digits can be entered (<CODE>0b101</CODE> instead of
|
---|
880 | <CODE>5</CODE>).
|
---|
881 | <P>
|
---|
882 |
|
---|
883 | <LI><CODE>__BOUNDS_CHECKING_ON</CODE> is defined if bound checking is activated.
|
---|
884 | <P>
|
---|
885 |
|
---|
886 | </UL>
|
---|
887 | <P>
|
---|
888 |
|
---|
889 | <A NAME="asm"></A>
|
---|
890 | <HR SIZE="6">
|
---|
891 | <A NAME="SEC10"></A>
|
---|
892 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
893 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> < </A>]</TD>
|
---|
894 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC11"> > </A>]</TD>
|
---|
895 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> << </A>]</TD>
|
---|
896 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
897 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> >> </A>]</TD>
|
---|
898 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
899 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
900 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
901 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
902 | </TR></TABLE>
|
---|
903 | <H1> 4. TinyCC Assembler </H1>
|
---|
904 | <!--docid::SEC10::-->
|
---|
905 | <P>
|
---|
906 |
|
---|
907 | Since version 0.9.16, TinyCC integrates its own assembler. TinyCC
|
---|
908 | assembler supports a gas-like syntax (GNU assembler). You can
|
---|
909 | deactivate assembler support if you want a smaller TinyCC executable
|
---|
910 | (the C compiler does not rely on the assembler).
|
---|
911 | </P><P>
|
---|
912 |
|
---|
913 | TinyCC Assembler is used to handle files with <TT>`.S'</TT> (C
|
---|
914 | preprocessed assembler) and <TT>`.s'</TT> extensions. It is also used to
|
---|
915 | handle the GNU inline assembler with the <CODE>asm</CODE> keyword.
|
---|
916 | </P><P>
|
---|
917 |
|
---|
918 | <HR SIZE="6">
|
---|
919 | <A NAME="SEC11"></A>
|
---|
920 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
921 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> < </A>]</TD>
|
---|
922 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC12"> > </A>]</TD>
|
---|
923 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> << </A>]</TD>
|
---|
924 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
|
---|
925 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> >> </A>]</TD>
|
---|
926 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
927 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
928 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
929 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
930 | </TR></TABLE>
|
---|
931 | <H2> 4.1 Syntax </H2>
|
---|
932 | <!--docid::SEC11::-->
|
---|
933 | <P>
|
---|
934 |
|
---|
935 | TinyCC Assembler supports most of the gas syntax. The tokens are the
|
---|
936 | same as C.
|
---|
937 | </P><P>
|
---|
938 |
|
---|
939 | <UL>
|
---|
940 |
|
---|
941 | <LI>C and C++ comments are supported.
|
---|
942 | <P>
|
---|
943 |
|
---|
944 | <LI>Identifiers are the same as C, so you cannot use '.' or '$'.
|
---|
945 | <P>
|
---|
946 |
|
---|
947 | <LI>Only 32 bit integer numbers are supported.
|
---|
948 | <P>
|
---|
949 |
|
---|
950 | </UL>
|
---|
951 | <P>
|
---|
952 |
|
---|
953 | <HR SIZE="6">
|
---|
954 | <A NAME="SEC12"></A>
|
---|
955 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
956 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC11"> < </A>]</TD>
|
---|
957 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> > </A>]</TD>
|
---|
958 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> << </A>]</TD>
|
---|
959 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
|
---|
960 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> >> </A>]</TD>
|
---|
961 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
962 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
963 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
964 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
965 | </TR></TABLE>
|
---|
966 | <H2> 4.2 Expressions </H2>
|
---|
967 | <!--docid::SEC12::-->
|
---|
968 | <P>
|
---|
969 |
|
---|
970 | <UL>
|
---|
971 |
|
---|
972 | <LI>Integers in decimal, octal and hexa are supported.
|
---|
973 | <P>
|
---|
974 |
|
---|
975 | <LI>Unary operators: +, -, ~.
|
---|
976 | <P>
|
---|
977 |
|
---|
978 | <LI>Binary operators in decreasing priority order:
|
---|
979 | <P>
|
---|
980 |
|
---|
981 | <OL>
|
---|
982 | <LI>*, /, %
|
---|
983 | <LI>&, |, ^
|
---|
984 | <LI>+, -
|
---|
985 | </OL>
|
---|
986 | <P>
|
---|
987 |
|
---|
988 | <LI>A value is either an absolute number or a label plus an offset.
|
---|
989 | All operators accept absolute values except '+' and '-'. '+' or '-' can be
|
---|
990 | used to add an offset to a label. '-' supports two labels only if they
|
---|
991 | are the same or if they are both defined and in the same section.
|
---|
992 | <P>
|
---|
993 |
|
---|
994 | </UL>
|
---|
995 | <P>
|
---|
996 |
|
---|
997 | <HR SIZE="6">
|
---|
998 | <A NAME="SEC13"></A>
|
---|
999 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1000 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC12"> < </A>]</TD>
|
---|
1001 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> > </A>]</TD>
|
---|
1002 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> << </A>]</TD>
|
---|
1003 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
|
---|
1004 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> >> </A>]</TD>
|
---|
1005 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1006 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1007 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1008 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1009 | </TR></TABLE>
|
---|
1010 | <H2> 4.3 Labels </H2>
|
---|
1011 | <!--docid::SEC13::-->
|
---|
1012 | <P>
|
---|
1013 |
|
---|
1014 | <UL>
|
---|
1015 |
|
---|
1016 | <LI>All labels are considered as local, except undefined ones.
|
---|
1017 | <P>
|
---|
1018 |
|
---|
1019 | <LI>Numeric labels can be used as local <CODE>gas</CODE>-like labels.
|
---|
1020 | They can be defined several times in the same source. Use 'b'
|
---|
1021 | (backward) or 'f' (forward) as suffix to reference them:
|
---|
1022 | <P>
|
---|
1023 |
|
---|
1024 | <TABLE><tr><td> </td><td class=example><pre> 1:
|
---|
1025 | jmp 1b /* jump to '1' label before */
|
---|
1026 | jmp 1f /* jump to '1' label after */
|
---|
1027 | 1:
|
---|
1028 | </pre></td></tr></table></P><P>
|
---|
1029 |
|
---|
1030 | </UL>
|
---|
1031 | <P>
|
---|
1032 |
|
---|
1033 | <HR SIZE="6">
|
---|
1034 | <A NAME="SEC14"></A>
|
---|
1035 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1036 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> < </A>]</TD>
|
---|
1037 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> > </A>]</TD>
|
---|
1038 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> << </A>]</TD>
|
---|
1039 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
|
---|
1040 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> >> </A>]</TD>
|
---|
1041 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1042 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1043 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1044 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1045 | </TR></TABLE>
|
---|
1046 | <H2> 4.4 Directives </H2>
|
---|
1047 | <!--docid::SEC14::-->
|
---|
1048 | <P>
|
---|
1049 |
|
---|
1050 | All directives are preceded by a '.'. The following directives are
|
---|
1051 | supported:
|
---|
1052 | </P><P>
|
---|
1053 |
|
---|
1054 | <UL>
|
---|
1055 | <LI>.align n[,value]
|
---|
1056 | <LI>.skip n[,value]
|
---|
1057 | <LI>.space n[,value]
|
---|
1058 | <LI>.byte value1[,...]
|
---|
1059 | <LI>.word value1[,...]
|
---|
1060 | <LI>.short value1[,...]
|
---|
1061 | <LI>.int value1[,...]
|
---|
1062 | <LI>.long value1[,...]
|
---|
1063 | <LI>.quad immediate_value1[,...]
|
---|
1064 | <LI>.globl symbol
|
---|
1065 | <LI>.global symbol
|
---|
1066 | <LI>.section section
|
---|
1067 | <LI>.text
|
---|
1068 | <LI>.data
|
---|
1069 | <LI>.bss
|
---|
1070 | <LI>.fill repeat[,size[,value]]
|
---|
1071 | <LI>.org n
|
---|
1072 | <LI>.previous
|
---|
1073 | <LI>.string string[,...]
|
---|
1074 | <LI>.asciz string[,...]
|
---|
1075 | <LI>.ascii string[,...]
|
---|
1076 | </UL>
|
---|
1077 | <P>
|
---|
1078 |
|
---|
1079 | <HR SIZE="6">
|
---|
1080 | <A NAME="SEC15"></A>
|
---|
1081 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1082 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> < </A>]</TD>
|
---|
1083 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> > </A>]</TD>
|
---|
1084 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> << </A>]</TD>
|
---|
1085 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
|
---|
1086 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> >> </A>]</TD>
|
---|
1087 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1088 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1089 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1090 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1091 | </TR></TABLE>
|
---|
1092 | <H2> 4.5 X86 Assembler </H2>
|
---|
1093 | <!--docid::SEC15::-->
|
---|
1094 | <P>
|
---|
1095 |
|
---|
1096 | All X86 opcodes are supported. Only ATT syntax is supported (source
|
---|
1097 | then destination operand order). If no size suffix is given, TinyCC
|
---|
1098 | tries to guess it from the operand sizes.
|
---|
1099 | </P><P>
|
---|
1100 |
|
---|
1101 | Currently, MMX opcodes are supported but not SSE ones.
|
---|
1102 | </P><P>
|
---|
1103 |
|
---|
1104 | <A NAME="linker"></A>
|
---|
1105 | <HR SIZE="6">
|
---|
1106 | <A NAME="SEC16"></A>
|
---|
1107 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1108 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> < </A>]</TD>
|
---|
1109 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC17"> > </A>]</TD>
|
---|
1110 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> << </A>]</TD>
|
---|
1111 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
1112 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> >> </A>]</TD>
|
---|
1113 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1114 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1115 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1116 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1117 | </TR></TABLE>
|
---|
1118 | <H1> 5. TinyCC Linker </H1>
|
---|
1119 | <!--docid::SEC16::-->
|
---|
1120 | <P>
|
---|
1121 |
|
---|
1122 | <HR SIZE="6">
|
---|
1123 | <A NAME="SEC17"></A>
|
---|
1124 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1125 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> < </A>]</TD>
|
---|
1126 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC18"> > </A>]</TD>
|
---|
1127 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> << </A>]</TD>
|
---|
1128 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
|
---|
1129 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> >> </A>]</TD>
|
---|
1130 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1131 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1132 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1133 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1134 | </TR></TABLE>
|
---|
1135 | <H2> 5.1 ELF file generation </H2>
|
---|
1136 | <!--docid::SEC17::-->
|
---|
1137 | <P>
|
---|
1138 |
|
---|
1139 | TCC can directly output relocatable ELF files (object files),
|
---|
1140 | executable ELF files and dynamic ELF libraries without relying on an
|
---|
1141 | external linker.
|
---|
1142 | </P><P>
|
---|
1143 |
|
---|
1144 | Dynamic ELF libraries can be output but the C compiler does not generate
|
---|
1145 | position independent code (PIC). It means that the dynamic library
|
---|
1146 | code generated by TCC cannot be factorized among processes yet.
|
---|
1147 | </P><P>
|
---|
1148 |
|
---|
1149 | TCC linker eliminates unreferenced object code in libraries. A single pass is
|
---|
1150 | done on the object and library list, so the order in which object files and
|
---|
1151 | libraries are specified is important (same constraint as GNU ld). No grouping
|
---|
1152 | options (<SAMP>`--start-group'</SAMP> and <SAMP>`--end-group'</SAMP>) are supported.
|
---|
1153 | </P><P>
|
---|
1154 |
|
---|
1155 | <HR SIZE="6">
|
---|
1156 | <A NAME="SEC18"></A>
|
---|
1157 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1158 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC17"> < </A>]</TD>
|
---|
1159 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> > </A>]</TD>
|
---|
1160 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> << </A>]</TD>
|
---|
1161 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
|
---|
1162 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> >> </A>]</TD>
|
---|
1163 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1164 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1165 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1166 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1167 | </TR></TABLE>
|
---|
1168 | <H2> 5.2 ELF file loader </H2>
|
---|
1169 | <!--docid::SEC18::-->
|
---|
1170 | <P>
|
---|
1171 |
|
---|
1172 | TCC can load ELF object files, archives (.a files) and dynamic
|
---|
1173 | libraries (.so).
|
---|
1174 | </P><P>
|
---|
1175 |
|
---|
1176 | <HR SIZE="6">
|
---|
1177 | <A NAME="SEC19"></A>
|
---|
1178 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1179 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC18"> < </A>]</TD>
|
---|
1180 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> > </A>]</TD>
|
---|
1181 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> << </A>]</TD>
|
---|
1182 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
|
---|
1183 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> >> </A>]</TD>
|
---|
1184 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1185 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1186 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1187 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1188 | </TR></TABLE>
|
---|
1189 | <H2> 5.3 PE-i386 file generation </H2>
|
---|
1190 | <!--docid::SEC19::-->
|
---|
1191 | <P>
|
---|
1192 |
|
---|
1193 | TCC for Windows supports the native Win32 executable file format (PE-i386). It
|
---|
1194 | generates EXE files (console and gui) and DLL files.
|
---|
1195 | </P><P>
|
---|
1196 |
|
---|
1197 | For usage on Windows, see also tcc-win32.txt.
|
---|
1198 | </P><P>
|
---|
1199 |
|
---|
1200 | <HR SIZE="6">
|
---|
1201 | <A NAME="SEC20"></A>
|
---|
1202 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1203 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> < </A>]</TD>
|
---|
1204 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> > </A>]</TD>
|
---|
1205 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> << </A>]</TD>
|
---|
1206 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
|
---|
1207 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> >> </A>]</TD>
|
---|
1208 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1209 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1210 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1211 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1212 | </TR></TABLE>
|
---|
1213 | <H2> 5.4 GNU Linker Scripts </H2>
|
---|
1214 | <!--docid::SEC20::-->
|
---|
1215 | <P>
|
---|
1216 |
|
---|
1217 | Because on many Linux systems some dynamic libraries (such as
|
---|
1218 | <TT>`/usr/lib/libc.so'</TT>) are in fact GNU ld link scripts (horrible!),
|
---|
1219 | the TCC linker also supports a subset of GNU ld scripts.
|
---|
1220 | </P><P>
|
---|
1221 |
|
---|
1222 | The <CODE>GROUP</CODE> and <CODE>FILE</CODE> commands are supported. <CODE>OUTPUT_FORMAT</CODE>
|
---|
1223 | and <CODE>TARGET</CODE> are ignored.
|
---|
1224 | </P><P>
|
---|
1225 |
|
---|
1226 | Example from <TT>`/usr/lib/libc.so'</TT>:
|
---|
1227 | <TABLE><tr><td> </td><td class=example><pre>/* GNU ld script
|
---|
1228 | Use the shared library, but some functions are only in
|
---|
1229 | the static library, so try that secondarily. */
|
---|
1230 | GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
|
---|
1231 | </pre></td></tr></table></P><P>
|
---|
1232 |
|
---|
1233 | <A NAME="Bounds"></A>
|
---|
1234 | <HR SIZE="6">
|
---|
1235 | <A NAME="SEC21"></A>
|
---|
1236 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1237 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> < </A>]</TD>
|
---|
1238 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> > </A>]</TD>
|
---|
1239 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> << </A>]</TD>
|
---|
1240 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
1241 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> >> </A>]</TD>
|
---|
1242 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1243 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1244 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1245 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1246 | </TR></TABLE>
|
---|
1247 | <H1> 6. TinyCC Memory and Bound checks </H1>
|
---|
1248 | <!--docid::SEC21::-->
|
---|
1249 | <P>
|
---|
1250 |
|
---|
1251 | This feature is activated with the <SAMP>`-b'</SAMP> (see section <A HREF="tcc-doc.html#SEC2">2. Command line invocation</A>).
|
---|
1252 | </P><P>
|
---|
1253 |
|
---|
1254 | Note that pointer size is <EM>unchanged</EM> and that code generated
|
---|
1255 | with bound checks is <EM>fully compatible</EM> with unchecked
|
---|
1256 | code. When a pointer comes from unchecked code, it is assumed to be
|
---|
1257 | valid. Even very obscure C code with casts should work correctly.
|
---|
1258 | </P><P>
|
---|
1259 |
|
---|
1260 | For more information about the ideas behind this method, see
|
---|
1261 | <A HREF="http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html">http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html</A>.
|
---|
1262 | </P><P>
|
---|
1263 |
|
---|
1264 | Here are some examples of caught errors:
|
---|
1265 | </P><P>
|
---|
1266 |
|
---|
1267 | <DL COMPACT>
|
---|
1268 |
|
---|
1269 | <DT>Invalid range with standard string function:
|
---|
1270 | <DD><TABLE><tr><td> </td><td class=example><pre>{
|
---|
1271 | char tab[10];
|
---|
1272 | memset(tab, 0, 11);
|
---|
1273 | }
|
---|
1274 | </pre></td></tr></table><P>
|
---|
1275 |
|
---|
1276 | <DT>Out of bounds-error in global or local arrays:
|
---|
1277 | <DD><TABLE><tr><td> </td><td class=example><pre>{
|
---|
1278 | int tab[10];
|
---|
1279 | for(i=0;i<11;i++) {
|
---|
1280 | sum += tab[i];
|
---|
1281 | }
|
---|
1282 | }
|
---|
1283 | </pre></td></tr></table><P>
|
---|
1284 |
|
---|
1285 | <DT>Out of bounds-error in malloc'ed data:
|
---|
1286 | <DD><TABLE><tr><td> </td><td class=example><pre>{
|
---|
1287 | int *tab;
|
---|
1288 | tab = malloc(20 * sizeof(int));
|
---|
1289 | for(i=0;i<21;i++) {
|
---|
1290 | sum += tab4[i];
|
---|
1291 | }
|
---|
1292 | free(tab);
|
---|
1293 | }
|
---|
1294 | </pre></td></tr></table><P>
|
---|
1295 |
|
---|
1296 | <DT>Access of freed memory:
|
---|
1297 | <DD><TABLE><tr><td> </td><td class=example><pre>{
|
---|
1298 | int *tab;
|
---|
1299 | tab = malloc(20 * sizeof(int));
|
---|
1300 | free(tab);
|
---|
1301 | for(i=0;i<20;i++) {
|
---|
1302 | sum += tab4[i];
|
---|
1303 | }
|
---|
1304 | }
|
---|
1305 | </pre></td></tr></table><P>
|
---|
1306 |
|
---|
1307 | <DT>Double free:
|
---|
1308 | <DD><TABLE><tr><td> </td><td class=example><pre>{
|
---|
1309 | int *tab;
|
---|
1310 | tab = malloc(20 * sizeof(int));
|
---|
1311 | free(tab);
|
---|
1312 | free(tab);
|
---|
1313 | }
|
---|
1314 | </pre></td></tr></table><P>
|
---|
1315 |
|
---|
1316 | </DL>
|
---|
1317 | <P>
|
---|
1318 |
|
---|
1319 | <A NAME="Libtcc"></A>
|
---|
1320 | <HR SIZE="6">
|
---|
1321 | <A NAME="SEC22"></A>
|
---|
1322 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1323 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> < </A>]</TD>
|
---|
1324 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> > </A>]</TD>
|
---|
1325 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> << </A>]</TD>
|
---|
1326 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
1327 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> >> </A>]</TD>
|
---|
1328 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1329 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1330 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1331 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1332 | </TR></TABLE>
|
---|
1333 | <H1> 7. The <CODE>libtcc</CODE> library </H1>
|
---|
1334 | <!--docid::SEC22::-->
|
---|
1335 | <P>
|
---|
1336 |
|
---|
1337 | The <CODE>libtcc</CODE> library enables you to use TCC as a backend for
|
---|
1338 | dynamic code generation.
|
---|
1339 | </P><P>
|
---|
1340 |
|
---|
1341 | Read the <TT>`libtcc.h'</TT> to have an overview of the API. Read
|
---|
1342 | <TT>`libtcc_test.c'</TT> to have a very simple example.
|
---|
1343 | </P><P>
|
---|
1344 |
|
---|
1345 | The idea consists in giving a C string containing the program you want
|
---|
1346 | to compile directly to <CODE>libtcc</CODE>. Then you can access to any global
|
---|
1347 | symbol (function or variable) defined.
|
---|
1348 | </P><P>
|
---|
1349 |
|
---|
1350 | <A NAME="devel"></A>
|
---|
1351 | <HR SIZE="6">
|
---|
1352 | <A NAME="SEC23"></A>
|
---|
1353 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1354 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> < </A>]</TD>
|
---|
1355 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC24"> > </A>]</TD>
|
---|
1356 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD>
|
---|
1357 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
1358 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1359 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1360 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1361 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1362 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1363 | </TR></TABLE>
|
---|
1364 | <H1> 8. Developer's guide </H1>
|
---|
1365 | <!--docid::SEC23::-->
|
---|
1366 | <P>
|
---|
1367 |
|
---|
1368 | This chapter gives some hints to understand how TCC works. You can skip
|
---|
1369 | it if you do not intend to modify the TCC code.
|
---|
1370 | </P><P>
|
---|
1371 |
|
---|
1372 | <HR SIZE="6">
|
---|
1373 | <A NAME="SEC24"></A>
|
---|
1374 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1375 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> < </A>]</TD>
|
---|
1376 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC25"> > </A>]</TD>
|
---|
1377 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD>
|
---|
1378 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1379 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1380 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1381 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1382 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1383 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1384 | </TR></TABLE>
|
---|
1385 | <H2> 8.1 File reading </H2>
|
---|
1386 | <!--docid::SEC24::-->
|
---|
1387 | <P>
|
---|
1388 |
|
---|
1389 | The <CODE>BufferedFile</CODE> structure contains the context needed to read a
|
---|
1390 | file, including the current line number. <CODE>tcc_open()</CODE> opens a new
|
---|
1391 | file and <CODE>tcc_close()</CODE> closes it. <CODE>inp()</CODE> returns the next
|
---|
1392 | character.
|
---|
1393 | </P><P>
|
---|
1394 |
|
---|
1395 | <HR SIZE="6">
|
---|
1396 | <A NAME="SEC25"></A>
|
---|
1397 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1398 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC24"> < </A>]</TD>
|
---|
1399 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> > </A>]</TD>
|
---|
1400 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> << </A>]</TD>
|
---|
1401 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1402 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1403 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1404 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1405 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1406 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1407 | </TR></TABLE>
|
---|
1408 | <H2> 8.2 Lexer </H2>
|
---|
1409 | <!--docid::SEC25::-->
|
---|
1410 | <P>
|
---|
1411 |
|
---|
1412 | <CODE>next()</CODE> reads the next token in the current
|
---|
1413 | file. <CODE>next_nomacro()</CODE> reads the next token without macro
|
---|
1414 | expansion.
|
---|
1415 | </P><P>
|
---|
1416 |
|
---|
1417 | <CODE>tok</CODE> contains the current token (see <CODE>TOK_xxx</CODE>)
|
---|
1418 | constants. Identifiers and keywords are also keywords. <CODE>tokc</CODE>
|
---|
1419 | contains additional infos about the token (for example a constant value
|
---|
1420 | if number or string token).
|
---|
1421 | </P><P>
|
---|
1422 |
|
---|
1423 | <HR SIZE="6">
|
---|
1424 | <A NAME="SEC26"></A>
|
---|
1425 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1426 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC25"> < </A>]</TD>
|
---|
1427 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> > </A>]</TD>
|
---|
1428 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> << </A>]</TD>
|
---|
1429 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1430 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1431 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1432 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1433 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1434 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1435 | </TR></TABLE>
|
---|
1436 | <H2> 8.3 Parser </H2>
|
---|
1437 | <!--docid::SEC26::-->
|
---|
1438 | <P>
|
---|
1439 |
|
---|
1440 | The parser is hardcoded (yacc is not necessary). It does only one pass,
|
---|
1441 | except:
|
---|
1442 | </P><P>
|
---|
1443 |
|
---|
1444 | <UL>
|
---|
1445 |
|
---|
1446 | <LI>For initialized arrays with unknown size, a first pass
|
---|
1447 | is done to count the number of elements.
|
---|
1448 | <P>
|
---|
1449 |
|
---|
1450 | <LI>For architectures where arguments are evaluated in
|
---|
1451 | reverse order, a first pass is done to reverse the argument order.
|
---|
1452 | <P>
|
---|
1453 |
|
---|
1454 | </UL>
|
---|
1455 | <P>
|
---|
1456 |
|
---|
1457 | <HR SIZE="6">
|
---|
1458 | <A NAME="SEC27"></A>
|
---|
1459 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1460 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> < </A>]</TD>
|
---|
1461 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> > </A>]</TD>
|
---|
1462 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> << </A>]</TD>
|
---|
1463 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1464 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1465 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1466 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1467 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1468 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1469 | </TR></TABLE>
|
---|
1470 | <H2> 8.4 Types </H2>
|
---|
1471 | <!--docid::SEC27::-->
|
---|
1472 | <P>
|
---|
1473 |
|
---|
1474 | The types are stored in a single 'int' variable. It was chosen in the
|
---|
1475 | first stages of development when tcc was much simpler. Now, it may not
|
---|
1476 | be the best solution.
|
---|
1477 | </P><P>
|
---|
1478 |
|
---|
1479 | <TABLE><tr><td> </td><td class=example><pre>#define VT_INT 0 /* integer type */
|
---|
1480 | #define VT_BYTE 1 /* signed byte type */
|
---|
1481 | #define VT_SHORT 2 /* short type */
|
---|
1482 | #define VT_VOID 3 /* void type */
|
---|
1483 | #define VT_PTR 4 /* pointer */
|
---|
1484 | #define VT_ENUM 5 /* enum definition */
|
---|
1485 | #define VT_FUNC 6 /* function type */
|
---|
1486 | #define VT_STRUCT 7 /* struct/union definition */
|
---|
1487 | #define VT_FLOAT 8 /* IEEE float */
|
---|
1488 | #define VT_DOUBLE 9 /* IEEE double */
|
---|
1489 | #define VT_LDOUBLE 10 /* IEEE long double */
|
---|
1490 | #define VT_BOOL 11 /* ISOC99 boolean type */
|
---|
1491 | #define VT_LLONG 12 /* 64 bit integer */
|
---|
1492 | #define VT_LONG 13 /* long integer (NEVER USED as type, only
|
---|
1493 | during parsing) */
|
---|
1494 | #define VT_BTYPE 0x000f /* mask for basic type */
|
---|
1495 | #define VT_UNSIGNED 0x0010 /* unsigned type */
|
---|
1496 | #define VT_ARRAY 0x0020 /* array type (also has VT_PTR) */
|
---|
1497 | #define VT_VLA 0x20000 /* VLA type (also has VT_PTR and VT_ARRAY) */
|
---|
1498 | #define VT_BITFIELD 0x0040 /* bitfield modifier */
|
---|
1499 | #define VT_CONSTANT 0x0800 /* const modifier */
|
---|
1500 | #define VT_VOLATILE 0x1000 /* volatile modifier */
|
---|
1501 | #define VT_DEFSIGN 0x2000 /* signed type */
|
---|
1502 |
|
---|
1503 | #define VT_STRUCT_SHIFT 18 /* structure/enum name shift (14 bits left) */
|
---|
1504 | </pre></td></tr></table></P><P>
|
---|
1505 |
|
---|
1506 | When a reference to another type is needed (for pointers, functions and
|
---|
1507 | structures), the <CODE>32 - VT_STRUCT_SHIFT</CODE> high order bits are used to
|
---|
1508 | store an identifier reference.
|
---|
1509 | </P><P>
|
---|
1510 |
|
---|
1511 | The <CODE>VT_UNSIGNED</CODE> flag can be set for chars, shorts, ints and long
|
---|
1512 | longs.
|
---|
1513 | </P><P>
|
---|
1514 |
|
---|
1515 | Arrays are considered as pointers <CODE>VT_PTR</CODE> with the flag
|
---|
1516 | <CODE>VT_ARRAY</CODE> set. Variable length arrays are considered as special
|
---|
1517 | arrays and have flag <CODE>VT_VLA</CODE> set instead of <CODE>VT_ARRAY</CODE>.
|
---|
1518 | </P><P>
|
---|
1519 |
|
---|
1520 | The <CODE>VT_BITFIELD</CODE> flag can be set for chars, shorts, ints and long
|
---|
1521 | longs. If it is set, then the bitfield position is stored from bits
|
---|
1522 | VT_STRUCT_SHIFT to VT_STRUCT_SHIFT + 5 and the bit field size is stored
|
---|
1523 | from bits VT_STRUCT_SHIFT + 6 to VT_STRUCT_SHIFT + 11.
|
---|
1524 | </P><P>
|
---|
1525 |
|
---|
1526 | <CODE>VT_LONG</CODE> is never used except during parsing.
|
---|
1527 | </P><P>
|
---|
1528 |
|
---|
1529 | During parsing, the storage of an object is also stored in the type
|
---|
1530 | integer:
|
---|
1531 | </P><P>
|
---|
1532 |
|
---|
1533 | <TABLE><tr><td> </td><td class=example><pre>#define VT_EXTERN 0x00000080 /* extern definition */
|
---|
1534 | #define VT_STATIC 0x00000100 /* static variable */
|
---|
1535 | #define VT_TYPEDEF 0x00000200 /* typedef definition */
|
---|
1536 | #define VT_INLINE 0x00000400 /* inline definition */
|
---|
1537 | #define VT_IMPORT 0x00004000 /* win32: extern data imported from dll */
|
---|
1538 | #define VT_EXPORT 0x00008000 /* win32: data exported from dll */
|
---|
1539 | #define VT_WEAK 0x00010000 /* win32: data exported from dll */
|
---|
1540 | </pre></td></tr></table></P><P>
|
---|
1541 |
|
---|
1542 | <HR SIZE="6">
|
---|
1543 | <A NAME="SEC28"></A>
|
---|
1544 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1545 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> < </A>]</TD>
|
---|
1546 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> > </A>]</TD>
|
---|
1547 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> << </A>]</TD>
|
---|
1548 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1549 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1550 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1551 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1552 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1553 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1554 | </TR></TABLE>
|
---|
1555 | <H2> 8.5 Symbols </H2>
|
---|
1556 | <!--docid::SEC28::-->
|
---|
1557 | <P>
|
---|
1558 |
|
---|
1559 | All symbols are stored in hashed symbol stacks. Each symbol stack
|
---|
1560 | contains <CODE>Sym</CODE> structures.
|
---|
1561 | </P><P>
|
---|
1562 |
|
---|
1563 | <CODE>Sym.v</CODE> contains the symbol name (remember
|
---|
1564 | an identifier is also a token, so a string is never necessary to store
|
---|
1565 | it). <CODE>Sym.t</CODE> gives the type of the symbol. <CODE>Sym.r</CODE> is usually
|
---|
1566 | the register in which the corresponding variable is stored. <CODE>Sym.c</CODE> is
|
---|
1567 | usually a constant associated to the symbol like its address for normal
|
---|
1568 | symbols, and the number of entries for symbols representing arrays.
|
---|
1569 | Variable length array types use <CODE>Sym.c</CODE> as a location on the stack
|
---|
1570 | which holds the runtime sizeof for the type.
|
---|
1571 | </P><P>
|
---|
1572 |
|
---|
1573 | Four main symbol stacks are defined:
|
---|
1574 | </P><P>
|
---|
1575 |
|
---|
1576 | <DL COMPACT>
|
---|
1577 |
|
---|
1578 | <DT><CODE>define_stack</CODE>
|
---|
1579 | <DD>for the macros (<CODE>#define</CODE>s).
|
---|
1580 | <P>
|
---|
1581 |
|
---|
1582 | <DT><CODE>global_stack</CODE>
|
---|
1583 | <DD>for the global variables, functions and types.
|
---|
1584 | <P>
|
---|
1585 |
|
---|
1586 | <DT><CODE>local_stack</CODE>
|
---|
1587 | <DD>for the local variables, functions and types.
|
---|
1588 | <P>
|
---|
1589 |
|
---|
1590 | <DT><CODE>global_label_stack</CODE>
|
---|
1591 | <DD>for the local labels (for <CODE>goto</CODE>).
|
---|
1592 | <P>
|
---|
1593 |
|
---|
1594 | <DT><CODE>label_stack</CODE>
|
---|
1595 | <DD>for GCC block local labels (see the <CODE>__label__</CODE> keyword).
|
---|
1596 | <P>
|
---|
1597 |
|
---|
1598 | </DL>
|
---|
1599 | <P>
|
---|
1600 |
|
---|
1601 | <CODE>sym_push()</CODE> is used to add a new symbol in the local symbol
|
---|
1602 | stack. If no local symbol stack is active, it is added in the global
|
---|
1603 | symbol stack.
|
---|
1604 | </P><P>
|
---|
1605 |
|
---|
1606 | <CODE>sym_pop(st,b)</CODE> pops symbols from the symbol stack <VAR>st</VAR> until
|
---|
1607 | the symbol <VAR>b</VAR> is on the top of stack. If <VAR>b</VAR> is NULL, the stack
|
---|
1608 | is emptied.
|
---|
1609 | </P><P>
|
---|
1610 |
|
---|
1611 | <CODE>sym_find(v)</CODE> return the symbol associated to the identifier
|
---|
1612 | <VAR>v</VAR>. The local stack is searched first from top to bottom, then the
|
---|
1613 | global stack.
|
---|
1614 | </P><P>
|
---|
1615 |
|
---|
1616 | <HR SIZE="6">
|
---|
1617 | <A NAME="SEC29"></A>
|
---|
1618 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1619 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> < </A>]</TD>
|
---|
1620 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> > </A>]</TD>
|
---|
1621 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> << </A>]</TD>
|
---|
1622 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1623 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1624 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1625 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1626 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1627 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1628 | </TR></TABLE>
|
---|
1629 | <H2> 8.6 Sections </H2>
|
---|
1630 | <!--docid::SEC29::-->
|
---|
1631 | <P>
|
---|
1632 |
|
---|
1633 | The generated code and data are written in sections. The structure
|
---|
1634 | <CODE>Section</CODE> contains all the necessary information for a given
|
---|
1635 | section. <CODE>new_section()</CODE> creates a new section. ELF file semantics
|
---|
1636 | is assumed for each section.
|
---|
1637 | </P><P>
|
---|
1638 |
|
---|
1639 | The following sections are predefined:
|
---|
1640 | </P><P>
|
---|
1641 |
|
---|
1642 | <DL COMPACT>
|
---|
1643 |
|
---|
1644 | <DT><CODE>text_section</CODE>
|
---|
1645 | <DD>is the section containing the generated code. <VAR>ind</VAR> contains the
|
---|
1646 | current position in the code section.
|
---|
1647 | <P>
|
---|
1648 |
|
---|
1649 | <DT><CODE>data_section</CODE>
|
---|
1650 | <DD>contains initialized data
|
---|
1651 | <P>
|
---|
1652 |
|
---|
1653 | <DT><CODE>bss_section</CODE>
|
---|
1654 | <DD>contains uninitialized data
|
---|
1655 | <P>
|
---|
1656 |
|
---|
1657 | <DT><CODE>bounds_section</CODE>
|
---|
1658 | <DD><DT><CODE>lbounds_section</CODE>
|
---|
1659 | <DD>are used when bound checking is activated
|
---|
1660 | <P>
|
---|
1661 |
|
---|
1662 | <DT><CODE>stab_section</CODE>
|
---|
1663 | <DD><DT><CODE>stabstr_section</CODE>
|
---|
1664 | <DD>are used when debugging is active to store debug information
|
---|
1665 | <P>
|
---|
1666 |
|
---|
1667 | <DT><CODE>symtab_section</CODE>
|
---|
1668 | <DD><DT><CODE>strtab_section</CODE>
|
---|
1669 | <DD>contain the exported symbols (currently only used for debugging).
|
---|
1670 | <P>
|
---|
1671 |
|
---|
1672 | </DL>
|
---|
1673 | <P>
|
---|
1674 |
|
---|
1675 | <HR SIZE="6">
|
---|
1676 | <A NAME="SEC30"></A>
|
---|
1677 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1678 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> < </A>]</TD>
|
---|
1679 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> > </A>]</TD>
|
---|
1680 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> << </A>]</TD>
|
---|
1681 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1682 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> >> </A>]</TD>
|
---|
1683 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1684 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1685 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1686 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1687 | </TR></TABLE>
|
---|
1688 | <H2> 8.7 Code generation </H2>
|
---|
1689 | <!--docid::SEC30::-->
|
---|
1690 | <P>
|
---|
1691 |
|
---|
1692 | <HR SIZE="6">
|
---|
1693 | <A NAME="SEC31"></A>
|
---|
1694 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1695 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> < </A>]</TD>
|
---|
1696 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC32"> > </A>]</TD>
|
---|
1697 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> << </A>]</TD>
|
---|
1698 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
|
---|
1699 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> >> </A>]</TD>
|
---|
1700 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1701 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1702 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1703 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1704 | </TR></TABLE>
|
---|
1705 | <H3> 8.7.1 Introduction </H3>
|
---|
1706 | <!--docid::SEC31::-->
|
---|
1707 | <P>
|
---|
1708 |
|
---|
1709 | The TCC code generator directly generates linked binary code in one
|
---|
1710 | pass. It is rather unusual these days (see gcc for example which
|
---|
1711 | generates text assembly), but it can be very fast and surprisingly
|
---|
1712 | little complicated.
|
---|
1713 | </P><P>
|
---|
1714 |
|
---|
1715 | The TCC code generator is register based. Optimization is only done at
|
---|
1716 | the expression level. No intermediate representation of expression is
|
---|
1717 | kept except the current values stored in the <EM>value stack</EM>.
|
---|
1718 | </P><P>
|
---|
1719 |
|
---|
1720 | On x86, three temporary registers are used. When more registers are
|
---|
1721 | needed, one register is spilled into a new temporary variable on the stack.
|
---|
1722 | </P><P>
|
---|
1723 |
|
---|
1724 | <HR SIZE="6">
|
---|
1725 | <A NAME="SEC32"></A>
|
---|
1726 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1727 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> < </A>]</TD>
|
---|
1728 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> > </A>]</TD>
|
---|
1729 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> << </A>]</TD>
|
---|
1730 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
|
---|
1731 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> >> </A>]</TD>
|
---|
1732 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1733 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1734 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1735 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1736 | </TR></TABLE>
|
---|
1737 | <H3> 8.7.2 The value stack </H3>
|
---|
1738 | <!--docid::SEC32::-->
|
---|
1739 | <P>
|
---|
1740 |
|
---|
1741 | When an expression is parsed, its value is pushed on the value stack
|
---|
1742 | (<VAR>vstack</VAR>). The top of the value stack is <VAR>vtop</VAR>. Each value
|
---|
1743 | stack entry is the structure <CODE>SValue</CODE>.
|
---|
1744 | </P><P>
|
---|
1745 |
|
---|
1746 | <CODE>SValue.t</CODE> is the type. <CODE>SValue.r</CODE> indicates how the value is
|
---|
1747 | currently stored in the generated code. It is usually a CPU register
|
---|
1748 | index (<CODE>REG_xxx</CODE> constants), but additional values and flags are
|
---|
1749 | defined:
|
---|
1750 | </P><P>
|
---|
1751 |
|
---|
1752 | <TABLE><tr><td> </td><td class=example><pre>#define VT_CONST 0x00f0
|
---|
1753 | #define VT_LLOCAL 0x00f1
|
---|
1754 | #define VT_LOCAL 0x00f2
|
---|
1755 | #define VT_CMP 0x00f3
|
---|
1756 | #define VT_JMP 0x00f4
|
---|
1757 | #define VT_JMPI 0x00f5
|
---|
1758 | #define VT_LVAL 0x0100
|
---|
1759 | #define VT_SYM 0x0200
|
---|
1760 | #define VT_MUSTCAST 0x0400
|
---|
1761 | #define VT_MUSTBOUND 0x0800
|
---|
1762 | #define VT_BOUNDED 0x8000
|
---|
1763 | #define VT_LVAL_BYTE 0x1000
|
---|
1764 | #define VT_LVAL_SHORT 0x2000
|
---|
1765 | #define VT_LVAL_UNSIGNED 0x4000
|
---|
1766 | #define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
|
---|
1767 | </pre></td></tr></table></P><P>
|
---|
1768 |
|
---|
1769 | <DL COMPACT>
|
---|
1770 |
|
---|
1771 | <DT><CODE>VT_CONST</CODE>
|
---|
1772 | <DD>indicates that the value is a constant. It is stored in the union
|
---|
1773 | <CODE>SValue.c</CODE>, depending on its type.
|
---|
1774 | <P>
|
---|
1775 |
|
---|
1776 | <DT><CODE>VT_LOCAL</CODE>
|
---|
1777 | <DD>indicates a local variable pointer at offset <CODE>SValue.c.i</CODE> in the
|
---|
1778 | stack.
|
---|
1779 | <P>
|
---|
1780 |
|
---|
1781 | <DT><CODE>VT_CMP</CODE>
|
---|
1782 | <DD>indicates that the value is actually stored in the CPU flags (i.e. the
|
---|
1783 | value is the consequence of a test). The value is either 0 or 1. The
|
---|
1784 | actual CPU flags used is indicated in <CODE>SValue.c.i</CODE>.
|
---|
1785 | <P>
|
---|
1786 |
|
---|
1787 | If any code is generated which destroys the CPU flags, this value MUST be
|
---|
1788 | put in a normal register.
|
---|
1789 | </P><P>
|
---|
1790 |
|
---|
1791 | <DT><CODE>VT_JMP</CODE>
|
---|
1792 | <DD><DT><CODE>VT_JMPI</CODE>
|
---|
1793 | <DD>indicates that the value is the consequence of a conditional jump. For VT_JMP,
|
---|
1794 | it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
|
---|
1795 | <P>
|
---|
1796 |
|
---|
1797 | These values are used to compile the <CODE>||</CODE> and <CODE>&&</CODE> logical
|
---|
1798 | operators.
|
---|
1799 | </P><P>
|
---|
1800 |
|
---|
1801 | If any code is generated, this value MUST be put in a normal
|
---|
1802 | register. Otherwise, the generated code won't be executed if the jump is
|
---|
1803 | taken.
|
---|
1804 | </P><P>
|
---|
1805 |
|
---|
1806 | <DT><CODE>VT_LVAL</CODE>
|
---|
1807 | <DD>is a flag indicating that the value is actually an lvalue (left value of
|
---|
1808 | an assignment). It means that the value stored is actually a pointer to
|
---|
1809 | the wanted value.
|
---|
1810 | <P>
|
---|
1811 |
|
---|
1812 | Understanding the use <CODE>VT_LVAL</CODE> is very important if you want to
|
---|
1813 | understand how TCC works.
|
---|
1814 | </P><P>
|
---|
1815 |
|
---|
1816 | <DT><CODE>VT_LVAL_BYTE</CODE>
|
---|
1817 | <DD><DT><CODE>VT_LVAL_SHORT</CODE>
|
---|
1818 | <DD><DT><CODE>VT_LVAL_UNSIGNED</CODE>
|
---|
1819 | <DD>if the lvalue has an integer type, then these flags give its real
|
---|
1820 | type. The type alone is not enough in case of cast optimisations.
|
---|
1821 | <P>
|
---|
1822 |
|
---|
1823 | <DT><CODE>VT_LLOCAL</CODE>
|
---|
1824 | <DD>is a saved lvalue on the stack. <CODE>VT_LVAL</CODE> must also be set with
|
---|
1825 | <CODE>VT_LLOCAL</CODE>. <CODE>VT_LLOCAL</CODE> can arise when a <CODE>VT_LVAL</CODE> in
|
---|
1826 | a register has to be saved to the stack, or it can come from an
|
---|
1827 | architecture-specific calling convention.
|
---|
1828 | <P>
|
---|
1829 |
|
---|
1830 | <DT><CODE>VT_MUSTCAST</CODE>
|
---|
1831 | <DD>indicates that a cast to the value type must be performed if the value
|
---|
1832 | is used (lazy casting).
|
---|
1833 | <P>
|
---|
1834 |
|
---|
1835 | <DT><CODE>VT_SYM</CODE>
|
---|
1836 | <DD>indicates that the symbol <CODE>SValue.sym</CODE> must be added to the constant.
|
---|
1837 | <P>
|
---|
1838 |
|
---|
1839 | <DT><CODE>VT_MUSTBOUND</CODE>
|
---|
1840 | <DD><DT><CODE>VT_BOUNDED</CODE>
|
---|
1841 | <DD>are only used for optional bound checking.
|
---|
1842 | <P>
|
---|
1843 |
|
---|
1844 | </DL>
|
---|
1845 | <P>
|
---|
1846 |
|
---|
1847 | <HR SIZE="6">
|
---|
1848 | <A NAME="SEC33"></A>
|
---|
1849 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1850 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC32"> < </A>]</TD>
|
---|
1851 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> > </A>]</TD>
|
---|
1852 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> << </A>]</TD>
|
---|
1853 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
|
---|
1854 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> >> </A>]</TD>
|
---|
1855 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1856 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1857 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1858 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1859 | </TR></TABLE>
|
---|
1860 | <H3> 8.7.3 Manipulating the value stack </H3>
|
---|
1861 | <!--docid::SEC33::-->
|
---|
1862 | <P>
|
---|
1863 |
|
---|
1864 | <CODE>vsetc()</CODE> and <CODE>vset()</CODE> pushes a new value on the value
|
---|
1865 | stack. If the previous <VAR>vtop</VAR> was stored in a very unsafe place(for
|
---|
1866 | example in the CPU flags), then some code is generated to put the
|
---|
1867 | previous <VAR>vtop</VAR> in a safe storage.
|
---|
1868 | </P><P>
|
---|
1869 |
|
---|
1870 | <CODE>vpop()</CODE> pops <VAR>vtop</VAR>. In some cases, it also generates cleanup
|
---|
1871 | code (for example if stacked floating point registers are used as on
|
---|
1872 | x86).
|
---|
1873 | </P><P>
|
---|
1874 |
|
---|
1875 | The <CODE>gv(rc)</CODE> function generates code to evaluate <VAR>vtop</VAR> (the
|
---|
1876 | top value of the stack) into registers. <VAR>rc</VAR> selects in which
|
---|
1877 | register class the value should be put. <CODE>gv()</CODE> is the <EM>most
|
---|
1878 | important function</EM> of the code generator.
|
---|
1879 | </P><P>
|
---|
1880 |
|
---|
1881 | <CODE>gv2()</CODE> is the same as <CODE>gv()</CODE> but for the top two stack
|
---|
1882 | entries.
|
---|
1883 | </P><P>
|
---|
1884 |
|
---|
1885 | <HR SIZE="6">
|
---|
1886 | <A NAME="SEC34"></A>
|
---|
1887 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1888 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> < </A>]</TD>
|
---|
1889 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> > </A>]</TD>
|
---|
1890 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> << </A>]</TD>
|
---|
1891 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
|
---|
1892 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> >> </A>]</TD>
|
---|
1893 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1894 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1895 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1896 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1897 | </TR></TABLE>
|
---|
1898 | <H3> 8.7.4 CPU dependent code generation </H3>
|
---|
1899 | <!--docid::SEC34::-->
|
---|
1900 | See the <TT>`i386-gen.c'</TT> file to have an example.
|
---|
1901 | <P>
|
---|
1902 |
|
---|
1903 | <DL COMPACT>
|
---|
1904 |
|
---|
1905 | <DT><CODE>load()</CODE>
|
---|
1906 | <DD>must generate the code needed to load a stack value into a register.
|
---|
1907 | <P>
|
---|
1908 |
|
---|
1909 | <DT><CODE>store()</CODE>
|
---|
1910 | <DD>must generate the code needed to store a register into a stack value
|
---|
1911 | lvalue.
|
---|
1912 | <P>
|
---|
1913 |
|
---|
1914 | <DT><CODE>gfunc_start()</CODE>
|
---|
1915 | <DD><DT><CODE>gfunc_param()</CODE>
|
---|
1916 | <DD><DT><CODE>gfunc_call()</CODE>
|
---|
1917 | <DD>should generate a function call
|
---|
1918 | <P>
|
---|
1919 |
|
---|
1920 | <DT><CODE>gfunc_prolog()</CODE>
|
---|
1921 | <DD><DT><CODE>gfunc_epilog()</CODE>
|
---|
1922 | <DD>should generate a function prolog/epilog.
|
---|
1923 | <P>
|
---|
1924 |
|
---|
1925 | <DT><CODE>gen_opi(op)</CODE>
|
---|
1926 | <DD>must generate the binary integer operation <VAR>op</VAR> on the two top
|
---|
1927 | entries of the stack which are guaranteed to contain integer types.
|
---|
1928 | <P>
|
---|
1929 |
|
---|
1930 | The result value should be put on the stack.
|
---|
1931 | </P><P>
|
---|
1932 |
|
---|
1933 | <DT><CODE>gen_opf(op)</CODE>
|
---|
1934 | <DD>same as <CODE>gen_opi()</CODE> for floating point operations. The two top
|
---|
1935 | entries of the stack are guaranteed to contain floating point values of
|
---|
1936 | same types.
|
---|
1937 | <P>
|
---|
1938 |
|
---|
1939 | <DT><CODE>gen_cvt_itof()</CODE>
|
---|
1940 | <DD>integer to floating point conversion.
|
---|
1941 | <P>
|
---|
1942 |
|
---|
1943 | <DT><CODE>gen_cvt_ftoi()</CODE>
|
---|
1944 | <DD>floating point to integer conversion.
|
---|
1945 | <P>
|
---|
1946 |
|
---|
1947 | <DT><CODE>gen_cvt_ftof()</CODE>
|
---|
1948 | <DD>floating point to floating point of different size conversion.
|
---|
1949 | <P>
|
---|
1950 |
|
---|
1951 | <DT><CODE>gen_bounded_ptr_add()</CODE>
|
---|
1952 | <DD><DT><CODE>gen_bounded_ptr_deref()</CODE>
|
---|
1953 | <DD>are only used for bounds checking.
|
---|
1954 | <P>
|
---|
1955 |
|
---|
1956 | </DL>
|
---|
1957 | <P>
|
---|
1958 |
|
---|
1959 | <HR SIZE="6">
|
---|
1960 | <A NAME="SEC35"></A>
|
---|
1961 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1962 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> < </A>]</TD>
|
---|
1963 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36"> > </A>]</TD>
|
---|
1964 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD>
|
---|
1965 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
|
---|
1966 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1967 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1968 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1969 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1970 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1971 | </TR></TABLE>
|
---|
1972 | <H2> 8.8 Optimizations done </H2>
|
---|
1973 | <!--docid::SEC35::-->
|
---|
1974 | Constant propagation is done for all operations. Multiplications and
|
---|
1975 | divisions are optimized to shifts when appropriate. Comparison
|
---|
1976 | operators are optimized by maintaining a special cache for the
|
---|
1977 | processor flags. &&, || and ! are optimized by maintaining a special
|
---|
1978 | 'jump target' value. No other jump optimization is currently performed
|
---|
1979 | because it would require to store the code in a more abstract fashion.
|
---|
1980 | <P>
|
---|
1981 |
|
---|
1982 | <HR SIZE="6">
|
---|
1983 | <A NAME="SEC36"></A>
|
---|
1984 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
1985 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> < </A>]</TD>
|
---|
1986 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ > ]</TD>
|
---|
1987 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD>
|
---|
1988 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
|
---|
1989 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD>
|
---|
1990 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
1991 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
1992 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
1993 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
1994 | </TR></TABLE>
|
---|
1995 | <H1> Concept Index </H1>
|
---|
1996 | <!--docid::SEC36::-->
|
---|
1997 | <table><tr><th valign=top>Jump to: </th><td><A HREF="tcc-doc.html#cp__" style="text-decoration:none"><b>_</b></A>
|
---|
1998 |
|
---|
1999 | <BR>
|
---|
2000 | <A HREF="tcc-doc.html#cp_A" style="text-decoration:none"><b>A</b></A>
|
---|
2001 |
|
---|
2002 | <A HREF="tcc-doc.html#cp_B" style="text-decoration:none"><b>B</b></A>
|
---|
2003 |
|
---|
2004 | <A HREF="tcc-doc.html#cp_C" style="text-decoration:none"><b>C</b></A>
|
---|
2005 |
|
---|
2006 | <A HREF="tcc-doc.html#cp_D" style="text-decoration:none"><b>D</b></A>
|
---|
2007 |
|
---|
2008 | <A HREF="tcc-doc.html#cp_E" style="text-decoration:none"><b>E</b></A>
|
---|
2009 |
|
---|
2010 | <A HREF="tcc-doc.html#cp_F" style="text-decoration:none"><b>F</b></A>
|
---|
2011 |
|
---|
2012 | <A HREF="tcc-doc.html#cp_G" style="text-decoration:none"><b>G</b></A>
|
---|
2013 |
|
---|
2014 | <A HREF="tcc-doc.html#cp_I" style="text-decoration:none"><b>I</b></A>
|
---|
2015 |
|
---|
2016 | <A HREF="tcc-doc.html#cp_J" style="text-decoration:none"><b>J</b></A>
|
---|
2017 |
|
---|
2018 | <A HREF="tcc-doc.html#cp_L" style="text-decoration:none"><b>L</b></A>
|
---|
2019 |
|
---|
2020 | <A HREF="tcc-doc.html#cp_M" style="text-decoration:none"><b>M</b></A>
|
---|
2021 |
|
---|
2022 | <A HREF="tcc-doc.html#cp_O" style="text-decoration:none"><b>O</b></A>
|
---|
2023 |
|
---|
2024 | <A HREF="tcc-doc.html#cp_P" style="text-decoration:none"><b>P</b></A>
|
---|
2025 |
|
---|
2026 | <A HREF="tcc-doc.html#cp_Q" style="text-decoration:none"><b>Q</b></A>
|
---|
2027 |
|
---|
2028 | <A HREF="tcc-doc.html#cp_R" style="text-decoration:none"><b>R</b></A>
|
---|
2029 |
|
---|
2030 | <A HREF="tcc-doc.html#cp_S" style="text-decoration:none"><b>S</b></A>
|
---|
2031 |
|
---|
2032 | <A HREF="tcc-doc.html#cp_T" style="text-decoration:none"><b>T</b></A>
|
---|
2033 |
|
---|
2034 | <A HREF="tcc-doc.html#cp_U" style="text-decoration:none"><b>U</b></A>
|
---|
2035 |
|
---|
2036 | <A HREF="tcc-doc.html#cp_V" style="text-decoration:none"><b>V</b></A>
|
---|
2037 |
|
---|
2038 | <A HREF="tcc-doc.html#cp_W" style="text-decoration:none"><b>W</b></A>
|
---|
2039 |
|
---|
2040 | </td></tr></table><br><P></P>
|
---|
2041 | <TABLE border=0>
|
---|
2042 | <TR><TD></TD><TH ALIGN=LEFT>Index Entry</TH><TH ALIGN=LEFT> Section</TH></TR>
|
---|
2043 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2044 | <TR><TH><A NAME="cp__"></A>_</TH><TD></TD><TD></TD></TR>
|
---|
2045 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX11">__asm__</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2046 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2047 | <TR><TH><A NAME="cp_A"></A>A</TH><TD></TD><TD></TD></TR>
|
---|
2048 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">align directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2049 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX1">aligned attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2050 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">ascii directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2051 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">asciz directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2052 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC15">assembler</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC15">4.5 X86 Assembler</A></TD></TR>
|
---|
2053 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">assembler directives</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2054 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX10">assembly, inline</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2055 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2056 | <TR><TH><A NAME="cp_B"></A>B</TH><TD></TD><TD></TD></TR>
|
---|
2057 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">bound checks</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD></TR>
|
---|
2058 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">bss directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2059 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">byte directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2060 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2061 | <TR><TH><A NAME="cp_C"></A>C</TH><TD></TD><TD></TD></TR>
|
---|
2062 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">caching processor flags</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
|
---|
2063 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX5">cdecl attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2064 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC30">code generation</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC30">8.7 Code generation</A></TD></TR>
|
---|
2065 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">comparison operators</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
|
---|
2066 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">constant propagation</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
|
---|
2067 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC34">CPU dependent</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC34">8.7.4 CPU dependent code generation</A></TD></TR>
|
---|
2068 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2069 | <TR><TH><A NAME="cp_D"></A>D</TH><TD></TD><TD></TD></TR>
|
---|
2070 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">data directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2071 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">directives, assembler</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2072 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX8">dllexport attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2073 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2074 | <TR><TH><A NAME="cp_E"></A>E</TH><TD></TD><TD></TD></TR>
|
---|
2075 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC17">ELF</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC17">5.1 ELF file generation</A></TD></TR>
|
---|
2076 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2077 | <TR><TH><A NAME="cp_F"></A>F</TH><TD></TD><TD></TD></TR>
|
---|
2078 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">FILE, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
|
---|
2079 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">fill directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2080 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">flags, caching</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
|
---|
2081 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2082 | <TR><TH><A NAME="cp_G"></A>G</TH><TD></TD><TD></TD></TR>
|
---|
2083 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX12">gas</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2084 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">global directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2085 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">globl directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2086 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">GROUP, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
|
---|
2087 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2088 | <TR><TH><A NAME="cp_I"></A>I</TH><TD></TD><TD></TD></TR>
|
---|
2089 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX9">inline assembly</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2090 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">int directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2091 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2092 | <TR><TH><A NAME="cp_J"></A>J</TH><TD></TD><TD></TD></TR>
|
---|
2093 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">jump optimization</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
|
---|
2094 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2095 | <TR><TH><A NAME="cp_L"></A>L</TH><TD></TD><TD></TD></TR>
|
---|
2096 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC16">linker</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A></TD></TR>
|
---|
2097 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">linker scripts</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
|
---|
2098 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">long directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2099 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2100 | <TR><TH><A NAME="cp_M"></A>M</TH><TD></TD><TD></TD></TR>
|
---|
2101 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">memory checks</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD></TR>
|
---|
2102 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2103 | <TR><TH><A NAME="cp_O"></A>O</TH><TD></TD><TD></TD></TR>
|
---|
2104 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">optimizations</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
|
---|
2105 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">org directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2106 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">OUTPUT_FORMAT, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
|
---|
2107 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2108 | <TR><TH><A NAME="cp_P"></A>P</TH><TD></TD><TD></TD></TR>
|
---|
2109 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX2">packed attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2110 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC19">PE-i386</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC19">5.3 PE-i386 file generation</A></TD></TR>
|
---|
2111 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">previous directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2112 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2113 | <TR><TH><A NAME="cp_Q"></A>Q</TH><TD></TD><TD></TD></TR>
|
---|
2114 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">quad directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2115 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2116 | <TR><TH><A NAME="cp_R"></A>R</TH><TD></TD><TD></TD></TR>
|
---|
2117 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX7">regparm attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2118 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2119 | <TR><TH><A NAME="cp_S"></A>S</TH><TD></TD><TD></TD></TR>
|
---|
2120 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">scripts, linker</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
|
---|
2121 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX3">section attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2122 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">section directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2123 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">short directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2124 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">skip directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2125 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">space directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2126 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX6">stdcall attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2127 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">strength reduction</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
|
---|
2128 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">string directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2129 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2130 | <TR><TH><A NAME="cp_T"></A>T</TH><TD></TD><TD></TD></TR>
|
---|
2131 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">TARGET, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
|
---|
2132 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">text directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2133 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2134 | <TR><TH><A NAME="cp_U"></A>U</TH><TD></TD><TD></TD></TR>
|
---|
2135 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX4">unused attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
|
---|
2136 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2137 | <TR><TH><A NAME="cp_V"></A>V</TH><TD></TD><TD></TD></TR>
|
---|
2138 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC33">value stack</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC33">8.7.3 Manipulating the value stack</A></TD></TR>
|
---|
2139 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC32">value stack, introduction</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC32">8.7.2 The value stack</A></TD></TR>
|
---|
2140 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2141 | <TR><TH><A NAME="cp_W"></A>W</TH><TD></TD><TD></TD></TR>
|
---|
2142 | <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">word directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
|
---|
2143 | <TR><TD COLSPAN=3> <HR></TD></TR>
|
---|
2144 | </TABLE><P></P><table><tr><th valign=top>Jump to: </th><td><A HREF="tcc-doc.html#cp__" style="text-decoration:none"><b>_</b></A>
|
---|
2145 |
|
---|
2146 | <BR>
|
---|
2147 | <A HREF="tcc-doc.html#cp_A" style="text-decoration:none"><b>A</b></A>
|
---|
2148 |
|
---|
2149 | <A HREF="tcc-doc.html#cp_B" style="text-decoration:none"><b>B</b></A>
|
---|
2150 |
|
---|
2151 | <A HREF="tcc-doc.html#cp_C" style="text-decoration:none"><b>C</b></A>
|
---|
2152 |
|
---|
2153 | <A HREF="tcc-doc.html#cp_D" style="text-decoration:none"><b>D</b></A>
|
---|
2154 |
|
---|
2155 | <A HREF="tcc-doc.html#cp_E" style="text-decoration:none"><b>E</b></A>
|
---|
2156 |
|
---|
2157 | <A HREF="tcc-doc.html#cp_F" style="text-decoration:none"><b>F</b></A>
|
---|
2158 |
|
---|
2159 | <A HREF="tcc-doc.html#cp_G" style="text-decoration:none"><b>G</b></A>
|
---|
2160 |
|
---|
2161 | <A HREF="tcc-doc.html#cp_I" style="text-decoration:none"><b>I</b></A>
|
---|
2162 |
|
---|
2163 | <A HREF="tcc-doc.html#cp_J" style="text-decoration:none"><b>J</b></A>
|
---|
2164 |
|
---|
2165 | <A HREF="tcc-doc.html#cp_L" style="text-decoration:none"><b>L</b></A>
|
---|
2166 |
|
---|
2167 | <A HREF="tcc-doc.html#cp_M" style="text-decoration:none"><b>M</b></A>
|
---|
2168 |
|
---|
2169 | <A HREF="tcc-doc.html#cp_O" style="text-decoration:none"><b>O</b></A>
|
---|
2170 |
|
---|
2171 | <A HREF="tcc-doc.html#cp_P" style="text-decoration:none"><b>P</b></A>
|
---|
2172 |
|
---|
2173 | <A HREF="tcc-doc.html#cp_Q" style="text-decoration:none"><b>Q</b></A>
|
---|
2174 |
|
---|
2175 | <A HREF="tcc-doc.html#cp_R" style="text-decoration:none"><b>R</b></A>
|
---|
2176 |
|
---|
2177 | <A HREF="tcc-doc.html#cp_S" style="text-decoration:none"><b>S</b></A>
|
---|
2178 |
|
---|
2179 | <A HREF="tcc-doc.html#cp_T" style="text-decoration:none"><b>T</b></A>
|
---|
2180 |
|
---|
2181 | <A HREF="tcc-doc.html#cp_U" style="text-decoration:none"><b>U</b></A>
|
---|
2182 |
|
---|
2183 | <A HREF="tcc-doc.html#cp_V" style="text-decoration:none"><b>V</b></A>
|
---|
2184 |
|
---|
2185 | <A HREF="tcc-doc.html#cp_W" style="text-decoration:none"><b>W</b></A>
|
---|
2186 |
|
---|
2187 | </td></tr></table><br><P>
|
---|
2188 |
|
---|
2189 | <HR SIZE="6">
|
---|
2190 | <A NAME="SEC_Contents"></A>
|
---|
2191 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
2192 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
2193 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
2194 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
2195 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
2196 | </TR></TABLE>
|
---|
2197 | <H1>Table of Contents</H1>
|
---|
2198 | <UL>
|
---|
2199 | <A NAME="TOC1" HREF="tcc-doc.html#SEC1">1. Introduction</A>
|
---|
2200 | <BR>
|
---|
2201 | <A NAME="TOC2" HREF="tcc-doc.html#SEC2">2. Command line invocation</A>
|
---|
2202 | <BR>
|
---|
2203 | <UL>
|
---|
2204 | <A NAME="TOC3" HREF="tcc-doc.html#SEC3">2.1 Quick start</A>
|
---|
2205 | <BR>
|
---|
2206 | <A NAME="TOC4" HREF="tcc-doc.html#SEC4">2.2 Option summary</A>
|
---|
2207 | <BR>
|
---|
2208 | </UL>
|
---|
2209 | <A NAME="TOC5" HREF="tcc-doc.html#SEC5">3. C language support</A>
|
---|
2210 | <BR>
|
---|
2211 | <UL>
|
---|
2212 | <A NAME="TOC6" HREF="tcc-doc.html#SEC6">3.1 ANSI C</A>
|
---|
2213 | <BR>
|
---|
2214 | <A NAME="TOC7" HREF="tcc-doc.html#SEC7">3.2 ISOC99 extensions</A>
|
---|
2215 | <BR>
|
---|
2216 | <A NAME="TOC8" HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A>
|
---|
2217 | <BR>
|
---|
2218 | <A NAME="TOC9" HREF="tcc-doc.html#SEC9">3.4 TinyCC extensions</A>
|
---|
2219 | <BR>
|
---|
2220 | </UL>
|
---|
2221 | <A NAME="TOC10" HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A>
|
---|
2222 | <BR>
|
---|
2223 | <UL>
|
---|
2224 | <A NAME="TOC11" HREF="tcc-doc.html#SEC11">4.1 Syntax</A>
|
---|
2225 | <BR>
|
---|
2226 | <A NAME="TOC12" HREF="tcc-doc.html#SEC12">4.2 Expressions</A>
|
---|
2227 | <BR>
|
---|
2228 | <A NAME="TOC13" HREF="tcc-doc.html#SEC13">4.3 Labels</A>
|
---|
2229 | <BR>
|
---|
2230 | <A NAME="TOC14" HREF="tcc-doc.html#SEC14">4.4 Directives</A>
|
---|
2231 | <BR>
|
---|
2232 | <A NAME="TOC15" HREF="tcc-doc.html#SEC15">4.5 X86 Assembler</A>
|
---|
2233 | <BR>
|
---|
2234 | </UL>
|
---|
2235 | <A NAME="TOC16" HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A>
|
---|
2236 | <BR>
|
---|
2237 | <UL>
|
---|
2238 | <A NAME="TOC17" HREF="tcc-doc.html#SEC17">5.1 ELF file generation</A>
|
---|
2239 | <BR>
|
---|
2240 | <A NAME="TOC18" HREF="tcc-doc.html#SEC18">5.2 ELF file loader</A>
|
---|
2241 | <BR>
|
---|
2242 | <A NAME="TOC19" HREF="tcc-doc.html#SEC19">5.3 PE-i386 file generation</A>
|
---|
2243 | <BR>
|
---|
2244 | <A NAME="TOC20" HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A>
|
---|
2245 | <BR>
|
---|
2246 | </UL>
|
---|
2247 | <A NAME="TOC21" HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>
|
---|
2248 | <BR>
|
---|
2249 | <A NAME="TOC22" HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>
|
---|
2250 | <BR>
|
---|
2251 | <A NAME="TOC23" HREF="tcc-doc.html#SEC23">8. Developer's guide</A>
|
---|
2252 | <BR>
|
---|
2253 | <UL>
|
---|
2254 | <A NAME="TOC24" HREF="tcc-doc.html#SEC24">8.1 File reading</A>
|
---|
2255 | <BR>
|
---|
2256 | <A NAME="TOC25" HREF="tcc-doc.html#SEC25">8.2 Lexer</A>
|
---|
2257 | <BR>
|
---|
2258 | <A NAME="TOC26" HREF="tcc-doc.html#SEC26">8.3 Parser</A>
|
---|
2259 | <BR>
|
---|
2260 | <A NAME="TOC27" HREF="tcc-doc.html#SEC27">8.4 Types</A>
|
---|
2261 | <BR>
|
---|
2262 | <A NAME="TOC28" HREF="tcc-doc.html#SEC28">8.5 Symbols</A>
|
---|
2263 | <BR>
|
---|
2264 | <A NAME="TOC29" HREF="tcc-doc.html#SEC29">8.6 Sections</A>
|
---|
2265 | <BR>
|
---|
2266 | <A NAME="TOC30" HREF="tcc-doc.html#SEC30">8.7 Code generation</A>
|
---|
2267 | <BR>
|
---|
2268 | <UL>
|
---|
2269 | <A NAME="TOC31" HREF="tcc-doc.html#SEC31">8.7.1 Introduction</A>
|
---|
2270 | <BR>
|
---|
2271 | <A NAME="TOC32" HREF="tcc-doc.html#SEC32">8.7.2 The value stack</A>
|
---|
2272 | <BR>
|
---|
2273 | <A NAME="TOC33" HREF="tcc-doc.html#SEC33">8.7.3 Manipulating the value stack</A>
|
---|
2274 | <BR>
|
---|
2275 | <A NAME="TOC34" HREF="tcc-doc.html#SEC34">8.7.4 CPU dependent code generation</A>
|
---|
2276 | <BR>
|
---|
2277 | </UL>
|
---|
2278 | <A NAME="TOC35" HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A>
|
---|
2279 | <BR>
|
---|
2280 | </UL>
|
---|
2281 | <A NAME="TOC36" HREF="tcc-doc.html#SEC36">Concept Index</A>
|
---|
2282 | <BR>
|
---|
2283 | </UL>
|
---|
2284 | <HR SIZE=1>
|
---|
2285 | <A NAME="SEC_OVERVIEW"></A>
|
---|
2286 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
2287 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
2288 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
2289 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
2290 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
2291 | </TR></TABLE>
|
---|
2292 | <H1>Short Table of Contents</H1>
|
---|
2293 | <BLOCKQUOTE>
|
---|
2294 | <A NAME="TOC1" HREF="tcc-doc.html#SEC1">1. Introduction</A>
|
---|
2295 | <BR>
|
---|
2296 | <A NAME="TOC2" HREF="tcc-doc.html#SEC2">2. Command line invocation</A>
|
---|
2297 | <BR>
|
---|
2298 | <A NAME="TOC5" HREF="tcc-doc.html#SEC5">3. C language support</A>
|
---|
2299 | <BR>
|
---|
2300 | <A NAME="TOC10" HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A>
|
---|
2301 | <BR>
|
---|
2302 | <A NAME="TOC16" HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A>
|
---|
2303 | <BR>
|
---|
2304 | <A NAME="TOC21" HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>
|
---|
2305 | <BR>
|
---|
2306 | <A NAME="TOC22" HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>
|
---|
2307 | <BR>
|
---|
2308 | <A NAME="TOC23" HREF="tcc-doc.html#SEC23">8. Developer's guide</A>
|
---|
2309 | <BR>
|
---|
2310 | <A NAME="TOC36" HREF="tcc-doc.html#SEC36">Concept Index</A>
|
---|
2311 | <BR>
|
---|
2312 |
|
---|
2313 | </BLOCKQUOTE>
|
---|
2314 | <HR SIZE=1>
|
---|
2315 | <A NAME="SEC_About"></A>
|
---|
2316 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
---|
2317 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
|
---|
2318 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
|
---|
2319 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
|
---|
2320 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
|
---|
2321 | </TR></TABLE>
|
---|
2322 | <H1>About this document</H1>
|
---|
2323 | This document was generated on <I>December, 17 2017</I>
|
---|
2324 | using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
|
---|
2325 | "><I>texi2html</I></A>
|
---|
2326 | <P></P>
|
---|
2327 | The buttons in the navigation panels have the following meaning:
|
---|
2328 | <P></P>
|
---|
2329 | <table border = "1">
|
---|
2330 | <TR>
|
---|
2331 | <TH> Button </TH>
|
---|
2332 | <TH> Name </TH>
|
---|
2333 | <TH> Go to </TH>
|
---|
2334 | <TH> From 1.2.3 go to</TH>
|
---|
2335 | </TR>
|
---|
2336 | <TR>
|
---|
2337 | <TD ALIGN="CENTER">
|
---|
2338 | [ < ] </TD>
|
---|
2339 | <TD ALIGN="CENTER">
|
---|
2340 | Back
|
---|
2341 | </TD>
|
---|
2342 | <TD>
|
---|
2343 | previous section in reading order
|
---|
2344 | </TD>
|
---|
2345 | <TD>
|
---|
2346 | 1.2.2
|
---|
2347 | </TD>
|
---|
2348 | </TR>
|
---|
2349 | <TR>
|
---|
2350 | <TD ALIGN="CENTER">
|
---|
2351 | [ > ] </TD>
|
---|
2352 | <TD ALIGN="CENTER">
|
---|
2353 | Forward
|
---|
2354 | </TD>
|
---|
2355 | <TD>
|
---|
2356 | next section in reading order
|
---|
2357 | </TD>
|
---|
2358 | <TD>
|
---|
2359 | 1.2.4
|
---|
2360 | </TD>
|
---|
2361 | </TR>
|
---|
2362 | <TR>
|
---|
2363 | <TD ALIGN="CENTER">
|
---|
2364 | [ << ] </TD>
|
---|
2365 | <TD ALIGN="CENTER">
|
---|
2366 | FastBack
|
---|
2367 | </TD>
|
---|
2368 | <TD>
|
---|
2369 | previous or up-and-previous section
|
---|
2370 | </TD>
|
---|
2371 | <TD>
|
---|
2372 | 1.1
|
---|
2373 | </TD>
|
---|
2374 | </TR>
|
---|
2375 | <TR>
|
---|
2376 | <TD ALIGN="CENTER">
|
---|
2377 | [ Up ] </TD>
|
---|
2378 | <TD ALIGN="CENTER">
|
---|
2379 | Up
|
---|
2380 | </TD>
|
---|
2381 | <TD>
|
---|
2382 | up section
|
---|
2383 | </TD>
|
---|
2384 | <TD>
|
---|
2385 | 1.2
|
---|
2386 | </TD>
|
---|
2387 | </TR>
|
---|
2388 | <TR>
|
---|
2389 | <TD ALIGN="CENTER">
|
---|
2390 | [ >> ] </TD>
|
---|
2391 | <TD ALIGN="CENTER">
|
---|
2392 | FastForward
|
---|
2393 | </TD>
|
---|
2394 | <TD>
|
---|
2395 | next or up-and-next section
|
---|
2396 | </TD>
|
---|
2397 | <TD>
|
---|
2398 | 1.3
|
---|
2399 | </TD>
|
---|
2400 | </TR>
|
---|
2401 | <TR>
|
---|
2402 | <TD ALIGN="CENTER">
|
---|
2403 | [Top] </TD>
|
---|
2404 | <TD ALIGN="CENTER">
|
---|
2405 | Top
|
---|
2406 | </TD>
|
---|
2407 | <TD>
|
---|
2408 | cover (top) of document
|
---|
2409 | </TD>
|
---|
2410 | <TD>
|
---|
2411 |
|
---|
2412 | </TD>
|
---|
2413 | </TR>
|
---|
2414 | <TR>
|
---|
2415 | <TD ALIGN="CENTER">
|
---|
2416 | [Contents] </TD>
|
---|
2417 | <TD ALIGN="CENTER">
|
---|
2418 | Contents
|
---|
2419 | </TD>
|
---|
2420 | <TD>
|
---|
2421 | table of contents
|
---|
2422 | </TD>
|
---|
2423 | <TD>
|
---|
2424 |
|
---|
2425 | </TD>
|
---|
2426 | </TR>
|
---|
2427 | <TR>
|
---|
2428 | <TD ALIGN="CENTER">
|
---|
2429 | [Index] </TD>
|
---|
2430 | <TD ALIGN="CENTER">
|
---|
2431 | Index
|
---|
2432 | </TD>
|
---|
2433 | <TD>
|
---|
2434 | concept index
|
---|
2435 | </TD>
|
---|
2436 | <TD>
|
---|
2437 |
|
---|
2438 | </TD>
|
---|
2439 | </TR>
|
---|
2440 | <TR>
|
---|
2441 | <TD ALIGN="CENTER">
|
---|
2442 | [ ? ] </TD>
|
---|
2443 | <TD ALIGN="CENTER">
|
---|
2444 | About
|
---|
2445 | </TD>
|
---|
2446 | <TD>
|
---|
2447 | this page
|
---|
2448 | </TD>
|
---|
2449 | <TD>
|
---|
2450 |
|
---|
2451 | </TD>
|
---|
2452 | </TR>
|
---|
2453 | </TABLE>
|
---|
2454 | <P></P>
|
---|
2455 | where the <STRONG> Example </STRONG> assumes that the current position
|
---|
2456 | is at <STRONG> Subsubsection One-Two-Three </STRONG> of a document of
|
---|
2457 | the following structure:
|
---|
2458 | <UL>
|
---|
2459 | <LI> 1. Section One </LI>
|
---|
2460 | <UL>
|
---|
2461 | <LI>1.1 Subsection One-One</LI>
|
---|
2462 | <UL>
|
---|
2463 | <LI> ... </LI>
|
---|
2464 | </UL>
|
---|
2465 | <LI>1.2 Subsection One-Two</LI>
|
---|
2466 | <UL>
|
---|
2467 | <LI>1.2.1 Subsubsection One-Two-One
|
---|
2468 | </LI><LI>1.2.2 Subsubsection One-Two-Two
|
---|
2469 | </LI><LI>1.2.3 Subsubsection One-Two-Three <STRONG>
|
---|
2470 | <== Current Position </STRONG>
|
---|
2471 | </LI><LI>1.2.4 Subsubsection One-Two-Four
|
---|
2472 | </LI></UL>
|
---|
2473 | <LI>1.3 Subsection One-Three</LI>
|
---|
2474 | <UL>
|
---|
2475 | <LI> ... </LI>
|
---|
2476 | </UL>
|
---|
2477 | <LI>1.4 Subsection One-Four</LI>
|
---|
2478 | </UL>
|
---|
2479 | </UL>
|
---|
2480 |
|
---|
2481 | <HR SIZE=1>
|
---|
2482 | <BR>
|
---|
2483 | <FONT SIZE="-1">
|
---|
2484 | This document was generated
|
---|
2485 | on <I>December, 17 2017</I>
|
---|
2486 | using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
|
---|
2487 | "><I>texi2html</I></A>
|
---|
2488 |
|
---|
2489 | </BODY>
|
---|
2490 | </HTML>
|
---|