752113cade8fa3eb42d90812ea2ef3847b4b9b5a
[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 book
4 \begin_preamble
5
6
7 \usepackage[
8   pdftitle={SDCC Compiler User Guide},
9   pdfauthor={SDCC development team},
10   pdfsubject={installation, user manual},
11   pdfkeywords={8032, 8051, ansi, c, compiler, CPU, DS390, 
12                embedded, GPL, HC08, manual, mcs51, PIC, Z80},
13   colorlinks=true,
14   linkcolor=blue] {hyperref}
15 %
16 \sloppy
17 \tolerance=500          
18 \emergencystretch=30pt 
19 %
20 \date{}
21 \end_preamble
22 \language english
23 \inputencoding default
24 \fontscheme pslatex
25 \graphics default
26 \paperfontsize default
27 \spacing single 
28 \papersize letterpaper
29 \paperpackage a4
30 \use_geometry 1
31 \use_amsmath 0
32 \use_natbib 0
33 \use_numerical_citations 0
34 \paperorientation portrait
35 \leftmargin 30mm
36 \topmargin 20mm
37 \rightmargin 25mm
38 \bottommargin 20mm
39 \secnumdepth 3
40 \tocdepth 3
41 \paragraph_separation indent
42 \defskip medskip
43 \quotes_language swedish
44 \quotes_times 2
45 \papercolumns 1
46 \papersides 1
47 \paperpagestyle fancy
48
49 \layout Comment
50
51 Please note: double dashed longoptions (e.g.
52  --version) are written this way: -
53 \begin_inset ERT
54 status Collapsed
55
56 \layout Standard
57
58 \backslash 
59 /
60 \end_inset 
61
62 -
63 \layout Comment
64
65 Two resp.
66  three consecutive dashes simply result in a long resp.
67  extra long dash.
68 \layout Comment
69
70 Architecture specific stuff (like memory models, code examples) should maybe
71  later go
72 \layout Comment
73
74 into seperate sections/chapters/appendices (it is hard to document PIC or
75  Z80 in 
76 \layout Comment
77
78 a 8051 centered document) - for now simply add.
79 \layout Title
80
81 SDCC Compiler User Guide
82 \layout Date
83
84
85 \size normal 
86 SDCC 2.4.7
87 \size footnotesize 
88
89 \newline 
90 $Date$ 
91 \newline 
92 $Revision$
93 \layout Comment
94
95 The above strings enclosed in $ are automatically updated by cvs
96 \layout Standard
97
98
99 \begin_inset LatexCommand \tableofcontents{}
100
101 \end_inset 
102
103
104 \layout Chapter
105
106 Introduction
107 \layout Section
108
109 About SDCC
110 \layout Standard
111
112
113 \series bold 
114 SDCC
115 \series default 
116  (
117 \emph on 
118 S
119 \emph default 
120 mall 
121 \emph on 
122 D
123 \emph default 
124 evice 
125 \emph on 
126 C
127 \emph default 
128  
129 \emph on 
130 C
131 \emph default 
132 ompiler) is an open source, retargettable, optimizing ANSI-C compiler by
133  
134 \series bold 
135 Sandeep Dutta
136 \series default 
137  designed for 8 bit Microprocessors.
138  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
139  8051, 8052
140 \begin_inset LatexCommand \index{8031, 8032, 8051, 8052, mcs51 CPU}
141
142 \end_inset 
143
144 , etc.), Dallas DS80C390 variants, Motorola HC08 and Zilog Z80 based MCUs.
145  It can be retargetted for other microprocessors, support for Microchip
146  PIC, Atmel AVR is under development.
147  The entire source code for the compiler is distributed under GPL.
148  SDCC uses ASXXXX
149 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
150
151 \end_inset 
152
153  & ASLINK
154 \begin_inset LatexCommand \index{aslink}
155
156 \end_inset 
157
158 , an open source retargettable assembler & linker.
159  SDCC has extensive language extensions suitable for utilizing various microcont
160 rollers and underlying hardware effectively.
161  
162 \newline 
163
164 \newline 
165 In addition to the MCU specific optimizations SDCC also does a host of standard
166  optimizations like:
167 \layout Itemize
168
169 global sub expression elimination, 
170 \layout Itemize
171
172 loop optimizations (loop invariant, strength reduction of induction variables
173  and loop reversing), 
174 \layout Itemize
175
176 constant folding & propagation, 
177 \layout Itemize
178
179 copy propagation, 
180 \layout Itemize
181
182 dead code elimination 
183 \layout Itemize
184
185 jump tables for 
186 \emph on 
187 switch
188 \emph default 
189  statements.
190 \layout Standard
191
192 For the back-end SDCC uses a global register allocation scheme which should
193  be well suited for other 8 bit MCUs.
194  
195 \newline 
196
197 \newline 
198 The peep hole optimizer uses a rule based substitution mechanism which is
199  MCU independent.
200  
201 \newline 
202
203 \newline 
204 Supported data-types are:
205 \layout Itemize
206
207 char (8 bits, 1 byte), 
208 \layout Itemize
209
210 short and int (16 bits, 2 bytes), 
211 \layout Itemize
212
213 long (32 bit, 4 bytes)
214 \layout Itemize
215
216 float (4 byte IEEE).
217  
218 \layout Standard
219
220 The compiler also allows 
221 \emph on 
222 inline assembler code
223 \emph default 
224  to be embedded anywhere in a function.
225  In addition, routines developed in assembly can also be called.
226 \newline 
227
228 \newline 
229 SDCC also provides an option (-
230 \begin_inset ERT
231 status Collapsed
232
233 \layout Standard
234
235 \backslash 
236 /
237 \end_inset 
238
239 -cyclomatic) to report the relative complexity of a function.
240  These functions can then be further optimized, or hand coded in assembly
241  if needed.
242  
243 \newline 
244
245 \newline 
246 SDCC also comes with a companion source level debugger SDCDB, the debugger
247  currently uses ucSim a freeware simulator for 8051 and other micro-controllers.
248  
249 \newline 
250
251 \newline 
252 The latest version can be downloaded from 
253 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
254
255 \end_inset 
256
257 .
258
259 \series bold 
260  
261 \series default 
262 \emph on 
263 Please note: the compiler will probably always be some steps ahead of this
264  documentation
265 \series bold 
266 \emph default 
267
268 \begin_inset LatexCommand \index{Status of documentation}
269
270 \end_inset 
271
272
273 \begin_inset Foot
274 collapsed false
275
276 \layout Standard
277
278 Obviously this has pros and cons
279 \end_inset 
280
281 .
282 \layout Section
283
284 Open Source
285 \layout Standard
286
287 All packages used in this compiler system are 
288 \emph on 
289 open source
290 \emph default 
291  and 
292 \emph on 
293 freeware
294 \emph default 
295 ; source code for all the sub-packages (pre-processor, assemblers, linkers
296  etc) is distributed with the package.
297  This documentation is maintained using a freeware word processor (LyX).
298 \newline 
299 This program is free software; you can redistribute it and/or modify it
300  under the terms of the GNU General Public License
301 \begin_inset LatexCommand \index{GNU General Public License, GPL}
302
303 \end_inset 
304
305  as published by the Free Software Foundation; either version 2, or (at
306  your option) any later version.
307  This program is distributed in the hope that it will be useful, but WITHOUT
308  ANY WARRANTY; without even the implied warranty
309 \begin_inset LatexCommand \index{warranty}
310
311 \end_inset 
312
313  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
314  See the GNU General Public License for more details.
315  You should have received a copy of the GNU General Public License along
316  with this program; if not, write to the Free Software Foundation, 59 Temple
317  Place - Suite 330, Boston, MA 02111-1307, USA.
318  In other words, you are welcome to use, share and improve this program.
319  You are forbidden to forbid anyone else to use, share and improve what
320  you give them.
321  Help stamp out software-hoarding! 
322 \layout Section
323
324 Typographic conventions
325 \begin_inset LatexCommand \index{Typographic conventions}
326
327 \end_inset 
328
329
330 \layout Standard
331
332 Throughout this manual, we will use the following convention.
333  Commands you have to type in are printed in 
334 \family sans 
335 \series bold 
336 "sans serif"
337 \series default 
338 .
339
340 \family default 
341  Code samples are printed in 
342 \family typewriter 
343 typewriter font.
344
345 \family default 
346  Interesting items and new terms are printed in 
347 \emph on 
348 italic.
349 \layout Section
350
351 Compatibility with previous versions
352 \layout Standard
353
354 This version has numerous bug fixes compared with the previous version.
355  But we also introduced some incompatibilities with older versions.
356  Not just for the fun of it, but to make the compiler more stable, efficient
357  and ANSI compliant
358 \begin_inset LatexCommand \index{ANSI-compliance}
359
360 \end_inset 
361
362  (see section 
363 \begin_inset LatexCommand \ref{sub:ANSI-Compliance}
364
365 \end_inset 
366
367  for ANSI-Compliance).
368  
369 \newline 
370
371 \layout Itemize
372
373 short is now equivalent to int (16 bits), it used to be equivalent to char
374  (8 bits) which is not ANSI compliant
375 \layout Itemize
376
377 the default directory for gcc-builds where include, library and documentation
378  files are stored is now in /usr/local/share
379 \layout Itemize
380
381 char type parameters to vararg functions are casted to int unless explicitly
382  casted, e.g.: 
383 \newline 
384
385 \family typewriter 
386 \SpecialChar ~
387 \SpecialChar ~
388 char a=3;
389 \newline 
390 \SpecialChar ~
391 \SpecialChar ~
392 printf ("%d %c
393 \backslash 
394 n", a, (char)a);
395 \family default 
396
397 \newline 
398  will push a as an int and as a char resp.
399 \layout Itemize
400
401 option -
402 \begin_inset ERT
403 status Collapsed
404
405 \layout Standard
406
407 \backslash 
408 /
409 \end_inset 
410
411 -regextend has been removed
412 \layout Itemize
413
414 option -
415 \begin_inset ERT
416 status Collapsed
417
418 \layout Standard
419
420 \backslash 
421 /
422 \end_inset 
423
424 -noregparms has been removed
425 \layout Itemize
426
427 option -
428 \begin_inset ERT
429 status Collapsed
430
431 \layout Standard
432
433 \backslash 
434 /
435 \end_inset 
436
437 -stack-after-data has been removed
438 \layout Standard
439
440
441 \emph on 
442 <pending: more incompatibilities?>
443 \layout Section
444
445 System Requirements
446 \layout Standard
447
448 What do you need before you start installation of SDCC? A computer, and
449  a desire to compute.
450  The preferred method of installation is to compile SDCC from source using
451  GNU gcc and make.
452  For Windows some pre-compiled binary distributions are available for your
453  convenience.
454  You should have some experience with command line tools and compiler use.
455 \layout Section
456
457 Other Resources
458 \layout Standard
459
460 The SDCC home page at 
461 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
462
463 \end_inset 
464
465  is a great place to find distribution sets.
466  You can also find links to the user mailing lists that offer help or discuss
467  SDCC with other SDCC users.
468  Web links to other SDCC related sites can also be found here.
469  This document can be found in the DOC directory of the source package as
470  a text or HTML file.
471  A pdf version of this document is available at 
472 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
473
474 \end_inset 
475
476 .
477  Some of the other tools (simulator and assembler) included with SDCC contain
478  their own documentation and can be found in the source distribution.
479  If you want the latest unreleased software, the complete source package
480  is available directly by anonymous CVS on cvs.sdcc.sourceforge.net.
481 \layout Section
482
483 Wishes for the future
484 \layout Standard
485
486 There are (and always will be) some things that could be done.
487  Here are some I can think of:
488 \newline 
489
490 \layout Standard
491
492
493 \family typewriter 
494 char KernelFunction3(char p) at 0x340;
495 \newline 
496
497 \layout Standard
498
499
500 \family typewriter 
501 code banking
502 \begin_inset LatexCommand \index{code banking (not supported)}
503
504 \end_inset 
505
506  support for mcs51
507 \newline 
508
509 \newline 
510
511 \family default 
512 If you can think of some more, please see the section 
513 \begin_inset LatexCommand \ref{sub:Requesting-Features}
514
515 \end_inset 
516
517  about filing feature requests
518 \begin_inset LatexCommand \index{Requesting features}
519
520 \end_inset 
521
522
523 \begin_inset LatexCommand \index{Feature request}
524
525 \end_inset 
526
527 .
528 \newline 
529
530 \layout Chapter
531
532 Installing SDCC
533 \begin_inset LatexCommand \index{Installation}
534
535 \end_inset 
536
537
538 \layout Standard
539
540 For most users it is sufficient to skip to either section 
541 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
542
543 \end_inset 
544
545  or section 
546 \begin_inset LatexCommand \ref{sub:Windows-Install}
547
548 \end_inset 
549
550 .
551  More detailled instructions follow below.
552 \layout Section
553
554 Configure Options
555 \begin_inset LatexCommand \index{Options SDCC configuration}
556
557 \end_inset 
558
559
560 \layout Standard
561
562 The install paths, search paths and other options are defined when running
563  'configure'.
564  The defaults can be overridden by:
565 \layout List
566 \labelwidthstring 00.00.0000
567
568 -
569 \begin_inset ERT
570 status Collapsed
571
572 \layout Standard
573
574 \backslash 
575 /
576 \end_inset 
577
578 -prefix see table below
579 \layout List
580 \labelwidthstring 00.00.0000
581
582 -
583 \begin_inset ERT
584 status Collapsed
585
586 \layout Standard
587
588 \backslash 
589 /
590 \end_inset 
591
592 -exec_prefix see table below
593 \layout List
594 \labelwidthstring 00.00.0000
595
596 -
597 \begin_inset ERT
598 status Collapsed
599
600 \layout Standard
601
602 \backslash 
603 /
604 \end_inset 
605
606 -bindir see table below
607 \layout List
608 \labelwidthstring 00.00.0000
609
610 -
611 \begin_inset ERT
612 status Collapsed
613
614 \layout Standard
615
616 \backslash 
617 /
618 \end_inset 
619
620 -datadir see table below
621 \layout List
622 \labelwidthstring 00.00.0000
623
624 docdir environment variable, see table below
625 \layout List
626 \labelwidthstring 00.00.0000
627
628 include_dir_suffix environment variable, see table below
629 \layout List
630 \labelwidthstring 00.00.0000
631
632 lib_dir_suffix environment variable, see table below
633 \layout List
634 \labelwidthstring 00.00.0000
635
636 sdccconf_h_dir_separator environment variable, either / or 
637 \backslash 
638
639 \backslash 
640  makes sense here.
641  This character will only be used in sdccconf.h; don't forget it's a C-header,
642  therefore a double-backslash is needed there.
643 \layout List
644 \labelwidthstring 00.00.0000
645
646 -
647 \begin_inset ERT
648 status Collapsed
649
650 \layout Standard
651
652 \backslash 
653 /
654 \end_inset 
655
656 -disable-mcs51-port Excludes the Intel mcs51 port
657 \layout List
658 \labelwidthstring 00.00.0000
659
660 -
661 \begin_inset ERT
662 status Collapsed
663
664 \layout Standard
665
666 \backslash 
667 /
668 \end_inset 
669
670 -disable-gbz80-port Excludes the Gameboy gbz80 port
671 \layout List
672 \labelwidthstring 00.00.0000
673
674 -
675 \begin_inset ERT
676 status Collapsed
677
678 \layout Standard
679
680 \backslash 
681 /
682 \end_inset 
683
684 -disable-z80-port Excludes the z80 port
685 \layout List
686 \labelwidthstring 00.00.0000
687
688 -
689 \begin_inset ERT
690 status Collapsed
691
692 \layout Standard
693
694 \backslash 
695 /
696 \end_inset 
697
698 -disable-avr-port Excludes the AVR port
699 \layout List
700 \labelwidthstring 00.00.0000
701
702 -
703 \begin_inset ERT
704 status Collapsed
705
706 \layout Standard
707
708 \backslash 
709 /
710 \end_inset 
711
712 -disable-ds390-port Excludes the DS390 port
713 \layout List
714 \labelwidthstring 00.00.0000
715
716 -
717 \begin_inset ERT
718 status Collapsed
719
720 \layout Standard
721
722 \backslash 
723 /
724 \end_inset 
725
726 -disable-hc08-port Excludes the HC08 port
727 \layout List
728 \labelwidthstring 00.00.0000
729
730 -
731 \begin_inset ERT
732 status Collapsed
733
734 \layout Standard
735
736 \backslash 
737 /
738 \end_inset 
739
740 -disable-pic-port Excludes the PIC port
741 \layout List
742 \labelwidthstring 00.00.0000
743
744 -
745 \begin_inset ERT
746 status Collapsed
747
748 \layout Standard
749
750 \backslash 
751 /
752 \end_inset 
753
754 -disable-xa51-port Excludes the XA51 port
755 \layout List
756 \labelwidthstring 00.00.0000
757
758 -
759 \begin_inset ERT
760 status Collapsed
761
762 \layout Standard
763
764 \backslash 
765 /
766 \end_inset 
767
768 -disable-ucsim Disables configuring and building of ucsim
769 \layout List
770 \labelwidthstring 00.00.0000
771
772 -
773 \begin_inset ERT
774 status Collapsed
775
776 \layout Standard
777
778 \backslash 
779 /
780 \end_inset 
781
782 -disable-device-lib-build Disables automatically building device libraries
783 \layout List
784 \labelwidthstring 00.00.0000
785
786 -
787 \begin_inset ERT
788 status Collapsed
789
790 \layout Standard
791
792 \backslash 
793 /
794 \end_inset 
795
796 -disable-packihx Disables building packihx
797 \layout List
798 \labelwidthstring 00.00.0000
799
800 -
801 \begin_inset ERT
802 status Collapsed
803
804 \layout Standard
805
806 \backslash 
807 /
808 \end_inset 
809
810 -enable-libgc Use the Bohem memory allocator.
811  Lower runtime footprint.
812 \layout Standard
813
814 Furthermore the environment variables CC, CFLAGS, ...
815  the tools and their arguments can be influenced.
816  Please see `configure -
817 \begin_inset ERT
818 status Collapsed
819
820 \layout Standard
821
822 \backslash 
823 /
824 \end_inset 
825
826 -help` and the man/info pages of `configure` for details.
827 \newline 
828
829 \newline 
830 The names of the standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB,
831  STD_FP_LIB, STD_DS390_LIB, STD_XA51_LIB and the environment variables SDCC_DIR_
832 NAME, SDCC_INCLUDE_NAME, SDCC_LIB_NAME are defined by `configure` too.
833  At the moment it's not possible to change the default settings (it was
834  simply never required).
835 \newline 
836
837 \newline 
838 These configure options are compiled into the binaries, and can only be
839  changed by rerunning 'configure' and recompiling SDCC.
840  The configure options are written in 
841 \emph on 
842 italics
843 \emph default 
844  to distinguish them from run time environment variables (see section search
845  paths).
846 \newline 
847
848 \newline 
849 The settings for 
850 \begin_inset Quotes sld
851 \end_inset 
852
853 Win32 builds
854 \begin_inset Quotes srd
855 \end_inset 
856
857  are used by the SDCC team to build the official Win32 binaries.
858  The SDCC team uses Mingw32 to build the official Windows binaries, because
859  it's
860 \layout Enumerate
861
862 open source, 
863 \layout Enumerate
864
865 a gcc compiler and last but not least
866 \layout Enumerate
867
868 the binaries can be built by cross compiling on Sourceforge's compile farm.
869 \layout Standard
870
871 See the examples, how to pass the Win32 settings to 'configure'.
872  The other Win32 builds using Borland, VC or whatever don't use 'configure',
873  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
874  for Win32.
875 \newline 
876
877 \newline 
878 These defaults are:
879 \newline 
880
881 \layout Standard
882 \align center 
883
884 \begin_inset  Tabular
885 <lyxtabular version="3" rows="8" columns="3">
886 <features>
887 <column alignment="block" valignment="top" leftline="true" width="0in">
888 <column alignment="block" valignment="top" leftline="true" width="0in">
889 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
890 <row topline="true" bottomline="true">
891 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
892 \begin_inset Text
893
894 \layout Standard
895
896 Variable
897 \end_inset 
898 </cell>
899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
900 \begin_inset Text
901
902 \layout Standard
903
904 default
905 \end_inset 
906 </cell>
907 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
908 \begin_inset Text
909
910 \layout Standard
911
912 Win32 builds
913 \end_inset 
914 </cell>
915 </row>
916 <row topline="true">
917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
918 \begin_inset Text
919
920 \layout Standard
921
922
923 \emph on 
924 PREFIX
925 \end_inset 
926 </cell>
927 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
928 \begin_inset Text
929
930 \layout Standard
931
932 /usr/local
933 \end_inset 
934 </cell>
935 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
936 \begin_inset Text
937
938 \layout Standard
939
940
941 \backslash 
942 sdcc
943 \end_inset 
944 </cell>
945 </row>
946 <row topline="true">
947 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
948 \begin_inset Text
949
950 \layout Standard
951
952
953 \emph on 
954 EXEC_PREFIX
955 \end_inset 
956 </cell>
957 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
958 \begin_inset Text
959
960 \layout Standard
961
962
963 \emph on 
964 $PREFIX
965 \end_inset 
966 </cell>
967 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
968 \begin_inset Text
969
970 \layout Standard
971
972
973 \emph on 
974 $PREFIX
975 \end_inset 
976 </cell>
977 </row>
978 <row topline="true">
979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
980 \begin_inset Text
981
982 \layout Standard
983
984
985 \emph on 
986 BINDIR
987 \end_inset 
988 </cell>
989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
990 \begin_inset Text
991
992 \layout Standard
993
994
995 \emph on 
996 $EXECPREFIX
997 \emph default 
998 /bin
999 \end_inset 
1000 </cell>
1001 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1002 \begin_inset Text
1003
1004 \layout Standard
1005
1006
1007 \emph on 
1008 $EXECPREFIX
1009 \emph default 
1010
1011 \backslash 
1012 bin
1013 \end_inset 
1014 </cell>
1015 </row>
1016 <row topline="true">
1017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1018 \begin_inset Text
1019
1020 \layout Standard
1021
1022
1023 \emph on 
1024 DATADIR
1025 \end_inset 
1026 </cell>
1027 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1028 \begin_inset Text
1029
1030 \layout Standard
1031
1032
1033 \emph on 
1034 $PREFIX
1035 \emph default 
1036 /share
1037 \end_inset 
1038 </cell>
1039 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1040 \begin_inset Text
1041
1042 \layout Standard
1043
1044
1045 \emph on 
1046 $PREFIX
1047 \end_inset 
1048 </cell>
1049 </row>
1050 <row topline="true">
1051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1052 \begin_inset Text
1053
1054 \layout Standard
1055
1056
1057 \emph on 
1058 DOCDIR
1059 \end_inset 
1060 </cell>
1061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1062 \begin_inset Text
1063
1064 \layout Standard
1065
1066
1067 \emph on 
1068 $DATADIR
1069 \emph default 
1070 /sdcc/doc
1071 \end_inset 
1072 </cell>
1073 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1074 \begin_inset Text
1075
1076 \layout Standard
1077
1078
1079 \emph on 
1080 $DATADIR
1081 \emph default 
1082
1083 \backslash 
1084 doc
1085 \end_inset 
1086 </cell>
1087 </row>
1088 <row topline="true">
1089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1090 \begin_inset Text
1091
1092 \layout Standard
1093
1094
1095 \emph on 
1096 INCLUDE_DIR_SUFFIX
1097 \end_inset 
1098 </cell>
1099 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1100 \begin_inset Text
1101
1102 \layout Standard
1103
1104 sdcc/include
1105 \end_inset 
1106 </cell>
1107 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1108 \begin_inset Text
1109
1110 \layout Standard
1111
1112 include
1113 \end_inset 
1114 </cell>
1115 </row>
1116 <row topline="true" bottomline="true">
1117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1118 \begin_inset Text
1119
1120 \layout Standard
1121
1122
1123 \emph on 
1124 LIB_DIR_SUFFIX
1125 \end_inset 
1126 </cell>
1127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1128 \begin_inset Text
1129
1130 \layout Standard
1131
1132 sdcc/lib
1133 \end_inset 
1134 </cell>
1135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1136 \begin_inset Text
1137
1138 \layout Standard
1139
1140 lib
1141 \end_inset 
1142 </cell>
1143 </row>
1144 </lyxtabular>
1145
1146 \end_inset 
1147
1148
1149 \newline 
1150
1151 \layout Standard
1152 \noindent 
1153 'configure' also computes relative paths.
1154  This is needed for full relocatability of a binary package and to complete
1155  search paths (see section search paths below):
1156 \newline 
1157  
1158 \layout Standard
1159 \align center 
1160
1161 \begin_inset  Tabular
1162 <lyxtabular version="3" rows="4" columns="3">
1163 <features>
1164 <column alignment="block" valignment="top" leftline="true" width="0in">
1165 <column alignment="block" valignment="top" leftline="true" width="0in">
1166 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1167 <row topline="true" bottomline="true">
1168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1169 \begin_inset Text
1170
1171 \layout Standard
1172
1173 Variable (computed)
1174 \end_inset 
1175 </cell>
1176 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1177 \begin_inset Text
1178
1179 \layout Standard
1180
1181 default
1182 \end_inset 
1183 </cell>
1184 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1185 \begin_inset Text
1186
1187 \layout Standard
1188
1189 Win32 builds
1190 \end_inset 
1191 </cell>
1192 </row>
1193 <row topline="true" bottomline="true">
1194 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1195 \begin_inset Text
1196
1197 \layout Standard
1198
1199
1200 \emph on 
1201 BIN2DATA_DIR
1202 \end_inset 
1203 </cell>
1204 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1205 \begin_inset Text
1206
1207 \layout Standard
1208
1209 ../share
1210 \end_inset 
1211 </cell>
1212 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1213 \begin_inset Text
1214
1215 \layout Standard
1216
1217 ..
1218 \end_inset 
1219 </cell>
1220 </row>
1221 <row bottomline="true">
1222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1223 \begin_inset Text
1224
1225 \layout Standard
1226
1227
1228 \emph on 
1229 PREFIX2BIN_DIR
1230 \end_inset 
1231 </cell>
1232 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1233 \begin_inset Text
1234
1235 \layout Standard
1236
1237 bin
1238 \end_inset 
1239 </cell>
1240 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1241 \begin_inset Text
1242
1243 \layout Standard
1244
1245 bin
1246 \end_inset 
1247 </cell>
1248 </row>
1249 <row bottomline="true">
1250 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1251 \begin_inset Text
1252
1253 \layout Standard
1254
1255
1256 \emph on 
1257 PREFIX2DATA_DIR
1258 \end_inset 
1259 </cell>
1260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1261 \begin_inset Text
1262
1263 \layout Standard
1264
1265 share/sdcc
1266 \end_inset 
1267 </cell>
1268 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1269 \begin_inset Text
1270
1271 \layout Standard
1272
1273 \end_inset 
1274 </cell>
1275 </row>
1276 </lyxtabular>
1277
1278 \end_inset 
1279
1280
1281 \newline 
1282
1283 \layout Standard
1284 \noindent 
1285 Examples:
1286 \layout LyX-Code
1287
1288 ./configure
1289 \newline 
1290 ./configure -
1291 \begin_inset ERT
1292 status Collapsed
1293
1294 \layout Standard
1295
1296 \backslash 
1297 /
1298 \end_inset 
1299
1300 -prefix=
1301 \begin_inset Quotes srd
1302 \end_inset 
1303
1304 /usr/bin
1305 \begin_inset Quotes srd
1306 \end_inset 
1307
1308  -
1309 \begin_inset ERT
1310 status Collapsed
1311
1312 \layout Standard
1313
1314 \backslash 
1315 /
1316 \end_inset 
1317
1318 -datadir=
1319 \begin_inset Quotes srd
1320 \end_inset 
1321
1322 /usr/share
1323 \begin_inset Quotes srd
1324 \end_inset 
1325
1326
1327 \newline 
1328 ./configure -
1329 \begin_inset ERT
1330 status Collapsed
1331
1332 \layout Standard
1333
1334 \backslash 
1335 /
1336 \end_inset 
1337
1338 -disable-avr-port -
1339 \begin_inset ERT
1340 status Collapsed
1341
1342 \layout Standard
1343
1344 \backslash 
1345 /
1346 \end_inset 
1347
1348 -disable-xa51-port
1349 \layout Standard
1350
1351 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
1352 32'):
1353 \layout LyX-Code
1354
1355 ./configure 
1356 \backslash 
1357
1358 \newline 
1359 CC=
1360 \begin_inset Quotes srd
1361 \end_inset 
1362
1363 i586-mingw32msvc-gcc
1364 \begin_inset Quotes srd
1365 \end_inset 
1366
1367  CXX=
1368 \begin_inset Quotes srd
1369 \end_inset 
1370
1371 i586-mingw32msvc-g++
1372 \begin_inset Quotes srd
1373 \end_inset 
1374
1375  
1376 \backslash 
1377  
1378 \newline 
1379 RANLIB=
1380 \begin_inset Quotes srd
1381 \end_inset 
1382
1383 i586-mingw32msvc-ranlib
1384 \begin_inset Quotes srd
1385 \end_inset 
1386
1387  
1388 \backslash 
1389
1390 \newline 
1391 STRIP=
1392 \begin_inset Quotes srd
1393 \end_inset 
1394
1395 i586-mingw32msvc-strip
1396 \begin_inset Quotes srd
1397 \end_inset 
1398
1399  
1400 \backslash 
1401
1402 \newline 
1403 -
1404 \begin_inset ERT
1405 status Collapsed
1406
1407 \layout Standard
1408
1409 \backslash 
1410 /
1411 \end_inset 
1412
1413 -prefix=
1414 \begin_inset Quotes srd
1415 \end_inset 
1416
1417 /sdcc
1418 \begin_inset Quotes srd
1419 \end_inset 
1420
1421  
1422 \backslash 
1423
1424 \newline 
1425 -
1426 \begin_inset ERT
1427 status Collapsed
1428
1429 \layout Standard
1430
1431 \backslash 
1432 /
1433 \end_inset 
1434
1435 -datadir=
1436 \begin_inset Quotes srd
1437 \end_inset 
1438
1439 /sdcc
1440 \begin_inset Quotes srd
1441 \end_inset 
1442
1443  
1444 \backslash 
1445
1446 \newline 
1447 docdir=
1448 \begin_inset Quotes srd
1449 \end_inset 
1450
1451 /sdcc/doc
1452 \begin_inset Quotes srd
1453 \end_inset 
1454
1455  
1456 \backslash 
1457
1458 \newline 
1459 include_dir_suffix=
1460 \begin_inset Quotes srd
1461 \end_inset 
1462
1463 include
1464 \begin_inset Quotes srd
1465 \end_inset 
1466
1467  
1468 \backslash 
1469
1470 \newline 
1471 lib_dir_suffix=
1472 \begin_inset Quotes srd
1473 \end_inset 
1474
1475 lib
1476 \begin_inset Quotes srd
1477 \end_inset 
1478
1479  
1480 \backslash 
1481
1482 \newline 
1483 sdccconf_h_dir_separator=
1484 \begin_inset Quotes srd
1485 \end_inset 
1486
1487
1488 \backslash 
1489
1490 \backslash 
1491
1492 \backslash 
1493
1494 \backslash 
1495
1496 \begin_inset Quotes srd
1497 \end_inset 
1498
1499  
1500 \backslash 
1501
1502 \newline 
1503 -
1504 \begin_inset ERT
1505 status Collapsed
1506
1507 \layout Standard
1508
1509 \backslash 
1510 /
1511 \end_inset 
1512
1513 -disable-device-lib-build
1514 \backslash 
1515
1516 \newline 
1517 -
1518 \begin_inset ERT
1519 status Collapsed
1520
1521 \layout Standard
1522
1523 \backslash 
1524 /
1525 \end_inset 
1526
1527 -disable-ucsim
1528 \backslash 
1529
1530 \newline 
1531 -
1532 \begin_inset ERT
1533 status Collapsed
1534
1535 \layout Standard
1536
1537 \backslash 
1538 /
1539 \end_inset 
1540
1541 -host=i586-mingw32msvc -
1542 \begin_inset ERT
1543 status Collapsed
1544
1545 \layout Standard
1546
1547 \backslash 
1548 /
1549 \end_inset 
1550
1551 -build=unknown-unknown-linux-gnu
1552 \layout Standard
1553
1554 To 
1555 \begin_inset Quotes sld
1556 \end_inset 
1557
1558 cross
1559 \begin_inset Quotes srd
1560 \end_inset 
1561
1562 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
1563 ):
1564 \layout LyX-Code
1565
1566 ./configure -C 
1567 \backslash 
1568
1569 \newline 
1570 CFLAGS=
1571 \begin_inset Quotes srd
1572 \end_inset 
1573
1574 -mno-cygwin -O2
1575 \begin_inset Quotes srd
1576 \end_inset 
1577
1578  
1579 \backslash 
1580
1581 \newline 
1582 LDFLAGS=
1583 \begin_inset Quotes srd
1584 \end_inset 
1585
1586 -mno-cygwin
1587 \begin_inset Quotes srd
1588 \end_inset 
1589
1590  
1591 \backslash 
1592
1593 \newline 
1594 -
1595 \begin_inset ERT
1596 status Collapsed
1597
1598 \layout Standard
1599
1600 \backslash 
1601 /
1602 \end_inset 
1603
1604 -prefix=
1605 \begin_inset Quotes srd
1606 \end_inset 
1607
1608 /sdcc
1609 \begin_inset Quotes srd
1610 \end_inset 
1611
1612  
1613 \backslash 
1614
1615 \newline 
1616 -
1617 \begin_inset ERT
1618 status Collapsed
1619
1620 \layout Standard
1621
1622 \backslash 
1623 /
1624 \end_inset 
1625
1626 -datadir=
1627 \begin_inset Quotes srd
1628 \end_inset 
1629
1630 /sdcc
1631 \begin_inset Quotes srd
1632 \end_inset 
1633
1634  
1635 \backslash 
1636
1637 \newline 
1638 docdir=
1639 \begin_inset Quotes srd
1640 \end_inset 
1641
1642 /sdcc/doc
1643 \begin_inset Quotes srd
1644 \end_inset 
1645
1646  
1647 \backslash 
1648  
1649 \newline 
1650 include_dir_suffix=
1651 \begin_inset Quotes srd
1652 \end_inset 
1653
1654 include
1655 \begin_inset Quotes srd
1656 \end_inset 
1657
1658  
1659 \backslash 
1660
1661 \newline 
1662 lib_dir_suffix=
1663 \begin_inset Quotes srd
1664 \end_inset 
1665
1666 lib
1667 \begin_inset Quotes srd
1668 \end_inset 
1669
1670  
1671 \backslash 
1672
1673 \newline 
1674 sdccconf_h_dir_separator=
1675 \begin_inset Quotes srd
1676 \end_inset 
1677
1678
1679 \backslash 
1680
1681 \backslash 
1682
1683 \backslash 
1684
1685 \backslash 
1686
1687 \begin_inset Quotes srd
1688 \end_inset 
1689
1690  
1691 \backslash 
1692
1693 \newline 
1694 -
1695 \begin_inset ERT
1696 status Collapsed
1697
1698 \layout Standard
1699
1700 \backslash 
1701 /
1702 \end_inset 
1703
1704 -disable-ucsim
1705 \layout Standard
1706
1707 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
1708  The option '-
1709 \begin_inset ERT
1710 status Collapsed
1711
1712 \layout Standard
1713
1714 \backslash 
1715 /
1716 \end_inset 
1717
1718 -C' turns on caching, which gives a little bit extra speed.
1719  However if options are changed, it can be necessary to delete the config.cache
1720  file.
1721 \layout Section
1722
1723 Install paths
1724 \begin_inset LatexCommand \label{sub:Install-paths}
1725
1726 \end_inset 
1727
1728
1729 \begin_inset LatexCommand \index{Install paths}
1730
1731 \end_inset 
1732
1733
1734 \layout Standard
1735 \added_space_top medskip \align center 
1736
1737 \begin_inset  Tabular
1738 <lyxtabular version="3" rows="5" columns="4">
1739 <features>
1740 <column alignment="center" valignment="top" leftline="true" width="0">
1741 <column alignment="center" valignment="top" leftline="true" width="0">
1742 <column alignment="center" valignment="top" leftline="true" width="0">
1743 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
1744 <row topline="true" bottomline="true">
1745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1746 \begin_inset Text
1747
1748 \layout Standard
1749
1750
1751 \series bold 
1752 Description
1753 \end_inset 
1754 </cell>
1755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1756 \begin_inset Text
1757
1758 \layout Standard
1759
1760
1761 \series bold 
1762 Path
1763 \end_inset 
1764 </cell>
1765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1766 \begin_inset Text
1767
1768 \layout Standard
1769
1770
1771 \series bold 
1772 Default
1773 \end_inset 
1774 </cell>
1775 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1776 \begin_inset Text
1777
1778 \layout Standard
1779
1780
1781 \series bold 
1782 Win32 builds
1783 \end_inset 
1784 </cell>
1785 </row>
1786 <row topline="true">
1787 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1788 \begin_inset Text
1789
1790 \layout Standard
1791
1792 Binary files*
1793 \end_inset 
1794 </cell>
1795 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1796 \begin_inset Text
1797
1798 \layout Standard
1799
1800
1801 \emph on 
1802 $EXEC_PREFIX
1803 \end_inset 
1804 </cell>
1805 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1806 \begin_inset Text
1807
1808 \layout Standard
1809
1810 /usr/local/bin
1811 \end_inset 
1812 </cell>
1813 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1814 \begin_inset Text
1815
1816 \layout Standard
1817
1818
1819 \backslash 
1820 sdcc
1821 \backslash 
1822 bin
1823 \end_inset 
1824 </cell>
1825 </row>
1826 <row topline="true">
1827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1828 \begin_inset Text
1829
1830 \layout Standard
1831
1832 Include files
1833 \end_inset 
1834 </cell>
1835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1836 \begin_inset Text
1837
1838 \layout Standard
1839
1840
1841 \emph on 
1842 $DATADIR/ $INCLUDE_DIR_SUFFIX
1843 \end_inset 
1844 </cell>
1845 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1846 \begin_inset Text
1847
1848 \layout Standard
1849
1850 /usr/local/share/sdcc/include
1851 \end_inset 
1852 </cell>
1853 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1854 \begin_inset Text
1855
1856 \layout Standard
1857
1858
1859 \backslash 
1860 sdcc
1861 \backslash 
1862 include
1863 \end_inset 
1864 </cell>
1865 </row>
1866 <row topline="true">
1867 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1868 \begin_inset Text
1869
1870 \layout Standard
1871
1872 Library file**
1873 \end_inset 
1874 </cell>
1875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1876 \begin_inset Text
1877
1878 \layout Standard
1879
1880
1881 \emph on 
1882 $DATADIR/$LIB_DIR_SUFFIX
1883 \end_inset 
1884 </cell>
1885 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1886 \begin_inset Text
1887
1888 \layout Standard
1889
1890 /usr/local/share/sdcc/lib
1891 \end_inset 
1892 </cell>
1893 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1894 \begin_inset Text
1895
1896 \layout Standard
1897
1898
1899 \backslash 
1900 sdcc
1901 \backslash 
1902 lib
1903 \end_inset 
1904 </cell>
1905 </row>
1906 <row topline="true" bottomline="true">
1907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1908 \begin_inset Text
1909
1910 \layout Standard
1911
1912 Documentation
1913 \end_inset 
1914 </cell>
1915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1916 \begin_inset Text
1917
1918 \layout Standard
1919
1920
1921 \emph on 
1922 $DOCDIR
1923 \end_inset 
1924 </cell>
1925 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1926 \begin_inset Text
1927
1928 \layout Standard
1929
1930 /usr/local/share/sdcc/doc
1931 \end_inset 
1932 </cell>
1933 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1934 \begin_inset Text
1935
1936 \layout Standard
1937
1938
1939 \backslash 
1940 sdcc
1941 \backslash 
1942 doc
1943 \end_inset 
1944 </cell>
1945 </row>
1946 </lyxtabular>
1947
1948 \end_inset 
1949
1950
1951 \layout Verse
1952
1953
1954 \size footnotesize 
1955 *compiler, preprocessor, assembler, and linker
1956 \newline 
1957 **the 
1958 \shape italic 
1959 model
1960 \shape default 
1961  is auto-appended by the compiler, e.g.
1962  small, large, z80, ds390 etc
1963 \layout Standard
1964 \noindent 
1965 The install paths can still be changed during `make install` with e.g.:
1966 \layout LyX-Code
1967
1968 make install prefix=$(HOME)/local/sdcc
1969 \layout Standard
1970
1971 Of course this doesn't change the search paths compiled into the binaries.
1972 \newline 
1973
1974 \newline 
1975 Moreover the install path can be changed by defining DESTDIR
1976 \begin_inset LatexCommand \index{DESTDIR}
1977
1978 \end_inset 
1979
1980 :
1981 \layout LyX-Code
1982
1983 make install DESTDIR=$(HOME)/sdcc.rpm/
1984 \layout Standard
1985
1986 Please note that DESTDIR must have a trailing slash!
1987 \layout Section
1988
1989 Search Paths
1990 \begin_inset LatexCommand \label{sub:Search-Paths}
1991
1992 \end_inset 
1993
1994
1995 \begin_inset LatexCommand \index{Search path}
1996
1997 \end_inset 
1998
1999
2000 \layout Standard
2001
2002 Some search paths or parts of them are determined by configure variables
2003  (in 
2004 \emph on 
2005 italics
2006 \emph default 
2007 , see section above).
2008  Further search paths are determined by environment variables during runtime.
2009  
2010 \newline 
2011 The paths searched when running the compiler are as follows (the first catch
2012  wins):
2013 \newline 
2014
2015 \newline 
2016 1.
2017  Binary files (preprocessor, assembler and linker)
2018 \newline 
2019
2020 \layout Standard
2021 \align center 
2022
2023 \begin_inset  Tabular
2024 <lyxtabular version="3" rows="4" columns="3">
2025 <features>
2026 <column alignment="block" valignment="top" leftline="true" width="0in">
2027 <column alignment="block" valignment="top" leftline="true" width="0in">
2028 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2029 <row topline="true" bottomline="true">
2030 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2031 \begin_inset Text
2032
2033 \layout Standard
2034
2035 Search path
2036 \end_inset 
2037 </cell>
2038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2039 \begin_inset Text
2040
2041 \layout Standard
2042
2043 default
2044 \end_inset 
2045 </cell>
2046 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2047 \begin_inset Text
2048
2049 \layout Standard
2050
2051 Win32 builds
2052 \end_inset 
2053 </cell>
2054 </row>
2055 <row topline="true">
2056 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2057 \begin_inset Text
2058
2059 \layout Standard
2060
2061 $SDCC_HOME/
2062 \emph on 
2063 $PPREFIX2BIN_DIR
2064 \end_inset 
2065 </cell>
2066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2067 \begin_inset Text
2068
2069 \layout Standard
2070
2071 $SDCC_HOME/bin
2072 \end_inset 
2073 </cell>
2074 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2075 \begin_inset Text
2076
2077 \layout Standard
2078
2079 $SDCC_HOME
2080 \backslash 
2081 bin
2082 \end_inset 
2083 </cell>
2084 </row>
2085 <row topline="true">
2086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2087 \begin_inset Text
2088
2089 \layout Standard
2090
2091 Path of argv[0] (if available)
2092 \end_inset 
2093 </cell>
2094 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2095 \begin_inset Text
2096
2097 \layout Standard
2098
2099 Path of argv[0]
2100 \end_inset 
2101 </cell>
2102 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2103 \begin_inset Text
2104
2105 \layout Standard
2106
2107 Path of argv[0]
2108 \end_inset 
2109 </cell>
2110 </row>
2111 <row topline="true" bottomline="true">
2112 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2113 \begin_inset Text
2114
2115 \layout Standard
2116
2117 $PATH
2118 \end_inset 
2119 </cell>
2120 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2121 \begin_inset Text
2122
2123 \layout Standard
2124
2125 $PATH
2126 \end_inset 
2127 </cell>
2128 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2129 \begin_inset Text
2130
2131 \layout Standard
2132
2133 $PATH
2134 \end_inset 
2135 </cell>
2136 </row>
2137 </lyxtabular>
2138
2139 \end_inset 
2140
2141  
2142 \newline 
2143
2144 \layout Standard
2145 \noindent 
2146 2.
2147  Include files
2148 \newline 
2149
2150 \layout Standard
2151 \align center 
2152
2153 \begin_inset  Tabular
2154 <lyxtabular version="3" rows="6" columns="3">
2155 <features>
2156 <column alignment="block" valignment="top" leftline="true" width="1.5in">
2157 <column alignment="block" valignment="top" leftline="true" width="1.5in">
2158 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2159 <row topline="true" bottomline="true">
2160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2161 \begin_inset Text
2162
2163 \layout Standard
2164
2165 Search path
2166 \end_inset 
2167 </cell>
2168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2169 \begin_inset Text
2170
2171 \layout Standard
2172
2173 default
2174 \end_inset 
2175 </cell>
2176 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2177 \begin_inset Text
2178
2179 \layout Standard
2180
2181 Win32 builds
2182 \end_inset 
2183 </cell>
2184 </row>
2185 <row topline="true">
2186 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2187 \begin_inset Text
2188
2189 \layout Standard
2190
2191 -
2192 \begin_inset ERT
2193 status Collapsed
2194
2195 \layout Standard
2196
2197 \backslash 
2198 /
2199 \end_inset 
2200
2201 -I dir
2202 \end_inset 
2203 </cell>
2204 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2205 \begin_inset Text
2206
2207 \layout Standard
2208
2209 -
2210 \begin_inset ERT
2211 status Collapsed
2212
2213 \layout Standard
2214
2215 \backslash 
2216 /
2217 \end_inset 
2218
2219 -I dir
2220 \end_inset 
2221 </cell>
2222 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2223 \begin_inset Text
2224
2225 \layout Standard
2226
2227 -
2228 \begin_inset ERT
2229 status Collapsed
2230
2231 \layout Standard
2232
2233 \backslash 
2234 /
2235 \end_inset 
2236
2237 -I dir
2238 \end_inset 
2239 </cell>
2240 </row>
2241 <row topline="true">
2242 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2243 \begin_inset Text
2244
2245 \layout Standard
2246
2247 $SDCC_INCLUDE
2248 \end_inset 
2249 </cell>
2250 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2251 \begin_inset Text
2252
2253 \layout Standard
2254
2255 $SDCC_INCLUDE
2256 \end_inset 
2257 </cell>
2258 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2259 \begin_inset Text
2260
2261 \layout Standard
2262
2263 $SDCC_INCLUDE
2264 \end_inset 
2265 </cell>
2266 </row>
2267 <row topline="true">
2268 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2269 \begin_inset Text
2270
2271 \layout Standard
2272
2273 $SDCC_HOME/
2274 \newline 
2275
2276 \emph on 
2277 $PREFIX2DATA_DIR/
2278 \newline 
2279 $INCLUDE_DIR_SUFFIX
2280 \end_inset 
2281 </cell>
2282 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2283 \begin_inset Text
2284
2285 \layout Standard
2286
2287 $SDCC_ HOME/
2288 \newline 
2289 share/sdcc/
2290 \newline 
2291 include
2292 \end_inset 
2293 </cell>
2294 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2295 \begin_inset Text
2296
2297 \layout Standard
2298
2299 $SDCC_HOME
2300 \backslash 
2301 include
2302 \end_inset 
2303 </cell>
2304 </row>
2305 <row topline="true">
2306 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2307 \begin_inset Text
2308
2309 \layout Standard
2310
2311 path(argv[0])/
2312 \newline 
2313
2314 \emph on 
2315 $BIN2DATADIR/
2316 \emph default 
2317
2318 \newline 
2319
2320 \emph on 
2321 $INCLUDE_DIR_SUFFIX
2322 \end_inset 
2323 </cell>
2324 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2325 \begin_inset Text
2326
2327 \layout Standard
2328
2329 path(argv[0])/
2330 \newline 
2331 ../sdcc/include
2332 \newline 
2333 \SpecialChar ~
2334 \SpecialChar ~
2335 \SpecialChar ~
2336 \SpecialChar ~
2337 \SpecialChar ~
2338 \SpecialChar ~
2339 \SpecialChar ~
2340 \SpecialChar ~
2341 \SpecialChar ~
2342 \SpecialChar ~
2343 \SpecialChar ~
2344 \SpecialChar ~
2345 \SpecialChar ~
2346 \SpecialChar ~
2347 \SpecialChar ~
2348 \SpecialChar ~
2349 \SpecialChar ~
2350 \SpecialChar ~
2351 \SpecialChar ~
2352 \SpecialChar ~
2353 \SpecialChar ~
2354 \SpecialChar ~
2355 \SpecialChar ~
2356 \SpecialChar ~
2357 \SpecialChar ~
2358 \SpecialChar ~
2359 \SpecialChar ~
2360 \SpecialChar ~
2361 \SpecialChar ~
2362 \SpecialChar ~
2363 \SpecialChar ~
2364 \SpecialChar ~
2365 \SpecialChar ~
2366 \SpecialChar ~
2367 \SpecialChar ~
2368 \SpecialChar ~
2369 \SpecialChar ~
2370 \SpecialChar ~
2371
2372 \end_inset 
2373 </cell>
2374 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2375 \begin_inset Text
2376
2377 \layout Standard
2378
2379 path(argv[0])
2380 \backslash 
2381 ..
2382 \backslash 
2383 include
2384 \end_inset 
2385 </cell>
2386 </row>
2387 <row topline="true" bottomline="true">
2388 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2389 \begin_inset Text
2390
2391 \layout Standard
2392
2393
2394 \emph on 
2395 $DATADIR/
2396 \emph default 
2397
2398 \newline 
2399
2400 \emph on 
2401 $INCLUDE_DIR_SUFFIX
2402 \end_inset 
2403 </cell>
2404 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2405 \begin_inset Text
2406
2407 \layout Standard
2408
2409 /usr/local/share/sdcc/
2410 \newline 
2411 include
2412 \end_inset 
2413 </cell>
2414 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2415 \begin_inset Text
2416
2417 \layout Standard
2418
2419 (not on Win32)
2420 \end_inset 
2421 </cell>
2422 </row>
2423 </lyxtabular>
2424
2425 \end_inset 
2426
2427  
2428 \newline 
2429
2430 \layout Standard
2431 \noindent 
2432 The option -
2433 \begin_inset ERT
2434 status Collapsed
2435
2436 \layout Standard
2437
2438 \backslash 
2439 /
2440 \end_inset 
2441
2442 -nostdinc disables the last two search paths.
2443 \newline 
2444
2445 \newline 
2446 3.
2447  Library files 
2448 \newline 
2449
2450 \layout Standard
2451
2452 With the exception of 
2453 \begin_inset Quotes sld
2454 \end_inset 
2455
2456 -
2457 \begin_inset ERT
2458 status Collapsed
2459
2460 \layout Standard
2461
2462 \backslash 
2463 /
2464 \end_inset 
2465
2466 -L dir
2467 \begin_inset Quotes srd
2468 \end_inset 
2469
2470  the 
2471 \shape italic 
2472 model
2473 \shape default 
2474  is auto-appended by the compiler (e.g.
2475  small, large, z80, ds390 etc.).
2476  
2477 \newline 
2478
2479 \layout Standard
2480 \align center 
2481
2482 \begin_inset  Tabular
2483 <lyxtabular version="3" rows="6" columns="3">
2484 <features>
2485 <column alignment="block" valignment="top" leftline="true" width="1.7in">
2486 <column alignment="block" valignment="top" leftline="true" width="1.2in">
2487 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
2488 <row topline="true" bottomline="true">
2489 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2490 \begin_inset Text
2491
2492 \layout Standard
2493
2494 Search path
2495 \end_inset 
2496 </cell>
2497 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2498 \begin_inset Text
2499
2500 \layout Standard
2501
2502 default
2503 \end_inset 
2504 </cell>
2505 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2506 \begin_inset Text
2507
2508 \layout Standard
2509
2510 Win32 builds
2511 \end_inset 
2512 </cell>
2513 </row>
2514 <row topline="true">
2515 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2516 \begin_inset Text
2517
2518 \layout Standard
2519
2520 -
2521 \begin_inset ERT
2522 status Collapsed
2523
2524 \layout Standard
2525
2526 \backslash 
2527 /
2528 \end_inset 
2529
2530 -L dir
2531 \end_inset 
2532 </cell>
2533 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2534 \begin_inset Text
2535
2536 \layout Standard
2537
2538 -
2539 \begin_inset ERT
2540 status Collapsed
2541
2542 \layout Standard
2543
2544 \backslash 
2545 /
2546 \end_inset 
2547
2548 -L dir
2549 \end_inset 
2550 </cell>
2551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2552 \begin_inset Text
2553
2554 \layout Standard
2555
2556 -
2557 \begin_inset ERT
2558 status Collapsed
2559
2560 \layout Standard
2561
2562 \backslash 
2563 /
2564 \end_inset 
2565
2566 -L dir
2567 \end_inset 
2568 </cell>
2569 </row>
2570 <row topline="true">
2571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2572 \begin_inset Text
2573
2574 \layout Standard
2575
2576 $SDCC_LIB/
2577 \newline 
2578
2579 \emph on 
2580 <model>
2581 \end_inset 
2582 </cell>
2583 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2584 \begin_inset Text
2585
2586 \layout Standard
2587
2588 $SDCC_LIB/
2589 \newline 
2590
2591 \emph on 
2592 <model>
2593 \end_inset 
2594 </cell>
2595 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2596 \begin_inset Text
2597
2598 \layout Standard
2599
2600 $SDCC_LIB
2601 \backslash 
2602
2603 \newline 
2604
2605 \emph on 
2606 <model>
2607 \end_inset 
2608 </cell>
2609 </row>
2610 <row topline="true">
2611 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2612 \begin_inset Text
2613
2614 \layout Standard
2615
2616 $SDCC_HOME/
2617 \newline 
2618
2619 \emph on 
2620 $PREFIX2DATA_DIR/
2621 \newline 
2622 $LIB_DIR_SUFFIX/<model>
2623 \end_inset 
2624 </cell>
2625 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2626 \begin_inset Text
2627
2628 \layout Standard
2629
2630 $SDCC_HOME/
2631 \newline 
2632 share/sdcc/
2633 \newline 
2634 lib/
2635 \emph on 
2636 <model>
2637 \end_inset 
2638 </cell>
2639 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2640 \begin_inset Text
2641
2642 \layout Standard
2643
2644 $SDCC_HOME
2645 \backslash 
2646 lib
2647 \backslash 
2648
2649 \emph on 
2650
2651 \newline 
2652 <model>
2653 \end_inset 
2654 </cell>
2655 </row>
2656 <row topline="true">
2657 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2658 \begin_inset Text
2659
2660 \layout Standard
2661
2662 path(argv[0])/
2663 \newline 
2664
2665 \emph on 
2666 $BIN2DATADIR/
2667 \emph default 
2668
2669 \newline 
2670
2671 \emph on 
2672 $LIB_DIR_SUFFIX/<model>
2673 \end_inset 
2674 </cell>
2675 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2676 \begin_inset Text
2677
2678 \layout Standard
2679
2680 path(argv[0])/
2681 \newline 
2682 ../sdcc/lib/
2683 \emph on 
2684 <model>
2685 \newline 
2686 \SpecialChar ~
2687 \SpecialChar ~
2688 \SpecialChar ~
2689 \SpecialChar ~
2690 \SpecialChar ~
2691 \SpecialChar ~
2692 \SpecialChar ~
2693 \SpecialChar ~
2694 \SpecialChar ~
2695 \SpecialChar ~
2696 \SpecialChar ~
2697 \SpecialChar ~
2698 \SpecialChar ~
2699 \SpecialChar ~
2700 \SpecialChar ~
2701 \SpecialChar ~
2702 \SpecialChar ~
2703 \SpecialChar ~
2704 \SpecialChar ~
2705 \SpecialChar ~
2706 \SpecialChar ~
2707 \SpecialChar ~
2708 \SpecialChar ~
2709 \SpecialChar ~
2710 \SpecialChar ~
2711 \SpecialChar ~
2712 \SpecialChar ~
2713 \SpecialChar ~
2714 \SpecialChar ~
2715 \SpecialChar ~
2716 \SpecialChar ~
2717 \SpecialChar ~
2718 \SpecialChar ~
2719 \SpecialChar ~
2720 \SpecialChar ~
2721 \SpecialChar ~
2722 \SpecialChar ~
2723 \SpecialChar ~
2724 \SpecialChar ~
2725
2726 \end_inset 
2727 </cell>
2728 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2729 \begin_inset Text
2730
2731 \layout Standard
2732
2733 path(argv[0])
2734 \backslash 
2735
2736 \newline 
2737 ..
2738 \backslash 
2739 lib
2740 \backslash 
2741
2742 \emph on 
2743 <model>
2744 \newline 
2745 \SpecialChar ~
2746 \SpecialChar ~
2747 \SpecialChar ~
2748 \SpecialChar ~
2749 \SpecialChar ~
2750 \SpecialChar ~
2751 \SpecialChar ~
2752 \SpecialChar ~
2753 \SpecialChar ~
2754 \SpecialChar ~
2755 \SpecialChar ~
2756 \SpecialChar ~
2757 \SpecialChar ~
2758 \SpecialChar ~
2759 \SpecialChar ~
2760 \SpecialChar ~
2761 \SpecialChar ~
2762 \SpecialChar ~
2763 \SpecialChar ~
2764 \SpecialChar ~
2765 \SpecialChar ~
2766 \SpecialChar ~
2767 \SpecialChar ~
2768 \SpecialChar ~
2769 \SpecialChar ~
2770 \SpecialChar ~
2771 \SpecialChar ~
2772 \SpecialChar ~
2773 \SpecialChar ~
2774 \SpecialChar ~
2775 \SpecialChar ~
2776 \SpecialChar ~
2777 \SpecialChar ~
2778 \SpecialChar ~
2779 \SpecialChar ~
2780
2781 \end_inset 
2782 </cell>
2783 </row>
2784 <row topline="true" bottomline="true">
2785 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2786 \begin_inset Text
2787
2788 \layout Standard
2789
2790
2791 \emph on 
2792 $DATADIR/
2793 \newline 
2794 $LIB_DIR_SUFFIX/<model>
2795 \end_inset 
2796 </cell>
2797 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2798 \begin_inset Text
2799
2800 \layout Standard
2801
2802 /usr/local/share/sdcc/
2803 \newline 
2804 lib/
2805 \emph on 
2806 <model>
2807 \end_inset 
2808 </cell>
2809 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2810 \begin_inset Text
2811
2812 \layout Standard
2813
2814 (not on Win32)
2815 \end_inset 
2816 </cell>
2817 </row>
2818 </lyxtabular>
2819
2820 \end_inset 
2821
2822
2823 \newline 
2824
2825 \layout Comment
2826
2827 Don't delete any of the stray spaces in the table above without checking
2828  the HTML output (last line)!
2829 \layout Standard
2830
2831 \SpecialChar ~
2832
2833 \newline 
2834 The option -
2835 \begin_inset ERT
2836 status Collapsed
2837
2838 \layout Standard
2839
2840 \backslash 
2841 /
2842 \end_inset 
2843
2844 -nostdlib disables the last two search paths.
2845 \layout Section
2846
2847 Building SDCC
2848 \begin_inset LatexCommand \index{Building SDCC}
2849
2850 \end_inset 
2851
2852
2853 \layout Subsection
2854
2855 Building SDCC on Linux
2856 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
2857
2858 \end_inset 
2859
2860
2861 \layout Enumerate
2862
2863
2864 \series medium 
2865 Download the source package
2866 \series default 
2867  either from the SDCC CVS repository or from the nightly snapshots
2868 \series medium 
2869 , it will be named something like sdcc
2870 \series default 
2871 .src
2872 \series medium 
2873 .t
2874 \series default 
2875 ar.
2876 \series medium 
2877 gz
2878 \series default 
2879  
2880 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
2881
2882 \end_inset 
2883
2884 .
2885 \layout Enumerate
2886
2887
2888 \series medium 
2889 Bring up a command line terminal, such as xterm.
2890 \layout Enumerate
2891
2892
2893 \series medium 
2894 Unpack the file using a command like: 
2895 \family sans 
2896 \series bold 
2897 "tar -xvzf sdcc.src.tar.gz
2898 \family default 
2899 \series default 
2900 "
2901 \series medium 
2902 , this will create a sub-directory called sdcc with all of the sources.
2903 \layout Enumerate
2904
2905 Change directory into the main SDCC directory, for example type: 
2906 \family sans 
2907 \series bold 
2908 "cd sdcc
2909 \series default 
2910 ".
2911 \layout Enumerate
2912
2913
2914 \series medium 
2915 Type 
2916 \family sans 
2917 \series bold 
2918 "./configure
2919 \family default 
2920 \series default 
2921 ".
2922  This configures the package for compilation on your system.
2923 \layout Enumerate
2924
2925
2926 \series medium 
2927 Type 
2928 \family sans 
2929 \series bold 
2930 "make
2931 \family default 
2932 \series default 
2933 "
2934 \series medium 
2935 .
2936
2937 \series default 
2938  All of the source packages will compile, this can take a while.
2939 \layout Enumerate
2940
2941
2942 \series medium 
2943 Type 
2944 \family sans 
2945 \series bold 
2946 "make install"
2947 \family default 
2948 \series default 
2949  as root
2950 \series medium 
2951 .
2952
2953 \series default 
2954  This copies the binary executables, the include files, the libraries and
2955  the documentation to the install directories.
2956  Proceed with section 
2957 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
2958
2959 \end_inset 
2960
2961 .
2962 \layout Subsection
2963
2964 Building SDCC on OSX 2.x
2965 \layout Standard
2966
2967 Follow the instruction for Linux.
2968 \newline 
2969
2970 \newline 
2971 On OSX 2.x it was reported, that the default gcc (version 3.1 20020420 (prerelease
2972 )) fails to compile SDCC.
2973  Fortunately there's also gcc 2.9.x installed, which works fine.
2974  This compiler can be selected by running 'configure' with:
2975 \layout LyX-Code
2976
2977 ./configure CC=gcc2 CXX=g++2
2978 \layout Subsection
2979
2980 Cross compiling SDCC on Linux for Windows
2981 \layout Standard
2982
2983 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
2984  See section 'Configure Options'.
2985 \layout Subsection
2986
2987 Building SDCC on Windows 
2988 \layout Standard
2989
2990 With the exception of Cygwin the SDCC binaries uCsim and sdcdb can't be
2991  built on Windows.
2992  They use Unix-sockets, which are not available on Win32.
2993 \layout Subsection
2994
2995 Building SDCC using Cygwin and Mingw32
2996 \layout Standard
2997
2998 For building and installing a Cygwin executable follow the instructions
2999  for Linux.
3000 \newline 
3001
3002 \newline 
3003 On Cygwin a 
3004 \begin_inset Quotes sld
3005 \end_inset 
3006
3007 native
3008 \begin_inset Quotes srd
3009 \end_inset 
3010
3011  Win32-binary can be built, which will not need the Cygwin-DLL.
3012  For the necessary 'configure' options see section 'configure options' or
3013  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
3014 \newline 
3015
3016 \newline 
3017 In order to install Cygwin on Windows download setup.exe from 
3018 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
3019
3020 \end_inset 
3021
3022 .
3023  Run it, set the 
3024 \begin_inset Quotes sld
3025 \end_inset 
3026
3027 default text file type
3028 \begin_inset Quotes srd
3029 \end_inset 
3030
3031  to 
3032 \begin_inset Quotes sld
3033 \end_inset 
3034
3035 unix
3036 \begin_inset Quotes srd
3037 \end_inset 
3038
3039  and download/install at least the following packages.
3040  Some packages are selected by default, others will be automatically selected
3041  because of dependencies with the manually selected packages.
3042  Never deselect these packages!
3043 \layout Itemize
3044
3045 flex
3046 \layout Itemize
3047
3048 bison
3049 \layout Itemize
3050
3051 gcc ; version 3.x is fine, no need to use the old 2.9x
3052 \layout Itemize
3053
3054 binutils ; selected with gcc
3055 \layout Itemize
3056
3057 make
3058 \layout Itemize
3059
3060 rxvt ; a nice console, which makes life much easier under windoze (see below)
3061 \layout Itemize
3062
3063 man ; not really needed for building SDCC, but you'll miss it sooner or
3064  later
3065 \layout Itemize
3066
3067 less ; not really needed for building SDCC, but you'll miss it sooner or
3068  later
3069 \layout Itemize
3070
3071 cvs ; only if you use CVS access
3072 \layout Standard
3073
3074 If you want to develop something you'll need:
3075 \layout Itemize
3076
3077 python ; for the regression tests
3078 \layout Itemize
3079
3080 gdb ; the gnu debugger, together with the nice GUI 
3081 \begin_inset Quotes sld
3082 \end_inset 
3083
3084 insight
3085 \begin_inset Quotes srd
3086 \end_inset 
3087
3088
3089 \layout Itemize
3090
3091 openssh ; to access the CF or commit changes
3092 \layout Itemize
3093
3094 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
3095  use autoconf-stable!
3096 \layout Standard
3097
3098 rxvt is a nice console with history.
3099  Replace in your cygwin.bat the line
3100 \layout LyX-Code
3101
3102 bash -
3103 \begin_inset ERT
3104 status Collapsed
3105
3106 \layout Standard
3107
3108 \backslash 
3109 /
3110 \end_inset 
3111
3112 -login -i 
3113 \layout Standard
3114
3115 with (one line):
3116 \layout LyX-Code
3117
3118 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
3119 \layout LyX-Code
3120
3121      -bg black -fg white -geometry 100x65 -e bash -
3122 \begin_inset ERT
3123 status Collapsed
3124
3125 \layout Standard
3126
3127 \backslash 
3128 /
3129 \end_inset 
3130
3131 -login
3132 \layout Standard
3133
3134 Text selected with the mouse is automatically copied to the clipboard, pasting
3135  works with shift-insert.
3136 \newline 
3137
3138 \newline 
3139 The other good tip is to make sure you have no //c/-style paths anywhere,
3140  use /cygdrive/c/ instead.
3141  Using // invokes a network lookup which is very slow.
3142  If you think 
3143 \begin_inset Quotes sld
3144 \end_inset 
3145
3146 cygdrive
3147 \begin_inset Quotes srd
3148 \end_inset 
3149
3150  is too long, you can change it with e.g.
3151 \layout LyX-Code
3152
3153 mount -s -u -c /mnt
3154 \layout Standard
3155
3156 SDCC sources use the unix line ending LF.
3157  Life is much easier, if you store the source tree on a drive which is mounted
3158  in binary mode.
3159  And use an editor which can handle LF-only line endings.
3160  Make sure not to commit files with windows line endings.
3161  The tabulator spacing
3162 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
3163
3164 \end_inset 
3165
3166  used in the project is 8.
3167  Although a tabulator spacing of 8 is a sensible choice for programmers
3168  (it's a power of 2 and allows to display 8/16 bit signed variables without
3169  loosing columns) the plan is to move towards using only spaces in the source.
3170 \layout Subsection
3171
3172 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
3173 \layout Standard
3174
3175
3176 \series medium 
3177 Download the source package
3178 \series default 
3179  either from the SDCC CVS repository or from the 
3180 \begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
3181
3182 \end_inset 
3183
3184
3185 \series medium 
3186 , it will be named something like sdcc
3187 \series default 
3188 .src
3189 \series medium 
3190 .tgz.
3191
3192 \series default 
3193  SDCC is distributed with all the projects, workspaces, and files you need
3194  to build it using Visual C++ 6.0/NET (except for sdcdb.exe which currently
3195  doesn't build under MSVC).
3196  The workspace name is 'sdcc.dsw'.
3197  Please note that as it is now, all the executables are created in a folder
3198  called sdcc
3199 \backslash 
3200 bin_vc.
3201  Once built you need to copy the executables from sdcc
3202 \backslash 
3203 bin_vc to sdcc
3204 \backslash 
3205 bin before running SDCC.
3206  
3207 \newline 
3208
3209 \newline 
3210 WARNING: Visual studio is very picky with line terminations; it expects
3211  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
3212  If you are getting a message such as "This makefile was not generated by
3213  Developer Studio etc.
3214  etc.
3215 \begin_inset Quotes srd
3216 \end_inset 
3217
3218  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
3219  need to convert the Unix style line endings to DOS style line endings.
3220  To do so you can use the 
3221 \begin_inset Quotes sld
3222 \end_inset 
3223
3224 unix2dos
3225 \begin_inset Quotes srd
3226 \end_inset 
3227
3228  utility freely available on the internet.
3229  Doug Hawkins reported in the sdcc-user list that this works:
3230 \newline 
3231
3232 \newline 
3233 C:
3234 \backslash 
3235 Programming
3236 \backslash 
3237 SDCC> unix2dos sdcc.dsw
3238 \newline 
3239 C:
3240 \backslash 
3241 Programming
3242 \backslash 
3243 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
3244 \newline 
3245
3246 \newline 
3247 In order to build SDCC with MSVC you need win32 executables of bison.exe,
3248  flex.exe, and gawk.exe.
3249  One good place to get them is 
3250 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
3251
3252 \end_inset 
3253
3254
3255 \newline 
3256
3257 \newline 
3258 Download the file UnxUtils
3259 \begin_inset LatexCommand \index{UnxUtils}
3260
3261 \end_inset 
3262
3263 .zip.
3264  Now you have to install the utilities and setup MSVC so it can locate the
3265  required programs.
3266  Here there are two alternatives (choose one!):
3267 \layout Enumerate
3268
3269 The easy way:
3270 \newline 
3271
3272 \newline 
3273 a) Extract UnxUtils.zip to your C:
3274 \backslash 
3275  hard disk PRESERVING the original paths, otherwise bison won't work.
3276  (If you are using WinZip make certain that 'Use folder names' is selected)
3277 \newline 
3278
3279 \newline 
3280 b) In the Visual C++ IDE click Tools, Options, select the Directory tab,
3281  in 'Show directories for:' select 'Executable files', and in the directories
3282  window add a new path: 'C:
3283 \backslash 
3284 user
3285 \backslash 
3286 local
3287 \backslash 
3288 wbin', click ok.
3289 \newline 
3290
3291 \newline 
3292 (As a side effect, you get a bunch of Unix utilities that could be useful,
3293  such as diff and patch.)
3294 \layout Enumerate
3295
3296 A more compact way:
3297 \newline 
3298
3299 \newline 
3300 This one avoids extracting a bunch of files you may not use, but requires
3301  some extra work:
3302 \newline 
3303
3304 \newline 
3305 a) Create a directory were to put the tools needed, or use a directory already
3306  present.
3307  Say for example 'C:
3308 \backslash 
3309 util'.
3310 \newline 
3311
3312 \newline 
3313 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and gawk.exe
3314  to such directory WITHOUT preserving the original paths.
3315  (If you are using WinZip make certain that 'Use folder names' is not selected)
3316 \newline 
3317
3318 \newline 
3319 c) Rename bison.exe to '_bison.exe'.
3320 \newline 
3321
3322 \newline 
3323 d) Create a batch file 'bison.bat' in 'C:
3324 \backslash 
3325 util
3326 \backslash 
3327 ' and add these lines: 
3328 \newline 
3329 \SpecialChar ~
3330 \SpecialChar ~
3331 set BISON_SIMPLE=C:
3332 \backslash 
3333 util
3334 \backslash 
3335 bison.simple 
3336 \newline 
3337 \SpecialChar ~
3338 \SpecialChar ~
3339 set BISON_HAIRY=C:
3340 \backslash 
3341 util
3342 \backslash 
3343 bison.hairy
3344 \newline 
3345 \SpecialChar ~
3346 \SpecialChar ~
3347 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
3348 \newline 
3349
3350 \newline 
3351 Steps 'c' and 'd' are needed because bison requires by default that the
3352  files 'bison.simple' and 'bison.hairy' reside in some weird Unix directory,
3353  '/usr/local/share/' I think.
3354  So it is necessary to tell bison where those files are located if they
3355  are not in such directory.
3356  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
3357 \newline 
3358
3359 \newline 
3360 e) In the Visual C++ IDE click Tools, Options, select the Directory tab,
3361  in 'Show directories for:' select 'Executable files', and in the directories
3362  window add a new path: 'c:
3363 \backslash 
3364 util', click ok.
3365  Note that you can use any other path instead of 'c:
3366 \backslash 
3367 util', even the path where the Visual C++ tools are, probably: 'C:
3368 \backslash 
3369 Program Files
3370 \backslash 
3371 Microsoft Visual Studio
3372 \backslash 
3373 Common
3374 \backslash 
3375 Tools'.
3376  So you don't have to execute step 'e' :)
3377 \layout Standard
3378
3379 That is it.
3380  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
3381  the executables from sdcc
3382 \backslash 
3383 bin_vc to sdcc
3384 \backslash 
3385 bin, and you can compile using SDCC.
3386 \layout Subsection
3387
3388 Building SDCC Using Borland
3389 \layout Enumerate
3390
3391 From the sdcc directory, run the command "make -f Makefile.bcc".
3392  This should regenerate all the .exe files in the bin directory except for
3393  sdcdb.exe (which currently doesn't build under Borland C++).
3394 \layout Enumerate
3395
3396 If you modify any source files and need to rebuild, be aware that the dependenci
3397 es may not be correctly calculated.
3398  The safest option is to delete all .obj files and run the build again.
3399  From a Cygwin BASH prompt, this can easily be done with the command (be
3400  sure you are in the sdcc directory):
3401 \newline 
3402
3403 \newline 
3404
3405 \family sans 
3406 \series bold 
3407 find .
3408  
3409 \backslash 
3410 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
3411 \backslash 
3412 ) -print -exec rm {} 
3413 \backslash 
3414 ;
3415 \family default 
3416 \series default 
3417
3418 \newline 
3419
3420 \newline 
3421 or on Windows NT/2000/XP from the command prompt with the command:
3422 \newline 
3423
3424 \family sans 
3425 \series bold 
3426
3427 \newline 
3428 del /s *.obj *.lib *.rul
3429 \family default 
3430 \series default 
3431  from the sdcc directory.
3432 \layout Subsection
3433
3434 Windows Install Using a Binary Package
3435 \begin_inset LatexCommand \label{sub:Windows-Install}
3436
3437 \end_inset 
3438
3439
3440 \layout Enumerate
3441
3442 Download the binary package from 
3443 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
3444
3445 \end_inset 
3446
3447  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
3448  This should unpack to a group of sub-directories.
3449  An example directory structure after unpacking the mingw32 package is:
3450  c:
3451 \backslash 
3452 sdcc
3453 \backslash 
3454 bin for the executables, c:
3455 \backslash 
3456 sdcc
3457 \backslash 
3458 include and c:
3459 \backslash 
3460 sdcc
3461 \backslash 
3462 lib for the include and libraries.
3463 \layout Enumerate
3464
3465 Adjust your environment variable PATH to include the location of the bin
3466  directory or start sdcc using the full path.
3467 \layout Section
3468
3469 Building the Documentation
3470 \layout Standard
3471
3472 If the necessary tools (LyX, LaTeX, LaTeX2HTML) are installed it is as easy
3473  as changing into the doc directory and typing 
3474 \family sans 
3475 \series bold 
3476
3477 \begin_inset Quotes srd
3478 \end_inset 
3479
3480 make
3481 \begin_inset Quotes srd
3482 \end_inset 
3483
3484
3485 \family default 
3486 \series default 
3487  there.
3488  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
3489 x).
3490  Using LyX 
3491 \begin_inset LatexCommand \url{www.lyx.org}
3492
3493 \end_inset 
3494
3495  as editor this is straightforward.
3496  Prebuilt documentation in html and pdf format is available from 
3497 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
3498
3499 \end_inset 
3500
3501 .
3502 \layout Section
3503
3504 Reading the Documentation
3505 \layout Standard
3506
3507 Currently reading the document in pdf format is recommended, as for unknown
3508  reason the hyperlinks are working there whereas in the html version they
3509  are not
3510 \begin_inset Foot
3511 collapsed false
3512
3513 \layout Standard
3514
3515 If you should know why please drop us a note
3516 \end_inset 
3517
3518 .
3519  You'll find the pdf version at 
3520 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
3521
3522 \end_inset 
3523
3524 .
3525 \newline 
3526 This documentation is in some aspects different from a commercial documentation:
3527  
3528 \layout Itemize
3529
3530 It tries to document SDCC for several processor architectures in one document
3531  (commercially these probably would be separate documents/products).
3532  This document
3533 \begin_inset LatexCommand \index{Status of documentation}
3534
3535 \end_inset 
3536
3537  currently matches SDCC for mcs51 and DS390 best and does give too few informati
3538 on about f.e.
3539  Z80, PIC14, PIC16 and HC08.
3540 \layout Itemize
3541
3542 There are many references pointing away from this documentation.
3543  Don't let this distract you.
3544  If there f.e.
3545  was a reference like 
3546 \begin_inset LatexCommand \url{www.opencores.org}
3547
3548 \end_inset 
3549
3550  together with a statement 
3551 \begin_inset Quotes sld
3552 \end_inset 
3553
3554 some processors which are targetted by SDCC can be implemented in a 
3555 \emph on 
3556 f
3557 \emph default 
3558 ield 
3559 \emph on 
3560 p
3561 \emph default 
3562 rogrammable 
3563 \emph on 
3564 g
3565 \emph default 
3566 ate 
3567 \emph on 
3568 a
3569 \emph default 
3570 rray
3571 \begin_inset LatexCommand \index{fpga (field programmable gate array)}
3572
3573 \end_inset 
3574
3575
3576 \begin_inset Quotes srd
3577 \end_inset 
3578
3579  we expect you to have a quick look there and come back.
3580  If you read this you are on the right track.
3581 \layout Itemize
3582
3583 Some sections attribute more space to problems, restrictions and warnings
3584  than to the solution.
3585 \layout Itemize
3586
3587 The installation section and the section about the debugger is intimidating.
3588 \layout Itemize
3589
3590 There are still lots of typos and there are more different writing styles
3591  than pictures.
3592 \layout Section
3593
3594 Testing the SDCC Compiler
3595 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
3596
3597 \end_inset 
3598
3599
3600 \layout Standard
3601
3602 The first thing you should do after installing your SDCC compiler is to
3603  see if it runs.
3604  Type 
3605 \family sans 
3606 \series bold 
3607 "sdcc -
3608 \begin_inset ERT
3609 status Collapsed
3610
3611 \layout Standard
3612
3613 \backslash 
3614 /
3615 \end_inset 
3616
3617 -version"
3618 \begin_inset LatexCommand \index{version}
3619
3620 \end_inset 
3621
3622
3623 \family default 
3624 \series default 
3625  at the prompt, and the program should run and tell you the version.
3626  If it doesn't run, or gives a message about not finding sdcc program, then
3627  you need to check over your installation.
3628  Make sure that the sdcc bin directory is in your executable search path
3629  defined by the PATH environment setting (
3630 \series medium 
3631 see 
3632 \series default 
3633 section 
3634 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
3635
3636 \end_inset 
3637
3638 \SpecialChar ~
3639
3640 \series medium 
3641 Install trouble-shooting for suggestions
3642 \series default 
3643 ).
3644  Make sure that the sdcc program is in the bin folder, if not perhaps something
3645  did not install correctly.
3646 \newline 
3647
3648 \newline 
3649
3650 \series medium 
3651 SDCC 
3652 \series default 
3653 is commonly installed as described in section 
3654 \begin_inset Quotes sld
3655 \end_inset 
3656
3657 Install and search paths
3658 \begin_inset Quotes srd
3659 \end_inset 
3660
3661 .
3662 \newline 
3663
3664 \newline 
3665
3666 \series medium 
3667 Make sure the compiler works on a very simple example.
3668  Type in the following test.c program using your favorite 
3669 \series default 
3670 ASCII 
3671 \series medium 
3672 editor:
3673 \layout Verse
3674
3675
3676 \family typewriter 
3677 char test;
3678 \newline 
3679
3680 \newline 
3681 void main(void) {
3682 \newline 
3683 \SpecialChar ~
3684 \SpecialChar ~
3685 \SpecialChar ~
3686 \SpecialChar ~
3687 test=0;
3688 \newline 
3689 }
3690 \layout Standard
3691
3692
3693 \series medium 
3694 Compile this using the following command: 
3695 \family sans 
3696 \series bold 
3697 "sdcc -c test.c".
3698
3699 \family default 
3700 \series default 
3701  
3702 \series medium 
3703 If all goes well, the compiler will generate a test.asm and test.rel file.
3704  Congratulations, you've just compiled your first program with SDCC.
3705  We used the -c option to tell SDCC not to link the generated code, just
3706  to keep things simple for this step.
3707 \series default 
3708
3709 \newline 
3710
3711 \newline 
3712
3713 \series medium 
3714 The next step is to try it with the linker.
3715  Type in 
3716 \family sans 
3717 \series bold 
3718 "sdcc test.c
3719 \family default 
3720 \series default 
3721 "
3722 \series medium 
3723 .
3724  If all goes well the compiler will link with the libraries and produce
3725  a test.ihx output file.
3726  If this step fails
3727 \series default 
3728  
3729 \series medium 
3730 (no test.ihx, and the linker generates warnings), then the problem is most
3731  likely that 
3732 \series default 
3733 SDCC
3734 \series medium 
3735  cannot find the 
3736 \series default 
3737 /
3738 \series medium 
3739 usr/local/share/sdcc/lib directory
3740 \series default 
3741  
3742 \series medium 
3743 (see 
3744 \series default 
3745 section 
3746 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
3747
3748 \end_inset 
3749
3750 \SpecialChar ~
3751
3752 \series medium 
3753 Install trouble-shooting for suggestions).
3754 \series default 
3755
3756 \newline 
3757
3758 \newline 
3759
3760 \series medium 
3761 The final test is to ensure 
3762 \series default 
3763 SDCC
3764 \series medium 
3765  can use the 
3766 \series default 
3767 standard
3768 \series medium 
3769  header files and libraries.
3770  Edit test.c and change it to the following:
3771 \layout Verse
3772
3773
3774 \family typewriter 
3775 #include <string.h>
3776 \newline 
3777
3778 \newline 
3779 char str1[10];
3780 \newline 
3781
3782 \newline 
3783 void main(void) {
3784 \newline 
3785 \SpecialChar ~
3786 \SpecialChar ~
3787 strcpy(str1, "testing");
3788 \newline 
3789 }
3790 \layout Standard
3791
3792
3793 \series medium 
3794 Compile this by typing 
3795 \family sans 
3796 \series bold 
3797 "sdcc test.c"
3798 \family default 
3799 \series medium 
3800 .
3801  This should generate a test.ihx output file, and it should give no warnings
3802  such as not finding the string.h file.
3803  If it cannot find the string.h file, then the problem is that 
3804 \series default 
3805 SDCC
3806 \series medium 
3807  cannot find the /usr/local/share/sdcc/include directory
3808 \series default 
3809  
3810 \series medium 
3811 (see the 
3812 \series default 
3813 section 
3814 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
3815
3816 \end_inset 
3817
3818 \SpecialChar ~
3819
3820 \series medium 
3821 Install trouble-shooting section for suggestions).
3822
3823 \series default 
3824  Use option 
3825 \series bold 
3826 -
3827 \begin_inset ERT
3828 status Collapsed
3829
3830 \layout Standard
3831
3832 \backslash 
3833 /
3834 \end_inset 
3835
3836 -print-search-dirs
3837 \series default 
3838
3839 \begin_inset LatexCommand \index{-\/-print-search-dirs}
3840
3841 \end_inset 
3842
3843  to find exactly where SDCC is looking for the include and lib files.
3844 \layout Section
3845
3846 Install Trouble-shooting
3847 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
3848
3849 \end_inset 
3850
3851
3852 \begin_inset LatexCommand \index{Install trouble-shooting}
3853
3854 \end_inset 
3855
3856
3857 \layout Subsection
3858
3859 If SDCC does not build correctly
3860 \layout Standard
3861
3862 A thing to try is starting from scratch by unpacking the .tgz source package
3863  again in an empty directory.
3864  Configure it like:
3865 \newline 
3866
3867 \newline 
3868
3869 \family sans 
3870 \series bold 
3871 ./configure 2>&1 | tee configure.log
3872 \family default 
3873 \series default 
3874
3875 \newline 
3876
3877 \newline 
3878 and build it like:
3879 \newline 
3880
3881 \newline 
3882
3883 \family sans 
3884 \series bold 
3885 make 2>&1 | tee make.log
3886 \family default 
3887 \series default 
3888
3889 \newline 
3890
3891 \newline 
3892 If anything goes wrong, you can review the log files to locate the problem.
3893  Or a relevant part of this can be attached to an email that could be helpful
3894  when requesting help from the mailing list.
3895 \layout Subsection
3896
3897 What the 
3898 \begin_inset Quotes sld
3899 \end_inset 
3900
3901 ./configure
3902 \begin_inset Quotes srd
3903 \end_inset 
3904
3905  does
3906 \layout Standard
3907
3908 The 
3909 \begin_inset Quotes sld
3910 \end_inset 
3911
3912 ./configure
3913 \begin_inset Quotes srd
3914 \end_inset 
3915
3916  command is a script that analyzes your system and performs some configuration
3917  to ensure the source package compiles on your system.
3918  It will take a few minutes to run, and will compile a few tests to determine
3919  what compiler features are installed.
3920 \layout Subsection
3921
3922 What the 
3923 \begin_inset Quotes sld
3924 \end_inset 
3925
3926 make
3927 \begin_inset Quotes srd
3928 \end_inset 
3929
3930  does
3931 \layout Standard
3932
3933 This runs the GNU make tool, which automatically compiles all the source
3934  packages into the final installed binary executables.
3935 \layout Subsection
3936
3937 What the 
3938 \begin_inset Quotes sld
3939 \end_inset 
3940
3941 make install
3942 \begin_inset Quotes erd
3943 \end_inset 
3944
3945  command does.
3946 \layout Standard
3947
3948 This will install the compiler, other executables libraries and include
3949  files into the appropriate directories.
3950  See sections 
3951 \begin_inset LatexCommand \ref{sub:Install-paths}
3952
3953 \end_inset 
3954
3955 ,\SpecialChar ~
3956
3957 \begin_inset LatexCommand \ref{sub:Search-Paths}
3958
3959 \end_inset 
3960
3961 \SpecialChar ~
3962 about install and search paths.
3963 \newline 
3964 On most systems you will need super-user privileges to do this.
3965 \layout Section
3966
3967 Components of SDCC
3968 \layout Standard
3969
3970 SDCC is not just a compiler, but a collection of tools by various developers.
3971  These include linkers, assemblers, simulators and other components.
3972  Here is a summary of some of the components.
3973  Note that the included simulator and assembler have separate documentation
3974  which you can find in the source package in their respective directories.
3975  As SDCC grows to include support for other processors, other packages from
3976  various developers are included and may have their own sets of documentation.
3977 \newline 
3978
3979 \newline 
3980 You might want to look at the files which are installed in <installdir>.
3981  At the time of this writing, we find the following programs for gcc-builds:
3982 \newline 
3983  
3984 \newline 
3985 In <installdir>/bin:
3986 \layout Itemize
3987
3988 sdcc - The compiler.
3989 \layout Itemize
3990
3991 sdcpp - The C preprocessor.
3992 \layout Itemize
3993
3994 asx8051 - The assembler for 8051 type processors.
3995 \layout Itemize
3996
3997 as-z80
3998 \series bold 
3999
4000 \series default 
4001 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
4002 \layout Itemize
4003
4004 aslink -The linker for 8051 type processors.
4005 \layout Itemize
4006
4007 link-z80
4008 \series bold 
4009
4010 \series default 
4011 link-gbz80 - The Z80 and GameBoy Z80 linkers.
4012 \layout Itemize
4013
4014 s51 - The ucSim 8051 simulator.
4015 \layout Itemize
4016
4017 sdcdb - The source debugger.
4018 \layout Itemize
4019
4020 packihx - A tool to pack (compress) Intel hex files.
4021 \layout Standard
4022
4023 In <installdir>/share/sdcc/include
4024 \layout Itemize
4025
4026 the include files
4027 \layout Standard
4028
4029 In <installdir>/share/sdcc/lib
4030 \layout Itemize
4031
4032 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
4033  relocatables.
4034 \layout Standard
4035
4036 In <installdir>/share/sdcc/doc
4037 \layout Itemize
4038
4039 the documentation
4040 \layout Standard
4041
4042 As development for other processors proceeds, this list will expand to include
4043  executables to support processors like AVR, PIC, etc.
4044 \layout Subsection
4045
4046 sdcc - The Compiler
4047 \layout Standard
4048
4049 This is the actual compiler, it in turn uses the c-preprocessor and invokes
4050  the assembler and linkage editor.
4051 \layout Subsection
4052
4053 sdcpp - The C-Preprocessor
4054 \layout Standard
4055
4056 The preprocessor
4057 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
4058
4059 \end_inset 
4060
4061  is a modified version of the GNU preprocessor.
4062  The C preprocessor is used to pull in #include sources, process #ifdef
4063  statements, #defines and so on.
4064 \layout Subsection
4065
4066 as
4067 \emph on 
4068 xxxx
4069 \emph default 
4070 , aslink, link-
4071 \emph on 
4072 xxx
4073 \emph default 
4074  - The Assemblers and Linkage Editors
4075 \layout Standard
4076
4077 This is retargettable assembler & linkage editor, it was developed by Alan
4078  Baldwin.
4079  John Hartman created the version for 8051, and I (Sandeep) have made some
4080  enhancements and bug fixes for it to work properly with SDCC.
4081 \layout Subsection
4082
4083 s51 - The Simulator
4084 \layout Standard
4085
4086 S51
4087 \begin_inset LatexCommand \index{s51}
4088
4089 \end_inset 
4090
4091  is a freeware, opensource simulator developed by Daniel Drotos (
4092 \begin_inset LatexCommand \url{mailto:drdani@mazsola.iit.uni-miskolc.hu}
4093
4094 \end_inset 
4095
4096 ).
4097  The simulator is built as part of the build process.
4098  For more information visit Daniel's web site at: 
4099 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
4100
4101 \end_inset 
4102
4103 .
4104  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
4105  XA51 family.
4106 \layout Subsection
4107
4108 sdcdb - Source Level Debugger
4109 \layout Standard
4110
4111 Sdcdb
4112 \begin_inset LatexCommand \index{sdcdb (debugger)}
4113
4114 \end_inset 
4115
4116  is the companion source level debugger.
4117  More about sdcdb in section 
4118 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
4119
4120 \end_inset 
4121
4122 .
4123  The current version of the debugger uses Daniel's Simulator S51
4124 \begin_inset LatexCommand \index{s51}
4125
4126 \end_inset 
4127
4128 , but can be easily changed to use other simulators.
4129  
4130 \layout Chapter
4131
4132 Using SDCC
4133 \layout Section
4134
4135 Compiling
4136 \layout Subsection
4137
4138 Single Source File Projects
4139 \layout Standard
4140
4141 For single source file 8051 projects the process is very simple.
4142  Compile your programs with the following command 
4143 \family sans 
4144 \series bold 
4145 "sdcc sourcefile.c".
4146
4147 \family default 
4148 \series default 
4149  This will compile, assemble and link your source file.
4150  Output files are as follows:
4151 \layout Itemize
4152
4153 sourcefile.asm
4154 \begin_inset LatexCommand \index{<file>.asm}
4155
4156 \end_inset 
4157
4158  - Assembler source
4159 \begin_inset LatexCommand \index{Assembler source}
4160
4161 \end_inset 
4162
4163  file created by the compiler
4164 \layout Itemize
4165
4166 sourcefile.lst
4167 \begin_inset LatexCommand \index{<file>.lst}
4168
4169 \end_inset 
4170
4171  - Assembler listing
4172 \begin_inset LatexCommand \index{Assembler listing}
4173
4174 \end_inset 
4175
4176  file created by the Assembler
4177 \layout Itemize
4178
4179 sourcefile.rst
4180 \begin_inset LatexCommand \index{<file>.rst}
4181
4182 \end_inset 
4183
4184  - Assembler listing
4185 \begin_inset LatexCommand \index{Assembler listing}
4186
4187 \end_inset 
4188
4189  file updated with linkedit information, created by linkage editor
4190 \layout Itemize
4191
4192 sourcefile.sym
4193 \begin_inset LatexCommand \index{<file>.sym}
4194
4195 \end_inset 
4196
4197  - symbol listing
4198 \begin_inset LatexCommand \index{Symbol listing}
4199
4200 \end_inset 
4201
4202  for the sourcefile, created by the assembler
4203 \layout Itemize
4204
4205 sourcefile.rel
4206 \begin_inset LatexCommand \index{<file>.rel}
4207
4208 \end_inset 
4209
4210  or sourcefile.o
4211 \begin_inset LatexCommand \index{<file>.o}
4212
4213 \end_inset 
4214
4215  - Object file
4216 \begin_inset LatexCommand \index{Object file}
4217
4218 \end_inset 
4219
4220  created by the assembler, input to Linkage editor
4221 \layout Itemize
4222
4223 sourcefile.map
4224 \begin_inset LatexCommand \index{<file>.map}
4225
4226 \end_inset 
4227
4228  - The memory map
4229 \begin_inset LatexCommand \index{Memory map}
4230
4231 \end_inset 
4232
4233  for the load module, created by the Linker
4234 \layout Itemize
4235
4236 sourcefile.mem
4237 \begin_inset LatexCommand \index{<file>.mem}
4238
4239 \end_inset 
4240
4241  - A file with a summary of the memory usage
4242 \layout Itemize
4243
4244 sourcefile.ihx
4245 \begin_inset LatexCommand \index{<file>.ihx}
4246
4247 \end_inset 
4248
4249  - The load module in Intel hex format
4250 \begin_inset LatexCommand \index{Intel hex format}
4251
4252 \end_inset 
4253
4254  (you can select the Motorola S19 format
4255 \begin_inset LatexCommand \index{Motorola S19 format}
4256
4257 \end_inset 
4258
4259  with -
4260 \begin_inset ERT
4261 status Collapsed
4262
4263 \layout Standard
4264
4265 \backslash 
4266 /
4267 \end_inset 
4268
4269 -out-fmt-s19
4270 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
4271
4272 \end_inset 
4273
4274 .
4275  If you need another format you might want to use 
4276 \family sans 
4277 \shape italic 
4278 objdump
4279 \family default 
4280 \shape default 
4281
4282 \begin_inset LatexCommand \index{objdump (tool)}
4283
4284 \end_inset 
4285
4286  or
4287 \family sans 
4288 \shape italic 
4289  srecord
4290 \family default 
4291 \shape default 
4292
4293 \begin_inset LatexCommand \index{srecord (tool)}
4294
4295 \end_inset 
4296
4297 ).
4298  Both formats are documented in the documentation of srecord
4299 \begin_inset LatexCommand \index{srecord (tool)}
4300
4301 \end_inset 
4302
4303
4304 \layout Itemize
4305
4306 sourcefile.adb
4307 \begin_inset LatexCommand \index{<file>.adb}
4308
4309 \end_inset 
4310
4311  - An intermediate file containing debug information needed to create the
4312  .cdb file (with -
4313 \begin_inset ERT
4314 status Open
4315
4316 \layout Standard
4317
4318 \backslash 
4319 /
4320 \end_inset 
4321
4322 -debug
4323 \begin_inset LatexCommand \index{-\/-debug}
4324
4325 \end_inset 
4326
4327
4328 \layout Itemize
4329
4330 sourcefile.cdb
4331 \begin_inset LatexCommand \index{<file>.cdb}
4332
4333 \end_inset 
4334
4335  - An optional file (with -
4336 \begin_inset ERT
4337 status Collapsed
4338
4339 \layout Standard
4340
4341 \backslash 
4342 /
4343 \end_inset 
4344
4345 -debug) containing debug information.
4346  The format is documented in cdbfileformat.pdf.
4347 \layout Itemize
4348
4349 sourcefile.
4350  - (no extension)
4351 \begin_inset LatexCommand \index{<file> (no extension)}
4352
4353 \end_inset 
4354
4355  An optional AOMF or AOMF51
4356 \begin_inset LatexCommand \index{AOMF, AOMF51}
4357
4358 \end_inset 
4359
4360  file containing debug information (generated with option -
4361 \begin_inset ERT
4362 status Collapsed
4363
4364 \layout Standard
4365
4366 \backslash 
4367 /
4368 \end_inset 
4369
4370 -debug).
4371  The (Intel)
4372 \emph on 
4373  a
4374 \emph default 
4375 bsolute 
4376 \emph on 
4377 o
4378 \emph default 
4379 bject 
4380 \emph on 
4381 m
4382 \emph default 
4383 odule 
4384 \emph on 
4385 f
4386 \emph default 
4387 ormat is commonly used by third party tools (debuggers
4388 \begin_inset LatexCommand \index{Debugger}
4389
4390 \end_inset 
4391
4392 , simulators, emulators)
4393 \layout Itemize
4394
4395 sourcefile.dump*
4396 \begin_inset LatexCommand \index{<file>.dump*}
4397
4398 \end_inset 
4399
4400  - Dump file to debug the compiler it self (generated with option -
4401 \begin_inset ERT
4402 status Collapsed
4403
4404 \layout Standard
4405
4406 \backslash 
4407 /
4408 \end_inset 
4409
4410 -dumpall) (see section 
4411 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
4412
4413 \end_inset 
4414
4415 \SpecialChar ~
4416  and section 
4417 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
4418
4419 \end_inset 
4420
4421 \SpecialChar ~
4422
4423 \begin_inset Quotes sld
4424 \end_inset 
4425
4426 Anatomy of the compiler
4427 \begin_inset Quotes srd
4428 \end_inset 
4429
4430 ).
4431 \layout Subsection
4432
4433 Projects with Multiple Source Files
4434 \layout Standard
4435
4436 SDCC can compile only ONE file at a time.
4437  Let us for example assume that you have a project containing the following
4438  files:
4439 \newline 
4440
4441 \newline 
4442 foo1.c (contains some functions)
4443 \newline 
4444 foo2.c (contains some more functions)
4445 \newline 
4446 foomain.c (contains more functions and the function main)
4447 \newline 
4448
4449 \size footnotesize 
4450
4451 \newline 
4452
4453 \size default 
4454 The first two files will need to be compiled separately with the commands:
4455 \size footnotesize 
4456  
4457 \size default 
4458
4459 \newline 
4460
4461 \newline 
4462
4463 \family sans 
4464 \series bold 
4465 sdcc\SpecialChar ~
4466 -c\SpecialChar ~
4467 foo1.c
4468 \family default 
4469 \series default 
4470 \size footnotesize 
4471
4472 \newline 
4473
4474 \family sans 
4475 \series bold 
4476 \size default 
4477 sdcc\SpecialChar ~
4478 -c\SpecialChar ~
4479 foo2.c
4480 \family default 
4481 \series default 
4482
4483 \newline 
4484
4485 \newline 
4486 Then compile the source file containing the 
4487 \emph on 
4488 main()
4489 \emph default 
4490  function and link
4491 \begin_inset LatexCommand \index{Linker}
4492
4493 \end_inset 
4494
4495  the files together with the following command: 
4496 \newline 
4497
4498 \newline 
4499
4500 \family sans 
4501 \series bold 
4502 sdcc\SpecialChar ~
4503 foomain.c\SpecialChar ~
4504 foo1.rel\SpecialChar ~
4505 foo2.rel
4506 \family default 
4507 \series default 
4508
4509 \begin_inset LatexCommand \index{<file>.rel}
4510
4511 \end_inset 
4512
4513
4514 \newline 
4515
4516 \newline 
4517 Alternatively, 
4518 \emph on 
4519 foomain.c 
4520 \emph default 
4521 can be separately compiled as well: 
4522 \family sans 
4523 \series bold 
4524
4525 \newline 
4526
4527 \newline 
4528 sdcc\SpecialChar ~
4529 -c\SpecialChar ~
4530 foomain.c
4531 \newline 
4532 sdcc foomain.rel foo1.rel foo2.rel
4533 \newline 
4534
4535 \newline 
4536
4537 \family default 
4538 \series default 
4539 The file containing the 
4540 \emph on 
4541 main()
4542 \emph default 
4543  function
4544 \emph on 
4545  
4546 \emph default 
4547 \noun on 
4548 must
4549 \noun default 
4550  be the 
4551 \noun on 
4552 first
4553 \noun default 
4554  file specified in the command line, since the linkage editor processes
4555  file in the order they are presented to it.
4556  The linker is invoked from SDCC using a script file with extension .lnk
4557 \begin_inset LatexCommand \index{<file>.lnk}
4558
4559 \end_inset 
4560
4561 .
4562  You can view this file to troubleshoot linking problems such as those arising
4563  from missing libraries.
4564 \layout Subsection
4565
4566 Projects with Additional Libraries
4567 \begin_inset LatexCommand \index{Libraries}
4568
4569 \end_inset 
4570
4571
4572 \layout Standard
4573
4574 Some reusable routines may be compiled into a library, see the documentation
4575  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
4576  for how to create a 
4577 \emph on 
4578 .lib
4579 \begin_inset LatexCommand \index{<file>.lib}
4580
4581 \end_inset 
4582
4583
4584 \emph default 
4585  library file.
4586  Libraries created in this manner can be included in the command line.
4587  Make sure you include the -L <library-path> option to tell the linker where
4588  to look for these files if they are not in the current directory.
4589  Here is an example, assuming you have the source file 
4590 \emph on 
4591 foomain.c
4592 \emph default 
4593  and a library
4594 \emph on 
4595  foolib.lib
4596 \emph default 
4597  in the directory 
4598 \emph on 
4599 mylib
4600 \emph default 
4601  (if that is not the same as your current project):
4602 \newline 
4603
4604 \newline 
4605
4606 \family sans 
4607 \series bold 
4608 sdcc foomain.c foolib.lib -L mylib
4609 \newline 
4610
4611 \newline 
4612
4613 \family default 
4614 \series default 
4615 Note here that
4616 \emph on 
4617  mylib
4618 \emph default 
4619  must be an absolute path name.
4620 \newline 
4621
4622 \newline 
4623 The most efficient way to use libraries is to keep separate modules in separate
4624  source files.
4625  The lib file now should name all the modules.rel
4626 \begin_inset LatexCommand \index{<file>.rel}
4627
4628 \end_inset 
4629
4630  files.
4631  For an example see the standard library file 
4632 \emph on 
4633 libsdcc.lib
4634 \emph default 
4635  in the directory <installdir>/share/lib/small.
4636 \layout Subsection
4637
4638 Using sdcclib to Create and Manage Libraries
4639 \begin_inset LatexCommand \index{sdcclib}
4640
4641 \end_inset 
4642
4643
4644 \layout Standard
4645
4646 Alternatively, instead of having a .rel file for each entry on the library
4647  file as described in the preceding section, sdcclib can be used to embed
4648  all the modules belonging to such library in the library file itself.
4649  This results in a larger library file, but it greatly reduces the number
4650  of disk files accessed by the linker.
4651   Additionally, the packed library file contains an index of all include
4652  modules and symbols that significantly speeds up the linking process.
4653  To display a list of options supported by sdcclib type:
4654 \newline 
4655
4656 \layout Standard
4657
4658
4659 \family sans 
4660 \series bold 
4661 sdcclib -?
4662 \begin_inset LatexCommand \index{sdcclib}
4663
4664 \end_inset 
4665
4666
4667 \newline 
4668
4669 \newline 
4670
4671 \family default 
4672 \series default 
4673 To create a new library file, start by compiling all the required modules.
4674  For example:
4675 \newline 
4676
4677 \layout Standard
4678
4679
4680 \family sans 
4681 \series bold 
4682 sdcc -c _divsint.c
4683 \layout Standard
4684
4685
4686 \family sans 
4687 \series bold 
4688 sdcc -c _divuint.c
4689 \layout Standard
4690
4691
4692 \family sans 
4693 \series bold 
4694 sdcc -c _modsint.c
4695 \layout Standard
4696
4697
4698 \family sans 
4699 \series bold 
4700 sdcc -c _moduint.c
4701 \layout Standard
4702
4703
4704 \family sans 
4705 \series bold 
4706 sdcc -c _mulint.c
4707 \newline 
4708
4709 \layout Standard
4710
4711 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
4712  and _mulint.rel.
4713  The next step is to add the .rel files to the library file:
4714 \newline 
4715
4716 \layout Standard
4717
4718
4719 \family sans 
4720 \series bold 
4721 sdcclib libint.lib _divsint.rel
4722 \family default 
4723
4724 \begin_inset LatexCommand \index{sdcclib}
4725
4726 \end_inset 
4727
4728
4729 \layout Standard
4730
4731
4732 \family sans 
4733 \series bold 
4734 sdcclib libint.lib _divuint.rel
4735 \layout Standard
4736
4737
4738 \family sans 
4739 \series bold 
4740 sdcclib libint.lib _modsint.rel
4741 \layout Standard
4742
4743
4744 \family sans 
4745 \series bold 
4746 sdcclib libint.lib _moduint.rel
4747 \layout Standard
4748
4749
4750 \family sans 
4751 \series bold 
4752 sdcclib libint.lib _mulint.rel
4753 \series default 
4754
4755 \newline 
4756
4757 \layout Standard
4758
4759 If the file already exists in the library, it will be replaced.
4760  To see what modules and symbols are included in the library, options -s
4761  and -m are available.
4762  For example:
4763 \newline 
4764
4765 \newline 
4766
4767 \family sans 
4768 \series bold 
4769 sdcclib -s libint.lib
4770 \family default 
4771
4772 \begin_inset LatexCommand \index{sdcclib}
4773
4774 \end_inset 
4775
4776
4777 \newline 
4778
4779 \family typewriter 
4780 \series default 
4781 _divsint.rel:
4782 \layout Standard
4783
4784
4785 \family typewriter 
4786 __divsint_a_1_1
4787 \layout Standard
4788
4789
4790 \family typewriter 
4791 __divsint_PARM_2
4792 \layout Standard
4793
4794
4795 \family typewriter 
4796 __divsint
4797 \newline 
4798 _divuint.rel:
4799 \layout Standard
4800
4801
4802 \family typewriter 
4803 __divuint_a_1_1
4804 \layout Standard
4805
4806
4807 \family typewriter 
4808 __divuint_PARM_2
4809 \layout Standard
4810
4811
4812 \family typewriter 
4813 __divuint_reste_1_1
4814 \layout Standard
4815
4816
4817 \family typewriter 
4818 __divuint_count_1_1
4819 \layout Standard
4820
4821
4822 \family typewriter 
4823 __divuint
4824 \newline 
4825 _modsint.rel:
4826 \layout Standard
4827
4828
4829 \family typewriter 
4830 __modsint_a_1_1
4831 \layout Standard
4832
4833
4834 \family typewriter 
4835 __modsint_PARM_2
4836 \layout Standard
4837
4838
4839 \family typewriter 
4840 __modsint
4841 \newline 
4842 _moduint.rel:
4843 \layout Standard
4844
4845
4846 \family typewriter 
4847 __moduint_a_1_1
4848 \layout Standard
4849
4850
4851 \family typewriter 
4852 __moduint_PARM_2
4853 \layout Standard
4854
4855
4856 \family typewriter 
4857 __moduint_count_1_1
4858 \layout Standard
4859
4860
4861 \family typewriter 
4862 __moduint
4863 \newline 
4864 _mulint.rel:
4865 \layout Standard
4866
4867
4868 \family typewriter 
4869 __mulint_PARM_2
4870 \layout Standard
4871
4872
4873 \family typewriter 
4874 __mulint
4875 \family default 
4876 \series bold 
4877
4878 \newline 
4879
4880 \layout Standard
4881
4882 If the source files are compiled using -
4883 \begin_inset ERT
4884 status Open
4885
4886 \layout Standard
4887
4888 \backslash 
4889 /
4890 \end_inset 
4891
4892 -debug
4893 \begin_inset LatexCommand \index{-\/-debug}
4894
4895 \end_inset 
4896
4897 , the corresponding debug information file .adb will be include in the library
4898  file as well.
4899  The library files created with sdcclib are plain text files, so they can
4900  be viewed with a text editor.
4901  It is not recomended to modify a library file created with sdcclib using
4902  a text editor, as there are file indexes numbers located accross the file
4903  used by the linker to quickly locate the required module to link.
4904  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
4905  it can be safely deleted, since all the information required for linking
4906  is embedded in the library file itself.
4907  Library files created using sdcclib are used as described in the preceding
4908  sections.
4909 \layout Section
4910
4911 Command Line Options
4912 \begin_inset LatexCommand \index{Command Line Options}
4913
4914 \end_inset 
4915
4916
4917 \layout Subsection
4918
4919 Processor Selection Options
4920 \begin_inset LatexCommand \index{Options processor selection}
4921
4922 \end_inset 
4923
4924
4925 \begin_inset LatexCommand \index{Processor selection options}
4926
4927 \end_inset 
4928
4929
4930 \layout List
4931 \labelwidthstring 00.00.0000
4932
4933
4934 \series bold 
4935 -mmcs51
4936 \begin_inset LatexCommand \index{-mmcs51}
4937
4938 \end_inset 
4939
4940
4941 \series default 
4942  Generate code for the Intel MCS51
4943 \begin_inset LatexCommand \index{MCS51}
4944
4945 \end_inset 
4946
4947  family of processors.
4948  This is the default processor target.
4949 \layout List
4950 \labelwidthstring 00.00.0000
4951
4952
4953 \series bold 
4954 -mds390
4955 \begin_inset LatexCommand \index{-mds390}
4956
4957 \end_inset 
4958
4959
4960 \series default 
4961  Generate code for the Dallas DS80C390
4962 \begin_inset LatexCommand \index{DS80C390}
4963
4964 \end_inset 
4965
4966  processor.
4967 \layout List
4968 \labelwidthstring 00.00.0000
4969
4970
4971 \series bold 
4972 -mds400
4973 \begin_inset LatexCommand \index{-mds400}
4974
4975 \end_inset 
4976
4977
4978 \series default 
4979  Generate code for the Dallas DS80C400
4980 \begin_inset LatexCommand \index{DS80C400}
4981
4982 \end_inset 
4983
4984  processor.
4985 \layout List
4986 \labelwidthstring 00.00.0000
4987
4988
4989 \series bold 
4990 -mhc08
4991 \begin_inset LatexCommand \index{-mhc08}
4992
4993 \end_inset 
4994
4995
4996 \series default 
4997  Generate code for the Motorola HC08
4998 \begin_inset LatexCommand \index{HC08}
4999
5000 \end_inset 
5001
5002  family of processors (added Oct 2003).
5003 \layout List
5004 \labelwidthstring 00.00.0000
5005
5006
5007 \series bold 
5008 -mz80
5009 \begin_inset LatexCommand \index{-mz80}
5010
5011 \end_inset 
5012
5013
5014 \series default 
5015  Generate code for the Zilog Z80
5016 \begin_inset LatexCommand \index{Z80}
5017
5018 \end_inset 
5019
5020  family of processors.
5021 \layout List
5022 \labelwidthstring 00.00.0000
5023
5024
5025 \series bold 
5026 -mgbz80
5027 \begin_inset LatexCommand \index{-mgbz80}
5028
5029 \end_inset 
5030
5031
5032 \series default 
5033  Generate code for the GameBoy Z80
5034 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
5035
5036 \end_inset 
5037
5038  processor (Not actively maintained).
5039 \layout List
5040 \labelwidthstring 00.00.0000
5041
5042
5043 \series bold 
5044 -mavr
5045 \begin_inset LatexCommand \index{-mavr}
5046
5047 \end_inset 
5048
5049
5050 \series default 
5051  Generate code for the Atmel AVR
5052 \begin_inset LatexCommand \index{AVR}
5053
5054 \end_inset 
5055
5056  processor (In development, not complete).
5057  AVR users should probably have a look at avr-gcc 
5058 \begin_inset LatexCommand \url{ http://savannah.nongnu.org/download/avr-libc/snapshots/}
5059
5060 \end_inset 
5061
5062  or winavr 
5063 \begin_inset LatexCommand \url{http://winavr.sourceforge.net}
5064
5065 \end_inset 
5066
5067 .
5068 \layout Comment
5069
5070 I think it is fair to direct users there for now.
5071  Open source is also about avoiding unnecessary work .
5072  But I didn't find the 'official' link.
5073 \layout List
5074 \labelwidthstring 00.00.0000
5075
5076
5077 \series bold 
5078 -mpic14
5079 \begin_inset LatexCommand \index{-mpic14}
5080
5081 \end_inset 
5082
5083
5084 \series default 
5085  Generate code for the Microchip PIC 14
5086 \begin_inset LatexCommand \index{PIC14}
5087
5088 \end_inset 
5089
5090 -bit processors (p16f84 and variants.
5091  In development, not complete).
5092 \layout Comment
5093
5094 p16f627 p16f628 p16f84 p16f873 p16f877?
5095 \layout List
5096 \labelwidthstring 00.00.0000
5097
5098
5099 \series bold 
5100 -mpic16
5101 \begin_inset LatexCommand \index{-mpic16}
5102
5103 \end_inset 
5104
5105
5106 \series default 
5107  Generate code for the Microchip PIC 16
5108 \begin_inset LatexCommand \index{PIC16}
5109
5110 \end_inset 
5111
5112 -bit processors (p18f452 and variants.
5113  In development, not complete).
5114 \layout List
5115 \labelwidthstring 00.00.0000
5116
5117
5118 \series bold 
5119 -mtlcs900h
5120 \series default 
5121  Generate code for the Toshiba TLCS-900H
5122 \begin_inset LatexCommand \index{TLCS-900H}
5123
5124 \end_inset 
5125
5126  processor (Not maintained, not complete).
5127 \layout List
5128 \labelwidthstring 00.00.0000
5129
5130
5131 \series bold 
5132 -mxa51
5133 \begin_inset LatexCommand \index{-mxa51}
5134
5135 \end_inset 
5136
5137
5138 \series default 
5139  Generate code for the Phillips XA51
5140 \begin_inset LatexCommand \index{XA51}
5141
5142 \end_inset 
5143
5144  processor (Not maintained, not complete).
5145 \layout Subsection
5146
5147 Preprocessor Options
5148 \begin_inset LatexCommand \index{Options preprocessor}
5149
5150 \end_inset 
5151
5152
5153 \begin_inset LatexCommand \index{Preprocessor options}
5154
5155 \end_inset 
5156
5157
5158 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5159
5160 \end_inset 
5161
5162
5163 \layout List
5164 \labelwidthstring 00.00.0000
5165
5166
5167 \series bold 
5168 -I<path>
5169 \begin_inset LatexCommand \index{-I<path>}
5170
5171 \end_inset 
5172
5173
5174 \series default 
5175  The additional location where the pre processor will look for <..h> or 
5176 \begin_inset Quotes eld
5177 \end_inset 
5178
5179 ..h
5180 \begin_inset Quotes erd
5181 \end_inset 
5182
5183  files.
5184 \layout List
5185 \labelwidthstring 00.00.0000
5186
5187
5188 \series bold 
5189 -D<macro[=value]>
5190 \begin_inset LatexCommand \index{-D<macro[=value]>}
5191
5192 \end_inset 
5193
5194
5195 \series default 
5196  Command line definition of macros.
5197  Passed to the preprocessor.
5198 \layout List
5199 \labelwidthstring 00.00.0000
5200
5201
5202 \series bold 
5203 -M
5204 \begin_inset LatexCommand \index{-M}
5205
5206 \end_inset 
5207
5208
5209 \series default 
5210  Tell the preprocessor to output a rule suitable for make describing the
5211  dependencies of each object file.
5212  For each source file, the preprocessor outputs one make-rule whose target
5213  is the object file name for that source file and whose dependencies are
5214  all the files `#include'd in it.
5215  This rule may be a single line or may be continued with `
5216 \backslash 
5217 '-newline if it is long.
5218  The list of rules is printed on standard output instead of the preprocessed
5219  C program.
5220  `-M' implies `-E
5221 \begin_inset LatexCommand \index{-E}
5222
5223 \end_inset 
5224
5225 '.
5226 \layout List
5227 \labelwidthstring 00.00.0000
5228
5229
5230 \series bold 
5231 -C
5232 \begin_inset LatexCommand \index{-C}
5233
5234 \end_inset 
5235
5236
5237 \series default 
5238  Tell the preprocessor not to discard comments.
5239  Used with the `-E' option.
5240 \layout List
5241 \labelwidthstring 00.00.0000
5242
5243
5244 \series bold 
5245 -MM
5246 \begin_inset LatexCommand \index{-MM}
5247
5248 \end_inset 
5249
5250
5251 \size large 
5252 \bar under 
5253  
5254 \series default 
5255 \size default 
5256 \bar default 
5257 Like `-M' but the output mentions only the user header files included with
5258  `#include 
5259 \begin_inset Quotes eld
5260 \end_inset 
5261
5262 file"'.
5263  System header files included with `#include <file>' are omitted.
5264 \layout List
5265 \labelwidthstring 00.00.0000
5266
5267
5268 \series bold 
5269 -Aquestion(answer)
5270 \begin_inset LatexCommand \index{-Aquestion(answer)}
5271
5272 \end_inset 
5273
5274
5275 \series default 
5276  Assert the answer answer for question, in case it is tested with a preprocessor
5277  conditional such as `#if #question(answer)'.
5278  `-A-' disables the standard assertions that normally describe the target
5279  machine.
5280 \layout List
5281 \labelwidthstring 00.00.0000
5282
5283
5284 \series bold 
5285 -Umacro
5286 \begin_inset LatexCommand \index{-Umacro}
5287
5288 \end_inset 
5289
5290
5291 \series default 
5292  Undefine macro macro.
5293  `-U' options are evaluated after all `-D' options, but before any `-include'
5294  and `-imacros' options.
5295 \layout List
5296 \labelwidthstring 00.00.0000
5297
5298
5299 \series bold 
5300 -dM
5301 \begin_inset LatexCommand \index{-dM}
5302
5303 \end_inset 
5304
5305
5306 \series default 
5307  Tell the preprocessor to output only a list of the macro definitions that
5308  are in effect at the end of preprocessing.
5309  Used with the `-E' option.
5310 \layout List
5311 \labelwidthstring 00.00.0000
5312
5313
5314 \series bold 
5315 -dD
5316 \begin_inset LatexCommand \index{-dD}
5317
5318 \end_inset 
5319
5320
5321 \series default 
5322  Tell the preprocessor to pass all macro definitions into the output, in
5323  their proper sequence in the rest of the output.
5324 \layout List
5325 \labelwidthstring 00.00.0000
5326
5327
5328 \series bold 
5329 -dN
5330 \begin_inset LatexCommand \index{-dN}
5331
5332 \end_inset 
5333
5334
5335 \size large 
5336 \bar under 
5337  
5338 \series default 
5339 \size default 
5340 \bar default 
5341 Like `-dD' except that the macro arguments and contents are omitted.
5342  Only `#define name' is included in the output.
5343 \layout List
5344 \labelwidthstring 00.00.0000
5345
5346
5347 \series bold 
5348 -Wp\SpecialChar ~
5349 preprocessorOption[,preprocessorOption]
5350 \series default 
5351
5352 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
5353
5354 \end_inset 
5355
5356 ...
5357  Pass the preprocessorOption to the preprocessor 
5358 \family typewriter 
5359 sdcpp
5360 \family default 
5361
5362 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5363
5364 \end_inset 
5365
5366 .
5367  SDCC uses an adapted version of the preprocessor cpp of the GNU Compiler
5368  Collection (gcc), if you need more dedicated options please refer to the
5369  documentation at 
5370 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
5371
5372 \end_inset 
5373
5374 .
5375 \layout Subsection
5376
5377 Linker Options
5378 \begin_inset LatexCommand \index{Options linker}
5379
5380 \end_inset 
5381
5382
5383 \begin_inset LatexCommand \index{Linker options}
5384
5385 \end_inset 
5386
5387
5388 \layout List
5389 \labelwidthstring 00.00.0000
5390
5391
5392 \series bold 
5393 -L\SpecialChar ~
5394 -
5395 \series default 
5396
5397 \begin_inset ERT
5398 status Collapsed
5399
5400 \layout Standard
5401
5402 \backslash 
5403 /
5404 \end_inset 
5405
5406
5407 \series bold 
5408 -lib-path
5409 \begin_inset LatexCommand \index{-\/-lib-path <path>}
5410
5411 \end_inset 
5412
5413
5414 \begin_inset LatexCommand \index{-L -\/-lib-path}
5415
5416 \end_inset 
5417
5418
5419 \series default 
5420 \SpecialChar ~
5421 <absolute path to additional libraries> This option is passed to the linkage
5422  editor's additional libraries
5423 \begin_inset LatexCommand \index{Libraries}
5424
5425 \end_inset 
5426
5427  search path.
5428  The path name must be absolute.
5429  Additional library files may be specified in the command line.
5430  See section Compiling programs for more details.
5431 \layout List
5432 \labelwidthstring 00.00.0000
5433
5434
5435 \series bold 
5436 -
5437 \begin_inset ERT
5438 status Collapsed
5439
5440 \layout Standard
5441
5442 \backslash 
5443 /
5444 \end_inset 
5445
5446 -xram-loc
5447 \series default 
5448
5449 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
5450
5451 \end_inset 
5452
5453 \SpecialChar ~
5454 <Value> The start location of the external ram
5455 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
5456
5457 \end_inset 
5458
5459 , default value is 0.
5460  The value entered can be in Hexadecimal or Decimal format, e.g.: -
5461 \begin_inset ERT
5462 status Collapsed
5463
5464 \layout Standard
5465
5466 \backslash 
5467 /
5468 \end_inset 
5469
5470 -xram-loc 0x8000 or -
5471 \begin_inset ERT
5472 status Collapsed
5473
5474 \layout Standard
5475
5476 \backslash 
5477 /
5478 \end_inset 
5479
5480 -xram-loc 32768.
5481 \layout List
5482 \labelwidthstring 00.00.0000
5483
5484
5485 \series bold 
5486 -
5487 \begin_inset ERT
5488 status Collapsed
5489
5490 \layout Standard
5491
5492 \backslash 
5493 /
5494 \end_inset 
5495
5496 -code-loc
5497 \series default 
5498
5499 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
5500
5501 \end_inset 
5502
5503 \SpecialChar ~
5504 <Value> The start location of the code
5505 \begin_inset LatexCommand \index{code}
5506
5507 \end_inset 
5508
5509  segment, default value 0.
5510  Note when this option is used the interrupt vector table is also relocated
5511  to the given address.
5512  The value entered can be in Hexadecimal or Decimal format, e.g.: -
5513 \begin_inset ERT
5514 status Collapsed
5515
5516 \layout Standard
5517
5518 \backslash 
5519 /
5520 \end_inset 
5521
5522 -code-loc 0x8000 or -
5523 \begin_inset ERT
5524 status Collapsed
5525
5526 \layout Standard
5527
5528 \backslash 
5529 /
5530 \end_inset 
5531
5532 -code-loc 32768.
5533 \layout List
5534 \labelwidthstring 00.00.0000
5535
5536
5537 \series bold 
5538 -
5539 \begin_inset ERT
5540 status Collapsed
5541
5542 \layout Standard
5543
5544 \backslash 
5545 /
5546 \end_inset 
5547
5548 -stack-loc
5549 \series default 
5550
5551 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
5552
5553 \end_inset 
5554
5555 \SpecialChar ~
5556 <Value> By default the stack
5557 \begin_inset LatexCommand \index{stack}
5558
5559 \end_inset 
5560
5561  is placed after the data segment.
5562  Using this option the stack can be placed anywhere in the internal memory
5563  space of the 8051.
5564  The value entered can be in Hexadecimal or Decimal format, e.g.
5565  -
5566 \begin_inset ERT
5567 status Collapsed
5568
5569 \layout Standard
5570
5571 \backslash 
5572 /
5573 \end_inset 
5574
5575 -stack-loc 0x20 or -
5576 \begin_inset ERT
5577 status Collapsed
5578
5579 \layout Standard
5580
5581 \backslash 
5582 /
5583 \end_inset 
5584
5585 -stack-loc 32.
5586  Since the sp register is incremented before a push or call, the initial
5587  sp will be set to one byte prior the provided value.
5588  The provided value should not overlap any other memory areas such as used
5589  register banks or the data segment and with enough space for the current
5590  application.
5591 \layout List
5592 \labelwidthstring 00.00.0000
5593
5594
5595 \series bold 
5596 -
5597 \begin_inset ERT
5598 status Collapsed
5599
5600 \layout Standard
5601
5602 \backslash 
5603 /
5604 \end_inset 
5605
5606 -data-loc
5607 \series default 
5608
5609 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
5610
5611 \end_inset 
5612
5613 \SpecialChar ~
5614 <Value> The start location of the internal ram data
5615 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
5616
5617 \end_inset 
5618
5619  segment.
5620  The value entered can be in Hexadecimal or Decimal format, eg.
5621  -
5622 \begin_inset ERT
5623 status Collapsed
5624
5625 \layout Standard
5626
5627 \backslash 
5628 /
5629 \end_inset 
5630
5631 -data-loc 0x20 or -
5632 \begin_inset ERT
5633 status Collapsed
5634
5635 \layout Standard
5636
5637 \backslash 
5638 /
5639 \end_inset 
5640
5641 -data-loc 32.
5642  (By default, the start location of the internal ram data segment  is set
5643  as low as possible in memory, taking into account the used register banks
5644  and the bit segment at address 0x20.
5645  For example if register banks 0 and 1 are used without bit variables, the
5646  data segment will be set, if -
5647 \begin_inset ERT
5648 status Collapsed
5649
5650 \layout Standard
5651
5652 \backslash 
5653 /
5654 \end_inset 
5655
5656 -data-loc is not used, to location 0x10.)
5657 \layout List
5658 \labelwidthstring 00.00.0000
5659
5660
5661 \series bold 
5662 -
5663 \begin_inset ERT
5664 status Collapsed
5665
5666 \layout Standard
5667
5668 \backslash 
5669 /
5670 \end_inset 
5671
5672 -idata-loc
5673 \series default 
5674
5675 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
5676
5677 \end_inset 
5678
5679 \SpecialChar ~
5680 <Value> The start location of the indirectly addressable internal ram
5681 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
5682
5683 \end_inset 
5684
5685  of the 8051, default value is 0x80.
5686  The value entered can be in Hexadecimal or Decimal format, eg.
5687  -
5688 \begin_inset ERT
5689 status Collapsed
5690
5691 \layout Standard
5692
5693 \backslash 
5694 /
5695 \end_inset 
5696
5697 -idata-loc 0x88 or -
5698 \begin_inset ERT
5699 status Collapsed
5700
5701 \layout Standard
5702
5703 \backslash 
5704 /
5705 \end_inset 
5706
5707 -idata-loc 136.
5708 \layout List
5709 \labelwidthstring 00.00.0000
5710
5711
5712 \series bold 
5713 -
5714 \begin_inset ERT
5715 status Collapsed
5716
5717 \layout Standard
5718
5719 \backslash 
5720 /
5721 \end_inset 
5722
5723 -bit-loc
5724 \series default 
5725 \SpecialChar ~
5726 <Value> The start location of the bit
5727 \begin_inset LatexCommand \index{bit}
5728
5729 \end_inset 
5730
5731  addressable internal ram of the 8051.
5732  This is 
5733 \emph on 
5734 not
5735 \emph default 
5736  implemented yet.
5737  Instead an option can be passed directly to the linker: -Wl\SpecialChar ~
5738 -bBSEG=<Value>.
5739 \layout List
5740 \labelwidthstring 00.00.0000
5741
5742
5743 \series bold 
5744 -
5745 \begin_inset ERT
5746 status Collapsed
5747
5748 \layout Standard
5749
5750 \backslash 
5751 /
5752 \end_inset 
5753
5754 -out-fmt-ihx
5755 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
5756
5757 \end_inset 
5758
5759
5760 \bar under 
5761  
5762 \series default 
5763 \bar default 
5764 The linker output (final object code) is in Intel Hex format.
5765 \begin_inset LatexCommand \index{Intel hex format}
5766
5767 \end_inset 
5768
5769  This is the default option.
5770  The format itself is documented in the documentation of srecord
5771 \begin_inset LatexCommand \index{srecord (tool)}
5772
5773 \end_inset 
5774
5775 .
5776 \layout List
5777 \labelwidthstring 00.00.0000
5778
5779
5780 \series bold 
5781 -
5782 \begin_inset ERT
5783 status Collapsed
5784
5785 \layout Standard
5786
5787 \backslash 
5788 /
5789 \end_inset 
5790
5791 -out-fmt-s19
5792 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5793
5794 \end_inset 
5795
5796
5797 \bar under 
5798  
5799 \series default 
5800 \bar default 
5801 The linker output (final object code) is in Motorola S19 format
5802 \begin_inset LatexCommand \index{Motorola S19 format}
5803
5804 \end_inset 
5805
5806 .
5807  The format itself is documented in the documentation of srecord.
5808 \layout List
5809 \labelwidthstring 00.00.0000
5810
5811
5812 \series bold 
5813 -Wl\SpecialChar ~
5814 linkOption[,linkOption]
5815 \series default 
5816
5817 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
5818
5819 \end_inset 
5820
5821 ...
5822  Pass the linkOption to the linker.
5823  See file sdcc/as/doc/asxhtm.html for more on linker options.
5824 \layout Subsection
5825
5826 MCS51 Options
5827 \begin_inset LatexCommand \index{Options MCS51}
5828
5829 \end_inset 
5830
5831
5832 \begin_inset LatexCommand \index{MCS51 options}
5833
5834 \end_inset 
5835
5836
5837 \layout List
5838 \labelwidthstring 00.00.0000
5839
5840
5841 \series bold 
5842 -
5843 \begin_inset ERT
5844 status Collapsed
5845
5846 \layout Standard
5847
5848 \backslash 
5849 /
5850 \end_inset 
5851
5852 -model-small
5853 \begin_inset LatexCommand \index{-\/-model-small}
5854
5855 \end_inset 
5856
5857
5858 \series default 
5859 \size large 
5860 \emph on 
5861  
5862 \size default 
5863 \emph default 
5864 Generate code for Small Model programs, see section Memory Models for more
5865  details.
5866  This is the default model.
5867 \layout List
5868 \labelwidthstring 00.00.0000
5869
5870
5871 \series bold 
5872 -
5873 \begin_inset ERT
5874 status Collapsed
5875
5876 \layout Standard
5877
5878 \backslash 
5879 /
5880 \end_inset 
5881
5882 -model-large
5883 \begin_inset LatexCommand \index{-\/-model-large}
5884
5885 \end_inset 
5886
5887
5888 \series default 
5889  Generate code for Large model programs, see section Memory Models for more
5890  details.
5891  If this option is used all source files in the project have to be compiled
5892  with this option.
5893 \layout List
5894 \labelwidthstring 00.00.0000
5895
5896
5897 \series bold 
5898 -
5899 \begin_inset ERT
5900 status Collapsed
5901
5902 \layout Standard
5903
5904 \backslash 
5905 /
5906 \end_inset 
5907
5908 -xstack
5909 \begin_inset LatexCommand \index{-\/-xstack}
5910
5911 \end_inset 
5912
5913
5914 \series default 
5915  Uses a pseudo stack in the first 256 bytes in the external ram for allocating
5916  variables and passing parameters.
5917  See section 
5918 \begin_inset LatexCommand \ref{sub:External-Stack}
5919
5920 \end_inset 
5921
5922 \SpecialChar ~
5923  External Stack for more details.
5924 \layout List
5925 \labelwidthstring 00.00.0000
5926
5927
5928 \series bold 
5929 -
5930 \begin_inset ERT
5931 status Collapsed
5932
5933 \layout Standard
5934
5935 \backslash 
5936 /
5937 \end_inset 
5938
5939 -iram-size
5940 \series default 
5941 \SpecialChar ~
5942 <Value>
5943 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
5944
5945 \end_inset 
5946
5947  Causes the linker to check if the internal ram usage is within limits of
5948  the given value.
5949 \layout List
5950 \labelwidthstring 00.00.0000
5951
5952
5953 \series bold 
5954 -
5955 \begin_inset ERT
5956 status Collapsed
5957
5958 \layout Standard
5959
5960 \backslash 
5961 /
5962 \end_inset 
5963
5964 -xram-size
5965 \series default 
5966 \SpecialChar ~
5967 <Value>
5968 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
5969
5970 \end_inset 
5971
5972  Causes the linker to check if the external ram usage is within limits of
5973  the given value.
5974 \layout List
5975 \labelwidthstring 00.00.0000
5976
5977
5978 \series bold 
5979 -
5980 \begin_inset ERT
5981 status Collapsed
5982
5983 \layout Standard
5984
5985 \backslash 
5986 /
5987 \end_inset 
5988
5989 -code-size
5990 \series default 
5991 \SpecialChar ~
5992 <Value>
5993 \begin_inset LatexCommand \index{-\/-code-size <Value>}
5994
5995 \end_inset 
5996
5997  Causes the linker to check if the code memory 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 -stack-size
6015 \series default 
6016 \SpecialChar ~
6017 <Value>
6018 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
6019
6020 \end_inset 
6021
6022  Causes the linker to check if there is at minimum <Value> bytes for stack.
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 -pack-iram
6039 \series default 
6040 \SpecialChar ~
6041
6042 \begin_inset LatexCommand \index{-\/-pack-iram}
6043
6044 \end_inset 
6045
6046  Causes the linker to use unused register banks for data variables and pack
6047  data, idata and stack together.
6048  This is the default now.
6049 \layout List
6050 \labelwidthstring 00.00.0000
6051
6052
6053 \series bold 
6054 -
6055 \begin_inset ERT
6056 status Collapsed
6057
6058 \layout Standard
6059
6060 \backslash 
6061 /
6062 \end_inset 
6063
6064 -no-pack-iram
6065 \series default 
6066 \SpecialChar ~
6067
6068 \begin_inset LatexCommand \index{-\/-pack-iram}
6069
6070 \end_inset 
6071
6072  Causes the linker to use old style for allocating memory areas.
6073 \layout Subsection
6074
6075 DS390 / DS400 Options
6076 \begin_inset LatexCommand \index{Options DS390}
6077
6078 \end_inset 
6079
6080
6081 \begin_inset LatexCommand \index{DS390 options}
6082
6083 \end_inset 
6084
6085
6086 \layout List
6087 \labelwidthstring 00.00.0000
6088
6089
6090 \series bold 
6091 -
6092 \begin_inset ERT
6093 status Collapsed
6094
6095 \layout Standard
6096
6097 \backslash 
6098 /
6099 \end_inset 
6100
6101 -model-flat24
6102 \series default 
6103
6104 \begin_inset LatexCommand \index{-\/-model-flat24}
6105
6106 \end_inset 
6107
6108
6109 \size large 
6110 \emph on 
6111  
6112 \size default 
6113 \emph default 
6114 Generate 24-bit flat mode code.
6115  This is the one and only that the ds390 code generator supports right now
6116  and is default when using 
6117 \emph on 
6118 -mds390
6119 \emph default 
6120 .
6121  See section Memory Models for more details.
6122 \layout List
6123 \labelwidthstring 00.00.0000
6124
6125
6126 \series bold 
6127 -
6128 \begin_inset ERT
6129 status Collapsed
6130
6131 \layout Standard
6132
6133 \backslash 
6134 /
6135 \end_inset 
6136
6137 -protect-sp-update
6138 \begin_inset LatexCommand \index{-\/-protect-sp-update}
6139
6140 \end_inset 
6141
6142
6143 \series default 
6144  disable interrupts during ESP:SP updates.
6145 \layout List
6146 \labelwidthstring 00.00.0000
6147
6148
6149 \series bold 
6150 -
6151 \begin_inset ERT
6152 status Collapsed
6153
6154 \layout Standard
6155
6156 \backslash 
6157 /
6158 \end_inset 
6159
6160 -stack-10bit
6161 \series default 
6162
6163 \begin_inset LatexCommand \index{-\/-stack-10bit}
6164
6165 \end_inset 
6166
6167  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
6168  This is the one and only that the ds390 code generator supports right now
6169  and is default when using 
6170 \emph on 
6171 -mds390
6172 \emph default 
6173 .
6174  In this mode, the stack is located in the lower 1K of the internal RAM,
6175  which is mapped to 0x400000.
6176  Note that the support is incomplete, since it still uses a single byte
6177  as the stack pointer.
6178  This means that only the lower 256 bytes of the potential 1K stack space
6179  will actually be used.
6180  However, this does allow you to reclaim the precious 256 bytes of low RAM
6181  for use for the DATA and IDATA segments.
6182  The compiler will not generate any code to put the processor into 10 bit
6183  stack mode.
6184  It is important to ensure that the processor is in this mode before calling
6185  any re-entrant functions compiled with this option.
6186  In principle, this should work with the 
6187 \emph on 
6188 -
6189 \begin_inset ERT
6190 status Collapsed
6191
6192 \layout Standard
6193
6194 \backslash 
6195 /
6196 \end_inset 
6197
6198 -stack-auto
6199 \begin_inset LatexCommand \index{-\/-stack-auto}
6200
6201 \end_inset 
6202
6203
6204 \emph default 
6205  option, but that has not been tested.
6206  It is incompatible with the 
6207 \emph on 
6208 -
6209 \begin_inset ERT
6210 status Collapsed
6211
6212 \layout Standard
6213
6214 \backslash 
6215 /
6216 \end_inset 
6217
6218 -xstack
6219 \begin_inset LatexCommand \index{-\/-xstack}
6220
6221 \end_inset 
6222
6223
6224 \emph default 
6225  option.
6226  It also only makes sense if the processor is in 24 bit contiguous addressing
6227  mode (see the 
6228 \emph on 
6229 -
6230 \begin_inset ERT
6231 status Collapsed
6232
6233 \layout Standard
6234
6235 \backslash 
6236 /
6237 \end_inset 
6238
6239 -model-flat24 option
6240 \emph default 
6241 ).
6242 \layout List
6243 \labelwidthstring 00.00.0000
6244
6245
6246 \series bold 
6247 -
6248 \begin_inset ERT
6249 status Collapsed
6250
6251 \layout Standard
6252
6253 \backslash 
6254 /
6255 \end_inset 
6256
6257 -stack-probe
6258 \begin_inset LatexCommand \index{-\/-stack-probe}
6259
6260 \end_inset 
6261
6262
6263 \series default 
6264  insert call to function __stack_probe at each function prologue.
6265 \layout List
6266 \labelwidthstring 00.00.0000
6267
6268
6269 \series bold 
6270 -
6271 \begin_inset ERT
6272 status Collapsed
6273
6274 \layout Standard
6275
6276 \backslash 
6277 /
6278 \end_inset 
6279
6280 -tini-libid
6281 \begin_inset LatexCommand \index{-\/-tini-libid}
6282
6283 \end_inset 
6284
6285
6286 \series default 
6287  <nnnn> LibraryID used in -mTININative.
6288  
6289 \layout List
6290 \labelwidthstring 00.00.0000
6291
6292
6293 \series bold 
6294 -
6295 \begin_inset ERT
6296 status Collapsed
6297
6298 \layout Standard
6299
6300 \backslash 
6301 /
6302 \end_inset 
6303
6304 -use-accelerator
6305 \begin_inset LatexCommand \index{-\/-use-accelerator}
6306
6307 \end_inset 
6308
6309
6310 \series default 
6311  generate code for DS390 Arithmetic Accelerator.
6312  
6313 \layout Subsection
6314
6315 Z80 Options
6316 \begin_inset LatexCommand \index{Options Z80}
6317
6318 \end_inset 
6319
6320
6321 \begin_inset LatexCommand \index{Z80 options}
6322
6323 \end_inset 
6324
6325
6326 \layout List
6327 \labelwidthstring 00.00.0000
6328
6329
6330 \series bold 
6331 -
6332 \begin_inset ERT
6333 status Collapsed
6334
6335 \layout Standard
6336
6337 \backslash 
6338 /
6339 \end_inset 
6340
6341 -callee-saves-bc
6342 \series default 
6343
6344 \begin_inset LatexCommand \index{-\/-callee-saves-bc}
6345
6346 \end_inset 
6347
6348
6349 \size large 
6350 \emph on 
6351  
6352 \size default 
6353 \emph default 
6354 Force a called function to always save BC.
6355 \layout List
6356 \labelwidthstring 00.00.0000
6357
6358
6359 \series bold 
6360 -
6361 \begin_inset ERT
6362 status Collapsed
6363
6364 \layout Standard
6365
6366 \backslash 
6367 /
6368 \end_inset 
6369
6370 -no-std-crt0
6371 \series default 
6372
6373 \begin_inset LatexCommand \index{-\/-no-std-crt0}
6374
6375 \end_inset 
6376
6377  When linking, skip the standard crt0.o object file.
6378  You must provide your own crt0.o for your system when linking.
6379  
6380 \layout Subsection
6381
6382 Optimization Options
6383 \begin_inset LatexCommand \index{Options optimization}
6384
6385 \end_inset 
6386
6387
6388 \begin_inset LatexCommand \index{Optimization options}
6389
6390 \end_inset 
6391
6392
6393 \layout List
6394 \labelwidthstring 00.00.0000
6395
6396
6397 \series bold 
6398 -
6399 \begin_inset ERT
6400 status Collapsed
6401
6402 \layout Standard
6403
6404 \backslash 
6405 /
6406 \end_inset 
6407
6408 -nogcse
6409 \begin_inset LatexCommand \index{-\/-nogcse}
6410
6411 \end_inset 
6412
6413
6414 \series default 
6415  Will not do global subexpression elimination, this option may be used when
6416  the compiler creates undesirably large stack/data spaces to store compiler
6417  temporaries.
6418  A warning message will be generated when this happens and the compiler
6419  will indicate the number of extra bytes it allocated.
6420  It is recommended that this option NOT be used, #pragma\SpecialChar ~
6421 nogcse
6422 \begin_inset LatexCommand \index{\#pragma nogcse}
6423
6424 \end_inset 
6425
6426  can be used to turn off global subexpression elimination
6427 \begin_inset LatexCommand \index{Subexpression elimination}
6428
6429 \end_inset 
6430
6431  for a given function only.
6432 \layout List
6433 \labelwidthstring 00.00.0000
6434
6435
6436 \series bold 
6437 -
6438 \begin_inset ERT
6439 status Collapsed
6440
6441 \layout Standard
6442
6443 \backslash 
6444 /
6445 \end_inset 
6446
6447 -noinvariant
6448 \begin_inset LatexCommand \index{-\/-noinvariant}
6449
6450 \end_inset 
6451
6452
6453 \series default 
6454  Will not do loop invariant optimizations, this may be turned off for reasons
6455  explained for the previous option.
6456  For more details of loop optimizations performed see Loop Invariants in
6457  section 
6458 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
6459
6460 \end_inset 
6461
6462 .
6463  It is recommended that this option NOT be used, #pragma\SpecialChar ~
6464 noinvariant
6465 \begin_inset LatexCommand \index{\#pragma noinvariant}
6466
6467 \end_inset 
6468
6469  can be used to turn off invariant optimizations for a given function only.
6470 \layout List
6471 \labelwidthstring 00.00.0000
6472
6473
6474 \series bold 
6475 -
6476 \begin_inset ERT
6477 status Collapsed
6478
6479 \layout Standard
6480
6481 \backslash 
6482 /
6483 \end_inset 
6484
6485 -noinduction
6486 \begin_inset LatexCommand \index{-\/-noinduction}
6487
6488 \end_inset 
6489
6490
6491 \series default 
6492  Will not do loop induction optimizations, see section strength reduction
6493  for more details.
6494  It is recommended that this option is NOT used, #pragma\SpecialChar ~
6495 noinduction
6496 \begin_inset LatexCommand \index{\#pragma noinduction}
6497
6498 \end_inset 
6499
6500  can be used to turn off induction optimizations for a given function only.
6501 \layout List
6502 \labelwidthstring 00.00.0000
6503
6504
6505 \series bold 
6506 -
6507 \begin_inset ERT
6508 status Collapsed
6509
6510 \layout Standard
6511
6512 \backslash 
6513 /
6514 \end_inset 
6515
6516 -nojtbound
6517 \begin_inset LatexCommand \index{-\/-nojtbound}
6518
6519 \end_inset 
6520
6521
6522 \size large 
6523 \bar under 
6524  
6525 \series default 
6526 \size default 
6527 \bar default 
6528  Will not generate boundary condition check when switch statements
6529 \begin_inset LatexCommand \index{switch statement}
6530
6531 \end_inset 
6532
6533  are implemented using jump-tables.
6534  See section 
6535 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
6536
6537 \end_inset 
6538
6539 \SpecialChar ~
6540 Switch Statements for more details.
6541  It is recommended that this option is NOT used, #pragma\SpecialChar ~
6542 nojtbound
6543 \begin_inset LatexCommand \index{\#pragma nojtbound}
6544
6545 \end_inset 
6546
6547  can be used to turn off boundary checking for jump tables for a given function
6548  only.
6549 \layout List
6550 \labelwidthstring 00.00.0000
6551
6552
6553 \series bold 
6554 -
6555 \begin_inset ERT
6556 status Collapsed
6557
6558 \layout Standard
6559
6560 \backslash 
6561 /
6562 \end_inset 
6563
6564 -noloopreverse
6565 \begin_inset LatexCommand \index{-\/-noloopreverse}
6566
6567 \end_inset 
6568
6569
6570 \series default 
6571 \size large 
6572  
6573 \size default 
6574 Will not do loop reversal 
6575 \begin_inset LatexCommand \index{Loop reversing}
6576
6577 \end_inset 
6578
6579 optimization.
6580 \layout List
6581 \labelwidthstring 00.00.0000
6582
6583 -
6584 \begin_inset ERT
6585 status Collapsed
6586
6587 \layout Standard
6588
6589 \backslash 
6590 /
6591 \end_inset 
6592
6593 -
6594 \series bold 
6595 nolabelopt
6596 \series default 
6597  
6598 \begin_inset LatexCommand \index{-\/-nolabelopt }
6599
6600 \end_inset 
6601
6602 Will not optimize labels (makes the dumpfiles more readable).
6603 \layout List
6604 \labelwidthstring 00.00.0000
6605
6606
6607 \series bold 
6608 -
6609 \begin_inset ERT
6610 status Collapsed
6611
6612 \layout Standard
6613
6614 \backslash 
6615 /
6616 \end_inset 
6617
6618 -no-xinit-opt
6619 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
6620
6621 \end_inset 
6622
6623
6624 \series default 
6625  Will not memcpy initialized data from code space into xdata space.
6626  This saves a few bytes in code space if you don't have initialized data.
6627 \layout List
6628 \labelwidthstring 00.00.0000
6629
6630
6631 \series bold 
6632 -
6633 \begin_inset ERT
6634 status Collapsed
6635
6636 \layout Standard
6637
6638 \backslash 
6639 /
6640 \end_inset 
6641
6642 -nooverlay
6643 \begin_inset LatexCommand \index{-\/-nooverlay}
6644
6645 \end_inset 
6646
6647
6648 \series default 
6649   The compiler will not overlay parameters and local variables of any function,
6650  see section Parameters and local variables for more details.
6651 \layout List
6652 \labelwidthstring 00.00.0000
6653
6654
6655 \series bold 
6656 -
6657 \begin_inset ERT
6658 status Collapsed
6659
6660 \layout Standard
6661
6662 \backslash 
6663 /
6664 \end_inset 
6665
6666 -no-peep
6667 \begin_inset LatexCommand \index{-\/-no-peep}
6668
6669 \end_inset 
6670
6671
6672 \series default 
6673  Disable peep-hole optimization.
6674 \layout List
6675 \labelwidthstring 00.00.0000
6676
6677
6678 \series bold 
6679 -
6680 \begin_inset ERT
6681 status Collapsed
6682
6683 \layout Standard
6684
6685 \backslash 
6686 /
6687 \end_inset 
6688
6689 -peep-file
6690 \series default 
6691
6692 \begin_inset LatexCommand \index{-\/-peep-file}
6693
6694 \end_inset 
6695
6696 \SpecialChar ~
6697 <filename> This option can be used to use additional rules to be used by
6698  the peep hole optimizer.
6699  See section 
6700 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
6701
6702 \end_inset 
6703
6704 \SpecialChar ~
6705 Peep Hole optimizations for details on how to write these rules.
6706 \layout List
6707 \labelwidthstring 00.00.0000
6708
6709
6710 \series bold 
6711 -
6712 \begin_inset ERT
6713 status Collapsed
6714
6715 \layout Standard
6716
6717 \backslash 
6718 /
6719 \end_inset 
6720
6721 -peep-asm
6722 \begin_inset LatexCommand \index{-\/-peep-asm}
6723
6724 \end_inset 
6725
6726
6727 \series default 
6728  Pass the inline assembler code through the peep hole optimizer.
6729  This can cause unexpected changes to inline assembler code, please go through
6730  the peephole optimizer
6731 \begin_inset LatexCommand \index{Peephole optimizer}
6732
6733 \end_inset 
6734
6735  rules defined in the source file tree '<target>/peeph.def' before using
6736  this option.
6737 \layout List
6738 \labelwidthstring 00.00.0000
6739
6740
6741 \series bold 
6742 -
6743 \begin_inset ERT
6744 status Collapsed
6745
6746 \layout Standard
6747
6748 \backslash 
6749 /
6750 \end_inset 
6751
6752 -opt-code-speed
6753 \begin_inset LatexCommand \index{-\/-opt-code-speed}
6754
6755 \end_inset 
6756
6757
6758 \series default 
6759  The compiler will optimize code generation towards fast code, possibly
6760  at the expense of code size.
6761 \layout List
6762 \labelwidthstring 00.00.0000
6763
6764
6765 \series bold 
6766 -
6767 \begin_inset ERT
6768 status Collapsed
6769
6770 \layout Standard
6771
6772 \backslash 
6773 /
6774 \end_inset 
6775
6776 -opt-code-size
6777 \begin_inset LatexCommand \index{-\/-opt-code-size}
6778
6779 \end_inset 
6780
6781
6782 \series default 
6783  The compiler will optimize code generation towards compact code, possibly
6784  at the expense of code speed.
6785 \layout Subsection
6786
6787 Other Options
6788 \begin_inset LatexCommand \index{Options other}
6789
6790 \end_inset 
6791
6792
6793 \layout List
6794 \labelwidthstring 00.00.0000
6795
6796
6797 \series bold 
6798 -c\SpecialChar ~
6799 -
6800 \begin_inset ERT
6801 status Collapsed
6802
6803 \layout Standard
6804
6805 \backslash 
6806 /
6807 \end_inset 
6808
6809 -compile-only
6810 \begin_inset LatexCommand \index{-\/-compile-only}
6811
6812 \end_inset 
6813
6814
6815 \begin_inset LatexCommand \index{-c -\/-compile-only}
6816
6817 \end_inset 
6818
6819
6820 \series default 
6821  will compile and assemble the source, but will not call the linkage editor.
6822 \layout List
6823 \labelwidthstring 00.00.0000
6824
6825
6826 \series bold 
6827 -
6828 \series default 
6829
6830 \begin_inset ERT
6831 status Collapsed
6832
6833 \layout Standard
6834
6835 \backslash 
6836 /
6837 \end_inset 
6838
6839
6840 \series bold 
6841 -c1mode
6842 \begin_inset LatexCommand \index{-\/-c1mode}
6843
6844 \end_inset 
6845
6846
6847 \series default 
6848  reads the preprocessed source from standard input and compiles it.
6849  The file name for the assembler output must be specified using the -o option.
6850 \layout List
6851 \labelwidthstring 00.00.0000
6852
6853
6854 \series bold 
6855 -E
6856 \begin_inset LatexCommand \index{-E}
6857
6858 \end_inset 
6859
6860
6861 \series default 
6862  Run only the C preprocessor.
6863  Preprocess all the C source files specified and output the results to standard
6864  output.
6865 \layout List
6866 \labelwidthstring 00.00.0000
6867
6868
6869 \series bold 
6870 -o\SpecialChar ~
6871 <path/file>
6872 \begin_inset LatexCommand \index{-o <path/file>}
6873
6874 \end_inset 
6875
6876  
6877 \series default 
6878 The output path resp.
6879  file where everything will be placed.
6880  If the parameter is a path, it must have a trailing slash (or backslash
6881  for the Windows binaries) to be recognized as a path.
6882  
6883 \layout List
6884 \labelwidthstring 00.00.0000
6885
6886
6887 \series bold 
6888 -
6889 \begin_inset ERT
6890 status Collapsed
6891
6892 \layout Standard
6893
6894 \backslash 
6895 /
6896 \end_inset 
6897
6898 -stack-auto
6899 \begin_inset LatexCommand \index{-\/-stack-auto}
6900
6901 \end_inset 
6902
6903
6904 \series default 
6905 \size large 
6906 \emph on 
6907  
6908 \size default 
6909 \emph default 
6910 All functions in the source file will be compiled as 
6911 \emph on 
6912 reentrant
6913 \emph default 
6914
6915 \begin_inset LatexCommand \index{reentrant}
6916
6917 \end_inset 
6918
6919 , i.e.
6920  the parameters and local variables will be allocated on the stack
6921 \begin_inset LatexCommand \index{stack}
6922
6923 \end_inset 
6924
6925 .
6926  See section 
6927 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
6928
6929 \end_inset 
6930
6931  Parameters and Local Variables for more details.
6932  If this option is used all source files in the project should be compiled
6933  with this option.
6934  It automatically implies --int-long-reent and --float-reent.
6935  
6936 \layout List
6937 \labelwidthstring 00.00.0000
6938
6939
6940 \series bold 
6941 -
6942 \begin_inset ERT
6943 status Collapsed
6944
6945 \layout Standard
6946
6947 \backslash 
6948 /
6949 \end_inset 
6950
6951 -callee-saves
6952 \begin_inset LatexCommand \index{-\/-callee-saves}
6953
6954 \end_inset 
6955
6956  function1[,function2][,function3]....
6957
6958 \series default 
6959  The compiler by default uses a caller saves convention for register saving
6960  across function calls, however this can cause unnecessary register pushing
6961  & popping when calling small functions from larger functions.
6962  This option can be used to switch the register saving convention for the
6963  function names specified.
6964  The compiler will not save registers when calling these functions, no extra
6965  code will be generated at the entry & exit (function prologue
6966 \series bold 
6967
6968 \begin_inset LatexCommand \index{function prologue}
6969
6970 \end_inset 
6971
6972
6973 \series default 
6974  & epilogue
6975 \series bold 
6976
6977 \begin_inset LatexCommand \index{function epilogue}
6978
6979 \end_inset 
6980
6981
6982 \series default 
6983 ) for these functions to save & restore the registers used by these functions,
6984  this can SUBSTANTIALLY reduce code & improve run time performance of the
6985  generated code.
6986  In the future the compiler (with inter procedural analysis) will be able
6987  to determine the appropriate scheme to use for each function call.
6988  DO NOT use this option for built-in functions such as _mulint..., if this
6989  option is used for a library function the appropriate library function
6990  needs to be recompiled with the same option.
6991  If the project consists of multiple source files then all the source file
6992  should be compiled with the same -
6993 \begin_inset ERT
6994 status Collapsed
6995
6996 \layout Standard
6997
6998 \backslash 
6999 /
7000 \end_inset 
7001
7002 -callee-saves option string.
7003  Also see #pragma\SpecialChar ~
7004 callee_saves
7005 \begin_inset LatexCommand \index{\#pragma callee\_saves}
7006
7007 \end_inset 
7008
7009 .
7010 \layout List
7011 \labelwidthstring 00.00.0000
7012
7013
7014 \series bold 
7015 -
7016 \begin_inset ERT
7017 status Collapsed
7018
7019 \layout Standard
7020
7021 \backslash 
7022 /
7023 \end_inset 
7024
7025 -debug
7026 \begin_inset LatexCommand \index{-\/-debug}
7027
7028 \end_inset 
7029
7030
7031 \bar under 
7032  
7033 \series default 
7034 \bar default 
7035 When this option is used the compiler will generate debug information.
7036  The debug information collected in a file with .cdb extension can be used
7037  with the SDCDB.
7038  For more information see documentation for SDCDB.
7039  Another file with no extension contains debug information in AOMF or AOMF51
7040 \begin_inset LatexCommand \index{AOMF, AOMF51}
7041
7042 \end_inset 
7043
7044  format which is commonly used by third party tools.
7045 \layout List
7046 \labelwidthstring 00.00.0000
7047
7048
7049 \series bold 
7050 -S
7051 \begin_inset LatexCommand \index{-S}
7052
7053 \end_inset 
7054
7055
7056 \size large 
7057 \bar under 
7058  
7059 \series default 
7060 \size default 
7061 \bar default 
7062 Stop after the stage of compilation proper; do not assemble.
7063  The output is an assembler code file for the input file specified.
7064 \layout List
7065 \labelwidthstring 00.00.0000
7066
7067
7068 \series bold 
7069 -
7070 \begin_inset ERT
7071 status Collapsed
7072
7073 \layout Standard
7074
7075 \backslash 
7076 /
7077 \end_inset 
7078
7079 -int-long-reent
7080 \begin_inset LatexCommand \index{-\/-int-long-reent}
7081
7082 \end_inset 
7083
7084
7085 \series default 
7086  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
7087  Note by default these libraries are compiled as non-reentrant.
7088  See section Installation for more details.
7089 \layout List
7090 \labelwidthstring 00.00.0000
7091
7092
7093 \series bold 
7094 -
7095 \begin_inset ERT
7096 status Collapsed
7097
7098 \layout Standard
7099
7100 \backslash 
7101 /
7102 \end_inset 
7103
7104 -cyclomatic
7105 \begin_inset LatexCommand \index{-\/-cyclomatic}
7106
7107 \end_inset 
7108
7109
7110 \bar under 
7111  
7112 \series default 
7113 \bar default 
7114 This option will cause the compiler to generate an information message for
7115  each function in the source file.
7116  The message contains some 
7117 \emph on 
7118 important
7119 \emph default 
7120  information about the function.
7121  The number of edges and nodes the compiler detected in the control flow
7122  graph of the function, and most importantly the 
7123 \emph on 
7124 cyclomatic complexity
7125 \begin_inset LatexCommand \index{Cyclomatic complexity}
7126
7127 \end_inset 
7128
7129
7130 \emph default 
7131  see section on Cyclomatic Complexity for more details.
7132 \layout List
7133 \labelwidthstring 00.00.0000
7134
7135
7136 \series bold 
7137 -
7138 \begin_inset ERT
7139 status Collapsed
7140
7141 \layout Standard
7142
7143 \backslash 
7144 /
7145 \end_inset 
7146
7147 -float-reent
7148 \begin_inset LatexCommand \index{-\/-float-reent}
7149
7150 \end_inset 
7151
7152
7153 \series default 
7154  Floating point library is compiled as reentrant
7155 \begin_inset LatexCommand \index{reentrant}
7156
7157 \end_inset 
7158
7159 .
7160  See section Installation for more details.
7161 \layout List
7162 \labelwidthstring 00.00.0000
7163
7164
7165 \series bold 
7166 -
7167 \begin_inset ERT
7168 status Collapsed
7169
7170 \layout Standard
7171
7172 \backslash 
7173 /
7174 \end_inset 
7175
7176 -main-return
7177 \begin_inset LatexCommand \index{-\/-main-return}
7178
7179 \end_inset 
7180
7181
7182 \series default 
7183  This option can be used if the code generated is called by a monitor program
7184  or if the main routine includes an endless loop.
7185  This option might result in slightly smaller code and save two bytes of
7186  stack space.
7187  The return from the 'main'
7188 \begin_inset LatexCommand \index{main return}
7189
7190 \end_inset 
7191
7192  function will return to the function calling main.
7193  The default setting is to lock up i.e.
7194  generate a '
7195 \family typewriter 
7196 sjmp .
7197 \family default 
7198 '.
7199 \layout List
7200 \labelwidthstring 00.00.0000
7201
7202
7203 \series bold 
7204 -
7205 \begin_inset ERT
7206 status Collapsed
7207
7208 \layout Standard
7209
7210 \backslash 
7211 /
7212 \end_inset 
7213
7214 -nostdinc
7215 \begin_inset LatexCommand \index{-\/-nostdinc}
7216
7217 \end_inset 
7218
7219
7220 \series default 
7221  This will prevent the compiler from passing on the default include path
7222  to the preprocessor.
7223 \layout List
7224 \labelwidthstring 00.00.0000
7225
7226
7227 \series bold 
7228 -
7229 \begin_inset ERT
7230 status Collapsed
7231
7232 \layout Standard
7233
7234 \backslash 
7235 /
7236 \end_inset 
7237
7238 -nostdlib
7239 \begin_inset LatexCommand \index{-\/-nostdlib}
7240
7241 \end_inset 
7242
7243
7244 \series default 
7245  This will prevent the compiler from passing on the default library
7246 \begin_inset LatexCommand \index{Libraries}
7247
7248 \end_inset 
7249
7250  path to the linker.
7251 \layout List
7252 \labelwidthstring 00.00.0000
7253
7254
7255 \series bold 
7256 -
7257 \begin_inset ERT
7258 status Collapsed
7259
7260 \layout Standard
7261
7262 \backslash 
7263 /
7264 \end_inset 
7265
7266 -verbose
7267 \begin_inset LatexCommand \index{-\/-verbose}
7268
7269 \end_inset 
7270
7271
7272 \series default 
7273  Shows the various actions the compiler is performing.
7274 \layout List
7275 \labelwidthstring 00.00.0000
7276
7277
7278 \series bold 
7279 -V
7280 \begin_inset LatexCommand \index{-V}
7281
7282 \end_inset 
7283
7284
7285 \series default 
7286  Shows the actual commands the compiler is executing.
7287 \layout List
7288 \labelwidthstring 00.00.0000
7289
7290
7291 \series bold 
7292 -
7293 \begin_inset ERT
7294 status Collapsed
7295
7296 \layout Standard
7297
7298 \backslash 
7299 /
7300 \end_inset 
7301
7302 -no-c-code-in-asm
7303 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
7304
7305 \end_inset 
7306
7307
7308 \series default 
7309  Hides your ugly and inefficient c-code from the asm file, so you can always
7310  blame the compiler :)
7311 \layout List
7312 \labelwidthstring 00.00.0000
7313
7314
7315 \series bold 
7316 -
7317 \begin_inset ERT
7318 status Collapsed
7319
7320 \layout Standard
7321
7322 \backslash 
7323 /
7324 \end_inset 
7325
7326 -no-peep-comments
7327 \begin_inset LatexCommand \index{-\/-no-peep-comments}
7328
7329 \end_inset 
7330
7331
7332 \series default 
7333  Will not include peep-hole comments in the generated files.
7334 \layout List
7335 \labelwidthstring 00.00.0000
7336
7337
7338 \series bold 
7339 -
7340 \begin_inset ERT
7341 status Collapsed
7342
7343 \layout Standard
7344
7345 \backslash 
7346 /
7347 \end_inset 
7348
7349 -i-code-in-asm
7350 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
7351
7352 \end_inset 
7353
7354
7355 \series default 
7356  Include i-codes in the asm file.
7357  Sounds like noise but is most helpful for debugging the compiler itself.
7358 \layout List
7359 \labelwidthstring 00.00.0000
7360
7361
7362 \series bold 
7363 -
7364 \begin_inset ERT
7365 status Collapsed
7366
7367 \layout Standard
7368
7369 \backslash 
7370 /
7371 \end_inset 
7372
7373 -less-pedantic
7374 \begin_inset LatexCommand \index{-\/-less-pedantic}
7375
7376 \end_inset 
7377
7378
7379 \series default 
7380  Disable some of the more pedantic warnings
7381 \begin_inset LatexCommand \index{Warnings}
7382
7383 \end_inset 
7384
7385  (jwk burps: please be more specific here, please!).
7386  If you want rather more than less warnings you should consider using a
7387  separate tool dedicated to syntax checking like splint 
7388 \begin_inset LatexCommand \url{www.splint.org}
7389
7390 \end_inset 
7391
7392 .
7393 \layout List
7394 \labelwidthstring 00.00.0000
7395
7396
7397 \series bold 
7398 -
7399 \begin_inset ERT
7400 status Collapsed
7401
7402 \layout Standard
7403
7404 \backslash 
7405 /
7406 \end_inset 
7407
7408 -disable-warning\SpecialChar ~
7409 <nnnn>
7410 \begin_inset LatexCommand \index{-\/-disable-warning}
7411
7412 \end_inset 
7413
7414
7415 \series default 
7416  Disable specific warning with number <nnnn>.
7417 \layout List
7418 \labelwidthstring 00.00.0000
7419
7420
7421 \series bold 
7422 -
7423 \begin_inset ERT
7424 status Collapsed
7425
7426 \layout Standard
7427
7428 \backslash 
7429 /
7430 \end_inset 
7431
7432 -print-search-dirs
7433 \begin_inset LatexCommand \index{-\/-print-search-dirs}
7434
7435 \end_inset 
7436
7437
7438 \series default 
7439  Display the directories in the compiler's search path
7440 \layout List
7441 \labelwidthstring 00.00.0000
7442
7443
7444 \series bold 
7445 -
7446 \begin_inset ERT
7447 status Collapsed
7448
7449 \layout Standard
7450
7451 \backslash 
7452 /
7453 \end_inset 
7454
7455 -vc
7456 \begin_inset LatexCommand \index{-\/-vc}
7457
7458 \end_inset 
7459
7460
7461 \series default 
7462  Display errors and warnings using MSVC style, so you can use SDCC with
7463  visual studio.
7464 \layout List
7465 \labelwidthstring 00.00.0000
7466
7467
7468 \series bold 
7469 -
7470 \begin_inset ERT
7471 status Collapsed
7472
7473 \layout Standard
7474
7475 \backslash 
7476 /
7477 \end_inset 
7478
7479 -use-stdout
7480 \begin_inset LatexCommand \index{-\/-use-stdout}
7481
7482 \end_inset 
7483
7484
7485 \series default 
7486  Send errors and warnings to stdout instead of stderr.
7487 \layout List
7488 \labelwidthstring 00.00.0000
7489
7490
7491 \series bold 
7492 -Wa\SpecialChar ~
7493 asmOption[,asmOption]
7494 \series default 
7495
7496 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
7497
7498 \end_inset 
7499
7500 ...
7501  Pass the asmOption to the assembler
7502 \begin_inset LatexCommand \index{Options assembler}
7503
7504 \end_inset 
7505
7506
7507 \begin_inset LatexCommand \index{Assembler options}
7508
7509 \end_inset 
7510
7511 .
7512  See file sdcc/as/doc/asxhtm.html for assembler options.
7513 \layout Subsection
7514
7515 Intermediate Dump Options
7516 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
7517
7518 \end_inset 
7519
7520
7521 \begin_inset LatexCommand \index{Options intermediate dump}
7522
7523 \end_inset 
7524
7525
7526 \begin_inset LatexCommand \index{Intermediate dump options}
7527
7528 \end_inset 
7529
7530
7531 \layout Standard
7532
7533 The following options are provided for the purpose of retargetting and debugging
7534  the compiler.
7535  These provided a means to dump the intermediate code (iCode
7536 \begin_inset LatexCommand \index{iCode}
7537
7538 \end_inset 
7539
7540 ) generated by the compiler in human readable form at various stages of
7541  the compilation process.
7542  More on iCodes see chapter 
7543 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
7544
7545 \end_inset 
7546
7547  
7548 \begin_inset Quotes srd
7549 \end_inset 
7550
7551 The anatomy of the compiler
7552 \begin_inset Quotes srd
7553 \end_inset 
7554
7555 .
7556 \layout List
7557 \labelwidthstring 00.00.0000
7558
7559
7560 \series bold 
7561 -
7562 \begin_inset ERT
7563 status Collapsed
7564
7565 \layout Standard
7566
7567 \backslash 
7568 /
7569 \end_inset 
7570
7571 -dumpraw
7572 \begin_inset LatexCommand \index{-\/-dumpraw}
7573
7574 \end_inset 
7575
7576
7577 \series default 
7578  This option will cause the compiler to dump the intermediate code into
7579  a file of named 
7580 \emph on 
7581 <source filename>.dumpraw
7582 \emph default 
7583  just after the intermediate code has been generated for a function, i.e.
7584  before any optimizations are done.
7585  The basic blocks
7586 \begin_inset LatexCommand \index{Basic blocks}
7587
7588 \end_inset 
7589
7590  at this stage ordered in the depth first number, so they may not be in
7591  sequence of execution.
7592 \layout List
7593 \labelwidthstring 00.00.0000
7594
7595
7596 \series bold 
7597 -
7598 \begin_inset ERT
7599 status Collapsed
7600
7601 \layout Standard
7602
7603 \backslash 
7604 /
7605 \end_inset 
7606
7607 -dumpgcse
7608 \begin_inset LatexCommand \index{-\/-dumpgcse}
7609
7610 \end_inset 
7611
7612
7613 \series default 
7614  Will create a dump of iCode's, after global subexpression elimination
7615 \begin_inset LatexCommand \index{Global subexpression elimination}
7616
7617 \end_inset 
7618
7619 , into a file named 
7620 \emph on 
7621 <source filename>.dumpgcse.
7622 \layout List
7623 \labelwidthstring 00.00.0000
7624
7625
7626 \series bold 
7627 -
7628 \begin_inset ERT
7629 status Collapsed
7630
7631 \layout Standard
7632
7633 \backslash 
7634 /
7635 \end_inset 
7636
7637 -dumpdeadcode
7638 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
7639
7640 \end_inset 
7641
7642
7643 \series default 
7644  Will create a dump of iCode's, after deadcode elimination
7645 \begin_inset LatexCommand \index{Dead-code elimination}
7646
7647 \end_inset 
7648
7649 , into a file named 
7650 \emph on 
7651 <source filename>.dumpdeadcode.
7652 \layout List
7653 \labelwidthstring 00.00.0000
7654
7655
7656 \series bold 
7657 -
7658 \begin_inset ERT
7659 status Collapsed
7660
7661 \layout Standard
7662
7663 \backslash 
7664 /
7665 \end_inset 
7666
7667 -dumploop
7668 \begin_inset LatexCommand \index{-\/-dumploop}
7669
7670 \end_inset 
7671
7672
7673 \series default 
7674 \size large 
7675  
7676 \size default 
7677 Will create a dump of iCode's, after loop optimizations
7678 \begin_inset LatexCommand \index{Loop optimization}
7679
7680 \end_inset 
7681
7682 , into a file named 
7683 \emph on 
7684 <source filename>.dumploop.
7685 \layout List
7686 \labelwidthstring 00.00.0000
7687
7688
7689 \series bold 
7690 -
7691 \begin_inset ERT
7692 status Collapsed
7693
7694 \layout Standard
7695
7696 \backslash 
7697 /
7698 \end_inset 
7699
7700 -dumprange
7701 \begin_inset LatexCommand \index{-\/-dumprange}
7702
7703 \end_inset 
7704
7705
7706 \series default 
7707 \size large 
7708  
7709 \size default 
7710 Will create a dump of iCode's, after live range analysis
7711 \begin_inset LatexCommand \index{Live range analysis}
7712
7713 \end_inset 
7714
7715 , into a file named 
7716 \emph on 
7717 <source filename>.dumprange.
7718 \layout List
7719 \labelwidthstring 00.00.0000
7720
7721
7722 \series bold 
7723 -
7724 \begin_inset ERT
7725 status Collapsed
7726
7727 \layout Standard
7728
7729 \backslash 
7730 /
7731 \end_inset 
7732
7733 -dumlrange
7734 \begin_inset LatexCommand \index{-\/-dumlrange}
7735
7736 \end_inset 
7737
7738
7739 \series default 
7740  Will dump the life ranges
7741 \begin_inset LatexCommand \index{Live range analysis}
7742
7743 \end_inset 
7744
7745  for all symbols.
7746 \layout List
7747 \labelwidthstring 00.00.0000
7748
7749
7750 \series bold 
7751 -
7752 \begin_inset ERT
7753 status Collapsed
7754
7755 \layout Standard
7756
7757 \backslash 
7758 /
7759 \end_inset 
7760
7761 -dumpregassign
7762 \begin_inset LatexCommand \index{-\/-dumpregassign}
7763
7764 \end_inset 
7765
7766
7767 \bar under 
7768  
7769 \series default 
7770 \bar default 
7771 Will create a dump of iCode's, after register assignment
7772 \begin_inset LatexCommand \index{Register assignment}
7773
7774 \end_inset 
7775
7776 , into a file named 
7777 \emph on 
7778 <source filename>.dumprassgn.
7779 \layout List
7780 \labelwidthstring 00.00.0000
7781
7782
7783 \series bold 
7784 -
7785 \begin_inset ERT
7786 status Collapsed
7787
7788 \layout Standard
7789
7790 \backslash 
7791 /
7792 \end_inset 
7793
7794 -dumplrange
7795 \begin_inset LatexCommand \index{-\/-dumplrange}
7796
7797 \end_inset 
7798
7799
7800 \series default 
7801  Will create a dump of the live ranges of iTemp's
7802 \layout List
7803 \labelwidthstring 00.00.0000
7804
7805
7806 \series bold 
7807 -
7808 \begin_inset ERT
7809 status Collapsed
7810
7811 \layout Standard
7812
7813 \backslash 
7814 /
7815 \end_inset 
7816
7817 -dumpall
7818 \begin_inset LatexCommand \index{-\/-dumpall}
7819
7820 \end_inset 
7821
7822
7823 \size large 
7824 \bar under 
7825  
7826 \series default 
7827 \size default 
7828 \bar default 
7829 Will cause all the above mentioned dumps to be created.
7830 \layout Subsection
7831
7832 Redirecting output on Windows Shells
7833 \layout Standard
7834
7835 By default SDCC writes it's error messages to 
7836 \begin_inset Quotes sld
7837 \end_inset 
7838
7839 standard error
7840 \begin_inset Quotes srd
7841 \end_inset 
7842
7843 .
7844  To force all messages to 
7845 \begin_inset Quotes sld
7846 \end_inset 
7847
7848 standard output
7849 \begin_inset Quotes srd
7850 \end_inset 
7851
7852  use 
7853 \series bold 
7854 -
7855 \series default 
7856 \emph on 
7857
7858 \begin_inset ERT
7859 status Collapsed
7860
7861 \layout Standard
7862
7863 \backslash 
7864 /
7865 \end_inset 
7866
7867
7868 \series bold 
7869 \emph default 
7870 -
7871 \series default 
7872 use-stdout
7873 \begin_inset LatexCommand \index{-\/-use-stdout}
7874
7875 \end_inset 
7876
7877 .
7878  Additionally, if you happen to have visual studio installed in your windows
7879  machine, you can use it to compile your sources using a custom build and
7880  the SDCC -
7881 \emph on 
7882
7883 \begin_inset ERT
7884 status Collapsed
7885
7886 \layout Standard
7887
7888 \backslash 
7889 /
7890 \end_inset 
7891
7892
7893 \emph default 
7894 -vc
7895 \begin_inset LatexCommand \index{-\/-vc}
7896
7897 \end_inset 
7898
7899  option.
7900  Something like this should work:
7901 \newline 
7902
7903 \newline 
7904
7905 \series bold 
7906 c:
7907 \backslash 
7908 sdcc
7909 \backslash 
7910 bin
7911 \backslash 
7912 sdcc.exe -
7913 \series default 
7914 \emph on 
7915
7916 \begin_inset ERT
7917 status Collapsed
7918
7919 \layout Standard
7920
7921 \backslash 
7922 /
7923 \end_inset 
7924
7925
7926 \series bold 
7927 \emph default 
7928 -vc -
7929 \series default 
7930 \emph on 
7931
7932 \begin_inset ERT
7933 status Collapsed
7934
7935 \layout Standard
7936
7937 \backslash 
7938 /
7939 \end_inset 
7940
7941
7942 \series bold 
7943 \emph default 
7944 -model-large -c $(InputPath)
7945 \layout Section
7946
7947 Environment variables
7948 \begin_inset LatexCommand \index{Environment variables}
7949
7950 \end_inset 
7951
7952
7953 \layout Standard
7954
7955 SDCC recognizes the following environment variables:
7956 \layout List
7957 \labelwidthstring 00.00.0000
7958
7959
7960 \series bold 
7961 SDCC_LEAVE_SIGNALS
7962 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
7963
7964 \end_inset 
7965
7966
7967 \series default 
7968  SDCC installs a signal handler
7969 \begin_inset LatexCommand \index{signal handler}
7970
7971 \end_inset 
7972
7973  to be able to delete temporary files after an user break (^C) or an exception.
7974  If this environment variable is set, SDCC won't install the signal handler
7975  in order to be able to debug SDCC.
7976 \layout List
7977 \labelwidthstring 00.00.0000
7978
7979
7980 \series bold 
7981 TMP,\SpecialChar ~
7982 TEMP,\SpecialChar ~
7983 TMPDIR
7984 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
7985
7986 \end_inset 
7987
7988
7989 \series default 
7990  Path, where temporary files will be created.
7991  The order of the variables is the search order.
7992  In a standard *nix environment these variables are not set, and there's
7993  no need to set them.
7994  On Windows it's recommended to set one of them.
7995 \layout List
7996 \labelwidthstring 00.00.0000
7997
7998
7999 \series bold 
8000 SDCC_HOME
8001 \begin_inset LatexCommand \index{SDCC\_HOME}
8002
8003 \end_inset 
8004
8005
8006 \series default 
8007  Path, see section 
8008 \begin_inset LatexCommand \ref{sub:Install-paths}
8009
8010 \end_inset 
8011
8012 \SpecialChar ~
8013
8014 \begin_inset Quotes sld
8015 \end_inset 
8016
8017  Install Paths
8018 \begin_inset Quotes srd
8019 \end_inset 
8020
8021 .
8022 \layout List
8023 \labelwidthstring 00.00.0000
8024
8025
8026 \series bold 
8027 SDCC_INCLUDE
8028 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
8029
8030 \end_inset 
8031
8032
8033 \series default 
8034  Path, see section 
8035 \begin_inset LatexCommand \ref{sub:Search-Paths}
8036
8037 \end_inset 
8038
8039 \SpecialChar ~
8040
8041 \begin_inset Quotes sld
8042 \end_inset 
8043
8044 Search Paths
8045 \begin_inset Quotes srd
8046 \end_inset 
8047
8048 .
8049 \layout List
8050 \labelwidthstring 00.00.0000
8051
8052
8053 \series bold 
8054 SDCC_LIB
8055 \begin_inset LatexCommand \index{SDCC\_LIB}
8056
8057 \end_inset 
8058
8059
8060 \series default 
8061  Path, see section 
8062 \begin_inset LatexCommand \ref{sub:Search-Paths}
8063
8064 \end_inset 
8065
8066 \SpecialChar ~
8067
8068 \begin_inset Quotes sld
8069 \end_inset 
8070
8071 Search Paths
8072 \begin_inset Quotes srd
8073 \end_inset 
8074
8075 ..
8076 \layout Standard
8077
8078 There are some more environment variables recognized by SDCC, but these
8079  are solely used for debugging purposes.
8080  They can change or disappear very quickly, and will never be documented.
8081 \layout Section
8082
8083 Storage Class Language Extensions
8084 \layout Subsection
8085
8086 MCS51/DS390 Storage Class
8087 \begin_inset LatexCommand \index{Storage class}
8088
8089 \end_inset 
8090
8091  Language Extensions
8092 \layout Standard
8093
8094 In addition to the ANSI storage classes SDCC allows the following MCS51
8095  specific storage classes:
8096 \layout Subsubsection
8097
8098 data
8099 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
8100
8101 \end_inset 
8102
8103  / near
8104 \begin_inset LatexCommand \index{near (storage class)}
8105
8106 \end_inset 
8107
8108
8109 \layout Standard
8110
8111 This is the 
8112 \series bold 
8113 default
8114 \series default 
8115  storage class for the Small Memory model (
8116 \emph on 
8117 data
8118 \emph default 
8119  and 
8120 \emph on 
8121 near
8122 \emph default 
8123  can be used synonymously).
8124  Variables declared with this storage class will be allocated in the directly
8125  addressable portion of the internal RAM of a 8051, e.g.:
8126 \layout Verse
8127
8128
8129 \family typewriter 
8130 data unsigned char test_data;
8131 \layout Standard
8132
8133 Writing 0x01 to this variable generates the assembly code:
8134 \layout Verse
8135
8136
8137 \family typewriter 
8138 75*00 01\SpecialChar ~
8139 \SpecialChar ~
8140 \SpecialChar ~
8141 mov\SpecialChar ~
8142 \SpecialChar ~
8143 _test_data,#0x01 
8144 \layout Subsubsection
8145
8146 xdata
8147 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
8148
8149 \end_inset 
8150
8151  / far
8152 \begin_inset LatexCommand \index{far (storage class)}
8153
8154 \end_inset 
8155
8156
8157 \layout Standard
8158
8159 Variables declared with this storage class will be placed in the external
8160  RAM.
8161  This is the 
8162 \series bold 
8163 default
8164 \series default 
8165  storage class for the Large Memory model, e.g.:
8166 \layout Verse
8167
8168
8169 \family typewriter 
8170 xdata unsigned char test_xdata;
8171 \layout Standard
8172
8173 Writing 0x01 to this variable generates the assembly code:
8174 \layout Verse
8175
8176
8177 \family typewriter 
8178 90s00r00\SpecialChar ~
8179 \SpecialChar ~
8180 \SpecialChar ~
8181 mov\SpecialChar ~
8182 \SpecialChar ~
8183 dptr,#_test_xdata 
8184 \newline 
8185 74\SpecialChar ~
8186 01\SpecialChar ~
8187 \SpecialChar ~
8188 \SpecialChar ~
8189 \SpecialChar ~
8190 \SpecialChar ~
8191 \SpecialChar ~
8192 mov\SpecialChar ~
8193 \SpecialChar ~
8194 a,#0x01 
8195 \newline 
8196 F0\SpecialChar ~
8197 \SpecialChar ~
8198 \SpecialChar ~
8199 \SpecialChar ~
8200 \SpecialChar ~
8201 \SpecialChar ~
8202 \SpecialChar ~
8203 \SpecialChar ~
8204 \SpecialChar ~
8205 movx\SpecialChar ~
8206 @dptr,a 
8207 \layout Subsubsection
8208
8209 idata
8210 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
8211
8212 \end_inset 
8213
8214
8215 \layout Standard
8216
8217 Variables declared with this storage class will be allocated into the indirectly
8218  addressable portion of the internal ram of a 8051, e.g.:
8219 \layout Verse
8220
8221
8222 \family typewriter 
8223 idata unsigned char test_idata;
8224 \layout Standard
8225
8226 Writing 0x01 to this variable generates the assembly code:
8227 \layout Verse
8228
8229
8230 \family typewriter 
8231 78r00\SpecialChar ~
8232 \SpecialChar ~
8233 \SpecialChar ~
8234 \SpecialChar ~
8235 \SpecialChar ~
8236 \SpecialChar ~
8237 \SpecialChar ~
8238 mov\SpecialChar ~
8239 \SpecialChar ~
8240 r0,#_test_idata
8241 \newline 
8242 76\SpecialChar ~
8243 01\SpecialChar ~
8244 \SpecialChar ~
8245 \SpecialChar ~
8246 \SpecialChar ~
8247 \SpecialChar ~
8248 \SpecialChar ~
8249 \SpecialChar ~
8250 mov\SpecialChar ~
8251 \SpecialChar ~
8252 @r0,#0x01
8253 \layout Standard
8254
8255 Please note, the first 128 byte of idata physically access the same RAM
8256  as the data memory.
8257  The original 8051 had 128 byte idata memory, nowadays most devices have
8258  256 byte idata memory.
8259  The stack
8260 \begin_inset LatexCommand \index{stack}
8261
8262 \end_inset 
8263
8264  is located in idata memory.
8265 \layout Subsubsection
8266
8267 pdata
8268 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8269
8270 \end_inset 
8271
8272
8273 \layout Standard
8274
8275 Paged xdata access is just as straightforward as using the other addressing
8276  modes of a 8051.
8277  It is typically located at the start of xdata and has a maximum size of
8278  256 bytes.
8279  The following example writes 0x01 to the address pointed to.
8280  Please note, pdata access physically accesses xdata memory.
8281  The high byte of the address is determined by port P2 
8282 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
8283
8284 \end_inset 
8285
8286 (or in case of some 8051 variants by a separate Special Function Register,
8287  see section 
8288 \begin_inset LatexCommand \ref{sub:MCS51-variants}
8289
8290 \end_inset 
8291
8292 ).
8293 \layout Verse
8294
8295
8296 \family typewriter 
8297 pdata unsigned char *test_pdata_ptr;
8298 \newline 
8299
8300 \newline 
8301 void main() 
8302 \newline 
8303
8304 \newline 
8305 \SpecialChar ~
8306 \SpecialChar ~
8307 \SpecialChar ~
8308 \SpecialChar ~
8309 test_pdata_ptr = (pdata *)0xfe; 
8310 \newline 
8311 \SpecialChar ~
8312 \SpecialChar ~
8313 \SpecialChar ~
8314 \SpecialChar ~
8315 *test_pdata_ptr = 1; 
8316 \newline 
8317
8318 \layout Standard
8319
8320 Generates the assembly code:
8321 \layout Verse
8322
8323
8324 \family typewriter 
8325 75*01 FE\SpecialChar ~
8326 \SpecialChar ~
8327 \SpecialChar ~
8328 mov\SpecialChar ~
8329  _test_pdata_ptr,#0xFE
8330 \newline 
8331 78 FE\SpecialChar ~
8332 \SpecialChar ~
8333 \SpecialChar ~
8334 \SpecialChar ~
8335 \SpecialChar ~
8336 \SpecialChar ~
8337 mov\SpecialChar ~
8338  r0,#0xFE 
8339 \newline 
8340 74 01\SpecialChar ~
8341 \SpecialChar ~
8342 \SpecialChar ~
8343 \SpecialChar ~
8344 \SpecialChar ~
8345 \SpecialChar ~
8346 mov\SpecialChar ~
8347  a,#0x01
8348 \newline 
8349 F2\SpecialChar ~
8350 \SpecialChar ~
8351 \SpecialChar ~
8352 \SpecialChar ~
8353 \SpecialChar ~
8354 \SpecialChar ~
8355 \SpecialChar ~
8356 \SpecialChar ~
8357 \SpecialChar ~
8358 movx @r0,a 
8359 \layout Standard
8360
8361 If the -
8362 \begin_inset ERT
8363 status Collapsed
8364
8365 \layout Standard
8366
8367 \backslash 
8368 /
8369 \end_inset 
8370
8371 -xstack
8372 \begin_inset LatexCommand \index{-\/-xstack}
8373
8374 \end_inset 
8375
8376  option is used the pdata memory area is followed by the xstack memory area
8377  and the sum of their sizes is limited to 256 bytes.
8378 \layout Subsubsection
8379
8380 code
8381 \begin_inset LatexCommand \index{code}
8382
8383 \end_inset 
8384
8385
8386 \layout Standard
8387
8388 'Variables' declared with this storage class will be placed in the code
8389  memory:
8390 \layout Verse
8391
8392
8393 \family typewriter 
8394 code unsigned char test_code;
8395 \layout Standard
8396
8397 Read access to this variable generates the assembly code:
8398 \layout Verse
8399
8400
8401 \family typewriter 
8402 90s00r6F\SpecialChar ~
8403 \SpecialChar ~
8404 \SpecialChar ~
8405 mov dptr,#_test_code
8406 \newline 
8407 E4\SpecialChar ~
8408 \SpecialChar ~
8409 \SpecialChar ~
8410 \SpecialChar ~
8411 \SpecialChar ~
8412 \SpecialChar ~
8413 \SpecialChar ~
8414 \SpecialChar ~
8415 \SpecialChar ~
8416 clr a
8417 \newline 
8418 93\SpecialChar ~
8419 \SpecialChar ~
8420 \SpecialChar ~
8421 \SpecialChar ~
8422 \SpecialChar ~
8423 \SpecialChar ~
8424 \SpecialChar ~
8425 \SpecialChar ~
8426 \SpecialChar ~
8427 movc a,@a+dptr 
8428 \layout Standard
8429
8430
8431 \family typewriter 
8432 char
8433 \family default 
8434  indexed arrays of characters in code memory can be accessed efficiently:
8435 \layout Verse
8436
8437
8438 \family typewriter 
8439 code char test_array[] = {'c','h','e','a','p'}; 
8440 \layout Standard
8441
8442 Read access to this array using an 8-bit unsigned index generates the assembly
8443  code:
8444 \layout Verse
8445
8446
8447 \family typewriter 
8448 E5*00\SpecialChar ~
8449 \SpecialChar ~
8450 \SpecialChar ~
8451 \SpecialChar ~
8452 \SpecialChar ~
8453 \SpecialChar ~
8454 mov a,_index 
8455 \layout Verse
8456
8457
8458 \family typewriter 
8459 90s00r41\SpecialChar ~
8460 \SpecialChar ~
8461 \SpecialChar ~
8462 mov dptr,#_test_array
8463 \layout Verse
8464
8465
8466 \family typewriter 
8467 93\SpecialChar ~
8468 \SpecialChar ~
8469 \SpecialChar ~
8470 \SpecialChar ~
8471 \SpecialChar ~
8472 \SpecialChar ~
8473 \SpecialChar ~
8474 \SpecialChar ~
8475 \SpecialChar ~
8476 movc a,@a+dptr 
8477 \layout Subsubsection
8478
8479 bit
8480 \begin_inset LatexCommand \index{bit}
8481
8482 \end_inset 
8483
8484
8485 \layout Standard
8486
8487 This is a data-type and a storage class specifier.
8488  When a variable is declared as a bit, it is allocated into the bit addressable
8489  memory of 8051, e.g.:
8490 \layout Verse
8491
8492
8493 \family typewriter 
8494 bit test_bit;
8495 \layout Standard
8496
8497 Writing 1 to this variable generates the assembly code:
8498 \layout Verse
8499
8500
8501 \family typewriter 
8502 D2*00\SpecialChar ~
8503 \SpecialChar ~
8504 \SpecialChar ~
8505 \SpecialChar ~
8506 \SpecialChar ~
8507 \SpecialChar ~
8508 \SpecialChar ~
8509 setb\SpecialChar ~
8510 _test_bit
8511 \layout Standard
8512
8513 The bit addressable memory consists of 128 bits which are located from 0x20
8514  to 0x2f in data memory.
8515  
8516 \newline 
8517 Apart from this 8051 specific storage class most architectures support ANSI-C
8518  bitfields
8519 \begin_inset LatexCommand \index{bitfields}
8520
8521 \end_inset 
8522
8523
8524 \begin_inset Foot
8525 collapsed false
8526
8527 \layout Standard
8528
8529 Not really meant as examples, but nevertheless showing what bitfields are
8530  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
8531 \end_inset 
8532
8533 .
8534  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
8535  signed modifier are implemented as unsigned.
8536 \layout Subsubsection
8537
8538 sfr
8539 \begin_inset LatexCommand \index{sfr}
8540
8541 \end_inset 
8542
8543  / sbit
8544 \begin_inset LatexCommand \index{sbit}
8545
8546 \end_inset 
8547
8548
8549 \layout Standard
8550
8551 Like the bit keyword, 
8552 \emph on 
8553 sfr / sbit 
8554 \emph default 
8555 signifies both a data-type and storage class, they are used to describe
8556  the 
8557 \emph on 
8558 s
8559 \emph default 
8560 pecial 
8561 \emph on 
8562 f
8563 \emph default 
8564 unction 
8565 \emph on 
8566 r
8567 \emph default 
8568 egisters and 
8569 \emph on 
8570 s
8571 \emph default 
8572 pecial 
8573 \emph on 
8574 bit
8575 \emph default 
8576  variables of a 8051, eg:
8577 \layout Verse
8578
8579
8580 \family typewriter 
8581 sfr at
8582 \begin_inset LatexCommand \index{at}
8583
8584 \end_inset 
8585
8586  0x80 P0;\SpecialChar ~
8587  /* special function register P0 at location 0x80 */
8588 \newline 
8589 sbit at 0xd7 CY; /* CY (Carry Flag
8590 \begin_inset LatexCommand \index{Flags}
8591
8592 \end_inset 
8593
8594
8595 \begin_inset LatexCommand \index{Carry flag}
8596
8597 \end_inset 
8598
8599 ) */
8600 \layout Standard
8601
8602 Special function registers which are located on an address dividable by
8603  8 are bit-addressable, an
8604 \emph on 
8605  sbit
8606 \emph default 
8607  addresses a specific bit within these sfr.
8608 \layout Subsubsection
8609
8610 Pointers
8611 \begin_inset LatexCommand \index{Pointer}
8612
8613 \end_inset 
8614
8615  to MCS51/DS390 specific memory spaces
8616 \layout Standard
8617
8618 SDCC allows (via language extensions) pointers to explicitly point to any
8619  of the memory spaces
8620 \begin_inset LatexCommand \index{Memory model}
8621
8622 \end_inset 
8623
8624  of the 8051.
8625  In addition to the explicit pointers, the compiler uses (by default) generic
8626  pointers which can be used to point to any of the memory spaces.
8627 \newline 
8628
8629 \newline 
8630 Pointer declaration examples:
8631 \layout Verse
8632
8633
8634 \family typewriter 
8635 /* pointer physically in internal ram pointing to object in external ram
8636  */ 
8637 \newline 
8638 xdata unsigned char * data p;
8639 \newline 
8640
8641 \newline 
8642 /* pointer physically in external ram pointing to object in internal ram
8643  */ 
8644 \newline 
8645 data unsigned char * xdata p;
8646 \newline 
8647
8648 \newline 
8649 /* pointer physically in code rom pointing to data in xdata space */ 
8650 \newline 
8651 xdata unsigned char * code p;
8652 \newline 
8653
8654 \newline 
8655 /* pointer physically in code space pointing to data in code space */ 
8656 \newline 
8657 code unsigned char * code p;
8658 \newline 
8659
8660 \newline 
8661 /* the following is a generic pointer physically located in xdata space
8662  */
8663 \newline 
8664 char * xdata p;
8665 \layout Standard
8666
8667 Well you get the idea.
8668  
8669 \newline 
8670
8671 \newline 
8672 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
8673 \emph on 
8674 generic
8675 \emph default 
8676  pointers.
8677  
8678 \size small 
8679
8680 \newline 
8681
8682 \newline 
8683
8684 \size default 
8685 The highest order byte of the 
8686 \emph on 
8687 generic
8688 \emph default 
8689  pointers contains the data space information.
8690  Assembler support routines are called whenever data is stored or retrieved
8691  using 
8692 \emph on 
8693 generic
8694 \emph default 
8695  pointers.
8696  These are useful for developing reusable library
8697 \begin_inset LatexCommand \index{Libraries}
8698
8699 \end_inset 
8700
8701  routines.
8702  Explicitly specifying the pointer type will generate the most efficient
8703  code.
8704 \layout Subsubsection
8705
8706 Notes on MCS51 memory
8707 \begin_inset LatexCommand \index{MCS51 memory}
8708
8709 \end_inset 
8710
8711  layout
8712 \layout Standard
8713
8714 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
8715  RAM memory which is structured as follows:
8716 \newline 
8717
8718 \newline 
8719 - Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R0 to R7,
8720  
8721 \newline 
8722 - Bytes 20-2F - 16 bytes to hold 128 bit
8723 \begin_inset LatexCommand \index{bit}
8724
8725 \end_inset 
8726
8727  variables and, 
8728 \newline 
8729 - Bytes 30-7F - 80 bytes for general purpose use.
8730 \newline 
8731
8732 \layout Standard
8733
8734 Additionally some members of the MCS51 family may have up to 128 bytes of
8735  additional, indirectly addressable, internal RAM memory (
8736 \emph on 
8737 idata
8738 \emph default 
8739
8740 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
8741
8742 \end_inset 
8743
8744 ).
8745  Furthermore, some chips may have some built in external memory (
8746 \emph on 
8747 xdata
8748 \emph default 
8749
8750 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
8751
8752 \end_inset 
8753
8754 ) which should not be confused with the internal, directly addressable RAM
8755  memory (
8756 \emph on 
8757 data
8758 \emph default 
8759
8760 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
8761
8762 \end_inset 
8763
8764 ).
8765  Sometimes this built in 
8766 \emph on 
8767 xdata
8768 \emph default 
8769  memory has to be activated before using it (you can probably find this
8770  information on the datasheet of the microcontroller your are using, see
8771  also section 
8772 \begin_inset LatexCommand \ref{sub:Startup-Code}
8773
8774 \end_inset 
8775
8776 \SpecialChar ~
8777 Startup-Code).
8778 \layout Standard
8779
8780 Normally SDCC will only use the first bank
8781 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
8782
8783 \end_inset 
8784
8785  of registers (register bank 0), but it is possible to specify that other
8786  banks of registers should be used in interrupt
8787 \begin_inset LatexCommand \index{interrupt}
8788
8789 \end_inset 
8790
8791  routines.
8792  By default, the compiler will place the stack after the last byte of allocated
8793  memory for variables.
8794  For example, if the first 2 banks of registers are used, and only four
8795  bytes are used for 
8796 \emph on 
8797 data
8798 \emph default 
8799  variables, it will position the base of the internal stack at address 20
8800  (0x14).
8801  This implies that as the stack
8802 \begin_inset LatexCommand \index{stack}
8803
8804 \end_inset 
8805
8806  grows, it will use up the remaining register banks, and the 16 bytes used
8807  by the 128 bit variables, and 80 bytes for general purpose use.
8808  If any bit variables are used, the data variables will be placed in unused
8809  register banks and after the byte holding the last bit variable.
8810  For example, if register banks 0 and 1 are used, and there are 9 bit variables
8811  (two bytes used), 
8812 \emph on 
8813 data
8814 \emph default 
8815  variables will be placed starting from address 0x10 to 0x20 and continue
8816  at address 0x22.
8817  You can also use -
8818 \begin_inset ERT
8819 status Collapsed
8820
8821 \layout Standard
8822
8823 \backslash 
8824 /
8825 \end_inset 
8826
8827 -data-loc
8828 \begin_inset LatexCommand \index{-\/-data-loc<Value>}
8829
8830 \end_inset 
8831
8832  to specify the start address of the 
8833 \emph on 
8834 data
8835 \emph default 
8836  and -
8837 \begin_inset ERT
8838 status Collapsed
8839
8840 \layout Standard
8841
8842 \backslash 
8843 /
8844 \end_inset 
8845
8846 -iram-size to specify the size of the total internal RAM (
8847 \emph on 
8848 data
8849 \emph default 
8850 +
8851 \emph on 
8852 idata
8853 \emph default 
8854 ).
8855  
8856 \layout Standard
8857
8858 By default the 8051 linker will place the stack after the last byte of (i)data
8859  variables.
8860  Option -
8861 \begin_inset ERT
8862 status Collapsed
8863
8864 \layout Standard
8865
8866 \backslash 
8867 /
8868 \end_inset 
8869
8870 -stack-loc
8871 \begin_inset LatexCommand \index{-\/-stack-loc<Value>}
8872
8873 \end_inset 
8874
8875  allows you to specify the start of the stack, i.e.
8876  you could start it after any data in the general purpose area.
8877  If your microcontroller has additional indirectly addressable internal
8878  RAM (
8879 \emph on 
8880 idata
8881 \emph default 
8882 ) you can place the stack on it.
8883  You may also need to use -
8884 \begin_inset ERT
8885 status Collapsed
8886
8887 \layout Standard
8888
8889 \backslash 
8890 /
8891 \end_inset 
8892
8893 -xdata-loc
8894 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
8895
8896 \end_inset 
8897
8898  to set the start address of the external RAM (
8899 \emph on 
8900 xdata
8901 \emph default 
8902 ) and -
8903 \begin_inset ERT
8904 status Collapsed
8905
8906 \layout Standard
8907
8908 \backslash 
8909 /
8910 \end_inset 
8911
8912 -xram-size
8913 \begin_inset LatexCommand \index{-\/-data-loc}
8914
8915 \end_inset 
8916
8917  to specify its size.
8918  Same goes for the code memory, using -
8919 \begin_inset ERT
8920 status Collapsed
8921
8922 \layout Standard
8923
8924 \backslash 
8925 /
8926 \end_inset 
8927
8928 -code-loc
8929 \begin_inset LatexCommand \index{-\/-data-loc}
8930
8931 \end_inset 
8932
8933  and -
8934 \begin_inset ERT
8935 status Collapsed
8936
8937 \layout Standard
8938
8939 \backslash 
8940 /
8941 \end_inset 
8942
8943 -code-size
8944 \begin_inset LatexCommand \index{-\/-data-loc}
8945
8946 \end_inset 
8947
8948 .
8949  If in doubt, don't specify any options and see if the resulting memory
8950  layout is appropriate, then you can adjust it.
8951 \layout Standard
8952
8953 The linker generates two files with memory allocation information.
8954  The first, with extension .map
8955 \begin_inset LatexCommand \index{<file>.map}
8956
8957 \end_inset 
8958
8959  shows all the variables and segments.
8960  The second with extension .mem
8961 \begin_inset LatexCommand \index{<file>.mem}
8962
8963 \end_inset 
8964
8965  shows the final memory layout.
8966  The linker will complain either if memory segments overlap, there is not
8967  enough memory, or there is not enough space for stack.
8968  If you get any linking warnings and/or errors related to stack or segments
8969  allocation, take a look at either the .map or .mem files to find out what
8970  the problem is.
8971  The .mem file may even suggest a solution to the problem.
8972 \layout Subsection
8973
8974 Z80/Z180 Storage Class
8975 \begin_inset LatexCommand \index{Storage class}
8976
8977 \end_inset 
8978
8979  Language Extensions
8980 \layout Subsubsection
8981
8982 sfr
8983 \begin_inset LatexCommand \index{sfr}
8984
8985 \end_inset 
8986
8987  (in/out to 8-bit addresses)
8988 \layout Standard
8989
8990 The Z80
8991 \begin_inset LatexCommand \index{Z80}
8992
8993 \end_inset 
8994
8995  family has separate address spaces for memory and 
8996 \emph on 
8997 i
8998 \emph default 
8999 nput/
9000 \emph on 
9001 o
9002 \emph default 
9003 utput memory.
9004  I/O memory
9005 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
9006
9007 \end_inset 
9008
9009  is accessed with special instructions, e.g.:
9010 \layout Verse
9011
9012
9013 \family typewriter 
9014 sfr at 0x78 IoPort;\SpecialChar ~
9015 \SpecialChar ~
9016 /* define a var in I/O space at 78h called IoPort */
9017  
9018 \layout Standard
9019
9020 Writing 0x01 to this variable generates the assembly code:
9021 \layout Verse
9022
9023
9024 \family typewriter 
9025 3E 01\SpecialChar ~
9026 \SpecialChar ~
9027 \SpecialChar ~
9028 \SpecialChar ~
9029 \SpecialChar ~
9030 \SpecialChar ~
9031 ld a,#0x01
9032 \newline 
9033 D3 78\SpecialChar ~
9034 \SpecialChar ~
9035 \SpecialChar ~
9036 \SpecialChar ~
9037 \SpecialChar ~
9038 \SpecialChar ~
9039 out (_IoPort),a 
9040 \layout Subsubsection
9041
9042 banked sfr
9043 \begin_inset LatexCommand \index{sfr}
9044
9045 \end_inset 
9046
9047  (in/out to 16-bit addresses)
9048 \layout Standard
9049
9050 The keyword 
9051 \emph on 
9052 banked
9053 \emph default 
9054  is used to support 16 bit addresses in I/O memory e.g.:
9055 \layout Verse
9056
9057
9058 \family typewriter 
9059 sfr banked at
9060 \begin_inset LatexCommand \index{at}
9061
9062 \end_inset 
9063
9064  0x123 IoPort; 
9065 \layout Standard
9066
9067 Writing 0x01 to this variable generates the assembly code:
9068 \layout Verse
9069
9070
9071 \family typewriter 
9072 01 23 01\SpecialChar ~
9073 \SpecialChar ~
9074 \SpecialChar ~
9075 ld bc,#_IoPort
9076 \newline 
9077 3E 01\SpecialChar ~
9078 \SpecialChar ~
9079 \SpecialChar ~
9080 \SpecialChar ~
9081 \SpecialChar ~
9082 \SpecialChar ~
9083 ld a,#0x01 
9084 \newline 
9085 ED 79\SpecialChar ~
9086 \SpecialChar ~
9087 \SpecialChar ~
9088 \SpecialChar ~
9089 \SpecialChar ~
9090 \SpecialChar ~
9091 out (c),a 
9092 \layout Subsubsection
9093
9094 sfr
9095 \begin_inset LatexCommand \index{sfr}
9096
9097 \end_inset 
9098
9099  (in0/out0 to 8 bit addresses on Z180
9100 \begin_inset LatexCommand \index{Z180}
9101
9102 \end_inset 
9103
9104 /HD64180
9105 \begin_inset LatexCommand \index{HD64180}
9106
9107 \end_inset 
9108
9109 )
9110 \layout Standard
9111
9112 The compiler option -
9113 \begin_inset ERT
9114 status Collapsed
9115
9116 \layout Standard
9117
9118 \backslash 
9119 /
9120 \end_inset 
9121
9122 -portmode=180 (80) and a compiler #pragma\SpecialChar ~
9123 portmode
9124 \begin_inset LatexCommand \index{\#pragma portmode}
9125
9126 \end_inset 
9127
9128 =z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
9129 ns 
9130 \family typewriter 
9131 in0/out0
9132 \family default 
9133  instead of 
9134 \family typewriter 
9135 in/out
9136 \family default 
9137 .
9138  If you include the file z180.h this will be set automatically.
9139 \layout Subsection
9140
9141 HC08 Storage Class
9142 \begin_inset LatexCommand \index{Storage class}
9143
9144 \end_inset 
9145
9146  Language Extensions
9147 \layout Subsubsection
9148
9149 data
9150 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
9151
9152 \end_inset 
9153
9154
9155 \layout Standard
9156
9157 The data storage class declares a variable that resides in the first 256
9158  bytes of memory (the direct page).
9159  The HC08 is most efficient at accessing variables (especially pointers)
9160  stored here.
9161 \layout Subsubsection
9162
9163 xdata
9164 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
9165
9166 \end_inset 
9167
9168
9169 \layout Standard
9170
9171 The xdata storage class declares a variable that can reside anywhere in
9172  memory.
9173  This is the default if no storage class is specified.
9174  
9175 \layout Section
9176
9177 Absolute Addressing
9178 \begin_inset LatexCommand \index{Absolute addressing}
9179
9180 \end_inset 
9181
9182
9183 \layout Standard
9184
9185 Data items can be assigned an absolute address with the 
9186 \emph on 
9187 at
9188 \begin_inset LatexCommand \index{at}
9189
9190 \end_inset 
9191
9192  <address>
9193 \emph default 
9194  keyword, in addition to a storage class, e.g.:
9195 \layout Verse
9196
9197
9198 \family typewriter 
9199 xdata
9200 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
9201
9202 \end_inset 
9203
9204  at
9205 \begin_inset LatexCommand \index{at}
9206
9207 \end_inset 
9208
9209  0x7ffe unsigned int chksum;
9210 \layout Standard
9211
9212 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
9213  of the external ram.
9214  The compiler does 
9215 \emph on 
9216 not
9217 \emph default 
9218  reserve any space for variables declared in this way (they are implemented
9219  with an equate in the assembler).
9220  Thus it is left to the programmer to make sure there are no overlaps with
9221  other variables that are declared without the absolute address.
9222  The assembler listing file (.lst
9223 \begin_inset LatexCommand \index{<file>.lst}
9224
9225 \end_inset 
9226
9227 ) and the linker output files (.rst
9228 \begin_inset LatexCommand \index{<file>.rst}
9229
9230 \end_inset 
9231
9232 ) and (.map
9233 \begin_inset LatexCommand \index{<file>.map}
9234
9235 \end_inset 
9236
9237 ) are good places to look for such overlaps.
9238  Variables with an absolute address are 
9239 \emph on 
9240 not
9241 \emph default 
9242  initialized
9243 \begin_inset LatexCommand \index{Variable initialization}
9244
9245 \end_inset 
9246
9247 .
9248 \layout Standard
9249
9250 In case of memory mapped I/O devices the keyword 
9251 \emph on 
9252 volatile
9253 \emph default 
9254  has to be used to tell the compiler that accesses might not be removed:
9255 \layout Verse
9256
9257
9258 \family typewriter 
9259 volatile
9260 \begin_inset LatexCommand \index{volatile}
9261
9262 \end_inset 
9263
9264  xdata
9265 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
9266
9267 \end_inset 
9268
9269  at
9270 \begin_inset LatexCommand \index{at}
9271
9272 \end_inset 
9273
9274  0x8000 unsigned char PORTA_8255;
9275 \layout Standard
9276
9277 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
9278 r) array
9279 \family typewriter 
9280 \size footnotesize 
9281
9282 \begin_inset LatexCommand \index{Aligned array}
9283
9284 \end_inset 
9285
9286
9287 \family default 
9288 \size default 
9289  starts at a block (256 byte) boundary
9290 \begin_inset LatexCommand \index{block boundary}
9291
9292 \end_inset 
9293
9294  (section 
9295 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
9296
9297 \end_inset 
9298
9299  has an example).
9300 \newline 
9301 Absolute addresses can be specified for variables in all storage classes,
9302  e.g.:
9303 \layout Verse
9304
9305
9306 \family typewriter 
9307 bit
9308 \begin_inset LatexCommand \index{bit}
9309
9310 \end_inset 
9311
9312  at
9313 \begin_inset LatexCommand \index{at}
9314
9315 \end_inset 
9316
9317  0x02 bvar;
9318 \layout Standard
9319
9320 The above example will allocate the variable at offset 0x02 in the bit-addressab
9321 le space.
9322  There is no real advantage to assigning absolute addresses to variables
9323  in this manner, unless you want strict control over all the variables allocated.
9324  One possible use would be to write hardware portable code.
9325  For example, if you have a routine that uses one or more of the microcontroller
9326  I/O pins, and such pins are different for two different hardwares, you
9327  can declare the I/O pins in your routine using:
9328 \layout Verse
9329
9330
9331 \family typewriter 
9332 extern volatile bit MOSI;\SpecialChar ~
9333 \SpecialChar ~
9334 \SpecialChar ~
9335 \SpecialChar ~
9336 /* master out, slave in */
9337 \newline 
9338 extern volatile bit MISO;\SpecialChar ~
9339 \SpecialChar ~
9340 \SpecialChar ~
9341 \SpecialChar ~
9342 /* master in, slave out */
9343 \newline 
9344 extern volatile bit MCLK;\SpecialChar ~
9345 \SpecialChar ~
9346 \SpecialChar ~
9347 \SpecialChar ~
9348 /* master clock */
9349 \newline 
9350
9351 \newline 
9352 /* Input and Output of a byte on a 3-wire serial bus.
9353 \newline 
9354 \SpecialChar ~
9355 \SpecialChar ~
9356 \SpecialChar ~
9357 If needed adapt polarity of clock, polarity of data and bit order
9358 \newline 
9359 \SpecialChar ~
9360 */
9361 \newline 
9362 unsigned char spi_io(unsigned char out_byte) 
9363 \newline 
9364
9365 \newline 
9366 \SpecialChar ~
9367 \SpecialChar ~
9368 \SpecialChar ~
9369 \SpecialChar ~
9370 unsigned char i=8;
9371 \newline 
9372 \SpecialChar ~
9373 \SpecialChar ~
9374 \SpecialChar ~
9375 \SpecialChar ~
9376 do { 
9377 \newline 
9378 \SpecialChar ~
9379 \SpecialChar ~
9380 \SpecialChar ~
9381 \SpecialChar ~
9382 \SpecialChar ~
9383 \SpecialChar ~
9384 \SpecialChar ~
9385 \SpecialChar ~
9386 MOSI = out_byte & 0x80; 
9387 \newline 
9388 \SpecialChar ~
9389 \SpecialChar ~
9390 \SpecialChar ~
9391 \SpecialChar ~
9392 \SpecialChar ~
9393 \SpecialChar ~
9394 \SpecialChar ~
9395 \SpecialChar ~
9396 out_byte <<= 1;
9397 \newline 
9398 \SpecialChar ~
9399 \SpecialChar ~
9400 \SpecialChar ~
9401 \SpecialChar ~
9402 \SpecialChar ~
9403 \SpecialChar ~
9404 \SpecialChar ~
9405 \SpecialChar ~
9406 MCLK = 1; 
9407 \newline 
9408 \SpecialChar ~
9409 \SpecialChar ~
9410 \SpecialChar ~
9411 \SpecialChar ~
9412 \SpecialChar ~
9413 \SpecialChar ~
9414 \SpecialChar ~
9415 \SpecialChar ~
9416 /* _asm nop _endasm; */\SpecialChar ~
9417 \SpecialChar ~
9418 \SpecialChar ~
9419 \SpecialChar ~
9420 \SpecialChar ~
9421 \SpecialChar ~
9422 \SpecialChar ~
9423 \SpecialChar ~
9424 /* for slow peripherals */
9425 \newline 
9426 \SpecialChar ~
9427 \SpecialChar ~
9428 \SpecialChar ~
9429 \SpecialChar ~
9430 \SpecialChar ~
9431 \SpecialChar ~
9432 \SpecialChar ~
9433 \SpecialChar ~
9434 if(MISO) 
9435 \newline 
9436 \SpecialChar ~
9437 \SpecialChar ~
9438 \SpecialChar ~
9439 \SpecialChar ~
9440 \SpecialChar ~
9441 \SpecialChar ~
9442 \SpecialChar ~
9443 \SpecialChar ~
9444 \SpecialChar ~
9445 \SpecialChar ~
9446 \SpecialChar ~
9447 \SpecialChar ~
9448 out_byte += 1; 
9449 \newline 
9450 \SpecialChar ~
9451 \SpecialChar ~
9452 \SpecialChar ~
9453 \SpecialChar ~
9454 \SpecialChar ~
9455 \SpecialChar ~
9456 \SpecialChar ~
9457 \SpecialChar ~
9458 MCLK = 0; 
9459 \newline 
9460 \SpecialChar ~
9461 \SpecialChar ~
9462 \SpecialChar ~
9463 \SpecialChar ~
9464 } while(--i);
9465 \newline 
9466 \SpecialChar ~
9467 \SpecialChar ~
9468 \SpecialChar ~
9469 \SpecialChar ~
9470 return out_byte; 
9471 \newline 
9472 }
9473 \layout Standard
9474
9475 Then, someplace in the code for the first hardware you would use
9476 \layout Verse
9477
9478
9479 \family typewriter 
9480 bit at 0x80 MOSI;\SpecialChar ~
9481 \SpecialChar ~
9482 \SpecialChar ~
9483 \SpecialChar ~
9484 /* I/O port 0, bit 0 */
9485 \newline 
9486 bit at 0x81 MISO;\SpecialChar ~
9487 \SpecialChar ~
9488 \SpecialChar ~
9489 \SpecialChar ~
9490 /* I/O port 0, bit 1 */
9491 \newline 
9492 bit at 0x82 MCLK;\SpecialChar ~
9493 \SpecialChar ~
9494 \SpecialChar ~
9495 \SpecialChar ~
9496 /* I/O port 0, bit 2 */
9497 \layout Standard
9498
9499 Similarly, for the second hardware you would use
9500 \layout Verse
9501
9502
9503 \family typewriter 
9504 bit at 0x83 MOSI;\SpecialChar ~
9505 \SpecialChar ~
9506 \SpecialChar ~
9507 \SpecialChar ~
9508 /* I/O port 0, bit 3 */
9509 \newline 
9510 bit at 0x91 MISO;\SpecialChar ~
9511 \SpecialChar ~
9512 \SpecialChar ~
9513 \SpecialChar ~
9514 /* I/O port 1, bit 1 */
9515 \newline 
9516 bit
9517 \begin_inset LatexCommand \index{bit}
9518
9519 \end_inset 
9520
9521  at 0x92 MCLK;\SpecialChar ~
9522 \SpecialChar ~
9523 \SpecialChar ~
9524 \SpecialChar ~
9525 /* I/O port 1, bit 2 */
9526 \layout Standard
9527
9528 and you can use the same hardware dependent routine without changes, as
9529  for example in a library.
9530  This is somehow similar to sbit, but only one absolute address has to be
9531  specified in the whole project.
9532 \layout Section
9533
9534 Parameters
9535 \begin_inset LatexCommand \index{Parameters}
9536
9537 \end_inset 
9538
9539
9540 \begin_inset LatexCommand \index{function parameter}
9541
9542 \end_inset 
9543
9544  & Local Variables
9545 \begin_inset LatexCommand \index{local variables}
9546
9547 \end_inset 
9548
9549
9550 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
9551
9552 \end_inset 
9553
9554
9555 \layout Standard
9556
9557 Automatic (local) variables and parameters to functions can either be placed
9558  on the stack or in data-space.
9559  The default action of the compiler is to place these variables in the internal
9560  RAM (for small model) or external RAM (for large model).
9561  This in fact makes them similar to 
9562 \emph on 
9563 static
9564 \begin_inset LatexCommand \index{static}
9565
9566 \end_inset 
9567
9568
9569 \emph default 
9570  so by default functions are non-reentrant
9571 \begin_inset LatexCommand \index{reentrant}
9572
9573 \end_inset 
9574
9575 .
9576  
9577 \newline 
9578
9579 \newline 
9580 They can be placed on the stack
9581 \begin_inset LatexCommand \index{stack}
9582
9583 \end_inset 
9584
9585  by using the
9586 \emph on 
9587  -
9588 \begin_inset ERT
9589 status Collapsed
9590
9591 \layout Standard
9592
9593 \backslash 
9594 /
9595 \end_inset 
9596
9597 -stack-auto
9598 \begin_inset LatexCommand \index{-\/-stack-auto}
9599
9600 \end_inset 
9601
9602
9603 \emph default 
9604  option, by using 
9605 \emph on 
9606 #pragma\SpecialChar ~
9607 stackauto
9608 \emph default 
9609
9610 \begin_inset LatexCommand \index{\#pragma stackauto}
9611
9612 \end_inset 
9613
9614  or by using the 
9615 \emph on 
9616 reentrant
9617 \begin_inset LatexCommand \index{reentrant}
9618
9619 \end_inset 
9620
9621
9622 \emph default 
9623  keyword in the function declaration, e.g.:
9624 \layout Verse
9625
9626
9627 \family typewriter 
9628 unsigned char foo(char i) reentrant 
9629 \newline 
9630
9631 \newline 
9632 \SpecialChar ~
9633 \SpecialChar ~
9634 \SpecialChar ~
9635 \SpecialChar ~
9636 ...
9637  
9638 \newline 
9639 }
9640 \layout Standard
9641
9642 Since stack space on 8051 is limited, the 
9643 \emph on 
9644 reentrant 
9645 \emph default 
9646 keyword or the
9647 \emph on 
9648  -
9649 \begin_inset ERT
9650 status Collapsed
9651
9652 \layout Standard
9653
9654 \backslash 
9655 /
9656 \end_inset 
9657
9658 -stack-auto
9659 \emph default 
9660  option should be used sparingly.
9661  Note that the reentrant keyword just means that the parameters & local
9662  variables will be allocated to the stack, it 
9663 \emph on 
9664 does not
9665 \emph default 
9666  mean that the function is register bank
9667 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
9668
9669 \end_inset 
9670
9671  independent.
9672 \newline 
9673
9674 \newline 
9675 Local variables
9676 \begin_inset LatexCommand \index{local variables}
9677
9678 \end_inset 
9679
9680  can be assigned storage classes and absolute
9681 \begin_inset LatexCommand \index{Absolute addressing}
9682
9683 \end_inset 
9684
9685  addresses, e.g.: 
9686 \layout Verse
9687
9688
9689 \family typewriter 
9690 unsigned char foo() 
9691 \newline 
9692 {
9693 \newline 
9694 \SpecialChar ~
9695 \SpecialChar ~
9696 \SpecialChar ~
9697 \SpecialChar ~
9698 xdata unsigned char i;
9699 \newline 
9700 \SpecialChar ~
9701 \SpecialChar ~
9702 \SpecialChar ~
9703 \SpecialChar ~
9704 bit bvar;
9705 \newline 
9706 \SpecialChar ~
9707 \SpecialChar ~
9708 \SpecialChar ~
9709 \SpecialChar ~
9710 data at
9711 \begin_inset LatexCommand \index{at}
9712
9713 \end_inset 
9714
9715  0x31 unsigned char j;
9716 \newline 
9717 \SpecialChar ~
9718 \SpecialChar ~
9719 \SpecialChar ~
9720 \SpecialChar ~
9721 ...
9722  
9723 \newline 
9724 }
9725 \layout Standard
9726
9727 In the above example the variable 
9728 \emph on 
9729 i
9730 \emph default 
9731  will be allocated in the external ram, 
9732 \emph on 
9733 bvar
9734 \emph default 
9735  in bit addressable space and
9736 \emph on 
9737  j
9738 \emph default 
9739  in internal ram.
9740  When compiled with 
9741 \emph on 
9742 -
9743 \begin_inset ERT
9744 status Collapsed
9745
9746 \layout Standard
9747
9748 \backslash 
9749 /
9750 \end_inset 
9751
9752 -stack-auto
9753 \emph default 
9754  or when a function is declared as 
9755 \emph on 
9756 reentrant
9757 \emph default 
9758  this should only be done for static variables.
9759 \layout Standard
9760
9761 Parameters
9762 \begin_inset LatexCommand \index{function parameter}
9763
9764 \end_inset 
9765
9766  however are not allowed any storage class
9767 \begin_inset LatexCommand \index{Storage class}
9768
9769 \end_inset 
9770
9771 , (storage classes for parameters will be ignored), their allocation is
9772  governed by the memory model in use, and the reentrancy options.
9773 \layout Section
9774
9775 Overlaying
9776 \begin_inset LatexCommand \label{sub:Overlaying}
9777
9778 \end_inset 
9779
9780
9781 \begin_inset LatexCommand \index{Overlaying}
9782
9783 \end_inset 
9784
9785
9786 \layout Standard
9787
9788 For non-reentrant
9789 \begin_inset LatexCommand \index{reentrant}
9790
9791 \end_inset 
9792
9793  functions SDCC will try to reduce internal ram space usage by overlaying
9794  parameters and local variables of a function (if possible).
9795  Parameters and local variables
9796 \begin_inset LatexCommand \index{local variables}
9797
9798 \end_inset 
9799
9800  of a function will be allocated to an overlayable segment if the function
9801  has 
9802 \emph on 
9803 no other function calls and the function is non-reentrant and the memory
9804  model
9805 \begin_inset LatexCommand \index{Memory model}
9806
9807 \end_inset 
9808
9809  is small.
9810
9811 \emph default 
9812  If an explicit storage class
9813 \begin_inset LatexCommand \index{Storage class}
9814
9815 \end_inset 
9816
9817  is specified for a local variable, it will NOT be overlayed.
9818 \layout Standard
9819
9820 Note that the compiler (not the linkage editor) makes the decision for overlayin
9821 g the data items.
9822  Functions that are called from an interrupt service routine should be preceded
9823  by a #pragma\SpecialChar ~
9824 nooverlay
9825 \begin_inset LatexCommand \index{\#pragma nooverlay}
9826
9827 \end_inset 
9828
9829  if they are not reentrant.
9830 \layout Standard
9831
9832 Also note that the compiler does not do any processing of inline assembler
9833  code, so the compiler might incorrectly assign local variables and parameters
9834  of a function into the overlay segment if the inline assembler code calls
9835  other c-functions that might use the overlay.
9836  In that case the #pragma\SpecialChar ~
9837 nooverlay should be used.
9838 \layout Standard
9839
9840 Parameters and local variables of functions that contain 16 or 32 bit multiplica
9841 tion
9842 \begin_inset LatexCommand \index{Multiplication}
9843
9844 \end_inset 
9845
9846  or division
9847 \begin_inset LatexCommand \index{Division}
9848
9849 \end_inset 
9850
9851  will NOT be overlayed since these are implemented using external functions,
9852  e.g.:
9853 \layout Verse
9854
9855
9856 \family typewriter 
9857 #pragma save 
9858 \newline 
9859 #pragma nooverlay
9860 \begin_inset LatexCommand \index{\#pragma nooverlay}
9861
9862 \end_inset 
9863
9864  
9865 \newline 
9866 void set_error(unsigned char errcd) 
9867 \newline 
9868 {
9869 \newline 
9870 \SpecialChar ~
9871 \SpecialChar ~
9872 \SpecialChar ~
9873 \SpecialChar ~
9874 P3 = errcd;
9875 \newline 
9876
9877 \newline 
9878 #pragma restore 
9879 \newline 
9880
9881 \newline 
9882 void some_isr () interrupt
9883 \begin_inset LatexCommand \index{interrupt}
9884
9885 \end_inset 
9886
9887  2
9888 \newline 
9889 {
9890 \newline 
9891 \SpecialChar ~
9892 \SpecialChar ~
9893 \SpecialChar ~
9894 \SpecialChar ~
9895 ...
9896 \newline 
9897 \SpecialChar ~
9898 \SpecialChar ~
9899 \SpecialChar ~
9900 \SpecialChar ~
9901 set_error(10);
9902 \newline 
9903 \SpecialChar ~
9904 \SpecialChar ~
9905 \SpecialChar ~
9906 \SpecialChar ~
9907 ...
9908  
9909 \newline 
9910 }
9911 \layout Standard
9912
9913 In the above example the parameter 
9914 \emph on 
9915 errcd
9916 \emph default 
9917  for the function 
9918 \emph on 
9919 set_error
9920 \emph default 
9921  would be assigned to the overlayable segment if the #pragma\SpecialChar ~
9922 nooverlay was
9923  not present, this could cause unpredictable runtime behavior when called
9924  from an interrupt service routine.
9925  The #pragma\SpecialChar ~
9926 nooverlay ensures that the parameters and local variables for
9927  the function are NOT overlayed.
9928 \layout Section
9929
9930 Interrupt Service Routines
9931 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
9932
9933 \end_inset 
9934
9935
9936 \layout Subsection
9937
9938 General Information
9939 \layout Standard
9940
9941 SDCC allows 
9942 \emph on 
9943 i
9944 \emph default 
9945 nterrupt 
9946 \emph on 
9947 s
9948 \emph default 
9949 ervice 
9950 \emph on 
9951 r
9952 \emph default 
9953 outines to be coded in C, with some extended keywords.
9954 \layout Verse
9955
9956
9957 \family typewriter 
9958 void timer_isr (void) interrupt 1 using 1 
9959 \newline 
9960
9961 \newline 
9962 \SpecialChar ~
9963 \SpecialChar ~
9964 \SpecialChar ~
9965 \SpecialChar ~
9966 ...
9967  
9968 \newline 
9969 }
9970 \layout Standard
9971
9972 The optional number following the 
9973 \emph on 
9974 interrupt
9975 \begin_inset LatexCommand \index{interrupt}
9976
9977 \end_inset 
9978
9979
9980 \emph default 
9981  keyword is the interrupt number this routine will service.
9982  When present, the compiler will insert a call to this routine in the interrupt
9983  vector table for the interrupt number specified.
9984  If you have multiple source files in your project, interrupt service routines
9985  can be present in any of them, but a prototype of the isr MUST be present
9986  or included in the file that contains the function 
9987 \emph on 
9988 main
9989 \emph default 
9990 .
9991  The 
9992 \emph on 
9993 using
9994 \emph default 
9995  keyword can be used to tell the compiler to use the specified register
9996  bank (8051 specific) when generating code for this function.
9997  
9998 \newline 
9999
10000 \layout Standard
10001
10002 Interrupt service routines open the door for some very interesting bugs:
10003 \newline 
10004 If an interrupt service routine changes variables which are accessed by
10005  other functions these variables have to be declared 
10006 \emph on 
10007 volatile
10008 \emph default 
10009
10010 \begin_inset LatexCommand \index{volatile}
10011
10012 \end_inset 
10013
10014 .
10015  
10016 \layout Standard
10017
10018 If the access to these variables is not 
10019 \emph on 
10020 atomic
10021 \begin_inset LatexCommand \index{atomic}
10022
10023 \end_inset 
10024
10025
10026 \emph default 
10027  (i.e.
10028  the processor needs more than one instruction for the access and could
10029  be interrupted while accessing the variable) the interrupt must be disabled
10030  during the access to avoid inconsistent data.
10031  Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
10032  and should be protected by disabling interrupts.
10033  You're not automatically on the safe side if you use 8 bit variables though.
10034  We need an example here: f.e.
10035  on the 8051 the harmless looking 
10036 \begin_inset Quotes srd
10037 \end_inset 
10038
10039
10040 \family typewriter 
10041 flags\SpecialChar ~
10042 |=\SpecialChar ~
10043 0x80;
10044 \family default 
10045
10046 \begin_inset Quotes sld
10047 \end_inset 
10048
10049  is not atomic if 
10050 \family typewriter 
10051 flags
10052 \family default 
10053  resides in xdata.
10054  Setting 
10055 \begin_inset Quotes srd
10056 \end_inset 
10057
10058
10059 \family typewriter 
10060 flags\SpecialChar ~
10061 |=\SpecialChar ~
10062 0x40;
10063 \family default 
10064
10065 \begin_inset Quotes sld
10066 \end_inset 
10067
10068  from within an interrupt routine might get lost if the interrupt occurs
10069  at the wrong time.
10070  
10071 \begin_inset Quotes sld
10072 \end_inset 
10073
10074
10075 \family typewriter 
10076 counter\SpecialChar ~
10077 +=\SpecialChar ~
10078 8;
10079 \family default 
10080
10081 \begin_inset Quotes srd
10082 \end_inset 
10083
10084  is not atomic on the 8051 even if 
10085 \family typewriter 
10086 counter
10087 \family default 
10088  is located in data memory.
10089  Bugs like these are hard to reproduce and can cause a lot of trouble.
10090  
10091 \layout Standard
10092
10093 The return address and the registers used in the interrupt service routine
10094  are saved on the stack
10095 \begin_inset LatexCommand \index{stack}
10096
10097 \end_inset 
10098
10099  so there must be sufficient stack space.
10100  If there isn't variables or registers (or even the return address itself)
10101  will be corrupted.
10102  This 
10103 \emph on 
10104 stack overflow
10105 \emph default 
10106
10107 \begin_inset LatexCommand \index{stack overflow}
10108
10109 \end_inset 
10110
10111  is most likely to happen if the interrupt occurs during the 
10112 \begin_inset Quotes sld
10113 \end_inset 
10114
10115 deepest
10116 \begin_inset Quotes srd
10117 \end_inset 
10118
10119  subroutine when the stack is already in use for f.e.
10120  many return addresses.
10121 \layout Standard
10122
10123 A special note here, int (16 bit) and long (32 bit) integer division
10124 \begin_inset LatexCommand \index{Division}
10125
10126 \end_inset 
10127
10128 , multiplication
10129 \begin_inset LatexCommand \index{Multiplication}
10130
10131 \end_inset 
10132
10133  & modulus
10134 \begin_inset LatexCommand \index{Modulus}
10135
10136 \end_inset 
10137
10138  and floating-point
10139 \begin_inset LatexCommand \index{Floating point support}
10140
10141 \end_inset 
10142
10143  operations are implemented using external support routines developed in
10144  ANSI-C.
10145  If an interrupt service routine needs to do any of these operations then
10146  the support routines (as mentioned in a following section) will have to
10147  be recompiled using the
10148 \emph on 
10149  -
10150 \begin_inset ERT
10151 status Collapsed
10152
10153 \layout Standard
10154
10155 \backslash 
10156 /
10157 \end_inset 
10158
10159 -stack-auto
10160 \begin_inset LatexCommand \index{-\/-stack-auto}
10161
10162 \end_inset 
10163
10164
10165 \emph default 
10166  option and the source file will need to be compiled using the 
10167 \emph on 
10168 -
10169 \begin_inset ERT
10170 status Collapsed
10171
10172 \layout Standard
10173
10174 \backslash 
10175 /
10176 \end_inset 
10177
10178 -int-long-reent
10179 \emph default 
10180
10181 \begin_inset LatexCommand \index{-\/-int-long-reent}
10182
10183 \end_inset 
10184
10185  compiler option.
10186 \layout Standard
10187
10188 Calling other functions from an interrupt service routine is not recommended,
10189  avoid it if possible.
10190  Note that when some function is called from an interrupt service routine
10191  it should be preceded by a #pragma\SpecialChar ~
10192 nooverlay
10193 \begin_inset LatexCommand \index{\#pragma nooverlay}
10194
10195 \end_inset 
10196
10197  if it is not reentrant.
10198  Furthermore nonreentrant functions should not be called from the main program
10199  while the interrupt service routine might be active.
10200  
10201 \newline 
10202
10203 \newline 
10204 Also see section 
10205 \begin_inset LatexCommand \ref{sub:Overlaying}
10206
10207 \end_inset 
10208
10209 \SpecialChar ~
10210 about Overlaying and section 
10211 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
10212
10213 \end_inset 
10214
10215 \SpecialChar ~
10216 about Functions using private register banks.
10217 \layout Subsection
10218
10219 MCS51/DS390 Interrupt Service Routines
10220 \layout Standard
10221
10222 Interrupt numbers and the corresponding address & descriptions for the Standard
10223  8051/8052 are listed below.
10224  SDCC will automatically adjust the interrupt vector table to the maximum
10225  interrupt number specified.
10226 \newline 
10227
10228 \layout Standard
10229 \align center 
10230
10231 \begin_inset  Tabular
10232 <lyxtabular version="3" rows="7" columns="3">
10233 <features>
10234 <column alignment="center" valignment="top" leftline="true" width="0in">
10235 <column alignment="center" valignment="top" leftline="true" width="0in">
10236 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0in">
10237 <row topline="true" bottomline="true">
10238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10239 \begin_inset Text
10240
10241 \layout Standard
10242
10243 Interrupt #
10244 \end_inset 
10245 </cell>
10246 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10247 \begin_inset Text
10248
10249 \layout Standard
10250
10251 Description
10252 \end_inset 
10253 </cell>
10254 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10255 \begin_inset Text
10256
10257 \layout Standard
10258
10259 Vector Address
10260 \end_inset 
10261 </cell>
10262 </row>
10263 <row topline="true">
10264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10265 \begin_inset Text
10266
10267 \layout Standard
10268
10269 0
10270 \end_inset 
10271 </cell>
10272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10273 \begin_inset Text
10274
10275 \layout Standard
10276
10277 External 0
10278 \end_inset 
10279 </cell>
10280 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10281 \begin_inset Text
10282
10283 \layout Standard
10284
10285 0x0003
10286 \end_inset 
10287 </cell>
10288 </row>
10289 <row topline="true">
10290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10291 \begin_inset Text
10292
10293 \layout Standard
10294
10295 1
10296 \end_inset 
10297 </cell>
10298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10299 \begin_inset Text
10300
10301 \layout Standard
10302
10303 Timer 0
10304 \end_inset 
10305 </cell>
10306 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10307 \begin_inset Text
10308
10309 \layout Standard
10310
10311 0x000B
10312 \end_inset 
10313 </cell>
10314 </row>
10315 <row topline="true">
10316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10317 \begin_inset Text
10318
10319 \layout Standard
10320
10321 2
10322 \end_inset 
10323 </cell>
10324 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10325 \begin_inset Text
10326
10327 \layout Standard
10328
10329 External 1
10330 \end_inset 
10331 </cell>
10332 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10333 \begin_inset Text
10334
10335 \layout Standard
10336
10337 0x0013
10338 \end_inset 
10339 </cell>
10340 </row>
10341 <row topline="true">
10342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10343 \begin_inset Text
10344
10345 \layout Standard
10346
10347 3
10348 \end_inset 
10349 </cell>
10350 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10351 \begin_inset Text
10352
10353 \layout Standard
10354
10355 Timer 1
10356 \end_inset 
10357 </cell>
10358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10359 \begin_inset Text
10360
10361 \layout Standard
10362
10363 0x001B
10364 \end_inset 
10365 </cell>
10366 </row>
10367 <row topline="true">
10368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10369 \begin_inset Text
10370
10371 \layout Standard
10372
10373 4
10374 \end_inset 
10375 </cell>
10376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10377 \begin_inset Text
10378
10379 \layout Standard
10380
10381 Serial
10382 \end_inset 
10383 </cell>
10384 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10385 \begin_inset Text
10386
10387 \layout Standard
10388
10389 0x0023
10390 \end_inset 
10391 </cell>
10392 </row>
10393 <row topline="true" bottomline="true">
10394 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10395 \begin_inset Text
10396
10397 \layout Standard
10398
10399 5
10400 \end_inset 
10401 </cell>
10402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10403 \begin_inset Text
10404
10405 \layout Standard
10406
10407 Timer 2 (8052)
10408 \end_inset 
10409 </cell>
10410 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10411 \begin_inset Text
10412
10413 \layout Standard
10414
10415 0x002B
10416 \end_inset 
10417 </cell>
10418 </row>
10419 </lyxtabular>
10420
10421 \end_inset 
10422
10423
10424 \newline 
10425
10426 \layout Standard
10427
10428 If the interrupt service routine is defined without 
10429 \emph on 
10430 using
10431 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
10432
10433 \end_inset 
10434
10435
10436 \emph default 
10437  a register bank or with register bank 0 (
10438 \emph on 
10439 using
10440 \emph default 
10441  0), the compiler will save the registers used by itself on the stack upon
10442  entry and restore them at exit, however if such an interrupt service routine
10443  calls another function then the entire register bank will be saved on the
10444  stack.
10445  This scheme may be advantageous for small interrupt service routines which
10446  have low register usage.
10447 \layout Standard
10448
10449 If the interrupt service routine is defined to be using a specific register
10450  bank then only 
10451 \emph on 
10452 a, b, dptr
10453 \emph default 
10454  & psw are saved and restored, if such an interrupt service routine calls
10455  another function (using another register bank) then the entire register
10456  bank of the called function will be saved on the stack.
10457  This scheme is recommended for larger interrupt service routines.
10458 \layout Subsection
10459
10460 HC08 Interrupt Service Routines
10461 \layout Standard
10462
10463 Since the number of interrupts available is chip specific and the interrupt
10464  vector table always ends at the last byte of memory, the interrupt numbers
10465  corresponds to the interrupt vectors in reverse order of address.
10466  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
10467  2 will use the interrupt vector at 0xfffa, and so on.
10468  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
10469  this way; instead see section 
10470 \begin_inset LatexCommand \ref{sub:Startup-Code}
10471
10472 \end_inset 
10473
10474  for details on customizing startup.
10475 \layout Subsection
10476
10477 Z80 Interrupt Service Routines
10478 \layout Standard
10479
10480 The Z80 uses several different methods for determining the correct interrupt
10481  vector depending on the hardware implementation.
10482  Therefore, SDCC ignores the optional interrupt number and does not attempt
10483  to generate an interrupt vector table.
10484 \layout Standard
10485
10486 By default, SDCC generates code for a maskable interrupt, which uses an
10487  RETI instruction to return from the interrupt.
10488  To write an interrupt handler for the non-maskable interrupt, which needs
10489  an RETN instruction instead, add the 
10490 \emph on 
10491 critical
10492 \emph default 
10493  keyword:
10494 \layout Verse
10495
10496
10497 \family typewriter 
10498 void nmi_isr (void) critical interrupt
10499 \newline 
10500
10501 \newline 
10502 \SpecialChar ~
10503 \SpecialChar ~
10504 \SpecialChar ~
10505 \SpecialChar ~
10506 ...
10507  
10508 \newline 
10509 }
10510 \layout Section
10511
10512 Enabling and Disabling Interrupts
10513 \layout Subsection
10514
10515 Critical Functions and Critical Statements
10516 \layout Standard
10517
10518 A special keyword may be associated with a block or a function declaring
10519  it as 
10520 \emph on 
10521 critical
10522 \emph default 
10523 .
10524  SDCC will generate code to disable all interrupts
10525 \begin_inset LatexCommand \index{interrupt}
10526
10527 \end_inset 
10528
10529  upon entry to a critical function and restore the interrupt enable to the
10530  previous state before returning.
10531  Nesting critical functions will need one additional byte on the stack
10532 \begin_inset LatexCommand \index{stack}
10533
10534 \end_inset 
10535
10536  for each call.
10537 \layout Verse
10538
10539
10540 \family typewriter 
10541 int foo () critical
10542 \begin_inset LatexCommand \index{critical}
10543
10544 \end_inset 
10545
10546  
10547 \newline 
10548
10549 \newline 
10550 \SpecialChar ~
10551 \SpecialChar ~
10552 \SpecialChar ~
10553 \SpecialChar ~
10554 ...
10555  
10556 \newline 
10557 \SpecialChar ~
10558 \SpecialChar ~
10559 \SpecialChar ~
10560 \SpecialChar ~
10561 ...
10562  
10563 \newline 
10564 }
10565 \layout Standard
10566
10567 The critical attribute maybe used with other attributes like 
10568 \emph on 
10569 reentrant.
10570 \emph default 
10571
10572 \newline 
10573 The keyword 
10574 \emph on 
10575 critical
10576 \emph default 
10577  may also be used to disable interrupts more locally:
10578 \layout Verse
10579
10580
10581 \family typewriter 
10582 critical{ i++; }
10583 \layout Standard
10584
10585 More than one statement could have been included in the block.
10586 \layout Subsection
10587
10588 Enabling and Disabling Interrupts directly
10589 \layout Standard
10590
10591 Interrupts
10592 \begin_inset LatexCommand \index{interrupt}
10593
10594 \end_inset 
10595
10596  can also be disabled and enabled directly (8051):
10597 \layout Verse
10598
10599
10600 \family typewriter 
10601 EA = 0;\SpecialChar ~
10602 \SpecialChar ~
10603 \SpecialChar ~
10604 \SpecialChar ~
10605 \SpecialChar ~
10606 \SpecialChar ~
10607 \SpecialChar ~
10608 \SpecialChar ~
10609 \SpecialChar ~
10610 \SpecialChar ~
10611 \SpecialChar ~
10612 \SpecialChar ~
10613 or:\SpecialChar ~
10614 \SpecialChar ~
10615 \SpecialChar ~
10616 \SpecialChar ~
10617 \SpecialChar ~
10618 \SpecialChar ~
10619 \SpecialChar ~
10620 \SpecialChar ~
10621 \SpecialChar ~
10622 \SpecialChar ~
10623 \SpecialChar ~
10624 EA_SAVE = EA;
10625 \layout Verse
10626
10627
10628 \family typewriter 
10629 ...\SpecialChar ~
10630 \SpecialChar ~
10631 \SpecialChar ~
10632 \SpecialChar ~
10633 \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 EA = 0;
10660 \layout Verse
10661
10662
10663 \family typewriter 
10664 EA = 1;\SpecialChar ~
10665 \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 ...
10691 \layout Verse
10692
10693
10694 \family typewriter 
10695 \SpecialChar ~
10696 \SpecialChar ~
10697 \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 \SpecialChar ~
10724 \SpecialChar ~
10725 \SpecialChar ~
10726 \SpecialChar ~
10727 \SpecialChar ~
10728 EA = EA_SAVE;
10729 \layout Standard
10730
10731 On other architectures which have seperate opcodes for enabling and disabling
10732  interrupts you might want to make use of defines with inline assembly
10733 \begin_inset LatexCommand \index{Assembler routines}
10734
10735 \end_inset 
10736
10737  (HC08):
10738 \layout Verse
10739
10740
10741 \family typewriter 
10742 #define CLI _asm
10743 \begin_inset LatexCommand \index{\_asm}
10744
10745 \end_inset 
10746
10747 \SpecialChar ~
10748 \SpecialChar ~
10749 cli\SpecialChar ~
10750 \SpecialChar ~
10751 _endasm
10752 \begin_inset LatexCommand \index{\_endasm}
10753
10754 \end_inset 
10755
10756
10757 \layout Verse
10758
10759
10760 \family typewriter 
10761 #define SEI _asm\SpecialChar ~
10762 \SpecialChar ~
10763 sei\SpecialChar ~
10764 \SpecialChar ~
10765 _endasm; 
10766 \layout Verse
10767
10768
10769 \family typewriter 
10770 ...
10771 \layout Standard
10772
10773 Note: it is sometimes sufficient to disable only a specific interrupt source
10774  like f.e.
10775  a timer or serial interrupt by manipulating an 
10776 \emph on 
10777 interrupt mask
10778 \begin_inset LatexCommand \index{interrupt mask}
10779
10780 \end_inset 
10781
10782
10783 \emph default 
10784  register.
10785  
10786 \layout Standard
10787
10788 Usually the time during which interrupts are disabled should be kept as
10789  short as possible.
10790  This minimizes both 
10791 \emph on 
10792 interrupt latency
10793 \emph default 
10794
10795 \begin_inset LatexCommand \index{interrupt latency}
10796
10797 \end_inset 
10798
10799  (the time between the occurrence of the interrupt and the execution of
10800  the first code in the interrupt routine) and 
10801 \emph on 
10802 interrupt jitter
10803 \emph default 
10804
10805 \begin_inset LatexCommand \index{interrupt jitter}
10806
10807 \end_inset 
10808
10809  (the difference between the shortest and the longest interrupt latency).
10810  These really are something different, f.e.
10811  a serial interrupt has to be served before its buffer overruns so it cares
10812  for the maximum interrupt latency, whereas it does not care about jitter.
10813  On a loudspeaker driven via a digital to analog converter which is fed
10814  by an interrupt a latency of a few milliseconds might be tolerable, whereas
10815  a much smaller jitter will be very audible.
10816 \layout Standard
10817
10818 You can reenable interrupts within an interrupt routine and on some architecture
10819 s you can make use of two (or more) levels of 
10820 \emph on 
10821 interrupt priorities
10822 \emph default 
10823
10824 \begin_inset LatexCommand \index{interrupt priority}
10825
10826 \end_inset 
10827
10828 .
10829  On some architectures which don't support interrupt priorities these can
10830  be implemented by manipulating the interrupt mask and reenabling interrupts
10831  within the interrupt routine.
10832  Check there is sufficient space on the stack
10833 \begin_inset LatexCommand \index{stack}
10834
10835 \end_inset 
10836
10837  and don't add complexity unless you have to.
10838  
10839 \layout Subsection
10840
10841 Semaphore
10842 \begin_inset LatexCommand \index{semaphore}
10843
10844 \end_inset 
10845
10846  locking (mcs51/ds390)
10847 \layout Standard
10848
10849 Some architectures (mcs51/ds390) have an atomic
10850 \begin_inset LatexCommand \index{atomic}
10851
10852 \end_inset 
10853
10854  bit test and
10855 \emph on 
10856  
10857 \emph default 
10858 clear
10859 \emph on 
10860  
10861 \emph default 
10862 instruction.
10863  These type of instructions are typically used in preemptive multitasking
10864  systems, where a routine f.e.
10865  claims the use of a data structure ('acquires a lock
10866 \begin_inset LatexCommand \index{lock}
10867
10868 \end_inset 
10869
10870  on it'), makes some modifications and then releases the lock when the data
10871  structure is consistent again.
10872  The instruction may also be used if interrupt and non-interrupt code have
10873  to compete for a resource.
10874  With the atomic bit test and clear instruction interrupts
10875 \begin_inset LatexCommand \index{interrupt}
10876
10877 \end_inset 
10878
10879  don't have to be disabled for the locking operation.
10880  
10881 \layout Standard
10882
10883 SDCC generates this instruction if the source follows this pattern:
10884 \layout Verse
10885
10886
10887 \family typewriter 
10888 volatile bit resource_is_free; 
10889 \newline 
10890
10891 \newline 
10892 if (resource_is_free) 
10893 \newline 
10894 \SpecialChar ~
10895 \SpecialChar ~
10896
10897 \newline 
10898 \SpecialChar ~
10899 \SpecialChar ~
10900 \SpecialChar ~
10901 \SpecialChar ~
10902 resource_is_free=0; 
10903 \newline 
10904 \SpecialChar ~
10905 \SpecialChar ~
10906 \SpecialChar ~
10907 \SpecialChar ~
10908 ...
10909  
10910 \newline 
10911 \SpecialChar ~
10912 \SpecialChar ~
10913 \SpecialChar ~
10914 \SpecialChar ~
10915 resource_is_free=1;
10916 \newline 
10917 \SpecialChar ~
10918 \SpecialChar ~
10919
10920 \layout Standard
10921
10922 Note, mcs51 and ds390 support only an atomic
10923 \begin_inset LatexCommand \index{atomic}
10924
10925 \end_inset 
10926
10927  bit test and 
10928 \emph on 
10929 clear
10930 \emph default 
10931  instruction (as opposed to atomic bit test and 
10932 \emph on 
10933 set).
10934 \layout Section
10935
10936 Functions using private register banks
10937 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
10938
10939 \end_inset 
10940
10941  (mcs51/ds390)
10942 \layout Standard
10943
10944 Some architectures have support for quickly changing register sets.
10945  SDCC supports this feature with the 
10946 \emph on 
10947 using
10948 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
10949
10950 \end_inset 
10951
10952
10953 \emph default 
10954  attribute (which tells the compiler to use a register bank
10955 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
10956
10957 \end_inset 
10958
10959  other than the default bank zero).
10960  It should only be applied to 
10961 \emph on 
10962 interrupt
10963 \begin_inset LatexCommand \index{interrupt}
10964
10965 \end_inset 
10966
10967
10968 \emph default 
10969  functions (see footnote below).
10970  This will in most circumstances make the generated ISR code more efficient
10971  since it will not have to save registers on the stack.
10972 \layout Standard
10973
10974 The 
10975 \emph on 
10976 using
10977 \emph default 
10978  attribute will have no effect on the generated code for a 
10979 \emph on 
10980 non-interrupt
10981 \emph default 
10982  function (but may occasionally be useful anyway
10983 \begin_inset Foot
10984 collapsed false
10985
10986 \layout Standard
10987
10988 possible exception: if a function is called ONLY from 'interrupt' functions
10989  using a particular bank, it can be declared with the same 'using' attribute
10990  as the calling 'interrupt' functions.
10991  For instance, if you have several ISRs using bank one, and all of them
10992  call memcpy(), it might make sense to create a specialized version of memcpy()
10993  'using 1', since this would prevent the ISR from having to save bank zero
10994  to the stack on entry and switch to bank zero before calling the function
10995 \end_inset 
10996
10997 ).
10998 \newline 
10999
11000 \emph on 
11001 (pending: I don't think this has been done yet)
11002 \layout Standard
11003
11004 An 
11005 \emph on 
11006 interrupt
11007 \emph default 
11008  function using a non-zero bank will assume that it can trash that register
11009  bank, and will not save it.
11010  Since high-priority interrupts
11011 \begin_inset LatexCommand \index{interrupt priority}
11012
11013 \end_inset 
11014
11015  can interrupt low-priority ones on the 8051 and friends, this means that
11016  if a high-priority ISR 
11017 \emph on 
11018 using
11019 \emph default 
11020  a particular bank occurs while processing a low-priority ISR 
11021 \emph on 
11022 using
11023 \emph default 
11024  the same bank, terrible and bad things can happen.
11025  To prevent this, no single register bank should be 
11026 \emph on 
11027 used
11028 \emph default 
11029  by both a high priority and a low priority ISR.
11030  This is probably most easily done by having all high priority ISRs use
11031  one bank and all low priority ISRs use another.
11032  If you have an ISR which can change priority at runtime, you're on your
11033  own: I suggest using the default bank zero and taking the small performance
11034  hit.
11035 \layout Standard
11036
11037 It is most efficient if your ISR calls no other functions.
11038  If your ISR must call other functions, it is most efficient if those functions
11039  use the same bank as the ISR (see note 1 below); the next best is if the
11040  called functions use bank zero.
11041  It is very inefficient to call a function using a different, non-zero bank
11042  from an ISR.
11043  
11044 \layout Section
11045
11046 Startup Code
11047 \begin_inset LatexCommand \label{sub:Startup-Code}
11048
11049 \end_inset 
11050
11051
11052 \begin_inset LatexCommand \index{Startup code}
11053
11054 \end_inset 
11055
11056
11057 \layout Subsection
11058
11059 MCS51/DS390 Startup Code
11060 \layout Standard
11061
11062 The compiler inserts a call to the C routine 
11063 \emph on 
11064 _sdcc_external_startup()
11065 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
11066
11067 \end_inset 
11068
11069
11070 \series bold 
11071 \emph default 
11072  
11073 \series default 
11074 at the start of the CODE area.
11075  This routine is in the runtime library
11076 \begin_inset LatexCommand \index{Runtime library}
11077
11078 \end_inset 
11079
11080 .
11081  By default this routine returns 0, if this routine returns a non-zero value,
11082  the static & global variable initialization will be skipped and the function
11083  main will be invoked.
11084  Otherwise static & global variables will be initialized before the function
11085  main is invoked.
11086  You could add a 
11087 \emph on 
11088 _sdcc_external_startup()
11089 \emph default 
11090  routine to your program to override the default if you need to setup hardware
11091  or perform some other critical operation prior to static & global variable
11092  initialization.
11093  On some mcs51 variants xdata has to be explicitly enabled before it can
11094  be accessed or if the watchdog needs to be disabled, this is the place
11095  to do it.
11096  The startup code clears all internal data memory, 256 bytes by default,
11097  but from 0 to n-1 if 
11098 \emph on 
11099 -
11100 \begin_inset ERT
11101 status Collapsed
11102
11103 \layout Standard
11104
11105 \backslash 
11106 /
11107 \end_inset 
11108
11109 -iram-size
11110 \begin_inset LatexCommand \index{-\/-iram-size}
11111
11112 \end_inset 
11113
11114 n
11115 \emph default 
11116  is used.
11117  (recommended for Chipcon CC1010).
11118 \layout Standard
11119
11120 See also the compiler option 
11121 \emph on 
11122 -
11123 \begin_inset ERT
11124 status Collapsed
11125
11126 \layout Standard
11127
11128 \backslash 
11129 /
11130 \end_inset 
11131
11132 -no-xinit
11133 \emph default 
11134 -
11135 \emph on 
11136 opt
11137 \emph default 
11138
11139 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
11140
11141 \end_inset 
11142
11143  and section 
11144 \begin_inset LatexCommand \ref{sub:MCS51-variants}
11145
11146 \end_inset 
11147
11148 \SpecialChar ~
11149 about MCS51-variants.
11150 \layout Subsection
11151
11152 HC08 Startup Code
11153 \layout Standard
11154
11155 The HC08 startup code follows the same scheme as the MCS51 startup code.
11156 \layout Subsection
11157
11158 Z80 Startup Code
11159 \layout Standard
11160
11161 On the Z80 the startup code is inserted by linking with crt0.o which is generated
11162  from sdcc/device/lib/z80/crt0.s.
11163  If you need a different startup code you can use the compiler option 
11164 \emph on 
11165 -
11166 \series bold 
11167 \emph default 
11168
11169 \begin_inset ERT
11170 status Collapsed
11171
11172 \layout Standard
11173
11174 \backslash 
11175 /
11176 \end_inset 
11177
11178
11179 \series default 
11180 \emph on 
11181 -no-std-crt0
11182 \emph default 
11183
11184 \begin_inset LatexCommand \index{-\/-no-std-crt0}
11185
11186 \end_inset 
11187
11188  and provide your own crt0.o.
11189  
11190 \layout Section
11191
11192 Inline Assembler Code
11193 \begin_inset LatexCommand \index{Assembler routines}
11194
11195 \end_inset 
11196
11197
11198 \layout Subsection
11199
11200 A Step by Step Introduction
11201 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
11202
11203 \end_inset 
11204
11205
11206 \layout Standard
11207
11208 Starting from a small snippet of c-code this example shows for the MCS51
11209  how to use inline assembly, access variables, a function parameter and
11210  an array in xdata memory.
11211  The example uses an MCS51 here but is easily adapted for other architectures.
11212  This is a buffer routine which should be optimized:
11213 \layout Verse
11214
11215
11216 \family typewriter 
11217 \size footnotesize 
11218 unsigned char far
11219 \begin_inset LatexCommand \index{far (storage class)}
11220
11221 \end_inset 
11222
11223  at
11224 \begin_inset LatexCommand \index{at}
11225
11226 \end_inset 
11227
11228  0x7f00 buf[0x100];
11229 \begin_inset LatexCommand \index{Aligned array}
11230
11231 \end_inset 
11232
11233
11234 \newline 
11235 unsigned char head,tail;
11236 \newline 
11237
11238 \newline 
11239 void to_buffer( unsigned char c ) 
11240 \newline 
11241 {
11242 \newline 
11243 \SpecialChar ~
11244 \SpecialChar ~
11245 \SpecialChar ~
11246 \SpecialChar ~
11247 if( head != tail-1 ) 
11248 \newline 
11249 \SpecialChar ~
11250 \SpecialChar ~
11251 \SpecialChar ~
11252 \SpecialChar ~
11253 \SpecialChar ~
11254 \SpecialChar ~
11255 \SpecialChar ~
11256 \SpecialChar ~
11257 buf[ head++ ] = c;\SpecialChar ~
11258 \SpecialChar ~
11259 \SpecialChar ~
11260 \SpecialChar ~
11261 /* access to a 256 byte aligned array */
11262 \newline 
11263
11264 \layout Standard
11265
11266 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
11267  then a corresponding buffer.asm file is generated.
11268  We define a new function 
11269 \family typewriter 
11270 to_buffer_asm()
11271 \family default 
11272  in file buffer.c in which we cut and paste the generated code, removing
11273  unwanted comments and some ':'.
11274  Then add 
11275 \begin_inset Quotes sld
11276 \end_inset 
11277
11278 _asm
11279 \begin_inset Quotes srd
11280 \end_inset 
11281
11282  and 
11283 \begin_inset Quotes sld
11284 \end_inset 
11285
11286 _endasm;
11287 \begin_inset Quotes srd
11288 \end_inset 
11289
11290  to the beginning and the end of the function body:
11291 \layout Verse
11292
11293
11294 \family typewriter 
11295 \size footnotesize 
11296 /* With a cut and paste from the .asm file, we have something to start with.
11297 \newline 
11298 \SpecialChar ~
11299 \SpecialChar ~
11300 \SpecialChar ~
11301 The function is not yet OK! (registers aren't saved) */ 
11302 \newline 
11303 void to_buffer_asm( unsigned char c ) 
11304 \newline 
11305
11306 \newline 
11307 \SpecialChar ~
11308 \SpecialChar ~
11309 \SpecialChar ~
11310 \SpecialChar ~
11311 _asm
11312 \begin_inset LatexCommand \index{\_asm}
11313
11314 \end_inset 
11315
11316
11317 \newline 
11318 \SpecialChar ~
11319 \SpecialChar ~
11320 \SpecialChar ~
11321 \SpecialChar ~
11322 mov\SpecialChar ~
11323 \SpecialChar ~
11324 r2,dpl 
11325 \newline 
11326 ;buffer.c if( head != tail-1 ) 
11327 \newline 
11328 \SpecialChar ~
11329 \SpecialChar ~
11330 \SpecialChar ~
11331 \SpecialChar ~
11332 mov\SpecialChar ~
11333 \SpecialChar ~
11334 a,_tail 
11335 \newline 
11336 \SpecialChar ~
11337 \SpecialChar ~
11338 \SpecialChar ~
11339 \SpecialChar ~
11340 dec\SpecialChar ~
11341 \SpecialChar ~
11342
11343 \newline 
11344 \SpecialChar ~
11345 \SpecialChar ~
11346 \SpecialChar ~
11347 \SpecialChar ~
11348 mov\SpecialChar ~
11349 \SpecialChar ~
11350 r3,a 
11351 \newline 
11352 \SpecialChar ~
11353 \SpecialChar ~
11354 \SpecialChar ~
11355 \SpecialChar ~
11356 mov\SpecialChar ~
11357 \SpecialChar ~
11358 a,_head 
11359 \newline 
11360 \SpecialChar ~
11361 \SpecialChar ~
11362 \SpecialChar ~
11363 \SpecialChar ~
11364 cjne a,ar3,00106$ 
11365 \newline 
11366 \SpecialChar ~
11367 \SpecialChar ~
11368 \SpecialChar ~
11369 \SpecialChar ~
11370 ret
11371 \newline 
11372 00106$: 
11373 \newline 
11374 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
11375 \begin_inset LatexCommand \index{Aligned array}
11376
11377 \end_inset 
11378
11379
11380 \newline 
11381 \SpecialChar ~
11382 \SpecialChar ~
11383 \SpecialChar ~
11384 \SpecialChar ~
11385 mov\SpecialChar ~
11386 \SpecialChar ~
11387 r3,_head 
11388 \newline 
11389 \SpecialChar ~
11390 \SpecialChar ~
11391 \SpecialChar ~
11392 \SpecialChar ~
11393 inc\SpecialChar ~
11394 \SpecialChar ~
11395 _head 
11396 \newline 
11397 \SpecialChar ~
11398 \SpecialChar ~
11399 \SpecialChar ~
11400 \SpecialChar ~
11401 mov\SpecialChar ~
11402 \SpecialChar ~
11403 dpl,r3 
11404 \newline 
11405 \SpecialChar ~
11406 \SpecialChar ~
11407 \SpecialChar ~
11408 \SpecialChar ~
11409 mov\SpecialChar ~
11410 \SpecialChar ~
11411 dph,#(_buf >> 8) 
11412 \newline 
11413 \SpecialChar ~
11414 \SpecialChar ~
11415 \SpecialChar ~
11416 \SpecialChar ~
11417 mov\SpecialChar ~
11418 \SpecialChar ~
11419 a,r2 
11420 \newline 
11421 \SpecialChar ~
11422 \SpecialChar ~
11423 \SpecialChar ~
11424 \SpecialChar ~
11425 movx @dptr,a 
11426 \newline 
11427 00103$: 
11428 \newline 
11429 \SpecialChar ~
11430 \SpecialChar ~
11431 \SpecialChar ~
11432 \SpecialChar ~
11433 ret
11434 \newline 
11435 \SpecialChar ~
11436 \SpecialChar ~
11437 \SpecialChar ~
11438 \SpecialChar ~
11439 _endasm;
11440 \newline 
11441
11442 \layout Standard
11443
11444 The new file buffer.c should compile with only one warning about the unreferenced
11445  function argument 'c'.
11446  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
11447  (1) and finally have:
11448 \layout Verse
11449
11450
11451 \family typewriter 
11452 \size footnotesize 
11453 unsigned char far at 0x7f00 buf[0x100];
11454 \newline 
11455 unsigned char head,tail;
11456 \newline 
11457 #define USE_ASSEMBLY (1)
11458 \newline 
11459
11460 \newline 
11461 #if !USE_ASSEMBLY
11462 \newline 
11463
11464 \newline 
11465 void to_buffer( unsigned char c )
11466 \newline 
11467 {
11468 \newline 
11469 \SpecialChar ~
11470 \SpecialChar ~
11471 \SpecialChar ~
11472 \SpecialChar ~
11473 if( head != tail-1 )
11474 \newline 
11475 \SpecialChar ~
11476 \SpecialChar ~
11477 \SpecialChar ~
11478 \SpecialChar ~
11479 \SpecialChar ~
11480 \SpecialChar ~
11481 \SpecialChar ~
11482 \SpecialChar ~
11483 buf[ head++ ] = c;
11484 \newline 
11485 }
11486 \newline 
11487
11488 \newline 
11489 #else
11490 \newline 
11491
11492 \newline 
11493 void to_buffer( unsigned char c )
11494 \newline 
11495 {
11496 \newline 
11497 \SpecialChar ~
11498 \SpecialChar ~
11499 \SpecialChar ~
11500 \SpecialChar ~
11501 c; // to avoid warning: unreferenced function argument
11502 \newline 
11503 \SpecialChar ~
11504 \SpecialChar ~
11505 \SpecialChar ~
11506 \SpecialChar ~
11507 _asm
11508 \begin_inset LatexCommand \index{\_asm}
11509
11510 \end_inset 
11511
11512
11513 \newline 
11514 \SpecialChar ~
11515 \SpecialChar ~
11516 \SpecialChar ~
11517 \SpecialChar ~
11518 \SpecialChar ~
11519 \SpecialChar ~
11520 \SpecialChar ~
11521 \SpecialChar ~
11522 ; save used registers here.
11523  
11524 \newline 
11525 \SpecialChar ~
11526 \SpecialChar ~
11527 \SpecialChar ~
11528 \SpecialChar ~
11529 \SpecialChar ~
11530 \SpecialChar ~
11531 \SpecialChar ~
11532 \SpecialChar ~
11533 ; If we were still using r2,r3 we would have to push them here.
11534  
11535 \newline 
11536 ; if( head != tail-1 )
11537 \newline 
11538 \SpecialChar ~
11539 \SpecialChar ~
11540 \SpecialChar ~
11541 \SpecialChar ~
11542 \SpecialChar ~
11543 \SpecialChar ~
11544 \SpecialChar ~
11545 \SpecialChar ~
11546 mov\SpecialChar ~
11547  a,_tail
11548 \newline 
11549 \SpecialChar ~
11550 \SpecialChar ~
11551 \SpecialChar ~
11552 \SpecialChar ~
11553 \SpecialChar ~
11554 \SpecialChar ~
11555 \SpecialChar ~
11556 \SpecialChar ~
11557 dec\SpecialChar ~
11558  a
11559 \newline 
11560 \SpecialChar ~
11561 \SpecialChar ~
11562 \SpecialChar ~
11563 \SpecialChar ~
11564 \SpecialChar ~
11565 \SpecialChar ~
11566 \SpecialChar ~
11567 \SpecialChar ~
11568 xrl\SpecialChar ~
11569  a,_head
11570 \newline 
11571 \SpecialChar ~
11572 \SpecialChar ~
11573 \SpecialChar ~
11574 \SpecialChar ~
11575 \SpecialChar ~
11576 \SpecialChar ~
11577 \SpecialChar ~
11578 \SpecialChar ~
11579 ; we could do an ANL a,#0x0f here to use a smaller buffer (see below)
11580 \newline 
11581 \SpecialChar ~
11582 \SpecialChar ~
11583 \SpecialChar ~
11584 \SpecialChar ~
11585 \SpecialChar ~
11586 \SpecialChar ~
11587 \SpecialChar ~
11588 \SpecialChar ~
11589 jz\SpecialChar ~
11590 \SpecialChar ~
11591  t_b_end$
11592 \newline 
11593 \SpecialChar ~
11594 \SpecialChar ~
11595 \SpecialChar ~
11596 \SpecialChar ~
11597 \SpecialChar ~
11598 \SpecialChar ~
11599 \SpecialChar ~
11600 \SpecialChar ~
11601 ;
11602 \newline 
11603 ; buf[ head++ ] = c;
11604 \newline 
11605 \SpecialChar ~
11606 \SpecialChar ~
11607 \SpecialChar ~
11608 \SpecialChar ~
11609 \SpecialChar ~
11610 \SpecialChar ~
11611 \SpecialChar ~
11612 \SpecialChar ~
11613 mov\SpecialChar ~
11614  a,dpl \SpecialChar ~
11615 \SpecialChar ~
11616 \SpecialChar ~
11617 \SpecialChar ~
11618 \SpecialChar ~
11619 \SpecialChar ~
11620 \SpecialChar ~
11621 ; dpl holds lower byte of function argument
11622 \newline 
11623 \SpecialChar ~
11624 \SpecialChar ~
11625 \SpecialChar ~
11626 \SpecialChar ~
11627 \SpecialChar ~
11628 \SpecialChar ~
11629 \SpecialChar ~
11630 \SpecialChar ~
11631 mov\SpecialChar ~
11632  dpl,_head \SpecialChar ~
11633 \SpecialChar ~
11634 \SpecialChar ~
11635 ; buf is 0x100 byte aligned so head can be used directly
11636 \newline 
11637 \SpecialChar ~
11638 \SpecialChar ~
11639 \SpecialChar ~
11640 \SpecialChar ~
11641 \SpecialChar ~
11642 \SpecialChar ~
11643 \SpecialChar ~
11644 \SpecialChar ~
11645 mov\SpecialChar ~
11646  dph,#(_buf>>8)
11647 \newline 
11648 \SpecialChar ~
11649 \SpecialChar ~
11650 \SpecialChar ~
11651 \SpecialChar ~
11652 \SpecialChar ~
11653 \SpecialChar ~
11654 \SpecialChar ~
11655 \SpecialChar ~
11656 movx @dptr,a
11657 \newline 
11658 \SpecialChar ~
11659 \SpecialChar ~
11660 \SpecialChar ~
11661 \SpecialChar ~
11662 \SpecialChar ~
11663 \SpecialChar ~
11664 \SpecialChar ~
11665 \SpecialChar ~
11666 inc \SpecialChar ~
11667 _head
11668 \newline 
11669 \SpecialChar ~
11670 \SpecialChar ~
11671 \SpecialChar ~
11672 \SpecialChar ~
11673 \SpecialChar ~
11674 \SpecialChar ~
11675 \SpecialChar ~
11676 \SpecialChar ~
11677 ; we could do an ANL _head,#0x0f here to use a smaller buffer (see above)
11678 \newline 
11679 t_b_end$:
11680 \newline 
11681 \SpecialChar ~
11682 \SpecialChar ~
11683 \SpecialChar ~
11684 \SpecialChar ~
11685 \SpecialChar ~
11686 \SpecialChar ~
11687 \SpecialChar ~
11688 \SpecialChar ~
11689 ; restore used registers here 
11690 \newline 
11691 \SpecialChar ~
11692 \SpecialChar ~
11693 \SpecialChar ~
11694 \SpecialChar ~
11695 _endasm;
11696 \newline 
11697 }
11698 \newline 
11699 #endif
11700 \layout Standard
11701
11702 The inline assembler code can contain any valid code understood by the assembler
11703 , this includes any assembler directives and comment lines
11704 \begin_inset Foot
11705 collapsed false
11706
11707 \layout Standard
11708
11709 The assembler does not like some characters like ':' or ''' in comments.
11710  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
11711 \end_inset 
11712
11713 .
11714  The compiler does not do any validation of the code within the 
11715 \family typewriter 
11716 _asm
11717 \begin_inset LatexCommand \index{\_asm}
11718
11719 \end_inset 
11720
11721  ...
11722  _endasm;
11723 \family default 
11724  keyword pair.
11725  Specifically it will not know which registers are used and thus register
11726  pushing/popping
11727 \begin_inset LatexCommand \index{push/pop}
11728
11729 \end_inset 
11730
11731  has to be done manually.
11732  
11733 \layout Standard
11734
11735 It is recommended that each assembly instruction (including labels) be placed
11736  in a separate line (as the example shows).
11737  When the -
11738 \begin_inset ERT
11739 status Collapsed
11740
11741 \layout Standard
11742
11743 \backslash 
11744 /
11745 \end_inset 
11746
11747 -
11748 \emph on 
11749 peep-asm
11750 \begin_inset LatexCommand \index{-\/-peep-asm}
11751
11752 \end_inset 
11753
11754
11755 \emph default 
11756  command line option is used, the inline assembler code will be passed through
11757  the peephole optimizer
11758 \begin_inset LatexCommand \index{Peephole optimizer}
11759
11760 \end_inset 
11761
11762 .
11763  There are only a few (if any) cases where this option makes sense, it might
11764  cause some unexpected changes in the inline assembler code.
11765  Please go through the peephole optimizer rules defined in file 
11766 \emph on 
11767 SDCCpeeph.def
11768 \emph default 
11769  before using this option.
11770 \layout Subsection
11771
11772 Naked Functions
11773 \begin_inset LatexCommand \label{sub:Naked-Functions}
11774
11775 \end_inset 
11776
11777
11778 \begin_inset LatexCommand \index{Naked functions}
11779
11780 \end_inset 
11781
11782
11783 \layout Standard
11784
11785 A special keyword may be associated with a function declaring it as 
11786 \emph on 
11787 _naked
11788 \begin_inset LatexCommand \index{\_naked}
11789
11790 \end_inset 
11791
11792 .
11793  
11794 \emph default 
11795 The 
11796 \emph on 
11797 _naked
11798 \emph default 
11799  function modifier attribute prevents the compiler from generating prologue
11800 \begin_inset LatexCommand \index{function prologue}
11801
11802 \end_inset 
11803
11804  and epilogue
11805 \begin_inset LatexCommand \index{function epilogue}
11806
11807 \end_inset 
11808
11809  code for that function.
11810  This means that the user is entirely responsible for such things as saving
11811  any registers that may need to be preserved, selecting the proper register
11812  bank, generating the 
11813 \emph on 
11814 return
11815 \emph default 
11816  instruction at the end, etc.
11817  Practically, this means that the contents of the function must be written
11818  in inline assembler.
11819  This is particularly useful for interrupt functions, which can have a large
11820  (and often unnecessary) prologue/epilogue.
11821  For example, compare the code generated by these two functions:
11822 \layout Verse
11823
11824
11825 \family typewriter 
11826 volatile
11827 \begin_inset LatexCommand \index{volatile}
11828
11829 \end_inset 
11830
11831  data unsigned char counter;
11832 \newline 
11833
11834 \newline 
11835 void simpleInterrupt(void) interrupt
11836 \begin_inset LatexCommand \index{interrupt}
11837
11838 \end_inset 
11839
11840  1
11841 \newline 
11842 {
11843 \newline 
11844 \SpecialChar ~
11845 \SpecialChar ~
11846 \SpecialChar ~
11847 \SpecialChar ~
11848 counter++;
11849 \newline 
11850 }
11851 \newline 
11852
11853 \newline 
11854 void nakedInterrupt(void) interrupt 2 _naked
11855 \newline 
11856 {
11857 \newline 
11858 \SpecialChar ~
11859 \SpecialChar ~
11860 \SpecialChar ~
11861 \SpecialChar ~
11862 _asm
11863 \begin_inset LatexCommand \index{\_asm}
11864
11865 \end_inset 
11866
11867
11868 \newline 
11869 \SpecialChar ~
11870 \SpecialChar ~
11871 \SpecialChar ~
11872 \SpecialChar ~
11873 \SpecialChar ~
11874 \SpecialChar ~
11875 inc\SpecialChar ~
11876 \SpecialChar ~
11877 \SpecialChar ~
11878 \SpecialChar ~
11879 \SpecialChar ~
11880 _counter ; does not change flags, no need to save psw
11881 \newline 
11882 \SpecialChar ~
11883 \SpecialChar ~
11884 \SpecialChar ~
11885 \SpecialChar ~
11886 \SpecialChar ~
11887 \SpecialChar ~
11888 reti\SpecialChar ~
11889 \SpecialChar ~
11890 \SpecialChar ~
11891 \SpecialChar ~
11892 ; MUST explicitly include ret or reti in _naked function.
11893 \newline 
11894 \SpecialChar ~
11895 \SpecialChar ~
11896 \SpecialChar ~
11897 \SpecialChar ~
11898 _endasm
11899 \begin_inset LatexCommand \index{\_endasm}
11900
11901 \end_inset 
11902
11903 ;
11904 \newline 
11905 }
11906 \layout Standard
11907
11908 For an 8051 target, the generated simpleInterrupt looks like:
11909 \layout Verse
11910
11911
11912 \family typewriter 
11913 _simpleInterrupt:
11914 \newline 
11915 \SpecialChar ~
11916 \SpecialChar ~
11917 \SpecialChar ~
11918 \SpecialChar ~
11919 push\SpecialChar ~
11920 \SpecialChar ~
11921 \SpecialChar ~
11922 \SpecialChar ~
11923 acc
11924 \newline 
11925 \SpecialChar ~
11926 \SpecialChar ~
11927 \SpecialChar ~
11928 \SpecialChar ~
11929 push\SpecialChar ~
11930 \SpecialChar ~
11931 \SpecialChar ~
11932 \SpecialChar ~
11933 b
11934 \newline 
11935 \SpecialChar ~
11936 \SpecialChar ~
11937 \SpecialChar ~
11938 \SpecialChar ~
11939 push\SpecialChar ~
11940 \SpecialChar ~
11941 \SpecialChar ~
11942 \SpecialChar ~
11943 dpl
11944 \newline 
11945 \SpecialChar ~
11946 \SpecialChar ~
11947 \SpecialChar ~
11948 \SpecialChar ~
11949 push\SpecialChar ~
11950 \SpecialChar ~
11951 \SpecialChar ~
11952 \SpecialChar ~
11953 dph
11954 \newline 
11955 \SpecialChar ~
11956 \SpecialChar ~
11957 \SpecialChar ~
11958 \SpecialChar ~
11959 push\SpecialChar ~
11960 \SpecialChar ~
11961 \SpecialChar ~
11962 \SpecialChar ~
11963 psw
11964 \newline 
11965 \SpecialChar ~
11966 \SpecialChar ~
11967 \SpecialChar ~
11968 \SpecialChar ~
11969 mov\SpecialChar ~
11970 \SpecialChar ~
11971 \SpecialChar ~
11972 \SpecialChar ~
11973 \SpecialChar ~
11974 psw,#0x00
11975 \newline 
11976 \SpecialChar ~
11977 \SpecialChar ~
11978 \SpecialChar ~
11979 \SpecialChar ~
11980 inc\SpecialChar ~
11981 \SpecialChar ~
11982 \SpecialChar ~
11983 \SpecialChar ~
11984 \SpecialChar ~
11985 _counter
11986 \newline 
11987 \SpecialChar ~
11988 \SpecialChar ~
11989 \SpecialChar ~
11990 \SpecialChar ~
11991 pop\SpecialChar ~
11992 \SpecialChar ~
11993 \SpecialChar ~
11994 \SpecialChar ~
11995 \SpecialChar ~
11996 psw
11997 \newline 
11998 \SpecialChar ~
11999 \SpecialChar ~
12000 \SpecialChar ~
12001 \SpecialChar ~
12002 pop\SpecialChar ~
12003 \SpecialChar ~
12004 \SpecialChar ~
12005 \SpecialChar ~
12006 \SpecialChar ~
12007 dph
12008 \newline 
12009 \SpecialChar ~
12010 \SpecialChar ~
12011 \SpecialChar ~
12012 \SpecialChar ~
12013 pop\SpecialChar ~
12014 \SpecialChar ~
12015 \SpecialChar ~
12016 \SpecialChar ~
12017 \SpecialChar ~
12018 dpl
12019 \newline 
12020 \SpecialChar ~
12021 \SpecialChar ~
12022 \SpecialChar ~
12023 \SpecialChar ~
12024 pop\SpecialChar ~
12025 \SpecialChar ~
12026 \SpecialChar ~
12027 \SpecialChar ~
12028 \SpecialChar ~
12029 b
12030 \newline 
12031 \SpecialChar ~
12032 \SpecialChar ~
12033 \SpecialChar ~
12034 \SpecialChar ~
12035 pop\SpecialChar ~
12036 \SpecialChar ~
12037 \SpecialChar ~
12038 \SpecialChar ~
12039 \SpecialChar ~
12040 acc
12041 \newline 
12042 \SpecialChar ~
12043 \SpecialChar ~
12044 \SpecialChar ~
12045 \SpecialChar ~
12046 reti
12047 \layout Standard
12048
12049 whereas nakedInterrupt looks like:
12050 \layout Verse
12051
12052
12053 \family typewriter 
12054 _nakedInterrupt:
12055 \newline 
12056 \SpecialChar ~
12057 \SpecialChar ~
12058 \SpecialChar ~
12059 \SpecialChar ~
12060 inc\SpecialChar ~
12061 \SpecialChar ~
12062 \SpecialChar ~
12063 \SpecialChar ~
12064 _counter ; does not change flags, no need to save psw
12065 \newline 
12066 \SpecialChar ~
12067 \SpecialChar ~
12068 \SpecialChar ~
12069 \SpecialChar ~
12070 reti\SpecialChar ~
12071 \SpecialChar ~
12072 \SpecialChar ~
12073 \SpecialChar ~
12074 \SpecialChar ~
12075 \SpecialChar ~
12076 \SpecialChar ~
12077 \SpecialChar ~
12078 \SpecialChar ~
12079 \SpecialChar ~
12080 \SpecialChar ~
12081 \SpecialChar ~
12082 ; MUST explicitly include ret or reti in _naked function
12083 \layout Standard
12084
12085 The related directive #pragma exclude
12086 \begin_inset LatexCommand \index{\#pragma exclude}
12087
12088 \end_inset 
12089
12090  allows a more fine grained control over pushing & popping
12091 \begin_inset LatexCommand \index{push/pop}
12092
12093 \end_inset 
12094
12095  the registers.
12096 \layout Standard
12097
12098 While there is nothing preventing you from writing C code inside a 
12099 \family typewriter 
12100 _naked
12101 \family default 
12102  function, there are many ways to shoot yourself in the foot doing this,
12103  and it is recommended that you stick to inline assembler.
12104 \layout Subsection
12105
12106 Use of Labels within Inline Assembler
12107 \layout Standard
12108
12109 SDCC allows the use of in-line assembler with a few restrictions regarding
12110  labels.
12111  In older versions of the compiler all labels defined within inline assembler
12112  code 
12113 \emph on 
12114 had to be
12115 \emph default 
12116  of the form 
12117 \emph on 
12118 nnnnn$
12119 \emph default 
12120  where nnnn is a number less than 100 (which implies a limit of utmost 100
12121  inline assembler labels 
12122 \emph on 
12123 per function
12124 \emph default 
12125 \noun on 
12126 )
12127 \noun default 
12128 .
12129  
12130 \layout Verse
12131
12132
12133 \family typewriter 
12134 _asm
12135 \begin_inset LatexCommand \index{\_asm}
12136
12137 \end_inset 
12138
12139  
12140 \newline 
12141 \SpecialChar ~
12142 \SpecialChar ~
12143 \SpecialChar ~
12144 \SpecialChar ~
12145 mov\SpecialChar ~
12146 \SpecialChar ~
12147 \SpecialChar ~
12148 \SpecialChar ~
12149 \SpecialChar ~
12150 b,#10 
12151 \newline 
12152 00001$: 
12153 \newline 
12154 \SpecialChar ~
12155 \SpecialChar ~
12156 \SpecialChar ~
12157 \SpecialChar ~
12158 djnz\SpecialChar ~
12159 \SpecialChar ~
12160 \SpecialChar ~
12161 \SpecialChar ~
12162 b,00001$ 
12163 \newline 
12164 _endasm
12165 \begin_inset LatexCommand \index{\_endasm}
12166
12167 \end_inset 
12168
12169  ;
12170 \layout Standard
12171
12172 Inline assembler code cannot reference any C-Labels, however it can reference
12173  labels
12174 \begin_inset LatexCommand \index{Labels}
12175
12176 \end_inset 
12177
12178  defined by the inline assembler, e.g.:
12179 \layout Verse
12180
12181
12182 \family typewriter 
12183 foo() { 
12184 \newline 
12185 \SpecialChar ~
12186 \SpecialChar ~
12187 \SpecialChar ~
12188 \SpecialChar ~
12189 /* some c code */ 
12190 \newline 
12191 \SpecialChar ~
12192 \SpecialChar ~
12193 \SpecialChar ~
12194 \SpecialChar ~
12195 _asm 
12196 \newline 
12197 \SpecialChar ~
12198 \SpecialChar ~
12199 \SpecialChar ~
12200 \SpecialChar ~
12201 \SpecialChar ~
12202 \SpecialChar ~
12203 ; some assembler code 
12204 \newline 
12205 \SpecialChar ~
12206 \SpecialChar ~
12207 \SpecialChar ~
12208 \SpecialChar ~
12209 \SpecialChar ~
12210 \SpecialChar ~
12211 ljmp $0003 
12212 \newline 
12213 \SpecialChar ~
12214 \SpecialChar ~
12215 \SpecialChar ~
12216 \SpecialChar ~
12217 _endasm; 
12218 \newline 
12219 \SpecialChar ~
12220 \SpecialChar ~
12221 \SpecialChar ~
12222 \SpecialChar ~
12223 /* some more c code */ 
12224 \newline 
12225 clabel:\SpecialChar ~
12226 \SpecialChar ~
12227 /* inline assembler cannot reference this label */ 
12228 \newline 
12229 \SpecialChar ~
12230 \SpecialChar ~
12231 \SpecialChar ~
12232 \SpecialChar ~
12233 _asm
12234 \newline 
12235 \SpecialChar ~
12236 \SpecialChar ~
12237 \SpecialChar ~
12238 \SpecialChar ~
12239 $0003: ;label (can be referenced by inline assembler only) 
12240 \newline 
12241 \SpecialChar ~
12242 \SpecialChar ~
12243 \SpecialChar ~
12244 \SpecialChar ~
12245 _endasm ; 
12246 \newline 
12247 \SpecialChar ~
12248 \SpecialChar ~
12249 \SpecialChar ~
12250 \SpecialChar ~
12251 /* some more c code */
12252 \newline 
12253 }
12254 \layout Standard
12255
12256 In other words inline assembly code can access labels defined in inline
12257  assembly within the scope of the function.
12258  The same goes the other way, i.e.
12259  labels defines in inline assembly can not be accessed by C statements.
12260 \layout Section
12261
12262 Interfacing with Assembler Code
12263 \begin_inset LatexCommand \index{Assembler routines}
12264
12265 \end_inset 
12266
12267
12268 \layout Subsection
12269
12270 Global Registers used for Parameter Passing
12271 \begin_inset LatexCommand \index{Parameter passing}
12272
12273 \end_inset 
12274
12275
12276 \layout Standard
12277
12278 The compiler always uses the global registers 
12279 \emph on 
12280 DPL, DPH
12281 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
12282
12283 \end_inset 
12284
12285
12286 \begin_inset LatexCommand \index{DPTR}
12287
12288 \end_inset 
12289
12290 , B
12291 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
12292
12293 \end_inset 
12294
12295  
12296 \emph default 
12297 and
12298 \emph on 
12299  ACC
12300 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
12301
12302 \end_inset 
12303
12304
12305 \emph default 
12306  to pass the first parameter to a routine.
12307  The second parameter onwards is either allocated on the stack (for reentrant
12308  routines or if -
12309 \begin_inset ERT
12310 status Collapsed
12311
12312 \layout Standard
12313
12314 \backslash 
12315 /
12316 \end_inset 
12317
12318 -stack-auto is used) or in data / xdata memory (depending on the memory
12319  model).
12320  
12321 \layout Subsection
12322
12323 Assembler Routine (non-reentrant)
12324 \layout Standard
12325
12326 In the following example
12327 \begin_inset LatexCommand \index{reentrant}
12328
12329 \end_inset 
12330
12331
12332 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
12333
12334 \end_inset 
12335
12336  the function c_func calls an assembler routine asm_func, which takes two
12337  parameters
12338 \begin_inset LatexCommand \index{function parameter}
12339
12340 \end_inset 
12341
12342 .
12343 \layout Verse
12344
12345
12346 \family typewriter 
12347 extern int asm_func(unsigned char, unsigned char);
12348 \newline 
12349
12350 \newline 
12351 int c_func (unsigned char i, unsigned char j)
12352 \newline 
12353 {
12354 \newline 
12355 \SpecialChar ~
12356 \SpecialChar ~
12357 \SpecialChar ~
12358 \SpecialChar ~
12359 return asm_func(i,j);
12360 \newline 
12361 }
12362 \newline 
12363
12364 \newline 
12365 int main()
12366 \newline 
12367 {
12368 \newline 
12369 \SpecialChar ~
12370 \SpecialChar ~
12371 \SpecialChar ~
12372 \SpecialChar ~
12373 return c_func(10,9);
12374 \newline 
12375 }
12376 \layout Standard
12377
12378 The corresponding assembler function is:
12379 \layout Verse
12380
12381
12382 \family typewriter 
12383 .globl _asm_func_PARM_2 
12384 \newline 
12385 \SpecialChar ~
12386 \SpecialChar ~
12387 \SpecialChar ~
12388 \SpecialChar ~
12389 \SpecialChar ~
12390 \SpecialChar ~
12391 \SpecialChar ~
12392 \SpecialChar ~
12393 .globl _asm_func 
12394 \newline 
12395 \SpecialChar ~
12396 \SpecialChar ~
12397 \SpecialChar ~
12398 \SpecialChar ~
12399 \SpecialChar ~
12400 \SpecialChar ~
12401 \SpecialChar ~
12402 \SpecialChar ~
12403 .area OSEG 
12404 \newline 
12405 _asm_func_PARM_2:
12406 \newline 
12407 \SpecialChar ~
12408 \SpecialChar ~
12409 \SpecialChar ~
12410 \SpecialChar ~
12411 \SpecialChar ~
12412 \SpecialChar ~
12413 \SpecialChar ~
12414 \SpecialChar ~
12415 .ds    1 
12416 \newline 
12417 \SpecialChar ~
12418 \SpecialChar ~
12419 \SpecialChar ~
12420 \SpecialChar ~
12421 \SpecialChar ~
12422 \SpecialChar ~
12423 \SpecialChar ~
12424 \SpecialChar ~
12425 .area CSEG 
12426 \newline 
12427 _asm_func: 
12428 \newline 
12429 \SpecialChar ~
12430 \SpecialChar ~
12431 \SpecialChar ~
12432 \SpecialChar ~
12433 \SpecialChar ~
12434 \SpecialChar ~
12435 \SpecialChar ~
12436 \SpecialChar ~
12437 mov\SpecialChar ~
12438 \SpecialChar ~
12439 \SpecialChar ~
12440 \SpecialChar ~
12441 a,dpl 
12442 \newline 
12443 \SpecialChar ~
12444 \SpecialChar ~
12445 \SpecialChar ~
12446 \SpecialChar ~
12447 \SpecialChar ~
12448 \SpecialChar ~
12449 \SpecialChar ~
12450 \SpecialChar ~
12451 add\SpecialChar ~
12452 \SpecialChar ~
12453 \SpecialChar ~
12454 \SpecialChar ~
12455 a,_asm_func_PARM_2 
12456 \newline 
12457 \SpecialChar ~
12458 \SpecialChar ~
12459 \SpecialChar ~
12460 \SpecialChar ~
12461 \SpecialChar ~
12462 \SpecialChar ~
12463 \SpecialChar ~
12464 \SpecialChar ~
12465 mov\SpecialChar ~
12466 \SpecialChar ~
12467 \SpecialChar ~
12468 \SpecialChar ~
12469 dpl,a 
12470 \newline 
12471 \SpecialChar ~
12472 \SpecialChar ~
12473 \SpecialChar ~
12474 \SpecialChar ~
12475 \SpecialChar ~
12476 \SpecialChar ~
12477 \SpecialChar ~
12478 \SpecialChar ~
12479 mov\SpecialChar ~
12480 \SpecialChar ~
12481 \SpecialChar ~
12482 \SpecialChar ~
12483 dph
12484 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
12485
12486 \end_inset 
12487
12488 ,#0x00 
12489 \newline 
12490 \SpecialChar ~
12491 \SpecialChar ~
12492 \SpecialChar ~
12493 \SpecialChar ~
12494 \SpecialChar ~
12495 \SpecialChar ~
12496 \SpecialChar ~
12497 \SpecialChar ~
12498 ret
12499 \layout Standard
12500
12501 Note here that the return values
12502 \begin_inset LatexCommand \index{return value}
12503
12504 \end_inset 
12505
12506  are placed in 'dpl' - One byte return value, 'dpl' LSB & 'dph' MSB for
12507  two byte values.
12508  'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
12509 b' & 'acc' for four byte values.
12510 \layout Standard
12511
12512 The parameter naming convention is _<function_name>_PARM_<n>, where n is
12513  the parameter number starting from 1, and counting from the left.
12514  The first parameter is passed in 
12515 \begin_inset Quotes eld
12516 \end_inset 
12517
12518 dpl
12519 \begin_inset Quotes erd
12520 \end_inset 
12521
12522  for a one byte parameter, 
12523 \begin_inset Quotes eld
12524 \end_inset 
12525
12526 dptr
12527 \begin_inset Quotes erd
12528 \end_inset 
12529
12530  for two bytes, 
12531 \begin_inset Quotes eld
12532 \end_inset 
12533
12534 b,dptr
12535 \begin_inset Quotes erd
12536 \end_inset 
12537
12538  for three bytes and 
12539 \begin_inset Quotes eld
12540 \end_inset 
12541
12542 acc,b,dptr
12543 \begin_inset Quotes erd
12544 \end_inset 
12545
12546  for a four bytes parameter.
12547  The variable name for the second parameter will be _<function_name>_PARM_2.
12548 \newline 
12549
12550 \newline 
12551 Assemble the assembler routine with the following command:
12552 \newline 
12553
12554 \newline 
12555
12556 \family sans 
12557 \series bold 
12558 asx8051 -losg asmfunc.asm
12559 \newline 
12560
12561 \newline 
12562
12563 \family default 
12564 \series default 
12565 Then compile and link the assembler routine to the C source file with the
12566  following command:
12567 \newline 
12568
12569 \newline 
12570
12571 \family sans 
12572 \series bold 
12573 sdcc cfunc.c asmfunc.rel
12574 \layout Subsection
12575
12576 Assembler Routine (reentrant)
12577 \layout Standard
12578
12579 In this case
12580 \begin_inset LatexCommand \index{reentrant}
12581
12582 \end_inset 
12583
12584
12585 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
12586
12587 \end_inset 
12588
12589  the second parameter
12590 \begin_inset LatexCommand \index{function parameter}
12591
12592 \end_inset 
12593
12594  onwards will be passed on the stack, the parameters are pushed from right
12595  to left i.e.
12596  after the call the leftmost parameter will be on the top of the stack.
12597  Here is an example:
12598 \layout Verse
12599
12600
12601 \family typewriter 
12602 extern int asm_func(unsigned char, unsigned char);
12603 \newline 
12604
12605 \newline 
12606 int c_func (unsigned char i, unsigned char j) reentrant 
12607 \newline 
12608
12609 \newline 
12610 \SpecialChar ~
12611 \SpecialChar ~
12612 \SpecialChar ~
12613 \SpecialChar ~
12614 return asm_func(i,j); 
12615 \newline 
12616
12617 \newline 
12618
12619 \newline 
12620 int main() 
12621 \newline 
12622
12623 \newline 
12624 \SpecialChar ~
12625 \SpecialChar ~
12626 \SpecialChar ~
12627 \SpecialChar ~
12628 return c_func(10,9); 
12629 \newline 
12630 }
12631 \layout Standard
12632
12633 The corresponding assembler routine is:
12634 \layout Verse
12635
12636
12637 \family typewriter 
12638 .globl _asm_func 
12639 \newline 
12640 _asm_func: 
12641 \newline 
12642 \SpecialChar ~
12643 \SpecialChar ~
12644 \SpecialChar ~
12645 \SpecialChar ~
12646 push  _bp 
12647 \newline 
12648 \SpecialChar ~
12649 \SpecialChar ~
12650 \SpecialChar ~
12651 \SpecialChar ~
12652 mov _bp,sp 
12653 \newline 
12654 \SpecialChar ~
12655 \SpecialChar ~
12656 \SpecialChar ~
12657 \SpecialChar ~
12658 mov r2,dpl
12659 \newline 
12660 \SpecialChar ~
12661 \SpecialChar ~
12662 \SpecialChar ~
12663 \SpecialChar ~
12664 mov a,_bp 
12665 \newline 
12666 \SpecialChar ~
12667 \SpecialChar ~
12668 \SpecialChar ~
12669 \SpecialChar ~
12670 add a,#0xfd 
12671 \newline 
12672 \SpecialChar ~
12673 \SpecialChar ~
12674 \SpecialChar ~
12675 \SpecialChar ~
12676 mov r0,a 
12677 \newline 
12678 \SpecialChar ~
12679 \SpecialChar ~
12680 \SpecialChar ~
12681 \SpecialChar ~
12682 add  a,#0xfc ;?
12683 \newline 
12684 \SpecialChar ~
12685 \SpecialChar ~
12686 \SpecialChar ~
12687 \SpecialChar ~
12688 mov  r1,a 
12689 \newline 
12690 \SpecialChar ~
12691 \SpecialChar ~
12692 \SpecialChar ~
12693 \SpecialChar ~
12694 mov  a,@r0 
12695 \newline 
12696 \SpecialChar ~
12697 \SpecialChar ~
12698 \SpecialChar ~
12699 \SpecialChar ~
12700 add  a,r2 ;?
12701 \newline 
12702 \SpecialChar ~
12703 \SpecialChar ~
12704 \SpecialChar ~
12705 \SpecialChar ~
12706 mov  dpl,a 
12707 \newline 
12708 \SpecialChar ~
12709 \SpecialChar ~
12710 \SpecialChar ~
12711 \SpecialChar ~
12712 mov  dph,#0x00 
12713 \newline 
12714 \SpecialChar ~
12715 \SpecialChar ~
12716 \SpecialChar ~
12717 \SpecialChar ~
12718 mov  sp,_bp 
12719 \newline 
12720 \SpecialChar ~
12721 \SpecialChar ~
12722 \SpecialChar ~
12723 \SpecialChar ~
12724 pop  _bp 
12725 \newline 
12726 \SpecialChar ~
12727 \SpecialChar ~
12728 \SpecialChar ~
12729 \SpecialChar ~
12730 ret
12731 \layout Standard
12732
12733 The compiling and linking procedure remains the same, however note the extra
12734  entry & exit linkage required for the assembler code, _bp is the stack
12735  frame pointer and is used to compute the offset into the stack for parameters
12736  and local variables.
12737 \layout Section
12738
12739 int (16 bit)
12740 \begin_inset LatexCommand \index{int (16 bit)}
12741
12742 \end_inset 
12743
12744  and long (32 bit)
12745 \begin_inset LatexCommand \index{long (32 bit)}
12746
12747 \end_inset 
12748
12749  Support
12750 \layout Standard
12751
12752 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
12753  multiplication and modulus operations are implemented by support routines.
12754  These support routines are all developed in ANSI-C to facilitate porting
12755  to other MCUs, although some model specific assembler optimizations are
12756  used.
12757  The following files contain the described routines, all of them can be
12758  found in <installdir>/share/sdcc/lib.
12759 \newline 
12760
12761 \layout Standard
12762 \align center 
12763
12764 \begin_inset  Tabular
12765 <lyxtabular version="3" rows="11" columns="2">
12766 <features>
12767 <column alignment="center" valignment="top" leftline="true" width="0">
12768 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
12769 <row topline="true" bottomline="true">
12770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12771 \begin_inset Text
12772
12773 \layout Standard
12774
12775
12776 \series bold 
12777 Function
12778 \end_inset 
12779 </cell>
12780 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12781 \begin_inset Text
12782
12783 \layout Standard
12784
12785
12786 \series bold 
12787 Description
12788 \end_inset 
12789 </cell>
12790 </row>
12791 <row topline="true">
12792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12793 \begin_inset Text
12794
12795 \layout Standard
12796
12797 _mulint.c 
12798 \end_inset 
12799 </cell>
12800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12801 \begin_inset Text
12802
12803 \layout Standard
12804
12805 16 bit multiplication
12806 \end_inset 
12807 </cell>
12808 </row>
12809 <row topline="true">
12810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12811 \begin_inset Text
12812
12813 \layout Standard
12814
12815 _divsint.c 
12816 \end_inset 
12817 </cell>
12818 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12819 \begin_inset Text
12820
12821 \layout Standard
12822
12823  signed 16 bit division (calls _divuint)
12824 \end_inset 
12825 </cell>
12826 </row>
12827 <row topline="true">
12828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12829 \begin_inset Text
12830
12831 \layout Standard
12832
12833 _divuint.c 
12834 \end_inset 
12835 </cell>
12836 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12837 \begin_inset Text
12838
12839 \layout Standard
12840
12841  unsigned 16 bit division
12842 \end_inset 
12843 </cell>
12844 </row>
12845 <row topline="true">
12846 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12847 \begin_inset Text
12848
12849 \layout Standard
12850
12851 _modsint.c
12852 \end_inset 
12853 </cell>
12854 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12855 \begin_inset Text
12856
12857 \layout Standard
12858
12859 signed 16 bit modulus (calls _moduint)
12860 \end_inset 
12861 </cell>
12862 </row>
12863 <row topline="true">
12864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12865 \begin_inset Text
12866
12867 \layout Standard
12868
12869 _moduint.c
12870 \end_inset 
12871 </cell>
12872 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12873 \begin_inset Text
12874
12875 \layout Standard
12876
12877 unsigned 16 bit modulus
12878 \end_inset 
12879 </cell>
12880 </row>
12881 <row topline="true">
12882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12883 \begin_inset Text
12884
12885 \layout Standard
12886
12887 _mullong.c
12888 \end_inset 
12889 </cell>
12890 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12891 \begin_inset Text
12892
12893 \layout Standard
12894
12895 32 bit multiplication
12896 \end_inset 
12897 </cell>
12898 </row>
12899 <row topline="true">
12900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12901 \begin_inset Text
12902
12903 \layout Standard
12904
12905 _divslong.c 
12906 \end_inset 
12907 </cell>
12908 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12909 \begin_inset Text
12910
12911 \layout Standard
12912
12913  signed 32 division (calls _divulong)
12914 \end_inset 
12915 </cell>
12916 </row>
12917 <row topline="true">
12918 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12919 \begin_inset Text
12920
12921 \layout Standard
12922
12923 _divulong.c 
12924 \end_inset 
12925 </cell>
12926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12927 \begin_inset Text
12928
12929 \layout Standard
12930
12931 unsigned 32 division
12932 \end_inset 
12933 </cell>
12934 </row>
12935 <row topline="true">
12936 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12937 \begin_inset Text
12938
12939 \layout Standard
12940
12941 _modslong.c
12942 \end_inset 
12943 </cell>
12944 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12945 \begin_inset Text
12946
12947 \layout Standard
12948
12949  signed 32 bit modulus (calls _modulong)
12950 \end_inset 
12951 </cell>
12952 </row>
12953 <row topline="true" bottomline="true">
12954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12955 \begin_inset Text
12956
12957 \layout Standard
12958
12959 _modulong.c
12960 \end_inset 
12961 </cell>
12962 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12963 \begin_inset Text
12964
12965 \layout Standard
12966
12967 unsigned 32 bit modulus
12968 \end_inset 
12969 </cell>
12970 </row>
12971 </lyxtabular>
12972
12973 \end_inset 
12974
12975
12976 \newline 
12977
12978 \layout Standard
12979
12980 Since they are compiled as 
12981 \emph on 
12982 non-reentrant
12983 \emph default 
12984
12985 \begin_inset LatexCommand \index{reentrant}
12986
12987 \end_inset 
12988
12989 , interrupt
12990 \begin_inset LatexCommand \index{interrupt}
12991
12992 \end_inset 
12993
12994  service routines should not do any of the above operations.
12995  If this is unavoidable then the above routines will need to be compiled
12996  with the 
12997 \emph on 
12998 -
12999 \begin_inset ERT
13000 status Collapsed
13001
13002 \layout Standard
13003
13004 \backslash 
13005 /
13006 \end_inset 
13007
13008 -stack-auto
13009 \begin_inset LatexCommand \index{-\/-stack-auto}
13010
13011 \end_inset 
13012
13013
13014 \emph default 
13015  option, after which the source program will have to be compiled with 
13016 \emph on 
13017 -
13018 \begin_inset ERT
13019 status Collapsed
13020
13021 \layout Standard
13022
13023 \backslash 
13024 /
13025 \end_inset 
13026
13027 -int-long-reent
13028 \begin_inset LatexCommand \index{-\/-int-long-reent}
13029
13030 \end_inset 
13031
13032
13033 \emph default 
13034  option.
13035  Notice that you don't have to call these routines directly.
13036  The compiler will use them automatically every time an integer operation
13037  is required.
13038 \layout Section
13039
13040 Floating Point Support
13041 \begin_inset LatexCommand \index{Floating point support}
13042
13043 \end_inset 
13044
13045
13046 \layout Standard
13047
13048 SDCC supports IEEE (single precision 4 bytes) floating point numbers.The
13049  floating point support routines are derived from gcc's floatlib.c and consist
13050  of the following routines:
13051 \newline 
13052
13053 \layout Standard
13054 \align center 
13055
13056 \size footnotesize 
13057
13058 \begin_inset  Tabular
13059 <lyxtabular version="3" rows="17" columns="2">
13060 <features>
13061 <column alignment="center" valignment="top" leftline="true" width="0">
13062 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
13063 <row topline="true" bottomline="true">
13064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13065 \begin_inset Text
13066
13067 \layout Standard
13068
13069
13070 \family roman 
13071 \series medium 
13072 \shape up 
13073 \size normal 
13074 \emph off 
13075 \bar no 
13076 \noun off 
13077 \color none
13078 Function 
13079 \end_inset 
13080 </cell>
13081 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13082 \begin_inset Text
13083
13084 \layout Standard
13085
13086 Description
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
13097 \family roman 
13098 \series medium 
13099 \shape up 
13100 \size normal 
13101 \emph off 
13102 \bar no 
13103 \noun off 
13104 \color none
13105 _fsadd.c
13106 \end_inset 
13107 </cell>
13108 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13109 \begin_inset Text
13110
13111 \layout Standard
13112
13113
13114 \family roman 
13115 \series medium 
13116 \shape up 
13117 \size normal 
13118 \emph off 
13119 \bar no 
13120 \noun off 
13121 \color none
13122 add floating point numbers
13123 \end_inset 
13124 </cell>
13125 </row>
13126 <row topline="true">
13127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13128 \begin_inset Text
13129
13130 \layout Standard
13131
13132
13133 \family roman 
13134 \series medium 
13135 \shape up 
13136 \size normal 
13137 \emph off 
13138 \bar no 
13139 \noun off 
13140 \color none
13141 _fssub.c 
13142 \end_inset 
13143 </cell>
13144 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13145 \begin_inset Text
13146
13147 \layout Standard
13148
13149
13150 \family roman 
13151 \series medium 
13152 \shape up 
13153 \size normal 
13154 \emph off 
13155 \bar no 
13156 \noun off 
13157 \color none
13158 subtract floating point numbers 
13159 \end_inset 
13160 </cell>
13161 </row>
13162 <row topline="true">
13163 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13164 \begin_inset Text
13165
13166 \layout Standard
13167
13168
13169 \family roman 
13170 \series medium 
13171 \shape up 
13172 \size normal 
13173 \emph off 
13174 \bar no 
13175 \noun off 
13176 \color none
13177 _fsdiv.c 
13178 \end_inset 
13179 </cell>
13180 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13181 \begin_inset Text
13182
13183 \layout Standard
13184
13185
13186 \family roman 
13187 \series medium 
13188 \shape up 
13189 \size normal 
13190 \emph off 
13191 \bar no 
13192 \noun off 
13193 \color none
13194 divide floating point numbers 
13195 \end_inset 
13196 </cell>
13197 </row>
13198 <row topline="true">
13199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13200 \begin_inset Text
13201
13202 \layout Standard
13203
13204
13205 \family roman 
13206 \series medium 
13207 \shape up 
13208 \size normal 
13209 \emph off 
13210 \bar no 
13211 \noun off 
13212 \color none
13213 _fsmul.c 
13214 \end_inset 
13215 </cell>
13216 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13217 \begin_inset Text
13218
13219 \layout Standard
13220
13221
13222 \family roman 
13223 \series medium 
13224 \shape up 
13225 \size normal 
13226 \emph off 
13227 \bar no 
13228 \noun off 
13229 \color none
13230 multiply floating point numbers 
13231 \end_inset 
13232 </cell>
13233 </row>
13234 <row topline="true">
13235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13236 \begin_inset Text
13237
13238 \layout Standard
13239
13240
13241 \family roman 
13242 \series medium 
13243 \shape up 
13244 \size normal 
13245 \emph off 
13246 \bar no 
13247 \noun off 
13248 \color none
13249 _fs2uchar.c
13250 \end_inset 
13251 </cell>
13252 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13253 \begin_inset Text
13254
13255 \layout Standard
13256
13257
13258 \family roman 
13259 \series medium 
13260 \shape up 
13261 \size normal 
13262 \emph off 
13263 \bar no 
13264 \noun off 
13265 \color none
13266 convert floating point to unsigned char
13267 \end_inset 
13268 </cell>
13269 </row>
13270 <row topline="true">
13271 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13272 \begin_inset Text
13273
13274 \layout Standard
13275
13276
13277 \family roman 
13278 \series medium 
13279 \shape up 
13280 \size normal 
13281 \emph off 
13282 \bar no 
13283 \noun off 
13284 \color none
13285 _fs2char.c
13286 \end_inset 
13287 </cell>
13288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13289 \begin_inset Text
13290
13291 \layout Standard
13292
13293
13294 \family roman 
13295 \series medium 
13296 \shape up 
13297 \size normal 
13298 \emph off 
13299 \bar no 
13300 \noun off 
13301 \color none
13302 convert floating point to signed char
13303 \end_inset 
13304 </cell>
13305 </row>
13306 <row topline="true">
13307 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13308 \begin_inset Text
13309
13310 \layout Standard
13311
13312
13313 \family roman 
13314 \series medium 
13315 \shape up 
13316 \size normal 
13317 \emph off 
13318 \bar no 
13319 \noun off 
13320 \color none
13321 _fs2uint.c
13322 \end_inset 
13323 </cell>
13324 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13325 \begin_inset Text
13326
13327 \layout Standard
13328
13329
13330 \family roman 
13331 \series medium 
13332 \shape up 
13333 \size normal 
13334 \emph off 
13335 \bar no 
13336 \noun off 
13337 \color none
13338 convert floating point to unsigned int
13339 \end_inset 
13340 </cell>
13341 </row>
13342 <row topline="true">
13343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13344 \begin_inset Text
13345
13346 \layout Standard
13347
13348
13349 \family roman 
13350 \series medium 
13351 \shape up 
13352 \size normal 
13353 \emph off 
13354 \bar no 
13355 \noun off 
13356 \color none
13357 _fs2int.c
13358 \end_inset 
13359 </cell>
13360 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13361 \begin_inset Text
13362
13363 \layout Standard
13364
13365
13366 \family roman 
13367 \series medium 
13368 \shape up 
13369 \size normal 
13370 \emph off 
13371 \bar no 
13372 \noun off 
13373 \color none
13374 convert floating point to signed int
13375 \end_inset 
13376 </cell>
13377 </row>
13378 <row topline="true">
13379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13380 \begin_inset Text
13381
13382 \layout Standard
13383
13384
13385 \family roman 
13386 \series medium 
13387 \shape up 
13388 \size normal 
13389 \emph off 
13390 \bar no 
13391 \noun off 
13392 \color none
13393 _fs2ulong.
13394 \family default 
13395 \series default 
13396 \shape default 
13397 \size default 
13398 \emph default 
13399 \bar default 
13400 \noun default 
13401 \color default
13402 c
13403 \end_inset 
13404 </cell>
13405 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13406 \begin_inset Text
13407
13408 \layout Standard
13409
13410
13411 \family roman 
13412 \series medium 
13413 \shape up 
13414 \size normal 
13415 \emph off 
13416 \bar no 
13417 \noun off 
13418 \color none
13419 convert floating point to unsigned long
13420 \end_inset 
13421 </cell>
13422 </row>
13423 <row topline="true">
13424 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13425 \begin_inset Text
13426
13427 \layout Standard
13428
13429
13430 \family roman 
13431 \series medium 
13432 \shape up 
13433 \size normal 
13434 \emph off 
13435 \bar no 
13436 \noun off 
13437 \color none
13438 _fs2long.c
13439 \end_inset 
13440 </cell>
13441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13442 \begin_inset Text
13443
13444 \layout Standard
13445
13446
13447 \family roman 
13448 \series medium 
13449 \shape up 
13450 \size normal 
13451 \emph off 
13452 \bar no 
13453 \noun off 
13454 \color none
13455 convert floating point to signed long
13456 \end_inset 
13457 </cell>
13458 </row>
13459 <row topline="true">
13460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13461 \begin_inset Text
13462
13463 \layout Standard
13464
13465
13466 \family roman 
13467 \series medium 
13468 \shape up 
13469 \size normal 
13470 \emph off 
13471 \bar no 
13472 \noun off 
13473 \color none
13474 _uchar2fs.c
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 \family roman 
13484 \series medium 
13485 \shape up 
13486 \size normal 
13487 \emph off 
13488 \bar no 
13489 \noun off 
13490 \color none
13491 convert unsigned char to floating point
13492 \end_inset 
13493 </cell>
13494 </row>
13495 <row topline="true">
13496 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13497 \begin_inset Text
13498
13499 \layout Standard
13500
13501
13502 \family roman 
13503 \series medium 
13504 \shape up 
13505 \size normal 
13506 \emph off 
13507 \bar no 
13508 \noun off 
13509 \color none
13510 _char2fs.c
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 \family roman 
13520 \series medium 
13521 \shape up 
13522 \size normal 
13523 \emph off 
13524 \bar no 
13525 \noun off 
13526 \color none
13527 convert char to floating point number
13528 \end_inset 
13529 </cell>
13530 </row>
13531 <row topline="true">
13532 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13533 \begin_inset Text
13534
13535 \layout Standard
13536
13537
13538 \family roman 
13539 \series medium 
13540 \shape up 
13541 \size normal 
13542 \emph off 
13543 \bar no 
13544 \noun off 
13545 \color none
13546 _uint2fs.c
13547 \end_inset 
13548 </cell>
13549 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13550 \begin_inset Text
13551
13552 \layout Standard
13553
13554
13555 \family roman 
13556 \series medium 
13557 \shape up 
13558 \size normal 
13559 \emph off 
13560 \bar no 
13561 \noun off 
13562 \color none
13563 convert unsigned int to floating point
13564 \end_inset 
13565 </cell>
13566 </row>
13567 <row topline="true">
13568 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13569 \begin_inset Text
13570
13571 \layout Standard
13572
13573
13574 \family roman 
13575 \series medium 
13576 \shape up 
13577 \size normal 
13578 \emph off 
13579 \bar no 
13580 \noun off 
13581 \color none
13582 _int2fs.c
13583 \end_inset 
13584 </cell>
13585 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13586 \begin_inset Text
13587
13588 \layout Standard
13589
13590
13591 \family roman 
13592 \series medium 
13593 \shape up 
13594 \size normal 
13595 \emph off 
13596 \bar no 
13597 \noun off 
13598 \color none
13599 convert int to floating point numbers
13600 \end_inset 
13601 </cell>
13602 </row>
13603 <row topline="true">
13604 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13605 \begin_inset Text
13606
13607 \layout Standard
13608
13609
13610 \family roman 
13611 \series medium 
13612 \shape up 
13613 \size normal 
13614 \emph off 
13615 \bar no 
13616 \noun off 
13617 \color none
13618 _ulong2fs.c
13619 \end_inset 
13620 </cell>
13621 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13622 \begin_inset Text
13623
13624 \layout Standard
13625
13626
13627 \family roman 
13628 \series medium 
13629 \shape up 
13630 \size normal 
13631 \emph off 
13632 \bar no 
13633 \noun off 
13634 \color none
13635 convert unsigned long to floating point number
13636 \end_inset 
13637 </cell>
13638 </row>
13639 <row topline="true" bottomline="true">
13640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13641 \begin_inset Text
13642
13643 \layout Standard
13644
13645
13646 \family roman 
13647 \series medium 
13648 \shape up 
13649 \size normal 
13650 \emph off 
13651 \bar no 
13652 \noun off 
13653 \color none
13654 _long2fs.c
13655 \end_inset 
13656 </cell>
13657 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13658 \begin_inset Text
13659
13660 \layout Standard
13661
13662
13663 \family roman 
13664 \series medium 
13665 \shape up 
13666 \size normal 
13667 \emph off 
13668 \bar no 
13669 \noun off 
13670 \color none
13671 convert long to floating point number
13672 \end_inset 
13673 </cell>
13674 </row>
13675 </lyxtabular>
13676
13677 \end_inset 
13678
13679
13680 \newline 
13681
13682 \layout Standard
13683
13684 These support routines are developed in ANSI-C so there is room for space
13685  and speed improvement.
13686  Note if all these routines are used simultaneously the data space might
13687  overflow.
13688  For serious floating point usage it is recommended that the large model
13689  be used.
13690  Also notice that you don't have to call this routines directly.
13691  The compiler will use them automatically every time a floating point operation
13692  is required.
13693 \layout Section
13694
13695 Library Routines
13696 \begin_inset LatexCommand \index{Libraries}
13697
13698 \end_inset 
13699
13700
13701 \layout Standard
13702
13703
13704 \emph on 
13705 <pending: this is messy and incomplete - a little more information is in
13706  sdcc/doc/libdoc.txt
13707 \emph default 
13708  >
13709 \layout Subsection
13710
13711 Compiler support routines (_gptrget, _mulint etc.)
13712 \layout Subsection
13713
13714 Stdclib functions (puts, printf, strcat etc.)
13715 \layout Subsubsection
13716
13717 <stdio.h>
13718 \layout Standard
13719
13720
13721 \begin_inset LatexCommand \index{<stdio.h>}
13722
13723 \end_inset 
13724
13725 As usual on embedded systems you have to provide your own 
13726 \family typewriter 
13727 getchar()
13728 \begin_inset LatexCommand \index{getchar()}
13729
13730 \end_inset 
13731
13732  
13733 \family default 
13734 and 
13735 \family typewriter 
13736 putchar()
13737 \begin_inset LatexCommand \index{putchar()}
13738
13739 \end_inset 
13740
13741
13742 \family default 
13743  routines.
13744  SDCC does not know whether the system connects to a serial line with or
13745  without handshake, LCD, keyboard or other device.
13746  You'll find examples for serial routines f.e.
13747  in sdcc/device/lib.
13748 \layout Standard
13749
13750 The default
13751 \family typewriter 
13752  printf()
13753 \begin_inset LatexCommand \index{printf()}
13754
13755 \end_inset 
13756
13757
13758 \family default 
13759 implementation in
13760 \family typewriter 
13761  printf_large.c
13762 \family default 
13763  does not support float (except on ds390).
13764  To enable this recompile it with the option 
13765 \emph on 
13766 -
13767 \begin_inset ERT
13768 status Collapsed
13769
13770 \layout Standard
13771
13772 \backslash 
13773 /
13774 \end_inset 
13775
13776 DUSE_FLOATS=1
13777 \begin_inset LatexCommand \index{USE\_FLOATS}
13778
13779 \end_inset 
13780
13781
13782 \emph default 
13783  on the command line.
13784  Use
13785 \emph on 
13786 -
13787 \begin_inset ERT
13788 status Collapsed
13789
13790 \layout Standard
13791
13792 \backslash 
13793 /
13794 \end_inset 
13795
13796 -model-large
13797 \begin_inset LatexCommand \index{-\/-model-large}
13798
13799 \end_inset 
13800
13801
13802 \emph default 
13803  for the mcs51 port, since this uses a lot of memory.
13804 \layout Standard
13805
13806 If you're short on memory you might want to use 
13807 \family typewriter 
13808 printf_small()
13809 \family default 
13810  
13811 \emph on 
13812 instead
13813 \emph default 
13814  of
13815 \family typewriter 
13816  printf().
13817
13818 \family default 
13819  For the mcs51 there is an assembly version 
13820 \family typewriter 
13821 printf_fast()
13822 \family default 
13823  which should fit the requirements of many embedded systems (by unsetting
13824  #defines it can be customized to 
13825 \emph on 
13826 not
13827 \emph default 
13828  support long variables and field widths).
13829 \layout Subsection
13830
13831 Math functions (sin, pow, sqrt etc.)
13832 \layout Subsection
13833
13834 Other libraries
13835 \layout Standard
13836
13837 Libraries
13838 \begin_inset LatexCommand \index{Libraries}
13839
13840 \end_inset 
13841
13842  included in SDCC should have a license at least as liberal as the GNU Lesser
13843  General Public License
13844 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
13845
13846 \end_inset 
13847
13848  
13849 \emph on 
13850 LGPL
13851 \emph default 
13852 .
13853 \layout Comment
13854
13855 license statements for the libraries are missing.
13856  sdcc/device/lib/ser_ir.c
13857 \layout Comment
13858
13859 or _decdptr f.e.
13860  come with a GPL (as opposed to LGPL) License - this will not be liberal
13861  enough for many embedded programmers.
13862 \layout Standard
13863
13864 If you have ported some library or want to share experience about some code
13865  which f.e.
13866  falls into any of these categories Busses (I
13867 \begin_inset Formula $^{\textrm{2}}$
13868 \end_inset 
13869
13870 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
13871  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
13872  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
13873 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
13874
13875 \end_inset 
13876
13877 \SpecialChar ~
13878 would certainly like to hear about it.
13879  Programmers coding for embedded systems are not especially famous for being
13880  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
13881 e these references are very valuable.
13882  Let's help to create a climate where information is shared.
13883 \layout Section
13884
13885 Memory Models
13886 \layout Subsection
13887
13888 MCS51 Memory Models
13889 \begin_inset LatexCommand \index{Memory model}
13890
13891 \end_inset 
13892
13893
13894 \begin_inset LatexCommand \index{MCS51 memory model}
13895
13896 \end_inset 
13897
13898
13899 \layout Subsubsection
13900
13901 Small and Large
13902 \layout Standard
13903
13904 SDCC allows two memory models for MCS51 code, 
13905 \shape slanted 
13906 small
13907 \shape default 
13908  and 
13909 \shape slanted 
13910 large
13911 \shape default 
13912 .
13913  Modules compiled with different memory models should 
13914 \emph on 
13915 never
13916 \emph default 
13917  be combined together or the results would be unpredictable.
13918  The library routines supplied with the compiler are compiled as both small
13919  and large.
13920  The compiled library modules are contained in separate directories as small
13921  and large so that you can link to either set.
13922  
13923 \layout Standard
13924
13925 When the large model is used all variables declared without a storage class
13926  will be allocated into the external ram, this includes all parameters and
13927  local variables (for non-reentrant
13928 \begin_inset LatexCommand \index{reentrant}
13929
13930 \end_inset 
13931
13932  functions).
13933  When the small model is used variables without storage class are allocated
13934  in the internal ram.
13935 \layout Standard
13936
13937 Judicious usage of the processor specific storage classes
13938 \begin_inset LatexCommand \index{Storage class}
13939
13940 \end_inset 
13941
13942  and the 'reentrant' function type will yield much more efficient code,
13943  than using the large model.
13944  Several optimizations are disabled when the program is compiled using the
13945  large model, it is therefore recommended that the small model be used unless
13946  absolutely required.
13947 \layout Subsubsection
13948
13949 External Stack
13950 \begin_inset LatexCommand \label{sub:External-Stack}
13951
13952 \end_inset 
13953
13954
13955 \begin_inset LatexCommand \index{stack}
13956
13957 \end_inset 
13958
13959
13960 \begin_inset LatexCommand \index{External stack (mcs51)}
13961
13962 \end_inset 
13963
13964
13965 \layout Standard
13966
13967 The external stack (-
13968 \begin_inset ERT
13969 status Collapsed
13970
13971 \layout Standard
13972
13973 \backslash 
13974 /
13975 \end_inset 
13976
13977 -xstack option
13978 \begin_inset LatexCommand \index{-\/-xstack}
13979
13980 \end_inset 
13981
13982 ) is located in pdata
13983 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
13984
13985 \end_inset 
13986
13987  memory (usually at the start of the external ram segment) and uses all
13988  unused space in pdata (max.
13989  256 bytes).
13990  When -
13991 \begin_inset ERT
13992 status Collapsed
13993
13994 \layout Standard
13995
13996 \backslash 
13997 /
13998 \end_inset 
13999
14000 -xstack option is used to compile the program, the parameters and local
14001  variables
14002 \begin_inset LatexCommand \index{local variables}
14003
14004 \end_inset 
14005
14006  of all reentrant functions are allocated in this area.
14007  This option is provided for programs with large stack space requirements.
14008  When used with the -
14009 \begin_inset ERT
14010 status Collapsed
14011
14012 \layout Standard
14013
14014 \backslash 
14015 /
14016 \end_inset 
14017
14018 -stack-auto
14019 \begin_inset LatexCommand \index{-\/-stack-auto}
14020
14021 \end_inset 
14022
14023  option, all parameters and local variables are allocated on the external
14024  stack (note: support libraries will need to be recompiled with the same
14025  options.
14026  There is a predefined target in the library makefile).
14027 \layout Standard
14028
14029 The compiler outputs the higher order address byte of the external ram segment
14030  into port P2
14031 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
14032
14033 \end_inset 
14034
14035  (see also section 
14036 \begin_inset LatexCommand \ref{sub:MCS51-variants}
14037
14038 \end_inset 
14039
14040 ), therefore when using the External Stack option, this port 
14041 \emph on 
14042 may not
14043 \emph default 
14044  be used by the application program.
14045 \layout Subsection
14046
14047 DS390 Memory Model
14048 \begin_inset LatexCommand \index{Memory model}
14049
14050 \end_inset 
14051
14052
14053 \begin_inset LatexCommand \index{DS390 memory model}
14054
14055 \end_inset 
14056
14057
14058 \layout Standard
14059
14060 The only model supported is Flat 24
14061 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
14062
14063 \end_inset 
14064
14065 .
14066  This generates code for the 24 bit contiguous addressing mode of the Dallas
14067  DS80C390 part.
14068  In this mode, up to four meg of external RAM or code space can be directly
14069  addressed.
14070  See the data sheets at www.dalsemi.com for further information on this part.
14071 \newline 
14072
14073 \newline 
14074 Note that the compiler does not generate any code to place the processor
14075  into 24 bitmode (although 
14076 \emph on 
14077 tinibios
14078 \emph default 
14079  in the ds390 libraries will do that for you).
14080  If you don't use 
14081 \emph on 
14082 tinibios
14083 \emph default 
14084
14085 \begin_inset LatexCommand \index{Tinibios (DS390)}
14086
14087 \end_inset 
14088
14089 , the boot loader or similar code must ensure that the processor is in 24
14090  bit contiguous addressing mode before calling the SDCC startup code.
14091 \newline 
14092
14093 \newline 
14094 Like the 
14095 \emph on 
14096 -
14097 \begin_inset ERT
14098 status Collapsed
14099
14100 \layout Standard
14101
14102 \backslash 
14103 /
14104 \end_inset 
14105
14106 -model-large
14107 \emph default 
14108  option, variables will by default be placed into the XDATA segment.
14109  
14110 \newline 
14111
14112 \newline 
14113 Segments may be placed anywhere in the 4 meg address space using the usual
14114  -
14115 \begin_inset ERT
14116 status Collapsed
14117
14118 \layout Standard
14119
14120 \backslash 
14121 /
14122 \end_inset 
14123
14124 -*-loc options.
14125  Note that if any segments are located above 64K, the -r flag must be passed
14126  to the linker to generate the proper segment relocations, and the Intel
14127  HEX output format must be used.
14128  The -r flag can be passed to the linker by using the option 
14129 \emph on 
14130 -Wl-r
14131 \emph default 
14132  on the SDCC command line.
14133  However, currently the linker can not handle code segments > 64k.
14134 \layout Section
14135
14136 Pragmas
14137 \begin_inset LatexCommand \index{Pragmas}
14138
14139 \end_inset 
14140
14141
14142 \layout Standard
14143
14144 SDCC supports the following #pragma directives:
14145 \layout Itemize
14146
14147 save
14148 \begin_inset LatexCommand \index{\#pragma save}
14149
14150 \end_inset 
14151
14152  - this will save all current options to the save/restore stack.
14153  See #pragma\SpecialChar ~
14154 restore.
14155 \layout Itemize
14156
14157 restore
14158 \begin_inset LatexCommand \index{\#pragma restore}
14159
14160 \end_inset 
14161
14162  - will restore saved options from the last save.
14163  saves & restores can be nested.
14164  SDCC uses a save/restore stack: save pushes current options to the stack,
14165  restore pulls current options from the stack.
14166  See #pragma\SpecialChar ~
14167 save.
14168 \newline 
14169
14170 \layout Itemize
14171
14172 callee_saves
14173 \begin_inset LatexCommand \index{\#pragma callee\_saves}
14174
14175 \end_inset 
14176
14177
14178 \begin_inset LatexCommand \index{function prologue}
14179
14180 \end_inset 
14181
14182  function1[,function2[,function3...]] - The compiler by default uses a caller
14183  saves convention for register saving across function calls, however this
14184  can cause unnecessary register pushing & popping
14185 \begin_inset LatexCommand \index{push/pop}
14186
14187 \end_inset 
14188
14189  when calling small functions from larger functions.
14190  This option can be used to switch off the register saving convention for
14191  the function names specified.
14192  The compiler will not save registers when calling these functions, extra
14193  code need to be manually inserted at the entry & exit for these functions
14194  to save & restore the registers used by these functions, this can SUBSTANTIALLY
14195  reduce code & improve run time performance of the generated code.
14196  In the future the compiler (with inter procedural analysis) may be able
14197  to determine the appropriate scheme to use for each function call.
14198  If -
14199 \begin_inset ERT
14200 status Collapsed
14201
14202 \layout Standard
14203
14204 \backslash 
14205 /
14206 \end_inset 
14207
14208 -callee-saves command line option is used, the function names specified
14209  in #pragma\SpecialChar ~
14210 callee_saves
14211 \begin_inset LatexCommand \index{\#pragma callee\_saves}
14212
14213 \end_inset 
14214
14215  is appended to the list of functions specified in the command line.
14216 \layout Itemize
14217
14218 exclude
14219 \begin_inset LatexCommand \index{\#pragma exclude}
14220
14221 \end_inset 
14222
14223  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
14224  of pairs of push/pop
14225 \begin_inset LatexCommand \index{push/pop}
14226
14227 \end_inset 
14228
14229  instructions in 
14230 \emph on 
14231 I
14232 \emph default 
14233 nterrupt
14234 \begin_inset LatexCommand \index{interrupt}
14235
14236 \end_inset 
14237
14238  
14239 \emph on 
14240 S
14241 \emph default 
14242 ervice 
14243 \emph on 
14244 R
14245 \emph default 
14246 outines.
14247  The directive should be placed immediately before the ISR function definition
14248  and it affects ALL ISR functions following it.
14249  To enable the normal register saving for ISR functions use #pragma\SpecialChar ~
14250 exclude\SpecialChar ~
14251 none
14252 \begin_inset LatexCommand \index{\#pragma exclude}
14253
14254 \end_inset 
14255
14256 .
14257  See also the related keyword _naked
14258 \begin_inset LatexCommand \index{\_naked}
14259
14260 \end_inset 
14261
14262 .
14263 \layout Itemize
14264
14265 less_pedantic
14266 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
14267
14268 \end_inset 
14269
14270  - the compiler will not warn you anymore for obvious mistakes, you'r on
14271  your own now ;-(
14272 \layout Itemize
14273
14274 disable_warning <nnnn>
14275 \begin_inset LatexCommand \index{\#pragma disable\_warning}
14276
14277 \end_inset 
14278
14279  - the compiler will not warn you anymore about warning number <nnnn>.
14280 \layout Itemize
14281
14282 nogcse
14283 \begin_inset LatexCommand \index{\#pragma nogcse}
14284
14285 \end_inset 
14286
14287  - will stop global common subexpression elimination.
14288 \layout Itemize
14289
14290 noinduction
14291 \begin_inset LatexCommand \index{\#pragma noinduction}
14292
14293 \end_inset 
14294
14295  - will stop loop induction optimizations.
14296 \layout Itemize
14297
14298 noinvariant
14299 \begin_inset LatexCommand \index{\#pragma noinvariant}
14300
14301 \end_inset 
14302
14303  - will not do loop invariant optimizations.
14304  For more details see Loop Invariants in section
14305 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
14306
14307 \end_inset 
14308
14309 .
14310 \layout Itemize
14311
14312 noiv
14313 \begin_inset LatexCommand \index{\#pragma noiv}
14314
14315 \end_inset 
14316
14317  - Do not generate interrupt
14318 \begin_inset LatexCommand \index{interrupt}
14319
14320 \end_inset 
14321
14322  vector table entries for all ISR functions defined after the pragma.
14323  This is useful in cases where the interrupt vector table must be defined
14324  manually, or when there is a secondary, manually defined interrupt vector
14325  table (e.g.
14326  for the autovector feature of the Cypress EZ-USB FX2).
14327  More elegantly this can be achieved by obmitting the optional interrupt
14328  number after the interrupt keyword, see section 
14329 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
14330
14331 \end_inset 
14332
14333 \SpecialChar ~
14334 about interrupts.
14335 \layout Itemize
14336
14337 nojtbound
14338 \begin_inset LatexCommand \index{\#pragma nojtbound}
14339
14340 \end_inset 
14341
14342  - will not generate code for boundary value checking, when switch statements
14343  are turned into jump-tables (dangerous).
14344  For more details see section 
14345 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
14346
14347 \end_inset 
14348
14349 .
14350 \layout Itemize
14351
14352 noloopreverse
14353 \begin_inset LatexCommand \index{\#pragma noloopreverse}
14354
14355 \end_inset 
14356
14357  - Will not do loop reversal optimization
14358 \layout Itemize
14359
14360 nooverlay
14361 \begin_inset LatexCommand \index{\#pragma nooverlay}
14362
14363 \end_inset 
14364
14365  - the compiler will not overlay the parameters and local variables of a
14366  function.
14367 \layout Itemize
14368
14369 stackauto
14370 \begin_inset LatexCommand \index{\#pragma stackauto}
14371
14372 \end_inset 
14373
14374 - See option -
14375 \begin_inset ERT
14376 status Collapsed
14377
14378 \layout Standard
14379
14380 \backslash 
14381 /
14382 \end_inset 
14383
14384 -stack-auto
14385 \begin_inset LatexCommand \index{-\/-stack-auto}
14386
14387 \end_inset 
14388
14389  and section 
14390 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
14391
14392 \end_inset 
14393
14394  Parameters and Local Variables.
14395 \layout Itemize
14396
14397 opt_code_speed 
14398 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
14399
14400 \end_inset 
14401
14402 - The compiler will optimize code generation towards fast code, possibly
14403  at the expense of code size.
14404 \layout Itemize
14405
14406 opt_code_size 
14407 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
14408
14409 \end_inset 
14410
14411 - The compiler will optimize code generation towards compact code, possibly
14412  at the expense of code speed.
14413 \layout Itemize
14414
14415 opt_code_balanced 
14416 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
14417
14418 \end_inset 
14419
14420 - The compiler will attempt to generate code that is both compact and fast,
14421  as long as meeting one goal is not a detriment to the other (this is the
14422  default).
14423  
14424 \layout Standard
14425
14426 SDCPP supports the following #pragma directives:
14427 \layout Itemize
14428
14429 preproc_asm
14430 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
14431
14432 \end_inset 
14433
14434  (+ | -) - switch _asm _endasm block preprocessing on / off.
14435  Default is on.
14436 \layout Standard
14437
14438 The pragma's are intended to be used to turn-on or off certain optimizations
14439  which might cause the compiler to generate extra stack / data space to
14440  store compiler generated temporary variables.
14441  This usually happens in large functions.
14442  Pragma directives should be used as shown in the following example, they
14443  are used to control options & optimizations for a given function; pragmas
14444  should be placed before and/or after a function, placing pragma's inside
14445  a function body could have unpredictable results.
14446 \layout Verse
14447
14448
14449 \family typewriter 
14450 #pragma save
14451 \begin_inset LatexCommand \index{\#pragma save}
14452
14453 \end_inset 
14454
14455  \SpecialChar ~
14456 \SpecialChar ~
14457 \SpecialChar ~
14458 \SpecialChar ~
14459 \SpecialChar ~
14460 \SpecialChar ~
14461 \SpecialChar ~
14462 /* save the current settings */ 
14463 \newline 
14464 #pragma nogcse
14465 \begin_inset LatexCommand \index{\#pragma nogcse}
14466
14467 \end_inset 
14468
14469  \SpecialChar ~
14470 \SpecialChar ~
14471 \SpecialChar ~
14472 \SpecialChar ~
14473 \SpecialChar ~
14474 /* turnoff global subexpression elimination */ 
14475 \newline 
14476 #pragma noinduction
14477 \begin_inset LatexCommand \index{\#pragma noinduction}
14478
14479 \end_inset 
14480
14481  /* turn off induction optimizations */ 
14482 \newline 
14483 int foo () 
14484 \newline 
14485
14486 \newline 
14487 \SpecialChar ~
14488  \SpecialChar ~
14489  ...
14490  
14491 \newline 
14492 \SpecialChar ~
14493  \SpecialChar ~
14494  /* large code */ 
14495 \newline 
14496 \SpecialChar ~
14497  \SpecialChar ~
14498  ...
14499  
14500 \newline 
14501
14502 \newline 
14503 #pragma restore
14504 \begin_inset LatexCommand \index{\#pragma restore}
14505
14506 \end_inset 
14507
14508  /* turn the optimizations back on */
14509 \layout Standard
14510
14511 The compiler will generate a warning message when extra space is allocated.
14512  It is strongly recommended that the save and restore pragma's be used when
14513  changing options for a function.
14514 \layout Section
14515
14516 Defines Created by the Compiler
14517 \layout Standard
14518
14519 The compiler creates the following #defines
14520 \begin_inset LatexCommand \index{\#defines}
14521
14522 \end_inset 
14523
14524
14525 \begin_inset LatexCommand \index{Defines created by the compiler}
14526
14527 \end_inset 
14528
14529 :
14530 \newline 
14531
14532 \layout Standard
14533
14534
14535 \begin_inset  Tabular
14536 <lyxtabular version="3" rows="10" columns="2">
14537 <features>
14538 <column alignment="center" valignment="top" leftline="true" width="0">
14539 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
14540 <row topline="true" bottomline="true">
14541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14542 \begin_inset Text
14543
14544 \layout Standard
14545
14546
14547 \series bold 
14548 #define
14549 \end_inset 
14550 </cell>
14551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14552 \begin_inset Text
14553
14554 \layout Standard
14555
14556
14557 \series bold 
14558 Description
14559 \end_inset 
14560 </cell>
14561 </row>
14562 <row topline="true">
14563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14564 \begin_inset Text
14565
14566 \layout Standard
14567
14568 SDCC
14569 \begin_inset LatexCommand \index{SDCC}
14570
14571 \end_inset 
14572
14573  
14574 \end_inset 
14575 </cell>
14576 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14577 \begin_inset Text
14578
14579 \layout Standard
14580
14581 this Symbol is always defined
14582 \end_inset 
14583 </cell>
14584 </row>
14585 <row topline="true">
14586 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14587 \begin_inset Text
14588
14589 \layout Standard
14590
14591 SDCC_mcs51
14592 \begin_inset LatexCommand \index{SDCC\_mcs51}
14593
14594 \end_inset 
14595
14596  or SDCC_ds390
14597 \begin_inset LatexCommand \index{SDCC\_ds390}
14598
14599 \end_inset 
14600
14601  or SDCC_z80
14602 \begin_inset LatexCommand \index{SDCC\_z80}
14603
14604 \end_inset 
14605
14606 , etc
14607 \end_inset 
14608 </cell>
14609 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14610 \begin_inset Text
14611
14612 \layout Standard
14613
14614 depending on the model used (e.g.: -mds390
14615 \end_inset 
14616 </cell>
14617 </row>
14618 <row topline="true">
14619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14620 \begin_inset Text
14621
14622 \layout Standard
14623
14624 __mcs51
14625 \begin_inset LatexCommand \index{\_\_mcs51}
14626
14627 \end_inset 
14628
14629 , __ds390
14630 \begin_inset LatexCommand \index{\_\_ds390}
14631
14632 \end_inset 
14633
14634 , __hc08
14635 \begin_inset LatexCommand \index{\_\_hc08}
14636
14637 \end_inset 
14638
14639 , __z80
14640 \begin_inset LatexCommand \index{\_\_z80}
14641
14642 \end_inset 
14643
14644 , etc
14645 \end_inset 
14646 </cell>
14647 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14648 \begin_inset Text
14649
14650 \layout Standard
14651
14652 depending on the model used (e.g.
14653  -mz80)
14654 \end_inset 
14655 </cell>
14656 </row>
14657 <row topline="true">
14658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14659 \begin_inset Text
14660
14661 \layout Standard
14662
14663 SDCC_STACK_AUTO
14664 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
14665
14666 \end_inset 
14667
14668
14669 \end_inset 
14670 </cell>
14671 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14672 \begin_inset Text
14673
14674 \layout Standard
14675
14676 when 
14677 \emph on 
14678 -
14679 \begin_inset ERT
14680 status Collapsed
14681
14682 \layout Standard
14683
14684 \backslash 
14685 /
14686 \end_inset 
14687
14688 -stack-auto
14689 \emph default 
14690  option is used
14691 \end_inset 
14692 </cell>
14693 </row>
14694 <row topline="true">
14695 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14696 \begin_inset Text
14697
14698 \layout Standard
14699
14700 SDCC_MODEL_SMALL
14701 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
14702
14703 \end_inset 
14704
14705
14706 \end_inset 
14707 </cell>
14708 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14709 \begin_inset Text
14710
14711 \layout Standard
14712
14713 when 
14714 \emph on 
14715 -
14716 \begin_inset ERT
14717 status Collapsed
14718
14719 \layout Standard
14720
14721 \backslash 
14722 /
14723 \end_inset 
14724
14725 -model-small
14726 \emph default 
14727  is used
14728 \end_inset 
14729 </cell>
14730 </row>
14731 <row topline="true">
14732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14733 \begin_inset Text
14734
14735 \layout Standard
14736
14737 SDCC_MODEL_LARGE
14738 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
14739
14740 \end_inset 
14741
14742
14743 \end_inset 
14744 </cell>
14745 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14746 \begin_inset Text
14747
14748 \layout Standard
14749
14750 when 
14751 \emph on 
14752 -
14753 \begin_inset ERT
14754 status Collapsed
14755
14756 \layout Standard
14757
14758 \backslash 
14759 /
14760 \end_inset 
14761
14762 -model-large
14763 \emph default 
14764  is used
14765 \end_inset 
14766 </cell>
14767 </row>
14768 <row topline="true">
14769 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14770 \begin_inset Text
14771
14772 \layout Standard
14773
14774 SDCC_USE_XSTACK
14775 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
14776
14777 \end_inset 
14778
14779
14780 \end_inset 
14781 </cell>
14782 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14783 \begin_inset Text
14784
14785 \layout Standard
14786
14787 when 
14788 \emph on 
14789 -
14790 \begin_inset ERT
14791 status Collapsed
14792
14793 \layout Standard
14794
14795 \backslash 
14796 /
14797 \end_inset 
14798
14799 -xstack
14800 \emph default 
14801  option is used
14802 \end_inset 
14803 </cell>
14804 </row>
14805 <row topline="true">
14806 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14807 \begin_inset Text
14808
14809 \layout Standard
14810
14811 SDCC_STACK_TENBIT
14812 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
14813
14814 \end_inset 
14815
14816  
14817 \end_inset 
14818 </cell>
14819 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14820 \begin_inset Text
14821
14822 \layout Standard
14823
14824 when 
14825 \emph on 
14826 -mds390
14827 \emph default 
14828  is used
14829 \end_inset 
14830 </cell>
14831 </row>
14832 <row topline="true" bottomline="true">
14833 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14834 \begin_inset Text
14835
14836 \layout Standard
14837
14838 SDCC_MODEL_FLAT24
14839 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
14840
14841 \end_inset 
14842
14843
14844 \end_inset 
14845 </cell>
14846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14847 \begin_inset Text
14848
14849 \layout Standard
14850
14851 when 
14852 \emph on 
14853 -mds390
14854 \emph default 
14855  is used
14856 \end_inset 
14857 </cell>
14858 </row>
14859 </lyxtabular>
14860
14861 \end_inset 
14862
14863
14864 \layout Chapter
14865
14866 Notes on supported Processors
14867 \layout Section
14868
14869 MCS51 variants
14870 \begin_inset LatexCommand \label{sub:MCS51-variants}
14871
14872 \end_inset 
14873
14874
14875 \begin_inset LatexCommand \index{MCS51 variants}
14876
14877 \end_inset 
14878
14879
14880 \layout Standard
14881
14882 MCS51 processors are available from many vendors and come in many different
14883  flavours.
14884  While they might differ considerably in respect to Special Function Registers
14885  the core MCS51 is usually not modified or is kept compatible.
14886  
14887 \layout Subsection
14888
14889 pdata access by SFR 
14890 \layout Standard
14891
14892 With the upcome of devices with internal xdata and flash memory devices
14893  using port P2
14894 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
14895
14896 \end_inset 
14897
14898  as dedicated I/O port is becoming more popular.
14899  Switching the high byte for pdata
14900 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
14901
14902 \end_inset 
14903
14904  access which was formerly done by port P2 is then achieved by a Special
14905  Function Register
14906 \begin_inset LatexCommand \index{sfr}
14907
14908 \end_inset 
14909
14910 .
14911  In well-established MCS51 tradition the address of this 
14912 \emph on 
14913 sfr
14914 \emph default 
14915  is where the chip designers decided to put it.
14916  Needless to say that they didn't agree on a common name either.
14917  So that the startup code can correctly initialize xdata variables, you
14918  should define an sfr with the name _XPAGE
14919 \family typewriter 
14920
14921 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
14922
14923 \end_inset 
14924
14925
14926 \family default 
14927  at the appropriate location if the default, port P2, is not used for this.
14928  Some examples are:
14929 \layout Verse
14930
14931
14932 \family typewriter 
14933 sfr at 0x92 _XPAGE; /* Cypress EZ-USB family */
14934 \layout Verse
14935
14936
14937 \family typewriter 
14938 sfr at 0xaf _XPAGE; /* some Silicon Labs (Cygnal) chips */
14939 \layout Verse
14940
14941
14942 \family typewriter 
14943 sfr at 0xaa _XPAGE; /* some Silicon Labs (Cygnal) chips */
14944 \layout Standard
14945
14946 For more exotic implementations further customizations may be needed.
14947  See section 
14948 \begin_inset LatexCommand \ref{sub:Startup-Code}
14949
14950 \end_inset 
14951
14952  for other possibilities.
14953 \layout Subsection
14954
14955 Other Features available by SFR
14956 \layout Standard
14957
14958 Some MCS51 variants offer features like Double DPTR
14959 \begin_inset LatexCommand \index{DPTR}
14960
14961 \end_inset 
14962
14963 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
14964  These are currently not used for the MCS51 port.
14965  If you absolutely need them you can fall back to inline assembly or submit
14966  a patch to SDCC.
14967 \layout Section
14968
14969 DS400 port
14970 \layout Standard
14971
14972 The DS80C400 microcontroller has a rich set of peripherals.
14973  In its built-in ROM library it includes functions to access some of the
14974  features, among them is a TCP stack with IP4 and IP6 support.
14975  Library headers (currently in beta status) and other files are provided
14976  at 
14977 \size footnotesize 
14978
14979 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
14980
14981 \end_inset 
14982
14983 .
14984  
14985 \layout Section
14986
14987 The Z80 and gbz80 port
14988 \layout Standard
14989
14990 SDCC can target both the Zilog 
14991 \begin_inset LatexCommand \index{Z80}
14992
14993 \end_inset 
14994
14995  and the Nintendo Gameboy's Z80-like gbz80
14996 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
14997
14998 \end_inset 
14999
15000 .
15001  The Z80 port is passed through the same 
15002 \emph on 
15003 regressions tests
15004 \begin_inset LatexCommand \index{Regression test}
15005
15006 \end_inset 
15007
15008
15009 \emph default 
15010  as the MCS51 and DS390 ports, so floating point support, support for long
15011  variables and bitfield support is fine.
15012  See mailing lists and forums about interrupt routines.
15013 \layout Standard
15014
15015 As always, the code is the authoritative reference - see z80/ralloc.c and
15016  z80/gen.c.
15017  The stack
15018 \begin_inset LatexCommand \index{stack}
15019
15020 \end_inset 
15021
15022  frame is similar to that generated by the IAR Z80 compiler.
15023  IX is used as the base pointer, HL and IY are used as a temporary registers,
15024  and BC and DE are available for holding variables.
15025  Return values
15026 \begin_inset LatexCommand \index{return value}
15027
15028 \end_inset 
15029
15030  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
15031  bytes).
15032  The gbz80 port use the same set of registers for the return values, but
15033  in a different order of significance: E (one byte), DE (two bytes), or
15034  HLDE (four bytes).
15035 \layout Section
15036
15037 The HC08 port
15038 \layout Standard
15039
15040 The port to the Motorola HC08
15041 \begin_inset LatexCommand \index{HC08}
15042
15043 \end_inset 
15044
15045  family has been added in October 2003, and is still undergoing some basic
15046  development.
15047  The code generator is complete, but the register allocation is still quite
15048  unoptimized.
15049  Some of the SDCC's standard C library functions have embedded non-HC08
15050  inline assembly and so are not yet usable.
15051 \newline 
15052
15053 \newline 
15054
15055 \layout Section
15056
15057 The PIC14 port
15058 \layout Standard
15059
15060 The 14bit PIC
15061 \begin_inset LatexCommand \index{PIC14}
15062
15063 \end_inset 
15064
15065  port still requires a major effort from the development community.
15066  However it can work for very simple code.
15067 \layout Subsection
15068
15069 C code and 14bit PIC code page
15070 \begin_inset LatexCommand \index{code page (pic14)}
15071
15072 \end_inset 
15073
15074  and RAM banks
15075 \begin_inset LatexCommand \index{RAM bank (pic14)}
15076
15077 \end_inset 
15078
15079
15080 \layout Standard
15081
15082 The linker organizes allocation for the code page and RAM banks.
15083  It does not have intimate knowledge of the code flow.
15084  It will put all the code section of a single asm file into a single code
15085  page.
15086  In order to make use of multiple code pages, separate asm files must be
15087  used.
15088  The compiler treats all functions of a single C file as being in the same
15089  code page unless it is non static.
15090  The compiler treats all local variables of a single C file as being in
15091  the same RAM bank unless it is an extern.
15092 \newline 
15093
15094 \newline 
15095 To get the best follow these guide lines:
15096 \layout Enumerate
15097
15098 make local functions static, as non static functions require code page selection
15099  overhead.
15100 \layout Enumerate
15101
15102 Make local variables static as extern variables require RAM bank selection
15103  overhead.
15104 \layout Enumerate
15105
15106 For devices that have multiple code pages it is more efficient to use the
15107  same number of files as pages, i.e.
15108  for the 16F877 use 4 separate files and i.e.
15109  for the 16F874 use 2 separate files.
15110  This way the linker can put the code for each file into different code
15111  pages and the compiler can allocate reusable variables more efficiently
15112  and there's less page selection overhead.
15113  And as for any 8 bit micro (especially for PIC 14 as they have a very simple
15114  instruction set) use 'unsigned char' whereever possible instead of 'int'.
15115 \layout Subsection
15116
15117 Creating a device include file 
15118 \layout Standard
15119
15120 For generating a device include file use the support perl script inc2h.pl
15121  kept in directory support/script.
15122 \layout Subsection
15123
15124 Interrupt code
15125 \layout Standard
15126
15127 For the interrupt function, use the keyword 'interrupt'
15128 \begin_inset LatexCommand \index{interrupt}
15129
15130 \end_inset 
15131
15132  with level number of 0 (PIC14 only has 1 interrupt so this number is only
15133  there to avoid a syntax error - it ought to be fixed).
15134  E.g.:
15135 \layout Verse
15136
15137
15138 \family typewriter 
15139 void Intr(void) interrupt 0
15140 \newline 
15141 {
15142 \newline 
15143 \SpecialChar ~
15144 \SpecialChar ~
15145 T0IF = 0; /* Clear timer interrupt */
15146 \newline 
15147 }
15148 \layout Subsection
15149
15150 Linking and assembling
15151 \layout Standard
15152
15153 For assembling you can use either GPUTILS'
15154 \begin_inset LatexCommand \index{gputils (pic tools)}
15155
15156 \end_inset 
15157
15158  gpasm.exe or MPLAB's mpasmwin.exe.
15159  GPUTILS is available from 
15160 \begin_inset LatexCommand \url{http://gputils.sourceforge.net/}
15161
15162 \end_inset 
15163
15164 .
15165  For linking you can use either GPUTIL's gplink or MPLAB's mplink.exe.
15166  If you use MPLAB and an interrupt function then the linker script file
15167  vectors section will need to be enlarged to link with mplink.
15168 \newline 
15169
15170 \newline 
15171 Here is a 
15172 \family typewriter 
15173 Makefile
15174 \family default 
15175  using GPUTILS:
15176 \layout Verse
15177
15178
15179 \family typewriter 
15180 .c.o:
15181 \newline 
15182 \SpecialChar ~
15183 \SpecialChar ~
15184 \SpecialChar ~
15185 \SpecialChar ~
15186 \SpecialChar ~
15187 \SpecialChar ~
15188 \SpecialChar ~
15189 \SpecialChar ~
15190 sdcc -S -V -mpic14 -p16F877 $< 
15191 \newline 
15192 \SpecialChar ~
15193 \SpecialChar ~
15194 \SpecialChar ~
15195 \SpecialChar ~
15196 \SpecialChar ~
15197 \SpecialChar ~
15198 \SpecialChar ~
15199 \SpecialChar ~
15200 gpasm -c $*.asm
15201 \newline 
15202
15203 \newline 
15204 $(PRJ).hex: $(OBJS) 
15205 \newline 
15206 \SpecialChar ~
15207 \SpecialChar ~
15208 \SpecialChar ~
15209 \SpecialChar ~
15210 \SpecialChar ~
15211 \SpecialChar ~
15212 \SpecialChar ~
15213 \SpecialChar ~
15214 gplink -m -s $(PRJ).lkr -o $(PRJ).hex $(OBJS)
15215 \layout Standard
15216
15217 Here is a 
15218 \family typewriter 
15219 Makefile
15220 \family default 
15221  using MPLAB:
15222 \layout Verse
15223
15224
15225 \family typewriter 
15226 .c.o: 
15227 \newline 
15228 \SpecialChar ~
15229 \SpecialChar ~
15230 \SpecialChar ~
15231 \SpecialChar ~
15232 \SpecialChar ~
15233 \SpecialChar ~
15234 \SpecialChar ~
15235 \SpecialChar ~
15236 sdcc -S -V -mpic14 -p16F877 $< 
15237 \newline 
15238 \SpecialChar ~
15239 \SpecialChar ~
15240 \SpecialChar ~
15241 \SpecialChar ~
15242 \SpecialChar ~
15243 \SpecialChar ~
15244 \SpecialChar ~
15245 \SpecialChar ~
15246 mpasmwin /q /o $*.asm
15247 \newline 
15248
15249 \newline 
15250 $(PRJ).hex: $(OBJS) 
15251 \newline 
15252 \SpecialChar ~
15253 \SpecialChar ~
15254 \SpecialChar ~
15255 \SpecialChar ~
15256 \SpecialChar ~
15257 \SpecialChar ~
15258 \SpecialChar ~
15259 \SpecialChar ~
15260 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS)
15261 \layout Standard
15262
15263 Please note that indentations within a
15264 \family typewriter 
15265  Makefile
15266 \family default 
15267  have to be done with a tabulator character.
15268 \layout Section
15269
15270 The PIC16
15271 \begin_inset LatexCommand \index{PIC16}
15272
15273 \end_inset 
15274
15275  port
15276 \layout Standard
15277
15278 The PIC16
15279 \begin_inset LatexCommand \index{PIC16}
15280
15281 \end_inset 
15282
15283  port is the portion of SDCC that is responsible to produce code for the
15284  Microchip
15285 \begin_inset LatexCommand \index{Microchip}
15286
15287 \end_inset 
15288
15289 (TM) microcontrollers with 16 bit core.
15290  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx.
15291 \layout Subsection
15292
15293 Global Options
15294 \layout Standard
15295
15296 PIC16 port supports the standard command line arguments as supposed, with
15297  the exception of certain cases that will be mentioned in the following
15298  list:
15299 \layout List
15300 \labelwidthstring 00.00.0000
15301
15302 -
15303 \begin_inset ERT
15304 status Collapsed
15305
15306 \layout Standard
15307
15308 \backslash 
15309 /
15310 \end_inset 
15311
15312 -callee-saves See -
15313 \begin_inset ERT
15314 status Collapsed
15315
15316 \layout Standard
15317
15318 \backslash 
15319 /
15320 \end_inset 
15321
15322 -all-callee-saves
15323 \layout List
15324 \labelwidthstring 00.00.0000
15325
15326 -
15327 \begin_inset ERT
15328 status Collapsed
15329
15330 \layout Standard
15331
15332 \backslash 
15333 /
15334 \end_inset 
15335
15336 -all-callee-saves All function arguments are passed on stack by default.
15337  
15338 \emph on 
15339 There is no need to specify this in the command line.
15340 \layout List
15341 \labelwidthstring 00.00.0000
15342
15343 -
15344 \begin_inset ERT
15345 status Collapsed
15346
15347 \layout Standard
15348
15349 \backslash 
15350 /
15351 \end_inset 
15352
15353 -fommit-frame-pointer Frame pointer will be omitted when the function uses
15354  no local variables.
15355 \layout Subsection
15356
15357 Port Specific Options
15358 \begin_inset LatexCommand \index{Options PIC16}
15359
15360 \end_inset 
15361
15362
15363 \layout Standard
15364
15365 The port specific options appear after the global options in the sdcc --help
15366  output.
15367 \layout Subsubsection
15368
15369 General Options
15370 \layout Standard
15371
15372 General options enable certain port features and optimizations.
15373 \layout List
15374 \labelwidthstring 00.00.0000
15375
15376 -
15377 \begin_inset ERT
15378 status Collapsed
15379
15380 \layout Standard
15381
15382 \backslash 
15383 /
15384 \end_inset 
15385
15386 -nodefaultlibs do not link default libraries when linking.
15387 \layout List
15388 \labelwidthstring 00.00.0000
15389
15390 -
15391 \begin_inset ERT
15392 status Collapsed
15393
15394 \layout Standard
15395
15396 \backslash 
15397 /
15398 \end_inset 
15399
15400 -obanksel=# Set optimization level for inserting BANKSELs.
15401 \begin_deeper 
15402 \layout List
15403 \labelwidthstring 00.00.0000
15404
15405 0 is no optimization
15406 \layout List
15407 \labelwidthstring 00.00.0000
15408
15409 1 checks previous used register and if it is the same then does not emit
15410  BANKSEL, accounts only for labels.
15411 \layout List
15412 \labelwidthstring 00.00.0000
15413
15414 2 tries to check the location of (even different) symbols and removes BANKSELs
15415  if they are in the same bank.
15416  Important: This will only work properly if the linker script does not have
15417  sections across bank borders!
15418 \end_deeper 
15419 \layout List
15420 \labelwidthstring 00.00.0000
15421
15422 -
15423 \begin_inset ERT
15424 status Collapsed
15425
15426 \layout Standard
15427
15428 \backslash 
15429 /
15430 \end_inset 
15431
15432 -pomit-config-words Omit the generation of the configuration words.
15433 \layout List
15434 \labelwidthstring 00.00.0000
15435
15436 -
15437 \begin_inset ERT
15438 status Collapsed
15439
15440 \layout Standard
15441
15442 \backslash 
15443 /
15444 \end_inset 
15445
15446 -pomit-ivt Omit the generation of the interrupt vectors.
15447 \layout List
15448 \labelwidthstring 00.00.0000
15449
15450 -
15451 \begin_inset ERT
15452 status Collapsed
15453
15454 \layout Standard
15455
15456 \backslash 
15457 /
15458 \end_inset 
15459
15460 -pleave-reset-vector Used in conjuction with -
15461 \begin_inset ERT
15462 status Collapsed
15463
15464 \layout Standard
15465
15466 \backslash 
15467 /
15468 \end_inset 
15469
15470 -pomit-ivt, instructs the port NOT to omit the reset vector.
15471 \layout List
15472 \labelwidthstring 00.00.0000
15473
15474 -
15475 \begin_inset ERT
15476 status Collapsed
15477
15478 \layout Standard
15479
15480 \backslash 
15481 /
15482 \end_inset 
15483
15484 -stack-model=[model] Used in conjuction with the command above.
15485  Defines the stack model to be used, valid stack models are : 
15486 \begin_deeper 
15487 \layout List
15488 \labelwidthstring 00.00.0000
15489
15490
15491 \emph on 
15492 small
15493 \emph default 
15494  Selects small stack model.
15495  8 bit stack and frame pointers.
15496  Supports 256 bytes stack size.
15497 \layout List
15498 \labelwidthstring 00.00.0000
15499
15500
15501 \emph on 
15502 large
15503 \emph default 
15504  Selects large stack model.
15505  16 bit stack and frame pointers.
15506  Supports 65536 bytes stack size.
15507 \end_deeper 
15508 \layout List
15509 \labelwidthstring 00.00.0000
15510
15511 -
15512 \begin_inset ERT
15513 status Collapsed
15514
15515 \layout Standard
15516
15517 \backslash 
15518 /
15519 \end_inset 
15520
15521 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
15522  unitialized data variables with [kword].
15523  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
15524 \layout List
15525 \labelwidthstring 00.00.0000
15526
15527 -
15528 \begin_inset ERT
15529 status Collapsed
15530
15531 \layout Standard
15532
15533 \backslash 
15534 /
15535 \end_inset 
15536
15537 -ivt-loc <nnnn> positions the Interrupt Vector Table at location <nnnn>.
15538  Useful for bootloaders.
15539 \layout List
15540 \labelwidthstring 00.00.0000
15541
15542 -
15543 \begin_inset ERT
15544 status Collapsed
15545
15546 \layout Standard
15547
15548 \backslash 
15549 /
15550 \end_inset 
15551
15552 -asm= sets the full path and name of an external assembler to call.
15553 \layout List
15554 \labelwidthstring 00.00.0000
15555
15556 -
15557 \begin_inset ERT
15558 status Collapsed
15559
15560 \layout Standard
15561
15562 \backslash 
15563 /
15564 \end_inset 
15565
15566 -link= sets the full path and name of an external linker to call.
15567 \layout List
15568 \labelwidthstring 00.00.0000
15569
15570 -
15571 \begin_inset ERT
15572 status Collapsed
15573
15574 \layout Standard
15575
15576 \backslash 
15577 /
15578 \end_inset 
15579
15580 -call-tree dump call tree in .calltree file
15581 \layout List
15582 \labelwidthstring 00.00.0000
15583
15584 -
15585 \begin_inset ERT
15586 status Collapsed
15587
15588 \layout Standard
15589
15590 \backslash 
15591 /
15592 \end_inset 
15593
15594 -mplab-comp MPLAB compatibility option.
15595  Currently only suppresses special gpasm directives.
15596 \layout List
15597 \labelwidthstring 00.00.0000
15598
15599 -
15600 \begin_inset ERT
15601 status Collapsed
15602
15603 \layout Standard
15604
15605 \backslash 
15606 /
15607 \end_inset 
15608
15609 -use-crt= Use a custom run-time module instead of the defaults.
15610 \layout List
15611 \labelwidthstring 00.00.0000
15612
15613 -
15614 \begin_inset ERT
15615 status Collapsed
15616
15617 \layout Standard
15618
15619 \backslash 
15620 /
15621 \end_inset 
15622
15623 -no-crt Don't link the default run-time modules
15624 \layout List
15625 \labelwidthstring 00.00.0000
15626
15627 -
15628 \begin_inset ERT
15629 status Collapsed
15630
15631 \layout Standard
15632
15633 \backslash 
15634 /
15635 \end_inset 
15636
15637 -optimize-goto Try to use (conditional) BRA instead of GOTO
15638 \layout Subsubsection
15639
15640 Debugging Options
15641 \layout Standard
15642
15643 Debugging options enable extra debugging information in the output files.
15644 \layout List
15645 \labelwidthstring 00.00.0000
15646
15647 -
15648 \begin_inset ERT
15649 status Collapsed
15650
15651 \layout Standard
15652
15653 \backslash 
15654 /
15655 \end_inset 
15656
15657 -debug-xtra Similar to -
15658 \begin_inset ERT
15659 status Collapsed
15660
15661 \layout Standard
15662
15663 \backslash 
15664 /
15665 \end_inset 
15666
15667 -debug
15668 \begin_inset LatexCommand \index{-\/-debug}
15669
15670 \end_inset 
15671
15672 , but dumps more information.
15673 \layout List
15674 \labelwidthstring 00.00.0000
15675
15676 -
15677 \begin_inset ERT
15678 status Collapsed
15679
15680 \layout Standard
15681
15682 \backslash 
15683 /
15684 \end_inset 
15685
15686 -debug-ralloc Force register allocator to dump <source>.d file with debugging
15687  information.
15688  <source> is the name of the file compiled.
15689 \layout List
15690 \labelwidthstring 00.00.0000
15691
15692 -
15693 \begin_inset ERT
15694 status Collapsed
15695
15696 \layout Standard
15697
15698 \backslash 
15699 /
15700 \end_inset 
15701
15702 -pcode-verbose Enable pcode debugging information in translation.
15703 \layout List
15704 \labelwidthstring 00.00.0000
15705
15706 -
15707 \begin_inset ERT
15708 status Collapsed
15709
15710 \layout Standard
15711
15712 \backslash 
15713 /
15714 \end_inset 
15715
15716 -denable-peeps Force the usage of peepholes.
15717  Use with care.
15718 \layout List
15719 \labelwidthstring 00.00.0000
15720
15721 -
15722 \begin_inset ERT
15723 status Collapsed
15724
15725 \layout Standard
15726
15727 \backslash 
15728 /
15729 \end_inset 
15730
15731 -gstack Trace push/pops for stack pointer overflow
15732 \layout Subsection
15733
15734 Preprocessor Macros
15735 \layout Standard
15736
15737 PIC16 port defines the following preprocessor macros while translating a
15738  source.
15739 \layout Standard
15740 \align center 
15741
15742 \begin_inset  Tabular
15743 <lyxtabular version="3" rows="2" columns="2">
15744 <features>
15745 <column alignment="center" valignment="top" leftline="true" width="0">
15746 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
15747 <row topline="true" bottomline="true">
15748 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15749 \begin_inset Text
15750
15751 \layout Standard
15752
15753 Macro
15754 \end_inset 
15755 </cell>
15756 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15757 \begin_inset Text
15758
15759 \layout Standard
15760
15761 Description
15762 \end_inset 
15763 </cell>
15764 </row>
15765 <row topline="true" bottomline="true">
15766 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15767 \begin_inset Text
15768
15769 \layout Standard
15770
15771 pic18fxxxx
15772 \end_inset 
15773 </cell>
15774 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15775 \begin_inset Text
15776
15777 \layout Standard
15778
15779 MCU Identification.
15780  
15781 \emph on 
15782 xxxx
15783 \emph default 
15784  is the microcontrol identification number, i.e.
15785  452, 6620, etc
15786 \end_inset 
15787 </cell>
15788 </row>
15789 </lyxtabular>
15790
15791 \end_inset 
15792
15793
15794 \layout Subsection
15795
15796 Directories
15797 \layout Standard
15798
15799 PIC16
15800 \begin_inset LatexCommand \index{PIC16}
15801
15802 \end_inset 
15803
15804  port uses the following directories for searching header files and libraries.
15805 \layout Standard
15806 \align center 
15807
15808 \begin_inset  Tabular
15809 <lyxtabular version="3" rows="3" columns="4">
15810 <features>
15811 <column alignment="center" valignment="top" leftline="true" width="0">
15812 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
15813 <column alignment="center" valignment="top" width="0">
15814 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
15815 <row topline="true" bottomline="true">
15816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15817 \begin_inset Text
15818
15819 \layout Standard
15820
15821 Directory
15822 \end_inset 
15823 </cell>
15824 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15825 \begin_inset Text
15826
15827 \layout Standard
15828
15829 Description
15830 \end_inset 
15831 </cell>
15832 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15833 \begin_inset Text
15834
15835 \layout Standard
15836
15837 Target
15838 \end_inset 
15839 </cell>
15840 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15841 \begin_inset Text
15842
15843 \layout Standard
15844
15845 Command prefix
15846 \end_inset 
15847 </cell>
15848 </row>
15849 <row topline="true">
15850 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15851 \begin_inset Text
15852
15853 \layout Standard
15854
15855 PREFIX/sdcc/include/pic16
15856 \end_inset 
15857 </cell>
15858 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15859 \begin_inset Text
15860
15861 \layout Standard
15862
15863 PIC16 specific headers
15864 \end_inset 
15865 </cell>
15866 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15867 \begin_inset Text
15868
15869 \layout Standard
15870
15871 Compiler
15872 \end_inset 
15873 </cell>
15874 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15875 \begin_inset Text
15876
15877 \layout Standard
15878
15879 -I
15880 \end_inset 
15881 </cell>
15882 </row>
15883 <row topline="true" bottomline="true">
15884 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15885 \begin_inset Text
15886
15887 \layout Standard
15888
15889 PREFIX/sdcc/lib/pic16
15890 \end_inset 
15891 </cell>
15892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15893 \begin_inset Text
15894
15895 \layout Standard
15896
15897 PIC16 specific libraries
15898 \end_inset 
15899 </cell>
15900 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15901 \begin_inset Text
15902
15903 \layout Standard
15904
15905 Linker
15906 \end_inset 
15907 </cell>
15908 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15909 \begin_inset Text
15910
15911 \layout Standard
15912
15913 -L
15914 \end_inset 
15915 </cell>
15916 </row>
15917 </lyxtabular>
15918
15919 \end_inset 
15920
15921
15922 \layout Subsection
15923
15924 Pragmas
15925 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
15926
15927 \end_inset 
15928
15929
15930 \layout Standard
15931
15932 PIC16 port currently supports the following pragmas:
15933 \layout List
15934 \labelwidthstring 00.00.0000
15935
15936 stack pragma stack forces the code generator to initialize the stack & frame
15937  pointers at a specific address.
15938  This is an adhoc solution for cases where no STACK directive is available
15939  in the linker script or gplink is not instructed to create a stack section.
15940 \newline 
15941 The stack pragma should be used only once in a project.
15942  Multiple pragmas may result in indeterminate behaviour of the program.
15943 \newline 
15944 The format is as follows:
15945 \layout LyX-Code
15946
15947 #pragma stack bottom_address [stack_size]
15948 \layout Standard
15949
15950
15951 \emph on 
15952 bottom_address
15953 \emph default 
15954  is the lower bound of the stack section.
15955  The stack pointer initially will point at address (bottom_address+stack_size-1).
15956 \layout LyX-Code
15957
15958 Example:
15959 \layout LyX-Code
15960
15961 \layout LyX-Code
15962
15963 /* initializes stack of 100 bytes at RAM address 0x200 */
15964 \layout LyX-Code
15965
15966 #pragma stack 0x200 100
15967 \layout List
15968 \labelwidthstring 00.00.0000
15969
15970 wparam use the WREG to pass one byte of the first function argument.
15971  This improves speed but you may not use this for functions with arguments
15972  that are called via function pointers, otherwise one byte of the first
15973  parameter will get lost.
15974  This pragma should be placed in the header file to propagate the calling
15975  convention to all callers.
15976 \layout LyX-Code
15977
15978 #pragma wparam function1[, function2, ...]
15979 \layout LyX-Code
15980
15981 \layout LyX-Code
15982
15983 Example:
15984 \layout LyX-Code
15985
15986 \layout LyX-Code
15987
15988 /* pass one byte via stack and one byte via WREG */
15989 \layout LyX-Code
15990
15991 #pragma wparam foo
15992 \layout LyX-Code
15993
15994 void foo(int x);
15995 \layout List
15996 \labelwidthstring 00.00.0000
15997
15998 code place a function symbol at static FLASH address
15999 \layout LyX-Code
16000
16001 Example:
16002 \layout LyX-Code
16003
16004 \layout LyX-Code
16005
16006 /* place function test_func at 0x4000 */
16007 \layout LyX-Code
16008
16009 #pragma code test_func 0x4000
16010 \layout List
16011 \labelwidthstring 00.00.0000
16012
16013 udata pragma udata instructs the compiler to emit code so that linker will
16014  place a variable at a specific memory bank
16015 \layout LyX-Code
16016
16017 Example:
16018 \layout LyX-Code
16019
16020 \layout LyX-Code
16021
16022 /* places variable foo at bank2 */
16023 \layout LyX-Code
16024
16025 #pragma udata bank2 foo
16026 \layout LyX-Code
16027
16028 char foo;
16029 \layout Standard
16030
16031 In order for this pragma to work there are some changes that must be made
16032  in the .lkr script used in link stage.
16033  In the following example a sample .lkr file is shown:
16034 \layout LyX-Code
16035
16036 \layout LyX-Code
16037
16038 // Sample linker script for the PIC18F452 processor
16039 \layout LyX-Code
16040
16041 LIBPATH .
16042 \layout LyX-Code
16043
16044 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
16045 \layout LyX-Code
16046
16047 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
16048 \layout LyX-Code
16049
16050 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
16051 \layout LyX-Code
16052
16053 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
16054 \layout LyX-Code
16055
16056 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
16057 \layout LyX-Code
16058
16059 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
16060 \layout LyX-Code
16061
16062 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
16063 \layout LyX-Code
16064
16065 \layout LyX-Code
16066
16067 DATABANK   NAME=gpr0       START=0x80           END=0xFF
16068 \layout LyX-Code
16069
16070 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
16071 \layout LyX-Code
16072
16073 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
16074 \layout LyX-Code
16075
16076 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
16077 \layout LyX-Code
16078
16079 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
16080 \layout LyX-Code
16081
16082 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
16083 \layout LyX-Code
16084
16085 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
16086 \layout LyX-Code
16087
16088 \layout LyX-Code
16089
16090 SECTION    NAME=CONFIG     ROM=config
16091 \layout LyX-Code
16092
16093 \layout LyX-Code
16094
16095 SECTION    NAME=bank0      RAM=gpr0
16096 \layout LyX-Code
16097
16098 SECTION    NAME=bank1      RAM=gpr1
16099 \layout LyX-Code
16100
16101 SECTION    NAME=bank2      RAM=gpr2
16102 \layout LyX-Code
16103
16104 SECTION    NAME=bank3      RAM=gpr3
16105 \layout LyX-Code
16106
16107 SECTION    NAME=bank4      RAM=gpr4
16108 \layout LyX-Code
16109
16110 SECTION    NAME=bank5      RAM=gpr5
16111 \layout Standard
16112
16113 The linker will recognise the section name set in the pragma statement and
16114  will position the variable at the memory bank set with the RAM field at
16115  the SECTION line in the linker script file.
16116 \layout Subsection
16117
16118 Header Files
16119 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
16120
16121 \end_inset 
16122
16123
16124 \layout Standard
16125
16126 There is one main header file that can be included to the source files using
16127  the pic16 port.
16128  That file is the 
16129 \series bold 
16130 pic18fregs.h
16131 \series default 
16132 .
16133  This header file contains the definitions for the processor special registers,
16134  so it is necessary if the source accesses them.
16135  It can be included by adding the following line in the beginning of the
16136  file:
16137 \layout LyX-Code
16138
16139 #include <pic18fregs.h>
16140 \layout Standard
16141
16142 The specific microcontroller is selected within the pic18fregs.h automatically,
16143  so the same source can be used with a variety of devices.
16144 \layout Subsection
16145
16146 Libraries
16147 \layout Standard
16148
16149 The libraries that PIC16
16150 \begin_inset LatexCommand \index{PIC16}
16151
16152 \end_inset 
16153
16154  port depends on are the microcontroller device libraries which contain
16155  the symbol definitions for the microcontroller special function registers.
16156  These libraries have the format pic18fxxxx.lib, where 
16157 \emph on 
16158 xxxx
16159 \emph default 
16160  is the microcontroller identification number.
16161  The specific library is selected automatically by the compiler at link
16162  stage according to the selected device.
16163 \layout Standard
16164
16165 Libraries are created with gplib which is part of the gputils package 
16166 \begin_inset LatexCommand \url{http://gputils.sourceforge.net}
16167
16168 \end_inset 
16169
16170 .
16171 \layout Subsection
16172
16173 Memory Models
16174 \layout Standard
16175
16176 The following memory models are supported by the PIC16 port:
16177 \layout Itemize
16178
16179 small model
16180 \layout Itemize
16181
16182 large model
16183 \layout Standard
16184
16185 Memory model affects the default size of pointers within the source.
16186  The sizes are shown in the next table:
16187 \layout Standard
16188 \align center 
16189
16190 \begin_inset  Tabular
16191 <lyxtabular version="3" rows="3" columns="3">
16192 <features>
16193 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
16194 <column alignment="center" valignment="top" leftline="true" width="0">
16195 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
16196 <row topline="true" bottomline="true">
16197 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16198 \begin_inset Text
16199
16200 \layout Standard
16201
16202 Pointer sizes according to memory model
16203 \end_inset 
16204 </cell>
16205 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16206 \begin_inset Text
16207
16208 \layout Standard
16209
16210 small model
16211 \end_inset 
16212 </cell>
16213 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16214 \begin_inset Text
16215
16216 \layout Standard
16217
16218 large model
16219 \end_inset 
16220 </cell>
16221 </row>
16222 <row topline="true" bottomline="true">
16223 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16224 \begin_inset Text
16225
16226 \layout Standard
16227
16228 code pointers
16229 \end_inset 
16230 </cell>
16231 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16232 \begin_inset Text
16233
16234 \layout Standard
16235
16236 16-bits
16237 \end_inset 
16238 </cell>
16239 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16240 \begin_inset Text
16241
16242 \layout Standard
16243
16244 24-bits
16245 \end_inset 
16246 </cell>
16247 </row>
16248 <row topline="true" bottomline="true">
16249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16250 \begin_inset Text
16251
16252 \layout Standard
16253
16254 data pointers
16255 \end_inset 
16256 </cell>
16257 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
16258 \begin_inset Text
16259
16260 \layout Standard
16261
16262 16-bits
16263 \end_inset 
16264 </cell>
16265 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16266 \begin_inset Text
16267
16268 \layout Standard
16269
16270 16-bits
16271 \end_inset 
16272 </cell>
16273 </row>
16274 </lyxtabular>
16275
16276 \end_inset 
16277
16278
16279 \layout Standard
16280
16281 It is advisable that all sources within a project are compiled with the
16282  same memory model.
16283  If one wants to override the default memory model, this can be done by
16284  declaring a pointer as 
16285 \series bold 
16286 far
16287 \series default 
16288  or 
16289 \series bold 
16290 near
16291 \series default 
16292 .
16293  Far selects large memory model's pointers, while near selects small memory
16294  model's pointers.
16295 \layout Standard
16296
16297 The standard device libraries (see 
16298 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
16299
16300 \end_inset 
16301
16302 ) contain no reference to pointers, so they can be used with both memory
16303  models.
16304 \layout Subsection
16305
16306 Stack
16307 \layout Standard
16308
16309 The stack implementation for the PIC16 port uses two indirect registers,
16310  FSR1 and FSR2.
16311 \layout List
16312 \labelwidthstring 00.00.0000
16313
16314 FSR1 is assigned as stack pointer
16315 \layout List
16316 \labelwidthstring 00.00.0000
16317
16318 FSR2 is assigned as frame pointer
16319 \layout Standard
16320
16321 The following stack models are supported by the PIC16 port
16322 \layout Itemize
16323
16324
16325 \noun on 
16326 small
16327 \noun default 
16328  model
16329 \layout Itemize
16330
16331
16332 \noun on 
16333 large
16334 \noun default 
16335  model
16336 \layout Standard
16337
16338
16339 \noun on 
16340 Small
16341 \noun default 
16342  model means that only the FSRxL byte is used to access stack and frame,
16343  while 
16344 \emph on 
16345 \noun on 
16346 large
16347 \emph default 
16348 \noun default 
16349  uses both FSRxL and FSRxH registers.
16350  The following table shows the stack/frame pointers sizes according to stack
16351  model and the maximum space they can address:
16352 \layout Standard
16353 \align center 
16354
16355 \begin_inset  Tabular
16356 <lyxtabular version="3" rows="3" columns="3">
16357 <features>
16358 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
16359 <column alignment="center" valignment="top" leftline="true" width="0">
16360 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
16361 <row topline="true" bottomline="true">
16362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16363 \begin_inset Text
16364
16365 \layout Standard
16366
16367 Stack & Frame pointer sizes according to stack model
16368 \end_inset 
16369 </cell>
16370 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16371 \begin_inset Text
16372
16373 \layout Standard
16374
16375 small
16376 \end_inset 
16377 </cell>
16378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16379 \begin_inset Text
16380
16381 \layout Standard
16382
16383 large
16384 \end_inset 
16385 </cell>
16386 </row>
16387 <row topline="true">
16388 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16389 \begin_inset Text
16390
16391 \layout Standard
16392
16393 Stack pointer FSR1
16394 \end_inset 
16395 </cell>
16396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16397 \begin_inset Text
16398
16399 \layout Standard
16400
16401 8-bits
16402 \end_inset 
16403 </cell>
16404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16405 \begin_inset Text
16406
16407 \layout Standard
16408
16409 16-bits
16410 \end_inset 
16411 </cell>
16412 </row>
16413 <row topline="true" bottomline="true">
16414 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16415 \begin_inset Text
16416
16417 \layout Standard
16418
16419 Frame pointer FSR2
16420 \end_inset 
16421 </cell>
16422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16423 \begin_inset Text
16424
16425 \layout Standard
16426
16427 8-bits
16428 \end_inset 
16429 </cell>
16430 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16431 \begin_inset Text
16432
16433 \layout Standard
16434
16435 16-bits
16436 \end_inset 
16437 </cell>
16438 </row>
16439 </lyxtabular>
16440
16441 \end_inset 
16442
16443
16444 \layout Standard
16445
16446
16447 \noun on 
16448 Large 
16449 \noun default 
16450 stack model is currently not working properly throughout the code generator.
16451  So its use is not advised.
16452  Also there are some other points that need special care:
16453 \layout Enumerate
16454
16455 Do not create stack sections with size more than one physical bank (that
16456  is 256 bytes)
16457 \layout Enumerate
16458
16459 Stack sections should no cross physical bank limits (i.e.
16460  #pragma stack 0x50 0x100)
16461 \layout Standard
16462
16463 These limitations are caused by the fact that only FSRxL is modified when
16464  using SMALL stack model, so no more than 256 bytes of stack can be used.
16465  This problem will disappear after LARGE model is fully implemented.
16466 \layout Subsection
16467
16468 Function return values
16469 \layout Standard
16470
16471 Return values from functions are placed to the appropriate registers following
16472  a modified Microchip policy optimized for SDCC.
16473  The following table shows these registers:
16474 \layout Standard
16475 \align center 
16476
16477 \begin_inset  Tabular
16478 <lyxtabular version="3" rows="6" columns="2">
16479 <features>
16480 <column alignment="center" valignment="top" leftline="true" width="0">
16481 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
16482 <row topline="true" bottomline="true">
16483 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16484 \begin_inset Text
16485
16486 \layout Standard
16487
16488 size
16489 \end_inset 
16490 </cell>
16491 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16492 \begin_inset Text
16493
16494 \layout Standard
16495
16496 destination register
16497 \end_inset 
16498 </cell>
16499 </row>
16500 <row topline="true">
16501 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16502 \begin_inset Text
16503
16504 \layout Standard
16505
16506 8 bits
16507 \end_inset 
16508 </cell>
16509 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16510 \begin_inset Text
16511
16512 \layout Standard
16513
16514 WREG
16515 \end_inset 
16516 </cell>
16517 </row>
16518 <row topline="true">
16519 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16520 \begin_inset Text
16521
16522 \layout Standard
16523
16524 16 bits
16525 \end_inset 
16526 </cell>
16527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16528 \begin_inset Text
16529
16530 \layout Standard
16531
16532 PRODL:WREG
16533 \end_inset 
16534 </cell>
16535 </row>
16536 <row topline="true">
16537 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16538 \begin_inset Text
16539
16540 \layout Standard
16541
16542 24 bits
16543 \end_inset 
16544 </cell>
16545 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16546 \begin_inset Text
16547
16548 \layout Standard
16549
16550 PRODH:PRODL:WREG
16551 \end_inset 
16552 </cell>
16553 </row>
16554 <row topline="true">
16555 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16556 \begin_inset Text
16557
16558 \layout Standard
16559
16560 32 bits
16561 \end_inset 
16562 </cell>
16563 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16564 \begin_inset Text
16565
16566 \layout Standard
16567
16568 FSR0L:PRODH:PRODL:WREG
16569 \end_inset 
16570 </cell>
16571 </row>
16572 <row topline="true" bottomline="true">
16573 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
16574 \begin_inset Text
16575
16576 \layout Standard
16577
16578 >32 bits
16579 \end_inset 
16580 </cell>
16581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
16582 \begin_inset Text
16583
16584 \layout Standard
16585
16586 on stack, FSR0 points to the beginning
16587 \end_inset 
16588 </cell>
16589 </row>
16590 </lyxtabular>
16591
16592 \end_inset 
16593
16594
16595 \layout Subsection
16596
16597 Interrupts
16598 \layout Standard
16599
16600 When entering an interrupt, currently the PIC16
16601 \begin_inset LatexCommand \index{PIC16}
16602
16603 \end_inset 
16604
16605  port automatically saves the following registers:
16606 \layout Itemize
16607
16608 WREG
16609 \layout Itemize
16610
16611 STATUS
16612 \layout Itemize
16613
16614 BSR
16615 \layout Itemize
16616
16617 PROD (PRODL and PRODH)
16618 \layout Itemize
16619
16620 FSR0 (FSR0L and FSR0H)
16621 \layout Standard
16622
16623 These registers are restored upon return from the interrupt routine.
16624  
16625 \layout Standard
16626
16627 When entering a high priority interrupt WREG, STATUS and BSR are not explicit
16628  saved by software.
16629  The hardware shadow registers for WREG, STATUS and BSR are used in these
16630  cases.
16631 \layout Standard
16632
16633
16634 \begin_inset Foot
16635 collapsed false
16636
16637 \layout Standard
16638
16639 NOTE that when the _naked attribute is specified for an interrupt routine,
16640  then NO registers are stored or restored.
16641 \end_inset 
16642
16643 .
16644 \layout Chapter
16645
16646 Debugging with SDCDB
16647 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
16648
16649 \end_inset 
16650
16651
16652 \begin_inset LatexCommand \index{sdcdb (debugger)}
16653
16654 \end_inset 
16655
16656  
16657 \layout Standard
16658
16659 SDCC is distributed with a source level debugger
16660 \begin_inset LatexCommand \index{Debugger}
16661
16662 \end_inset 
16663
16664 .
16665  The debugger uses a command line interface, the command repertoire of the
16666  debugger has been kept as close to gdb
16667 \begin_inset LatexCommand \index{gdb}
16668
16669 \end_inset 
16670
16671  (the GNU debugger) as possible.
16672  The configuration and build process is part of the standard compiler installati
16673 on, which also builds and installs the debugger in the target directory
16674  specified during configuration.
16675  The debugger allows you debug BOTH at the C source and at the ASM source
16676  level.
16677  Sdcdb is available on Unix platforms only.
16678 \layout Section
16679
16680 Compiling for Debugging
16681 \layout Standard
16682
16683 The -
16684 \begin_inset ERT
16685 status Collapsed
16686
16687 \layout Standard
16688
16689 \backslash 
16690 /
16691 \end_inset 
16692
16693 -debug
16694 \begin_inset LatexCommand \index{-\/-debug}
16695
16696 \end_inset 
16697
16698  option must be specified for all files for which debug information is to
16699  be generated.
16700  The complier generates a .adb file for each of these files.
16701  The linker creates the .cdb
16702 \begin_inset LatexCommand \index{<file>.cdb}
16703
16704 \end_inset 
16705
16706  file from the .adb
16707 \begin_inset LatexCommand \index{<file>.adb}
16708
16709 \end_inset 
16710
16711  files and the address information.
16712  This .cdb is used by the debugger.
16713 \layout Section
16714
16715 How the Debugger Works
16716 \layout Standard
16717
16718 When the -
16719 \begin_inset ERT
16720 status Collapsed
16721
16722 \layout Standard
16723
16724 \backslash 
16725 /
16726 \end_inset 
16727
16728 -debug option is specified the compiler generates extra symbol information
16729  some of which are put into the assembler source and some are put into the
16730  .adb file.
16731   Then the linker creates the .cdb file from the individual .adb files with
16732  the address information for the symbols.
16733  The debugger reads the symbolic information generated by the compiler &
16734  the address information generated by the linker.
16735  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
16736  execution is controlled by the debugger.
16737  When a command is issued for the debugger, it translates it into appropriate
16738  commands for the simulator.
16739 \layout Section
16740
16741 Starting the Debugger
16742 \layout Standard
16743
16744 The debugger can be started using the following command line.
16745  (Assume the file you are debugging has the file name foo).
16746 \newline 
16747
16748 \newline 
16749
16750 \family sans 
16751 \series bold 
16752 sdcdb foo
16753 \newline 
16754
16755 \family default 
16756 \series default 
16757
16758 \newline 
16759 The debugger will look for the following files.
16760 \layout Itemize
16761
16762 foo.c - the source file.
16763 \layout Itemize
16764
16765 foo.cdb - the debugger symbol information file.
16766 \layout Itemize
16767
16768 foo.ihx - the Intel hex format
16769 \begin_inset LatexCommand \index{Intel hex format}
16770
16771 \end_inset 
16772
16773  object file.
16774 \layout Section
16775
16776 Command Line Options.
16777 \layout Itemize
16778
16779 -
16780 \begin_inset ERT
16781 status Collapsed
16782
16783 \layout Standard
16784
16785 \backslash 
16786 /
16787 \end_inset 
16788
16789 -directory=<source file directory> this option can used to specify the directory
16790  search list.
16791  The debugger will look into the directory list specified for source, cdb
16792  & ihx files.
16793  The items in the directory list must be separated by ':', e.g.
16794  if the source files can be in the directories /home/src1 and /home/src2,
16795  the -
16796 \begin_inset ERT
16797 status Collapsed
16798
16799 \layout Standard
16800
16801 \backslash 
16802 /
16803 \end_inset 
16804
16805 -directory option should be -
16806 \begin_inset ERT
16807 status Collapsed
16808
16809 \layout Standard
16810
16811 \backslash 
16812 /
16813 \end_inset 
16814
16815 -directory=/home/src1:/home/src2.
16816  Note there can be no spaces in the option.
16817  
16818 \layout Itemize
16819
16820 -cd <directory> - change to the <directory>.
16821 \layout Itemize
16822
16823 -fullname - used by GUI front ends.
16824 \layout Itemize
16825
16826 -cpu <cpu-type> - this argument is passed to the simulator please see the
16827  simulator docs for details.
16828 \layout Itemize
16829
16830 -X <Clock frequency > this options is passed to the simulator please see
16831  the simulator docs for details.
16832 \layout Itemize
16833
16834 -s <serial port file> passed to simulator see the simulator docs for details.
16835 \layout Itemize
16836
16837 -S <serial in,out> passed to simulator see the simulator docs for details.
16838 \layout Itemize
16839
16840 -k <port number> passed to simulator see the simulator docs for details.
16841 \layout Section
16842
16843 Debugger Commands.
16844 \layout Standard
16845
16846 As mentioned earlier the command interface for the debugger has been deliberatel
16847 y kept as close the GNU debugger gdb, as possible.
16848  This will help the integration with existing graphical user interfaces
16849  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
16850  If you use a graphical user interface for the debugger you can skip the
16851  next sections.
16852 \layout Subsubsection*
16853
16854 break [line | file:line | function | file:function]
16855 \layout Standard
16856
16857 Set breakpoint at specified line or function:
16858 \newline 
16859
16860 \newline 
16861
16862 \family sans 
16863 \series bold 
16864 sdcdb>break 100 
16865 \newline 
16866 sdcdb>break foo.c:100
16867 \newline 
16868 sdcdb>break funcfoo
16869 \newline 
16870 sdcdb>break foo.c:funcfoo
16871 \layout Subsubsection*
16872
16873 clear [line | file:line | function | file:function ]
16874 \layout Standard
16875
16876 Clear breakpoint at specified line or function:
16877 \newline 
16878
16879 \newline 
16880
16881 \family sans 
16882 \series bold 
16883 sdcdb>clear 100
16884 \newline 
16885 sdcdb>clear foo.c:100
16886 \newline 
16887 sdcdb>clear funcfoo
16888 \newline 
16889 sdcdb>clear foo.c:funcfoo
16890 \layout Subsubsection*
16891
16892 continue
16893 \layout Standard
16894
16895 Continue program being debugged, after breakpoint.
16896 \layout Subsubsection*
16897
16898 finish
16899 \layout Standard
16900
16901 Execute till the end of the current function.
16902 \layout Subsubsection*
16903
16904 delete [n]
16905 \layout Standard
16906
16907 Delete breakpoint number 'n'.
16908  If used without any option clear ALL user defined break points.
16909 \layout Subsubsection*
16910
16911 info [break | stack | frame | registers ]
16912 \layout Itemize
16913
16914 info break - list all breakpoints
16915 \layout Itemize
16916
16917 info stack - show the function call stack.
16918 \layout Itemize
16919
16920 info frame - show information about the current execution frame.
16921 \layout Itemize
16922
16923 info registers - show content of all registers.
16924 \layout Subsubsection*
16925
16926 step
16927 \layout Standard
16928
16929 Step program until it reaches a different source line.
16930  Note: pressing <return> repeats the last command.
16931 \layout Subsubsection*
16932
16933 next
16934 \layout Standard
16935
16936 Step program, proceeding through subroutine calls.
16937 \layout Subsubsection*
16938
16939 run
16940 \layout Standard
16941
16942 Start debugged program.
16943 \layout Subsubsection*
16944
16945 ptype variable 
16946 \layout Standard
16947
16948 Print type information of the variable.
16949 \layout Subsubsection*
16950
16951 print variable
16952 \layout Standard
16953
16954 print value of variable.
16955 \layout Subsubsection*
16956
16957 file filename
16958 \layout Standard
16959
16960 load the given file name.
16961  Note this is an alternate method of loading file for debugging.
16962 \layout Subsubsection*
16963
16964 frame
16965 \layout Standard
16966
16967 print information about current frame.
16968 \layout Subsubsection*
16969
16970 set srcmode
16971 \layout Standard
16972
16973 Toggle between C source & assembly source.
16974 \layout Subsubsection*
16975
16976 ! simulator command
16977 \layout Standard
16978
16979 Send the string following '!' to the simulator, the simulator response is
16980  displayed.
16981  Note the debugger does not interpret the command being sent to the simulator,
16982  so if a command like 'go' is sent the debugger can loose its execution
16983  context and may display incorrect values.
16984 \layout Subsubsection*
16985
16986 quit
16987 \layout Standard
16988
16989 "Watch me now.
16990  Iam going Down.
16991  My name is Bobby Brown"
16992 \layout Section
16993
16994 Interfacing with XEmacs
16995 \begin_inset LatexCommand \index{XEmacs}
16996
16997 \end_inset 
16998
16999
17000 \begin_inset LatexCommand \index{Emacs}
17001
17002 \end_inset 
17003
17004 .
17005 \layout Standard
17006
17007 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
17008  sdcdb.el and sdcdbsrc.el.
17009  These two files can be found in the $(prefix)/bin directory after the installat
17010 ion is complete.
17011  These files need to be loaded into XEmacs for the interface to work.
17012  This can be done at XEmacs startup time by inserting the following into
17013  your '.xemacs' file (which can be found in your HOME directory): 
17014 \newline 
17015
17016 \newline 
17017
17018 \family typewriter 
17019 (load-file sdcdbsrc.el) 
17020 \family default 
17021
17022 \newline 
17023
17024 \newline 
17025 .xemacs is a lisp file so the () around the command is REQUIRED.
17026  The files can also be loaded dynamically while XEmacs is running, set the
17027  environment variable 'EMACSLOADPATH' to the installation bin directory
17028  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
17029  To start the interface enter the following command: 
17030 \newline 
17031
17032 \newline 
17033
17034 \family sans 
17035 \series bold 
17036 ESC-x sdcdbsrc
17037 \family default 
17038 \series default 
17039
17040 \newline 
17041
17042 \newline 
17043 You will prompted to enter the file name to be debugged.
17044  
17045 \newline 
17046
17047 \newline 
17048 The command line options that are passed to the simulator directly are bound
17049  to default values in the file sdcdbsrc.el.
17050  The variables are listed below, these values maybe changed as required.
17051 \layout Itemize
17052
17053 sdcdbsrc-cpu-type '51
17054 \layout Itemize
17055
17056 sdcdbsrc-frequency '11059200
17057 \layout Itemize
17058
17059 sdcdbsrc-serial nil
17060 \layout Standard
17061
17062 The following is a list of key mapping for the debugger interface.
17063 \layout Standard
17064
17065 \SpecialChar ~
17066
17067 \family typewriter 
17068
17069 \newline 
17070 ;;\SpecialChar ~
17071 Current Listing :: 
17072 \newline 
17073 ;;key\SpecialChar ~
17074 \SpecialChar ~
17075 \SpecialChar ~
17076 \SpecialChar ~
17077 \SpecialChar ~
17078 \SpecialChar ~
17079 \SpecialChar ~
17080 \SpecialChar ~
17081 \SpecialChar ~
17082 \SpecialChar ~
17083 \SpecialChar ~
17084 \SpecialChar ~
17085 \SpecialChar ~
17086 \SpecialChar ~
17087 binding\SpecialChar ~
17088 \SpecialChar ~
17089 \SpecialChar ~
17090 \SpecialChar ~
17091 \SpecialChar ~
17092 \SpecialChar ~
17093 \SpecialChar ~
17094 \SpecialChar ~
17095 \SpecialChar ~
17096 \SpecialChar ~
17097 \SpecialChar ~
17098 \SpecialChar ~
17099 \SpecialChar ~
17100 \SpecialChar ~
17101 \SpecialChar ~
17102 \SpecialChar ~
17103 \SpecialChar ~
17104 \SpecialChar ~
17105 \SpecialChar ~
17106 \SpecialChar ~
17107 \SpecialChar ~
17108 \SpecialChar ~
17109 Comment 
17110 \newline 
17111 ;;---\SpecialChar ~
17112 \SpecialChar ~
17113 \SpecialChar ~
17114 \SpecialChar ~
17115 \SpecialChar ~
17116 \SpecialChar ~
17117 \SpecialChar ~
17118 \SpecialChar ~
17119 \SpecialChar ~
17120 \SpecialChar ~
17121 \SpecialChar ~
17122 \SpecialChar ~
17123 \SpecialChar ~
17124 \SpecialChar ~
17125 -------\SpecialChar ~
17126 \SpecialChar ~
17127 \SpecialChar ~
17128 \SpecialChar ~
17129 \SpecialChar ~
17130 \SpecialChar ~
17131 \SpecialChar ~
17132 \SpecialChar ~
17133 \SpecialChar ~
17134 \SpecialChar ~
17135 \SpecialChar ~
17136 \SpecialChar ~
17137 \SpecialChar ~
17138 \SpecialChar ~
17139 \SpecialChar ~
17140 \SpecialChar ~
17141 \SpecialChar ~
17142 \SpecialChar ~
17143 \SpecialChar ~
17144 \SpecialChar ~
17145 \SpecialChar ~
17146 \SpecialChar ~
17147 -------
17148 \newline 
17149 ;; 
17150 \newline 
17151 ;;\SpecialChar ~
17152 n\SpecialChar ~
17153 \SpecialChar ~
17154 \SpecialChar ~
17155 \SpecialChar ~
17156 \SpecialChar ~
17157 \SpecialChar ~
17158 \SpecialChar ~
17159 \SpecialChar ~
17160 \SpecialChar ~
17161 \SpecialChar ~
17162 \SpecialChar ~
17163 \SpecialChar ~
17164 \SpecialChar ~
17165 \SpecialChar ~
17166 \SpecialChar ~
17167 sdcdb-next-from-src\SpecialChar ~
17168 \SpecialChar ~
17169 \SpecialChar ~
17170 \SpecialChar ~
17171 \SpecialChar ~
17172 \SpecialChar ~
17173 \SpecialChar ~
17174 \SpecialChar ~
17175 \SpecialChar ~
17176 \SpecialChar ~
17177 SDCDB next command 
17178 \newline 
17179 ;;\SpecialChar ~
17180 b\SpecialChar ~
17181 \SpecialChar ~
17182 \SpecialChar ~
17183 \SpecialChar ~
17184 \SpecialChar ~
17185 \SpecialChar ~
17186 \SpecialChar ~
17187 \SpecialChar ~
17188 \SpecialChar ~
17189 \SpecialChar ~
17190 \SpecialChar ~
17191 \SpecialChar ~
17192 \SpecialChar ~
17193 \SpecialChar ~
17194 \SpecialChar ~
17195 sdcdb-back-from-src\SpecialChar ~
17196 \SpecialChar ~
17197 \SpecialChar ~
17198 \SpecialChar ~
17199 \SpecialChar ~
17200 \SpecialChar ~
17201 \SpecialChar ~
17202 \SpecialChar ~
17203 \SpecialChar ~
17204 \SpecialChar ~
17205 SDCDB back command 
17206 \newline 
17207 ;;\SpecialChar ~
17208 c\SpecialChar ~
17209 \SpecialChar ~
17210 \SpecialChar ~
17211 \SpecialChar ~
17212 \SpecialChar ~
17213 \SpecialChar ~
17214 \SpecialChar ~
17215 \SpecialChar ~
17216 \SpecialChar ~
17217 \SpecialChar ~
17218 \SpecialChar ~
17219 \SpecialChar ~
17220 \SpecialChar ~
17221 \SpecialChar ~
17222 \SpecialChar ~
17223 sdcdb-cont-from-src\SpecialChar ~
17224 \SpecialChar ~
17225 \SpecialChar ~
17226 \SpecialChar ~
17227 \SpecialChar ~
17228 \SpecialChar ~
17229 \SpecialChar ~
17230 \SpecialChar ~
17231 \SpecialChar ~
17232 \SpecialChar ~
17233 SDCDB continue command
17234 \newline 
17235 ;;\SpecialChar ~
17236 s\SpecialChar ~
17237 \SpecialChar ~
17238 \SpecialChar ~
17239 \SpecialChar ~
17240 \SpecialChar ~
17241 \SpecialChar ~
17242 \SpecialChar ~
17243 \SpecialChar ~
17244 \SpecialChar ~
17245 \SpecialChar ~
17246 \SpecialChar ~
17247 \SpecialChar ~
17248 \SpecialChar ~
17249 \SpecialChar ~
17250 \SpecialChar ~
17251 sdcdb-step-from-src\SpecialChar ~
17252 \SpecialChar ~
17253 \SpecialChar ~
17254 \SpecialChar ~
17255 \SpecialChar ~
17256 \SpecialChar ~
17257 \SpecialChar ~
17258 \SpecialChar ~
17259 \SpecialChar ~
17260 \SpecialChar ~
17261 SDCDB step command 
17262 \newline 
17263 ;;\SpecialChar ~
17264 ?\SpecialChar ~
17265 \SpecialChar ~
17266 \SpecialChar ~
17267 \SpecialChar ~
17268 \SpecialChar ~
17269 \SpecialChar ~
17270 \SpecialChar ~
17271 \SpecialChar ~
17272 \SpecialChar ~
17273 \SpecialChar ~
17274 \SpecialChar ~
17275 \SpecialChar ~
17276 \SpecialChar ~
17277 \SpecialChar ~
17278 \SpecialChar ~
17279 sdcdb-whatis-c-sexp\SpecialChar ~
17280 \SpecialChar ~
17281 \SpecialChar ~
17282 \SpecialChar ~
17283 \SpecialChar ~
17284 \SpecialChar ~
17285 \SpecialChar ~
17286 \SpecialChar ~
17287 \SpecialChar ~
17288 \SpecialChar ~
17289 SDCDB ptypecommand for data at 
17290 \newline 
17291 ;;\SpecialChar ~
17292 \SpecialChar ~
17293 \SpecialChar ~
17294 \SpecialChar ~
17295 \SpecialChar ~
17296 \SpecialChar ~
17297 \SpecialChar ~
17298 \SpecialChar ~
17299 \SpecialChar ~
17300 \SpecialChar ~
17301 \SpecialChar ~
17302 \SpecialChar ~
17303 \SpecialChar ~
17304 \SpecialChar ~
17305 \SpecialChar ~
17306 \SpecialChar ~
17307 \SpecialChar ~
17308 \SpecialChar ~
17309 \SpecialChar ~
17310 \SpecialChar ~
17311 \SpecialChar ~
17312 \SpecialChar ~
17313 \SpecialChar ~
17314 \SpecialChar ~
17315 \SpecialChar ~
17316 \SpecialChar ~
17317 \SpecialChar ~
17318 \SpecialChar ~
17319 \SpecialChar ~
17320 \SpecialChar ~
17321 \SpecialChar ~
17322 \SpecialChar ~
17323 \SpecialChar ~
17324 \SpecialChar ~
17325 \SpecialChar ~
17326 \SpecialChar ~
17327 \SpecialChar ~
17328 \SpecialChar ~
17329 \SpecialChar ~
17330 \SpecialChar ~
17331 \SpecialChar ~
17332 \SpecialChar ~
17333 \SpecialChar ~
17334 \SpecialChar ~
17335 \SpecialChar ~
17336 \SpecialChar ~
17337 \SpecialChar ~
17338 buffer point 
17339 \newline 
17340 ;;\SpecialChar ~
17341 x\SpecialChar ~
17342 \SpecialChar ~
17343 \SpecialChar ~
17344 \SpecialChar ~
17345 \SpecialChar ~
17346 \SpecialChar ~
17347 \SpecialChar ~
17348 \SpecialChar ~
17349 \SpecialChar ~
17350 \SpecialChar ~
17351 \SpecialChar ~
17352 \SpecialChar ~
17353 \SpecialChar ~
17354 \SpecialChar ~
17355 \SpecialChar ~
17356 sdcdbsrc-delete\SpecialChar ~
17357 \SpecialChar ~
17358 \SpecialChar ~
17359 \SpecialChar ~
17360 \SpecialChar ~
17361 \SpecialChar ~
17362 \SpecialChar ~
17363 \SpecialChar ~
17364 \SpecialChar ~
17365 \SpecialChar ~
17366 \SpecialChar ~
17367 \SpecialChar ~
17368 \SpecialChar ~
17369 \SpecialChar ~
17370 SDCDB Delete all breakpoints if no arg 
17371 \newline 
17372 ;;\SpecialChar ~
17373 \SpecialChar ~
17374 \SpecialChar ~
17375 \SpecialChar ~
17376 \SpecialChar ~
17377 \SpecialChar ~
17378 \SpecialChar ~
17379 \SpecialChar ~
17380 \SpecialChar ~
17381 \SpecialChar ~
17382 \SpecialChar ~
17383 \SpecialChar ~
17384 \SpecialChar ~
17385 \SpecialChar ~
17386 \SpecialChar ~
17387 \SpecialChar ~
17388 \SpecialChar ~
17389 \SpecialChar ~
17390 \SpecialChar ~
17391 \SpecialChar ~
17392 \SpecialChar ~
17393 \SpecialChar ~
17394 \SpecialChar ~
17395 \SpecialChar ~
17396 \SpecialChar ~
17397 \SpecialChar ~
17398 \SpecialChar ~
17399 \SpecialChar ~
17400 \SpecialChar ~
17401 \SpecialChar ~
17402 \SpecialChar ~
17403 \SpecialChar ~
17404 \SpecialChar ~
17405 \SpecialChar ~
17406 \SpecialChar ~
17407 \SpecialChar ~
17408 \SpecialChar ~
17409 \SpecialChar ~
17410 \SpecialChar ~
17411 \SpecialChar ~
17412 \SpecialChar ~
17413 \SpecialChar ~
17414 \SpecialChar ~
17415 \SpecialChar ~
17416 \SpecialChar ~
17417 \SpecialChar ~
17418 \SpecialChar ~
17419 given or delete arg (C-u arg x) 
17420 \newline 
17421 ;;\SpecialChar ~
17422 m\SpecialChar ~
17423 \SpecialChar ~
17424 \SpecialChar ~
17425 \SpecialChar ~
17426 \SpecialChar ~
17427 \SpecialChar ~
17428 \SpecialChar ~
17429 \SpecialChar ~
17430 \SpecialChar ~
17431 \SpecialChar ~
17432 \SpecialChar ~
17433 \SpecialChar ~
17434 \SpecialChar ~
17435 \SpecialChar ~
17436 \SpecialChar ~
17437 sdcdbsrc-frame\SpecialChar ~
17438 \SpecialChar ~
17439 \SpecialChar ~
17440 \SpecialChar ~
17441 \SpecialChar ~
17442 \SpecialChar ~
17443 \SpecialChar ~
17444 \SpecialChar ~
17445 \SpecialChar ~
17446 \SpecialChar ~
17447 \SpecialChar ~
17448 \SpecialChar ~
17449 \SpecialChar ~
17450 \SpecialChar ~
17451 \SpecialChar ~
17452 SDCDB Display current frame if no arg, 
17453 \newline 
17454 ;;\SpecialChar ~
17455 \SpecialChar ~
17456 \SpecialChar ~
17457 \SpecialChar ~
17458 \SpecialChar ~
17459 \SpecialChar ~
17460 \SpecialChar ~
17461 \SpecialChar ~
17462 \SpecialChar ~
17463 \SpecialChar ~
17464 \SpecialChar ~
17465 \SpecialChar ~
17466 \SpecialChar ~
17467 \SpecialChar ~
17468 \SpecialChar ~
17469 \SpecialChar ~
17470 \SpecialChar ~
17471 \SpecialChar ~
17472 \SpecialChar ~
17473 \SpecialChar ~
17474 \SpecialChar ~
17475 \SpecialChar ~
17476 \SpecialChar ~
17477 \SpecialChar ~
17478 \SpecialChar ~
17479 \SpecialChar ~
17480 \SpecialChar ~
17481 \SpecialChar ~
17482 \SpecialChar ~
17483 \SpecialChar ~
17484 \SpecialChar ~
17485 \SpecialChar ~
17486 \SpecialChar ~
17487 \SpecialChar ~
17488 \SpecialChar ~
17489 \SpecialChar ~
17490 \SpecialChar ~
17491 \SpecialChar ~
17492 \SpecialChar ~
17493 \SpecialChar ~
17494 \SpecialChar ~
17495 \SpecialChar ~
17496 \SpecialChar ~
17497 \SpecialChar ~
17498 \SpecialChar ~
17499 \SpecialChar ~
17500 \SpecialChar ~
17501 given or display frame arg 
17502 \newline 
17503 ;;\SpecialChar ~
17504 \SpecialChar ~
17505 \SpecialChar ~
17506 \SpecialChar ~
17507 \SpecialChar ~
17508 \SpecialChar ~
17509 \SpecialChar ~
17510 \SpecialChar ~
17511 \SpecialChar ~
17512 \SpecialChar ~
17513 \SpecialChar ~
17514 \SpecialChar ~
17515 \SpecialChar ~
17516 \SpecialChar ~
17517 \SpecialChar ~
17518 \SpecialChar ~
17519 \SpecialChar ~
17520 \SpecialChar ~
17521 \SpecialChar ~
17522 \SpecialChar ~
17523 \SpecialChar ~
17524 \SpecialChar ~
17525 \SpecialChar ~
17526 \SpecialChar ~
17527 \SpecialChar ~
17528 \SpecialChar ~
17529 \SpecialChar ~
17530 \SpecialChar ~
17531 \SpecialChar ~
17532 \SpecialChar ~
17533 \SpecialChar ~
17534 \SpecialChar ~
17535 \SpecialChar ~
17536 \SpecialChar ~
17537 \SpecialChar ~
17538 \SpecialChar ~
17539 \SpecialChar ~
17540 \SpecialChar ~
17541 \SpecialChar ~
17542 \SpecialChar ~
17543 \SpecialChar ~
17544 \SpecialChar ~
17545 \SpecialChar ~
17546 \SpecialChar ~
17547 \SpecialChar ~
17548 \SpecialChar ~
17549 \SpecialChar ~
17550 buffer point 
17551 \newline 
17552 ;;\SpecialChar ~
17553 !\SpecialChar ~
17554 \SpecialChar ~
17555 \SpecialChar ~
17556 \SpecialChar ~
17557 \SpecialChar ~
17558 \SpecialChar ~
17559 \SpecialChar ~
17560 \SpecialChar ~
17561 \SpecialChar ~
17562 \SpecialChar ~
17563 \SpecialChar ~
17564 \SpecialChar ~
17565 \SpecialChar ~
17566 \SpecialChar ~
17567 \SpecialChar ~
17568 sdcdbsrc-goto-sdcdb\SpecialChar ~
17569 \SpecialChar ~
17570 \SpecialChar ~
17571 \SpecialChar ~
17572 \SpecialChar ~
17573 \SpecialChar ~
17574 \SpecialChar ~
17575 \SpecialChar ~
17576 \SpecialChar ~
17577 \SpecialChar ~
17578 Goto the SDCDB output buffer 
17579 \newline 
17580 ;;\SpecialChar ~
17581 p\SpecialChar ~
17582 \SpecialChar ~
17583 \SpecialChar ~
17584 \SpecialChar ~
17585 \SpecialChar ~
17586 \SpecialChar ~
17587 \SpecialChar ~
17588 \SpecialChar ~
17589 \SpecialChar ~
17590 \SpecialChar ~
17591 \SpecialChar ~
17592 \SpecialChar ~
17593 \SpecialChar ~
17594 \SpecialChar ~
17595 \SpecialChar ~
17596 sdcdb-print-c-sexp\SpecialChar ~
17597 \SpecialChar ~
17598 \SpecialChar ~
17599 \SpecialChar ~
17600 \SpecialChar ~
17601 \SpecialChar ~
17602 \SpecialChar ~
17603 \SpecialChar ~
17604 \SpecialChar ~
17605 \SpecialChar ~
17606 \SpecialChar ~
17607 SDCDB print command for data at 
17608 \newline 
17609 ;;\SpecialChar ~
17610 \SpecialChar ~
17611 \SpecialChar ~
17612 \SpecialChar ~
17613 \SpecialChar ~
17614 \SpecialChar ~
17615 \SpecialChar ~
17616 \SpecialChar ~
17617 \SpecialChar ~
17618 \SpecialChar ~
17619 \SpecialChar ~
17620 \SpecialChar ~
17621 \SpecialChar ~
17622 \SpecialChar ~
17623 \SpecialChar ~
17624 \SpecialChar ~
17625 \SpecialChar ~
17626 \SpecialChar ~
17627 \SpecialChar ~
17628 \SpecialChar ~
17629 \SpecialChar ~
17630 \SpecialChar ~
17631 \SpecialChar ~
17632 \SpecialChar ~
17633 \SpecialChar ~
17634 \SpecialChar ~
17635 \SpecialChar ~
17636 \SpecialChar ~
17637 \SpecialChar ~
17638 \SpecialChar ~
17639 \SpecialChar ~
17640 \SpecialChar ~
17641 \SpecialChar ~
17642 \SpecialChar ~
17643 \SpecialChar ~
17644 \SpecialChar ~
17645 \SpecialChar ~
17646 \SpecialChar ~
17647 \SpecialChar ~
17648 \SpecialChar ~
17649 \SpecialChar ~
17650 \SpecialChar ~
17651 \SpecialChar ~
17652 \SpecialChar ~
17653 \SpecialChar ~
17654 \SpecialChar ~
17655 \SpecialChar ~
17656 buffer point 
17657 \newline 
17658 ;;\SpecialChar ~
17659 g\SpecialChar ~
17660 \SpecialChar ~
17661 \SpecialChar ~
17662 \SpecialChar ~
17663 \SpecialChar ~
17664 \SpecialChar ~
17665 \SpecialChar ~
17666 \SpecialChar ~
17667 \SpecialChar ~
17668 \SpecialChar ~
17669 \SpecialChar ~
17670 \SpecialChar ~
17671 \SpecialChar ~
17672 \SpecialChar ~
17673 \SpecialChar ~
17674 sdcdbsrc-goto-sdcdb\SpecialChar ~
17675 \SpecialChar ~
17676 \SpecialChar ~
17677 \SpecialChar ~
17678 \SpecialChar ~
17679 \SpecialChar ~
17680 \SpecialChar ~
17681 \SpecialChar ~
17682 \SpecialChar ~
17683 \SpecialChar ~
17684 Goto the SDCDB output buffer 
17685 \newline 
17686 ;;\SpecialChar ~
17687 t\SpecialChar ~
17688 \SpecialChar ~
17689 \SpecialChar ~
17690 \SpecialChar ~
17691 \SpecialChar ~
17692 \SpecialChar ~
17693 \SpecialChar ~
17694 \SpecialChar ~
17695 \SpecialChar ~
17696 \SpecialChar ~
17697 \SpecialChar ~
17698 \SpecialChar ~
17699 \SpecialChar ~
17700 \SpecialChar ~
17701 \SpecialChar ~
17702 sdcdbsrc-mode\SpecialChar ~
17703 \SpecialChar ~
17704 \SpecialChar ~
17705 \SpecialChar ~
17706 \SpecialChar ~
17707 \SpecialChar ~
17708 \SpecialChar ~
17709 \SpecialChar ~
17710 \SpecialChar ~
17711 \SpecialChar ~
17712 \SpecialChar ~
17713 \SpecialChar ~
17714 \SpecialChar ~
17715 \SpecialChar ~
17716 \SpecialChar ~
17717 \SpecialChar ~
17718 Toggles Sdcdbsrc mode (turns it off) 
17719 \newline 
17720 ;; 
17721 \newline 
17722 ;;\SpecialChar ~
17723 C-c\SpecialChar ~
17724 C-f\SpecialChar ~
17725 \SpecialChar ~
17726 \SpecialChar ~
17727 \SpecialChar ~
17728 \SpecialChar ~
17729 \SpecialChar ~
17730 \SpecialChar ~
17731 \SpecialChar ~
17732 \SpecialChar ~
17733 sdcdb-finish-from-src\SpecialChar ~
17734 \SpecialChar ~
17735 \SpecialChar ~
17736 \SpecialChar ~
17737 \SpecialChar ~
17738 \SpecialChar ~
17739 \SpecialChar ~
17740 \SpecialChar ~
17741 SDCDB finish command 
17742 \newline 
17743 ;; 
17744 \newline 
17745 ;;\SpecialChar ~
17746 C-x\SpecialChar ~
17747 SPC\SpecialChar ~
17748 \SpecialChar ~
17749 \SpecialChar ~
17750 \SpecialChar ~
17751 \SpecialChar ~
17752 \SpecialChar ~
17753 \SpecialChar ~
17754 \SpecialChar ~
17755 \SpecialChar ~
17756 sdcdb-break\SpecialChar ~
17757 \SpecialChar ~
17758 \SpecialChar ~
17759 \SpecialChar ~
17760 \SpecialChar ~
17761 \SpecialChar ~
17762 \SpecialChar ~
17763 \SpecialChar ~
17764 \SpecialChar ~
17765 \SpecialChar ~
17766 \SpecialChar ~
17767 \SpecialChar ~
17768 \SpecialChar ~
17769 \SpecialChar ~
17770 \SpecialChar ~
17771 \SpecialChar ~
17772 \SpecialChar ~
17773 \SpecialChar ~
17774 Set break for line with point 
17775 \newline 
17776 ;;\SpecialChar ~
17777 ESC\SpecialChar ~
17778 t\SpecialChar ~
17779 \SpecialChar ~
17780 \SpecialChar ~
17781 \SpecialChar ~
17782 \SpecialChar ~
17783 \SpecialChar ~
17784 \SpecialChar ~
17785 \SpecialChar ~
17786 \SpecialChar ~
17787 \SpecialChar ~
17788 \SpecialChar ~
17789 sdcdbsrc-mode\SpecialChar ~
17790 \SpecialChar ~
17791 \SpecialChar ~
17792 \SpecialChar ~
17793 \SpecialChar ~
17794 \SpecialChar ~
17795 \SpecialChar ~
17796 \SpecialChar ~
17797 \SpecialChar ~
17798 \SpecialChar ~
17799 \SpecialChar ~
17800 \SpecialChar ~
17801 \SpecialChar ~
17802 \SpecialChar ~
17803 \SpecialChar ~
17804 \SpecialChar ~
17805 Toggle Sdcdbsrc mode 
17806 \newline 
17807 ;;\SpecialChar ~
17808 ESC\SpecialChar ~
17809 m\SpecialChar ~
17810 \SpecialChar ~
17811 \SpecialChar ~
17812 \SpecialChar ~
17813 \SpecialChar ~
17814 \SpecialChar ~
17815 \SpecialChar ~
17816 \SpecialChar ~
17817 \SpecialChar ~
17818 \SpecialChar ~
17819 \SpecialChar ~
17820 sdcdbsrc-srcmode\SpecialChar ~
17821 \SpecialChar ~
17822 \SpecialChar ~
17823 \SpecialChar ~
17824 \SpecialChar ~
17825 \SpecialChar ~
17826 \SpecialChar ~
17827 \SpecialChar ~
17828 \SpecialChar ~
17829 \SpecialChar ~
17830 \SpecialChar ~
17831 \SpecialChar ~
17832 \SpecialChar ~
17833 Toggle list mode 
17834 \newline 
17835 ;; 
17836 \newline 
17837
17838 \layout Chapter
17839 \pagebreak_top 
17840 TIPS
17841 \layout Standard
17842
17843 Here are a few guidelines that will help the compiler generate more efficient
17844  code, some of the tips are specific to this compiler others are generally
17845  good programming practice.
17846 \layout Itemize
17847
17848 Use the smallest data type to represent your data-value.
17849  If it is known in advance that the value is going to be less than 256 then
17850  use an 'unsigned char' instead of a 'short' or 'int'.
17851  Please note, that ANSI C requires both signed and unsigned chars to be
17852  promoted to 'signed int' before doing any operation.
17853  This promotion can be omitted, if the result is the same.
17854  The effect of the promotion rules together with the sign-extension is often
17855  surprising:
17856 \begin_deeper 
17857 \layout Verse
17858
17859
17860 \family typewriter 
17861 unsigned char uc = 0xfe;
17862 \newline 
17863 if (uc * uc < 0) /* this is true! */
17864 \newline 
17865 {
17866 \newline 
17867 \SpecialChar ~
17868 \SpecialChar ~
17869 \SpecialChar ~
17870 \SpecialChar ~
17871 ....
17872 \newline 
17873 }
17874 \layout Standard
17875
17876
17877 \family typewriter 
17878 uc * uc
17879 \family default 
17880  is evaluated as 
17881 \family typewriter 
17882 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
17883 \family default 
17884 .
17885  
17886 \newline 
17887 Another one:
17888 \layout Verse
17889
17890
17891 \family typewriter 
17892 (unsigned char) -12 / (signed char) -3 = ...
17893 \layout Standard
17894
17895 No, the result is not 4:
17896 \layout Verse
17897
17898
17899 \family typewriter 
17900 (int) (unsigned char) -12 / (int) (signed char) -3 =
17901 \newline 
17902 (int) (unsigned char) 0xf4 / (int) (signed char) 0xfd =
17903 \newline 
17904 (int) 0x00f4 / (int) 0xfffd =
17905 \newline 
17906 (int) 0x00f4 / (int) 0xfffd =
17907 \newline 
17908 (int) 244 / (int) -3 =
17909 \newline 
17910 (int) -81 = (int) 0xffaf;
17911 \layout Standard
17912
17913 Don't complain, that gcc gives you a different result.
17914  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
17915  Therefore the results are different.
17916 \newline 
17917 From 
17918 \begin_inset Quotes sld
17919 \end_inset 
17920
17921 comp.lang.c FAQ
17922 \begin_inset Quotes srd
17923 \end_inset 
17924
17925 :
17926 \layout Quote
17927
17928 If well-defined overflow characteristics are important and negative values
17929  are not, or if you want to steer clear of sign-extension problems when
17930  manipulating bits or bytes, use one of the corresponding unsigned types.
17931  (Beware when mixing signed and unsigned values in expressions, though.)
17932 \newline 
17933 Although character types (especially unsigned char) can be used as "tiny"
17934  integers, doing so is sometimes more trouble than it's worth, due to unpredicta
17935 ble sign extension and increased code size.
17936 \end_deeper 
17937 \layout Itemize
17938
17939 Use unsigned when it is known in advance that the value is not going to
17940  be negative.
17941  This helps especially if you are doing division or multiplication, bit-shifting
17942  or are using an array index.
17943 \layout Itemize
17944
17945 NEVER jump into a LOOP.
17946 \layout Itemize
17947
17948 Declare the variables to be local
17949 \begin_inset LatexCommand \index{local variables}
17950
17951 \end_inset 
17952
17953  whenever possible, especially loop control variables (induction).
17954 \layout Itemize
17955
17956 Since the compiler does not always do implicit integral promotion, the programme
17957 r should do an explicit cast when integral promotion is required.
17958 \layout Itemize
17959
17960 Reducing the size of division, multiplication & modulus operations can reduce
17961  code size substantially.
17962  Take the following code for example.
17963 \begin_deeper 
17964 \layout Verse
17965
17966
17967 \family typewriter 
17968 foobar(unsigned int p1, unsigned char ch)
17969 \newline 
17970 {
17971 \newline 
17972 \SpecialChar ~
17973 \SpecialChar ~
17974 \SpecialChar ~
17975 \SpecialChar ~
17976 unsigned char ch1 = p1 % ch ;
17977 \newline 
17978 \SpecialChar ~
17979 \SpecialChar ~
17980 \SpecialChar ~
17981 \SpecialChar ~
17982 ....
17983 \newline 
17984 }
17985 \layout Standard
17986
17987 For the modulus operation the variable ch will be promoted to unsigned int
17988  first then the modulus operation will be performed (this will lead to a
17989  call to support routine _moduint()), and the result will be casted to a
17990  char.
17991  If the code is changed to 
17992 \layout Verse
17993
17994
17995 \family typewriter 
17996 foobar(unsigned int p1, unsigned char ch)
17997 \newline 
17998 {
17999 \newline 
18000 \SpecialChar ~
18001 \SpecialChar ~
18002 \SpecialChar ~
18003 \SpecialChar ~
18004 unsigned char ch1 = (unsigned char)p1 % ch ;
18005 \newline 
18006 \SpecialChar ~
18007 \SpecialChar ~
18008 \SpecialChar ~
18009 \SpecialChar ~
18010 ....
18011 \newline 
18012 }
18013 \layout Standard
18014
18015 It would substantially reduce the code generated (future versions of the
18016  compiler will be smart enough to detect such optimization opportunities).
18017 \end_deeper 
18018 \layout Itemize
18019
18020 Have a look at the assembly listing to get a 
18021 \begin_inset Quotes sld
18022 \end_inset 
18023
18024 feeling
18025 \begin_inset Quotes srd
18026 \end_inset 
18027
18028  for the code generation.
18029 \layout Section
18030
18031 Tools
18032 \begin_inset LatexCommand \index{Tools}
18033
18034 \end_inset 
18035
18036  included in the distribution
18037 \layout Standard
18038 \align center 
18039
18040 \begin_inset  Tabular
18041 <lyxtabular version="3" rows="12" columns="3">
18042 <features>
18043 <column alignment="center" valignment="top" leftline="true" width="0pt">
18044 <column alignment="center" valignment="top" leftline="true" width="0pt">
18045 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
18046 <row topline="true" bottomline="true">
18047 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18048 \begin_inset Text
18049
18050 \layout Standard
18051
18052 Name
18053 \end_inset 
18054 </cell>
18055 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18056 \begin_inset Text
18057
18058 \layout Standard
18059
18060 Purpose
18061 \end_inset 
18062 </cell>
18063 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18064 \begin_inset Text
18065
18066 \layout Standard
18067
18068 Directory
18069 \end_inset 
18070 </cell>
18071 </row>
18072 <row topline="true">
18073 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18074 \begin_inset Text
18075
18076 \layout Standard
18077
18078 uCsim
18079 \end_inset 
18080 </cell>
18081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18082 \begin_inset Text
18083
18084 \layout Standard
18085
18086 Simulator for various architectures
18087 \end_inset 
18088 </cell>
18089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18090 \begin_inset Text
18091
18092 \layout Standard
18093
18094 sdcc/sim/ucsim
18095 \end_inset 
18096 </cell>
18097 </row>
18098 <row topline="true">
18099 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18100 \begin_inset Text
18101
18102 \layout Standard
18103
18104 keil2sdcc.pl
18105 \end_inset 
18106 </cell>
18107 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18108 \begin_inset Text
18109
18110 \layout Standard
18111
18112 header file conversion
18113 \end_inset 
18114 </cell>
18115 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18116 \begin_inset Text
18117
18118 \layout Standard
18119
18120 sdcc/support/scripts
18121 \end_inset 
18122 </cell>
18123 </row>
18124 <row topline="true">
18125 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18126 \begin_inset Text
18127
18128 \layout Standard
18129
18130 mh2h.c
18131 \end_inset 
18132 </cell>
18133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18134 \begin_inset Text
18135
18136 \layout Standard
18137
18138 header file conversion
18139 \end_inset 
18140 </cell>
18141 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18142 \begin_inset Text
18143
18144 \layout Standard
18145
18146 sdcc/support/scripts
18147 \end_inset 
18148 </cell>
18149 </row>
18150 <row topline="true">
18151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18152 \begin_inset Text
18153
18154 \layout Standard
18155
18156 as-gbz80
18157 \end_inset 
18158 </cell>
18159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18160 \begin_inset Text
18161
18162 \layout Standard
18163
18164 Assembler
18165 \end_inset 
18166 </cell>
18167 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18168 \begin_inset Text
18169
18170 \layout Standard
18171
18172
18173 \family roman 
18174 \series medium 
18175 \shape up 
18176 \size normal 
18177 \emph off 
18178 \bar no 
18179 \noun off 
18180 \color none
18181 sdcc/bin
18182 \end_inset 
18183 </cell>
18184 </row>
18185 <row topline="true">
18186 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18187 \begin_inset Text
18188
18189 \layout Standard
18190
18191 as-z80
18192 \end_inset 
18193 </cell>
18194 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18195 \begin_inset Text
18196
18197 \layout Standard
18198
18199 Assembler
18200 \end_inset 
18201 </cell>
18202 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18203 \begin_inset Text
18204
18205 \layout Standard
18206
18207
18208 \family roman 
18209 \series medium 
18210 \shape up 
18211 \size normal 
18212 \emph off 
18213 \bar no 
18214 \noun off 
18215 \color none
18216 sdcc/bin
18217 \end_inset 
18218 </cell>
18219 </row>
18220 <row topline="true">
18221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18222 \begin_inset Text
18223
18224 \layout Standard
18225
18226 asx8051
18227 \end_inset 
18228 </cell>
18229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18230 \begin_inset Text
18231
18232 \layout Standard
18233
18234 Assembler
18235 \end_inset 
18236 </cell>
18237 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18238 \begin_inset Text
18239
18240 \layout Standard
18241
18242
18243 \family roman 
18244 \series medium 
18245 \shape up 
18246 \size normal 
18247 \emph off 
18248 \bar no 
18249 \noun off 
18250 \color none
18251 sdcc/bin
18252 \end_inset 
18253 </cell>
18254 </row>
18255 <row topline="true">
18256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18257 \begin_inset Text
18258
18259 \layout Standard
18260
18261 sdcdb
18262 \end_inset 
18263 </cell>
18264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18265 \begin_inset Text
18266
18267 \layout Standard
18268
18269 Simulator
18270 \end_inset 
18271 </cell>
18272 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18273 \begin_inset Text
18274
18275 \layout Standard
18276
18277
18278 \family roman 
18279 \series medium 
18280 \shape up 
18281 \size normal 
18282 \emph off 
18283 \bar no 
18284 \noun off 
18285 \color none
18286 sdcc/bin
18287 \end_inset 
18288 </cell>
18289 </row>
18290 <row topline="true">
18291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18292 \begin_inset Text
18293
18294 \layout Standard
18295
18296 aslink
18297 \end_inset 
18298 </cell>
18299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18300 \begin_inset Text
18301
18302 \layout Standard
18303
18304 Linker
18305 \end_inset 
18306 </cell>
18307 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18308 \begin_inset Text
18309
18310 \layout Standard
18311
18312
18313 \family roman 
18314 \series medium 
18315 \shape up 
18316 \size normal 
18317 \emph off 
18318 \bar no 
18319 \noun off 
18320 \color none
18321 sdcc/bin
18322 \end_inset 
18323 </cell>
18324 </row>
18325 <row topline="true">
18326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18327 \begin_inset Text
18328
18329 \layout Standard
18330
18331 link-z80
18332 \end_inset 
18333 </cell>
18334 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18335 \begin_inset Text
18336
18337 \layout Standard
18338
18339 Linker
18340 \end_inset 
18341 </cell>
18342 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18343 \begin_inset Text
18344
18345 \layout Standard
18346
18347
18348 \family roman 
18349 \series medium 
18350 \shape up 
18351 \size normal 
18352 \emph off 
18353 \bar no 
18354 \noun off 
18355 \color none
18356 sdcc/bin
18357 \end_inset 
18358 </cell>
18359 </row>
18360 <row topline="true">
18361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18362 \begin_inset Text
18363
18364 \layout Standard
18365
18366 link-gbz80
18367 \end_inset 
18368 </cell>
18369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18370 \begin_inset Text
18371
18372 \layout Standard
18373
18374 Linker
18375 \end_inset 
18376 </cell>
18377 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18378 \begin_inset Text
18379
18380 \layout Standard
18381
18382
18383 \family roman 
18384 \series medium 
18385 \shape up 
18386 \size normal 
18387 \emph off 
18388 \bar no 
18389 \noun off 
18390 \color none
18391 sdcc/bin
18392 \end_inset 
18393 </cell>
18394 </row>
18395 <row topline="true" bottomline="true">
18396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18397 \begin_inset Text
18398
18399 \layout Standard
18400
18401 packihx
18402 \end_inset 
18403 </cell>
18404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18405 \begin_inset Text
18406
18407 \layout Standard
18408
18409 ihx packer
18410 \end_inset 
18411 </cell>
18412 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18413 \begin_inset Text
18414
18415 \layout Standard
18416
18417
18418 \family roman 
18419 \series medium 
18420 \shape up 
18421 \size normal 
18422 \emph off 
18423 \bar no 
18424 \noun off 
18425 \color none
18426 sdcc/bin
18427 \end_inset 
18428 </cell>
18429 </row>
18430 </lyxtabular>
18431
18432 \end_inset 
18433
18434
18435 \newline 
18436
18437 \layout Section
18438
18439 Documentation
18440 \begin_inset LatexCommand \index{Documentation}
18441
18442 \end_inset 
18443
18444  included in the distribution
18445 \layout Standard
18446 \align center 
18447
18448 \begin_inset  Tabular
18449 <lyxtabular version="3" rows="10" columns="2">
18450 <features>
18451 <column alignment="left" valignment="top" leftline="true" width="0">
18452 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
18453 <row topline="true" bottomline="true">
18454 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18455 \begin_inset Text
18456
18457 \layout Standard
18458
18459 Subject / Title
18460 \end_inset 
18461 </cell>
18462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18463 \begin_inset Text
18464
18465 \layout Standard
18466
18467 Where to get / filename
18468 \end_inset 
18469 </cell>
18470 </row>
18471 <row topline="true">
18472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18473 \begin_inset Text
18474
18475 \layout Standard
18476
18477 SDCC Compiler User Guide
18478 \end_inset 
18479 </cell>
18480 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18481 \begin_inset Text
18482
18483 \layout Standard
18484
18485 You're reading it right now
18486 \end_inset 
18487 </cell>
18488 </row>
18489 <row topline="true">
18490 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18491 \begin_inset Text
18492
18493 \layout Standard
18494
18495 Changelog of SDCC
18496 \end_inset 
18497 </cell>
18498 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18499 \begin_inset Text
18500
18501 \layout Standard
18502
18503 sdcc/Changelog
18504 \end_inset 
18505 </cell>
18506 </row>
18507 <row topline="true">
18508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18509 \begin_inset Text
18510
18511 \layout Standard
18512
18513 ASXXXX
18514 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
18515
18516 \end_inset 
18517
18518
18519 \begin_inset LatexCommand \index{Assembler documentation}
18520
18521 \end_inset 
18522
18523  Assemblers and ASLINK
18524 \begin_inset LatexCommand \index{aslink}
18525
18526 \end_inset 
18527
18528
18529 \begin_inset LatexCommand \index{Linker documentation}
18530
18531 \end_inset 
18532
18533  Relocating Linker
18534 \end_inset 
18535 </cell>
18536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18537 \begin_inset Text
18538
18539 \layout Standard
18540
18541 sdcc/as/doc/asxhtm.html
18542 \end_inset 
18543 </cell>
18544 </row>
18545 <row topline="true">
18546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18547 \begin_inset Text
18548
18549 \layout Standard
18550
18551 SDCC regression test
18552 \begin_inset LatexCommand \index{Regression test}
18553
18554 \end_inset 
18555
18556
18557 \end_inset 
18558 </cell>
18559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18560 \begin_inset Text
18561
18562 \layout Standard
18563
18564 sdcc/doc/test_suite_spec.pdf
18565 \end_inset 
18566 </cell>
18567 </row>
18568 <row topline="true">
18569 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18570 \begin_inset Text
18571
18572 \layout Standard
18573
18574 Various notes
18575 \end_inset 
18576 </cell>
18577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18578 \begin_inset Text
18579
18580 \layout Standard
18581
18582 sdcc/doc/*
18583 \end_inset 
18584 </cell>
18585 </row>
18586 <row topline="true">
18587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18588 \begin_inset Text
18589
18590 \layout Standard
18591
18592 Notes on debugging with sdcdb
18593 \begin_inset LatexCommand \index{sdcdb (debugger)}
18594
18595 \end_inset 
18596
18597
18598 \end_inset 
18599 </cell>
18600 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18601 \begin_inset Text
18602
18603 \layout Standard
18604
18605 sdcc/debugger/README
18606 \end_inset 
18607 </cell>
18608 </row>
18609 <row topline="true">
18610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18611 \begin_inset Text
18612
18613 \layout Standard
18614
18615 Software simulator for microcontrollers
18616 \end_inset 
18617 </cell>
18618 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18619 \begin_inset Text
18620
18621 \layout Standard
18622
18623
18624 \family roman 
18625 \series medium 
18626 \shape up 
18627 \size normal 
18628 \emph off 
18629 \bar no 
18630 \noun off 
18631 \color none
18632 sdcc/sim/ucsim/doc
18633 \family default 
18634 \series default 
18635 \shape default 
18636 \size default 
18637 \emph default 
18638 \bar default 
18639 \noun default 
18640 \color default
18641 /index.html
18642 \end_inset 
18643 </cell>
18644 </row>
18645 <row topline="true">
18646 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18647 \begin_inset Text
18648
18649 \layout Standard
18650
18651 Temporary notes on the pic16
18652 \begin_inset LatexCommand \index{PIC16}
18653
18654 \end_inset 
18655
18656  port
18657 \end_inset 
18658 </cell>
18659 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18660 \begin_inset Text
18661
18662 \layout Standard
18663
18664 sdcc/src/pic16/NOTES
18665 \end_inset 
18666 </cell>
18667 </row>
18668 <row topline="true" bottomline="true">
18669 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18670 \begin_inset Text
18671
18672 \layout Standard
18673
18674 SDCC internal documentation (debugging file format)
18675 \end_inset 
18676 </cell>
18677 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18678 \begin_inset Text
18679
18680 \layout Standard
18681
18682 sdcc/doc/
18683 \family roman 
18684 \series medium 
18685 \shape up 
18686 \size normal 
18687 \emph off 
18688 \bar no 
18689 \noun off 
18690 \color none
18691 cdbfileformat.pd
18692 \family default 
18693 \series default 
18694 \shape default 
18695 \size default 
18696 \emph default 
18697 \bar default 
18698 \noun default 
18699 \color default
18700 f
18701 \end_inset 
18702 </cell>
18703 </row>
18704 </lyxtabular>
18705
18706 \end_inset 
18707
18708
18709 \newline 
18710
18711 \layout Section
18712
18713 Related open source tools
18714 \begin_inset LatexCommand \index{Related tools}
18715
18716 \end_inset 
18717
18718
18719 \layout Standard
18720 \align center 
18721
18722 \begin_inset  Tabular
18723 <lyxtabular version="3" rows="11" columns="3">
18724 <features>
18725 <column alignment="center" valignment="top" leftline="true" width="0pt">
18726 <column alignment="block" valignment="top" leftline="true" width="30line%">
18727 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
18728 <row topline="true" bottomline="true">
18729 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18730 \begin_inset Text
18731
18732 \layout Standard
18733
18734 Name
18735 \end_inset 
18736 </cell>
18737 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18738 \begin_inset Text
18739
18740 \layout Standard
18741
18742 Purpose
18743 \end_inset 
18744 </cell>
18745 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18746 \begin_inset Text
18747
18748 \layout Standard
18749
18750 Where to get
18751 \end_inset 
18752 </cell>
18753 </row>
18754 <row topline="true">
18755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18756 \begin_inset Text
18757
18758 \layout Standard
18759
18760 gpsim
18761 \begin_inset LatexCommand \index{gpsim (pic simulator)}
18762
18763 \end_inset 
18764
18765
18766 \end_inset 
18767 </cell>
18768 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18769 \begin_inset Text
18770
18771 \layout Standard
18772
18773 PIC simulator
18774 \end_inset 
18775 </cell>
18776 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18777 \begin_inset Text
18778
18779 \layout Standard
18780
18781
18782 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
18783
18784 \end_inset 
18785
18786
18787 \end_inset 
18788 </cell>
18789 </row>
18790 <row topline="true">
18791 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18792 \begin_inset Text
18793
18794 \layout Standard
18795
18796 gputils
18797 \begin_inset LatexCommand \index{gputils (pic tools)}
18798
18799 \end_inset 
18800
18801
18802 \end_inset 
18803 </cell>
18804 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18805 \begin_inset Text
18806
18807 \layout Standard
18808
18809 GNU PIC utilities
18810 \end_inset 
18811 </cell>
18812 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18813 \begin_inset Text
18814
18815 \layout Standard
18816
18817
18818 \begin_inset LatexCommand \url{http://gputils.sourceforge.net/}
18819
18820 \end_inset 
18821
18822
18823 \end_inset 
18824 </cell>
18825 </row>
18826 <row topline="true">
18827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18828 \begin_inset Text
18829
18830 \layout Standard
18831
18832 flP5
18833 \end_inset 
18834 </cell>
18835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18836 \begin_inset Text
18837
18838 \layout Standard
18839
18840 PIC programmer
18841 \end_inset 
18842 </cell>
18843 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18844 \begin_inset Text
18845
18846 \layout Standard
18847
18848
18849 \begin_inset LatexCommand \url{http://digilander.libero.it/fbradasc/FLP5.html}
18850
18851 \end_inset 
18852
18853
18854 \end_inset 
18855 </cell>
18856 </row>
18857 <row topline="true">
18858 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18859 \begin_inset Text
18860
18861 \layout Standard
18862
18863 indent
18864 \begin_inset LatexCommand \index{indent (source formatting tool)}
18865
18866 \end_inset 
18867
18868
18869 \end_inset 
18870 </cell>
18871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18872 \begin_inset Text
18873
18874 \layout Standard
18875
18876 Formats C source - Master of the white spaces
18877 \end_inset 
18878 </cell>
18879 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18880 \begin_inset Text
18881
18882 \layout Standard
18883
18884
18885 \begin_inset LatexCommand \url{http://home.hccnet.nl/d.ingamells/beautify.html}
18886
18887 \end_inset 
18888
18889
18890 \end_inset 
18891 </cell>
18892 </row>
18893 <row topline="true">
18894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18895 \begin_inset Text
18896
18897 \layout Standard
18898
18899 srecord
18900 \begin_inset LatexCommand \index{srecord (tool)}
18901
18902 \end_inset 
18903
18904
18905 \end_inset 
18906 </cell>
18907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18908 \begin_inset Text
18909
18910 \layout Standard
18911
18912 Object file conversion, checksumming, ...
18913 \end_inset 
18914 </cell>
18915 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18916 \begin_inset Text
18917
18918 \layout Standard
18919
18920
18921 \begin_inset LatexCommand \url{http://srecord.sourceforge.net/}
18922
18923 \end_inset 
18924
18925
18926 \end_inset 
18927 </cell>
18928 </row>
18929 <row topline="true">
18930 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18931 \begin_inset Text
18932
18933 \layout Standard
18934
18935 objdump
18936 \begin_inset LatexCommand \index{objdump (tool)}
18937
18938 \end_inset 
18939
18940
18941 \end_inset 
18942 </cell>
18943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18944 \begin_inset Text
18945
18946 \layout Standard
18947
18948 Object file conversion, ...
18949 \end_inset 
18950 </cell>
18951 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18952 \begin_inset Text
18953
18954 \layout Standard
18955
18956 Part of binutils (should be there anyway)
18957 \end_inset 
18958 </cell>
18959 </row>
18960 <row topline="true">
18961 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18962 \begin_inset Text
18963
18964 \layout Standard
18965
18966 doxygen
18967 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
18968
18969 \end_inset 
18970
18971
18972 \end_inset 
18973 </cell>
18974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18975 \begin_inset Text
18976
18977 \layout Standard
18978
18979 Source code documentation system
18980 \end_inset 
18981 </cell>
18982 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18983 \begin_inset Text
18984
18985 \layout Standard
18986
18987
18988 \begin_inset LatexCommand \url{http://www.doxygen.org}
18989
18990 \end_inset 
18991
18992
18993 \end_inset 
18994 </cell>
18995 </row>
18996 <row topline="true">
18997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18998 \begin_inset Text
18999
19000 \layout Standard
19001
19002 kdevelop
19003 \end_inset 
19004 </cell>
19005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19006 \begin_inset Text
19007
19008 \layout Standard
19009
19010 IDE (has anyone tried integrating SDCC & sdcdb? Unix only)
19011 \end_inset 
19012 </cell>
19013 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19014 \begin_inset Text
19015
19016 \layout Standard
19017
19018
19019 \begin_inset LatexCommand \url{http://www.kdevelop.org}
19020
19021 \end_inset 
19022
19023
19024 \end_inset 
19025 </cell>
19026 </row>
19027 <row topline="true">
19028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19029 \begin_inset Text
19030
19031 \layout Standard
19032
19033 splint
19034 \begin_inset LatexCommand \index{splint (syntax checking tool)}
19035
19036 \end_inset 
19037
19038
19039 \end_inset 
19040 </cell>
19041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19042 \begin_inset Text
19043
19044 \layout Standard
19045
19046 Statically checks c sources (has anyone adapted splint for SDCC?)
19047 \end_inset 
19048 </cell>
19049 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19050 \begin_inset Text
19051
19052 \layout Standard
19053
19054
19055 \begin_inset LatexCommand \url{http://www.splint.org}
19056
19057 \end_inset 
19058
19059
19060 \end_inset 
19061 </cell>
19062 </row>
19063 <row topline="true" bottomline="true">
19064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19065 \begin_inset Text
19066
19067 \layout Standard
19068
19069 ddd
19070 \begin_inset LatexCommand \index{ddd (debugger)}
19071
19072 \end_inset 
19073
19074
19075 \end_inset 
19076 </cell>
19077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19078 \begin_inset Text
19079
19080 \layout Standard
19081
19082 Debugger, serves nicely as GUI to sdcdb
19083 \begin_inset LatexCommand \index{sdcdb (debugger)}
19084
19085 \end_inset 
19086
19087  (Unix only)
19088 \end_inset 
19089 </cell>
19090 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19091 \begin_inset Text
19092
19093 \layout Standard
19094
19095
19096 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
19097
19098 \end_inset 
19099
19100
19101 \end_inset 
19102 </cell>
19103 </row>
19104 </lyxtabular>
19105
19106 \end_inset 
19107
19108
19109 \newline 
19110
19111 \layout Section
19112
19113 Related documentation / recommended reading
19114 \layout Standard
19115 \align center 
19116
19117 \begin_inset  Tabular
19118 <lyxtabular version="3" rows="6" columns="3">
19119 <features>
19120 <column alignment="center" valignment="top" leftline="true" width="0pt">
19121 <column alignment="block" valignment="top" leftline="true" width="30line%">
19122 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
19123 <row topline="true" bottomline="true">
19124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19125 \begin_inset Text
19126
19127 \layout Standard
19128
19129 Name
19130 \end_inset 
19131 </cell>
19132 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19133 \begin_inset Text
19134
19135 \layout Standard
19136
19137 Subject / Title
19138 \end_inset 
19139 </cell>
19140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19141 \begin_inset Text
19142
19143 \layout Standard
19144
19145 Where to get
19146 \end_inset 
19147 </cell>
19148 </row>
19149 <row topline="true">
19150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19151 \begin_inset Text
19152
19153 \layout Standard
19154
19155
19156 \family roman 
19157 \series medium 
19158 \shape up 
19159 \size normal 
19160 \emph off 
19161 \bar no 
19162 \noun off 
19163 \color none
19164 c-refcard.pdf
19165 \end_inset 
19166 </cell>
19167 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19168 \begin_inset Text
19169
19170 \layout Standard
19171
19172 C Reference Card
19173 \begin_inset LatexCommand \index{C Reference card}
19174
19175 \end_inset 
19176
19177 , 2 pages
19178 \end_inset 
19179 </cell>
19180 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19181 \begin_inset Text
19182
19183 \layout Standard
19184
19185
19186 \begin_inset LatexCommand \url{http://www.refcards.com/about/c.html}
19187
19188 \end_inset 
19189
19190
19191 \end_inset 
19192 </cell>
19193 </row>
19194 <row topline="true">
19195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19196 \begin_inset Text
19197
19198 \layout Standard
19199
19200 c-faq
19201 \end_inset 
19202 </cell>
19203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19204 \begin_inset Text
19205
19206 \layout Standard
19207
19208 C-FAQ-list
19209 \end_inset 
19210 </cell>
19211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19212 \begin_inset Text
19213
19214 \layout Standard
19215
19216
19217 \begin_inset LatexCommand \url{http://www.eskimo.com/~scs/C-faq/top.html}
19218
19219 \end_inset 
19220
19221
19222 \end_inset 
19223 </cell>
19224 </row>
19225 <row topline="true">
19226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19227 \begin_inset Text
19228
19229 \layout Standard
19230
19231 \end_inset 
19232 </cell>
19233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19234 \begin_inset Text
19235
19236 \layout Standard
19237
19238 Latest datasheet of the target CPU
19239 \end_inset 
19240 </cell>
19241 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19242 \begin_inset Text
19243
19244 \layout Standard
19245
19246 vendor
19247 \end_inset 
19248 </cell>
19249 </row>
19250 <row topline="true">
19251 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19252 \begin_inset Text
19253
19254 \layout Standard
19255
19256 \end_inset 
19257 </cell>
19258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19259 \begin_inset Text
19260
19261 \layout Standard
19262
19263 Revision history of datasheet
19264 \end_inset 
19265 </cell>
19266 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19267 \begin_inset Text
19268
19269 \layout Standard
19270
19271 vendor
19272 \end_inset 
19273 </cell>
19274 </row>
19275 <row topline="true" bottomline="true">
19276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19277 \begin_inset Text
19278
19279 \layout Standard
19280
19281 S.
19282  S.
19283  Muchnick
19284 \end_inset 
19285 </cell>
19286 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19287 \begin_inset Text
19288
19289 \layout Standard
19290
19291 Advanced Compiler Design and Implementation
19292 \end_inset 
19293 </cell>
19294 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19295 \begin_inset Text
19296
19297 \layout Standard
19298
19299 bookstore (very dedicated, probably read other books first)
19300 \end_inset 
19301 </cell>
19302 </row>
19303 </lyxtabular>
19304
19305 \end_inset 
19306
19307
19308 \newline 
19309
19310 \layout Section
19311
19312 Some Questions
19313 \layout Standard
19314
19315 Some questions answered, some pointers given - it might be time to in turn
19316  ask 
19317 \emph on 
19318 you
19319 \emph default 
19320  some questions: 
19321 \layout Itemize
19322
19323 can you solve your project with the selected microcontroller? Would you
19324  find out early or rather late that your target is too small/slow/whatever?
19325  Can you switch to a slightly better device if it doesn't fit?
19326 \layout Itemize
19327
19328 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
19329  and/or another programming language be more adequate? Would an operating
19330  system on the target device help?
19331 \layout Itemize
19332
19333 if you solved the problem, will the marketing department be happy?
19334 \layout Itemize
19335
19336 if the marketing department is happy, will customers be happy?
19337 \layout Itemize
19338
19339 if you're the project manager, marketing department and maybe even the customer
19340  in one person, have you tried to see the project from the outside?
19341 \layout Itemize
19342
19343 is the project done if you think it is done? Or is just that other interface/pro
19344 tocol/feature/configuration/option missing? How about website, manual(s),
19345  internationali(z|s)ation, packaging, labels, 2nd source for components,
19346  electromagnetic compatability/interference, documentation for production,
19347  production test software, update mechanism, patent issues?
19348 \layout Itemize
19349
19350 is your project adequately positioned in that magic triangle: fame, fortune,
19351  fun?
19352 \layout Standard
19353
19354 Maybe not all answers to these questions are known and some answers may
19355  even be 
19356 \emph on 
19357 no
19358 \emph default 
19359 , nevertheless knowing these questions may help you to avoid burnout
19360 \begin_inset Foot
19361 collapsed false
19362
19363 \layout Standard
19364
19365 burnout is bad for electronic devices, programmers and motorcycle tyres
19366 \end_inset 
19367
19368 .
19369  Chances are you didn't want to hear some of them...
19370 \layout Chapter
19371
19372 Support
19373 \begin_inset LatexCommand \index{Support}
19374
19375 \end_inset 
19376
19377
19378 \layout Standard
19379
19380 SDCC has grown to be a large project.
19381  The compiler alone (without the preprocessor, assembler and linker) is
19382  well over 100,000 lines of code (blank stripped).
19383  The open source nature of this project is a key to its continued growth
19384  and support.
19385  You gain the benefit and support of many active software developers and
19386  end users.
19387  Is SDCC perfect? No, that's why we need your help.
19388  The developers take pride in fixing reported bugs.
19389  You can help by reporting the bugs and helping other SDCC users.
19390  There are lots of ways to contribute, and we encourage you to take part
19391  in making SDCC a great software package.
19392  
19393 \layout Standard
19394
19395 The SDCC project is hosted on the SDCC sourceforge site at 
19396 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
19397
19398 \end_inset 
19399
19400 .
19401  You'll find the complete set of mailing lists
19402 \begin_inset LatexCommand \index{Mailing list(s)}
19403
19404 \end_inset 
19405
19406 , forums, bug reporting system, patch submission
19407 \begin_inset LatexCommand \index{Patch submission}
19408
19409 \end_inset 
19410
19411  system, download
19412 \begin_inset LatexCommand \index{download}
19413
19414 \end_inset 
19415
19416  area and cvs code repository
19417 \begin_inset LatexCommand \index{cvs code repository}
19418
19419 \end_inset 
19420
19421  there.
19422 \layout Section
19423
19424 Reporting Bugs
19425 \begin_inset LatexCommand \index{Bug reporting}
19426
19427 \end_inset 
19428
19429
19430 \begin_inset LatexCommand \index{Reporting bugs}
19431
19432 \end_inset 
19433
19434
19435 \layout Standard
19436
19437 The recommended way of reporting bugs is using the infrastructure of the
19438  sourceforge site.
19439  You can follow the status of bug reports there and have an overview about
19440  the known bugs.
19441 \layout Standard
19442
19443 Bug reports are automatically forwarded to the developer mailing list and
19444  will be fixed ASAP.
19445  When reporting a bug, it is very useful to include a small test program
19446  (the smaller the better) which reproduces the problem.
19447  If you can isolate the problem by looking at the generated assembly code,
19448  this can be very helpful.
19449  Compiling your program with the -
19450 \begin_inset ERT
19451 status Collapsed
19452
19453 \layout Standard
19454
19455 \backslash 
19456 /
19457 \end_inset 
19458
19459 -dumpall
19460 \begin_inset LatexCommand \index{-\/-dumpall}
19461
19462 \end_inset 
19463
19464  option can sometimes be useful in locating optimization problems.
19465  When reporting a bug please maker sure you:
19466 \layout Enumerate
19467
19468 Attach the code you are compiling with SDCC.
19469  
19470 \layout Enumerate
19471
19472 Specify the exact command you use to run SDCC, or attach your Makefile.
19473  
19474 \layout Enumerate
19475
19476 Specify the SDCC version (type "
19477 \family sans 
19478 \series bold 
19479 sdcc -v
19480 \family default 
19481 \series default 
19482 "), your platform, and operating system.
19483  
19484 \layout Enumerate
19485
19486 Provide an exact copy of any error message or incorrect output.
19487  
19488 \layout Enumerate
19489
19490 Put something meaningful in the subject of your message.
19491 \layout Standard
19492
19493 Please attempt to include these 5 important parts, as applicable, in all
19494  requests for support or when reporting any problems or bugs with SDCC.
19495  Though this will make your message lengthy, it will greatly improve your
19496  chance that SDCC users and developers will be able to help you.
19497  Some SDCC developers are frustrated by bug reports without code provided
19498  that they can use to reproduce and ultimately fix the problem, so please
19499  be sure to provide sample code if you are reporting a bug! 
19500 \layout Standard
19501
19502 Please have a short check that you are using a recent version of SDCC and
19503  the bug is not yet known.
19504  This is the link for reporting bugs: 
19505 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
19506
19507 \end_inset 
19508
19509 .
19510 \layout Section
19511
19512 Requesting Features
19513 \begin_inset LatexCommand \label{sub:Requesting-Features}
19514
19515 \end_inset 
19516
19517
19518 \begin_inset LatexCommand \index{Feature request}
19519
19520 \end_inset 
19521
19522
19523 \begin_inset LatexCommand \index{Requesting features}
19524
19525 \end_inset 
19526
19527
19528 \layout Standard
19529
19530 Like bug reports feature requests are forwarded to the developer mailing
19531  list.
19532  This is the link for requesting features: 
19533 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
19534
19535 \end_inset 
19536
19537 .
19538 \layout Section
19539
19540 Submitting patches
19541 \layout Standard
19542
19543 Like bug reports contributed patches are forwarded to the developer mailing
19544  list.
19545  This is the link for submitting patches
19546 \begin_inset LatexCommand \index{Patch submission}
19547
19548 \end_inset 
19549
19550
19551 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
19552
19553 \end_inset 
19554
19555 .
19556 \layout Standard
19557
19558 You need to specify some parameters to the 
19559 \family typewriter 
19560 diff
19561 \family default 
19562  command for the patches to be useful.
19563  If you modified more than one file a patch created f.e.
19564  with 
19565 \family sans 
19566 \series bold 
19567
19568 \begin_inset Quotes sld
19569 \end_inset 
19570
19571 diff -Naur unmodified_directory modified_directory >my_changes.patch
19572 \begin_inset Quotes srd
19573 \end_inset 
19574
19575
19576 \family default 
19577 \series default 
19578  will be fine, otherwise 
19579 \family sans 
19580 \series bold 
19581
19582 \begin_inset Quotes sld
19583 \end_inset 
19584
19585 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
19586 \begin_inset Quotes srd
19587 \end_inset 
19588
19589
19590 \series default 
19591  
19592 \family default 
19593 will do.
19594 \layout Section
19595
19596 Getting Help
19597 \layout Standard
19598
19599 These links should take you directly to the 
19600 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
19601
19602 \end_inset 
19603
19604
19605 \begin_inset Foot
19606 collapsed false
19607
19608 \layout Standard
19609
19610 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
19611  automated messages (mid 2003)
19612 \end_inset 
19613
19614  and the 
19615 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
19616
19617 \end_inset 
19618
19619 , lists
19620 \begin_inset LatexCommand \index{Mailing list(s)}
19621
19622 \end_inset 
19623
19624  and forums are archived and searchable so if you are lucky someone already
19625  had a similar problem.
19626  While mails to the lists themselves are delivered promptly their web front
19627  end on sourceforge sometimes shows a severe time lag (up to several weeks),
19628  if you're seriously using SDCC please consider subscribing to the lists.
19629 \layout Section
19630
19631 ChangeLog
19632 \layout Standard
19633
19634 You can follow the status of the cvs version
19635 \begin_inset LatexCommand \index{version}
19636
19637 \end_inset 
19638
19639  of SDCC by watching the Changelog
19640 \begin_inset LatexCommand \index{Changelog}
19641
19642 \end_inset 
19643
19644  in the cvs-repository
19645 \newline 
19646
19647 \size footnotesize 
19648
19649 \begin_inset LatexCommand \htmlurl{http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sdcc/sdcc/ChangeLog?rev=HEAD&content-type=text/plain}
19650
19651 \end_inset 
19652
19653 .
19654 \layout Section
19655
19656 Release policy
19657 \begin_inset LatexCommand \index{Release policy}
19658
19659 \end_inset 
19660
19661
19662 \layout Standard
19663
19664 Historically there often were long delays between official releases and
19665  the sourceforge download area tends to get not updated at all.
19666  Excuses in the past might have referred to problems with live range analysis,
19667  but as this was fixed a while ago, the current problem is that another
19668  excuse has to be found.
19669  Kidding aside, we have to get better there! On the other hand there are
19670  daily snapshots available at 
19671 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
19672
19673 \end_inset 
19674
19675 , and you can always build the very last version (hopefully with many bugs
19676  fixed, and features added) from the source code available at 
19677 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
19678
19679 \end_inset 
19680
19681 .
19682 \layout Section
19683
19684 Examples
19685 \begin_inset LatexCommand \index{Examples}
19686
19687 \end_inset 
19688
19689
19690 \layout Standard
19691
19692 You'll find some small examples in the directory 
19693 \emph on 
19694 sdcc/device/examples/.
19695  
19696 \emph default 
19697 More examples and libraries are available at
19698 \emph on 
19699  The SDCC Open Knowledge Resource 
19700 \begin_inset LatexCommand \url{http://www.qsl.net/dl9sec/SDCC_OKR.html}
19701
19702 \end_inset 
19703
19704  
19705 \emph default 
19706 web site or at 
19707 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
19708
19709 \end_inset 
19710
19711 .
19712 \layout Comment
19713
19714 I did insert a reference to Paul's web site here although it seems rather
19715  dedicated to a specific 8032 board (I think it's okay because it f.e.
19716  shows LCD/Harddisc interface and has a free 8051 monitor.
19717  Independent 8032 board vendors face hard competition of heavily subsidized
19718  development boards anyway).
19719 \layout Comment
19720
19721 Maybe we should include some links to real world applications.
19722  Preferably pointer to pointers (one for each architecture) so this stays
19723  manageable here?
19724 \layout Section
19725
19726 Quality control
19727 \begin_inset LatexCommand \index{Quality control}
19728
19729 \end_inset 
19730
19731
19732 \layout Standard
19733
19734 The compiler is passed through nightly compile and build checks.
19735  The so called 
19736 \shape italic 
19737 regression tests
19738 \shape default 
19739
19740 \begin_inset LatexCommand \index{Regression test}
19741
19742 \end_inset 
19743
19744  check that SDCC itself compiles flawlessly on several platforms and checks
19745  the quality of the code generated by SDCC by running the code through simulator
19746 s.
19747  There is a separate document 
19748 \shape italic 
19749 test_suite.pdf
19750 \begin_inset LatexCommand \index{Test suite}
19751
19752 \end_inset 
19753
19754
19755 \shape default 
19756  about this.
19757 \layout Standard
19758
19759 You'll find the test code in the directory 
19760 \shape italic 
19761 sdcc/support/regression
19762 \shape default 
19763 .
19764  You can run these tests manually by running 
19765 \family sans 
19766 make
19767 \family default 
19768  in this directory (or f.e.
19769  
19770 \family sans 
19771 \series bold 
19772
19773 \begin_inset Quotes sld
19774 \end_inset 
19775
19776 make test-mcs51
19777 \begin_inset Quotes srd
19778 \end_inset 
19779
19780
19781 \family default 
19782 \series default 
19783  if you don't want to run the complete tests).
19784  The test code might also be interesting if you want to look for examples
19785 \begin_inset LatexCommand \index{Examples}
19786
19787 \end_inset 
19788
19789  checking corner cases of SDCC or if you plan to submit patches
19790 \begin_inset LatexCommand \index{Patch submission}
19791
19792 \end_inset 
19793
19794 .
19795 \layout Standard
19796
19797 The pic port uses a different set of regression tests, you'll find them
19798  in the directory 
19799 \shape italic 
19800 sdcc/src/regression
19801 \shape default 
19802 .
19803 \layout Chapter
19804 \pagebreak_top 
19805 SDCC Technical Data
19806 \layout Section
19807
19808 Optimizations
19809 \begin_inset LatexCommand \index{Optimizations}
19810
19811 \end_inset 
19812
19813
19814 \layout Standard
19815
19816 SDCC performs a host of standard optimizations in addition to some MCU specific
19817  optimizations.
19818  
19819 \layout Subsection
19820
19821 Sub-expression Elimination
19822 \begin_inset LatexCommand \index{Subexpression elimination}
19823
19824 \end_inset 
19825
19826
19827 \layout Standard
19828
19829 The compiler does local and 
19830 \emph on 
19831 g
19832 \emph default 
19833 lobal 
19834 \emph on 
19835 c
19836 \emph default 
19837 ommon 
19838 \emph on 
19839 s
19840 \emph default 
19841 ubexpression 
19842 \emph on 
19843 e
19844 \emph default 
19845 limination, e.g.: 
19846 \layout Verse
19847
19848
19849 \family typewriter 
19850 i = x + y + 1; 
19851 \newline 
19852 j = x + y;
19853 \layout Standard
19854
19855 will be translated to
19856 \layout Verse
19857
19858
19859 \family typewriter 
19860 iTemp = x + y; 
19861 \newline 
19862 i = iTemp + 1; 
19863 \newline 
19864 j = iTemp;
19865 \layout Standard
19866
19867 Some subexpressions are not as obvious as the above example, e.g.:
19868 \layout Verse
19869
19870
19871 \family typewriter 
19872 a->b[i].c = 10; 
19873 \newline 
19874 a->b[i].d = 11;
19875 \layout Standard
19876
19877 In this case the address arithmetic a->b[i] will be computed only once;
19878  the equivalent code in C would be.
19879 \layout Verse
19880
19881
19882 \family typewriter 
19883 iTemp = a->b[i]; 
19884 \newline 
19885 iTemp.c = 10; 
19886 \newline 
19887 iTemp.d = 11;
19888 \layout Standard
19889
19890 The compiler will try to keep these temporary variables in registers.
19891 \layout Subsection
19892
19893 Dead-Code Elimination
19894 \begin_inset LatexCommand \index{Dead-code elimination}
19895
19896 \end_inset 
19897
19898
19899 \layout Verse
19900
19901
19902 \family typewriter 
19903 int global;
19904 \newline 
19905
19906 \newline 
19907 void f () { 
19908 \newline 
19909 \SpecialChar ~
19910 \SpecialChar ~
19911 int i; 
19912 \newline 
19913 \SpecialChar ~
19914 \SpecialChar ~
19915 i = 1; \SpecialChar ~
19916 \SpecialChar ~
19917 \SpecialChar ~
19918 \SpecialChar ~
19919 \SpecialChar ~
19920 /* dead store */ 
19921 \newline 
19922 \SpecialChar ~
19923 \SpecialChar ~
19924 global = 1;\SpecialChar ~
19925 /* dead store */ 
19926 \newline 
19927 \SpecialChar ~
19928 \SpecialChar ~
19929 global = 2; 
19930 \newline 
19931 \SpecialChar ~
19932 \SpecialChar ~
19933 return; 
19934 \newline 
19935 \SpecialChar ~
19936 \SpecialChar ~
19937 global = 3;\SpecialChar ~
19938 /* unreachable */ 
19939 \newline 
19940 }
19941 \layout Standard
19942
19943 will be changed to
19944 \layout Verse
19945
19946
19947 \family typewriter 
19948 int global;
19949 \newline 
19950
19951 \newline 
19952 void f () {
19953 \newline 
19954 \SpecialChar ~
19955 \SpecialChar ~
19956 global = 2; 
19957 \newline 
19958 }
19959 \layout Subsection
19960
19961 Copy-Propagation
19962 \begin_inset LatexCommand \index{Copy propagation}
19963
19964 \end_inset 
19965
19966
19967 \layout Verse
19968
19969
19970 \family typewriter 
19971 int f() { 
19972 \newline 
19973 \SpecialChar ~
19974 \SpecialChar ~
19975 int i, j; 
19976 \newline 
19977 \SpecialChar ~
19978 \SpecialChar ~
19979 i = 10; 
19980 \newline 
19981 \SpecialChar ~
19982 \SpecialChar ~
19983 j = i; 
19984 \newline 
19985 \SpecialChar ~
19986 \SpecialChar ~
19987 return j; 
19988 \newline 
19989 }
19990 \layout Standard
19991
19992 will be changed to 
19993 \layout Verse
19994
19995
19996 \family typewriter 
19997 int f() { 
19998 \newline 
19999 \SpecialChar ~
20000 \SpecialChar ~
20001 int i, j; 
20002 \newline 
20003 \SpecialChar ~
20004 \SpecialChar ~
20005 i = 10; 
20006 \newline 
20007 \SpecialChar ~
20008 \SpecialChar ~
20009 j = 10; 
20010 \newline 
20011 \SpecialChar ~
20012 \SpecialChar ~
20013 return 10; 
20014 \newline 
20015 }
20016 \layout Standard
20017
20018 Note: the dead stores created by this copy propagation will be eliminated
20019  by dead-code elimination.
20020 \layout Subsection
20021
20022 Loop Optimizations
20023 \begin_inset LatexCommand \index{Loop optimization}
20024
20025 \end_inset 
20026
20027
20028 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
20029
20030 \end_inset 
20031
20032
20033 \layout Standard
20034
20035 Two types of loop optimizations are done by SDCC 
20036 \emph on 
20037 loop invariant
20038 \emph default 
20039  lifting and
20040 \emph on 
20041  strength reduction
20042 \emph default 
20043  of loop induction variables.
20044  In addition to the strength reduction the optimizer marks the induction
20045  variables and the register allocator tries to keep the induction variables
20046  in registers for the duration of the loop.
20047  Because of this preference of the register allocator
20048 \begin_inset LatexCommand \index{Register allocation}
20049
20050 \end_inset 
20051
20052 , loop induction optimization causes an increase in register pressure, which
20053  may cause unwanted spilling of other temporary variables into the stack
20054 \begin_inset LatexCommand \index{stack}
20055
20056 \end_inset 
20057
20058  / data space.
20059  The compiler will generate a warning message when it is forced to allocate
20060  extra space either on the stack or data space.
20061  If this extra space allocation is undesirable then induction optimization
20062  can be eliminated either for the entire source file (with -
20063 \begin_inset ERT
20064 status Collapsed
20065
20066 \layout Standard
20067
20068 \backslash 
20069 /
20070 \end_inset 
20071
20072 -noinduction option) or for a given function only using #pragma\SpecialChar ~
20073 noinduction
20074 \begin_inset LatexCommand \index{\#pragma noinduction}
20075
20076 \end_inset 
20077
20078 .
20079 \newline 
20080
20081 \newline 
20082 Loop Invariant:
20083 \layout Verse
20084
20085
20086 \family typewriter 
20087 for (i = 0 ; i < 100 ; i ++) 
20088 \newline 
20089 \SpecialChar ~
20090 \SpecialChar ~
20091 \SpecialChar ~
20092 \SpecialChar ~
20093 f += k + l;
20094 \layout Standard
20095
20096 changed to
20097 \layout Verse
20098
20099
20100 \family typewriter 
20101 itemp = k + l; 
20102 \newline 
20103 for (i = 0; i < 100; i++) 
20104 \newline 
20105 \SpecialChar ~
20106 \SpecialChar ~
20107 \SpecialChar ~
20108 \SpecialChar ~
20109 f += itemp;
20110 \layout Standard
20111
20112 As mentioned previously some loop invariants are not as apparent, all static
20113  address computations are also moved out of the loop.
20114 \newline 
20115
20116 \newline 
20117 Strength Reduction
20118 \begin_inset LatexCommand \index{Strength reduction}
20119
20120 \end_inset 
20121
20122 , this optimization substitutes an expression by a cheaper expression:
20123 \layout Verse
20124
20125
20126 \family typewriter 
20127 for (i=0;i < 100; i++)
20128 \newline 
20129 \SpecialChar ~
20130 \SpecialChar ~
20131 \SpecialChar ~
20132 \SpecialChar ~
20133 ar[i*5] = i*3;
20134 \layout Standard
20135
20136 changed to
20137 \layout Verse
20138
20139
20140 \family typewriter 
20141 itemp1 = 0; 
20142 \newline 
20143 itemp2 = 0; 
20144 \newline 
20145 for (i=0;i< 100;i++) { 
20146 \newline 
20147 \SpecialChar ~
20148 \SpecialChar ~
20149 \SpecialChar ~
20150 \SpecialChar ~
20151 ar[itemp1] = itemp2; 
20152 \newline 
20153 \SpecialChar ~
20154 \SpecialChar ~
20155 \SpecialChar ~
20156 \SpecialChar ~
20157 itemp1 += 5; 
20158 \newline 
20159 \SpecialChar ~
20160 \SpecialChar ~
20161 \SpecialChar ~
20162 \SpecialChar ~
20163 itemp2 += 3; 
20164 \newline 
20165 }
20166 \layout Standard
20167
20168 The more expensive multiplication
20169 \begin_inset LatexCommand \index{Multiplication}
20170
20171 \end_inset 
20172
20173  is changed to a less expensive addition.
20174 \layout Subsection
20175
20176 Loop Reversing
20177 \begin_inset LatexCommand \index{Loop reversing}
20178
20179 \end_inset 
20180
20181
20182 \layout Standard
20183
20184 This optimization is done to reduce the overhead of checking loop boundaries
20185  for every iteration.
20186  Some simple loops can be reversed and implemented using a 
20187 \begin_inset Quotes eld
20188 \end_inset 
20189
20190 decrement and jump if not zero
20191 \begin_inset Quotes erd
20192 \end_inset 
20193
20194  instruction.
20195  SDCC checks for the following criterion to determine if a loop is reversible
20196  (note: more sophisticated compilers use data-dependency analysis to make
20197  this determination, SDCC uses a more simple minded analysis).
20198 \layout Itemize
20199
20200 The 'for' loop is of the form 
20201 \newline 
20202
20203 \newline 
20204
20205 \family typewriter 
20206 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
20207  += 1])
20208 \newline 
20209 \SpecialChar ~
20210 \SpecialChar ~
20211 \SpecialChar ~
20212 \SpecialChar ~
20213 <for body>
20214 \layout Itemize
20215
20216 The <for body> does not contain 
20217 \begin_inset Quotes eld
20218 \end_inset 
20219
20220 continue
20221 \begin_inset Quotes erd
20222 \end_inset 
20223
20224  or 'break
20225 \begin_inset Quotes erd
20226 \end_inset 
20227
20228 .
20229 \layout Itemize
20230
20231 All goto's are contained within the loop.
20232 \layout Itemize
20233
20234 No function calls within the loop.
20235 \layout Itemize
20236
20237 The loop control variable <sym> is not assigned any value within the loop
20238 \layout Itemize
20239
20240 The loop control variable does NOT participate in any arithmetic operation
20241  within the loop.
20242 \layout Itemize
20243
20244 There are NO switch statements in the loop.
20245 \layout Subsection
20246
20247 Algebraic Simplifications
20248 \layout Standard
20249
20250 SDCC does numerous algebraic simplifications, the following is a small sub-set
20251  of these optimizations.
20252 \layout Verse
20253
20254
20255 \family typewriter 
20256 i = j + 0;\SpecialChar ~
20257 \SpecialChar ~
20258 \SpecialChar ~
20259 \SpecialChar ~
20260  /* changed to: */\SpecialChar ~
20261 \SpecialChar ~
20262 \SpecialChar ~
20263 \SpecialChar ~
20264  i = j; 
20265 \newline 
20266 i /= 2;\SpecialChar ~
20267 \SpecialChar ~
20268 \SpecialChar ~
20269 \SpecialChar ~
20270 \SpecialChar ~
20271 \SpecialChar ~
20272 \SpecialChar ~
20273  /* changed to: */\SpecialChar ~
20274 \SpecialChar ~
20275 \SpecialChar ~
20276 \SpecialChar ~
20277  i >>= 1; 
20278 \newline 
20279 i = j - j;\SpecialChar ~
20280 \SpecialChar ~
20281 \SpecialChar ~
20282 \SpecialChar ~
20283  /* changed to: */\SpecialChar ~
20284 \SpecialChar ~
20285 \SpecialChar ~
20286 \SpecialChar ~
20287  i = 0; 
20288 \newline 
20289 i = j / 1;\SpecialChar ~
20290 \SpecialChar ~
20291 \SpecialChar ~
20292 \SpecialChar ~
20293  /* changed to: */\SpecialChar ~
20294 \SpecialChar ~
20295 \SpecialChar ~
20296 \SpecialChar ~
20297  i = j;
20298 \layout Standard
20299
20300 Note the subexpressions
20301 \begin_inset LatexCommand \index{Subexpression}
20302
20303 \end_inset 
20304
20305  given above are generally introduced by macro expansions or as a result
20306  of copy/constant propagation.
20307 \layout Subsection
20308
20309 'switch' Statements
20310 \begin_inset LatexCommand \label{sub:'switch'-Statements}
20311
20312 \end_inset 
20313
20314
20315 \begin_inset LatexCommand \index{switch statement}
20316
20317 \end_inset 
20318
20319
20320 \layout Standard
20321
20322 SDCC can optimize switch statements to jump tables
20323 \begin_inset LatexCommand \index{jump tables}
20324
20325 \end_inset 
20326
20327 .
20328  It makes the decision based on an estimate of the generated code size.
20329  SDCC is quite liberal in the requirements for jump table generation: 
20330 \layout Itemize
20331
20332 The labels need not be in order, and the starting number need not be one
20333  or zero, the case labels are in numerical sequence or not too many case
20334  labels are missing.
20335 \begin_deeper 
20336 \layout Verse
20337
20338
20339 \family typewriter 
20340 switch(i) {\SpecialChar ~
20341 \SpecialChar ~
20342 \SpecialChar ~
20343 \SpecialChar ~
20344 \SpecialChar ~
20345 \SpecialChar ~
20346 \SpecialChar ~
20347 \SpecialChar ~
20348 \SpecialChar ~
20349 \SpecialChar ~
20350 \SpecialChar ~
20351 \SpecialChar ~
20352 \SpecialChar ~
20353 \SpecialChar ~
20354 \SpecialChar ~
20355 \SpecialChar ~
20356 \SpecialChar ~
20357 \SpecialChar ~
20358 \SpecialChar ~
20359 \SpecialChar ~
20360 \SpecialChar ~
20361 \SpecialChar ~
20362 \SpecialChar ~
20363 \SpecialChar ~
20364 \SpecialChar ~
20365 \SpecialChar ~
20366 switch (i) { 
20367 \newline 
20368 \SpecialChar ~
20369 \SpecialChar ~
20370 \SpecialChar ~
20371 case 4: ...\SpecialChar ~
20372 \SpecialChar ~
20373 \SpecialChar ~
20374 \SpecialChar ~
20375 \SpecialChar ~
20376 \SpecialChar ~
20377 \SpecialChar ~
20378 \SpecialChar ~
20379 \SpecialChar ~
20380 \SpecialChar ~
20381 \SpecialChar ~
20382 \SpecialChar ~
20383 \SpecialChar ~
20384 \SpecialChar ~
20385 \SpecialChar ~
20386 \SpecialChar ~
20387 \SpecialChar ~
20388 \SpecialChar ~
20389 \SpecialChar ~
20390 \SpecialChar ~
20391 \SpecialChar ~
20392 \SpecialChar ~
20393 \SpecialChar ~
20394 \SpecialChar ~
20395 \SpecialChar ~
20396 \SpecialChar ~
20397 case 0: ...
20398  
20399 \newline 
20400 \SpecialChar ~
20401 \SpecialChar ~
20402 \SpecialChar ~
20403 case 5: ...\SpecialChar ~
20404 \SpecialChar ~
20405 \SpecialChar ~
20406 \SpecialChar ~
20407 \SpecialChar ~
20408 \SpecialChar ~
20409 \SpecialChar ~
20410 \SpecialChar ~
20411 \SpecialChar ~
20412 \SpecialChar ~
20413 \SpecialChar ~
20414 \SpecialChar ~
20415 \SpecialChar ~
20416 \SpecialChar ~
20417 \SpecialChar ~
20418 \SpecialChar ~
20419 \SpecialChar ~
20420 \SpecialChar ~
20421 \SpecialChar ~
20422 \SpecialChar ~
20423 \SpecialChar ~
20424 \SpecialChar ~
20425 \SpecialChar ~
20426 \SpecialChar ~
20427 \SpecialChar ~
20428 \SpecialChar ~
20429 case 1: ...
20430  
20431 \newline 
20432 \SpecialChar ~
20433 \SpecialChar ~
20434 \SpecialChar ~
20435 case 3: ...\SpecialChar ~
20436 \SpecialChar ~
20437 \SpecialChar ~
20438 \SpecialChar ~
20439 \SpecialChar ~
20440 \SpecialChar ~
20441 \SpecialChar ~
20442 \SpecialChar ~
20443 \SpecialChar ~
20444 \SpecialChar ~
20445 \SpecialChar ~
20446 \SpecialChar ~
20447 \SpecialChar ~
20448 \SpecialChar ~
20449 \SpecialChar ~
20450 \SpecialChar ~
20451 \SpecialChar ~
20452 \SpecialChar ~
20453 \SpecialChar ~
20454 \SpecialChar ~
20455 \SpecialChar ~
20456 \SpecialChar ~
20457 \SpecialChar ~
20458 \SpecialChar ~
20459 \SpecialChar ~
20460 \SpecialChar ~
20461
20462 \newline 
20463 \SpecialChar ~
20464 \SpecialChar ~
20465 \SpecialChar ~
20466 case 6: ...\SpecialChar ~
20467 \SpecialChar ~
20468 \SpecialChar ~
20469 \SpecialChar ~
20470 \SpecialChar ~
20471 \SpecialChar ~
20472 \SpecialChar ~
20473 \SpecialChar ~
20474 \SpecialChar ~
20475 \SpecialChar ~
20476 \SpecialChar ~
20477 \SpecialChar ~
20478 \SpecialChar ~
20479 \SpecialChar ~
20480 \SpecialChar ~
20481 \SpecialChar ~
20482 \SpecialChar ~
20483 \SpecialChar ~
20484 \SpecialChar ~
20485 \SpecialChar ~
20486 \SpecialChar ~
20487 \SpecialChar ~
20488 \SpecialChar ~
20489 \SpecialChar ~
20490 \SpecialChar ~
20491 \SpecialChar ~
20492 case 3: ...
20493  
20494 \newline 
20495 \SpecialChar ~
20496 \SpecialChar ~
20497 \SpecialChar ~
20498 case 7: ...\SpecialChar ~
20499 \SpecialChar ~
20500 \SpecialChar ~
20501 \SpecialChar ~
20502 \SpecialChar ~
20503 \SpecialChar ~
20504 \SpecialChar ~
20505 \SpecialChar ~
20506 \SpecialChar ~
20507 \SpecialChar ~
20508 \SpecialChar ~
20509 \SpecialChar ~
20510 \SpecialChar ~
20511 \SpecialChar ~
20512 \SpecialChar ~
20513 \SpecialChar ~
20514 \SpecialChar ~
20515 \SpecialChar ~
20516 \SpecialChar ~
20517 \SpecialChar ~
20518 \SpecialChar ~
20519 \SpecialChar ~
20520 \SpecialChar ~
20521 \SpecialChar ~
20522 \SpecialChar ~
20523 \SpecialChar ~
20524 case 4: ...
20525  
20526 \newline 
20527 \SpecialChar ~
20528 \SpecialChar ~
20529 \SpecialChar ~
20530 case 8: ...\SpecialChar ~
20531 \SpecialChar ~
20532 \SpecialChar ~
20533 \SpecialChar ~
20534 \SpecialChar ~
20535 \SpecialChar ~
20536 \SpecialChar ~
20537 \SpecialChar ~
20538 \SpecialChar ~
20539 \SpecialChar ~
20540 \SpecialChar ~
20541 \SpecialChar ~
20542 \SpecialChar ~
20543 \SpecialChar ~
20544 \SpecialChar ~
20545 \SpecialChar ~
20546 \SpecialChar ~
20547 \SpecialChar ~
20548 \SpecialChar ~
20549 \SpecialChar ~
20550 \SpecialChar ~
20551 \SpecialChar ~
20552 \SpecialChar ~
20553 \SpecialChar ~
20554 \SpecialChar ~
20555 \SpecialChar ~
20556 case 5: ...
20557  
20558 \newline 
20559 \SpecialChar ~
20560 \SpecialChar ~
20561 \SpecialChar ~
20562 case 9: ...\SpecialChar ~
20563 \SpecialChar ~
20564 \SpecialChar ~
20565 \SpecialChar ~
20566 \SpecialChar ~
20567 \SpecialChar ~
20568 \SpecialChar ~
20569 \SpecialChar ~
20570 \SpecialChar ~
20571 \SpecialChar ~
20572 \SpecialChar ~
20573 \SpecialChar ~
20574 \SpecialChar ~
20575 \SpecialChar ~
20576 \SpecialChar ~
20577 \SpecialChar ~
20578 \SpecialChar ~
20579 \SpecialChar ~
20580 \SpecialChar ~
20581 \SpecialChar ~
20582 \SpecialChar ~
20583 \SpecialChar ~
20584 \SpecialChar ~
20585 \SpecialChar ~
20586 \SpecialChar ~
20587 \SpecialChar ~
20588 case 6: ...
20589  
20590 \newline 
20591 \SpecialChar ~
20592 \SpecialChar ~
20593 \SpecialChar ~
20594 case 10: ...\SpecialChar ~
20595 \SpecialChar ~
20596 \SpecialChar ~
20597 \SpecialChar ~
20598 \SpecialChar ~
20599 \SpecialChar ~
20600 \SpecialChar ~
20601 \SpecialChar ~
20602 \SpecialChar ~
20603 \SpecialChar ~
20604 \SpecialChar ~
20605 \SpecialChar ~
20606 \SpecialChar ~
20607 \SpecialChar ~
20608 \SpecialChar ~
20609 \SpecialChar ~
20610 \SpecialChar ~
20611 \SpecialChar ~
20612 \SpecialChar ~
20613 \SpecialChar ~
20614 \SpecialChar ~
20615 \SpecialChar ~
20616 \SpecialChar ~
20617 \SpecialChar ~
20618 \SpecialChar ~
20619 case 7: ...
20620  
20621 \newline 
20622 \SpecialChar ~
20623 \SpecialChar ~
20624 \SpecialChar ~
20625 case 11: ...\SpecialChar ~
20626 \SpecialChar ~
20627 \SpecialChar ~
20628 \SpecialChar ~
20629 \SpecialChar ~
20630 \SpecialChar ~
20631 \SpecialChar ~
20632 \SpecialChar ~
20633 \SpecialChar ~
20634 \SpecialChar ~
20635 \SpecialChar ~
20636 \SpecialChar ~
20637 \SpecialChar ~
20638 \SpecialChar ~
20639 \SpecialChar ~
20640 \SpecialChar ~
20641 \SpecialChar ~
20642 \SpecialChar ~
20643 \SpecialChar ~
20644 \SpecialChar ~
20645 \SpecialChar ~
20646 \SpecialChar ~
20647 \SpecialChar ~
20648 \SpecialChar ~
20649 \SpecialChar ~
20650 case 8: ...
20651  
20652 \newline 
20653 }\SpecialChar ~
20654 \SpecialChar ~
20655 \SpecialChar ~
20656 \SpecialChar ~
20657 \SpecialChar ~
20658 \SpecialChar ~
20659 \SpecialChar ~
20660 \SpecialChar ~
20661 \SpecialChar ~
20662 \SpecialChar ~
20663 \SpecialChar ~
20664 \SpecialChar ~
20665 \SpecialChar ~
20666 \SpecialChar ~
20667 \SpecialChar ~
20668 \SpecialChar ~
20669 \SpecialChar ~
20670 \SpecialChar ~
20671 \SpecialChar ~
20672 \SpecialChar ~
20673 \SpecialChar ~
20674 \SpecialChar ~
20675 \SpecialChar ~
20676 \SpecialChar ~
20677 \SpecialChar ~
20678 \SpecialChar ~
20679 \SpecialChar ~
20680 \SpecialChar ~
20681 \SpecialChar ~
20682 \SpecialChar ~
20683 \SpecialChar ~
20684 \SpecialChar ~
20685 \SpecialChar ~
20686 \SpecialChar ~
20687 \SpecialChar ~
20688 \SpecialChar ~
20689 }
20690 \layout Standard
20691
20692 Both the above switch statements will be implemented using a jump-table.
20693  The example to the right side is slightly more efficient as the check for
20694  the lower boundary of the jump-table is not needed.
20695 \end_deeper 
20696 \layout Itemize
20697
20698 The number of case labels is not larger than supported by the target architectur
20699 e.
20700 \layout Itemize
20701
20702 If the case labels are not in numerical sequence ('gaps' between cases)
20703  SDCC checks whether a jump table with additionally inserted dummy cases
20704  is still attractive.
20705  
20706 \layout Itemize
20707
20708 If the starting number is not zero and a check for the lower boundary of
20709  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
20710  ...
20711  .
20712 \layout Standard
20713
20714 Switch statements which have large gaps in the numeric sequence or those
20715  that have too many case labels can be split into more than one switch statement
20716  for efficient code generation, e.g.:
20717 \layout Verse
20718
20719
20720 \family typewriter 
20721 switch (i) { 
20722 \newline 
20723 \SpecialChar ~
20724 \SpecialChar ~
20725 case 1: ...
20726  
20727 \newline 
20728 \SpecialChar ~
20729 \SpecialChar ~
20730 case 2: ...
20731  
20732 \newline 
20733 \SpecialChar ~
20734 \SpecialChar ~
20735 case 3: ...
20736  
20737 \newline 
20738 \SpecialChar ~
20739 \SpecialChar ~
20740 case 4: ...
20741  
20742 \newline 
20743 \SpecialChar ~
20744 \SpecialChar ~
20745 case 5: ...
20746  
20747 \newline 
20748 \SpecialChar ~
20749 \SpecialChar ~
20750 case 6: ...
20751  
20752 \newline 
20753 \SpecialChar ~
20754 \SpecialChar ~
20755 case 7: ...
20756  
20757 \newline 
20758 \SpecialChar ~
20759 \SpecialChar ~
20760 case 101: ...
20761  
20762 \newline 
20763 \SpecialChar ~
20764 \SpecialChar ~
20765 case 102: ...
20766  
20767 \newline 
20768 \SpecialChar ~
20769 \SpecialChar ~
20770 case 103: ...
20771  
20772 \newline 
20773 \SpecialChar ~
20774 \SpecialChar ~
20775 case 104: ...
20776  
20777 \newline 
20778 \SpecialChar ~
20779 \SpecialChar ~
20780 case 105: ...
20781  
20782 \newline 
20783 \SpecialChar ~
20784 \SpecialChar ~
20785 case 106: ...
20786  
20787 \newline 
20788 \SpecialChar ~
20789 \SpecialChar ~
20790 case 107: ...
20791  
20792 \newline 
20793 }
20794 \layout Standard
20795
20796 If the above switch statement is broken down into two switch statements
20797 \layout Verse
20798
20799
20800 \family typewriter 
20801 switch (i) { 
20802 \newline 
20803 \SpecialChar ~
20804 \SpecialChar ~
20805 case 1: ...
20806  
20807 \newline 
20808 \SpecialChar ~
20809 \SpecialChar ~
20810 case 2: ...
20811  
20812 \newline 
20813 \SpecialChar ~
20814 \SpecialChar ~
20815 case 3: ...
20816  
20817 \newline 
20818 \SpecialChar ~
20819 \SpecialChar ~
20820 case 4: ...
20821  
20822 \newline 
20823 \SpecialChar ~
20824 \SpecialChar ~
20825 case 5: ...
20826  
20827 \newline 
20828 \SpecialChar ~
20829 \SpecialChar ~
20830 case 6: ...
20831  
20832 \newline 
20833 \SpecialChar ~
20834 \SpecialChar ~
20835 case 7: ...
20836  
20837 \newline 
20838 }
20839 \layout Standard
20840
20841 and
20842 \layout Verse
20843
20844
20845 \family typewriter 
20846 switch (i) { 
20847 \newline 
20848 \SpecialChar ~
20849 \SpecialChar ~
20850 case 101: ...
20851  
20852 \newline 
20853 \SpecialChar ~
20854 \SpecialChar ~
20855 case 102: ...
20856  
20857 \newline 
20858 \SpecialChar ~
20859 \SpecialChar ~
20860 case 103: ...
20861  
20862 \newline 
20863 \SpecialChar ~
20864 \SpecialChar ~
20865 case 104: ...
20866  
20867 \newline 
20868 \SpecialChar ~
20869 \SpecialChar ~
20870 case 105: ...
20871  
20872 \newline 
20873 \SpecialChar ~
20874 \SpecialChar ~
20875 case 106: ...
20876  
20877 \newline 
20878 \SpecialChar ~
20879 \SpecialChar ~
20880 case 107: ...
20881  
20882 \newline 
20883 }
20884 \layout Standard
20885
20886 then both the switch statements will be implemented using jump-tables whereas
20887  the unmodified switch statement will not be.
20888 \layout Comment
20889
20890 There might be reasons which SDCC cannot know about to either favour or
20891  not favour jump tables.
20892  If the target system has to be as quick for the last switch case as for
20893  the first (pro jump table), or if the switch argument is known to be zero
20894  in the majority of the cases (contra jump table).
20895 \layout Standard
20896
20897 The pragma nojtbound
20898 \begin_inset LatexCommand \index{\#pragma nojtbound}
20899
20900 \end_inset 
20901
20902  can be used to turn off checking the 
20903 \emph on 
20904 j
20905 \emph default 
20906 ump 
20907 \emph on 
20908 t
20909 \emph default 
20910 able 
20911 \emph on 
20912 bound
20913 \emph default 
20914 aries.
20915  It has no effect if a default label is supplied.
20916  Use of this pragma is dangerous: if the switch argument is not matched
20917  by a case statement the processor will happily jump into Nirvana.
20918 \layout Subsection
20919
20920 Bit-shifting Operations
20921 \begin_inset LatexCommand \index{Bit shifting}
20922
20923 \end_inset 
20924
20925 .
20926 \layout Standard
20927
20928 Bit shifting is one of the most frequently used operation in embedded programmin
20929 g.
20930  SDCC tries to implement bit-shift operations in the most efficient way
20931  possible, e.g.:
20932 \layout Verse
20933
20934
20935 \family typewriter 
20936 unsigned char i;
20937 \newline 
20938 ...
20939  
20940 \newline 
20941 i >>= 4; 
20942 \newline 
20943 ...
20944 \layout Standard
20945
20946 generates the following code:
20947 \layout Verse
20948
20949
20950 \family typewriter 
20951 mov\SpecialChar ~
20952  a,_i 
20953 \newline 
20954 swap a 
20955 \newline 
20956 anl\SpecialChar ~
20957  a,#0x0f 
20958 \newline 
20959 mov\SpecialChar ~
20960  _i,a
20961 \layout Standard
20962
20963 In general SDCC will never setup a loop if the shift count is known.
20964  Another example:
20965 \layout Verse
20966
20967
20968 \family typewriter 
20969 unsigned int i; 
20970 \newline 
20971 ...
20972  
20973 \newline 
20974 i >>= 9; 
20975 \newline 
20976 ...
20977 \layout Standard
20978
20979 will generate:
20980 \layout Verse
20981
20982
20983 \family typewriter 
20984 mov\SpecialChar ~
20985 \SpecialChar ~
20986 a,(_i + 1) 
20987 \newline 
20988 mov\SpecialChar ~
20989 \SpecialChar ~
20990 (_i + 1),#0x00 
20991 \newline 
20992 clr\SpecialChar ~
20993 \SpecialChar ~
20994
20995 \newline 
20996 rrc\SpecialChar ~
20997 \SpecialChar ~
20998
20999 \newline 
21000 mov\SpecialChar ~
21001 \SpecialChar ~
21002 _i,a
21003 \layout Subsection
21004
21005 Bit-rotation
21006 \begin_inset LatexCommand \index{Bit rotation}
21007
21008 \end_inset 
21009
21010
21011 \layout Standard
21012
21013 A special case of the bit-shift operation is bit rotation
21014 \begin_inset LatexCommand \index{rotating bits}
21015
21016 \end_inset 
21017
21018 , SDCC recognizes the following expression to be a left bit-rotation:
21019 \layout Verse
21020
21021
21022 \family typewriter 
21023 \series bold 
21024 unsigned
21025 \series default 
21026 \SpecialChar ~
21027 \SpecialChar ~
21028 char i;\SpecialChar ~
21029 \SpecialChar ~
21030 \SpecialChar ~
21031 \SpecialChar ~
21032 \SpecialChar ~
21033 \SpecialChar ~
21034 \SpecialChar ~
21035 \SpecialChar ~
21036 \SpecialChar ~
21037 \SpecialChar ~
21038 \SpecialChar ~
21039 /* unsigned is needed for rotation */ 
21040 \newline 
21041 ...
21042  
21043 \newline 
21044 i = ((i << 1) | (i >> 7)); 
21045 \family default 
21046
21047 \newline 
21048
21049 \family typewriter 
21050 ...
21051 \layout Standard
21052
21053 will generate the following code:
21054 \layout Verse
21055
21056
21057 \family typewriter 
21058 mov\SpecialChar ~
21059 \SpecialChar ~
21060 a,_i 
21061 \newline 
21062 rl\SpecialChar ~
21063 \SpecialChar ~
21064 \SpecialChar ~
21065
21066 \newline 
21067 mov\SpecialChar ~
21068 \SpecialChar ~
21069 _i,a
21070 \layout Standard
21071
21072 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
21073 ns of this case will also be recognized as bit-rotation, i.e.: 
21074 \layout Verse
21075
21076
21077 \family typewriter 
21078 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
21079 \layout Subsection
21080
21081 Nibble and Byte Swapping
21082 \layout Standard
21083
21084 Other special cases of the bit-shift operations are nibble or byte swapping
21085 \begin_inset LatexCommand \index{swapping nibbles/bytes}
21086
21087 \end_inset 
21088
21089 , SDCC recognizes the following expressions:
21090 \layout Verse
21091
21092
21093 \family typewriter 
21094 \series bold 
21095 unsigned
21096 \series default 
21097 \SpecialChar ~
21098 \SpecialChar ~
21099 char i; 
21100 \newline 
21101
21102 \series bold 
21103 unsigned
21104 \series default 
21105 \SpecialChar ~
21106 \SpecialChar ~
21107 int j; 
21108 \newline 
21109 ...
21110  
21111 \newline 
21112 i = ((i << 4) | (i >> 4)); 
21113 \family default 
21114
21115 \newline 
21116
21117 \family typewriter 
21118 j = ((j << 8) | (j >> 8)); 
21119 \layout Standard
21120
21121 and generates a swap instruction for the nibble swapping
21122 \begin_inset LatexCommand \index{Nibble swapping}
21123
21124 \end_inset 
21125
21126  or move instructions for the byte swapping
21127 \begin_inset LatexCommand \index{Byte swapping}
21128
21129 \end_inset 
21130
21131 .
21132  The 
21133 \begin_inset Quotes sld
21134 \end_inset 
21135
21136 j
21137 \begin_inset Quotes srd
21138 \end_inset 
21139
21140  example can be used to convert from little to big-endian or vice versa.
21141  If you want to change the endianness of a 
21142 \emph on 
21143 signed
21144 \emph default 
21145  integer you have to cast to 
21146 \family typewriter 
21147 (unsigned int)
21148 \family default 
21149  first.
21150 \layout Standard
21151
21152 Note that SDCC stores numbers in little-endian
21153 \begin_inset Foot
21154 collapsed false
21155
21156 \layout Standard
21157
21158 Usually 8-bit processors don't care much about endianness.
21159  This is not the case for the standard 8051 which only has an instruction
21160  to increment its 
21161 \emph on 
21162 dptr
21163 \emph default 
21164
21165 \begin_inset LatexCommand \index{DPTR}
21166
21167 \end_inset 
21168
21169 -datapointer
21170 \emph on 
21171  
21172 \emph default 
21173 so little-endian is the more efficient byte order.
21174 \end_inset 
21175
21176
21177 \begin_inset LatexCommand \index{little-endian}
21178
21179 \end_inset 
21180
21181
21182 \begin_inset LatexCommand \index{Endianness}
21183
21184 \end_inset 
21185
21186  format (i.e.
21187  lowest order first).
21188 \layout Subsection
21189
21190 Highest Order Bit
21191 \begin_inset LatexCommand \index{Highest Order Bit}
21192
21193 \end_inset 
21194
21195
21196 \layout Standard
21197
21198 It is frequently required to obtain the highest order bit of an integral
21199  type (long, int, short or char types).
21200  SDCC recognizes the following expression to yield the highest order bit
21201  and generates optimized code for it, e.g.:
21202 \layout Verse
21203
21204
21205 \family typewriter 
21206 unsigned int gint; 
21207 \newline 
21208
21209 \newline 
21210 foo () { 
21211 \newline 
21212 \SpecialChar ~
21213 \SpecialChar ~
21214 unsigned char hob; 
21215 \newline 
21216 \SpecialChar ~
21217 \SpecialChar ~
21218 ...
21219  
21220 \newline 
21221 \SpecialChar ~
21222 \SpecialChar ~
21223 hob = (gint >> 15) & 1; 
21224 \newline 
21225 \SpecialChar ~
21226 \SpecialChar ~
21227 ..
21228  
21229 \newline 
21230 }
21231 \layout Standard
21232
21233 will generate the following code:
21234 \layout Verse
21235
21236
21237 \family typewriter 
21238 \SpecialChar ~
21239 \SpecialChar ~
21240 \SpecialChar ~
21241 \SpecialChar ~
21242 \SpecialChar ~
21243 \SpecialChar ~
21244 \SpecialChar ~
21245 \SpecialChar ~
21246 \SpecialChar ~
21247 \SpecialChar ~
21248 \SpecialChar ~
21249 \SpecialChar ~
21250 \SpecialChar ~
21251 \SpecialChar ~
21252 \SpecialChar ~
21253 \SpecialChar ~
21254 \SpecialChar ~
21255 \SpecialChar ~
21256 \SpecialChar ~
21257 \SpecialChar ~
21258 \SpecialChar ~
21259 \SpecialChar ~
21260 \SpecialChar ~
21261 \SpecialChar ~
21262 \SpecialChar ~
21263  61 ;\SpecialChar ~
21264  hob.c 7 
21265 \newline 
21266 000A E5*01\SpecialChar ~
21267 \SpecialChar ~
21268 \SpecialChar ~
21269 \SpecialChar ~
21270 \SpecialChar ~
21271 \SpecialChar ~
21272 \SpecialChar ~
21273 \SpecialChar ~
21274 \SpecialChar ~
21275 \SpecialChar ~
21276 \SpecialChar ~
21277 \SpecialChar ~
21278 \SpecialChar ~
21279 \SpecialChar ~
21280 \SpecialChar ~
21281  62\SpecialChar ~
21282 \SpecialChar ~
21283 \SpecialChar ~
21284 \SpecialChar ~
21285 \SpecialChar ~
21286 \SpecialChar ~
21287 \SpecialChar ~
21288 \SpecialChar ~
21289  mov\SpecialChar ~
21290 \SpecialChar ~
21291  a,(_gint + 1) 
21292 \newline 
21293 000C 23\SpecialChar ~
21294 \SpecialChar ~
21295 \SpecialChar ~
21296 \SpecialChar ~
21297 \SpecialChar ~
21298 \SpecialChar ~
21299 \SpecialChar ~
21300 \SpecialChar ~
21301 \SpecialChar ~
21302 \SpecialChar ~
21303 \SpecialChar ~
21304 \SpecialChar ~
21305 \SpecialChar ~
21306 \SpecialChar ~
21307 \SpecialChar ~
21308 \SpecialChar ~
21309 \SpecialChar ~
21310 \SpecialChar ~
21311  63\SpecialChar ~
21312 \SpecialChar ~
21313 \SpecialChar ~
21314 \SpecialChar ~
21315 \SpecialChar ~
21316 \SpecialChar ~
21317 \SpecialChar ~
21318 \SpecialChar ~
21319  rl\SpecialChar ~
21320 \SpecialChar ~
21321 \SpecialChar ~
21322  a 
21323 \newline 
21324 000D 54 01\SpecialChar ~
21325 \SpecialChar ~
21326 \SpecialChar ~
21327 \SpecialChar ~
21328 \SpecialChar ~
21329 \SpecialChar ~
21330 \SpecialChar ~
21331 \SpecialChar ~
21332 \SpecialChar ~
21333 \SpecialChar ~
21334 \SpecialChar ~
21335 \SpecialChar ~
21336 \SpecialChar ~
21337 \SpecialChar ~
21338 \SpecialChar ~
21339  64\SpecialChar ~
21340 \SpecialChar ~
21341 \SpecialChar ~
21342 \SpecialChar ~
21343 \SpecialChar ~
21344 \SpecialChar ~
21345 \SpecialChar ~
21346 \SpecialChar ~
21347  anl\SpecialChar ~
21348 \SpecialChar ~
21349  a,#0x01 
21350 \newline 
21351 000F F5*02\SpecialChar ~
21352 \SpecialChar ~
21353 \SpecialChar ~
21354 \SpecialChar ~
21355 \SpecialChar ~
21356 \SpecialChar ~
21357 \SpecialChar ~
21358 \SpecialChar ~
21359 \SpecialChar ~
21360 \SpecialChar ~
21361 \SpecialChar ~
21362 \SpecialChar ~
21363 \SpecialChar ~
21364 \SpecialChar ~
21365 \SpecialChar ~
21366  65\SpecialChar ~
21367 \SpecialChar ~
21368 \SpecialChar ~
21369 \SpecialChar ~
21370 \SpecialChar ~
21371 \SpecialChar ~
21372 \SpecialChar ~
21373 \SpecialChar ~
21374  mov\SpecialChar ~
21375 \SpecialChar ~
21376  _foo_hob_1_1,a
21377 \layout Standard
21378
21379 Variations of this case however will 
21380 \emph on 
21381 not
21382 \emph default 
21383  be recognized.
21384  It is a standard C expression, so I heartily recommend this be the only
21385  way to get the highest order bit, (it is portable).
21386  Of course it will be recognized even if it is embedded in other expressions,
21387  e.g.:
21388 \layout Verse
21389
21390
21391 \family typewriter 
21392 xyz = gint + ((gint >> 15) & 1);
21393 \layout Standard
21394
21395 will still be recognized.
21396 \layout Subsection
21397
21398 Peephole Optimizer
21399 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
21400
21401 \end_inset 
21402
21403
21404 \begin_inset LatexCommand \index{Peephole optimizer}
21405
21406 \end_inset 
21407
21408
21409 \layout Standard
21410
21411 The compiler uses a rule based, pattern matching and re-writing mechanism
21412  for peep-hole optimization.
21413  It is inspired by 
21414 \emph on 
21415 copt
21416 \emph default 
21417  a peep-hole optimizer by Christopher W.
21418  Fraser (cwfraser@microsoft.com).
21419  A default set of rules are compiled into the compiler, additional rules
21420  may be added with the 
21421 \emph on 
21422 -
21423 \begin_inset ERT
21424 status Collapsed
21425
21426 \layout Standard
21427
21428 \backslash 
21429 /
21430 \end_inset 
21431
21432 -peep-file
21433 \begin_inset LatexCommand \index{-\/-peep-file}
21434
21435 \end_inset 
21436
21437  <filename>
21438 \emph default 
21439  option.
21440  The rule language is best illustrated with examples.
21441 \layout Verse
21442
21443
21444 \family typewriter 
21445 replace { 
21446 \newline 
21447 \SpecialChar ~
21448 \SpecialChar ~
21449 mov %1,a 
21450 \newline 
21451 \SpecialChar ~
21452 \SpecialChar ~
21453 mov a,%1
21454 \newline 
21455 } by {
21456 \newline 
21457 \SpecialChar ~
21458 \SpecialChar ~
21459 mov %1,a
21460 \newline 
21461 }
21462 \layout Standard
21463
21464 The above rule will change the following assembly
21465 \begin_inset LatexCommand \index{Assembler routines}
21466
21467 \end_inset 
21468
21469  sequence:
21470 \layout Verse
21471
21472
21473 \family typewriter 
21474 mov r1,a 
21475 \newline 
21476 mov a,r1
21477 \layout Standard
21478
21479 to
21480 \layout Verse
21481
21482
21483 \family typewriter 
21484 mov r1,a
21485 \layout Standard
21486
21487 Note: All occurrences of a 
21488 \emph on 
21489 %n
21490 \emph default 
21491  (pattern variable) must denote the same string.
21492  With the above rule, the assembly sequence:
21493 \layout Verse
21494
21495
21496 \family typewriter 
21497 mov r1,a 
21498 \newline 
21499 mov a,r2
21500 \layout Standard
21501
21502 will remain unmodified.
21503 \newline 
21504
21505 \newline 
21506 Other special case optimizations may be added by the user (via 
21507 \emph on 
21508 -
21509 \begin_inset ERT
21510 status Collapsed
21511
21512 \layout Standard
21513
21514 \backslash 
21515 /
21516 \end_inset 
21517
21518 -peep-file option
21519 \emph default 
21520 ).
21521  E.g.
21522  some variants of the 8051 MCU
21523 \begin_inset LatexCommand \index{MCS51 variants}
21524
21525 \end_inset 
21526
21527  allow only 
21528 \family typewriter 
21529 ajmp
21530 \family default 
21531  and 
21532 \family typewriter 
21533 acall
21534 \family default 
21535 .
21536  The following two rules will change all 
21537 \family typewriter 
21538 ljmp
21539 \family default 
21540  and 
21541 \family typewriter 
21542 lcall
21543 \family default 
21544  to 
21545 \family typewriter 
21546 ajmp
21547 \family default 
21548  and 
21549 \family typewriter 
21550 acall
21551 \layout Verse
21552
21553
21554 \family typewriter 
21555 replace { lcall %1 } by { acall %1 } 
21556 \newline 
21557 replace { ljmp %1 } by { ajmp %1 }
21558 \layout Standard
21559
21560 The 
21561 \emph on 
21562 inline-assembler code
21563 \emph default 
21564  is also passed through the peep hole optimizer, thus the peephole optimizer
21565  can also be used as an assembly level macro expander.
21566  The rules themselves are MCU dependent whereas the rule language infra-structur
21567 e is MCU independent.
21568  Peephole optimization rules for other MCU can be easily programmed using
21569  the rule language.
21570 \newline 
21571
21572 \newline 
21573 The syntax for a rule is as follows:
21574 \layout Verse
21575
21576
21577 \family typewriter 
21578 rule := replace [ restart ] '{' <assembly sequence> '
21579 \backslash 
21580 n' 
21581 \newline 
21582 \SpecialChar ~
21583  \SpecialChar ~
21584  \SpecialChar ~
21585  \SpecialChar ~
21586  \SpecialChar ~
21587  \SpecialChar ~
21588  \SpecialChar ~
21589  \SpecialChar ~
21590  \SpecialChar ~
21591  \SpecialChar ~
21592  \SpecialChar ~
21593  \SpecialChar ~
21594  \SpecialChar ~
21595  \SpecialChar ~
21596  '}' by '{' '
21597 \backslash 
21598 n' 
21599 \newline 
21600 \SpecialChar ~
21601  \SpecialChar ~
21602  \SpecialChar ~
21603  \SpecialChar ~
21604  \SpecialChar ~
21605  \SpecialChar ~
21606  \SpecialChar ~
21607  \SpecialChar ~
21608  \SpecialChar ~
21609  \SpecialChar ~
21610  \SpecialChar ~
21611  \SpecialChar ~
21612  \SpecialChar ~
21613  \SpecialChar ~
21614  \SpecialChar ~
21615  \SpecialChar ~
21616  <assembly sequence> '
21617 \backslash 
21618 n' 
21619 \newline 
21620 \SpecialChar ~
21621  \SpecialChar ~
21622  \SpecialChar ~
21623  \SpecialChar ~
21624  \SpecialChar ~
21625  \SpecialChar ~
21626  \SpecialChar ~
21627  \SpecialChar ~
21628  \SpecialChar ~
21629  \SpecialChar ~
21630  \SpecialChar ~
21631  \SpecialChar ~
21632  \SpecialChar ~
21633  \SpecialChar ~
21634  '}' [if <functionName> ] '
21635 \backslash 
21636 n' 
21637 \layout Standard
21638
21639 <assembly sequence> := assembly instruction (each instruction including
21640  labels must be on a separate line).
21641 \newline 
21642
21643 \newline 
21644 The optimizer will apply to the rules one by one from the top in the sequence
21645  of their appearance, it will terminate when all rules are exhausted.
21646  If the 'restart' option is specified, then the optimizer will start matching
21647  the rules again from the top, this option for a rule is expensive (performance)
21648 , it is intended to be used in situations where a transformation will trigger
21649  the same rule again.
21650  An example of this (not a good one, it has side effects) is the following
21651  rule:
21652 \layout Verse
21653
21654
21655 \family typewriter 
21656 replace restart { 
21657 \newline 
21658 \SpecialChar ~
21659 \SpecialChar ~
21660 pop %1 
21661 \newline 
21662 \SpecialChar ~
21663 \SpecialChar ~
21664 push %1 } by { 
21665 \newline 
21666 \SpecialChar ~
21667 \SpecialChar ~
21668 ; nop 
21669 \newline 
21670 }
21671 \layout Standard
21672
21673 Note that the replace pattern cannot be a blank, but can be a comment line.
21674  Without the 'restart' option only the innermost 'pop' 'push' pair would
21675  be eliminated, i.e.:
21676 \layout Verse
21677
21678
21679 \family typewriter 
21680 pop ar1 
21681 \newline 
21682 pop ar2 
21683 \newline 
21684 push ar2 
21685 \newline 
21686 push ar1
21687 \layout Standard
21688
21689 would result in:
21690 \layout Verse
21691
21692
21693 \family typewriter 
21694 pop ar1 
21695 \newline 
21696 ; nop 
21697 \newline 
21698 push ar1
21699 \layout Standard
21700
21701
21702 \emph on 
21703 with
21704 \emph default 
21705  the restart option the rule will be applied again to the resulting code
21706  and then all the pop-push pairs will be eliminated to yield:
21707 \layout Verse
21708
21709
21710 \family typewriter 
21711 ; nop 
21712 \newline 
21713 ; nop
21714 \layout Standard
21715
21716 A conditional function can be attached to a rule.
21717  Attaching rules are somewhat more involved, let me illustrate this with
21718  an example.
21719 \layout Verse
21720
21721
21722 \family typewriter 
21723 replace { 
21724 \newline 
21725 \SpecialChar ~
21726  \SpecialChar ~
21727  \SpecialChar ~
21728 ljmp %5 
21729 \newline 
21730 %2:
21731 \newline 
21732 } by { 
21733 \newline 
21734 \SpecialChar ~
21735  \SpecialChar ~
21736  \SpecialChar ~
21737 sjmp %5 
21738 \newline 
21739 %2:
21740 \newline 
21741 } if labelInRange
21742 \layout Standard
21743
21744 The optimizer does a look-up of a function name table defined in function
21745  
21746 \emph on 
21747 callFuncByName
21748 \emph default 
21749  in the source file SDCCpeeph.c, with the name 
21750 \emph on 
21751 labelInRange
21752 \emph default 
21753 .
21754  If it finds a corresponding entry the function is called.
21755  Note there can be no parameters specified for these functions, in this
21756  case the use of 
21757 \emph on 
21758 %5
21759 \emph default 
21760  is crucial, since the function 
21761 \emph on 
21762 labelInRange
21763 \emph default 
21764  expects to find the label in that particular variable (the hash table containin
21765 g the variable bindings is passed as a parameter).
21766  If you want to code more such functions, take a close look at the function
21767  labelInRange and the calling mechanism in source file SDCCpeeph.c.
21768  Currently implemented are 
21769 \emph on 
21770 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
21771  24bitMode, portIsDS390, 24bitModeAndPortDS390 
21772 \emph default 
21773 and
21774 \emph on 
21775  notVolatile
21776 \emph default 
21777 .
21778 \layout Standard
21779
21780 I know this whole thing is a little kludgey, but maybe some day we will
21781  have some better means.
21782  If you are looking at this file, you will see the default rules that are
21783  compiled into the compiler, you can add your own rules in the default set
21784  there if you get tired of specifying the -
21785 \begin_inset ERT
21786 status Collapsed
21787
21788 \layout Standard
21789
21790 \backslash 
21791 /
21792 \end_inset 
21793
21794 -peep-file option.
21795 \layout Section
21796
21797 ANSI-Compliance
21798 \begin_inset LatexCommand \index{ANSI-compliance}
21799
21800 \end_inset 
21801
21802
21803 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
21804
21805 \end_inset 
21806
21807
21808 \layout Standard
21809
21810 Deviations from the compliance:
21811 \layout Itemize
21812
21813 functions are not always reentrant
21814 \begin_inset LatexCommand \index{reentrant}
21815
21816 \end_inset 
21817
21818 .
21819 \layout Itemize
21820
21821 structures cannot be assigned values directly, cannot be passed as function
21822  parameters or assigned to each other and cannot be a return value from
21823  a function, e.g.:
21824 \begin_deeper 
21825 \layout Verse
21826
21827
21828 \family typewriter 
21829 struct s { ...
21830  }; 
21831 \newline 
21832 struct s s1, s2; 
21833 \newline 
21834 foo() 
21835 \newline 
21836
21837 \newline 
21838 \SpecialChar ~
21839 \SpecialChar ~
21840 \SpecialChar ~
21841 \SpecialChar ~
21842 ...
21843  
21844 \newline 
21845 \SpecialChar ~
21846 \SpecialChar ~
21847 \SpecialChar ~
21848 \SpecialChar ~
21849 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
21850 \newline 
21851 \SpecialChar ~
21852 \SpecialChar ~
21853 \SpecialChar ~
21854 \SpecialChar ~
21855 ...
21856  
21857 \newline 
21858 }
21859 \newline 
21860 struct s foo1 (struct s parms) /* invalid in SDCC although allowed in ANSI
21861  */
21862 \newline 
21863
21864 \newline 
21865 \SpecialChar ~
21866 \SpecialChar ~
21867 \SpecialChar ~
21868 \SpecialChar ~
21869 struct s rets; 
21870 \newline 
21871 \SpecialChar ~
21872 \SpecialChar ~
21873 \SpecialChar ~
21874 \SpecialChar ~
21875 ...
21876  
21877 \newline 
21878 \SpecialChar ~
21879 \SpecialChar ~
21880 \SpecialChar ~
21881 \SpecialChar ~
21882 return rets;/* is invalid in SDCC although allowed in ANSI */ 
21883 \newline 
21884 }
21885 \end_deeper 
21886 \layout Itemize
21887
21888 'long long
21889 \begin_inset LatexCommand \index{long long (not supported)}
21890
21891 \end_inset 
21892
21893 ' (64 bit integers
21894 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
21895
21896 \end_inset 
21897
21898 ) not supported.
21899 \layout Itemize
21900
21901 'double
21902 \begin_inset LatexCommand \index{double (not supported)}
21903
21904 \end_inset 
21905
21906 ' precision floating point 
21907 \begin_inset LatexCommand \index{Floating point support}
21908
21909 \end_inset 
21910
21911 not supported.
21912 \layout Itemize
21913
21914 No support for setjmp
21915 \begin_inset LatexCommand \index{setjmp (not supported)}
21916
21917 \end_inset 
21918
21919  and longjmp
21920 \begin_inset LatexCommand \index{longjmp (not supported)}
21921
21922 \end_inset 
21923
21924  (for now).
21925 \layout Itemize
21926
21927 Old K&R style
21928 \begin_inset LatexCommand \index{K\&R style}
21929
21930 \end_inset 
21931
21932  function declarations are NOT allowed.
21933 \begin_deeper 
21934 \layout Verse
21935
21936
21937 \family typewriter 
21938 foo(i,j) /* this old style of function declarations */ 
21939 \newline 
21940 int i,j; /* are valid in ANSI but not valid in SDCC */ 
21941 \newline 
21942
21943 \newline 
21944 \SpecialChar ~
21945 \SpecialChar ~
21946 \SpecialChar ~
21947 \SpecialChar ~
21948 ...
21949  
21950 \newline 
21951 }
21952 \end_deeper 
21953 \layout Section
21954
21955 Cyclomatic Complexity
21956 \begin_inset LatexCommand \index{Cyclomatic complexity}
21957
21958 \end_inset 
21959
21960
21961 \layout Standard
21962
21963 Cyclomatic complexity of a function is defined as the number of independent
21964  paths the program can take during execution of the function.
21965  This is an important number since it defines the number test cases you
21966  have to generate to validate the function.
21967  The accepted industry standard for complexity number is 10, if the cyclomatic
21968  complexity reported by SDCC exceeds 10 you should think about simplification
21969  of the function logic.
21970  Note that the complexity level is not related to the number of lines of
21971  code in a function.
21972  Large functions can have low complexity, and small functions can have large
21973  complexity levels.
21974  
21975 \newline 
21976
21977 \newline 
21978 SDCC uses the following formula to compute the complexity:
21979 \newline 
21980
21981 \layout Standard
21982
21983 complexity = (number of edges in control flow graph) - (number of nodes
21984  in control flow graph) + 2;
21985 \newline 
21986
21987 \newline 
21988 Having said that the industry standard is 10, you should be aware that in
21989  some cases it be may unavoidable to have a complexity level of less than
21990  10.
21991  For example if you have switch statement with more than 10 case labels,
21992  each case label adds one to the complexity level.
21993  The complexity level is by no means an absolute measure of the algorithmic
21994  complexity of the function, it does however provide a good starting point
21995  for which functions you might look at for further optimization.
21996 \layout Section
21997
21998 Retargetting for other Processors
21999 \layout Standard
22000
22001 The issues for retargetting the compiler are far too numerous to be covered
22002  by this document.
22003  What follows is a brief description of each of the seven phases of the
22004  compiler and its MCU dependency.
22005 \layout Itemize
22006
22007 Parsing the source and building the annotated parse tree.
22008  This phase is largely MCU independent (except for the language extensions).
22009  Syntax & semantic checks are also done in this phase, along with some initial
22010  optimizations like back patching labels and the pattern matching optimizations
22011  like bit-rotation etc.
22012 \layout Itemize
22013
22014 The second phase involves generating an intermediate code which can be easy
22015  manipulated during the later phases.
22016  This phase is entirely MCU independent.
22017  The intermediate code generation assumes the target machine has unlimited
22018  number of registers, and designates them with the name iTemp.
22019  The compiler can be made to dump a human readable form of the code generated
22020  by using the -
22021 \begin_inset ERT
22022 status Collapsed
22023
22024 \layout Standard
22025
22026 \backslash 
22027 /
22028 \end_inset 
22029
22030 -dumpraw option.
22031 \layout Itemize
22032
22033 This phase does the bulk of the standard optimizations and is also MCU independe
22034 nt.
22035  This phase can be broken down into several sub-phases:
22036 \newline 
22037
22038 \newline 
22039 Break down intermediate code (iCode) into basic blocks.
22040 \newline 
22041 Do control flow & data flow analysis on the basic blocks.
22042 \newline 
22043 Do local common subexpression elimination, then global subexpression elimination
22044 \newline 
22045 Dead code elimination
22046 \newline 
22047 Loop optimizations
22048 \newline 
22049 If loop optimizations caused any changes then do 'global subexpression eliminati
22050 on' and 'dead code elimination' again.
22051 \layout Itemize
22052
22053 This phase determines the live-ranges; by live range I mean those iTemp
22054  variables defined by the compiler that still survive after all the optimization
22055 s.
22056  Live range analysis
22057 \begin_inset LatexCommand \index{Live range analysis}
22058
22059 \end_inset 
22060
22061  is essential for register allocation, since these computation determines
22062  which of these iTemps will be assigned to registers, and for how long.
22063 \layout Itemize
22064
22065 Phase five is register allocation.
22066  There are two parts to this process.
22067 \newline 
22068
22069 \newline 
22070 The first part I call 'register packing' (for lack of a better term).
22071  In this case several MCU specific expression folding is done to reduce
22072  register pressure.
22073 \newline 
22074
22075 \newline 
22076 The second part is more MCU independent and deals with allocating registers
22077  to the remaining live ranges.
22078  A lot of MCU specific code does creep into this phase because of the limited
22079  number of index registers available in the 8051.
22080 \layout Itemize
22081
22082 The Code generation phase is (unhappily), entirely MCU dependent and very
22083  little (if any at all) of this code can be reused for other MCU.
22084  However the scheme for allocating a homogenized assembler operand for each
22085  iCode operand may be reused.
22086 \layout Itemize
22087
22088 As mentioned in the optimization section the peep-hole optimizer is rule
22089  based system, which can reprogrammed for other MCUs.
22090 \layout Chapter
22091
22092 Compiler internals
22093 \begin_inset LatexCommand \index{Compiler internals}
22094
22095 \end_inset 
22096
22097
22098 \layout Section
22099
22100 The anatomy of the compiler
22101 \begin_inset LatexCommand \label{sub:The-anatomy-of}
22102
22103 \end_inset 
22104
22105
22106 \layout Standard
22107
22108
22109 \shape italic 
22110 This is an excerpt from an article published in Circuit Cellar Magazine
22111  in august 2000.
22112  It's a little outdated (the compiler is much more efficient now and user/develo
22113 per friendly), but pretty well exposes the guts of it all.
22114 \shape default 
22115
22116 \newline 
22117
22118 \newline 
22119 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
22120  It is fairly easy to retarget for other 8-bit MCU.
22121  Here we take a look at some of the internals of the compiler.
22122  
22123 \layout Paragraph*
22124
22125 Parsing
22126 \begin_inset LatexCommand \index{Parsing}
22127
22128 \end_inset 
22129
22130  
22131 \layout Standard
22132
22133 Parsing the input source file and creating an AST (Annotated Syntax Tree
22134 \begin_inset LatexCommand \index{Annotated syntax tree}
22135
22136 \end_inset 
22137
22138 ).
22139  This phase also involves propagating types (annotating each node of the
22140  parse tree with type information) and semantic analysis.
22141  There are some MCU specific parsing rules.
22142  For example the storage classes, the extended storage classes are MCU specific
22143  while there may be a xdata storage class for 8051 there is no such storage
22144  class for z80 or Atmel AVR.
22145  SDCC allows MCU specific storage class extensions, i.e.
22146  xdata will be treated as a storage class specifier when parsing 8051 C
22147  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
22148  C code.
22149 \layout Paragraph*
22150
22151 Generating iCode
22152 \begin_inset LatexCommand \index{iCode}
22153
22154 \end_inset 
22155
22156
22157 \layout Standard
22158
22159 Intermediate code generation.
22160  In this phase the AST is broken down into three-operand form (iCode).
22161  These three operand forms are represented as doubly linked lists.
22162  ICode is the term given to the intermediate form generated by the compiler.
22163  ICode example section shows some examples of iCode generated for some simple
22164  C source functions.
22165 \layout Paragraph*
22166
22167 Optimizations
22168 \begin_inset LatexCommand \index{Optimizations}
22169
22170 \end_inset 
22171
22172 .
22173 \layout Standard
22174
22175 Bulk of the target independent optimizations is performed in this phase.
22176  The optimizations include constant propagation, common sub-expression eliminati
22177 on, loop invariant code movement, strength reduction of loop induction variables
22178  and dead-code elimination.
22179 \layout Paragraph*
22180
22181 Live range analysis
22182 \begin_inset LatexCommand \index{Live range analysis}
22183
22184 \end_inset 
22185
22186
22187 \layout Standard
22188
22189 During intermediate code generation phase, the compiler assumes the target
22190  machine has infinite number of registers and generates a lot of temporary
22191  variables.
22192  The live range computation determines the lifetime of each of these compiler-ge
22193 nerated temporaries.
22194  A picture speaks a thousand words.
22195  ICode example sections show the live range annotations for each of the
22196  operand.
22197  It is important to note here, each iCode is assigned a number in the order
22198  of its execution in the function.
22199  The live ranges are computed in terms of these numbers.
22200  The from number is the number of the iCode which first defines the operand
22201  and the to number signifies the iCode which uses this operand last.
22202 \layout Paragraph*
22203
22204 Register Allocation
22205 \begin_inset LatexCommand \index{Register allocation}
22206
22207 \end_inset 
22208
22209
22210 \layout Standard
22211
22212 The register allocation determines the type and number of registers needed
22213  by each operand.
22214  In most MCUs only a few registers can be used for indirect addressing.
22215  In case of 8051 for example the registers R0 & R1 can be used to indirectly
22216  address the internal ram and DPTR to indirectly address the external ram.
22217  The compiler will try to allocate the appropriate register to pointer variables
22218  if it can.
22219  ICode example section shows the operands annotated with the registers assigned
22220  to them.
22221  The compiler will try to keep operands in registers as much as possible;
22222  there are several schemes the compiler uses to do achieve this.
22223  When the compiler runs out of registers the compiler will check to see
22224  if there are any live operands which is not used or defined in the current
22225  basic block being processed, if there are any found then it will push that
22226  operand and use the registers in this block, the operand will then be popped
22227  at the end of the basic block.
22228  
22229 \layout Standard
22230
22231 There are other MCU specific considerations in this phase.
22232  Some MCUs have an accumulator; very short-lived operands could be assigned
22233  to the accumulator instead of a general-purpose register.
22234 \layout Paragraph*
22235
22236 Code generation
22237 \layout Standard
22238
22239 Figure II gives a table of iCode operations supported by the compiler.
22240  The code generation involves translating these operations into corresponding
22241  assembly code for the processor.
22242  This sounds overly simple but that is the essence of code generation.
22243  Some of the iCode operations are generated on a MCU specific manner for
22244  example, the z80 port does not use registers to pass parameters so the
22245  SEND and RECV iCode operations will not be generated, and it also does
22246  not support JUMPTABLES.
22247  
22248 \newline 
22249
22250 \series bold 
22251 \shape italic 
22252 \color red
22253 <Where is Figure II?>
22254 \layout Comment
22255
22256 In the original article Figure II was announced to be downloadable on 
22257 \shape italic 
22258 Circuit Cellar
22259 \shape default 
22260 's web site.
22261  Unfortunately it never seemed to have shown up there, so: where is Figure
22262  II?
22263 \layout Paragraph*
22264
22265 ICode Example
22266 \begin_inset LatexCommand \index{iCode}
22267
22268 \end_inset 
22269
22270
22271 \layout Standard
22272
22273 This section shows some details of iCode.
22274  The example C code does not do anything useful; it is used as an example
22275  to illustrate the intermediate code generated by the compiler.
22276 \layout Verse
22277
22278
22279 \family typewriter 
22280 1.\SpecialChar ~
22281 xdata int * p;
22282 \newline 
22283 2.\SpecialChar ~
22284 int gint;
22285 \newline 
22286 3.\SpecialChar ~
22287 /* This function does nothing useful.
22288  It is used
22289 \newline 
22290 4.\SpecialChar ~
22291 \SpecialChar ~
22292 \SpecialChar ~
22293 \SpecialChar ~
22294 for the purpose of explaining iCode */
22295 \newline 
22296 5.\SpecialChar ~
22297 short function (data int *x)
22298 \newline 
22299 6.\SpecialChar ~
22300 {
22301 \newline 
22302 7.\SpecialChar ~
22303 \SpecialChar ~
22304 \SpecialChar ~
22305 short i=10; \SpecialChar ~
22306 \SpecialChar ~
22307 /* dead initialization eliminated */
22308 \newline 
22309 8.\SpecialChar ~
22310 \SpecialChar ~
22311 \SpecialChar ~
22312 short sum=10; /* dead initialization eliminated */
22313 \newline 
22314 9.\SpecialChar ~
22315 \SpecialChar ~
22316 \SpecialChar ~
22317 short mul;
22318 \newline 
22319 10.\SpecialChar ~
22320 \SpecialChar ~
22321 int j ;
22322 \newline 
22323 11.\SpecialChar ~
22324 \SpecialChar ~
22325 while (*x) *x++ = *p++; 
22326 \newline 
22327 12.\SpecialChar ~
22328 \SpecialChar ~
22329 \SpecialChar ~
22330 \SpecialChar ~
22331 sum = 0 ; 
22332 \newline 
22333 13.\SpecialChar ~
22334 \SpecialChar ~
22335 mul = 0;
22336 \newline 
22337 14.\SpecialChar ~
22338 \SpecialChar ~
22339 /* compiler detects i,j to be induction variables */
22340 \newline 
22341 15.\SpecialChar ~
22342 \SpecialChar ~
22343 for (i = 0, j = 10 ; i < 10 ; i++, j
22344 \family default 
22345 -
22346 \begin_inset ERT
22347 status Collapsed
22348
22349 \layout Standard
22350
22351 \backslash 
22352 /
22353 \end_inset 
22354
22355 -
22356 \family typewriter 
22357 ) {
22358 \newline 
22359 16.\SpecialChar ~
22360 \SpecialChar ~
22361 \SpecialChar ~
22362 \SpecialChar ~
22363 sum += i;
22364 \newline 
22365 17.\SpecialChar ~
22366 \SpecialChar ~
22367 \SpecialChar ~
22368 \SpecialChar ~
22369 mul += i * 3; \SpecialChar ~
22370 \SpecialChar ~
22371 /* this multiplication remains */
22372 \newline 
22373 18.\SpecialChar ~
22374 \SpecialChar ~
22375 \SpecialChar ~
22376 \SpecialChar ~
22377 gint += j * 3;\SpecialChar ~
22378 \SpecialChar ~
22379 /* this multiplication changed to addition */
22380 \newline 
22381 19.\SpecialChar ~
22382 \SpecialChar ~
22383 }
22384 \newline 
22385 20.\SpecialChar ~
22386 \SpecialChar ~
22387 return sum+mul;
22388 \newline 
22389 21.\SpecialChar ~
22390 }
22391 \layout Standard
22392
22393 In addition to the operands each iCode contains information about the filename
22394  and line it corresponds to in the source file.
22395  The first field in the listing should be interpreted as follows:
22396 \newline 
22397
22398 \shape italic 
22399 \size footnotesize 
22400 Filename(linenumber: iCode Execution sequence number : ICode hash table
22401  key : loop depth of the iCode).
22402 \shape default 
22403 \size default 
22404
22405 \newline 
22406 Then follows the human readable form of the ICode operation.
22407  Each operand of this triplet form can be of three basic types a) compiler
22408  generated temporary b) user defined variable c) a constant value.
22409  Note that local variables and parameters are replaced by compiler generated
22410  temporaries.
22411  Live ranges
22412 \begin_inset LatexCommand \index{Live range analysis}
22413
22414 \end_inset 
22415
22416  are computed only for temporaries (i.e.
22417  live ranges are not computed for global variables).
22418  Registers
22419 \begin_inset LatexCommand \index{Register allocation}
22420
22421 \end_inset 
22422
22423  are allocated for temporaries only.
22424  Operands are formatted in the following manner:
22425 \newline 
22426
22427 \shape italic 
22428 \size footnotesize 
22429 Operand Name [lr live-from : live-to ] { type information } [ registers
22430  allocated ].
22431 \shape default 
22432 \size default 
22433
22434 \newline 
22435 As mentioned earlier the live ranges are computed in terms of the execution
22436  sequence number of the iCodes, for example 
22437 \newline 
22438 the iTemp0 is live from (i.e.
22439  first defined in iCode with execution sequence number 3, and is last used
22440  in the iCode with sequence number 5).
22441  For induction variables such as iTemp21 the live range computation extends
22442  the lifetime from the start to the end of the loop.
22443 \newline 
22444 The register allocator used the live range information to allocate registers,
22445  the same registers may be used for different temporaries if their live
22446  ranges do not overlap, for example r0 is allocated to both iTemp6 and to
22447  iTemp17 since their live ranges do not overlap.
22448  In addition the allocator also takes into consideration the type and usage
22449  of a temporary, for example itemp6 is a pointer to near space and is used
22450  as to fetch data from (i.e.
22451  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
22452  Some short lived temporaries are allocated to special registers which have
22453  meaning to the code generator e.g.
22454  iTemp13 is allocated to a pseudo register CC which tells the back end that
22455  the temporary is used only for a conditional jump the code generation makes
22456  use of this information to optimize a compare and jump ICode.
22457 \newline 
22458 There are several loop optimizations
22459 \begin_inset LatexCommand \index{Loop optimization}
22460
22461 \end_inset 
22462
22463  performed by the compiler.
22464  It can detect induction variables iTemp21(i) and iTemp23(j).
22465  Also note the compiler does selective strength reduction
22466 \begin_inset LatexCommand \index{Strength reduction}
22467
22468 \end_inset 
22469
22470 , i.e.
22471  the multiplication of an induction variable in line 18 (gint = j * 3) is
22472  changed to addition, a new temporary iTemp17 is allocated and assigned
22473  a initial value, a constant 3 is then added for each iteration of the loop.
22474  The compiler does not change the multiplication
22475 \begin_inset LatexCommand \index{Multiplication}
22476
22477 \end_inset 
22478
22479  in line 17 however since the processor does support an 8 * 8 bit multiplication.
22480 \newline 
22481 Note the dead code elimination
22482 \begin_inset LatexCommand \index{Dead-code elimination}
22483
22484 \end_inset 
22485
22486  optimization eliminated the dead assignments in line 7 & 8 to I and sum
22487  respectively.
22488 \newline 
22489
22490 \layout Standard
22491
22492
22493 \size footnotesize 
22494 Sample.c (5:1:0:0) _entry($9) :
22495 \layout Standard
22496
22497
22498 \size footnotesize 
22499 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
22500 \layout Standard
22501
22502
22503 \size footnotesize 
22504 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
22505 \layout Standard
22506
22507
22508 \size footnotesize 
22509 Sample.c(11:4:53:0) preHeaderLbl0($11) :
22510 \layout Standard
22511
22512
22513 \size footnotesize 
22514 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
22515  * int}[r2]
22516 \layout Standard
22517
22518
22519 \size footnotesize 
22520 Sample.c(11:6:5:1) _whilecontinue_0($1) :
22521 \layout Standard
22522
22523
22524 \size footnotesize 
22525 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
22526  int}[r0]]
22527 \layout Standard
22528
22529
22530 \size footnotesize 
22531 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
22532 \layout Standard
22533
22534
22535 \size footnotesize 
22536 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
22537  * int}
22538 \layout Standard
22539
22540
22541 \size footnotesize 
22542 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
22543  {short}
22544 \layout Standard
22545
22546
22547 \size footnotesize 
22548 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
22549  * int}[DPTR]]
22550 \layout Standard
22551
22552
22553 \size footnotesize 
22554 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
22555 }[r2 r3]
22556 \layout Standard
22557
22558
22559 \size footnotesize 
22560 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
22561  * int}[r0] + 0x2 {short}
22562 \layout Standard
22563
22564
22565 \size footnotesize 
22566 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
22567 \layout Standard
22568
22569
22570 \size footnotesize 
22571 Sample.c(11:17:21:0)_whilebreak_0($3) :
22572 \layout Standard
22573
22574
22575 \size footnotesize 
22576 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
22577 \layout Standard
22578
22579
22580 \size footnotesize 
22581 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
22582 \layout Standard
22583
22584
22585 \size footnotesize 
22586 Sample.c(15:20:54:0)preHeaderLbl1($13) :
22587 \layout Standard
22588
22589
22590 \size footnotesize 
22591 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
22592 \layout Standard
22593
22594
22595 \size footnotesize 
22596 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
22597 \layout Standard
22598
22599
22600 \size footnotesize 
22601 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
22602 \layout Standard
22603
22604
22605 \size footnotesize 
22606 Sample.c(15:24:26:1)_forcond_0($4) :
22607 \layout Standard
22608
22609
22610 \size footnotesize 
22611 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
22612  < 0xa {short}
22613 \layout Standard
22614
22615
22616 \size footnotesize 
22617 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
22618 \layout Standard
22619
22620
22621 \size footnotesize 
22622 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
22623  + ITemp21 [lr21:38]{short}[r4]
22624 \layout Standard
22625
22626
22627 \size footnotesize 
22628 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
22629  * 0x3 {short}
22630 \layout Standard
22631
22632
22633 \size footnotesize 
22634 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
22635  + iTemp15 [lr29:30]{short}[r1]
22636 \layout Standard
22637
22638
22639 \size footnotesize 
22640 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
22641  r0]- 0x3 {short}
22642 \layout Standard
22643
22644
22645 \size footnotesize 
22646 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
22647 int}[r7 r0]
22648 \layout Standard
22649
22650
22651 \size footnotesize 
22652 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
22653  + 0x1 {short}
22654 \layout Standard
22655
22656
22657 \size footnotesize 
22658 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
22659  r6]- 0x1 {short}
22660 \layout Standard
22661
22662
22663 \size footnotesize 
22664 Sample.c(19:38:47:1) goto _forcond_0($4)
22665 \layout Standard
22666
22667
22668 \size footnotesize 
22669 Sample.c(19:39:48:0)_forbreak_0($7) :
22670 \layout Standard
22671
22672
22673 \size footnotesize 
22674 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
22675  + ITemp11 [lr19:40]{short}[r3]
22676 \layout Standard
22677
22678
22679 \size footnotesize 
22680 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
22681 \layout Standard
22682
22683
22684 \size footnotesize 
22685 Sample.c(20:42:51:0)_return($8) :
22686 \layout Standard
22687
22688
22689 \size footnotesize 
22690 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
22691 \size default 
22692
22693 \newline 
22694
22695 \newline 
22696 Finally the code generated for this function:
22697 \newline 
22698
22699 \layout Standard
22700
22701
22702 \size footnotesize 
22703 .area DSEG (DATA)
22704 \layout Standard
22705
22706
22707 \size footnotesize 
22708 _p::
22709 \layout Standard
22710
22711
22712 \size footnotesize 
22713 \SpecialChar ~
22714 \SpecialChar ~
22715 .ds 2
22716 \layout Standard
22717
22718
22719 \size footnotesize 
22720 _gint::
22721 \layout Standard
22722
22723
22724 \size footnotesize 
22725 \SpecialChar ~
22726 \SpecialChar ~
22727 .ds 2
22728 \layout Standard
22729
22730
22731 \size footnotesize 
22732 ; sample.c 5
22733 \layout Standard
22734
22735
22736 \size footnotesize 
22737 ; ----------------------------------------------
22738 \layout Standard
22739
22740
22741 \size footnotesize 
22742 ; function function
22743 \layout Standard
22744
22745
22746 \size footnotesize 
22747 ; ----------------------------------------------
22748 \layout Standard
22749
22750
22751 \size footnotesize 
22752 _function:
22753 \layout Standard
22754
22755
22756 \size footnotesize 
22757 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
22758 \layout Standard
22759
22760
22761 \size footnotesize 
22762 \SpecialChar ~
22763 \SpecialChar ~
22764 mov r2,dpl
22765 \layout Standard
22766
22767
22768 \size footnotesize 
22769 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
22770 \layout Standard
22771
22772
22773 \size footnotesize 
22774 \SpecialChar ~
22775 \SpecialChar ~
22776 mov ar0,r2
22777 \layout Standard
22778
22779
22780 \size footnotesize 
22781 ;_whilecontinue_0($1) :
22782 \layout Standard
22783
22784
22785 \size footnotesize 
22786 00101$:
22787 \layout Standard
22788
22789
22790 \size footnotesize 
22791 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
22792 \layout Standard
22793
22794
22795 \size footnotesize 
22796 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
22797 \layout Standard
22798
22799
22800 \size footnotesize 
22801 \SpecialChar ~
22802 \SpecialChar ~
22803 mov ar2,@r0
22804 \layout Standard
22805
22806
22807 \size footnotesize 
22808 \SpecialChar ~
22809 \SpecialChar ~
22810 inc r0
22811 \layout Standard
22812
22813
22814 \size footnotesize 
22815 \SpecialChar ~
22816 \SpecialChar ~
22817 mov ar3,@r0
22818 \layout Standard
22819
22820
22821 \size footnotesize 
22822 \SpecialChar ~
22823 \SpecialChar ~
22824 dec r0
22825 \layout Standard
22826
22827
22828 \size footnotesize 
22829 \SpecialChar ~
22830 \SpecialChar ~
22831 mov a,r2
22832 \layout Standard
22833
22834
22835 \size footnotesize 
22836 \SpecialChar ~
22837 \SpecialChar ~
22838 orl a,r3
22839 \layout Standard
22840
22841
22842 \size footnotesize 
22843 \SpecialChar ~
22844 \SpecialChar ~
22845 jz 00103$
22846 \layout Standard
22847
22848
22849 \size footnotesize 
22850 00114$:
22851 \layout Standard
22852
22853
22854 \size footnotesize 
22855 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
22856 \layout Standard
22857
22858
22859 \size footnotesize 
22860 \SpecialChar ~
22861 \SpecialChar ~
22862 mov dpl,_p
22863 \layout Standard
22864
22865
22866 \size footnotesize 
22867 \SpecialChar ~
22868 \SpecialChar ~
22869 mov dph,(_p + 1)
22870 \layout Standard
22871
22872
22873 \size footnotesize 
22874 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
22875 \layout Standard
22876
22877
22878 \size footnotesize 
22879 \SpecialChar ~
22880 \SpecialChar ~
22881 mov a,#0x02
22882 \layout Standard
22883
22884
22885 \size footnotesize 
22886 \SpecialChar ~
22887 \SpecialChar ~
22888 add a,_p
22889 \layout Standard
22890
22891
22892 \size footnotesize 
22893 \SpecialChar ~
22894 \SpecialChar ~
22895 mov _p,a
22896 \layout Standard
22897
22898
22899 \size footnotesize 
22900 \SpecialChar ~
22901 \SpecialChar ~
22902 clr a
22903 \layout Standard
22904
22905
22906 \size footnotesize 
22907 \SpecialChar ~
22908 \SpecialChar ~
22909 addc a,(_p + 1)
22910 \layout Standard
22911
22912
22913 \size footnotesize 
22914 \SpecialChar ~
22915 \SpecialChar ~
22916 mov (_p + 1),a
22917 \layout Standard
22918
22919
22920 \size footnotesize 
22921 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
22922 \layout Standard
22923
22924
22925 \size footnotesize 
22926 \SpecialChar ~
22927 \SpecialChar ~
22928 movx a,@dptr
22929 \layout Standard
22930
22931
22932 \size footnotesize 
22933 \SpecialChar ~
22934 \SpecialChar ~
22935 mov r2,a
22936 \layout Standard
22937
22938
22939 \size footnotesize 
22940 \SpecialChar ~
22941 \SpecialChar ~
22942 inc dptr
22943 \layout Standard
22944
22945
22946 \size footnotesize 
22947 \SpecialChar ~
22948 \SpecialChar ~
22949 movx a,@dptr
22950 \layout Standard
22951
22952
22953 \size footnotesize 
22954 \SpecialChar ~
22955 \SpecialChar ~
22956 mov r3,a
22957 \layout Standard
22958
22959
22960 \size footnotesize 
22961 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
22962 \layout Standard
22963
22964
22965 \size footnotesize 
22966 \SpecialChar ~
22967 \SpecialChar ~
22968 mov @r0,ar2
22969 \layout Standard
22970
22971
22972 \size footnotesize 
22973 \SpecialChar ~
22974 \SpecialChar ~
22975 inc r0
22976 \layout Standard
22977
22978
22979 \size footnotesize 
22980 \SpecialChar ~
22981 \SpecialChar ~
22982 mov @r0,ar3
22983 \layout Standard
22984
22985
22986 \size footnotesize 
22987 ; iTemp6 [lr5:16]{_near * int}[r0] = 
22988 \layout Standard
22989
22990
22991 \size footnotesize 
22992 ; iTemp6 [lr5:16]{_near * int}[r0] + 
22993 \layout Standard
22994
22995
22996 \size footnotesize 
22997 ; 0x2 {short}
22998 \layout Standard
22999
23000
23001 \size footnotesize 
23002 \SpecialChar ~
23003 \SpecialChar ~
23004 inc r0
23005 \layout Standard
23006
23007
23008 \size footnotesize 
23009 ; goto _whilecontinue_0($1)
23010 \layout Standard
23011
23012
23013 \size footnotesize 
23014 \SpecialChar ~
23015 \SpecialChar ~
23016 sjmp 00101$
23017 \layout Standard
23018
23019
23020 \size footnotesize 
23021 ; _whilebreak_0($3) :
23022 \layout Standard
23023
23024
23025 \size footnotesize 
23026 00103$:
23027 \layout Standard
23028
23029
23030 \size footnotesize 
23031 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
23032 \layout Standard
23033
23034
23035 \size footnotesize 
23036 \SpecialChar ~
23037 \SpecialChar ~
23038 mov r2,#0x00
23039 \layout Standard
23040
23041
23042 \size footnotesize 
23043 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
23044 \layout Standard
23045
23046
23047 \size footnotesize 
23048 \SpecialChar ~
23049 \SpecialChar ~
23050 mov r3,#0x00
23051 \layout Standard
23052
23053
23054 \size footnotesize 
23055 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
23056 \layout Standard
23057
23058
23059 \size footnotesize 
23060 \SpecialChar ~
23061 \SpecialChar ~
23062 mov r4,#0x00
23063 \layout Standard
23064
23065
23066 \size footnotesize 
23067 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
23068 \layout Standard
23069
23070
23071 \size footnotesize 
23072 \SpecialChar ~
23073 \SpecialChar ~
23074 mov r5,#0x0A
23075 \layout Standard
23076
23077
23078 \size footnotesize 
23079 \SpecialChar ~
23080 \SpecialChar ~
23081 mov r6,#0x00
23082 \layout Standard
23083
23084
23085 \size footnotesize 
23086 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
23087 \layout Standard
23088
23089
23090 \size footnotesize 
23091 \SpecialChar ~
23092 \SpecialChar ~
23093 mov r7,#0x1E
23094 \layout Standard
23095
23096
23097 \size footnotesize 
23098 \SpecialChar ~
23099 \SpecialChar ~
23100 mov r0,#0x00
23101 \layout Standard
23102
23103
23104 \size footnotesize 
23105 ; _forcond_0($4) :
23106 \layout Standard
23107
23108
23109 \size footnotesize 
23110 00104$:
23111 \layout Standard
23112
23113
23114 \size footnotesize 
23115 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
23116 \layout Standard
23117
23118
23119 \size footnotesize 
23120 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
23121 \layout Standard
23122
23123
23124 \size footnotesize 
23125 \SpecialChar ~
23126 \SpecialChar ~
23127 clr c
23128 \layout Standard
23129
23130
23131 \size footnotesize 
23132 \SpecialChar ~
23133 \SpecialChar ~
23134 mov a,r4
23135 \layout Standard
23136
23137
23138 \size footnotesize 
23139 \SpecialChar ~
23140 \SpecialChar ~
23141 xrl a,#0x80
23142 \layout Standard
23143
23144
23145 \size footnotesize 
23146 \SpecialChar ~
23147 \SpecialChar ~
23148 subb a,#0x8a
23149 \layout Standard
23150
23151
23152 \size footnotesize 
23153 \SpecialChar ~
23154 \SpecialChar ~
23155 jnc 00107$
23156 \layout Standard
23157
23158
23159 \size footnotesize 
23160 00115$:
23161 \layout Standard
23162
23163
23164 \size footnotesize 
23165 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
23166 \layout Standard
23167
23168
23169 \size footnotesize 
23170 ; iTemp21 [lr21:38]{short}[r4]
23171 \layout Standard
23172
23173
23174 \size footnotesize 
23175 \SpecialChar ~
23176 \SpecialChar ~
23177 mov a,r4
23178 \layout Standard
23179
23180
23181 \size footnotesize 
23182 \SpecialChar ~
23183 \SpecialChar ~
23184 add a,r2
23185 \layout Standard
23186
23187
23188 \size footnotesize 
23189 \SpecialChar ~
23190 \SpecialChar ~
23191 mov r2,a
23192 \layout Standard
23193
23194
23195 \size footnotesize 
23196 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
23197 \layout Standard
23198
23199
23200 \size footnotesize 
23201 \SpecialChar ~
23202 \SpecialChar ~
23203 mov b,#0x03
23204 \layout Standard
23205
23206
23207 \size footnotesize 
23208 \SpecialChar ~
23209 \SpecialChar ~
23210 mov a,r4
23211 \layout Standard
23212
23213
23214 \size footnotesize 
23215 \SpecialChar ~
23216 \SpecialChar ~
23217 mul ab
23218 \layout Standard
23219
23220
23221 \size footnotesize 
23222 \SpecialChar ~
23223 \SpecialChar ~
23224 mov r1,a
23225 \layout Standard
23226
23227
23228 \size footnotesize 
23229 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
23230 \layout Standard
23231
23232
23233 \size footnotesize 
23234 ; iTemp15 [lr29:30]{short}[r1]
23235 \layout Standard
23236
23237
23238 \size footnotesize 
23239 \SpecialChar ~
23240 \SpecialChar ~
23241 add a,r3
23242 \layout Standard
23243
23244
23245 \size footnotesize 
23246 \SpecialChar ~
23247 \SpecialChar ~
23248 mov r3,a
23249 \layout Standard
23250
23251
23252 \size footnotesize 
23253 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
23254 \layout Standard
23255
23256
23257 \size footnotesize 
23258 \SpecialChar ~
23259 \SpecialChar ~
23260 mov a,r7
23261 \layout Standard
23262
23263
23264 \size footnotesize 
23265 \SpecialChar ~
23266 \SpecialChar ~
23267 add a,#0xfd
23268 \layout Standard
23269
23270
23271 \size footnotesize 
23272 \SpecialChar ~
23273 \SpecialChar ~
23274 mov r7,a
23275 \layout Standard
23276
23277
23278 \size footnotesize 
23279 \SpecialChar ~
23280 \SpecialChar ~
23281 mov a,r0
23282 \layout Standard
23283
23284
23285 \size footnotesize 
23286 \SpecialChar ~
23287 \SpecialChar ~
23288 addc a,#0xff
23289 \layout Standard
23290
23291
23292 \size footnotesize 
23293 \SpecialChar ~
23294 \SpecialChar ~
23295 mov r0,a
23296 \layout Standard
23297
23298
23299 \size footnotesize 
23300 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
23301 \layout Standard
23302
23303
23304 \size footnotesize 
23305 \SpecialChar ~
23306 \SpecialChar ~
23307 mov a,r7
23308 \layout Standard
23309
23310
23311 \size footnotesize 
23312 \SpecialChar ~
23313 \SpecialChar ~
23314 add a,_gint
23315 \layout Standard
23316
23317
23318 \size footnotesize 
23319 \SpecialChar ~
23320 \SpecialChar ~
23321 mov _gint,a
23322 \layout Standard
23323
23324
23325 \size footnotesize 
23326 \SpecialChar ~
23327 \SpecialChar ~
23328 mov a,r0
23329 \layout Standard
23330
23331
23332 \size footnotesize 
23333 \SpecialChar ~
23334 \SpecialChar ~
23335 addc a,(_gint + 1)
23336 \layout Standard
23337
23338
23339 \size footnotesize 
23340 \SpecialChar ~
23341 \SpecialChar ~
23342 mov (_gint + 1),a
23343 \layout Standard
23344
23345
23346 \size footnotesize 
23347 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
23348 \layout Standard
23349
23350
23351 \size footnotesize 
23352 \SpecialChar ~
23353 \SpecialChar ~
23354 inc r4
23355 \layout Standard
23356
23357
23358 \size footnotesize 
23359 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
23360 \layout Standard
23361
23362
23363 \size footnotesize 
23364 \SpecialChar ~
23365 \SpecialChar ~
23366 dec r5
23367 \layout Standard
23368
23369
23370 \size footnotesize 
23371 \SpecialChar ~
23372 \SpecialChar ~
23373 cjne r5,#0xff,00104$
23374 \layout Standard
23375
23376
23377 \size footnotesize 
23378 \SpecialChar ~
23379 \SpecialChar ~
23380 dec r6
23381 \layout Standard
23382
23383
23384 \size footnotesize 
23385 ; goto _forcond_0($4)
23386 \layout Standard
23387
23388
23389 \size footnotesize 
23390 \SpecialChar ~
23391 \SpecialChar ~
23392 sjmp 00104$
23393 \layout Standard
23394
23395
23396 \size footnotesize 
23397 ; _forbreak_0($7) :
23398 \layout Standard
23399
23400
23401 \size footnotesize 
23402 00107$:
23403 \layout Standard
23404
23405
23406 \size footnotesize 
23407 ; ret iTemp24 [lr40:41]{short}
23408 \layout Standard
23409
23410
23411 \size footnotesize 
23412 \SpecialChar ~
23413 \SpecialChar ~
23414 mov a,r3
23415 \layout Standard
23416
23417
23418 \size footnotesize 
23419 \SpecialChar ~
23420 \SpecialChar ~
23421 add a,r2
23422 \layout Standard
23423
23424
23425 \size footnotesize 
23426 \SpecialChar ~
23427 \SpecialChar ~
23428 mov dpl,a
23429 \layout Standard
23430
23431
23432 \size footnotesize 
23433 ; _return($8) :
23434 \layout Standard
23435
23436
23437 \size footnotesize 
23438 00108$:
23439 \layout Standard
23440
23441
23442 \size footnotesize 
23443 \SpecialChar ~
23444 \SpecialChar ~
23445 ret
23446 \newline 
23447
23448 \layout Section
23449
23450 A few words about basic block successors, predecessors and dominators
23451 \layout Standard
23452
23453 Successors are basic blocks
23454 \begin_inset LatexCommand \index{Basic blocks}
23455
23456 \end_inset 
23457
23458  that might execute after this basic block.
23459 \newline 
23460 Predecessors are basic blocks that might execute before reaching this basic
23461  block.
23462 \newline 
23463 Dominators are basic blocks that WILL execute before reaching this basic
23464  block.
23465 \newline 
23466
23467 \layout Standard
23468
23469 [basic block 1]
23470 \layout Standard
23471
23472 if (something)
23473 \layout Standard
23474
23475 \SpecialChar ~
23476 \SpecialChar ~
23477 \SpecialChar ~
23478 \SpecialChar ~
23479 [basic block 2]
23480 \layout Standard
23481
23482 else
23483 \layout Standard
23484
23485 \SpecialChar ~
23486 \SpecialChar ~
23487 \SpecialChar ~
23488 \SpecialChar ~
23489 [basic block 3]
23490 \layout Standard
23491
23492 [basic block 4]
23493 \newline 
23494
23495 \layout Standard
23496
23497 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
23498 \layout Standard
23499
23500 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
23501 \layout Standard
23502
23503 c) domVect of [BB4] = BB1 ...
23504  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
23505  was executed.
23506 \layout Chapter
23507
23508 Acknowledgments
23509 \layout Standard
23510
23511
23512 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
23513
23514 \end_inset 
23515
23516
23517 \newline 
23518
23519 \newline 
23520
23521 \emph on 
23522 Thanks to all the other volunteer developers who have helped with coding,
23523  testing, web-page creation, distribution sets, etc.
23524  You know who you are :-)
23525 \emph default 
23526
23527 \newline 
23528
23529 \layout Standard
23530
23531 This document was initially written by Sandeep Dutta
23532 \layout Standard
23533
23534 All product names mentioned herein may be trademarks
23535 \begin_inset LatexCommand \index{Trademarks}
23536
23537 \end_inset 
23538
23539  of their respective companies.
23540  
23541 \layout Section*
23542
23543 Alphabetical index
23544 \layout Standard
23545
23546 To avoid confusion, the installation and building options for SDCC itself
23547  (chapter 2) are not part of the index.
23548 \layout Standard
23549
23550
23551 \begin_inset LatexCommand \printindex{}
23552
23553 \end_inset 
23554
23555
23556 \the_end