a small hack to fix the double dash --problem
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 220
3 \textclass article
4 \language english
5 \inputencoding default
6 \fontscheme pslatex
7 \graphics default
8 \paperfontsize default
9 \spacing single 
10 \papersize Default
11 \paperpackage a4
12 \use_geometry 0
13 \use_amsmath 0
14 \use_natbib 0
15 \use_numerical_citations 0
16 \paperorientation portrait
17 \secnumdepth 3
18 \tocdepth 3
19 \paragraph_separation indent
20 \defskip medskip
21 \quotes_language swedish
22 \quotes_times 2
23 \papercolumns 1
24 \papersides 1
25 \paperpagestyle fancy
26
27 \layout Comment
28
29 Please note: double dashed options (e.g.
30  --version) need three dashes in this document to be visable in html and
31  pdf output.
32 \layout Title
33
34 SDCC Compiler User Guide
35 \layout Standard
36
37
38 \begin_inset LatexCommand \tableofcontents{}
39
40 \end_inset 
41
42
43 \layout Section
44
45 Introduction
46 \layout Subsection
47
48 About SDCC
49 \layout Standard
50
51
52 \series bold 
53 SDCC
54 \series default 
55  is a Freeware, retargettable, optimizing ANSI-C compiler by 
56 \series bold 
57 Sandeep Dutta
58 \series default 
59  designed for 8 bit Microprocessors.
60  The current version targets Intel MCS51 based Microprocessors(8051,8052,
61  etc), Zilog Z80 based MCUs, and the Dallas DS80C390 variant.
62  It can be retargetted for other microprocessors, support for PIC, AVR and
63  186 is under development.
64  The entire source code for the compiler is distributed under GPL.
65  SDCC uses ASXXXX & ASLINK, a Freeware, retargettable assembler & linker.
66  SDCC has extensive language extensions suitable for utilizing various microcont
67 rollers and underlying hardware effectively.
68  
69 \newline 
70
71 \newline 
72 In addition to the MCU specific optimizations SDCC also does a host of standard
73  optimizations like:
74 \layout Itemize
75
76 global sub expression elimination, 
77 \layout Itemize
78
79 loop optimizations (loop invariant, strength reduction of induction variables
80  and loop reversing), 
81 \layout Itemize
82
83 constant folding & propagation, 
84 \layout Itemize
85
86 copy propagation, 
87 \layout Itemize
88
89 dead code elimination 
90 \layout Itemize
91
92 jumptables for 
93 \emph on 
94 switch
95 \emph default 
96  statements.
97 \layout Standard
98
99 For the back-end SDCC uses a global register allocation scheme which should
100  be well suited for other 8 bit MCUs.
101  
102 \newline 
103
104 \newline 
105 The peep hole optimizer uses a rule based substitution mechanism which is
106  MCU independent.
107  
108 \newline 
109
110 \newline 
111 Supported data-types are:
112 \layout Itemize
113
114 char (8 bits, 1 byte), 
115 \layout Itemize
116
117 short and int (16 bits, 2 bytes), 
118 \layout Itemize
119
120 long (32 bit, 4 bytes)
121 \layout Itemize
122
123 float (4 byte IEEE).
124  
125 \layout Standard
126
127 The compiler also allows 
128 \emph on 
129 inline assembler code
130 \emph default 
131  to be embedded anywhere in a function.
132  In addition, routines developed in assembly can also be called.
133 \newline 
134
135 \newline 
136 SDCC also provides an option (---cyclomatic) to report the relative complexity
137  of a function.
138  These functions can then be further optimized, or hand coded in assembly
139  if needed.
140  
141 \newline 
142
143 \newline 
144 SDCC also comes with a companion source level debugger SDCDB, the debugger
145  currently uses ucSim a freeware simulator for 8051 and other micro-controllers.
146  
147 \newline 
148
149 \newline 
150 The latest version can be downloaded from 
151 \begin_inset LatexCommand \htmlurl{http://sdcc.sourceforge.net/}
152
153 \end_inset 
154
155
156 \series bold 
157 .
158 \layout Subsection
159
160 Open Source
161 \layout Standard
162
163 All packages used in this compiler system are 
164 \emph on 
165 opensource
166 \emph default 
167  and 
168 \emph on 
169 freeware
170 \emph default 
171 ; source code for all the sub-packages (pre-processor, assemblers, linkers
172  etc) is distributed with the package.
173  This documentation is maintained using a freeware word processor (LyX).
174 \newline 
175 This program is free software; you can redistribute it and/or modify it
176  under the terms of the GNU General Public License as published by the Free
177  Software Foundation; either version 2, or (at your option) any later version.
178  This program is distributed in the hope that it will be useful, but WITHOUT
179  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
180  FOR A PARTICULAR PURPOSE.
181  See the GNU General Public License for more details.
182  You should have received a copy of the GNU General Public License along
183  with this program; if not, write to the Free Software Foundation, 59 Temple
184  Place - Suite 330, Boston, MA 02111-1307, USA.
185  In other words, you are welcome to use, share and improve this program.
186  You are forbidden to forbid anyone else to use, share and improve what
187  you give them.
188  Help stamp out software-hoarding! 
189 \layout Subsection
190
191 Typographic conventions
192 \layout Standard
193
194 Throughout this manual, we will use the following convention.
195  Commands you have to type in are printed in 
196 \family sans 
197 \series bold 
198 "sans serif"
199 \series default 
200 .
201
202 \family default 
203  Code samples are printed in 
204 \family typewriter 
205 typewriter font.
206
207 \family default 
208  Interesting items and new terms are printed in 
209 \emph on 
210 italic.
211 \layout Subsection
212
213 Compatibility with previous versions
214 \layout Standard
215
216 This version has numerous bug fixes compared with the previous version.
217  But we also introduced some incompatibilities with older versions.
218  Not just for the fun of it, but to make the compiler more stable, efficient
219  and ANSI compliant.
220  
221 \newline 
222
223 \layout Itemize
224
225 short is now equivalent to int (16 bits), it used to be equivalent to char
226  (8 bits) which is not ANSI compliant
227 \layout Itemize
228
229 the default directory where include, library and documention files are stored
230  is now in /usr/local/share
231 \layout Itemize
232
233 char type parameters to vararg functions are casted to int unless explicitly
234  casted, e.g.: 
235 \newline 
236
237 \family typewriter 
238 \SpecialChar ~
239 \SpecialChar ~
240 char a=3;
241 \newline 
242 \SpecialChar ~
243 \SpecialChar ~
244 printf ("%d %c
245 \backslash 
246 n", a, (char)a);
247 \family default 
248
249 \newline 
250  will push a as an int and as a char resp.
251 \layout Itemize
252
253 option ---regextend has been removed
254 \layout Itemize
255
256 option ---noregparms has been removed
257 \layout Itemize
258
259 option ---stack-after-data has been removed
260 \layout Standard
261
262
263 \emph on 
264 <pending: more incompatibilities?>
265 \layout Subsection
266
267 System Requirements
268 \layout Standard
269
270 What do you need before you start installation of SDCC? A computer, and
271  a desire to compute.
272  The preferred method of installation is to compile SDCC from source using
273  GNU gcc and make.
274  For Windows some pre-compiled binary distributions are available for your
275  convenience.
276  You should have some experience with command line tools and compiler use.
277 \layout Subsection
278
279 Other Resources
280 \layout Standard
281
282 The SDCC home page at 
283 \begin_inset LatexCommand \htmlurl{http://sdcc.sourceforge.net/}
284
285 \end_inset 
286
287  is a great place to find distribution sets.
288  You can also find links to the user mailing lists that offer help or discuss
289  SDCC with other SDCC users.
290  Web links to other SDCC related sites can also be found here.
291  This document can be found in the DOC directory of the source package as
292  a text or HTML file.
293  Some of the other tools (simulator and assembler) included with SDCC contain
294  their own documentation and can be found in the source distribution.
295  If you want the latest unreleased software, the complete source package
296  is available directly by anonymous CVS on cvs.sdcc.sourceforge.net.
297 \layout Subsection
298
299 Wishes for the future
300 \layout Standard
301
302 There are (and always will be) some things that could be done.
303  Here are some I can think of:
304 \newline 
305
306 \layout Standard
307
308
309 \family typewriter 
310 char KernelFunction3(char p) at 0x340;
311 \newline 
312
313 \newline 
314
315 \family default 
316 If you can think of some more, please send them to the list.
317 \newline 
318
319 \newline 
320
321 \emph on 
322 <pending: And then of course a proper index-table
323 \begin_inset LatexCommand \index{index}
324
325 \end_inset 
326
327 >
328 \layout Section
329
330 Installation
331 \layout Subsection
332
333 Install and search paths
334 \layout Standard
335
336 Linux (and other gcc-builds like Solaris, Cygwin, Mingw and OSX) by default
337  install in /usr/local.
338  You can override this when configuring with ---prefix-path.
339  Subdirs used will be bin, share/sdcc/include, share/sdcc/lib and share/sdcc/doc.
340 \newline 
341 Windows MSVC and Borland builds will install in one single tree (e.g.
342  /sdcc) with subdirs bin, lib, include and doc.
343 \newline 
344
345 \newline 
346 The paths searched when running the compiler are as follows (the first catch
347  wins):
348 \layout Enumerate
349
350 Binary files (preprocessor, assembler and linker):
351 \newline 
352 - the path of argv[0] (if available)
353 \newline 
354 - getenv(
355 \begin_inset Quotes sld
356 \end_inset 
357
358 SDCC_BIN_PATH
359 \begin_inset Quotes srd
360 \end_inset 
361
362 )
363 \newline 
364 - getenv(
365 \begin_inset Quotes sld
366 \end_inset 
367
368 SDCCHOME
369 \begin_inset Quotes srd
370 \end_inset 
371
372 )/bin
373 \newline 
374 - $PATH
375 \layout Enumerate
376
377 Include files:
378 \newline 
379 - -I dir
380 \newline 
381 - getenv(
382 \begin_inset Quotes sld
383 \end_inset 
384
385 SDCC_INCLUDE_PATH
386 \begin_inset Quotes srd
387 \end_inset 
388
389 )
390 \newline 
391 - getenv(
392 \begin_inset Quotes sld
393 \end_inset 
394
395 SDCCHOME)/include
396 \newline 
397 - /usr/local/share/sdcc/include (gcc builds)
398 \newline 
399 - path(arv[0])/../include and then /sdcc/include (as a last resort for windoze
400  msvc and borland builds)
401 \layout Enumerate
402
403 Library files (the 
404 \shape italic 
405 model
406 \shape default 
407  is auto-appended by the compiler, e.g.
408  small, large, z80, ds390 etc.):
409 \newline 
410 - -L dir
411 \newline 
412 - getenv(
413 \begin_inset Quotes sld
414 \end_inset 
415
416 SDCC_LIB_PATH
417 \begin_inset Quotes srd
418 \end_inset 
419
420 )/
421 \shape italic 
422 model
423 \shape default 
424
425 \newline 
426 - getenv(
427 \begin_inset Quotes sld
428 \end_inset 
429
430 SDCCHOME
431 \begin_inset Quotes srd
432 \end_inset 
433
434 )/lib/
435 \shape italic 
436 model
437 \shape default 
438
439 \newline 
440 - /usr/local/share/sdcc/lib/
441 \shape italic 
442 model
443 \shape default 
444  (gcc builds)
445 \newline 
446 - path(argv[0])/../lib/
447 \shape italic 
448 model
449 \shape default 
450  and then /sdcc/lib/
451 \shape italic 
452 model
453 \shape default 
454  (as a last resort for windoze msvc and borland builds)
455 \layout Enumerate
456
457 Documentation (although never really searched for, you have to do that yourself
458  :):
459 \newline 
460 - getenv(
461 \begin_inset Quotes sld
462 \end_inset 
463
464 SDCCHOME
465 \begin_inset Quotes srd
466 \end_inset 
467
468 )/doc
469 \newline 
470 - /usr/local/share/sdcc/doc (gcc builds)
471 \newline 
472 - /sdcc/doc (windoze msvc and borland builds)
473 \layout Standard
474
475 So, for windoze it is highly recommended to set the environment variable
476  SDCCHOME to prevent needless usage of -I and -L.
477 \layout Subsection
478
479 Linux and other gcc-based systems (cygwin, mingw, osx)
480 \layout Enumerate
481
482
483 \series medium 
484 Download the source package
485 \series default 
486  either from the SDCC CVS repository or from the 
487 \begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
488
489 \end_inset 
490
491
492 \series medium 
493 , it will be named something like sdcc
494 \series default 
495 .src
496 \series medium 
497 .tgz.
498 \layout Enumerate
499
500
501 \series medium 
502 Bring up a command line terminal, such as xterm.
503 \layout Enumerate
504
505
506 \series medium 
507 Unpack the file using a command like: 
508 \family sans 
509 \series bold 
510 "tar -xzf sdcc.src.tgz
511 \family default 
512 \series default 
513 "
514 \series medium 
515 , this will create a sub-directory called sdcc with all of the sources.
516 \layout Enumerate
517
518 Change directory into the main SDCC directory, for example type: 
519 \family sans 
520 \series bold 
521 "cd sdcc
522 \series default 
523 ".
524 \layout Enumerate
525
526
527 \series medium 
528 Type 
529 \family sans 
530 \series bold 
531 "./configure
532 \family default 
533 \series default 
534 ".
535  This configures the package for compilation on your system.
536 \layout Enumerate
537
538
539 \series medium 
540 Type 
541 \family sans 
542 \series bold 
543 "make
544 \family default 
545 \series default 
546 "
547 \series medium 
548 .
549
550 \series default 
551  All of the source packages will compile, this can take a while.
552 \layout Enumerate
553
554
555 \series medium 
556 Type 
557 \family sans 
558 \series bold 
559 "make install"
560 \family default 
561 \series default 
562  as root
563 \series medium 
564 .
565
566 \series default 
567  This copies the binary executables, the include files, the libraries and
568  the documentation to the install directories.
569 \layout Subsection
570
571 Windows 
572 \layout Subsubsection
573
574 Windows Install Using a Binary Package
575 \layout Enumerate
576
577 Download the binary package and unpack it using your favorite unpacking
578  tool (gunzip, WinZip, etc).
579  This should unpack to a group of sub-directories.
580  An example directory structure after unpacking the mingw package is: c:
581 \backslash 
582 usr
583 \backslash 
584 local
585 \backslash 
586 bin for the executables, c:
587 \backslash 
588 usr
589 \backslash 
590 local
591 \backslash 
592 share
593 \backslash 
594 sdcc
595 \backslash 
596 include and c:
597 \backslash 
598 usr
599 \backslash 
600 local
601 \backslash 
602 share
603 \backslash 
604 sdcc
605 \backslash 
606 lib for the include and libraries.
607 \layout Enumerate
608
609 Adjust your environment variable PATH to include the location of the bin
610  directory or start sdcc using the full path.
611 \layout Subsubsection
612
613 Windows Install Using Cygwin and Mingw
614 \layout Standard
615
616 Follow the instruction in 
617 \series bold 
618 Linux and other gcc-based systems
619 \series default 
620 .
621 \layout Subsubsection
622
623 Windows Install Using Microsoft Visual C++ 6.0/NET
624 \layout Standard
625
626
627 \series medium 
628 Download the source package
629 \series default 
630  either from the SDCC CVS repository or from the 
631 \begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
632
633 \end_inset 
634
635
636 \series medium 
637 , it will be named something like sdcc
638 \series default 
639 .src
640 \series medium 
641 .tgz.
642
643 \series default 
644  SDCC is distributed with all the projects, workspaces, and files you need
645  to build it using Visual C++ 6.0/NET.
646  The workspace name is 'sdcc.dsw'.
647  Please note that as it is now, all the executables are created in a folder
648  called sdcc
649 \backslash 
650 bin_vc.
651  Once built you need to copy the executables from sdcc
652 \backslash 
653 bin_vc to sdcc
654 \backslash 
655 bin before runnng SDCC.
656  
657 \newline 
658
659 \newline 
660 In order to build SDCC with Visual C++ 6.0/NET you need win32 executables
661  of bison.exe, flex.exe, and gawk.exe.
662  One good place to get them is 
663 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
664
665 \end_inset 
666
667
668 \newline 
669
670 \newline 
671 Download the file UnxUtils.zip.
672  Now you have to install the utilities and setup Visual C++ so it can locate
673  the required programs.
674  Here there are two alternatives (choose one!):
675 \layout Enumerate
676
677 The easy way:
678 \newline 
679
680 \newline 
681 a) Extract UnxUtils.zip to your C:
682 \backslash 
683  hard disk PRESERVING the original paths, otherwise bison won't work.
684  (If you are using WinZip make certain that 'Use folder names' is selected)
685 \newline 
686
687 \newline 
688 b) In the Visual C++ IDE click Tools, Options, select the Directory tab,
689  in 'Show directories for:' select 'Executable files', and in the directories
690  window add a new path: 'C:
691 \backslash 
692 user
693 \backslash 
694 local
695 \backslash 
696 wbin', click ok.
697 \newline 
698
699 \newline 
700 (As a side effect, you get a bunch of Unix utilities that could be useful,
701  such as diff and patch.)
702 \layout Enumerate
703
704 A more compact way:
705 \newline 
706
707 \newline 
708 This one avoids extracting a bunch of files you may not use, but requires
709  some extra work:
710 \newline 
711
712 \newline 
713 a) Create a directory were to put the tools needed, or use a directory already
714  present.
715  Say for example 'C:
716 \backslash 
717 util'.
718 \newline 
719
720 \newline 
721 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and gawk.exe
722  to such directory WITHOUT preserving the original paths.
723  (If you are using WinZip make certain that 'Use folder names' is not selected)
724 \newline 
725
726 \newline 
727 c) Rename bison.exe to '_bison.exe'.
728 \newline 
729
730 \newline 
731 d) Create a batch file 'bison.bat' in 'C:
732 \backslash 
733 util
734 \backslash 
735 ' and add these lines: 
736 \newline 
737 \SpecialChar ~
738 \SpecialChar ~
739 set BISON_SIMPLE=C:
740 \backslash 
741 util
742 \backslash 
743 bison.simple 
744 \newline 
745 \SpecialChar ~
746 \SpecialChar ~
747 set BISON_HAIRY=C:
748 \backslash 
749 util
750 \backslash 
751 bison.hairy
752 \newline 
753 \SpecialChar ~
754 \SpecialChar ~
755 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
756 \newline 
757
758 \newline 
759 Steps 'c' and 'd' are needed because bison requires by default that the
760  files 'bison.simple' and 'bison.hairy' reside in some weird Unix directory,
761  '/usr/local/share/' I think.
762  So it is necessary to tell bison where those files are located if they
763  are not in such directory.
764  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
765 \newline 
766
767 \newline 
768 e) In the Visual C++ IDE click Tools, Options, select the Directory tab,
769  in 'Show directories for:' select 'Executable files', and in the directories
770  window add a new path: 'c:
771 \backslash 
772 util', click ok.
773  Note that you can use any other path instead of 'c:
774 \backslash 
775 util', even the path where the Visual C++ tools are, probably: 'C:
776 \backslash 
777 Program Files
778 \backslash 
779 Microsoft Visual Studio
780 \backslash 
781 Common
782 \backslash 
783 Tools'.
784  So you don't have to execute step 'e' :)
785 \layout Standard
786
787 That is it.
788  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
789  the executables from sdcc
790 \backslash 
791 bin_vc to sdcc
792 \backslash 
793 bin, and you can compile using sdcc.
794 \layout Subsubsection
795
796 Windows Install Using Borland ......
797 \layout Standard
798
799
800 \shape italic 
801 <pending>
802 \layout Subsection
803
804 Testing out the SDCC Compiler
805 \layout Standard
806
807 The first thing you should do after installing your SDCC compiler is to
808  see if it runs.
809  Type 
810 \family sans 
811 \series bold 
812 "sdcc ---version"
813 \family default 
814 \series default 
815  at the prompt, and the program should run and tell you the version.
816  If it doesn't run, or gives a message about not finding sdcc program, then
817  you need to check over your installation.
818  Make sure that the sdcc bin directory is in your executable search path
819  defined by the PATH environment setting (see the Trouble-shooting section
820  for suggestions).
821  Make sure that the sdcc program is in the bin folder, if not perhaps something
822  did not install correctly.
823 \newline 
824
825 \newline 
826
827 \series medium 
828 SDCC binaries are commonly installed in a directory arrangement like this:
829 \series default 
830
831 \newline 
832
833 \newline 
834
835 \begin_inset  Tabular
836 <lyxtabular version="3" rows="3" columns="2">
837 <features>
838 <column alignment="left" valignment="top" leftline="true" width="0(null)">
839 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0(null)">
840 <row topline="true" bottomline="true">
841 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
842 \begin_inset Text
843
844 \layout Standard
845
846 /
847 \series medium 
848 usr/local/bin
849 \end_inset 
850 </cell>
851 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
852 \begin_inset Text
853
854 \layout Standard
855
856
857 \series medium 
858 Holds executables(sdcc, s51, aslink, 
859 \series default 
860 ...
861 \series medium 
862 )
863 \end_inset 
864 </cell>
865 </row>
866 <row topline="true">
867 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
868 \begin_inset Text
869
870 \layout Standard
871
872 /
873 \series medium 
874 usr/local/share/sdcc/lib 
875 \end_inset 
876 </cell>
877 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
878 \begin_inset Text
879
880 \layout Standard
881
882
883 \series medium 
884 Holds common C 
885 \series default 
886 libraries
887 \end_inset 
888 </cell>
889 </row>
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 /
897 \series medium 
898 usr/local/share/sdcc/include
899 \end_inset 
900 </cell>
901 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
902 \begin_inset Text
903
904 \layout Standard
905
906
907 \series medium 
908 Holds common C header files
909 \end_inset 
910 </cell>
911 </row>
912 </lyxtabular>
913
914 \end_inset 
915
916
917 \newline 
918
919 \newline 
920
921 \series medium 
922 Make sure the compiler works on a very simple example.
923  Type in the following test.c program using your favorite editor:
924 \series default 
925
926 \newline 
927
928 \family typewriter 
929
930 \newline 
931 char test;
932 \newline 
933
934 \newline 
935 void main(void) {
936 \newline 
937 \SpecialChar ~
938 \SpecialChar ~
939 \SpecialChar ~
940 \SpecialChar ~
941 test=0;
942 \newline 
943 }
944 \family default 
945
946 \newline 
947
948 \emph on 
949
950 \newline 
951
952 \series medium 
953 \emph default 
954 Compile this using the following command: 
955 \family sans 
956 \series bold 
957 "sdcc -c test.c".
958
959 \family default 
960 \series default 
961  
962 \series medium 
963 If all goes well, the compiler will generate a test.asm and test.rel file.
964  Congratulations, you've just compiled your first program with SDCC.
965  We used the -c option to tell SDCC not to link the generated code, just
966  to keep things simple for this step.
967 \series default 
968
969 \newline 
970
971 \newline 
972
973 \series medium 
974 The next step is to try it with the linker.
975  Type in 
976 \family sans 
977 \series bold 
978 "sdcc test.c
979 \family default 
980 \series default 
981 "
982 \series medium 
983 .
984  If all goes well the compiler will link with the libraries and produce
985  a test.ihx output file.
986  If this step fails
987 \series default 
988  
989 \series medium 
990 (no test.ihx, and the linker generates warnings), then the problem is most
991  likely that sdcc cannot find the 
992 \series default 
993 /
994 \series medium 
995 usr/local/share/sdcc/lib directory
996 \series default 
997  
998 \series medium 
999 (see the Install trouble-shooting section for suggestions).
1000 \series default 
1001
1002 \newline 
1003
1004 \newline 
1005
1006 \series medium 
1007 The final test is to ensure sdcc can use the 
1008 \series default 
1009 standard
1010 \series medium 
1011  header files and libraries.
1012  Edit test.c and change it to the following:
1013 \series default 
1014
1015 \newline 
1016
1017 \newline 
1018
1019 \family typewriter 
1020 #include <string.h>
1021 \newline 
1022
1023 \newline 
1024 char str1[10];
1025 \newline 
1026
1027 \newline 
1028 void main(void) {
1029 \newline 
1030 \SpecialChar ~
1031 \SpecialChar ~
1032 strcpy(str1, "testing");
1033 \newline 
1034 }
1035 \newline 
1036
1037 \newline 
1038
1039 \family default 
1040 \series medium 
1041 Compile this by typing 
1042 \family sans 
1043 \series bold 
1044 "sdcc test.c"
1045 \family default 
1046 \series medium 
1047 .
1048  This should generate a test.ihx output file, and it should give no warnings
1049  such as not finding the string.h file.
1050  If it cannot find the string.h file, then the problem is that sdcc cannot
1051  find the /usr/local/share/sdcc/include directory
1052 \series default 
1053  
1054 \series medium 
1055 (see the Install trouble-shooting section for suggestions).
1056 \layout Subsection
1057
1058 Install Trouble-shooting
1059 \layout Subsubsection
1060
1061 SDCC does not build correctly.
1062 \layout Standard
1063
1064 A thing to try is starting from scratch by unpacking the .tgz source package
1065  again in an empty directory.
1066  Confure it like:
1067 \newline 
1068
1069 \newline 
1070
1071 \family typewriter 
1072 ./configure 2>&1 | tee configure.log
1073 \family default 
1074
1075 \newline 
1076
1077 \newline 
1078 and build it like:
1079 \newline 
1080
1081 \newline 
1082
1083 \family typewriter 
1084 make 2>&1 | tee make.log
1085 \family default 
1086
1087 \newline 
1088
1089 \newline 
1090 If anything goes wrong, you can review the log files to locate the problem.
1091  Or a relevant part of this can be attached to an email that could be helpful
1092  when requesting help from the mailing list.
1093 \layout Subsubsection
1094
1095 What the 
1096 \begin_inset Quotes sld
1097 \end_inset 
1098
1099 ./configure
1100 \begin_inset Quotes srd
1101 \end_inset 
1102
1103  does
1104 \layout Standard
1105
1106 The 
1107 \begin_inset Quotes sld
1108 \end_inset 
1109
1110 ./configure
1111 \begin_inset Quotes srd
1112 \end_inset 
1113
1114  command is a script that analyzes your system and performs some configuration
1115  to ensure the source package compiles on your system.
1116  It will take a few minutes to run, and will compile a few tests to determine
1117  what compiler features are installed.
1118 \layout Subsubsection
1119
1120 What the 
1121 \begin_inset Quotes sld
1122 \end_inset 
1123
1124 make
1125 \begin_inset Quotes srd
1126 \end_inset 
1127
1128  does.
1129 \layout Standard
1130
1131 This runs the GNU make tool, which automatically compiles all the source
1132  packages into the final installed binary executables.
1133 \layout Subsubsection
1134
1135 What the 
1136 \begin_inset Quotes sld
1137 \end_inset 
1138
1139 make install
1140 \begin_inset Quotes erd
1141 \end_inset 
1142
1143  command does.
1144 \layout Standard
1145
1146 This will install the compiler, other executables and libraries in to the
1147  appropriate system directories.
1148  The default is to copy the executables to /usr/local/bin and the libraries
1149  and header files to /usr/local/share/sdcc/lib and /usr/local/share/sdcc/include.
1150  On most systems you will need super-user privilages to do this.
1151 \layout Subsection
1152
1153 Advanced Install Options
1154 \layout Standard
1155
1156 The 
1157 \begin_inset Quotes eld
1158 \end_inset 
1159
1160 configure
1161 \begin_inset Quotes erd
1162 \end_inset 
1163
1164  command has several options.
1165  The most commonly used option is ---prefix=<directory name>, where <directory
1166  name> is the final location for the sdcc executables and libraries, (default
1167  location is /usr/local).
1168  The installation process will create the following directory structure
1169  under the <directory name> specified (if they do not already exist).
1170  
1171 \newline 
1172
1173 \newline 
1174 bin/ - binary exectables (add to PATH environment variable)
1175 \newline 
1176 bin/share/
1177 \newline 
1178 bin/share/sdcc/include/ - include header files
1179 \newline 
1180 bin/share/sdcc/lib/
1181 \newline 
1182 bin/share/sdcc/lib/small/ - Object & library files for small model library
1183 \newline 
1184 bin/share/sdcc/lib/large/ - Object & library files for large model library
1185 \newline 
1186 bin/share/sdcc/lib/ds390/ - Object & library files for DS80C390 library
1187 \newline 
1188 bin/share/sdcc/lib/z80/ - Object & library files for Z80 library
1189 \newline 
1190
1191 \newline 
1192 The command 
1193 \family sans 
1194 \series bold 
1195
1196 \begin_inset Quotes sld
1197 \end_inset 
1198
1199 ./configure ---prefix=/usr/local
1200 \begin_inset Quotes erd
1201 \end_inset 
1202
1203  
1204 \family default 
1205 \series default 
1206 will configure the compiler to be installed in directory /usr/local.
1207 \layout Subsection
1208
1209 Components of SDCC
1210 \layout Standard
1211
1212 SDCC is not just a compiler, but a collection of tools by various developers.
1213  These include linkers, assemblers, simulators and other components.
1214  Here is a summary of some of the components.
1215  Note that the included simulator and assembler have separate documentation
1216  which you can find in the source package in their respective directories.
1217  As SDCC grows to include support for other processors, other packages from
1218  various developers are included and may have their own sets of documentation.
1219 \newline 
1220
1221 \newline 
1222 You might want to look at the files which are installed in <installdir>.
1223  At the time of this writing, we find the following programs:
1224 \newline 
1225  
1226 \newline 
1227 In <installdir>/bin:
1228 \layout Itemize
1229
1230 sdcc - The compiler.
1231 \layout Itemize
1232
1233 sdcpp - The C preprocessor.
1234 \layout Itemize
1235
1236 asx8051 - The assembler for 8051 type processors.
1237 \layout Itemize
1238
1239 as-z80
1240 \series bold 
1241
1242 \series default 
1243 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
1244 \layout Itemize
1245
1246 aslink -The linker for 8051 type processors.
1247 \layout Itemize
1248
1249 link-z80
1250 \series bold 
1251
1252 \series default 
1253 link-gbz80 - The Z80 and GameBoy Z80 linkers.
1254 \layout Itemize
1255
1256 s51 - The ucSim 8051 simulator.
1257 \layout Itemize
1258
1259 sdcdb - The source debugger.
1260 \layout Itemize
1261
1262 packihx - A tool to pack (compress) Intel hex files.
1263 \layout Standard
1264
1265 In <installdir>/share/sdcc/include
1266 \layout Itemize
1267
1268 the include files
1269 \layout Standard
1270
1271 In <installdir>/share/sdcc/lib
1272 \layout Itemize
1273
1274 the sources of the runtime library and the subdirs small large and ds390
1275  with the precompiled relocatables.
1276 \layout Standard
1277
1278 In <installdir>/share/sdcc/doc
1279 \layout Itemize
1280
1281 the documentation
1282 \layout Standard
1283
1284 As development for other processors proceeds, this list will expand to include
1285  executables to support processors like AVR, PIC, etc.
1286 \layout Subsubsection
1287
1288 sdcc - The Compiler
1289 \layout Standard
1290
1291 This is the actual compiler, it in turn uses the c-preprocessor and invokes
1292  the assembler and linkage editor.
1293 \layout Subsubsection
1294
1295 sdcpp - The C-Preprocessor
1296 \layout Standard
1297
1298 The preprocessor is a modified version of the GNU preprocessor.
1299  The C preprocessor is used to pull in #include sources, process #ifdef
1300  statements, #defines and so on.
1301 \layout Subsubsection
1302
1303 asx8051, as-z80, as-gbz80, aslink, link-z80, link-gbz80 - The Assemblers
1304  and Linkage Editors
1305 \layout Standard
1306
1307 This is retargettable assembler & linkage editor, it was developed by Alan
1308  Baldwin.
1309  John Hartman created the version for 8051, and I (Sandeep) have made some
1310  enhancements and bug fixes for it to work properly with the SDCC.
1311 \layout Subsubsection
1312
1313 s51 - The Simulator
1314 \layout Standard
1315
1316 S51 is a freeware, opensource simulator developed by Daniel Drotos (
1317 \begin_inset LatexCommand \url{mailto:drdani@mazsola.iit.uni-miskolc.hu}
1318
1319 \end_inset 
1320
1321 ).
1322  The simulator is built as part of the build process.
1323  For more information visit Daniel's website at: 
1324 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
1325
1326 \end_inset 
1327
1328 .
1329  It currently support the core mcs51, the Dallas DS80C390 and the Philips
1330  XA51 family.
1331 \layout Subsubsection
1332
1333 sdcdb - Source Level Debugger
1334 \layout Standard
1335
1336
1337 \family typewriter 
1338 \shape italic 
1339 <todo: is this thing alive?>
1340 \newline 
1341
1342 \newline 
1343
1344 \family default 
1345 \shape default 
1346 Sdcdb is the companion source level debugger.
1347  The current version of the debugger uses Daniel's Simulator S51, but can
1348  be easily changed to use other simulators.
1349 \layout Section
1350
1351 Using SDCC
1352 \layout Subsection
1353
1354 Compiling
1355 \layout Subsubsection
1356
1357 Single Source File Projects
1358 \layout Standard
1359
1360 For single source file 8051 projects the process is very simple.
1361  Compile your programs with the following command 
1362 \family sans 
1363 \series bold 
1364 "sdcc sourcefile.c".
1365
1366 \family default 
1367 \series default 
1368  This will compile, assemble and link your source file.
1369  Output files are as follows
1370 \newline 
1371
1372 \newline 
1373 sourcefile.asm - Assembler source file created by the compiler
1374 \newline 
1375 sourcefile.lst - Assembler listing file created by the Assembler
1376 \newline 
1377 sourcefile.rst - Assembler listing file updated with linkedit information,
1378  created by linkage editor
1379 \newline 
1380 sourcefile.sym - symbol listing for the sourcefile, created by the assembler
1381 \newline 
1382 sourcefile.rel - Object file created by the assembler, input to Linkage editor
1383 \newline 
1384 sourcefile.map - The memory map for the load module, created by the Linker
1385 \newline 
1386 sourcefile.ihx - The load module in Intel hex format (you can select the
1387  Motorola S19 format with ---out-fmt-s19)
1388 \newline 
1389 sourcefile.cdb - An optional file (with ---debug) containing debug information
1390 \newline 
1391
1392 \layout Subsubsection
1393
1394 Projects with Multiple Source Files
1395 \layout Standard
1396
1397 SDCC can compile only ONE file at a time.
1398  Let us for example assume that you have a project containing the following
1399  files:
1400 \newline 
1401
1402 \newline 
1403 foo1.c (contains some functions)
1404 \newline 
1405 foo2.c (contains some more functions)
1406 \newline 
1407 foomain.c (contains more functions and the function main)
1408 \newline 
1409
1410 \size footnotesize 
1411
1412 \newline 
1413
1414 \size default 
1415 The first two files will need to be compiled separately with the commands:
1416 \size footnotesize 
1417  
1418 \size default 
1419
1420 \newline 
1421
1422 \newline 
1423
1424 \family sans 
1425 \series bold 
1426 sdcc\SpecialChar ~
1427 -c\SpecialChar ~
1428 foo1.c
1429 \family default 
1430 \series default 
1431 \size footnotesize 
1432
1433 \newline 
1434
1435 \family sans 
1436 \series bold 
1437 \size default 
1438 sdcc\SpecialChar ~
1439 -c\SpecialChar ~
1440 foo2.c
1441 \family default 
1442 \series default 
1443
1444 \newline 
1445
1446 \newline 
1447 Then compile the source file containing the 
1448 \emph on 
1449 main()
1450 \emph default 
1451  function and link the files together with the following command: 
1452 \newline 
1453
1454 \newline 
1455
1456 \family sans 
1457 \series bold 
1458 sdcc\SpecialChar ~
1459 foomain.c\SpecialChar ~
1460 foo1.rel\SpecialChar ~
1461 foo2.rel
1462 \family default 
1463 \series default 
1464
1465 \newline 
1466
1467 \newline 
1468 Alternatively, 
1469 \emph on 
1470 foomain.c 
1471 \emph default 
1472 can be separately compiled as well: 
1473 \family sans 
1474 \series bold 
1475
1476 \newline 
1477
1478 \newline 
1479 sdcc\SpecialChar ~
1480 -c\SpecialChar ~
1481 foomain.c
1482 \newline 
1483 sdcc foomain.rel foo1.rel foo2.rel
1484 \newline 
1485
1486 \newline 
1487
1488 \family default 
1489 \series default 
1490 The file containing the 
1491 \emph on 
1492 main()
1493 \emph default 
1494  function
1495 \emph on 
1496  
1497 \emph default 
1498 \noun on 
1499 must
1500 \noun default 
1501  be the 
1502 \noun on 
1503 first
1504 \noun default 
1505  file specified in the command line, since the linkage editor processes
1506  file in the order they are presented to it.
1507 \layout Subsubsection
1508
1509 Projects with Additional Libraries
1510 \layout Standard
1511
1512 Some reusable routines may be compiled into a library, see the documentation
1513  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
1514  for how to create a 
1515 \emph on 
1516 .lib
1517 \emph default 
1518  library file.
1519  Libraries created in this manner can be included in the command line.
1520  Make sure you include the -L <library-path> option to tell the linker where
1521  to look for these files if they are not in the current directory.
1522  Here is an example, assuming you have the source file 
1523 \emph on 
1524 foomain.c
1525 \emph default 
1526  and a library
1527 \emph on 
1528  foolib.lib
1529 \emph default 
1530  in the directory 
1531 \emph on 
1532 mylib
1533 \emph default 
1534  (if that is not the same as your current project):
1535 \newline 
1536
1537 \newline 
1538
1539 \family sans 
1540 \series bold 
1541 sdcc foomain.c foolib.lib -L mylib
1542 \newline 
1543
1544 \newline 
1545
1546 \family default 
1547 \series default 
1548 Note here that
1549 \emph on 
1550  mylib
1551 \emph default 
1552  must be an absolute path name.
1553 \newline 
1554
1555 \newline 
1556 The most efficient way to use libraries is to keep seperate modules in seperate
1557  source files.
1558  The lib file now should name all the modules.rel files.
1559  For an example see the standard library file 
1560 \emph on 
1561 libsdcc.lib
1562 \emph default 
1563  in the directory <installdir>/share/lib/small.
1564 \layout Subsection
1565
1566 Command Line Options
1567 \layout Subsubsection
1568
1569 Processor Selection Options
1570 \layout List
1571 \labelwidthstring 00.00.0000
1572
1573
1574 \series bold 
1575 -mmcs51
1576 \series default 
1577  Generate code for the MCS51 (8051) family of processors.
1578  This is the default processor target.
1579 \layout List
1580 \labelwidthstring 00.00.0000
1581
1582
1583 \series bold 
1584 -mds390
1585 \series default 
1586  Generate code for the DS80C390 processor.
1587 \layout List
1588 \labelwidthstring 00.00.0000
1589
1590
1591 \series bold 
1592 -mz80
1593 \series default 
1594  Generate code for the Z80 family of processors.
1595 \layout List
1596 \labelwidthstring 00.00.0000
1597
1598
1599 \series bold 
1600 -mgbz80
1601 \series default 
1602  Generate code for the GameBoy Z80 processor.
1603 \layout List
1604 \labelwidthstring 00.00.0000
1605
1606
1607 \series bold 
1608 -mavr
1609 \series default 
1610  Generate code for the Atmel AVR processor (In development, not complete).
1611 \layout List
1612 \labelwidthstring 00.00.0000
1613
1614
1615 \series bold 
1616 -mpic14
1617 \series default 
1618  Generate code for the PIC 14-bit processors (In development, not complete).
1619 \layout List
1620 \labelwidthstring 00.00.0000
1621
1622
1623 \series bold 
1624 -mtlcs900h
1625 \series default 
1626  Generate code for the Toshiba TLCS-900H processor (In development, not
1627  complete).
1628 \layout List
1629 \labelwidthstring 00.00.0000
1630
1631
1632 \series bold 
1633 -mxa51
1634 \series default 
1635  Generate code for the Philips XA51 processor (In development, not complete).
1636 \layout Subsubsection
1637
1638 Preprocessor Options
1639 \layout List
1640 \labelwidthstring 00.00.0000
1641
1642
1643 \series bold 
1644 -I<path>
1645 \series default 
1646  The additional location where the pre processor will look for <..h> or 
1647 \begin_inset Quotes eld
1648 \end_inset 
1649
1650 ..h
1651 \begin_inset Quotes erd
1652 \end_inset 
1653
1654  files.
1655 \layout List
1656 \labelwidthstring 00.00.0000
1657
1658
1659 \series bold 
1660 -D<macro[=value]>
1661 \series default 
1662  Command line definition of macros.
1663  Passed to the pre processor.
1664 \layout List
1665 \labelwidthstring 00.00.0000
1666
1667
1668 \series bold 
1669 -M
1670 \series default 
1671  Tell the preprocessor to output a rule suitable for make describing the
1672  dependencies of each object file.
1673  For each source file, the preprocessor outputs one make-rule whose target
1674  is the object file name for that source file and whose dependencies are
1675  all the files `#include'd in it.
1676  This rule may be a single line or may be continued with `
1677 \backslash 
1678 '-newline if it is long.
1679  The list of rules is printed on standard output instead of the preprocessed
1680  C program.
1681  `-M' implies `-E'.
1682 \layout List
1683 \labelwidthstring 00.00.0000
1684
1685
1686 \series bold 
1687 -C
1688 \series default 
1689  Tell the preprocessor not to discard comments.
1690  Used with the `-E' option.
1691 \layout List
1692 \labelwidthstring 00.00.0000
1693
1694
1695 \series bold 
1696 -MM
1697 \size large 
1698 \bar under 
1699  
1700 \series default 
1701 \size default 
1702 \bar default 
1703 Like `-M' but the output mentions only the user header files included with
1704  `#include 
1705 \begin_inset Quotes eld
1706 \end_inset 
1707
1708 file"'.
1709  System header files included with `#include <file>' are omitted.
1710 \layout List
1711 \labelwidthstring 00.00.0000
1712
1713
1714 \series bold 
1715 -Aquestion(answer)
1716 \series default 
1717  Assert the answer answer for question, in case it is tested with a preprocessor
1718  conditional such as `#if #question(answer)'.
1719  `-A-' disables the standard assertions that normally describe the target
1720  machine.
1721 \layout List
1722 \labelwidthstring 00.00.0000
1723
1724
1725 \series bold 
1726 -Aquestion
1727 \series default 
1728  (answer) Assert the answer answer for question, in case it is tested with
1729  a preprocessor conditional such as `#if #question(answer)'.
1730  `-A-' disables the standard assertions that normally describe the target
1731  machine.
1732 \layout List
1733 \labelwidthstring 00.00.0000
1734
1735
1736 \series bold 
1737 -Umacro
1738 \series default 
1739  Undefine macro macro.
1740  `-U' options are evaluated after all `-D' options, but before any `-include'
1741  and `-imacros' options.
1742 \layout List
1743 \labelwidthstring 00.00.0000
1744
1745
1746 \series bold 
1747 -dM
1748 \series default 
1749  Tell the preprocessor to output only a list of the macro definitions that
1750  are in effect at the end of preprocessing.
1751  Used with the `-E' option.
1752 \layout List
1753 \labelwidthstring 00.00.0000
1754
1755
1756 \series bold 
1757 -dD
1758 \series default 
1759  Tell the preprocessor to pass all macro definitions into the output, in
1760  their proper sequence in the rest of the output.
1761 \layout List
1762 \labelwidthstring 00.00.0000
1763
1764
1765 \series bold 
1766 -dN
1767 \size large 
1768 \bar under 
1769  
1770 \series default 
1771 \size default 
1772 \bar default 
1773 Like `-dD' except that the macro arguments and contents are omitted.
1774  Only `#define name' is included in the output.
1775 \layout Subsubsection
1776
1777 Linker Options
1778 \layout List
1779 \labelwidthstring 00.00.0000
1780
1781
1782 \series bold 
1783 -o\SpecialChar ~
1784 <path/file> 
1785 \series default 
1786 the output path resp.
1787  file where everything will be placed
1788 \layout List
1789 \labelwidthstring 00.00.0000
1790
1791
1792 \series bold 
1793 -L\SpecialChar ~
1794 ---lib-path
1795 \bar under 
1796  
1797 \series default 
1798 \bar default 
1799 <absolute path to additional libraries> This option is passed to the linkage
1800  editor's additional libraries search path.
1801  The path name must be absolute.
1802  Additional library files may be specified in the command line.
1803  See section Compiling programs for more details.
1804 \layout List
1805 \labelwidthstring 00.00.0000
1806
1807
1808 \series bold 
1809 ---xram-loc
1810 \series default 
1811 <Value> The start location of the external ram, default value is 0.
1812  The value entered can be in Hexadecimal or Decimal format, e.g.: ---xram-loc
1813  0x8000 or ---xram-loc 32768.
1814 \layout List
1815 \labelwidthstring 00.00.0000
1816
1817
1818 \series bold 
1819 ---code-loc
1820 \series default 
1821 <Value> The start location of the code segment, default value 0.
1822  Note when this option is used the interrupt vector table is also relocated
1823  to the given address.
1824  The value entered can be in Hexadecimal or Decimal format, e.g.: ---code-loc
1825  0x8000 or ---code-loc 32768.
1826 \layout List
1827 \labelwidthstring 00.00.0000
1828
1829
1830 \series bold 
1831 ---stack-loc
1832 \series default 
1833 <Value> By default the stack is placed after the data segment.
1834  Using this option the stack can be placed anywhere in the internal memory
1835  space of the 8051.
1836  The value entered can be in Hexadecimal or Decimal format, e.g.
1837  ---stack-loc 0x20 or ---stack-loc 32.
1838  Since the sp register is incremented before a push or call, the initial
1839  sp will be set to one byte prior the provided value.
1840  The provided value should not overlap any other memory areas such as used
1841  register banks or the data segment and with enough space for the current
1842  application.
1843 \layout List
1844 \labelwidthstring 00.00.0000
1845
1846
1847 \series bold 
1848 ---data-loc
1849 \series default 
1850 <Value> The start location of the internal ram data segment.
1851  The value entered can be in Hexadecimal or Decimal format, eg.
1852  ---data-loc 0x20 or ---data-loc 32.
1853  (By default, the start location of the internal ram data segment  is set
1854  as low as possible in memory, taking into account the used register banks
1855  and the bit segment at address 0x20.
1856  For example if register banks 0 and 1 are used without bit variables, the
1857  data segment will be set, if ---data-loc is not used, to location 0x10.)
1858 \layout List
1859 \labelwidthstring 00.00.0000
1860
1861
1862 \series bold 
1863 ---idata-loc
1864 \series default 
1865 <Value> The start location of the indirectly addressable internal ram, default
1866  value is 0x80.
1867  The value entered can be in Hexadecimal or Decimal format, eg.
1868  ---idata-loc 0x88 or ---idata-loc 136.
1869 \layout List
1870 \labelwidthstring 00.00.0000
1871
1872
1873 \series bold 
1874 ---out-fmt-ihx
1875 \bar under 
1876  
1877 \series default 
1878 \bar default 
1879 The linker output (final object code) is in Intel Hex format.
1880  (This is the default option).
1881 \layout List
1882 \labelwidthstring 00.00.0000
1883
1884
1885 \series bold 
1886 ---out-fmt-s19
1887 \bar under 
1888  
1889 \series default 
1890 \bar default 
1891 The linker output (final object code) is in Motorola S19 format.
1892 \layout Subsubsection
1893
1894 MCS51 Options
1895 \layout List
1896 \labelwidthstring 00.00.0000
1897
1898
1899 \series bold 
1900 ---model-large
1901 \series default 
1902  Generate code for Large model programs see section Memory Models for more
1903  details.
1904  If this option is used all source files in the project should be compiled
1905  with this option.
1906  In addition the standard library routines are compiled with small model,
1907  they will need to be recompiled.
1908 \layout List
1909 \labelwidthstring 00.00.0000
1910
1911
1912 \series bold 
1913 ---model-small
1914 \series default 
1915 \size large 
1916 \emph on 
1917  
1918 \size default 
1919 \emph default 
1920 Generate code for Small Model programs see section Memory Models for more
1921  details.
1922  This is the default model.
1923 \layout Subsubsection
1924
1925 DS390 Options
1926 \layout List
1927 \labelwidthstring 00.00.0000
1928
1929
1930 \series bold 
1931 ---model-flat24
1932 \series default 
1933 \size large 
1934 \emph on 
1935  
1936 \size default 
1937 \emph default 
1938 Generate 24-bit flat mode code.
1939  This is the one and only that the ds390 code generator supports right now
1940  and is default when using 
1941 \emph on 
1942 -mds390
1943 \emph default 
1944 .
1945  See section Memory Models for more details.
1946 \layout List
1947 \labelwidthstring 00.00.0000
1948
1949
1950 \series bold 
1951 ---stack-10bit
1952 \series default 
1953  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
1954  This is the one and only that the ds390 code generator supports right now
1955  and is default when using 
1956 \emph on 
1957 -mds390
1958 \emph default 
1959 .
1960  In this mode, the stack is located in the lower 1K of the internal RAM,
1961  which is mapped to 0x400000.
1962  Note that the support is incomplete, since it still uses a single byte
1963  as the stack pointer.
1964  This means that only the lower 256 bytes of the potential 1K stack space
1965  will actually be used.
1966  However, this does allow you to reclaim the precious 256 bytes of low RAM
1967  for use for the DATA and IDATA segments.
1968  The compiler will not generate any code to put the processor into 10 bit
1969  stack mode.
1970  It is important to ensure that the processor is in this mode before calling
1971  any re-entrant functions compiled with this option.
1972  In principle, this should work with the 
1973 \emph on 
1974 ---stack-auto
1975 \emph default 
1976  option, but that has not been tested.
1977  It is incompatible with the 
1978 \emph on 
1979 ---xstack
1980 \emph default 
1981  option.
1982  It also only makes sense if the processor is in 24 bit contiguous addressing
1983  mode (see the 
1984 \emph on 
1985 ---model-flat24 option
1986 \emph default 
1987 ).
1988 \layout Subsubsection
1989
1990 Optimization Options
1991 \layout List
1992 \labelwidthstring 00.00.0000
1993
1994
1995 \series bold 
1996 ---nogcse
1997 \series default 
1998  Will not do global subexpression elimination, this option may be used when
1999  the compiler creates undesirably large stack/data spaces to store compiler
2000  temporaries.
2001  A warning message will be generated when this happens and the compiler
2002  will indicate the number of extra bytes it allocated.
2003  It recommended that this option NOT be used, #pragma\SpecialChar ~
2004 NOGCSE can be used
2005  to turn off global subexpression elimination for a given function only.
2006 \layout List
2007 \labelwidthstring 00.00.0000
2008
2009
2010 \series bold 
2011 ---noinvariant
2012 \series default 
2013  Will not do loop invariant optimizations, this may be turned off for reasons
2014  explained for the previous option.
2015  For more details of loop optimizations performed see section Loop Invariants.It
2016  recommended that this option NOT be used, #pragma\SpecialChar ~
2017 NOINVARIANT can be used
2018  to turn off invariant optimizations for a given function only.
2019 \layout List
2020 \labelwidthstring 00.00.0000
2021
2022
2023 \series bold 
2024 ---noinduction
2025 \series default 
2026  Will not do loop induction optimizations, see section strength reduction
2027  for more details.It is recommended that this option is NOT used, #pragma\SpecialChar ~
2028 NOINDUCT
2029 ION can be used to turn off induction optimizations for a given function
2030  only.
2031 \layout List
2032 \labelwidthstring 00.00.0000
2033
2034
2035 \series bold 
2036 ---nojtbound
2037 \size large 
2038 \bar under 
2039  
2040 \series default 
2041 \size default 
2042 \bar default 
2043  Will not generate boundary condition check when switch statements are implement
2044 ed using jump-tables.
2045  See section Switch Statements for more details.
2046  It is recommended that this option is NOT used, #pragma\SpecialChar ~
2047 NOJTBOUND can be
2048  used to turn off boundary checking for jump tables for a given function
2049  only.
2050 \layout List
2051 \labelwidthstring 00.00.0000
2052
2053
2054 \series bold 
2055 ---noloopreverse
2056 \series default 
2057 \size large 
2058  
2059 \size default 
2060 Will not do loop reversal optimization.
2061 \layout List
2062 \labelwidthstring 00.00.0000
2063
2064
2065 \series bold 
2066 ---no-xinit-opt
2067 \series default 
2068  This will disable the memcpy of initialized data in far space from code
2069  space
2070 \layout Subsubsection
2071
2072 Other Options
2073 \layout List
2074 \labelwidthstring 00.00.0000
2075
2076
2077 \series bold 
2078 -c\SpecialChar ~
2079 ---compile-only
2080 \series default 
2081  will compile and assemble the source, but will not call the linkage editor.
2082 \layout List
2083 \labelwidthstring 00.00.0000
2084
2085
2086 \series bold 
2087 -E
2088 \series default 
2089  Run only the C preprocessor.
2090  Preprocess all the C source files specified and output the results to standard
2091  output.
2092 \layout List
2093 \labelwidthstring 00.00.0000
2094
2095
2096 \series bold 
2097 ---stack-auto
2098 \series default 
2099 \size large 
2100 \emph on 
2101  
2102 \size default 
2103 \emph default 
2104 All functions in the source file will be compiled as 
2105 \emph on 
2106 reentrant
2107 \emph default 
2108 , i.e.
2109  the parameters and local variables will be allocated on the stack.
2110  see section Parameters and Local Variables for more details.
2111  If this option is used all source files in the project should be compiled
2112  with this option.
2113  
2114 \layout List
2115 \labelwidthstring 00.00.0000
2116
2117
2118 \series bold 
2119 ---xstack
2120 \series default 
2121  Uses a pseudo stack in the first 256 bytes in the external ram for allocating
2122  variables and passing parameters.
2123  See section on external stack for more details.
2124 \layout List
2125 \labelwidthstring 00.00.0000
2126
2127
2128 \series bold 
2129 ---callee-saves function1[,function2][,function3]....
2130
2131 \series default 
2132  The compiler by default uses a caller saves convention for register saving
2133  across function calls, however this can cause unneccessary register pushing
2134  & popping when calling small functions from larger functions.
2135  This option can be used to switch the register saving convention for the
2136  function names specified.
2137  The compiler will not save registers when calling these functions, no extra
2138  code will be generated at the entry & exit for these functions to save
2139  & restore the registers used by these functions, this can SUBSTANTIALLY
2140  reduce code & improve run time performance of the generated code.
2141  In the future the compiler (with interprocedural analysis) will be able
2142  to determine the appropriate scheme to use for each function call.
2143  DO NOT use this option for built-in functions such as _muluint..., if this
2144  option is used for a library function the appropriate library function
2145  needs to be recompiled with the same option.
2146  If the project consists of multiple source files then all the source file
2147  should be compiled with the same ---callee-saves option string.
2148  Also see #pragma\SpecialChar ~
2149 CALLEE-SAVES.
2150 \layout List
2151 \labelwidthstring 00.00.0000
2152
2153
2154 \series bold 
2155 ---debug
2156 \bar under 
2157  
2158 \series default 
2159 \bar default 
2160 When this option is used the compiler will generate debug information, that
2161  can be used with the SDCDB.
2162  The debug information is collected in a file with .cdb extension.
2163  For more information see documentation for SDCDB.
2164 \layout List
2165 \labelwidthstring 00.00.0000
2166
2167
2168 \series bold 
2169 ---peep-file
2170 \series default 
2171 <filename> This option can be used to use additional rules to be used by
2172  the peep hole optimizer.
2173  See section Peep Hole optimizations for details on how to write these rules.
2174 \layout List
2175 \labelwidthstring 00.00.0000
2176
2177
2178 \series bold 
2179 -S
2180 \size large 
2181 \bar under 
2182  
2183 \series default 
2184 \size default 
2185 \bar default 
2186 Stop after the stage of compilation proper; do not assemble.
2187  The output is an assembler code file for the input file specified.
2188 \layout List
2189 \labelwidthstring 00.00.0000
2190
2191
2192 \series bold 
2193 -Wa_asmOption[,asmOption]
2194 \series default 
2195 ...
2196  Pass the asmOption to the assembler.
2197 \layout List
2198 \labelwidthstring 00.00.0000
2199
2200
2201 \series bold 
2202 -Wl_linkOption[,linkOption]
2203 \series default 
2204 ...
2205  Pass the linkOption to the linker.
2206 \layout List
2207 \labelwidthstring 00.00.0000
2208
2209
2210 \series bold 
2211 ---int-long-reent
2212 \series default 
2213 \size large 
2214  
2215 \size default 
2216  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
2217  Note by default these libraries are compiled as non-reentrant.
2218  See section Installation for more details.
2219 \layout List
2220 \labelwidthstring 00.00.0000
2221
2222
2223 \series bold 
2224 ---cyclomatic
2225 \bar under 
2226  
2227 \series default 
2228 \bar default 
2229 This option will cause the compiler to generate an information message for
2230  each function in the source file.
2231  The message contains some 
2232 \emph on 
2233 important
2234 \emph default 
2235  information about the function.
2236  The number of edges and nodes the compiler detected in the control flow
2237  graph of the function, and most importantly the 
2238 \emph on 
2239 cyclomatic complexity
2240 \emph default 
2241  see section on Cyclomatic Complexity for more details.
2242 \layout List
2243 \labelwidthstring 00.00.0000
2244
2245
2246 \series bold 
2247 ---float-reent
2248 \bar under 
2249  
2250 \series default 
2251 \bar default 
2252  Floating point library is compiled as reentrant.See section Installation
2253  for more details.
2254 \layout List
2255 \labelwidthstring 00.00.0000
2256
2257
2258 \series bold 
2259 ---nooverlay
2260 \series default 
2261   The compiler will not overlay parameters and local variables of any function,
2262  see section Parameters and local variables for more details.
2263 \layout List
2264 \labelwidthstring 00.00.0000
2265
2266
2267 \series bold 
2268 ---main-return
2269 \series default 
2270  This option can be used when the code generated is called by a monitor
2271  program.
2272  The compiler will generate a 'ret' upon return from the 'main' function.
2273  The default option is to lock up i.e.
2274  generate a 'ljmp '.
2275 \layout List
2276 \labelwidthstring 00.00.0000
2277
2278
2279 \series bold 
2280 ---no-peep
2281 \series default 
2282   Disable peep-hole optimization.
2283 \layout List
2284 \labelwidthstring 00.00.0000
2285
2286
2287 \series bold 
2288 ---peep-asm
2289 \series default 
2290   Pass the inline assembler code through the peep hole optimizer.
2291  This can cause unexpected changes to inline assembler code, please go through
2292  the peephole optimizer rules defined in the source file tree '<target>/peeph.def
2293 ' before using this option.
2294 \layout List
2295 \labelwidthstring 00.00.0000
2296
2297
2298 \series bold 
2299 ---iram-size
2300 \series default 
2301 <Value> Causes the linker to check if the internal ram usage is within limits
2302  of the given value.
2303 \layout List
2304 \labelwidthstring 00.00.0000
2305
2306
2307 \series bold 
2308 ---xram-size
2309 \series default 
2310 <Value> Causes the linker to check if the external ram usage is within limits
2311  of the given value.
2312 \layout List
2313 \labelwidthstring 00.00.0000
2314
2315
2316 \series bold 
2317 ---code-size
2318 \series default 
2319 <Value> Causes the linker to check if the code usage is within limits of
2320  the given value.
2321 \layout List
2322 \labelwidthstring 00.00.0000
2323
2324
2325 \series bold 
2326 ---nostdincl
2327 \series default 
2328  This will prevent the compiler from passing on the default include path
2329  to the preprocessor.
2330 \layout List
2331 \labelwidthstring 00.00.0000
2332
2333
2334 \series bold 
2335 ---nostdlib
2336 \series default 
2337  This will prevent the compiler from passing on the default library path
2338  to the linker.
2339 \layout List
2340 \labelwidthstring 00.00.0000
2341
2342
2343 \series bold 
2344 ---verbose
2345 \series default 
2346  Shows the various actions the compiler is performing.
2347 \layout List
2348 \labelwidthstring 00.00.0000
2349
2350
2351 \series bold 
2352 -V
2353 \series default 
2354  Shows the actual commands the compiler is executing.
2355 \layout Subsubsection
2356
2357 Intermediate Dump Options
2358 \layout Standard
2359
2360 The following options are provided for the purpose of retargetting and debugging
2361  the compiler.
2362  These provided a means to dump the intermediate code (iCode) generated
2363  by the compiler in human readable form at various stages of the compilation
2364  process.
2365  
2366 \layout List
2367 \labelwidthstring 00.00.0000
2368
2369
2370 \series bold 
2371 ---dumpraw
2372 \series default 
2373  This option will cause the compiler to dump the intermediate code into
2374  a file of named 
2375 \emph on 
2376 <source filename>.dumpraw
2377 \emph default 
2378  just after the intermediate code has been generated for a function, i.e.
2379  before any optimizations are done.
2380  The basic blocks at this stage ordered in the depth first number, so they
2381  may not be in sequence of execution.
2382 \layout List
2383 \labelwidthstring 00.00.0000
2384
2385
2386 \series bold 
2387 ---dumpgcse
2388 \series default 
2389  Will create a dump of iCode's, after global subexpression elimination,
2390  into a file named 
2391 \emph on 
2392 <source filename>.dumpgcse.
2393 \layout List
2394 \labelwidthstring 00.00.0000
2395
2396
2397 \series bold 
2398 ---dumpdeadcode
2399 \series default 
2400  Will create a dump of iCode's, after deadcode elimination, into a file
2401  named 
2402 \emph on 
2403 <source filename>.dumpdeadcode.
2404 \layout List
2405 \labelwidthstring 00.00.0000
2406
2407
2408 \series bold 
2409 ---dumploop
2410 \series default 
2411 \size large 
2412  
2413 \size default 
2414 Will create a dump of iCode's, after loop optimizations, into a file named
2415  
2416 \emph on 
2417 <source filename>.dumploop.
2418 \layout List
2419 \labelwidthstring 00.00.0000
2420
2421
2422 \series bold 
2423 ---dumprange
2424 \series default 
2425 \size large 
2426  
2427 \size default 
2428 Will create a dump of iCode's, after live range analysis, into a file named
2429  
2430 \emph on 
2431 <source filename>.dumprange.
2432 \layout List
2433 \labelwidthstring 00.00.0000
2434
2435
2436 \series bold 
2437 ---dumlrange
2438 \series default 
2439  Will dump the life ranges for all symbols.
2440 \layout List
2441 \labelwidthstring 00.00.0000
2442
2443
2444 \series bold 
2445 ---dumpregassign
2446 \bar under 
2447  
2448 \series default 
2449 \bar default 
2450 Will create a dump of iCode's, after register assignment, into a file named
2451  
2452 \emph on 
2453 <source filename>.dumprassgn.
2454 \layout List
2455 \labelwidthstring 00.00.0000
2456
2457
2458 \series bold 
2459 ---dumplrange
2460 \series default 
2461  Will create a dump of the live ranges of iTemp's
2462 \layout List
2463 \labelwidthstring 00.00.0000
2464
2465
2466 \series bold 
2467 ---dumpall
2468 \size large 
2469 \bar under 
2470  
2471 \series default 
2472 \size default 
2473 \bar default 
2474 Will cause all the above mentioned dumps to be created.
2475 \layout Subsection
2476
2477 MCS51/DS390 Storage Class Language Extensions
2478 \layout Standard
2479
2480 In addition to the ANSI storage classes SDCC allows the following MCS51
2481  specific storage classes.
2482 \layout Subsubsection
2483
2484 xdata
2485 \layout Standard
2486
2487 Variables declared with this storage class will be placed in the extern
2488  RAM.
2489  This is the 
2490 \series bold 
2491 default
2492 \series default 
2493  storage class for Large Memory model, e.g.:
2494 \newline 
2495
2496 \newline 
2497
2498 \family typewriter 
2499 xdata unsigned char xduc;
2500 \layout Subsubsection
2501
2502 data
2503 \layout Standard
2504
2505 This is the 
2506 \series bold 
2507 default
2508 \series default 
2509  storage class for Small Memory model.
2510  Variables declared with this storage class will be allocated in the internal
2511  RAM, e.g.:
2512 \newline 
2513
2514 \newline 
2515
2516 \family typewriter 
2517 data int iramdata;
2518 \layout Subsubsection
2519
2520 idata
2521 \layout Standard
2522
2523 Variables declared with this storage class will be allocated into the indirectly
2524  addressable portion of the internal ram of a 8051, e.g.:
2525 \newline 
2526
2527 \newline 
2528
2529 \family typewriter 
2530 idata int idi;
2531 \layout Subsubsection
2532
2533 bit
2534 \layout Standard
2535
2536 This is a data-type and a storage class specifier.
2537  When a variable is declared as a bit, it is allocated into the bit addressable
2538  memory of 8051, e.g.:
2539 \newline 
2540
2541 \newline 
2542
2543 \family typewriter 
2544 bit iFlag;
2545 \layout Subsubsection
2546
2547 sfr / sbit
2548 \layout Standard
2549
2550 Like the bit keyword, 
2551 \emph on 
2552 sfr / sbit 
2553 \emph default 
2554 signifies both a data-type and storage class, they are used to describe
2555  the special function registers and special bit variables of a 8051, eg:
2556 \newline 
2557
2558 \newline 
2559
2560 \family typewriter 
2561 sfr at 0x80 P0; /* special function register P0 at location 0x80 */
2562 \newline 
2563 sbit at 0xd7 CY; /* CY (Carry Flag) */
2564 \layout Subsection
2565
2566 Pointers
2567 \layout Standard
2568
2569 SDCC allows (via language extensions) pointers to explicitly point to any
2570  of the memory spaces of the 8051.
2571  In addition to the explicit pointers, the compiler uses (by default) generic
2572  pointers which can be used to point to any of the memory spaces.
2573 \newline 
2574
2575 \newline 
2576 Pointer declaration examples:
2577 \newline 
2578
2579 \size small 
2580
2581 \newline 
2582
2583 \family typewriter 
2584 \size default 
2585 /* pointer physically in xternal ram pointing to object in internal ram
2586  */ 
2587 \newline 
2588 data unsigned char * xdata p;
2589 \newline 
2590
2591 \newline 
2592 /* pointer physically in code rom pointing to data in xdata space */ 
2593 \newline 
2594 xdata unsigned char * code p;
2595 \newline 
2596
2597 \newline 
2598 /* pointer physically in code space pointing to data in code space */ 
2599 \newline 
2600 code unsigned char * code p;
2601 \newline 
2602
2603 \newline 
2604 /* the folowing is a generic pointer physically located in xdata space */
2605 \newline 
2606 char * xdata p;
2607 \family default 
2608 \size small 
2609
2610 \newline 
2611
2612 \newline 
2613
2614 \size default 
2615 Well you get the idea.
2616  
2617 \newline 
2618
2619 \newline 
2620 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
2621 \emph on 
2622 generic
2623 \emph default 
2624  pointers.
2625  
2626 \size small 
2627
2628 \newline 
2629
2630 \newline 
2631
2632 \size default 
2633 The highest order byte of the 
2634 \emph on 
2635 generic
2636 \emph default 
2637  pointers contains the data space information.
2638  Assembler support routines are called whenever data is stored or retrieved
2639  using 
2640 \emph on 
2641 generic
2642 \emph default 
2643  pointers.
2644  These are useful for developing reusable library routines.
2645  Explicitly specifying the pointer type will generate the most efficient
2646  code.
2647 \layout Subsection
2648
2649 Parameters & Local Variables
2650 \layout Standard
2651
2652 Automatic (local) variables and parameters to functions can either be placed
2653  on the stack or in data-space.
2654  The default action of the compiler is to place these variables in the internal
2655  RAM (for small model) or external RAM (for large model).
2656  This in fact makes them 
2657 \emph on 
2658 static
2659 \emph default 
2660  so by default functions are non-reentrant.
2661 \newline 
2662
2663 \newline 
2664 They can be placed on the stack either by using the
2665 \emph on 
2666  ---stack-auto
2667 \emph default 
2668  option or by using the 
2669 \emph on 
2670 reentrant
2671 \emph default 
2672  keyword in the function declaration, e.g.:
2673 \newline 
2674
2675 \size small 
2676
2677 \newline 
2678
2679 \family typewriter 
2680 \size default 
2681 unsigned char foo(char i) reentrant 
2682 \newline 
2683
2684 \newline 
2685 ...
2686  
2687 \newline 
2688 }
2689 \newline 
2690
2691 \family default 
2692
2693 \newline 
2694 Since stack space on 8051 is limited, the 
2695 \emph on 
2696 reentrant 
2697 \emph default 
2698 keyword or the
2699 \emph on 
2700  ---stack-auto
2701 \emph default 
2702  option should be used sparingly.
2703  Note that the reentrant keyword just means that the parameters & local
2704  variables will be allocated to the stack, it 
2705 \emph on 
2706 does not
2707 \emph default 
2708  mean that the function is register bank independent.
2709 \newline 
2710
2711 \newline 
2712 Local variables can be assigned storage classes and absolute addresses,
2713  e.g.: 
2714 \newline 
2715
2716 \newline 
2717
2718 \family typewriter 
2719 unsigned char foo() {
2720 \newline 
2721 \SpecialChar ~
2722 \SpecialChar ~
2723 \SpecialChar ~
2724 \SpecialChar ~
2725 xdata unsigned char i;
2726 \newline 
2727 \SpecialChar ~
2728 \SpecialChar ~
2729 \SpecialChar ~
2730 \SpecialChar ~
2731 bit bvar;
2732 \newline 
2733 \SpecialChar ~
2734 \SpecialChar ~
2735 \SpecialChar ~
2736 \SpecialChar ~
2737 data at 0x31 unsiged char j;
2738 \newline 
2739 \SpecialChar ~
2740 \SpecialChar ~
2741 \SpecialChar ~
2742 \SpecialChar ~
2743 ...
2744  
2745 \newline 
2746 }
2747 \newline 
2748
2749 \newline 
2750
2751 \family default 
2752 In the above example the variable 
2753 \emph on 
2754 i
2755 \emph default 
2756  will be allocated in the external ram, 
2757 \emph on 
2758 bvar
2759 \emph default 
2760  in bit addressable space and
2761 \emph on 
2762  j
2763 \emph default 
2764  in internal ram.
2765  When compiled with 
2766 \emph on 
2767 ---stack-auto
2768 \emph default 
2769  or when a function is declared as 
2770 \emph on 
2771 reentrant
2772 \emph default 
2773  this should only be done for static variables.
2774 \layout Standard
2775
2776 Parameters however are not allowed any storage class, (storage classes for
2777  parameters will be ignored), their allocation is governed by the memory
2778  model in use, and the reentrancy options.
2779 \layout Subsection
2780
2781 Overlaying
2782 \layout Standard
2783
2784 For non-reentrant functions SDCC will try to reduce internal ram space usage
2785  by overlaying parameters and local variables of a function (if possible).
2786  Parameters and local variables of a function will be allocated to an overlayabl
2787 e segment if the function has 
2788 \emph on 
2789 no other function calls and the function is non-reentrant and the memory
2790  model is small.
2791
2792 \emph default 
2793  If an explicit storage class is specified for a local variable, it will
2794  NOT be overlayed.
2795 \layout Standard
2796
2797 Note that the compiler (not the linkage editor) makes the decision for overlayin
2798 g the data items.
2799  Functions that are called from an interrupt service routine should be preceded
2800  by a #pragma\SpecialChar ~
2801 NOOVERLAY if they are not reentrant.
2802 \layout Standard
2803
2804 Also note that the compiler does not do any processing of inline assembler
2805  code, so the compiler might incorrectly assign local variables and parameters
2806  of a function into the overlay segment if the inline assembler code calls
2807  other c-functions that might use the overlay.
2808  In that case the #pragma\SpecialChar ~
2809 NOOVERLAY should be used.
2810 \layout Standard
2811
2812 Parameters and Local variables of functions that contain 16 or 32 bit multiplica
2813 tion or division will NOT be overlayed since these are implemented using
2814  external functions, e.g.:
2815 \newline 
2816
2817 \newline 
2818
2819 \family typewriter 
2820 #pragma SAVE 
2821 \newline 
2822 #pragma NOOVERLAY 
2823 \newline 
2824 void set_error(unsigned char errcd) 
2825 \newline 
2826 {
2827 \newline 
2828 \SpecialChar ~
2829 \SpecialChar ~
2830 \SpecialChar ~
2831 \SpecialChar ~
2832 P3 = errcd;
2833 \newline 
2834
2835 \newline 
2836 #pragma RESTORE 
2837 \newline 
2838
2839 \newline 
2840 void some_isr () interrupt 2 using 1 
2841 \newline 
2842 {
2843 \newline 
2844 \SpecialChar ~
2845 \SpecialChar ~
2846 \SpecialChar ~
2847 \SpecialChar ~
2848 ...
2849 \newline 
2850 \SpecialChar ~
2851 \SpecialChar ~
2852 \SpecialChar ~
2853 \SpecialChar ~
2854 set_error(10);
2855 \newline 
2856 \SpecialChar ~
2857 \SpecialChar ~
2858 \SpecialChar ~
2859 \SpecialChar ~
2860 ...
2861  
2862 \newline 
2863 }
2864 \newline 
2865
2866 \newline 
2867
2868 \family default 
2869 In the above example the parameter 
2870 \emph on 
2871 errcd
2872 \emph default 
2873  for the function 
2874 \emph on 
2875 set_error
2876 \emph default 
2877  would be assigned to the overlayable segment if the #pragma\SpecialChar ~
2878 NOOVERLAY was
2879  not present, this could cause unpredictable runtime behavior when called
2880  from an ISR.
2881  The #pragma\SpecialChar ~
2882 NOOVERLAY ensures that the parameters and local variables for
2883  the function are NOT overlayed.
2884 \layout Subsection
2885
2886 Interrupt Service Routines
2887 \layout Standard
2888
2889 SDCC allows interrupt service routines to be coded in C, with some extended
2890  keywords.
2891 \newline 
2892
2893 \newline 
2894
2895 \family typewriter 
2896 void timer_isr (void) interrupt 2 using 1 
2897 \newline 
2898
2899 \newline 
2900 ..
2901  
2902 \newline 
2903 }
2904 \newline 
2905
2906 \newline 
2907
2908 \family default 
2909 The number following the 
2910 \emph on 
2911 interrupt
2912 \emph default 
2913  keyword is the interrupt number this routine will service.
2914  The compiler will insert a call to this routine in the interrupt vector
2915  table for the interrupt number specified.
2916  The 
2917 \emph on 
2918 using
2919 \emph default 
2920  keyword is used to tell the compiler to use the specified register bank
2921  (8051 specific) when generating code for this function.
2922  Note that when some function is called from an interrupt service routine
2923  it should be preceded by a #pragma\SpecialChar ~
2924 NOOVERLAY if it is not reentrant.
2925  A special note here, int (16 bit) and long (32 bit) integer division, multiplic
2926 ation & modulus operations are implemented using external support routines
2927  developed in ANSI-C, if an interrupt service routine needs to do any of
2928  these operations then the support routines (as mentioned in a following
2929  section) will have to be recompiled using the
2930 \emph on 
2931  ---stack-auto
2932 \emph default 
2933  option and the source file will need to be compiled using the 
2934 \emph on 
2935 ---int-long-ren
2936 \emph default 
2937 t compiler option.
2938 \layout Standard
2939
2940 If you have multiple source files in your project, interrupt service routines
2941  can be present in any of them, but a prototype of the isr MUST be present
2942  or included in the file that contains the function 
2943 \emph on 
2944 main
2945 \emph default 
2946 .
2947 \layout Standard
2948
2949 Interrupt Numbers and the corresponding address & descriptions for the Standard
2950  8051 are listed below.
2951  SDCC will automatically adjust the interrupt vector table to the maximum
2952  interrupt number specified.
2953 \newline 
2954
2955 \layout Standard
2956
2957
2958 \begin_inset  Tabular
2959 <lyxtabular version="3" rows="6" columns="3">
2960 <features>
2961 <column alignment="center" valignment="top" leftline="true" width="0(null)">
2962 <column alignment="center" valignment="top" leftline="true" width="0(null)">
2963 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
2964 <row topline="true" bottomline="true">
2965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2966 \begin_inset Text
2967
2968 \layout Standard
2969
2970 Interrupt #
2971 \end_inset 
2972 </cell>
2973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2974 \begin_inset Text
2975
2976 \layout Standard
2977
2978 Description
2979 \end_inset 
2980 </cell>
2981 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2982 \begin_inset Text
2983
2984 \layout Standard
2985
2986 Vector Address
2987 \end_inset 
2988 </cell>
2989 </row>
2990 <row topline="true">
2991 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2992 \begin_inset Text
2993
2994 \layout Standard
2995
2996 0
2997 \end_inset 
2998 </cell>
2999 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3000 \begin_inset Text
3001
3002 \layout Standard
3003
3004 External 0
3005 \end_inset 
3006 </cell>
3007 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3008 \begin_inset Text
3009
3010 \layout Standard
3011
3012 0x0003
3013 \end_inset 
3014 </cell>
3015 </row>
3016 <row topline="true">
3017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3018 \begin_inset Text
3019
3020 \layout Standard
3021
3022 1
3023 \end_inset 
3024 </cell>
3025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3026 \begin_inset Text
3027
3028 \layout Standard
3029
3030 Timer 0
3031 \end_inset 
3032 </cell>
3033 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3034 \begin_inset Text
3035
3036 \layout Standard
3037
3038 0x000B
3039 \end_inset 
3040 </cell>
3041 </row>
3042 <row topline="true">
3043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3044 \begin_inset Text
3045
3046 \layout Standard
3047
3048 2
3049 \end_inset 
3050 </cell>
3051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3052 \begin_inset Text
3053
3054 \layout Standard
3055
3056 External 1
3057 \end_inset 
3058 </cell>
3059 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3060 \begin_inset Text
3061
3062 \layout Standard
3063
3064 0x0013
3065 \end_inset 
3066 </cell>
3067 </row>
3068 <row topline="true">
3069 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3070 \begin_inset Text
3071
3072 \layout Standard
3073
3074 3
3075 \end_inset 
3076 </cell>
3077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3078 \begin_inset Text
3079
3080 \layout Standard
3081
3082 Timer 1
3083 \end_inset 
3084 </cell>
3085 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3086 \begin_inset Text
3087
3088 \layout Standard
3089
3090 0x001B
3091 \end_inset 
3092 </cell>
3093 </row>
3094 <row topline="true" bottomline="true">
3095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3096 \begin_inset Text
3097
3098 \layout Standard
3099
3100 4
3101 \end_inset 
3102 </cell>
3103 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3104 \begin_inset Text
3105
3106 \layout Standard
3107
3108 Serial
3109 \end_inset 
3110 </cell>
3111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3112 \begin_inset Text
3113
3114 \layout Standard
3115
3116 0x0023
3117 \end_inset 
3118 </cell>
3119 </row>
3120 </lyxtabular>
3121
3122 \end_inset 
3123
3124
3125 \newline 
3126
3127 \newline 
3128 If the interrupt service routine is defined without 
3129 \emph on 
3130 using
3131 \emph default 
3132  a register bank or with register bank 0 (using 0), the compiler will save
3133  the registers used by itself on the stack upon entry and restore them at
3134  exit, however if such an interrupt service routine calls another function
3135  then the entire register bank will be saved on the stack.
3136  This scheme may be advantageous for small interrupt service routines which
3137  have low register usage.
3138 \layout Standard
3139
3140 If the interrupt service routine is defined to be using a specific register
3141  bank then only 
3142 \emph on 
3143 a, b & dptr
3144 \emph default 
3145  are save and restored, if such an interrupt service routine calls another
3146  function (using another register bank) then the entire register bank of
3147  the called function will be saved on the stack.
3148  This scheme is recommended for larger interrupt service routines.
3149 \layout Standard
3150
3151 Calling other functions from an interrupt service routine is not recommended,
3152  avoid it if possible.
3153 \newline 
3154
3155 \newline 
3156 Also see the _naked modifier.
3157 \layout Subsection
3158
3159 Critical Functions
3160 \layout Standard
3161
3162
3163 \shape italic 
3164 <TODO: this isn't implemented at all!>
3165 \shape default 
3166
3167 \newline 
3168
3169 \newline 
3170 A special keyword may be associated with a function declaring it as 
3171 \emph on 
3172 critical
3173 \emph default 
3174 .
3175  SDCC will generate code to disable all interrupts upon entry to a critical
3176  function and enable them back before returning.
3177  Note that nesting critical functions may cause unpredictable results.
3178 \newline 
3179
3180 \size small 
3181
3182 \newline 
3183
3184 \family typewriter 
3185 \size default 
3186 int foo () critical 
3187 \newline 
3188
3189 \newline 
3190 ...
3191  
3192 \newline 
3193 ...
3194  
3195 \newline 
3196 }
3197 \newline 
3198
3199 \family default 
3200
3201 \newline 
3202 The critical attribute maybe used with other attributes like 
3203 \emph on 
3204 reentrant.
3205 \layout Subsection
3206
3207 Naked Functions
3208 \layout Standard
3209
3210 A special keyword may be associated with a function declaring it as 
3211 \emph on 
3212 _naked.
3213  
3214 \emph default 
3215 The 
3216 \emph on 
3217 _naked
3218 \emph default 
3219  function modifier attribute prevents the compiler from generating prologue
3220  and epilogue code for that function.
3221  This means that the user is entirely responsible for such things as saving
3222  any registers that may need to be preserved, selecting the proper register
3223  bank, generating the 
3224 \emph on 
3225 return
3226 \emph default 
3227  instruction at the end, etc.
3228  Practically, this means that the contents of the function must be written
3229  in inline assembler.
3230  This is particularly useful for interrupt functions, which can have a large
3231  (and often unnecessary) prologue/epilogue.
3232  For example, compare the code generated by these two functions:
3233 \newline 
3234
3235 \newline 
3236
3237 \family typewriter 
3238 data unsigned char counter;
3239 \newline 
3240 void simpleInterrupt(void) interrupt 1
3241 \newline 
3242 {
3243 \newline 
3244 \SpecialChar ~
3245 \SpecialChar ~
3246 \SpecialChar ~
3247 \SpecialChar ~
3248 counter++;
3249 \newline 
3250 }
3251 \newline 
3252
3253 \newline 
3254 void nakedInterrupt(void) interrupt 2 _naked
3255 \newline 
3256 {
3257 \newline 
3258 \SpecialChar ~
3259 \SpecialChar ~
3260 \SpecialChar ~
3261 \SpecialChar ~
3262 _asm
3263 \newline 
3264 \SpecialChar ~
3265 \SpecialChar ~
3266 \SpecialChar ~
3267 \SpecialChar ~
3268 \SpecialChar ~
3269 \SpecialChar ~
3270 inc\SpecialChar ~
3271 \SpecialChar ~
3272 \SpecialChar ~
3273 \SpecialChar ~
3274 \SpecialChar ~
3275 _counter
3276 \newline 
3277 \SpecialChar ~
3278 \SpecialChar ~
3279 \SpecialChar ~
3280 \SpecialChar ~
3281 \SpecialChar ~
3282 \SpecialChar ~
3283 reti\SpecialChar ~
3284 \SpecialChar ~
3285 \SpecialChar ~
3286 \SpecialChar ~
3287 ; MUST explicitly include ret in _naked function.
3288 \newline 
3289 \SpecialChar ~
3290 \SpecialChar ~
3291 \SpecialChar ~
3292 \SpecialChar ~
3293 _endasm;
3294 \newline 
3295 }
3296 \family default 
3297
3298 \newline 
3299
3300 \newline 
3301 For an 8051 target, the generated simpleInterrupt looks like:
3302 \newline 
3303
3304 \newline 
3305
3306 \family typewriter 
3307 _simpleIterrupt:
3308 \newline 
3309 \SpecialChar ~
3310 \SpecialChar ~
3311 \SpecialChar ~
3312 \SpecialChar ~
3313 push\SpecialChar ~
3314 \SpecialChar ~
3315 \SpecialChar ~
3316 \SpecialChar ~
3317 acc
3318 \newline 
3319 \SpecialChar ~
3320 \SpecialChar ~
3321 \SpecialChar ~
3322 \SpecialChar ~
3323 push\SpecialChar ~
3324 \SpecialChar ~
3325 \SpecialChar ~
3326 \SpecialChar ~
3327 b
3328 \newline 
3329 \SpecialChar ~
3330 \SpecialChar ~
3331 \SpecialChar ~
3332 \SpecialChar ~
3333 push\SpecialChar ~
3334 \SpecialChar ~
3335 \SpecialChar ~
3336 \SpecialChar ~
3337 dpl
3338 \newline 
3339 \SpecialChar ~
3340 \SpecialChar ~
3341 \SpecialChar ~
3342 \SpecialChar ~
3343 push\SpecialChar ~
3344 \SpecialChar ~
3345 \SpecialChar ~
3346 \SpecialChar ~
3347 dph
3348 \newline 
3349 \SpecialChar ~
3350 \SpecialChar ~
3351 \SpecialChar ~
3352 \SpecialChar ~
3353 push\SpecialChar ~
3354 \SpecialChar ~
3355 \SpecialChar ~
3356 \SpecialChar ~
3357 psw
3358 \newline 
3359 \SpecialChar ~
3360 \SpecialChar ~
3361 \SpecialChar ~
3362 \SpecialChar ~
3363 mov\SpecialChar ~
3364 \SpecialChar ~
3365 \SpecialChar ~
3366 \SpecialChar ~
3367 \SpecialChar ~
3368 psw,#0x00
3369 \newline 
3370 \SpecialChar ~
3371 \SpecialChar ~
3372 \SpecialChar ~
3373 \SpecialChar ~
3374 inc\SpecialChar ~
3375 \SpecialChar ~
3376 \SpecialChar ~
3377 \SpecialChar ~
3378 \SpecialChar ~
3379 _counter
3380 \newline 
3381 \SpecialChar ~
3382 \SpecialChar ~
3383 \SpecialChar ~
3384 \SpecialChar ~
3385 pop\SpecialChar ~
3386 \SpecialChar ~
3387 \SpecialChar ~
3388 \SpecialChar ~
3389 \SpecialChar ~
3390 psw
3391 \newline 
3392 \SpecialChar ~
3393 \SpecialChar ~
3394 \SpecialChar ~
3395 \SpecialChar ~
3396 pop\SpecialChar ~
3397 \SpecialChar ~
3398 \SpecialChar ~
3399 \SpecialChar ~
3400 \SpecialChar ~
3401 dph
3402 \newline 
3403 \SpecialChar ~
3404 \SpecialChar ~
3405 \SpecialChar ~
3406 \SpecialChar ~
3407 pop\SpecialChar ~
3408 \SpecialChar ~
3409 \SpecialChar ~
3410 \SpecialChar ~
3411 \SpecialChar ~
3412 dpl
3413 \newline 
3414 \SpecialChar ~
3415 \SpecialChar ~
3416 \SpecialChar ~
3417 \SpecialChar ~
3418 pop\SpecialChar ~
3419 \SpecialChar ~
3420 \SpecialChar ~
3421 \SpecialChar ~
3422 \SpecialChar ~
3423 b
3424 \newline 
3425 \SpecialChar ~
3426 \SpecialChar ~
3427 \SpecialChar ~
3428 \SpecialChar ~
3429 pop\SpecialChar ~
3430 \SpecialChar ~
3431 \SpecialChar ~
3432 \SpecialChar ~
3433 \SpecialChar ~
3434 acc
3435 \newline 
3436 \SpecialChar ~
3437 \SpecialChar ~
3438 \SpecialChar ~
3439 \SpecialChar ~
3440 reti
3441 \family default 
3442
3443 \newline 
3444
3445 \newline 
3446 whereas nakedInterrupt looks like:
3447 \newline 
3448
3449 \newline 
3450
3451 \family typewriter 
3452 _nakedInterrupt:
3453 \newline 
3454 \SpecialChar ~
3455 \SpecialChar ~
3456 \SpecialChar ~
3457 \SpecialChar ~
3458 inc\SpecialChar ~
3459 \SpecialChar ~
3460 \SpecialChar ~
3461 \SpecialChar ~
3462 _counter
3463 \newline 
3464 \SpecialChar ~
3465 \SpecialChar ~
3466 \SpecialChar ~
3467 \SpecialChar ~
3468 reti\SpecialChar ~
3469 \SpecialChar ~
3470 \SpecialChar ~
3471 ; MUST explicitly include ret(i) in _naked function.
3472 \family default 
3473
3474 \newline 
3475
3476 \newline 
3477 While there is nothing preventing you from writing C code inside a _naked
3478  function, there are many ways to shoot yourself in the foot doing this,
3479  and it is recommended that you stick to inline assembler.
3480 \layout Subsection
3481
3482 Functions using private banks
3483 \layout Standard
3484
3485 The 
3486 \emph on 
3487 using
3488 \emph default 
3489  attribute (which tells the compiler to use a register bank other than the
3490  default bank zero) should only be applied to 
3491 \emph on 
3492 interrupt
3493 \emph default 
3494  functions (see note 1 below).
3495  This will in most circumstances make the generated ISR code more efficient
3496  since it will not have to save registers on the stack.
3497 \layout Standard
3498
3499 The 
3500 \emph on 
3501 using
3502 \emph default 
3503  attribute will have no effect on the generated code for a 
3504 \emph on 
3505 non-interrupt
3506 \emph default 
3507  function (but may occasionally be useful anyway
3508 \begin_inset Foot
3509 collapsed true
3510
3511 \layout Standard
3512
3513 possible exception: if a function is called ONLY from 'interrupt' functions
3514  using a particular bank, it can be declared with the same 'using' attribute
3515  as the calling 'interrupt' functions.
3516  For instance, if you have several ISRs using bank one, and all of them
3517  call memcpy(), it might make sense to create a specialized version of memcpy()
3518  'using 1', since this would prevent the ISR from having to save bank zero
3519  to the stack on entry and switch to bank zero before calling the function
3520 \end_inset 
3521
3522 ).
3523 \newline 
3524
3525 \emph on 
3526 (pending: I don't think this has been done yet)
3527 \layout Standard
3528
3529 An 
3530 \emph on 
3531 interrupt
3532 \emph default 
3533  function using a non-zero bank will assume that it can trash that register
3534  bank, and will not save it.
3535  Since high-priority interrupts can interrupt low-priority ones on the 8051
3536  and friends, this means that if a high-priority ISR 
3537 \emph on 
3538 using
3539 \emph default 
3540  a particular bank occurs while processing a low-priority ISR 
3541 \emph on 
3542 using
3543 \emph default 
3544  the same bank, terrible and bad things can happen.
3545  To prevent this, no single register bank should be 
3546 \emph on 
3547 used
3548 \emph default 
3549  by both a high priority and a low priority ISR.
3550  This is probably most easily done by having all high priority ISRs use
3551  one bank and all low priority ISRs use another.
3552  If you have an ISR which can change priority at runtime, you're on your
3553  own: I suggest using the default bank zero and taking the small performance
3554  hit.
3555 \layout Standard
3556
3557 It is most efficient if your ISR calls no other functions.
3558  If your ISR must call other functions, it is most efficient if those functions
3559  use the same bank as the ISR (see note 1 below); the next best is if the
3560  called functions use bank zero.
3561  It is very inefficient to call a function using a different, non-zero bank
3562  from an ISR.
3563  
3564 \layout Subsection
3565
3566 Absolute Addressing
3567 \layout Standard
3568
3569 Data items can be assigned an absolute address with the 
3570 \emph on 
3571 at <address>
3572 \emph default 
3573  keyword, in addition to a storage class, e.g.:
3574 \newline 
3575
3576 \newline 
3577
3578 \family typewriter 
3579 xdata at 0x8000 unsigned char PORTA_8255 ;
3580 \newline 
3581
3582 \family default 
3583
3584 \newline 
3585 In the above example the PORTA_8255 will be allocated to the location 0x8000
3586  of the external ram.
3587  Note that this feature is provided to give the programmer access to 
3588 \emph on 
3589 memory mapped
3590 \emph default 
3591  devices attached to the controller.
3592  The compiler does not actually reserve any space for variables declared
3593  in this way (they are implemented with an equate in the assembler).
3594  Thus it is left to the programmer to make sure there are no overlaps with
3595  other variables that are declared without the absolute address.
3596  The assembler listing file (.lst) and the linker output files (.rst) and
3597  (.map) are a good places to look for such overlaps.
3598 \newline 
3599
3600 \newline 
3601 Absolute address can be specified for variables in all storage classes,
3602  e.g.:
3603 \newline 
3604
3605 \newline 
3606
3607 \family typewriter 
3608 bit at 0x02 bvar;
3609 \newline 
3610
3611 \newline 
3612
3613 \family default 
3614 The above example will allocate the variable at offset 0x02 in the bit-addressab
3615 le space.
3616  There is no real advantage to assigning absolute addresses to variables
3617  in this manner, unless you want strict control over all the variables allocated.
3618 \layout Subsection
3619
3620 Startup Code
3621 \layout Standard
3622
3623 The compiler inserts a call to the C routine 
3624 \emph on 
3625 _sdcc__external__startup()
3626 \series bold 
3627 \emph default 
3628  
3629 \series default 
3630 at the start of the CODE area.
3631  This routine is in the runtime library.
3632  By default this routine returns 0, if this routine returns a non-zero value,
3633  the static & global variable initialization will be skipped and the function
3634  main will be invoked Other wise static & global variables will be initialized
3635  before the function main is invoked.
3636  You could add a 
3637 \emph on 
3638 _sdcc__external__startup()
3639 \emph default 
3640  routine to your program to override the default if you need to setup hardware
3641  or perform some other critical operation prior to static & global variable
3642  initialization.
3643 \layout Subsection
3644
3645 Inline Assembler Code
3646 \layout Standard
3647
3648 SDCC allows the use of in-line assembler with a few restriction as regards
3649  labels.
3650  All labels defined within inline assembler code 
3651 \emph on 
3652 has to be
3653 \emph default 
3654  of the form 
3655 \emph on 
3656 nnnnn$
3657 \emph default 
3658  where nnnn is a number less than 100 (which implies a limit of utmost 100
3659  inline assembler labels 
3660 \emph on 
3661 per function
3662 \emph default 
3663 \noun on 
3664 )
3665 \noun default 
3666 .
3667  It is strongly recommended that each assembly instruction (including labels)
3668  be placed in a separate line (as the example shows).
3669  When the 
3670 \emph on 
3671 ---peep-asm
3672 \emph default 
3673  command line option is used, the inline assembler code will be passed through
3674  the peephole optimizer.
3675  This might cause some unexpected changes in the inline assembler code.
3676  Please go throught the peephole optimizer rules defined in file 
3677 \emph on 
3678 SDCCpeeph.def
3679 \emph default 
3680  carefully before using this option.
3681 \newline 
3682
3683 \newline 
3684
3685 \family typewriter 
3686 _asm 
3687 \newline 
3688 \SpecialChar ~
3689 \SpecialChar ~
3690 \SpecialChar ~
3691 \SpecialChar ~
3692 mov\SpecialChar ~
3693 \SpecialChar ~
3694 \SpecialChar ~
3695 \SpecialChar ~
3696 \SpecialChar ~
3697 b,#10 
3698 \newline 
3699 00001$: 
3700 \newline 
3701 \SpecialChar ~
3702 \SpecialChar ~
3703 \SpecialChar ~
3704 \SpecialChar ~
3705 djnz\SpecialChar ~
3706 \SpecialChar ~
3707 \SpecialChar ~
3708 \SpecialChar ~
3709 b,00001$ 
3710 \newline 
3711 _endasm ;
3712 \family default 
3713 \size small 
3714
3715 \newline 
3716
3717 \newline 
3718
3719 \size default 
3720 The inline assembler code can contain any valid code understood by the assembler
3721 , this includes any assembler directives and comment lines.
3722  The compiler does not do any validation of the code within the 
3723 \family typewriter 
3724 _asm ...
3725  _endasm;
3726 \family default 
3727  keyword pair.
3728  
3729 \newline 
3730
3731 \newline 
3732 Inline assembler code cannot reference any C-Labels, however it can reference
3733  labels defined by the inline assembler, e.g.:
3734 \newline 
3735
3736 \newline 
3737
3738 \family typewriter 
3739 foo() { 
3740 \newline 
3741 \SpecialChar ~
3742 \SpecialChar ~
3743 \SpecialChar ~
3744 \SpecialChar ~
3745 /* some c code */ 
3746 \newline 
3747 \SpecialChar ~
3748 \SpecialChar ~
3749 \SpecialChar ~
3750 \SpecialChar ~
3751 _asm 
3752 \newline 
3753 \SpecialChar ~
3754 \SpecialChar ~
3755 \SpecialChar ~
3756 \SpecialChar ~
3757 \SpecialChar ~
3758 \SpecialChar ~
3759 ; some assembler code 
3760 \newline 
3761 \SpecialChar ~
3762 \SpecialChar ~
3763 \SpecialChar ~
3764 \SpecialChar ~
3765 \SpecialChar ~
3766 \SpecialChar ~
3767 ljmp $0003 
3768 \newline 
3769 \SpecialChar ~
3770 \SpecialChar ~
3771 \SpecialChar ~
3772 \SpecialChar ~
3773 _endasm; 
3774 \newline 
3775 \SpecialChar ~
3776 \SpecialChar ~
3777 \SpecialChar ~
3778 \SpecialChar ~
3779 /* some more c code */ 
3780 \newline 
3781 clabel:\SpecialChar ~
3782 \SpecialChar ~
3783 /* inline assembler cannot reference this label */ 
3784 \newline 
3785 \SpecialChar ~
3786 \SpecialChar ~
3787 \SpecialChar ~
3788 \SpecialChar ~
3789 _asm
3790 \newline 
3791 \SpecialChar ~
3792 \SpecialChar ~
3793 \SpecialChar ~
3794 \SpecialChar ~
3795 $0003: ;label (can be reference by inline assembler only) 
3796 \newline 
3797 \SpecialChar ~
3798 \SpecialChar ~
3799 \SpecialChar ~
3800 \SpecialChar ~
3801 _endasm ; 
3802 \newline 
3803 \SpecialChar ~
3804 \SpecialChar ~
3805 \SpecialChar ~
3806 \SpecialChar ~
3807 /* some more c code */
3808 \newline 
3809 }
3810 \newline 
3811
3812 \newline 
3813
3814 \family default 
3815 In other words inline assembly code can access labels defined in inline
3816  assembly within the scope of the funtion.
3817  
3818 \layout Standard
3819
3820 The same goes the other way, ie.
3821  labels defines in inline assembly CANNOT be accessed by C statements.
3822 \layout Subsection
3823
3824 int(16 bit) and long (32 bit) Support
3825 \layout Standard
3826
3827 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
3828  multiplication and modulus operations are implemented by support routines.
3829  These support routines are all developed in ANSI-C to facilitate porting
3830  to other MCUs, although some model specific assembler optimations are used.
3831  The following files contain the described routine, all of them can be found
3832  in <installdir>/share/sdcc/lib.
3833 \newline 
3834
3835 \newline 
3836
3837 \emph on 
3838 <pending: tabularise this>
3839 \emph default 
3840
3841 \newline 
3842
3843 \newline 
3844 _mulsint.c - signed 16 bit multiplication (calls _muluint)
3845 \newline 
3846 _muluint.c - unsigned 16 bit multiplication
3847 \newline 
3848 _divsint.c - signed 16 bit division (calls _divuint)
3849 \newline 
3850 _divuint.c - unsigned 16 bit division
3851 \newline 
3852 _modsint.c - signed 16 bit modulus (call _moduint)
3853 \newline 
3854 _moduint.c - unsigned 16 bit modulus
3855 \newline 
3856 _mulslong.c - signed 32 bit multiplication (calls _mululong)
3857 \newline 
3858 _mululong.c - unsigned32 bit multiplication
3859 \newline 
3860 _divslong.c - signed 32 division (calls _divulong)
3861 \newline 
3862 _divulong.c - unsigned 32 division
3863 \newline 
3864 _modslong.c - signed 32 bit modulus (calls _modulong)
3865 \newline 
3866 _modulong.c - unsigned 32 bit modulus 
3867 \size footnotesize 
3868
3869 \newline 
3870
3871 \newline 
3872
3873 \size default 
3874 Since they are compiled as 
3875 \emph on 
3876 non-reentrant
3877 \emph default 
3878 , interrupt service routines should not do any of the above operations.
3879  If this is unavoidable then the above routines will need to be compiled
3880  with the 
3881 \emph on 
3882 ---stack-auto
3883 \emph default 
3884  option, after which the source program will have to be compiled with 
3885 \emph on 
3886 ---int-long-rent
3887 \emph default 
3888  option.
3889 \layout Subsection
3890
3891 Floating Point Support
3892 \layout Standard
3893
3894 SDCC supports IEEE (single precision 4bytes) floating point numbers.The floating
3895  point support routines are derived from gcc's floatlib.c and consists of
3896  the following routines:
3897 \newline 
3898
3899 \newline 
3900
3901 \emph on 
3902 <pending: tabularise this>
3903 \emph default 
3904
3905 \newline 
3906
3907 \newline 
3908 _fsadd.c - add floating point numbers
3909 \newline 
3910 _fssub.c - subtract floating point numbers
3911 \newline 
3912 _fsdiv.c - divide floating point numbers
3913 \newline 
3914 _fsmul.c - multiply floating point numbers
3915 \newline 
3916 _fs2uchar.c - convert floating point to unsigned char
3917 \newline 
3918 _fs2char.c - convert floating point to signed char
3919 \newline 
3920 _fs2uint.c - convert floating point to unsigned int
3921 \newline 
3922 _fs2int.c - convert floating point to signed int
3923 \newline 
3924 _fs2ulong.c - convert floating point to unsigned long
3925 \newline 
3926 _fs2long.c - convert floating point to signed long
3927 \newline 
3928 _uchar2fs.c - convert unsigned char to floating point
3929 \newline 
3930 _char2fs.c - convert char to floating point number
3931 \newline 
3932 _uint2fs.c - convert unsigned int to floating point
3933 \newline 
3934 _int2fs.c - convert int to floating point numbers
3935 \newline 
3936 _ulong2fs.c - convert unsigned long to floating point number
3937 \newline 
3938 _long2fs.c - convert long to floating point number
3939 \size footnotesize 
3940
3941 \newline 
3942
3943 \newline 
3944
3945 \size default 
3946 Note if all these routines are used simultaneously the data space might
3947  overflow.
3948  For serious floating point usage it is strongly recommended that the large
3949  model be used.
3950 \layout Subsection
3951
3952 MCS51 Memory Models
3953 \layout Standard
3954
3955 SDCC allows two memory models for MCS51 code, small and large.
3956  Modules compiled with different memory models should 
3957 \emph on 
3958 never
3959 \emph default 
3960  be combined together or the results would be unpredictable.
3961  The library routines supplied with the compiler are compiled as both small
3962  and large.
3963  The compiled library modules are contained in seperate directories as small
3964  and large so that you can link to either set.
3965  
3966 \layout Standard
3967
3968 When the large model is used all variables declared without a storage class
3969  will be allocated into the external ram, this includes all parameters and
3970  local variables (for non-reentrant functions).
3971  When the small model is used variables without storage class are allocated
3972  in the internal ram.
3973 \layout Standard
3974
3975 Judicious usage of the processor specific storage classes and the 'reentrant'
3976  function type will yield much more efficient code, than using the large
3977  model.
3978  Several optimizations are disabled when the program is compiled using the
3979  large model, it is therefore strongly recommdended that the small model
3980  be used unless absolutely required.
3981 \layout Subsection
3982
3983 DS390 Memory Models
3984 \layout Standard
3985
3986 The only model supported is Flat 24.
3987  This generates code for the 24 bit contiguous addressing mode of the Dallas
3988  DS80C390 part.
3989  In this mode, up to four meg of external RAM or code space can be directly
3990  addressed.
3991  See the data sheets at www.dalsemi.com for further information on this part.
3992 \newline 
3993
3994 \newline 
3995 In older versions of the compiler, this option was used with the MCS51 code
3996  generator (
3997 \emph on 
3998 -mmcs51
3999 \emph default 
4000 ).
4001  Now, however, the '390 has it's own code generator, selected by the 
4002 \emph on 
4003 -mds390
4004 \emph default 
4005  switch.
4006  
4007 \newline 
4008
4009 \newline 
4010 Note that the compiler does not generate any code to place the processor
4011  into 24 bitmode (although 
4012 \emph on 
4013 tinibios
4014 \emph default 
4015  in the ds390 libraries will do that for you).
4016  If you don't use 
4017 \emph on 
4018 tinibios
4019 \emph default 
4020 , the boot loader or similar code must ensure that the processor is in 24
4021  bit contiguous addressing mode before calling the SDCC startup code.
4022 \newline 
4023
4024 \newline 
4025 Like the 
4026 \emph on 
4027 ---model-large
4028 \emph default 
4029  option, variables will by default be placed into the XDATA segment.
4030  
4031 \newline 
4032
4033 \newline 
4034 Segments may be placed anywhere in the 4 meg address space using the usual
4035  ---*-loc options.
4036  Note that if any segments are located above 64K, the -r flag must be passed
4037  to the linker to generate the proper segment relocations, and the Intel
4038  HEX output format must be used.
4039  The -r flag can be passed to the linker by using the option 
4040 \emph on 
4041 -Wl-r
4042 \emph default 
4043  on the sdcc command line.
4044  However, currently the linker can not handle code segments > 64k.
4045 \layout Subsection
4046
4047 Defines Created by the Compiler
4048 \layout Standard
4049
4050 The compiler creates the following #defines.
4051 \layout Itemize
4052
4053 SDCC - this Symbol is always defined.
4054 \layout Itemize
4055
4056 SDCC_mcs51 or SDCC_ds390 or SDCC_z80, etc - depending on the model used
4057  (e.g.: -mds390)
4058 \layout Itemize
4059
4060 __mcs51 or __ds390 or __z80, etc - depending on the model used (e.g.
4061  -mz80)
4062 \layout Itemize
4063
4064 SDCC_STACK_AUTO - this symbol is defined when 
4065 \emph on 
4066 ---stack-auto
4067 \emph default 
4068  option is used.
4069 \layout Itemize
4070
4071 SDCC_MODEL_SMALL - when 
4072 \emph on 
4073 ---model-small
4074 \emph default 
4075  is used.
4076 \layout Itemize
4077
4078 SDCC_MODEL_LARGE - when 
4079 \emph on 
4080 ---model-large
4081 \emph default 
4082  is used.
4083 \layout Itemize
4084
4085 SDCC_USE_XSTACK - when 
4086 \emph on 
4087 ---xstack
4088 \emph default 
4089  option is used.
4090 \layout Itemize
4091
4092 SDCC_STACK_TENBIT - when 
4093 \emph on 
4094 -mds390
4095 \emph default 
4096  is used
4097 \layout Itemize
4098
4099 SDCC_MODEL_FLAT24 - when 
4100 \emph on 
4101 -mds390
4102 \emph default 
4103  is used
4104 \layout Section
4105
4106 SDCC Technical Data
4107 \layout Subsection
4108
4109 Optimizations
4110 \layout Standard
4111
4112 SDCC performs a host of standard optimizations in addition to some MCU specific
4113  optimizations.
4114  
4115 \layout Subsubsection
4116
4117 Sub-expression Elimination
4118 \layout Standard
4119
4120 The compiler does local and global common subexpression elimination, e.g.:
4121  
4122 \newline 
4123
4124 \newline 
4125
4126 \family typewriter 
4127 i = x + y + 1; 
4128 \newline 
4129 j = x + y;
4130 \family default 
4131
4132 \newline 
4133
4134 \newline 
4135 will be translated to
4136 \newline 
4137
4138 \newline 
4139
4140 \family typewriter 
4141 iTemp = x + y 
4142 \newline 
4143 i = iTemp + 1 
4144 \newline 
4145 j = iTemp
4146 \newline 
4147
4148 \family default 
4149
4150 \newline 
4151 Some subexpressions are not as obvious as the above example, e.g.:
4152 \newline 
4153
4154 \newline 
4155
4156 \family typewriter 
4157 a->b[i].c = 10; 
4158 \newline 
4159 a->b[i].d = 11;
4160 \family default 
4161
4162 \newline 
4163
4164 \newline 
4165 In this case the address arithmetic a->b[i] will be computed only once;
4166  the equivalent code in C would be.
4167 \newline 
4168
4169 \newline 
4170
4171 \family typewriter 
4172 iTemp = a->b[i]; 
4173 \newline 
4174 iTemp.c = 10; 
4175 \newline 
4176 iTemp.d = 11;
4177 \family default 
4178
4179 \newline 
4180
4181 \newline 
4182 The compiler will try to keep these temporary variables in registers.
4183 \layout Subsubsection
4184
4185 Dead-Code Elimination
4186 \layout Standard
4187
4188
4189 \family typewriter 
4190 int global; 
4191 \newline 
4192 void f () { 
4193 \newline 
4194 \SpecialChar ~
4195 \SpecialChar ~
4196 int i; 
4197 \newline 
4198 \SpecialChar ~
4199 \SpecialChar ~
4200 i = 1; \SpecialChar ~
4201 /* dead store */ 
4202 \newline 
4203 \SpecialChar ~
4204 \SpecialChar ~
4205 global = 1;\SpecialChar ~
4206 /* dead store */ 
4207 \newline 
4208 \SpecialChar ~
4209 \SpecialChar ~
4210 global = 2; 
4211 \newline 
4212 \SpecialChar ~
4213 \SpecialChar ~
4214 return; 
4215 \newline 
4216 \SpecialChar ~
4217 \SpecialChar ~
4218 global = 3;\SpecialChar ~
4219 /* unreachable */ 
4220 \newline 
4221 }
4222 \family default 
4223
4224 \newline 
4225
4226 \newline 
4227 will be changed to
4228 \newline 
4229
4230 \newline 
4231
4232 \family typewriter 
4233 int global; void f () 
4234 \newline 
4235 {
4236 \newline 
4237 \SpecialChar ~
4238 \SpecialChar ~
4239 global = 2; 
4240 \newline 
4241 \SpecialChar ~
4242 \SpecialChar ~
4243 return; 
4244 \newline 
4245 }
4246 \layout Subsubsection
4247
4248 Copy-Propagation
4249 \layout Standard
4250
4251
4252 \family typewriter 
4253 int f() { 
4254 \newline 
4255 \SpecialChar ~
4256 \SpecialChar ~
4257 int i, j; 
4258 \newline 
4259 \SpecialChar ~
4260 \SpecialChar ~
4261 i = 10; 
4262 \newline 
4263 \SpecialChar ~
4264 \SpecialChar ~
4265 j = i; 
4266 \newline 
4267 \SpecialChar ~
4268 \SpecialChar ~
4269 return j; 
4270 \newline 
4271 }
4272 \family default 
4273
4274 \newline 
4275
4276 \newline 
4277 will be changed to 
4278 \newline 
4279
4280 \newline 
4281
4282 \family typewriter 
4283 int f() { 
4284 \newline 
4285 \SpecialChar ~
4286  \SpecialChar ~
4287  int i,j; 
4288 \newline 
4289 \SpecialChar ~
4290  \SpecialChar ~
4291  i = 10; 
4292 \newline 
4293 \SpecialChar ~
4294  \SpecialChar ~
4295  j = 10; 
4296 \newline 
4297 \SpecialChar ~
4298  \SpecialChar ~
4299  return 10; 
4300 \newline 
4301 }
4302 \newline 
4303
4304 \newline 
4305
4306 \family default 
4307 Note: the dead stores created by this copy propagation will be eliminated
4308  by dead-code elimination.
4309 \layout Subsubsection
4310
4311 Loop Optimizations
4312 \layout Standard
4313
4314 Two types of loop optimizations are done by SDCC loop invariant lifting
4315  and strength reduction of loop induction variables.
4316  In addition to the strength reduction the optimizer marks the induction
4317  variables and the register allocator tries to keep the induction variables
4318  in registers for the duration of the loop.
4319  Because of this preference of the register allocator, loop induction optimizati
4320 on causes an increase in register pressure, which may cause unwanted spilling
4321  of other temporary variables into the stack / data space.
4322  The compiler will generate a warning message when it is forced to allocate
4323  extra space either on the stack or data space.
4324  If this extra space allocation is undesirable then induction optimization
4325  can be eliminated either for the entire source file (with ---noinduction
4326  option) or for a given function only using #pragma\SpecialChar ~
4327 NOINDUCTION.
4328 \newline 
4329
4330 \newline 
4331 Loop Invariant:
4332 \newline 
4333
4334 \newline 
4335
4336 \family typewriter 
4337 for (i = 0 ; i < 100 ; i ++) 
4338 \newline 
4339  \SpecialChar ~
4340  \SpecialChar ~
4341 f += k + l;
4342 \family default 
4343
4344 \newline 
4345
4346 \newline 
4347 changed to
4348 \newline 
4349
4350 \newline 
4351
4352 \family typewriter 
4353 itemp = k + l; 
4354 \newline 
4355 for (i = 0; i < 100; i++) 
4356 \newline 
4357 \SpecialChar ~
4358 \SpecialChar ~
4359 f += itemp;
4360 \family default 
4361
4362 \newline 
4363
4364 \newline 
4365 As mentioned previously some loop invariants are not as apparent, all static
4366  address computations are also moved out of the loop.
4367 \newline 
4368
4369 \newline 
4370 Strength Reduction, this optimization substitutes an expression by a cheaper
4371  expression:
4372 \newline 
4373
4374 \newline 
4375
4376 \family typewriter 
4377 for (i=0;i < 100; i++)
4378 \newline 
4379 \SpecialChar ~
4380 \SpecialChar ~
4381 ar[i*5] = i*3;
4382 \family default 
4383
4384 \newline 
4385
4386 \newline 
4387 changed to
4388 \newline 
4389
4390 \newline 
4391
4392 \family typewriter 
4393 itemp1 = 0; 
4394 \newline 
4395 itemp2 = 0; 
4396 \newline 
4397 for (i=0;i< 100;i++) { 
4398 \newline 
4399  \SpecialChar ~
4400  \SpecialChar ~
4401 ar[itemp1] = itemp2; 
4402 \newline 
4403  \SpecialChar ~
4404  \SpecialChar ~
4405 itemp1 += 5; 
4406 \newline 
4407  \SpecialChar ~
4408  \SpecialChar ~
4409 itemp2 += 3; 
4410 \newline 
4411 }
4412 \family default 
4413
4414 \newline 
4415
4416 \newline 
4417 The more expensive multiplication is changed to a less expensive addition.
4418 \layout Subsubsection
4419
4420 Loop Reversing
4421 \layout Standard
4422
4423 This optimization is done to reduce the overhead of checking loop boundaries
4424  for every iteration.
4425  Some simple loops can be reversed and implemented using a 
4426 \begin_inset Quotes eld
4427 \end_inset 
4428
4429 decrement and jump if not zero
4430 \begin_inset Quotes erd
4431 \end_inset 
4432
4433  instruction.
4434  SDCC checks for the following criterion to determine if a loop is reversible
4435  (note: more sophisticated compilers use data-dependency analysis to make
4436  this determination, SDCC uses a more simple minded analysis).
4437 \layout Itemize
4438
4439 The 'for' loop is of the form 
4440 \newline 
4441
4442 \newline 
4443
4444 \family typewriter 
4445 for (<symbol> = <expression> ; <sym> [< | <=] <expression> ; [<sym>++ |
4446  <sym> += 1])
4447 \newline 
4448 \SpecialChar ~
4449 \SpecialChar ~
4450 \SpecialChar ~
4451 \SpecialChar ~
4452 <for body>
4453 \layout Itemize
4454
4455 The <for body> does not contain 
4456 \begin_inset Quotes eld
4457 \end_inset 
4458
4459 continue
4460 \begin_inset Quotes erd
4461 \end_inset 
4462
4463  or 'break
4464 \begin_inset Quotes erd
4465 \end_inset 
4466
4467 .
4468 \layout Itemize
4469
4470 All goto's are contained within the loop.
4471 \layout Itemize
4472
4473 No function calls within the loop.
4474 \layout Itemize
4475
4476 The loop control variable <sym> is not assigned any value within the loop
4477 \layout Itemize
4478
4479 The loop control variable does NOT participate in any arithmetic operation
4480  within the loop.
4481 \layout Itemize
4482
4483 There are NO switch statements in the loop.
4484 \layout Subsubsection
4485
4486 Algebraic Simplifications
4487 \layout Standard
4488
4489 SDCC does numerous algebraic simplifications, the following is a small sub-set
4490  of these optimizations.
4491 \newline 
4492
4493 \newline 
4494
4495 \family typewriter 
4496 i = j + 0 ; /* changed to */ i = j; 
4497 \newline 
4498 i /= 2; /* changed to */ i >>= 1; 
4499 \newline 
4500 i = j - j ; /* changed to */ i = 0; 
4501 \newline 
4502 i = j / 1 ; /* changed to */ i = j;
4503 \family default 
4504
4505 \newline 
4506
4507 \newline 
4508 Note the subexpressions given above are generally introduced by macro expansions
4509  or as a result of copy/constant propagation.
4510 \layout Subsubsection
4511
4512 'switch' Statements
4513 \layout Standard
4514
4515 SDCC changes switch statements to jump tables when the following conditions
4516  are true.
4517  
4518 \layout Itemize
4519
4520 The case labels are in numerical sequence, the labels need not be in order,
4521  and the starting number need not be one or zero.
4522 \newline 
4523
4524 \newline 
4525
4526 \family typewriter 
4527 switch(i) {\SpecialChar ~
4528  \SpecialChar ~
4529  \SpecialChar ~
4530  \SpecialChar ~
4531  \SpecialChar ~
4532  \SpecialChar ~
4533  \SpecialChar ~
4534  \SpecialChar ~
4535  \SpecialChar ~
4536  \SpecialChar ~
4537  \SpecialChar ~
4538  \SpecialChar ~
4539  \SpecialChar ~
4540 switch (i) { 
4541 \newline 
4542 case 4:...
4543  \SpecialChar ~
4544  \SpecialChar ~
4545  \SpecialChar ~
4546  \SpecialChar ~
4547  \SpecialChar ~
4548  \SpecialChar ~
4549  \SpecialChar ~
4550  \SpecialChar ~
4551  \SpecialChar ~
4552  \SpecialChar ~
4553  \SpecialChar ~
4554  \SpecialChar ~
4555  \SpecialChar ~
4556 case 1: ...
4557  
4558 \newline 
4559 case 5:...
4560  \SpecialChar ~
4561  \SpecialChar ~
4562  \SpecialChar ~
4563  \SpecialChar ~
4564  \SpecialChar ~
4565  \SpecialChar ~
4566  \SpecialChar ~
4567  \SpecialChar ~
4568  \SpecialChar ~
4569  \SpecialChar ~
4570  \SpecialChar ~
4571  \SpecialChar ~
4572  \SpecialChar ~
4573 case 2: ...
4574  
4575 \newline 
4576 case 3:...
4577  \SpecialChar ~
4578  \SpecialChar ~
4579  \SpecialChar ~
4580  \SpecialChar ~
4581  \SpecialChar ~
4582  \SpecialChar ~
4583  \SpecialChar ~
4584  \SpecialChar ~
4585  \SpecialChar ~
4586  \SpecialChar ~
4587  \SpecialChar ~
4588  \SpecialChar ~
4589  \SpecialChar ~
4590 case 3: ...
4591  
4592 \newline 
4593 case 6:...
4594  \SpecialChar ~
4595  \SpecialChar ~
4596  \SpecialChar ~
4597  \SpecialChar ~
4598  \SpecialChar ~
4599  \SpecialChar ~
4600  \SpecialChar ~
4601  \SpecialChar ~
4602  \SpecialChar ~
4603  \SpecialChar ~
4604  \SpecialChar ~
4605  \SpecialChar ~
4606  \SpecialChar ~
4607 case 4: ...
4608  
4609 \newline 
4610 }\SpecialChar ~
4611  \SpecialChar ~
4612  \SpecialChar ~
4613  \SpecialChar ~
4614  \SpecialChar ~
4615  \SpecialChar ~
4616  \SpecialChar ~
4617  \SpecialChar ~
4618  \SpecialChar ~
4619  \SpecialChar ~
4620  \SpecialChar ~
4621  \SpecialChar ~
4622  \SpecialChar ~
4623  \SpecialChar ~
4624  \SpecialChar ~
4625  \SpecialChar ~
4626  \SpecialChar ~
4627  \SpecialChar ~
4628 }
4629 \newline 
4630
4631 \newline 
4632
4633 \family default 
4634 Both the above switch statements will be implemented using a jump-table.
4635 \layout Itemize
4636
4637 The number of case labels is at least three, since it takes two conditional
4638  statements to handle the boundary conditions.
4639 \layout Itemize
4640
4641 The number of case labels is less than 84, since each label takes 3 bytes
4642  and a jump-table can be utmost 256 bytes long.
4643  
4644 \layout Standard
4645
4646 Switch statements which have gaps in the numeric sequence or those that
4647  have more that 84 case labels can be split into more than one switch statement
4648  for efficient code generation, e.g.:
4649 \newline 
4650
4651 \newline 
4652
4653 \family typewriter 
4654 switch (i) { 
4655 \newline 
4656 case 1: ...
4657  
4658 \newline 
4659 case 2: ...
4660  
4661 \newline 
4662 case 3: ...
4663  
4664 \newline 
4665 case 4: ...
4666  
4667 \newline 
4668 case 9: ...
4669  
4670 \newline 
4671 case 10: ...
4672  
4673 \newline 
4674 case 11: ...
4675  
4676 \newline 
4677 case 12: ...
4678  
4679 \newline 
4680 }
4681 \family default 
4682
4683 \newline 
4684
4685 \newline 
4686 If the above switch statement is broken down into two switch statements
4687 \newline 
4688
4689 \newline 
4690
4691 \family typewriter 
4692 switch (i) { 
4693 \newline 
4694 case 1: ...
4695  
4696 \newline 
4697 case 2: ...
4698  
4699 \newline 
4700 case 3: ...
4701  
4702 \newline 
4703 case 4: ...
4704  
4705 \newline 
4706 }
4707 \newline 
4708
4709 \newline 
4710
4711 \family default 
4712 and
4713 \family typewriter 
4714
4715 \newline 
4716
4717 \newline 
4718 switch (i) { 
4719 \newline 
4720 case 9: \SpecialChar ~
4721 ...
4722  
4723 \newline 
4724 case 10: ...
4725  
4726 \newline 
4727 case 11: ...
4728  
4729 \newline 
4730 case 12:\SpecialChar ~
4731 ...
4732  
4733 \newline 
4734 }
4735 \newline 
4736
4737 \newline 
4738
4739 \family default 
4740 then both the switch statements will be implemented using jump-tables whereas
4741  the unmodified switch statement will not be.
4742 \layout Subsubsection
4743
4744 Bit-shifting Operations.
4745 \layout Standard
4746
4747 Bit shifting is one of the most frequently used operation in embedded programmin
4748 g.
4749  SDCC tries to implement bit-shift operations in the most efficient way
4750  possible, e.g.:
4751 \newline 
4752
4753 \family typewriter 
4754
4755 \newline 
4756 unsigned char i;
4757 \newline 
4758 ...
4759  
4760 \newline 
4761 i>>= 4; 
4762 \newline 
4763 ...
4764 \newline 
4765
4766 \family default 
4767
4768 \newline 
4769 generates the following code:
4770 \newline 
4771
4772 \family typewriter 
4773
4774 \newline 
4775 mov a,_i 
4776 \newline 
4777 swap a 
4778 \newline 
4779 anl a,#0x0f 
4780 \newline 
4781 mov _i,a
4782 \family default 
4783
4784 \newline 
4785
4786 \newline 
4787 In general SDCC will never setup a loop if the shift count is known.
4788  Another example:
4789 \newline 
4790
4791 \newline 
4792
4793 \family typewriter 
4794 unsigned int i; 
4795 \newline 
4796 ...
4797  
4798 \newline 
4799 i >>= 9; 
4800 \newline 
4801 ...
4802 \family default 
4803
4804 \newline 
4805
4806 \newline 
4807 will generate:
4808 \newline 
4809
4810 \newline 
4811
4812 \family typewriter 
4813 mov a,(_i + 1) 
4814 \newline 
4815 mov (_i + 1),#0x00 
4816 \newline 
4817 clr c 
4818 \newline 
4819 rrc a 
4820 \newline 
4821 mov _i,a
4822 \family default 
4823
4824 \newline 
4825
4826 \newline 
4827 Note that SDCC stores numbers in little-endian format (i.e.
4828  lowest order first).
4829 \layout Subsubsection
4830
4831 Bit-rotation
4832 \layout Standard
4833
4834 A special case of the bit-shift operation is bit rotation, SDCC recognizes
4835  the following expression to be a left bit-rotation:
4836 \newline 
4837
4838 \newline 
4839
4840 \family typewriter 
4841 unsigned char i; 
4842 \newline 
4843 ...
4844  
4845 \newline 
4846 i = ((i << 1) | (i >> 7)); 
4847 \family default 
4848
4849 \newline 
4850 ...
4851 \newline 
4852
4853 \newline 
4854 will generate the following code:
4855 \newline 
4856
4857 \newline 
4858
4859 \family typewriter 
4860 mov a,_i 
4861 \newline 
4862 rl a 
4863 \newline 
4864 mov _i,a
4865 \family default 
4866
4867 \newline 
4868
4869 \newline 
4870 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
4871 ns of this case will also be recognized as bit-rotation, i.e.: 
4872 \newline 
4873
4874 \newline 
4875
4876 \family typewriter 
4877 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
4878 \layout Subsubsection
4879
4880 Highest Order Bit
4881 \layout Standard
4882
4883 It is frequently required to obtain the highest order bit of an integral
4884  type (long, int, short or char types).
4885  SDCC recognizes the following expression to yield the highest order bit
4886  and generates optimized code for it, e.g.:
4887 \newline 
4888
4889 \newline 
4890  
4891 \family typewriter 
4892 unsigned int gint; 
4893 \newline 
4894
4895 \newline 
4896 foo () { 
4897 \newline 
4898 unsigned char hob; 
4899 \newline 
4900 \SpecialChar ~
4901 \SpecialChar ~
4902 ...
4903  
4904 \newline 
4905 \SpecialChar ~
4906 \SpecialChar ~
4907 hob = (gint >> 15) & 1; 
4908 \newline 
4909 \SpecialChar ~
4910 \SpecialChar ~
4911 ..
4912  
4913 \newline 
4914 }
4915 \family default 
4916
4917 \newline 
4918
4919 \newline 
4920 will generate the following code:
4921 \newline 
4922
4923 \family typewriter 
4924
4925 \newline 
4926 \SpecialChar ~
4927 \SpecialChar ~
4928 \SpecialChar ~
4929 \SpecialChar ~
4930 \SpecialChar ~
4931 \SpecialChar ~
4932 \SpecialChar ~
4933 \SpecialChar ~
4934 \SpecialChar ~
4935 \SpecialChar ~
4936 \SpecialChar ~
4937 \SpecialChar ~
4938 \SpecialChar ~
4939 \SpecialChar ~
4940 \SpecialChar ~
4941 \SpecialChar ~
4942 \SpecialChar ~
4943 \SpecialChar ~
4944 \SpecialChar ~
4945 \SpecialChar ~
4946 \SpecialChar ~
4947 \SpecialChar ~
4948 \SpecialChar ~
4949 \SpecialChar ~
4950 \SpecialChar ~
4951 \SpecialChar ~
4952 \SpecialChar ~
4953 \SpecialChar ~
4954  61 ;\SpecialChar ~
4955  hob.c 7 
4956 \newline 
4957 \SpecialChar ~
4958 \SpecialChar ~
4959  000A E5*01\SpecialChar ~
4960 \SpecialChar ~
4961 \SpecialChar ~
4962 \SpecialChar ~
4963 \SpecialChar ~
4964 \SpecialChar ~
4965 \SpecialChar ~
4966 \SpecialChar ~
4967 \SpecialChar ~
4968 \SpecialChar ~
4969 \SpecialChar ~
4970 \SpecialChar ~
4971 \SpecialChar ~
4972 \SpecialChar ~
4973 \SpecialChar ~
4974  62\SpecialChar ~
4975 \SpecialChar ~
4976 \SpecialChar ~
4977 \SpecialChar ~
4978 \SpecialChar ~
4979 \SpecialChar ~
4980 \SpecialChar ~
4981 \SpecialChar ~
4982  mov\SpecialChar ~
4983  a,(_gint + 1) 
4984 \newline 
4985 \SpecialChar ~
4986 \SpecialChar ~
4987  000C 33\SpecialChar ~
4988 \SpecialChar ~
4989 \SpecialChar ~
4990 \SpecialChar ~
4991 \SpecialChar ~
4992 \SpecialChar ~
4993 \SpecialChar ~
4994 \SpecialChar ~
4995 \SpecialChar ~
4996 \SpecialChar ~
4997 \SpecialChar ~
4998 \SpecialChar ~
4999 \SpecialChar ~
5000 \SpecialChar ~
5001 \SpecialChar ~
5002 \SpecialChar ~
5003 \SpecialChar ~
5004 \SpecialChar ~
5005  63\SpecialChar ~
5006 \SpecialChar ~
5007 \SpecialChar ~
5008 \SpecialChar ~
5009 \SpecialChar ~
5010 \SpecialChar ~
5011 \SpecialChar ~
5012 \SpecialChar ~
5013  rlc\SpecialChar ~
5014  a 
5015 \newline 
5016 \SpecialChar ~
5017 \SpecialChar ~
5018  000D E4\SpecialChar ~
5019 \SpecialChar ~
5020 \SpecialChar ~
5021 \SpecialChar ~
5022 \SpecialChar ~
5023 \SpecialChar ~
5024 \SpecialChar ~
5025 \SpecialChar ~
5026 \SpecialChar ~
5027 \SpecialChar ~
5028 \SpecialChar ~
5029 \SpecialChar ~
5030 \SpecialChar ~
5031 \SpecialChar ~
5032 \SpecialChar ~
5033 \SpecialChar ~
5034 \SpecialChar ~
5035 \SpecialChar ~
5036  64\SpecialChar ~
5037 \SpecialChar ~
5038 \SpecialChar ~
5039 \SpecialChar ~
5040 \SpecialChar ~
5041 \SpecialChar ~
5042 \SpecialChar ~
5043 \SpecialChar ~
5044  clr\SpecialChar ~
5045  a 
5046 \newline 
5047 \SpecialChar ~
5048 \SpecialChar ~
5049  000E 13\SpecialChar ~
5050 \SpecialChar ~
5051 \SpecialChar ~
5052 \SpecialChar ~
5053 \SpecialChar ~
5054 \SpecialChar ~
5055 \SpecialChar ~
5056 \SpecialChar ~
5057 \SpecialChar ~
5058 \SpecialChar ~
5059 \SpecialChar ~
5060 \SpecialChar ~
5061 \SpecialChar ~
5062 \SpecialChar ~
5063 \SpecialChar ~
5064 \SpecialChar ~
5065 \SpecialChar ~
5066 \SpecialChar ~
5067  65\SpecialChar ~
5068 \SpecialChar ~
5069 \SpecialChar ~
5070 \SpecialChar ~
5071 \SpecialChar ~
5072 \SpecialChar ~
5073 \SpecialChar ~
5074 \SpecialChar ~
5075  rrc\SpecialChar ~
5076  a 
5077 \newline 
5078 \SpecialChar ~
5079 \SpecialChar ~
5080  000F F5*02\SpecialChar ~
5081 \SpecialChar ~
5082 \SpecialChar ~
5083 \SpecialChar ~
5084 \SpecialChar ~
5085 \SpecialChar ~
5086 \SpecialChar ~
5087 \SpecialChar ~
5088 \SpecialChar ~
5089 \SpecialChar ~
5090 \SpecialChar ~
5091 \SpecialChar ~
5092 \SpecialChar ~
5093 \SpecialChar ~
5094 \SpecialChar ~
5095  66\SpecialChar ~
5096 \SpecialChar ~
5097 \SpecialChar ~
5098 \SpecialChar ~
5099 \SpecialChar ~
5100 \SpecialChar ~
5101 \SpecialChar ~
5102 \SpecialChar ~
5103  mov\SpecialChar ~
5104  _foo_hob_1_1,a
5105 \newline 
5106
5107 \newline 
5108
5109 \family default 
5110 Variations of this case however will 
5111 \emph on 
5112 not
5113 \emph default 
5114  be recognized.
5115  It is a standard C expression, so I heartily recommend this be the only
5116  way to get the highest order bit, (it is portable).
5117  Of course it will be recognized even if it is embedded in other expressions,
5118  e.g.:
5119 \newline 
5120
5121 \newline 
5122
5123 \family typewriter 
5124 xyz = gint + ((gint >> 15) & 1);
5125 \family default 
5126
5127 \newline 
5128
5129 \newline 
5130 will still be recognized.
5131 \layout Subsubsection
5132
5133 Peep-hole Optimizer
5134 \layout Standard
5135
5136 The compiler uses a rule based, pattern matching and re-writing mechanism
5137  for peep-hole optimization.
5138  It is inspired by 
5139 \emph on 
5140 copt
5141 \emph default 
5142  a peep-hole optimizer by Christopher W.
5143  Fraser (cwfraser@microsoft.com).
5144  A default set of rules are compiled into the compiler, additional rules
5145  may be added with the 
5146 \emph on 
5147 ---peep-file <filename>
5148 \emph default 
5149  option.
5150  The rule language is best illustrated with examples.
5151 \newline 
5152
5153 \newline 
5154
5155 \family typewriter 
5156 replace { 
5157 \newline 
5158 \SpecialChar ~
5159 \SpecialChar ~
5160 mov %1,a 
5161 \newline 
5162 \SpecialChar ~
5163 \SpecialChar ~
5164 mov a,%1
5165 \newline 
5166 } by {
5167 \newline 
5168 \SpecialChar ~
5169 \SpecialChar ~
5170 mov %1,a
5171 \newline 
5172 }
5173 \family default 
5174
5175 \newline 
5176
5177 \newline 
5178 The above rule will change the following assembly sequence:
5179 \newline 
5180
5181 \newline 
5182
5183 \family typewriter 
5184 \SpecialChar ~
5185 \SpecialChar ~
5186 mov r1,a 
5187 \newline 
5188 \SpecialChar ~
5189 \SpecialChar ~
5190 mov a,r1
5191 \family default 
5192
5193 \newline 
5194
5195 \newline 
5196 to
5197 \newline 
5198
5199 \newline 
5200
5201 \family typewriter 
5202 mov r1,a
5203 \family default 
5204
5205 \newline 
5206
5207 \newline 
5208 Note: All occurrences of a 
5209 \emph on 
5210 %n
5211 \emph default 
5212  (pattern variable) must denote the same string.
5213  With the above rule, the assembly sequence:
5214 \newline 
5215
5216 \newline 
5217
5218 \family typewriter 
5219 \SpecialChar ~
5220 \SpecialChar ~
5221 mov r1,a 
5222 \newline 
5223 \SpecialChar ~
5224 \SpecialChar ~
5225 mov a,r2
5226 \family default 
5227
5228 \newline 
5229
5230 \newline 
5231 will remain unmodified.
5232 \newline 
5233
5234 \newline 
5235 Other special case optimizations may be added by the user (via 
5236 \emph on 
5237 ---peep-file option
5238 \emph default 
5239 ).
5240  E.g.
5241  some variants of the 8051 MCU allow only 
5242 \family typewriter 
5243 ajmp
5244 \family default 
5245  and 
5246 \family typewriter 
5247 acall
5248 \family default 
5249 .
5250  The following two rules will change all 
5251 \family typewriter 
5252 ljmp
5253 \family default 
5254  and 
5255 \family typewriter 
5256 lcall
5257 \family default 
5258  to 
5259 \family typewriter 
5260 ajmp
5261 \family default 
5262  and 
5263 \family typewriter 
5264 acall
5265 \family default 
5266
5267 \newline 
5268
5269 \newline 
5270
5271 \family typewriter 
5272 replace { lcall %1 } by { acall %1 } 
5273 \newline 
5274 replace { ljmp %1 } by { ajmp %1 }
5275 \family default 
5276
5277 \newline 
5278
5279 \newline 
5280 The 
5281 \emph on 
5282 inline-assembler code
5283 \emph default 
5284  is also passed through the peep hole optimizer, thus the peephole optimizer
5285  can also be used as an assembly level macro expander.
5286  The rules themselves are MCU dependent whereas the rule language infra-structur
5287 e is MCU independent.
5288  Peephole optimization rules for other MCU can be easily programmed using
5289  the rule language.
5290 \newline 
5291
5292 \newline 
5293 The syntax for a rule is as follows:
5294 \newline 
5295
5296 \newline 
5297
5298 \family typewriter 
5299 rule := replace [ restart ] '{' <assembly sequence> '
5300 \backslash 
5301 n' 
5302 \newline 
5303 \SpecialChar ~
5304  \SpecialChar ~
5305  \SpecialChar ~
5306  \SpecialChar ~
5307  \SpecialChar ~
5308  \SpecialChar ~
5309  \SpecialChar ~
5310  \SpecialChar ~
5311  \SpecialChar ~
5312  \SpecialChar ~
5313  \SpecialChar ~
5314  \SpecialChar ~
5315  \SpecialChar ~
5316  \SpecialChar ~
5317  '}' by '{' '
5318 \backslash 
5319 n' 
5320 \newline 
5321 \SpecialChar ~
5322  \SpecialChar ~
5323  \SpecialChar ~
5324  \SpecialChar ~
5325  \SpecialChar ~
5326  \SpecialChar ~
5327  \SpecialChar ~
5328  \SpecialChar ~
5329  \SpecialChar ~
5330  \SpecialChar ~
5331  \SpecialChar ~
5332  \SpecialChar ~
5333  \SpecialChar ~
5334  \SpecialChar ~
5335  \SpecialChar ~
5336  \SpecialChar ~
5337  <assembly sequence> '
5338 \backslash 
5339 n' 
5340 \newline 
5341 \SpecialChar ~
5342  \SpecialChar ~
5343  \SpecialChar ~
5344  \SpecialChar ~
5345  \SpecialChar ~
5346  \SpecialChar ~
5347  \SpecialChar ~
5348  \SpecialChar ~
5349  \SpecialChar ~
5350  \SpecialChar ~
5351  \SpecialChar ~
5352  \SpecialChar ~
5353  \SpecialChar ~
5354  \SpecialChar ~
5355  '}' [if <functionName> ] '
5356 \backslash 
5357 n' 
5358 \newline 
5359
5360 \family default 
5361
5362 \newline 
5363 <assembly sequence> := assembly instruction (each instruction including
5364  labels must be on a separate line).
5365 \newline 
5366
5367 \newline 
5368 The optimizer will apply to the rules one by one from the top in the sequence
5369  of their appearance, it will terminate when all rules are exhausted.
5370  If the 'restart' option is specified, then the optimizer will start matching
5371  the rules again from the top, this option for a rule is expensive (performance)
5372 , it is intended to be used in situations where a transformation will trigger
5373  the same rule again.
5374  An example of this (not a good one, it has side effects) is the following
5375  rule:
5376 \newline 
5377
5378 \newline 
5379
5380 \family typewriter 
5381 replace restart { 
5382 \newline 
5383 \SpecialChar ~
5384 \SpecialChar ~
5385 pop %1 
5386 \newline 
5387 \SpecialChar ~
5388 \SpecialChar ~
5389 push %1 } by { 
5390 \newline 
5391 \SpecialChar ~
5392 \SpecialChar ~
5393 ; nop 
5394 \newline 
5395 }
5396 \family default 
5397
5398 \newline 
5399
5400 \newline 
5401 Note that the replace pattern cannot be a blank, but can be a comment line.
5402  Without the 'restart' option only the inner most 'pop' 'push' pair would
5403  be eliminated, i.e.:
5404 \newline 
5405
5406 \newline 
5407
5408 \family typewriter 
5409 \SpecialChar ~
5410 \SpecialChar ~
5411 pop ar1 
5412 \newline 
5413 \SpecialChar ~
5414 \SpecialChar ~
5415 pop ar2 
5416 \newline 
5417 \SpecialChar ~
5418 \SpecialChar ~
5419 push ar2 
5420 \newline 
5421 \SpecialChar ~
5422 \SpecialChar ~
5423 push ar1
5424 \family default 
5425
5426 \newline 
5427
5428 \newline 
5429 would result in:
5430 \newline 
5431
5432 \newline 
5433
5434 \family typewriter 
5435 \SpecialChar ~
5436 \SpecialChar ~
5437 pop ar1 
5438 \newline 
5439 \SpecialChar ~
5440 \SpecialChar ~
5441 ; nop 
5442 \newline 
5443 \SpecialChar ~
5444 \SpecialChar ~
5445 push ar1
5446 \family default 
5447
5448 \newline 
5449
5450 \newline 
5451
5452 \emph on 
5453 with
5454 \emph default 
5455  the restart option the rule will be applied again to the resulting code
5456  and then all the pop-push pairs will be eliminated to yield:
5457 \newline 
5458
5459 \newline 
5460
5461 \family typewriter 
5462 \SpecialChar ~
5463 \SpecialChar ~
5464 ; nop 
5465 \newline 
5466 \SpecialChar ~
5467 \SpecialChar ~
5468 ; nop
5469 \family default 
5470
5471 \newline 
5472
5473 \newline 
5474 A conditional function can be attached to a rule.
5475  Attaching rules are somewhat more involved, let me illustrate this with
5476  an example.
5477 \newline 
5478
5479 \newline 
5480
5481 \family typewriter 
5482 replace { 
5483 \newline 
5484 \SpecialChar ~
5485  \SpecialChar ~
5486  \SpecialChar ~
5487 ljmp %5 
5488 \newline 
5489 %2:
5490 \newline 
5491 } by { 
5492 \newline 
5493 \SpecialChar ~
5494  \SpecialChar ~
5495  \SpecialChar ~
5496 sjmp %5 
5497 \newline 
5498 %2:
5499 \newline 
5500 } if labelInRange
5501 \family default 
5502
5503 \newline 
5504
5505 \newline 
5506 The optimizer does a look-up of a function name table defined in function
5507  
5508 \emph on 
5509 callFuncByName
5510 \emph default 
5511  in the source file SDCCpeeph.c, with the name 
5512 \emph on 
5513 labelInRange
5514 \emph default 
5515 .
5516  If it finds a corresponding entry the function is called.
5517  Note there can be no parameters specified for these functions, in this
5518  case the use of 
5519 \emph on 
5520 %5
5521 \emph default 
5522  is crucial, since the function 
5523 \emph on 
5524 labelInRange
5525 \emph default 
5526  expects to find the label in that particular variable (the hash table containin
5527 g the variable bindings is passed as a parameter).
5528  If you want to code more such functions, take a close look at the function
5529  labelInRange and the calling mechanism in source file SDCCpeeph.c.
5530  I know this whole thing is a little kludgey, but maybe some day we will
5531  have some better means.
5532  If you are looking at this file, you will also see the default rules that
5533  are compiled into the compiler, you can add your own rules in the default
5534  set there if you get tired of specifying the ---peep-file option.
5535 \layout Subsection
5536
5537 Pragmas
5538 \layout Standard
5539
5540 SDCC supports the following #pragma directives.
5541  This directives are applicable only at a function level.
5542 \layout Itemize
5543
5544 SAVE - this will save all the current options.
5545 \layout Itemize
5546
5547 RESTORE - will restore the saved options from the last save.
5548  Note that SAVES & RESTOREs cannot be nested.
5549  SDCC uses the same buffer to save the options each time a SAVE is called.
5550 \layout Itemize
5551
5552 NOGCSE - will stop global subexpression elimination.
5553 \layout Itemize
5554
5555 NOINDUCTION - will stop loop induction optimizations.
5556 \layout Itemize
5557
5558 NOJTBOUND - will not generate code for boundary value checking, when switch
5559  statements are turned into jump-tables.
5560 \layout Itemize
5561
5562 NOOVERLAY - the compiler will not overlay the parameters and local variables
5563  of a function.
5564 \layout Itemize
5565
5566 NOLOOPREVERSE - Will not do loop reversal optimization
5567 \layout Itemize
5568
5569 EXCLUDE NONE | {acc[,b[,dpl[,dph]]] - The exclude pragma disables generation
5570  of pair of push/pop instruction in ISR function (using interrupt keyword).
5571  The directive should be placed immediately before the ISR function definition
5572  and it affects ALL ISR functions following it.
5573  To enable the normal register saving for ISR functions use #pragma\SpecialChar ~
5574 EXCLUDE\SpecialChar ~
5575 none.
5576 \layout Itemize
5577
5578 NOIV - Do not generate interrupt vector table entries for all ISR functions
5579  defined after the pragma.
5580  This is useful in cases where the interrupt vector table must be defined
5581  manually, or when there is a secondary, manually defined interrupt vector
5582  table (e.g.
5583  for the autovector feature of the Cypress EZ-USB FX2).
5584 \layout Itemize
5585
5586 CALLEE-SAVES function1[,function2[,function3...]] - The compiler by default
5587  uses a caller saves convention for register saving across function calls,
5588  however this can cause unneccessary register pushing & popping when calling
5589  small functions from larger functions.
5590  This option can be used to switch the register saving convention for the
5591  function names specified.
5592  The compiler will not save registers when calling these functions, extra
5593  code will be generated at the entry & exit for these functions to save
5594  & restore the registers used by these functions, this can SUBSTANTIALLY
5595  reduce code & improve run time performance of the generated code.
5596  In future the compiler (with interprocedural analysis) will be able to
5597  determine the appropriate scheme to use for each function call.
5598  If ---callee-saves command line option is used, the function names specified
5599  in #pragma\SpecialChar ~
5600 CALLEE-SAVES is appended to the list of functions specified inthe
5601  command line.
5602 \layout Standard
5603
5604 The pragma's are intended to be used to turn-off certain optimizations which
5605  might cause the compiler to generate extra stack / data space to store
5606  compiler generated temporary variables.
5607  This usually happens in large functions.
5608  Pragma directives should be used as shown in the following example, they
5609  are used to control options & optimizations for a given function; pragmas
5610  should be placed before and/or after a function, placing pragma's inside
5611  a function body could have unpredictable results.
5612 \newline 
5613
5614 \newline 
5615
5616 \family typewriter 
5617 #pragma SAVE /* save the current settings */ 
5618 \newline 
5619 #pragma NOGCSE /* turnoff global subexpression elimination */ 
5620 \newline 
5621 #pragma NOINDUCTION /* turn off induction optimizations */ 
5622 \newline 
5623 int foo () 
5624 \newline 
5625
5626 \newline 
5627 \SpecialChar ~
5628  \SpecialChar ~
5629  ...
5630  
5631 \newline 
5632 \SpecialChar ~
5633  \SpecialChar ~
5634  /* large code */ 
5635 \newline 
5636 \SpecialChar ~
5637  \SpecialChar ~
5638  ...
5639  
5640 \newline 
5641
5642 \newline 
5643 #pragma RESTORE /* turn the optimizations back on */
5644 \family default 
5645
5646 \newline 
5647
5648 \newline 
5649 The compiler will generate a warning message when extra space is allocated.
5650  It is strongly recommended that the SAVE and RESTORE pragma's be used when
5651  changing options for a function.
5652 \layout Subsection
5653
5654
5655 \emph on 
5656 <pending: this is messy and incomplete>
5657 \emph default 
5658  Library Routines
5659 \layout Enumerate
5660
5661 Compiler support routines (_gptrget, _mulint etc)
5662 \layout Enumerate
5663
5664 Stdclib functions (puts, printf, strcat etc)
5665 \layout Enumerate
5666
5667 Math functions (sin, pow, sqrt etc)
5668 \layout Subsection
5669
5670 Interfacing with Assembly Routines
5671 \layout Subsubsection
5672
5673 Global Registers used for Parameter Passing
5674 \layout Standard
5675
5676 The compiler always uses the global registers 
5677 \emph on 
5678 DPL,DPH,B 
5679 \emph default 
5680 and
5681 \emph on 
5682  ACC
5683 \emph default 
5684  to pass the first parameter to a routine.
5685  The second parameter onwards is either allocated on the stack (for reentrant
5686  routines or if ---stack-auto is used) or in the internal / external ram
5687  (depending on the memory model).
5688  
5689 \layout Subsubsection
5690
5691 Assembler Routine(non-reentrant)
5692 \layout Standard
5693
5694 In the following example the function cfunc calls an assembler routine asm_func,
5695  which takes two parameters.
5696 \newline 
5697
5698 \newline 
5699
5700 \family typewriter 
5701 extern int asm_func(unsigned char, unsigned char);
5702 \newline 
5703
5704 \newline 
5705 int c_func (unsigned char i, unsigned char j)
5706 \newline 
5707 {
5708 \newline 
5709 \SpecialChar ~
5710 \SpecialChar ~
5711 \SpecialChar ~
5712 \SpecialChar ~
5713 return asm_func(i,j);
5714 \newline 
5715 }
5716 \newline 
5717
5718 \newline 
5719 int main()
5720 \newline 
5721 {
5722 \newline 
5723 \SpecialChar ~
5724 \SpecialChar ~
5725 \SpecialChar ~
5726 \SpecialChar ~
5727 return c_func(10,9);
5728 \newline 
5729 }
5730 \newline 
5731
5732 \newline 
5733
5734 \family default 
5735 The corresponding assembler function is:
5736 \newline 
5737
5738 \newline 
5739
5740 \family typewriter 
5741 .globl _asm_func_PARM_2 
5742 \newline 
5743 \SpecialChar ~
5744 \SpecialChar ~
5745 \SpecialChar ~
5746 \SpecialChar ~
5747 \SpecialChar ~
5748 \SpecialChar ~
5749 \SpecialChar ~
5750 \SpecialChar ~
5751 .globl _asm_func 
5752 \newline 
5753 \SpecialChar ~
5754 \SpecialChar ~
5755 \SpecialChar ~
5756 \SpecialChar ~
5757 \SpecialChar ~
5758 \SpecialChar ~
5759 \SpecialChar ~
5760 \SpecialChar ~
5761 .area OSEG 
5762 \newline 
5763 _asm_func_PARM_2:
5764 \newline 
5765 \SpecialChar ~
5766 \SpecialChar ~
5767 \SpecialChar ~
5768 \SpecialChar ~
5769 \SpecialChar ~
5770 \SpecialChar ~
5771 \SpecialChar ~
5772 \SpecialChar ~
5773 .ds      1 
5774 \newline 
5775 \SpecialChar ~
5776 \SpecialChar ~
5777 \SpecialChar ~
5778 \SpecialChar ~
5779 \SpecialChar ~
5780 \SpecialChar ~
5781 \SpecialChar ~
5782 \SpecialChar ~
5783 .area CSEG 
5784 \newline 
5785 _asm_func: 
5786 \newline 
5787 \SpecialChar ~
5788 \SpecialChar ~
5789 \SpecialChar ~
5790 \SpecialChar ~
5791 \SpecialChar ~
5792 \SpecialChar ~
5793 \SpecialChar ~
5794 \SpecialChar ~
5795 mov     a,dpl 
5796 \newline 
5797 \SpecialChar ~
5798 \SpecialChar ~
5799 \SpecialChar ~
5800 \SpecialChar ~
5801 \SpecialChar ~
5802 \SpecialChar ~
5803 \SpecialChar ~
5804 \SpecialChar ~
5805 add     a,_asm_func_PARM_2 
5806 \newline 
5807 \SpecialChar ~
5808 \SpecialChar ~
5809 \SpecialChar ~
5810 \SpecialChar ~
5811 \SpecialChar ~
5812 \SpecialChar ~
5813 \SpecialChar ~
5814 \SpecialChar ~
5815 mov     dpl,a 
5816 \newline 
5817 \SpecialChar ~
5818 \SpecialChar ~
5819 \SpecialChar ~
5820 \SpecialChar ~
5821 \SpecialChar ~
5822 \SpecialChar ~
5823 \SpecialChar ~
5824 \SpecialChar ~
5825 mov     dpl,#0x00 
5826 \newline 
5827 \SpecialChar ~
5828 \SpecialChar ~
5829 \SpecialChar ~
5830 \SpecialChar ~
5831 \SpecialChar ~
5832 \SpecialChar ~
5833 \SpecialChar ~
5834 \SpecialChar ~
5835 ret
5836 \newline 
5837
5838 \newline 
5839
5840 \family default 
5841 Note here that the return values are placed in 'dpl' - One byte return value,
5842  'dpl' LSB & 'dph' MSB for two byte values.
5843  'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
5844 b' & 'acc' for four byte values.
5845 \layout Standard
5846
5847 The parameter naming convention is _<function_name>_PARM_<n>, where n is
5848  the parameter number starting from 1, and counting from the left.
5849  The first parameter is passed in 
5850 \begin_inset Quotes eld
5851 \end_inset 
5852
5853 dpl
5854 \begin_inset Quotes erd
5855 \end_inset 
5856
5857  for One bye parameter, 
5858 \begin_inset Quotes eld
5859 \end_inset 
5860
5861 dptr
5862 \begin_inset Quotes erd
5863 \end_inset 
5864
5865  if two bytes, 
5866 \begin_inset Quotes eld
5867 \end_inset 
5868
5869 b,dptr
5870 \begin_inset Quotes erd
5871 \end_inset 
5872
5873  for three bytes and 
5874 \begin_inset Quotes eld
5875 \end_inset 
5876
5877 acc,b,dptr
5878 \begin_inset Quotes erd
5879 \end_inset 
5880
5881  for four bytes, the varible name for the second parameter will be _<function_na
5882 me>_PARM_2.
5883 \newline 
5884
5885 \newline 
5886 Assemble the assembler routine with the following command:
5887 \newline 
5888
5889 \newline 
5890
5891 \family sans 
5892 \series bold 
5893 asx8051 -losg asmfunc.asm
5894 \newline 
5895
5896 \newline 
5897
5898 \family default 
5899 \series default 
5900 Then compile and link the assembler routine to the C source file with the
5901  following command:
5902 \newline 
5903
5904 \newline 
5905
5906 \family sans 
5907 \series bold 
5908 sdcc cfunc.c asmfunc.rel
5909 \layout Subsubsection
5910
5911 Assembler Routine(reentrant)
5912 \layout Standard
5913
5914 In this case the second parameter onwards will be passed on the stack, the
5915  parameters are pushed from right to left i.e.
5916  after the call the left most parameter will be on the top of the stack.
5917  Here is an example:
5918 \newline 
5919
5920 \newline 
5921
5922 \family typewriter 
5923 extern int asm_func(unsigned char, unsigned char);
5924 \newline 
5925
5926 \newline 
5927 int c_func (unsigned char i, unsigned char j) reentrant 
5928 \newline 
5929
5930 \newline 
5931 \SpecialChar ~
5932 \SpecialChar ~
5933 \SpecialChar ~
5934 \SpecialChar ~
5935 return asm_func(i,j); 
5936 \newline 
5937
5938 \newline 
5939
5940 \newline 
5941 int main() 
5942 \newline 
5943
5944 \newline 
5945 \SpecialChar ~
5946 \SpecialChar ~
5947 \SpecialChar ~
5948 \SpecialChar ~
5949 return c_func(10,9); 
5950 \newline 
5951 }
5952 \newline 
5953
5954 \family default 
5955
5956 \newline 
5957 The corresponding assembler routine is:
5958 \newline 
5959
5960 \newline 
5961
5962 \family typewriter 
5963 .globl _asm_func 
5964 \newline 
5965 _asm_func: 
5966 \newline 
5967 \SpecialChar ~
5968 \SpecialChar ~
5969 \SpecialChar ~
5970 \SpecialChar ~
5971 push  _bp 
5972 \newline 
5973 \SpecialChar ~
5974 \SpecialChar ~
5975 \SpecialChar ~
5976 \SpecialChar ~
5977 mov  _bp,sp 
5978 \newline 
5979 \SpecialChar ~
5980 \SpecialChar ~
5981 \SpecialChar ~
5982 \SpecialChar ~
5983 mov  r2,dpl
5984 \newline 
5985 \SpecialChar ~
5986 \SpecialChar ~
5987 \SpecialChar ~
5988 \SpecialChar ~
5989 mov  a,_bp 
5990 \newline 
5991 \SpecialChar ~
5992 \SpecialChar ~
5993 \SpecialChar ~
5994 \SpecialChar ~
5995 clr  c 
5996 \newline 
5997 \SpecialChar ~
5998 \SpecialChar ~
5999 \SpecialChar ~
6000 \SpecialChar ~
6001 add  a,#0xfd 
6002 \newline 
6003 \SpecialChar ~
6004 \SpecialChar ~
6005 \SpecialChar ~
6006 \SpecialChar ~
6007 mov  r0,a 
6008 \newline 
6009 \SpecialChar ~
6010 \SpecialChar ~
6011 \SpecialChar ~
6012 \SpecialChar ~
6013 add  a,#0xfc
6014 \newline 
6015 \SpecialChar ~
6016 \SpecialChar ~
6017 \SpecialChar ~
6018 \SpecialChar ~
6019 mov  r1,a 
6020 \newline 
6021 \SpecialChar ~
6022 \SpecialChar ~
6023 \SpecialChar ~
6024 \SpecialChar ~
6025 mov  a,@r0 
6026 \newline 
6027 \SpecialChar ~
6028 \SpecialChar ~
6029 \SpecialChar ~
6030 \SpecialChar ~
6031 add  a,r2
6032 \newline 
6033 \SpecialChar ~
6034 \SpecialChar ~
6035 \SpecialChar ~
6036 \SpecialChar ~
6037 mov  dpl,a 
6038 \newline 
6039 \SpecialChar ~
6040 \SpecialChar ~
6041 \SpecialChar ~
6042 \SpecialChar ~
6043 mov  dph,#0x00 
6044 \newline 
6045 \SpecialChar ~
6046 \SpecialChar ~
6047 \SpecialChar ~
6048 \SpecialChar ~
6049 mov  sp,_bp 
6050 \newline 
6051 \SpecialChar ~
6052 \SpecialChar ~
6053 \SpecialChar ~
6054 \SpecialChar ~
6055 pop  _bp 
6056 \newline 
6057 \SpecialChar ~
6058 \SpecialChar ~
6059 \SpecialChar ~
6060 \SpecialChar ~
6061 ret
6062 \newline 
6063
6064 \newline 
6065
6066 \family default 
6067 The compiling and linking procedure remains the same, however note the extra
6068  entry & exit linkage required for the assembler code, _bp is the stack
6069  frame pointer and is used to compute the offset into the stack for parameters
6070  and local variables.
6071 \layout Subsection
6072
6073 External Stack
6074 \layout Standard
6075
6076 The external stack is located at the start of the external ram segment,
6077  and is 256 bytes in size.
6078  When ---xstack option is used to compile the program, the parameters and
6079  local variables of all reentrant functions are allocated in this area.
6080  This option is provided for programs with large stack space requirements.
6081  When used with the ---stack-auto option, all parameters and local variables
6082  are allocated on the external stack (note support libraries will need to
6083  be recompiled with the same options).
6084 \layout Standard
6085
6086 The compiler outputs the higher order address byte of the external ram segment
6087  into PORT P2, therefore when using the External Stack option, this port
6088  MAY NOT be used by the application program.
6089 \layout Subsection
6090
6091 ANSI-Compliance
6092 \layout Standard
6093
6094 Deviations from the compliancy.
6095 \layout Itemize
6096
6097 functions are not always reentrant.
6098 \layout Itemize
6099
6100 structures cannot be assigned values directly, cannot be passed as function
6101  parameters or assigned to each other and cannot be a return value from
6102  a function, e.g.:
6103 \family typewriter 
6104
6105 \newline 
6106
6107 \newline 
6108 struct s { ...
6109  }; 
6110 \newline 
6111 struct s s1, s2; 
6112 \newline 
6113 foo() 
6114 \newline 
6115
6116 \newline 
6117 \SpecialChar ~
6118 \SpecialChar ~
6119 \SpecialChar ~
6120 \SpecialChar ~
6121 ...
6122  
6123 \newline 
6124 \SpecialChar ~
6125 \SpecialChar ~
6126 \SpecialChar ~
6127 \SpecialChar ~
6128 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
6129 \newline 
6130 \SpecialChar ~
6131 \SpecialChar ~
6132 \SpecialChar ~
6133 \SpecialChar ~
6134 ...
6135  
6136 \newline 
6137 }
6138 \newline 
6139 struct s foo1 (struct s parms) /* is invalid in SDCC although allowed in
6140  ANSI */ 
6141 \newline 
6142
6143 \newline 
6144 \SpecialChar ~
6145 \SpecialChar ~
6146 \SpecialChar ~
6147 \SpecialChar ~
6148 struct s rets; 
6149 \newline 
6150 \SpecialChar ~
6151 \SpecialChar ~
6152 \SpecialChar ~
6153 \SpecialChar ~
6154 ...
6155  
6156 \newline 
6157 \SpecialChar ~
6158 \SpecialChar ~
6159 \SpecialChar ~
6160 \SpecialChar ~
6161 return rets;/* is invalid in SDCC although allowed in ANSI */ 
6162 \newline 
6163 }
6164 \layout Itemize
6165
6166 'long long' (64 bit integers) not supported.
6167 \layout Itemize
6168
6169 'double' precision floating point not supported.
6170 \layout Itemize
6171
6172 No support for setjmp and longjmp (for now).
6173 \layout Itemize
6174
6175 Old K&R style function declarations are NOT allowed.
6176 \newline 
6177
6178 \family typewriter 
6179
6180 \newline 
6181 foo(i,j) /* this old style of function declarations */ 
6182 \newline 
6183 int i,j; /* are valid in ANSI but not valid in SDCC */ 
6184 \newline 
6185
6186 \newline 
6187 \SpecialChar ~
6188 \SpecialChar ~
6189 \SpecialChar ~
6190 \SpecialChar ~
6191 ...
6192  
6193 \newline 
6194 }
6195 \layout Itemize
6196
6197 functions declared as pointers must be dereferenced during the call.
6198 \newline 
6199
6200 \family typewriter 
6201
6202 \newline 
6203 int (*foo)();
6204 \newline 
6205 ...
6206  
6207 \newline 
6208 /* has to be called like this */ 
6209 \newline 
6210 (*foo)(); /* ansi standard allows calls to be made like 'foo()' */
6211 \layout Subsection
6212
6213 Cyclomatic Complexity
6214 \layout Standard
6215
6216 Cyclomatic complexity of a function is defined as the number of independent
6217  paths the program can take during execution of the function.
6218  This is an important number since it defines the number test cases you
6219  have to generate to validate the function.
6220  The accepted industry standard for complexity number is 10, if the cyclomatic
6221  complexity reported by SDCC exceeds 10 you should think about simplification
6222  of the function logic.
6223  Note that the complexity level is not related to the number of lines of
6224  code in a function.
6225  Large functions can have low complexity, and small functions can have large
6226  complexity levels.
6227  
6228 \newline 
6229
6230 \newline 
6231 SDCC uses the following formula to compute the complexity:
6232 \newline 
6233
6234 \layout Standard
6235
6236 complexity = (number of edges in control flow graph) - (number of nodes
6237  in control flow graph) + 2;
6238 \newline 
6239
6240 \newline 
6241 Having said that the industry standard is 10, you should be aware that in
6242  some cases it be may unavoidable to have a complexity level of less than
6243  10.
6244  For example if you have switch statement with more than 10 case labels,
6245  each case label adds one to the complexity level.
6246  The complexity level is by no means an absolute measure of the algorithmic
6247  complexity of the function, it does however provide a good starting point
6248  for which functions you might look at for further optimization.
6249 \layout Section
6250
6251 TIPS
6252 \layout Standard
6253
6254 Here are a few guidelines that will help the compiler generate more efficient
6255  code, some of the tips are specific to this compiler others are generally
6256  good programming practice.
6257 \layout Itemize
6258
6259 Use the smallest data type to represent your data-value.
6260  If it is known in advance that the value is going to be less than 256 then
6261  use a 'char' instead of a 'short' or 'int'.
6262 \layout Itemize
6263
6264 Use unsigned when it is known in advance that the value is not going to
6265  be negative.
6266  This helps especially if you are doing division or multiplication.
6267 \layout Itemize
6268
6269 NEVER jump into a LOOP.
6270 \layout Itemize
6271
6272 Declare the variables to be local whenever possible, especially loop control
6273  variables (induction).
6274 \layout Itemize
6275
6276 Since the compiler does not do implicit integral promotion, the programmer
6277  should do an explicit cast when integral promotion is required.
6278 \layout Itemize
6279
6280 Reducing the size of division, multiplication & modulus operations can reduce
6281  code size substantially.
6282  Take the following code for example.
6283 \family typewriter 
6284
6285 \newline 
6286
6287 \newline 
6288 foobar(unsigned int p1, unsigned char ch)
6289 \newline 
6290 {
6291 \newline 
6292     unsigned char ch1 = p1 % ch ;
6293 \newline 
6294     ....
6295     
6296 \newline 
6297 }
6298 \newline 
6299
6300 \family default 
6301
6302 \newline 
6303 For the modulus operation the variable ch will be promoted to unsigned int
6304  first then the modulus operation will be performed (this will lead to a
6305  call to support routine _moduint()), and the result will be casted to a
6306  char.
6307  If the code is changed to 
6308 \newline 
6309
6310 \family typewriter 
6311
6312 \newline 
6313 foobar(unsigned int p1, unsigned char ch)
6314 \newline 
6315 {
6316 \newline 
6317     unsigned char ch1 = (unsigned char)p1 % ch ;
6318 \newline 
6319     ....
6320     
6321 \newline 
6322 }
6323 \newline 
6324
6325 \family default 
6326
6327 \newline 
6328 It would substantially reduce the code generated (future versions of the
6329  compiler will be smart enough to detect such optimization oppurtunities).
6330 \layout Subsection
6331
6332 Notes on MCS51 memory layout
6333 \layout Standard
6334
6335 The 8051 family of micro controller have a minimum of 128 bytes of internal
6336  memory which is structured as follows
6337 \newline 
6338
6339 \newline 
6340 - Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R7 to R7
6341  
6342 \newline 
6343 - Bytes 20-2F - 16 bytes to hold 128 bit variables and 
6344 \newline 
6345 - Bytes 30-7F - 60 bytes for general purpose use.
6346 \newline 
6347
6348 \newline 
6349 Normally the SDCC compiler will only utilise the first bank of registers,
6350  but it is possible to specify that other banks of registers should be used
6351  in interrupt routines.
6352  By default, the compiler will place the stack after the last bank of used
6353  registers, i.e.
6354  if the first 2 banks of registers are used, it will position the base of
6355  the internal stack at address 16 (0X10).
6356  This implies that as the stack grows, it will use up the remaining register
6357  banks, and the 16 bytes used by the 128 bit variables, and 60 bytes for
6358  general purpose use.
6359 \layout Standard
6360
6361 By default, the compiler uses the 60 general purpose bytes to hold "near
6362  data".
6363  The compiler/optimiser may also declare some Local Variables in this area
6364  to hold local data.
6365  
6366 \layout Standard
6367
6368 If any of the 128 bit variables are used, or near data is being used then
6369  care needs to be taken to ensure that the stack does not grow so much that
6370  it starts to over write either your bit variables or "near data".
6371  There is no runtime checking to prevent this from happening.
6372 \layout Standard
6373
6374 The amount of stack being used is affected by the use of the "internal stack"
6375  to save registers before a subroutine call is made (---stack-auto will
6376  declare parameters and local variables on the stack) and the number of
6377  nested subroutines.
6378 \layout Standard
6379
6380 If you detect that the stack is over writing you data, then the following
6381  can be done.
6382  ---xstack will cause an external stack to be used for saving registers
6383  and (if ---stack-auto is being used) storing parameters and local variables.
6384  However this will produce more code which will be slower to execute.
6385  
6386 \layout Standard
6387
6388 ---stack-loc will allow you specify the start of the stack, i.e.
6389  you could start it after any data in the general purpose area.
6390  However this may waste the memory not used by the register banks and if
6391  the size of the "near data" increases, it may creep into the bottom of
6392  the stack.
6393 \layout Standard
6394
6395 ---stack-after-data, similar to the ---stack-loc, but it automatically places
6396  the stack after the end of the "near data".
6397  Again this could waste any spare register space.
6398 \layout Standard
6399
6400 ---data-loc allows you to specify the start address of the near data.
6401  This could be used to move the "near data" further away from the stack
6402  giving it more room to grow.
6403  This will only work if no bit variables are being used and the stack can
6404  grow to use the bit variable space.
6405 \newline 
6406
6407 \newline 
6408 Conclusion.
6409 \newline 
6410
6411 \newline 
6412 If you find that the stack is over writing your bit variables or "near data"
6413  then the approach which best utilised the internal memory is to position
6414  the "near data" after the last bank of used registers or, if you use bit
6415  variables, after the last bit variable by using the ---data-loc, e.g.
6416  if two register banks are being used and no bit variables, ---data-loc
6417  16, and use the ---stack-after-data option.
6418 \layout Standard
6419
6420 If bit variables are being used, another method would be to try and squeeze
6421  the data area in the unused register banks if it will fit, and start the
6422  stack after the last bit variable.
6423 \layout Section
6424
6425 Retargetting for other MCUs.
6426 \layout Standard
6427
6428 The issues for retargetting the compiler are far too numerous to be covered
6429  by this document.
6430  What follows is a brief description of each of the seven phases of the
6431  compiler and its MCU dependency.
6432 \layout Itemize
6433
6434 Parsing the source and building the annotated parse tree.
6435  This phase is largely MCU independent (except for the language extensions).
6436  Syntax & semantic checks are also done in this phase, along with some initial
6437  optimizations like back patching labels and the pattern matching optimizations
6438  like bit-rotation etc.
6439 \layout Itemize
6440
6441 The second phase involves generating an intermediate code which can be easy
6442  manipulated during the later phases.
6443  This phase is entirely MCU independent.
6444  The intermediate code generation assumes the target machine has unlimited
6445  number of registers, and designates them with the name iTemp.
6446  The compiler can be made to dump a human readable form of the code generated
6447  by using the ---dumpraw option.
6448 \layout Itemize
6449
6450 This phase does the bulk of the standard optimizations and is also MCU independe
6451 nt.
6452  This phase can be broken down into several sub-phases:
6453 \newline 
6454
6455 \newline 
6456 Break down intermediate code (iCode) into basic blocks.
6457 \newline 
6458 Do control flow & data flow analysis on the basic blocks.
6459 \newline 
6460 Do local common subexpression elimination, then global subexpression elimination
6461 \newline 
6462 Dead code elimination
6463 \newline 
6464 Loop optimizations
6465 \newline 
6466 If loop optimizations caused any changes then do 'global subexpression eliminati
6467 on' and 'dead code elimination' again.
6468 \layout Itemize
6469
6470 This phase determines the live-ranges; by live range I mean those iTemp
6471  variables defined by the compiler that still survive after all the optimization
6472 s.
6473  Live range analysis is essential for register allocation, since these computati
6474 on determines which of these iTemps will be assigned to registers, and for
6475  how long.
6476 \layout Itemize
6477
6478 Phase five is register allocation.
6479  There are two parts to this process.
6480 \newline 
6481
6482 \newline 
6483 The first part I call 'register packing' (for lack of a better term).
6484  In this case several MCU specific expression folding is done to reduce
6485  register pressure.
6486 \newline 
6487
6488 \newline 
6489 The second part is more MCU independent and deals with allocating registers
6490  to the remaining live ranges.
6491  A lot of MCU specific code does creep into this phase because of the limited
6492  number of index registers available in the 8051.
6493 \layout Itemize
6494
6495 The Code generation phase is (unhappily), entirely MCU dependent and very
6496  little (if any at all) of this code can be reused for other MCU.
6497  However the scheme for allocating a homogenized assembler operand for each
6498  iCode operand may be reused.
6499 \layout Itemize
6500
6501 As mentioned in the optimization section the peep-hole optimizer is rule
6502  based system, which can reprogrammed for other MCUs.
6503 \layout Section
6504
6505 SDCDB - Source Level Debugger
6506 \layout Standard
6507
6508 SDCC is distributed with a source level debugger.
6509  The debugger uses a command line interface, the command repertoire of the
6510  debugger has been kept as close to gdb (the GNU debugger) as possible.
6511  The configuration and build process is part of the standard compiler installati
6512 on, which also builds and installs the debugger in the target directory
6513  specified during configuration.
6514  The debugger allows you debug BOTH at the C source and at the ASM source
6515  level.
6516 \layout Subsection
6517
6518 Compiling for Debugging
6519 \layout Standard
6520
6521 The \SpecialChar \-
6522 \SpecialChar \-
6523 debug option must be specified for all files for which debug information
6524  is to be generated.
6525  The complier generates a .cdb file for each of these files.
6526  The linker updates the .cdb file with the address information.
6527  This .cdb is used by the debugger.
6528 \layout Subsection
6529
6530 How the Debugger Works
6531 \layout Standard
6532
6533 When the ---debug option is specified the compiler generates extra symbol
6534  information some of which are put into the the assembler source and some
6535  are put into the .cdb file, the linker updates the .cdb file with the address
6536  information for the symbols.
6537  The debugger reads the symbolic information generated by the compiler &
6538  the address information generated by the linker.
6539  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
6540  execution is controlled by the debugger.
6541  When a command is issued for the debugger, it translates it into appropriate
6542  commands for the simulator.
6543 \layout Subsection
6544
6545 Starting the Debugger
6546 \layout Standard
6547
6548 The debugger can be started using the following command line.
6549  (Assume the file you are debugging has the file name foo).
6550 \newline 
6551
6552 \newline 
6553
6554 \family sans 
6555 \series bold 
6556 sdcdb foo
6557 \newline 
6558
6559 \family default 
6560 \series default 
6561
6562 \newline 
6563 The debugger will look for the following files.
6564 \layout Itemize
6565
6566 foo.c - the source file.
6567 \layout Itemize
6568
6569 foo.cdb - the debugger symbol information file.
6570 \layout Itemize
6571
6572 foo.ihx - the intel hex format object file.
6573 \layout Subsection
6574
6575 Command Line Options.
6576 \layout Itemize
6577
6578 ---directory=<source file directory> this option can used to specify the
6579  directory search list.
6580  The debugger will look into the directory list specified for source, cdb
6581  & ihx files.
6582  The items in the directory list must be separated by ':', e.g.
6583  if the source files can be in the directories /home/src1 and /home/src2,
6584  the ---directory option should be ---directory=/home/src1:/home/src2.
6585  Note there can be no spaces in the option.
6586  
6587 \layout Itemize
6588
6589 -cd <directory> - change to the <directory>.
6590 \layout Itemize
6591
6592 -fullname - used by GUI front ends.
6593 \layout Itemize
6594
6595 -cpu <cpu-type> - this argument is passed to the simulator please see the
6596  simulator docs for details.
6597 \layout Itemize
6598
6599 -X <Clock frequency > this options is passed to the simulator please see
6600  the simulator docs for details.
6601 \layout Itemize
6602
6603 -s <serial port file> passed to simulator see the simulator docs for details.
6604 \layout Itemize
6605
6606 -S <serial in,out> passed to simulator see the simulator docs for details.
6607 \layout Subsection
6608
6609 Debugger Commands.
6610 \layout Standard
6611
6612 As mention earlier the command interface for the debugger has been deliberately
6613  kept as close the GNU debugger gdb, as possible.
6614  This will help the integration with existing graphical user interfaces
6615  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
6616 \layout Subsubsection
6617
6618 break [line | file:line | function | file:function]
6619 \layout Standard
6620
6621 Set breakpoint at specified line or function:
6622 \newline 
6623
6624 \newline 
6625
6626 \family sans 
6627 \series bold 
6628 sdcdb>break 100 
6629 \newline 
6630 sdcdb>break foo.c:100
6631 \newline 
6632 sdcdb>break funcfoo
6633 \newline 
6634 sdcdb>break foo.c:funcfoo
6635 \layout Subsubsection
6636
6637 clear [line | file:line | function | file:function ]
6638 \layout Standard
6639
6640 Clear breakpoint at specified line or function:
6641 \newline 
6642
6643 \newline 
6644
6645 \family sans 
6646 \series bold 
6647 sdcdb>clear 100
6648 \newline 
6649 sdcdb>clear foo.c:100
6650 \newline 
6651 sdcdb>clear funcfoo
6652 \newline 
6653 sdcdb>clear foo.c:funcfoo
6654 \layout Subsubsection
6655
6656 continue
6657 \layout Standard
6658
6659 Continue program being debugged, after breakpoint.
6660 \layout Subsubsection
6661
6662 finish
6663 \layout Standard
6664
6665 Execute till the end of the current function.
6666 \layout Subsubsection
6667
6668 delete [n]
6669 \layout Standard
6670
6671 Delete breakpoint number 'n'.
6672  If used without any option clear ALL user defined break points.
6673 \layout Subsubsection
6674
6675 info [break | stack | frame | registers ]
6676 \layout Itemize
6677
6678 info break - list all breakpoints
6679 \layout Itemize
6680
6681 info stack - show the function call stack.
6682 \layout Itemize
6683
6684 info frame - show information about the current execution frame.
6685 \layout Itemize
6686
6687 info registers - show content of all registers.
6688 \layout Subsubsection
6689
6690 step
6691 \layout Standard
6692
6693 Step program until it reaches a different source line.
6694 \layout Subsubsection
6695
6696 next
6697 \layout Standard
6698
6699 Step program, proceeding through subroutine calls.
6700 \layout Subsubsection
6701
6702 run
6703 \layout Standard
6704
6705 Start debugged program.
6706 \layout Subsubsection
6707
6708 ptype variable 
6709 \layout Standard
6710
6711 Print type information of the variable.
6712 \layout Subsubsection
6713
6714 print variable
6715 \layout Standard
6716
6717 print value of variable.
6718 \layout Subsubsection
6719
6720 file filename
6721 \layout Standard
6722
6723 load the given file name.
6724  Note this is an alternate method of loading file for debugging.
6725 \layout Subsubsection
6726
6727 frame
6728 \layout Standard
6729
6730 print information about current frame.
6731 \layout Subsubsection
6732
6733 set srcmode
6734 \layout Standard
6735
6736 Toggle between C source & assembly source.
6737 \layout Subsubsection
6738
6739 ! simulator command
6740 \layout Standard
6741
6742 Send the string following '!' to the simulator, the simulator response is
6743  displayed.
6744  Note the debugger does not interpret the command being sent to the simulator,
6745  so if a command like 'go' is sent the debugger can loose its execution
6746  context and may display incorrect values.
6747 \layout Subsubsection
6748
6749 quit.
6750 \layout Standard
6751
6752 "Watch me now.
6753  Iam going Down.
6754  My name is Bobby Brown"
6755 \layout Subsection
6756
6757 Interfacing with XEmacs.
6758 \layout Standard
6759
6760 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
6761  sdcdb.el and sdcdbsrc.el.
6762  These two files can be found in the $(prefix)/bin directory after the installat
6763 ion is complete.
6764  These files need to be loaded into XEmacs for the interface to work.
6765  This can be done at XEmacs startup time by inserting the following into
6766  your '.xemacs' file (which can be found in your HOME directory): 
6767 \newline 
6768
6769 \newline 
6770
6771 \family typewriter 
6772 (load-file sdcdbsrc.el) 
6773 \family default 
6774
6775 \newline 
6776
6777 \newline 
6778 .xemacs is a lisp file so the () around the command is REQUIRED.
6779  The files can also be loaded dynamically while XEmacs is running, set the
6780  environment variable 'EMACSLOADPATH' to the installation bin directory
6781  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
6782  To start the interface enter the following command: 
6783 \newline 
6784
6785 \newline 
6786
6787 \family sans 
6788 \series bold 
6789 ESC-x sdcdbsrc
6790 \family default 
6791 \series default 
6792
6793 \newline 
6794
6795 \newline 
6796 You will prompted to enter the file name to be debugged.
6797  
6798 \newline 
6799
6800 \newline 
6801 The command line options that are passed to the simulator directly are bound
6802  to default values in the file sdcdbsrc.el.
6803  The variables are listed below, these values maybe changed as required.
6804 \layout Itemize
6805
6806 sdcdbsrc-cpu-type '51
6807 \layout Itemize
6808
6809 sdcdbsrc-frequency '11059200
6810 \layout Itemize
6811
6812 sdcdbsrc-serial nil
6813 \layout Standard
6814
6815 The following is a list of key mapping for the debugger interface.
6816 \layout Standard
6817
6818 \SpecialChar ~
6819
6820 \family typewriter 
6821
6822 \newline 
6823 ;; Current Listing :: 
6824 \newline 
6825 ;;key\SpecialChar ~
6826 \SpecialChar ~
6827 \SpecialChar ~
6828 \SpecialChar ~
6829 \SpecialChar ~
6830 \SpecialChar ~
6831 \SpecialChar ~
6832 \SpecialChar ~
6833 \SpecialChar ~
6834 \SpecialChar ~
6835 \SpecialChar ~
6836 \SpecialChar ~
6837 \SpecialChar ~
6838 \SpecialChar ~
6839 \SpecialChar ~
6840 binding\SpecialChar ~
6841 \SpecialChar ~
6842 \SpecialChar ~
6843 \SpecialChar ~
6844 \SpecialChar ~
6845 \SpecialChar ~
6846 \SpecialChar ~
6847 \SpecialChar ~
6848 \SpecialChar ~
6849 \SpecialChar ~
6850 \SpecialChar ~
6851 \SpecialChar ~
6852 \SpecialChar ~
6853 \SpecialChar ~
6854 \SpecialChar ~
6855 \SpecialChar ~
6856 \SpecialChar ~
6857 \SpecialChar ~
6858 \SpecialChar ~
6859 \SpecialChar ~
6860 \SpecialChar ~
6861 \SpecialChar ~
6862 Comment 
6863 \newline 
6864 ;;---\SpecialChar ~
6865 \SpecialChar ~
6866 \SpecialChar ~
6867 \SpecialChar ~
6868 \SpecialChar ~
6869 \SpecialChar ~
6870 \SpecialChar ~
6871 \SpecialChar ~
6872 \SpecialChar ~
6873 \SpecialChar ~
6874 \SpecialChar ~
6875 \SpecialChar ~
6876 \SpecialChar ~
6877 \SpecialChar ~
6878 \SpecialChar ~
6879 ------\SpecialChar ~
6880 \SpecialChar ~
6881 \SpecialChar ~
6882 \SpecialChar ~
6883 \SpecialChar ~
6884 \SpecialChar ~
6885 \SpecialChar ~
6886 \SpecialChar ~
6887 \SpecialChar ~
6888 \SpecialChar ~
6889 \SpecialChar ~
6890 \SpecialChar ~
6891 \SpecialChar ~
6892 \SpecialChar ~
6893 \SpecialChar ~
6894 \SpecialChar ~
6895 \SpecialChar ~
6896 \SpecialChar ~
6897 \SpecialChar ~
6898 \SpecialChar ~
6899 \SpecialChar ~
6900 \SpecialChar ~
6901 -------- 
6902 \newline 
6903 ;; 
6904 \newline 
6905 ;; n\SpecialChar ~
6906 \SpecialChar ~
6907 \SpecialChar ~
6908 \SpecialChar ~
6909 \SpecialChar ~
6910 \SpecialChar ~
6911 \SpecialChar ~
6912 \SpecialChar ~
6913 \SpecialChar ~
6914 \SpecialChar ~
6915 \SpecialChar ~
6916 \SpecialChar ~
6917 \SpecialChar ~
6918 \SpecialChar ~
6919  sdcdb-next-from-src\SpecialChar ~
6920 \SpecialChar ~
6921 \SpecialChar ~
6922 \SpecialChar ~
6923 \SpecialChar ~
6924 \SpecialChar ~
6925 \SpecialChar ~
6926 \SpecialChar ~
6927 \SpecialChar ~
6928 \SpecialChar ~
6929 SDCDB next command 
6930 \newline 
6931 ;; b\SpecialChar ~
6932 \SpecialChar ~
6933 \SpecialChar ~
6934 \SpecialChar ~
6935 \SpecialChar ~
6936 \SpecialChar ~
6937 \SpecialChar ~
6938 \SpecialChar ~
6939 \SpecialChar ~
6940 \SpecialChar ~
6941 \SpecialChar ~
6942 \SpecialChar ~
6943 \SpecialChar ~
6944 \SpecialChar ~
6945  sdcdb-back-from-src\SpecialChar ~
6946 \SpecialChar ~
6947 \SpecialChar ~
6948 \SpecialChar ~
6949 \SpecialChar ~
6950 \SpecialChar ~
6951 \SpecialChar ~
6952 \SpecialChar ~
6953 \SpecialChar ~
6954 \SpecialChar ~
6955 SDCDB back command 
6956 \newline 
6957 ;; c\SpecialChar ~
6958 \SpecialChar ~
6959 \SpecialChar ~
6960 \SpecialChar ~
6961 \SpecialChar ~
6962 \SpecialChar ~
6963 \SpecialChar ~
6964 \SpecialChar ~
6965 \SpecialChar ~
6966 \SpecialChar ~
6967 \SpecialChar ~
6968 \SpecialChar ~
6969 \SpecialChar ~
6970 \SpecialChar ~
6971  sdcdb-cont-from-src\SpecialChar ~
6972 \SpecialChar ~
6973 \SpecialChar ~
6974 \SpecialChar ~
6975 \SpecialChar ~
6976 \SpecialChar ~
6977 \SpecialChar ~
6978 \SpecialChar ~
6979 \SpecialChar ~
6980 \SpecialChar ~
6981 SDCDB continue command
6982 \newline 
6983 ;; s\SpecialChar ~
6984 \SpecialChar ~
6985 \SpecialChar ~
6986 \SpecialChar ~
6987 \SpecialChar ~
6988 \SpecialChar ~
6989 \SpecialChar ~
6990 \SpecialChar ~
6991 \SpecialChar ~
6992 \SpecialChar ~
6993 \SpecialChar ~
6994 \SpecialChar ~
6995 \SpecialChar ~
6996 \SpecialChar ~
6997  sdcdb-step-from-src\SpecialChar ~
6998 \SpecialChar ~
6999 \SpecialChar ~
7000 \SpecialChar ~
7001 \SpecialChar ~
7002 \SpecialChar ~
7003 \SpecialChar ~
7004 \SpecialChar ~
7005 \SpecialChar ~
7006 \SpecialChar ~
7007 SDCDB step command 
7008 \newline 
7009 ;; ?\SpecialChar ~
7010 \SpecialChar ~
7011 \SpecialChar ~
7012 \SpecialChar ~
7013 \SpecialChar ~
7014 \SpecialChar ~
7015 \SpecialChar ~
7016 \SpecialChar ~
7017 \SpecialChar ~
7018 \SpecialChar ~
7019 \SpecialChar ~
7020 \SpecialChar ~
7021 \SpecialChar ~
7022 \SpecialChar ~
7023  sdcdb-whatis-c-sexp\SpecialChar ~
7024 \SpecialChar ~
7025 \SpecialChar ~
7026 \SpecialChar ~
7027 \SpecialChar ~
7028 \SpecialChar ~
7029 \SpecialChar ~
7030 \SpecialChar ~
7031 \SpecialChar ~
7032 \SpecialChar ~
7033 SDCDB ptypecommand for data at 
7034 \newline 
7035 ;;\SpecialChar ~
7036 \SpecialChar ~
7037 \SpecialChar ~
7038 \SpecialChar ~
7039 \SpecialChar ~
7040 \SpecialChar ~
7041 \SpecialChar ~
7042 \SpecialChar ~
7043 \SpecialChar ~
7044 \SpecialChar ~
7045 \SpecialChar ~
7046 \SpecialChar ~
7047 \SpecialChar ~
7048 \SpecialChar ~
7049 \SpecialChar ~
7050 \SpecialChar ~
7051 \SpecialChar ~
7052 \SpecialChar ~
7053 \SpecialChar ~
7054 \SpecialChar ~
7055 \SpecialChar ~
7056 \SpecialChar ~
7057 \SpecialChar ~
7058 \SpecialChar ~
7059 \SpecialChar ~
7060 \SpecialChar ~
7061 \SpecialChar ~
7062 \SpecialChar ~
7063 \SpecialChar ~
7064 \SpecialChar ~
7065 \SpecialChar ~
7066 \SpecialChar ~
7067 \SpecialChar ~
7068 \SpecialChar ~
7069 \SpecialChar ~
7070 \SpecialChar ~
7071 \SpecialChar ~
7072 \SpecialChar ~
7073 \SpecialChar ~
7074 \SpecialChar ~
7075 \SpecialChar ~
7076 \SpecialChar ~
7077 \SpecialChar ~
7078 \SpecialChar ~
7079 \SpecialChar ~
7080 \SpecialChar ~
7081  buffer point 
7082 \newline 
7083 ;; x\SpecialChar ~
7084 \SpecialChar ~
7085 \SpecialChar ~
7086 \SpecialChar ~
7087 \SpecialChar ~
7088 \SpecialChar ~
7089 \SpecialChar ~
7090 \SpecialChar ~
7091 \SpecialChar ~
7092 \SpecialChar ~
7093 \SpecialChar ~
7094 \SpecialChar ~
7095 \SpecialChar ~
7096 \SpecialChar ~
7097  sdcdbsrc-delete\SpecialChar ~
7098 \SpecialChar ~
7099 \SpecialChar ~
7100 \SpecialChar ~
7101 \SpecialChar ~
7102 \SpecialChar ~
7103 \SpecialChar ~
7104 \SpecialChar ~
7105 \SpecialChar ~
7106 \SpecialChar ~
7107 \SpecialChar ~
7108 \SpecialChar ~
7109 \SpecialChar ~
7110 \SpecialChar ~
7111 SDCDB Delete all breakpoints if no arg 
7112 \newline 
7113 ;;\SpecialChar ~
7114 \SpecialChar ~
7115 \SpecialChar ~
7116 \SpecialChar ~
7117 \SpecialChar ~
7118 \SpecialChar ~
7119 \SpecialChar ~
7120 \SpecialChar ~
7121 \SpecialChar ~
7122 \SpecialChar ~
7123 \SpecialChar ~
7124 \SpecialChar ~
7125 \SpecialChar ~
7126 \SpecialChar ~
7127 \SpecialChar ~
7128 \SpecialChar ~
7129 \SpecialChar ~
7130 \SpecialChar ~
7131 \SpecialChar ~
7132 \SpecialChar ~
7133 \SpecialChar ~
7134 \SpecialChar ~
7135 \SpecialChar ~
7136 \SpecialChar ~
7137 \SpecialChar ~
7138 \SpecialChar ~
7139 \SpecialChar ~
7140 \SpecialChar ~
7141 \SpecialChar ~
7142 \SpecialChar ~
7143 \SpecialChar ~
7144 \SpecialChar ~
7145 \SpecialChar ~
7146 \SpecialChar ~
7147 \SpecialChar ~
7148 \SpecialChar ~
7149 \SpecialChar ~
7150 \SpecialChar ~
7151 \SpecialChar ~
7152 \SpecialChar ~
7153 \SpecialChar ~
7154 \SpecialChar ~
7155 \SpecialChar ~
7156 \SpecialChar ~
7157 \SpecialChar ~
7158 \SpecialChar ~
7159 given or delete arg (C-u arg x) 
7160 \newline 
7161 ;; m\SpecialChar ~
7162 \SpecialChar ~
7163 \SpecialChar ~
7164 \SpecialChar ~
7165 \SpecialChar ~
7166 \SpecialChar ~
7167 \SpecialChar ~
7168 \SpecialChar ~
7169 \SpecialChar ~
7170 \SpecialChar ~
7171 \SpecialChar ~
7172 \SpecialChar ~
7173 \SpecialChar ~
7174 \SpecialChar ~
7175  sdcdbsrc-frame\SpecialChar ~
7176 \SpecialChar ~
7177 \SpecialChar ~
7178 \SpecialChar ~
7179 \SpecialChar ~
7180 \SpecialChar ~
7181 \SpecialChar ~
7182 \SpecialChar ~
7183 \SpecialChar ~
7184 \SpecialChar ~
7185 \SpecialChar ~
7186 \SpecialChar ~
7187 \SpecialChar ~
7188 \SpecialChar ~
7189 \SpecialChar ~
7190 SDCDB Display current frame if no arg, 
7191 \newline 
7192 ;;\SpecialChar ~
7193 \SpecialChar ~
7194 \SpecialChar ~
7195 \SpecialChar ~
7196 \SpecialChar ~
7197 \SpecialChar ~
7198 \SpecialChar ~
7199 \SpecialChar ~
7200 \SpecialChar ~
7201 \SpecialChar ~
7202 \SpecialChar ~
7203 \SpecialChar ~
7204 \SpecialChar ~
7205 \SpecialChar ~
7206 \SpecialChar ~
7207 \SpecialChar ~
7208 \SpecialChar ~
7209 \SpecialChar ~
7210 \SpecialChar ~
7211 \SpecialChar ~
7212 \SpecialChar ~
7213 \SpecialChar ~
7214 \SpecialChar ~
7215 \SpecialChar ~
7216 \SpecialChar ~
7217 \SpecialChar ~
7218 \SpecialChar ~
7219 \SpecialChar ~
7220 \SpecialChar ~
7221 \SpecialChar ~
7222 \SpecialChar ~
7223 \SpecialChar ~
7224 \SpecialChar ~
7225 \SpecialChar ~
7226 \SpecialChar ~
7227 \SpecialChar ~
7228 \SpecialChar ~
7229 \SpecialChar ~
7230 \SpecialChar ~
7231 \SpecialChar ~
7232 \SpecialChar ~
7233 \SpecialChar ~
7234 \SpecialChar ~
7235 \SpecialChar ~
7236 \SpecialChar ~
7237 \SpecialChar ~
7238 \SpecialChar ~
7239 given or display frame arg 
7240 \newline 
7241 ;;\SpecialChar ~
7242 \SpecialChar ~
7243 \SpecialChar ~
7244 \SpecialChar ~
7245 \SpecialChar ~
7246 \SpecialChar ~
7247 \SpecialChar ~
7248 \SpecialChar ~
7249 \SpecialChar ~
7250 \SpecialChar ~
7251 \SpecialChar ~
7252 \SpecialChar ~
7253 \SpecialChar ~
7254 \SpecialChar ~
7255 \SpecialChar ~
7256 \SpecialChar ~
7257 \SpecialChar ~
7258 \SpecialChar ~
7259 \SpecialChar ~
7260 \SpecialChar ~
7261 \SpecialChar ~
7262 \SpecialChar ~
7263 \SpecialChar ~
7264 \SpecialChar ~
7265 \SpecialChar ~
7266 \SpecialChar ~
7267 \SpecialChar ~
7268 \SpecialChar ~
7269 \SpecialChar ~
7270 \SpecialChar ~
7271 \SpecialChar ~
7272 \SpecialChar ~
7273 \SpecialChar ~
7274 \SpecialChar ~
7275 \SpecialChar ~
7276 \SpecialChar ~
7277 \SpecialChar ~
7278 \SpecialChar ~
7279 \SpecialChar ~
7280 \SpecialChar ~
7281 \SpecialChar ~
7282 \SpecialChar ~
7283 \SpecialChar ~
7284 \SpecialChar ~
7285 \SpecialChar ~
7286 \SpecialChar ~
7287 \SpecialChar ~
7288 buffer point 
7289 \newline 
7290 ;; !\SpecialChar ~
7291 \SpecialChar ~
7292 \SpecialChar ~
7293 \SpecialChar ~
7294 \SpecialChar ~
7295 \SpecialChar ~
7296 \SpecialChar ~
7297 \SpecialChar ~
7298 \SpecialChar ~
7299 \SpecialChar ~
7300 \SpecialChar ~
7301 \SpecialChar ~
7302 \SpecialChar ~
7303 \SpecialChar ~
7304  sdcdbsrc-goto-sdcdb\SpecialChar ~
7305 \SpecialChar ~
7306 \SpecialChar ~
7307 \SpecialChar ~
7308 \SpecialChar ~
7309 \SpecialChar ~
7310 \SpecialChar ~
7311 \SpecialChar ~
7312 \SpecialChar ~
7313 \SpecialChar ~
7314 Goto the SDCDB output buffer 
7315 \newline 
7316 ;; p\SpecialChar ~
7317 \SpecialChar ~
7318 \SpecialChar ~
7319 \SpecialChar ~
7320 \SpecialChar ~
7321 \SpecialChar ~
7322 \SpecialChar ~
7323 \SpecialChar ~
7324 \SpecialChar ~
7325 \SpecialChar ~
7326 \SpecialChar ~
7327 \SpecialChar ~
7328 \SpecialChar ~
7329 \SpecialChar ~
7330  sdcdb-print-c-sexp\SpecialChar ~
7331 \SpecialChar ~
7332 \SpecialChar ~
7333 \SpecialChar ~
7334 \SpecialChar ~
7335 \SpecialChar ~
7336 \SpecialChar ~
7337 \SpecialChar ~
7338 \SpecialChar ~
7339 \SpecialChar ~
7340 \SpecialChar ~
7341 SDCDB print command for data at 
7342 \newline 
7343 ;;\SpecialChar ~
7344 \SpecialChar ~
7345 \SpecialChar ~
7346 \SpecialChar ~
7347 \SpecialChar ~
7348 \SpecialChar ~
7349 \SpecialChar ~
7350 \SpecialChar ~
7351 \SpecialChar ~
7352 \SpecialChar ~
7353 \SpecialChar ~
7354 \SpecialChar ~
7355 \SpecialChar ~
7356 \SpecialChar ~
7357 \SpecialChar ~
7358 \SpecialChar ~
7359 \SpecialChar ~
7360 \SpecialChar ~
7361 \SpecialChar ~
7362 \SpecialChar ~
7363 \SpecialChar ~
7364 \SpecialChar ~
7365 \SpecialChar ~
7366 \SpecialChar ~
7367 \SpecialChar ~
7368 \SpecialChar ~
7369 \SpecialChar ~
7370 \SpecialChar ~
7371 \SpecialChar ~
7372 \SpecialChar ~
7373 \SpecialChar ~
7374 \SpecialChar ~
7375 \SpecialChar ~
7376 \SpecialChar ~
7377 \SpecialChar ~
7378 \SpecialChar ~
7379 \SpecialChar ~
7380 \SpecialChar ~
7381 \SpecialChar ~
7382 \SpecialChar ~
7383 \SpecialChar ~
7384 \SpecialChar ~
7385 \SpecialChar ~
7386 \SpecialChar ~
7387 \SpecialChar ~
7388 \SpecialChar ~
7389  buffer point 
7390 \newline 
7391 ;; g\SpecialChar ~
7392 \SpecialChar ~
7393 \SpecialChar ~
7394 \SpecialChar ~
7395 \SpecialChar ~
7396 \SpecialChar ~
7397 \SpecialChar ~
7398 \SpecialChar ~
7399 \SpecialChar ~
7400 \SpecialChar ~
7401 \SpecialChar ~
7402 \SpecialChar ~
7403 \SpecialChar ~
7404 \SpecialChar ~
7405  sdcdbsrc-goto-sdcdb\SpecialChar ~
7406 \SpecialChar ~
7407 \SpecialChar ~
7408 \SpecialChar ~
7409 \SpecialChar ~
7410 \SpecialChar ~
7411 \SpecialChar ~
7412 \SpecialChar ~
7413 \SpecialChar ~
7414 \SpecialChar ~
7415 Goto the SDCDB output buffer 
7416 \newline 
7417 ;; t\SpecialChar ~
7418 \SpecialChar ~
7419 \SpecialChar ~
7420 \SpecialChar ~
7421 \SpecialChar ~
7422 \SpecialChar ~
7423 \SpecialChar ~
7424 \SpecialChar ~
7425 \SpecialChar ~
7426 \SpecialChar ~
7427 \SpecialChar ~
7428 \SpecialChar ~
7429 \SpecialChar ~
7430 \SpecialChar ~
7431  sdcdbsrc-mode\SpecialChar ~
7432 \SpecialChar ~
7433 \SpecialChar ~
7434 \SpecialChar ~
7435 \SpecialChar ~
7436 \SpecialChar ~
7437 \SpecialChar ~
7438 \SpecialChar ~
7439 \SpecialChar ~
7440 \SpecialChar ~
7441 \SpecialChar ~
7442 \SpecialChar ~
7443 \SpecialChar ~
7444 \SpecialChar ~
7445 \SpecialChar ~
7446 \SpecialChar ~
7447 Toggles Sdcdbsrc mode (turns it off) 
7448 \newline 
7449 ;; 
7450 \newline 
7451 ;; C-c C-f\SpecialChar ~
7452 \SpecialChar ~
7453 \SpecialChar ~
7454 \SpecialChar ~
7455 \SpecialChar ~
7456 \SpecialChar ~
7457 \SpecialChar ~
7458 \SpecialChar ~
7459  sdcdb-finish-from-src\SpecialChar ~
7460 \SpecialChar ~
7461 \SpecialChar ~
7462 \SpecialChar ~
7463 \SpecialChar ~
7464 \SpecialChar ~
7465 \SpecialChar ~
7466 \SpecialChar ~
7467 SDCDB finish command 
7468 \newline 
7469 ;; 
7470 \newline 
7471 ;; C-x SPC\SpecialChar ~
7472 \SpecialChar ~
7473 \SpecialChar ~
7474 \SpecialChar ~
7475 \SpecialChar ~
7476 \SpecialChar ~
7477 \SpecialChar ~
7478 \SpecialChar ~
7479  sdcdb-break\SpecialChar ~
7480 \SpecialChar ~
7481 \SpecialChar ~
7482 \SpecialChar ~
7483 \SpecialChar ~
7484 \SpecialChar ~
7485 \SpecialChar ~
7486 \SpecialChar ~
7487 \SpecialChar ~
7488 \SpecialChar ~
7489 \SpecialChar ~
7490 \SpecialChar ~
7491 \SpecialChar ~
7492 \SpecialChar ~
7493 \SpecialChar ~
7494 \SpecialChar ~
7495 \SpecialChar ~
7496 \SpecialChar ~
7497 Set break for line with point 
7498 \newline 
7499 ;; ESC t\SpecialChar ~
7500 \SpecialChar ~
7501 \SpecialChar ~
7502 \SpecialChar ~
7503 \SpecialChar ~
7504 \SpecialChar ~
7505 \SpecialChar ~
7506 \SpecialChar ~
7507 \SpecialChar ~
7508 \SpecialChar ~
7509  sdcdbsrc-mode\SpecialChar ~
7510 \SpecialChar ~
7511 \SpecialChar ~
7512 \SpecialChar ~
7513 \SpecialChar ~
7514 \SpecialChar ~
7515 \SpecialChar ~
7516 \SpecialChar ~
7517 \SpecialChar ~
7518 \SpecialChar ~
7519 \SpecialChar ~
7520 \SpecialChar ~
7521 \SpecialChar ~
7522 \SpecialChar ~
7523 \SpecialChar ~
7524 \SpecialChar ~
7525 Toggle Sdcdbsrc mode 
7526 \newline 
7527 ;; ESC m\SpecialChar ~
7528 \SpecialChar ~
7529 \SpecialChar ~
7530 \SpecialChar ~
7531 \SpecialChar ~
7532 \SpecialChar ~
7533 \SpecialChar ~
7534 \SpecialChar ~
7535 \SpecialChar ~
7536 \SpecialChar ~
7537  sdcdbsrc-srcmode\SpecialChar ~
7538 \SpecialChar ~
7539 \SpecialChar ~
7540 \SpecialChar ~
7541 \SpecialChar ~
7542 \SpecialChar ~
7543 \SpecialChar ~
7544 \SpecialChar ~
7545 \SpecialChar ~
7546 \SpecialChar ~
7547 \SpecialChar ~
7548 \SpecialChar ~
7549  Toggle list mode 
7550 \newline 
7551 ;; 
7552 \family default 
7553
7554 \newline 
7555
7556 \layout Section
7557
7558 Other Processors
7559 \layout Subsection
7560
7561 The Z80 and gbz80 port
7562 \layout Standard
7563
7564 SDCC can target both the Zilog Z80 and the Nintendo Gameboy's Z80-like gbz80.
7565  The port is incomplete - long support is incomplete (mul, div and mod are
7566  unimplimented), and both float and bitfield support is missing.
7567  Apart from that the code generated is correct.
7568 \layout Standard
7569
7570 As always, the code is the authoritave reference - see z80/ralloc.c and z80/gen.c.
7571  The stack frame is similar to that generated by the IAR Z80 compiler.
7572  IX is used as the base pointer, HL is used as a temporary register, and
7573  BC and DE are available for holding varibles.
7574  IY is currently unusued.
7575  Return values are stored in HL.
7576  One bad side effect of using IX as the base pointer is that a functions
7577  stack frame is limited to 127 bytes - this will be fixed in a later version.
7578 \layout Section
7579
7580 Support
7581 \layout Standard
7582
7583 SDCC has grown to be a large project.
7584  The compiler alone (without the preprocessor, assembler and linker) is
7585  about 40,000 lines of code (blank stripped).
7586  The open source nature of this project is a key to its continued growth
7587  and support.
7588  You gain the benefit and support of many active software developers and
7589  end users.
7590  Is SDCC perfect? No, that's why we need your help.
7591  The developers take pride in fixing reported bugs.
7592  You can help by reporting the bugs and helping other SDCC users.
7593  There are lots of ways to contribute, and we encourage you to take part
7594  in making SDCC a great software package.
7595 \layout Subsection
7596
7597 Reporting Bugs
7598 \layout Standard
7599
7600 Send an email to the mailing list at 'user-sdcc@sdcc.sourceforge.net' or 'devel-sd
7601 cc@sdcc.sourceforge.net'.
7602  Bugs will be fixed ASAP.
7603  When reporting a bug, it is very useful to include a small test program
7604  which reproduces the problem.
7605  If you can isolate the problem by looking at the generated assembly code,
7606  this can be very helpful.
7607  Compiling your program with the ---dumpall option can sometimes be useful
7608  in locating optimization problems.
7609 \layout Section
7610
7611 The anatomy of the compiler
7612 \layout Standard
7613
7614
7615 \shape italic 
7616 This is an excerpt from an atricle published in Circuit Cellar MagaZine
7617  in august 2000.
7618  It's a little outdated (the compiler is much more efficient now and user/devell
7619 oper friendly), but pretty well exposes the guts of it all.
7620 \shape default 
7621
7622 \newline 
7623
7624 \newline 
7625 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
7626  It is fairly easy to retarget for other 8-bit MCU.
7627  Here we take a look at some of the internals of the compiler.
7628  
7629 \layout Paragraph*
7630
7631 Parsing 
7632 \layout Standard
7633
7634 Parsing the input source file and creating an AST (Annotated Syntax Tree).
7635  This phase also involves propagating types (annotating each node of the
7636  parse tree with type information) and semantic analysis.
7637  There are some MCU specific parsing rules.
7638  For example the storage classes, the extended storage classes are MCU specific
7639  while there may be a xdata storage class for 8051 there is no such storage
7640  class for z80 or Atmel AVR.
7641  SDCC allows MCU specific storage class extensions, i.e.
7642  xdata will be treated as a storage class specifier when parsing 8051 C
7643  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
7644  C code.
7645 \layout Paragraph*
7646
7647 Generating iCode
7648 \layout Standard
7649
7650 Intermediate code generation.
7651  In this phase the AST is broken down into three-operand form (iCode).
7652  These three operand forms are represented as doubly linked lists.
7653  ICode is the term given to the intermediate form generated by the compiler.
7654  ICode example section shows some examples of iCode generated for some simple
7655  C source functions.
7656 \layout Paragraph*
7657
7658 Optimizations.
7659 \layout Standard
7660
7661 Bulk of the target independent optimizations is performed in this phase.
7662  The optimizations include constant propagation, common sub-expression eliminati
7663 on, loop invariant code movement, strength reduction of loop induction variables
7664  and dead-code elimination.
7665 \layout Paragraph*
7666
7667 Live range analysis
7668 \layout Standard
7669
7670 During intermediate code generation phase, the compiler assumes the target
7671  machine has infinite number of registers and generates a lot of temporary
7672  variables.
7673  The live range computation determines the lifetime of each of these compiler-ge
7674 nerated temporaries.
7675  A picture speaks a thousand words.
7676  ICode example sections show the live range annotations for each of the
7677  operand.
7678  It is important to note here, each iCode is assigned a number in the order
7679  of its execution in the function.
7680  The live ranges are computed in terms of these numbers.
7681  The from number is the number of the iCode which first defines the operand
7682  and the to number signifies the iCode which uses this operand last.
7683 \layout Paragraph*
7684
7685 Register Allocation
7686 \layout Standard
7687
7688 The register allocation determines the type and number of registers needed
7689  by each operand.
7690  In most MCUs only a few registers can be used for indirect addressing.
7691  In case of 8051 for example the registers R0 & R1 can be used to indirectly
7692  address the internal ram and DPTR to indirectly address the external ram.
7693  The compiler will try to allocate the appropriate register to pointer variables
7694  if it can.
7695  ICode example section shows the operands annotated with the registers assigned
7696  to them.
7697  The compiler will try to keep operands in registers as much as possible;
7698  there are several schemes the compiler uses to do achieve this.
7699  When the compiler runs out of registers the compiler will check to see
7700  if there are any live operands which is not used or defined in the current
7701  basic block being processed, if there are any found then it will push that
7702  operand and use the registers in this block, the operand will then be popped
7703  at the end of the basic block.
7704  
7705 \layout Standard
7706
7707 There are other MCU specific considerations in this phase.
7708  Some MCUs have an accumulator; very short-lived operands could be assigned
7709  to the accumulator instead of general-purpose register.
7710 \layout Paragraph*
7711
7712 Code generation
7713 \layout Standard
7714
7715 Figure II gives a table of iCode operations supported by the compiler.
7716  The code generation involves translating these operations into corresponding
7717  assembly code for the processor.
7718  This sounds overly simple but that is the essence of code generation.
7719  Some of the iCode operations are generated on a MCU specific manner for
7720  example, the z80 port does not use registers to pass parameters so the
7721  SEND and RECV iCode operations will not be generated, and it also does
7722  not support JUMPTABLES.
7723  
7724 \newline 
7725
7726 \series bold 
7727 \shape italic 
7728 \color red
7729 <Where is Figure II ?>
7730 \layout Paragraph*
7731
7732 ICode Example
7733 \layout Standard
7734
7735 This section shows some details of iCode.
7736  The example C code does not do anything useful; it is used as an example
7737  to illustrate the intermediate code generated by the compiler.
7738 \newline 
7739
7740 \newline 
7741
7742 \family typewriter 
7743 1.\SpecialChar ~
7744 xdata int * p;
7745 \newline 
7746 2.\SpecialChar ~
7747 int gint;
7748 \newline 
7749 3.\SpecialChar ~
7750 /* This function does nothing useful.
7751  It is used
7752 \newline 
7753 4.\SpecialChar ~
7754 \SpecialChar ~
7755 \SpecialChar ~
7756 \SpecialChar ~
7757 for the purpose of explaining iCode */
7758 \newline 
7759 5.\SpecialChar ~
7760 short function (data int *x)
7761 \newline 
7762 6.\SpecialChar ~
7763 {
7764 \newline 
7765 7.\SpecialChar ~
7766 \SpecialChar ~
7767 \SpecialChar ~
7768 short i=10; /* dead initialization eliminated */
7769 \newline 
7770 8.\SpecialChar ~
7771 \SpecialChar ~
7772 \SpecialChar ~
7773 short sum=10; /* dead initialization eliminated */
7774 \newline 
7775 9.\SpecialChar ~
7776 \SpecialChar ~
7777 \SpecialChar ~
7778 short mul;
7779 \newline 
7780 10.\SpecialChar ~
7781 \SpecialChar ~
7782 int j ;
7783 \newline 
7784 11.\SpecialChar ~
7785 \SpecialChar ~
7786 while (*x) *x++ = *p++; 
7787 \newline 
7788 12.\SpecialChar ~
7789 \SpecialChar ~
7790 \SpecialChar ~
7791 \SpecialChar ~
7792 sum = 0 ; 
7793 \newline 
7794 13.\SpecialChar ~
7795 \SpecialChar ~
7796 mul = 0;
7797 \newline 
7798 14.\SpecialChar ~
7799 \SpecialChar ~
7800 /* compiler detects i,j to be induction variables */
7801 \newline 
7802 15.\SpecialChar ~
7803 \SpecialChar ~
7804 for (i = 0, j = 10 ; i < 10 ; i++, j---) {
7805 \newline 
7806 16.\SpecialChar ~
7807 \SpecialChar ~
7808 \SpecialChar ~
7809 \SpecialChar ~
7810 sum += i;
7811 \newline 
7812 17.\SpecialChar ~
7813 \SpecialChar ~
7814 \SpecialChar ~
7815 \SpecialChar ~
7816 mul += i * 3; /* this multiplication remains */
7817 \newline 
7818 18.\SpecialChar ~
7819 \SpecialChar ~
7820 \SpecialChar ~
7821 \SpecialChar ~
7822 gint += j * 3;/* this multiplication changed to addition */
7823 \newline 
7824 19.\SpecialChar ~
7825 \SpecialChar ~
7826 }
7827 \newline 
7828 20.\SpecialChar ~
7829 \SpecialChar ~
7830 return sum+mul;
7831 \newline 
7832 21.\SpecialChar ~
7833 }
7834 \newline 
7835
7836 \newline 
7837
7838 \family default 
7839 In addition to the operands each iCode contains information about the filename
7840  and line it corresponds to in the source file.
7841  The first field in the listing should be interpreted as follows:
7842 \newline 
7843
7844 \shape italic 
7845 \size footnotesize 
7846 Filename(linenumber: iCode Execution sequence number : ICode hash table
7847  key : loop depth of the iCode).
7848 \shape default 
7849 \size default 
7850
7851 \newline 
7852 Then follows the human readable form of the ICode operation.
7853  Each operand of this triplet form can be of three basic types a) compiler
7854  generated temporary b) user defined variable c) a constant value.
7855  Note that local variables and parameters are replaced by compiler generated
7856  temporaries.
7857  Live ranges are computed only for temporaries (i.e.
7858  live ranges are not computed for global variables).
7859  Registers are allocated for temporaries only.
7860  Operands are formatted in the following manner:
7861 \newline 
7862
7863 \shape italic 
7864 \size footnotesize 
7865 Operand Name [lr live-from : live-to ] { type information } [ registers
7866  allocated ].
7867 \shape default 
7868 \size default 
7869
7870 \newline 
7871 As mentioned earlier the live ranges are computed in terms of the execution
7872  sequence number of the iCodes, for example 
7873 \newline 
7874 the iTemp0 is live from (i.e.
7875  first defined in iCode with execution sequence number 3, and is last used
7876  in the iCode with sequence number 5).
7877  For induction variables such as iTemp21 the live range computation extends
7878  the lifetime from the start to the end of the loop.
7879 \newline 
7880 The register allocator used the live range information to allocate registers,
7881  the same registers may be used for different temporaries if their live
7882  ranges do not overlap, for example r0 is allocated to both iTemp6 and to
7883  iTemp17 since their live ranges do not overlap.
7884  In addition the allocator also takes into consideration the type and usage
7885  of a temporary, for example itemp6 is a pointer to near space and is used
7886  as to fetch data from (i.e.
7887  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer registers (r0).
7888  Some short lived temporaries are allocated to special registers which have
7889  meaning to the code generator e.g.
7890  iTemp13 is allocated to a pseudo register CC which tells the back end that
7891  the temporary is used only for a conditional jump the code generation makes
7892  use of this information to optimize a compare and jump ICode.
7893 \newline 
7894 There are several loop optimizations performed by the compiler.
7895  It can detect induction variables iTemp21(i) and iTemp23(j).
7896  Also note the compiler does selective strength reduction, i.e.
7897  the multiplication of an induction variable in line 18 (gint = j * 3) is
7898  changed to addition, a new temporary iTemp17 is allocated and assigned
7899  a initial value, a constant 3 is then added for each iteration of the loop.
7900  The compiler does not change the multiplication in line 17 however since
7901  the processor does support an 8 * 8 bit multiplication.
7902 \newline 
7903 Note the dead code elimination optimization eliminated the dead assignments
7904  in line 7 & 8 to I and sum respectively.
7905 \newline 
7906
7907 \layout Standard
7908
7909
7910 \size footnotesize 
7911 Sample.c (5:1:0:0) _entry($9) :
7912 \layout Standard
7913
7914
7915 \size footnotesize 
7916 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
7917 \layout Standard
7918
7919
7920 \size footnotesize 
7921 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
7922 \layout Standard
7923
7924
7925 \size footnotesize 
7926 Sample.c(11:4:53:0) preHeaderLbl0($11) :
7927 \layout Standard
7928
7929
7930 \size footnotesize 
7931 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
7932  * int}[r2]
7933 \layout Standard
7934
7935
7936 \size footnotesize 
7937 Sample.c(11:6:5:1) _whilecontinue_0($1) :
7938 \layout Standard
7939
7940
7941 \size footnotesize 
7942 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
7943  int}[r0]]
7944 \layout Standard
7945
7946
7947 \size footnotesize 
7948 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
7949 \layout Standard
7950
7951
7952 \size footnotesize 
7953 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
7954  * int}
7955 \layout Standard
7956
7957
7958 \size footnotesize 
7959 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
7960  {short}
7961 \layout Standard
7962
7963
7964 \size footnotesize 
7965 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
7966  * int}[DPTR]]
7967 \layout Standard
7968
7969
7970 \size footnotesize 
7971 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
7972 }[r2 r3]
7973 \layout Standard
7974
7975
7976 \size footnotesize 
7977 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
7978  * int}[r0] + 
7979 \layout Standard
7980
7981
7982 \size footnotesize 
7983 0x2 {short}
7984 \layout Standard
7985
7986
7987 \size footnotesize 
7988 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
7989 \layout Standard
7990
7991
7992 \size footnotesize 
7993 Sample.c(11:17:21:0)_whilebreak_0($3) :
7994 \layout Standard
7995
7996
7997 \size footnotesize 
7998 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
7999 \layout Standard
8000
8001
8002 \size footnotesize 
8003 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
8004 \layout Standard
8005
8006
8007 \size footnotesize 
8008 Sample.c(15:20:54:0)preHeaderLbl1($13) :
8009 \layout Standard
8010
8011
8012 \size footnotesize 
8013 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
8014 \layout Standard
8015
8016
8017 \size footnotesize 
8018 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
8019 \layout Standard
8020
8021
8022 \size footnotesize 
8023 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
8024 \layout Standard
8025
8026
8027 \size footnotesize 
8028 Sample.c(15:24:26:1)_forcond_0($4) :
8029 \layout Standard
8030
8031
8032 \size footnotesize 
8033 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
8034  < 0xa {short}
8035 \layout Standard
8036
8037
8038 \size footnotesize 
8039 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
8040 \layout Standard
8041
8042
8043 \size footnotesize 
8044 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
8045  + 
8046 \layout Standard
8047
8048
8049 \size footnotesize 
8050 ITemp21 [lr21:38]{short}[r4]
8051 \layout Standard
8052
8053
8054 \size footnotesize 
8055 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
8056  * 0x3 {short}
8057 \layout Standard
8058
8059
8060 \size footnotesize 
8061 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
8062  + 
8063 \layout Standard
8064
8065
8066 \size footnotesize 
8067 iTemp15 [lr29:30]{short}[r1]
8068 \layout Standard
8069
8070
8071 \size footnotesize 
8072 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
8073  r0]- 0x3 {short}
8074 \layout Standard
8075
8076
8077 \size footnotesize 
8078 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
8079 int}[r7 r0]
8080 \layout Standard
8081
8082
8083 \size footnotesize 
8084 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
8085  + 0x1 {short}
8086 \layout Standard
8087
8088
8089 \size footnotesize 
8090 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
8091  r6]- 0x1 {short}
8092 \layout Standard
8093
8094
8095 \size footnotesize 
8096 Sample.c(19:38:47:1) goto _forcond_0($4)
8097 \layout Standard
8098
8099
8100 \size footnotesize 
8101 Sample.c(19:39:48:0)_forbreak_0($7) :
8102 \layout Standard
8103
8104
8105 \size footnotesize 
8106 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
8107  + 
8108 \layout Standard
8109
8110
8111 \size footnotesize 
8112 ITemp11 [lr19:40]{short}[r3]
8113 \layout Standard
8114
8115
8116 \size footnotesize 
8117 sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
8118 \layout Standard
8119
8120
8121 \size footnotesize 
8122 sample.c(20:42:51:0)_return($8) :
8123 \layout Standard
8124
8125
8126 \size footnotesize 
8127 sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
8128 \size default 
8129
8130 \newline 
8131
8132 \newline 
8133 Finally the code generated for this function:
8134 \newline 
8135
8136 \layout Standard
8137
8138
8139 \size footnotesize 
8140 .area DSEG (DATA)
8141 \layout Standard
8142
8143
8144 \size footnotesize 
8145 _p::
8146 \layout Standard
8147
8148
8149 \size footnotesize 
8150 \SpecialChar ~
8151 \SpecialChar ~
8152 .ds 2
8153 \layout Standard
8154
8155
8156 \size footnotesize 
8157 _gint::
8158 \layout Standard
8159
8160
8161 \size footnotesize 
8162 \SpecialChar ~
8163 \SpecialChar ~
8164 .ds 2
8165 \layout Standard
8166
8167
8168 \size footnotesize 
8169 ; sample.c 5
8170 \layout Standard
8171
8172
8173 \size footnotesize 
8174 ; ----------------------------------------------
8175 \layout Standard
8176
8177
8178 \size footnotesize 
8179 ; function function
8180 \layout Standard
8181
8182
8183 \size footnotesize 
8184 ; ----------------------------------------------
8185 \layout Standard
8186
8187
8188 \size footnotesize 
8189 _function:
8190 \layout Standard
8191
8192
8193 \size footnotesize 
8194 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
8195 \layout Standard
8196
8197
8198 \size footnotesize 
8199 \SpecialChar ~
8200 \SpecialChar ~
8201 mov r2,dpl
8202 \layout Standard
8203
8204
8205 \size footnotesize 
8206 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
8207 \layout Standard
8208
8209
8210 \size footnotesize 
8211 \SpecialChar ~
8212 \SpecialChar ~
8213 mov ar0,r2
8214 \layout Standard
8215
8216
8217 \size footnotesize 
8218 ;_whilecontinue_0($1) :
8219 \layout Standard
8220
8221
8222 \size footnotesize 
8223 00101$:
8224 \layout Standard
8225
8226
8227 \size footnotesize 
8228 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
8229 \layout Standard
8230
8231
8232 \size footnotesize 
8233 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
8234 \layout Standard
8235
8236
8237 \size footnotesize 
8238 \SpecialChar ~
8239 \SpecialChar ~
8240 mov ar2,@r0
8241 \layout Standard
8242
8243
8244 \size footnotesize 
8245 \SpecialChar ~
8246 \SpecialChar ~
8247 inc r0
8248 \layout Standard
8249
8250
8251 \size footnotesize 
8252 \SpecialChar ~
8253 \SpecialChar ~
8254 mov ar3,@r0
8255 \layout Standard
8256
8257
8258 \size footnotesize 
8259 \SpecialChar ~
8260 \SpecialChar ~
8261 dec r0
8262 \layout Standard
8263
8264
8265 \size footnotesize 
8266 \SpecialChar ~
8267 \SpecialChar ~
8268 mov a,r2
8269 \layout Standard
8270
8271
8272 \size footnotesize 
8273 \SpecialChar ~
8274 \SpecialChar ~
8275 orl a,r3
8276 \layout Standard
8277
8278
8279 \size footnotesize 
8280 \SpecialChar ~
8281 \SpecialChar ~
8282 jz 00103$
8283 \layout Standard
8284
8285
8286 \size footnotesize 
8287 00114$:
8288 \layout Standard
8289
8290
8291 \size footnotesize 
8292 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
8293 \layout Standard
8294
8295
8296 \size footnotesize 
8297 \SpecialChar ~
8298 \SpecialChar ~
8299 mov dpl,_p
8300 \layout Standard
8301
8302
8303 \size footnotesize 
8304 \SpecialChar ~
8305 \SpecialChar ~
8306 mov dph,(_p + 1)
8307 \layout Standard
8308
8309
8310 \size footnotesize 
8311 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
8312 \layout Standard
8313
8314
8315 \size footnotesize 
8316 \SpecialChar ~
8317 \SpecialChar ~
8318 mov a,#0x02
8319 \layout Standard
8320
8321
8322 \size footnotesize 
8323 \SpecialChar ~
8324 \SpecialChar ~
8325 add a,_p
8326 \layout Standard
8327
8328
8329 \size footnotesize 
8330 \SpecialChar ~
8331 \SpecialChar ~
8332 mov _p,a
8333 \layout Standard
8334
8335
8336 \size footnotesize 
8337 \SpecialChar ~
8338 \SpecialChar ~
8339 clr a
8340 \layout Standard
8341
8342
8343 \size footnotesize 
8344 \SpecialChar ~
8345 \SpecialChar ~
8346 addc a,(_p + 1)
8347 \layout Standard
8348
8349
8350 \size footnotesize 
8351 \SpecialChar ~
8352 \SpecialChar ~
8353 mov (_p + 1),a
8354 \layout Standard
8355
8356
8357 \size footnotesize 
8358 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
8359 \layout Standard
8360
8361
8362 \size footnotesize 
8363 \SpecialChar ~
8364 \SpecialChar ~
8365 movx a,@dptr
8366 \layout Standard
8367
8368
8369 \size footnotesize 
8370 \SpecialChar ~
8371 \SpecialChar ~
8372 mov r2,a
8373 \layout Standard
8374
8375
8376 \size footnotesize 
8377 \SpecialChar ~
8378 \SpecialChar ~
8379 inc dptr
8380 \layout Standard
8381
8382
8383 \size footnotesize 
8384 \SpecialChar ~
8385 \SpecialChar ~
8386 movx a,@dptr
8387 \layout Standard
8388
8389
8390 \size footnotesize 
8391 \SpecialChar ~
8392 \SpecialChar ~
8393 mov r3,a
8394 \layout Standard
8395
8396
8397 \size footnotesize 
8398 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
8399 \layout Standard
8400
8401
8402 \size footnotesize 
8403 \SpecialChar ~
8404 \SpecialChar ~
8405 mov @r0,ar2
8406 \layout Standard
8407
8408
8409 \size footnotesize 
8410 \SpecialChar ~
8411 \SpecialChar ~
8412 inc r0
8413 \layout Standard
8414
8415
8416 \size footnotesize 
8417 \SpecialChar ~
8418 \SpecialChar ~
8419 mov @r0,ar3
8420 \layout Standard
8421
8422
8423 \size footnotesize 
8424 ; iTemp6 [lr5:16]{_near * int}[r0] = 
8425 \layout Standard
8426
8427
8428 \size footnotesize 
8429 ; iTemp6 [lr5:16]{_near * int}[r0] + 
8430 \layout Standard
8431
8432
8433 \size footnotesize 
8434 ; 0x2 {short}
8435 \layout Standard
8436
8437
8438 \size footnotesize 
8439 \SpecialChar ~
8440 \SpecialChar ~
8441 inc r0
8442 \layout Standard
8443
8444
8445 \size footnotesize 
8446 ; goto _whilecontinue_0($1)
8447 \layout Standard
8448
8449
8450 \size footnotesize 
8451 \SpecialChar ~
8452 \SpecialChar ~
8453 sjmp 00101$
8454 \layout Standard
8455
8456
8457 \size footnotesize 
8458 ; _whilebreak_0($3) :
8459 \layout Standard
8460
8461
8462 \size footnotesize 
8463 00103$:
8464 \layout Standard
8465
8466
8467 \size footnotesize 
8468 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
8469 \layout Standard
8470
8471
8472 \size footnotesize 
8473 \SpecialChar ~
8474 \SpecialChar ~
8475 mov r2,#0x00
8476 \layout Standard
8477
8478
8479 \size footnotesize 
8480 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
8481 \layout Standard
8482
8483
8484 \size footnotesize 
8485 \SpecialChar ~
8486 \SpecialChar ~
8487 mov r3,#0x00
8488 \layout Standard
8489
8490
8491 \size footnotesize 
8492 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
8493 \layout Standard
8494
8495
8496 \size footnotesize 
8497 \SpecialChar ~
8498 \SpecialChar ~
8499 mov r4,#0x00
8500 \layout Standard
8501
8502
8503 \size footnotesize 
8504 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
8505 \layout Standard
8506
8507
8508 \size footnotesize 
8509 \SpecialChar ~
8510 \SpecialChar ~
8511 mov r5,#0x0A
8512 \layout Standard
8513
8514
8515 \size footnotesize 
8516 \SpecialChar ~
8517 \SpecialChar ~
8518 mov r6,#0x00
8519 \layout Standard
8520
8521
8522 \size footnotesize 
8523 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
8524 \layout Standard
8525
8526
8527 \size footnotesize 
8528 \SpecialChar ~
8529 \SpecialChar ~
8530 mov r7,#0x1E
8531 \layout Standard
8532
8533
8534 \size footnotesize 
8535 \SpecialChar ~
8536 \SpecialChar ~
8537 mov r0,#0x00
8538 \layout Standard
8539
8540
8541 \size footnotesize 
8542 ; _forcond_0($4) :
8543 \layout Standard
8544
8545
8546 \size footnotesize 
8547 00104$:
8548 \layout Standard
8549
8550
8551 \size footnotesize 
8552 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
8553 \layout Standard
8554
8555
8556 \size footnotesize 
8557 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
8558 \layout Standard
8559
8560
8561 \size footnotesize 
8562 \SpecialChar ~
8563 \SpecialChar ~
8564 clr c
8565 \layout Standard
8566
8567
8568 \size footnotesize 
8569 \SpecialChar ~
8570 \SpecialChar ~
8571 mov a,r4
8572 \layout Standard
8573
8574
8575 \size footnotesize 
8576 \SpecialChar ~
8577 \SpecialChar ~
8578 xrl a,#0x80
8579 \layout Standard
8580
8581
8582 \size footnotesize 
8583 \SpecialChar ~
8584 \SpecialChar ~
8585 subb a,#0x8a
8586 \layout Standard
8587
8588
8589 \size footnotesize 
8590 \SpecialChar ~
8591 \SpecialChar ~
8592 jnc 00107$
8593 \layout Standard
8594
8595
8596 \size footnotesize 
8597 00115$:
8598 \layout Standard
8599
8600
8601 \size footnotesize 
8602 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
8603 \layout Standard
8604
8605
8606 \size footnotesize 
8607 ; iTemp21 [lr21:38]{short}[r4]
8608 \layout Standard
8609
8610
8611 \size footnotesize 
8612 \SpecialChar ~
8613 \SpecialChar ~
8614 mov a,r4
8615 \layout Standard
8616
8617
8618 \size footnotesize 
8619 \SpecialChar ~
8620 \SpecialChar ~
8621 add a,r2
8622 \layout Standard
8623
8624
8625 \size footnotesize 
8626 \SpecialChar ~
8627 \SpecialChar ~
8628 mov r2,a
8629 \layout Standard
8630
8631
8632 \size footnotesize 
8633 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
8634 \layout Standard
8635
8636
8637 \size footnotesize 
8638 \SpecialChar ~
8639 \SpecialChar ~
8640 mov b,#0x03
8641 \layout Standard
8642
8643
8644 \size footnotesize 
8645 \SpecialChar ~
8646 \SpecialChar ~
8647 mov a,r4
8648 \layout Standard
8649
8650
8651 \size footnotesize 
8652 \SpecialChar ~
8653 \SpecialChar ~
8654 mul ab
8655 \layout Standard
8656
8657
8658 \size footnotesize 
8659 \SpecialChar ~
8660 \SpecialChar ~
8661 mov r1,a
8662 \layout Standard
8663
8664
8665 \size footnotesize 
8666 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
8667 \layout Standard
8668
8669
8670 \size footnotesize 
8671 ; iTemp15 [lr29:30]{short}[r1]
8672 \layout Standard
8673
8674
8675 \size footnotesize 
8676 \SpecialChar ~
8677 \SpecialChar ~
8678 add a,r3
8679 \layout Standard
8680
8681
8682 \size footnotesize 
8683 \SpecialChar ~
8684 \SpecialChar ~
8685 mov r3,a
8686 \layout Standard
8687
8688
8689 \size footnotesize 
8690 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
8691 \layout Standard
8692
8693
8694 \size footnotesize 
8695 \SpecialChar ~
8696 \SpecialChar ~
8697 mov a,r7
8698 \layout Standard
8699
8700
8701 \size footnotesize 
8702 \SpecialChar ~
8703 \SpecialChar ~
8704 add a,#0xfd
8705 \layout Standard
8706
8707
8708 \size footnotesize 
8709 \SpecialChar ~
8710 \SpecialChar ~
8711 mov r7,a
8712 \layout Standard
8713
8714
8715 \size footnotesize 
8716 \SpecialChar ~
8717 \SpecialChar ~
8718 mov a,r0
8719 \layout Standard
8720
8721
8722 \size footnotesize 
8723 \SpecialChar ~
8724 \SpecialChar ~
8725 addc a,#0xff
8726 \layout Standard
8727
8728
8729 \size footnotesize 
8730 \SpecialChar ~
8731 \SpecialChar ~
8732 mov r0,a
8733 \layout Standard
8734
8735
8736 \size footnotesize 
8737 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
8738 \layout Standard
8739
8740
8741 \size footnotesize 
8742 \SpecialChar ~
8743 \SpecialChar ~
8744 mov a,r7
8745 \layout Standard
8746
8747
8748 \size footnotesize 
8749 \SpecialChar ~
8750 \SpecialChar ~
8751 add a,_gint
8752 \layout Standard
8753
8754
8755 \size footnotesize 
8756 \SpecialChar ~
8757 \SpecialChar ~
8758 mov _gint,a
8759 \layout Standard
8760
8761
8762 \size footnotesize 
8763 \SpecialChar ~
8764 \SpecialChar ~
8765 mov a,r0
8766 \layout Standard
8767
8768
8769 \size footnotesize 
8770 \SpecialChar ~
8771 \SpecialChar ~
8772 addc a,(_gint + 1)
8773 \layout Standard
8774
8775
8776 \size footnotesize 
8777 \SpecialChar ~
8778 \SpecialChar ~
8779 mov (_gint + 1),a
8780 \layout Standard
8781
8782
8783 \size footnotesize 
8784 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
8785 \layout Standard
8786
8787
8788 \size footnotesize 
8789 \SpecialChar ~
8790 \SpecialChar ~
8791 inc r4
8792 \layout Standard
8793
8794
8795 \size footnotesize 
8796 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
8797 \layout Standard
8798
8799
8800 \size footnotesize 
8801 \SpecialChar ~
8802 \SpecialChar ~
8803 dec r5
8804 \layout Standard
8805
8806
8807 \size footnotesize 
8808 \SpecialChar ~
8809 \SpecialChar ~
8810 cjne r5,#0xff,00104$
8811 \layout Standard
8812
8813
8814 \size footnotesize 
8815 \SpecialChar ~
8816 \SpecialChar ~
8817 dec r6
8818 \layout Standard
8819
8820
8821 \size footnotesize 
8822 ; goto _forcond_0($4)
8823 \layout Standard
8824
8825
8826 \size footnotesize 
8827 \SpecialChar ~
8828 \SpecialChar ~
8829 sjmp 00104$
8830 \layout Standard
8831
8832
8833 \size footnotesize 
8834 ; _forbreak_0($7) :
8835 \layout Standard
8836
8837
8838 \size footnotesize 
8839 00107$:
8840 \layout Standard
8841
8842
8843 \size footnotesize 
8844 ; ret iTemp24 [lr40:41]{short}
8845 \layout Standard
8846
8847
8848 \size footnotesize 
8849 \SpecialChar ~
8850 \SpecialChar ~
8851 mov a,r3
8852 \layout Standard
8853
8854
8855 \size footnotesize 
8856 \SpecialChar ~
8857 \SpecialChar ~
8858 add a,r2
8859 \layout Standard
8860
8861
8862 \size footnotesize 
8863 \SpecialChar ~
8864 \SpecialChar ~
8865 mov dpl,a
8866 \layout Standard
8867
8868
8869 \size footnotesize 
8870 ; _return($8) :
8871 \layout Standard
8872
8873
8874 \size footnotesize 
8875 00108$:
8876 \layout Standard
8877
8878
8879 \size footnotesize 
8880 \SpecialChar ~
8881 \SpecialChar ~
8882 ret
8883 \size default 
8884
8885 \newline 
8886
8887 \layout Section
8888
8889 Acknowledgments
8890 \layout Standard
8891
8892
8893 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
8894
8895 \end_inset 
8896
8897
8898 \newline 
8899
8900 \newline 
8901
8902 \emph on 
8903 Thanks to all the other volunteer developers who have helped with coding,
8904  testing, web-page creation, distribution sets, etc.
8905  You know who you are :-)
8906 \emph default 
8907
8908 \newline 
8909
8910 \layout Standard
8911
8912 This document was initially written by Sandeep Dutta
8913 \layout Standard
8914
8915 All product names mentioned herein may be trademarks of their respective
8916  companies.
8917  
8918 \layout Standard
8919
8920
8921 \begin_inset LatexCommand \printindex{}
8922
8923 \end_inset 
8924
8925
8926 \the_end