Table in section 2.2 looks better now
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
3 \textclass article
4 \begin_preamble
5 \usepackage[
6   pdftitle={SDCC Compiler User Guide},
7   pdfauthor={SDCC development team},
8   pdfsubject={installation, user manual},
9   pdfkeywords={8032, 8051, ansi, c, compiler, CPU, DS390, 
10                embedded, GPL, manual, mcs51, PIC, small, Z80},
11   colorlinks=true,
12   linkcolor=blue] {hyperref}
13 \date{}
14 \end_preamble
15 \language english
16 \inputencoding default
17 \fontscheme pslatex
18 \graphics default
19 \paperfontsize default
20 \spacing single 
21 \papersize Default
22 \paperpackage a4
23 \use_geometry 1
24 \use_amsmath 0
25 \use_natbib 0
26 \use_numerical_citations 0
27 \paperorientation portrait
28 \leftmargin 30mm
29 \topmargin 10mm
30 \rightmargin 25mm
31 \bottommargin 15mm
32 \secnumdepth 3
33 \tocdepth 3
34 \paragraph_separation indent
35 \defskip medskip
36 \quotes_language swedish
37 \quotes_times 2
38 \papercolumns 1
39 \papersides 1
40 \paperpagestyle fancy
41
42 \layout Comment
43
44 Please note: double dashed longoptions (e.g.
45  --version) are written this way: -
46 \begin_inset ERT
47 status Collapsed
48
49 \layout Standard
50
51 \backslash 
52 /
53 \end_inset 
54
55 -
56 \layout Comment
57
58 Two resp.
59  three consecutive dashes simply result in a long resp.
60  extra long dash.
61 \layout Title
62
63 SDCC Compiler User Guide
64 \layout Standard
65 \align center 
66 2003-06-02
67 \layout Comment
68
69 The strings enclosed in $ are automatically updated by cvs:
70 \layout Standard
71 \align center 
72
73 \size scriptsize 
74 cvs: $Revision$ $Date$
75 \layout Standard
76
77
78 \begin_inset LatexCommand \tableofcontents{}
79
80 \end_inset 
81
82
83 \layout Section
84 \pagebreak_top 
85 Introduction
86 \layout Subsection
87
88 About SDCC
89 \layout Standard
90
91
92 \series bold 
93 SDCC
94 \series default 
95  is a Freeware, retargettable, optimizing ANSI-C compiler by 
96 \series bold 
97 Sandeep Dutta
98 \series default 
99  designed for 8 bit Microprocessors.
100  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
101  8051, 8052
102 \begin_inset LatexCommand \index{8031, 8032, 8051, 8052 CPU}
103
104 \end_inset 
105
106 , etc), Zilog Z80 based MCUs, and the Dallas DS80C390 variant.
107  It can be retargetted for other microprocessors, support for PIC, AVR and
108  186 is under development.
109  The entire source code for the compiler is distributed under GPL.
110  SDCC uses ASXXXX & ASLINK, a Freeware, retargettable assembler & linker.
111  SDCC has extensive language extensions suitable for utilizing various microcont
112 rollers and underlying hardware effectively.
113  
114 \newline 
115
116 \newline 
117 In addition to the MCU specific optimizations SDCC also does a host of standard
118  optimizations like:
119 \layout Itemize
120
121 global sub expression elimination, 
122 \layout Itemize
123
124 loop optimizations (loop invariant, strength reduction of induction variables
125  and loop reversing), 
126 \layout Itemize
127
128 constant folding & propagation, 
129 \layout Itemize
130
131 copy propagation, 
132 \layout Itemize
133
134 dead code elimination 
135 \layout Itemize
136
137 jump tables for 
138 \emph on 
139 switch
140 \emph default 
141  statements.
142 \layout Standard
143
144 For the back-end SDCC uses a global register allocation scheme which should
145  be well suited for other 8 bit MCUs.
146  
147 \newline 
148
149 \newline 
150 The peep hole optimizer uses a rule based substitution mechanism which is
151  MCU independent.
152  
153 \newline 
154
155 \newline 
156 Supported data-types are:
157 \layout Itemize
158
159 char (8 bits, 1 byte), 
160 \layout Itemize
161
162 short and int (16 bits, 2 bytes), 
163 \layout Itemize
164
165 long (32 bit, 4 bytes)
166 \layout Itemize
167
168 float (4 byte IEEE).
169  
170 \layout Standard
171
172 The compiler also allows 
173 \emph on 
174 inline assembler code
175 \emph default 
176  to be embedded anywhere in a function.
177  In addition, routines developed in assembly can also be called.
178 \newline 
179
180 \newline 
181 SDCC also provides an option (-
182 \begin_inset ERT
183 status Collapsed
184
185 \layout Standard
186
187 \backslash 
188 /
189 \end_inset 
190
191 -cyclomatic) to report the relative complexity of a function.
192  These functions can then be further optimized, or hand coded in assembly
193  if needed.
194  
195 \newline 
196
197 \newline 
198 SDCC also comes with a companion source level debugger SDCDB, the debugger
199  currently uses ucSim a freeware simulator for 8051 and other micro-controllers.
200  
201 \newline 
202
203 \newline 
204 The latest version can be downloaded from 
205 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
206
207 \end_inset 
208
209 .
210
211 \series bold 
212  
213 \series default 
214 \emph on 
215 Please note: the compiler will probably always be some steps ahead of this
216  documentation
217 \series bold 
218 \emph default 
219
220 \begin_inset LatexCommand \index{Status of documentation}
221
222 \end_inset 
223
224
225 \begin_inset Foot
226 collapsed false
227
228 \layout Standard
229
230 Obviously this has pros and cons
231 \end_inset 
232
233 .
234 \layout Subsection
235
236 Open Source
237 \layout Standard
238
239 All packages used in this compiler system are 
240 \emph on 
241 opensource
242 \emph default 
243  and 
244 \emph on 
245 freeware
246 \emph default 
247 ; source code for all the sub-packages (pre-processor, assemblers, linkers
248  etc) is distributed with the package.
249  This documentation is maintained using a freeware word processor (LyX).
250 \newline 
251 This program is free software; you can redistribute it and/or modify it
252  under the terms of the GNU General Public License
253 \begin_inset LatexCommand \index{GNU General Public License, GPL}
254
255 \end_inset 
256
257  as published by the Free Software Foundation; either version 2, or (at
258  your option) any later version.
259  This program is distributed in the hope that it will be useful, but WITHOUT
260  ANY WARRANTY; without even the implied warranty
261 \begin_inset LatexCommand \index{warranty}
262
263 \end_inset 
264
265  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
266  See the GNU General Public License for more details.
267  You should have received a copy of the GNU General Public License along
268  with this program; if not, write to the Free Software Foundation, 59 Temple
269  Place - Suite 330, Boston, MA 02111-1307, USA.
270  In other words, you are welcome to use, share and improve this program.
271  You are forbidden to forbid anyone else to use, share and improve what
272  you give them.
273  Help stamp out software-hoarding! 
274 \layout Subsection
275
276 Typographic conventions
277 \begin_inset LatexCommand \index{Typographic conventions}
278
279 \end_inset 
280
281
282 \layout Standard
283
284 Throughout this manual, we will use the following convention.
285  Commands you have to type in are printed in 
286 \family sans 
287 \series bold 
288 "sans serif"
289 \series default 
290 .
291
292 \family default 
293  Code samples are printed in 
294 \family typewriter 
295 typewriter font.
296
297 \family default 
298  Interesting items and new terms are printed in 
299 \emph on 
300 italic.
301 \layout Subsection
302
303 Compatibility with previous versions
304 \layout Standard
305
306 This version has numerous bug fixes compared with the previous version.
307  But we also introduced some incompatibilities with older versions.
308  Not just for the fun of it, but to make the compiler more stable, efficient
309  and ANSI compliant
310 \begin_inset LatexCommand \index{ANSI-compliance}
311
312 \end_inset 
313
314 .
315  
316 \newline 
317
318 \layout Itemize
319
320 short is now equivalent to int (16 bits), it used to be equivalent to char
321  (8 bits) which is not ANSI compliant
322 \layout Itemize
323
324 the default directory for gcc-builds where include, library and documentation
325  files are stored is now in /usr/local/share
326 \layout Itemize
327
328 char type parameters to vararg functions are casted to int unless explicitly
329  casted, e.g.: 
330 \newline 
331
332 \family typewriter 
333 \SpecialChar ~
334 \SpecialChar ~
335 char a=3;
336 \newline 
337 \SpecialChar ~
338 \SpecialChar ~
339 printf ("%d %c
340 \backslash 
341 n", a, (char)a);
342 \family default 
343
344 \newline 
345  will push a as an int and as a char resp.
346 \layout Itemize
347
348 option -
349 \begin_inset ERT
350 status Collapsed
351
352 \layout Standard
353
354 \backslash 
355 /
356 \end_inset 
357
358 -regextend has been removed
359 \layout Itemize
360
361 option -
362 \begin_inset ERT
363 status Collapsed
364
365 \layout Standard
366
367 \backslash 
368 /
369 \end_inset 
370
371 -noregparms has been removed
372 \layout Itemize
373
374 option -
375 \begin_inset ERT
376 status Collapsed
377
378 \layout Standard
379
380 \backslash 
381 /
382 \end_inset 
383
384 -stack-after-data has been removed
385 \layout Standard
386
387
388 \emph on 
389 <pending: more incompatibilities?>
390 \layout Subsection
391
392 System Requirements
393 \layout Standard
394
395 What do you need before you start installation of SDCC? A computer, and
396  a desire to compute.
397  The preferred method of installation is to compile SDCC from source using
398  GNU gcc and make.
399  For Windows some pre-compiled binary distributions are available for your
400  convenience.
401  You should have some experience with command line tools and compiler use.
402 \layout Subsection
403
404 Other Resources
405 \layout Standard
406
407 The SDCC home page at 
408 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
409
410 \end_inset 
411
412  is a great place to find distribution sets.
413  You can also find links to the user mailing lists that offer help or discuss
414  SDCC with other SDCC users.
415  Web links to other SDCC related sites can also be found here.
416  This document can be found in the DOC directory of the source package as
417  a text or HTML file.
418  Some of the other tools (simulator and assembler) included with SDCC contain
419  their own documentation and can be found in the source distribution.
420  If you want the latest unreleased software, the complete source package
421  is available directly by anonymous CVS on cvs.sdcc.sourceforge.net.
422 \layout Comment
423
424 ANSI C reference / related tools / recommended reading / compiler building:
425  Muchnik?
426 \layout Subsection
427
428 Wishes for the future
429 \layout Standard
430
431 There are (and always will be) some things that could be done.
432  Here are some I can think of:
433 \newline 
434
435 \layout Standard
436
437
438 \family typewriter 
439 char KernelFunction3(char p) at 0x340;
440 \newline 
441
442 \layout Standard
443
444
445 \family typewriter 
446 code banking
447 \begin_inset LatexCommand \index{code banking (not supported)}
448
449 \end_inset 
450
451  support for mcs51
452 \newline 
453
454 \family default 
455 If you can think of some more, please see the chapter 9 about filing feature
456  requests
457 \begin_inset LatexCommand \index{Requesting features}
458
459 \end_inset 
460
461
462 \begin_inset LatexCommand \index{Feature request}
463
464 \end_inset 
465
466 .
467 \newline 
468
469 \layout Section
470 \pagebreak_top 
471 Installation
472 \begin_inset LatexCommand \index{Installation}
473
474 \end_inset 
475
476
477 \layout Subsection
478
479 Configure Options
480 \begin_inset LatexCommand \index{Options SDCC configuration}
481
482 \end_inset 
483
484
485 \layout Standard
486
487 The install paths, search paths and other options are defined when running
488  'configure'.
489  The defaults can be overridden by:
490 \layout List
491 \labelwidthstring 00.00.0000
492
493 -
494 \begin_inset ERT
495 status Collapsed
496
497 \layout Standard
498
499 \backslash 
500 /
501 \end_inset 
502
503 -prefix see table below
504 \layout List
505 \labelwidthstring 00.00.0000
506
507 -
508 \begin_inset ERT
509 status Collapsed
510
511 \layout Standard
512
513 \backslash 
514 /
515 \end_inset 
516
517 -exec_prefix see table below
518 \layout List
519 \labelwidthstring 00.00.0000
520
521 -
522 \begin_inset ERT
523 status Collapsed
524
525 \layout Standard
526
527 \backslash 
528 /
529 \end_inset 
530
531 -bindir see table below
532 \layout List
533 \labelwidthstring 00.00.0000
534
535 -
536 \begin_inset ERT
537 status Collapsed
538
539 \layout Standard
540
541 \backslash 
542 /
543 \end_inset 
544
545 -datadir see table below
546 \layout List
547 \labelwidthstring 00.00.0000
548
549 docdir environment variable, see table below
550 \layout List
551 \labelwidthstring 00.00.0000
552
553 include_dir_suffix environment variable, see table below
554 \layout List
555 \labelwidthstring 00.00.0000
556
557 lib_dir_suffix environment variable, see table below
558 \layout List
559 \labelwidthstring 00.00.0000
560
561 sdccconf_h_dir_separator environment variable, either / or 
562 \backslash 
563
564 \backslash 
565  makes sense here.
566  This character will only be used in sdccconf.h; don't forget it's a C-header,
567  therefore a double-backslash is needed there.
568 \layout List
569 \labelwidthstring 00.00.0000
570
571 -
572 \begin_inset ERT
573 status Collapsed
574
575 \layout Standard
576
577 \backslash 
578 /
579 \end_inset 
580
581 -disable-mcs51-port Excludes the Intel mcs51 port
582 \layout List
583 \labelwidthstring 00.00.0000
584
585 -
586 \begin_inset ERT
587 status Collapsed
588
589 \layout Standard
590
591 \backslash 
592 /
593 \end_inset 
594
595 -disable-gbz80-port Excludes the Gameboy gbz80 port
596 \layout List
597 \labelwidthstring 00.00.0000
598
599 -
600 \begin_inset ERT
601 status Collapsed
602
603 \layout Standard
604
605 \backslash 
606 /
607 \end_inset 
608
609 -z80-port Excludes the z80 port
610 \layout List
611 \labelwidthstring 00.00.0000
612
613 -
614 \begin_inset ERT
615 status Collapsed
616
617 \layout Standard
618
619 \backslash 
620 /
621 \end_inset 
622
623 -disable-avr-port Excludes the AVR port
624 \layout List
625 \labelwidthstring 00.00.0000
626
627 -
628 \begin_inset ERT
629 status Collapsed
630
631 \layout Standard
632
633 \backslash 
634 /
635 \end_inset 
636
637 -disable-ds390-port Excludes the DS390 port
638 \layout List
639 \labelwidthstring 00.00.0000
640
641 -
642 \begin_inset ERT
643 status Collapsed
644
645 \layout Standard
646
647 \backslash 
648 /
649 \end_inset 
650
651 -disable-pic-port Excludes the PIC port
652 \layout List
653 \labelwidthstring 00.00.0000
654
655 -
656 \begin_inset ERT
657 status Collapsed
658
659 \layout Standard
660
661 \backslash 
662 /
663 \end_inset 
664
665 -disable-xa51-port Excludes the XA51 port
666 \layout List
667 \labelwidthstring 00.00.0000
668
669 -
670 \begin_inset ERT
671 status Collapsed
672
673 \layout Standard
674
675 \backslash 
676 /
677 \end_inset 
678
679 -disable-ucsim Disables configuring and building of ucsim
680 \layout List
681 \labelwidthstring 00.00.0000
682
683 -
684 \begin_inset ERT
685 status Collapsed
686
687 \layout Standard
688
689 \backslash 
690 /
691 \end_inset 
692
693 -disable-device-lib-build Disables automatically building device libraries
694 \layout List
695 \labelwidthstring 00.00.0000
696
697 -
698 \begin_inset ERT
699 status Collapsed
700
701 \layout Standard
702
703 \backslash 
704 /
705 \end_inset 
706
707 -disable-packihx Disables building packihx
708 \layout List
709 \labelwidthstring 00.00.0000
710
711 -
712 \begin_inset ERT
713 status Collapsed
714
715 \layout Standard
716
717 \backslash 
718 /
719 \end_inset 
720
721 -enable-libgc Use the Bohem memory allocator.
722  Lower runtime footprint.
723 \layout Standard
724
725 Furthermore the environment variables CC, CFLAGS, ...
726  the tools and their arguments can be influenced.
727  Please see `configure -
728 \begin_inset ERT
729 status Collapsed
730
731 \layout Standard
732
733 \backslash 
734 /
735 \end_inset 
736
737 -help` and the man/info pages of `configure` for details.
738 \newline 
739
740 \newline 
741 The names of the standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB,
742  STD_FP_LIB, STD_DS390_LIB, STD_XA51_LIB and the environment variables SDCC_DIR_
743 NAME, SDCC_INCLUDE_NAME, SDCC_LIB_NAME are defined by `configure` too.
744  At the moment it's not possible to change the default settings (it was
745  simply never required.
746 \newline 
747
748 \newline 
749 These configure options are compiled into the binaries, and can only be
750  changed by rerunning 'configure' and recompiling SDCC.
751  The configure options are written in 
752 \emph on 
753 italics
754 \emph default 
755  to distinguish them from run time environment variables (see section search
756  paths).
757 \newline 
758
759 \newline 
760 The settings for 
761 \begin_inset Quotes sld
762 \end_inset 
763
764 Win32 builds
765 \begin_inset Quotes srd
766 \end_inset 
767
768  are used by the SDCC team to build the official Win32 binaries.
769  The SDCC team uses Mingw32 to build the official Windows binaries, because
770  it's
771 \layout Enumerate
772
773 open source, 
774 \layout Enumerate
775
776 a gcc compiler and last but not least
777 \layout Enumerate
778
779 the binaries can be built by cross compiling on Sourceforge's compile farm.
780 \layout Standard
781
782 See the examples, how to pass the Win32 settings to 'configure'.
783  The other Win32 builds using Borland, VC or whatever don't use 'configure',
784  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
785  for Win32.
786 \newline 
787
788 \newline 
789 These defaults are:
790 \newline 
791
792 \layout Standard
793 \align center 
794
795 \begin_inset  Tabular
796 <lyxtabular version="3" rows="8" columns="3">
797 <features>
798 <column alignment="block" valignment="top" leftline="true" width="0in">
799 <column alignment="block" valignment="top" leftline="true" width="0in">
800 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
801 <row topline="true" bottomline="true">
802 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
803 \begin_inset Text
804
805 \layout Standard
806
807 Variable
808 \end_inset 
809 </cell>
810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
811 \begin_inset Text
812
813 \layout Standard
814
815 default
816 \end_inset 
817 </cell>
818 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
819 \begin_inset Text
820
821 \layout Standard
822
823 Win32 builds
824 \end_inset 
825 </cell>
826 </row>
827 <row topline="true">
828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
829 \begin_inset Text
830
831 \layout Standard
832
833
834 \emph on 
835 PREFIX
836 \end_inset 
837 </cell>
838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
839 \begin_inset Text
840
841 \layout Standard
842
843 /usr/local
844 \end_inset 
845 </cell>
846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
847 \begin_inset Text
848
849 \layout Standard
850
851
852 \backslash 
853 sdcc
854 \end_inset 
855 </cell>
856 </row>
857 <row topline="true">
858 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
859 \begin_inset Text
860
861 \layout Standard
862
863
864 \emph on 
865 EXEC_PREFIX
866 \end_inset 
867 </cell>
868 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
869 \begin_inset Text
870
871 \layout Standard
872
873
874 \emph on 
875 $PREFIX
876 \end_inset 
877 </cell>
878 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
879 \begin_inset Text
880
881 \layout Standard
882
883
884 \emph on 
885 $PREFIX
886 \end_inset 
887 </cell>
888 </row>
889 <row topline="true">
890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
891 \begin_inset Text
892
893 \layout Standard
894
895
896 \emph on 
897 BINDIR
898 \end_inset 
899 </cell>
900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
901 \begin_inset Text
902
903 \layout Standard
904
905
906 \emph on 
907 $EXECPREFIX
908 \emph default 
909 /bin
910 \end_inset 
911 </cell>
912 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
913 \begin_inset Text
914
915 \layout Standard
916
917
918 \emph on 
919 $EXECPREFIX
920 \emph default 
921
922 \backslash 
923 bin
924 \end_inset 
925 </cell>
926 </row>
927 <row topline="true">
928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
929 \begin_inset Text
930
931 \layout Standard
932
933
934 \emph on 
935 DATADIR
936 \end_inset 
937 </cell>
938 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
939 \begin_inset Text
940
941 \layout Standard
942
943
944 \emph on 
945 $PREFIX
946 \emph default 
947 /share
948 \end_inset 
949 </cell>
950 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
951 \begin_inset Text
952
953 \layout Standard
954
955
956 \emph on 
957 $PREFIX
958 \end_inset 
959 </cell>
960 </row>
961 <row topline="true">
962 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
963 \begin_inset Text
964
965 \layout Standard
966
967
968 \emph on 
969 DOCDIR
970 \end_inset 
971 </cell>
972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
973 \begin_inset Text
974
975 \layout Standard
976
977
978 \emph on 
979 $DATADIR
980 \emph default 
981 /sdcc/doc
982 \end_inset 
983 </cell>
984 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
985 \begin_inset Text
986
987 \layout Standard
988
989
990 \emph on 
991 $DATADIR
992 \emph default 
993
994 \backslash 
995 doc
996 \end_inset 
997 </cell>
998 </row>
999 <row topline="true">
1000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1001 \begin_inset Text
1002
1003 \layout Standard
1004
1005
1006 \emph on 
1007 INCLUDE_DIR_SUFFIX
1008 \end_inset 
1009 </cell>
1010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1011 \begin_inset Text
1012
1013 \layout Standard
1014
1015 sdcc/include
1016 \end_inset 
1017 </cell>
1018 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1019 \begin_inset Text
1020
1021 \layout Standard
1022
1023 include
1024 \end_inset 
1025 </cell>
1026 </row>
1027 <row topline="true" bottomline="true">
1028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1029 \begin_inset Text
1030
1031 \layout Standard
1032
1033
1034 \emph on 
1035 LIB_DIR_SUFFIX
1036 \end_inset 
1037 </cell>
1038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1039 \begin_inset Text
1040
1041 \layout Standard
1042
1043 sdcc/lib
1044 \end_inset 
1045 </cell>
1046 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1047 \begin_inset Text
1048
1049 \layout Standard
1050
1051 lib
1052 \end_inset 
1053 </cell>
1054 </row>
1055 </lyxtabular>
1056
1057 \end_inset 
1058
1059
1060 \newline 
1061
1062 \layout Standard
1063 \noindent 
1064 'configure' also computes relative paths.
1065  This is needed for full relocatability of a binary package and to complete
1066  search paths (see section search paths below):
1067 \newline 
1068  
1069 \layout Standard
1070 \align center 
1071
1072 \begin_inset  Tabular
1073 <lyxtabular version="3" rows="4" columns="3">
1074 <features>
1075 <column alignment="block" valignment="top" leftline="true" width="0in">
1076 <column alignment="block" valignment="top" leftline="true" width="0in">
1077 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1078 <row topline="true" bottomline="true">
1079 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1080 \begin_inset Text
1081
1082 \layout Standard
1083
1084 Variable (computed)
1085 \end_inset 
1086 </cell>
1087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1088 \begin_inset Text
1089
1090 \layout Standard
1091
1092 default
1093 \end_inset 
1094 </cell>
1095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1096 \begin_inset Text
1097
1098 \layout Standard
1099
1100 Win32 builds
1101 \end_inset 
1102 </cell>
1103 </row>
1104 <row topline="true" bottomline="true">
1105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1106 \begin_inset Text
1107
1108 \layout Standard
1109
1110
1111 \emph on 
1112 BIN2DATA_DIR
1113 \end_inset 
1114 </cell>
1115 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1116 \begin_inset Text
1117
1118 \layout Standard
1119
1120 ../share
1121 \end_inset 
1122 </cell>
1123 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1124 \begin_inset Text
1125
1126 \layout Standard
1127
1128 ..
1129 \backslash 
1130
1131 \end_inset 
1132 </cell>
1133 </row>
1134 <row bottomline="true">
1135 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1136 \begin_inset Text
1137
1138 \layout Standard
1139
1140
1141 \emph on 
1142 PREFIX2BIN_DIR
1143 \end_inset 
1144 </cell>
1145 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1146 \begin_inset Text
1147
1148 \layout Standard
1149
1150 bin
1151 \end_inset 
1152 </cell>
1153 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1154 \begin_inset Text
1155
1156 \layout Standard
1157
1158 bin
1159 \end_inset 
1160 </cell>
1161 </row>
1162 <row bottomline="true">
1163 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1164 \begin_inset Text
1165
1166 \layout Standard
1167
1168
1169 \emph on 
1170 PREFIX2DATA_DIR
1171 \end_inset 
1172 </cell>
1173 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1174 \begin_inset Text
1175
1176 \layout Standard
1177
1178 share/sdcc
1179 \end_inset 
1180 </cell>
1181 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1182 \begin_inset Text
1183
1184 \layout Standard
1185
1186 \end_inset 
1187 </cell>
1188 </row>
1189 </lyxtabular>
1190
1191 \end_inset 
1192
1193
1194 \newline 
1195
1196 \layout Standard
1197 \noindent 
1198 Examples:
1199 \layout LyX-Code
1200
1201 ./configure
1202 \newline 
1203 ./configure -
1204 \begin_inset ERT
1205 status Collapsed
1206
1207 \layout Standard
1208
1209 \backslash 
1210 /
1211 \end_inset 
1212
1213 -prefix=
1214 \begin_inset Quotes srd
1215 \end_inset 
1216
1217 /usr/bin
1218 \begin_inset Quotes srd
1219 \end_inset 
1220
1221  -
1222 \begin_inset ERT
1223 status Collapsed
1224
1225 \layout Standard
1226
1227 \backslash 
1228 /
1229 \end_inset 
1230
1231 -datadir=
1232 \begin_inset Quotes srd
1233 \end_inset 
1234
1235 /usr/share
1236 \begin_inset Quotes srd
1237 \end_inset 
1238
1239
1240 \newline 
1241 ./configure -
1242 \begin_inset ERT
1243 status Collapsed
1244
1245 \layout Standard
1246
1247 \backslash 
1248 /
1249 \end_inset 
1250
1251 -disable-avr-port -
1252 \begin_inset ERT
1253 status Collapsed
1254
1255 \layout Standard
1256
1257 \backslash 
1258 /
1259 \end_inset 
1260
1261 -disable-xa51-port
1262 \layout Standard
1263
1264 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
1265 32'):
1266 \layout LyX-Code
1267
1268 ./configure 
1269 \backslash 
1270
1271 \newline 
1272 CC=
1273 \begin_inset Quotes srd
1274 \end_inset 
1275
1276 i586-mingw32msvc-gcc
1277 \begin_inset Quotes srd
1278 \end_inset 
1279
1280  CXX=
1281 \begin_inset Quotes srd
1282 \end_inset 
1283
1284 i586-mingw32msvc-g++
1285 \begin_inset Quotes srd
1286 \end_inset 
1287
1288  
1289 \backslash 
1290  
1291 \newline 
1292 RANLIB=
1293 \begin_inset Quotes srd
1294 \end_inset 
1295
1296 i586-mingw32msvc-ranlib
1297 \begin_inset Quotes srd
1298 \end_inset 
1299
1300  
1301 \backslash 
1302
1303 \newline 
1304 STRIP=
1305 \begin_inset Quotes srd
1306 \end_inset 
1307
1308 i586-mingw32msvc-strip
1309 \begin_inset Quotes srd
1310 \end_inset 
1311
1312  
1313 \backslash 
1314
1315 \newline 
1316 -
1317 \begin_inset ERT
1318 status Collapsed
1319
1320 \layout Standard
1321
1322 \backslash 
1323 /
1324 \end_inset 
1325
1326 -prefix=
1327 \begin_inset Quotes srd
1328 \end_inset 
1329
1330 /sdcc
1331 \begin_inset Quotes srd
1332 \end_inset 
1333
1334  
1335 \backslash 
1336
1337 \newline 
1338 -
1339 \begin_inset ERT
1340 status Collapsed
1341
1342 \layout Standard
1343
1344 \backslash 
1345 /
1346 \end_inset 
1347
1348 -datadir=
1349 \begin_inset Quotes srd
1350 \end_inset 
1351
1352 /sdcc
1353 \begin_inset Quotes srd
1354 \end_inset 
1355
1356  
1357 \backslash 
1358
1359 \newline 
1360 docdir=
1361 \begin_inset Quotes srd
1362 \end_inset 
1363
1364 /sdcc/doc
1365 \begin_inset Quotes srd
1366 \end_inset 
1367
1368  
1369 \backslash 
1370
1371 \newline 
1372 include_dir_suffix=
1373 \begin_inset Quotes srd
1374 \end_inset 
1375
1376 include
1377 \begin_inset Quotes srd
1378 \end_inset 
1379
1380  
1381 \backslash 
1382
1383 \newline 
1384 lib_dir_suffix=
1385 \begin_inset Quotes srd
1386 \end_inset 
1387
1388 lib
1389 \begin_inset Quotes srd
1390 \end_inset 
1391
1392  
1393 \backslash 
1394
1395 \newline 
1396 sdccconf_h_dir_separator=
1397 \begin_inset Quotes srd
1398 \end_inset 
1399
1400
1401 \backslash 
1402
1403 \backslash 
1404
1405 \backslash 
1406
1407 \backslash 
1408
1409 \begin_inset Quotes srd
1410 \end_inset 
1411
1412  
1413 \backslash 
1414
1415 \newline 
1416 -
1417 \begin_inset ERT
1418 status Collapsed
1419
1420 \layout Standard
1421
1422 \backslash 
1423 /
1424 \end_inset 
1425
1426 -disable-device-lib-build
1427 \backslash 
1428
1429 \newline 
1430 -
1431 \begin_inset ERT
1432 status Collapsed
1433
1434 \layout Standard
1435
1436 \backslash 
1437 /
1438 \end_inset 
1439
1440 -disable-ucsim
1441 \backslash 
1442
1443 \newline 
1444 -
1445 \begin_inset ERT
1446 status Collapsed
1447
1448 \layout Standard
1449
1450 \backslash 
1451 /
1452 \end_inset 
1453
1454 -host=i586-mingw32msvc -
1455 \begin_inset ERT
1456 status Collapsed
1457
1458 \layout Standard
1459
1460 \backslash 
1461 /
1462 \end_inset 
1463
1464 -build=unknown-unknown-linux-gnu
1465 \layout Standard
1466
1467 To 
1468 \begin_inset Quotes sld
1469 \end_inset 
1470
1471 cross
1472 \begin_inset Quotes srd
1473 \end_inset 
1474
1475 compile on Cygwin for Mingw32(see also sdcc/support/scripts/sdcc_cygwin_mingw32)
1476 :
1477 \layout LyX-Code
1478
1479 ./configure -C 
1480 \backslash 
1481
1482 \newline 
1483 CFLAGS=
1484 \begin_inset Quotes srd
1485 \end_inset 
1486
1487 -mno-cygwin -O2
1488 \begin_inset Quotes srd
1489 \end_inset 
1490
1491  
1492 \backslash 
1493
1494 \newline 
1495 LDFLAGS=
1496 \begin_inset Quotes srd
1497 \end_inset 
1498
1499 -mno-cygwin
1500 \begin_inset Quotes srd
1501 \end_inset 
1502
1503  
1504 \backslash 
1505
1506 \newline 
1507 -
1508 \begin_inset ERT
1509 status Collapsed
1510
1511 \layout Standard
1512
1513 \backslash 
1514 /
1515 \end_inset 
1516
1517 -prefix=
1518 \begin_inset Quotes srd
1519 \end_inset 
1520
1521 /sdcc
1522 \begin_inset Quotes srd
1523 \end_inset 
1524
1525  
1526 \backslash 
1527
1528 \newline 
1529 -
1530 \begin_inset ERT
1531 status Collapsed
1532
1533 \layout Standard
1534
1535 \backslash 
1536 /
1537 \end_inset 
1538
1539 -datadir=
1540 \begin_inset Quotes srd
1541 \end_inset 
1542
1543 /sdcc
1544 \begin_inset Quotes srd
1545 \end_inset 
1546
1547  
1548 \backslash 
1549
1550 \newline 
1551 docdir=
1552 \begin_inset Quotes srd
1553 \end_inset 
1554
1555 /sdcc/doc
1556 \begin_inset Quotes srd
1557 \end_inset 
1558
1559  
1560 \backslash 
1561  
1562 \newline 
1563 include_dir_suffix=
1564 \begin_inset Quotes srd
1565 \end_inset 
1566
1567 include
1568 \begin_inset Quotes srd
1569 \end_inset 
1570
1571  
1572 \backslash 
1573
1574 \newline 
1575 lib_dir_suffix=
1576 \begin_inset Quotes srd
1577 \end_inset 
1578
1579 lib
1580 \begin_inset Quotes srd
1581 \end_inset 
1582
1583  
1584 \backslash 
1585
1586 \newline 
1587 sdccconf_h_dir_separator=
1588 \begin_inset Quotes srd
1589 \end_inset 
1590
1591
1592 \backslash 
1593
1594 \backslash 
1595
1596 \backslash 
1597
1598 \backslash 
1599
1600 \begin_inset Quotes srd
1601 \end_inset 
1602
1603  
1604 \backslash 
1605
1606 \newline 
1607 -
1608 \begin_inset ERT
1609 status Collapsed
1610
1611 \layout Standard
1612
1613 \backslash 
1614 /
1615 \end_inset 
1616
1617 -disable-ucsim
1618 \layout Standard
1619
1620 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
1621  The option '-
1622 \begin_inset ERT
1623 status Collapsed
1624
1625 \layout Standard
1626
1627 \backslash 
1628 /
1629 \end_inset 
1630
1631 -C' turns on caching, which gives a little bit extra speed.
1632  However if options are changed, it can be necessary to delete the config.cache
1633  file.
1634 \layout Subsection
1635
1636 Install paths
1637 \begin_inset LatexCommand \index{Install paths}
1638
1639 \end_inset 
1640
1641
1642 \layout Standard
1643 \added_space_top medskip \align center 
1644
1645 \begin_inset  Tabular
1646 <lyxtabular version="3" rows="5" columns="4">
1647 <features>
1648 <column alignment="center" valignment="top" leftline="true" width="0(null)">
1649 <column alignment="center" valignment="top" leftline="true" width="0(null)">
1650 <column alignment="center" valignment="top" leftline="true" width="0(null)">
1651 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
1652 <row topline="true" bottomline="true">
1653 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1654 \begin_inset Text
1655
1656 \layout Standard
1657
1658
1659 \series bold 
1660 Description
1661 \end_inset 
1662 </cell>
1663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1664 \begin_inset Text
1665
1666 \layout Standard
1667
1668
1669 \series bold 
1670 Path
1671 \end_inset 
1672 </cell>
1673 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1674 \begin_inset Text
1675
1676 \layout Standard
1677
1678
1679 \series bold 
1680 Default
1681 \end_inset 
1682 </cell>
1683 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1684 \begin_inset Text
1685
1686 \layout Standard
1687
1688
1689 \series bold 
1690 Win32 builds
1691 \end_inset 
1692 </cell>
1693 </row>
1694 <row topline="true">
1695 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1696 \begin_inset Text
1697
1698 \layout Standard
1699
1700 Binary files*
1701 \end_inset 
1702 </cell>
1703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1704 \begin_inset Text
1705
1706 \layout Standard
1707
1708
1709 \emph on 
1710 $EXEC_PREFIX
1711 \end_inset 
1712 </cell>
1713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1714 \begin_inset Text
1715
1716 \layout Standard
1717
1718 /usr/local/bin
1719 \end_inset 
1720 </cell>
1721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1722 \begin_inset Text
1723
1724 \layout Standard
1725
1726
1727 \backslash 
1728 sdcc
1729 \backslash 
1730 bin
1731 \end_inset 
1732 </cell>
1733 </row>
1734 <row topline="true">
1735 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1736 \begin_inset Text
1737
1738 \layout Standard
1739
1740 Include files
1741 \end_inset 
1742 </cell>
1743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1744 \begin_inset Text
1745
1746 \layout Standard
1747
1748
1749 \emph on 
1750 $DATADIR/ $INCLUDE_DIR_SUFFIX
1751 \end_inset 
1752 </cell>
1753 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1754 \begin_inset Text
1755
1756 \layout Standard
1757
1758 /usr/local/share/sdcc/include
1759 \end_inset 
1760 </cell>
1761 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1762 \begin_inset Text
1763
1764 \layout Standard
1765
1766
1767 \backslash 
1768 sdcc
1769 \backslash 
1770 include
1771 \end_inset 
1772 </cell>
1773 </row>
1774 <row topline="true">
1775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1776 \begin_inset Text
1777
1778 \layout Standard
1779
1780 Library file**
1781 \end_inset 
1782 </cell>
1783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1784 \begin_inset Text
1785
1786 \layout Standard
1787
1788
1789 \emph on 
1790 $DATADIR/$LIB_DIR_SUFFIX
1791 \end_inset 
1792 </cell>
1793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1794 \begin_inset Text
1795
1796 \layout Standard
1797
1798 /usr/local/share/sdcc/lib
1799 \end_inset 
1800 </cell>
1801 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1802 \begin_inset Text
1803
1804 \layout Standard
1805
1806
1807 \backslash 
1808 sdcc
1809 \backslash 
1810 lib
1811 \end_inset 
1812 </cell>
1813 </row>
1814 <row topline="true" bottomline="true">
1815 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1816 \begin_inset Text
1817
1818 \layout Standard
1819
1820 Documentation
1821 \end_inset 
1822 </cell>
1823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1824 \begin_inset Text
1825
1826 \layout Standard
1827
1828
1829 \emph on 
1830 $DOCDIR
1831 \end_inset 
1832 </cell>
1833 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1834 \begin_inset Text
1835
1836 \layout Standard
1837
1838 /usr/local/share/sdcc/doc
1839 \end_inset 
1840 </cell>
1841 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1842 \begin_inset Text
1843
1844 \layout Standard
1845
1846
1847 \backslash 
1848 sdcc
1849 \backslash 
1850 doc
1851 \end_inset 
1852 </cell>
1853 </row>
1854 </lyxtabular>
1855
1856 \end_inset 
1857
1858
1859 \layout Verse
1860
1861
1862 \size footnotesize 
1863 *compiler, preprocessor, assembler, and linker
1864 \newline 
1865 **the 
1866 \shape italic 
1867 model
1868 \shape default 
1869  is auto-appended by the compiler, e.g.
1870  small, large, z80, ds390 etc
1871 \layout Standard
1872 \noindent 
1873 The install paths can still be changed during `make install` with e.g.:
1874 \layout LyX-Code
1875
1876 make install prefix=$(HOME)/local/sdcc
1877 \layout Standard
1878
1879 Of course this doesn't change the search paths compiled into the binaries.
1880 \layout Subsection
1881
1882 Search Paths
1883 \begin_inset LatexCommand \index{Search path}
1884
1885 \end_inset 
1886
1887
1888 \layout Standard
1889
1890 Some search paths or parts of them are determined by configure variables
1891  (in 
1892 \emph on 
1893 italics
1894 \emph default 
1895 , see section above).
1896  Further search paths are determined by environment variables during runtime.
1897  
1898 \newline 
1899 The paths searched when running the compiler are as follows (the first catch
1900  wins):
1901 \newline 
1902
1903 \newline 
1904 1.
1905  Binary files (preprocessor, assembler and linker)
1906 \newline 
1907
1908 \layout Standard
1909 \align center 
1910
1911 \begin_inset  Tabular
1912 <lyxtabular version="3" rows="4" columns="3">
1913 <features>
1914 <column alignment="block" valignment="top" leftline="true" width="0in">
1915 <column alignment="block" valignment="top" leftline="true" width="0in">
1916 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1917 <row topline="true" bottomline="true">
1918 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1919 \begin_inset Text
1920
1921 \layout Standard
1922
1923 Search path
1924 \end_inset 
1925 </cell>
1926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1927 \begin_inset Text
1928
1929 \layout Standard
1930
1931 default
1932 \end_inset 
1933 </cell>
1934 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1935 \begin_inset Text
1936
1937 \layout Standard
1938
1939 Win32 builds
1940 \end_inset 
1941 </cell>
1942 </row>
1943 <row topline="true">
1944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1945 \begin_inset Text
1946
1947 \layout Standard
1948
1949 $SDCC_HOME/
1950 \emph on 
1951 $PPREFIX2BIN_DIR
1952 \end_inset 
1953 </cell>
1954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1955 \begin_inset Text
1956
1957 \layout Standard
1958
1959 $SDCC_HOME/bin
1960 \end_inset 
1961 </cell>
1962 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1963 \begin_inset Text
1964
1965 \layout Standard
1966
1967 $SDCC_HOME
1968 \backslash 
1969 bin
1970 \end_inset 
1971 </cell>
1972 </row>
1973 <row topline="true">
1974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1975 \begin_inset Text
1976
1977 \layout Standard
1978
1979 Path of argv[0] (if available)
1980 \end_inset 
1981 </cell>
1982 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1983 \begin_inset Text
1984
1985 \layout Standard
1986
1987 Path of argv[0]
1988 \end_inset 
1989 </cell>
1990 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1991 \begin_inset Text
1992
1993 \layout Standard
1994
1995 Path of argv[0]
1996 \end_inset 
1997 </cell>
1998 </row>
1999 <row topline="true" bottomline="true">
2000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2001 \begin_inset Text
2002
2003 \layout Standard
2004
2005 $PATH
2006 \end_inset 
2007 </cell>
2008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2009 \begin_inset Text
2010
2011 \layout Standard
2012
2013 $PATH
2014 \end_inset 
2015 </cell>
2016 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2017 \begin_inset Text
2018
2019 \layout Standard
2020
2021 $PATH
2022 \end_inset 
2023 </cell>
2024 </row>
2025 </lyxtabular>
2026
2027 \end_inset 
2028
2029  
2030 \newline 
2031
2032 \layout Standard
2033 \noindent 
2034 2.
2035  Include files
2036 \newline 
2037
2038 \layout Standard
2039 \align center 
2040
2041 \begin_inset  Tabular
2042 <lyxtabular version="3" rows="6" columns="3">
2043 <features>
2044 <column alignment="block" valignment="top" leftline="true" width="1.5in">
2045 <column alignment="block" valignment="top" leftline="true" width="1.5in">
2046 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2047 <row topline="true" bottomline="true">
2048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2049 \begin_inset Text
2050
2051 \layout Standard
2052
2053 Search path
2054 \end_inset 
2055 </cell>
2056 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2057 \begin_inset Text
2058
2059 \layout Standard
2060
2061 default
2062 \end_inset 
2063 </cell>
2064 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2065 \begin_inset Text
2066
2067 \layout Standard
2068
2069 Win32 builds
2070 \end_inset 
2071 </cell>
2072 </row>
2073 <row topline="true">
2074 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2075 \begin_inset Text
2076
2077 \layout Standard
2078
2079 -
2080 \begin_inset ERT
2081 status Collapsed
2082
2083 \layout Standard
2084
2085 \backslash 
2086 /
2087 \end_inset 
2088
2089 -I dir
2090 \end_inset 
2091 </cell>
2092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2093 \begin_inset Text
2094
2095 \layout Standard
2096
2097 -
2098 \begin_inset ERT
2099 status Collapsed
2100
2101 \layout Standard
2102
2103 \backslash 
2104 /
2105 \end_inset 
2106
2107 -I dir
2108 \end_inset 
2109 </cell>
2110 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2111 \begin_inset Text
2112
2113 \layout Standard
2114
2115 -
2116 \begin_inset ERT
2117 status Collapsed
2118
2119 \layout Standard
2120
2121 \backslash 
2122 /
2123 \end_inset 
2124
2125 -I dir
2126 \end_inset 
2127 </cell>
2128 </row>
2129 <row topline="true">
2130 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2131 \begin_inset Text
2132
2133 \layout Standard
2134
2135 $SDCC_INCLUDE
2136 \end_inset 
2137 </cell>
2138 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2139 \begin_inset Text
2140
2141 \layout Standard
2142
2143 $SDCC_INCLUDE
2144 \end_inset 
2145 </cell>
2146 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2147 \begin_inset Text
2148
2149 \layout Standard
2150
2151 $SDCC_INCLUDE
2152 \end_inset 
2153 </cell>
2154 </row>
2155 <row topline="true">
2156 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2157 \begin_inset Text
2158
2159 \layout Standard
2160
2161 $SDCC_HOME/
2162 \newline 
2163
2164 \emph on 
2165 $PREFIX2DATA_DIR/
2166 \newline 
2167 $INCLUDE_DIR_SUFFIX
2168 \end_inset 
2169 </cell>
2170 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2171 \begin_inset Text
2172
2173 \layout Standard
2174
2175 $SDCC_ HOME/
2176 \newline 
2177 share/sdcc/
2178 \newline 
2179 include
2180 \end_inset 
2181 </cell>
2182 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2183 \begin_inset Text
2184
2185 \layout Standard
2186
2187 $SDCC_HOME
2188 \backslash 
2189 include
2190 \end_inset 
2191 </cell>
2192 </row>
2193 <row topline="true">
2194 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2195 \begin_inset Text
2196
2197 \layout Standard
2198
2199 path(argv[0])/
2200 \newline 
2201
2202 \emph on 
2203 $BIN2DATADIR/
2204 \emph default 
2205
2206 \newline 
2207
2208 \emph on 
2209 $INCLUDE_DIR_SUFFIX
2210 \end_inset 
2211 </cell>
2212 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2213 \begin_inset Text
2214
2215 \layout Standard
2216
2217 path(argv[0])/
2218 \newline 
2219 ../sdcc/include
2220 \newline 
2221 \SpecialChar ~
2222 \SpecialChar ~
2223 \SpecialChar ~
2224 \SpecialChar ~
2225 \SpecialChar ~
2226 \SpecialChar ~
2227 \SpecialChar ~
2228 \SpecialChar ~
2229 \SpecialChar ~
2230 \SpecialChar ~
2231 \SpecialChar ~
2232 \SpecialChar ~
2233 \SpecialChar ~
2234 \SpecialChar ~
2235 \SpecialChar ~
2236 \SpecialChar ~
2237 \SpecialChar ~
2238 \SpecialChar ~
2239 \SpecialChar ~
2240 \SpecialChar ~
2241 \SpecialChar ~
2242 \SpecialChar ~
2243 \SpecialChar ~
2244 \SpecialChar ~
2245 \SpecialChar ~
2246 \SpecialChar ~
2247 \SpecialChar ~
2248 \SpecialChar ~
2249 \SpecialChar ~
2250 \SpecialChar ~
2251 \SpecialChar ~
2252 \SpecialChar ~
2253 \SpecialChar ~
2254 \SpecialChar ~
2255 \SpecialChar ~
2256 \SpecialChar ~
2257 \SpecialChar ~
2258 \SpecialChar ~
2259
2260 \end_inset 
2261 </cell>
2262 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2263 \begin_inset Text
2264
2265 \layout Standard
2266
2267 path(argv[0])
2268 \backslash 
2269 ..
2270 \backslash 
2271 include
2272 \end_inset 
2273 </cell>
2274 </row>
2275 <row topline="true" bottomline="true">
2276 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2277 \begin_inset Text
2278
2279 \layout Standard
2280
2281
2282 \emph on 
2283 $DATADIR/
2284 \emph default 
2285
2286 \newline 
2287
2288 \emph on 
2289 $INCLUDE_DIR_SUFFIX
2290 \end_inset 
2291 </cell>
2292 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2293 \begin_inset Text
2294
2295 \layout Standard
2296
2297 /usr/local/share/sdcc/
2298 \newline 
2299 include
2300 \end_inset 
2301 </cell>
2302 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2303 \begin_inset Text
2304
2305 \layout Standard
2306
2307 (not on Win32)
2308 \end_inset 
2309 </cell>
2310 </row>
2311 </lyxtabular>
2312
2313 \end_inset 
2314
2315  
2316 \newline 
2317
2318 \layout Standard
2319 \noindent 
2320 The option -
2321 \begin_inset ERT
2322 status Collapsed
2323
2324 \layout Standard
2325
2326 \backslash 
2327 /
2328 \end_inset 
2329
2330 -nostdinc disables the last two search paths.
2331 \newline 
2332
2333 \newline 
2334 3.
2335  Library files 
2336 \newline 
2337
2338 \layout Standard
2339
2340 With the exception of 
2341 \begin_inset Quotes sld
2342 \end_inset 
2343
2344 -
2345 \begin_inset ERT
2346 status Collapsed
2347
2348 \layout Standard
2349
2350 \backslash 
2351 /
2352 \end_inset 
2353
2354 -L dir
2355 \begin_inset Quotes srd
2356 \end_inset 
2357
2358  the 
2359 \shape italic 
2360 model
2361 \shape default 
2362  is auto-appended by the compiler (e.g.
2363  small, large, z80, ds390 etc.).
2364  
2365 \newline 
2366
2367 \layout Standard
2368 \align center 
2369
2370 \begin_inset  Tabular
2371 <lyxtabular version="3" rows="6" columns="3">
2372 <features>
2373 <column alignment="block" valignment="top" leftline="true" width="1.7in">
2374 <column alignment="block" valignment="top" leftline="true" width="1.2in">
2375 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
2376 <row topline="true" bottomline="true">
2377 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2378 \begin_inset Text
2379
2380 \layout Standard
2381
2382 Search path
2383 \end_inset 
2384 </cell>
2385 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2386 \begin_inset Text
2387
2388 \layout Standard
2389
2390 default
2391 \end_inset 
2392 </cell>
2393 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2394 \begin_inset Text
2395
2396 \layout Standard
2397
2398 Win32 builds
2399 \end_inset 
2400 </cell>
2401 </row>
2402 <row topline="true">
2403 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2404 \begin_inset Text
2405
2406 \layout Standard
2407
2408 -
2409 \begin_inset ERT
2410 status Collapsed
2411
2412 \layout Standard
2413
2414 \backslash 
2415 /
2416 \end_inset 
2417
2418 -L dir
2419 \end_inset 
2420 </cell>
2421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2422 \begin_inset Text
2423
2424 \layout Standard
2425
2426 -
2427 \begin_inset ERT
2428 status Collapsed
2429
2430 \layout Standard
2431
2432 \backslash 
2433 /
2434 \end_inset 
2435
2436 -L dir
2437 \end_inset 
2438 </cell>
2439 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2440 \begin_inset Text
2441
2442 \layout Standard
2443
2444 -
2445 \begin_inset ERT
2446 status Collapsed
2447
2448 \layout Standard
2449
2450 \backslash 
2451 /
2452 \end_inset 
2453
2454 -L dir
2455 \end_inset 
2456 </cell>
2457 </row>
2458 <row topline="true">
2459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2460 \begin_inset Text
2461
2462 \layout Standard
2463
2464 $SDCC_LIB/
2465 \newline 
2466
2467 \emph on 
2468 <model>
2469 \end_inset 
2470 </cell>
2471 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2472 \begin_inset Text
2473
2474 \layout Standard
2475
2476 $SDCC_LIB/
2477 \newline 
2478
2479 \emph on 
2480 <model>
2481 \end_inset 
2482 </cell>
2483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2484 \begin_inset Text
2485
2486 \layout Standard
2487
2488 $SDCC_LIB
2489 \backslash 
2490
2491 \newline 
2492
2493 \emph on 
2494 <model>
2495 \end_inset 
2496 </cell>
2497 </row>
2498 <row topline="true">
2499 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2500 \begin_inset Text
2501
2502 \layout Standard
2503
2504 $SDCC_HOME/
2505 \newline 
2506
2507 \emph on 
2508 $PREFIX2DATA_DIR/
2509 \newline 
2510 $LIB_DIR_SUFFIX/<model>
2511 \end_inset 
2512 </cell>
2513 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2514 \begin_inset Text
2515
2516 \layout Standard
2517
2518 $SDCC_HOME/
2519 \newline 
2520 share/sdcc/
2521 \newline 
2522 lib/
2523 \emph on 
2524 <model>
2525 \end_inset 
2526 </cell>
2527 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2528 \begin_inset Text
2529
2530 \layout Standard
2531
2532 $SDCC_HOME
2533 \backslash 
2534 lib
2535 \backslash 
2536
2537 \emph on 
2538
2539 \newline 
2540 <model>
2541 \end_inset 
2542 </cell>
2543 </row>
2544 <row topline="true">
2545 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2546 \begin_inset Text
2547
2548 \layout Standard
2549
2550 path(argv[0])/
2551 \newline 
2552
2553 \emph on 
2554 $BIN2DATADIR/
2555 \emph default 
2556
2557 \newline 
2558
2559 \emph on 
2560 $LIB_DIR_SUFFIX/<model>
2561 \end_inset 
2562 </cell>
2563 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2564 \begin_inset Text
2565
2566 \layout Standard
2567
2568 path(argv[0])/
2569 \newline 
2570 ../sdcc/lib/
2571 \emph on 
2572 <model>
2573 \newline 
2574 \SpecialChar ~
2575 \SpecialChar ~
2576 \SpecialChar ~
2577 \SpecialChar ~
2578 \SpecialChar ~
2579 \SpecialChar ~
2580 \SpecialChar ~
2581 \SpecialChar ~
2582 \SpecialChar ~
2583 \SpecialChar ~
2584 \SpecialChar ~
2585 \SpecialChar ~
2586 \SpecialChar ~
2587 \SpecialChar ~
2588 \SpecialChar ~
2589 \SpecialChar ~
2590 \SpecialChar ~
2591 \SpecialChar ~
2592 \SpecialChar ~
2593 \SpecialChar ~
2594 \SpecialChar ~
2595 \SpecialChar ~
2596 \SpecialChar ~
2597 \SpecialChar ~
2598 \SpecialChar ~
2599 \SpecialChar ~
2600 \SpecialChar ~
2601 \SpecialChar ~
2602 \SpecialChar ~
2603 \SpecialChar ~
2604 \SpecialChar ~
2605 \SpecialChar ~
2606 \SpecialChar ~
2607 \SpecialChar ~
2608 \SpecialChar ~
2609 \SpecialChar ~
2610 \SpecialChar ~
2611 \SpecialChar ~
2612 \SpecialChar ~
2613
2614 \end_inset 
2615 </cell>
2616 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2617 \begin_inset Text
2618
2619 \layout Standard
2620
2621 path(argv[0])
2622 \backslash 
2623
2624 \newline 
2625 ..
2626 \backslash 
2627 lib
2628 \backslash 
2629
2630 \emph on 
2631 <model>
2632 \newline 
2633 \SpecialChar ~
2634 \SpecialChar ~
2635 \SpecialChar ~
2636 \SpecialChar ~
2637 \SpecialChar ~
2638 \SpecialChar ~
2639 \SpecialChar ~
2640 \SpecialChar ~
2641 \SpecialChar ~
2642 \SpecialChar ~
2643 \SpecialChar ~
2644 \SpecialChar ~
2645 \SpecialChar ~
2646 \SpecialChar ~
2647 \SpecialChar ~
2648 \SpecialChar ~
2649 \SpecialChar ~
2650 \SpecialChar ~
2651 \SpecialChar ~
2652 \SpecialChar ~
2653 \SpecialChar ~
2654 \SpecialChar ~
2655 \SpecialChar ~
2656 \SpecialChar ~
2657 \SpecialChar ~
2658 \SpecialChar ~
2659 \SpecialChar ~
2660 \SpecialChar ~
2661 \SpecialChar ~
2662 \SpecialChar ~
2663 \SpecialChar ~
2664 \SpecialChar ~
2665 \SpecialChar ~
2666 \SpecialChar ~
2667 \SpecialChar ~
2668
2669 \end_inset 
2670 </cell>
2671 </row>
2672 <row topline="true" bottomline="true">
2673 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2674 \begin_inset Text
2675
2676 \layout Standard
2677
2678
2679 \emph on 
2680 $DATADIR/
2681 \newline 
2682 $LIB_DIR_SUFFIX/<model>
2683 \end_inset 
2684 </cell>
2685 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2686 \begin_inset Text
2687
2688 \layout Standard
2689
2690 /usr/local/share/sdcc/
2691 \newline 
2692 lib/
2693 \emph on 
2694 <model>
2695 \end_inset 
2696 </cell>
2697 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2698 \begin_inset Text
2699
2700 \layout Standard
2701
2702 (not on Win32)
2703 \end_inset 
2704 </cell>
2705 </row>
2706 </lyxtabular>
2707
2708 \end_inset 
2709
2710
2711 \newline 
2712
2713 \layout Comment
2714
2715 Don't delete any of the stray spaces in the table above without checking
2716  the HTML output (last line)!
2717 \layout Standard
2718
2719 \SpecialChar ~
2720
2721 \newline 
2722 The option -
2723 \begin_inset ERT
2724 status Collapsed
2725
2726 \layout Standard
2727
2728 \backslash 
2729 /
2730 \end_inset 
2731
2732 -nostdlib disables the last two search paths.
2733 \layout Subsection
2734
2735 Building SDCC
2736 \begin_inset LatexCommand \index{Building SDCC}
2737
2738 \end_inset 
2739
2740
2741 \layout Subsubsection
2742
2743 Building SDCC on Linux
2744 \layout Enumerate
2745
2746
2747 \series medium 
2748 Download the source package
2749 \series default 
2750  either from the SDCC CVS repository or from the 
2751 \begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
2752
2753 \end_inset 
2754
2755
2756 \series medium 
2757 , it will be named something like sdcc
2758 \series default 
2759 .src
2760 \series medium 
2761 .t
2762 \series default 
2763 ar.
2764 \series medium 
2765 gz.
2766 \layout Enumerate
2767
2768
2769 \series medium 
2770 Bring up a command line terminal, such as xterm.
2771 \layout Enumerate
2772
2773
2774 \series medium 
2775 Unpack the file using a command like: 
2776 \family sans 
2777 \series bold 
2778 "tar -xzf sdcc.src.tar.gz
2779 \family default 
2780 \series default 
2781 "
2782 \series medium 
2783 , this will create a sub-directory called sdcc with all of the sources.
2784 \layout Enumerate
2785
2786 Change directory into the main SDCC directory, for example type: 
2787 \family sans 
2788 \series bold 
2789 "cd sdcc
2790 \series default 
2791 ".
2792 \layout Enumerate
2793
2794
2795 \series medium 
2796 Type 
2797 \family sans 
2798 \series bold 
2799 "./configure
2800 \family default 
2801 \series default 
2802 ".
2803  This configures the package for compilation on your system.
2804 \layout Enumerate
2805
2806
2807 \series medium 
2808 Type 
2809 \family sans 
2810 \series bold 
2811 "make
2812 \family default 
2813 \series default 
2814 "
2815 \series medium 
2816 .
2817
2818 \series default 
2819  All of the source packages will compile, this can take a while.
2820 \layout Enumerate
2821
2822
2823 \series medium 
2824 Type 
2825 \family sans 
2826 \series bold 
2827 "make install"
2828 \family default 
2829 \series default 
2830  as root
2831 \series medium 
2832 .
2833
2834 \series default 
2835  This copies the binary executables, the include files, the libraries and
2836  the documentation to the install directories.
2837 \layout Subsubsection
2838
2839 Building SDCC on OSX 2.x
2840 \layout Standard
2841
2842 Follow the instruction for Linux.
2843 \newline 
2844
2845 \newline 
2846 On OSX 2.x it was reported, that the default gcc (version 3.1 20020420 (prerelease
2847 )) fails to compile SDCC.
2848  Fortunately there's also gcc 2.9.x installed, which works fine.
2849  This compiler can be selected by running 'configure' with:
2850 \layout LyX-Code
2851
2852 ./configure CC=gcc2 CXX=g++2
2853 \layout Subsubsection
2854
2855 Cross compiling SDCC on Linux for Windows
2856 \layout Standard
2857
2858 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
2859  See section 'Configure Options'.
2860 \layout Subsubsection
2861
2862 Building SDCC on Windows 
2863 \layout Standard
2864
2865 With the exception of Cygwin the SDCC binaries uCsim and sdcdb can't be
2866  built on Windows.
2867  They use Unix-sockets, which are not available on Win32.
2868 \layout Subsubsection
2869
2870 Windows Install Using a Binary Package
2871 \layout Enumerate
2872
2873 Download the binary package and unpack it using your favorite unpacking
2874  tool (gunzip, WinZip, etc).
2875  This should unpack to a group of sub-directories.
2876  An example directory structure after unpacking the mingw32 package is:
2877  c:
2878 \backslash 
2879 sdcc
2880 \backslash 
2881 bin for the executables, c:
2882 \backslash 
2883 sdcc
2884 \backslash 
2885 include and c:
2886 \backslash 
2887 sdcc
2888 \backslash 
2889 lib for the include and libraries.
2890 \layout Enumerate
2891
2892 Adjust your environment variable PATH to include the location of the bin
2893  directory or start sdcc using the full path.
2894 \layout Subsubsection
2895
2896 Building SDCC using Cygwin and Mingw32
2897 \layout Standard
2898
2899 For building and installing a Cygwin executable follow the instructions
2900  for Linux.
2901 \newline 
2902
2903 \newline 
2904 On Cygwin a 
2905 \begin_inset Quotes sld
2906 \end_inset 
2907
2908 native
2909 \begin_inset Quotes srd
2910 \end_inset 
2911
2912  Win32-binary can be built, which will not need the Cygwin-DLL.
2913  For the necessary 'configure' options see section 'configure options' or
2914  the script 'sdcc/support/scripts/sdcc_cygwinmingw32'.
2915 \newline 
2916
2917 \newline 
2918 In order to install Cygwin on Windows download setup.exe from 
2919 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
2920
2921 \end_inset 
2922
2923 .
2924  Run it, set the 
2925 \begin_inset Quotes sld
2926 \end_inset 
2927
2928 default text file type
2929 \begin_inset Quotes srd
2930 \end_inset 
2931
2932  to 
2933 \begin_inset Quotes sld
2934 \end_inset 
2935
2936 unix
2937 \begin_inset Quotes srd
2938 \end_inset 
2939
2940  and download/install at least the following packages.
2941  Some packages are selected by default, others will be automatically selected
2942  because of dependencies with the manually selected packages.
2943  Never deselect these packages!
2944 \layout Itemize
2945
2946 flex
2947 \layout Itemize
2948
2949 bison
2950 \layout Itemize
2951
2952 gcc ; version 3.x is fine, no need to use the old 2.9x
2953 \layout Itemize
2954
2955 binutils ; selected with gcc
2956 \layout Itemize
2957
2958 make
2959 \layout Itemize
2960
2961 rxvt ; a nice console, which makes life much easier under windoze (see below)
2962 \layout Itemize
2963
2964 man ; not really needed for building SDCC, but you'll miss it sooner or
2965  later
2966 \layout Itemize
2967
2968 less ; not really needed for building SDCC, but you'll miss it sooner or
2969  later
2970 \layout Itemize
2971
2972 cvs ; only if you use CVS access
2973 \layout Standard
2974
2975 If you want to develop something you'll need:
2976 \layout Itemize
2977
2978 python ; for the regression tests
2979 \layout Itemize
2980
2981 gdb ; the gnu debugger, together with the nice GUI 
2982 \begin_inset Quotes sld
2983 \end_inset 
2984
2985 insight
2986 \begin_inset Quotes srd
2987 \end_inset 
2988
2989
2990 \layout Itemize
2991
2992 openssh ; to access the CF or commit changes
2993 \layout Itemize
2994
2995 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
2996  use autoconf-stable!
2997 \layout Standard
2998
2999 rxvt is a nice console with history.
3000  Replace in your cygwin.bat the line
3001 \layout LyX-Code
3002
3003 bash -
3004 \begin_inset ERT
3005 status Collapsed
3006
3007 \layout Standard
3008
3009 \backslash 
3010 /
3011 \end_inset 
3012
3013 -login -i 
3014 \layout Standard
3015
3016 with (one line):
3017 \layout LyX-Code
3018
3019 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
3020 \layout LyX-Code
3021
3022      -bg black -fg white -geometry 100x65 -e bash -
3023 \begin_inset ERT
3024 status Collapsed
3025
3026 \layout Standard
3027
3028 \backslash 
3029 /
3030 \end_inset 
3031
3032 -login
3033 \layout Standard
3034
3035 Text selected with the mouse is automatically copied to the clipboard, pasting
3036  works with shift-insert.
3037 \newline 
3038
3039 \newline 
3040 The other good tip is to make sure you have no //c/-style paths anywhere,
3041  use /cygdrive/c/ instead.
3042  Using // invokes a network lookup which is very slow.
3043  If you think 
3044 \begin_inset Quotes sld
3045 \end_inset 
3046
3047 cygdrive
3048 \begin_inset Quotes srd
3049 \end_inset 
3050
3051  is too long, you can change it with e.g.
3052 \layout LyX-Code
3053
3054 mount -s -u -c /mnt
3055 \layout Standard
3056
3057 SDCC sources use the unix line ending LF.
3058  Life is much easier, if you store the source tree on a drive, which is
3059  mount in binary mode.
3060  And use an editor which can handle LF-only line endings.
3061  Make sure not to commit files with windows line endings.
3062 \layout Subsubsection
3063
3064 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
3065 \layout Standard
3066
3067
3068 \series medium 
3069 Download the source package
3070 \series default 
3071  either from the SDCC CVS repository or from the 
3072 \begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
3073
3074 \end_inset 
3075
3076
3077 \series medium 
3078 , it will be named something like sdcc
3079 \series default 
3080 .src
3081 \series medium 
3082 .tgz.
3083
3084 \series default 
3085  SDCC is distributed with all the projects, workspaces, and files you need
3086  to build it using Visual C++ 6.0/NET (except for sdcdb.exe which currently
3087  doesn't build under MSVC).
3088  The workspace name is 'sdcc.dsw'.
3089  Please note that as it is now, all the executables are created in a folder
3090  called sdcc
3091 \backslash 
3092 bin_vc.
3093  Once built you need to copy the executables from sdcc
3094 \backslash 
3095 bin_vc to sdcc
3096 \backslash 
3097 bin before running SDCC.
3098  
3099 \newline 
3100
3101 \newline 
3102 In order to build SDCC with MSVC you need win32 executables of bison.exe,
3103  flex.exe, and gawk.exe.
3104  One good place to get them is 
3105 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
3106
3107 \end_inset 
3108
3109
3110 \newline 
3111
3112 \newline 
3113 Download the file UnxUtils
3114 \begin_inset LatexCommand \index{UnxUtils}
3115
3116 \end_inset 
3117
3118 .zip.
3119  Now you have to install the utilities and setup MSVC so it can locate the
3120  required programs.
3121  Here there are two alternatives (choose one!):
3122 \layout Enumerate
3123
3124 The easy way:
3125 \newline 
3126
3127 \newline 
3128 a) Extract UnxUtils.zip to your C:
3129 \backslash 
3130  hard disk PRESERVING the original paths, otherwise bison won't work.
3131  (If you are using WinZip make certain that 'Use folder names' is selected)
3132 \newline 
3133
3134 \newline 
3135 b) In the Visual C++ IDE click Tools, Options, select the Directory tab,
3136  in 'Show directories for:' select 'Executable files', and in the directories
3137  window add a new path: 'C:
3138 \backslash 
3139 user
3140 \backslash 
3141 local
3142 \backslash 
3143 wbin', click ok.
3144 \newline 
3145
3146 \newline 
3147 (As a side effect, you get a bunch of Unix utilities that could be useful,
3148  such as diff and patch.)
3149 \layout Enumerate
3150
3151 A more compact way:
3152 \newline 
3153
3154 \newline 
3155 This one avoids extracting a bunch of files you may not use, but requires
3156  some extra work:
3157 \newline 
3158
3159 \newline 
3160 a) Create a directory were to put the tools needed, or use a directory already
3161  present.
3162  Say for example 'C:
3163 \backslash 
3164 util'.
3165 \newline 
3166
3167 \newline 
3168 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and gawk.exe
3169  to such directory WITHOUT preserving the original paths.
3170  (If you are using WinZip make certain that 'Use folder names' is not selected)
3171 \newline 
3172
3173 \newline 
3174 c) Rename bison.exe to '_bison.exe'.
3175 \newline 
3176
3177 \newline 
3178 d) Create a batch file 'bison.bat' in 'C:
3179 \backslash 
3180 util
3181 \backslash 
3182 ' and add these lines: 
3183 \newline 
3184 \SpecialChar ~
3185 \SpecialChar ~
3186 set BISON_SIMPLE=C:
3187 \backslash 
3188 util
3189 \backslash 
3190 bison.simple 
3191 \newline 
3192 \SpecialChar ~
3193 \SpecialChar ~
3194 set BISON_HAIRY=C:
3195 \backslash 
3196 util
3197 \backslash 
3198 bison.hairy
3199 \newline 
3200 \SpecialChar ~
3201 \SpecialChar ~
3202 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
3203 \newline 
3204
3205 \newline 
3206 Steps 'c' and 'd' are needed because bison requires by default that the
3207  files 'bison.simple' and 'bison.hairy' reside in some weird Unix directory,
3208  '/usr/local/share/' I think.
3209  So it is necessary to tell bison where those files are located if they
3210  are not in such directory.
3211  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
3212 \newline 
3213
3214 \newline 
3215 e) In the Visual C++ IDE click Tools, Options, select the Directory tab,
3216  in 'Show directories for:' select 'Executable files', and in the directories
3217  window add a new path: 'c:
3218 \backslash 
3219 util', click ok.
3220  Note that you can use any other path instead of 'c:
3221 \backslash 
3222 util', even the path where the Visual C++ tools are, probably: 'C:
3223 \backslash 
3224 Program Files
3225 \backslash 
3226 Microsoft Visual Studio
3227 \backslash 
3228 Common
3229 \backslash 
3230 Tools'.
3231  So you don't have to execute step 'e' :)
3232 \layout Standard
3233
3234 That is it.
3235  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
3236  the executables from sdcc
3237 \backslash 
3238 bin_vc to sdcc
3239 \backslash 
3240 bin, and you can compile using sdcc.
3241 \layout Subsubsection
3242
3243 Building SDCC Using Borland
3244 \layout Enumerate
3245
3246 From the sdcc directory, run the command "make -f Makefile.bcc".
3247  This should regenerate all the .exe files in the bin directory except for
3248  sdcdb.exe (which currently doesn't build under Borland C++).
3249 \layout Enumerate
3250
3251 If you modify any source files and need to rebuild, be aware that the dependenci
3252 es may not be correctly calculated.
3253  The safest option is to delete all .obj files and run the build again.
3254  From a Cygwin BASH prompt, this can easily be done with the command:
3255 \newline 
3256
3257 \newline 
3258
3259 \family sans 
3260 \series bold 
3261 find .
3262  
3263 \backslash 
3264 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
3265 \backslash 
3266 ) -print -exec rm {} 
3267 \backslash 
3268 ;
3269 \family default 
3270 \series default 
3271
3272 \newline 
3273
3274 \newline 
3275 or on Windows NT/2000/XP from the command prompt with the command:
3276 \newline 
3277
3278 \family sans 
3279 \series bold 
3280
3281 \newline 
3282 del /s *.obj *.lib *.rul
3283 \family default 
3284 \series default 
3285  from the sdcc directory.
3286 \layout Subsection
3287
3288 Building the Documentation
3289 \layout Standard
3290
3291 ...
3292  coming soon
3293 \layout Subsection
3294
3295 Testing out the SDCC Compiler
3296 \layout Standard
3297
3298 The first thing you should do after installing your SDCC compiler is to
3299  see if it runs.
3300  Type 
3301 \family sans 
3302 \series bold 
3303 "sdcc -
3304 \begin_inset ERT
3305 status Collapsed
3306
3307 \layout Standard
3308
3309 \backslash 
3310 /
3311 \end_inset 
3312
3313 -version"
3314 \begin_inset LatexCommand \index{version}
3315
3316 \end_inset 
3317
3318
3319 \family default 
3320 \series default 
3321  at the prompt, and the program should run and tell you the version.
3322  If it doesn't run, or gives a message about not finding sdcc program, then
3323  you need to check over your installation.
3324  Make sure that the sdcc bin directory is in your executable search path
3325  defined by the PATH environment setting (see the Trouble-shooting section
3326  for suggestions).
3327  Make sure that the sdcc program is in the bin folder, if not perhaps something
3328  did not install correctly.
3329 \newline 
3330
3331 \newline 
3332
3333 \series medium 
3334 SDCC 
3335 \series default 
3336 is commonly installed as described in section 
3337 \begin_inset Quotes sld
3338 \end_inset 
3339
3340 Install and search paths
3341 \begin_inset Quotes srd
3342 \end_inset 
3343
3344
3345 \newline 
3346
3347 \newline 
3348
3349 \series medium 
3350 Make sure the compiler works on a very simple example.
3351  Type in the following test.c program using your favorite 
3352 \series default 
3353 ASCII 
3354 \series medium 
3355 editor:
3356 \layout Verse
3357
3358
3359 \family typewriter 
3360 char test;
3361 \newline 
3362
3363 \newline 
3364 void main(void) {
3365 \newline 
3366 \SpecialChar ~
3367 \SpecialChar ~
3368 \SpecialChar ~
3369 \SpecialChar ~
3370 test=0;
3371 \newline 
3372 }
3373 \layout Standard
3374
3375
3376 \series medium 
3377 Compile this using the following command: 
3378 \family sans 
3379 \series bold 
3380 "sdcc -c test.c".
3381
3382 \family default 
3383 \series default 
3384  
3385 \series medium 
3386 If all goes well, the compiler will generate a test.asm and test.rel file.
3387  Congratulations, you've just compiled your first program with SDCC.
3388  We used the -c option to tell SDCC not to link the generated code, just
3389  to keep things simple for this step.
3390 \series default 
3391
3392 \newline 
3393
3394 \newline 
3395
3396 \series medium 
3397 The next step is to try it with the linker.
3398  Type in 
3399 \family sans 
3400 \series bold 
3401 "sdcc test.c
3402 \family default 
3403 \series default 
3404 "
3405 \series medium 
3406 .
3407  If all goes well the compiler will link with the libraries and produce
3408  a test.ihx output file.
3409  If this step fails
3410 \series default 
3411  
3412 \series medium 
3413 (no test.ihx, and the linker generates warnings), then the problem is most
3414  likely that sdcc cannot find the 
3415 \series default 
3416 /
3417 \series medium 
3418 usr/local/share/sdcc/lib directory
3419 \series default 
3420  
3421 \series medium 
3422 (see the Install trouble-shooting section for suggestions).
3423 \series default 
3424
3425 \newline 
3426
3427 \newline 
3428
3429 \series medium 
3430 The final test is to ensure sdcc can use the 
3431 \series default 
3432 standard
3433 \series medium 
3434  header files and libraries.
3435  Edit test.c and change it to the following:
3436 \layout Verse
3437
3438
3439 \family typewriter 
3440 #include <string.h>
3441 \newline 
3442
3443 \newline 
3444 char str1[10];
3445 \newline 
3446
3447 \newline 
3448 void main(void) {
3449 \newline 
3450 \SpecialChar ~
3451 \SpecialChar ~
3452 strcpy(str1, "testing");
3453 \newline 
3454 }
3455 \layout Standard
3456
3457
3458 \series medium 
3459 Compile this by typing 
3460 \family sans 
3461 \series bold 
3462 "sdcc test.c"
3463 \family default 
3464 \series medium 
3465 .
3466  This should generate a test.ihx output file, and it should give no warnings
3467  such as not finding the string.h file.
3468  If it cannot find the string.h file, then the problem is that sdcc cannot
3469  find the /usr/local/share/sdcc/include directory
3470 \series default 
3471  
3472 \series medium 
3473 (see the Install trouble-shooting section for suggestions).
3474
3475 \series default 
3476  Use option 
3477 \series bold 
3478 -
3479 \begin_inset ERT
3480 status Collapsed
3481
3482 \layout Standard
3483
3484 \backslash 
3485 /
3486 \end_inset 
3487
3488 -print-search-dirs
3489 \series default 
3490
3491 \begin_inset LatexCommand \index{-\/-print-search-dirs}
3492
3493 \end_inset 
3494
3495  to find exactly where SDCC is looking for the include and lib files.
3496 \layout Subsection
3497
3498 Install Trouble-shooting
3499 \begin_inset LatexCommand \index{Install trouble-shooting}
3500
3501 \end_inset 
3502
3503
3504 \layout Subsubsection
3505
3506 SDCC does not build correctly.
3507 \layout Standard
3508
3509 A thing to try is starting from scratch by unpacking the .tgz source package
3510  again in an empty directory.
3511  Configure it like:
3512 \newline 
3513
3514 \newline 
3515
3516 \family sans 
3517 \series bold 
3518 ./configure 2>&1 | tee configure.log
3519 \family default 
3520 \series default 
3521
3522 \newline 
3523
3524 \newline 
3525 and build it like:
3526 \newline 
3527
3528 \newline 
3529
3530 \family sans 
3531 \series bold 
3532 make 2>&1 | tee make.log
3533 \family default 
3534 \series default 
3535
3536 \newline 
3537
3538 \newline 
3539 If anything goes wrong, you can review the log files to locate the problem.
3540  Or a relevant part of this can be attached to an email that could be helpful
3541  when requesting help from the mailing list.
3542 \layout Subsubsection
3543
3544 What the 
3545 \begin_inset Quotes sld
3546 \end_inset 
3547
3548 ./configure
3549 \begin_inset Quotes srd
3550 \end_inset 
3551
3552  does
3553 \layout Standard
3554
3555 The 
3556 \begin_inset Quotes sld
3557 \end_inset 
3558
3559 ./configure
3560 \begin_inset Quotes srd
3561 \end_inset 
3562
3563  command is a script that analyzes your system and performs some configuration
3564  to ensure the source package compiles on your system.
3565  It will take a few minutes to run, and will compile a few tests to determine
3566  what compiler features are installed.
3567 \layout Subsubsection
3568
3569 What the 
3570 \begin_inset Quotes sld
3571 \end_inset 
3572
3573 make
3574 \begin_inset Quotes srd
3575 \end_inset 
3576
3577  does.
3578 \layout Standard
3579
3580 This runs the GNU make tool, which automatically compiles all the source
3581  packages into the final installed binary executables.
3582 \layout Subsubsection
3583
3584 What the 
3585 \begin_inset Quotes sld
3586 \end_inset 
3587
3588 make install
3589 \begin_inset Quotes erd
3590 \end_inset 
3591
3592  command does.
3593 \layout Standard
3594
3595 This will install the compiler, other executables libraries and include
3596  files in to the appropriate directories.
3597  See section 
3598 \begin_inset Quotes sld
3599 \end_inset 
3600
3601 Install and Search PATHS
3602 \begin_inset Quotes srd
3603 \end_inset 
3604
3605 .
3606 \newline 
3607 On most systems you will need super-user privileges to do this.
3608 \layout Subsection
3609
3610 Components of SDCC
3611 \layout Standard
3612
3613 SDCC is not just a compiler, but a collection of tools by various developers.
3614  These include linkers, assemblers, simulators and other components.
3615  Here is a summary of some of the components.
3616  Note that the included simulator and assembler have separate documentation
3617  which you can find in the source package in their respective directories.
3618  As SDCC grows to include support for other processors, other packages from
3619  various developers are included and may have their own sets of documentation.
3620 \newline 
3621
3622 \newline 
3623 You might want to look at the files which are installed in <installdir>.
3624  At the time of this writing, we find the following programs for gcc-builds:
3625 \newline 
3626  
3627 \newline 
3628 In <installdir>/bin:
3629 \layout Itemize
3630
3631 sdcc - The compiler.
3632 \layout Itemize
3633
3634 sdcpp - The C preprocessor.
3635 \layout Itemize
3636
3637 asx8051 - The assembler for 8051 type processors.
3638 \layout Itemize
3639
3640 as-z80
3641 \series bold 
3642
3643 \series default 
3644 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
3645 \layout Itemize
3646
3647 aslink -The linker for 8051 type processors.
3648 \layout Itemize
3649
3650 link-z80
3651 \series bold 
3652
3653 \series default 
3654 link-gbz80 - The Z80 and GameBoy Z80 linkers.
3655 \layout Itemize
3656
3657 s51 - The ucSim 8051 simulator.
3658 \layout Itemize
3659
3660 sdcdb - The source debugger.
3661 \layout Itemize
3662
3663 packihx - A tool to pack (compress) Intel hex files.
3664 \layout Standard
3665
3666 In <installdir>/share/sdcc/include
3667 \layout Itemize
3668
3669 the include files
3670 \layout Standard
3671
3672 In <installdir>/share/sdcc/lib
3673 \layout Itemize
3674
3675 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
3676  relocatables.
3677 \layout Standard
3678
3679 In <installdir>/share/sdcc/doc
3680 \layout Itemize
3681
3682 the documentation
3683 \layout Standard
3684
3685 As development for other processors proceeds, this list will expand to include
3686  executables to support processors like AVR, PIC, etc.
3687 \layout Subsubsection
3688
3689 sdcc - The Compiler
3690 \layout Standard
3691
3692 This is the actual compiler, it in turn uses the c-preprocessor and invokes
3693  the assembler and linkage editor.
3694 \layout Subsubsection
3695
3696 sdcpp
3697 \begin_inset LatexCommand \index{sdcpp}
3698
3699 \end_inset 
3700
3701  - The C-Preprocessor
3702 \layout Standard
3703
3704 The preprocessor is a modified version of the GNU preprocessor.
3705  The C preprocessor is used to pull in #include sources, process #ifdef
3706  statements, #defines and so on.
3707 \layout Subsubsection
3708
3709 asx8051, as-z80, as-gbz80, aslink, link-z80, link-gbz80 - The Assemblers
3710  and Linkage Editors
3711 \layout Standard
3712
3713 This is retargettable assembler & linkage editor, it was developed by Alan
3714  Baldwin.
3715  John Hartman created the version for 8051, and I (Sandeep) have made some
3716  enhancements and bug fixes for it to work properly with the SDCC.
3717 \layout Subsubsection
3718
3719 s51 - The Simulator
3720 \begin_inset LatexCommand \index{s51}
3721
3722 \end_inset 
3723
3724
3725 \layout Standard
3726
3727 S51 is a freeware, opensource simulator developed by Daniel Drotos (
3728 \begin_inset LatexCommand \url{mailto:drdani@mazsola.iit.uni-miskolc.hu}
3729
3730 \end_inset 
3731
3732 ).
3733  The simulator is built as part of the build process.
3734  For more information visit Daniel's web site at: 
3735 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
3736
3737 \end_inset 
3738
3739 .
3740  It currently support the core mcs51, the Dallas DS80C390 and the Phillips
3741  XA51 family.
3742 \layout Subsubsection
3743
3744 sdcdb
3745 \begin_inset LatexCommand \index{sdcdb}
3746
3747 \end_inset 
3748
3749  - Source Level Debugger
3750 \layout Standard
3751
3752 Sdcdb is the companion source level debugger.
3753  The current version of the debugger uses Daniel's Simulator S51, but can
3754  be easily changed to use other simulators.
3755 \layout Section
3756 \pagebreak_top 
3757 Using SDCC
3758 \layout Subsection
3759
3760 Compiling
3761 \layout Subsubsection
3762
3763 Single Source File Projects
3764 \layout Standard
3765
3766 For single source file 8051 projects the process is very simple.
3767  Compile your programs with the following command 
3768 \family sans 
3769 \series bold 
3770 "sdcc sourcefile.c".
3771
3772 \family default 
3773 \series default 
3774  This will compile, assemble and link your source file.
3775  Output files are as follows
3776 \layout Itemize
3777
3778 sourcefile.asm
3779 \begin_inset LatexCommand \index{.asm}
3780
3781 \end_inset 
3782
3783  - Assembler source
3784 \begin_inset LatexCommand \index{Assembler source}
3785
3786 \end_inset 
3787
3788  file created by the compiler
3789 \layout Itemize
3790
3791 sourcefile.lst
3792 \begin_inset LatexCommand \index{.lst}
3793
3794 \end_inset 
3795
3796  - Assembler listing
3797 \begin_inset LatexCommand \index{Assembler listing}
3798
3799 \end_inset 
3800
3801  file created by the Assembler
3802 \layout Itemize
3803
3804 sourcefile.rst
3805 \begin_inset LatexCommand \index{.rst}
3806
3807 \end_inset 
3808
3809  - Assembler listing
3810 \begin_inset LatexCommand \index{Assembler listing}
3811
3812 \end_inset 
3813
3814  file updated with linkedit information, created by linkage editor
3815 \layout Itemize
3816
3817 sourcefile.sym
3818 \begin_inset LatexCommand \index{.sym}
3819
3820 \end_inset 
3821
3822  - symbol listing
3823 \begin_inset LatexCommand \index{Symbol listing}
3824
3825 \end_inset 
3826
3827  for the sourcefile, created by the assembler
3828 \layout Itemize
3829
3830 sourcefile.rel
3831 \begin_inset LatexCommand \index{.rel}
3832
3833 \end_inset 
3834
3835  - Object file
3836 \begin_inset LatexCommand \index{Object file}
3837
3838 \end_inset 
3839
3840  created by the assembler, input to Linkage editor
3841 \layout Itemize
3842
3843 sourcefile.map
3844 \begin_inset LatexCommand \index{.map}
3845
3846 \end_inset 
3847
3848  - The memory map
3849 \begin_inset LatexCommand \index{Memory map}
3850
3851 \end_inset 
3852
3853  for the load module, created by the Linker
3854 \layout Itemize
3855
3856 sourcefile.mem
3857 \begin_inset LatexCommand \index{.mem}
3858
3859 \end_inset 
3860
3861  - A file with a summary of the memory usage
3862 \layout Itemize
3863
3864 sourcefile.ihx
3865 \begin_inset LatexCommand \index{.ihx}
3866
3867 \end_inset 
3868
3869  - The load module in Intel hex format
3870 \begin_inset LatexCommand \index{Intel hex format}
3871
3872 \end_inset 
3873
3874  (you can select the Motorola S19 format
3875 \begin_inset LatexCommand \index{Motorola S19 format}
3876
3877 \end_inset 
3878
3879  with -
3880 \begin_inset ERT
3881 status Collapsed
3882
3883 \layout Standard
3884
3885 \backslash 
3886 /
3887 \end_inset 
3888
3889 -out-fmt-s19
3890 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
3891
3892 \end_inset 
3893
3894 .
3895  If you need another format you might want to use objdump
3896 \begin_inset LatexCommand \index{objdump}
3897
3898 \end_inset 
3899
3900  or srecord
3901 \begin_inset LatexCommand \index{srecord}
3902
3903 \end_inset 
3904
3905 )
3906 \layout Itemize
3907
3908 sourcefile.adb
3909 \begin_inset LatexCommand \index{.adb}
3910
3911 \end_inset 
3912
3913  - An intermediate file containing debug information needed to create the
3914  .cdb file (with -
3915 \begin_inset ERT
3916 status Collapsed
3917
3918 \layout Standard
3919
3920 \backslash 
3921 /
3922 \end_inset 
3923
3924 -debug
3925 \begin_inset LatexCommand \index{-\/-debug}
3926
3927 \end_inset 
3928
3929
3930 \layout Itemize
3931
3932 sourcefile.cdb
3933 \begin_inset LatexCommand \index{.cdb}
3934
3935 \end_inset 
3936
3937  - An optional file (with -
3938 \begin_inset ERT
3939 status Collapsed
3940
3941 \layout Standard
3942
3943 \backslash 
3944 /
3945 \end_inset 
3946
3947 -debug) containing debug information
3948 \layout Itemize
3949
3950 sourcefile.
3951  - (no extension)
3952 \begin_inset LatexCommand \index{. (no extension)}
3953
3954 \end_inset 
3955
3956  An optional AOMF51 file containing debug information (with -
3957 \begin_inset ERT
3958 status Collapsed
3959
3960 \layout Standard
3961
3962 \backslash 
3963 /
3964 \end_inset 
3965
3966 -debug)
3967 \layout Itemize
3968
3969 sourcefile.dump*
3970 \begin_inset LatexCommand \index{.dump*}
3971
3972 \end_inset 
3973
3974  - Dump file to debug the compiler it self (with -
3975 \begin_inset ERT
3976 status Collapsed
3977
3978 \layout Standard
3979
3980 \backslash 
3981 /
3982 \end_inset 
3983
3984 -dumpall) (see section 
3985 \begin_inset Quotes sld
3986 \end_inset 
3987
3988 Anatomy of the compiler
3989 \begin_inset Quotes srd
3990 \end_inset 
3991
3992 ).
3993 \layout Subsubsection
3994
3995 Projects with Multiple Source Files
3996 \layout Standard
3997
3998 SDCC can compile only ONE file at a time.
3999  Let us for example assume that you have a project containing the following
4000  files:
4001 \newline 
4002
4003 \newline 
4004 foo1.c (contains some functions)
4005 \newline 
4006 foo2.c (contains some more functions)
4007 \newline 
4008 foomain.c (contains more functions and the function main)
4009 \newline 
4010
4011 \size footnotesize 
4012
4013 \newline 
4014
4015 \size default 
4016 The first two files will need to be compiled separately with the commands:
4017 \size footnotesize 
4018  
4019 \size default 
4020
4021 \newline 
4022
4023 \newline 
4024
4025 \family sans 
4026 \series bold 
4027 sdcc\SpecialChar ~
4028 -c\SpecialChar ~
4029 foo1.c
4030 \family default 
4031 \series default 
4032 \size footnotesize 
4033
4034 \newline 
4035
4036 \family sans 
4037 \series bold 
4038 \size default 
4039 sdcc\SpecialChar ~
4040 -c\SpecialChar ~
4041 foo2.c
4042 \family default 
4043 \series default 
4044
4045 \newline 
4046
4047 \newline 
4048 Then compile the source file containing the 
4049 \emph on 
4050 main()
4051 \emph default 
4052  function and link
4053 \begin_inset LatexCommand \index{Linker}
4054
4055 \end_inset 
4056
4057  the files together with the following command: 
4058 \newline 
4059
4060 \newline 
4061
4062 \family sans 
4063 \series bold 
4064 sdcc\SpecialChar ~
4065 foomain.c\SpecialChar ~
4066 foo1.rel\SpecialChar ~
4067 foo2.rel
4068 \family default 
4069 \series default 
4070
4071 \begin_inset LatexCommand \index{.rel}
4072
4073 \end_inset 
4074
4075
4076 \newline 
4077
4078 \newline 
4079 Alternatively, 
4080 \emph on 
4081 foomain.c 
4082 \emph default 
4083 can be separately compiled as well: 
4084 \family sans 
4085 \series bold 
4086
4087 \newline 
4088
4089 \newline 
4090 sdcc\SpecialChar ~
4091 -c\SpecialChar ~
4092 foomain.c
4093 \newline 
4094 sdcc foomain.rel foo1.rel foo2.rel
4095 \newline 
4096
4097 \newline 
4098
4099 \family default 
4100 \series default 
4101 The file containing the 
4102 \emph on 
4103 main()
4104 \emph default 
4105  function
4106 \emph on 
4107  
4108 \emph default 
4109 \noun on 
4110 must
4111 \noun default 
4112  be the 
4113 \noun on 
4114 first
4115 \noun default 
4116  file specified in the command line, since the linkage editor processes
4117  file in the order they are presented to it.
4118  The linker is invoked from sdcc using a script file with extension .lnk
4119 \begin_inset LatexCommand \index{.lnk}
4120
4121 \end_inset 
4122
4123 .
4124  You can view this file to troubleshoot linking problems such as those arising
4125  from missing libraries.
4126 \layout Subsubsection
4127
4128 Projects with Additional Libraries
4129 \begin_inset LatexCommand \index{Libraries}
4130
4131 \end_inset 
4132
4133
4134 \layout Standard
4135
4136 Some reusable routines may be compiled into a library, see the documentation
4137  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
4138  for how to create a 
4139 \emph on 
4140 .lib
4141 \begin_inset LatexCommand \index{.lib}
4142
4143 \end_inset 
4144
4145
4146 \emph default 
4147  library file.
4148  Libraries created in this manner can be included in the command line.
4149  Make sure you include the -L <library-path> option to tell the linker where
4150  to look for these files if they are not in the current directory.
4151  Here is an example, assuming you have the source file 
4152 \emph on 
4153 foomain.c
4154 \emph default 
4155  and a library
4156 \emph on 
4157  foolib.lib
4158 \emph default 
4159  in the directory 
4160 \emph on 
4161 mylib
4162 \emph default 
4163  (if that is not the same as your current project):
4164 \newline 
4165
4166 \newline 
4167
4168 \family sans 
4169 \series bold 
4170 sdcc foomain.c foolib.lib -L mylib
4171 \newline 
4172
4173 \newline 
4174
4175 \family default 
4176 \series default 
4177 Note here that
4178 \emph on 
4179  mylib
4180 \emph default 
4181  must be an absolute path name.
4182 \newline 
4183
4184 \newline 
4185 The most efficient way to use libraries is to keep separate modules in separate
4186  source files.
4187  The lib file now should name all the modules.rel
4188 \begin_inset LatexCommand \index{rel}
4189
4190 \end_inset 
4191
4192  files.
4193  For an example see the standard library file 
4194 \emph on 
4195 libsdcc.lib
4196 \emph default 
4197  in the directory <installdir>/share/lib/small.
4198 \layout Subsection
4199
4200 Command Line Options
4201 \begin_inset LatexCommand \index{Command Line Options}
4202
4203 \end_inset 
4204
4205
4206 \layout Subsubsection
4207
4208 Processor Selection Options
4209 \begin_inset LatexCommand \index{Options processor selection}
4210
4211 \end_inset 
4212
4213
4214 \begin_inset LatexCommand \index{Processor selection options}
4215
4216 \end_inset 
4217
4218
4219 \layout List
4220 \labelwidthstring 00.00.0000
4221
4222
4223 \series bold 
4224 -mmcs51
4225 \begin_inset LatexCommand \index{-mmcs51}
4226
4227 \end_inset 
4228
4229
4230 \series default 
4231  Generate code for the MCS51
4232 \begin_inset LatexCommand \index{MCS51}
4233
4234 \end_inset 
4235
4236  family of processors.
4237  This is the default processor target.
4238 \layout List
4239 \labelwidthstring 00.00.0000
4240
4241
4242 \series bold 
4243 -mds390
4244 \begin_inset LatexCommand \index{-mds390}
4245
4246 \end_inset 
4247
4248
4249 \series default 
4250  Generate code for the DS80C390
4251 \begin_inset LatexCommand \index{DS80C390}
4252
4253 \end_inset 
4254
4255  processor.
4256 \layout List
4257 \labelwidthstring 00.00.0000
4258
4259
4260 \series bold 
4261 -mds400
4262 \begin_inset LatexCommand \index{-mds400}
4263
4264 \end_inset 
4265
4266
4267 \series default 
4268  Generate code for the DS80C400
4269 \begin_inset LatexCommand \index{DS80C400}
4270
4271 \end_inset 
4272
4273  processor.
4274 \layout List
4275 \labelwidthstring 00.00.0000
4276
4277
4278 \series bold 
4279 -mz80
4280 \begin_inset LatexCommand \index{-mz80}
4281
4282 \end_inset 
4283
4284
4285 \series default 
4286  Generate code for the Z80
4287 \begin_inset LatexCommand \index{Z80}
4288
4289 \end_inset 
4290
4291  family of processors.
4292 \layout List
4293 \labelwidthstring 00.00.0000
4294
4295
4296 \series bold 
4297 -mgbz80
4298 \begin_inset LatexCommand \index{-mgbz80}
4299
4300 \end_inset 
4301
4302
4303 \series default 
4304  Generate code for the GameBoy Z80
4305 \begin_inset LatexCommand \index{GameBoy Z80}
4306
4307 \end_inset 
4308
4309  processor.
4310 \layout List
4311 \labelwidthstring 00.00.0000
4312
4313
4314 \series bold 
4315 -mavr
4316 \begin_inset LatexCommand \index{-mavr}
4317
4318 \end_inset 
4319
4320
4321 \series default 
4322  Generate code for the Atmel AVR
4323 \begin_inset LatexCommand \index{AVR}
4324
4325 \end_inset 
4326
4327  processor (In development, not complete).
4328  AVR users should probably have a look at avr-gcc 
4329 \begin_inset LatexCommand \url[FIXME: official URL?]{ http://savannah.nongnu.org/download/avr-libc/snapshots/}
4330
4331 \end_inset 
4332
4333 .
4334 \layout Comment
4335
4336 I think it is fair to direct users there for now.
4337  Open source is also about avoiding unnecessary work .
4338  But I didn't find the 'official' link.
4339 \layout List
4340 \labelwidthstring 00.00.0000
4341
4342
4343 \series bold 
4344 -mpic14
4345 \begin_inset LatexCommand \index{-mpic14}
4346
4347 \end_inset 
4348
4349
4350 \series default 
4351  Generate code for the PIC 14
4352 \begin_inset LatexCommand \index{PIC14}
4353
4354 \end_inset 
4355
4356 -bit processors (In development, not complete).
4357 \layout Comment
4358
4359 p16f627 p16f628 p16f84 p16f873 p16f877?
4360 \layout List
4361 \labelwidthstring 00.00.0000
4362
4363
4364 \series bold 
4365 -mtlcs900h
4366 \series default 
4367  Generate code for the Toshiba TLCS-900H
4368 \begin_inset LatexCommand \index{TLCS-900H}
4369
4370 \end_inset 
4371
4372  processor (In development, not complete).
4373 \layout List
4374 \labelwidthstring 00.00.0000
4375
4376
4377 \series bold 
4378 -mxa51
4379 \begin_inset LatexCommand \index{-mxa51}
4380
4381 \end_inset 
4382
4383
4384 \series default 
4385  Generate code for the Phillips XA51
4386 \begin_inset LatexCommand \index{XA51}
4387
4388 \end_inset 
4389
4390  processor (In development, not complete).
4391 \layout Subsubsection
4392
4393 Preprocessor Options
4394 \begin_inset LatexCommand \index{Options preprocessor}
4395
4396 \end_inset 
4397
4398
4399 \begin_inset LatexCommand \index{Preprocessor options}
4400
4401 \end_inset 
4402
4403
4404 \layout List
4405 \labelwidthstring 00.00.0000
4406
4407
4408 \series bold 
4409 -I<path>
4410 \begin_inset LatexCommand \index{-I<path>}
4411
4412 \end_inset 
4413
4414
4415 \series default 
4416  The additional location where the pre processor will look for <..h> or 
4417 \begin_inset Quotes eld
4418 \end_inset 
4419
4420 ..h
4421 \begin_inset Quotes erd
4422 \end_inset 
4423
4424  files.
4425 \layout List
4426 \labelwidthstring 00.00.0000
4427
4428
4429 \series bold 
4430 -D<macro[=value]>
4431 \begin_inset LatexCommand \index{-D<macro[=value]>}
4432
4433 \end_inset 
4434
4435
4436 \series default 
4437  Command line definition of macros.
4438  Passed to the pre processor.
4439 \layout List
4440 \labelwidthstring 00.00.0000
4441
4442
4443 \series bold 
4444 -M
4445 \begin_inset LatexCommand \index{-M}
4446
4447 \end_inset 
4448
4449
4450 \series default 
4451  Tell the preprocessor to output a rule suitable for make describing the
4452  dependencies of each object file.
4453  For each source file, the preprocessor outputs one make-rule whose target
4454  is the object file name for that source file and whose dependencies are
4455  all the files `#include'd in it.
4456  This rule may be a single line or may be continued with `
4457 \backslash 
4458 '-newline if it is long.
4459  The list of rules is printed on standard output instead of the preprocessed
4460  C program.
4461  `-M' implies `-E'.
4462 \layout List
4463 \labelwidthstring 00.00.0000
4464
4465
4466 \series bold 
4467 -C
4468 \begin_inset LatexCommand \index{-C}
4469
4470 \end_inset 
4471
4472
4473 \series default 
4474  Tell the preprocessor not to discard comments.
4475  Used with the `-E' option.
4476 \layout List
4477 \labelwidthstring 00.00.0000
4478
4479
4480 \series bold 
4481 -MM
4482 \begin_inset LatexCommand \index{-MM}
4483
4484 \end_inset 
4485
4486
4487 \size large 
4488 \bar under 
4489  
4490 \series default 
4491 \size default 
4492 \bar default 
4493 Like `-M' but the output mentions only the user header files included with
4494  `#include 
4495 \begin_inset Quotes eld
4496 \end_inset 
4497
4498 file"'.
4499  System header files included with `#include <file>' are omitted.
4500 \layout List
4501 \labelwidthstring 00.00.0000
4502
4503
4504 \series bold 
4505 -Aquestion(answer)
4506 \begin_inset LatexCommand \index{-Aquestion(answer)}
4507
4508 \end_inset 
4509
4510
4511 \series default 
4512  Assert the answer answer for question, in case it is tested with a preprocessor
4513  conditional such as `#if #question(answer)'.
4514  `-A-' disables the standard assertions that normally describe the target
4515  machine.
4516 \layout List
4517 \labelwidthstring 00.00.0000
4518
4519
4520 \series bold 
4521 -Aquestion
4522 \series default 
4523  (answer) Assert the answer answer for question, in case it is tested with
4524  a preprocessor conditional such as `#if #question(answer)'.
4525  `-A-' disables the standard assertions that normally describe the target
4526  machine.
4527 \layout List
4528 \labelwidthstring 00.00.0000
4529
4530
4531 \series bold 
4532 -Umacro
4533 \begin_inset LatexCommand \index{-Umacro}
4534
4535 \end_inset 
4536
4537
4538 \series default 
4539  Undefine macro macro.
4540  `-U' options are evaluated after all `-D' options, but before any `-include'
4541  and `-imacros' options.
4542 \layout List
4543 \labelwidthstring 00.00.0000
4544
4545
4546 \series bold 
4547 -dM
4548 \begin_inset LatexCommand \index{-dM}
4549
4550 \end_inset 
4551
4552
4553 \series default 
4554  Tell the preprocessor to output only a list of the macro definitions that
4555  are in effect at the end of preprocessing.
4556  Used with the `-E' option.
4557 \layout List
4558 \labelwidthstring 00.00.0000
4559
4560
4561 \series bold 
4562 -dD
4563 \begin_inset LatexCommand \index{-dD}
4564
4565 \end_inset 
4566
4567
4568 \series default 
4569  Tell the preprocessor to pass all macro definitions into the output, in
4570  their proper sequence in the rest of the output.
4571 \layout List
4572 \labelwidthstring 00.00.0000
4573
4574
4575 \series bold 
4576 -dN
4577 \begin_inset LatexCommand \index{-dN}
4578
4579 \end_inset 
4580
4581
4582 \size large 
4583 \bar under 
4584  
4585 \series default 
4586 \size default 
4587 \bar default 
4588 Like `-dD' except that the macro arguments and contents are omitted.
4589  Only `#define name' is included in the output.
4590 \layout Subsubsection
4591
4592 Linker Options
4593 \begin_inset LatexCommand \index{Options linker}
4594
4595 \end_inset 
4596
4597
4598 \begin_inset LatexCommand \index{Linker options}
4599
4600 \end_inset 
4601
4602
4603 \layout List
4604 \labelwidthstring 00.00.0000
4605
4606
4607 \series bold 
4608 -L\SpecialChar ~
4609 -
4610 \series default 
4611
4612 \begin_inset ERT
4613 status Collapsed
4614
4615 \layout Standard
4616
4617 \backslash 
4618 /
4619 \end_inset 
4620
4621
4622 \series bold 
4623 -lib-path
4624 \begin_inset LatexCommand \index{-\/-lib-path}
4625
4626 \end_inset 
4627
4628
4629 \begin_inset LatexCommand \index{-L -\/-lib-path}
4630
4631 \end_inset 
4632
4633
4634 \bar under 
4635  
4636 \series default 
4637 \bar default 
4638 <absolute path to additional libraries> This option is passed to the linkage
4639  editor's additional libraries
4640 \begin_inset LatexCommand \index{Libraries}
4641
4642 \end_inset 
4643
4644  search path.
4645  The path name must be absolute.
4646  Additional library files may be specified in the command line.
4647  See section Compiling programs for more details.
4648 \layout List
4649 \labelwidthstring 00.00.0000
4650
4651
4652 \series bold 
4653 -
4654 \begin_inset ERT
4655 status Collapsed
4656
4657 \layout Standard
4658
4659 \backslash 
4660 /
4661 \end_inset 
4662
4663 -xram-loc
4664 \series default 
4665
4666 \begin_inset LatexCommand \index{-\/-xram-loc}
4667
4668 \end_inset 
4669
4670 <Value> The start location of the external ram
4671 \begin_inset LatexCommand \index{xdata}
4672
4673 \end_inset 
4674
4675 , default value is 0.
4676  The value entered can be in Hexadecimal or Decimal format, e.g.: -
4677 \begin_inset ERT
4678 status Collapsed
4679
4680 \layout Standard
4681
4682 \backslash 
4683 /
4684 \end_inset 
4685
4686 -xram-loc 0x8000 or -
4687 \begin_inset ERT
4688 status Collapsed
4689
4690 \layout Standard
4691
4692 \backslash 
4693 /
4694 \end_inset 
4695
4696 -xram-loc 32768.
4697 \layout List
4698 \labelwidthstring 00.00.0000
4699
4700
4701 \series bold 
4702 -
4703 \begin_inset ERT
4704 status Collapsed
4705
4706 \layout Standard
4707
4708 \backslash 
4709 /
4710 \end_inset 
4711
4712 -code-loc
4713 \series default 
4714
4715 \begin_inset LatexCommand \index{-\/-code-loc}
4716
4717 \end_inset 
4718
4719 <Value> The start location of the code
4720 \begin_inset LatexCommand \index{code}
4721
4722 \end_inset 
4723
4724  segment, default value 0.
4725  Note when this option is used the interrupt vector table is also relocated
4726  to the given address.
4727  The value entered can be in Hexadecimal or Decimal format, e.g.: -
4728 \begin_inset ERT
4729 status Collapsed
4730
4731 \layout Standard
4732
4733 \backslash 
4734 /
4735 \end_inset 
4736
4737 -code-loc 0x8000 or -
4738 \begin_inset ERT
4739 status Collapsed
4740
4741 \layout Standard
4742
4743 \backslash 
4744 /
4745 \end_inset 
4746
4747 -code-loc 32768.
4748 \layout List
4749 \labelwidthstring 00.00.0000
4750
4751
4752 \series bold 
4753 -
4754 \begin_inset ERT
4755 status Collapsed
4756
4757 \layout Standard
4758
4759 \backslash 
4760 /
4761 \end_inset 
4762
4763 -stack-loc
4764 \series default 
4765
4766 \begin_inset LatexCommand \index{-\/-stack-loc}
4767
4768 \end_inset 
4769
4770 <Value> By default the stack
4771 \begin_inset LatexCommand \index{stack}
4772
4773 \end_inset 
4774
4775  is placed after the data segment.
4776  Using this option the stack can be placed anywhere in the internal memory
4777  space of the 8051.
4778  The value entered can be in Hexadecimal or Decimal format, e.g.
4779  -
4780 \begin_inset ERT
4781 status Collapsed
4782
4783 \layout Standard
4784
4785 \backslash 
4786 /
4787 \end_inset 
4788
4789 -stack-loc 0x20 or -
4790 \begin_inset ERT
4791 status Collapsed
4792
4793 \layout Standard
4794
4795 \backslash 
4796 /
4797 \end_inset 
4798
4799 -stack-loc 32.
4800  Since the sp register is incremented before a push or call, the initial
4801  sp will be set to one byte prior the provided value.
4802  The provided value should not overlap any other memory areas such as used
4803  register banks or the data segment and with enough space for the current
4804  application.
4805 \layout List
4806 \labelwidthstring 00.00.0000
4807
4808
4809 \series bold 
4810 -
4811 \begin_inset ERT
4812 status Collapsed
4813
4814 \layout Standard
4815
4816 \backslash 
4817 /
4818 \end_inset 
4819
4820 -data-loc
4821 \series default 
4822
4823 \begin_inset LatexCommand \index{-\/-data-loc}
4824
4825 \end_inset 
4826
4827 <Value> The start location of the internal ram data
4828 \begin_inset LatexCommand \index{data}
4829
4830 \end_inset 
4831
4832  segment.
4833  The value entered can be in Hexadecimal or Decimal format, eg.
4834  -
4835 \begin_inset ERT
4836 status Collapsed
4837
4838 \layout Standard
4839
4840 \backslash 
4841 /
4842 \end_inset 
4843
4844 -data-loc 0x20 or -
4845 \begin_inset ERT
4846 status Collapsed
4847
4848 \layout Standard
4849
4850 \backslash 
4851 /
4852 \end_inset 
4853
4854 -data-loc 32.
4855  (By default, the start location of the internal ram data segment  is set
4856  as low as possible in memory, taking into account the used register banks
4857  and the bit segment at address 0x20.
4858  For example if register banks 0 and 1 are used without bit variables, the
4859  data segment will be set, if -
4860 \begin_inset ERT
4861 status Collapsed
4862
4863 \layout Standard
4864
4865 \backslash 
4866 /
4867 \end_inset 
4868
4869 -data-loc is not used, to location 0x10.)
4870 \layout List
4871 \labelwidthstring 00.00.0000
4872
4873
4874 \series bold 
4875 -
4876 \begin_inset ERT
4877 status Collapsed
4878
4879 \layout Standard
4880
4881 \backslash 
4882 /
4883 \end_inset 
4884
4885 -idata-loc
4886 \series default 
4887
4888 \begin_inset LatexCommand \index{-\/-idata-loc}
4889
4890 \end_inset 
4891
4892 <Value> The start location of the indirectly addressable internal ram
4893 \begin_inset LatexCommand \index{idata}
4894
4895 \end_inset 
4896
4897 , default value is 0x80.
4898  The value entered can be in Hexadecimal or Decimal format, eg.
4899  -
4900 \begin_inset ERT
4901 status Collapsed
4902
4903 \layout Standard
4904
4905 \backslash 
4906 /
4907 \end_inset 
4908
4909 -idata-loc 0x88 or -
4910 \begin_inset ERT
4911 status Collapsed
4912
4913 \layout Standard
4914
4915 \backslash 
4916 /
4917 \end_inset 
4918
4919 -idata-loc 136.
4920 \layout List
4921 \labelwidthstring 00.00.0000
4922
4923
4924 \series bold 
4925 -
4926 \begin_inset ERT
4927 status Collapsed
4928
4929 \layout Standard
4930
4931 \backslash 
4932 /
4933 \end_inset 
4934
4935 -out-fmt-ihx
4936 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
4937
4938 \end_inset 
4939
4940
4941 \bar under 
4942  
4943 \series default 
4944 \bar default 
4945 The linker output (final object code) is in Intel Hex format.
4946 \begin_inset LatexCommand \index{Intel hex format}
4947
4948 \end_inset 
4949
4950  (This is the default option).
4951 \layout List
4952 \labelwidthstring 00.00.0000
4953
4954
4955 \series bold 
4956 -
4957 \begin_inset ERT
4958 status Collapsed
4959
4960 \layout Standard
4961
4962 \backslash 
4963 /
4964 \end_inset 
4965
4966 -out-fmt-s19
4967 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
4968
4969 \end_inset 
4970
4971
4972 \bar under 
4973  
4974 \series default 
4975 \bar default 
4976 The linker output (final object code) is in Motorola S19 format
4977 \begin_inset LatexCommand \index{Motorola S19 format}
4978
4979 \end_inset 
4980
4981 .
4982 \layout Subsubsection
4983
4984 MCS51 Options
4985 \begin_inset LatexCommand \index{Options MCS51}
4986
4987 \end_inset 
4988
4989
4990 \begin_inset LatexCommand \index{MCS51 options}
4991
4992 \end_inset 
4993
4994
4995 \layout List
4996 \labelwidthstring 00.00.0000
4997
4998
4999 \series bold 
5000 -
5001 \begin_inset ERT
5002 status Collapsed
5003
5004 \layout Standard
5005
5006 \backslash 
5007 /
5008 \end_inset 
5009
5010 -model-large
5011 \begin_inset LatexCommand \index{-\/-model-large}
5012
5013 \end_inset 
5014
5015
5016 \series default 
5017  Generate code for Large model programs see section Memory Models for more
5018  details.
5019  If this option is used all source files in the project should be compiled
5020  with this option.
5021  In addition the standard library routines are compiled with small model,
5022  they will need to be recompiled.
5023 \layout List
5024 \labelwidthstring 00.00.0000
5025
5026
5027 \series bold 
5028 -
5029 \begin_inset ERT
5030 status Collapsed
5031
5032 \layout Standard
5033
5034 \backslash 
5035 /
5036 \end_inset 
5037
5038 -model-small
5039 \begin_inset LatexCommand \index{-\/-model-small}
5040
5041 \end_inset 
5042
5043
5044 \series default 
5045 \size large 
5046 \emph on 
5047  
5048 \size default 
5049 \emph default 
5050 Generate code for Small Model programs see section Memory Models for more
5051  details.
5052  This is the default model.
5053 \layout Subsubsection
5054
5055 DS390 Options
5056 \begin_inset LatexCommand \index{Options DS390}
5057
5058 \end_inset 
5059
5060
5061 \begin_inset LatexCommand \index{DS390 options}
5062
5063 \end_inset 
5064
5065
5066 \layout List
5067 \labelwidthstring 00.00.0000
5068
5069
5070 \series bold 
5071 -
5072 \begin_inset ERT
5073 status Collapsed
5074
5075 \layout Standard
5076
5077 \backslash 
5078 /
5079 \end_inset 
5080
5081 -model-flat24
5082 \series default 
5083
5084 \begin_inset LatexCommand \index{-\/-model-flat24}
5085
5086 \end_inset 
5087
5088
5089 \size large 
5090 \emph on 
5091  
5092 \size default 
5093 \emph default 
5094 Generate 24-bit flat mode code.
5095  This is the one and only that the ds390 code generator supports right now
5096  and is default when using 
5097 \emph on 
5098 -mds390
5099 \emph default 
5100 .
5101  See section Memory Models for more details.
5102 \layout List
5103 \labelwidthstring 00.00.0000
5104
5105
5106 \series bold 
5107 -
5108 \begin_inset ERT
5109 status Collapsed
5110
5111 \layout Standard
5112
5113 \backslash 
5114 /
5115 \end_inset 
5116
5117 -stack-10bit
5118 \series default 
5119
5120 \begin_inset LatexCommand \index{-\/-stack-10bit}
5121
5122 \end_inset 
5123
5124  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
5125  This is the one and only that the ds390 code generator supports right now
5126  and is default when using 
5127 \emph on 
5128 -mds390
5129 \emph default 
5130 .
5131  In this mode, the stack is located in the lower 1K of the internal RAM,
5132  which is mapped to 0x400000.
5133  Note that the support is incomplete, since it still uses a single byte
5134  as the stack pointer.
5135  This means that only the lower 256 bytes of the potential 1K stack space
5136  will actually be used.
5137  However, this does allow you to reclaim the precious 256 bytes of low RAM
5138  for use for the DATA and IDATA segments.
5139  The compiler will not generate any code to put the processor into 10 bit
5140  stack mode.
5141  It is important to ensure that the processor is in this mode before calling
5142  any re-entrant functions compiled with this option.
5143  In principle, this should work with the 
5144 \emph on 
5145 -
5146 \begin_inset ERT
5147 status Collapsed
5148
5149 \layout Standard
5150
5151 \backslash 
5152 /
5153 \end_inset 
5154
5155 -stack-auto
5156 \begin_inset LatexCommand \index{-\/-stack-auto}
5157
5158 \end_inset 
5159
5160
5161 \emph default 
5162  option, but that has not been tested.
5163  It is incompatible with the 
5164 \emph on 
5165 -
5166 \begin_inset ERT
5167 status Collapsed
5168
5169 \layout Standard
5170
5171 \backslash 
5172 /
5173 \end_inset 
5174
5175 -xstack
5176 \begin_inset LatexCommand \index{-\/-xstack}
5177
5178 \end_inset 
5179
5180
5181 \emph default 
5182  option.
5183  It also only makes sense if the processor is in 24 bit contiguous addressing
5184  mode (see the 
5185 \emph on 
5186 -
5187 \begin_inset ERT
5188 status Collapsed
5189
5190 \layout Standard
5191
5192 \backslash 
5193 /
5194 \end_inset 
5195
5196 -model-flat24 option
5197 \emph default 
5198 ).
5199 \layout Subsubsection
5200
5201 Optimization Options
5202 \begin_inset LatexCommand \index{Options optimization}
5203
5204 \end_inset 
5205
5206
5207 \begin_inset LatexCommand \index{Optimization options}
5208
5209 \end_inset 
5210
5211
5212 \layout List
5213 \labelwidthstring 00.00.0000
5214
5215
5216 \series bold 
5217 -
5218 \begin_inset ERT
5219 status Collapsed
5220
5221 \layout Standard
5222
5223 \backslash 
5224 /
5225 \end_inset 
5226
5227 -nogcse
5228 \begin_inset LatexCommand \index{-\/-nogcse}
5229
5230 \end_inset 
5231
5232
5233 \series default 
5234  Will not do global subexpression elimination, this option may be used when
5235  the compiler creates undesirably large stack/data spaces to store compiler
5236  temporaries.
5237  A warning message will be generated when this happens and the compiler
5238  will indicate the number of extra bytes it allocated.
5239  It recommended that this option NOT be used, #pragma\SpecialChar ~
5240 NOGCSE
5241 \begin_inset LatexCommand \index{\#pragma NOGCSE}
5242
5243 \end_inset 
5244
5245  can be used to turn off global subexpression elimination
5246 \begin_inset LatexCommand \index{Subexpression elimination}
5247
5248 \end_inset 
5249
5250  for a given function only.
5251 \layout List
5252 \labelwidthstring 00.00.0000
5253
5254
5255 \series bold 
5256 -
5257 \begin_inset ERT
5258 status Collapsed
5259
5260 \layout Standard
5261
5262 \backslash 
5263 /
5264 \end_inset 
5265
5266 -noinvariant
5267 \begin_inset LatexCommand \index{-\/-noinvariant}
5268
5269 \end_inset 
5270
5271
5272 \series default 
5273  Will not do loop invariant optimizations, this may be turned off for reasons
5274  explained for the previous option.
5275  For more details of loop optimizations performed see section Loop Invariants.It
5276  recommended that this option NOT be used, #pragma\SpecialChar ~
5277 NOINVARIANT
5278 \begin_inset LatexCommand \index{\#pragma NOINVARIANT}
5279
5280 \end_inset 
5281
5282  can be used to turn off invariant optimizations for a given function only.
5283 \layout List
5284 \labelwidthstring 00.00.0000
5285
5286
5287 \series bold 
5288 -
5289 \begin_inset ERT
5290 status Collapsed
5291
5292 \layout Standard
5293
5294 \backslash 
5295 /
5296 \end_inset 
5297
5298 -noinduction
5299 \begin_inset LatexCommand \index{-\/-noinduction}
5300
5301 \end_inset 
5302
5303
5304 \series default 
5305  Will not do loop induction optimizations, see section strength reduction
5306  for more details.It is recommended that this option is NOT used, #pragma\SpecialChar ~
5307 NOINDUCT
5308 ION
5309 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
5310
5311 \end_inset 
5312
5313  can be used to turn off induction optimizations for a given function only.
5314 \layout List
5315 \labelwidthstring 00.00.0000
5316
5317
5318 \series bold 
5319 -
5320 \begin_inset ERT
5321 status Collapsed
5322
5323 \layout Standard
5324
5325 \backslash 
5326 /
5327 \end_inset 
5328
5329 -nojtbound
5330 \begin_inset LatexCommand \index{-\/-nojtbound}
5331
5332 \end_inset 
5333
5334
5335 \size large 
5336 \bar under 
5337  
5338 \series default 
5339 \size default 
5340 \bar default 
5341  Will not generate boundary condition check when switch statements
5342 \begin_inset LatexCommand \index{switch statement}
5343
5344 \end_inset 
5345
5346  are implemented using jump-tables.
5347  See section Switch Statements for more details.
5348  It is recommended that this option is NOT used, #pragma\SpecialChar ~
5349 NOJTBOUND
5350 \begin_inset LatexCommand \index{\#pragma NOJTBOUND}
5351
5352 \end_inset 
5353
5354  can be used to turn off boundary checking for jump tables for a given function
5355  only.
5356 \layout List
5357 \labelwidthstring 00.00.0000
5358
5359
5360 \series bold 
5361 -
5362 \begin_inset ERT
5363 status Collapsed
5364
5365 \layout Standard
5366
5367 \backslash 
5368 /
5369 \end_inset 
5370
5371 -noloopreverse
5372 \begin_inset LatexCommand \index{-\/-noloopreverse}
5373
5374 \end_inset 
5375
5376
5377 \series default 
5378 \size large 
5379  
5380 \size default 
5381 Will not do loop reversal 
5382 \begin_inset LatexCommand \index{Loop reversing}
5383
5384 \end_inset 
5385
5386 optimization.
5387 \layout List
5388 \labelwidthstring 00.00.0000
5389
5390 -
5391 \begin_inset ERT
5392 status Collapsed
5393
5394 \layout Standard
5395
5396 \backslash 
5397 /
5398 \end_inset 
5399
5400 -
5401 \series bold 
5402 nolabelopt
5403 \series default 
5404  
5405 \begin_inset LatexCommand \index{-\/-nolabelopt }
5406
5407 \end_inset 
5408
5409 Will not optimize labels (makes the dumpfiles more readable).
5410 \layout List
5411 \labelwidthstring 00.00.0000
5412
5413
5414 \series bold 
5415 -
5416 \begin_inset ERT
5417 status Collapsed
5418
5419 \layout Standard
5420
5421 \backslash 
5422 /
5423 \end_inset 
5424
5425 -no-xinit-opt
5426 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
5427
5428 \end_inset 
5429
5430
5431 \series default 
5432  Will not memcpy initialized data in far space from code space.
5433  This saves a few bytes in code space if you don't have initialized data.
5434 \layout Subsubsection
5435
5436 Other Options
5437 \begin_inset LatexCommand \index{Options other}
5438
5439 \end_inset 
5440
5441
5442 \layout List
5443 \labelwidthstring 00.00.0000
5444
5445
5446 \series bold 
5447 -c\SpecialChar ~
5448 -
5449 \begin_inset ERT
5450 status Collapsed
5451
5452 \layout Standard
5453
5454 \backslash 
5455 /
5456 \end_inset 
5457
5458 -compile-only
5459 \begin_inset LatexCommand \index{-\/-compile-only}
5460
5461 \end_inset 
5462
5463
5464 \begin_inset LatexCommand \index{-c -\/-compile-only}
5465
5466 \end_inset 
5467
5468
5469 \series default 
5470  will compile and assemble the source, but will not call the linkage editor.
5471 \layout List
5472 \labelwidthstring 00.00.0000
5473
5474
5475 \series bold 
5476 -
5477 \series default 
5478
5479 \begin_inset ERT
5480 status Collapsed
5481
5482 \layout Standard
5483
5484 \backslash 
5485 /
5486 \end_inset 
5487
5488
5489 \series bold 
5490 -c1mode
5491 \begin_inset LatexCommand \index{-\/-c1mode}
5492
5493 \end_inset 
5494
5495
5496 \series default 
5497  reads the preprocessed source from standard input and compiles it.
5498  The file name for the assembler output must be specified using the -o option.
5499 \layout List
5500 \labelwidthstring 00.00.0000
5501
5502
5503 \series bold 
5504 -E
5505 \begin_inset LatexCommand \index{-E}
5506
5507 \end_inset 
5508
5509
5510 \series default 
5511  Run only the C preprocessor.
5512  Preprocess all the C source files specified and output the results to standard
5513  output.
5514 \layout List
5515 \labelwidthstring 00.00.0000
5516
5517
5518 \series bold 
5519 -o\SpecialChar ~
5520 <path/file>
5521 \begin_inset LatexCommand \index{-o <path/file>}
5522
5523 \end_inset 
5524
5525  
5526 \series default 
5527 The output path resp.
5528  file where everything will be placed.
5529  If the parameter is a path, it must have a trailing slash (or backslash
5530  for the Windows binaries) to be recognized as a path.
5531  
5532 \layout List
5533 \labelwidthstring 00.00.0000
5534
5535
5536 \series bold 
5537 -
5538 \begin_inset ERT
5539 status Collapsed
5540
5541 \layout Standard
5542
5543 \backslash 
5544 /
5545 \end_inset 
5546
5547 -stack-auto
5548 \begin_inset LatexCommand \index{-\/-stack-auto}
5549
5550 \end_inset 
5551
5552
5553 \series default 
5554 \size large 
5555 \emph on 
5556  
5557 \size default 
5558 \emph default 
5559 All functions in the source file will be compiled as 
5560 \emph on 
5561 reentrant
5562 \emph default 
5563
5564 \begin_inset LatexCommand \index{reentrant}
5565
5566 \end_inset 
5567
5568 , i.e.
5569  the parameters and local variables will be allocated on the stack
5570 \begin_inset LatexCommand \index{stack}
5571
5572 \end_inset 
5573
5574 .
5575  see section Parameters and Local Variables for more details.
5576  If this option is used all source files in the project should be compiled
5577  with this option.
5578  
5579 \layout List
5580 \labelwidthstring 00.00.0000
5581
5582
5583 \series bold 
5584 -
5585 \begin_inset ERT
5586 status Collapsed
5587
5588 \layout Standard
5589
5590 \backslash 
5591 /
5592 \end_inset 
5593
5594 -xstack
5595 \begin_inset LatexCommand \index{-\/-xstack}
5596
5597 \end_inset 
5598
5599
5600 \series default 
5601  Uses a pseudo stack in the first 256 bytes in the external ram for allocating
5602  variables and passing parameters.
5603  See section on external stack for more details.
5604 \layout List
5605 \labelwidthstring 00.00.0000
5606
5607
5608 \series bold 
5609 -
5610 \begin_inset ERT
5611 status Collapsed
5612
5613 \layout Standard
5614
5615 \backslash 
5616 /
5617 \end_inset 
5618
5619 -callee-saves
5620 \begin_inset LatexCommand \index{-\/-callee-saves}
5621
5622 \end_inset 
5623
5624
5625 \begin_inset LatexCommand \index{function prologue}
5626
5627 \end_inset 
5628
5629  function1[,function2][,function3]....
5630
5631 \series default 
5632  The compiler by default uses a caller saves convention for register saving
5633  across function calls, however this can cause unnecessary register pushing
5634  & popping when calling small functions from larger functions.
5635  This option can be used to switch the register saving convention for the
5636  function names specified.
5637  The compiler will not save registers when calling these functions, no extra
5638  code will be generated at the entry & exit for these functions to save
5639  & restore the registers used by these functions, this can SUBSTANTIALLY
5640  reduce code & improve run time performance of the generated code.
5641  In the future the compiler (with inter procedural analysis) will be able
5642  to determine the appropriate scheme to use for each function call.
5643  DO NOT use this option for built-in functions such as _mulint..., if this
5644  option is used for a library function the appropriate library function
5645  needs to be recompiled with the same option.
5646  If the project consists of multiple source files then all the source file
5647  should be compiled with the same -
5648 \begin_inset ERT
5649 status Collapsed
5650
5651 \layout Standard
5652
5653 \backslash 
5654 /
5655 \end_inset 
5656
5657 -callee-saves option string.
5658  Also see #pragma\SpecialChar ~
5659 CALLEE-SAVES
5660 \begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
5661
5662 \end_inset 
5663
5664 .
5665 \layout List
5666 \labelwidthstring 00.00.0000
5667
5668
5669 \series bold 
5670 -
5671 \begin_inset ERT
5672 status Collapsed
5673
5674 \layout Standard
5675
5676 \backslash 
5677 /
5678 \end_inset 
5679
5680 -debug
5681 \begin_inset LatexCommand \index{-\/-debug}
5682
5683 \end_inset 
5684
5685
5686 \bar under 
5687  
5688 \series default 
5689 \bar default 
5690 When this option is used the compiler will generate debug information, that
5691  can be used with the SDCDB.
5692  The debug information is collected in a file with .cdb extension.
5693  For more information see documentation for SDCDB.
5694 \layout List
5695 \labelwidthstring 00.00.0000
5696
5697
5698 \series bold 
5699 -
5700 \begin_inset ERT
5701 status Collapsed
5702
5703 \layout Standard
5704
5705 \backslash 
5706 /
5707 \end_inset 
5708
5709 -peep-file
5710 \series default 
5711
5712 \begin_inset LatexCommand \index{-\/-peep-file}
5713
5714 \end_inset 
5715
5716 <filename> This option can be used to use additional rules to be used by
5717  the peep hole optimizer.
5718  See section Peep Hole optimizations for details on how to write these rules.
5719 \layout List
5720 \labelwidthstring 00.00.0000
5721
5722
5723 \series bold 
5724 -S
5725 \begin_inset LatexCommand \index{-S}
5726
5727 \end_inset 
5728
5729
5730 \size large 
5731 \bar under 
5732  
5733 \series default 
5734 \size default 
5735 \bar default 
5736 Stop after the stage of compilation proper; do not assemble.
5737  The output is an assembler code file for the input file specified.
5738 \layout List
5739 \labelwidthstring 00.00.0000
5740
5741
5742 \series bold 
5743 -Wa_asmOption[,asmOption]
5744 \series default 
5745
5746 \begin_inset LatexCommand \index{-Wa\_asmOption[,asmOption]}
5747
5748 \end_inset 
5749
5750 ...
5751  Pass the asmOption to the assembler.
5752 \layout List
5753 \labelwidthstring 00.00.0000
5754
5755
5756 \series bold 
5757 -Wl_linkOption[,linkOption]
5758 \series default 
5759
5760 \begin_inset LatexCommand \index{-Wl\_linkOption[,linkOption]}
5761
5762 \end_inset 
5763
5764 ...
5765  Pass the linkOption to the linker.
5766 \layout List
5767 \labelwidthstring 00.00.0000
5768
5769
5770 \series bold 
5771 -
5772 \begin_inset ERT
5773 status Collapsed
5774
5775 \layout Standard
5776
5777 \backslash 
5778 /
5779 \end_inset 
5780
5781 -int-long-reent
5782 \begin_inset LatexCommand \index{-\/-int-long-reent}
5783
5784 \end_inset 
5785
5786
5787 \series default 
5788  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
5789  Note by default these libraries are compiled as non-reentrant.
5790  See section Installation for more details.
5791 \layout List
5792 \labelwidthstring 00.00.0000
5793
5794
5795 \series bold 
5796 -
5797 \begin_inset ERT
5798 status Collapsed
5799
5800 \layout Standard
5801
5802 \backslash 
5803 /
5804 \end_inset 
5805
5806 -cyclomatic
5807 \begin_inset LatexCommand \index{-\/-cyclomatic}
5808
5809 \end_inset 
5810
5811
5812 \bar under 
5813  
5814 \series default 
5815 \bar default 
5816 This option will cause the compiler to generate an information message for
5817  each function in the source file.
5818  The message contains some 
5819 \emph on 
5820 important
5821 \emph default 
5822  information about the function.
5823  The number of edges and nodes the compiler detected in the control flow
5824  graph of the function, and most importantly the 
5825 \emph on 
5826 cyclomatic complexity
5827 \begin_inset LatexCommand \index{Cyclomatic complexity}
5828
5829 \end_inset 
5830
5831
5832 \emph default 
5833  see section on Cyclomatic Complexity for more details.
5834 \layout List
5835 \labelwidthstring 00.00.0000
5836
5837
5838 \series bold 
5839 -
5840 \begin_inset ERT
5841 status Collapsed
5842
5843 \layout Standard
5844
5845 \backslash 
5846 /
5847 \end_inset 
5848
5849 -float-reent
5850 \begin_inset LatexCommand \index{-\/-float-reent}
5851
5852 \end_inset 
5853
5854
5855 \bar under 
5856  
5857 \series default 
5858 \bar default 
5859  Floating point library is compiled as reentrant
5860 \begin_inset LatexCommand \index{reentrant}
5861
5862 \end_inset 
5863
5864 .See section Installation for more details.
5865 \layout List
5866 \labelwidthstring 00.00.0000
5867
5868
5869 \series bold 
5870 -
5871 \begin_inset ERT
5872 status Collapsed
5873
5874 \layout Standard
5875
5876 \backslash 
5877 /
5878 \end_inset 
5879
5880 -nooverlay
5881 \begin_inset LatexCommand \index{-\/-nooverlay}
5882
5883 \end_inset 
5884
5885
5886 \series default 
5887   The compiler will not overlay parameters and local variables of any function,
5888  see section Parameters and local variables for more details.
5889 \layout List
5890 \labelwidthstring 00.00.0000
5891
5892
5893 \series bold 
5894 -
5895 \begin_inset ERT
5896 status Collapsed
5897
5898 \layout Standard
5899
5900 \backslash 
5901 /
5902 \end_inset 
5903
5904 -main-return
5905 \begin_inset LatexCommand \index{-\/-main-return}
5906
5907 \end_inset 
5908
5909
5910 \series default 
5911  This option can be used when the code generated is called by a monitor
5912  program.
5913  The compiler will generate a 'ret' upon return from the 'main'
5914 \begin_inset LatexCommand \index{main return}
5915
5916 \end_inset 
5917
5918  function.
5919  The default option is to lock up i.e.
5920  generate a 'ljmp '.
5921 \layout List
5922 \labelwidthstring 00.00.0000
5923
5924
5925 \series bold 
5926 -
5927 \begin_inset ERT
5928 status Collapsed
5929
5930 \layout Standard
5931
5932 \backslash 
5933 /
5934 \end_inset 
5935
5936 -no-peep
5937 \begin_inset LatexCommand \index{-\/-no-peep}
5938
5939 \end_inset 
5940
5941
5942 \series default 
5943   Disable peep-hole optimization.
5944 \layout List
5945 \labelwidthstring 00.00.0000
5946
5947
5948 \series bold 
5949 -
5950 \begin_inset ERT
5951 status Collapsed
5952
5953 \layout Standard
5954
5955 \backslash 
5956 /
5957 \end_inset 
5958
5959 -peep-asm
5960 \begin_inset LatexCommand \index{-\/-peep-asm}
5961
5962 \end_inset 
5963
5964
5965 \series default 
5966   Pass the inline assembler code through the peep hole optimizer.
5967  This can cause unexpected changes to inline assembler code, please go through
5968  the peephole optimizer
5969 \begin_inset LatexCommand \index{Peephole optimizer}
5970
5971 \end_inset 
5972
5973  rules defined in the source file tree '<target>/peeph.def' before using
5974  this option.
5975 \layout List
5976 \labelwidthstring 00.00.0000
5977
5978
5979 \series bold 
5980 -
5981 \begin_inset ERT
5982 status Collapsed
5983
5984 \layout Standard
5985
5986 \backslash 
5987 /
5988 \end_inset 
5989
5990 -iram-size
5991 \series default 
5992 <Value>
5993 \begin_inset LatexCommand \index{-\/-iram-size<Value>}
5994
5995 \end_inset 
5996
5997  Causes the linker to check if the internal ram usage is within limits of
5998  the given value.
5999 \layout List
6000 \labelwidthstring 00.00.0000
6001
6002
6003 \series bold 
6004 -
6005 \begin_inset ERT
6006 status Collapsed
6007
6008 \layout Standard
6009
6010 \backslash 
6011 /
6012 \end_inset 
6013
6014 -xram-size
6015 \series default 
6016 <Value>
6017 \begin_inset LatexCommand \index{-\/-xram-size<Value>}
6018
6019 \end_inset 
6020
6021  Causes the linker to check if the external ram usage is within limits of
6022  the given value.
6023 \layout List
6024 \labelwidthstring 00.00.0000
6025
6026
6027 \series bold 
6028 -
6029 \begin_inset ERT
6030 status Collapsed
6031
6032 \layout Standard
6033
6034 \backslash 
6035 /
6036 \end_inset 
6037
6038 -code-size
6039 \series default 
6040 <Value>
6041 \begin_inset LatexCommand \index{-\/-code-size<Value>}
6042
6043 \end_inset 
6044
6045  Causes the linker to check if the code usage is within limits of the given
6046  value.
6047 \layout List
6048 \labelwidthstring 00.00.0000
6049
6050
6051 \series bold 
6052 -
6053 \begin_inset ERT
6054 status Collapsed
6055
6056 \layout Standard
6057
6058 \backslash 
6059 /
6060 \end_inset 
6061
6062 -nostdincl
6063 \begin_inset LatexCommand \index{-\/-nostdincl}
6064
6065 \end_inset 
6066
6067
6068 \series default 
6069  This will prevent the compiler from passing on the default include path
6070  to the preprocessor.
6071 \layout List
6072 \labelwidthstring 00.00.0000
6073
6074
6075 \series bold 
6076 -
6077 \begin_inset ERT
6078 status Collapsed
6079
6080 \layout Standard
6081
6082 \backslash 
6083 /
6084 \end_inset 
6085
6086 -nostdlib
6087 \begin_inset LatexCommand \index{-\/-nostdlib}
6088
6089 \end_inset 
6090
6091
6092 \series default 
6093  This will prevent the compiler from passing on the default library
6094 \begin_inset LatexCommand \index{Libraries}
6095
6096 \end_inset 
6097
6098  path to the linker.
6099 \layout List
6100 \labelwidthstring 00.00.0000
6101
6102
6103 \series bold 
6104 -
6105 \begin_inset ERT
6106 status Collapsed
6107
6108 \layout Standard
6109
6110 \backslash 
6111 /
6112 \end_inset 
6113
6114 -verbose
6115 \begin_inset LatexCommand \index{-\/-verbose}
6116
6117 \end_inset 
6118
6119
6120 \series default 
6121  Shows the various actions the compiler is performing.
6122 \layout List
6123 \labelwidthstring 00.00.0000
6124
6125
6126 \series bold 
6127 -V
6128 \begin_inset LatexCommand \index{-V}
6129
6130 \end_inset 
6131
6132
6133 \series default 
6134  Shows the actual commands the compiler is executing.
6135 \layout List
6136 \labelwidthstring 00.00.0000
6137
6138
6139 \series bold 
6140 -
6141 \begin_inset ERT
6142 status Collapsed
6143
6144 \layout Standard
6145
6146 \backslash 
6147 /
6148 \end_inset 
6149
6150 -no-c-code-in-asm
6151 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
6152
6153 \end_inset 
6154
6155
6156 \series default 
6157  Hides your ugly and inefficient c-code from the asm file, so you can always
6158  blame the compiler :).
6159 \layout List
6160 \labelwidthstring 00.00.0000
6161
6162
6163 \series bold 
6164 -
6165 \begin_inset ERT
6166 status Collapsed
6167
6168 \layout Standard
6169
6170 \backslash 
6171 /
6172 \end_inset 
6173
6174 -i-code-in-asm
6175 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
6176
6177 \end_inset 
6178
6179
6180 \series default 
6181  Include i-codes in the asm file.
6182  Sounds like noise but is most helpful for debugging the compiler itself.
6183 \layout List
6184 \labelwidthstring 00.00.0000
6185
6186
6187 \series bold 
6188 -
6189 \begin_inset ERT
6190 status Collapsed
6191
6192 \layout Standard
6193
6194 \backslash 
6195 /
6196 \end_inset 
6197
6198 -less-pedantic
6199 \begin_inset LatexCommand \index{-\/-less-pedantic}
6200
6201 \end_inset 
6202
6203
6204 \series default 
6205  Disable some of the more pedantic warnings (jwk burps: please be more specific
6206  here, please!)
6207 \layout List
6208 \labelwidthstring 00.00.0000
6209
6210
6211 \series bold 
6212 -
6213 \begin_inset ERT
6214 status Collapsed
6215
6216 \layout Standard
6217
6218 \backslash 
6219 /
6220 \end_inset 
6221
6222 -print-search-dirs
6223 \begin_inset LatexCommand \index{-\/-print-search-dirs}
6224
6225 \end_inset 
6226
6227
6228 \series default 
6229  Display the directories in the compiler's search path
6230 \layout List
6231 \labelwidthstring 00.00.0000
6232
6233
6234 \series bold 
6235 -
6236 \begin_inset ERT
6237 status Collapsed
6238
6239 \layout Standard
6240
6241 \backslash 
6242 /
6243 \end_inset 
6244
6245 -vc
6246 \begin_inset LatexCommand \index{-\/-vc}
6247
6248 \end_inset 
6249
6250
6251 \series default 
6252  Display the errors and warnings using MSVC style, so you can use SDCC with
6253  visual studio
6254 \layout Subsubsection
6255
6256 Intermediate Dump Options
6257 \begin_inset LatexCommand \index{Options intermediate dump}
6258
6259 \end_inset 
6260
6261
6262 \begin_inset LatexCommand \index{Intermediate dump options}
6263
6264 \end_inset 
6265
6266
6267 \layout Standard
6268
6269 The following options are provided for the purpose of retargetting and debugging
6270  the compiler.
6271  These provided a means to dump the intermediate code (iCode
6272 \begin_inset LatexCommand \index{iCode}
6273
6274 \end_inset 
6275
6276 ) generated by the compiler in human readable form at various stages of
6277  the compilation process.
6278  
6279 \layout List
6280 \labelwidthstring 00.00.0000
6281
6282
6283 \series bold 
6284 -
6285 \begin_inset ERT
6286 status Collapsed
6287
6288 \layout Standard
6289
6290 \backslash 
6291 /
6292 \end_inset 
6293
6294 -dumpraw
6295 \begin_inset LatexCommand \index{-\/-dumpraw}
6296
6297 \end_inset 
6298
6299
6300 \series default 
6301  This option will cause the compiler to dump the intermediate code into
6302  a file of named 
6303 \emph on 
6304 <source filename>.dumpraw
6305 \emph default 
6306  just after the intermediate code has been generated for a function, i.e.
6307  before any optimizations are done.
6308  The basic blocks
6309 \begin_inset LatexCommand \index{Basic blocks}
6310
6311 \end_inset 
6312
6313  at this stage ordered in the depth first number, so they may not be in
6314  sequence of execution.
6315 \layout List
6316 \labelwidthstring 00.00.0000
6317
6318
6319 \series bold 
6320 -
6321 \begin_inset ERT
6322 status Collapsed
6323
6324 \layout Standard
6325
6326 \backslash 
6327 /
6328 \end_inset 
6329
6330 -dumpgcse
6331 \begin_inset LatexCommand \index{-\/-dumpgcse}
6332
6333 \end_inset 
6334
6335
6336 \series default 
6337  Will create a dump of iCode's, after global subexpression elimination
6338 \begin_inset LatexCommand \index{Global subexpression elimination}
6339
6340 \end_inset 
6341
6342 , into a file named 
6343 \emph on 
6344 <source filename>.dumpgcse.
6345 \layout List
6346 \labelwidthstring 00.00.0000
6347
6348
6349 \series bold 
6350 -
6351 \begin_inset ERT
6352 status Collapsed
6353
6354 \layout Standard
6355
6356 \backslash 
6357 /
6358 \end_inset 
6359
6360 -dumpdeadcode
6361 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
6362
6363 \end_inset 
6364
6365
6366 \series default 
6367  Will create a dump of iCode's, after deadcode elimination
6368 \begin_inset LatexCommand \index{Dead-code elimination}
6369
6370 \end_inset 
6371
6372 , into a file named 
6373 \emph on 
6374 <source filename>.dumpdeadcode.
6375 \layout List
6376 \labelwidthstring 00.00.0000
6377
6378
6379 \series bold 
6380 -
6381 \begin_inset ERT
6382 status Collapsed
6383
6384 \layout Standard
6385
6386 \backslash 
6387 /
6388 \end_inset 
6389
6390 -dumploop
6391 \begin_inset LatexCommand \index{-\/-dumploop}
6392
6393 \end_inset 
6394
6395
6396 \series default 
6397 \size large 
6398  
6399 \size default 
6400 Will create a dump of iCode's, after loop optimizations
6401 \begin_inset LatexCommand \index{Loop optimization}
6402
6403 \end_inset 
6404
6405 , into a file named 
6406 \emph on 
6407 <source filename>.dumploop.
6408 \layout List
6409 \labelwidthstring 00.00.0000
6410
6411
6412 \series bold 
6413 -
6414 \begin_inset ERT
6415 status Collapsed
6416
6417 \layout Standard
6418
6419 \backslash 
6420 /
6421 \end_inset 
6422
6423 -dumprange
6424 \begin_inset LatexCommand \index{-\/-dumprange}
6425
6426 \end_inset 
6427
6428
6429 \series default 
6430 \size large 
6431  
6432 \size default 
6433 Will create a dump of iCode's, after live range analysis
6434 \begin_inset LatexCommand \index{Live range analysis}
6435
6436 \end_inset 
6437
6438 , into a file named 
6439 \emph on 
6440 <source filename>.dumprange.
6441 \layout List
6442 \labelwidthstring 00.00.0000
6443
6444
6445 \series bold 
6446 -
6447 \begin_inset ERT
6448 status Collapsed
6449
6450 \layout Standard
6451
6452 \backslash 
6453 /
6454 \end_inset 
6455
6456 -dumlrange
6457 \begin_inset LatexCommand \index{-\/-dumlrange}
6458
6459 \end_inset 
6460
6461
6462 \series default 
6463  Will dump the life ranges
6464 \begin_inset LatexCommand \index{Live range analysis}
6465
6466 \end_inset 
6467
6468  for all symbols.
6469 \layout List
6470 \labelwidthstring 00.00.0000
6471
6472
6473 \series bold 
6474 -
6475 \begin_inset ERT
6476 status Collapsed
6477
6478 \layout Standard
6479
6480 \backslash 
6481 /
6482 \end_inset 
6483
6484 -dumpregassign
6485 \begin_inset LatexCommand \index{-\/-dumpregassign}
6486
6487 \end_inset 
6488
6489
6490 \bar under 
6491  
6492 \series default 
6493 \bar default 
6494 Will create a dump of iCode's, after register assignment
6495 \begin_inset LatexCommand \index{Register assignment}
6496
6497 \end_inset 
6498
6499 , into a file named 
6500 \emph on 
6501 <source filename>.dumprassgn.
6502 \layout List
6503 \labelwidthstring 00.00.0000
6504
6505
6506 \series bold 
6507 -
6508 \begin_inset ERT
6509 status Collapsed
6510
6511 \layout Standard
6512
6513 \backslash 
6514 /
6515 \end_inset 
6516
6517 -dumplrange
6518 \begin_inset LatexCommand \index{-\/-dumplrange}
6519
6520 \end_inset 
6521
6522
6523 \series default 
6524  Will create a dump of the live ranges of iTemp's
6525 \layout List
6526 \labelwidthstring 00.00.0000
6527
6528
6529 \series bold 
6530 -
6531 \begin_inset ERT
6532 status Collapsed
6533
6534 \layout Standard
6535
6536 \backslash 
6537 /
6538 \end_inset 
6539
6540 -dumpall
6541 \begin_inset LatexCommand \index{-\/-dumpall}
6542
6543 \end_inset 
6544
6545
6546 \size large 
6547 \bar under 
6548  
6549 \series default 
6550 \size default 
6551 \bar default 
6552 Will cause all the above mentioned dumps to be created.
6553 \layout Subsection
6554
6555 Environment variables
6556 \begin_inset LatexCommand \index{Environment variables}
6557
6558 \end_inset 
6559
6560
6561 \layout Standard
6562
6563 SDCC recognizes the following environment variables:
6564 \layout List
6565 \labelwidthstring 00.00.0000
6566
6567
6568 \series bold 
6569 SDCC_LEAVE_SIGNALS
6570 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
6571
6572 \end_inset 
6573
6574
6575 \series default 
6576  SDCC installs a signal handler
6577 \begin_inset LatexCommand \index{signal handler}
6578
6579 \end_inset 
6580
6581  to be able to delete temporary files after an user break (^C) or an exception.
6582  If this environment variable is set, SDCC won't install the signal handler
6583  in order to be able to debug SDCC.
6584 \layout List
6585 \labelwidthstring 00.00.0000
6586
6587
6588 \series bold 
6589 TMP
6590 \begin_inset LatexCommand \index{TMP}
6591
6592 \end_inset 
6593
6594 ,\SpecialChar ~
6595 TEMP
6596 \begin_inset LatexCommand \index{TEMP}
6597
6598 \end_inset 
6599
6600 ,\SpecialChar ~
6601 TMPDIR
6602 \begin_inset LatexCommand \index{TMPDIR}
6603
6604 \end_inset 
6605
6606
6607 \series default 
6608  Path, where temporary files will be created.
6609  The order of the variables is the search order.
6610  In a standard *nix environment these variables are not set, and there's
6611  no need to set them.
6612  On Windows it's recommended to set one of them.
6613 \layout List
6614 \labelwidthstring 00.00.0000
6615
6616
6617 \series bold 
6618 SDCC_HOME
6619 \begin_inset LatexCommand \index{SDCC\_HOME}
6620
6621 \end_inset 
6622
6623
6624 \series default 
6625  Path, see 
6626 \begin_inset Quotes sld
6627 \end_inset 
6628
6629 2.3 Install and search paths
6630 \begin_inset Quotes srd
6631 \end_inset 
6632
6633 .
6634 \layout List
6635 \labelwidthstring 00.00.0000
6636
6637
6638 \series bold 
6639 SDCC_INCLUDE
6640 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
6641
6642 \end_inset 
6643
6644
6645 \series default 
6646  Path, see 
6647 \begin_inset Quotes sld
6648 \end_inset 
6649
6650 2.3 Install and search paths
6651 \begin_inset Quotes srd
6652 \end_inset 
6653
6654 .
6655 \layout List
6656 \labelwidthstring 00.00.0000
6657
6658
6659 \series bold 
6660 SDCC_LIB
6661 \begin_inset LatexCommand \index{SDCC\_LIB}
6662
6663 \end_inset 
6664
6665
6666 \series default 
6667  Path, see 
6668 \begin_inset Quotes sld
6669 \end_inset 
6670
6671 2.3 Install and search paths
6672 \begin_inset Quotes srd
6673 \end_inset 
6674
6675 .
6676 \layout Standard
6677
6678 There are some more environment variables recognized by SDCC, but these
6679  are solely used for debugging purposes.
6680  They can change or disappear very quickly, and will never be documented.
6681 \layout Subsection
6682
6683 MCS51/DS390 Storage Class
6684 \begin_inset LatexCommand \index{Storage class}
6685
6686 \end_inset 
6687
6688  Language Extensions
6689 \layout Standard
6690
6691 In addition to the ANSI storage classes SDCC allows the following MCS51
6692  specific storage classes.
6693 \layout Subsubsection
6694
6695 xdata
6696 \begin_inset LatexCommand \index{xdata}
6697
6698 \end_inset 
6699
6700
6701 \layout Standard
6702
6703 Variables declared with this storage class will be placed in the extern
6704  RAM.
6705  This is the 
6706 \series bold 
6707 default
6708 \series default 
6709  storage class for Large Memory model, e.g.:
6710 \layout Verse
6711
6712
6713 \family typewriter 
6714 xdata unsigned char xduc;
6715 \layout Subsubsection
6716
6717 data
6718 \begin_inset LatexCommand \index{data}
6719
6720 \end_inset 
6721
6722
6723 \layout Standard
6724
6725 This is the 
6726 \series bold 
6727 default
6728 \series default 
6729  storage class for Small Memory model.
6730  Variables declared with this storage class will be allocated in the internal
6731  RAM, e.g.:
6732 \layout Verse
6733
6734
6735 \family typewriter 
6736 data int iramdata;
6737 \layout Subsubsection
6738
6739 idata
6740 \begin_inset LatexCommand \index{idata}
6741
6742 \end_inset 
6743
6744
6745 \layout Standard
6746
6747 Variables declared with this storage class will be allocated into the indirectly
6748  addressable portion of the internal ram of a 8051, e.g.:
6749 \layout Verse
6750
6751
6752 \family typewriter 
6753 idata int idi;
6754 \layout Subsubsection
6755
6756 bit
6757 \begin_inset LatexCommand \index{bit}
6758
6759 \end_inset 
6760
6761
6762 \layout Standard
6763
6764 This is a data-type and a storage class specifier.
6765  When a variable is declared as a bit, it is allocated into the bit addressable
6766  memory of 8051, e.g.:
6767 \layout Verse
6768
6769
6770 \family typewriter 
6771 bit iFlag;
6772 \layout Subsubsection
6773
6774 sfr
6775 \begin_inset LatexCommand \index{sfr}
6776
6777 \end_inset 
6778
6779  / sbit
6780 \begin_inset LatexCommand \index{sbit}
6781
6782 \end_inset 
6783
6784
6785 \layout Standard
6786
6787 Like the bit keyword, 
6788 \emph on 
6789 sfr / sbit 
6790 \emph default 
6791 signifies both a data-type and storage class, they are used to describe
6792  the special function registers and special bit variables of a 8051, eg:
6793 \layout Verse
6794
6795
6796 \family typewriter 
6797 sfr at 0x80 P0; /* special function register P0 at location 0x80 */
6798 \newline 
6799 sbit at 0xd7 CY; /* CY (Carry Flag
6800 \begin_inset LatexCommand \index{Flags}
6801
6802 \end_inset 
6803
6804
6805 \begin_inset LatexCommand \index{Carry flag}
6806
6807 \end_inset 
6808
6809 ) */
6810 \layout Subsection
6811
6812 Pointers
6813 \begin_inset LatexCommand \index{Pointers}
6814
6815 \end_inset 
6816
6817
6818 \layout Standard
6819
6820 SDCC allows (via language extensions) pointers to explicitly point to any
6821  of the memory spaces
6822 \begin_inset LatexCommand \index{Memory model}
6823
6824 \end_inset 
6825
6826  of the 8051.
6827  In addition to the explicit pointers, the compiler uses (by default) generic
6828  pointers which can be used to point to any of the memory spaces.
6829 \newline 
6830
6831 \newline 
6832 Pointer declaration examples:
6833 \layout Verse
6834
6835
6836 \family typewriter 
6837 /* pointer physically in xternal ram pointing to object in internal ram
6838  */ 
6839 \newline 
6840 data unsigned char * xdata p;
6841 \newline 
6842
6843 \newline 
6844 /* pointer physically in code rom pointing to data in xdata space */ 
6845 \newline 
6846 xdata unsigned char * code p;
6847 \newline 
6848
6849 \newline 
6850 /* pointer physically in code space pointing to data in code space */ 
6851 \newline 
6852 code unsigned char * code p;
6853 \newline 
6854
6855 \newline 
6856 /* the following is a generic pointer physically located in xdata space
6857  */
6858 \newline 
6859 char * xdata p;
6860 \layout Standard
6861
6862 Well you get the idea.
6863  
6864 \newline 
6865
6866 \newline 
6867 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
6868 \emph on 
6869 generic
6870 \emph default 
6871  pointers.
6872  
6873 \size small 
6874
6875 \newline 
6876
6877 \newline 
6878
6879 \size default 
6880 The highest order byte of the 
6881 \emph on 
6882 generic
6883 \emph default 
6884  pointers contains the data space information.
6885  Assembler support routines are called whenever data is stored or retrieved
6886  using 
6887 \emph on 
6888 generic
6889 \emph default 
6890  pointers.
6891  These are useful for developing reusable library
6892 \begin_inset LatexCommand \index{Libraries}
6893
6894 \end_inset 
6895
6896  routines.
6897  Explicitly specifying the pointer type will generate the most efficient
6898  code.
6899 \layout Subsection
6900
6901 Parameters
6902 \begin_inset LatexCommand \index{Parameters}
6903
6904 \end_inset 
6905
6906  & Local Variables
6907 \begin_inset LatexCommand \index{Local variable}
6908
6909 \end_inset 
6910
6911
6912 \layout Standard
6913
6914 Automatic (local) variables and parameters to functions can either be placed
6915  on the stack or in data-space.
6916  The default action of the compiler is to place these variables in the internal
6917  RAM (for small model) or external RAM (for large model).
6918  This in fact makes them 
6919 \emph on 
6920 static
6921 \begin_inset LatexCommand \index{static}
6922
6923 \end_inset 
6924
6925
6926 \emph default 
6927  so by default functions are non-reentrant
6928 \begin_inset LatexCommand \index{reentrant}
6929
6930 \end_inset 
6931
6932 .
6933 \newline 
6934
6935 \newline 
6936 They can be placed on the stack
6937 \begin_inset LatexCommand \index{stack}
6938
6939 \end_inset 
6940
6941  either by using the
6942 \emph on 
6943  -
6944 \begin_inset ERT
6945 status Collapsed
6946
6947 \layout Standard
6948
6949 \backslash 
6950 /
6951 \end_inset 
6952
6953 -stack-auto
6954 \begin_inset LatexCommand \index{-\/-stack-auto}
6955
6956 \end_inset 
6957
6958
6959 \emph default 
6960  option or by using the 
6961 \emph on 
6962 reentrant
6963 \begin_inset LatexCommand \index{reentrant}
6964
6965 \end_inset 
6966
6967
6968 \emph default 
6969  keyword in the function declaration, e.g.:
6970 \layout Verse
6971
6972
6973 \family typewriter 
6974 unsigned char foo(char i) reentrant 
6975 \newline 
6976
6977 \newline 
6978 ...
6979  
6980 \newline 
6981 }
6982 \layout Standard
6983
6984 Since stack space on 8051 is limited, the 
6985 \emph on 
6986 reentrant 
6987 \emph default 
6988 keyword or the
6989 \emph on 
6990  -
6991 \begin_inset ERT
6992 status Collapsed
6993
6994 \layout Standard
6995
6996 \backslash 
6997 /
6998 \end_inset 
6999
7000 -stack-auto
7001 \emph default 
7002  option should be used sparingly.
7003  Note that the reentrant keyword just means that the parameters & local
7004  variables will be allocated to the stack, it 
7005 \emph on 
7006 does not
7007 \emph default 
7008  mean that the function is register bank independent.
7009 \newline 
7010
7011 \newline 
7012 Local variables can be assigned storage classes and absolute
7013 \begin_inset LatexCommand \index{Absolute addressing}
7014
7015 \end_inset 
7016
7017  addresses, e.g.: 
7018 \layout Verse
7019
7020
7021 \family typewriter 
7022 unsigned char foo() {
7023 \newline 
7024 \SpecialChar ~
7025 \SpecialChar ~
7026 \SpecialChar ~
7027 \SpecialChar ~
7028 xdata unsigned char i;
7029 \newline 
7030 \SpecialChar ~
7031 \SpecialChar ~
7032 \SpecialChar ~
7033 \SpecialChar ~
7034 bit bvar;
7035 \newline 
7036 \SpecialChar ~
7037 \SpecialChar ~
7038 \SpecialChar ~
7039 \SpecialChar ~
7040 data at 0x31 unsigned char j;
7041 \newline 
7042 \SpecialChar ~
7043 \SpecialChar ~
7044 \SpecialChar ~
7045 \SpecialChar ~
7046 ...
7047  
7048 \newline 
7049 }
7050 \layout Standard
7051
7052 In the above example the variable 
7053 \emph on 
7054 i
7055 \emph default 
7056  will be allocated in the external ram, 
7057 \emph on 
7058 bvar
7059 \emph default 
7060  in bit addressable space and
7061 \emph on 
7062  j
7063 \emph default 
7064  in internal ram.
7065  When compiled with 
7066 \emph on 
7067 -
7068 \begin_inset ERT
7069 status Collapsed
7070
7071 \layout Standard
7072
7073 \backslash 
7074 /
7075 \end_inset 
7076
7077 -stack-auto
7078 \emph default 
7079  or when a function is declared as 
7080 \emph on 
7081 reentrant
7082 \emph default 
7083  this should only be done for static variables.
7084 \layout Standard
7085
7086 Parameters however are not allowed any storage class, (storage classes for
7087  parameters will be ignored), their allocation is governed by the memory
7088  model in use, and the reentrancy options.
7089 \layout Subsection
7090
7091 Overlaying
7092 \begin_inset LatexCommand \index{Overlaying}
7093
7094 \end_inset 
7095
7096
7097 \layout Standard
7098
7099 For non-reentrant
7100 \begin_inset LatexCommand \index{reentrant}
7101
7102 \end_inset 
7103
7104  functions SDCC will try to reduce internal ram space usage by overlaying
7105  parameters and local variables of a function (if possible).
7106  Parameters and local variables of a function will be allocated to an overlayabl
7107 e segment if the function has 
7108 \emph on 
7109 no other function calls and the function is non-reentrant and the memory
7110  model
7111 \begin_inset LatexCommand \index{Memory model}
7112
7113 \end_inset 
7114
7115  is small.
7116
7117 \emph default 
7118  If an explicit storage class
7119 \begin_inset LatexCommand \index{Storage class}
7120
7121 \end_inset 
7122
7123  is specified for a local variable, it will NOT be overlayed.
7124 \layout Standard
7125
7126 Note that the compiler (not the linkage editor) makes the decision for overlayin
7127 g the data items.
7128  Functions that are called from an interrupt service routine should be preceded
7129  by a #pragma\SpecialChar ~
7130 NOOVERLAY
7131 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
7132
7133 \end_inset 
7134
7135  if they are not reentrant.
7136 \layout Standard
7137
7138 Also note that the compiler does not do any processing of inline
7139 \begin_inset LatexCommand \index{inline}
7140
7141 \end_inset 
7142
7143  assembler code, so the compiler might incorrectly assign local variables
7144  and parameters of a function into the overlay segment if the inline assembler
7145  code calls other c-functions that might use the overlay.
7146  In that case the #pragma\SpecialChar ~
7147 NOOVERLAY should be used.
7148 \layout Standard
7149
7150 Parameters and Local variables of functions that contain 16 or 32 bit multiplica
7151 tion
7152 \begin_inset LatexCommand \index{Multiplication}
7153
7154 \end_inset 
7155
7156  or division
7157 \begin_inset LatexCommand \index{Division}
7158
7159 \end_inset 
7160
7161  will NOT be overlayed since these are implemented using external functions,
7162  e.g.:
7163 \layout Verse
7164
7165
7166 \family typewriter 
7167 #pragma SAVE 
7168 \newline 
7169 #pragma NOOVERLAY
7170 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
7171
7172 \end_inset 
7173
7174  
7175 \newline 
7176 void set_error(unsigned char errcd) 
7177 \newline 
7178 {
7179 \newline 
7180 \SpecialChar ~
7181 \SpecialChar ~
7182 \SpecialChar ~
7183 \SpecialChar ~
7184 P3 = errcd;
7185 \newline 
7186
7187 \newline 
7188 #pragma RESTORE 
7189 \newline 
7190
7191 \newline 
7192 void some_isr () interrupt
7193 \begin_inset LatexCommand \index{interrupt}
7194
7195 \end_inset 
7196
7197  2 using
7198 \begin_inset LatexCommand \index{using}
7199
7200 \end_inset 
7201
7202  1 
7203 \newline 
7204 {
7205 \newline 
7206 \SpecialChar ~
7207 \SpecialChar ~
7208 \SpecialChar ~
7209 \SpecialChar ~
7210 ...
7211 \newline 
7212 \SpecialChar ~
7213 \SpecialChar ~
7214 \SpecialChar ~
7215 \SpecialChar ~
7216 set_error(10);
7217 \newline 
7218 \SpecialChar ~
7219 \SpecialChar ~
7220 \SpecialChar ~
7221 \SpecialChar ~
7222 ...
7223  
7224 \newline 
7225 }
7226 \layout Standard
7227
7228 In the above example the parameter 
7229 \emph on 
7230 errcd
7231 \emph default 
7232  for the function 
7233 \emph on 
7234 set_error
7235 \emph default 
7236  would be assigned to the overlayable segment if the #pragma\SpecialChar ~
7237 NOOVERLAY was
7238  not present, this could cause unpredictable runtime behavior when called
7239  from an ISR.
7240  The #pragma\SpecialChar ~
7241 NOOVERLAY ensures that the parameters and local variables for
7242  the function are NOT overlayed.
7243 \layout Subsection
7244
7245 Interrupt Service Routines
7246 \layout Standard
7247
7248 SDCC allows interrupt service routines to be coded in C, with some extended
7249  keywords.
7250 \layout Verse
7251
7252
7253 \family typewriter 
7254 void timer_isr (void) interrupt 2 using 1 
7255 \newline 
7256
7257 \newline 
7258 ..
7259  
7260 \newline 
7261 }
7262 \layout Standard
7263
7264 The number following the 
7265 \emph on 
7266 interrupt
7267 \begin_inset LatexCommand \index{interrupt}
7268
7269 \end_inset 
7270
7271
7272 \emph default 
7273  keyword is the interrupt number this routine will service.
7274  The compiler will insert a call to this routine in the interrupt vector
7275  table for the interrupt number specified.
7276  The 
7277 \emph on 
7278 using
7279 \emph default 
7280  keyword is used to tell the compiler to use the specified register bank
7281  (8051 specific) when generating code for this function.
7282  Note that when some function is called from an interrupt service routine
7283  it should be preceded by a #pragma\SpecialChar ~
7284 NOOVERLAY
7285 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
7286
7287 \end_inset 
7288
7289  if it is not reentrant.
7290  A special note here, int (16 bit) and long (32 bit) integer division
7291 \begin_inset LatexCommand \index{Division}
7292
7293 \end_inset 
7294
7295 , multiplication
7296 \begin_inset LatexCommand \index{Multiplication}
7297
7298 \end_inset 
7299
7300  & modulus
7301 \begin_inset LatexCommand \index{Modulus}
7302
7303 \end_inset 
7304
7305  operations are implemented using external support routines developed in
7306  ANSI-C, if an interrupt service routine needs to do any of these operations
7307  then the support routines (as mentioned in a following section) will have
7308  to be recompiled using the
7309 \emph on 
7310  -
7311 \begin_inset ERT
7312 status Collapsed
7313
7314 \layout Standard
7315
7316 \backslash 
7317 /
7318 \end_inset 
7319
7320 -stack-auto
7321 \begin_inset LatexCommand \index{-\/-stack-auto}
7322
7323 \end_inset 
7324
7325
7326 \emph default 
7327  option and the source file will need to be compiled using the 
7328 \emph on 
7329 -
7330 \begin_inset ERT
7331 status Collapsed
7332
7333 \layout Standard
7334
7335 \backslash 
7336 /
7337 \end_inset 
7338
7339 -int-long-ren
7340 \emph default 
7341 t
7342 \begin_inset LatexCommand \index{-\/-int-long-rent}
7343
7344 \end_inset 
7345
7346  compiler option.
7347 \layout Standard
7348
7349 If you have multiple source files in your project, interrupt service routines
7350  can be present in any of them, but a prototype of the isr MUST be present
7351  or included in the file that contains the function 
7352 \emph on 
7353 main
7354 \emph default 
7355 .
7356 \layout Standard
7357
7358 Interrupt Numbers and the corresponding address & descriptions for the Standard
7359  8051 are listed below.
7360  SDCC will automatically adjust the interrupt vector table to the maximum
7361  interrupt number specified.
7362 \newline 
7363
7364 \layout Standard
7365 \align center 
7366
7367 \begin_inset  Tabular
7368 <lyxtabular version="3" rows="6" columns="3">
7369 <features>
7370 <column alignment="center" valignment="top" leftline="true" width="0in">
7371 <column alignment="center" valignment="top" leftline="true" width="0in">
7372 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0in">
7373 <row topline="true" bottomline="true">
7374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7375 \begin_inset Text
7376
7377 \layout Standard
7378
7379 Interrupt #
7380 \end_inset 
7381 </cell>
7382 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7383 \begin_inset Text
7384
7385 \layout Standard
7386
7387 Description
7388 \end_inset 
7389 </cell>
7390 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
7391 \begin_inset Text
7392
7393 \layout Standard
7394
7395 Vector Address
7396 \end_inset 
7397 </cell>
7398 </row>
7399 <row topline="true">
7400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7401 \begin_inset Text
7402
7403 \layout Standard
7404
7405 0
7406 \end_inset 
7407 </cell>
7408 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7409 \begin_inset Text
7410
7411 \layout Standard
7412
7413 External 0
7414 \end_inset 
7415 </cell>
7416 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
7417 \begin_inset Text
7418
7419 \layout Standard
7420
7421 0x0003
7422 \end_inset 
7423 </cell>
7424 </row>
7425 <row topline="true">
7426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7427 \begin_inset Text
7428
7429 \layout Standard
7430
7431 1
7432 \end_inset 
7433 </cell>
7434 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7435 \begin_inset Text
7436
7437 \layout Standard
7438
7439 Timer 0
7440 \end_inset 
7441 </cell>
7442 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
7443 \begin_inset Text
7444
7445 \layout Standard
7446
7447 0x000B
7448 \end_inset 
7449 </cell>
7450 </row>
7451 <row topline="true">
7452 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7453 \begin_inset Text
7454
7455 \layout Standard
7456
7457 2
7458 \end_inset 
7459 </cell>
7460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7461 \begin_inset Text
7462
7463 \layout Standard
7464
7465 External 1
7466 \end_inset 
7467 </cell>
7468 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
7469 \begin_inset Text
7470
7471 \layout Standard
7472
7473 0x0013
7474 \end_inset 
7475 </cell>
7476 </row>
7477 <row topline="true">
7478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7479 \begin_inset Text
7480
7481 \layout Standard
7482
7483 3
7484 \end_inset 
7485 </cell>
7486 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7487 \begin_inset Text
7488
7489 \layout Standard
7490
7491 Timer 1
7492 \end_inset 
7493 </cell>
7494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
7495 \begin_inset Text
7496
7497 \layout Standard
7498
7499 0x001B
7500 \end_inset 
7501 </cell>
7502 </row>
7503 <row topline="true" bottomline="true">
7504 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7505 \begin_inset Text
7506
7507 \layout Standard
7508
7509 4
7510 \end_inset 
7511 </cell>
7512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
7513 \begin_inset Text
7514
7515 \layout Standard
7516
7517 Serial
7518 \end_inset 
7519 </cell>
7520 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
7521 \begin_inset Text
7522
7523 \layout Standard
7524
7525 0x0023
7526 \end_inset 
7527 </cell>
7528 </row>
7529 </lyxtabular>
7530
7531 \end_inset 
7532
7533
7534 \newline 
7535
7536 \layout Standard
7537
7538 If the interrupt service routine is defined without 
7539 \emph on 
7540 using
7541 \begin_inset LatexCommand \index{using}
7542
7543 \end_inset 
7544
7545
7546 \emph default 
7547  a register bank or with register bank 0 (using 0), the compiler will save
7548  the registers used by itself on the stack upon entry and restore them at
7549  exit, however if such an interrupt service routine calls another function
7550  then the entire register bank will be saved on the stack.
7551  This scheme may be advantageous for small interrupt service routines which
7552  have low register usage.
7553 \layout Standard
7554
7555 If the interrupt service routine is defined to be using a specific register
7556  bank then only 
7557 \emph on 
7558 a, b & dptr
7559 \emph default 
7560  are save and restored, if such an interrupt service routine calls another
7561  function (using another register bank) then the entire register bank of
7562  the called function will be saved on the stack.
7563  This scheme is recommended for larger interrupt service routines.
7564 \layout Standard
7565
7566 Calling other functions from an interrupt service routine is not recommended,
7567  avoid it if possible.
7568 \newline 
7569
7570 \newline 
7571 Also see the _naked modifier.
7572 \layout Subsection
7573
7574 Critical Functions
7575 \layout Standard
7576
7577
7578 \shape italic 
7579 <TODO: this isn't implemented at all!>
7580 \shape default 
7581
7582 \newline 
7583
7584 \newline 
7585 A special keyword may be associated with a function declaring it as 
7586 \emph on 
7587 critical
7588 \emph default 
7589 .
7590  SDCC will generate code to disable all interrupts upon entry to a critical
7591  function and enable them back before returning.
7592  Note that nesting critical functions may cause unpredictable results.
7593 \layout Verse
7594
7595
7596 \family typewriter 
7597 int foo () critical 
7598 \newline 
7599
7600 \newline 
7601 ...
7602  
7603 \newline 
7604 ...
7605  
7606 \newline 
7607 }
7608 \layout Standard
7609
7610 The critical attribute maybe used with other attributes like 
7611 \emph on 
7612 reentrant.
7613 \layout Subsection
7614
7615 Naked Functions
7616 \begin_inset LatexCommand \index{Naked functions}
7617
7618 \end_inset 
7619
7620
7621 \layout Standard
7622
7623 A special keyword may be associated with a function declaring it as 
7624 \emph on 
7625 _naked
7626 \begin_inset LatexCommand \index{\_naked}
7627
7628 \end_inset 
7629
7630 .
7631  
7632 \emph default 
7633 The 
7634 \emph on 
7635 _naked
7636 \emph default 
7637  function modifier attribute prevents the compiler from generating prologue
7638 \begin_inset LatexCommand \index{function prologue}
7639
7640 \end_inset 
7641
7642  and epilogue
7643 \begin_inset LatexCommand \index{function epilogue}
7644
7645 \end_inset 
7646
7647  code for that function.
7648  This means that the user is entirely responsible for such things as saving
7649  any registers that may need to be preserved, selecting the proper register
7650  bank, generating the 
7651 \emph on 
7652 return
7653 \emph default 
7654  instruction at the end, etc.
7655  Practically, this means that the contents of the function must be written
7656  in inline assembler.
7657  This is particularly useful for interrupt functions, which can have a large
7658  (and often unnecessary) prologue/epilogue.
7659  For example, compare the code generated by these two functions:
7660 \layout Verse
7661
7662
7663 \family typewriter 
7664 data unsigned char counter;
7665 \newline 
7666 void simpleInterrupt(void) interrupt
7667 \begin_inset LatexCommand \index{interrupt}
7668
7669 \end_inset 
7670
7671  1
7672 \newline 
7673 {
7674 \newline 
7675 \SpecialChar ~
7676 \SpecialChar ~
7677 \SpecialChar ~
7678 \SpecialChar ~
7679 counter++;
7680 \newline 
7681 }
7682 \newline 
7683
7684 \newline 
7685 void nakedInterrupt(void) interrupt 2 _naked
7686 \newline 
7687 {
7688 \newline 
7689 \SpecialChar ~
7690 \SpecialChar ~
7691 \SpecialChar ~
7692 \SpecialChar ~
7693 _asm
7694 \begin_inset LatexCommand \index{\_asm}
7695
7696 \end_inset 
7697
7698
7699 \newline 
7700 \SpecialChar ~
7701 \SpecialChar ~
7702 \SpecialChar ~
7703 \SpecialChar ~
7704 \SpecialChar ~
7705 \SpecialChar ~
7706 inc\SpecialChar ~
7707 \SpecialChar ~
7708 \SpecialChar ~
7709 \SpecialChar ~
7710 \SpecialChar ~
7711 _counter
7712 \newline 
7713 \SpecialChar ~
7714 \SpecialChar ~
7715 \SpecialChar ~
7716 \SpecialChar ~
7717 \SpecialChar ~
7718 \SpecialChar ~
7719 reti\SpecialChar ~
7720 \SpecialChar ~
7721 \SpecialChar ~
7722 \SpecialChar ~
7723 ; MUST explicitly include ret in _naked function.
7724 \newline 
7725 \SpecialChar ~
7726 \SpecialChar ~
7727 \SpecialChar ~
7728 \SpecialChar ~
7729 _endasm
7730 \begin_inset LatexCommand \index{\_endasm}
7731
7732 \end_inset 
7733
7734 ;
7735 \newline 
7736 }
7737 \layout Standard
7738
7739 For an 8051 target, the generated simpleInterrupt looks like:
7740 \layout Verse
7741
7742
7743 \family typewriter 
7744 _simpleIterrupt:
7745 \newline 
7746 \SpecialChar ~
7747 \SpecialChar ~
7748 \SpecialChar ~
7749 \SpecialChar ~
7750 push\SpecialChar ~
7751 \SpecialChar ~
7752 \SpecialChar ~
7753 \SpecialChar ~
7754 acc
7755 \newline 
7756 \SpecialChar ~
7757 \SpecialChar ~
7758 \SpecialChar ~
7759 \SpecialChar ~
7760 push\SpecialChar ~
7761 \SpecialChar ~
7762 \SpecialChar ~
7763 \SpecialChar ~
7764 b
7765 \newline 
7766 \SpecialChar ~
7767 \SpecialChar ~
7768 \SpecialChar ~
7769 \SpecialChar ~
7770 push\SpecialChar ~
7771 \SpecialChar ~
7772 \SpecialChar ~
7773 \SpecialChar ~
7774 dpl
7775 \newline 
7776 \SpecialChar ~
7777 \SpecialChar ~
7778 \SpecialChar ~
7779 \SpecialChar ~
7780 push\SpecialChar ~
7781 \SpecialChar ~
7782 \SpecialChar ~
7783 \SpecialChar ~
7784 dph
7785 \newline 
7786 \SpecialChar ~
7787 \SpecialChar ~
7788 \SpecialChar ~
7789 \SpecialChar ~
7790 push\SpecialChar ~
7791 \SpecialChar ~
7792 \SpecialChar ~
7793 \SpecialChar ~
7794 psw
7795 \newline 
7796 \SpecialChar ~
7797 \SpecialChar ~
7798 \SpecialChar ~
7799 \SpecialChar ~
7800 mov\SpecialChar ~
7801 \SpecialChar ~
7802 \SpecialChar ~
7803 \SpecialChar ~
7804 \SpecialChar ~
7805 psw,#0x00
7806 \newline 
7807 \SpecialChar ~
7808 \SpecialChar ~
7809 \SpecialChar ~
7810 \SpecialChar ~
7811 inc\SpecialChar ~
7812 \SpecialChar ~
7813 \SpecialChar ~
7814 \SpecialChar ~
7815 \SpecialChar ~
7816 _counter
7817 \newline 
7818 \SpecialChar ~
7819 \SpecialChar ~
7820 \SpecialChar ~
7821 \SpecialChar ~
7822 pop\SpecialChar ~
7823 \SpecialChar ~
7824 \SpecialChar ~
7825 \SpecialChar ~
7826 \SpecialChar ~
7827 psw
7828 \newline 
7829 \SpecialChar ~
7830 \SpecialChar ~
7831 \SpecialChar ~
7832 \SpecialChar ~
7833 pop\SpecialChar ~
7834 \SpecialChar ~
7835 \SpecialChar ~
7836 \SpecialChar ~
7837 \SpecialChar ~
7838 dph
7839 \newline 
7840 \SpecialChar ~
7841 \SpecialChar ~
7842 \SpecialChar ~
7843 \SpecialChar ~
7844 pop\SpecialChar ~
7845 \SpecialChar ~
7846 \SpecialChar ~
7847 \SpecialChar ~
7848 \SpecialChar ~
7849 dpl
7850 \newline 
7851 \SpecialChar ~
7852 \SpecialChar ~
7853 \SpecialChar ~
7854 \SpecialChar ~
7855 pop\SpecialChar ~
7856 \SpecialChar ~
7857 \SpecialChar ~
7858 \SpecialChar ~
7859 \SpecialChar ~
7860 b
7861 \newline 
7862 \SpecialChar ~
7863 \SpecialChar ~
7864 \SpecialChar ~
7865 \SpecialChar ~
7866 pop\SpecialChar ~
7867 \SpecialChar ~
7868 \SpecialChar ~
7869 \SpecialChar ~
7870 \SpecialChar ~
7871 acc
7872 \newline 
7873 \SpecialChar ~
7874 \SpecialChar ~
7875 \SpecialChar ~
7876 \SpecialChar ~
7877 reti
7878 \layout Standard
7879
7880 whereas nakedInterrupt looks like:
7881 \layout Verse
7882
7883
7884 \family typewriter 
7885 _nakedInterrupt:
7886 \newline 
7887 \SpecialChar ~
7888 \SpecialChar ~
7889 \SpecialChar ~
7890 \SpecialChar ~
7891 inc\SpecialChar ~
7892 \SpecialChar ~
7893 \SpecialChar ~
7894 \SpecialChar ~
7895 _counter
7896 \newline 
7897 \SpecialChar ~
7898 \SpecialChar ~
7899 \SpecialChar ~
7900 \SpecialChar ~
7901 reti\SpecialChar ~
7902 \SpecialChar ~
7903 \SpecialChar ~
7904 ; MUST explicitly include ret(i) in _naked function.
7905 \layout Standard
7906
7907 While there is nothing preventing you from writing C code inside a _naked
7908  function, there are many ways to shoot yourself in the foot doing this,
7909  and it is recommended that you stick to inline assembler.
7910 \layout Subsection
7911
7912 Functions using private banks
7913 \begin_inset LatexCommand \index{bank}
7914
7915 \end_inset 
7916
7917
7918 \layout Standard
7919
7920 The 
7921 \emph on 
7922 using
7923 \begin_inset LatexCommand \index{using}
7924
7925 \end_inset 
7926
7927
7928 \emph default 
7929  attribute (which tells the compiler to use a register bank other than the
7930  default bank zero) should only be applied to 
7931 \emph on 
7932 interrupt
7933 \begin_inset LatexCommand \index{interrupt}
7934
7935 \end_inset 
7936
7937
7938 \emph default 
7939  functions (see note 1 below).
7940  This will in most circumstances make the generated ISR code more efficient
7941  since it will not have to save registers on the stack.
7942 \layout Standard
7943
7944 The 
7945 \emph on 
7946 using
7947 \emph default 
7948  attribute will have no effect on the generated code for a 
7949 \emph on 
7950 non-interrupt
7951 \emph default 
7952  function (but may occasionally be useful anyway
7953 \begin_inset Foot
7954 collapsed false
7955
7956 \layout Standard
7957
7958 possible exception: if a function is called ONLY from 'interrupt' functions
7959  using a particular bank, it can be declared with the same 'using' attribute
7960  as the calling 'interrupt' functions.
7961  For instance, if you have several ISRs using bank one, and all of them
7962  call memcpy(), it might make sense to create a specialized version of memcpy()
7963  'using 1', since this would prevent the ISR from having to save bank zero
7964  to the stack on entry and switch to bank zero before calling the function
7965 \end_inset 
7966
7967 ).
7968 \newline 
7969
7970 \emph on 
7971 (pending: I don't think this has been done yet)
7972 \layout Standard
7973
7974 An 
7975 \emph on 
7976 interrupt
7977 \emph default 
7978  function using a non-zero bank will assume that it can trash that register
7979  bank, and will not save it.
7980  Since high-priority interrupts
7981 \begin_inset LatexCommand \index{interrupt priority}
7982
7983 \end_inset 
7984
7985  can interrupt low-priority ones on the 8051 and friends, this means that
7986  if a high-priority ISR 
7987 \emph on 
7988 using
7989 \emph default 
7990  a particular bank occurs while processing a low-priority ISR 
7991 \emph on 
7992 using
7993 \emph default 
7994  the same bank, terrible and bad things can happen.
7995  To prevent this, no single register bank should be 
7996 \emph on 
7997 used
7998 \emph default 
7999  by both a high priority and a low priority ISR.
8000  This is probably most easily done by having all high priority ISRs use
8001  one bank and all low priority ISRs use another.
8002  If you have an ISR which can change priority at runtime, you're on your
8003  own: I suggest using the default bank zero and taking the small performance
8004  hit.
8005 \layout Standard
8006
8007 It is most efficient if your ISR calls no other functions.
8008  If your ISR must call other functions, it is most efficient if those functions
8009  use the same bank as the ISR (see note 1 below); the next best is if the
8010  called functions use bank zero.
8011  It is very inefficient to call a function using a different, non-zero bank
8012  from an ISR.
8013  
8014 \layout Subsection
8015
8016 Absolute Addressing
8017 \begin_inset LatexCommand \index{Absolute addressing}
8018
8019 \end_inset 
8020
8021
8022 \layout Standard
8023
8024 Data items can be assigned an absolute address with the 
8025 \emph on 
8026 at
8027 \begin_inset LatexCommand \index{at}
8028
8029 \end_inset 
8030
8031  <address>
8032 \emph default 
8033  keyword, in addition to a storage class, e.g.:
8034 \layout Verse
8035
8036
8037 \family typewriter 
8038 xdata
8039 \begin_inset LatexCommand \index{xdata}
8040
8041 \end_inset 
8042
8043  at
8044 \begin_inset LatexCommand \index{at}
8045
8046 \end_inset 
8047
8048  0x8000 unsigned char PORTA_8255 ;
8049 \layout Standard
8050
8051 In the above example the PORTA_8255 will be allocated to the location 0x8000
8052  of the external ram.
8053  Note that this feature is provided to give the programmer access to 
8054 \emph on 
8055 memory mapped
8056 \emph default 
8057  devices attached to the controller.
8058  The compiler does not actually reserve any space for variables declared
8059  in this way (they are implemented with an equate in the assembler).
8060  Thus it is left to the programmer to make sure there are no overlaps with
8061  other variables that are declared without the absolute address.
8062  The assembler listing file (.lst
8063 \begin_inset LatexCommand \index{.lst}
8064
8065 \end_inset 
8066
8067 ) and the linker output files (.rst
8068 \begin_inset LatexCommand \index{.rst}
8069
8070 \end_inset 
8071
8072 ) and (.map
8073 \begin_inset LatexCommand \index{.map}
8074
8075 \end_inset 
8076
8077 ) are a good places to look for such overlaps.
8078 \newline 
8079
8080 \newline 
8081 Absolute address can be specified for variables in all storage classes,
8082  e.g.:
8083 \layout Verse
8084
8085
8086 \family typewriter 
8087 bit
8088 \begin_inset LatexCommand \index{bit}
8089
8090 \end_inset 
8091
8092  at
8093 \begin_inset LatexCommand \index{at}
8094
8095 \end_inset 
8096
8097  0x02 bvar;
8098 \layout Standard
8099
8100 The above example will allocate the variable at offset 0x02 in the bit-addressab
8101 le space.
8102  There is no real advantage to assigning absolute addresses to variables
8103  in this manner, unless you want strict control over all the variables allocated.
8104  One possible use would be to write hardware portable code.
8105  For example, if you have a routine that uses one or more of the microcontroller
8106  I/O pins, and such pins are different for two different hardwares, you
8107  can declare the I/O pins in you routine using
8108 \layout Verse
8109
8110
8111 \family typewriter 
8112 extern bit SDI;
8113 \newline 
8114 extern bit SCLK;
8115 \newline 
8116 extern bit CPOL;
8117 \newline 
8118
8119 \newline 
8120 void DS1306_put(unsigned char value)
8121 \newline 
8122 {
8123 \newline 
8124 \SpecialChar ~
8125 \SpecialChar ~
8126 \SpecialChar ~
8127 \SpecialChar ~
8128 unsigned char mask=0x80;
8129 \newline 
8130
8131 \newline 
8132 \SpecialChar ~
8133 \SpecialChar ~
8134 \SpecialChar ~
8135 \SpecialChar ~
8136 while(mask)
8137 \newline 
8138 \SpecialChar ~
8139 \SpecialChar ~
8140 \SpecialChar ~
8141 \SpecialChar ~
8142 {
8143 \newline 
8144 \SpecialChar ~
8145 \SpecialChar ~
8146 \SpecialChar ~
8147 \SpecialChar ~
8148 \SpecialChar ~
8149 \SpecialChar ~
8150 \SpecialChar ~
8151 \SpecialChar ~
8152 SDI=(value & mask)?1:0;
8153 \newline 
8154 \SpecialChar ~
8155 \SpecialChar ~
8156 \SpecialChar ~
8157 \SpecialChar ~
8158 \SpecialChar ~
8159 \SpecialChar ~
8160 \SpecialChar ~
8161 \SpecialChar ~
8162 SCLK=!CPOL;
8163 \newline 
8164 \SpecialChar ~
8165 \SpecialChar ~
8166 \SpecialChar ~
8167 \SpecialChar ~
8168 \SpecialChar ~
8169 \SpecialChar ~
8170 \SpecialChar ~
8171 \SpecialChar ~
8172 SCLK=CPOL;
8173 \newline 
8174 \SpecialChar ~
8175 \SpecialChar ~
8176 \SpecialChar ~
8177 \SpecialChar ~
8178 \SpecialChar ~
8179 \SpecialChar ~
8180 \SpecialChar ~
8181 \SpecialChar ~
8182 mask/=2;
8183 \newline 
8184 \SpecialChar ~
8185 \SpecialChar ~
8186 \SpecialChar ~
8187 \SpecialChar ~
8188 }
8189 \newline 
8190 }
8191 \layout Standard
8192
8193 Then, someplace in the code for the first hardware you would use
8194 \layout Verse
8195
8196
8197 \family typewriter 
8198 bit at 0x80 SDI;\SpecialChar ~
8199 \SpecialChar ~
8200 \SpecialChar ~
8201 \SpecialChar ~
8202 /*I/O port 0, bit 0*/
8203 \newline 
8204 bit at 0x81 SCLK;\SpecialChar ~
8205 \SpecialChar ~
8206 \SpecialChar ~
8207 /*I/O port 0, bit 1*/
8208 \newline 
8209 bit CPOL;\SpecialChar ~
8210 \SpecialChar ~
8211 \SpecialChar ~
8212 \SpecialChar ~
8213 \SpecialChar ~
8214 \SpecialChar ~
8215 \SpecialChar ~
8216 \SpecialChar ~
8217 \SpecialChar ~
8218 \SpecialChar ~
8219 \SpecialChar ~
8220 /*This is a variable, let the linker allocate this one*/
8221 \layout Standard
8222
8223 Similarly, for the second hardware you would use
8224 \layout Verse
8225
8226
8227 \family typewriter 
8228 bit at 0x83 SDI;\SpecialChar ~
8229 \SpecialChar ~
8230 \SpecialChar ~
8231 \SpecialChar ~
8232 /*I/O port 0, bit 3*/
8233 \newline 
8234 bit at 0x91 SCLK;\SpecialChar ~
8235 \SpecialChar ~
8236 \SpecialChar ~
8237 /*I/O port 1, bit 1*/
8238 \newline 
8239 bit CPOL;\SpecialChar ~
8240 \SpecialChar ~
8241 \SpecialChar ~
8242 \SpecialChar ~
8243 \SpecialChar ~
8244 \SpecialChar ~
8245 \SpecialChar ~
8246 \SpecialChar ~
8247 \SpecialChar ~
8248 \SpecialChar ~
8249 \SpecialChar ~
8250 /*This is a variable, let the linker allocate this one*/
8251 \layout Standard
8252
8253 and you can use the same hardware dependent routine without changes, as
8254  for example in a library.
8255  This is somehow similar to sbit, but only one absolute address has to be
8256  specified in the whole project.
8257 \layout Subsection
8258
8259 Startup Code
8260 \begin_inset LatexCommand \index{Startup code}
8261
8262 \end_inset 
8263
8264
8265 \layout Standard
8266
8267 The compiler inserts a call to the C routine 
8268 \emph on 
8269 _sdcc_external_startup()
8270 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
8271
8272 \end_inset 
8273
8274
8275 \series bold 
8276 \emph default 
8277  
8278 \series default 
8279 at the start of the CODE area.
8280  This routine is in the runtime library
8281 \begin_inset LatexCommand \index{Runtime library}
8282
8283 \end_inset 
8284
8285 .
8286  By default this routine returns 0, if this routine returns a non-zero value,
8287  the static & global variable initialization will be skipped and the function
8288  main will be invoked Other wise static & global variables will be initialized
8289  before the function main is invoked.
8290  You could add a 
8291 \emph on 
8292 _sdcc_external_startup()
8293 \emph default 
8294  routine to your program to override the default if you need to setup hardware
8295  or perform some other critical operation prior to static & global variable
8296  initialization.
8297 \layout Subsection
8298
8299 Inline Assembler Code
8300 \begin_inset LatexCommand \index{Assembler routines}
8301
8302 \end_inset 
8303
8304
8305 \layout Standard
8306
8307 SDCC allows the use of in-line assembler with a few restriction as regards
8308  labels.
8309  All labels defined within inline assembler code 
8310 \emph on 
8311 has to be
8312 \emph default 
8313  of the form 
8314 \emph on 
8315 nnnnn$
8316 \emph default 
8317  where nnnn is a number less than 100 (which implies a limit of utmost 100
8318  inline assembler labels 
8319 \emph on 
8320 per function
8321 \emph default 
8322 \noun on 
8323 )
8324 \noun default 
8325 .
8326  It is strongly recommended that each assembly instruction (including labels)
8327  be placed in a separate line (as the example shows).
8328  When the 
8329 \emph on 
8330 -
8331 \begin_inset ERT
8332 status Collapsed
8333
8334 \layout Standard
8335
8336 \backslash 
8337 /
8338 \end_inset 
8339
8340 -peep-asm
8341 \begin_inset LatexCommand \index{-\/-peep-asm}
8342
8343 \end_inset 
8344
8345
8346 \emph default 
8347  command line option is used, the inline assembler code will be passed through
8348  the peephole optimizer
8349 \begin_inset LatexCommand \index{Peephole optimizer}
8350
8351 \end_inset 
8352
8353 .
8354  This might cause some unexpected changes in the inline assembler code.
8355  Please go through the peephole optimizer rules defined in file 
8356 \emph on 
8357 SDCCpeeph.def
8358 \emph default 
8359  carefully before using this option.
8360 \layout Verse
8361
8362
8363 \family typewriter 
8364 _asm
8365 \begin_inset LatexCommand \index{\_asm}
8366
8367 \end_inset 
8368
8369  
8370 \newline 
8371 \SpecialChar ~
8372 \SpecialChar ~
8373 \SpecialChar ~
8374 \SpecialChar ~
8375 mov\SpecialChar ~
8376 \SpecialChar ~
8377 \SpecialChar ~
8378 \SpecialChar ~
8379 \SpecialChar ~
8380 b,#10 
8381 \newline 
8382 00001$: 
8383 \newline 
8384 \SpecialChar ~
8385 \SpecialChar ~
8386 \SpecialChar ~
8387 \SpecialChar ~
8388 djnz\SpecialChar ~
8389 \SpecialChar ~
8390 \SpecialChar ~
8391 \SpecialChar ~
8392 b,00001$ 
8393 \newline 
8394 _endasm
8395 \begin_inset LatexCommand \index{\_endasm}
8396
8397 \end_inset 
8398
8399  ;
8400 \layout Standard
8401
8402 The inline assembler code can contain any valid code understood by the assembler
8403 , this includes any assembler directives and comment lines.
8404  The compiler does not do any validation of the code within the 
8405 \family typewriter 
8406 _asm ...
8407  _endasm;
8408 \family default 
8409  keyword pair.
8410  
8411 \newline 
8412
8413 \newline 
8414 Inline assembler code cannot reference any C-Labels, however it can reference
8415  labels
8416 \begin_inset LatexCommand \index{Labels}
8417
8418 \end_inset 
8419
8420  defined by the inline assembler, e.g.:
8421 \layout Verse
8422
8423
8424 \family typewriter 
8425 foo() { 
8426 \newline 
8427 \SpecialChar ~
8428 \SpecialChar ~
8429 \SpecialChar ~
8430 \SpecialChar ~
8431 /* some c code */ 
8432 \newline 
8433 \SpecialChar ~
8434 \SpecialChar ~
8435 \SpecialChar ~
8436 \SpecialChar ~
8437 _asm 
8438 \newline 
8439 \SpecialChar ~
8440 \SpecialChar ~
8441 \SpecialChar ~
8442 \SpecialChar ~
8443 \SpecialChar ~
8444 \SpecialChar ~
8445 ; some assembler code 
8446 \newline 
8447 \SpecialChar ~
8448 \SpecialChar ~
8449 \SpecialChar ~
8450 \SpecialChar ~
8451 \SpecialChar ~
8452 \SpecialChar ~
8453 ljmp $0003 
8454 \newline 
8455 \SpecialChar ~
8456 \SpecialChar ~
8457 \SpecialChar ~
8458 \SpecialChar ~
8459 _endasm; 
8460 \newline 
8461 \SpecialChar ~
8462 \SpecialChar ~
8463 \SpecialChar ~
8464 \SpecialChar ~
8465 /* some more c code */ 
8466 \newline 
8467 clabel:\SpecialChar ~
8468 \SpecialChar ~
8469 /* inline assembler cannot reference this label */ 
8470 \newline 
8471 \SpecialChar ~
8472 \SpecialChar ~
8473 \SpecialChar ~
8474 \SpecialChar ~
8475 _asm
8476 \newline 
8477 \SpecialChar ~
8478 \SpecialChar ~
8479 \SpecialChar ~
8480 \SpecialChar ~
8481 $0003: ;label (can be reference by inline assembler only) 
8482 \newline 
8483 \SpecialChar ~
8484 \SpecialChar ~
8485 \SpecialChar ~
8486 \SpecialChar ~
8487 _endasm ; 
8488 \newline 
8489 \SpecialChar ~
8490 \SpecialChar ~
8491 \SpecialChar ~
8492 \SpecialChar ~
8493 /* some more c code */
8494 \newline 
8495 }
8496 \layout Standard
8497
8498 In other words inline assembly code can access labels defined in inline
8499  assembly within the scope of the function.
8500  The same goes the other way, ie.
8501  labels defines in inline assembly CANNOT be accessed by C statements.
8502 \layout Subsection
8503
8504 int (16 bit)
8505 \begin_inset LatexCommand \index{int (16 bit)}
8506
8507 \end_inset 
8508
8509  and long (32 bit)
8510 \begin_inset LatexCommand \index{long (32 bit)}
8511
8512 \end_inset 
8513
8514  Support
8515 \layout Standard
8516
8517 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
8518  multiplication and modulus operations are implemented by support routines.
8519  These support routines are all developed in ANSI-C to facilitate porting
8520  to other MCUs, although some model specific assembler optimizations are
8521  used.
8522  The following files contain the described routine, all of them can be found
8523  in <installdir>/share/sdcc/lib.
8524 \newline 
8525
8526 \layout Standard
8527 \align center 
8528
8529 \begin_inset  Tabular
8530 <lyxtabular version="3" rows="11" columns="2">
8531 <features>
8532 <column alignment="center" valignment="top" leftline="true" width="0(null)">
8533 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
8534 <row topline="true" bottomline="true">
8535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8536 \begin_inset Text
8537
8538 \layout Standard
8539
8540
8541 \series bold 
8542 Function
8543 \end_inset 
8544 </cell>
8545 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8546 \begin_inset Text
8547
8548 \layout Standard
8549
8550
8551 \series bold 
8552 Description
8553 \end_inset 
8554 </cell>
8555 </row>
8556 <row topline="true">
8557 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8558 \begin_inset Text
8559
8560 \layout Standard
8561
8562 _mulint.c 
8563 \end_inset 
8564 </cell>
8565 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8566 \begin_inset Text
8567
8568 \layout Standard
8569
8570 16 bit multiplication
8571 \end_inset 
8572 </cell>
8573 </row>
8574 <row topline="true">
8575 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8576 \begin_inset Text
8577
8578 \layout Standard
8579
8580 _divsint.c 
8581 \end_inset 
8582 </cell>
8583 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8584 \begin_inset Text
8585
8586 \layout Standard
8587
8588  signed 16 bit division (calls _divuint)
8589 \end_inset 
8590 </cell>
8591 </row>
8592 <row topline="true">
8593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8594 \begin_inset Text
8595
8596 \layout Standard
8597
8598 _divuint.c 
8599 \end_inset 
8600 </cell>
8601 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8602 \begin_inset Text
8603
8604 \layout Standard
8605
8606  unsigned 16 bit division
8607 \end_inset 
8608 </cell>
8609 </row>
8610 <row topline="true">
8611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8612 \begin_inset Text
8613
8614 \layout Standard
8615
8616 _modsint.c
8617 \end_inset 
8618 </cell>
8619 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8620 \begin_inset Text
8621
8622 \layout Standard
8623
8624 signed 16 bit modulus (calls _moduint)
8625 \end_inset 
8626 </cell>
8627 </row>
8628 <row topline="true">
8629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8630 \begin_inset Text
8631
8632 \layout Standard
8633
8634 _moduint.c
8635 \end_inset 
8636 </cell>
8637 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8638 \begin_inset Text
8639
8640 \layout Standard
8641
8642 unsigned 16 bit modulus
8643 \end_inset 
8644 </cell>
8645 </row>
8646 <row topline="true">
8647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8648 \begin_inset Text
8649
8650 \layout Standard
8651
8652 _mullong.c
8653 \end_inset 
8654 </cell>
8655 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8656 \begin_inset Text
8657
8658 \layout Standard
8659
8660 32 bit multiplication
8661 \end_inset 
8662 </cell>
8663 </row>
8664 <row topline="true">
8665 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8666 \begin_inset Text
8667
8668 \layout Standard
8669
8670 _divslong.c 
8671 \end_inset 
8672 </cell>
8673 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8674 \begin_inset Text
8675
8676 \layout Standard
8677
8678  signed 32 division (calls _divulong)
8679 \end_inset 
8680 </cell>
8681 </row>
8682 <row topline="true">
8683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8684 \begin_inset Text
8685
8686 \layout Standard
8687
8688 _divulong.c 
8689 \end_inset 
8690 </cell>
8691 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8692 \begin_inset Text
8693
8694 \layout Standard
8695
8696 unsigned 32 division
8697 \end_inset 
8698 </cell>
8699 </row>
8700 <row topline="true">
8701 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8702 \begin_inset Text
8703
8704 \layout Standard
8705
8706 _modslong.c
8707 \end_inset 
8708 </cell>
8709 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8710 \begin_inset Text
8711
8712 \layout Standard
8713
8714  signed 32 bit modulus (calls _modulong)
8715 \end_inset 
8716 </cell>
8717 </row>
8718 <row topline="true" bottomline="true">
8719 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8720 \begin_inset Text
8721
8722 \layout Standard
8723
8724 _modulong.c
8725 \end_inset 
8726 </cell>
8727 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8728 \begin_inset Text
8729
8730 \layout Standard
8731
8732 unsigned 32 bit modulus
8733 \end_inset 
8734 </cell>
8735 </row>
8736 </lyxtabular>
8737
8738 \end_inset 
8739
8740
8741 \newline 
8742
8743 \layout Standard
8744
8745 Since they are compiled as 
8746 \emph on 
8747 non-reentrant
8748 \emph default 
8749
8750 \begin_inset LatexCommand \index{reentrant}
8751
8752 \end_inset 
8753
8754 , interrupt
8755 \begin_inset LatexCommand \index{interrupt}
8756
8757 \end_inset 
8758
8759  service routines should not do any of the above operations.
8760  If this is unavoidable then the above routines will need to be compiled
8761  with the 
8762 \emph on 
8763 -
8764 \begin_inset ERT
8765 status Collapsed
8766
8767 \layout Standard
8768
8769 \backslash 
8770 /
8771 \end_inset 
8772
8773 -stack-auto
8774 \begin_inset LatexCommand \index{-\/-stack-auto}
8775
8776 \end_inset 
8777
8778
8779 \emph default 
8780  option, after which the source program will have to be compiled with 
8781 \emph on 
8782 -
8783 \begin_inset ERT
8784 status Collapsed
8785
8786 \layout Standard
8787
8788 \backslash 
8789 /
8790 \end_inset 
8791
8792 -int-long-rent
8793 \begin_inset LatexCommand \index{-\/-int-long-rent}
8794
8795 \end_inset 
8796
8797
8798 \emph default 
8799  option.
8800  Notice that you don't have to call this routines directly.
8801  The compiler will use them automatically every time a integer operation
8802  is required.
8803 \layout Subsection
8804
8805 Floating Point Support
8806 \begin_inset LatexCommand \index{Floating point support}
8807
8808 \end_inset 
8809
8810
8811 \layout Standard
8812
8813 SDCC supports IEEE (single precision 4 bytes) floating point numbers.The
8814  floating point support routines are derived from gcc's floatlib.c and consists
8815  of the following routines:
8816 \newline 
8817
8818 \layout Standard
8819 \align center 
8820
8821 \size footnotesize 
8822
8823 \begin_inset  Tabular
8824 <lyxtabular version="3" rows="17" columns="2">
8825 <features>
8826 <column alignment="center" valignment="top" leftline="true" width="0(null)">
8827 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
8828 <row topline="true" bottomline="true">
8829 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8830 \begin_inset Text
8831
8832 \layout Standard
8833
8834
8835 \family roman 
8836 \series medium 
8837 \shape up 
8838 \size normal 
8839 \emph off 
8840 \bar no 
8841 \noun off 
8842 \color none
8843 Function 
8844 \end_inset 
8845 </cell>
8846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8847 \begin_inset Text
8848
8849 \layout Standard
8850
8851 Description
8852 \end_inset 
8853 </cell>
8854 </row>
8855 <row topline="true">
8856 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8857 \begin_inset Text
8858
8859 \layout Standard
8860
8861
8862 \family roman 
8863 \series medium 
8864 \shape up 
8865 \size normal 
8866 \emph off 
8867 \bar no 
8868 \noun off 
8869 \color none
8870 _fsadd.c
8871 \end_inset 
8872 </cell>
8873 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8874 \begin_inset Text
8875
8876 \layout Standard
8877
8878
8879 \family roman 
8880 \series medium 
8881 \shape up 
8882 \size normal 
8883 \emph off 
8884 \bar no 
8885 \noun off 
8886 \color none
8887 add floating point numbers
8888 \end_inset 
8889 </cell>
8890 </row>
8891 <row topline="true">
8892 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8893 \begin_inset Text
8894
8895 \layout Standard
8896
8897
8898 \family roman 
8899 \series medium 
8900 \shape up 
8901 \size normal 
8902 \emph off 
8903 \bar no 
8904 \noun off 
8905 \color none
8906 _fssub.c 
8907 \end_inset 
8908 </cell>
8909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8910 \begin_inset Text
8911
8912 \layout Standard
8913
8914
8915 \family roman 
8916 \series medium 
8917 \shape up 
8918 \size normal 
8919 \emph off 
8920 \bar no 
8921 \noun off 
8922 \color none
8923 subtract floating point numbers 
8924 \end_inset 
8925 </cell>
8926 </row>
8927 <row topline="true">
8928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8929 \begin_inset Text
8930
8931 \layout Standard
8932
8933
8934 \family roman 
8935 \series medium 
8936 \shape up 
8937 \size normal 
8938 \emph off 
8939 \bar no 
8940 \noun off 
8941 \color none
8942 _fsdiv.c 
8943 \end_inset 
8944 </cell>
8945 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8946 \begin_inset Text
8947
8948 \layout Standard
8949
8950
8951 \family roman 
8952 \series medium 
8953 \shape up 
8954 \size normal 
8955 \emph off 
8956 \bar no 
8957 \noun off 
8958 \color none
8959 divide floating point numbers 
8960 \end_inset 
8961 </cell>
8962 </row>
8963 <row topline="true">
8964 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8965 \begin_inset Text
8966
8967 \layout Standard
8968
8969
8970 \family roman 
8971 \series medium 
8972 \shape up 
8973 \size normal 
8974 \emph off 
8975 \bar no 
8976 \noun off 
8977 \color none
8978 _fsmul.c 
8979 \end_inset 
8980 </cell>
8981 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8982 \begin_inset Text
8983
8984 \layout Standard
8985
8986
8987 \family roman 
8988 \series medium 
8989 \shape up 
8990 \size normal 
8991 \emph off 
8992 \bar no 
8993 \noun off 
8994 \color none
8995 multiply floating point numbers 
8996 \end_inset 
8997 </cell>
8998 </row>
8999 <row topline="true">
9000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9001 \begin_inset Text
9002
9003 \layout Standard
9004
9005
9006 \family roman 
9007 \series medium 
9008 \shape up 
9009 \size normal 
9010 \emph off 
9011 \bar no 
9012 \noun off 
9013 \color none
9014 _fs2uchar.c
9015 \end_inset 
9016 </cell>
9017 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9018 \begin_inset Text
9019
9020 \layout Standard
9021
9022
9023 \family roman 
9024 \series medium 
9025 \shape up 
9026 \size normal 
9027 \emph off 
9028 \bar no 
9029 \noun off 
9030 \color none
9031 convert floating point to unsigned char
9032 \end_inset 
9033 </cell>
9034 </row>
9035 <row topline="true">
9036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9037 \begin_inset Text
9038
9039 \layout Standard
9040
9041
9042 \family roman 
9043 \series medium 
9044 \shape up 
9045 \size normal 
9046 \emph off 
9047 \bar no 
9048 \noun off 
9049 \color none
9050 _fs2char.c
9051 \end_inset 
9052 </cell>
9053 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9054 \begin_inset Text
9055
9056 \layout Standard
9057
9058
9059 \family roman 
9060 \series medium 
9061 \shape up 
9062 \size normal 
9063 \emph off 
9064 \bar no 
9065 \noun off 
9066 \color none
9067 convert floating point to signed char
9068 \end_inset 
9069 </cell>
9070 </row>
9071 <row topline="true">
9072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9073 \begin_inset Text
9074
9075 \layout Standard
9076
9077
9078 \family roman 
9079 \series medium 
9080 \shape up 
9081 \size normal 
9082 \emph off 
9083 \bar no 
9084 \noun off 
9085 \color none
9086 _fs2uint.c
9087 \end_inset 
9088 </cell>
9089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9090 \begin_inset Text
9091
9092 \layout Standard
9093
9094
9095 \family roman 
9096 \series medium 
9097 \shape up 
9098 \size normal 
9099 \emph off 
9100 \bar no 
9101 \noun off 
9102 \color none
9103 convert floating point to unsigned int
9104 \end_inset 
9105 </cell>
9106 </row>
9107 <row topline="true">
9108 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9109 \begin_inset Text
9110
9111 \layout Standard
9112
9113
9114 \family roman 
9115 \series medium 
9116 \shape up 
9117 \size normal 
9118 \emph off 
9119 \bar no 
9120 \noun off 
9121 \color none
9122 _fs2int.c
9123 \end_inset 
9124 </cell>
9125 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9126 \begin_inset Text
9127
9128 \layout Standard
9129
9130
9131 \family roman 
9132 \series medium 
9133 \shape up 
9134 \size normal 
9135 \emph off 
9136 \bar no 
9137 \noun off 
9138 \color none
9139 convert floating point to signed int
9140 \end_inset 
9141 </cell>
9142 </row>
9143 <row topline="true">
9144 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9145 \begin_inset Text
9146
9147 \layout Standard
9148
9149
9150 \family roman 
9151 \series medium 
9152 \shape up 
9153 \size normal 
9154 \emph off 
9155 \bar no 
9156 \noun off 
9157 \color none
9158 _fs2ulong.
9159 \family default 
9160 \series default 
9161 \shape default 
9162 \size default 
9163 \emph default 
9164 \bar default 
9165 \noun default 
9166 \color default
9167 c
9168 \end_inset 
9169 </cell>
9170 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9171 \begin_inset Text
9172
9173 \layout Standard
9174
9175
9176 \family roman 
9177 \series medium 
9178 \shape up 
9179 \size normal 
9180 \emph off 
9181 \bar no 
9182 \noun off 
9183 \color none
9184 convert floating point to unsigned long
9185 \end_inset 
9186 </cell>
9187 </row>
9188 <row topline="true">
9189 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9190 \begin_inset Text
9191
9192 \layout Standard
9193
9194
9195 \family roman 
9196 \series medium 
9197 \shape up 
9198 \size normal 
9199 \emph off 
9200 \bar no 
9201 \noun off 
9202 \color none
9203 _fs2long.c
9204 \end_inset 
9205 </cell>
9206 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9207 \begin_inset Text
9208
9209 \layout Standard
9210
9211
9212 \family roman 
9213 \series medium 
9214 \shape up 
9215 \size normal 
9216 \emph off 
9217 \bar no 
9218 \noun off 
9219 \color none
9220 convert floating point to signed long
9221 \end_inset 
9222 </cell>
9223 </row>
9224 <row topline="true">
9225 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9226 \begin_inset Text
9227
9228 \layout Standard
9229
9230
9231 \family roman 
9232 \series medium 
9233 \shape up 
9234 \size normal 
9235 \emph off 
9236 \bar no 
9237 \noun off 
9238 \color none
9239 _uchar2fs.c
9240 \end_inset 
9241 </cell>
9242 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9243 \begin_inset Text
9244
9245 \layout Standard
9246
9247
9248 \family roman 
9249 \series medium 
9250 \shape up 
9251 \size normal 
9252 \emph off 
9253 \bar no 
9254 \noun off 
9255 \color none
9256 convert unsigned char to floating point
9257 \end_inset 
9258 </cell>
9259 </row>
9260 <row topline="true">
9261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9262 \begin_inset Text
9263
9264 \layout Standard
9265
9266
9267 \family roman 
9268 \series medium 
9269 \shape up 
9270 \size normal 
9271 \emph off 
9272 \bar no 
9273 \noun off 
9274 \color none
9275 _char2fs.c
9276 \end_inset 
9277 </cell>
9278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9279 \begin_inset Text
9280
9281 \layout Standard
9282
9283
9284 \family roman 
9285 \series medium 
9286 \shape up 
9287 \size normal 
9288 \emph off 
9289 \bar no 
9290 \noun off 
9291 \color none
9292 convert char to floating point number
9293 \end_inset 
9294 </cell>
9295 </row>
9296 <row topline="true">
9297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9298 \begin_inset Text
9299
9300 \layout Standard
9301
9302
9303 \family roman 
9304 \series medium 
9305 \shape up 
9306 \size normal 
9307 \emph off 
9308 \bar no 
9309 \noun off 
9310 \color none
9311 _uint2fs.c
9312 \end_inset 
9313 </cell>
9314 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9315 \begin_inset Text
9316
9317 \layout Standard
9318
9319
9320 \family roman 
9321 \series medium 
9322 \shape up 
9323 \size normal 
9324 \emph off 
9325 \bar no 
9326 \noun off 
9327 \color none
9328 convert unsigned int to floating point
9329 \end_inset 
9330 </cell>
9331 </row>
9332 <row topline="true">
9333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9334 \begin_inset Text
9335
9336 \layout Standard
9337
9338
9339 \family roman 
9340 \series medium 
9341 \shape up 
9342 \size normal 
9343 \emph off 
9344 \bar no 
9345 \noun off 
9346 \color none
9347 _int2fs.c
9348 \end_inset 
9349 </cell>
9350 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9351 \begin_inset Text
9352
9353 \layout Standard
9354
9355
9356 \family roman 
9357 \series medium 
9358 \shape up 
9359 \size normal 
9360 \emph off 
9361 \bar no 
9362 \noun off 
9363 \color none
9364 convert int to floating point numbers
9365 \end_inset 
9366 </cell>
9367 </row>
9368 <row topline="true">
9369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9370 \begin_inset Text
9371
9372 \layout Standard
9373
9374
9375 \family roman 
9376 \series medium 
9377 \shape up 
9378 \size normal 
9379 \emph off 
9380 \bar no 
9381 \noun off 
9382 \color none
9383 _ulong2fs.c
9384 \end_inset 
9385 </cell>
9386 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9387 \begin_inset Text
9388
9389 \layout Standard
9390
9391
9392 \family roman 
9393 \series medium 
9394 \shape up 
9395 \size normal 
9396 \emph off 
9397 \bar no 
9398 \noun off 
9399 \color none
9400 convert unsigned long to floating point number
9401 \end_inset 
9402 </cell>
9403 </row>
9404 <row topline="true" bottomline="true">
9405 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9406 \begin_inset Text
9407
9408 \layout Standard
9409
9410
9411 \family roman 
9412 \series medium 
9413 \shape up 
9414 \size normal 
9415 \emph off 
9416 \bar no 
9417 \noun off 
9418 \color none
9419 _long2fs.c
9420 \end_inset 
9421 </cell>
9422 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9423 \begin_inset Text
9424
9425 \layout Standard
9426
9427
9428 \family roman 
9429 \series medium 
9430 \shape up 
9431 \size normal 
9432 \emph off 
9433 \bar no 
9434 \noun off 
9435 \color none
9436 convert long to floating point number
9437 \end_inset 
9438 </cell>
9439 </row>
9440 </lyxtabular>
9441
9442 \end_inset 
9443
9444
9445 \newline 
9446
9447 \layout Standard
9448
9449 Note if all these routines are used simultaneously the data space might
9450  overflow.
9451  For serious floating point usage it is strongly recommended that the large
9452  model be used.
9453  Also notice that you don't have to call this routines directly.
9454  The compiler will use them automatically every time a floating point operation
9455  is required.
9456 \layout Subsection
9457
9458 MCS51 Memory Models
9459 \begin_inset LatexCommand \index{Memory model}
9460
9461 \end_inset 
9462
9463
9464 \begin_inset LatexCommand \index{MCS51 memory}
9465
9466 \end_inset 
9467
9468
9469 \layout Standard
9470
9471 SDCC allows two memory models for MCS51 code, small and large.
9472  Modules compiled with different memory models should 
9473 \emph on 
9474 never
9475 \emph default 
9476  be combined together or the results would be unpredictable.
9477  The library routines supplied with the compiler are compiled as both small
9478  and large.
9479  The compiled library modules are contained in separate directories as small
9480  and large so that you can link to either set.
9481  
9482 \layout Standard
9483
9484 When the large model is used all variables declared without a storage class
9485  will be allocated into the external ram, this includes all parameters and
9486  local variables (for non-reentrant
9487 \begin_inset LatexCommand \index{reentrant}
9488
9489 \end_inset 
9490
9491  functions).
9492  When the small model is used variables without storage class are allocated
9493  in the internal ram.
9494 \layout Standard
9495
9496 Judicious usage of the processor specific storage classes
9497 \begin_inset LatexCommand \index{Storage class}
9498
9499 \end_inset 
9500
9501  and the 'reentrant' function type will yield much more efficient code,
9502  than using the large model.
9503  Several optimizations are disabled when the program is compiled using the
9504  large model, it is therefore strongly recommended that the small model
9505  be used unless absolutely required.
9506 \layout Subsection
9507
9508 DS390 Memory Models
9509 \begin_inset LatexCommand \index{Memory model}
9510
9511 \end_inset 
9512
9513
9514 \begin_inset LatexCommand \index{DS390 memory model}
9515
9516 \end_inset 
9517
9518
9519 \layout Standard
9520
9521 The only model supported is Flat 24
9522 \begin_inset LatexCommand \index{Flat 24 (memory model)}
9523
9524 \end_inset 
9525
9526 .
9527  This generates code for the 24 bit contiguous addressing mode of the Dallas
9528  DS80C390 part.
9529  In this mode, up to four meg of external RAM or code space can be directly
9530  addressed.
9531  See the data sheets at www.dalsemi.com for further information on this part.
9532 \newline 
9533
9534 \newline 
9535 In older versions of the compiler, this option was used with the MCS51 code
9536  generator (
9537 \emph on 
9538 -mmcs51
9539 \emph default 
9540 ).
9541  Now, however, the '390 has it's own code generator, selected by the 
9542 \emph on 
9543 -mds390
9544 \emph default 
9545  switch.
9546  
9547 \newline 
9548
9549 \newline 
9550 Note that the compiler does not generate any code to place the processor
9551  into 24 bitmode (although 
9552 \emph on 
9553 tinibios
9554 \emph default 
9555  in the ds390 libraries will do that for you).
9556  If you don't use 
9557 \emph on 
9558 tinibios
9559 \emph default 
9560
9561 \begin_inset LatexCommand \index{Tinibios (DS390)}
9562
9563 \end_inset 
9564
9565 , the boot loader or similar code must ensure that the processor is in 24
9566  bit contiguous addressing mode before calling the SDCC startup code.
9567 \newline 
9568
9569 \newline 
9570 Like the 
9571 \emph on 
9572 -
9573 \begin_inset ERT
9574 status Collapsed
9575
9576 \layout Standard
9577
9578 \backslash 
9579 /
9580 \end_inset 
9581
9582 -model-large
9583 \emph default 
9584  option, variables will by default be placed into the XDATA segment.
9585  
9586 \newline 
9587
9588 \newline 
9589 Segments may be placed anywhere in the 4 meg address space using the usual
9590  -
9591 \begin_inset ERT
9592 status Collapsed
9593
9594 \layout Standard
9595
9596 \backslash 
9597 /
9598 \end_inset 
9599
9600 -*-loc options.
9601  Note that if any segments are located above 64K, the -r flag must be passed
9602  to the linker to generate the proper segment relocations, and the Intel
9603  HEX output format must be used.
9604  The -r flag can be passed to the linker by using the option 
9605 \emph on 
9606 -Wl-r
9607 \emph default 
9608  on the sdcc command line.
9609  However, currently the linker can not handle code segments > 64k.
9610 \layout Subsection
9611
9612 Defines Created by the Compiler
9613 \begin_inset LatexCommand \index{Defines created by the compiler}
9614
9615 \end_inset 
9616
9617
9618 \layout Standard
9619
9620 The compiler creates the following #defines
9621 \begin_inset LatexCommand \index{\#defines}
9622
9623 \end_inset 
9624
9625 :
9626 \newline 
9627
9628 \layout Standard
9629
9630
9631 \begin_inset  Tabular
9632 <lyxtabular version="3" rows="10" columns="2">
9633 <features>
9634 <column alignment="center" valignment="top" leftline="true" width="0(null)">
9635 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
9636 <row topline="true" bottomline="true">
9637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9638 \begin_inset Text
9639
9640 \layout Standard
9641
9642
9643 \series bold 
9644 #define
9645 \end_inset 
9646 </cell>
9647 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9648 \begin_inset Text
9649
9650 \layout Standard
9651
9652
9653 \series bold 
9654 Description
9655 \end_inset 
9656 </cell>
9657 </row>
9658 <row topline="true">
9659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9660 \begin_inset Text
9661
9662 \layout Standard
9663
9664 SDCC
9665 \begin_inset LatexCommand \index{SDCC}
9666
9667 \end_inset 
9668
9669  
9670 \end_inset 
9671 </cell>
9672 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9673 \begin_inset Text
9674
9675 \layout Standard
9676
9677 this Symbol is always defined
9678 \end_inset 
9679 </cell>
9680 </row>
9681 <row topline="true">
9682 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9683 \begin_inset Text
9684
9685 \layout Standard
9686
9687 SDCC_mcs51
9688 \begin_inset LatexCommand \index{SDCC\_mcs51}
9689
9690 \end_inset 
9691
9692  or SDCC_ds390
9693 \begin_inset LatexCommand \index{SDCC\_ds390}
9694
9695 \end_inset 
9696
9697  or SDCC_z80
9698 \begin_inset LatexCommand \index{SDCC\_z80}
9699
9700 \end_inset 
9701
9702 , etc
9703 \end_inset 
9704 </cell>
9705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9706 \begin_inset Text
9707
9708 \layout Standard
9709
9710 depending on the model used (e.g.: -mds390
9711 \end_inset 
9712 </cell>
9713 </row>
9714 <row topline="true">
9715 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9716 \begin_inset Text
9717
9718 \layout Standard
9719
9720 __mcs51
9721 \begin_inset LatexCommand \index{\_\_mcs51}
9722
9723 \end_inset 
9724
9725  or __ds390
9726 \begin_inset LatexCommand \index{\_\_ds390}
9727
9728 \end_inset 
9729
9730  or __z80
9731 \begin_inset LatexCommand \index{\_\_z80}
9732
9733 \end_inset 
9734
9735 , etc
9736 \end_inset 
9737 </cell>
9738 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9739 \begin_inset Text
9740
9741 \layout Standard
9742
9743 depending on the model used (e.g.
9744  -mz80)
9745 \end_inset 
9746 </cell>
9747 </row>
9748 <row topline="true">
9749 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9750 \begin_inset Text
9751
9752 \layout Standard
9753
9754 SDCC_STACK_AUTO
9755 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
9756
9757 \end_inset 
9758
9759
9760 \end_inset 
9761 </cell>
9762 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9763 \begin_inset Text
9764
9765 \layout Standard
9766
9767 when 
9768 \emph on 
9769 -
9770 \begin_inset ERT
9771 status Collapsed
9772
9773 \layout Standard
9774
9775 \backslash 
9776 /
9777 \end_inset 
9778
9779 -stack-auto
9780 \emph default 
9781  option is used
9782 \end_inset 
9783 </cell>
9784 </row>
9785 <row topline="true">
9786 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9787 \begin_inset Text
9788
9789 \layout Standard
9790
9791 SDCC_MODEL_SMALL
9792 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
9793
9794 \end_inset 
9795
9796
9797 \end_inset 
9798 </cell>
9799 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9800 \begin_inset Text
9801
9802 \layout Standard
9803
9804 when 
9805 \emph on 
9806 -
9807 \begin_inset ERT
9808 status Collapsed
9809
9810 \layout Standard
9811
9812 \backslash 
9813 /
9814 \end_inset 
9815
9816 -model-small
9817 \emph default 
9818  is used
9819 \end_inset 
9820 </cell>
9821 </row>
9822 <row topline="true">
9823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9824 \begin_inset Text
9825
9826 \layout Standard
9827
9828 SDCC_MODEL_LARGE
9829 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
9830
9831 \end_inset 
9832
9833
9834 \end_inset 
9835 </cell>
9836 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9837 \begin_inset Text
9838
9839 \layout Standard
9840
9841 when 
9842 \emph on 
9843 -
9844 \begin_inset ERT
9845 status Collapsed
9846
9847 \layout Standard
9848
9849 \backslash 
9850 /
9851 \end_inset 
9852
9853 -model-large
9854 \emph default 
9855  is used
9856 \end_inset 
9857 </cell>
9858 </row>
9859 <row topline="true">
9860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9861 \begin_inset Text
9862
9863 \layout Standard
9864
9865 SDCC_USE_XSTACK
9866 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
9867
9868 \end_inset 
9869
9870
9871 \end_inset 
9872 </cell>
9873 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9874 \begin_inset Text
9875
9876 \layout Standard
9877
9878 when 
9879 \emph on 
9880 -
9881 \begin_inset ERT
9882 status Collapsed
9883
9884 \layout Standard
9885
9886 \backslash 
9887 /
9888 \end_inset 
9889
9890 -xstack
9891 \emph default 
9892  option is used
9893 \end_inset 
9894 </cell>
9895 </row>
9896 <row topline="true">
9897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9898 \begin_inset Text
9899
9900 \layout Standard
9901
9902 SDCC_STACK_TENBIT
9903 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
9904
9905 \end_inset 
9906
9907  
9908 \end_inset 
9909 </cell>
9910 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9911 \begin_inset Text
9912
9913 \layout Standard
9914
9915 when 
9916 \emph on 
9917 -mds390
9918 \emph default 
9919  is used
9920 \end_inset 
9921 </cell>
9922 </row>
9923 <row topline="true" bottomline="true">
9924 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9925 \begin_inset Text
9926
9927 \layout Standard
9928
9929 SDCC_MODEL_FLAT24
9930 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
9931
9932 \end_inset 
9933
9934
9935 \end_inset 
9936 </cell>
9937 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9938 \begin_inset Text
9939
9940 \layout Standard
9941
9942 when 
9943 \emph on 
9944 -mds390
9945 \emph default 
9946  is used
9947 \end_inset 
9948 </cell>
9949 </row>
9950 </lyxtabular>
9951
9952 \end_inset 
9953
9954
9955 \newline 
9956
9957 \layout Subsection
9958
9959 Redirecting output on Windows Shells
9960 \layout Standard
9961
9962 SDCC writes it's error messages to 
9963 \begin_inset Quotes sld
9964 \end_inset 
9965
9966 standard error
9967 \begin_inset Quotes srd
9968 \end_inset 
9969
9970 .
9971  The windows 95/98/me shell (command or cmd) can't redirect it to a file.
9972  The solution is to use a reasonable shell or a helper program like redir.exe:
9973 \layout Standard
9974
9975
9976 \begin_inset LatexCommand \url{http://www.cygwin.com/ml/cygwin/1999-02/msg00603.html}
9977
9978 \end_inset 
9979
9980
9981 \layout Standard
9982
9983
9984 \begin_inset LatexCommand \url{ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/misc/redir.zip}
9985
9986 \end_inset 
9987
9988
9989 \layout Standard
9990
9991
9992 \begin_inset LatexCommand \url{ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/misc/README.redir}
9993
9994 \end_inset 
9995
9996
9997 \newline 
9998
9999 \newline 
10000 If you are using a windows NT/2K/XP shell, you can redirect the 
10001 \begin_inset Quotes sld
10002 \end_inset 
10003
10004 standard error
10005 \begin_inset Quotes srd
10006 \end_inset 
10007
10008  output to a file using 
10009 \begin_inset Quotes sld
10010 \end_inset 
10011
10012 2>
10013 \begin_inset Quotes srd
10014 \end_inset 
10015
10016 .
10017  For example:
10018 \newline 
10019
10020 \series bold 
10021
10022 \newline 
10023 sdcc -c foo.c 2> foo.err
10024 \newline 
10025
10026 \newline 
10027
10028 \series default 
10029 To append the 
10030 \begin_inset Quotes sld
10031 \end_inset 
10032
10033 standard error
10034 \begin_inset Quotes srd
10035 \end_inset 
10036
10037  output of SDCC to a file you can use 
10038 \begin_inset Quotes sld
10039 \end_inset 
10040
10041 2>>
10042 \begin_inset Quotes srd
10043 \end_inset 
10044
10045 .
10046  I you happen to have visual studio installed in your windows machine, you
10047  can use it to compile your sources using a custom build and the SDCC -
10048 \emph on 
10049
10050 \begin_inset ERT
10051 status Collapsed
10052
10053 \layout Standard
10054
10055 \backslash 
10056 /
10057 \end_inset 
10058
10059
10060 \emph default 
10061 -vc
10062 \begin_inset LatexCommand \index{-\/-vc}
10063
10064 \end_inset 
10065
10066  option.
10067  Something like this should work:
10068 \newline 
10069
10070 \newline 
10071
10072 \series bold 
10073 c:
10074 \backslash 
10075 sdcc
10076 \backslash 
10077 bin
10078 \backslash 
10079 sdcc.exe -
10080 \series default 
10081 \emph on 
10082
10083 \begin_inset ERT
10084 status Collapsed
10085
10086 \layout Standard
10087
10088 \backslash 
10089 /
10090 \end_inset 
10091
10092
10093 \series bold 
10094 \emph default 
10095 -vc -
10096 \series default 
10097 \emph on 
10098
10099 \begin_inset ERT
10100 status Collapsed
10101
10102 \layout Standard
10103
10104 \backslash 
10105 /
10106 \end_inset 
10107
10108
10109 \series bold 
10110 \emph default 
10111 -model-large -c $(InputPath)
10112 \layout Section
10113 \pagebreak_top 
10114 SDCC Technical Data
10115 \layout Subsection
10116
10117 Optimizations
10118 \begin_inset LatexCommand \index{Optimizations}
10119
10120 \end_inset 
10121
10122
10123 \layout Standard
10124
10125 SDCC performs a host of standard optimizations in addition to some MCU specific
10126  optimizations.
10127  
10128 \layout Subsubsection
10129
10130 Sub-expression Elimination
10131 \begin_inset LatexCommand \index{Subexpression elimination}
10132
10133 \end_inset 
10134
10135
10136 \layout Standard
10137
10138 The compiler does local and global common subexpression elimination, e.g.:
10139  
10140 \layout Verse
10141
10142
10143 \family typewriter 
10144 i = x + y + 1; 
10145 \newline 
10146 j = x + y;
10147 \layout Standard
10148
10149 will be translated to
10150 \layout Verse
10151
10152
10153 \family typewriter 
10154 iTemp = x + y 
10155 \newline 
10156 i = iTemp + 1 
10157 \newline 
10158 j = iTemp
10159 \layout Standard
10160
10161 Some subexpressions are not as obvious as the above example, e.g.:
10162 \layout Verse
10163
10164
10165 \family typewriter 
10166 a->b[i].c = 10; 
10167 \newline 
10168 a->b[i].d = 11;
10169 \layout Standard
10170
10171 In this case the address arithmetic a->b[i] will be computed only once;
10172  the equivalent code in C would be.
10173 \layout Verse
10174
10175
10176 \family typewriter 
10177 iTemp = a->b[i]; 
10178 \newline 
10179 iTemp.c = 10; 
10180 \newline 
10181 iTemp.d = 11;
10182 \layout Standard
10183
10184 The compiler will try to keep these temporary variables in registers.
10185 \layout Subsubsection
10186
10187 Dead-Code Elimination
10188 \begin_inset LatexCommand \index{Dead-code elimination}
10189
10190 \end_inset 
10191
10192
10193 \layout Verse
10194
10195
10196 \family typewriter 
10197 int global; 
10198 \newline 
10199 void f () { 
10200 \newline 
10201 \SpecialChar ~
10202 \SpecialChar ~
10203 int i; 
10204 \newline 
10205 \SpecialChar ~
10206 \SpecialChar ~
10207 i = 1; \SpecialChar ~
10208 /* dead store */ 
10209 \newline 
10210 \SpecialChar ~
10211 \SpecialChar ~
10212 global = 1;\SpecialChar ~
10213 /* dead store */ 
10214 \newline 
10215 \SpecialChar ~
10216 \SpecialChar ~
10217 global = 2; 
10218 \newline 
10219 \SpecialChar ~
10220 \SpecialChar ~
10221 return; 
10222 \newline 
10223 \SpecialChar ~
10224 \SpecialChar ~
10225 global = 3;\SpecialChar ~
10226 /* unreachable */ 
10227 \newline 
10228 }
10229 \layout Standard
10230
10231 will be changed to
10232 \layout Verse
10233
10234
10235 \family typewriter 
10236 int global; void f () 
10237 \newline 
10238 {
10239 \newline 
10240 \SpecialChar ~
10241 \SpecialChar ~
10242 global = 2; 
10243 \newline 
10244 \SpecialChar ~
10245 \SpecialChar ~
10246 return; 
10247 \newline 
10248 }
10249 \layout Subsubsection
10250
10251 Copy-Propagation
10252 \begin_inset LatexCommand \index{Copy propagation}
10253
10254 \end_inset 
10255
10256
10257 \layout Verse
10258
10259
10260 \family typewriter 
10261 int f() { 
10262 \newline 
10263 \SpecialChar ~
10264 \SpecialChar ~
10265 int i, j; 
10266 \newline 
10267 \SpecialChar ~
10268 \SpecialChar ~
10269 i = 10; 
10270 \newline 
10271 \SpecialChar ~
10272 \SpecialChar ~
10273 j = i; 
10274 \newline 
10275 \SpecialChar ~
10276 \SpecialChar ~
10277 return j; 
10278 \newline 
10279 }
10280 \layout Standard
10281
10282 will be changed to 
10283 \layout Verse
10284
10285
10286 \family typewriter 
10287 int f() { 
10288 \newline 
10289 \SpecialChar ~
10290 \SpecialChar ~
10291 int i, j; 
10292 \newline 
10293 \SpecialChar ~
10294 \SpecialChar ~
10295 i = 10; 
10296 \newline 
10297 \SpecialChar ~
10298 \SpecialChar ~
10299 j = 10; 
10300 \newline 
10301 \SpecialChar ~
10302 \SpecialChar ~
10303 return 10; 
10304 \newline 
10305 }
10306 \layout Standard
10307
10308 Note: the dead stores created by this copy propagation will be eliminated
10309  by dead-code elimination.
10310 \layout Subsubsection
10311
10312 Loop Optimizations
10313 \begin_inset LatexCommand \index{Loop optimization}
10314
10315 \end_inset 
10316
10317
10318 \layout Standard
10319
10320 Two types of loop optimizations are done by SDCC loop invariant lifting
10321  and strength reduction of loop induction variables.
10322  In addition to the strength reduction the optimizer marks the induction
10323  variables and the register allocator tries to keep the induction variables
10324  in registers for the duration of the loop.
10325  Because of this preference of the register allocator
10326 \begin_inset LatexCommand \index{Register allocation}
10327
10328 \end_inset 
10329
10330 , loop induction optimization causes an increase in register pressure, which
10331  may cause unwanted spilling of other temporary variables into the stack
10332 \begin_inset LatexCommand \index{stack}
10333
10334 \end_inset 
10335
10336  / data space.
10337  The compiler will generate a warning message when it is forced to allocate
10338  extra space either on the stack or data space.
10339  If this extra space allocation is undesirable then induction optimization
10340  can be eliminated either for the entire source file (with -
10341 \begin_inset ERT
10342 status Collapsed
10343
10344 \layout Standard
10345
10346 \backslash 
10347 /
10348 \end_inset 
10349
10350 -noinduction option) or for a given function only using #pragma\SpecialChar ~
10351 NOINDUCTION
10352 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
10353
10354 \end_inset 
10355
10356 .
10357 \newline 
10358
10359 \newline 
10360 Loop Invariant:
10361 \layout Verse
10362
10363
10364 \family typewriter 
10365 for (i = 0 ; i < 100 ; i ++) 
10366 \newline 
10367 \SpecialChar ~
10368 \SpecialChar ~
10369 f += k + l;
10370 \layout Standard
10371
10372 changed to
10373 \layout Verse
10374
10375
10376 \family typewriter 
10377 itemp = k + l; 
10378 \newline 
10379 for (i = 0; i < 100; i++) 
10380 \newline 
10381 \SpecialChar ~
10382 \SpecialChar ~
10383 f += itemp;
10384 \layout Standard
10385
10386 As mentioned previously some loop invariants are not as apparent, all static
10387  address computations are also moved out of the loop.
10388 \newline 
10389
10390 \newline 
10391 Strength Reduction
10392 \begin_inset LatexCommand \index{Strength reduction}
10393
10394 \end_inset 
10395
10396 , this optimization substitutes an expression by a cheaper expression:
10397 \layout Verse
10398
10399
10400 \family typewriter 
10401 for (i=0;i < 100; i++)
10402 \newline 
10403 \SpecialChar ~
10404 \SpecialChar ~
10405 ar[i*5] = i*3;
10406 \layout Standard
10407
10408 changed to
10409 \layout Verse
10410
10411
10412 \family typewriter 
10413 itemp1 = 0; 
10414 \newline 
10415 itemp2 = 0; 
10416 \newline 
10417 for (i=0;i< 100;i++) { 
10418 \newline 
10419 \SpecialChar ~
10420 \SpecialChar ~
10421 \SpecialChar ~
10422 \SpecialChar ~
10423 ar[itemp1] = itemp2; 
10424 \newline 
10425 \SpecialChar ~
10426 \SpecialChar ~
10427 \SpecialChar ~
10428 \SpecialChar ~
10429 itemp1 += 5; 
10430 \newline 
10431 \SpecialChar ~
10432 \SpecialChar ~
10433 \SpecialChar ~
10434 \SpecialChar ~
10435 itemp2 += 3; 
10436 \newline 
10437 }
10438 \layout Standard
10439
10440 The more expensive multiplication
10441 \begin_inset LatexCommand \index{Multiplication}
10442
10443 \end_inset 
10444
10445  is changed to a less expensive addition.
10446 \layout Subsubsection
10447
10448 Loop Reversing
10449 \begin_inset LatexCommand \index{Loop reversing}
10450
10451 \end_inset 
10452
10453
10454 \layout Standard
10455
10456 This optimization is done to reduce the overhead of checking loop boundaries
10457  for every iteration.
10458  Some simple loops can be reversed and implemented using a 
10459 \begin_inset Quotes eld
10460 \end_inset 
10461
10462 decrement and jump if not zero
10463 \begin_inset Quotes erd
10464 \end_inset 
10465
10466  instruction.
10467  SDCC checks for the following criterion to determine if a loop is reversible
10468  (note: more sophisticated compilers use data-dependency analysis to make
10469  this determination, SDCC uses a more simple minded analysis).
10470 \layout Itemize
10471
10472 The 'for' loop is of the form 
10473 \newline 
10474
10475 \newline 
10476
10477 \family typewriter 
10478 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
10479  += 1])
10480 \newline 
10481 \SpecialChar ~
10482 \SpecialChar ~
10483 \SpecialChar ~
10484 \SpecialChar ~
10485 <for body>
10486 \layout Itemize
10487
10488 The <for body> does not contain 
10489 \begin_inset Quotes eld
10490 \end_inset 
10491
10492 continue
10493 \begin_inset Quotes erd
10494 \end_inset 
10495
10496  or 'break
10497 \begin_inset Quotes erd
10498 \end_inset 
10499
10500 .
10501 \layout Itemize
10502
10503 All goto's are contained within the loop.
10504 \layout Itemize
10505
10506 No function calls within the loop.
10507 \layout Itemize
10508
10509 The loop control variable <sym> is not assigned any value within the loop
10510 \layout Itemize
10511
10512 The loop control variable does NOT participate in any arithmetic operation
10513  within the loop.
10514 \layout Itemize
10515
10516 There are NO switch statements in the loop.
10517 \layout Subsubsection
10518
10519 Algebraic Simplifications
10520 \layout Standard
10521
10522 SDCC does numerous algebraic simplifications, the following is a small sub-set
10523  of these optimizations.
10524 \layout Verse
10525
10526
10527 \family typewriter 
10528 i = j + 0 ; /* changed to */ i = j; 
10529 \newline 
10530 i /= 2; /* changed to */ i >>= 1; 
10531 \newline 
10532 i = j - j ; /* changed to */ i = 0; 
10533 \newline 
10534 i = j / 1 ; /* changed to */ i = j;
10535 \layout Standard
10536
10537 Note the subexpressions
10538 \begin_inset LatexCommand \index{Subexpression}
10539
10540 \end_inset 
10541
10542  given above are generally introduced by macro expansions or as a result
10543  of copy/constant propagation.
10544 \layout Subsubsection
10545
10546 'switch' Statements
10547 \begin_inset LatexCommand \index{switch statement}
10548
10549 \end_inset 
10550
10551
10552 \layout Standard
10553
10554 SDCC changes switch statements to jump tables
10555 \begin_inset LatexCommand \index{jump tables}
10556
10557 \end_inset 
10558
10559  when the following conditions are true.
10560  
10561 \layout Itemize
10562
10563 The case labels are in numerical sequence, the labels need not be in order,
10564  and the starting number need not be one or zero.
10565 \begin_deeper 
10566 \layout Verse
10567
10568
10569 \family typewriter 
10570 switch(i) {\SpecialChar ~
10571 \SpecialChar ~
10572 \SpecialChar ~
10573 \SpecialChar ~
10574 \SpecialChar ~
10575 \SpecialChar ~
10576 \SpecialChar ~
10577 \SpecialChar ~
10578 \SpecialChar ~
10579 \SpecialChar ~
10580 \SpecialChar ~
10581 \SpecialChar ~
10582 \SpecialChar ~
10583 \SpecialChar ~
10584 \SpecialChar ~
10585 \SpecialChar ~
10586 \SpecialChar ~
10587 \SpecialChar ~
10588 \SpecialChar ~
10589 \SpecialChar ~
10590 \SpecialChar ~
10591 \SpecialChar ~
10592 \SpecialChar ~
10593 \SpecialChar ~
10594 \SpecialChar ~
10595 \SpecialChar ~
10596 switch (i) { 
10597 \newline 
10598 \SpecialChar ~
10599 \SpecialChar ~
10600 \SpecialChar ~
10601 case 4: ...\SpecialChar ~
10602 \SpecialChar ~
10603 \SpecialChar ~
10604 \SpecialChar ~
10605 \SpecialChar ~
10606 \SpecialChar ~
10607 \SpecialChar ~
10608 \SpecialChar ~
10609 \SpecialChar ~
10610 \SpecialChar ~
10611 \SpecialChar ~
10612 \SpecialChar ~
10613 \SpecialChar ~
10614 \SpecialChar ~
10615 \SpecialChar ~
10616 \SpecialChar ~
10617 \SpecialChar ~
10618 \SpecialChar ~
10619 \SpecialChar ~
10620 \SpecialChar ~
10621 \SpecialChar ~
10622 \SpecialChar ~
10623 \SpecialChar ~
10624 \SpecialChar ~
10625 \SpecialChar ~
10626 \SpecialChar ~
10627 case 1: ...
10628  
10629 \newline 
10630 \SpecialChar ~
10631 \SpecialChar ~
10632 \SpecialChar ~
10633 case 5: ...\SpecialChar ~
10634 \SpecialChar ~
10635 \SpecialChar ~
10636 \SpecialChar ~
10637 \SpecialChar ~
10638 \SpecialChar ~
10639 \SpecialChar ~
10640 \SpecialChar ~
10641 \SpecialChar ~
10642 \SpecialChar ~
10643 \SpecialChar ~
10644 \SpecialChar ~
10645 \SpecialChar ~
10646 \SpecialChar ~
10647 \SpecialChar ~
10648 \SpecialChar ~
10649 \SpecialChar ~
10650 \SpecialChar ~
10651 \SpecialChar ~
10652 \SpecialChar ~
10653 \SpecialChar ~
10654 \SpecialChar ~
10655 \SpecialChar ~
10656 \SpecialChar ~
10657 \SpecialChar ~
10658 \SpecialChar ~
10659 case 2: ...
10660  
10661 \newline 
10662 \SpecialChar ~
10663 \SpecialChar ~
10664 \SpecialChar ~
10665 case 3: ...\SpecialChar ~
10666 \SpecialChar ~
10667 \SpecialChar ~
10668 \SpecialChar ~
10669 \SpecialChar ~
10670 \SpecialChar ~
10671 \SpecialChar ~
10672 \SpecialChar ~
10673 \SpecialChar ~
10674 \SpecialChar ~
10675 \SpecialChar ~
10676 \SpecialChar ~
10677 \SpecialChar ~
10678 \SpecialChar ~
10679 \SpecialChar ~
10680 \SpecialChar ~
10681 \SpecialChar ~
10682 \SpecialChar ~
10683 \SpecialChar ~
10684 \SpecialChar ~
10685 \SpecialChar ~
10686 \SpecialChar ~
10687 \SpecialChar ~
10688 \SpecialChar ~
10689 \SpecialChar ~
10690 \SpecialChar ~
10691 case 3: ...
10692  
10693 \newline 
10694 \SpecialChar ~
10695 \SpecialChar ~
10696 \SpecialChar ~
10697 case 6: ...\SpecialChar ~
10698 \SpecialChar ~
10699 \SpecialChar ~
10700 \SpecialChar ~
10701 \SpecialChar ~
10702 \SpecialChar ~
10703 \SpecialChar ~
10704 \SpecialChar ~
10705 \SpecialChar ~
10706 \SpecialChar ~
10707 \SpecialChar ~
10708 \SpecialChar ~
10709 \SpecialChar ~
10710 \SpecialChar ~
10711 \SpecialChar ~
10712 \SpecialChar ~
10713 \SpecialChar ~
10714 \SpecialChar ~
10715 \SpecialChar ~
10716 \SpecialChar ~
10717 \SpecialChar ~
10718 \SpecialChar ~
10719 \SpecialChar ~
10720 \SpecialChar ~
10721 \SpecialChar ~
10722 \SpecialChar ~
10723 case 4: ...
10724  
10725 \newline 
10726 }\SpecialChar ~
10727 \SpecialChar ~
10728 \SpecialChar ~
10729 \SpecialChar ~
10730 \SpecialChar ~
10731 \SpecialChar ~
10732 \SpecialChar ~
10733 \SpecialChar ~
10734 \SpecialChar ~
10735 \SpecialChar ~
10736 \SpecialChar ~
10737 \SpecialChar ~
10738 \SpecialChar ~
10739 \SpecialChar ~
10740 \SpecialChar ~
10741 \SpecialChar ~
10742 \SpecialChar ~
10743 \SpecialChar ~
10744 \SpecialChar ~
10745 \SpecialChar ~
10746 \SpecialChar ~
10747 \SpecialChar ~
10748 \SpecialChar ~
10749 \SpecialChar ~
10750 \SpecialChar ~
10751 \SpecialChar ~
10752 \SpecialChar ~
10753 \SpecialChar ~
10754 \SpecialChar ~
10755 \SpecialChar ~
10756 \SpecialChar ~
10757 \SpecialChar ~
10758 \SpecialChar ~
10759 \SpecialChar ~
10760 \SpecialChar ~
10761 \SpecialChar ~
10762 }
10763 \layout Standard
10764
10765 Both the above switch statements will be implemented using a jump-table.
10766 \end_deeper 
10767 \layout Itemize
10768
10769 The number of case labels is at least three, since it takes two conditional
10770  statements to handle the boundary conditions.
10771 \layout Itemize
10772
10773 The number of case labels is less than 84, since each label takes 3 bytes
10774  and a jump-table can be utmost 256 bytes long.
10775  
10776 \layout Standard
10777
10778 Switch statements which have gaps in the numeric sequence or those that
10779  have more that 84 case labels can be split into more than one switch statement
10780  for efficient code generation, e.g.:
10781 \layout Verse
10782
10783
10784 \family typewriter 
10785 switch (i) { 
10786 \newline 
10787 \SpecialChar ~
10788 \SpecialChar ~
10789 case 1: ...
10790  
10791 \newline 
10792 \SpecialChar ~
10793 \SpecialChar ~
10794 case 2: ...
10795  
10796 \newline 
10797 \SpecialChar ~
10798 \SpecialChar ~
10799 case 3: ...
10800  
10801 \newline 
10802 \SpecialChar ~
10803 \SpecialChar ~
10804 case 4: ...
10805  
10806 \newline 
10807 \SpecialChar ~
10808 \SpecialChar ~
10809 case 9: ...
10810  
10811 \newline 
10812 \SpecialChar ~
10813 \SpecialChar ~
10814 case 10: ...
10815  
10816 \newline 
10817 \SpecialChar ~
10818 \SpecialChar ~
10819 case 11: ...
10820  
10821 \newline 
10822 \SpecialChar ~
10823 \SpecialChar ~
10824 case 12: ...
10825  
10826 \newline 
10827 }
10828 \layout Standard
10829
10830 If the above switch statement is broken down into two switch statements
10831 \layout Verse
10832
10833
10834 \family typewriter 
10835 switch (i) { 
10836 \newline 
10837 \SpecialChar ~
10838 \SpecialChar ~
10839 case 1: ...
10840  
10841 \newline 
10842 \SpecialChar ~
10843 \SpecialChar ~
10844 case 2: ...
10845  
10846 \newline 
10847 \SpecialChar ~
10848 \SpecialChar ~
10849 case 3: ...
10850  
10851 \newline 
10852 \SpecialChar ~
10853 \SpecialChar ~
10854 case 4: ...
10855  
10856 \newline 
10857 }
10858 \layout Standard
10859
10860 and
10861 \layout Verse
10862
10863
10864 \family typewriter 
10865 switch (i) { 
10866 \newline 
10867 \SpecialChar ~
10868 \SpecialChar ~
10869 case 9: \SpecialChar ~
10870 ...
10871  
10872 \newline 
10873 \SpecialChar ~
10874 \SpecialChar ~
10875 case 10: ...
10876  
10877 \newline 
10878 \SpecialChar ~
10879 \SpecialChar ~
10880 case 11: ...
10881  
10882 \newline 
10883 \SpecialChar ~
10884 \SpecialChar ~
10885 case 12:\SpecialChar ~
10886 ...
10887  
10888 \newline 
10889 }
10890 \layout Standard
10891
10892 then both the switch statements will be implemented using jump-tables whereas
10893  the unmodified switch statement will not be.
10894 \layout Subsubsection
10895
10896 Bit-shifting Operations
10897 \begin_inset LatexCommand \index{Bit shifting}
10898
10899 \end_inset 
10900
10901 .
10902 \layout Standard
10903
10904 Bit shifting is one of the most frequently used operation in embedded programmin
10905 g.
10906  SDCC tries to implement bit-shift operations in the most efficient way
10907  possible, e.g.:
10908 \layout Verse
10909
10910
10911 \family typewriter 
10912 unsigned char i;
10913 \newline 
10914 ...
10915  
10916 \newline 
10917 i>>= 4; 
10918 \newline 
10919 ...
10920 \layout Standard
10921
10922 generates the following code:
10923 \layout Verse
10924
10925
10926 \family typewriter 
10927 mov a,_i 
10928 \newline 
10929 swap a 
10930 \newline 
10931 anl a,#0x0f 
10932 \newline 
10933 mov _i,a
10934 \layout Standard
10935
10936 In general SDCC will never setup a loop if the shift count is known.
10937  Another example:
10938 \layout Verse
10939
10940
10941 \family typewriter 
10942 unsigned int i; 
10943 \newline 
10944 ...
10945  
10946 \newline 
10947 i >>= 9; 
10948 \newline 
10949 ...
10950 \layout Standard
10951
10952 will generate:
10953 \layout Verse
10954
10955
10956 \family typewriter 
10957 mov a,(_i + 1) 
10958 \newline 
10959 mov (_i + 1),#0x00 
10960 \newline 
10961 clr c 
10962 \newline 
10963 rrc a 
10964 \newline 
10965 mov _i,a
10966 \layout Standard
10967
10968 Note that SDCC stores numbers in little-endian format (i.e.
10969  lowest order first).
10970 \layout Subsubsection
10971
10972 Bit-rotation
10973 \begin_inset LatexCommand \index{Bit rotation}
10974
10975 \end_inset 
10976
10977
10978 \layout Standard
10979
10980 A special case of the bit-shift operation is bit rotation, SDCC recognizes
10981  the following expression to be a left bit-rotation:
10982 \layout Verse
10983
10984
10985 \family typewriter 
10986 unsigned char i; 
10987 \newline 
10988 ...
10989  
10990 \newline 
10991 i = ((i << 1) | (i >> 7)); 
10992 \family default 
10993
10994 \newline 
10995
10996 \family typewriter 
10997 ...
10998 \layout Standard
10999
11000 will generate the following code:
11001 \layout Verse
11002
11003
11004 \family typewriter 
11005 mov a,_i 
11006 \newline 
11007 rl a 
11008 \newline 
11009 mov _i,a
11010 \layout Standard
11011
11012 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
11013 ns of this case will also be recognized as bit-rotation, i.e.: 
11014 \layout Verse
11015
11016
11017 \family typewriter 
11018 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
11019 \layout Subsubsection
11020
11021 Highest Order Bit
11022 \begin_inset LatexCommand \index{Highest Order Bit}
11023
11024 \end_inset 
11025
11026
11027 \layout Standard
11028
11029 It is frequently required to obtain the highest order bit of an integral
11030  type (long, int, short or char types).
11031  SDCC recognizes the following expression to yield the highest order bit
11032  and generates optimized code for it, e.g.:
11033 \layout Verse
11034
11035
11036 \family typewriter 
11037 unsigned int gint; 
11038 \newline 
11039
11040 \newline 
11041 foo () { 
11042 \newline 
11043 unsigned char hob; 
11044 \newline 
11045 \SpecialChar ~
11046 \SpecialChar ~
11047 ...
11048  
11049 \newline 
11050 \SpecialChar ~
11051 \SpecialChar ~
11052 hob = (gint >> 15) & 1; 
11053 \newline 
11054 \SpecialChar ~
11055 \SpecialChar ~
11056 ..
11057  
11058 \newline 
11059 }
11060 \layout Standard
11061
11062 will generate the following code:
11063 \layout Verse
11064
11065
11066 \family typewriter 
11067 \SpecialChar ~
11068 \SpecialChar ~
11069 \SpecialChar ~
11070 \SpecialChar ~
11071 \SpecialChar ~
11072 \SpecialChar ~
11073 \SpecialChar ~
11074 \SpecialChar ~
11075 \SpecialChar ~
11076 \SpecialChar ~
11077 \SpecialChar ~
11078 \SpecialChar ~
11079 \SpecialChar ~
11080 \SpecialChar ~
11081 \SpecialChar ~
11082 \SpecialChar ~
11083 \SpecialChar ~
11084 \SpecialChar ~
11085 \SpecialChar ~
11086 \SpecialChar ~
11087 \SpecialChar ~
11088 \SpecialChar ~
11089 \SpecialChar ~
11090 \SpecialChar ~
11091 \SpecialChar ~
11092  61 ;\SpecialChar ~
11093  hob.c 7 
11094 \newline 
11095 000A E5*01\SpecialChar ~
11096 \SpecialChar ~
11097 \SpecialChar ~
11098 \SpecialChar ~
11099 \SpecialChar ~
11100 \SpecialChar ~
11101 \SpecialChar ~
11102 \SpecialChar ~
11103 \SpecialChar ~
11104 \SpecialChar ~
11105 \SpecialChar ~
11106 \SpecialChar ~
11107 \SpecialChar ~
11108 \SpecialChar ~
11109 \SpecialChar ~
11110  62\SpecialChar ~
11111 \SpecialChar ~
11112 \SpecialChar ~
11113 \SpecialChar ~
11114 \SpecialChar ~
11115 \SpecialChar ~
11116 \SpecialChar ~
11117 \SpecialChar ~
11118  mov\SpecialChar ~
11119  a,(_gint + 1) 
11120 \newline 
11121 000C 33\SpecialChar ~
11122 \SpecialChar ~
11123 \SpecialChar ~
11124 \SpecialChar ~
11125 \SpecialChar ~
11126 \SpecialChar ~
11127 \SpecialChar ~
11128 \SpecialChar ~
11129 \SpecialChar ~
11130 \SpecialChar ~
11131 \SpecialChar ~
11132 \SpecialChar ~
11133 \SpecialChar ~
11134 \SpecialChar ~
11135 \SpecialChar ~
11136 \SpecialChar ~
11137 \SpecialChar ~
11138 \SpecialChar ~
11139  63\SpecialChar ~
11140 \SpecialChar ~
11141 \SpecialChar ~
11142 \SpecialChar ~
11143 \SpecialChar ~
11144 \SpecialChar ~
11145 \SpecialChar ~
11146 \SpecialChar ~
11147  rlc\SpecialChar ~
11148  a 
11149 \newline 
11150 000D E4\SpecialChar ~
11151 \SpecialChar ~
11152 \SpecialChar ~
11153 \SpecialChar ~
11154 \SpecialChar ~
11155 \SpecialChar ~
11156 \SpecialChar ~
11157 \SpecialChar ~
11158 \SpecialChar ~
11159 \SpecialChar ~
11160 \SpecialChar ~
11161 \SpecialChar ~
11162 \SpecialChar ~
11163 \SpecialChar ~
11164 \SpecialChar ~
11165 \SpecialChar ~
11166 \SpecialChar ~
11167 \SpecialChar ~
11168  64\SpecialChar ~
11169 \SpecialChar ~
11170 \SpecialChar ~
11171 \SpecialChar ~
11172 \SpecialChar ~
11173 \SpecialChar ~
11174 \SpecialChar ~
11175 \SpecialChar ~
11176  clr\SpecialChar ~
11177  a 
11178 \newline 
11179 000E 13\SpecialChar ~
11180 \SpecialChar ~
11181 \SpecialChar ~
11182 \SpecialChar ~
11183 \SpecialChar ~
11184 \SpecialChar ~
11185 \SpecialChar ~
11186 \SpecialChar ~
11187 \SpecialChar ~
11188 \SpecialChar ~
11189 \SpecialChar ~
11190 \SpecialChar ~
11191 \SpecialChar ~
11192 \SpecialChar ~
11193 \SpecialChar ~
11194 \SpecialChar ~
11195 \SpecialChar ~
11196 \SpecialChar ~
11197  65\SpecialChar ~
11198 \SpecialChar ~
11199 \SpecialChar ~
11200 \SpecialChar ~
11201 \SpecialChar ~
11202 \SpecialChar ~
11203 \SpecialChar ~
11204 \SpecialChar ~
11205  rrc\SpecialChar ~
11206  a 
11207 \newline 
11208 000F F5*02\SpecialChar ~
11209 \SpecialChar ~
11210 \SpecialChar ~
11211 \SpecialChar ~
11212 \SpecialChar ~
11213 \SpecialChar ~
11214 \SpecialChar ~
11215 \SpecialChar ~
11216 \SpecialChar ~
11217 \SpecialChar ~
11218 \SpecialChar ~
11219 \SpecialChar ~
11220 \SpecialChar ~
11221 \SpecialChar ~
11222 \SpecialChar ~
11223  66\SpecialChar ~
11224 \SpecialChar ~
11225 \SpecialChar ~
11226 \SpecialChar ~
11227 \SpecialChar ~
11228 \SpecialChar ~
11229 \SpecialChar ~
11230 \SpecialChar ~
11231  mov\SpecialChar ~
11232  _foo_hob_1_1,a
11233 \layout Standard
11234
11235 Variations of this case however will 
11236 \emph on 
11237 not
11238 \emph default 
11239  be recognized.
11240  It is a standard C expression, so I heartily recommend this be the only
11241  way to get the highest order bit, (it is portable).
11242  Of course it will be recognized even if it is embedded in other expressions,
11243  e.g.:
11244 \layout Verse
11245
11246
11247 \family typewriter 
11248 xyz = gint + ((gint >> 15) & 1);
11249 \layout Standard
11250
11251 will still be recognized.
11252 \layout Subsubsection
11253
11254 Peephole Optimizer
11255 \begin_inset LatexCommand \index{Peephole optimizer}
11256
11257 \end_inset 
11258
11259
11260 \layout Standard
11261
11262 The compiler uses a rule based, pattern matching and re-writing mechanism
11263  for peep-hole optimization.
11264  It is inspired by 
11265 \emph on 
11266 copt
11267 \emph default 
11268  a peep-hole optimizer by Christopher W.
11269  Fraser (cwfraser@microsoft.com).
11270  A default set of rules are compiled into the compiler, additional rules
11271  may be added with the 
11272 \emph on 
11273 -
11274 \begin_inset ERT
11275 status Collapsed
11276
11277 \layout Standard
11278
11279 \backslash 
11280 /
11281 \end_inset 
11282
11283 -peep-file
11284 \begin_inset LatexCommand \index{-\/-peep-file}
11285
11286 \end_inset 
11287
11288  <filename>
11289 \emph default 
11290  option.
11291  The rule language is best illustrated with examples.
11292 \layout Verse
11293
11294
11295 \family typewriter 
11296 replace { 
11297 \newline 
11298 \SpecialChar ~
11299 \SpecialChar ~
11300 mov %1,a 
11301 \newline 
11302 \SpecialChar ~
11303 \SpecialChar ~
11304 mov a,%1
11305 \newline 
11306 } by {
11307 \newline 
11308 \SpecialChar ~
11309 \SpecialChar ~
11310 mov %1,a
11311 \newline 
11312 }
11313 \layout Standard
11314
11315 The above rule will change the following assembly
11316 \begin_inset LatexCommand \index{Assembler routines}
11317
11318 \end_inset 
11319
11320  sequence:
11321 \layout Verse
11322
11323
11324 \family typewriter 
11325 mov r1,a 
11326 \newline 
11327 mov a,r1
11328 \layout Standard
11329
11330 to
11331 \layout Verse
11332
11333
11334 \family typewriter 
11335 mov r1,a
11336 \layout Standard
11337
11338 Note: All occurrences of a 
11339 \emph on 
11340 %n
11341 \emph default 
11342  (pattern variable) must denote the same string.
11343  With the above rule, the assembly sequence:
11344 \layout Verse
11345
11346
11347 \family typewriter 
11348 mov r1,a 
11349 \newline 
11350 mov a,r2
11351 \layout Standard
11352
11353 will remain unmodified.
11354 \newline 
11355
11356 \newline 
11357 Other special case optimizations may be added by the user (via 
11358 \emph on 
11359 -
11360 \begin_inset ERT
11361 status Collapsed
11362
11363 \layout Standard
11364
11365 \backslash 
11366 /
11367 \end_inset 
11368
11369 -peep-file option
11370 \emph default 
11371 ).
11372  E.g.
11373  some variants of the 8051 MCU allow only 
11374 \family typewriter 
11375 ajmp
11376 \family default 
11377  and 
11378 \family typewriter 
11379 acall
11380 \family default 
11381 .
11382  The following two rules will change all 
11383 \family typewriter 
11384 ljmp
11385 \family default 
11386  and 
11387 \family typewriter 
11388 lcall
11389 \family default 
11390  to 
11391 \family typewriter 
11392 ajmp
11393 \family default 
11394  and 
11395 \family typewriter 
11396 acall
11397 \layout Verse
11398
11399
11400 \family typewriter 
11401 replace { lcall %1 } by { acall %1 } 
11402 \newline 
11403 replace { ljmp %1 } by { ajmp %1 }
11404 \layout Standard
11405
11406 The 
11407 \emph on 
11408 inline-assembler code
11409 \emph default 
11410  is also passed through the peep hole optimizer, thus the peephole optimizer
11411  can also be used as an assembly level macro expander.
11412  The rules themselves are MCU dependent whereas the rule language infra-structur
11413 e is MCU independent.
11414  Peephole optimization rules for other MCU can be easily programmed using
11415  the rule language.
11416 \newline 
11417
11418 \newline 
11419 The syntax for a rule is as follows:
11420 \layout Verse
11421
11422
11423 \family typewriter 
11424 rule := replace [ restart ] '{' <assembly sequence> '
11425 \backslash 
11426 n' 
11427 \newline 
11428 \SpecialChar ~
11429  \SpecialChar ~
11430  \SpecialChar ~
11431  \SpecialChar ~
11432  \SpecialChar ~
11433  \SpecialChar ~
11434  \SpecialChar ~
11435  \SpecialChar ~
11436  \SpecialChar ~
11437  \SpecialChar ~
11438  \SpecialChar ~
11439  \SpecialChar ~
11440  \SpecialChar ~
11441  \SpecialChar ~
11442  '}' by '{' '
11443 \backslash 
11444 n' 
11445 \newline 
11446 \SpecialChar ~
11447  \SpecialChar ~
11448  \SpecialChar ~
11449  \SpecialChar ~
11450  \SpecialChar ~
11451  \SpecialChar ~
11452  \SpecialChar ~
11453  \SpecialChar ~
11454  \SpecialChar ~
11455  \SpecialChar ~
11456  \SpecialChar ~
11457  \SpecialChar ~
11458  \SpecialChar ~
11459  \SpecialChar ~
11460  \SpecialChar ~
11461  \SpecialChar ~
11462  <assembly sequence> '
11463 \backslash 
11464 n' 
11465 \newline 
11466 \SpecialChar ~
11467  \SpecialChar ~
11468  \SpecialChar ~
11469  \SpecialChar ~
11470  \SpecialChar ~
11471  \SpecialChar ~
11472  \SpecialChar ~
11473  \SpecialChar ~
11474  \SpecialChar ~
11475  \SpecialChar ~
11476  \SpecialChar ~
11477  \SpecialChar ~
11478  \SpecialChar ~
11479  \SpecialChar ~
11480  '}' [if <functionName> ] '
11481 \backslash 
11482 n' 
11483 \layout Standard
11484
11485 <assembly sequence> := assembly instruction (each instruction including
11486  labels must be on a separate line).
11487 \newline 
11488
11489 \newline 
11490 The optimizer will apply to the rules one by one from the top in the sequence
11491  of their appearance, it will terminate when all rules are exhausted.
11492  If the 'restart' option is specified, then the optimizer will start matching
11493  the rules again from the top, this option for a rule is expensive (performance)
11494 , it is intended to be used in situations where a transformation will trigger
11495  the same rule again.
11496  An example of this (not a good one, it has side effects) is the following
11497  rule:
11498 \layout Verse
11499
11500
11501 \family typewriter 
11502 replace restart { 
11503 \newline 
11504 \SpecialChar ~
11505 \SpecialChar ~
11506 pop %1 
11507 \newline 
11508 \SpecialChar ~
11509 \SpecialChar ~
11510 push %1 } by { 
11511 \newline 
11512 \SpecialChar ~
11513 \SpecialChar ~
11514 ; nop 
11515 \newline 
11516 }
11517 \layout Standard
11518
11519 Note that the replace pattern cannot be a blank, but can be a comment line.
11520  Without the 'restart' option only the inner most 'pop' 'push' pair would
11521  be eliminated, i.e.:
11522 \layout Verse
11523
11524
11525 \family typewriter 
11526 pop ar1 
11527 \newline 
11528 pop ar2 
11529 \newline 
11530 push ar2 
11531 \newline 
11532 push ar1
11533 \layout Standard
11534
11535 would result in:
11536 \layout Verse
11537
11538
11539 \family typewriter 
11540 pop ar1 
11541 \newline 
11542 ; nop 
11543 \newline 
11544 push ar1
11545 \layout Standard
11546
11547
11548 \emph on 
11549 with
11550 \emph default 
11551  the restart option the rule will be applied again to the resulting code
11552  and then all the pop-push pairs will be eliminated to yield:
11553 \layout Verse
11554
11555
11556 \family typewriter 
11557 ; nop 
11558 \newline 
11559 ; nop
11560 \layout Standard
11561
11562 A conditional function can be attached to a rule.
11563  Attaching rules are somewhat more involved, let me illustrate this with
11564  an example.
11565 \layout Verse
11566
11567
11568 \family typewriter 
11569 replace { 
11570 \newline 
11571 \SpecialChar ~
11572  \SpecialChar ~
11573  \SpecialChar ~
11574 ljmp %5 
11575 \newline 
11576 %2:
11577 \newline 
11578 } by { 
11579 \newline 
11580 \SpecialChar ~
11581  \SpecialChar ~
11582  \SpecialChar ~
11583 sjmp %5 
11584 \newline 
11585 %2:
11586 \newline 
11587 } if labelInRange
11588 \layout Standard
11589
11590 The optimizer does a look-up of a function name table defined in function
11591  
11592 \emph on 
11593 callFuncByName
11594 \emph default 
11595  in the source file SDCCpeeph.c, with the name 
11596 \emph on 
11597 labelInRange
11598 \emph default 
11599 .
11600  If it finds a corresponding entry the function is called.
11601  Note there can be no parameters specified for these functions, in this
11602  case the use of 
11603 \emph on 
11604 %5
11605 \emph default 
11606  is crucial, since the function 
11607 \emph on 
11608 labelInRange
11609 \emph default 
11610  expects to find the label in that particular variable (the hash table containin
11611 g the variable bindings is passed as a parameter).
11612  If you want to code more such functions, take a close look at the function
11613  labelInRange and the calling mechanism in source file SDCCpeeph.c.
11614  I know this whole thing is a little kludgey, but maybe some day we will
11615  have some better means.
11616  If you are looking at this file, you will also see the default rules that
11617  are compiled into the compiler, you can add your own rules in the default
11618  set there if you get tired of specifying the -
11619 \begin_inset ERT
11620 status Collapsed
11621
11622 \layout Standard
11623
11624 \backslash 
11625 /
11626 \end_inset 
11627
11628 -peep-file option.
11629 \layout Subsection
11630
11631 Pragmas
11632 \begin_inset LatexCommand \index{Pragmas}
11633
11634 \end_inset 
11635
11636
11637 \layout Standard
11638
11639 SDCC supports the following #pragma directives.
11640 \layout Itemize
11641
11642 SAVE
11643 \begin_inset LatexCommand \index{\#pragma SAVE}
11644
11645 \end_inset 
11646
11647  - this will save all current options to the SAVE/RESTORE stack.
11648  See RESTORE.
11649 \layout Itemize
11650
11651 RESTORE
11652 \begin_inset LatexCommand \index{\#pragma RESTORE}
11653
11654 \end_inset 
11655
11656  - will restore saved options from the last save.
11657  SAVEs & RESTOREs can be nested.
11658  SDCC uses a SAVE/RESTORE stack: SAVE pushes current options to the stack,
11659  RESTORE pulls current options from the stack.
11660  See SAVE.
11661 \layout Itemize
11662
11663 NOGCSE
11664 \begin_inset LatexCommand \index{\#pragma NOGCSE}
11665
11666 \end_inset 
11667
11668  - will stop global subexpression elimination.
11669 \layout Itemize
11670
11671 NOINDUCTION
11672 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
11673
11674 \end_inset 
11675
11676  - will stop loop induction optimizations.
11677 \layout Itemize
11678
11679 NOJTBOUND
11680 \begin_inset LatexCommand \index{\#pragma NOJTBOUND}
11681
11682 \end_inset 
11683
11684  - will not generate code for boundary value checking, when switch statements
11685  are turned into jump-tables.
11686 \layout Itemize
11687
11688 NOOVERLAY
11689 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
11690
11691 \end_inset 
11692
11693  - the compiler will not overlay the parameters and local variables of a
11694  function.
11695 \layout Itemize
11696
11697 LESS_PEDANTIC
11698 \begin_inset LatexCommand \index{\#pragma LESS\_PEDANTIC}
11699
11700 \end_inset 
11701
11702  - the compiler will not warn you anymore for obvious mistakes, you'r on
11703  your own now ;-(
11704 \layout Itemize
11705
11706 NOLOOPREVERSE
11707 \begin_inset LatexCommand \index{\#pragma NOLOOPREVERSE}
11708
11709 \end_inset 
11710
11711  - Will not do loop reversal optimization
11712 \layout Itemize
11713
11714 EXCLUDE
11715 \begin_inset LatexCommand \index{\#pragma EXCLUDE}
11716
11717 \end_inset 
11718
11719  NONE | {acc[,b[,dpl[,dph]]] - The exclude pragma disables generation of
11720  pair of push/pop
11721 \begin_inset LatexCommand \index{push/pop}
11722
11723 \end_inset 
11724
11725  instruction in ISR function (using interrupt
11726 \begin_inset LatexCommand \index{interrupt}
11727
11728 \end_inset 
11729
11730  keyword).
11731  The directive should be placed immediately before the ISR function definition
11732  and it affects ALL ISR functions following it.
11733  To enable the normal register saving for ISR functions use #pragma\SpecialChar ~
11734 EXCLUDE\SpecialChar ~
11735 none
11736 \begin_inset LatexCommand \index{\#pragma EXCLUDE}
11737
11738 \end_inset 
11739
11740 .
11741 \layout Itemize
11742
11743 NOIV
11744 \begin_inset LatexCommand \index{\#pragma NOIV}
11745
11746 \end_inset 
11747
11748  - Do not generate interrupt vector table entries for all ISR functions
11749  defined after the pragma.
11750  This is useful in cases where the interrupt vector table must be defined
11751  manually, or when there is a secondary, manually defined interrupt vector
11752  table (e.g.
11753  for the autovector feature of the Cypress EZ-USB FX2).
11754 \layout Itemize
11755
11756 CALLEE-SAVES
11757 \begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
11758
11759 \end_inset 
11760
11761
11762 \begin_inset LatexCommand \index{function prologue}
11763
11764 \end_inset 
11765
11766  function1[,function2[,function3...]] - The compiler by default uses a caller
11767  saves convention for register saving across function calls, however this
11768  can cause unnecessary register pushing & popping when calling small functions
11769  from larger functions.
11770  This option can be used to switch off the register saving convention for
11771  the function names specified.
11772  The compiler will not save registers when calling these functions, extra
11773  code need to be manually inserted at the entry & exit for these functions
11774  to save & restore the registers used by these functions, this can SUBSTANTIALLY
11775  reduce code & improve run time performance of the generated code.
11776  In the future the compiler (with inter procedural analysis) may be able
11777  to determine the appropriate scheme to use for each function call.
11778  If -
11779 \begin_inset ERT
11780 status Collapsed
11781
11782 \layout Standard
11783
11784 \backslash 
11785 /
11786 \end_inset 
11787
11788 -callee-saves command line option is used, the function names specified
11789  in #pragma\SpecialChar ~
11790 CALLEE-SAVES
11791 \begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
11792
11793 \end_inset 
11794
11795  is appended to the list of functions specified in the command line.
11796 \layout Standard
11797
11798 The pragma's are intended to be used to turn-off certain optimizations which
11799  might cause the compiler to generate extra stack / data space to store
11800  compiler generated temporary variables.
11801  This usually happens in large functions.
11802  Pragma directives should be used as shown in the following example, they
11803  are used to control options & optimizations for a given function; pragmas
11804  should be placed before and/or after a function, placing pragma's inside
11805  a function body could have unpredictable results.
11806 \layout Verse
11807
11808
11809 \family typewriter 
11810 #pragma SAVE
11811 \begin_inset LatexCommand \index{\#pragma SAVE}
11812
11813 \end_inset 
11814
11815  /* save the current settings */ 
11816 \newline 
11817 #pragma NOGCSE
11818 \begin_inset LatexCommand \index{\#pragma NOGCSE}
11819
11820 \end_inset 
11821
11822  /* turnoff global subexpression elimination */ 
11823 \newline 
11824 #pragma NOINDUCTION
11825 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
11826
11827 \end_inset 
11828
11829  /* turn off induction optimizations */ 
11830 \newline 
11831 int foo () 
11832 \newline 
11833
11834 \newline 
11835 \SpecialChar ~
11836  \SpecialChar ~
11837  ...
11838  
11839 \newline 
11840 \SpecialChar ~
11841  \SpecialChar ~
11842  /* large code */ 
11843 \newline 
11844 \SpecialChar ~
11845  \SpecialChar ~
11846  ...
11847  
11848 \newline 
11849
11850 \newline 
11851 #pragma RESTORE
11852 \begin_inset LatexCommand \index{\#pragma RESTORE}
11853
11854 \end_inset 
11855
11856  /* turn the optimizations back on */
11857 \layout Standard
11858
11859 The compiler will generate a warning message when extra space is allocated.
11860  It is strongly recommended that the SAVE and RESTORE pragma's be used when
11861  changing options for a function.
11862 \layout Subsection
11863
11864 Library Routines
11865 \emph on 
11866  <pending: this is messy and incomplete>
11867 \emph default 
11868  
11869 \layout Enumerate
11870
11871 Compiler support routines (_gptrget, _mulint etc)
11872 \layout Enumerate
11873
11874 Stdclib functions (puts, printf, strcat etc)
11875 \layout Enumerate
11876
11877 Math functions (sin, pow, sqrt etc)
11878 \layout Comment
11879
11880 license statements for the libraries are missing
11881 \layout Subsection
11882
11883 Interfacing with Assembly Routines
11884 \begin_inset LatexCommand \index{Assembler routines}
11885
11886 \end_inset 
11887
11888
11889 \layout Subsubsection
11890
11891 Global Registers used for Parameter Passing
11892 \begin_inset LatexCommand \index{Parameter passing}
11893
11894 \end_inset 
11895
11896
11897 \layout Standard
11898
11899 The compiler always uses the global registers 
11900 \emph on 
11901 DPL, DPH
11902 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
11903
11904 \end_inset 
11905
11906 , B
11907 \begin_inset LatexCommand \index{B (register)}
11908
11909 \end_inset 
11910
11911  
11912 \emph default 
11913 and
11914 \emph on 
11915  ACC
11916 \begin_inset LatexCommand \index{ACC}
11917
11918 \end_inset 
11919
11920
11921 \emph default 
11922  to pass the first parameter to a routine.
11923  The second parameter onwards is either allocated on the stack (for reentrant
11924  routines or if -
11925 \begin_inset ERT
11926 status Collapsed
11927
11928 \layout Standard
11929
11930 \backslash 
11931 /
11932 \end_inset 
11933
11934 -stack-auto is used) or in the internal / external ram (depending on the
11935  memory model).
11936  
11937 \layout Subsubsection
11938
11939 Assembler Routine(non-reentrant
11940 \begin_inset LatexCommand \index{reentrant}
11941
11942 \end_inset 
11943
11944 )
11945 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
11946
11947 \end_inset 
11948
11949
11950 \layout Standard
11951
11952 In the following example the function c_func calls an assembler routine
11953  asm_func, which takes two parameters.
11954 \layout Verse
11955
11956
11957 \family typewriter 
11958 extern int asm_func(unsigned char, unsigned char);
11959 \newline 
11960
11961 \newline 
11962 int c_func (unsigned char i, unsigned char j)
11963 \newline 
11964 {
11965 \newline 
11966 \SpecialChar ~
11967 \SpecialChar ~
11968 \SpecialChar ~
11969 \SpecialChar ~
11970 return asm_func(i,j);
11971 \newline 
11972 }
11973 \newline 
11974
11975 \newline 
11976 int main()
11977 \newline 
11978 {
11979 \newline 
11980 \SpecialChar ~
11981 \SpecialChar ~
11982 \SpecialChar ~
11983 \SpecialChar ~
11984 return c_func(10,9);
11985 \newline 
11986 }
11987 \layout Standard
11988
11989 The corresponding assembler function is:
11990 \layout Verse
11991
11992
11993 \family typewriter 
11994 .globl _asm_func_PARM_2 
11995 \newline 
11996 \SpecialChar ~
11997 \SpecialChar ~
11998 \SpecialChar ~
11999 \SpecialChar ~
12000 \SpecialChar ~
12001 \SpecialChar ~
12002 \SpecialChar ~
12003 \SpecialChar ~
12004 .globl _asm_func 
12005 \newline 
12006 \SpecialChar ~
12007 \SpecialChar ~
12008 \SpecialChar ~
12009 \SpecialChar ~
12010 \SpecialChar ~
12011 \SpecialChar ~
12012 \SpecialChar ~
12013 \SpecialChar ~
12014 .area OSEG 
12015 \newline 
12016 _asm_func_PARM_2:
12017 \newline 
12018 \SpecialChar ~
12019 \SpecialChar ~
12020 \SpecialChar ~
12021 \SpecialChar ~
12022 \SpecialChar ~
12023 \SpecialChar ~
12024 \SpecialChar ~
12025 \SpecialChar ~
12026 .ds      1 
12027 \newline 
12028 \SpecialChar ~
12029 \SpecialChar ~
12030 \SpecialChar ~
12031 \SpecialChar ~
12032 \SpecialChar ~
12033 \SpecialChar ~
12034 \SpecialChar ~
12035 \SpecialChar ~
12036 .area CSEG 
12037 \newline 
12038 _asm_func: 
12039 \newline 
12040 \SpecialChar ~
12041 \SpecialChar ~
12042 \SpecialChar ~
12043 \SpecialChar ~
12044 \SpecialChar ~
12045 \SpecialChar ~
12046 \SpecialChar ~
12047 \SpecialChar ~
12048 mov    a,dpl 
12049 \newline 
12050 \SpecialChar ~
12051 \SpecialChar ~
12052 \SpecialChar ~
12053 \SpecialChar ~
12054 \SpecialChar ~
12055 \SpecialChar ~
12056 \SpecialChar ~
12057 \SpecialChar ~
12058 add    a,_asm_func_PARM_2 
12059 \newline 
12060 \SpecialChar ~
12061 \SpecialChar ~
12062 \SpecialChar ~
12063 \SpecialChar ~
12064 \SpecialChar ~
12065 \SpecialChar ~
12066 \SpecialChar ~
12067 \SpecialChar ~
12068 mov    dpl,a 
12069 \newline 
12070 \SpecialChar ~
12071 \SpecialChar ~
12072 \SpecialChar ~
12073 \SpecialChar ~
12074 \SpecialChar ~
12075 \SpecialChar ~
12076 \SpecialChar ~
12077 \SpecialChar ~
12078 mov\SpecialChar ~
12079 \SpecialChar ~
12080 \SpecialChar ~
12081 \SpecialChar ~
12082 dpl
12083 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
12084
12085 \end_inset 
12086
12087 ,#0x00 
12088 \newline 
12089 \SpecialChar ~
12090 \SpecialChar ~
12091 \SpecialChar ~
12092 \SpecialChar ~
12093 \SpecialChar ~
12094 \SpecialChar ~
12095 \SpecialChar ~
12096 \SpecialChar ~
12097 ret
12098 \layout Standard
12099
12100 Note here that the return values are placed in 'dpl' - One byte return value,
12101  'dpl' LSB & 'dph' MSB for two byte values.
12102  'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
12103 b' & 'acc' for four byte values.
12104 \layout Standard
12105
12106 The parameter naming convention is _<function_name>_PARM_<n>, where n is
12107  the parameter number starting from 1, and counting from the left.
12108  The first parameter is passed in 
12109 \begin_inset Quotes eld
12110 \end_inset 
12111
12112 dpl
12113 \begin_inset Quotes erd
12114 \end_inset 
12115
12116  for One bye parameter, 
12117 \begin_inset Quotes eld
12118 \end_inset 
12119
12120 dptr
12121 \begin_inset Quotes erd
12122 \end_inset 
12123
12124  if two bytes, 
12125 \begin_inset Quotes eld
12126 \end_inset 
12127
12128 b,dptr
12129 \begin_inset Quotes erd
12130 \end_inset 
12131
12132  for three bytes and 
12133 \begin_inset Quotes eld
12134 \end_inset 
12135
12136 acc,b,dptr
12137 \begin_inset Quotes erd
12138 \end_inset 
12139
12140  for four bytes, the variable name for the second parameter will be _<function_n
12141 ame>_PARM_2.
12142 \newline 
12143
12144 \newline 
12145 Assemble the assembler routine with the following command:
12146 \newline 
12147
12148 \newline 
12149
12150 \family sans 
12151 \series bold 
12152 asx8051 -losg asmfunc.asm
12153 \newline 
12154
12155 \newline 
12156
12157 \family default 
12158 \series default 
12159 Then compile and link the assembler routine to the C source file with the
12160  following command:
12161 \newline 
12162
12163 \newline 
12164
12165 \family sans 
12166 \series bold 
12167 sdcc cfunc.c asmfunc.rel
12168 \layout Subsubsection
12169
12170 Assembler Routine(reentrant
12171 \begin_inset LatexCommand \index{reentrant}
12172
12173 \end_inset 
12174
12175 )
12176 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
12177
12178 \end_inset 
12179
12180
12181 \layout Standard
12182
12183 In this case the second parameter onwards will be passed on the stack, the
12184  parameters are pushed from right to left i.e.
12185  after the call the left most parameter will be on the top of the stack.
12186  Here is an example:
12187 \layout Verse
12188
12189
12190 \family typewriter 
12191 extern int asm_func(unsigned char, unsigned char);
12192 \newline 
12193
12194 \newline 
12195 int c_func (unsigned char i, unsigned char j) reentrant 
12196 \newline 
12197
12198 \newline 
12199 \SpecialChar ~
12200 \SpecialChar ~
12201 \SpecialChar ~
12202 \SpecialChar ~
12203 return asm_func(i,j); 
12204 \newline 
12205
12206 \newline 
12207
12208 \newline 
12209 int main() 
12210 \newline 
12211
12212 \newline 
12213 \SpecialChar ~
12214 \SpecialChar ~
12215 \SpecialChar ~
12216 \SpecialChar ~
12217 return c_func(10,9); 
12218 \newline 
12219 }
12220 \layout Standard
12221
12222 The corresponding assembler routine is:
12223 \layout Verse
12224
12225
12226 \family typewriter 
12227 .globl _asm_func 
12228 \newline 
12229 _asm_func: 
12230 \newline 
12231 \SpecialChar ~
12232 \SpecialChar ~
12233 \SpecialChar ~
12234 \SpecialChar ~
12235 push  _bp 
12236 \newline 
12237 \SpecialChar ~
12238 \SpecialChar ~
12239 \SpecialChar ~
12240 \SpecialChar ~
12241 mov _bp,sp 
12242 \newline 
12243 \SpecialChar ~
12244 \SpecialChar ~
12245 \SpecialChar ~
12246 \SpecialChar ~
12247 mov  r2,dpl
12248 \newline 
12249 \SpecialChar ~
12250 \SpecialChar ~
12251 \SpecialChar ~
12252 \SpecialChar ~
12253 mov  a,_bp 
12254 \newline 
12255 \SpecialChar ~
12256 \SpecialChar ~
12257 \SpecialChar ~
12258 \SpecialChar ~
12259 clr  c 
12260 \newline 
12261 \SpecialChar ~
12262 \SpecialChar ~
12263 \SpecialChar ~
12264 \SpecialChar ~
12265 add  a,#0xfd 
12266 \newline 
12267 \SpecialChar ~
12268 \SpecialChar ~
12269 \SpecialChar ~
12270 \SpecialChar ~
12271 mov  r0,a 
12272 \newline 
12273 \SpecialChar ~
12274 \SpecialChar ~
12275 \SpecialChar ~
12276 \SpecialChar ~
12277 add  a,#0xfc
12278 \newline 
12279 \SpecialChar ~
12280 \SpecialChar ~
12281 \SpecialChar ~
12282 \SpecialChar ~
12283 mov  r1,a 
12284 \newline 
12285 \SpecialChar ~
12286 \SpecialChar ~
12287 \SpecialChar ~
12288 \SpecialChar ~
12289 mov  a,@r0 
12290 \newline 
12291 \SpecialChar ~
12292 \SpecialChar ~
12293 \SpecialChar ~
12294 \SpecialChar ~
12295 add  a,r2
12296 \newline 
12297 \SpecialChar ~
12298 \SpecialChar ~
12299 \SpecialChar ~
12300 \SpecialChar ~
12301 mov  dpl,a 
12302 \newline 
12303 \SpecialChar ~
12304 \SpecialChar ~
12305 \SpecialChar ~
12306 \SpecialChar ~
12307 mov  dph,#0x00 
12308 \newline 
12309 \SpecialChar ~
12310 \SpecialChar ~
12311 \SpecialChar ~
12312 \SpecialChar ~
12313 mov  sp,_bp 
12314 \newline 
12315 \SpecialChar ~
12316 \SpecialChar ~
12317 \SpecialChar ~
12318 \SpecialChar ~
12319 pop  _bp 
12320 \newline 
12321 \SpecialChar ~
12322 \SpecialChar ~
12323 \SpecialChar ~
12324 \SpecialChar ~
12325 ret
12326 \layout Standard
12327
12328 The compiling and linking procedure remains the same, however note the extra
12329  entry & exit linkage required for the assembler code, _bp is the stack
12330  frame pointer and is used to compute the offset into the stack for parameters
12331  and local variables.
12332 \layout Subsection
12333
12334 External Stack
12335 \begin_inset LatexCommand \index{stack}
12336
12337 \end_inset 
12338
12339
12340 \begin_inset LatexCommand \index{External stack}
12341
12342 \end_inset 
12343
12344
12345 \layout Standard
12346
12347 The external stack is located at the start of the external ram segment,
12348  and is 256 bytes in size.
12349  When -
12350 \begin_inset ERT
12351 status Collapsed
12352
12353 \layout Standard
12354
12355 \backslash 
12356 /
12357 \end_inset 
12358
12359 -xstack option is used to compile the program, the parameters and local
12360  variables of all reentrant functions are allocated in this area.
12361  This option is provided for programs with large stack space requirements.
12362  When used with the -
12363 \begin_inset ERT
12364 status Collapsed
12365
12366 \layout Standard
12367
12368 \backslash 
12369 /
12370 \end_inset 
12371
12372 -stack-auto option, all parameters and local variables are allocated on
12373  the external stack (note support libraries will need to be recompiled with
12374  the same options).
12375 \layout Standard
12376
12377 The compiler outputs the higher order address byte of the external ram segment
12378  into PORT P2, therefore when using the External Stack option, this port
12379  MAY NOT be used by the application program.
12380 \layout Subsection
12381
12382 ANSI-Compliance
12383 \begin_inset LatexCommand \index{ANSI-compliance}
12384
12385 \end_inset 
12386
12387
12388 \layout Standard
12389
12390 Deviations from the compliance:
12391 \layout Itemize
12392
12393 functions are not always reentrant.
12394 \layout Itemize
12395
12396 structures cannot be assigned values directly, cannot be passed as function
12397  parameters or assigned to each other and cannot be a return value from
12398  a function, e.g.:
12399 \begin_deeper 
12400 \layout Verse
12401
12402
12403 \family typewriter 
12404 struct s { ...
12405  }; 
12406 \newline 
12407 struct s s1, s2; 
12408 \newline 
12409 foo() 
12410 \newline 
12411
12412 \newline 
12413 \SpecialChar ~
12414 \SpecialChar ~
12415 \SpecialChar ~
12416 \SpecialChar ~
12417 ...
12418  
12419 \newline 
12420 \SpecialChar ~
12421 \SpecialChar ~
12422 \SpecialChar ~
12423 \SpecialChar ~
12424 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
12425 \newline 
12426 \SpecialChar ~
12427 \SpecialChar ~
12428 \SpecialChar ~
12429 \SpecialChar ~
12430 ...
12431  
12432 \newline 
12433 }
12434 \newline 
12435 struct s foo1 (struct s parms) /* invalid in SDCC although allowed in ANSI
12436  */
12437 \newline 
12438
12439 \newline 
12440 \SpecialChar ~
12441 \SpecialChar ~
12442 \SpecialChar ~
12443 \SpecialChar ~
12444 struct s rets; 
12445 \newline 
12446 \SpecialChar ~
12447 \SpecialChar ~
12448 \SpecialChar ~
12449 \SpecialChar ~
12450 ...
12451  
12452 \newline 
12453 \SpecialChar ~
12454 \SpecialChar ~
12455 \SpecialChar ~
12456 \SpecialChar ~
12457 return rets;/* is invalid in SDCC although allowed in ANSI */ 
12458 \newline 
12459 }
12460 \end_deeper 
12461 \layout Itemize
12462
12463 'long long
12464 \begin_inset LatexCommand \index{long long (not supported)}
12465
12466 \end_inset 
12467
12468 ' (64 bit integers
12469 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
12470
12471 \end_inset 
12472
12473 ) not supported.
12474 \layout Itemize
12475
12476 'double
12477 \begin_inset LatexCommand \index{double (not supported)}
12478
12479 \end_inset 
12480
12481 ' precision floating point 
12482 \begin_inset LatexCommand \index{Floating point support}
12483
12484 \end_inset 
12485
12486 not supported.
12487 \layout Itemize
12488
12489 No support for setjmp and longjmp (for now).
12490 \layout Itemize
12491
12492 Old K&R style
12493 \begin_inset LatexCommand \index{K\&R style}
12494
12495 \end_inset 
12496
12497  function declarations are NOT allowed.
12498 \begin_deeper 
12499 \layout Verse
12500
12501
12502 \family typewriter 
12503 foo(i,j) /* this old style of function declarations */ 
12504 \newline 
12505 int i,j; /* are valid in ANSI but not valid in SDCC */ 
12506 \newline 
12507
12508 \newline 
12509 \SpecialChar ~
12510 \SpecialChar ~
12511 \SpecialChar ~
12512 \SpecialChar ~
12513 ...
12514  
12515 \newline 
12516 }
12517 \end_deeper 
12518 \layout Itemize
12519
12520 functions declared as pointers must be dereferenced during the call.
12521 \begin_deeper 
12522 \layout Verse
12523
12524
12525 \family typewriter 
12526 int (*foo)();
12527 \newline 
12528 ...
12529  
12530 \newline 
12531 /* has to be called like this */ 
12532 \newline 
12533 (*foo)(); /* ANSI standard allows calls to be made like 'foo()' */
12534 \end_deeper 
12535 \layout Subsection
12536
12537 Cyclomatic Complexity
12538 \begin_inset LatexCommand \index{Cyclomatic complexity}
12539
12540 \end_inset 
12541
12542
12543 \layout Standard
12544
12545 Cyclomatic complexity of a function is defined as the number of independent
12546  paths the program can take during execution of the function.
12547  This is an important number since it defines the number test cases you
12548  have to generate to validate the function.
12549  The accepted industry standard for complexity number is 10, if the cyclomatic
12550  complexity reported by SDCC exceeds 10 you should think about simplification
12551  of the function logic.
12552  Note that the complexity level is not related to the number of lines of
12553  code in a function.
12554  Large functions can have low complexity, and small functions can have large
12555  complexity levels.
12556  
12557 \newline 
12558
12559 \newline 
12560 SDCC uses the following formula to compute the complexity:
12561 \newline 
12562
12563 \layout Standard
12564
12565 complexity = (number of edges in control flow graph) - (number of nodes
12566  in control flow graph) + 2;
12567 \newline 
12568
12569 \newline 
12570 Having said that the industry standard is 10, you should be aware that in
12571  some cases it be may unavoidable to have a complexity level of less than
12572  10.
12573  For example if you have switch statement with more than 10 case labels,
12574  each case label adds one to the complexity level.
12575  The complexity level is by no means an absolute measure of the algorithmic
12576  complexity of the function, it does however provide a good starting point
12577  for which functions you might look at for further optimization.
12578 \layout Section
12579 \pagebreak_top 
12580 TIPS
12581 \layout Standard
12582
12583 Here are a few guidelines that will help the compiler generate more efficient
12584  code, some of the tips are specific to this compiler others are generally
12585  good programming practice.
12586 \layout Itemize
12587
12588 Use the smallest data type to represent your data-value.
12589  If it is known in advance that the value is going to be less than 256 then
12590  use an 'unsigned char' instead of a 'short' or 'int'.
12591 \layout Itemize
12592
12593 Use unsigned when it is known in advance that the value is not going to
12594  be negative.
12595  This helps especially if you are doing division or multiplication.
12596 \layout Itemize
12597
12598 NEVER jump into a LOOP.
12599 \layout Itemize
12600
12601 Declare the variables to be local whenever possible, especially loop control
12602  variables (induction).
12603 \layout Itemize
12604
12605 Since the compiler does not always do implicit integral promotion, the programme
12606 r should do an explicit cast when integral promotion is required.
12607 \layout Itemize
12608
12609 Reducing the size of division, multiplication & modulus operations can reduce
12610  code size substantially.
12611  Take the following code for example.
12612 \begin_deeper 
12613 \layout Verse
12614
12615
12616 \family typewriter 
12617 foobar(unsigned int p1, unsigned char ch)
12618 \newline 
12619 {
12620 \newline 
12621 \SpecialChar ~
12622 \SpecialChar ~
12623 \SpecialChar ~
12624 \SpecialChar ~
12625 unsigned char ch1 = p1 % ch ;
12626 \newline 
12627 \SpecialChar ~
12628 \SpecialChar ~
12629 \SpecialChar ~
12630 \SpecialChar ~
12631 ....
12632 \newline 
12633 }
12634 \layout Standard
12635
12636 For the modulus operation the variable ch will be promoted to unsigned int
12637  first then the modulus operation will be performed (this will lead to a
12638  call to support routine _moduint()), and the result will be casted to a
12639  char.
12640  If the code is changed to 
12641 \layout Verse
12642
12643
12644 \family typewriter 
12645 foobar(unsigned int p1, unsigned char ch)
12646 \newline 
12647 {
12648 \newline 
12649 \SpecialChar ~
12650 \SpecialChar ~
12651 \SpecialChar ~
12652 \SpecialChar ~
12653 unsigned char ch1 = (unsigned char)p1 % ch ;
12654 \newline 
12655 \SpecialChar ~
12656 \SpecialChar ~
12657 \SpecialChar ~
12658 \SpecialChar ~
12659 ....
12660 \newline 
12661 }
12662 \layout Standard
12663
12664 It would substantially reduce the code generated (future versions of the
12665  compiler will be smart enough to detect such optimization opportunities).
12666 \end_deeper 
12667 \layout Subsection
12668
12669 Notes on MCS51 memory
12670 \begin_inset LatexCommand \index{MCS51 memory}
12671
12672 \end_inset 
12673
12674  layout
12675 \layout Standard
12676
12677 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12678  RAM memory which is structured as follows
12679 \newline 
12680
12681 \newline 
12682 - Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R0 to R7,
12683  
12684 \newline 
12685 - Bytes 20-2F - 16 bytes to hold 128 bit variables and, 
12686 \newline 
12687 - Bytes 30-7F - 80 bytes for general purpose use.
12688 \newline 
12689
12690 \layout Standard
12691
12692 Additionally some members of the MCS51 family may have up to 128 bytes of
12693  additional, indirectly addressable, internal RAM memory (
12694 \emph on 
12695 idata
12696 \emph default 
12697 ).
12698  Furthermore, some chips may have some built in external memory (
12699 \emph on 
12700 xdata
12701 \emph default 
12702 ) which should not be confused with the internal, directly addressable RAM
12703  memory (
12704 \emph on 
12705 data
12706 \emph default 
12707 ).
12708  Usually this built in 
12709 \emph on 
12710 xdata
12711 \emph default 
12712  memory has to be activated before using it (you can probably find this
12713  information on the datasheet of the microcontroller your are using).
12714 \layout Standard
12715
12716 Normally SDCC will only use the first bank
12717 \begin_inset LatexCommand \index{bank}
12718
12719 \end_inset 
12720
12721  of registers (register bank 0), but it is possible to specify that other
12722  banks of registers should be used in interrupt
12723 \begin_inset LatexCommand \index{interrupt}
12724
12725 \end_inset 
12726
12727  routines.
12728  By default, the compiler will place the stack after the last byte of allocated
12729  memory for variables.
12730  For example, if the first 2 banks of registers are used, and only four
12731  bytes are used for 
12732 \emph on 
12733 data
12734 \emph default 
12735  variables, it will position the base of the internal stack at address 20
12736  (0x14).
12737  This implies that as the stack
12738 \begin_inset LatexCommand \index{stack}
12739
12740 \end_inset 
12741
12742  grows, it will use up the remaining register banks, and the 16 bytes used
12743  by the 128 bit variables, and 80 bytes for general purpose use.
12744  If any bit variables are used, the data variables will be placed after
12745  the byte holding the last bit variable.
12746  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12747  (two bytes used), 
12748 \emph on 
12749 data
12750 \emph default 
12751  variables will be placed starting at address 0x22.
12752  You can also use -
12753 \begin_inset ERT
12754 status Collapsed
12755
12756 \layout Standard
12757
12758 \backslash 
12759 /
12760 \end_inset 
12761
12762 -data-loc
12763 \begin_inset LatexCommand \index{-\/-data-loc}
12764
12765 \end_inset 
12766
12767  to specify the start address of the 
12768 \emph on 
12769 data
12770 \emph default 
12771  and -
12772 \begin_inset ERT
12773 status Collapsed
12774
12775 \layout Standard
12776
12777 \backslash 
12778 /
12779 \end_inset 
12780
12781 -iram-size to specify the size of the total internal RAM (
12782 \emph on 
12783 data
12784 \emph default 
12785 +
12786 \emph on 
12787 idata
12788 \emph default 
12789 ).
12790  
12791 \layout Standard
12792
12793 By default the 8051 linker will place the stack after the last byte of data
12794  variables.
12795  Option -
12796 \begin_inset ERT
12797 status Collapsed
12798
12799 \layout Standard
12800
12801 \backslash 
12802 /
12803 \end_inset 
12804
12805 -stack-loc
12806 \begin_inset LatexCommand \index{-\/-stack-loc}
12807
12808 \end_inset 
12809
12810  allows you to specify the start of the stack, i.e.
12811  you could start it after any data in the general purpose area.
12812  If your microcontroller has additional indirectly addressable internal
12813  RAM (
12814 \emph on 
12815 idata
12816 \emph default 
12817 ) you can place the stack on it.
12818  You may also need to use -
12819 \begin_inset ERT
12820 status Collapsed
12821
12822 \layout Standard
12823
12824 \backslash 
12825 /
12826 \end_inset 
12827
12828 -xdata-loc
12829 \begin_inset LatexCommand \index{-\/-data-loc}
12830
12831 \end_inset 
12832
12833  to set the start address of the external RAM (
12834 \emph on 
12835 xdata
12836 \emph default 
12837 ) and -
12838 \begin_inset ERT
12839 status Collapsed
12840
12841 \layout Standard
12842
12843 \backslash 
12844 /
12845 \end_inset 
12846
12847 -xram-size
12848 \begin_inset LatexCommand \index{-\/-data-loc}
12849
12850 \end_inset 
12851
12852  to specify its size.
12853  Same goes for the code memory, using -
12854 \begin_inset ERT
12855 status Collapsed
12856
12857 \layout Standard
12858
12859 \backslash 
12860 /
12861 \end_inset 
12862
12863 -code-loc
12864 \begin_inset LatexCommand \index{-\/-data-loc}
12865
12866 \end_inset 
12867
12868  and -
12869 \begin_inset ERT
12870 status Collapsed
12871
12872 \layout Standard
12873
12874 \backslash 
12875 /
12876 \end_inset 
12877
12878 -code-size
12879 \begin_inset LatexCommand \index{-\/-data-loc}
12880
12881 \end_inset 
12882
12883 .
12884  If in doubt, don't specify any options and see if the resulting memory
12885  layout is appropriate, then you can adjust it.
12886 \layout Standard
12887
12888 The 8051 linker generates two files with memory allocation information.
12889  The first, with extension .map shows all the variables and segments.
12890  The second with extension .mem shows the final memory layout.
12891  The linker will complaint either if memory segments overlap, there is not
12892  enough memory, or there is not enough space for stack.
12893  If you get any linking warnings and/or errors related to stack or segments
12894  allocation, take a look at either the .map or .mem files to find out what
12895  the problem is.
12896  The .mem file may even suggest a solution to the problem.
12897 \layout Subsection
12898
12899 Tools
12900 \begin_inset LatexCommand \index{Tools}
12901
12902 \end_inset 
12903
12904  included in the distribution
12905 \newline 
12906
12907 \layout Standard
12908 \align center 
12909
12910 \begin_inset  Tabular
12911 <lyxtabular version="3" rows="12" columns="3">
12912 <features>
12913 <column alignment="center" valignment="top" leftline="true" width="0pt">
12914 <column alignment="center" valignment="top" leftline="true" width="0pt">
12915 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
12916 <row topline="true" bottomline="true">
12917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12918 \begin_inset Text
12919
12920 \layout Standard
12921
12922 Name
12923 \end_inset 
12924 </cell>
12925 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12926 \begin_inset Text
12927
12928 \layout Standard
12929
12930 Purpose
12931 \end_inset 
12932 </cell>
12933 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12934 \begin_inset Text
12935
12936 \layout Standard
12937
12938 Directory
12939 \end_inset 
12940 </cell>
12941 </row>
12942 <row topline="true">
12943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12944 \begin_inset Text
12945
12946 \layout Standard
12947
12948 uCsim
12949 \end_inset 
12950 </cell>
12951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12952 \begin_inset Text
12953
12954 \layout Standard
12955
12956 Simulator for various architectures
12957 \end_inset 
12958 </cell>
12959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12960 \begin_inset Text
12961
12962 \layout Standard
12963
12964 sdcc/sim/ucsim
12965 \end_inset 
12966 </cell>
12967 </row>
12968 <row topline="true">
12969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12970 \begin_inset Text
12971
12972 \layout Standard
12973
12974 keil2sdcc.pl
12975 \end_inset 
12976 </cell>
12977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12978 \begin_inset Text
12979
12980 \layout Standard
12981
12982 header file conversion
12983 \end_inset 
12984 </cell>
12985 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12986 \begin_inset Text
12987
12988 \layout Standard
12989
12990 sdcc/support/scripts
12991 \end_inset 
12992 </cell>
12993 </row>
12994 <row topline="true">
12995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12996 \begin_inset Text
12997
12998 \layout Standard
12999
13000 mh2h.c
13001 \end_inset 
13002 </cell>
13003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13004 \begin_inset Text
13005
13006 \layout Standard
13007
13008 header file conversion
13009 \end_inset 
13010 </cell>
13011 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13012 \begin_inset Text
13013
13014 \layout Standard
13015
13016 sdcc/support/scripts
13017 \end_inset 
13018 </cell>
13019 </row>
13020 <row topline="true">
13021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13022 \begin_inset Text
13023
13024 \layout Standard
13025
13026 as-gbz80
13027 \end_inset 
13028 </cell>
13029 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13030 \begin_inset Text
13031
13032 \layout Standard
13033
13034 Assembler
13035 \end_inset 
13036 </cell>
13037 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13038 \begin_inset Text
13039
13040 \layout Standard
13041
13042
13043 \family roman 
13044 \series medium 
13045 \shape up 
13046 \size normal 
13047 \emph off 
13048 \bar no 
13049 \noun off 
13050 \color none
13051 sdcc/bin
13052 \end_inset 
13053 </cell>
13054 </row>
13055 <row topline="true">
13056 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13057 \begin_inset Text
13058
13059 \layout Standard
13060
13061 as-z80
13062 \end_inset 
13063 </cell>
13064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13065 \begin_inset Text
13066
13067 \layout Standard
13068
13069 Assembler
13070 \end_inset 
13071 </cell>
13072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13073 \begin_inset Text
13074
13075 \layout Standard
13076
13077
13078 \family roman 
13079 \series medium 
13080 \shape up 
13081 \size normal 
13082 \emph off 
13083 \bar no 
13084 \noun off 
13085 \color none
13086 sdcc/bin
13087 \end_inset 
13088 </cell>
13089 </row>
13090 <row topline="true">
13091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13092 \begin_inset Text
13093
13094 \layout Standard
13095
13096 asx8051
13097 \end_inset 
13098 </cell>
13099 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13100 \begin_inset Text
13101
13102 \layout Standard
13103
13104 Assembler
13105 \end_inset 
13106 </cell>
13107 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13108 \begin_inset Text
13109
13110 \layout Standard
13111
13112
13113 \family roman 
13114 \series medium 
13115 \shape up 
13116 \size normal 
13117 \emph off 
13118 \bar no 
13119 \noun off 
13120 \color none
13121 sdcc/bin
13122 \end_inset 
13123 </cell>
13124 </row>
13125 <row topline="true">
13126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13127 \begin_inset Text
13128
13129 \layout Standard
13130
13131 sdcdb
13132 \end_inset 
13133 </cell>
13134 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13135 \begin_inset Text
13136
13137 \layout Standard
13138
13139 Simulator
13140 \end_inset 
13141 </cell>
13142 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13143 \begin_inset Text
13144
13145 \layout Standard
13146
13147
13148 \family roman 
13149 \series medium 
13150 \shape up 
13151 \size normal 
13152 \emph off 
13153 \bar no 
13154 \noun off 
13155 \color none
13156 sdcc/bin
13157 \end_inset 
13158 </cell>
13159 </row>
13160 <row topline="true">
13161 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13162 \begin_inset Text
13163
13164 \layout Standard
13165
13166 aslink
13167 \end_inset 
13168 </cell>
13169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13170 \begin_inset Text
13171
13172 \layout Standard
13173
13174 Linker
13175 \end_inset 
13176 </cell>
13177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13178 \begin_inset Text
13179
13180 \layout Standard
13181
13182
13183 \family roman 
13184 \series medium 
13185 \shape up 
13186 \size normal 
13187 \emph off 
13188 \bar no 
13189 \noun off 
13190 \color none
13191 sdcc/bin
13192 \end_inset 
13193 </cell>
13194 </row>
13195 <row topline="true">
13196 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13197 \begin_inset Text
13198
13199 \layout Standard
13200
13201 link-z80
13202 \end_inset 
13203 </cell>
13204 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13205 \begin_inset Text
13206
13207 \layout Standard
13208
13209 Linker
13210 \end_inset 
13211 </cell>
13212 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13213 \begin_inset Text
13214
13215 \layout Standard
13216
13217
13218 \family roman 
13219 \series medium 
13220 \shape up 
13221 \size normal 
13222 \emph off 
13223 \bar no 
13224 \noun off 
13225 \color none
13226 sdcc/bin
13227 \end_inset 
13228 </cell>
13229 </row>
13230 <row topline="true">
13231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13232 \begin_inset Text
13233
13234 \layout Standard
13235
13236 link-gbz80
13237 \end_inset 
13238 </cell>
13239 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13240 \begin_inset Text
13241
13242 \layout Standard
13243
13244 Linker
13245 \end_inset 
13246 </cell>
13247 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13248 \begin_inset Text
13249
13250 \layout Standard
13251
13252
13253 \family roman 
13254 \series medium 
13255 \shape up 
13256 \size normal 
13257 \emph off 
13258 \bar no 
13259 \noun off 
13260 \color none
13261 sdcc/bin
13262 \end_inset 
13263 </cell>
13264 </row>
13265 <row topline="true" bottomline="true">
13266 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13267 \begin_inset Text
13268
13269 \layout Standard
13270
13271 packihx
13272 \end_inset 
13273 </cell>
13274 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13275 \begin_inset Text
13276
13277 \layout Standard
13278
13279 ihx packer
13280 \end_inset 
13281 </cell>
13282 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13283 \begin_inset Text
13284
13285 \layout Standard
13286
13287
13288 \family roman 
13289 \series medium 
13290 \shape up 
13291 \size normal 
13292 \emph off 
13293 \bar no 
13294 \noun off 
13295 \color none
13296 sdcc/bin
13297 \end_inset 
13298 </cell>
13299 </row>
13300 </lyxtabular>
13301
13302 \end_inset 
13303
13304
13305 \newline 
13306
13307 \layout Subsection
13308
13309 Related open source tools
13310 \begin_inset LatexCommand \index{Related tools}
13311
13312 \end_inset 
13313
13314
13315 \newline 
13316
13317 \layout Standard
13318 \align center 
13319
13320 \begin_inset  Tabular
13321 <lyxtabular version="3" rows="7" columns="3">
13322 <features>
13323 <column alignment="center" valignment="top" leftline="true" width="0pt">
13324 <column alignment="center" valignment="top" leftline="true" width="0pt">
13325 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
13326 <row topline="true" bottomline="true">
13327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13328 \begin_inset Text
13329
13330 \layout Standard
13331
13332 Name
13333 \end_inset 
13334 </cell>
13335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13336 \begin_inset Text
13337
13338 \layout Standard
13339
13340 Purpose
13341 \end_inset 
13342 </cell>
13343 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13344 \begin_inset Text
13345
13346 \layout Standard
13347
13348 Where to get
13349 \end_inset 
13350 </cell>
13351 </row>
13352 <row topline="true">
13353 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13354 \begin_inset Text
13355
13356 \layout Standard
13357
13358 gpsim
13359 \begin_inset LatexCommand \index{gpsim}
13360
13361 \end_inset 
13362
13363
13364 \end_inset 
13365 </cell>
13366 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13367 \begin_inset Text
13368
13369 \layout Standard
13370
13371 PIC simulator
13372 \end_inset 
13373 </cell>
13374 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13375 \begin_inset Text
13376
13377 \layout Standard
13378
13379
13380 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
13381
13382 \end_inset 
13383
13384
13385 \end_inset 
13386 </cell>
13387 </row>
13388 <row topline="true">
13389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13390 \begin_inset Text
13391
13392 \layout Standard
13393
13394 srecord
13395 \begin_inset LatexCommand \index{srecord}
13396
13397 \end_inset 
13398
13399
13400 \end_inset 
13401 </cell>
13402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13403 \begin_inset Text
13404
13405 \layout Standard
13406
13407 Object file conversion, checksumming, ...
13408 \end_inset 
13409 </cell>
13410 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13411 \begin_inset Text
13412
13413 \layout Standard
13414
13415
13416 \begin_inset LatexCommand \url{http://srecord.sourceforge.net/}
13417
13418 \end_inset 
13419
13420
13421 \end_inset 
13422 </cell>
13423 </row>
13424 <row topline="true">
13425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13426 \begin_inset Text
13427
13428 \layout Standard
13429
13430 objdump
13431 \begin_inset LatexCommand \index{objdump}
13432
13433 \end_inset 
13434
13435
13436 \end_inset 
13437 </cell>
13438 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13439 \begin_inset Text
13440
13441 \layout Standard
13442
13443 Object file conversion, ...
13444 \end_inset 
13445 </cell>
13446 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13447 \begin_inset Text
13448
13449 \layout Standard
13450
13451 Part of binutils (should be there anyway)
13452 \end_inset 
13453 </cell>
13454 </row>
13455 <row topline="true">
13456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13457 \begin_inset Text
13458
13459 \layout Standard
13460
13461 doxygen
13462 \begin_inset LatexCommand \index{doxygen}
13463
13464 \end_inset 
13465
13466
13467 \end_inset 
13468 </cell>
13469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13470 \begin_inset Text
13471
13472 \layout Standard
13473
13474 Source code documentation system
13475 \end_inset 
13476 </cell>
13477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13478 \begin_inset Text
13479
13480 \layout Standard
13481
13482
13483 \begin_inset LatexCommand \url{http://www.doxygen.org}
13484
13485 \end_inset 
13486
13487
13488 \end_inset 
13489 </cell>
13490 </row>
13491 <row topline="true">
13492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13493 \begin_inset Text
13494
13495 \layout Standard
13496
13497 splint
13498 \begin_inset LatexCommand \index{splint}
13499
13500 \end_inset 
13501
13502
13503 \end_inset 
13504 </cell>
13505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13506 \begin_inset Text
13507
13508 \layout Standard
13509
13510 Statically checks c sources
13511 \end_inset 
13512 </cell>
13513 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13514 \begin_inset Text
13515
13516 \layout Standard
13517
13518
13519 \begin_inset LatexCommand \url{http://www.splint.org}
13520
13521 \end_inset 
13522
13523
13524 \end_inset 
13525 </cell>
13526 </row>
13527 <row topline="true" bottomline="true">
13528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13529 \begin_inset Text
13530
13531 \layout Standard
13532
13533 ddd
13534 \begin_inset LatexCommand \index{ddd}
13535
13536 \end_inset 
13537
13538
13539 \end_inset 
13540 </cell>
13541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13542 \begin_inset Text
13543
13544 \layout Standard
13545
13546 Debugger, serves nicely as GUI to sdcdb
13547 \begin_inset LatexCommand \index{sdcdb}
13548
13549 \end_inset 
13550
13551
13552 \end_inset 
13553 </cell>
13554 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13555 \begin_inset Text
13556
13557 \layout Standard
13558
13559
13560 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
13561
13562 \end_inset 
13563
13564
13565 \end_inset 
13566 </cell>
13567 </row>
13568 </lyxtabular>
13569
13570 \end_inset 
13571
13572
13573 \newline 
13574
13575 \layout Subsection
13576
13577 Related documentation / recommended reading
13578 \newline 
13579
13580 \layout Standard
13581 \align center 
13582
13583 \begin_inset  Tabular
13584 <lyxtabular version="3" rows="5" columns="3">
13585 <features>
13586 <column alignment="center" valignment="top" leftline="true" width="0pt">
13587 <column alignment="center" valignment="top" leftline="true" width="0pt">
13588 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
13589 <row topline="true" bottomline="true">
13590 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13591 \begin_inset Text
13592
13593 \layout Standard
13594
13595 Name
13596 \end_inset 
13597 </cell>
13598 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13599 \begin_inset Text
13600
13601 \layout Standard
13602
13603 Subject / Title
13604 \end_inset 
13605 </cell>
13606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13607 \begin_inset Text
13608
13609 \layout Standard
13610
13611 Where to get
13612 \end_inset 
13613 </cell>
13614 </row>
13615 <row topline="true">
13616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13617 \begin_inset Text
13618
13619 \layout Standard
13620
13621 S.
13622  S.
13623  Muchnick
13624 \end_inset 
13625 </cell>
13626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13627 \begin_inset Text
13628
13629 \layout Standard
13630
13631 Advanced Compiler Design and Implementation
13632 \end_inset 
13633 </cell>
13634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13635 \begin_inset Text
13636
13637 \layout Standard
13638
13639 bookstore
13640 \end_inset 
13641 </cell>
13642 </row>
13643 <row topline="true">
13644 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13645 \begin_inset Text
13646
13647 \layout Standard
13648
13649
13650 \family roman 
13651 \series medium 
13652 \shape up 
13653 \size normal 
13654 \emph off 
13655 \bar no 
13656 \noun off 
13657 \color none
13658 c-refcard.pdf
13659 \end_inset 
13660 </cell>
13661 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13662 \begin_inset Text
13663
13664 \layout Standard
13665
13666 C Reference Card
13667 \begin_inset LatexCommand \index{C Reference card}
13668
13669 \end_inset 
13670
13671 , 2 pages
13672 \end_inset 
13673 </cell>
13674 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13675 \begin_inset Text
13676
13677 \layout Standard
13678
13679
13680 \begin_inset LatexCommand \url{http://www.refcards.com/about/c.html}
13681
13682 \end_inset 
13683
13684
13685 \end_inset 
13686 </cell>
13687 </row>
13688 <row topline="true">
13689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13690 \begin_inset Text
13691
13692 \layout Standard
13693
13694 test_suite_spec.pdf
13695 \end_inset 
13696 </cell>
13697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13698 \begin_inset Text
13699
13700 \layout Standard
13701
13702 sdcc regression test
13703 \begin_inset LatexCommand \index{Regression test}
13704
13705 \end_inset 
13706
13707
13708 \end_inset 
13709 </cell>
13710 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13711 \begin_inset Text
13712
13713 \layout Standard
13714
13715 sdcc/doc
13716 \end_inset 
13717 </cell>
13718 </row>
13719 <row topline="true" bottomline="true">
13720 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13721 \begin_inset Text
13722
13723 \layout Standard
13724
13725
13726 \family roman 
13727 \series medium 
13728 \shape up 
13729 \size normal 
13730 \emph off 
13731 \bar no 
13732 \noun off 
13733 \color none
13734 cdbfileformat.pd
13735 \family default 
13736 \series default 
13737 \shape default 
13738 \size default 
13739 \emph default 
13740 \bar default 
13741 \noun default 
13742 \color default
13743 f
13744 \end_inset 
13745 </cell>
13746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13747 \begin_inset Text
13748
13749 \layout Standard
13750
13751 sdcc internal documentation
13752 \end_inset 
13753 </cell>
13754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13755 \begin_inset Text
13756
13757 \layout Standard
13758
13759 sdcc/doc
13760 \end_inset 
13761 </cell>
13762 </row>
13763 </lyxtabular>
13764
13765 \end_inset 
13766
13767
13768 \newline 
13769
13770 \layout Section
13771 \pagebreak_top 
13772 Retargetting for other MCUs.
13773 \layout Standard
13774
13775 The issues for retargetting the compiler are far too numerous to be covered
13776  by this document.
13777  What follows is a brief description of each of the seven phases of the
13778  compiler and its MCU dependency.
13779 \layout Itemize
13780
13781 Parsing the source and building the annotated parse tree.
13782  This phase is largely MCU independent (except for the language extensions).
13783  Syntax & semantic checks are also done in this phase, along with some initial
13784  optimizations like back patching labels and the pattern matching optimizations
13785  like bit-rotation etc.
13786 \layout Itemize
13787
13788 The second phase involves generating an intermediate code which can be easy
13789  manipulated during the later phases.
13790  This phase is entirely MCU independent.
13791  The intermediate code generation assumes the target machine has unlimited
13792  number of registers, and designates them with the name iTemp.
13793  The compiler can be made to dump a human readable form of the code generated
13794  by using the -
13795 \begin_inset ERT
13796 status Collapsed
13797
13798 \layout Standard
13799
13800 \backslash 
13801 /
13802 \end_inset 
13803
13804 -dumpraw option.
13805 \layout Itemize
13806
13807 This phase does the bulk of the standard optimizations and is also MCU independe
13808 nt.
13809  This phase can be broken down into several sub-phases:
13810 \newline 
13811
13812 \newline 
13813 Break down intermediate code (iCode) into basic blocks.
13814 \newline 
13815 Do control flow & data flow analysis on the basic blocks.
13816 \newline 
13817 Do local common subexpression elimination, then global subexpression elimination
13818 \newline 
13819 Dead code elimination
13820 \newline 
13821 Loop optimizations
13822 \newline 
13823 If loop optimizations caused any changes then do 'global subexpression eliminati
13824 on' and 'dead code elimination' again.
13825 \layout Itemize
13826
13827 This phase determines the live-ranges; by live range I mean those iTemp
13828  variables defined by the compiler that still survive after all the optimization
13829 s.
13830  Live range analysis
13831 \begin_inset LatexCommand \index{Live range analysis}
13832
13833 \end_inset 
13834
13835  is essential for register allocation, since these computation determines
13836  which of these iTemps will be assigned to registers, and for how long.
13837 \layout Itemize
13838
13839 Phase five is register allocation.
13840  There are two parts to this process.
13841 \newline 
13842
13843 \newline 
13844 The first part I call 'register packing' (for lack of a better term).
13845  In this case several MCU specific expression folding is done to reduce
13846  register pressure.
13847 \newline 
13848
13849 \newline 
13850 The second part is more MCU independent and deals with allocating registers
13851  to the remaining live ranges.
13852  A lot of MCU specific code does creep into this phase because of the limited
13853  number of index registers available in the 8051.
13854 \layout Itemize
13855
13856 The Code generation phase is (unhappily), entirely MCU dependent and very
13857  little (if any at all) of this code can be reused for other MCU.
13858  However the scheme for allocating a homogenized assembler operand for each
13859  iCode operand may be reused.
13860 \layout Itemize
13861
13862 As mentioned in the optimization section the peep-hole optimizer is rule
13863  based system, which can reprogrammed for other MCUs.
13864 \layout Section
13865 \pagebreak_top 
13866 SDCDB
13867 \begin_inset LatexCommand \index{sdcdb}
13868
13869 \end_inset 
13870
13871  - Source Level Debugger
13872 \begin_inset LatexCommand \index{Debugger}
13873
13874 \end_inset 
13875
13876
13877 \layout Standard
13878
13879 SDCC is distributed with a source level debugger.
13880  The debugger uses a command line interface, the command repertoire of the
13881  debugger has been kept as close to gdb
13882 \begin_inset LatexCommand \index{gdb}
13883
13884 \end_inset 
13885
13886  (the GNU debugger) as possible.
13887  The configuration and build process is part of the standard compiler installati
13888 on, which also builds and installs the debugger in the target directory
13889  specified during configuration.
13890  The debugger allows you debug BOTH at the C source and at the ASM source
13891  level.
13892 \layout Subsection
13893
13894 Compiling for Debugging
13895 \layout Standard
13896
13897 The \SpecialChar \-
13898 \SpecialChar \-
13899 debug option must be specified for all files for which debug information
13900  is to be generated.
13901  The complier generates a .adb file for each of these files.
13902  The linker creates the .cdb file from the .adb files and the address information.
13903  This .cdb is used by the debugger.
13904 \layout Subsection
13905
13906 How the Debugger Works
13907 \layout Standard
13908
13909 When the -
13910 \begin_inset ERT
13911 status Collapsed
13912
13913 \layout Standard
13914
13915 \backslash 
13916 /
13917 \end_inset 
13918
13919 -debug option is specified the compiler generates extra symbol information
13920  some of which are put into the the assembler source and some are put into
13921  the .adb file.
13922   Then the linker creates the .cdb file from the individual .adb files with
13923  the address information for the symbols.
13924  The debugger reads the symbolic information generated by the compiler &
13925  the address information generated by the linker.
13926  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
13927  execution is controlled by the debugger.
13928  When a command is issued for the debugger, it translates it into appropriate
13929  commands for the simulator.
13930 \layout Subsection
13931
13932 Starting the Debugger
13933 \layout Standard
13934
13935 The debugger can be started using the following command line.
13936  (Assume the file you are debugging has the file name foo).
13937 \newline 
13938
13939 \newline 
13940
13941 \family sans 
13942 \series bold 
13943 sdcdb foo
13944 \newline 
13945
13946 \family default 
13947 \series default 
13948
13949 \newline 
13950 The debugger will look for the following files.
13951 \layout Itemize
13952
13953 foo.c - the source file.
13954 \layout Itemize
13955
13956 foo.cdb - the debugger symbol information file.
13957 \layout Itemize
13958
13959 foo.ihx - the Intel hex format
13960 \begin_inset LatexCommand \index{Intel hex format}
13961
13962 \end_inset 
13963
13964  object file.
13965 \layout Subsection
13966
13967 Command Line Options.
13968 \layout Itemize
13969
13970 -
13971 \begin_inset ERT
13972 status Collapsed
13973
13974 \layout Standard
13975
13976 \backslash 
13977 /
13978 \end_inset 
13979
13980 -directory=<source file directory> this option can used to specify the directory
13981  search list.
13982  The debugger will look into the directory list specified for source, cdb
13983  & ihx files.
13984  The items in the directory list must be separated by ':', e.g.
13985  if the source files can be in the directories /home/src1 and /home/src2,
13986  the -
13987 \begin_inset ERT
13988 status Collapsed
13989
13990 \layout Standard
13991
13992 \backslash 
13993 /
13994 \end_inset 
13995
13996 -directory option should be -
13997 \begin_inset ERT
13998 status Collapsed
13999
14000 \layout Standard
14001
14002 \backslash 
14003 /
14004 \end_inset 
14005
14006 -directory=/home/src1:/home/src2.
14007  Note there can be no spaces in the option.
14008  
14009 \layout Itemize
14010
14011 -cd <directory> - change to the <directory>.
14012 \layout Itemize
14013
14014 -fullname - used by GUI front ends.
14015 \layout Itemize
14016
14017 -cpu <cpu-type> - this argument is passed to the simulator please see the
14018  simulator docs for details.
14019 \layout Itemize
14020
14021 -X <Clock frequency > this options is passed to the simulator please see
14022  the simulator docs for details.
14023 \layout Itemize
14024
14025 -s <serial port file> passed to simulator see the simulator docs for details.
14026 \layout Itemize
14027
14028 -S <serial in,out> passed to simulator see the simulator docs for details.
14029 \layout Subsection
14030
14031 Debugger Commands.
14032 \layout Standard
14033
14034 As mention earlier the command interface for the debugger has been deliberately
14035  kept as close the GNU debugger gdb, as possible.
14036  This will help the integration with existing graphical user interfaces
14037  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
14038 \layout Subsubsection
14039
14040 break [line | file:line | function | file:function]
14041 \layout Standard
14042
14043 Set breakpoint at specified line or function:
14044 \newline 
14045
14046 \newline 
14047
14048 \family sans 
14049 \series bold 
14050 sdcdb>break 100 
14051 \newline 
14052 sdcdb>break foo.c:100
14053 \newline 
14054 sdcdb>break funcfoo
14055 \newline 
14056 sdcdb>break foo.c:funcfoo
14057 \layout Subsubsection
14058
14059 clear [line | file:line | function | file:function ]
14060 \layout Standard
14061
14062 Clear breakpoint at specified line or function:
14063 \newline 
14064
14065 \newline 
14066
14067 \family sans 
14068 \series bold 
14069 sdcdb>clear 100
14070 \newline 
14071 sdcdb>clear foo.c:100
14072 \newline 
14073 sdcdb>clear funcfoo
14074 \newline 
14075 sdcdb>clear foo.c:funcfoo
14076 \layout Subsubsection
14077
14078 continue
14079 \layout Standard
14080
14081 Continue program being debugged, after breakpoint.
14082 \layout Subsubsection
14083
14084 finish
14085 \layout Standard
14086
14087 Execute till the end of the current function.
14088 \layout Subsubsection
14089
14090 delete [n]
14091 \layout Standard
14092
14093 Delete breakpoint number 'n'.
14094  If used without any option clear ALL user defined break points.
14095 \layout Subsubsection
14096
14097 info [break | stack | frame | registers ]
14098 \layout Itemize
14099
14100 info break - list all breakpoints
14101 \layout Itemize
14102
14103 info stack - show the function call stack.
14104 \layout Itemize
14105
14106 info frame - show information about the current execution frame.
14107 \layout Itemize
14108
14109 info registers - show content of all registers.
14110 \layout Subsubsection
14111
14112 step
14113 \layout Standard
14114
14115 Step program until it reaches a different source line.
14116 \layout Subsubsection
14117
14118 next
14119 \layout Standard
14120
14121 Step program, proceeding through subroutine calls.
14122 \layout Subsubsection
14123
14124 run
14125 \layout Standard
14126
14127 Start debugged program.
14128 \layout Subsubsection
14129
14130 ptype variable 
14131 \layout Standard
14132
14133 Print type information of the variable.
14134 \layout Subsubsection
14135
14136 print variable
14137 \layout Standard
14138
14139 print value of variable.
14140 \layout Subsubsection
14141
14142 file filename
14143 \layout Standard
14144
14145 load the given file name.
14146  Note this is an alternate method of loading file for debugging.
14147 \layout Subsubsection
14148
14149 frame
14150 \layout Standard
14151
14152 print information about current frame.
14153 \layout Subsubsection
14154
14155 set srcmode
14156 \layout Standard
14157
14158 Toggle between C source & assembly source.
14159 \layout Subsubsection
14160
14161 ! simulator command
14162 \layout Standard
14163
14164 Send the string following '!' to the simulator, the simulator response is
14165  displayed.
14166  Note the debugger does not interpret the command being sent to the simulator,
14167  so if a command like 'go' is sent the debugger can loose its execution
14168  context and may display incorrect values.
14169 \layout Subsubsection
14170
14171 quit.
14172 \layout Standard
14173
14174 "Watch me now.
14175  Iam going Down.
14176  My name is Bobby Brown"
14177 \layout Subsection
14178
14179 Interfacing with XEmacs
14180 \begin_inset LatexCommand \index{XEmacs}
14181
14182 \end_inset 
14183
14184
14185 \begin_inset LatexCommand \index{Emacs}
14186
14187 \end_inset 
14188
14189 .
14190 \layout Standard
14191
14192 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
14193  sdcdb.el and sdcdbsrc.el.
14194  These two files can be found in the $(prefix)/bin directory after the installat
14195 ion is complete.
14196  These files need to be loaded into XEmacs for the interface to work.
14197  This can be done at XEmacs startup time by inserting the following into
14198  your '.xemacs' file (which can be found in your HOME directory): 
14199 \newline 
14200
14201 \newline 
14202
14203 \family typewriter 
14204 (load-file sdcdbsrc.el) 
14205 \family default 
14206
14207 \newline 
14208
14209 \newline 
14210 .xemacs is a lisp file so the () around the command is REQUIRED.
14211  The files can also be loaded dynamically while XEmacs is running, set the
14212  environment variable 'EMACSLOADPATH' to the installation bin directory
14213  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
14214  To start the interface enter the following command: 
14215 \newline 
14216
14217 \newline 
14218
14219 \family sans 
14220 \series bold 
14221 ESC-x sdcdbsrc
14222 \family default 
14223 \series default 
14224
14225 \newline 
14226
14227 \newline 
14228 You will prompted to enter the file name to be debugged.
14229  
14230 \newline 
14231
14232 \newline 
14233 The command line options that are passed to the simulator directly are bound
14234  to default values in the file sdcdbsrc.el.
14235  The variables are listed below, these values maybe changed as required.
14236 \layout Itemize
14237
14238 sdcdbsrc-cpu-type '51
14239 \layout Itemize
14240
14241 sdcdbsrc-frequency '11059200
14242 \layout Itemize
14243
14244 sdcdbsrc-serial nil
14245 \layout Standard
14246
14247 The following is a list of key mapping for the debugger interface.
14248 \layout Standard
14249
14250 \SpecialChar ~
14251
14252 \family typewriter 
14253
14254 \newline 
14255 ;; Current Listing :: 
14256 \newline 
14257 ;;key\SpecialChar ~
14258 \SpecialChar ~
14259 \SpecialChar ~
14260 \SpecialChar ~
14261 \SpecialChar ~
14262 \SpecialChar ~
14263 \SpecialChar ~
14264 \SpecialChar ~
14265 \SpecialChar ~
14266 \SpecialChar ~
14267 \SpecialChar ~
14268 \SpecialChar ~
14269 \SpecialChar ~
14270 \SpecialChar ~
14271 \SpecialChar ~
14272 binding\SpecialChar ~
14273 \SpecialChar ~
14274 \SpecialChar ~
14275 \SpecialChar ~
14276 \SpecialChar ~
14277 \SpecialChar ~
14278 \SpecialChar ~
14279 \SpecialChar ~
14280 \SpecialChar ~
14281 \SpecialChar ~
14282 \SpecialChar ~
14283 \SpecialChar ~
14284 \SpecialChar ~
14285 \SpecialChar ~
14286 \SpecialChar ~
14287 \SpecialChar ~
14288 \SpecialChar ~
14289 \SpecialChar ~
14290 \SpecialChar ~
14291 \SpecialChar ~
14292 \SpecialChar ~
14293 \SpecialChar ~
14294 Comment 
14295 \newline 
14296 ;;---\SpecialChar ~
14297 \SpecialChar ~
14298 \SpecialChar ~
14299 \SpecialChar ~
14300 \SpecialChar ~
14301 \SpecialChar ~
14302 \SpecialChar ~
14303 \SpecialChar ~
14304 \SpecialChar ~
14305 \SpecialChar ~
14306 \SpecialChar ~
14307 \SpecialChar ~
14308 \SpecialChar ~
14309 \SpecialChar ~
14310 \SpecialChar ~
14311 ------\SpecialChar ~
14312 \SpecialChar ~
14313 \SpecialChar ~
14314 \SpecialChar ~
14315 \SpecialChar ~
14316 \SpecialChar ~
14317 \SpecialChar ~
14318 \SpecialChar ~
14319 \SpecialChar ~
14320 \SpecialChar ~
14321 \SpecialChar ~
14322 \SpecialChar ~
14323 \SpecialChar ~
14324 \SpecialChar ~
14325 \SpecialChar ~
14326 \SpecialChar ~
14327 \SpecialChar ~
14328 \SpecialChar ~
14329 \SpecialChar ~
14330 \SpecialChar ~
14331 \SpecialChar ~
14332 \SpecialChar ~
14333 --------
14334 \newline 
14335 ;; 
14336 \newline 
14337 ;; n\SpecialChar ~
14338 \SpecialChar ~
14339 \SpecialChar ~
14340 \SpecialChar ~
14341 \SpecialChar ~
14342 \SpecialChar ~
14343 \SpecialChar ~
14344 \SpecialChar ~
14345 \SpecialChar ~
14346 \SpecialChar ~
14347 \SpecialChar ~
14348 \SpecialChar ~
14349 \SpecialChar ~
14350 \SpecialChar ~
14351  sdcdb-next-from-src\SpecialChar ~
14352 \SpecialChar ~
14353 \SpecialChar ~
14354 \SpecialChar ~
14355 \SpecialChar ~
14356 \SpecialChar ~
14357 \SpecialChar ~
14358 \SpecialChar ~
14359 \SpecialChar ~
14360 \SpecialChar ~
14361 SDCDB next command 
14362 \newline 
14363 ;; b\SpecialChar ~
14364 \SpecialChar ~
14365 \SpecialChar ~
14366 \SpecialChar ~
14367 \SpecialChar ~
14368 \SpecialChar ~
14369 \SpecialChar ~
14370 \SpecialChar ~
14371 \SpecialChar ~
14372 \SpecialChar ~
14373 \SpecialChar ~
14374 \SpecialChar ~
14375 \SpecialChar ~
14376 \SpecialChar ~
14377  sdcdb-back-from-src\SpecialChar ~
14378 \SpecialChar ~
14379 \SpecialChar ~
14380 \SpecialChar ~
14381 \SpecialChar ~
14382 \SpecialChar ~
14383 \SpecialChar ~
14384 \SpecialChar ~
14385 \SpecialChar ~
14386 \SpecialChar ~
14387 SDCDB back command 
14388 \newline 
14389 ;; c\SpecialChar ~
14390 \SpecialChar ~
14391 \SpecialChar ~
14392 \SpecialChar ~
14393 \SpecialChar ~
14394 \SpecialChar ~
14395 \SpecialChar ~
14396 \SpecialChar ~
14397 \SpecialChar ~
14398 \SpecialChar ~
14399 \SpecialChar ~
14400 \SpecialChar ~
14401 \SpecialChar ~
14402 \SpecialChar ~
14403  sdcdb-cont-from-src\SpecialChar ~
14404 \SpecialChar ~
14405 \SpecialChar ~
14406 \SpecialChar ~
14407 \SpecialChar ~
14408 \SpecialChar ~
14409 \SpecialChar ~
14410 \SpecialChar ~
14411 \SpecialChar ~
14412 \SpecialChar ~
14413 SDCDB continue command
14414 \newline 
14415 ;; s\SpecialChar ~
14416 \SpecialChar ~
14417 \SpecialChar ~
14418 \SpecialChar ~
14419 \SpecialChar ~
14420 \SpecialChar ~
14421 \SpecialChar ~
14422 \SpecialChar ~
14423 \SpecialChar ~
14424 \SpecialChar ~
14425 \SpecialChar ~
14426 \SpecialChar ~
14427 \SpecialChar ~
14428 \SpecialChar ~
14429  sdcdb-step-from-src\SpecialChar ~
14430 \SpecialChar ~
14431 \SpecialChar ~
14432 \SpecialChar ~
14433 \SpecialChar ~
14434 \SpecialChar ~
14435 \SpecialChar ~
14436 \SpecialChar ~
14437 \SpecialChar ~
14438 \SpecialChar ~
14439 SDCDB step command 
14440 \newline 
14441 ;; ?\SpecialChar ~
14442 \SpecialChar ~
14443 \SpecialChar ~
14444 \SpecialChar ~
14445 \SpecialChar ~
14446 \SpecialChar ~
14447 \SpecialChar ~
14448 \SpecialChar ~
14449 \SpecialChar ~
14450 \SpecialChar ~
14451 \SpecialChar ~
14452 \SpecialChar ~
14453 \SpecialChar ~
14454 \SpecialChar ~
14455  sdcdb-whatis-c-sexp\SpecialChar ~
14456 \SpecialChar ~
14457 \SpecialChar ~
14458 \SpecialChar ~
14459 \SpecialChar ~
14460 \SpecialChar ~
14461 \SpecialChar ~
14462 \SpecialChar ~
14463 \SpecialChar ~
14464 \SpecialChar ~
14465 SDCDB ptypecommand for data at 
14466 \newline 
14467 ;;\SpecialChar ~
14468 \SpecialChar ~
14469 \SpecialChar ~
14470 \SpecialChar ~
14471 \SpecialChar ~
14472 \SpecialChar ~
14473 \SpecialChar ~
14474 \SpecialChar ~
14475 \SpecialChar ~
14476 \SpecialChar ~
14477 \SpecialChar ~
14478 \SpecialChar ~
14479 \SpecialChar ~
14480 \SpecialChar ~
14481 \SpecialChar ~
14482 \SpecialChar ~
14483 \SpecialChar ~
14484 \SpecialChar ~
14485 \SpecialChar ~
14486 \SpecialChar ~
14487 \SpecialChar ~
14488 \SpecialChar ~
14489 \SpecialChar ~
14490 \SpecialChar ~
14491 \SpecialChar ~
14492 \SpecialChar ~
14493 \SpecialChar ~
14494 \SpecialChar ~
14495 \SpecialChar ~
14496 \SpecialChar ~
14497 \SpecialChar ~
14498 \SpecialChar ~
14499 \SpecialChar ~
14500 \SpecialChar ~
14501 \SpecialChar ~
14502 \SpecialChar ~
14503 \SpecialChar ~
14504 \SpecialChar ~
14505 \SpecialChar ~
14506 \SpecialChar ~
14507 \SpecialChar ~
14508 \SpecialChar ~
14509 \SpecialChar ~
14510 \SpecialChar ~
14511 \SpecialChar ~
14512 \SpecialChar ~
14513  buffer point 
14514 \newline 
14515 ;; x\SpecialChar ~
14516 \SpecialChar ~
14517 \SpecialChar ~
14518 \SpecialChar ~
14519 \SpecialChar ~
14520 \SpecialChar ~
14521 \SpecialChar ~
14522 \SpecialChar ~
14523 \SpecialChar ~
14524 \SpecialChar ~
14525 \SpecialChar ~
14526 \SpecialChar ~
14527 \SpecialChar ~
14528 \SpecialChar ~
14529  sdcdbsrc-delete\SpecialChar ~
14530 \SpecialChar ~
14531 \SpecialChar ~
14532 \SpecialChar ~
14533 \SpecialChar ~
14534 \SpecialChar ~
14535 \SpecialChar ~
14536 \SpecialChar ~
14537 \SpecialChar ~
14538 \SpecialChar ~
14539 \SpecialChar ~
14540 \SpecialChar ~
14541 \SpecialChar ~
14542 \SpecialChar ~
14543 SDCDB Delete all breakpoints if no arg 
14544 \newline 
14545 ;;\SpecialChar ~
14546 \SpecialChar ~
14547 \SpecialChar ~
14548 \SpecialChar ~
14549 \SpecialChar ~
14550 \SpecialChar ~
14551 \SpecialChar ~
14552 \SpecialChar ~
14553 \SpecialChar ~
14554 \SpecialChar ~
14555 \SpecialChar ~
14556 \SpecialChar ~
14557 \SpecialChar ~
14558 \SpecialChar ~
14559 \SpecialChar ~
14560 \SpecialChar ~
14561 \SpecialChar ~
14562 \SpecialChar ~
14563 \SpecialChar ~
14564 \SpecialChar ~
14565 \SpecialChar ~
14566 \SpecialChar ~
14567 \SpecialChar ~
14568 \SpecialChar ~
14569 \SpecialChar ~
14570 \SpecialChar ~
14571 \SpecialChar ~
14572 \SpecialChar ~
14573 \SpecialChar ~
14574 \SpecialChar ~
14575 \SpecialChar ~
14576 \SpecialChar ~
14577 \SpecialChar ~
14578 \SpecialChar ~
14579 \SpecialChar ~
14580 \SpecialChar ~
14581 \SpecialChar ~
14582 \SpecialChar ~
14583 \SpecialChar ~
14584 \SpecialChar ~
14585 \SpecialChar ~
14586 \SpecialChar ~
14587 \SpecialChar ~
14588 \SpecialChar ~
14589 \SpecialChar ~
14590 \SpecialChar ~
14591 given or delete arg (C-u arg x) 
14592 \newline 
14593 ;; m\SpecialChar ~
14594 \SpecialChar ~
14595 \SpecialChar ~
14596 \SpecialChar ~
14597 \SpecialChar ~
14598 \SpecialChar ~
14599 \SpecialChar ~
14600 \SpecialChar ~
14601 \SpecialChar ~
14602 \SpecialChar ~
14603 \SpecialChar ~
14604 \SpecialChar ~
14605 \SpecialChar ~
14606 \SpecialChar ~
14607  sdcdbsrc-frame\SpecialChar ~
14608 \SpecialChar ~
14609 \SpecialChar ~
14610 \SpecialChar ~
14611 \SpecialChar ~
14612 \SpecialChar ~
14613 \SpecialChar ~
14614 \SpecialChar ~
14615 \SpecialChar ~
14616 \SpecialChar ~
14617 \SpecialChar ~
14618 \SpecialChar ~
14619 \SpecialChar ~
14620 \SpecialChar ~
14621 \SpecialChar ~
14622 SDCDB Display current frame if no arg, 
14623 \newline 
14624 ;;\SpecialChar ~
14625 \SpecialChar ~
14626 \SpecialChar ~
14627 \SpecialChar ~
14628 \SpecialChar ~
14629 \SpecialChar ~
14630 \SpecialChar ~
14631 \SpecialChar ~
14632 \SpecialChar ~
14633 \SpecialChar ~
14634 \SpecialChar ~
14635 \SpecialChar ~
14636 \SpecialChar ~
14637 \SpecialChar ~
14638 \SpecialChar ~
14639 \SpecialChar ~
14640 \SpecialChar ~
14641 \SpecialChar ~
14642 \SpecialChar ~
14643 \SpecialChar ~
14644 \SpecialChar ~
14645 \SpecialChar ~
14646 \SpecialChar ~
14647 \SpecialChar ~
14648 \SpecialChar ~
14649 \SpecialChar ~
14650 \SpecialChar ~
14651 \SpecialChar ~
14652 \SpecialChar ~
14653 \SpecialChar ~
14654 \SpecialChar ~
14655 \SpecialChar ~
14656 \SpecialChar ~
14657 \SpecialChar ~
14658 \SpecialChar ~
14659 \SpecialChar ~
14660 \SpecialChar ~
14661 \SpecialChar ~
14662 \SpecialChar ~
14663 \SpecialChar ~
14664 \SpecialChar ~
14665 \SpecialChar ~
14666 \SpecialChar ~
14667 \SpecialChar ~
14668 \SpecialChar ~
14669 \SpecialChar ~
14670 \SpecialChar ~
14671 given or display frame arg 
14672 \newline 
14673 ;;\SpecialChar ~
14674 \SpecialChar ~
14675 \SpecialChar ~
14676 \SpecialChar ~
14677 \SpecialChar ~
14678 \SpecialChar ~
14679 \SpecialChar ~
14680 \SpecialChar ~
14681 \SpecialChar ~
14682 \SpecialChar ~
14683 \SpecialChar ~
14684 \SpecialChar ~
14685 \SpecialChar ~
14686 \SpecialChar ~
14687 \SpecialChar ~
14688 \SpecialChar ~
14689 \SpecialChar ~
14690 \SpecialChar ~
14691 \SpecialChar ~
14692 \SpecialChar ~
14693 \SpecialChar ~
14694 \SpecialChar ~
14695 \SpecialChar ~
14696 \SpecialChar ~
14697 \SpecialChar ~
14698 \SpecialChar ~
14699 \SpecialChar ~
14700 \SpecialChar ~
14701 \SpecialChar ~
14702 \SpecialChar ~
14703 \SpecialChar ~
14704 \SpecialChar ~
14705 \SpecialChar ~
14706 \SpecialChar ~
14707 \SpecialChar ~
14708 \SpecialChar ~
14709 \SpecialChar ~
14710 \SpecialChar ~
14711 \SpecialChar ~
14712 \SpecialChar ~
14713 \SpecialChar ~
14714 \SpecialChar ~
14715 \SpecialChar ~
14716 \SpecialChar ~
14717 \SpecialChar ~
14718 \SpecialChar ~
14719 \SpecialChar ~
14720 buffer point 
14721 \newline 
14722 ;; !\SpecialChar ~
14723 \SpecialChar ~
14724 \SpecialChar ~
14725 \SpecialChar ~
14726 \SpecialChar ~
14727 \SpecialChar ~
14728 \SpecialChar ~
14729 \SpecialChar ~
14730 \SpecialChar ~
14731 \SpecialChar ~
14732 \SpecialChar ~
14733 \SpecialChar ~
14734 \SpecialChar ~
14735 \SpecialChar ~
14736  sdcdbsrc-goto-sdcdb\SpecialChar ~
14737 \SpecialChar ~
14738 \SpecialChar ~
14739 \SpecialChar ~
14740 \SpecialChar ~
14741 \SpecialChar ~
14742 \SpecialChar ~
14743 \SpecialChar ~
14744 \SpecialChar ~
14745 \SpecialChar ~
14746 Goto the SDCDB output buffer 
14747 \newline 
14748 ;; p\SpecialChar ~
14749 \SpecialChar ~
14750 \SpecialChar ~
14751 \SpecialChar ~
14752 \SpecialChar ~
14753 \SpecialChar ~
14754 \SpecialChar ~
14755 \SpecialChar ~
14756 \SpecialChar ~
14757 \SpecialChar ~
14758 \SpecialChar ~
14759 \SpecialChar ~
14760 \SpecialChar ~
14761 \SpecialChar ~
14762  sdcdb-print-c-sexp\SpecialChar ~
14763 \SpecialChar ~
14764 \SpecialChar ~
14765 \SpecialChar ~
14766 \SpecialChar ~
14767 \SpecialChar ~
14768 \SpecialChar ~
14769 \SpecialChar ~
14770 \SpecialChar ~
14771 \SpecialChar ~
14772 \SpecialChar ~
14773 SDCDB print command for data at 
14774 \newline 
14775 ;;\SpecialChar ~
14776 \SpecialChar ~
14777 \SpecialChar ~
14778 \SpecialChar ~
14779 \SpecialChar ~
14780 \SpecialChar ~
14781 \SpecialChar ~
14782 \SpecialChar ~
14783 \SpecialChar ~
14784 \SpecialChar ~
14785 \SpecialChar ~
14786 \SpecialChar ~
14787 \SpecialChar ~
14788 \SpecialChar ~
14789 \SpecialChar ~
14790 \SpecialChar ~
14791 \SpecialChar ~
14792 \SpecialChar ~
14793 \SpecialChar ~
14794 \SpecialChar ~
14795 \SpecialChar ~
14796 \SpecialChar ~
14797 \SpecialChar ~
14798 \SpecialChar ~
14799 \SpecialChar ~
14800 \SpecialChar ~
14801 \SpecialChar ~
14802 \SpecialChar ~
14803 \SpecialChar ~
14804 \SpecialChar ~
14805 \SpecialChar ~
14806 \SpecialChar ~
14807 \SpecialChar ~
14808 \SpecialChar ~
14809 \SpecialChar ~
14810 \SpecialChar ~
14811 \SpecialChar ~
14812 \SpecialChar ~
14813 \SpecialChar ~
14814 \SpecialChar ~
14815 \SpecialChar ~
14816 \SpecialChar ~
14817 \SpecialChar ~
14818 \SpecialChar ~
14819 \SpecialChar ~
14820 \SpecialChar ~
14821  buffer point 
14822 \newline 
14823 ;; g\SpecialChar ~
14824 \SpecialChar ~
14825 \SpecialChar ~
14826 \SpecialChar ~
14827 \SpecialChar ~
14828 \SpecialChar ~
14829 \SpecialChar ~
14830 \SpecialChar ~
14831 \SpecialChar ~
14832 \SpecialChar ~
14833 \SpecialChar ~
14834 \SpecialChar ~
14835 \SpecialChar ~
14836 \SpecialChar ~
14837  sdcdbsrc-goto-sdcdb\SpecialChar ~
14838 \SpecialChar ~
14839 \SpecialChar ~
14840 \SpecialChar ~
14841 \SpecialChar ~
14842 \SpecialChar ~
14843 \SpecialChar ~
14844 \SpecialChar ~
14845 \SpecialChar ~
14846 \SpecialChar ~
14847 Goto the SDCDB output buffer 
14848 \newline 
14849 ;; t\SpecialChar ~
14850 \SpecialChar ~
14851 \SpecialChar ~
14852 \SpecialChar ~
14853 \SpecialChar ~
14854 \SpecialChar ~
14855 \SpecialChar ~
14856 \SpecialChar ~
14857 \SpecialChar ~
14858 \SpecialChar ~
14859 \SpecialChar ~
14860 \SpecialChar ~
14861 \SpecialChar ~
14862 \SpecialChar ~
14863  sdcdbsrc-mode\SpecialChar ~
14864 \SpecialChar ~
14865 \SpecialChar ~
14866 \SpecialChar ~
14867 \SpecialChar ~
14868 \SpecialChar ~
14869 \SpecialChar ~
14870 \SpecialChar ~
14871 \SpecialChar ~
14872 \SpecialChar ~
14873 \SpecialChar ~
14874 \SpecialChar ~
14875 \SpecialChar ~
14876 \SpecialChar ~
14877 \SpecialChar ~
14878 \SpecialChar ~
14879 Toggles Sdcdbsrc mode (turns it off) 
14880 \newline 
14881 ;; 
14882 \newline 
14883 ;; C-c C-f\SpecialChar ~
14884 \SpecialChar ~
14885 \SpecialChar ~
14886 \SpecialChar ~
14887 \SpecialChar ~
14888 \SpecialChar ~
14889 \SpecialChar ~
14890 \SpecialChar ~
14891  sdcdb-finish-from-src\SpecialChar ~
14892 \SpecialChar ~
14893 \SpecialChar ~
14894 \SpecialChar ~
14895 \SpecialChar ~
14896 \SpecialChar ~
14897 \SpecialChar ~
14898 \SpecialChar ~
14899 SDCDB finish command 
14900 \newline 
14901 ;; 
14902 \newline 
14903 ;; C-x SPC\SpecialChar ~
14904 \SpecialChar ~
14905 \SpecialChar ~
14906 \SpecialChar ~
14907 \SpecialChar ~
14908 \SpecialChar ~
14909 \SpecialChar ~
14910 \SpecialChar ~
14911  sdcdb-break\SpecialChar ~
14912 \SpecialChar ~
14913 \SpecialChar ~
14914 \SpecialChar ~
14915 \SpecialChar ~
14916 \SpecialChar ~
14917 \SpecialChar ~
14918 \SpecialChar ~
14919 \SpecialChar ~
14920 \SpecialChar ~
14921 \SpecialChar ~
14922 \SpecialChar ~
14923 \SpecialChar ~
14924 \SpecialChar ~
14925 \SpecialChar ~
14926 \SpecialChar ~
14927 \SpecialChar ~
14928 \SpecialChar ~
14929 Set break for line with point 
14930 \newline 
14931 ;; ESC t\SpecialChar ~
14932 \SpecialChar ~
14933 \SpecialChar ~
14934 \SpecialChar ~
14935 \SpecialChar ~
14936 \SpecialChar ~
14937 \SpecialChar ~
14938 \SpecialChar ~
14939 \SpecialChar ~
14940 \SpecialChar ~
14941  sdcdbsrc-mode\SpecialChar ~
14942 \SpecialChar ~
14943 \SpecialChar ~
14944 \SpecialChar ~
14945 \SpecialChar ~
14946 \SpecialChar ~
14947 \SpecialChar ~
14948 \SpecialChar ~
14949 \SpecialChar ~
14950 \SpecialChar ~
14951 \SpecialChar ~
14952 \SpecialChar ~
14953 \SpecialChar ~
14954 \SpecialChar ~
14955 \SpecialChar ~
14956 \SpecialChar ~
14957 Toggle Sdcdbsrc mode 
14958 \newline 
14959 ;; ESC m\SpecialChar ~
14960 \SpecialChar ~
14961 \SpecialChar ~
14962 \SpecialChar ~
14963 \SpecialChar ~
14964 \SpecialChar ~
14965 \SpecialChar ~
14966 \SpecialChar ~
14967 \SpecialChar ~
14968 \SpecialChar ~
14969  sdcdbsrc-srcmode\SpecialChar ~
14970 \SpecialChar ~
14971 \SpecialChar ~
14972 \SpecialChar ~
14973 \SpecialChar ~
14974 \SpecialChar ~
14975 \SpecialChar ~
14976 \SpecialChar ~
14977 \SpecialChar ~
14978 \SpecialChar ~
14979 \SpecialChar ~
14980 \SpecialChar ~
14981  Toggle list mode 
14982 \newline 
14983 ;; 
14984 \family default 
14985
14986 \newline 
14987
14988 \layout Section
14989
14990 Other Processors
14991 \layout Subsection
14992
14993 The Z80 and gbz80 port
14994 \layout Standard
14995
14996 SDCC can target both the Zilog Z80 and the Nintendo Gameboy's Z80-like gbz80.
14997  The port is incomplete - long support is incomplete (mul, div and mod are
14998  unimplemented), and both float and bitfield support is missing.
14999  Apart from that the code generated is correct.
15000 \layout Standard
15001
15002 As always, the code is the authoritave reference - see z80/ralloc.c and z80/gen.c.
15003  The stack frame is similar to that generated by the IAR Z80 compiler.
15004  IX is used as the base pointer, HL is used as a temporary register, and
15005  BC and DE are available for holding variables.
15006  IY is currently unused.
15007  Return values are stored in HL.
15008  One bad side effect of using IX as the base pointer is that a functions
15009  stack frame is limited to 127 bytes - this will be fixed in a later version.
15010 \layout Section
15011 \pagebreak_top 
15012 Support
15013 \begin_inset LatexCommand \index{Support}
15014
15015 \end_inset 
15016
15017
15018 \layout Standard
15019
15020 SDCC has grown to be a large project.
15021  The compiler alone (without the preprocessor, assembler and linker) is
15022  about 40,000 lines of code (blank stripped).
15023  The open source nature of this project is a key to its continued growth
15024  and support.
15025  You gain the benefit and support of many active software developers and
15026  end users.
15027  Is SDCC perfect? No, that's why we need your help.
15028  The developers take pride in fixing reported bugs.
15029  You can help by reporting the bugs and helping other SDCC users.
15030  There are lots of ways to contribute, and we encourage you to take part
15031  in making SDCC a great software package.
15032  
15033 \layout Standard
15034
15035 The SDCC project is hosted on the sdcc sourceforge site at 
15036 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
15037
15038 \end_inset 
15039
15040 .
15041  You'll find the complete set of mailing lists
15042 \begin_inset LatexCommand \index{Mailing list}
15043
15044 \end_inset 
15045
15046 , forums, bug reporting system, patch submission
15047 \begin_inset LatexCommand \index{Patch submission}
15048
15049 \end_inset 
15050
15051  system, download
15052 \begin_inset LatexCommand \index{download}
15053
15054 \end_inset 
15055
15056  area and cvs code repository
15057 \begin_inset LatexCommand \index{cvs code repository}
15058
15059 \end_inset 
15060
15061  there.
15062 \layout Subsection
15063
15064 Reporting Bugs
15065 \begin_inset LatexCommand \index{Bugs}
15066
15067 \end_inset 
15068
15069
15070 \begin_inset LatexCommand \index{Reporting bugs}
15071
15072 \end_inset 
15073
15074
15075 \layout Standard
15076
15077 The recommended way of reporting bugs is using the infrastructure of the
15078  sourceforge site.
15079  You can follow the status of bug reports there and have an overview about
15080  the known bugs.
15081 \layout Standard
15082
15083 Bug reports are automatically forwarded to the developer mailing list and
15084  will be fixed ASAP.
15085  When reporting a bug, it is very useful to include a small test program
15086  (the smaller the better) which reproduces the problem.
15087  If you can isolate the problem by looking at the generated assembly code,
15088  this can be very helpful.
15089  Compiling your program with the -
15090 \begin_inset ERT
15091 status Collapsed
15092
15093 \layout Standard
15094
15095 \backslash 
15096 /
15097 \end_inset 
15098
15099 -dumpall
15100 \begin_inset LatexCommand \index{-\/-dumpall}
15101
15102 \end_inset 
15103
15104  option can sometimes be useful in locating optimization problems.
15105  When reporting a bug please maker sure you:
15106 \layout Enumerate
15107
15108 Attach the code you are compiling with SDCC.
15109  
15110 \layout Enumerate
15111
15112 Specify the exact command you use to run SDCC, or attach your Makefile.
15113  
15114 \layout Enumerate
15115
15116 Specify the SDCC version (type "sdcc -v"), your platform, and operating
15117  system.
15118  
15119 \layout Enumerate
15120
15121 Provide an exact copy of any error message or incorrect output.
15122  
15123 \layout Enumerate
15124
15125 Put something meaningful in the subject of your message.
15126 \layout Standard
15127
15128 Please attempt to include these 5 important parts, as applicable, in all
15129  requests for support or when reporting any problems or bugs with SDCC.
15130  Though this will make your message lengthy, it will greatly improve your
15131  chance that SDCC users and developers will be able to help you.
15132  Some SDCC developers are frustrated by bug reports without code provided
15133  that they can use to reproduce and ultimately fix the problem, so please
15134  be sure to provide sample code if you are reporting a bug! 
15135 \layout Standard
15136
15137 Please have a short check that you are using a recent version of SDCC and
15138  the bug is not yet known.
15139  This is the link for reporting bugs: 
15140 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
15141
15142 \end_inset 
15143
15144 .
15145 \layout Subsection
15146
15147 Requesting Features
15148 \begin_inset LatexCommand \index{Feature request}
15149
15150 \end_inset 
15151
15152
15153 \begin_inset LatexCommand \index{Requesting features}
15154
15155 \end_inset 
15156
15157
15158 \layout Standard
15159
15160 Like bug reports feature requests are forwarded to the developer mailing
15161  list.
15162  This is the link for requesting features: 
15163 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
15164
15165 \end_inset 
15166
15167 .
15168 \layout Subsection
15169
15170 Getting Help
15171 \layout Standard
15172
15173 These links should take you directly to the 
15174 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
15175
15176 \end_inset 
15177
15178
15179 \begin_inset Foot
15180 collapsed false
15181
15182 \layout Standard
15183
15184 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
15185  automated messages (mid 2003)
15186 \end_inset 
15187
15188  and the 
15189 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
15190
15191 \end_inset 
15192
15193 , lists and forums are archived so if you are lucky someone already had
15194  a similar problem.
15195 \layout Subsection
15196
15197 ChangeLog
15198 \begin_inset LatexCommand \index{Changelog}
15199
15200 \end_inset 
15201
15202
15203 \layout Standard
15204
15205 You can follow the status of the cvs version
15206 \begin_inset LatexCommand \index{version}
15207
15208 \end_inset 
15209
15210  of SDCC by watching the file 
15211 \begin_inset LatexCommand \htmlurl[ChangeLog]{http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sdcc/sdcc/ChangeLog?rev=HEAD&content-type=text/plain}
15212
15213 \end_inset 
15214
15215  in the cvs-repository.
15216 \layout Subsection
15217
15218 Release policy
15219 \begin_inset LatexCommand \index{Release policy}
15220
15221 \end_inset 
15222
15223
15224 \layout Standard
15225
15226 Historically there often were long delays between official releases and
15227  the sourceforge download area tends to get not updated at all.
15228  Current excuses might refer to problems with live range analysis, but if
15229  this is fixed, the next problem rising is that another excuse will have
15230  to be found.
15231  Kidding aside, we have to get better there! On the other hand there are
15232  daily snapshots available at 
15233 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
15234
15235 \end_inset 
15236
15237 , and you can always built the very last version (hopefully with many bugs
15238  fixed, and features added) from the source code available at 
15239 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
15240
15241 \end_inset 
15242
15243 .
15244 \layout Subsection
15245
15246 Examples
15247 \begin_inset LatexCommand \index{Examples}
15248
15249 \end_inset 
15250
15251
15252 \layout Standard
15253
15254 You'll find some small examples in the directory sdcc/device/examples/
15255 \layout Comment
15256
15257 Maybe we should include some links to real world applications.
15258  Preferably pointer to pointers (one for each architecture) so this stays
15259  manageable here?
15260 \layout Subsection
15261
15262 Quality control
15263 \begin_inset LatexCommand \index{Quality control}
15264
15265 \end_inset 
15266
15267
15268 \layout Standard
15269
15270 The compiler is passed through nightly compile and build checks.
15271  The so called 
15272 \shape italic 
15273 regression tests
15274 \shape default 
15275
15276 \begin_inset LatexCommand \index{Regression test}
15277
15278 \end_inset 
15279
15280  check that SDCC itself compiles flawlessly on several platforms and checks
15281  the quality of the code generated by SDCC by running the code through simulator
15282 s.
15283  There is a separate document 
15284 \shape italic 
15285 test_suite.pdf
15286 \begin_inset LatexCommand \index{Test suite}
15287
15288 \end_inset 
15289
15290
15291 \shape default 
15292  about this.
15293 \layout Standard
15294
15295 You'll find the test code in the directory 
15296 \shape italic 
15297 sdcc/support/regression
15298 \shape default 
15299 .
15300  You can run these tests manually by running 
15301 \family sans 
15302 make
15303 \family default 
15304  in this directory (or f.e.
15305  
15306 \family sans 
15307 make test-mcs51
15308 \family default 
15309  if you don't want to run the complete tests).
15310  The test code might also be interesting if you want to look for examples
15311 \begin_inset LatexCommand \index{Examples}
15312
15313 \end_inset 
15314
15315  checking corner cases of SDCC or if you plan to submit patches
15316 \begin_inset LatexCommand \index{Patch submission}
15317
15318 \end_inset 
15319
15320 .
15321 \layout Standard
15322
15323 The pic port uses a different set of regression tests, you'll find them
15324  in the directory 
15325 \shape italic 
15326 sdcc/src/regression
15327 \shape default 
15328 .
15329 \layout Section
15330 \pagebreak_top 
15331 Compiler internals
15332 \begin_inset LatexCommand \index{Compiler internals}
15333
15334 \end_inset 
15335
15336
15337 \layout Subsection
15338
15339 The anatomy of the compiler
15340 \layout Standard
15341
15342
15343 \shape italic 
15344 This is an excerpt from an article published in Circuit Cellar Magazine
15345  in august 2000.
15346  It's a little outdated (the compiler is much more efficient now and user/develo
15347 per friendly), but pretty well exposes the guts of it all.
15348 \shape default 
15349
15350 \newline 
15351
15352 \newline 
15353 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
15354  It is fairly easy to retarget for other 8-bit MCU.
15355  Here we take a look at some of the internals of the compiler.
15356  
15357 \layout Paragraph*
15358
15359 Parsing
15360 \begin_inset LatexCommand \index{Parsing}
15361
15362 \end_inset 
15363
15364  
15365 \layout Standard
15366
15367 Parsing the input source file and creating an AST (Annotated Syntax Tree
15368 \begin_inset LatexCommand \index{Annotated syntax tree}
15369
15370 \end_inset 
15371
15372 ).
15373  This phase also involves propagating types (annotating each node of the
15374  parse tree with type information) and semantic analysis.
15375  There are some MCU specific parsing rules.
15376  For example the storage classes, the extended storage classes are MCU specific
15377  while there may be a xdata storage class for 8051 there is no such storage
15378  class for z80 or Atmel AVR.
15379  SDCC allows MCU specific storage class extensions, i.e.
15380  xdata will be treated as a storage class specifier when parsing 8051 C
15381  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
15382  C code.
15383 \layout Paragraph*
15384
15385 Generating iCode
15386 \begin_inset LatexCommand \index{iCode}
15387
15388 \end_inset 
15389
15390
15391 \layout Standard
15392
15393 Intermediate code generation.
15394  In this phase the AST is broken down into three-operand form (iCode).
15395  These three operand forms are represented as doubly linked lists.
15396  ICode is the term given to the intermediate form generated by the compiler.
15397  ICode example section shows some examples of iCode generated for some simple
15398  C source functions.
15399 \layout Paragraph*
15400
15401 Optimizations
15402 \begin_inset LatexCommand \index{Optimizations}
15403
15404 \end_inset 
15405
15406 .
15407 \layout Standard
15408
15409 Bulk of the target independent optimizations is performed in this phase.
15410  The optimizations include constant propagation, common sub-expression eliminati
15411 on, loop invariant code movement, strength reduction of loop induction variables
15412  and dead-code elimination.
15413 \layout Paragraph*
15414
15415 Live range analysis
15416 \begin_inset LatexCommand \index{Live range analysis}
15417
15418 \end_inset 
15419
15420
15421 \layout Standard
15422
15423 During intermediate code generation phase, the compiler assumes the target
15424  machine has infinite number of registers and generates a lot of temporary
15425  variables.
15426  The live range computation determines the lifetime of each of these compiler-ge
15427 nerated temporaries.
15428  A picture speaks a thousand words.
15429  ICode example sections show the live range annotations for each of the
15430  operand.
15431  It is important to note here, each iCode is assigned a number in the order
15432  of its execution in the function.
15433  The live ranges are computed in terms of these numbers.
15434  The from number is the number of the iCode which first defines the operand
15435  and the to number signifies the iCode which uses this operand last.
15436 \layout Paragraph*
15437
15438 Register Allocation
15439 \begin_inset LatexCommand \index{Register allocation}
15440
15441 \end_inset 
15442
15443
15444 \layout Standard
15445
15446 The register allocation determines the type and number of registers needed
15447  by each operand.
15448  In most MCUs only a few registers can be used for indirect addressing.
15449  In case of 8051 for example the registers R0 & R1 can be used to indirectly
15450  address the internal ram and DPTR to indirectly address the external ram.
15451  The compiler will try to allocate the appropriate register to pointer variables
15452  if it can.
15453  ICode example section shows the operands annotated with the registers assigned
15454  to them.
15455  The compiler will try to keep operands in registers as much as possible;
15456  there are several schemes the compiler uses to do achieve this.
15457  When the compiler runs out of registers the compiler will check to see
15458  if there are any live operands which is not used or defined in the current
15459  basic block being processed, if there are any found then it will push that
15460  operand and use the registers in this block, the operand will then be popped
15461  at the end of the basic block.
15462  
15463 \layout Standard
15464
15465 There are other MCU specific considerations in this phase.
15466  Some MCUs have an accumulator; very short-lived operands could be assigned
15467  to the accumulator instead of general-purpose register.
15468 \layout Paragraph*
15469
15470 Code generation
15471 \layout Standard
15472
15473 Figure II gives a table of iCode operations supported by the compiler.
15474  The code generation involves translating these operations into corresponding
15475  assembly code for the processor.
15476  This sounds overly simple but that is the essence of code generation.
15477  Some of the iCode operations are generated on a MCU specific manner for
15478  example, the z80 port does not use registers to pass parameters so the
15479  SEND and RECV iCode operations will not be generated, and it also does
15480  not support JUMPTABLES.
15481  
15482 \newline 
15483
15484 \series bold 
15485 \shape italic 
15486 \color red
15487 <Where is Figure II ?>
15488 \layout Paragraph*
15489
15490 ICode Example
15491 \begin_inset LatexCommand \index{iCode}
15492
15493 \end_inset 
15494
15495
15496 \layout Standard
15497
15498 This section shows some details of iCode.
15499  The example C code does not do anything useful; it is used as an example
15500  to illustrate the intermediate code generated by the compiler.
15501 \layout Verse
15502
15503
15504 \family typewriter 
15505 1.\SpecialChar ~
15506 xdata int * p;
15507 \newline 
15508 2.\SpecialChar ~
15509 int gint;
15510 \newline 
15511 3.\SpecialChar ~
15512 /* This function does nothing useful.
15513  It is used
15514 \newline 
15515 4.\SpecialChar ~
15516 \SpecialChar ~
15517 \SpecialChar ~
15518 \SpecialChar ~
15519 for the purpose of explaining iCode */
15520 \newline 
15521 5.\SpecialChar ~
15522 short function (data int *x)
15523 \newline 
15524 6.\SpecialChar ~
15525 {
15526 \newline 
15527 7.\SpecialChar ~
15528 \SpecialChar ~
15529 \SpecialChar ~
15530 short i=10; /* dead initialization eliminated */
15531 \newline 
15532 8.\SpecialChar ~
15533 \SpecialChar ~
15534 \SpecialChar ~
15535 short sum=10; /* dead initialization eliminated */
15536 \newline 
15537 9.\SpecialChar ~
15538 \SpecialChar ~
15539 \SpecialChar ~
15540 short mul;
15541 \newline 
15542 10.\SpecialChar ~
15543 \SpecialChar ~
15544 int j ;
15545 \newline 
15546 11.\SpecialChar ~
15547 \SpecialChar ~
15548 while (*x) *x++ = *p++; 
15549 \newline 
15550 12.\SpecialChar ~
15551 \SpecialChar ~
15552 \SpecialChar ~
15553 \SpecialChar ~
15554 sum = 0 ; 
15555 \newline 
15556 13.\SpecialChar ~
15557 \SpecialChar ~
15558 mul = 0;
15559 \newline 
15560 14.\SpecialChar ~
15561 \SpecialChar ~
15562 /* compiler detects i,j to be induction variables */
15563 \newline 
15564 15.\SpecialChar ~
15565 \SpecialChar ~
15566 for (i = 0, j = 10 ; i < 10 ; i++, j
15567 \family default 
15568 -
15569 \begin_inset ERT
15570 status Collapsed
15571
15572 \layout Standard
15573
15574 \backslash 
15575 /
15576 \end_inset 
15577
15578 -
15579 \family typewriter 
15580 ) {
15581 \newline 
15582 16.\SpecialChar ~
15583 \SpecialChar ~
15584 \SpecialChar ~
15585 \SpecialChar ~
15586 sum += i;
15587 \newline 
15588 17.\SpecialChar ~
15589 \SpecialChar ~
15590 \SpecialChar ~
15591 \SpecialChar ~
15592 mul += i * 3; /* this multiplication remains */
15593 \newline 
15594 18.\SpecialChar ~
15595 \SpecialChar ~
15596 \SpecialChar ~
15597 \SpecialChar ~
15598 gint += j * 3;/* this multiplication changed to addition */
15599 \newline 
15600 19.\SpecialChar ~
15601 \SpecialChar ~
15602 }
15603 \newline 
15604 20.\SpecialChar ~
15605 \SpecialChar ~
15606 return sum+mul;
15607 \newline 
15608 21.\SpecialChar ~
15609 }
15610 \layout Standard
15611
15612 In addition to the operands each iCode contains information about the filename
15613  and line it corresponds to in the source file.
15614  The first field in the listing should be interpreted as follows:
15615 \newline 
15616
15617 \shape italic 
15618 \size footnotesize 
15619 Filename(linenumber: iCode Execution sequence number : ICode hash table
15620  key : loop depth of the iCode).
15621 \shape default 
15622 \size default 
15623
15624 \newline 
15625 Then follows the human readable form of the ICode operation.
15626  Each operand of this triplet form can be of three basic types a) compiler
15627  generated temporary b) user defined variable c) a constant value.
15628  Note that local variables and parameters are replaced by compiler generated
15629  temporaries.
15630  Live ranges
15631 \begin_inset LatexCommand \index{Live range analysis}
15632
15633 \end_inset 
15634
15635  are computed only for temporaries (i.e.
15636  live ranges are not computed for global variables).
15637  Registers
15638 \begin_inset LatexCommand \index{Register allocation}
15639
15640 \end_inset 
15641
15642  are allocated for temporaries only.
15643  Operands are formatted in the following manner:
15644 \newline 
15645
15646 \shape italic 
15647 \size footnotesize 
15648 Operand Name [lr live-from : live-to ] { type information } [ registers
15649  allocated ].
15650 \shape default 
15651 \size default 
15652
15653 \newline 
15654 As mentioned earlier the live ranges are computed in terms of the execution
15655  sequence number of the iCodes, for example 
15656 \newline 
15657 the iTemp0 is live from (i.e.
15658  first defined in iCode with execution sequence number 3, and is last used
15659  in the iCode with sequence number 5).
15660  For induction variables such as iTemp21 the live range computation extends
15661  the lifetime from the start to the end of the loop.
15662 \newline 
15663 The register allocator used the live range information to allocate registers,
15664  the same registers may be used for different temporaries if their live
15665  ranges do not overlap, for example r0 is allocated to both iTemp6 and to
15666  iTemp17 since their live ranges do not overlap.
15667  In addition the allocator also takes into consideration the type and usage
15668  of a temporary, for example itemp6 is a pointer to near space and is used
15669  as to fetch data from (i.e.
15670  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer registers (r0).
15671  Some short lived temporaries are allocated to special registers which have
15672  meaning to the code generator e.g.
15673  iTemp13 is allocated to a pseudo register CC which tells the back end that
15674  the temporary is used only for a conditional jump the code generation makes
15675  use of this information to optimize a compare and jump ICode.
15676 \newline 
15677 There are several loop optimizations
15678 \begin_inset LatexCommand \index{Loop optimization}
15679
15680 \end_inset 
15681
15682  performed by the compiler.
15683  It can detect induction variables iTemp21(i) and iTemp23(j).
15684  Also note the compiler does selective strength reduction
15685 \begin_inset LatexCommand \index{Strength reduction}
15686
15687 \end_inset 
15688
15689 , i.e.
15690  the multiplication of an induction variable in line 18 (gint = j * 3) is
15691  changed to addition, a new temporary iTemp17 is allocated and assigned
15692  a initial value, a constant 3 is then added for each iteration of the loop.
15693  The compiler does not change the multiplication
15694 \begin_inset LatexCommand \index{Multiplication}
15695
15696 \end_inset 
15697
15698  in line 17 however since the processor does support an 8 * 8 bit multiplication.
15699 \newline 
15700 Note the dead code elimination
15701 \begin_inset LatexCommand \index{Dead-code elimination}
15702
15703 \end_inset 
15704
15705  optimization eliminated the dead assignments in line 7 & 8 to I and sum
15706  respectively.
15707 \newline 
15708
15709 \layout Standard
15710
15711
15712 \size footnotesize 
15713 Sample.c (5:1:0:0) _entry($9) :
15714 \layout Standard
15715
15716
15717 \size footnotesize 
15718 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
15719 \layout Standard
15720
15721
15722 \size footnotesize 
15723 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
15724 \layout Standard
15725
15726
15727 \size footnotesize 
15728 Sample.c(11:4:53:0) preHeaderLbl0($11) :
15729 \layout Standard
15730
15731
15732 \size footnotesize 
15733 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
15734  * int}[r2]
15735 \layout Standard
15736
15737
15738 \size footnotesize 
15739 Sample.c(11:6:5:1) _whilecontinue_0($1) :
15740 \layout Standard
15741
15742
15743 \size footnotesize 
15744 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
15745  int}[r0]]
15746 \layout Standard
15747
15748
15749 \size footnotesize 
15750 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
15751 \layout Standard
15752
15753
15754 \size footnotesize 
15755 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
15756  * int}
15757 \layout Standard
15758
15759
15760 \size footnotesize 
15761 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
15762  {short}
15763 \layout Standard
15764
15765
15766 \size footnotesize 
15767 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
15768  * int}[DPTR]]
15769 \layout Standard
15770
15771
15772 \size footnotesize 
15773 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
15774 }[r2 r3]
15775 \layout Standard
15776
15777
15778 \size footnotesize 
15779 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
15780  * int}[r0] + 0x2 {short}
15781 \layout Standard
15782
15783
15784 \size footnotesize 
15785 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
15786 \layout Standard
15787
15788
15789 \size footnotesize 
15790 Sample.c(11:17:21:0)_whilebreak_0($3) :
15791 \layout Standard
15792
15793
15794 \size footnotesize 
15795 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
15796 \layout Standard
15797
15798
15799 \size footnotesize 
15800 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
15801 \layout Standard
15802
15803
15804 \size footnotesize 
15805 Sample.c(15:20:54:0)preHeaderLbl1($13) :
15806 \layout Standard
15807
15808
15809 \size footnotesize 
15810 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
15811 \layout Standard
15812
15813
15814 \size footnotesize 
15815 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
15816 \layout Standard
15817
15818
15819 \size footnotesize 
15820 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
15821 \layout Standard
15822
15823
15824 \size footnotesize 
15825 Sample.c(15:24:26:1)_forcond_0($4) :
15826 \layout Standard
15827
15828
15829 \size footnotesize 
15830 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
15831  < 0xa {short}
15832 \layout Standard
15833
15834
15835 \size footnotesize 
15836 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
15837 \layout Standard
15838
15839
15840 \size footnotesize 
15841 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
15842  + ITemp21 [lr21:38]{short}[r4]
15843 \layout Standard
15844
15845
15846 \size footnotesize 
15847 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
15848  * 0x3 {short}
15849 \layout Standard
15850
15851
15852 \size footnotesize 
15853 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
15854  + iTemp15 [lr29:30]{short}[r1]
15855 \layout Standard
15856
15857
15858 \size footnotesize 
15859 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
15860  r0]- 0x3 {short}
15861 \layout Standard
15862
15863
15864 \size footnotesize 
15865 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
15866 int}[r7 r0]
15867 \layout Standard
15868
15869
15870 \size footnotesize 
15871 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
15872  + 0x1 {short}
15873 \layout Standard
15874
15875
15876 \size footnotesize 
15877 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
15878  r6]- 0x1 {short}
15879 \layout Standard
15880
15881
15882 \size footnotesize 
15883 Sample.c(19:38:47:1) goto _forcond_0($4)
15884 \layout Standard
15885
15886
15887 \size footnotesize 
15888 Sample.c(19:39:48:0)_forbreak_0($7) :
15889 \layout Standard
15890
15891
15892 \size footnotesize 
15893 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
15894  + ITemp11 [lr19:40]{short}[r3]
15895 \layout Standard
15896
15897
15898 \size footnotesize 
15899 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
15900 \layout Standard
15901
15902
15903 \size footnotesize 
15904 Sample.c(20:42:51:0)_return($8) :
15905 \layout Standard
15906
15907
15908 \size footnotesize 
15909 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
15910 \size default 
15911
15912 \newline 
15913
15914 \newline 
15915 Finally the code generated for this function:
15916 \newline 
15917
15918 \layout Standard
15919
15920
15921 \size footnotesize 
15922 .area DSEG (DATA)
15923 \layout Standard
15924
15925
15926 \size footnotesize 
15927 _p::
15928 \layout Standard
15929
15930
15931 \size footnotesize 
15932 \SpecialChar ~
15933 \SpecialChar ~
15934 .ds 2
15935 \layout Standard
15936
15937
15938 \size footnotesize 
15939 _gint::
15940 \layout Standard
15941
15942
15943 \size footnotesize 
15944 \SpecialChar ~
15945 \SpecialChar ~
15946 .ds 2
15947 \layout Standard
15948
15949
15950 \size footnotesize 
15951 ; sample.c 5
15952 \layout Standard
15953
15954
15955 \size footnotesize 
15956 ; ----------------------------------------------
15957 \layout Standard
15958
15959
15960 \size footnotesize 
15961 ; function function
15962 \layout Standard
15963
15964
15965 \size footnotesize 
15966 ; ----------------------------------------------
15967 \layout Standard
15968
15969
15970 \size footnotesize 
15971 _function:
15972 \layout Standard
15973
15974
15975 \size footnotesize 
15976 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
15977 \layout Standard
15978
15979
15980 \size footnotesize 
15981 \SpecialChar ~
15982 \SpecialChar ~
15983 mov r2,dpl
15984 \layout Standard
15985
15986
15987 \size footnotesize 
15988 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
15989 \layout Standard
15990
15991
15992 \size footnotesize 
15993 \SpecialChar ~
15994 \SpecialChar ~
15995 mov ar0,r2
15996 \layout Standard
15997
15998
15999 \size footnotesize 
16000 ;_whilecontinue_0($1) :
16001 \layout Standard
16002
16003
16004 \size footnotesize 
16005 00101$:
16006 \layout Standard
16007
16008
16009 \size footnotesize 
16010 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
16011 \layout Standard
16012
16013
16014 \size footnotesize 
16015 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
16016 \layout Standard
16017
16018
16019 \size footnotesize 
16020 \SpecialChar ~
16021 \SpecialChar ~
16022 mov ar2,@r0
16023 \layout Standard
16024
16025
16026 \size footnotesize 
16027 \SpecialChar ~
16028 \SpecialChar ~
16029 inc r0
16030 \layout Standard
16031
16032
16033 \size footnotesize 
16034 \SpecialChar ~
16035 \SpecialChar ~
16036 mov ar3,@r0
16037 \layout Standard
16038
16039
16040 \size footnotesize 
16041 \SpecialChar ~
16042 \SpecialChar ~
16043 dec r0
16044 \layout Standard
16045
16046
16047 \size footnotesize 
16048 \SpecialChar ~
16049 \SpecialChar ~
16050 mov a,r2
16051 \layout Standard
16052
16053
16054 \size footnotesize 
16055 \SpecialChar ~
16056 \SpecialChar ~
16057 orl a,r3
16058 \layout Standard
16059
16060
16061 \size footnotesize 
16062 \SpecialChar ~
16063 \SpecialChar ~
16064 jz 00103$
16065 \layout Standard
16066
16067
16068 \size footnotesize 
16069 00114$:
16070 \layout Standard
16071
16072
16073 \size footnotesize 
16074 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
16075 \layout Standard
16076
16077
16078 \size footnotesize 
16079 \SpecialChar ~
16080 \SpecialChar ~
16081 mov dpl,_p
16082 \layout Standard
16083
16084
16085 \size footnotesize 
16086 \SpecialChar ~
16087 \SpecialChar ~
16088 mov dph,(_p + 1)
16089 \layout Standard
16090
16091
16092 \size footnotesize 
16093 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
16094 \layout Standard
16095
16096
16097 \size footnotesize 
16098 \SpecialChar ~
16099 \SpecialChar ~
16100 mov a,#0x02
16101 \layout Standard
16102
16103
16104 \size footnotesize 
16105 \SpecialChar ~
16106 \SpecialChar ~
16107 add a,_p
16108 \layout Standard
16109
16110
16111 \size footnotesize 
16112 \SpecialChar ~
16113 \SpecialChar ~
16114 mov _p,a
16115 \layout Standard
16116
16117
16118 \size footnotesize 
16119 \SpecialChar ~
16120 \SpecialChar ~
16121 clr a
16122 \layout Standard
16123
16124
16125 \size footnotesize 
16126 \SpecialChar ~
16127 \SpecialChar ~
16128 addc a,(_p + 1)
16129 \layout Standard
16130
16131
16132 \size footnotesize 
16133 \SpecialChar ~
16134 \SpecialChar ~
16135 mov (_p + 1),a
16136 \layout Standard
16137
16138
16139 \size footnotesize 
16140 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
16141 \layout Standard
16142
16143
16144 \size footnotesize 
16145 \SpecialChar ~
16146 \SpecialChar ~
16147 movx a,@dptr
16148 \layout Standard
16149
16150
16151 \size footnotesize 
16152 \SpecialChar ~
16153 \SpecialChar ~
16154 mov r2,a
16155 \layout Standard
16156
16157
16158 \size footnotesize 
16159 \SpecialChar ~
16160 \SpecialChar ~
16161 inc dptr
16162 \layout Standard
16163
16164
16165 \size footnotesize 
16166 \SpecialChar ~
16167 \SpecialChar ~
16168 movx a,@dptr
16169 \layout Standard
16170
16171
16172 \size footnotesize 
16173 \SpecialChar ~
16174 \SpecialChar ~
16175 mov r3,a
16176 \layout Standard
16177
16178
16179 \size footnotesize 
16180 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
16181 \layout Standard
16182
16183
16184 \size footnotesize 
16185 \SpecialChar ~
16186 \SpecialChar ~
16187 mov @r0,ar2
16188 \layout Standard
16189
16190
16191 \size footnotesize 
16192 \SpecialChar ~
16193 \SpecialChar ~
16194 inc r0
16195 \layout Standard
16196
16197
16198 \size footnotesize 
16199 \SpecialChar ~
16200 \SpecialChar ~
16201 mov @r0,ar3
16202 \layout Standard
16203
16204
16205 \size footnotesize 
16206 ; iTemp6 [lr5:16]{_near * int}[r0] = 
16207 \layout Standard
16208
16209
16210 \size footnotesize 
16211 ; iTemp6 [lr5:16]{_near * int}[r0] + 
16212 \layout Standard
16213
16214
16215 \size footnotesize 
16216 ; 0x2 {short}
16217 \layout Standard
16218
16219
16220 \size footnotesize 
16221 \SpecialChar ~
16222 \SpecialChar ~
16223 inc r0
16224 \layout Standard
16225
16226
16227 \size footnotesize 
16228 ; goto _whilecontinue_0($1)
16229 \layout Standard
16230
16231
16232 \size footnotesize 
16233 \SpecialChar ~
16234 \SpecialChar ~
16235 sjmp 00101$
16236 \layout Standard
16237
16238
16239 \size footnotesize 
16240 ; _whilebreak_0($3) :
16241 \layout Standard
16242
16243
16244 \size footnotesize 
16245 00103$:
16246 \layout Standard
16247
16248
16249 \size footnotesize 
16250 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
16251 \layout Standard
16252
16253
16254 \size footnotesize 
16255 \SpecialChar ~
16256 \SpecialChar ~
16257 mov r2,#0x00
16258 \layout Standard
16259
16260
16261 \size footnotesize 
16262 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
16263 \layout Standard
16264
16265
16266 \size footnotesize 
16267 \SpecialChar ~
16268 \SpecialChar ~
16269 mov r3,#0x00
16270 \layout Standard
16271
16272
16273 \size footnotesize 
16274 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
16275 \layout Standard
16276
16277
16278 \size footnotesize 
16279 \SpecialChar ~
16280 \SpecialChar ~
16281 mov r4,#0x00
16282 \layout Standard
16283
16284
16285 \size footnotesize 
16286 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
16287 \layout Standard
16288
16289
16290 \size footnotesize 
16291 \SpecialChar ~
16292 \SpecialChar ~
16293 mov r5,#0x0A
16294 \layout Standard
16295
16296
16297 \size footnotesize 
16298 \SpecialChar ~
16299 \SpecialChar ~
16300 mov r6,#0x00
16301 \layout Standard
16302
16303
16304 \size footnotesize 
16305 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
16306 \layout Standard
16307
16308
16309 \size footnotesize 
16310 \SpecialChar ~
16311 \SpecialChar ~
16312 mov r7,#0x1E
16313 \layout Standard
16314
16315
16316 \size footnotesize 
16317 \SpecialChar ~
16318 \SpecialChar ~
16319 mov r0,#0x00
16320 \layout Standard
16321
16322
16323 \size footnotesize 
16324 ; _forcond_0($4) :
16325 \layout Standard
16326
16327
16328 \size footnotesize 
16329 00104$:
16330 \layout Standard
16331
16332
16333 \size footnotesize 
16334 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
16335 \layout Standard
16336
16337
16338 \size footnotesize 
16339 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
16340 \layout Standard
16341
16342
16343 \size footnotesize 
16344 \SpecialChar ~
16345 \SpecialChar ~
16346 clr c
16347 \layout Standard
16348
16349
16350 \size footnotesize 
16351 \SpecialChar ~
16352 \SpecialChar ~
16353 mov a,r4
16354 \layout Standard
16355
16356
16357 \size footnotesize 
16358 \SpecialChar ~
16359 \SpecialChar ~
16360 xrl a,#0x80
16361 \layout Standard
16362
16363
16364 \size footnotesize 
16365 \SpecialChar ~
16366 \SpecialChar ~
16367 subb a,#0x8a
16368 \layout Standard
16369
16370
16371 \size footnotesize 
16372 \SpecialChar ~
16373 \SpecialChar ~
16374 jnc 00107$
16375 \layout Standard
16376
16377
16378 \size footnotesize 
16379 00115$:
16380 \layout Standard
16381
16382
16383 \size footnotesize 
16384 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
16385 \layout Standard
16386
16387
16388 \size footnotesize 
16389 ; iTemp21 [lr21:38]{short}[r4]
16390 \layout Standard
16391
16392
16393 \size footnotesize 
16394 \SpecialChar ~
16395 \SpecialChar ~
16396 mov a,r4
16397 \layout Standard
16398
16399
16400 \size footnotesize 
16401 \SpecialChar ~
16402 \SpecialChar ~
16403 add a,r2
16404 \layout Standard
16405
16406
16407 \size footnotesize 
16408 \SpecialChar ~
16409 \SpecialChar ~
16410 mov r2,a
16411 \layout Standard
16412
16413
16414 \size footnotesize 
16415 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
16416 \layout Standard
16417
16418
16419 \size footnotesize 
16420 \SpecialChar ~
16421 \SpecialChar ~
16422 mov b,#0x03
16423 \layout Standard
16424
16425
16426 \size footnotesize 
16427 \SpecialChar ~
16428 \SpecialChar ~
16429 mov a,r4
16430 \layout Standard
16431
16432
16433 \size footnotesize 
16434 \SpecialChar ~
16435 \SpecialChar ~
16436 mul ab
16437 \layout Standard
16438
16439
16440 \size footnotesize 
16441 \SpecialChar ~
16442 \SpecialChar ~
16443 mov r1,a
16444 \layout Standard
16445
16446
16447 \size footnotesize 
16448 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
16449 \layout Standard
16450
16451
16452 \size footnotesize 
16453 ; iTemp15 [lr29:30]{short}[r1]
16454 \layout Standard
16455
16456
16457 \size footnotesize 
16458 \SpecialChar ~
16459 \SpecialChar ~
16460 add a,r3
16461 \layout Standard
16462
16463
16464 \size footnotesize 
16465 \SpecialChar ~
16466 \SpecialChar ~
16467 mov r3,a
16468 \layout Standard
16469
16470
16471 \size footnotesize 
16472 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
16473 \layout Standard
16474
16475
16476 \size footnotesize 
16477 \SpecialChar ~
16478 \SpecialChar ~
16479 mov a,r7
16480 \layout Standard
16481
16482
16483 \size footnotesize 
16484 \SpecialChar ~
16485 \SpecialChar ~
16486 add a,#0xfd
16487 \layout Standard
16488
16489
16490 \size footnotesize 
16491 \SpecialChar ~
16492 \SpecialChar ~
16493 mov r7,a
16494 \layout Standard
16495
16496
16497 \size footnotesize 
16498 \SpecialChar ~
16499 \SpecialChar ~
16500 mov a,r0
16501 \layout Standard
16502
16503
16504 \size footnotesize 
16505 \SpecialChar ~
16506 \SpecialChar ~
16507 addc a,#0xff
16508 \layout Standard
16509
16510
16511 \size footnotesize 
16512 \SpecialChar ~
16513 \SpecialChar ~
16514 mov r0,a
16515 \layout Standard
16516
16517
16518 \size footnotesize 
16519 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
16520 \layout Standard
16521
16522
16523 \size footnotesize 
16524 \SpecialChar ~
16525 \SpecialChar ~
16526 mov a,r7
16527 \layout Standard
16528
16529
16530 \size footnotesize 
16531 \SpecialChar ~
16532 \SpecialChar ~
16533 add a,_gint
16534 \layout Standard
16535
16536
16537 \size footnotesize 
16538 \SpecialChar ~
16539 \SpecialChar ~
16540 mov _gint,a
16541 \layout Standard
16542
16543
16544 \size footnotesize 
16545 \SpecialChar ~
16546 \SpecialChar ~
16547 mov a,r0
16548 \layout Standard
16549
16550
16551 \size footnotesize 
16552 \SpecialChar ~
16553 \SpecialChar ~
16554 addc a,(_gint + 1)
16555 \layout Standard
16556
16557
16558 \size footnotesize 
16559 \SpecialChar ~
16560 \SpecialChar ~
16561 mov (_gint + 1),a
16562 \layout Standard
16563
16564
16565 \size footnotesize 
16566 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
16567 \layout Standard
16568
16569
16570 \size footnotesize 
16571 \SpecialChar ~
16572 \SpecialChar ~
16573 inc r4
16574 \layout Standard
16575
16576
16577 \size footnotesize 
16578 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
16579 \layout Standard
16580
16581
16582 \size footnotesize 
16583 \SpecialChar ~
16584 \SpecialChar ~
16585 dec r5
16586 \layout Standard
16587
16588
16589 \size footnotesize 
16590 \SpecialChar ~
16591 \SpecialChar ~
16592 cjne r5,#0xff,00104$
16593 \layout Standard
16594
16595
16596 \size footnotesize 
16597 \SpecialChar ~
16598 \SpecialChar ~
16599 dec r6
16600 \layout Standard
16601
16602
16603 \size footnotesize 
16604 ; goto _forcond_0($4)
16605 \layout Standard
16606
16607
16608 \size footnotesize 
16609 \SpecialChar ~
16610 \SpecialChar ~
16611 sjmp 00104$
16612 \layout Standard
16613
16614
16615 \size footnotesize 
16616 ; _forbreak_0($7) :
16617 \layout Standard
16618
16619
16620 \size footnotesize 
16621 00107$:
16622 \layout Standard
16623
16624
16625 \size footnotesize 
16626 ; ret iTemp24 [lr40:41]{short}
16627 \layout Standard
16628
16629
16630 \size footnotesize 
16631 \SpecialChar ~
16632 \SpecialChar ~
16633 mov a,r3
16634 \layout Standard
16635
16636
16637 \size footnotesize 
16638 \SpecialChar ~
16639 \SpecialChar ~
16640 add a,r2
16641 \layout Standard
16642
16643
16644 \size footnotesize 
16645 \SpecialChar ~
16646 \SpecialChar ~
16647 mov dpl,a
16648 \layout Standard
16649
16650
16651 \size footnotesize 
16652 ; _return($8) :
16653 \layout Standard
16654
16655
16656 \size footnotesize 
16657 00108$:
16658 \layout Standard
16659
16660
16661 \size footnotesize 
16662 \SpecialChar ~
16663 \SpecialChar ~
16664 ret
16665 \newline 
16666
16667 \layout Subsection
16668
16669 A few words about basic block successors, predecessors and dominators
16670 \layout Standard
16671
16672 Successors are basic blocks
16673 \begin_inset LatexCommand \index{Basic blocks}
16674
16675 \end_inset 
16676
16677  that might execute after this basic block.
16678 \newline 
16679 Predecessors are basic blocks that might execute before reaching this basic
16680  block.
16681 \newline 
16682 Dominators are basic blocks that WILL execute before reaching this basic
16683  block.
16684 \newline 
16685
16686 \layout Standard
16687
16688 [basic block 1]
16689 \layout Standard
16690
16691 if (something)
16692 \layout Standard
16693
16694 [basic block 2]
16695 \layout Standard
16696
16697 else
16698 \layout Standard
16699
16700 [basic block 3]
16701 \layout Standard
16702
16703 [basic block 4]
16704 \newline 
16705
16706 \layout Standard
16707
16708 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
16709 \layout Standard
16710
16711 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
16712 \layout Standard
16713
16714 c) domVect of [BB4] = BB1 ...
16715  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
16716  was executed.
16717 \layout Section
16718
16719 Acknowledgments
16720 \layout Standard
16721
16722
16723 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
16724
16725 \end_inset 
16726
16727
16728 \newline 
16729
16730 \newline 
16731
16732 \emph on 
16733 Thanks to all the other volunteer developers who have helped with coding,
16734  testing, web-page creation, distribution sets, etc.
16735  You know who you are :-)
16736 \emph default 
16737
16738 \newline 
16739
16740 \layout Standard
16741
16742 This document was initially written by Sandeep Dutta
16743 \layout Standard
16744
16745 All product names mentioned herein may be trademarks
16746 \begin_inset LatexCommand \index{Trademarks}
16747
16748 \end_inset 
16749
16750  of their respective companies.
16751  
16752 \layout Section
16753
16754 Alphabetical index
16755 \layout Standard
16756
16757 To avoid confusion, the installation and building options for sdcc itself
16758  (chapter 2) are not part of the index.
16759 \layout Standard
16760
16761
16762 \begin_inset LatexCommand \printindex{}
16763
16764 \end_inset 
16765
16766
16767 \the_end