* .version, sdcc.spec, doc/sdccman.lyx, doc/INSTALL.txt:
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.5.7 created this file. For more info see http://www.lyx.org/
2 \lyxformat 276
3 \begin_document
4 \begin_header
5 \textclass book
6 \begin_preamble
7 \pdfoptionpdfminorversion=3
8 \usepackage[
9   pdftitle={SDCC Compiler User Guide},
10   pdfauthor={SDCC development team},
11   pdfsubject={installation, user manual},
12   pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
13   pdfpagemode=UseOutlines,
14   colorlinks=true,
15   linkcolor=blue] {hyperref}
16 %
17 \sloppy
18 \tolerance=500          
19 \emergencystretch=30pt 
20 %
21 \date{}
22 \end_preamble
23 \language english
24 \inputencoding default
25 \font_roman times
26 \font_sans helvet
27 \font_typewriter courier
28 \font_default_family default
29 \font_sc false
30 \font_osf false
31 \font_sf_scale 100
32 \font_tt_scale 100
33 \graphics default
34 \paperfontsize default
35 \spacing single
36 \papersize letterpaper
37 \use_geometry true
38 \use_amsmath 1
39 \use_esint 0
40 \cite_engine basic
41 \use_bibtopic false
42 \paperorientation portrait
43 \leftmargin 30mm
44 \topmargin 20mm
45 \rightmargin 25mm
46 \bottommargin 20mm
47 \secnumdepth 3
48 \tocdepth 3
49 \paragraph_separation indent
50 \defskip medskip
51 \quotes_language swedish
52 \papercolumns 1
53 \papersides 1
54 \paperpagestyle fancy
55 \tracking_changes false
56 \output_changes false
57 \author "" 
58 \author "" 
59 \end_header
60
61 \begin_body
62
63 \begin_layout Standard
64 \begin_inset Note Note
65 status collapsed
66
67 \begin_layout Standard
68 Please note: double dashed longoptions (e.g.
69  --version) are written this way: -
70 \begin_inset ERT
71 status collapsed
72
73 \begin_layout Standard
74
75
76 \backslash
77 /
78 \end_layout
79
80 \end_inset
81
82 -
83 \end_layout
84
85 \begin_layout Standard
86 Two resp.
87  three consecutive dashes would otherwise result in a long resp.
88  extra long dash.
89 \end_layout
90
91 \begin_layout Standard
92 Architecture specific stuff (like memory models, code examples) should maybe
93  later go
94 \end_layout
95
96 \begin_layout Standard
97 into separate sections/chapters/appendices (it is hard to document PIC or
98  Z80 in 
99 \end_layout
100
101 \begin_layout Standard
102 a 8051 centered document) - for now simply add.
103 \end_layout
104
105 \end_inset
106
107
108 \end_layout
109
110 \begin_layout Title
111 SDCC Compiler User Guide
112 \end_layout
113
114 \begin_layout Date
115
116 \size normal
117 SDCC 2.9.0
118 \size footnotesize
119
120 \newline
121 $Date::            $ 
122 \newline
123 $Revision$
124 \end_layout
125
126 \begin_layout Standard
127 \begin_inset Note Note
128 status collapsed
129
130 \begin_layout Standard
131 The above strings enclosed in $ are automatically updated by Subversion
132 \end_layout
133
134 \end_inset
135
136
137 \end_layout
138
139 \begin_layout Standard
140 \begin_inset LatexCommand tableofcontents
141
142 \end_inset
143
144
145 \end_layout
146
147 \begin_layout Chapter
148 Introduction
149 \end_layout
150
151 \begin_layout Section
152 About SDCC
153 \end_layout
154
155 \begin_layout Standard
156
157 \series bold
158 SDCC
159 \series default
160  (
161 \emph on
162 S
163 \emph default
164 mall 
165 \emph on
166 D
167 \emph default
168 evice 
169 \emph on
170 C
171 \emph default
172  
173 \emph on
174 C
175 \emph default
176 ompiler) is free open source, retargettable, optimizing ANSI-C compiler
177  by 
178 \series bold
179 Sandeep Dutta
180 \series default
181  designed for 8 bit Microprocessors.
182  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
183  8051, 8052
184 \begin_inset LatexCommand index
185 name "8031, 8032, 8051, 8052, mcs51 CPU"
186
187 \end_inset
188
189 , etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and
190  Zilog Z80 based MCUs.
191  It can be retargeted for other microprocessors, support for Microchip PIC,
192  Atmel AVR is under development.
193  The entire source code for the compiler is distributed under GPL.
194  SDCC uses ASXXXX
195 \begin_inset LatexCommand index
196 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
197
198 \end_inset
199
200  & ASLINK
201 \begin_inset LatexCommand index
202 name "aslink"
203
204 \end_inset
205
206 , an open source retargetable assembler & linker.
207  SDCC has extensive language extensions suitable for utilizing various microcont
208 rollers and underlying hardware effectively.
209  
210 \newline
211
212 \newline
213 In addition to the MCU specific optimizations SDCC also does a host of
214  standard optimizations like:
215 \end_layout
216
217 \begin_layout Itemize
218 global sub expression elimination, 
219 \end_layout
220
221 \begin_layout Itemize
222 loop optimizations (loop invariant, strength reduction of induction variables
223  and loop reversing), 
224 \end_layout
225
226 \begin_layout Itemize
227 constant folding & propagation, 
228 \end_layout
229
230 \begin_layout Itemize
231 copy propagation, 
232 \end_layout
233
234 \begin_layout Itemize
235 dead code elimination 
236 \end_layout
237
238 \begin_layout Itemize
239 jump tables for 
240 \emph on
241 switch
242 \emph default
243  statements.
244 \end_layout
245
246 \begin_layout Standard
247 For the back-end SDCC uses a global register allocation scheme which should
248  be well suited for other 8 bit MCUs.
249  
250 \newline
251
252 \newline
253 The peep hole optimizer uses a rule based substitution mechanism which
254  is MCU independent.
255  
256 \newline
257
258 \newline
259 Supported data-types are:
260 \end_layout
261
262 \begin_layout Standard
263 \begin_inset Tabular
264 <lyxtabular version="3" rows="8" columns="5">
265 <features>
266 <column alignment="center" valignment="top" leftline="true" width="0">
267 <column alignment="center" valignment="top" leftline="true" width="0">
268 <column alignment="center" valignment="top" leftline="true" width="0">
269 <column alignment="center" valignment="top" leftline="true" width="0">
270 <column alignment="block" valignment="top" leftline="true" rightline="true" width="20text%">
271 <row topline="true" bottomline="true">
272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
273 \begin_inset Text
274
275 \begin_layout Standard
276 type
277 \end_layout
278
279 \end_inset
280 </cell>
281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
282 \begin_inset Text
283
284 \begin_layout Standard
285 width
286 \end_layout
287
288 \end_inset
289 </cell>
290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
291 \begin_inset Text
292
293 \begin_layout Standard
294 default
295 \end_layout
296
297 \end_inset
298 </cell>
299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
300 \begin_inset Text
301
302 \begin_layout Standard
303 signed range
304 \end_layout
305
306 \end_inset
307 </cell>
308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
309 \begin_inset Text
310
311 \begin_layout Standard
312 unsigned range
313 \end_layout
314
315 \end_inset
316 </cell>
317 </row>
318 <row topline="true">
319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
320 \begin_inset Text
321
322 \begin_layout Standard
323 bool
324 \end_layout
325
326 \end_inset
327 </cell>
328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
329 \begin_inset Text
330
331 \begin_layout Standard
332 1 bit
333 \end_layout
334
335 \end_inset
336 </cell>
337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
338 \begin_inset Text
339
340 \begin_layout Standard
341 unsigned
342 \end_layout
343
344 \end_inset
345 </cell>
346 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
347 \begin_inset Text
348
349 \begin_layout Standard
350 -
351 \end_layout
352
353 \end_inset
354 </cell>
355 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
356 \begin_inset Text
357
358 \begin_layout Standard
359 0, 1
360 \end_layout
361
362 \end_inset
363 </cell>
364 </row>
365 <row topline="true">
366 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
367 \begin_inset Text
368
369 \begin_layout Standard
370 char
371 \end_layout
372
373 \end_inset
374 </cell>
375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
376 \begin_inset Text
377
378 \begin_layout Standard
379 8 bits, 1 byte
380 \end_layout
381
382 \end_inset
383 </cell>
384 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
385 \begin_inset Text
386
387 \begin_layout Standard
388 signed
389 \end_layout
390
391 \end_inset
392 </cell>
393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
394 \begin_inset Text
395
396 \begin_layout Standard
397 -128, +127
398 \end_layout
399
400 \end_inset
401 </cell>
402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
403 \begin_inset Text
404
405 \begin_layout Standard
406 0, +255
407 \end_layout
408
409 \end_inset
410 </cell>
411 </row>
412 <row topline="true">
413 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
414 \begin_inset Text
415
416 \begin_layout Standard
417 short
418 \end_layout
419
420 \end_inset
421 </cell>
422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
423 \begin_inset Text
424
425 \begin_layout Standard
426 16 bits, 2 bytes
427 \end_layout
428
429 \end_inset
430 </cell>
431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
432 \begin_inset Text
433
434 \begin_layout Standard
435 signed
436 \end_layout
437
438 \end_inset
439 </cell>
440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
441 \begin_inset Text
442
443 \begin_layout Standard
444 -32.768, +32.767
445 \end_layout
446
447 \end_inset
448 </cell>
449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
450 \begin_inset Text
451
452 \begin_layout Standard
453 0, +65.535
454 \end_layout
455
456 \end_inset
457 </cell>
458 </row>
459 <row topline="true">
460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
461 \begin_inset Text
462
463 \begin_layout Standard
464 int
465 \end_layout
466
467 \end_inset
468 </cell>
469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
470 \begin_inset Text
471
472 \begin_layout Standard
473 16 bits, 2 bytes
474 \end_layout
475
476 \end_inset
477 </cell>
478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
479 \begin_inset Text
480
481 \begin_layout Standard
482 signed
483 \end_layout
484
485 \end_inset
486 </cell>
487 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
488 \begin_inset Text
489
490 \begin_layout Standard
491 -32.768, +32.767
492 \end_layout
493
494 \end_inset
495 </cell>
496 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
497 \begin_inset Text
498
499 \begin_layout Standard
500 0, +65.535
501 \end_layout
502
503 \end_inset
504 </cell>
505 </row>
506 <row topline="true" bottomline="true">
507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
508 \begin_inset Text
509
510 \begin_layout Standard
511 long
512 \end_layout
513
514 \end_inset
515 </cell>
516 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
517 \begin_inset Text
518
519 \begin_layout Standard
520 32 bits, 4 bytes
521 \end_layout
522
523 \end_inset
524 </cell>
525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
526 \begin_inset Text
527
528 \begin_layout Standard
529 signed
530 \end_layout
531
532 \end_inset
533 </cell>
534 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
535 \begin_inset Text
536
537 \begin_layout Standard
538 -2.147.483.648, +2.147.483.647
539 \end_layout
540
541 \end_inset
542 </cell>
543 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
544 \begin_inset Text
545
546 \begin_layout Standard
547 0, +4.294.967.295
548 \end_layout
549
550 \end_inset
551 </cell>
552 </row>
553 <row topline="true" bottomline="true">
554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
555 \begin_inset Text
556
557 \begin_layout Standard
558 float
559 \end_layout
560
561 \end_inset
562 </cell>
563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
564 \begin_inset Text
565
566 \begin_layout Standard
567 4 bytes IEEE 754
568 \end_layout
569
570 \end_inset
571 </cell>
572 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
573 \begin_inset Text
574
575 \begin_layout Standard
576 signed
577 \end_layout
578
579 \end_inset
580 </cell>
581 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
582 \begin_inset Text
583
584 \begin_layout Standard
585
586 \end_layout
587
588 \end_inset
589 </cell>
590 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
591 \begin_inset Text
592
593 \begin_layout Standard
594 1.175494351E-38, 
595 \family roman
596 \series medium
597 \shape up
598 \size normal
599 \emph off
600 \bar no
601 \noun off
602 \color none
603 3.402823466E+38
604 \end_layout
605
606 \end_inset
607 </cell>
608 </row>
609 <row topline="true" bottomline="true">
610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
611 \begin_inset Text
612
613 \begin_layout Standard
614 pointer
615 \end_layout
616
617 \end_inset
618 </cell>
619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
620 \begin_inset Text
621
622 \begin_layout Standard
623 1, 2, 3 or 4 bytes
624 \end_layout
625
626 \end_inset
627 </cell>
628 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
629 \begin_inset Text
630
631 \begin_layout Standard
632 generic
633 \end_layout
634
635 \end_inset
636 </cell>
637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
638 \begin_inset Text
639
640 \begin_layout Standard
641
642 \end_layout
643
644 \end_inset
645 </cell>
646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
647 \begin_inset Text
648
649 \begin_layout Standard
650
651 \end_layout
652
653 \end_inset
654 </cell>
655 </row>
656 </lyxtabular>
657
658 \end_inset
659
660
661 \newline
662 The compiler also allows 
663 \emph on
664 inline assembler code
665 \emph default
666  to be embedded anywhere in a function.
667  In addition, routines developed in assembly can also be called.
668 \newline
669
670 \newline
671 SDCC also
672  provides an option (-
673 \begin_inset ERT
674 status collapsed
675
676 \begin_layout Standard
677
678
679 \backslash
680 /
681 \end_layout
682
683 \end_inset
684
685 -cyclomatic) to report the relative complexity of a function.
686  These functions can then be further optimized, or hand coded in assembly
687  if needed.
688  
689 \newline
690
691 \newline
692 SDCC also comes with a companion source level debugger SDCDB.
693  The debugger currently uses ucSim, a free open source simulator for 8051
694  and other micro-controllers.
695 \newline
696
697 \newline
698 The latest SDCC version can be downloaded from
699  
700 \begin_inset LatexCommand url
701 target "http://sdcc.sourceforge.net/snap.php"
702
703 \end_inset
704
705 .
706  
707 \emph on
708 Please note: the compiler will probably always be some steps ahead of this
709  documentation
710 \series bold
711 \emph default
712
713 \begin_inset LatexCommand index
714 name "Status of documentation"
715
716 \end_inset
717
718
719 \begin_inset Foot
720 status open
721
722 \begin_layout Standard
723 Obviously this has pros and cons
724 \end_layout
725
726 \end_inset
727
728 .
729 \end_layout
730
731 \begin_layout Section
732 Open Source
733 \end_layout
734
735 \begin_layout Standard
736 All packages used in this compiler system are 
737 \emph on
738 open source
739 \emph default
740  and 
741 \emph on
742 freeware
743 \emph default
744 ; source code for all the sub-packages (pre-processor, assemblers, linkers
745  etc.) is distributed with the package.
746  This documentation is maintained using a free open source word processor
747  (LyX).
748 \newline
749 This program is free software; you can redistribute it and/or modify
750  it under the terms of the GNU General Public License
751 \begin_inset LatexCommand index
752 name "GNU General Public License, GPL"
753
754 \end_inset
755
756  as published by the Free Software Foundation; either version 2, or (at
757  your option) any later version.
758  This program is distributed in the hope that it will be useful, but WITHOUT
759  ANY WARRANTY; without even the implied warranty
760 \begin_inset LatexCommand index
761 name "warranty"
762
763 \end_inset
764
765  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
766  See the GNU General Public License for more details.
767  You should have received a copy of the GNU General Public License along
768  with this program; if not, write to the Free Software Foundation, 59 Temple
769  Place - Suite 330, Boston, MA 02111-1307, USA.
770  In other words, you are welcome to use, share and improve this program.
771  You are forbidden to forbid anyone else to use, share and improve what
772  you give them.
773  Help stamp out software-hoarding! 
774 \end_layout
775
776 \begin_layout Section
777 Typographic conventions
778 \begin_inset LatexCommand index
779 name "Typographic conventions"
780
781 \end_inset
782
783
784 \end_layout
785
786 \begin_layout Standard
787 Throughout this manual, we will use the following convention.
788  Commands you have to type in are printed in 
789 \family sans
790 \series bold
791 "sans serif"
792 \series default
793 .
794
795 \family default
796  Code samples are printed in 
797 \family typewriter
798 typewriter font.
799
800 \family default
801  Interesting items and new terms are printed in 
802 \emph on
803 italic.
804 \end_layout
805
806 \begin_layout Section
807 Compatibility
808 \begin_inset LatexCommand label
809 name "sec:Compatibility-with-previous"
810
811 \end_inset
812
813  with previous versions
814 \begin_inset LatexCommand index
815 name "Compatibility with previous versions"
816
817 \end_inset
818
819
820 \end_layout
821
822 \begin_layout Standard
823 Newer versions have usually numerous bug fixes compared with the previous
824  version.
825  But we also sometimes introduce some incompatibilities with older versions.
826  Not just for the fun of it, but to make the compiler more stable, efficient
827  and ANSI compliant
828 \begin_inset LatexCommand index
829 name "ANSI-compliance"
830
831 \end_inset
832
833  (see section 
834 \begin_inset LatexCommand ref
835 reference "sub:ANSI-Compliance"
836
837 \end_inset
838
839  for ANSI-Compliance).
840  
841 \begin_inset Note Note
842 status collapsed
843
844 \begin_layout Standard
845 It would be fine to add to each item, in which version was it changed.
846 \end_layout
847
848 \end_inset
849
850
851 \newline
852
853 \end_layout
854
855 \begin_layout Itemize
856 short is now equivalent to int (16 bits), it used to be equivalent to char
857  (8 bits) which is not ANSI compliant.
858  To maintain compatibility, old programs may be compiled using the -
859 \begin_inset ERT
860 status collapsed
861
862 \begin_layout Standard
863
864
865 \backslash
866 /
867 \end_layout
868
869 \end_inset
870
871 -short-is-8bits commandline option (see 
872 \begin_inset LatexCommand vref
873 reference "lyx:--short-is-8bits"
874
875 \end_inset
876
877 ).
878 \end_layout
879
880 \begin_layout Itemize
881 the default directory for gcc-builds where include, library and documentation
882  files are stored is now in /usr/local/share.
883 \end_layout
884
885 \begin_layout Itemize
886 char type parameters to vararg
887 \begin_inset LatexCommand index
888 name "vararg, va\\_arg"
889
890 \end_inset
891
892  functions are casted to int unless explicitly casted and 
893 \series bold
894 -
895 \begin_inset ERT
896 status collapsed
897
898 \begin_layout Standard
899
900
901 \backslash
902 /
903 \end_layout
904
905 \end_inset
906
907 -std-c89
908 \begin_inset LatexCommand index
909 name "-\\/-std-c89"
910
911 \end_inset
912
913
914 \series default
915  and 
916 \series bold
917 -
918 \begin_inset ERT
919 status collapsed
920
921 \begin_layout Standard
922
923
924 \backslash
925 /
926 \end_layout
927
928 \end_inset
929
930 -std-c99
931 \begin_inset LatexCommand index
932 name "-\\/-std-c99"
933
934 \end_inset
935
936
937 \series default
938  command line option are not defined 
939 \begin_inset Marginal
940 status collapsed
941
942 \begin_layout Standard
943
944 \series bold
945 \InsetSpace ~
946 !
947 \end_layout
948
949 \end_inset
950
951 , e.g.: 
952 \newline
953
954 \family typewriter
955 \InsetSpace ~
956 \InsetSpace ~
957 char a=3;
958 \newline
959 \InsetSpace ~
960 \InsetSpace ~
961 printf ("%d %c
962 \backslash
963 n", a, (char)a);
964 \family default
965
966 \newline
967  will push a as an int and as a char resp if 
968 \series bold
969 -
970 \begin_inset ERT
971 status collapsed
972
973 \begin_layout Standard
974
975
976 \backslash
977 /
978 \end_layout
979
980 \end_inset
981
982 -std-c89
983 \begin_inset LatexCommand index
984 name "-\\/-std-c89"
985
986 \end_inset
987
988
989 \series default
990  and 
991 \series bold
992 -
993 \begin_inset ERT
994 status collapsed
995
996 \begin_layout Standard
997
998
999 \backslash
1000 /
1001 \end_layout
1002
1003 \end_inset
1004
1005 -std-c99
1006 \begin_inset LatexCommand index
1007 name "-\\/-std-c99"
1008
1009 \end_inset
1010
1011
1012 \series default
1013  command line options are not defined,
1014 \newline
1015  will push a as two ints if 
1016 \series bold
1017 -
1018 \begin_inset ERT
1019 status collapsed
1020
1021 \begin_layout Standard
1022
1023
1024 \backslash
1025 /
1026 \end_layout
1027
1028 \end_inset
1029
1030 -std-c89
1031 \begin_inset LatexCommand index
1032 name "-\\/-std-c89"
1033
1034 \end_inset
1035
1036
1037 \series default
1038  or 
1039 \series bold
1040 -
1041 \begin_inset ERT
1042 status collapsed
1043
1044 \begin_layout Standard
1045
1046
1047 \backslash
1048 /
1049 \end_layout
1050
1051 \end_inset
1052
1053 -std-c99
1054 \begin_inset LatexCommand index
1055 name "-\\/-std-c99"
1056
1057 \end_inset
1058
1059
1060 \series default
1061  command line option is defined.
1062 \end_layout
1063
1064 \begin_layout Itemize
1065 option -
1066 \begin_inset ERT
1067 status collapsed
1068
1069 \begin_layout Standard
1070
1071
1072 \backslash
1073 /
1074 \end_layout
1075
1076 \end_inset
1077
1078 -regextend has been removed.
1079 \end_layout
1080
1081 \begin_layout Itemize
1082 option -
1083 \begin_inset ERT
1084 status collapsed
1085
1086 \begin_layout Standard
1087
1088
1089 \backslash
1090 /
1091 \end_layout
1092
1093 \end_inset
1094
1095 -noregparms has been removed.
1096 \end_layout
1097
1098 \begin_layout Itemize
1099 option -
1100 \begin_inset ERT
1101 status collapsed
1102
1103 \begin_layout Standard
1104
1105
1106 \backslash
1107 /
1108 \end_layout
1109
1110 \end_inset
1111
1112 -stack-after-data has been removed.
1113 \end_layout
1114
1115 \begin_layout Itemize
1116 bit
1117 \begin_inset LatexCommand index
1118 name "bit"
1119
1120 \end_inset
1121
1122  and sbit
1123 \begin_inset LatexCommand index
1124 name "sbit"
1125
1126 \end_inset
1127
1128
1129 \begin_inset LatexCommand index
1130 name "\\_\\_sbit"
1131
1132 \end_inset
1133
1134  types now consistently behave like the C99 _Bool type with respect to type
1135  conversion
1136 \begin_inset LatexCommand index
1137 name "type conversion"
1138
1139 \end_inset
1140
1141
1142 \begin_inset LatexCommand index
1143 name "type promotion"
1144
1145 \end_inset
1146
1147 .
1148  The most common incompatibility resulting from this change is related to
1149  bit toggling
1150 \begin_inset LatexCommand index
1151 name "Bit toggling"
1152
1153 \end_inset
1154
1155  idioms, e.g.:
1156 \newline
1157
1158 \family typewriter
1159 \InsetSpace ~
1160 \InsetSpace ~
1161 bit b;
1162 \newline
1163 \InsetSpace ~
1164 \InsetSpace ~
1165 b = ~
1166 \begin_inset LatexCommand index
1167 name "\\~\\/ Operator"
1168
1169 \end_inset
1170
1171 b; /* equivalent to b=1 instead of toggling b */
1172 \begin_inset Marginal
1173 status collapsed
1174
1175 \begin_layout Standard
1176
1177 \series bold
1178 \InsetSpace ~
1179 !
1180 \end_layout
1181
1182 \end_inset
1183
1184
1185 \newline
1186 \InsetSpace ~
1187 \InsetSpace ~
1188 b = !b; /* toggles b */
1189 \newline
1190
1191 \family default
1192 In previous versions, both forms would have toggled the bit.
1193 \end_layout
1194
1195 \begin_layout Itemize
1196 in older versions, the preprocessor was always called with 
1197 \series bold
1198 -
1199 \begin_inset ERT
1200 status collapsed
1201
1202 \begin_layout Standard
1203
1204
1205 \backslash
1206 /
1207 \end_layout
1208
1209 \end_inset
1210
1211 -std-c99
1212 \begin_inset LatexCommand index
1213 name "-\\/-std-c99"
1214
1215 \end_inset
1216
1217
1218 \series default
1219  regardless of the 
1220 \series bold
1221 -
1222 \begin_inset ERT
1223 status collapsed
1224
1225 \begin_layout Standard
1226
1227
1228 \backslash
1229 /
1230 \end_layout
1231
1232 \end_inset
1233
1234 -std-xxx
1235 \series default
1236  setting.
1237  This is no longer true, and can cause compilation failures on code built
1238  with 
1239 \series bold
1240 -
1241 \begin_inset ERT
1242 status collapsed
1243
1244 \begin_layout Standard
1245
1246
1247 \backslash
1248 /
1249 \end_layout
1250
1251 \end_inset
1252
1253 -std-c89
1254 \begin_inset LatexCommand index
1255 name "-\\/-std-c89"
1256
1257 \end_inset
1258
1259
1260 \series default
1261  but using c99 preprocessor features, such as one-line (//) comments
1262 \end_layout
1263
1264 \begin_layout Itemize
1265 in versions older then 2.8.4 the pic16 *printf() and printf_tiny() library
1266  functions supported undocumented and not standard compliant 'b' binary
1267  format specifier ("%b", "%hb" and "%lb").
1268  The 'b' specifier is now disabled by default.
1269  It can be enabled by defining BINARY_SPECIFIER macro in files device/lib/pic16/
1270 libc/stdio/vfprintf.c and device/lib/pic16/libc/stdio/printf_tiny.c and recompilin
1271 g the library.
1272 \end_layout
1273
1274 \begin_layout Itemize
1275 in versions older then 2.8.5 the unnamed bitfield structure members participated
1276  in initialization, which is not conforming with ISO/IEC 9899:1999 standard
1277  (see section Section 6.7.8 Initialization, clause 9)
1278 \newline
1279
1280 \newline
1281 Old behavior, before
1282  version 2.8.5:
1283 \family typewriter
1284
1285 \newline
1286 \InsetSpace ~
1287 \InsetSpace ~
1288 struct {
1289 \newline
1290 \InsetSpace ~
1291 \InsetSpace ~
1292 \InsetSpace ~
1293 \InsetSpace ~
1294 int a : 2;
1295 \newline
1296 \InsetSpace ~
1297 \InsetSpace ~
1298 \InsetSpace ~
1299 \InsetSpace ~
1300 char\InsetSpace ~
1301  : 2;
1302 \newline
1303 \InsetSpace ~
1304 \InsetSpace ~
1305 \InsetSpace ~
1306 \InsetSpace ~
1307 int b : 2;
1308 \newline
1309 \InsetSpace ~
1310 \InsetSpace ~
1311 } s = {1, 2, 3};
1312 \family default
1313
1314 \newline
1315
1316 \family typewriter
1317 /* s.a = 1, s.b = 3 */
1318 \family default
1319
1320 \newline
1321
1322 \newline
1323 New behavior:
1324 \family typewriter
1325
1326 \newline
1327 \InsetSpace ~
1328 \InsetSpace ~
1329 struct {
1330 \newline
1331 \InsetSpace ~
1332 \InsetSpace ~
1333 \InsetSpace ~
1334 \InsetSpace ~
1335 int a : 2;
1336 \newline
1337 \InsetSpace ~
1338 \InsetSpace ~
1339 \InsetSpace ~
1340 \InsetSpace ~
1341 char\InsetSpace ~
1342  : 2;
1343 \newline
1344 \InsetSpace ~
1345 \InsetSpace ~
1346 \InsetSpace ~
1347 \InsetSpace ~
1348 int b : 2;
1349 \newline
1350 \InsetSpace ~
1351 \InsetSpace ~
1352 } s = {1, 2};
1353 \family default
1354
1355 \newline
1356
1357 \family typewriter
1358 /* s.a = 1, s.b = 2 */
1359 \end_layout
1360
1361 \begin_layout Section
1362 System Requirements
1363 \end_layout
1364
1365 \begin_layout Standard
1366 What do you need before you start installation of SDCC? A computer, and
1367  a desire to compute.
1368  The preferred method of installation is to compile SDCC from source using
1369  GNU gcc and make.
1370  For Windows some pre-compiled binary distributions are available for your
1371  convenience.
1372  You should have some experience with command line tools and compiler use.
1373 \end_layout
1374
1375 \begin_layout Section
1376 Other Resources
1377 \end_layout
1378
1379 \begin_layout Standard
1380 The SDCC home page at 
1381 \begin_inset LatexCommand url
1382 target "http://sdcc.sourceforge.net/"
1383
1384 \end_inset
1385
1386  is a great place to find distribution sets.
1387  You can also find links to the user mailing lists that offer help or discuss
1388  SDCC with other SDCC users.
1389  Web links to other SDCC related sites can also be found here.
1390  This document can be found in the DOC directory of the source package as
1391  a text or HTML file.
1392  A pdf version of this document is available at 
1393 \begin_inset LatexCommand url
1394 target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
1395
1396 \end_inset
1397
1398 .
1399  Some of the other tools (simulator and assembler) included with SDCC contain
1400  their own documentation and can be found in the source distribution.
1401  If you want the latest unreleased software, the complete source package
1402  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1403 sdcc/trunk/sdcc.
1404 \end_layout
1405
1406 \begin_layout Section
1407 Wishes for the future
1408 \end_layout
1409
1410 \begin_layout Standard
1411 There are (and always will be) some things that could be done.
1412  Here are some I can think of:
1413 \newline
1414
1415 \end_layout
1416
1417 \begin_layout Standard
1418
1419 \family typewriter
1420 char KernelFunction3(char p) at 0x340;
1421 \newline
1422
1423 \end_layout
1424
1425 \begin_layout Standard
1426
1427 \family typewriter
1428 better code banking
1429 \begin_inset LatexCommand index
1430 name "code banking (limited support)"
1431
1432 \end_inset
1433
1434  support for mcs51
1435 \newline
1436
1437 \newline
1438
1439 \family default
1440 If you can think of some more, please see the section 
1441 \begin_inset LatexCommand ref
1442 reference "sub:Requesting-Features"
1443
1444 \end_inset
1445
1446  about filing feature requests
1447 \begin_inset LatexCommand index
1448 name "Requesting features"
1449
1450 \end_inset
1451
1452
1453 \begin_inset LatexCommand index
1454 name "Feature request"
1455
1456 \end_inset
1457
1458 .
1459 \newline
1460
1461 \end_layout
1462
1463 \begin_layout Chapter
1464 Installing SDCC
1465 \begin_inset LatexCommand index
1466 name "Installation"
1467
1468 \end_inset
1469
1470
1471 \end_layout
1472
1473 \begin_layout Standard
1474 For most users it is sufficient to skip to either section 
1475 \begin_inset LatexCommand ref
1476 reference "sub:Building-SDCC-on-Linux"
1477
1478 \end_inset
1479
1480  (Unix) or section 
1481 \begin_inset LatexCommand ref
1482 reference "sub:Windows-Install"
1483
1484 \end_inset
1485
1486  (Windows).
1487  More detailed instructions follow below.
1488 \end_layout
1489
1490 \begin_layout Section
1491 Configure Options
1492 \begin_inset LatexCommand index
1493 name "Options SDCC configuration"
1494
1495 \end_inset
1496
1497
1498 \end_layout
1499
1500 \begin_layout Standard
1501 The install paths, search paths and other options are defined when running
1502  'configure'.
1503  The defaults can be overridden by:
1504 \end_layout
1505
1506 \begin_layout List
1507 \labelwidthstring 00.00.0000
1508 -
1509 \begin_inset ERT
1510 status collapsed
1511
1512 \begin_layout Standard
1513
1514
1515 \backslash
1516 /
1517 \end_layout
1518
1519 \end_inset
1520
1521 -prefix see table below
1522 \end_layout
1523
1524 \begin_layout List
1525 \labelwidthstring 00.00.0000
1526 -
1527 \begin_inset ERT
1528 status collapsed
1529
1530 \begin_layout Standard
1531
1532
1533 \backslash
1534 /
1535 \end_layout
1536
1537 \end_inset
1538
1539 -exec_prefix see table below
1540 \end_layout
1541
1542 \begin_layout List
1543 \labelwidthstring 00.00.0000
1544 -
1545 \begin_inset ERT
1546 status collapsed
1547
1548 \begin_layout Standard
1549
1550
1551 \backslash
1552 /
1553 \end_layout
1554
1555 \end_inset
1556
1557 -bindir see table below
1558 \end_layout
1559
1560 \begin_layout List
1561 \labelwidthstring 00.00.0000
1562 -
1563 \begin_inset ERT
1564 status collapsed
1565
1566 \begin_layout Standard
1567
1568
1569 \backslash
1570 /
1571 \end_layout
1572
1573 \end_inset
1574
1575 -datadir see table below
1576 \end_layout
1577
1578 \begin_layout List
1579 \labelwidthstring 00.00.0000
1580 -
1581 \begin_inset ERT
1582 status collapsed
1583
1584 \begin_layout Standard
1585
1586
1587 \backslash
1588 /
1589 \end_layout
1590
1591 \end_inset
1592
1593 -datarootdir see table below
1594 \newline
1595
1596 \end_layout
1597
1598 \begin_layout List
1599 \labelwidthstring 00.00.0000
1600 \InsetSpace ~
1601 \InsetSpace ~
1602 docdir environment variable, see table below
1603 \end_layout
1604
1605 \begin_layout List
1606 \labelwidthstring 00.00.0000
1607 \InsetSpace ~
1608 \InsetSpace ~
1609 include_dir_suffix environment variable, see table below
1610 \end_layout
1611
1612 \begin_layout List
1613 \labelwidthstring 00.00.0000
1614 \InsetSpace ~
1615 \InsetSpace ~
1616 lib_dir_suffix environment variable, see table below
1617 \end_layout
1618
1619 \begin_layout List
1620 \labelwidthstring 00.00.0000
1621 \InsetSpace ~
1622 \InsetSpace ~
1623 sdccconf_h_dir_separator environment variable, either / or 
1624 \backslash
1625
1626 \backslash
1627  makes sense here.
1628  This character will only be used in sdccconf.h; don't forget it's a C-header,
1629  therefore a double-backslash is needed there.
1630 \newline
1631
1632 \end_layout
1633
1634 \begin_layout List
1635 \labelwidthstring 00.00.0000
1636 -
1637 \begin_inset ERT
1638 status collapsed
1639
1640 \begin_layout Standard
1641
1642
1643 \backslash
1644 /
1645 \end_layout
1646
1647 \end_inset
1648
1649 -disable-mcs51-port Excludes the Intel mcs51 port
1650 \end_layout
1651
1652 \begin_layout List
1653 \labelwidthstring 00.00.0000
1654 -
1655 \begin_inset ERT
1656 status collapsed
1657
1658 \begin_layout Standard
1659
1660
1661 \backslash
1662 /
1663 \end_layout
1664
1665 \end_inset
1666
1667 -disable-gbz80-port Excludes the Gameboy gbz80 port
1668 \end_layout
1669
1670 \begin_layout List
1671 \labelwidthstring 00.00.0000
1672 -
1673 \begin_inset ERT
1674 status collapsed
1675
1676 \begin_layout Standard
1677
1678
1679 \backslash
1680 /
1681 \end_layout
1682
1683 \end_inset
1684
1685 -disable-z80-port Excludes the z80 port
1686 \end_layout
1687
1688 \begin_layout List
1689 \labelwidthstring 00.00.0000
1690 -
1691 \begin_inset ERT
1692 status collapsed
1693
1694 \begin_layout Standard
1695
1696
1697 \backslash
1698 /
1699 \end_layout
1700
1701 \end_inset
1702
1703 -disable-avr-port Excludes the AVR port
1704 \end_layout
1705
1706 \begin_layout List
1707 \labelwidthstring 00.00.0000
1708 -
1709 \begin_inset ERT
1710 status collapsed
1711
1712 \begin_layout Standard
1713
1714
1715 \backslash
1716 /
1717 \end_layout
1718
1719 \end_inset
1720
1721 -disable-ds390-port Excludes the DS390 port
1722 \end_layout
1723
1724 \begin_layout List
1725 \labelwidthstring 00.00.0000
1726 -
1727 \begin_inset ERT
1728 status collapsed
1729
1730 \begin_layout Standard
1731
1732
1733 \backslash
1734 /
1735 \end_layout
1736
1737 \end_inset
1738
1739 -disable-hc08-port Excludes the HC08 port
1740 \end_layout
1741
1742 \begin_layout List
1743 \labelwidthstring 00.00.0000
1744 -
1745 \begin_inset ERT
1746 status collapsed
1747
1748 \begin_layout Standard
1749
1750
1751 \backslash
1752 /
1753 \end_layout
1754
1755 \end_inset
1756
1757 -disable-pic-port Excludes the PIC14 port
1758 \end_layout
1759
1760 \begin_layout List
1761 \labelwidthstring 00.00.0000
1762 -
1763 \begin_inset ERT
1764 status collapsed
1765
1766 \begin_layout Standard
1767
1768
1769 \backslash
1770 /
1771 \end_layout
1772
1773 \end_inset
1774
1775 -disable-pic16-port Excludes the PIC16 port
1776 \end_layout
1777
1778 \begin_layout List
1779 \labelwidthstring 00.00.0000
1780 -
1781 \begin_inset ERT
1782 status collapsed
1783
1784 \begin_layout Standard
1785
1786
1787 \backslash
1788 /
1789 \end_layout
1790
1791 \end_inset
1792
1793 -disable-xa51-port Excludes the XA51 port
1794 \end_layout
1795
1796 \begin_layout List
1797 \labelwidthstring 00.00.0000
1798 -
1799 \begin_inset ERT
1800 status collapsed
1801
1802 \begin_layout Standard
1803
1804
1805 \backslash
1806 /
1807 \end_layout
1808
1809 \end_inset
1810
1811 -disable-ucsim Disables configuring and building of ucsim
1812 \end_layout
1813
1814 \begin_layout List
1815 \labelwidthstring 00.00.0000
1816 -
1817 \begin_inset ERT
1818 status collapsed
1819
1820 \begin_layout Standard
1821
1822
1823 \backslash
1824 /
1825 \end_layout
1826
1827 \end_inset
1828
1829 -disable-device-lib Disables automatically building device libraries
1830 \end_layout
1831
1832 \begin_layout List
1833 \labelwidthstring 00.00.0000
1834 -
1835 \begin_inset ERT
1836 status collapsed
1837
1838 \begin_layout Standard
1839
1840
1841 \backslash
1842 /
1843 \end_layout
1844
1845 \end_inset
1846
1847 -disable-packihx Disables building packihx
1848 \newline
1849
1850 \end_layout
1851
1852 \begin_layout List
1853 \labelwidthstring 00.00.0000
1854 -
1855 \begin_inset ERT
1856 status collapsed
1857
1858 \begin_layout Standard
1859
1860
1861 \backslash
1862 /
1863 \end_layout
1864
1865 \end_inset
1866
1867 -enable-doc Build pdf, html and txt files from the lyx sources
1868 \end_layout
1869
1870 \begin_layout List
1871 \labelwidthstring 00.00.0000
1872 -
1873 \begin_inset ERT
1874 status collapsed
1875
1876 \begin_layout Standard
1877
1878
1879 \backslash
1880 /
1881 \end_layout
1882
1883 \end_inset
1884
1885 -enable-libgc Use the Bohem memory allocator.
1886  Lower runtime footprint.
1887 \end_layout
1888
1889 \begin_layout List
1890 \labelwidthstring 00.00.0000
1891 -
1892 \begin_inset ERT
1893 status collapsed
1894
1895 \begin_layout Standard
1896
1897
1898 \backslash
1899 /
1900 \end_layout
1901
1902 \end_inset
1903
1904 -without-ccache Do not use ccache even if available
1905 \end_layout
1906
1907 \begin_layout Standard
1908 Furthermore the environment variables CC, CFLAGS, ...
1909  the tools and their arguments can be influenced.
1910  Please see `configure -
1911 \begin_inset ERT
1912 status collapsed
1913
1914 \begin_layout Standard
1915
1916
1917 \backslash
1918 /
1919 \end_layout
1920
1921 \end_inset
1922
1923 -help' and the man/info pages of `configure' for details.
1924 \newline
1925
1926 \newline
1927 The names of the
1928  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1929 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1930  SDCC_LIB_NAME are defined by `configure' too.
1931  At the moment it's not possible to change the default settings (it was
1932  simply never required).
1933 \newline
1934
1935 \newline
1936 These configure options are compiled into the binaries,
1937  and can only be changed by rerunning 'configure' and recompiling SDCC.
1938  The configure options are written in 
1939 \emph on
1940 italics
1941 \emph default
1942  to distinguish them from run time environment variables (see section search
1943  paths).
1944 \newline
1945
1946 \newline
1947 The settings for 
1948 \begin_inset Quotes sld
1949 \end_inset
1950
1951 Win32 builds
1952 \begin_inset Quotes srd
1953 \end_inset
1954
1955  are used by the SDCC team to build the official Win32 binaries.
1956  The SDCC team uses Mingw32 to build the official Windows binaries, because
1957  it's
1958 \end_layout
1959
1960 \begin_layout Enumerate
1961 open source, 
1962 \end_layout
1963
1964 \begin_layout Enumerate
1965 a gcc compiler and last but not least
1966 \end_layout
1967
1968 \begin_layout Enumerate
1969 the binaries can be built by cross compiling on SDCC Distributed Compile
1970  Farm.
1971 \end_layout
1972
1973 \begin_layout Standard
1974 See the examples, how to pass the Win32 settings to 'configure'.
1975  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1976  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1977  for Win32.
1978 \newline
1979
1980 \newline
1981 These defaults are:
1982 \newline
1983
1984 \end_layout
1985
1986 \begin_layout Standard
1987 \align center
1988 \begin_inset Tabular
1989 <lyxtabular version="3" rows="9" columns="3">
1990 <features>
1991 <column alignment="block" valignment="top" leftline="true" width="0in">
1992 <column alignment="block" valignment="top" leftline="true" width="0in">
1993 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1994 <row topline="true" bottomline="true">
1995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1996 \begin_inset Text
1997
1998 \begin_layout Standard
1999 Variable
2000 \end_layout
2001
2002 \end_inset
2003 </cell>
2004 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2005 \begin_inset Text
2006
2007 \begin_layout Standard
2008 default
2009 \end_layout
2010
2011 \end_inset
2012 </cell>
2013 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2014 \begin_inset Text
2015
2016 \begin_layout Standard
2017 Win32 builds
2018 \end_layout
2019
2020 \end_inset
2021 </cell>
2022 </row>
2023 <row topline="true">
2024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2025 \begin_inset Text
2026
2027 \begin_layout Standard
2028
2029 \emph on
2030 PREFIX
2031 \end_layout
2032
2033 \end_inset
2034 </cell>
2035 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2036 \begin_inset Text
2037
2038 \begin_layout Standard
2039 /usr/local
2040 \end_layout
2041
2042 \end_inset
2043 </cell>
2044 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2045 \begin_inset Text
2046
2047 \begin_layout Standard
2048
2049 \backslash
2050 sdcc
2051 \end_layout
2052
2053 \end_inset
2054 </cell>
2055 </row>
2056 <row topline="true">
2057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2058 \begin_inset Text
2059
2060 \begin_layout Standard
2061
2062 \emph on
2063 EXEC_PREFIX
2064 \end_layout
2065
2066 \end_inset
2067 </cell>
2068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2069 \begin_inset Text
2070
2071 \begin_layout Standard
2072
2073 \emph on
2074 $PREFIX
2075 \end_layout
2076
2077 \end_inset
2078 </cell>
2079 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2080 \begin_inset Text
2081
2082 \begin_layout Standard
2083
2084 \emph on
2085 $PREFIX
2086 \end_layout
2087
2088 \end_inset
2089 </cell>
2090 </row>
2091 <row topline="true">
2092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2093 \begin_inset Text
2094
2095 \begin_layout Standard
2096
2097 \emph on
2098 BINDIR
2099 \end_layout
2100
2101 \end_inset
2102 </cell>
2103 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2104 \begin_inset Text
2105
2106 \begin_layout Standard
2107
2108 \emph on
2109 $EXEC_PREFIX
2110 \emph default
2111 /bin
2112 \end_layout
2113
2114 \end_inset
2115 </cell>
2116 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2117 \begin_inset Text
2118
2119 \begin_layout Standard
2120
2121 \emph on
2122 $EXEC_PREFIX
2123 \emph default
2124
2125 \backslash
2126 bin
2127 \end_layout
2128
2129 \end_inset
2130 </cell>
2131 </row>
2132 <row topline="true">
2133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2134 \begin_inset Text
2135
2136 \begin_layout Standard
2137
2138 \emph on
2139 DATADIR
2140 \end_layout
2141
2142 \end_inset
2143 </cell>
2144 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2145 \begin_inset Text
2146
2147 \begin_layout Standard
2148
2149 \emph on
2150 $DATAROOTDIR
2151 \end_layout
2152
2153 \end_inset
2154 </cell>
2155 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2156 \begin_inset Text
2157
2158 \begin_layout Standard
2159
2160 \emph on
2161 $DATAROOTDIR
2162 \end_layout
2163
2164 \end_inset
2165 </cell>
2166 </row>
2167 <row topline="true">
2168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2169 \begin_inset Text
2170
2171 \begin_layout Standard
2172
2173 \emph on
2174 DATAROOTDIR
2175 \end_layout
2176
2177 \end_inset
2178 </cell>
2179 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2180 \begin_inset Text
2181
2182 \begin_layout Standard
2183
2184 \emph on
2185 $PREFIX
2186 \emph default
2187 /share
2188 \end_layout
2189
2190 \end_inset
2191 </cell>
2192 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2193 \begin_inset Text
2194
2195 \begin_layout Standard
2196
2197 \emph on
2198 $PREFIX
2199 \end_layout
2200
2201 \end_inset
2202 </cell>
2203 </row>
2204 <row topline="true">
2205 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2206 \begin_inset Text
2207
2208 \begin_layout Standard
2209
2210 \emph on
2211 DOCDIR
2212 \end_layout
2213
2214 \end_inset
2215 </cell>
2216 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2217 \begin_inset Text
2218
2219 \begin_layout Standard
2220
2221 \emph on
2222 $DATAROOTDIR
2223 \emph default
2224 /sdcc/doc
2225 \end_layout
2226
2227 \end_inset
2228 </cell>
2229 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2230 \begin_inset Text
2231
2232 \begin_layout Standard
2233
2234 \emph on
2235 $DATAROOTDIR
2236 \emph default
2237
2238 \backslash
2239 doc
2240 \end_layout
2241
2242 \end_inset
2243 </cell>
2244 </row>
2245 <row topline="true">
2246 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2247 \begin_inset Text
2248
2249 \begin_layout Standard
2250
2251 \emph on
2252 INCLUDE_DIR_SUFFIX
2253 \end_layout
2254
2255 \end_inset
2256 </cell>
2257 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2258 \begin_inset Text
2259
2260 \begin_layout Standard
2261 sdcc/include
2262 \end_layout
2263
2264 \end_inset
2265 </cell>
2266 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2267 \begin_inset Text
2268
2269 \begin_layout Standard
2270 include
2271 \end_layout
2272
2273 \end_inset
2274 </cell>
2275 </row>
2276 <row topline="true" bottomline="true">
2277 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2278 \begin_inset Text
2279
2280 \begin_layout Standard
2281
2282 \emph on
2283 LIB_DIR_SUFFIX
2284 \end_layout
2285
2286 \end_inset
2287 </cell>
2288 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2289 \begin_inset Text
2290
2291 \begin_layout Standard
2292 sdcc/lib
2293 \end_layout
2294
2295 \end_inset
2296 </cell>
2297 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2298 \begin_inset Text
2299
2300 \begin_layout Standard
2301 lib
2302 \end_layout
2303
2304 \end_inset
2305 </cell>
2306 </row>
2307 </lyxtabular>
2308
2309 \end_inset
2310
2311
2312 \newline
2313
2314 \end_layout
2315
2316 \begin_layout Standard
2317 \noindent
2318 'configure' also computes relative paths.
2319  This is needed for full relocatability of a binary package and to complete
2320  search paths (see section search paths below):
2321 \newline
2322  
2323 \end_layout
2324
2325 \begin_layout Standard
2326 \align center
2327 \begin_inset Tabular
2328 <lyxtabular version="3" rows="4" columns="3">
2329 <features>
2330 <column alignment="block" valignment="top" leftline="true" width="0in">
2331 <column alignment="block" valignment="top" leftline="true" width="0in">
2332 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2333 <row topline="true" bottomline="true">
2334 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2335 \begin_inset Text
2336
2337 \begin_layout Standard
2338 Variable (computed)
2339 \end_layout
2340
2341 \end_inset
2342 </cell>
2343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2344 \begin_inset Text
2345
2346 \begin_layout Standard
2347 default
2348 \end_layout
2349
2350 \end_inset
2351 </cell>
2352 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2353 \begin_inset Text
2354
2355 \begin_layout Standard
2356 Win32 builds
2357 \end_layout
2358
2359 \end_inset
2360 </cell>
2361 </row>
2362 <row topline="true" bottomline="true">
2363 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2364 \begin_inset Text
2365
2366 \begin_layout Standard
2367
2368 \emph on
2369 BIN2DATA_DIR
2370 \end_layout
2371
2372 \end_inset
2373 </cell>
2374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2375 \begin_inset Text
2376
2377 \begin_layout Standard
2378 ../share
2379 \end_layout
2380
2381 \end_inset
2382 </cell>
2383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2384 \begin_inset Text
2385
2386 \begin_layout Standard
2387 ..
2388 \end_layout
2389
2390 \end_inset
2391 </cell>
2392 </row>
2393 <row bottomline="true">
2394 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2395 \begin_inset Text
2396
2397 \begin_layout Standard
2398
2399 \emph on
2400 PREFIX2BIN_DIR
2401 \end_layout
2402
2403 \end_inset
2404 </cell>
2405 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2406 \begin_inset Text
2407
2408 \begin_layout Standard
2409 bin
2410 \end_layout
2411
2412 \end_inset
2413 </cell>
2414 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2415 \begin_inset Text
2416
2417 \begin_layout Standard
2418 bin
2419 \end_layout
2420
2421 \end_inset
2422 </cell>
2423 </row>
2424 <row bottomline="true">
2425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2426 \begin_inset Text
2427
2428 \begin_layout Standard
2429
2430 \emph on
2431 PREFIX2DATA_DIR
2432 \end_layout
2433
2434 \end_inset
2435 </cell>
2436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2437 \begin_inset Text
2438
2439 \begin_layout Standard
2440 share/sdcc
2441 \end_layout
2442
2443 \end_inset
2444 </cell>
2445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2446 \begin_inset Text
2447
2448 \begin_layout Standard
2449
2450 \end_layout
2451
2452 \end_inset
2453 </cell>
2454 </row>
2455 </lyxtabular>
2456
2457 \end_inset
2458
2459
2460 \newline
2461
2462 \end_layout
2463
2464 \begin_layout Standard
2465 \noindent
2466 Examples:
2467 \end_layout
2468
2469 \begin_layout LyX-Code
2470 ./configure
2471 \newline
2472 ./configure -
2473 \begin_inset ERT
2474 status collapsed
2475
2476 \begin_layout Standard
2477
2478
2479 \backslash
2480 /
2481 \end_layout
2482
2483 \end_inset
2484
2485 -prefix=
2486 \begin_inset Quotes srd
2487 \end_inset
2488
2489 /usr/bin
2490 \begin_inset Quotes srd
2491 \end_inset
2492
2493  -
2494 \begin_inset ERT
2495 status collapsed
2496
2497 \begin_layout Standard
2498
2499
2500 \backslash
2501 /
2502 \end_layout
2503
2504 \end_inset
2505
2506 -datarootdir=
2507 \begin_inset Quotes srd
2508 \end_inset
2509
2510 /usr/share
2511 \begin_inset Quotes srd
2512 \end_inset
2513
2514
2515 \newline
2516 ./configure -
2517 \begin_inset ERT
2518 status collapsed
2519
2520 \begin_layout Standard
2521
2522
2523 \backslash
2524 /
2525 \end_layout
2526
2527 \end_inset
2528
2529 -disable-avr-port -
2530 \begin_inset ERT
2531 status collapsed
2532
2533 \begin_layout Standard
2534
2535
2536 \backslash
2537 /
2538 \end_layout
2539
2540 \end_inset
2541
2542 -disable-xa51-port
2543 \end_layout
2544
2545 \begin_layout Standard
2546 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2547 32'):
2548 \end_layout
2549
2550 \begin_layout LyX-Code
2551 ./configure 
2552 \backslash
2553
2554 \newline
2555 CC=
2556 \begin_inset Quotes srd
2557 \end_inset
2558
2559 i586-mingw32msvc-gcc
2560 \begin_inset Quotes srd
2561 \end_inset
2562
2563  CXX=
2564 \begin_inset Quotes srd
2565 \end_inset
2566
2567 i586-mingw32msvc-g++
2568 \begin_inset Quotes srd
2569 \end_inset
2570
2571  
2572 \backslash
2573  
2574 \newline
2575 RANLIB=
2576 \begin_inset Quotes srd
2577 \end_inset
2578
2579 i586-mingw32msvc-ranlib
2580 \begin_inset Quotes srd
2581 \end_inset
2582
2583  
2584 \backslash
2585
2586 \newline
2587 STRIP=
2588 \begin_inset Quotes srd
2589 \end_inset
2590
2591 i586-mingw32msvc-strip
2592 \begin_inset Quotes srd
2593 \end_inset
2594
2595  
2596 \backslash
2597
2598 \newline
2599 -
2600 \begin_inset ERT
2601 status collapsed
2602
2603 \begin_layout Standard
2604
2605
2606 \backslash
2607 /
2608 \end_layout
2609
2610 \end_inset
2611
2612 -prefix=
2613 \begin_inset Quotes srd
2614 \end_inset
2615
2616 /sdcc
2617 \begin_inset Quotes srd
2618 \end_inset
2619
2620  
2621 \backslash
2622
2623 \newline
2624 -
2625 \begin_inset ERT
2626 status collapsed
2627
2628 \begin_layout Standard
2629
2630
2631 \backslash
2632 /
2633 \end_layout
2634
2635 \end_inset
2636
2637 -datarootdir=
2638 \begin_inset Quotes srd
2639 \end_inset
2640
2641 /sdcc
2642 \begin_inset Quotes srd
2643 \end_inset
2644
2645  
2646 \backslash
2647
2648 \newline
2649 docdir=
2650 \begin_inset Quotes srd
2651 \end_inset
2652
2653
2654 \backslash
2655 ${datarootdir}/doc
2656 \begin_inset Quotes srd
2657 \end_inset
2658
2659  
2660 \backslash
2661
2662 \newline
2663 include_dir_suffix=
2664 \begin_inset Quotes srd
2665 \end_inset
2666
2667 include
2668 \begin_inset Quotes srd
2669 \end_inset
2670
2671  
2672 \backslash
2673
2674 \newline
2675 lib_dir_suffix=
2676 \begin_inset Quotes srd
2677 \end_inset
2678
2679 lib
2680 \begin_inset Quotes srd
2681 \end_inset
2682
2683  
2684 \backslash
2685
2686 \newline
2687 sdccconf_h_dir_separator=
2688 \begin_inset Quotes srd
2689 \end_inset
2690
2691
2692 \backslash
2693
2694 \backslash
2695
2696 \backslash
2697
2698 \backslash
2699
2700 \begin_inset Quotes srd
2701 \end_inset
2702
2703  
2704 \backslash
2705
2706 \newline
2707 -
2708 \begin_inset ERT
2709 status collapsed
2710
2711 \begin_layout Standard
2712
2713
2714 \backslash
2715 /
2716 \end_layout
2717
2718 \end_inset
2719
2720 -disable-device-lib
2721 \backslash
2722
2723 \newline
2724 -
2725 \begin_inset ERT
2726 status collapsed
2727
2728 \begin_layout Standard
2729
2730
2731 \backslash
2732 /
2733 \end_layout
2734
2735 \end_inset
2736
2737 -host=i586-mingw32msvc
2738 \backslash
2739
2740 \newline
2741 -
2742 \begin_inset ERT
2743 status collapsed
2744
2745 \begin_layout Standard
2746
2747
2748 \backslash
2749 /
2750 \end_layout
2751
2752 \end_inset
2753
2754 -build=unknown-unknown-linux-gnu
2755 \end_layout
2756
2757 \begin_layout Standard
2758 To 
2759 \begin_inset Quotes sld
2760 \end_inset
2761
2762 cross
2763 \begin_inset Quotes srd
2764 \end_inset
2765
2766 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2767 ):
2768 \end_layout
2769
2770 \begin_layout LyX-Code
2771 ./configure -C 
2772 \backslash
2773
2774 \newline
2775 -
2776 \begin_inset ERT
2777 status collapsed
2778
2779 \begin_layout Standard
2780
2781
2782 \backslash
2783 /
2784 \end_layout
2785
2786 \end_inset
2787
2788 -prefix=
2789 \begin_inset Quotes srd
2790 \end_inset
2791
2792 /sdcc
2793 \begin_inset Quotes srd
2794 \end_inset
2795
2796  
2797 \backslash
2798
2799 \newline
2800 -
2801 \begin_inset ERT
2802 status collapsed
2803
2804 \begin_layout Standard
2805
2806
2807 \backslash
2808 /
2809 \end_layout
2810
2811 \end_inset
2812
2813 -datarootdir=
2814 \begin_inset Quotes srd
2815 \end_inset
2816
2817 /sdcc
2818 \begin_inset Quotes srd
2819 \end_inset
2820
2821  
2822 \backslash
2823
2824 \newline
2825 docdir=
2826 \begin_inset Quotes srd
2827 \end_inset
2828
2829
2830 \backslash
2831 ${datarootdir}/doc
2832 \begin_inset Quotes srd
2833 \end_inset
2834
2835  
2836 \backslash
2837  
2838 \newline
2839 include_dir_suffix=
2840 \begin_inset Quotes srd
2841 \end_inset
2842
2843 include
2844 \begin_inset Quotes srd
2845 \end_inset
2846
2847  
2848 \backslash
2849
2850 \newline
2851 lib_dir_suffix=
2852 \begin_inset Quotes srd
2853 \end_inset
2854
2855 lib
2856 \begin_inset Quotes srd
2857 \end_inset
2858
2859  
2860 \backslash
2861
2862 \newline
2863 sdccconf_h_dir_separator=
2864 \begin_inset Quotes srd
2865 \end_inset
2866
2867
2868 \backslash
2869
2870 \backslash
2871
2872 \backslash
2873
2874 \backslash
2875
2876 \begin_inset Quotes srd
2877 \end_inset
2878
2879  
2880 \backslash
2881
2882 \newline
2883 CC=
2884 \begin_inset Quotes srd
2885 \end_inset
2886
2887 gcc -mno-cygwin
2888 \begin_inset Quotes srd
2889 \end_inset
2890
2891  
2892 \backslash
2893
2894 \newline
2895 CXX=
2896 \begin_inset Quotes srd
2897 \end_inset
2898
2899 g++ -mno-cygwin
2900 \begin_inset Quotes srd
2901 \end_inset
2902
2903  
2904 \end_layout
2905
2906 \begin_layout Standard
2907 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2908  The option '-
2909 \begin_inset ERT
2910 status collapsed
2911
2912 \begin_layout Standard
2913
2914
2915 \backslash
2916 /
2917 \end_layout
2918
2919 \end_inset
2920
2921 -C' turns on caching, which gives a little bit extra speed.
2922  However if options are changed, it can be necessary to delete the config.cache
2923  file.
2924 \end_layout
2925
2926 \begin_layout Section
2927 Install paths
2928 \begin_inset LatexCommand label
2929 name "sub:Install-paths"
2930
2931 \end_inset
2932
2933
2934 \begin_inset LatexCommand index
2935 name "Install paths"
2936
2937 \end_inset
2938
2939
2940 \end_layout
2941
2942 \begin_layout Standard
2943 \begin_inset VSpace medskip
2944 \end_inset
2945
2946
2947 \end_layout
2948
2949 \begin_layout Standard
2950 \align center
2951 \begin_inset Tabular
2952 <lyxtabular version="3" rows="5" columns="4">
2953 <features>
2954 <column alignment="left" valignment="top" leftline="true" width="0">
2955 <column alignment="left" valignment="top" leftline="true" width="0">
2956 <column alignment="left" valignment="top" leftline="true" width="0">
2957 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2958 <row topline="true" bottomline="true">
2959 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2960 \begin_inset Text
2961
2962 \begin_layout Standard
2963
2964 \series bold
2965 Description
2966 \end_layout
2967
2968 \end_inset
2969 </cell>
2970 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2971 \begin_inset Text
2972
2973 \begin_layout Standard
2974
2975 \series bold
2976 Path
2977 \end_layout
2978
2979 \end_inset
2980 </cell>
2981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2982 \begin_inset Text
2983
2984 \begin_layout Standard
2985
2986 \series bold
2987 Default
2988 \end_layout
2989
2990 \end_inset
2991 </cell>
2992 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2993 \begin_inset Text
2994
2995 \begin_layout Standard
2996
2997 \series bold
2998 Win32 builds
2999 \end_layout
3000
3001 \end_inset
3002 </cell>
3003 </row>
3004 <row topline="true">
3005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3006 \begin_inset Text
3007
3008 \begin_layout Standard
3009 Binary files*
3010 \end_layout
3011
3012 \end_inset
3013 </cell>
3014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3015 \begin_inset Text
3016
3017 \begin_layout Standard
3018
3019 \emph on
3020 $EXEC_PREFIX
3021 \end_layout
3022
3023 \end_inset
3024 </cell>
3025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3026 \begin_inset Text
3027
3028 \begin_layout Standard
3029 /usr/local/bin
3030 \end_layout
3031
3032 \end_inset
3033 </cell>
3034 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3035 \begin_inset Text
3036
3037 \begin_layout Standard
3038
3039 \backslash
3040 sdcc
3041 \backslash
3042 bin
3043 \end_layout
3044
3045 \end_inset
3046 </cell>
3047 </row>
3048 <row topline="true">
3049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3050 \begin_inset Text
3051
3052 \begin_layout Standard
3053 Include files
3054 \end_layout
3055
3056 \end_inset
3057 </cell>
3058 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3059 \begin_inset Text
3060
3061 \begin_layout Standard
3062
3063 \emph on
3064 $DATADIR/ $INCLUDE_DIR_SUFFIX
3065 \end_layout
3066
3067 \end_inset
3068 </cell>
3069 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3070 \begin_inset Text
3071
3072 \begin_layout Standard
3073 /usr/local/share/sdcc/include
3074 \end_layout
3075
3076 \end_inset
3077 </cell>
3078 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3079 \begin_inset Text
3080
3081 \begin_layout Standard
3082
3083 \backslash
3084 sdcc
3085 \backslash
3086 include
3087 \end_layout
3088
3089 \end_inset
3090 </cell>
3091 </row>
3092 <row topline="true">
3093 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3094 \begin_inset Text
3095
3096 \begin_layout Standard
3097 Library file**
3098 \end_layout
3099
3100 \end_inset
3101 </cell>
3102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3103 \begin_inset Text
3104
3105 \begin_layout Standard
3106
3107 \emph on
3108 $DATADIR/$LIB_DIR_SUFFIX
3109 \end_layout
3110
3111 \end_inset
3112 </cell>
3113 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3114 \begin_inset Text
3115
3116 \begin_layout Standard
3117 /usr/local/share/sdcc/lib
3118 \end_layout
3119
3120 \end_inset
3121 </cell>
3122 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3123 \begin_inset Text
3124
3125 \begin_layout Standard
3126
3127 \backslash
3128 sdcc
3129 \backslash
3130 lib
3131 \end_layout
3132
3133 \end_inset
3134 </cell>
3135 </row>
3136 <row topline="true" bottomline="true">
3137 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3138 \begin_inset Text
3139
3140 \begin_layout Standard
3141 Documentation
3142 \end_layout
3143
3144 \end_inset
3145 </cell>
3146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3147 \begin_inset Text
3148
3149 \begin_layout Standard
3150
3151 \emph on
3152 $DOCDIR
3153 \end_layout
3154
3155 \end_inset
3156 </cell>
3157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3158 \begin_inset Text
3159
3160 \begin_layout Standard
3161 /usr/local/share/sdcc/doc
3162 \end_layout
3163
3164 \end_inset
3165 </cell>
3166 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3167 \begin_inset Text
3168
3169 \begin_layout Standard
3170
3171 \backslash
3172 sdcc
3173 \backslash
3174 doc
3175 \end_layout
3176
3177 \end_inset
3178 </cell>
3179 </row>
3180 </lyxtabular>
3181
3182 \end_inset
3183
3184
3185 \end_layout
3186
3187 \begin_layout Verse
3188
3189 \size footnotesize
3190 *compiler, preprocessor, assembler, and linker
3191 \newline
3192 **the 
3193 \shape italic
3194 model
3195 \shape default
3196  is auto-appended by the compiler, e.g.
3197  small, large, z80, ds390 etc
3198 \end_layout
3199
3200 \begin_layout Standard
3201 \noindent
3202 The install paths can still be changed during `make install' with e.g.:
3203 \end_layout
3204
3205 \begin_layout LyX-Code
3206 make install prefix=$(HOME)/local/sdcc
3207 \end_layout
3208
3209 \begin_layout Standard
3210 Of course this doesn't change the search paths compiled into the binaries.
3211 \newline
3212
3213 \newline
3214 Moreove
3215 r the install path can be changed by defining DESTDIR
3216 \begin_inset LatexCommand index
3217 name "DESTDIR"
3218
3219 \end_inset
3220
3221 :
3222 \end_layout
3223
3224 \begin_layout LyX-Code
3225 make install DESTDIR=$(HOME)/sdcc.rpm/
3226 \end_layout
3227
3228 \begin_layout Standard
3229 Please note that DESTDIR must have a trailing slash!
3230 \end_layout
3231
3232 \begin_layout Section
3233 Search Paths
3234 \begin_inset LatexCommand label
3235 name "sub:Search-Paths"
3236
3237 \end_inset
3238
3239
3240 \begin_inset LatexCommand index
3241 name "Search path"
3242
3243 \end_inset
3244
3245
3246 \end_layout
3247
3248 \begin_layout Standard
3249 Some search paths or parts of them are determined by configure variables
3250  (in 
3251 \emph on
3252 italics
3253 \emph default
3254 , see section above).
3255  Further search paths are determined by environment variables during runtime.
3256  
3257 \newline
3258 The paths searched when running the compiler are as follows (the first
3259  catch wins):
3260 \newline
3261
3262 \newline
3263 1.
3264  Binary files (preprocessor, assembler and linker)
3265 \newline
3266
3267 \end_layout
3268
3269 \begin_layout Standard
3270 \align center
3271 \begin_inset Tabular
3272 <lyxtabular version="3" rows="4" columns="3">
3273 <features>
3274 <column alignment="block" valignment="top" leftline="true" width="0in">
3275 <column alignment="block" valignment="top" leftline="true" width="0in">
3276 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3277 <row topline="true" bottomline="true">
3278 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3279 \begin_inset Text
3280
3281 \begin_layout Standard
3282 Search path
3283 \end_layout
3284
3285 \end_inset
3286 </cell>
3287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3288 \begin_inset Text
3289
3290 \begin_layout Standard
3291 default
3292 \end_layout
3293
3294 \end_inset
3295 </cell>
3296 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3297 \begin_inset Text
3298
3299 \begin_layout Standard
3300 Win32 builds
3301 \end_layout
3302
3303 \end_inset
3304 </cell>
3305 </row>
3306 <row topline="true">
3307 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3308 \begin_inset Text
3309
3310 \begin_layout Standard
3311 $SDCC_HOME/
3312 \emph on
3313 $PPREFIX2BIN_DIR
3314 \end_layout
3315
3316 \end_inset
3317 </cell>
3318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3319 \begin_inset Text
3320
3321 \begin_layout Standard
3322 $SDCC_HOME/bin
3323 \end_layout
3324
3325 \end_inset
3326 </cell>
3327 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3328 \begin_inset Text
3329
3330 \begin_layout Standard
3331 $SDCC_HOME
3332 \backslash
3333 bin
3334 \end_layout
3335
3336 \end_inset
3337 </cell>
3338 </row>
3339 <row topline="true">
3340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3341 \begin_inset Text
3342
3343 \begin_layout Standard
3344 Path of argv[0] (if available)
3345 \end_layout
3346
3347 \end_inset
3348 </cell>
3349 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3350 \begin_inset Text
3351
3352 \begin_layout Standard
3353 Path of argv[0]
3354 \end_layout
3355
3356 \end_inset
3357 </cell>
3358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3359 \begin_inset Text
3360
3361 \begin_layout Standard
3362 Path of argv[0]
3363 \end_layout
3364
3365 \end_inset
3366 </cell>
3367 </row>
3368 <row topline="true" bottomline="true">
3369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3370 \begin_inset Text
3371
3372 \begin_layout Standard
3373 $PATH
3374 \end_layout
3375
3376 \end_inset
3377 </cell>
3378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3379 \begin_inset Text
3380
3381 \begin_layout Standard
3382 $PATH
3383 \end_layout
3384
3385 \end_inset
3386 </cell>
3387 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3388 \begin_inset Text
3389
3390 \begin_layout Standard
3391 $PATH
3392 \end_layout
3393
3394 \end_inset
3395 </cell>
3396 </row>
3397 </lyxtabular>
3398
3399 \end_inset
3400
3401  
3402 \newline
3403
3404 \end_layout
3405
3406 \begin_layout Standard
3407 \noindent
3408 2.
3409  Include files
3410 \newline
3411
3412 \end_layout
3413
3414 \begin_layout Standard
3415 \align center
3416 \begin_inset Tabular
3417 <lyxtabular version="3" rows="6" columns="3">
3418 <features>
3419 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3420 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3421 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3422 <row topline="true" bottomline="true">
3423 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3424 \begin_inset Text
3425
3426 \begin_layout Standard
3427 Search path
3428 \end_layout
3429
3430 \end_inset
3431 </cell>
3432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3433 \begin_inset Text
3434
3435 \begin_layout Standard
3436 default
3437 \end_layout
3438
3439 \end_inset
3440 </cell>
3441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3442 \begin_inset Text
3443
3444 \begin_layout Standard
3445 Win32 builds
3446 \end_layout
3447
3448 \end_inset
3449 </cell>
3450 </row>
3451 <row topline="true">
3452 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3453 \begin_inset Text
3454
3455 \begin_layout Standard
3456 -
3457 \begin_inset ERT
3458 status collapsed
3459
3460 \begin_layout Standard
3461
3462
3463 \backslash
3464 /
3465 \end_layout
3466
3467 \end_inset
3468
3469 -I dir
3470 \end_layout
3471
3472 \end_inset
3473 </cell>
3474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3475 \begin_inset Text
3476
3477 \begin_layout Standard
3478 -
3479 \begin_inset ERT
3480 status collapsed
3481
3482 \begin_layout Standard
3483
3484
3485 \backslash
3486 /
3487 \end_layout
3488
3489 \end_inset
3490
3491 -I dir
3492 \end_layout
3493
3494 \end_inset
3495 </cell>
3496 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3497 \begin_inset Text
3498
3499 \begin_layout Standard
3500 -
3501 \begin_inset ERT
3502 status collapsed
3503
3504 \begin_layout Standard
3505
3506
3507 \backslash
3508 /
3509 \end_layout
3510
3511 \end_inset
3512
3513 -I dir
3514 \end_layout
3515
3516 \end_inset
3517 </cell>
3518 </row>
3519 <row topline="true">
3520 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3521 \begin_inset Text
3522
3523 \begin_layout Standard
3524 $SDCC_INCLUDE
3525 \end_layout
3526
3527 \end_inset
3528 </cell>
3529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3530 \begin_inset Text
3531
3532 \begin_layout Standard
3533 $SDCC_INCLUDE
3534 \end_layout
3535
3536 \end_inset
3537 </cell>
3538 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3539 \begin_inset Text
3540
3541 \begin_layout Standard
3542 $SDCC_INCLUDE
3543 \end_layout
3544
3545 \end_inset
3546 </cell>
3547 </row>
3548 <row topline="true">
3549 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3550 \begin_inset Text
3551
3552 \begin_layout Standard
3553 $SDCC_HOME/
3554 \newline
3555
3556 \emph on
3557 $PREFIX2DATA_DIR/
3558 \newline
3559 $INCLUDE_DIR_SUFFIX
3560 \end_layout
3561
3562 \end_inset
3563 </cell>
3564 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3565 \begin_inset Text
3566
3567 \begin_layout Standard
3568 $SDCC_ HOME/
3569 \newline
3570 share/sdcc/
3571 \newline
3572 include
3573 \end_layout
3574
3575 \end_inset
3576 </cell>
3577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3578 \begin_inset Text
3579
3580 \begin_layout Standard
3581 $SDCC_HOME
3582 \backslash
3583 include
3584 \end_layout
3585
3586 \end_inset
3587 </cell>
3588 </row>
3589 <row topline="true">
3590 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3591 \begin_inset Text
3592
3593 \begin_layout Standard
3594 path(argv[0])/
3595 \newline
3596
3597 \emph on
3598 $BIN2DATADIR/
3599 \emph default
3600
3601 \newline
3602
3603 \emph on
3604 $INCLUDE_DIR_SUFFIX
3605 \end_layout
3606
3607 \end_inset
3608 </cell>
3609 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3610 \begin_inset Text
3611
3612 \begin_layout Standard
3613 path(argv[0])/
3614 \newline
3615 ../sdcc/include
3616 \newline
3617 \InsetSpace ~
3618 \InsetSpace ~
3619 \InsetSpace ~
3620 \InsetSpace ~
3621 \InsetSpace ~
3622 \InsetSpace ~
3623 \InsetSpace ~
3624 \InsetSpace ~
3625 \InsetSpace ~
3626 \InsetSpace ~
3627 \InsetSpace ~
3628 \InsetSpace ~
3629 \InsetSpace ~
3630 \InsetSpace ~
3631 \InsetSpace ~
3632 \InsetSpace ~
3633 \InsetSpace ~
3634 \InsetSpace ~
3635 \InsetSpace ~
3636 \InsetSpace ~
3637 \InsetSpace ~
3638 \InsetSpace ~
3639 \InsetSpace ~
3640 \InsetSpace ~
3641 \InsetSpace ~
3642 \InsetSpace ~
3643 \InsetSpace ~
3644 \InsetSpace ~
3645 \InsetSpace ~
3646 \InsetSpace ~
3647 \InsetSpace ~
3648 \InsetSpace ~
3649 \InsetSpace ~
3650 \InsetSpace ~
3651 \InsetSpace ~
3652 \InsetSpace ~
3653 \InsetSpace ~
3654 \InsetSpace ~
3655
3656 \end_layout
3657
3658 \end_inset
3659 </cell>
3660 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3661 \begin_inset Text
3662
3663 \begin_layout Standard
3664 path(argv[0])
3665 \backslash
3666 ..
3667 \backslash
3668 include
3669 \end_layout
3670
3671 \end_inset
3672 </cell>
3673 </row>
3674 <row topline="true" bottomline="true">
3675 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3676 \begin_inset Text
3677
3678 \begin_layout Standard
3679
3680 \emph on
3681 $DATADIR/
3682 \emph default
3683
3684 \newline
3685
3686 \emph on
3687 $INCLUDE_DIR_SUFFIX
3688 \end_layout
3689
3690 \end_inset
3691 </cell>
3692 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3693 \begin_inset Text
3694
3695 \begin_layout Standard
3696 /usr/local/share/sdcc/
3697 \newline
3698 include
3699 \end_layout
3700
3701 \end_inset
3702 </cell>
3703 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3704 \begin_inset Text
3705
3706 \begin_layout Standard
3707 (not on Win32)
3708 \end_layout
3709
3710 \end_inset
3711 </cell>
3712 </row>
3713 </lyxtabular>
3714
3715 \end_inset
3716
3717  
3718 \newline
3719
3720 \end_layout
3721
3722 \begin_layout Standard
3723 \noindent
3724 The option -
3725 \begin_inset ERT
3726 status collapsed
3727
3728 \begin_layout Standard
3729
3730
3731 \backslash
3732 /
3733 \end_layout
3734
3735 \end_inset
3736
3737 -nostdinc disables the last two search paths.
3738 \newline
3739
3740 \newline
3741 3.
3742  Library files 
3743 \newline
3744
3745 \end_layout
3746
3747 \begin_layout Standard
3748 With the exception of 
3749 \begin_inset Quotes sld
3750 \end_inset
3751
3752 -
3753 \begin_inset ERT
3754 status collapsed
3755
3756 \begin_layout Standard
3757
3758
3759 \backslash
3760 /
3761 \end_layout
3762
3763 \end_inset
3764
3765 -L dir
3766 \begin_inset Quotes srd
3767 \end_inset
3768
3769  the 
3770 \shape italic
3771 model
3772 \shape default
3773  is auto-appended by the compiler (e.g.
3774  small, large, z80, ds390 etc.).
3775  
3776 \newline
3777
3778 \end_layout
3779
3780 \begin_layout Standard
3781 \align center
3782 \begin_inset Tabular
3783 <lyxtabular version="3" rows="6" columns="3">
3784 <features>
3785 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3786 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3787 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3788 <row topline="true" bottomline="true">
3789 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3790 \begin_inset Text
3791
3792 \begin_layout Standard
3793 Search path
3794 \end_layout
3795
3796 \end_inset
3797 </cell>
3798 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3799 \begin_inset Text
3800
3801 \begin_layout Standard
3802 default
3803 \end_layout
3804
3805 \end_inset
3806 </cell>
3807 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3808 \begin_inset Text
3809
3810 \begin_layout Standard
3811 Win32 builds
3812 \end_layout
3813
3814 \end_inset
3815 </cell>
3816 </row>
3817 <row topline="true">
3818 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3819 \begin_inset Text
3820
3821 \begin_layout Standard
3822 -
3823 \begin_inset ERT
3824 status collapsed
3825
3826 \begin_layout Standard
3827
3828
3829 \backslash
3830 /
3831 \end_layout
3832
3833 \end_inset
3834
3835 -L dir
3836 \end_layout
3837
3838 \end_inset
3839 </cell>
3840 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3841 \begin_inset Text
3842
3843 \begin_layout Standard
3844 -
3845 \begin_inset ERT
3846 status collapsed
3847
3848 \begin_layout Standard
3849
3850
3851 \backslash
3852 /
3853 \end_layout
3854
3855 \end_inset
3856
3857 -L dir
3858 \end_layout
3859
3860 \end_inset
3861 </cell>
3862 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3863 \begin_inset Text
3864
3865 \begin_layout Standard
3866 -
3867 \begin_inset ERT
3868 status collapsed
3869
3870 \begin_layout Standard
3871
3872
3873 \backslash
3874 /
3875 \end_layout
3876
3877 \end_inset
3878
3879 -L dir
3880 \end_layout
3881
3882 \end_inset
3883 </cell>
3884 </row>
3885 <row topline="true">
3886 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3887 \begin_inset Text
3888
3889 \begin_layout Standard
3890 $SDCC_LIB/
3891 \newline
3892
3893 \emph on
3894 <model>
3895 \end_layout
3896
3897 \end_inset
3898 </cell>
3899 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3900 \begin_inset Text
3901
3902 \begin_layout Standard
3903 $SDCC_LIB/
3904 \newline
3905
3906 \emph on
3907 <model>
3908 \end_layout
3909
3910 \end_inset
3911 </cell>
3912 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3913 \begin_inset Text
3914
3915 \begin_layout Standard
3916 $SDCC_LIB
3917 \backslash
3918
3919 \newline
3920
3921 \emph on
3922 <model>
3923 \end_layout
3924
3925 \end_inset
3926 </cell>
3927 </row>
3928 <row topline="true">
3929 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3930 \begin_inset Text
3931
3932 \begin_layout Standard
3933 $SDCC_HOME/
3934 \newline
3935
3936 \emph on
3937 $PREFIX2DATA_DIR/
3938 \newline
3939 $LIB_DIR_SUFFIX/<model>
3940 \end_layout
3941
3942 \end_inset
3943 </cell>
3944 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3945 \begin_inset Text
3946
3947 \begin_layout Standard
3948 $SDCC_HOME/
3949 \newline
3950 share/sdcc/
3951 \newline
3952 lib/
3953 \emph on
3954 <model>
3955 \end_layout
3956
3957 \end_inset
3958 </cell>
3959 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3960 \begin_inset Text
3961
3962 \begin_layout Standard
3963 $SDCC_HOME
3964 \backslash
3965 lib
3966 \backslash
3967
3968 \emph on
3969
3970 \newline
3971 <model>
3972 \end_layout
3973
3974 \end_inset
3975 </cell>
3976 </row>
3977 <row topline="true">
3978 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3979 \begin_inset Text
3980
3981 \begin_layout Standard
3982 path(argv[0])/
3983 \newline
3984
3985 \emph on
3986 $BIN2DATADIR/
3987 \emph default
3988
3989 \newline
3990
3991 \emph on
3992 $LIB_DIR_SUFFIX/<model>
3993 \end_layout
3994
3995 \end_inset
3996 </cell>
3997 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3998 \begin_inset Text
3999
4000 \begin_layout Standard
4001 path(argv[0])/
4002 \newline
4003 ../sdcc/lib/
4004 \emph on
4005 <model>
4006 \newline
4007 \InsetSpace ~
4008 \InsetSpace ~
4009 \InsetSpace ~
4010 \InsetSpace ~
4011 \InsetSpace ~
4012 \InsetSpace ~
4013 \InsetSpace ~
4014 \InsetSpace ~
4015 \InsetSpace ~
4016 \InsetSpace ~
4017 \InsetSpace ~
4018 \InsetSpace ~
4019 \InsetSpace ~
4020 \InsetSpace ~
4021 \InsetSpace ~
4022 \InsetSpace ~
4023 \InsetSpace ~
4024 \InsetSpace ~
4025 \InsetSpace ~
4026 \InsetSpace ~
4027 \InsetSpace ~
4028 \InsetSpace ~
4029 \InsetSpace ~
4030 \InsetSpace ~
4031 \InsetSpace ~
4032 \InsetSpace ~
4033 \InsetSpace ~
4034 \InsetSpace ~
4035 \InsetSpace ~
4036 \InsetSpace ~
4037 \InsetSpace ~
4038 \InsetSpace ~
4039 \InsetSpace ~
4040 \InsetSpace ~
4041 \InsetSpace ~
4042 \InsetSpace ~
4043 \InsetSpace ~
4044 \InsetSpace ~
4045 \InsetSpace ~
4046
4047 \end_layout
4048
4049 \end_inset
4050 </cell>
4051 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4052 \begin_inset Text
4053
4054 \begin_layout Standard
4055 path(argv[0])
4056 \backslash
4057
4058 \newline
4059 ..
4060 \backslash
4061 lib
4062 \backslash
4063
4064 \emph on
4065 <model>
4066 \newline
4067 \InsetSpace ~
4068 \InsetSpace ~
4069 \InsetSpace ~
4070 \InsetSpace ~
4071 \InsetSpace ~
4072 \InsetSpace ~
4073 \InsetSpace ~
4074 \InsetSpace ~
4075 \InsetSpace ~
4076 \InsetSpace ~
4077 \InsetSpace ~
4078 \InsetSpace ~
4079 \InsetSpace ~
4080 \InsetSpace ~
4081 \InsetSpace ~
4082 \InsetSpace ~
4083 \InsetSpace ~
4084 \InsetSpace ~
4085 \InsetSpace ~
4086 \InsetSpace ~
4087 \InsetSpace ~
4088 \InsetSpace ~
4089 \InsetSpace ~
4090 \InsetSpace ~
4091 \InsetSpace ~
4092 \InsetSpace ~
4093 \InsetSpace ~
4094 \InsetSpace ~
4095 \InsetSpace ~
4096 \InsetSpace ~
4097 \InsetSpace ~
4098 \InsetSpace ~
4099 \InsetSpace ~
4100 \InsetSpace ~
4101 \InsetSpace ~
4102
4103 \end_layout
4104
4105 \end_inset
4106 </cell>
4107 </row>
4108 <row topline="true" bottomline="true">
4109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4110 \begin_inset Text
4111
4112 \begin_layout Standard
4113
4114 \emph on
4115 $DATADIR/
4116 \newline
4117 $LIB_DIR_SUFFIX/<model>
4118 \end_layout
4119
4120 \end_inset
4121 </cell>
4122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4123 \begin_inset Text
4124
4125 \begin_layout Standard
4126 /usr/local/share/sdcc/
4127 \newline
4128 lib/
4129 \emph on
4130 <model>
4131 \end_layout
4132
4133 \end_inset
4134 </cell>
4135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4136 \begin_inset Text
4137
4138 \begin_layout Standard
4139 (not on Win32)
4140 \end_layout
4141
4142 \end_inset
4143 </cell>
4144 </row>
4145 </lyxtabular>
4146
4147 \end_inset
4148
4149
4150 \newline
4151
4152 \end_layout
4153
4154 \begin_layout Standard
4155 \begin_inset Note Note
4156 status collapsed
4157
4158 \begin_layout Standard
4159 Don't delete any of the stray spaces in the table above without checking
4160  the HTML output (last line)!
4161 \end_layout
4162
4163 \end_inset
4164
4165
4166 \end_layout
4167
4168 \begin_layout Standard
4169 \InsetSpace ~
4170
4171 \newline
4172 The option -
4173 \begin_inset ERT
4174 status collapsed
4175
4176 \begin_layout Standard
4177
4178
4179 \backslash
4180 /
4181 \end_layout
4182
4183 \end_inset
4184
4185 -nostdlib disables the last two search paths.
4186 \end_layout
4187
4188 \begin_layout Section
4189 Building SDCC
4190 \begin_inset LatexCommand index
4191 name "Building SDCC"
4192
4193 \end_inset
4194
4195
4196 \end_layout
4197
4198 \begin_layout Subsection
4199 Building SDCC on Linux
4200 \begin_inset LatexCommand label
4201 name "sub:Building-SDCC-on-Linux"
4202
4203 \end_inset
4204
4205
4206 \end_layout
4207
4208 \begin_layout Enumerate
4209
4210 \series medium
4211 Download the source package
4212 \series default
4213  either from the SDCC Subversion repository or from snapshot builds
4214 \series medium
4215 , it will be named something like sdcc
4216 \series default
4217 -src
4218 \series medium
4219 -yyyymmdd-rrrr.t
4220 \series default
4221 ar.
4222 \series medium
4223 bz2
4224 \series default
4225  
4226 \begin_inset LatexCommand url
4227 target "http://sdcc.sourceforge.net/snap.php"
4228
4229 \end_inset
4230
4231 .
4232 \end_layout
4233
4234 \begin_layout Enumerate
4235
4236 \series medium
4237 Bring up a command line terminal, such as xterm.
4238 \end_layout
4239
4240 \begin_layout Enumerate
4241
4242 \series medium
4243 Unpack the file using a command like:
4244 \series default
4245  
4246 \family sans
4247 \series bold
4248 "tar -xvjf sdcc-src-yyyymmdd-rrrr.tar.bz2
4249 \begin_inset Quotes srd
4250 \end_inset
4251
4252
4253 \family default
4254 \series medium
4255 , this will create a sub-directory called sdcc with all of the sources.
4256 \end_layout
4257
4258 \begin_layout Enumerate
4259 Change directory into the main SDCC directory, for example type: 
4260 \family sans
4261 \series bold
4262 "cd sdcc
4263 \series default
4264 ".
4265 \end_layout
4266
4267 \begin_layout Enumerate
4268
4269 \series medium
4270 Type
4271 \series default
4272  
4273 \family sans
4274 \series bold
4275 "./configure
4276 \family default
4277 \series default
4278 ".
4279  This configures the package for compilation on your system.
4280 \end_layout
4281
4282 \begin_layout Enumerate
4283
4284 \series medium
4285 Type
4286 \series default
4287  
4288 \family sans
4289 \series bold
4290 "make
4291 \family default
4292 \series default
4293 "
4294 \series medium
4295 .
4296
4297 \series default
4298  All of the source packages will compile, this can take a while.
4299 \end_layout
4300
4301 \begin_layout Enumerate
4302
4303 \series medium
4304 Type
4305 \series default
4306  
4307 \family sans
4308 \series bold
4309 "make install"
4310 \family default
4311 \series default
4312  as root
4313 \series medium
4314 .
4315
4316 \series default
4317  This copies the binary executables, the include files, the libraries and
4318  the documentation to the install directories.
4319  Proceed with section 
4320 \begin_inset LatexCommand ref
4321 reference "sec:Testing-the-SDCC"
4322
4323 \end_inset
4324
4325 .
4326 \end_layout
4327
4328 \begin_layout Subsection
4329 Building SDCC on Mac OS X
4330 \end_layout
4331
4332 \begin_layout Standard
4333 Follow the instruction for Linux.
4334 \newline
4335
4336 \newline
4337 On Mac OS X 10.2.x it was reported, that the
4338  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
4339  Fortunately there's also gcc 2.9.x installed, which works fine.
4340  This compiler can be selected by running 'configure' with:
4341 \end_layout
4342
4343 \begin_layout LyX-Code
4344 ./configure CC=gcc2 CXX=g++2
4345 \end_layout
4346
4347 \begin_layout Standard
4348 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
4349  Xcode.
4350  Run 'configure' with:
4351 \end_layout
4352
4353 \begin_layout LyX-Code
4354 ./configure 
4355 \backslash
4356
4357 \end_layout
4358
4359 \begin_layout LyX-Code
4360 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4361  ppc" 
4362 \backslash
4363
4364 \end_layout
4365
4366 \begin_layout LyX-Code
4367 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4368  ppc" 
4369 \backslash
4370
4371 \end_layout
4372
4373 \begin_layout LyX-Code
4374 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
4375 \end_layout
4376
4377 \begin_layout Subsection
4378 Cross compiling SDCC on Linux for Windows
4379 \end_layout
4380
4381 \begin_layout Standard
4382 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
4383  See section 'Configure Options'.
4384 \end_layout
4385
4386 \begin_layout Subsection
4387 Building SDCC using Cygwin and Mingw32
4388 \end_layout
4389
4390 \begin_layout Standard
4391 For building and installing a Cygwin executable follow the instructions
4392  for Linux.
4393 \newline
4394
4395 \newline
4396 On Cygwin a 
4397 \begin_inset Quotes sld
4398 \end_inset
4399
4400 native
4401 \begin_inset Quotes srd
4402 \end_inset
4403
4404  Win32-binary can be built, which will not need the Cygwin-DLL.
4405  For the necessary 'configure' options see section 'configure options' or
4406  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4407 \newline
4408
4409 \newline
4410 In order to install
4411  Cygwin on Windows download setup.exe from 
4412 \begin_inset LatexCommand url
4413 name "www.cygwin.com"
4414 target "http://www.cygwin.com/"
4415
4416 \end_inset
4417
4418 .
4419  Run it, set the 
4420 \begin_inset Quotes sld
4421 \end_inset
4422
4423 default text file type
4424 \begin_inset Quotes srd
4425 \end_inset
4426
4427  to 
4428 \begin_inset Quotes sld
4429 \end_inset
4430
4431 unix
4432 \begin_inset Quotes srd
4433 \end_inset
4434
4435  and download/install at least the following packages.
4436  Some packages are selected by default, others will be automatically selected
4437  because of dependencies with the manually selected packages.
4438  Never deselect these packages!
4439 \end_layout
4440
4441 \begin_layout Itemize
4442 flex
4443 \end_layout
4444
4445 \begin_layout Itemize
4446 bison
4447 \end_layout
4448
4449 \begin_layout Itemize
4450 gcc ; version 3.x is fine, no need to use the old 2.9x
4451 \end_layout
4452
4453 \begin_layout Itemize
4454 binutils ; selected with gcc
4455 \end_layout
4456
4457 \begin_layout Itemize
4458 make
4459 \end_layout
4460
4461 \begin_layout Itemize
4462 rxvt ; a nice console, which makes life much easier under windoze (see below)
4463 \end_layout
4464
4465 \begin_layout Itemize
4466 man ; not really needed for building SDCC, but you'll miss it sooner or
4467  later
4468 \end_layout
4469
4470 \begin_layout Itemize
4471 less ; not really needed for building SDCC, but you'll miss it sooner or
4472  later
4473 \end_layout
4474
4475 \begin_layout Itemize
4476 svn ; only if you use Subversion access
4477 \end_layout
4478
4479 \begin_layout Standard
4480 If you want to develop something you'll need:
4481 \end_layout
4482
4483 \begin_layout Itemize
4484 python ; for the regression tests
4485 \end_layout
4486
4487 \begin_layout Itemize
4488 gdb ; the gnu debugger, together with the nice GUI 
4489 \begin_inset Quotes sld
4490 \end_inset
4491
4492 insight
4493 \begin_inset Quotes srd
4494 \end_inset
4495
4496
4497 \end_layout
4498
4499 \begin_layout Itemize
4500 openssh ; to access the CF or commit changes
4501 \end_layout
4502
4503 \begin_layout Itemize
4504 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4505  use autoconf-stable!
4506 \end_layout
4507
4508 \begin_layout Standard
4509 rxvt is a nice console with history.
4510  Replace in your cygwin.bat the line
4511 \end_layout
4512
4513 \begin_layout LyX-Code
4514 bash -
4515 \begin_inset ERT
4516 status collapsed
4517
4518 \begin_layout Standard
4519
4520
4521 \backslash
4522 /
4523 \end_layout
4524
4525 \end_inset
4526
4527 -login -i 
4528 \end_layout
4529
4530 \begin_layout Standard
4531 with (one line):
4532 \end_layout
4533
4534 \begin_layout LyX-Code
4535 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4536 \end_layout
4537
4538 \begin_layout LyX-Code
4539      -bg black -fg white -geometry 100x65 -e bash -
4540 \begin_inset ERT
4541 status collapsed
4542
4543 \begin_layout Standard
4544
4545
4546 \backslash
4547 /
4548 \end_layout
4549
4550 \end_inset
4551
4552 -login
4553 \end_layout
4554
4555 \begin_layout Standard
4556 Text selected with the mouse is automatically copied to the clipboard, pasting
4557  works with shift-insert.
4558 \newline
4559
4560 \newline
4561 The other good tip is to make sure you have no //c/-styl
4562 e paths anywhere, use /cygdrive/c/ instead.
4563  Using // invokes a network lookup which is very slow.
4564  If you think 
4565 \begin_inset Quotes sld
4566 \end_inset
4567
4568 cygdrive
4569 \begin_inset Quotes srd
4570 \end_inset
4571
4572  is too long, you can change it with e.g.
4573 \end_layout
4574
4575 \begin_layout LyX-Code
4576 mount -s -u -c /mnt
4577 \end_layout
4578
4579 \begin_layout Standard
4580 SDCC sources use the unix line ending LF.
4581  Life is much easier, if you store the source tree on a drive which is mounted
4582  in binary mode.
4583  And use an editor which can handle LF-only line endings.
4584  Make sure not to commit files with windows line endings.
4585  The tabulator spacing
4586 \begin_inset LatexCommand index
4587 name "tabulator spacing (8 columns)"
4588
4589 \end_inset
4590
4591  used in the project is 8.
4592  Although a tabulator spacing of 8 is a sensible choice for programmers
4593  (it's a power of 2 and allows to display 8/16 bit signed variables without
4594  loosing columns) the plan is to move towards using only spaces in the source.
4595 \end_layout
4596
4597 \begin_layout Subsection
4598 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4599 \end_layout
4600
4601 \begin_layout Standard
4602
4603 \series medium
4604 Download the source package
4605 \series default
4606  either from the SDCC Subversion repository or from the 
4607 \begin_inset LatexCommand url
4608 name "snapshot builds"
4609 target "http://sdcc.sourceforge.net/snap.php"
4610
4611 \end_inset
4612
4613
4614 \series medium
4615 , it will be named something like sdcc
4616 \series default
4617 -src
4618 \series medium
4619 -yyyymmdd-rrrr.tar.bz2.
4620
4621 \series default
4622  SDCC is distributed with all the projects, workspaces, and files you need
4623  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4624  The workspace name is 'sdcc.dsw'.
4625  Please note that as it is now, all the executables are created in a folder
4626  called sdcc
4627 \backslash
4628 bin_vc.
4629  Once built you need to copy the executables from sdcc
4630 \backslash
4631 bin_vc to sdcc
4632 \backslash
4633 bin before running SDCC.
4634  
4635 \newline
4636
4637 \newline
4638 WARNING: Visual studio is very picky with line terminations; it expects
4639  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4640  When using the Subversion repository it's easiest to configure the svn
4641  client to convert automatically for you.
4642  If however you are getting a message such as "This makefile was not generated
4643  by Developer Studio etc.
4644  etc.
4645 \begin_inset Quotes srd
4646 \end_inset
4647
4648  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4649  need to convert the Unix style line endings to DOS style line endings.
4650  To do so you can use the 
4651 \begin_inset Quotes sld
4652 \end_inset
4653
4654 unix2dos
4655 \begin_inset Quotes srd
4656 \end_inset
4657
4658  utility freely available on the internet.
4659  Doug Hawkins reported in the sdcc-user list that this works:
4660 \newline
4661
4662 \newline
4663 C:
4664 \backslash
4665 Programming
4666 \backslash
4667 SDCC> unix2dos sdcc.dsw
4668 \newline
4669 C:
4670 \backslash
4671 Programming
4672 \backslash
4673 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4674 \newline
4675
4676 \newline
4677 In order to build SDCC with MSVC
4678  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4679  One good place to get them is 
4680 \begin_inset LatexCommand url
4681 name "here"
4682 target "http://unxutils.sourceforge.net"
4683
4684 \end_inset
4685
4686
4687 \newline
4688
4689 \newline
4690 Download the file UnxUtils
4691 \begin_inset LatexCommand index
4692 name "UnxUtils"
4693
4694 \end_inset
4695
4696 .zip.
4697  Now you have to install the utilities and setup MSVC so it can locate the
4698  required programs.
4699  Here there are two alternatives (choose one!):
4700 \end_layout
4701
4702 \begin_layout Enumerate
4703 The easy way:
4704 \newline
4705
4706 \newline
4707 a) Extract UnxUtils.zip to your C:
4708 \backslash
4709  hard disk PRESERVING the original paths, otherwise bison won't work.
4710  (If you are using WinZip make certain that 'Use folder names' is selected)
4711 \newline
4712
4713 \newline
4714 b)
4715  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4716  'Show directories for:' select 'Executable files', and in the directories
4717  window add a new path: 'C:
4718 \backslash
4719 user
4720 \backslash
4721 local
4722 \backslash
4723 wbin', click ok.
4724 \newline
4725
4726 \newline
4727 (As a side effect, you get a bunch of Unix utilities that
4728  could be useful, such as diff and patch.)
4729 \end_layout
4730
4731 \begin_layout Enumerate
4732 A more compact way:
4733 \newline
4734
4735 \newline
4736 This one avoids extracting a bunch of files you may not
4737  use, but requires some extra work:
4738 \newline
4739
4740 \newline
4741 a) Create a directory were to put the
4742  tools needed, or use a directory already present.
4743  Say for example 'C:
4744 \backslash
4745 util'.
4746 \newline
4747
4748 \newline
4749 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4750  gawk.exe to such directory WITHOUT preserving the original paths.
4751  (If you are using WinZip make certain that 'Use folder names' is not selected)
4752 \newline
4753
4754 \newline
4755 c
4756 ) Rename bison.exe to '_bison.exe'.
4757 \newline
4758
4759 \newline
4760 d) Create a batch file 'bison.bat' in 'C:
4761 \backslash
4762 util
4763 \backslash
4764 ' and add these lines: 
4765 \newline
4766 \InsetSpace ~
4767 \InsetSpace ~
4768 set BISON_SIMPLE=C:
4769 \backslash
4770 util
4771 \backslash
4772 bison.simple 
4773 \newline
4774 \InsetSpace ~
4775 \InsetSpace ~
4776 set BISON_HAIRY=C:
4777 \backslash
4778 util
4779 \backslash
4780 bison.hairy
4781 \newline
4782 \InsetSpace ~
4783 \InsetSpace ~
4784 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4785 \newline
4786
4787 \newline
4788 Steps 'c' and 'd' are needed
4789  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4790  reside in some weird Unix directory, '/usr/local/share/' I think.
4791  So it is necessary to tell bison where those files are located if they
4792  are not in such directory.
4793  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4794 \newline
4795
4796 \newline
4797 e
4798 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4799  in 'Show directories for:' select 'Executable files', and in the directories
4800  window add a new path: 'c:
4801 \backslash
4802 util', click ok.
4803  Note that you can use any other path instead of 'c:
4804 \backslash
4805 util', even the path where the Visual C++ tools are, probably: 'C:
4806 \backslash
4807 Program Files
4808 \backslash
4809 Microsoft Visual Studio
4810 \backslash
4811 Common
4812 \backslash
4813 Tools'.
4814  So you don't have to execute step 'e' :)
4815 \end_layout
4816
4817 \begin_layout Standard
4818 That is it.
4819  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4820  the executables from sdcc
4821 \backslash
4822 bin_vc to sdcc
4823 \backslash
4824 bin, and you can compile using SDCC.
4825 \end_layout
4826
4827 \begin_layout Subsection
4828 Building SDCC Using Borland
4829 \end_layout
4830
4831 \begin_layout Enumerate
4832 From the sdcc directory, run the command "make -f Makefile.bcc".
4833  This should regenerate all the .exe files in the bin directory except for
4834  SDCDB and ucSim.
4835 \end_layout
4836
4837 \begin_layout Enumerate
4838 If you modify any source files and need to rebuild, be aware that the dependenci
4839 es may not be correctly calculated.
4840  The safest option is to delete all .obj files and run the build again.
4841  From a Cygwin BASH prompt, this can easily be done with the command (be
4842  sure you are in the sdcc directory):
4843 \newline
4844
4845 \newline
4846
4847 \family sans
4848 \series bold
4849 find .
4850  
4851 \backslash
4852 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4853 \backslash
4854 ) -print -exec rm {} 
4855 \backslash
4856 ;
4857 \family default
4858 \series default
4859
4860 \newline
4861
4862 \newline
4863 or on Windows NT/2000/XP from the command prompt with the command:
4864 \newline
4865
4866 \family sans
4867 \series bold
4868
4869 \newline
4870 del /s *.obj *.lib *.rul
4871 \family default
4872 \series default
4873  from the sdcc directory.
4874 \end_layout
4875
4876 \begin_layout Subsection
4877 Windows Install Using a ZIP Package
4878 \end_layout
4879
4880 \begin_layout Enumerate
4881 Download the binary zip package from 
4882 \begin_inset LatexCommand url
4883 target "http://sdcc.sf.net/snap.php"
4884
4885 \end_inset
4886
4887  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4888  This should unpack to a group of sub-directories.
4889  An example directory structure after unpacking the mingw32 package is:
4890  c:
4891 \backslash
4892 sdcc
4893 \backslash
4894 bin for the executables, c:
4895 \backslash
4896 sdcc
4897 \backslash
4898 include and c:
4899 \backslash
4900 sdcc
4901 \backslash
4902 lib for the include and libraries.
4903 \end_layout
4904
4905 \begin_layout Enumerate
4906 Adjust your environment variable PATH to include the location of the bin
4907  directory or start sdcc using the full path.
4908 \end_layout
4909
4910 \begin_layout Subsection
4911 Windows Install Using the Setup Program
4912 \begin_inset LatexCommand label
4913 name "sub:Windows-Install"
4914
4915 \end_inset
4916
4917
4918 \end_layout
4919
4920 \begin_layout Standard
4921 Download the setup program 
4922 \emph on
4923 sdcc-x.y.z-setup.exe
4924 \emph default
4925  for an official release from 
4926 \newline
4927
4928 \begin_inset LatexCommand url
4929 target "http://sf.net/project/showfiles.php?group_id=599"
4930
4931 \end_inset
4932
4933  or a setup program for one of the snapshots 
4934 \emph on
4935 sdcc-yyyymmdd-xxxx-setup.exe
4936 \emph default
4937  from 
4938 \begin_inset LatexCommand url
4939 target "http://sdcc.sf.net/snap.php"
4940
4941 \end_inset
4942
4943  and execute it.
4944  A windows typical installer will guide you through the installation process.
4945 \end_layout
4946
4947 \begin_layout Subsection
4948 VPATH
4949 \begin_inset LatexCommand index
4950 name "VPATH"
4951
4952 \end_inset
4953
4954  feature
4955 \end_layout
4956
4957 \begin_layout Standard
4958 SDCC supports the VPATH feature provided by configure and make.
4959  It allows to separate the source and build trees.
4960  Here's an example:
4961 \end_layout
4962
4963 \begin_layout Standard
4964
4965 \family typewriter
4966 cd ~\InsetSpace ~
4967 \InsetSpace ~
4968 \InsetSpace ~
4969 \InsetSpace ~
4970 \InsetSpace ~
4971 \InsetSpace ~
4972 \InsetSpace ~
4973 \InsetSpace ~
4974 \InsetSpace ~
4975 \InsetSpace ~
4976 \InsetSpace ~
4977 \InsetSpace ~
4978 \InsetSpace ~
4979 \InsetSpace ~
4980 \InsetSpace ~
4981 \InsetSpace ~
4982 \InsetSpace ~
4983 \InsetSpace ~
4984 \InsetSpace ~
4985 \InsetSpace ~
4986 \InsetSpace ~
4987 \InsetSpace ~
4988 \InsetSpace ~
4989 \InsetSpace ~
4990 \InsetSpace ~
4991 \InsetSpace ~
4992 \InsetSpace ~
4993 \InsetSpace ~
4994 \InsetSpace ~
4995 \InsetSpace ~
4996 \InsetSpace ~
4997 \InsetSpace ~
4998 \InsetSpace ~
4999 \InsetSpace ~
5000 \InsetSpace ~
5001 \InsetSpace ~
5002 # cd $HOME
5003 \end_layout
5004
5005 \begin_layout Standard
5006
5007 \family typewriter
5008 tar -xjf sdcc-src-yyyymmdd-rrrr.tar.bz2\InsetSpace ~
5009 # extract source to directory sdcc
5010 \end_layout
5011
5012 \begin_layout Standard
5013
5014 \family typewriter
5015 mkdir sdcc.build\InsetSpace ~
5016 \InsetSpace ~
5017 \InsetSpace ~
5018 \InsetSpace ~
5019 \InsetSpace ~
5020 \InsetSpace ~
5021 \InsetSpace ~
5022 \InsetSpace ~
5023 \InsetSpace ~
5024 \InsetSpace ~
5025 \InsetSpace ~
5026 \InsetSpace ~
5027 \InsetSpace ~
5028 \InsetSpace ~
5029 \InsetSpace ~
5030 \InsetSpace ~
5031 \InsetSpace ~
5032 \InsetSpace ~
5033 \InsetSpace ~
5034 \InsetSpace ~
5035 \InsetSpace ~
5036 \InsetSpace ~
5037 \InsetSpace ~
5038 \InsetSpace ~
5039 # put output in sdcc.build
5040 \end_layout
5041
5042 \begin_layout Standard
5043
5044 \family typewriter
5045 cd sdcc.build
5046 \end_layout
5047
5048 \begin_layout Standard
5049
5050 \family typewriter
5051 ../sdcc/configure\InsetSpace ~
5052 \InsetSpace ~
5053 \InsetSpace ~
5054 \InsetSpace ~
5055 \InsetSpace ~
5056 \InsetSpace ~
5057 \InsetSpace ~
5058 \InsetSpace ~
5059 \InsetSpace ~
5060 \InsetSpace ~
5061 \InsetSpace ~
5062 \InsetSpace ~
5063 \InsetSpace ~
5064 \InsetSpace ~
5065 \InsetSpace ~
5066 \InsetSpace ~
5067 \InsetSpace ~
5068 \InsetSpace ~
5069 \InsetSpace ~
5070 \InsetSpace ~
5071 \InsetSpace ~
5072 \InsetSpace ~
5073 \InsetSpace ~
5074 # configure is doing all the magic!
5075 \end_layout
5076
5077 \begin_layout Standard
5078
5079 \family typewriter
5080 make
5081 \end_layout
5082
5083 \begin_layout Standard
5084 \noindent
5085 That's it! 
5086 \series bold
5087 configure
5088 \series default
5089  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
5090  It automagically computes the variables srcdir, top_srcdir and top_buildir
5091  for each directory.
5092  After running 
5093 \series bold
5094 make
5095 \series default
5096  the generated files will be in ~/sdcc.build, while the source files stay
5097  in ~/sdcc.
5098 \newline
5099 This is not only usefull for building different binaries, e.g.
5100  when cross compiling.
5101  It also gives you a much better overview in the source tree when all the
5102  generated files are not scattered between the source files.
5103  And the best thing is: if you want to change a file you can leave the original
5104  file untouched in the source directory.
5105  Simply copy it to the build directory, edit it, enter `make clean', `rm
5106  Makefile.dep' and `make'.
5107  
5108 \series bold
5109 make
5110 \series default
5111  will do the rest for you!
5112 \end_layout
5113
5114 \begin_layout Section
5115 Building the Documentation
5116 \end_layout
5117
5118 \begin_layout Standard
5119 Add -
5120 \begin_inset ERT
5121 status collapsed
5122
5123 \begin_layout Standard
5124
5125
5126 \backslash
5127 /
5128 \end_layout
5129
5130 \end_inset
5131
5132 -enable-doc to the configure arguments to build the documentation together
5133  with all the other stuff.
5134  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
5135  dvips and makeindex) to get the job done.
5136  Another possibility is to change to the doc directory and to type 
5137 \family sans
5138 \series bold
5139
5140 \begin_inset Quotes srd
5141 \end_inset
5142
5143 make
5144 \begin_inset Quotes srd
5145 \end_inset
5146
5147
5148 \family default
5149 \series default
5150  there.
5151  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
5152 x).
5153  Using LyX 
5154 \begin_inset LatexCommand url
5155 target "http://www.lyx.org"
5156
5157 \end_inset
5158
5159  as editor is straightforward.
5160  Prebuilt documentation in html and pdf format is available from 
5161 \begin_inset LatexCommand url
5162 target "http://sdcc.sf.net/snap.php"
5163
5164 \end_inset
5165
5166 .
5167 \end_layout
5168
5169 \begin_layout Section
5170 Reading the Documentation
5171 \begin_inset LatexCommand index
5172 name "Documentation"
5173
5174 \end_inset
5175
5176
5177 \end_layout
5178
5179 \begin_layout Standard
5180 Currently reading the document in pdf format is recommended, as for unknown
5181  reason the hyperlinks are working there whereas in the html version they
5182  are not
5183 \begin_inset Foot
5184 status open
5185
5186 \begin_layout Standard
5187 If you should know why please drop us a note
5188 \end_layout
5189
5190 \end_inset
5191
5192 .
5193  
5194 \newline
5195 You'll find the pdf version
5196 \begin_inset LatexCommand index
5197 name "PDF version of this document"
5198
5199 \end_inset
5200
5201  at 
5202 \begin_inset LatexCommand url
5203 target "http://sdcc.sf.net/doc/sdccman.pdf"
5204
5205 \end_inset
5206
5207 .
5208  
5209 \newline
5210 A html version
5211 \begin_inset LatexCommand index
5212 name "HTML version of this document"
5213
5214 \end_inset
5215
5216  should be online at 
5217 \begin_inset LatexCommand url
5218 target "http://sdcc.sf.net/doc/sdccman.html/index.html"
5219
5220 \end_inset
5221
5222 .
5223 \newline
5224 This documentation is in some aspects different from a commercial documentation:
5225  
5226 \end_layout
5227
5228 \begin_layout Itemize
5229 It tries to document SDCC for several processor architectures in one document
5230  (commercially these probably would be separate documents/products).
5231  This document
5232 \begin_inset LatexCommand index
5233 name "Status of documentation"
5234
5235 \end_inset
5236
5237  currently matches SDCC for mcs51 and DS390 best and does give too few informati
5238 on about f.e.
5239  Z80, PIC14, PIC16 and HC08.
5240 \end_layout
5241
5242 \begin_layout Itemize
5243 There are many references pointing away from this documentation.
5244  Don't let this distract you.
5245  If there f.e.
5246  was a reference like 
5247 \begin_inset LatexCommand url
5248 target "http://www.opencores.org"
5249
5250 \end_inset
5251
5252  together with a statement 
5253 \begin_inset Quotes sld
5254 \end_inset
5255
5256 some processors which are targetted by SDCC can be implemented in a 
5257 \emph on
5258 f
5259 \emph default
5260 ield 
5261 \emph on
5262 p
5263 \emph default
5264 rogrammable 
5265 \emph on
5266 g
5267 \emph default
5268 ate 
5269 \emph on
5270 a
5271 \emph default
5272 rray
5273 \begin_inset LatexCommand index
5274 name "FPGA (field programmable gate array)"
5275
5276 \end_inset
5277
5278
5279 \begin_inset Quotes srd
5280 \end_inset
5281
5282  or 
5283 \begin_inset LatexCommand url
5284 target "http://sf.net/projects/fpgac"
5285
5286 \end_inset
5287
5288
5289 \begin_inset LatexCommand index
5290 name "FpgaC ((subset of) C to FPGA compiler)"
5291
5292 \end_inset
5293
5294  
5295 \begin_inset Quotes sld
5296 \end_inset
5297
5298 have you ever heard of an open source compiler that compiles a subset of
5299  C for an FPGA?
5300 \begin_inset Quotes srd
5301 \end_inset
5302
5303  we expect you to have a quick look there and come back.
5304  If you read this you are on the right track.
5305 \end_layout
5306
5307 \begin_layout Itemize
5308 Some sections attribute more space to problems, restrictions and warnings
5309  than to the solution.
5310 \end_layout
5311
5312 \begin_layout Itemize
5313 The installation section and the section about the debugger is intimidating.
5314 \end_layout
5315
5316 \begin_layout Itemize
5317 There are still lots of typos and there are more different writing styles
5318  than pictures.
5319 \end_layout
5320
5321 \begin_layout Section
5322 Testing the SDCC Compiler
5323 \begin_inset LatexCommand label
5324 name "sec:Testing-the-SDCC"
5325
5326 \end_inset
5327
5328
5329 \end_layout
5330
5331 \begin_layout Standard
5332 The first thing you should do after installing your SDCC compiler is to
5333  see if it runs.
5334  Type 
5335 \family sans
5336 \series bold
5337 "sdcc -
5338 \begin_inset ERT
5339 status collapsed
5340
5341 \begin_layout Standard
5342
5343
5344 \backslash
5345 /
5346 \end_layout
5347
5348 \end_inset
5349
5350 -version"
5351 \begin_inset LatexCommand index
5352 name "version"
5353
5354 \end_inset
5355
5356
5357 \family default
5358 \series default
5359  at the prompt, and the program should run and output its version like:
5360  
5361 \newline
5362
5363 \family typewriter
5364 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
5365  (UNIX)
5366 \end_layout
5367
5368 \begin_layout Standard
5369 If it doesn't run, or gives a message about not finding sdcc program, then
5370  you need to check over your installation.
5371  Make sure that the sdcc bin directory is in your executable search path
5372  defined by the PATH environment setting (
5373 \series medium
5374 see
5375 \series default
5376  section 
5377 \begin_inset LatexCommand ref
5378 reference "sub:Install-Trouble-shooting"
5379
5380 \end_inset
5381
5382 \InsetSpace ~
5383
5384 \series medium
5385 Install trouble-shooting for suggestions
5386 \series default
5387 ).
5388  Make sure that the sdcc program is in the bin folder, if not perhaps something
5389  did not install correctly.
5390 \newline
5391
5392 \newline
5393
5394 \series medium
5395 SDCC
5396 \series default
5397  is commonly installed as described in section 
5398 \begin_inset Quotes sld
5399 \end_inset
5400
5401 Install and search paths
5402 \begin_inset Quotes srd
5403 \end_inset
5404
5405 .
5406 \newline
5407
5408 \newline
5409
5410 \series medium
5411 Make sure the compiler works on a very simple example.
5412  Type in the following test.c program using your favorite
5413 \series default
5414  ASCII 
5415 \series medium
5416 editor:
5417 \end_layout
5418
5419 \begin_layout Verse
5420
5421 \family typewriter
5422 char test;
5423 \newline
5424
5425 \newline
5426 void main(void) {
5427 \newline
5428 \InsetSpace ~
5429 \InsetSpace ~
5430 \InsetSpace ~
5431 \InsetSpace ~
5432 test=0;
5433 \newline
5434 }
5435 \end_layout
5436
5437 \begin_layout Standard
5438
5439 \series medium
5440 Compile this using the following command:
5441 \series default
5442  
5443 \family sans
5444 \series bold
5445 "sdcc -c test.c".
5446
5447 \family default
5448 \series default
5449  
5450 \series medium
5451 If all goes well, the compiler will generate a test.asm and test.rel file.
5452  Congratulations, you've just compiled your first program with SDCC.
5453  We used the -c option to tell SDCC not to link the generated code, just
5454  to keep things simple for this step.
5455 \series default
5456
5457 \newline
5458
5459 \newline
5460
5461 \series medium
5462 The next step is to try it with the linker.
5463  Type in
5464 \series default
5465  
5466 \family sans
5467 \series bold
5468 "sdcc test.c
5469 \family default
5470 \series default
5471 "
5472 \series medium
5473 .
5474  If all goes well the compiler will link with the libraries and produce
5475  a test.ihx output file.
5476  If this step fails
5477 \series default
5478  
5479 \series medium
5480 (no test.ihx, and the linker generates warnings), then the problem is most
5481  likely that
5482 \series default
5483  SDCC 
5484 \series medium
5485 cannot find the
5486 \series default
5487  /
5488 \series medium
5489 usr/local/share/sdcc/lib directory
5490 \series default
5491  
5492 \series medium
5493 (see
5494 \series default
5495  section 
5496 \begin_inset LatexCommand ref
5497 reference "sub:Install-Trouble-shooting"
5498
5499 \end_inset
5500
5501 \InsetSpace ~
5502
5503 \series medium
5504 Install trouble-shooting for suggestions).
5505 \series default
5506
5507 \newline
5508
5509 \newline
5510
5511 \series medium
5512 The final test is to ensure
5513 \series default
5514  SDCC 
5515 \series medium
5516 can use the
5517 \series default
5518  standard 
5519 \series medium
5520 header files and libraries.
5521  Edit test.c and change it to the following:
5522 \end_layout
5523
5524 \begin_layout Verse
5525
5526 \family typewriter
5527 #include <string.h>
5528 \newline
5529
5530 \newline
5531 char str1[10];
5532 \newline
5533
5534 \newline
5535 void main(void) {
5536 \newline
5537 \InsetSpace ~
5538 \InsetSpace ~
5539 strcpy(str1, "testing");
5540 \newline
5541 }
5542 \end_layout
5543
5544 \begin_layout Standard
5545
5546 \series medium
5547 Compile this by typing
5548 \series default
5549  
5550 \family sans
5551 \series bold
5552 "sdcc test.c"
5553 \family default
5554 \series medium
5555 .
5556  This should generate a test.ihx output file, and it should give no warnings
5557  such as not finding the string.h file.
5558  If it cannot find the string.h file, then the problem is that
5559 \series default
5560  SDCC 
5561 \series medium
5562 cannot find the /usr/local/share/sdcc/include directory
5563 \series default
5564  
5565 \series medium
5566 (see the
5567 \series default
5568  section 
5569 \begin_inset LatexCommand ref
5570 reference "sub:Install-Trouble-shooting"
5571
5572 \end_inset
5573
5574 \InsetSpace ~
5575
5576 \series medium
5577 Install trouble-shooting section for suggestions).
5578
5579 \series default
5580  Use option 
5581 \series bold
5582 -
5583 \begin_inset ERT
5584 status collapsed
5585
5586 \begin_layout Standard
5587
5588
5589 \backslash
5590 /
5591 \end_layout
5592
5593 \end_inset
5594
5595 -print-search-dirs
5596 \series default
5597
5598 \begin_inset LatexCommand index
5599 name "-\\/-print-search-dirs"
5600
5601 \end_inset
5602
5603  to find exactly where SDCC is looking for the include and lib files.
5604 \end_layout
5605
5606 \begin_layout Section
5607 Install Trouble-shooting
5608 \begin_inset LatexCommand label
5609 name "sub:Install-Trouble-shooting"
5610
5611 \end_inset
5612
5613
5614 \begin_inset LatexCommand index
5615 name "Install trouble-shooting"
5616
5617 \end_inset
5618
5619
5620 \end_layout
5621
5622 \begin_layout Subsection
5623 If SDCC does not build correctly
5624 \end_layout
5625
5626 \begin_layout Standard
5627 A thing to try is starting from scratch by unpacking the .tgz source package
5628  again in an empty directory.
5629  Configure it like:
5630 \newline
5631
5632 \newline
5633
5634 \family sans
5635 \series bold
5636 ./configure 2>&1 | tee configure.log
5637 \family default
5638 \series default
5639
5640 \newline
5641
5642 \newline
5643 and build it like:
5644 \newline
5645
5646 \newline
5647
5648 \family sans
5649 \series bold
5650 make 2>&1 | tee make.log
5651 \family default
5652 \series default
5653
5654 \newline
5655
5656 \newline
5657 If anything goes wrong, you can review the log files to locate the problem.
5658  Or a relevant part of this can be attached to an email that could be helpful
5659  when requesting help from the mailing list.
5660 \end_layout
5661
5662 \begin_layout Subsection
5663 What the 
5664 \begin_inset Quotes sld
5665 \end_inset
5666
5667 ./configure
5668 \begin_inset Quotes srd
5669 \end_inset
5670
5671  does
5672 \end_layout
5673
5674 \begin_layout Standard
5675 The 
5676 \begin_inset Quotes sld
5677 \end_inset
5678
5679 ./configure
5680 \begin_inset Quotes srd
5681 \end_inset
5682
5683  command is a script that analyzes your system and performs some configuration
5684  to ensure the source package compiles on your system.
5685  It will take a few minutes to run, and will compile a few tests to determine
5686  what compiler features are installed.
5687 \end_layout
5688
5689 \begin_layout Subsection
5690 What the 
5691 \begin_inset Quotes sld
5692 \end_inset
5693
5694 make
5695 \begin_inset Quotes srd
5696 \end_inset
5697
5698  does
5699 \end_layout
5700
5701 \begin_layout Standard
5702 This runs the GNU make tool, which automatically compiles all the source
5703  packages into the final installed binary executables.
5704 \end_layout
5705
5706 \begin_layout Subsection
5707 What the 
5708 \begin_inset Quotes sld
5709 \end_inset
5710
5711 make install
5712 \begin_inset Quotes erd
5713 \end_inset
5714
5715  command does.
5716 \end_layout
5717
5718 \begin_layout Standard
5719 This will install the compiler, other executables libraries and include
5720  files into the appropriate directories.
5721  See sections 
5722 \begin_inset LatexCommand ref
5723 reference "sub:Install-paths"
5724
5725 \end_inset
5726
5727 ,\InsetSpace ~
5728
5729 \begin_inset LatexCommand ref
5730 reference "sub:Search-Paths"
5731
5732 \end_inset
5733
5734 \InsetSpace ~
5735 about install and search paths.
5736 \newline
5737 On most systems you will need super-user privilege
5738 s to do this.
5739 \end_layout
5740
5741 \begin_layout Section
5742 Components of SDCC
5743 \end_layout
5744
5745 \begin_layout Standard
5746 SDCC is not just a compiler, but a collection of tools by various developers.
5747  These include linkers, assemblers, simulators and other components.
5748  Here is a summary of some of the components.
5749  Note that the included simulator and assembler have separate documentation
5750  which you can find in the source package in their respective directories.
5751  As SDCC grows to include support for other processors, other packages from
5752  various developers are included and may have their own sets of documentation.
5753 \newline
5754
5755 \newline
5756 You
5757  might want to look at the files which are installed in <installdir>.
5758  At the time of this writing, we find the following programs for gcc-builds:
5759 \newline
5760
5761  
5762 \newline
5763 In <installdir>/bin:
5764 \end_layout
5765
5766 \begin_layout Itemize
5767 sdcc - The compiler.
5768 \end_layout
5769
5770 \begin_layout Itemize
5771 sdcpp - The C preprocessor.
5772 \end_layout
5773
5774 \begin_layout Itemize
5775 asx8051 - The assembler for 8051 type processors.
5776 \end_layout
5777
5778 \begin_layout Itemize
5779 as-z80
5780 \series bold
5781 ,
5782 \series default
5783  as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5784 \end_layout
5785
5786 \begin_layout Itemize
5787 aslink -The linker for 8051 type processors.
5788 \end_layout
5789
5790 \begin_layout Itemize
5791 link-z80
5792 \series bold
5793 ,
5794 \series default
5795  link-gbz80 - The Z80 and GameBoy Z80 linkers.
5796 \end_layout
5797
5798 \begin_layout Itemize
5799 s51 - The ucSim 8051 simulator.
5800 \end_layout
5801
5802 \begin_layout Itemize
5803 sdcdb - The source debugger.
5804 \end_layout
5805
5806 \begin_layout Itemize
5807 packihx - A tool to pack (compress) Intel hex files.
5808 \end_layout
5809
5810 \begin_layout Standard
5811 In <installdir>/share/sdcc/include
5812 \end_layout
5813
5814 \begin_layout Itemize
5815 the include files
5816 \end_layout
5817
5818 \begin_layout Standard
5819 In <installdir>/share/sdcc/lib
5820 \end_layout
5821
5822 \begin_layout Itemize
5823 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5824  relocatables.
5825 \end_layout
5826
5827 \begin_layout Standard
5828 In <installdir>/share/sdcc/doc
5829 \end_layout
5830
5831 \begin_layout Itemize
5832 the documentation
5833 \end_layout
5834
5835 \begin_layout Standard
5836 As development for other processors proceeds, this list will expand to include
5837  executables to support processors like AVR, PIC, etc.
5838 \end_layout
5839
5840 \begin_layout Subsection
5841 sdcc - The Compiler
5842 \end_layout
5843
5844 \begin_layout Standard
5845 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5846  the assembler and linkage editor.
5847 \end_layout
5848
5849 \begin_layout Subsection
5850 sdcpp - The C-Preprocessor
5851 \end_layout
5852
5853 \begin_layout Standard
5854 The preprocessor
5855 \begin_inset LatexCommand index
5856 name "sdcpp (preprocessor)"
5857
5858 \end_inset
5859
5860  is a modified version of the GNU cpp
5861 \begin_inset LatexCommand index
5862 name "cpp|see{sdcpp}"
5863
5864 \end_inset
5865
5866  preprocessor 
5867 \begin_inset LatexCommand url
5868 target "http://gcc.gnu.org/"
5869
5870 \end_inset
5871
5872 .
5873  The C preprocessor is used to pull in #include sources, process #ifdef
5874  statements, #defines and so on.
5875 \end_layout
5876
5877 \begin_layout Subsection
5878 as
5879 \emph on
5880 xxxx
5881 \emph default
5882 , aslink, link-
5883 \emph on
5884 xxx
5885 \emph default
5886  - The Assemblers and Linkage Editors
5887 \end_layout
5888
5889 \begin_layout Standard
5890 This is retargettable assembler & linkage editor, it was developed by Alan
5891  Baldwin.
5892  John Hartman created the version for 8051, and I (Sandeep) have made some
5893  enhancements and bug fixes for it to work properly with SDCC.
5894 \end_layout
5895
5896 \begin_layout Subsection
5897 s51 - The Simulator
5898 \end_layout
5899
5900 \begin_layout Standard
5901 S51
5902 \begin_inset LatexCommand index
5903 name "s51"
5904
5905 \end_inset
5906
5907  is a free open source simulator developed by Daniel Drotos.
5908  The simulator is built as part of the build process.
5909  For more information visit Daniel's web site at: 
5910 \begin_inset LatexCommand url
5911 target "http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51"
5912
5913 \end_inset
5914
5915 .
5916  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5917  XA51 family.
5918 \end_layout
5919
5920 \begin_layout Subsection
5921 sdcdb - Source Level Debugger
5922 \end_layout
5923
5924 \begin_layout Standard
5925 SDCDB
5926 \begin_inset LatexCommand index
5927 name "SDCDB (debugger)"
5928
5929 \end_inset
5930
5931  is the companion source level debugger.
5932  More about SDCDB in section 
5933 \begin_inset LatexCommand ref
5934 reference "cha:Debugging-with-SDCDB"
5935
5936 \end_inset
5937
5938 .
5939  The current version of the debugger uses Daniel's Simulator S51
5940 \begin_inset LatexCommand index
5941 name "s51"
5942
5943 \end_inset
5944
5945 , but can be easily changed to use other simulators.
5946 \end_layout
5947
5948 \begin_layout Chapter
5949 Using SDCC
5950 \end_layout
5951
5952 \begin_layout Section
5953 Compiling
5954 \end_layout
5955
5956 \begin_layout Subsection
5957 Single Source File Projects
5958 \end_layout
5959
5960 \begin_layout Standard
5961 For single source file 8051 projects the process is very simple.
5962  Compile your programs with the following command 
5963 \family sans
5964 \series bold
5965 "sdcc sourcefile.c".
5966
5967 \family default
5968 \series default
5969  This will compile, assemble and link your source file.
5970  Output files are as follows:
5971 \end_layout
5972
5973 \begin_layout Itemize
5974 sourcefile.asm
5975 \begin_inset LatexCommand index
5976 name "<file>.asm"
5977
5978 \end_inset
5979
5980  - Assembler source
5981 \begin_inset LatexCommand index
5982 name "Assembler source"
5983
5984 \end_inset
5985
5986  file created by the compiler
5987 \end_layout
5988
5989 \begin_layout Itemize
5990 sourcefile.lst
5991 \begin_inset LatexCommand index
5992 name "<file>.lst"
5993
5994 \end_inset
5995
5996  - Assembler listing
5997 \begin_inset LatexCommand index
5998 name "Assembler listing"
5999
6000 \end_inset
6001
6002  file created by the Assembler
6003 \end_layout
6004
6005 \begin_layout Itemize
6006 sourcefile.rst
6007 \begin_inset LatexCommand index
6008 name "<file>.rst"
6009
6010 \end_inset
6011
6012  - Assembler listing
6013 \begin_inset LatexCommand index
6014 name "Assembler listing"
6015
6016 \end_inset
6017
6018  file updated with linkedit information, created by linkage editor
6019 \end_layout
6020
6021 \begin_layout Itemize
6022 sourcefile.sym
6023 \begin_inset LatexCommand index
6024 name "<file>.sym"
6025
6026 \end_inset
6027
6028  - symbol listing
6029 \begin_inset LatexCommand index
6030 name "Symbol listing"
6031
6032 \end_inset
6033
6034  for the sourcefile, created by the assembler
6035 \end_layout
6036
6037 \begin_layout Itemize
6038 sourcefile.rel
6039 \begin_inset LatexCommand index
6040 name "<file>.rel"
6041
6042 \end_inset
6043
6044  or sourcefile.o
6045 \begin_inset LatexCommand index
6046 name "<file>.o"
6047
6048 \end_inset
6049
6050  - Object file
6051 \begin_inset LatexCommand index
6052 name "Object file"
6053
6054 \end_inset
6055
6056  created by the assembler, input to Linkage editor
6057 \end_layout
6058
6059 \begin_layout Itemize
6060 sourcefile.map
6061 \begin_inset LatexCommand index
6062 name "<file>.map"
6063
6064 \end_inset
6065
6066  - The memory map
6067 \begin_inset LatexCommand index
6068 name "Memory map"
6069
6070 \end_inset
6071
6072  for the load module, created by the Linker
6073 \end_layout
6074
6075 \begin_layout Itemize
6076 sourcefile.mem
6077 \begin_inset LatexCommand index
6078 name "<file>.mem"
6079
6080 \end_inset
6081
6082  - A file with a summary of the memory usage
6083 \end_layout
6084
6085 \begin_layout Itemize
6086 sourcefile.ihx
6087 \begin_inset LatexCommand index
6088 name "<file>.ihx"
6089
6090 \end_inset
6091
6092  - The load module in Intel hex format
6093 \begin_inset LatexCommand index
6094 name "Intel hex format"
6095
6096 \end_inset
6097
6098  (you can select the Motorola S19 format
6099 \begin_inset LatexCommand index
6100 name "Motorola S19 format"
6101
6102 \end_inset
6103
6104  with -
6105 \begin_inset ERT
6106 status collapsed
6107
6108 \begin_layout Standard
6109
6110
6111 \backslash
6112 /
6113 \end_layout
6114
6115 \end_inset
6116
6117 -out-fmt-s19
6118 \begin_inset LatexCommand index
6119 name "-\\/-out-fmt-s19"
6120
6121 \end_inset
6122
6123 .
6124  If you need another format you might want to use 
6125 \family sans
6126 \shape italic
6127 objdump
6128 \family default
6129 \shape default
6130
6131 \begin_inset LatexCommand index
6132 name "objdump (tool)"
6133
6134 \end_inset
6135
6136  or 
6137 \family sans
6138 \shape italic
6139 srecord
6140 \family default
6141 \shape default
6142
6143 \begin_inset LatexCommand index
6144 name "srecord (bin, hex, ... tool)"
6145
6146 \end_inset
6147
6148
6149 \begin_inset Note Note
6150 status collapsed
6151
6152 \begin_layout Standard
6153 hyperlinks needed
6154 \end_layout
6155
6156 \end_inset
6157
6158  - see also section 
6159 \begin_inset LatexCommand vref
6160 reference "sub:Postprocessing-the-Intel"
6161
6162 \end_inset
6163
6164 ).
6165  Both formats are documented in the documentation of srecord
6166 \begin_inset LatexCommand index
6167 name "srecord (bin, hex, ... tool)"
6168
6169 \end_inset
6170
6171
6172 \end_layout
6173
6174 \begin_layout Itemize
6175 sourcefile.adb
6176 \begin_inset LatexCommand index
6177 name "<file>.adb"
6178
6179 \end_inset
6180
6181  - An intermediate file containing debug information needed to create the
6182  .cdb file (with -
6183 \begin_inset ERT
6184 status collapsed
6185
6186 \begin_layout Standard
6187
6188
6189 \backslash
6190 /
6191 \end_layout
6192
6193 \end_inset
6194
6195 -debug
6196 \begin_inset LatexCommand index
6197 name "-\\/-debug"
6198
6199 \end_inset
6200
6201
6202 \end_layout
6203
6204 \begin_layout Itemize
6205 sourcefile.cdb
6206 \begin_inset LatexCommand index
6207 name "<file>.cdb"
6208
6209 \end_inset
6210
6211  - An optional file (with -
6212 \begin_inset ERT
6213 status collapsed
6214
6215 \begin_layout Standard
6216
6217
6218 \backslash
6219 /
6220 \end_layout
6221
6222 \end_inset
6223
6224 -debug) containing debug information.
6225  The format is documented in cdbfileformat.pdf
6226 \end_layout
6227
6228 \begin_layout Itemize
6229 sourcefile.
6230  - (no extension)
6231 \begin_inset LatexCommand index
6232 name "<file> (no extension)"
6233
6234 \end_inset
6235
6236  An optional AOMF or AOMF51
6237 \begin_inset LatexCommand index
6238 name "AOMF, AOMF51"
6239
6240 \end_inset
6241
6242  
6243 \begin_inset LatexCommand label
6244 name "OMF file"
6245
6246 \end_inset
6247
6248 file containing debug information (generated with option -
6249 \begin_inset ERT
6250 status collapsed
6251
6252 \begin_layout Standard
6253
6254
6255 \backslash
6256 /
6257 \end_layout
6258
6259 \end_inset
6260
6261 -debug).
6262  The (Intel) 
6263 \emph on
6264 a
6265 \emph default
6266 bsolute 
6267 \emph on
6268 o
6269 \emph default
6270 bject 
6271 \emph on
6272 m
6273 \emph default
6274 odule 
6275 \emph on
6276 f
6277 \emph default
6278 ormat is a subformat of the OMF51 format and is commonly used by third party
6279  tools (debuggers
6280 \begin_inset LatexCommand index
6281 name "Debugger"
6282
6283 \end_inset
6284
6285 , simulators, emulators).
6286 \end_layout
6287
6288 \begin_layout Itemize
6289 sourcefile.dump*
6290 \begin_inset LatexCommand index
6291 name "<file>.dump*"
6292
6293 \end_inset
6294
6295  - Dump file to debug the compiler it self (generated with option -
6296 \begin_inset ERT
6297 status collapsed
6298
6299 \begin_layout Standard
6300
6301
6302 \backslash
6303 /
6304 \end_layout
6305
6306 \end_inset
6307
6308 -dumpall) (see section 
6309 \begin_inset LatexCommand ref
6310 reference "sub:Intermediate-Dump-Options"
6311
6312 \end_inset
6313
6314 \InsetSpace ~
6315  and section 
6316 \begin_inset LatexCommand ref
6317 reference "sub:The-anatomy-of"
6318
6319 \end_inset
6320
6321 \InsetSpace ~
6322
6323 \begin_inset Quotes sld
6324 \end_inset
6325
6326 Anatomy of the compiler
6327 \begin_inset Quotes srd
6328 \end_inset
6329
6330 ).
6331 \end_layout
6332
6333 \begin_layout Subsection
6334 Postprocessing the Intel Hex
6335 \begin_inset LatexCommand index
6336 name "Intel hex format"
6337
6338 \end_inset
6339
6340  file
6341 \begin_inset LatexCommand label
6342 name "sub:Postprocessing-the-Intel"
6343
6344 \end_inset
6345
6346
6347 \end_layout
6348
6349 \begin_layout Standard
6350 In most cases this won't be needed but the Intel Hex file
6351 \begin_inset LatexCommand index
6352 name "<file>.ihx"
6353
6354 \end_inset
6355
6356  which is generated by SDCC might include lines of varying length and the
6357  addresses within the file are not guaranteed to be strictly ascending.
6358  If your toolchain or a bootloader does not like this you can use the tool
6359  
6360 \family typewriter
6361 packihx
6362 \family default
6363
6364 \begin_inset LatexCommand index
6365 name "packihx (tool)"
6366
6367 \end_inset
6368
6369  which is part of the SDCC distribution: 
6370 \newline
6371
6372 \newline
6373  
6374 \family sans
6375 \series bold
6376 packihx sourcefile.ihx >sourcefile.hex
6377 \family default
6378 \series default
6379
6380 \newline
6381
6382 \newline
6383 The separately available 
6384 \emph on
6385 srecord
6386 \emph default
6387
6388 \begin_inset LatexCommand index
6389 name "srecord (bin, hex, ... tool)"
6390
6391 \end_inset
6392
6393  package additionally allows to set undefined locations to a predefined
6394  value, to insert checksums
6395 \begin_inset LatexCommand index
6396 name "checksum"
6397
6398 \end_inset
6399
6400  of various flavours (crc, add, xor) and to perform other manipulations
6401  (convert, split, crop, offset, ...).
6402  
6403 \newline
6404
6405 \newline
6406
6407 \family sans
6408 \series bold
6409 srec_cat\InsetSpace ~
6410 \InsetSpace ~
6411 sourcefile.ihx -intel\InsetSpace ~
6412 \InsetSpace ~
6413 -o sourcefile.hex -intel
6414 \newline
6415
6416 \newline
6417
6418 \family default
6419 \series default
6420 An example for a more complex command line
6421 \begin_inset Foot
6422 status open
6423
6424 \begin_layout Standard
6425 the command backfills
6426 \begin_inset LatexCommand index
6427 name "backfill unused memory"
6428
6429 \end_inset
6430
6431  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
6432  block is zero.
6433  If the program counter on an mcs51 runs wild the backfill pattern 0x12
6434  will be interpreted as an 
6435 \family typewriter
6436 lcall
6437 \family default
6438  to address 
6439 \family typewriter
6440 0x1212
6441 \family default
6442  (where an emergency routine could sit).
6443 \end_layout
6444
6445 \end_inset
6446
6447  could look like:
6448 \newline
6449
6450 \newline
6451
6452 \family sans
6453 \series bold
6454 \size footnotesize
6455 srec_cat\InsetSpace ~
6456 sourcefile.ihx -intel\InsetSpace ~
6457 \InsetSpace ~
6458 -fill 0x12 0x0000 0xfffe\InsetSpace ~
6459 -little-endian-checksum-nega
6460 tive 0xfffe 0x02 0x02\InsetSpace ~
6461 \InsetSpace ~
6462 -o sourcefile.hex -intel
6463 \size default
6464
6465 \newline
6466
6467 \newline
6468
6469 \family default
6470 \series default
6471 The srecord package is available at 
6472 \begin_inset LatexCommand url
6473 target "http://sf.net/projects/srecord"
6474
6475 \end_inset
6476
6477  .
6478 \end_layout
6479
6480 \begin_layout Subsection
6481 Projects with Multiple Source Files
6482 \end_layout
6483
6484 \begin_layout Standard
6485 SDCC can compile only ONE file at a time.
6486  Let us for example assume that you have a project containing the following
6487  files:
6488 \newline
6489
6490 \newline
6491 foo1.c (contains some functions)
6492 \newline
6493 foo2.c (contains some more functions)
6494 \newline
6495 foomai
6496 n.c (contains more functions and the function main)
6497 \newline
6498
6499 \size footnotesize
6500
6501 \newline
6502
6503 \size default
6504 The first two files will need to be compiled separately with the commands:
6505 \size footnotesize
6506  
6507 \size default
6508
6509 \newline
6510
6511 \newline
6512
6513 \family sans
6514 \series bold
6515 sdcc\InsetSpace ~
6516 -c\InsetSpace ~
6517 foo1.c
6518 \family default
6519 \series default
6520 \size footnotesize
6521
6522 \newline
6523
6524 \family sans
6525 \series bold
6526 \size default
6527 sdcc\InsetSpace ~
6528 -c\InsetSpace ~
6529 foo2.c
6530 \family default
6531 \series default
6532
6533 \newline
6534
6535 \newline
6536 Then compile the source file containing the 
6537 \emph on
6538 main()
6539 \emph default
6540  function and link
6541 \begin_inset LatexCommand index
6542 name "Linker"
6543
6544 \end_inset
6545
6546  the files together with the following command: 
6547 \newline
6548
6549 \newline
6550
6551 \family sans
6552 \series bold
6553 sdcc\InsetSpace ~
6554 foomain.c\InsetSpace ~
6555 foo1.rel\InsetSpace ~
6556 foo2.rel
6557 \family default
6558 \series default
6559
6560 \begin_inset LatexCommand index
6561 name "<file>.rel"
6562
6563 \end_inset
6564
6565
6566 \newline
6567
6568 \newline
6569 Alternatively, 
6570 \emph on
6571 foomain.c
6572 \emph default
6573  can be separately compiled as well: 
6574 \family sans
6575 \series bold
6576
6577 \newline
6578
6579 \newline
6580 sdcc\InsetSpace ~
6581 -c\InsetSpace ~
6582 foomain.c
6583 \newline
6584 sdcc foomain.rel foo1.rel foo2.rel
6585 \newline
6586
6587 \newline
6588
6589 \family default
6590 \series default
6591 The file containing the 
6592 \emph on
6593 main()
6594 \emph default
6595  function 
6596 \noun on
6597 must
6598 \noun default
6599  be the 
6600 \noun on
6601 first
6602 \noun default
6603  file specified in the command line, since the linkage editor processes
6604  file in the order they are presented to it.
6605  The linker is invoked from SDCC using a script file with extension .lnk
6606 \begin_inset LatexCommand index
6607 name "<file>.lnk"
6608
6609 \end_inset
6610
6611 .
6612  You can view this file to troubleshoot linking problems such as those arising
6613  from missing libraries.
6614 \end_layout
6615
6616 \begin_layout Subsection
6617 Projects with Additional Libraries
6618 \begin_inset LatexCommand index
6619 name "Libraries"
6620
6621 \end_inset
6622
6623
6624 \end_layout
6625
6626 \begin_layout Standard
6627 Some reusable routines may be compiled into a library, see the documentation
6628  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6629  for how to create a 
6630 \emph on
6631 .lib
6632 \begin_inset LatexCommand index
6633 name "<file>.lib"
6634
6635 \end_inset
6636
6637
6638 \emph default
6639  library file.
6640  Libraries created in this manner can be included in the command line.
6641  Make sure you include the -L <library-path> option to tell the linker where
6642  to look for these files if they are not in the current directory.
6643  Here is an example, assuming you have the source file 
6644 \emph on
6645 foomain.c
6646 \emph default
6647  and a library 
6648 \emph on
6649 foolib.lib
6650 \emph default
6651  in the directory 
6652 \emph on
6653 mylib
6654 \emph default
6655  (if that is not the same as your current project):
6656 \newline
6657
6658 \newline
6659
6660 \family sans
6661 \series bold
6662 sdcc foomain.c foolib.lib -L mylib
6663 \newline
6664
6665 \newline
6666
6667 \family default
6668 \series default
6669 Note here that 
6670 \emph on
6671 mylib
6672 \emph default
6673  must be an absolute path name.
6674 \newline
6675
6676 \newline
6677 The most efficient way to use libraries is
6678  to keep separate modules in separate source files.
6679  The lib file now should name all the modules.rel
6680 \begin_inset LatexCommand index
6681 name "<file>.rel"
6682
6683 \end_inset
6684
6685  files.
6686  For an example see the standard library file 
6687 \emph on
6688 libsdcc.lib
6689 \emph default
6690  in the directory <installdir>/share/lib/small.
6691 \end_layout
6692
6693 \begin_layout Subsection
6694 Using sdcclib to Create and Manage Libraries
6695 \begin_inset LatexCommand index
6696 name "sdcclib"
6697
6698 \end_inset
6699
6700
6701 \end_layout
6702
6703 \begin_layout Standard
6704 Alternatively, instead of having a .rel file for each entry on the library
6705  file as described in the preceding section, sdcclib can be used to embed
6706  all the modules belonging to such library in the library file itself.
6707  This results in a larger library file, but it greatly reduces the number
6708  of disk files accessed by the linker.
6709   Additionally, the packed library file contains an index of all include
6710  modules and symbols that significantly speeds up the linking process.
6711  To display a list of options supported by sdcclib type:
6712 \newline
6713
6714 \end_layout
6715
6716 \begin_layout Standard
6717
6718 \family sans
6719 \series bold
6720 sdcclib -?
6721 \begin_inset LatexCommand index
6722 name "sdcclib"
6723
6724 \end_inset
6725
6726
6727 \newline
6728
6729 \newline
6730
6731 \family default
6732 \series default
6733 To create a new library file, start by compiling all the required modules.
6734  For example:
6735 \newline
6736
6737 \end_layout
6738
6739 \begin_layout Standard
6740
6741 \family sans
6742 \series bold
6743 sdcc -c _divsint.c
6744 \end_layout
6745
6746 \begin_layout Standard
6747
6748 \family sans
6749 \series bold
6750 sdcc -c _divuint.c
6751 \end_layout
6752
6753 \begin_layout Standard
6754
6755 \family sans
6756 \series bold
6757 sdcc -c _modsint.c
6758 \end_layout
6759
6760 \begin_layout Standard
6761
6762 \family sans
6763 \series bold
6764 sdcc -c _moduint.c
6765 \end_layout
6766
6767 \begin_layout Standard
6768
6769 \family sans
6770 \series bold
6771 sdcc -c _mulint.c
6772 \newline
6773
6774 \end_layout
6775
6776 \begin_layout Standard
6777 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6778  and _mulint.rel.
6779  The next step is to add the .rel files to the library file:
6780 \newline
6781
6782 \end_layout
6783
6784 \begin_layout Standard
6785
6786 \family sans
6787 \series bold
6788 sdcclib libint.lib _divsint.rel
6789 \family default
6790
6791 \begin_inset LatexCommand index
6792 name "sdcclib"
6793
6794 \end_inset
6795
6796
6797 \end_layout
6798
6799 \begin_layout Standard
6800
6801 \family sans
6802 \series bold
6803 sdcclib libint.lib _divuint.rel
6804 \end_layout
6805
6806 \begin_layout Standard
6807
6808 \family sans
6809 \series bold
6810 sdcclib libint.lib _modsint.rel
6811 \end_layout
6812
6813 \begin_layout Standard
6814
6815 \family sans
6816 \series bold
6817 sdcclib libint.lib _moduint.rel
6818 \end_layout
6819
6820 \begin_layout Standard
6821
6822 \family sans
6823 \series bold
6824 sdcclib libint.lib _mulint.rel
6825 \family default
6826 \series default
6827
6828 \newline
6829
6830 \end_layout
6831
6832 \begin_layout Standard
6833 Or, if you preffer:
6834 \family sans
6835 \series bold
6836
6837 \newline
6838
6839 \end_layout
6840
6841 \begin_layout Standard
6842
6843 \family sans
6844 \series bold
6845 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6846 \family default
6847 \series default
6848
6849 \newline
6850
6851 \end_layout
6852
6853 \begin_layout Standard
6854 If the file already exists in the library, it will be replaced.
6855  If a list of .rel files is available, you can tell sdcclib to add those
6856  files to a library.
6857  For example, if the file 'myliblist.txt' contains
6858 \family sans
6859 \series bold
6860
6861 \newline
6862
6863 \end_layout
6864
6865 \begin_layout Standard
6866
6867 \family sans
6868 \series bold
6869 _divsint.rel
6870 \end_layout
6871
6872 \begin_layout Standard
6873
6874 \family sans
6875 \series bold
6876 _divuint.rel
6877 \end_layout
6878
6879 \begin_layout Standard
6880
6881 \family sans
6882 \series bold
6883 _modsint.rel
6884 \end_layout
6885
6886 \begin_layout Standard
6887
6888 \family sans
6889 \series bold
6890 _moduint.rel
6891 \end_layout
6892
6893 \begin_layout Standard
6894
6895 \family sans
6896 \series bold
6897 _mulint.rel
6898 \family default
6899 \series default
6900
6901 \newline
6902
6903 \end_layout
6904
6905 \begin_layout Standard
6906 Use
6907 \family sans
6908 \series bold
6909
6910 \newline
6911
6912 \end_layout
6913
6914 \begin_layout Standard
6915
6916 \family sans
6917 \series bold
6918 sdcclib -l libint.lib myliblist.txt
6919 \family default
6920 \series default
6921
6922 \newline
6923
6924 \end_layout
6925
6926 \begin_layout Standard
6927 Additionally, you can instruct sdcclib to compiles the files before adding
6928  them to the library.
6929  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6930  For example:
6931 \family sans
6932 \series bold
6933
6934 \newline
6935
6936 \end_layout
6937
6938 \begin_layout Standard
6939
6940 \family sans
6941 \series bold
6942 set SDCCLIB_CC=sdcc -c
6943 \end_layout
6944
6945 \begin_layout Standard
6946
6947 \family sans
6948 \series bold
6949 sdcclib -l libint.lib myliblist.txt
6950 \family default
6951 \series default
6952
6953 \newline
6954
6955 \end_layout
6956
6957 \begin_layout Standard
6958 To see what modules and symbols are included in the library, options -s
6959  and -m are available.
6960  For example:
6961 \newline
6962
6963 \newline
6964
6965 \family sans
6966 \series bold
6967 sdcclib -s libint.lib
6968 \family default
6969
6970 \begin_inset LatexCommand index
6971 name "sdcclib"
6972
6973 \end_inset
6974
6975
6976 \newline
6977
6978 \family typewriter
6979 \series default
6980 _divsint.rel:
6981 \end_layout
6982
6983 \begin_layout Standard
6984
6985 \family typewriter
6986 __divsint_a_1_1
6987 \end_layout
6988
6989 \begin_layout Standard
6990
6991 \family typewriter
6992 __divsint_PARM_2
6993 \end_layout
6994
6995 \begin_layout Standard
6996
6997 \family typewriter
6998 __divsint
6999 \newline
7000 _divuint.rel:
7001 \end_layout
7002
7003 \begin_layout Standard
7004
7005 \family typewriter
7006 __divuint_a_1_1
7007 \end_layout
7008
7009 \begin_layout Standard
7010
7011 \family typewriter
7012 __divuint_PARM_2
7013 \end_layout
7014
7015 \begin_layout Standard
7016
7017 \family typewriter
7018 __divuint_reste_1_1
7019 \end_layout
7020
7021 \begin_layout Standard
7022
7023 \family typewriter
7024 __divuint_count_1_1
7025 \end_layout
7026
7027 \begin_layout Standard
7028
7029 \family typewriter
7030 __divuint
7031 \newline
7032 _modsint.rel:
7033 \end_layout
7034
7035 \begin_layout Standard
7036
7037 \family typewriter
7038 __modsint_a_1_1
7039 \end_layout
7040
7041 \begin_layout Standard
7042
7043 \family typewriter
7044 __modsint_PARM_2
7045 \end_layout
7046
7047 \begin_layout Standard
7048
7049 \family typewriter
7050 __modsint
7051 \newline
7052 _moduint.rel:
7053 \end_layout
7054
7055 \begin_layout Standard
7056
7057 \family typewriter
7058 __moduint_a_1_1
7059 \end_layout
7060
7061 \begin_layout Standard
7062
7063 \family typewriter
7064 __moduint_PARM_2
7065 \end_layout
7066
7067 \begin_layout Standard
7068
7069 \family typewriter
7070 __moduint_count_1_1
7071 \end_layout
7072
7073 \begin_layout Standard
7074
7075 \family typewriter
7076 __moduint
7077 \newline
7078 _mulint.rel:
7079 \end_layout
7080
7081 \begin_layout Standard
7082
7083 \family typewriter
7084 __mulint_PARM_2
7085 \end_layout
7086
7087 \begin_layout Standard
7088
7089 \family typewriter
7090 __mulint
7091 \family default
7092 \series bold
7093
7094 \newline
7095
7096 \end_layout
7097
7098 \begin_layout Standard
7099 If the source files are compiled using -
7100 \begin_inset ERT
7101 status collapsed
7102
7103 \begin_layout Standard
7104
7105
7106 \backslash
7107 /
7108 \end_layout
7109
7110 \end_inset
7111
7112 -debug
7113 \begin_inset LatexCommand index
7114 name "-\\/-debug"
7115
7116 \end_inset
7117
7118 , the corresponding debug information file .adb will be include in the library
7119  file as well.
7120  The library files created with sdcclib are plain text files, so they can
7121  be viewed with a text editor.
7122  It is not recommended to modify a library file created with sdcclib using
7123  a text editor, as there are file indexes numbers located across the file
7124  used by the linker to quickly locate the required module to link.
7125  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
7126  it can be safely deleted, since all the information required for linking
7127  is embedded in the library file itself.
7128  Library files created using sdcclib are used as described in the preceding
7129  sections.
7130 \end_layout
7131
7132 \begin_layout Subsection
7133 Using ar to Create and Manage Libraries
7134 \begin_inset LatexCommand index
7135 name "ar"
7136
7137 \end_inset
7138
7139
7140 \end_layout
7141
7142 \begin_layout Standard
7143 Support for ar format libraries was introduced in sdcc 2.9.0.
7144  Ar is a standard archive managing utility on unices (Linux, Mac OS X, several
7145  unix flavors) so it is not included in the sdcc package.
7146 \series bold
7147
7148 \newline
7149
7150 \newline
7151
7152 \series default
7153 For Windows platform you can find ar utility in GNU binutils package included
7154  in several projects: Cygwin at 
7155 \begin_inset LatexCommand url
7156 target "http://www.cygwin.com/"
7157
7158 \end_inset
7159
7160 , MinGW at 
7161 \begin_inset LatexCommand url
7162 target "http://www.mingw.org/"
7163
7164 \end_inset
7165
7166 .
7167 \series bold
7168
7169 \newline
7170
7171 \newline
7172
7173 \series default
7174 Both the GNU and BSD ar format variants are suppurated by asxxxx linkers.
7175  Ar doesn't understand the asxxxx object file format, so there is a special
7176  version of ranlib distributed with sdcc, called asranlib, which produces
7177  the ar symbol lookup table.
7178 \series bold
7179
7180 \newline
7181
7182 \newline
7183
7184 \series default
7185 To create a library containing asxxxx object files, you should use the following
7186  sequence:
7187 \series bold
7188
7189 \newline
7190
7191 \end_layout
7192
7193 \begin_layout Standard
7194
7195 \family sans
7196 \series bold
7197 ar -Sq <library name>.lib <list of .rel files>
7198 \end_layout
7199
7200 \begin_layout Standard
7201
7202 \family sans
7203 \series bold
7204 asranlib <library name>.lib
7205 \end_layout
7206
7207 \begin_layout Standard
7208 \begin_inset VSpace bigskip
7209 \end_inset
7210
7211
7212 \end_layout
7213
7214 \begin_layout Section
7215 Command Line Options
7216 \begin_inset LatexCommand index
7217 name "Command Line Options"
7218
7219 \end_inset
7220
7221
7222 \begin_inset LatexCommand label
7223 name "sec:Command-Line-Options"
7224
7225 \end_inset
7226
7227
7228 \end_layout
7229
7230 \begin_layout Subsection
7231 Processor Selection Options
7232 \begin_inset LatexCommand index
7233 name "Options processor selection"
7234
7235 \end_inset
7236
7237
7238 \begin_inset LatexCommand index
7239 name "Processor selection options"
7240
7241 \end_inset
7242
7243
7244 \end_layout
7245
7246 \begin_layout List
7247 \labelwidthstring 00.00.0000
7248
7249 \series bold
7250 -mmcs51
7251 \begin_inset LatexCommand index
7252 name "-mmcs51"
7253
7254 \end_inset
7255
7256
7257 \series default
7258  Generate code for the Intel MCS51
7259 \begin_inset LatexCommand index
7260 name "MCS51"
7261
7262 \end_inset
7263
7264  family of processors.
7265  This is the default processor target.
7266 \end_layout
7267
7268 \begin_layout List
7269 \labelwidthstring 00.00.0000
7270
7271 \series bold
7272 -mds390
7273 \begin_inset LatexCommand index
7274 name "-mds390"
7275
7276 \end_inset
7277
7278
7279 \series default
7280  Generate code for the Dallas DS80C390
7281 \begin_inset LatexCommand index
7282 name "DS80C390"
7283
7284 \end_inset
7285
7286  processor.
7287 \end_layout
7288
7289 \begin_layout List
7290 \labelwidthstring 00.00.0000
7291
7292 \series bold
7293 -mds400
7294 \begin_inset LatexCommand index
7295 name "-mds400"
7296
7297 \end_inset
7298
7299
7300 \series default
7301  Generate code for the Dallas DS80C400
7302 \begin_inset LatexCommand index
7303 name "DS80C400"
7304
7305 \end_inset
7306
7307  processor.
7308 \end_layout
7309
7310 \begin_layout List
7311 \labelwidthstring 00.00.0000
7312
7313 \series bold
7314 -mhc08
7315 \begin_inset LatexCommand index
7316 name "-mhc08"
7317
7318 \end_inset
7319
7320
7321 \series default
7322  Generate code for the Freescale/Motorola HC08
7323 \begin_inset LatexCommand index
7324 name "HC08"
7325
7326 \end_inset
7327
7328  family of processors.
7329 \end_layout
7330
7331 \begin_layout List
7332 \labelwidthstring 00.00.0000
7333
7334 \series bold
7335 -mz80
7336 \begin_inset LatexCommand index
7337 name "-mz80"
7338
7339 \end_inset
7340
7341
7342 \series default
7343  Generate code for the Zilog Z80
7344 \begin_inset LatexCommand index
7345 name "Z80"
7346
7347 \end_inset
7348
7349  family of processors.
7350 \end_layout
7351
7352 \begin_layout List
7353 \labelwidthstring 00.00.0000
7354
7355 \series bold
7356 -mgbz80
7357 \begin_inset LatexCommand index
7358 name "-mgbz80"
7359
7360 \end_inset
7361
7362
7363 \series default
7364  Generate code for the GameBoy Z80
7365 \begin_inset LatexCommand index
7366 name "gbz80 (GameBoy Z80)"
7367
7368 \end_inset
7369
7370  processor (Not actively maintained).
7371 \end_layout
7372
7373 \begin_layout List
7374 \labelwidthstring 00.00.0000
7375
7376 \series bold
7377 -mavr
7378 \begin_inset LatexCommand index
7379 name "-mavr"
7380
7381 \end_inset
7382
7383
7384 \series default
7385  Generate code for the Atmel AVR
7386 \begin_inset LatexCommand index
7387 name "AVR"
7388
7389 \end_inset
7390
7391  processor (Not maintained, not complete).
7392  AVR users should probably have a look at winavr 
7393 \begin_inset LatexCommand url
7394 target "http://sourceforge.net/projects/winavr"
7395
7396 \end_inset
7397
7398  or 
7399 \begin_inset LatexCommand url
7400 target "http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index"
7401
7402 \end_inset
7403
7404 , which is based on AVR-port of the gcc compiler.
7405 \end_layout
7406
7407 \begin_layout Standard
7408 \begin_inset Note Note
7409 status collapsed
7410
7411 \begin_layout Standard
7412 I think it is fair to direct users there for now.
7413  Open source is also about avoiding unnecessary work .
7414  But I didn't find the 'official' link.
7415 \end_layout
7416
7417 \end_inset
7418
7419
7420 \end_layout
7421
7422 \begin_layout List
7423 \labelwidthstring 00.00.0000
7424
7425 \series bold
7426 -mpic14
7427 \begin_inset LatexCommand index
7428 name "-mpic14"
7429
7430 \end_inset
7431
7432
7433 \series default
7434  Generate code for the Microchip PIC 14
7435 \begin_inset LatexCommand index
7436 name "PIC14"
7437
7438 \end_inset
7439
7440 -bit processors (p16f84 and variants.
7441  In development, not complete).
7442 \end_layout
7443
7444 \begin_layout Standard
7445 \begin_inset Note Note
7446 status collapsed
7447
7448 \begin_layout Standard
7449 p16f627 p16f628 p16f84 p16f873 p16f877?
7450 \end_layout
7451
7452 \end_inset
7453
7454
7455 \end_layout
7456
7457 \begin_layout List
7458 \labelwidthstring 00.00.0000
7459
7460 \series bold
7461 -mpic16
7462 \begin_inset LatexCommand index
7463 name "-mpic16"
7464
7465 \end_inset
7466
7467
7468 \series default
7469  Generate code for the Microchip PIC 16
7470 \begin_inset LatexCommand index
7471 name "PIC16"
7472
7473 \end_inset
7474
7475 -bit processors (p18f452 and variants.
7476  In development, not complete).
7477 \end_layout
7478
7479 \begin_layout List
7480 \labelwidthstring 00.00.0000
7481
7482 \series bold
7483 -mtlcs900h
7484 \series default
7485  Generate code for the Toshiba TLCS-900H
7486 \begin_inset LatexCommand index
7487 name "TLCS-900H"
7488
7489 \end_inset
7490
7491  processor (Not maintained, not complete).
7492 \end_layout
7493
7494 \begin_layout List
7495 \labelwidthstring 00.00.0000
7496
7497 \series bold
7498 -mxa51
7499 \begin_inset LatexCommand index
7500 name "-mxa51"
7501
7502 \end_inset
7503
7504
7505 \series default
7506  Generate code for the Phillips XA51
7507 \begin_inset LatexCommand index
7508 name "XA51"
7509
7510 \end_inset
7511
7512  processor (Not maintained, not complete).
7513 \end_layout
7514
7515 \begin_layout Standard
7516 \begin_inset VSpace bigskip
7517 \end_inset
7518
7519
7520 \end_layout
7521
7522 \begin_layout Subsection
7523 Preprocessor Options
7524 \begin_inset LatexCommand index
7525 name "Options preprocessor"
7526
7527 \end_inset
7528
7529
7530 \begin_inset LatexCommand index
7531 name "Preprocessor options"
7532
7533 \end_inset
7534
7535
7536 \begin_inset LatexCommand index
7537 name "sdcpp (preprocessor)"
7538
7539 \end_inset
7540
7541
7542 \end_layout
7543
7544 \begin_layout List
7545 \labelwidthstring 00.00.0000
7546
7547 \series bold
7548 -I<path>
7549 \begin_inset LatexCommand index
7550 name "-I<path>"
7551
7552 \end_inset
7553
7554
7555 \series default
7556  The additional location where the preprocessor will look for <..h> or 
7557 \begin_inset Quotes eld
7558 \end_inset
7559
7560 ..h
7561 \begin_inset Quotes erd
7562 \end_inset
7563
7564  files.
7565 \end_layout
7566
7567 \begin_layout List
7568 \labelwidthstring 00.00.0000
7569
7570 \series bold
7571 -D<macro[=value]>
7572 \begin_inset LatexCommand index
7573 name "-D<macro[=value]>"
7574
7575 \end_inset
7576
7577
7578 \series default
7579  Command line definition of macros.
7580  Passed to the preprocessor.
7581 \end_layout
7582
7583 \begin_layout List
7584 \labelwidthstring 00.00.0000
7585
7586 \series bold
7587 -M
7588 \begin_inset LatexCommand index
7589 name "-M"
7590
7591 \end_inset
7592
7593
7594 \series default
7595  Tell the preprocessor to output a rule suitable for make describing the
7596  dependencies of each object file.
7597  For each source file, the preprocessor outputs one make-rule whose target
7598  is the object file name for that source file and whose dependencies are
7599  all the files `#include'd in it.
7600  This rule may be a single line or may be continued with `
7601 \backslash
7602 '-newline if it is long.
7603  The list of rules is printed on standard output instead of the preprocessed
7604  C program.
7605  `-M' implies `-E
7606 \begin_inset LatexCommand index
7607 name "-E"
7608
7609 \end_inset
7610
7611 '.
7612 \end_layout
7613
7614 \begin_layout List
7615 \labelwidthstring 00.00.0000
7616
7617 \series bold
7618 -C
7619 \begin_inset LatexCommand index
7620 name "-C"
7621
7622 \end_inset
7623
7624
7625 \series default
7626  Tell the preprocessor not to discard comments.
7627  Used with the `-E' option.
7628 \end_layout
7629
7630 \begin_layout List
7631 \labelwidthstring 00.00.0000
7632
7633 \series bold
7634 -MM
7635 \begin_inset LatexCommand index
7636 name "-MM"
7637
7638 \end_inset
7639
7640
7641 \series default
7642 \size large
7643  
7644 \size default
7645 Like `-M' but the output mentions only the user header files included with
7646  `#include 
7647 \begin_inset Quotes eld
7648 \end_inset
7649
7650 file"'.
7651  System header files included with `#include <file>' are omitted.
7652 \end_layout
7653
7654 \begin_layout List
7655 \labelwidthstring 00.00.0000
7656
7657 \series bold
7658 -Aquestion(answer)
7659 \begin_inset LatexCommand index
7660 name "-Aquestion(answer)"
7661
7662 \end_inset
7663
7664
7665 \series default
7666  Assert the answer answer for question, in case it is tested with a preprocessor
7667  conditional such as `#if #question(answer)'.
7668  `-A-' disables the standard assertions that normally describe the target
7669  machine.
7670 \end_layout
7671
7672 \begin_layout List
7673 \labelwidthstring 00.00.0000
7674
7675 \series bold
7676 -Umacro
7677 \begin_inset LatexCommand index
7678 name "-Umacro"
7679
7680 \end_inset
7681
7682
7683 \series default
7684  Undefine macro macro.
7685  `-U' options are evaluated after all `-D' options, but before any `-include'
7686  and `-imacros' options.
7687 \end_layout
7688
7689 \begin_layout List
7690 \labelwidthstring 00.00.0000
7691
7692 \series bold
7693 -dM
7694 \begin_inset LatexCommand index
7695 name "-dM"
7696
7697 \end_inset
7698
7699
7700 \series default
7701  Tell the preprocessor to output only a list of the macro definitions that
7702  are in effect at the end of preprocessing.
7703  Used with the `-E' option.
7704 \end_layout
7705
7706 \begin_layout List
7707 \labelwidthstring 00.00.0000
7708
7709 \series bold
7710 -dD
7711 \begin_inset LatexCommand index
7712 name "-dD"
7713
7714 \end_inset
7715
7716
7717 \series default
7718  Tell the preprocessor to pass all macro definitions into the output, in
7719  their proper sequence in the rest of the output.
7720 \end_layout
7721
7722 \begin_layout List
7723 \labelwidthstring 00.00.0000
7724
7725 \series bold
7726 -dN
7727 \begin_inset LatexCommand index
7728 name "-dN"
7729
7730 \end_inset
7731
7732
7733 \series default
7734 \size large
7735  
7736 \size default
7737 Like `-dD' except that the macro arguments and contents are omitted.
7738  Only `#define name' is included in the output.
7739 \end_layout
7740
7741 \begin_layout List
7742 \labelwidthstring 00.00.0000
7743
7744 \series bold
7745 -pedantic-parse-number
7746 \begin_inset LatexCommand index
7747 name "pedantic"
7748
7749 \end_inset
7750
7751
7752 \begin_inset LatexCommand index
7753 name "-pedantic-parse-number"
7754
7755 \end_inset
7756
7757
7758 \size large
7759 \bar under
7760
7761 \begin_inset LatexCommand label
7762 name "lyx:-pedantic-parse-number"
7763
7764 \end_inset
7765
7766
7767 \series default
7768 \bar default
7769  
7770 \size default
7771 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7772  and the macro LO_B(3) gets expanded.
7773  See also #pragma pedantic_parse_number 
7774 \begin_inset LatexCommand vpageref
7775 reference "ite:pedantic_parse_number"
7776
7777 \end_inset
7778
7779  in section
7780 \begin_inset LatexCommand ref
7781 reference "sec:Pragmas"
7782
7783 \end_inset
7784
7785  
7786 \emph on
7787 Note: this functionality is not in conformance with C99 standard!
7788 \end_layout
7789
7790 \begin_layout List
7791 \labelwidthstring 00.00.0000
7792
7793 \series bold
7794 -Wp\InsetSpace ~
7795 preprocessorOption[,preprocessorOption]
7796 \series default
7797
7798 \begin_inset LatexCommand index
7799 name "-Wp preprocessorOption[,preprocessorOption]"
7800
7801 \end_inset
7802
7803 ...
7804  Pass the preprocessorOption to the preprocessor 
7805 \family typewriter
7806 sdcpp
7807 \family default
7808
7809 \begin_inset LatexCommand index
7810 name "sdcpp (preprocessor)"
7811
7812 \end_inset
7813
7814 .
7815  SDCC uses an adapted version of the GNU Compiler Collection
7816 \begin_inset LatexCommand index
7817 name "gcc (GNU Compiler Collection)"
7818
7819 \end_inset
7820
7821  preprocessor 
7822 \emph on
7823 cpp
7824 \emph default
7825  (
7826 \emph on
7827 gcc
7828 \emph default
7829  
7830 \begin_inset LatexCommand url
7831 target "http://gcc.gnu.org/"
7832
7833 \end_inset
7834
7835 ).
7836  If you need more dedicated options please refer to the GCC\InsetSpace ~
7837 CPP\InsetSpace ~
7838 Manual at
7839  
7840 \begin_inset LatexCommand htmlurl
7841 target "http://www.gnu.org/software/gcc/onlinedocs/"
7842
7843 \end_inset
7844
7845 .
7846 \end_layout
7847
7848 \begin_layout Standard
7849 \begin_inset VSpace bigskip
7850 \end_inset
7851
7852
7853 \end_layout
7854
7855 \begin_layout Subsection
7856 Linker Options
7857 \begin_inset LatexCommand index
7858 name "Options linker"
7859
7860 \end_inset
7861
7862
7863 \begin_inset LatexCommand index
7864 name "Linker options"
7865
7866 \end_inset
7867
7868
7869 \end_layout
7870
7871 \begin_layout List
7872 \labelwidthstring 00.00.0000
7873
7874 \series bold
7875 -L\InsetSpace ~
7876 -
7877 \series default
7878
7879 \begin_inset ERT
7880 status collapsed
7881
7882 \begin_layout Standard
7883
7884
7885 \backslash
7886 /
7887 \end_layout
7888
7889 \end_inset
7890
7891
7892 \series bold
7893 -lib-path
7894 \begin_inset LatexCommand index
7895 name "-\\/-lib-path <path>"
7896
7897 \end_inset
7898
7899
7900 \begin_inset LatexCommand index
7901 name "-L <path>"
7902
7903 \end_inset
7904
7905
7906 \series default
7907 \InsetSpace ~
7908 <absolute path to additional libraries> This option is passed to the linkage
7909  editor's additional libraries
7910 \begin_inset LatexCommand index
7911 name "Libraries"
7912
7913 \end_inset
7914
7915  search path.
7916  The path name must be absolute.
7917  Additional library files may be specified in the command line.
7918  See section Compiling programs for more details.
7919 \end_layout
7920
7921 \begin_layout List
7922 \labelwidthstring 00.00.0000
7923
7924 \series bold
7925 -
7926 \begin_inset ERT
7927 status collapsed
7928
7929 \begin_layout Standard
7930
7931
7932 \backslash
7933 /
7934 \end_layout
7935
7936 \end_inset
7937
7938 -xram-loc
7939 \series default
7940
7941 \begin_inset LatexCommand index
7942 name "-\\/-xram-loc <Value>"
7943
7944 \end_inset
7945
7946 \InsetSpace ~
7947 <Value> The start location of the external ram
7948 \begin_inset LatexCommand index
7949 name "xdata (mcs51, ds390 storage class)"
7950
7951 \end_inset
7952
7953 , default value is 0.
7954  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7955 \begin_inset ERT
7956 status collapsed
7957
7958 \begin_layout Standard
7959
7960
7961 \backslash
7962 /
7963 \end_layout
7964
7965 \end_inset
7966
7967 -xram-loc 0x8000 or -
7968 \begin_inset ERT
7969 status collapsed
7970
7971 \begin_layout Standard
7972
7973
7974 \backslash
7975 /
7976 \end_layout
7977
7978 \end_inset
7979
7980 -xram-loc 32768.
7981 \end_layout
7982
7983 \begin_layout List
7984 \labelwidthstring 00.00.0000
7985
7986 \series bold
7987 -
7988 \begin_inset ERT
7989 status collapsed
7990
7991 \begin_layout Standard
7992
7993
7994 \backslash
7995 /
7996 \end_layout
7997
7998 \end_inset
7999
8000 -code-loc
8001 \series default
8002
8003 \begin_inset LatexCommand index
8004 name "-\\/-code-loc <Value>"
8005
8006 \end_inset
8007
8008 \InsetSpace ~
8009 <Value> The start location of the code
8010 \begin_inset LatexCommand index
8011 name "code"
8012
8013 \end_inset
8014
8015  segment, default value 0.
8016  Note when this option is used the interrupt vector table
8017 \begin_inset LatexCommand index
8018 name "interrupt vector table"
8019
8020 \end_inset
8021
8022  is also relocated to the given address.
8023  The value entered can be in Hexadecimal or Decimal format, e.g.: -
8024 \begin_inset ERT
8025 status collapsed
8026
8027 \begin_layout Standard
8028
8029
8030 \backslash
8031 /
8032 \end_layout
8033
8034 \end_inset
8035
8036 -code-loc 0x8000 or -
8037 \begin_inset ERT
8038 status collapsed
8039
8040 \begin_layout Standard
8041
8042
8043 \backslash
8044 /
8045 \end_layout
8046
8047 \end_inset
8048
8049 -code-loc 32768.
8050 \end_layout
8051
8052 \begin_layout List
8053 \labelwidthstring 00.00.0000
8054
8055 \series bold
8056 -
8057 \begin_inset ERT
8058 status collapsed
8059
8060 \begin_layout Standard
8061
8062
8063 \backslash
8064 /
8065 \end_layout
8066
8067 \end_inset
8068
8069 -stack-loc
8070 \series default
8071
8072 \begin_inset LatexCommand index
8073 name "-\\/-stack-loc <Value>"
8074
8075 \end_inset
8076
8077 \InsetSpace ~
8078 <Value> By default the stack
8079 \begin_inset LatexCommand index
8080 name "stack"
8081
8082 \end_inset
8083
8084  is placed after the data segment.
8085  Using this option the stack can be placed anywhere in the internal memory
8086  space of the 8051.
8087  The value entered can be in Hexadecimal or Decimal format, e.g.
8088  -
8089 \begin_inset ERT
8090 status collapsed
8091
8092 \begin_layout Standard
8093
8094
8095 \backslash
8096 /
8097 \end_layout
8098
8099 \end_inset
8100
8101 -stack-loc 0x20 or -
8102 \begin_inset ERT
8103 status collapsed
8104
8105 \begin_layout Standard
8106
8107
8108 \backslash
8109 /
8110 \end_layout
8111
8112 \end_inset
8113
8114 -stack-loc 32.
8115  Since the sp register is incremented before a push or call, the initial
8116  sp will be set to one byte prior the provided value.
8117  The provided value should not overlap any other memory areas such as used
8118  register banks or the data segment and with enough space for the current
8119  application.
8120  The 
8121 \series bold
8122 -
8123 \begin_inset ERT
8124 status collapsed
8125
8126 \begin_layout Standard
8127
8128
8129 \backslash
8130 /
8131 \end_layout
8132
8133 \end_inset
8134
8135 -pack-iram
8136 \series default
8137 \InsetSpace ~
8138
8139 \begin_inset LatexCommand index
8140 name "-\\/-pack-iram"
8141
8142 \end_inset
8143
8144  option (which is now a default setting) will override this setting, so
8145  you should also specify the 
8146 \series bold
8147 -
8148 \begin_inset ERT
8149 status collapsed
8150
8151 \begin_layout Standard
8152
8153
8154 \backslash
8155 /
8156 \end_layout
8157
8158 \end_inset
8159
8160 -no-pack-iram
8161 \series default
8162 \InsetSpace ~
8163
8164 \begin_inset LatexCommand index
8165 name "-\\/-no-pack-iram"
8166
8167 \end_inset
8168
8169  option if you need to manually place the stack.
8170 \end_layout
8171
8172 \begin_layout List
8173 \labelwidthstring 00.00.0000
8174
8175 \series bold
8176 -
8177 \begin_inset ERT
8178 status collapsed
8179
8180 \begin_layout Standard
8181
8182
8183 \backslash
8184 /
8185 \end_layout
8186
8187 \end_inset
8188
8189 -xstack-loc
8190 \series default
8191
8192 \begin_inset LatexCommand index
8193 name "-\\/-xstack-loc <Value>"
8194
8195 \end_inset
8196
8197 \InsetSpace ~
8198 <Value> By default the external stack
8199 \begin_inset LatexCommand index
8200 name "xstack"
8201
8202 \end_inset
8203
8204  is placed after the pdata
8205 \begin_inset LatexCommand index
8206 name "pdata (mcs51, ds390 storage class)"
8207
8208 \end_inset
8209
8210  segment.
8211  Using this option the xstack can be placed anywhere in the external memory
8212  space of the 8051.
8213  The value entered can be in Hexadecimal or Decimal format, e.g.
8214  -
8215 \begin_inset ERT
8216 status collapsed
8217
8218 \begin_layout Standard
8219
8220
8221 \backslash
8222 /
8223 \end_layout
8224
8225 \end_inset
8226
8227 -xstack-loc 0x8000 or -
8228 \begin_inset ERT
8229 status collapsed
8230
8231 \begin_layout Standard
8232
8233
8234 \backslash
8235 /
8236 \end_layout
8237
8238 \end_inset
8239
8240 -stack-loc 32768.
8241  The provided value should not overlap any other memory areas such as the
8242  pdata or xdata segment and with enough space for the current application.
8243 \end_layout
8244
8245 \begin_layout List
8246 \labelwidthstring 00.00.0000
8247
8248 \series bold
8249 -
8250 \begin_inset ERT
8251 status collapsed
8252
8253 \begin_layout Standard
8254
8255
8256 \backslash
8257 /
8258 \end_layout
8259
8260 \end_inset
8261
8262 -data-loc
8263 \series default
8264
8265 \begin_inset LatexCommand index
8266 name "-\\/-data-loc <Value>"
8267
8268 \end_inset
8269
8270 \InsetSpace ~
8271 <Value> The start location of the internal ram data
8272 \begin_inset LatexCommand index
8273 name "data (mcs51, ds390 storage class)"
8274
8275 \end_inset
8276
8277  segment.
8278  The value entered can be in Hexadecimal or Decimal format, eg.
8279  -
8280 \begin_inset ERT
8281 status collapsed
8282
8283 \begin_layout Standard
8284
8285
8286 \backslash
8287 /
8288 \end_layout
8289
8290 \end_inset
8291
8292 -data-loc 0x20 or -
8293 \begin_inset ERT
8294 status collapsed
8295
8296 \begin_layout Standard
8297
8298
8299 \backslash
8300 /
8301 \end_layout
8302
8303 \end_inset
8304
8305 -data-loc 32.
8306  (By default, the start location of the internal ram data segment  is set
8307  as low as possible in memory, taking into account the used register banks
8308  and the bit segment at address 0x20.
8309  For example if register banks 0 and 1 are used without bit variables, the
8310  data segment will be set, if -
8311 \begin_inset ERT
8312 status collapsed
8313
8314 \begin_layout Standard
8315
8316
8317 \backslash
8318 /
8319 \end_layout
8320
8321 \end_inset
8322
8323 -data-loc is not used, to location 0x10.)
8324 \end_layout
8325
8326 \begin_layout List
8327 \labelwidthstring 00.00.0000
8328
8329 \series bold
8330 -
8331 \begin_inset ERT
8332 status collapsed
8333
8334 \begin_layout Standard
8335
8336
8337 \backslash
8338 /
8339 \end_layout
8340
8341 \end_inset
8342
8343 -idata-loc
8344 \series default
8345
8346 \begin_inset LatexCommand index
8347 name "-\\/-idata-loc <Value>"
8348
8349 \end_inset
8350
8351 \InsetSpace ~
8352 <Value> The start location of the indirectly addressable internal ram
8353 \begin_inset LatexCommand index
8354 name "idata (mcs51, ds390 storage class)"
8355
8356 \end_inset
8357
8358  of the 8051, default value is 0x80.
8359  The value entered can be in Hexadecimal or Decimal format, eg.
8360  -
8361 \begin_inset ERT
8362 status collapsed
8363
8364 \begin_layout Standard
8365
8366
8367 \backslash
8368 /
8369 \end_layout
8370
8371 \end_inset
8372
8373 -idata-loc 0x88 or -
8374 \begin_inset ERT
8375 status collapsed
8376
8377 \begin_layout Standard
8378
8379
8380 \backslash
8381 /
8382 \end_layout
8383
8384 \end_inset
8385
8386 -idata-loc 136.
8387 \end_layout
8388
8389 \begin_layout List
8390 \labelwidthstring 00.00.0000
8391
8392 \series bold
8393 -
8394 \begin_inset ERT
8395 status collapsed
8396
8397 \begin_layout Standard
8398
8399
8400 \backslash
8401 /
8402 \end_layout
8403
8404 \end_inset
8405
8406 -bit-loc
8407 \series default
8408 \InsetSpace ~
8409 <Value> The start location of the bit
8410 \begin_inset LatexCommand index
8411 name "bit"
8412
8413 \end_inset
8414
8415  addressable internal ram of the 8051.
8416  This is 
8417 \emph on
8418 not
8419 \emph default
8420  implemented yet.
8421  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
8422 -bBSEG=<Value>.
8423 \end_layout
8424
8425 \begin_layout List
8426 \labelwidthstring 00.00.0000
8427
8428 \series bold
8429 -
8430 \begin_inset ERT
8431 status collapsed
8432
8433 \begin_layout Standard
8434
8435
8436 \backslash
8437 /
8438 \end_layout
8439
8440 \end_inset
8441
8442 -out-fmt-ihx
8443 \begin_inset LatexCommand index
8444 name "-\\/-out-fmt-ihx"
8445
8446 \end_inset
8447
8448  
8449 \series default
8450 The linker output (final object code) is in Intel Hex format.
8451 \begin_inset LatexCommand index
8452 name "Intel hex format"
8453
8454 \end_inset
8455
8456  This is the default option.
8457  The format itself is documented in the documentation of srecord
8458 \begin_inset LatexCommand index
8459 name "srecord (bin, hex, ... tool)"
8460
8461 \end_inset
8462
8463 .
8464 \end_layout
8465
8466 \begin_layout List
8467 \labelwidthstring 00.00.0000
8468
8469 \series bold
8470 -
8471 \begin_inset ERT
8472 status collapsed
8473
8474 \begin_layout Standard
8475
8476
8477 \backslash
8478 /
8479 \end_layout
8480
8481 \end_inset
8482
8483 -out-fmt-s19
8484 \begin_inset LatexCommand index
8485 name "-\\/-out-fmt-s19"
8486
8487 \end_inset
8488
8489  
8490 \series default
8491 The linker output (final object code) is in Motorola S19 format
8492 \begin_inset LatexCommand index
8493 name "Motorola S19 format"
8494
8495 \end_inset
8496
8497 .
8498  The format itself is documented in the documentation of srecord.
8499 \end_layout
8500
8501 \begin_layout List
8502 \labelwidthstring 00.00.0000
8503
8504 \series bold
8505 -
8506 \begin_inset ERT
8507 status collapsed
8508
8509 \begin_layout Standard
8510
8511
8512 \backslash
8513 /
8514 \end_layout
8515
8516 \end_inset
8517
8518 -out-fmt-elf
8519 \begin_inset LatexCommand index
8520 name "-\\/-out-fmt-s19"
8521
8522 \end_inset
8523
8524
8525 \begin_inset LatexCommand index
8526 name "HC08!Options!-\\/-out-fmt-elf"
8527
8528 \end_inset
8529
8530  
8531 \series default
8532 The linker output (final object code) is in ELF format
8533 \begin_inset LatexCommand index
8534 name "ELF format"
8535
8536 \end_inset
8537
8538 .
8539  (Currently only supported for the HC08
8540 \begin_inset LatexCommand index
8541 name "HC08"
8542
8543 \end_inset
8544
8545  processors)
8546 \end_layout
8547
8548 \begin_layout List
8549 \labelwidthstring 00.00.0000
8550
8551 \series bold
8552 -Wl\InsetSpace ~
8553 linkOption[,linkOption]
8554 \series default
8555
8556 \begin_inset LatexCommand index
8557 name "-Wl linkOption[,linkOption]"
8558
8559 \end_inset
8560
8561
8562 \begin_inset LatexCommand label
8563 name "lyx:-Wl option"
8564
8565 \end_inset
8566
8567 ...
8568  Pass the linkOption to the linker.
8569  If a bootloader is used an option like 
8570 \begin_inset Quotes sld
8571 \end_inset
8572
8573 -Wl\InsetSpace ~
8574 -bCSEG=0x1000
8575 \begin_inset Quotes srd
8576 \end_inset
8577
8578  would be typical to set the start of the code segment.
8579  Either use the double quotes around this option or use no space (e.g.
8580  -Wl-bCSEG=0x1000).
8581  See also #pragma constseg and #pragma codeseg in section 
8582 \begin_inset LatexCommand ref
8583 reference "sec:Pragmas"
8584
8585 \end_inset
8586
8587  .
8588  File sdcc/as/doc/asxhtm.html has more on linker options.
8589 \end_layout
8590
8591 \begin_layout Standard
8592 \begin_inset VSpace bigskip
8593 \end_inset
8594
8595
8596 \end_layout
8597
8598 \begin_layout Subsection
8599 MCS51 Options
8600 \begin_inset LatexCommand index
8601 name "Options MCS51"
8602
8603 \end_inset
8604
8605
8606 \begin_inset LatexCommand index
8607 name "MCS51 options"
8608
8609 \end_inset
8610
8611
8612 \end_layout
8613
8614 \begin_layout List
8615 \labelwidthstring 00.00.0000
8616
8617 \series bold
8618 -
8619 \begin_inset ERT
8620 status collapsed
8621
8622 \begin_layout Standard
8623
8624
8625 \backslash
8626 /
8627 \end_layout
8628
8629 \end_inset
8630
8631 -model-small
8632 \begin_inset LatexCommand index
8633 name "-\\/-model-small"
8634
8635 \end_inset
8636
8637
8638 \series default
8639 \size large
8640  
8641 \size default
8642 Generate code for Small Model programs, see section Memory Models for more
8643  details.
8644  This is the default model.
8645 \end_layout
8646
8647 \begin_layout List
8648 \labelwidthstring 00.00.0000
8649
8650 \series bold
8651 -
8652 \begin_inset ERT
8653 status collapsed
8654
8655 \begin_layout Standard
8656
8657
8658 \backslash
8659 /
8660 \end_layout
8661
8662 \end_inset
8663
8664 -model-medium
8665 \begin_inset LatexCommand index
8666 name "-\\/-model-medium"
8667
8668 \end_inset
8669
8670
8671 \series default
8672  Generate code for Medium model programs, see section Memory Models for
8673  more details.
8674  If this option is used all source files in the project have to be compiled
8675  with this option.
8676  It must also be used when invoking the linker.
8677 \end_layout
8678
8679 \begin_layout List
8680 \labelwidthstring 00.00.0000
8681
8682 \series bold
8683 -
8684 \begin_inset ERT
8685 status collapsed
8686
8687 \begin_layout Standard
8688
8689
8690 \backslash
8691 /
8692 \end_layout
8693
8694 \end_inset
8695
8696 -model-large
8697 \begin_inset LatexCommand index
8698 name "-\\/-model-large"
8699
8700 \end_inset
8701
8702
8703 \series default
8704  Generate code for Large model programs, see section Memory Models for more
8705  details.
8706  If this option is used all source files in the project have to be compiled
8707  with this option.
8708  It must also be used when invoking the linker.
8709 \end_layout
8710
8711 \begin_layout List
8712 \labelwidthstring 00.00.0000
8713
8714 \series bold
8715 -
8716 \begin_inset ERT
8717 status collapsed
8718
8719 \begin_layout Standard
8720
8721
8722 \backslash
8723 /
8724 \end_layout
8725
8726 \end_inset
8727
8728 -xstack
8729 \begin_inset LatexCommand index
8730 name "-\\/-xstack"
8731
8732 \end_inset
8733
8734
8735 \series default
8736  Uses a pseudo stack in the pdata
8737 \begin_inset LatexCommand index
8738 name "pdata (mcs51, ds390 storage class)"
8739
8740 \end_inset
8741
8742  area (usually the first 256 bytes in the external ram) for allocating variables
8743  and passing parameters.
8744  See section 
8745 \begin_inset LatexCommand ref
8746 reference "sub:External-Stack"
8747
8748 \end_inset
8749
8750 \InsetSpace ~
8751  External Stack for more details.
8752 \end_layout
8753
8754 \begin_layout List
8755 \labelwidthstring 00.00.0000
8756
8757 \series bold
8758 -
8759 \begin_inset ERT
8760 status collapsed
8761
8762 \begin_layout Standard
8763
8764
8765 \backslash
8766 /
8767 \end_layout
8768
8769 \end_inset
8770
8771 -iram-size
8772 \series default
8773 \InsetSpace ~
8774 <Value>
8775 \begin_inset LatexCommand index
8776 name "-\\/-iram-size <Value>"
8777
8778 \end_inset
8779
8780  Causes the linker to check if the internal ram usage is within limits of
8781  the given value.
8782 \end_layout
8783
8784 \begin_layout List
8785 \labelwidthstring 00.00.0000
8786
8787 \series bold
8788 -
8789 \begin_inset ERT
8790 status collapsed
8791
8792 \begin_layout Standard
8793
8794
8795 \backslash
8796 /
8797 \end_layout
8798
8799 \end_inset
8800
8801 -xram-size
8802 \series default
8803 \InsetSpace ~
8804 <Value>
8805 \begin_inset LatexCommand index
8806 name "-\\/-xram-size <Value>"
8807
8808 \end_inset
8809
8810  Causes the linker to check if the external ram usage is within limits of
8811  the given value.
8812 \end_layout
8813
8814 \begin_layout List
8815 \labelwidthstring 00.00.0000
8816
8817 \series bold
8818 -
8819 \begin_inset ERT
8820 status collapsed
8821
8822 \begin_layout Standard
8823
8824
8825 \backslash
8826 /
8827 \end_layout
8828
8829 \end_inset
8830
8831 -code-size
8832 \series default
8833 \InsetSpace ~
8834 <Value>
8835 \begin_inset LatexCommand index
8836 name "-\\/-code-size <Value>"
8837
8838 \end_inset
8839
8840  Causes the linker to check if the code memory usage is within limits of
8841  the given value.
8842 \end_layout
8843
8844 \begin_layout List
8845 \labelwidthstring 00.00.0000
8846
8847 \series bold
8848 -
8849 \begin_inset ERT
8850 status collapsed
8851
8852 \begin_layout Standard
8853
8854
8855 \backslash
8856 /
8857 \end_layout
8858
8859 \end_inset
8860
8861 -stack-size
8862 \series default
8863 \InsetSpace ~
8864 <Value>
8865 \begin_inset LatexCommand index
8866 name "-\\/-stack-size <Value>"
8867
8868 \end_inset
8869
8870  Causes the linker to check if there is at minimum <Value> bytes for stack.
8871 \end_layout
8872
8873 \begin_layout List
8874 \labelwidthstring 00.00.0000
8875
8876 \series bold
8877 -
8878 \begin_inset ERT
8879 status collapsed
8880
8881 \begin_layout Standard
8882
8883
8884 \backslash
8885 /
8886 \end_layout
8887
8888 \end_inset
8889
8890 -pack-iram
8891 \series default
8892 \InsetSpace ~
8893
8894 \begin_inset LatexCommand index
8895 name "-\\/-pack-iram"
8896
8897 \end_inset
8898
8899  Causes the linker to use unused register banks for data variables and pack
8900  data, idata and stack together.
8901  This is the default now.
8902 \end_layout
8903
8904 \begin_layout List
8905 \labelwidthstring 00.00.0000
8906
8907 \series bold
8908 -
8909 \begin_inset ERT
8910 status collapsed
8911
8912 \begin_layout Standard
8913
8914
8915 \backslash
8916 /
8917 \end_layout
8918
8919 \end_inset
8920
8921 -no-pack-iram
8922 \series default
8923 \InsetSpace ~
8924
8925 \begin_inset LatexCommand index
8926 name "-\\/-no-pack-iram"
8927
8928 \end_inset
8929
8930  Causes the linker to use old style for allocating memory areas.
8931 \end_layout
8932
8933 \begin_layout List
8934 \labelwidthstring 00.00.0000
8935
8936 \series bold
8937 -
8938 \begin_inset ERT
8939 status collapsed
8940
8941 \begin_layout Standard
8942
8943
8944 \backslash
8945 /
8946 \end_layout
8947
8948 \end_inset
8949
8950 -acall-ajmp
8951 \series default
8952 \InsetSpace ~
8953
8954 \begin_inset LatexCommand index
8955 name "-\\/-acall-ajmp"
8956
8957 \end_inset
8958
8959  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8960  acall/ajmp.
8961  Only use this option if your code is in the same 2k block of memory.
8962  You may need to use this option for some 8051 derivatives which lack the
8963  lcall/ljmp instructions..
8964 \end_layout
8965
8966 \begin_layout Standard
8967 \begin_inset VSpace bigskip
8968 \end_inset
8969
8970
8971 \end_layout
8972
8973 \begin_layout Subsection
8974 DS390 / DS400 Options
8975 \begin_inset LatexCommand index
8976 name "Options DS390"
8977
8978 \end_inset
8979
8980
8981 \begin_inset LatexCommand index
8982 name "DS390"
8983
8984 \end_inset
8985
8986
8987 \end_layout
8988
8989 \begin_layout List
8990 \labelwidthstring 00.00.0000
8991
8992 \series bold
8993 -
8994 \begin_inset ERT
8995 status collapsed
8996
8997 \begin_layout Standard
8998
8999
9000 \backslash
9001 /
9002 \end_layout
9003
9004 \end_inset
9005
9006 -model-flat24
9007 \series default
9008
9009 \begin_inset LatexCommand index
9010 name "DS390!Options!-\\/-model-flat24"
9011
9012 \end_inset
9013
9014
9015 \size large
9016  
9017 \size default
9018 Generate 24-bit flat mode code.
9019  This is the one and only that the ds390 code generator supports right now
9020  and is default when using 
9021 \emph on
9022 -mds390
9023 \emph default
9024 .
9025  See section Memory Models for more details.
9026 \end_layout
9027
9028 \begin_layout List
9029 \labelwidthstring 00.00.0000
9030
9031 \series bold
9032 -
9033 \begin_inset ERT
9034 status collapsed
9035
9036 \begin_layout Standard
9037
9038
9039 \backslash
9040 /
9041 \end_layout
9042
9043 \end_inset
9044
9045 -protect-sp-update
9046 \begin_inset LatexCommand index
9047 name "DS390!Options!-\\/-protect-sp-update"
9048
9049 \end_inset
9050
9051
9052 \series default
9053  disable interrupts during ESP:SP updates.
9054 \end_layout
9055
9056 \begin_layout List
9057 \labelwidthstring 00.00.0000
9058
9059 \series bold
9060 -
9061 \begin_inset ERT
9062 status collapsed
9063
9064 \begin_layout Standard
9065
9066
9067 \backslash
9068 /
9069 \end_layout
9070
9071 \end_inset
9072
9073 -stack-10bit
9074 \series default
9075
9076 \begin_inset LatexCommand index
9077 name "DS390!Options!-\\/-stack-10bit"
9078
9079 \end_inset
9080
9081  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
9082  This is the one and only that the ds390 code generator supports right now
9083  and is default when using 
9084 \emph on
9085 -mds390
9086 \emph default
9087 .
9088  In this mode, the stack is located in the lower 1K of the internal RAM,
9089  which is mapped to 0x400000.
9090  Note that the support is incomplete, since it still uses a single byte
9091  as the stack pointer.
9092  This means that only the lower 256 bytes of the potential 1K stack space
9093  will actually be used.
9094  However, this does allow you to reclaim the precious 256 bytes of low RAM
9095  for use for the DATA and IDATA segments.
9096  The compiler will not generate any code to put the processor into 10 bit
9097  stack mode.
9098  It is important to ensure that the processor is in this mode before calling
9099  any re-entrant functions compiled with this option.
9100  In principle, this should work with the 
9101 \emph on
9102 -
9103 \begin_inset ERT
9104 status collapsed
9105
9106 \begin_layout Standard
9107
9108
9109 \backslash
9110 /
9111 \end_layout
9112
9113 \end_inset
9114
9115 -stack-auto
9116 \begin_inset LatexCommand index
9117 name "-\\/-stack-auto"
9118
9119 \end_inset
9120
9121
9122 \emph default
9123  option, but that has not been tested.
9124  It is incompatible with the 
9125 \emph on
9126 -
9127 \begin_inset ERT
9128 status collapsed
9129
9130 \begin_layout Standard
9131
9132
9133 \backslash
9134 /
9135 \end_layout
9136
9137 \end_inset
9138
9139 -xstack
9140 \begin_inset LatexCommand index
9141 name "-\\/-xstack"
9142
9143 \end_inset
9144
9145
9146 \emph default
9147  option.
9148  It also only makes sense if the processor is in 24 bit contiguous addressing
9149  mode (see the 
9150 \emph on
9151 -
9152 \begin_inset ERT
9153 status collapsed
9154
9155 \begin_layout Standard
9156
9157
9158 \backslash
9159 /
9160 \end_layout
9161
9162 \end_inset
9163
9164 -model-flat24 option
9165 \emph default
9166 ).
9167 \series bold
9168
9169 \begin_inset Note Note
9170 status collapsed
9171
9172 \begin_layout List
9173 \labelwidthstring 00.00.0000
9174
9175 \series bold
9176 -
9177 \begin_inset ERT
9178 status open
9179
9180 \begin_layout Standard
9181
9182
9183 \backslash
9184 /
9185 \end_layout
9186
9187 \end_inset
9188
9189 -stack-8-bit - switches off the 10-bit mode
9190 \end_layout
9191
9192 \end_inset
9193
9194
9195 \end_layout
9196
9197 \begin_layout List
9198 \labelwidthstring 00.00.0000
9199
9200 \series bold
9201 -
9202 \begin_inset ERT
9203 status collapsed
9204
9205 \begin_layout Standard
9206
9207
9208 \backslash
9209 /
9210 \end_layout
9211
9212 \end_inset
9213
9214 -stack-probe
9215 \begin_inset LatexCommand index
9216 name "DS390!Options!-\\/-stack-probe"
9217
9218 \end_inset
9219
9220
9221 \series default
9222  insert call to function __stack_probe at each function prologue.
9223 \end_layout
9224
9225 \begin_layout List
9226 \labelwidthstring 00.00.0000
9227
9228 \series bold
9229 -
9230 \begin_inset ERT
9231 status open
9232
9233 \begin_layout Standard
9234
9235
9236 \backslash
9237 /
9238 \end_layout
9239
9240 \end_inset
9241
9242 -tini-libid
9243 \begin_inset LatexCommand index
9244 name "DS390!Options!-\\/-tini-libid"
9245
9246 \end_inset
9247
9248
9249 \series default
9250  <nnnn> LibraryID used in -mTININative.
9251  
9252 \end_layout
9253
9254 \begin_layout List
9255 \labelwidthstring 00.00.0000
9256
9257 \series bold
9258 -
9259 \begin_inset ERT
9260 status collapsed
9261
9262 \begin_layout Standard
9263
9264
9265 \backslash
9266 /
9267 \end_layout
9268
9269 \end_inset
9270
9271 -use-accelerator
9272 \begin_inset LatexCommand index
9273 name "DS390!Options!-\\/-use-accelerator"
9274
9275 \end_inset
9276
9277
9278 \series default
9279  generate code for DS390 Arithmetic Accelerator.
9280  
9281 \end_layout
9282
9283 \begin_layout Standard
9284 \begin_inset VSpace bigskip
9285 \end_inset
9286
9287
9288 \end_layout
9289
9290 \begin_layout Subsection
9291 Z80 Options
9292 \begin_inset LatexCommand index
9293 name "Options Z80"
9294
9295 \end_inset
9296
9297
9298 \begin_inset LatexCommand index
9299 name "Z80"
9300
9301 \end_inset
9302
9303
9304 \end_layout
9305
9306 \begin_layout List
9307 \labelwidthstring 00.00.0000
9308
9309 \series bold
9310 -
9311 \begin_inset ERT
9312 status collapsed
9313
9314 \begin_layout Standard
9315
9316
9317 \backslash
9318 /
9319 \end_layout
9320
9321 \end_inset
9322
9323 -callee-saves-bc
9324 \series default
9325
9326 \begin_inset LatexCommand index
9327 name "Z80!Options!-\\/-callee-saves-bc"
9328
9329 \end_inset
9330
9331
9332 \size large
9333  
9334 \size default
9335 Force a called function to always save BC.
9336 \end_layout
9337
9338 \begin_layout List
9339 \labelwidthstring 00.00.0000
9340
9341 \series bold
9342 -
9343 \begin_inset ERT
9344 status collapsed
9345
9346 \begin_layout Standard
9347
9348
9349 \backslash
9350 /
9351 \end_layout
9352
9353 \end_inset
9354
9355 -no-std-crt0
9356 \series default
9357
9358 \begin_inset LatexCommand index
9359 name "Z80!Options!-\\/-no-std-crt0"
9360
9361 \end_inset
9362
9363  When linking, skip the standard crt0.o object file.
9364  You must provide your own crt0.o for your system when linking.
9365 \end_layout
9366
9367 \begin_layout List
9368 \labelwidthstring 00.00.0000
9369
9370 \series bold
9371 -
9372 \begin_inset ERT
9373 status collapsed
9374
9375 \begin_layout Standard
9376
9377
9378 \backslash
9379 /
9380 \end_layout
9381
9382 \end_inset
9383
9384 -portmode=
9385 \series default
9386 <Value>
9387 \begin_inset LatexCommand index
9388 name "Z80!Options!-\\/-portmode=<Value>"
9389
9390 \end_inset
9391
9392  Determinate PORT I/O mode (<Value> is z80 or z180).
9393 \end_layout
9394
9395 \begin_layout List
9396 \labelwidthstring 00.00.0000
9397
9398 \series bold
9399 -
9400 \begin_inset ERT
9401 status collapsed
9402
9403 \begin_layout Standard
9404
9405
9406 \backslash
9407 /
9408 \end_layout
9409
9410 \end_inset
9411
9412 -asm=
9413 \series default
9414 <Value>
9415 \begin_inset LatexCommand index
9416 name "Z80!Options!-\\/-asm=<Value>"
9417
9418 \end_inset
9419
9420  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
9421 \end_layout
9422
9423 \begin_layout List
9424 \labelwidthstring 00.00.0000
9425
9426 \series bold
9427 -
9428 \begin_inset ERT
9429 status collapsed
9430
9431 \begin_layout Standard
9432
9433
9434 \backslash
9435 /
9436 \end_layout
9437
9438 \end_inset
9439
9440 -codeseg
9441 \series default
9442 \InsetSpace ~
9443 <Value>
9444 \begin_inset LatexCommand index
9445 name "Z80!Options!-\\/-codeseg <Value>"
9446
9447 \end_inset
9448
9449  Use <Value> for the code segment name.
9450 \end_layout
9451
9452 \begin_layout List
9453 \labelwidthstring 00.00.0000
9454
9455 \series bold
9456 -
9457 \begin_inset ERT
9458 status collapsed
9459
9460 \begin_layout Standard
9461
9462
9463 \backslash
9464 /
9465 \end_layout
9466
9467 \end_inset
9468
9469 -constseg
9470 \series default
9471 \InsetSpace ~
9472 <Value>
9473 \begin_inset LatexCommand index
9474 name "Z80!Options!-\\/-constseg <Value>"
9475
9476 \end_inset
9477
9478  Use <Value> for the const segment name.
9479 \end_layout
9480
9481 \begin_layout List
9482 \labelwidthstring 00.00.0000
9483 \begin_inset VSpace bigskip
9484 \end_inset
9485
9486
9487 \end_layout
9488
9489 \begin_layout Subsection
9490 GBZ80 Options
9491 \begin_inset LatexCommand index
9492 name "Options GBZ80"
9493
9494 \end_inset
9495
9496
9497 \begin_inset LatexCommand index
9498 name "GBZ80"
9499
9500 \end_inset
9501
9502
9503 \end_layout
9504
9505 \begin_layout List
9506 \labelwidthstring 00.00.0000
9507
9508 \series bold
9509 -
9510 \begin_inset ERT
9511 status collapsed
9512
9513 \begin_layout Standard
9514
9515
9516 \backslash
9517 /
9518 \end_layout
9519
9520 \end_inset
9521
9522 -callee-saves-bc
9523 \series default
9524
9525 \begin_inset LatexCommand index
9526 name "GBZ80!Options!-\\/-callee-saves-bc"
9527
9528 \end_inset
9529
9530
9531 \size large
9532  
9533 \size default
9534 Force a called function to always save BC.
9535 \end_layout
9536
9537 \begin_layout List
9538 \labelwidthstring 00.00.0000
9539
9540 \series bold
9541 -
9542 \begin_inset ERT
9543 status collapsed
9544
9545 \begin_layout Standard
9546
9547
9548 \backslash
9549 /
9550 \end_layout
9551
9552 \end_inset
9553
9554 -no-std-crt0
9555 \series default
9556
9557 \begin_inset LatexCommand index
9558 name "Z80!Options!-\\/-no-std-crt0"
9559
9560 \end_inset
9561
9562  When linking, skip the standard crt0.o object file.
9563  You must provide your own crt0.o for your system when linking.
9564 \end_layout
9565
9566 \begin_layout List
9567 \labelwidthstring 00.00.0000
9568
9569 \series bold
9570 -bo
9571 \series default
9572 \InsetSpace ~
9573 <Num>
9574 \begin_inset LatexCommand index
9575 name "GBZ80!Options!-bo <Num>"
9576
9577 \end_inset
9578
9579  Use code bank <Num>.
9580 \end_layout
9581
9582 \begin_layout List
9583 \labelwidthstring 00.00.0000
9584
9585 \series bold
9586 -ba
9587 \series default
9588 \InsetSpace ~
9589 <Num>
9590 \begin_inset LatexCommand index
9591 name "GBZ80!Options!-ba <Num>"
9592
9593 \end_inset
9594
9595  Use data bank <Num>.
9596 \end_layout
9597
9598 \begin_layout List
9599 \labelwidthstring 00.00.0000
9600
9601 \series bold
9602 -
9603 \begin_inset ERT
9604 status collapsed
9605
9606 \begin_layout Standard
9607
9608
9609 \backslash
9610 /
9611 \end_layout
9612
9613 \end_inset
9614
9615 -codeseg
9616 \series default
9617 \InsetSpace ~
9618 <Value>
9619 \begin_inset LatexCommand index
9620 name "GBZ80!Options!-\\/-codeseg <Value>"
9621
9622 \end_inset
9623
9624  Use <Value> for the code segment name.
9625 \end_layout
9626
9627 \begin_layout List
9628 \labelwidthstring 00.00.0000
9629
9630 \series bold
9631 -
9632 \begin_inset ERT
9633 status collapsed
9634
9635 \begin_layout Standard
9636
9637
9638 \backslash
9639 /
9640 \end_layout
9641
9642 \end_inset
9643
9644 -constseg
9645 \series default
9646 \InsetSpace ~
9647 <Value>
9648 \begin_inset LatexCommand index
9649 name "GBZ80!Options!-\\/-constseg <Value>"
9650
9651 \end_inset
9652
9653  Use <Value> for the const segment name.
9654 \end_layout
9655
9656 \begin_layout Standard
9657 \begin_inset VSpace bigskip
9658 \end_inset
9659
9660
9661 \end_layout
9662
9663 \begin_layout Subsection
9664 Optimization Options
9665 \begin_inset LatexCommand index
9666 name "Options optimization"
9667
9668 \end_inset
9669
9670
9671 \begin_inset LatexCommand index
9672 name "Optimization options"
9673
9674 \end_inset
9675
9676
9677 \end_layout
9678
9679 \begin_layout List
9680 \labelwidthstring 00.00.0000
9681
9682 \series bold
9683 -
9684 \begin_inset ERT
9685 status collapsed
9686
9687 \begin_layout Standard
9688
9689
9690 \backslash
9691 /
9692 \end_layout
9693
9694 \end_inset
9695
9696 -nogcse
9697 \begin_inset LatexCommand index
9698 name "-\\/-nogcse"
9699
9700 \end_inset
9701
9702
9703 \series default
9704  Will not do global subexpression elimination, this option may be used when
9705  the compiler creates undesirably large stack/data spaces to store compiler
9706  temporaries (
9707 \emph on
9708 s
9709 \emph default
9710 pill 
9711 \emph on
9712 loc
9713 \emph default
9714 ations, sloc
9715 \begin_inset LatexCommand index
9716 name "sloc (spill location)"
9717
9718 \end_inset
9719
9720 ).
9721  A warning message will be generated when this happens and the compiler
9722  will indicate the number of extra bytes it allocated.
9723  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9724 nogcse
9725 \begin_inset LatexCommand index
9726 name "\\#pragma nogcse"
9727
9728 \end_inset
9729
9730  can be used to turn off global subexpression elimination
9731 \begin_inset LatexCommand index
9732 name "Subexpression elimination"
9733
9734 \end_inset
9735
9736  for a given function only.
9737 \end_layout
9738
9739 \begin_layout List
9740 \labelwidthstring 00.00.0000
9741
9742 \series bold
9743 -
9744 \begin_inset ERT
9745 status collapsed
9746
9747 \begin_layout Standard
9748
9749
9750 \backslash
9751 /
9752 \end_layout
9753
9754 \end_inset
9755
9756 -noinvariant
9757 \begin_inset LatexCommand index
9758 name "-\\/-noinvariant"
9759
9760 \end_inset
9761
9762
9763 \series default
9764  Will not do loop invariant optimizations, this may be turned off for reasons
9765  explained for the previous option.
9766  For more details of loop optimizations performed see Loop Invariants in
9767  section 
9768 \begin_inset LatexCommand ref
9769 reference "sub:Loop-Optimizations"
9770
9771 \end_inset
9772
9773 .
9774  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9775 noinvariant
9776 \begin_inset LatexCommand index
9777 name "\\#pragma noinvariant"
9778
9779 \end_inset
9780
9781  can be used to turn off invariant optimizations for a given function only.
9782 \end_layout
9783
9784 \begin_layout List
9785 \labelwidthstring 00.00.0000
9786
9787 \series bold
9788 -
9789 \begin_inset ERT
9790 status collapsed
9791
9792 \begin_layout Standard
9793
9794
9795 \backslash
9796 /
9797 \end_layout
9798
9799 \end_inset
9800
9801 -noinduction
9802 \begin_inset LatexCommand index
9803 name "-\\/-noinduction"
9804
9805 \end_inset
9806
9807
9808 \series default
9809  Will not do loop induction optimizations, see section strength reduction
9810  for more details.
9811  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9812 noinduction
9813 \begin_inset LatexCommand index
9814 name "\\#pragma noinduction"
9815
9816 \end_inset
9817
9818  can be used to turn off induction optimizations for a given function only.
9819 \end_layout
9820
9821 \begin_layout List
9822 \labelwidthstring 00.00.0000
9823
9824 \series bold
9825 -
9826 \begin_inset ERT
9827 status collapsed
9828
9829 \begin_layout Standard
9830
9831
9832 \backslash
9833 /
9834 \end_layout
9835
9836 \end_inset
9837
9838 -nojtbound
9839 \begin_inset LatexCommand index
9840 name "-\\/-nojtbound"
9841
9842 \end_inset
9843
9844
9845 \size large
9846  
9847 \series default
9848 \size default
9849  Will not generate boundary condition check when switch statements
9850 \begin_inset LatexCommand index
9851 name "switch statement"
9852
9853 \end_inset
9854
9855  are implemented using jump-tables.
9856  See section 
9857 \begin_inset LatexCommand ref
9858 reference "sub:'switch'-Statements"
9859
9860 \end_inset
9861
9862 \InsetSpace ~
9863 Switch Statements for more details.
9864  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9865 nojtbound
9866 \begin_inset LatexCommand index
9867 name "\\#pragma nojtbound"
9868
9869 \end_inset
9870
9871  can be used to turn off boundary checking for jump tables for a given function
9872  only.
9873 \end_layout
9874
9875 \begin_layout List
9876 \labelwidthstring 00.00.0000
9877
9878 \series bold
9879 -
9880 \begin_inset ERT
9881 status collapsed
9882
9883 \begin_layout Standard
9884
9885
9886 \backslash
9887 /
9888 \end_layout
9889
9890 \end_inset
9891
9892 -noloopreverse
9893 \begin_inset LatexCommand index
9894 name "-\\/-noloopreverse"
9895
9896 \end_inset
9897
9898
9899 \series default
9900 \size large
9901  
9902 \size default
9903 Will not do loop reversal 
9904 \begin_inset LatexCommand index
9905 name "Loop reversing"
9906
9907 \end_inset
9908
9909 optimization.
9910 \end_layout
9911
9912 \begin_layout List
9913 \labelwidthstring 00.00.0000
9914 -
9915 \begin_inset ERT
9916 status collapsed
9917
9918 \begin_layout Standard
9919
9920
9921 \backslash
9922 /
9923 \end_layout
9924
9925 \end_inset
9926
9927 -
9928 \series bold
9929 nolabelopt
9930 \series default
9931  
9932 \begin_inset LatexCommand index
9933 name "-\\/-nolabelopt "
9934
9935 \end_inset
9936
9937 Will not optimize labels (makes the dumpfiles more readable).
9938 \end_layout
9939
9940 \begin_layout List
9941 \labelwidthstring 00.00.0000
9942
9943 \series bold
9944 -
9945 \begin_inset ERT
9946 status collapsed
9947
9948 \begin_layout Standard
9949
9950
9951 \backslash
9952 /
9953 \end_layout
9954
9955 \end_inset
9956
9957 -no-xinit-opt
9958 \begin_inset LatexCommand index
9959 name "-\\/-no-xinit-opt"
9960
9961 \end_inset
9962
9963
9964 \series default
9965  Will not memcpy initialized data from code space into xdata space.
9966  This saves a few bytes in code space if you don't have initialized data
9967 \begin_inset LatexCommand index
9968 name "Variable initialization"
9969
9970 \end_inset
9971
9972 .
9973 \end_layout
9974
9975 \begin_layout List
9976 \labelwidthstring 00.00.0000
9977
9978 \series bold
9979 -
9980 \begin_inset ERT
9981 status collapsed
9982
9983 \begin_layout Standard
9984
9985
9986 \backslash
9987 /
9988 \end_layout
9989
9990 \end_inset
9991
9992 -nooverlay
9993 \begin_inset LatexCommand index
9994 name "-\\/-nooverlay"
9995
9996 \end_inset
9997
9998
9999 \series default
10000   The compiler will not overlay parameters and local variables of any function,
10001  see section Parameters and local variables for more details.
10002 \end_layout
10003
10004 \begin_layout List
10005 \labelwidthstring 00.00.0000
10006
10007 \series bold
10008 -
10009 \begin_inset ERT
10010 status collapsed
10011
10012 \begin_layout Standard
10013
10014
10015 \backslash
10016 /
10017 \end_layout
10018
10019 \end_inset
10020
10021 -no-peep
10022 \begin_inset LatexCommand index
10023 name "-\\/-no-peep"
10024
10025 \end_inset
10026
10027
10028 \series default
10029  Disable peep-hole optimization with built-in rules.
10030 \end_layout
10031
10032 \begin_layout List
10033 \labelwidthstring 00.00.0000
10034
10035 \series bold
10036 -
10037 \begin_inset ERT
10038 status collapsed
10039
10040 \begin_layout Standard
10041
10042
10043 \backslash
10044 /
10045 \end_layout
10046
10047 \end_inset
10048
10049 -peep-file
10050 \series default
10051
10052 \begin_inset LatexCommand index
10053 name "-\\/-peep-file"
10054
10055 \end_inset
10056
10057 \InsetSpace ~
10058 <filename> This option can be used to use additional rules to be used by
10059  the peep hole optimizer.
10060  See section 
10061 \begin_inset LatexCommand ref
10062 reference "sub:Peephole-Optimizer"
10063
10064 \end_inset
10065
10066 \InsetSpace ~
10067 Peep Hole optimizations for details on how to write these rules.
10068 \end_layout
10069
10070 \begin_layout List
10071 \labelwidthstring 00.00.0000
10072
10073 \series bold
10074 -
10075 \begin_inset ERT
10076 status collapsed
10077
10078 \begin_layout Standard
10079
10080
10081 \backslash
10082 /
10083 \end_layout
10084
10085 \end_inset
10086
10087 -peep-asm
10088 \begin_inset LatexCommand index
10089 name "-\\/-peep-asm"
10090
10091 \end_inset
10092
10093
10094 \series default
10095  Pass the inline assembler code through the peep hole optimizer.
10096  This can cause unexpected changes to inline assembler code, please go through
10097  the peephole optimizer
10098 \begin_inset LatexCommand index
10099 name "Peephole optimizer"
10100
10101 \end_inset
10102
10103  rules defined in the source file tree '<target>/peeph.def' before using
10104  this option.
10105 \end_layout
10106
10107 \begin_layout List
10108 \labelwidthstring 00.00.0000
10109
10110 \series bold
10111 -
10112 \begin_inset ERT
10113 status collapsed
10114
10115 \begin_layout Standard
10116
10117
10118 \backslash
10119 /
10120 \end_layout
10121
10122 \end_inset
10123
10124 -opt-code-speed
10125 \begin_inset LatexCommand index
10126 name "-\\/-opt-code-speed"
10127
10128 \end_inset
10129
10130
10131 \series default
10132  The compiler will optimize code generation towards fast code, possibly
10133  at the expense of code size.
10134 \end_layout
10135
10136 \begin_layout List
10137 \labelwidthstring 00.00.0000
10138
10139 \series bold
10140 -
10141 \begin_inset ERT
10142 status collapsed
10143
10144 \begin_layout Standard
10145
10146
10147 \backslash
10148 /
10149 \end_layout
10150
10151 \end_inset
10152
10153 -opt-code-size
10154 \begin_inset LatexCommand index
10155 name "-\\/-opt-code-size"
10156
10157 \end_inset
10158
10159
10160 \series default
10161  The compiler will optimize code generation towards compact code, possibly
10162  at the expense of code speed.
10163 \end_layout
10164
10165 \begin_layout Standard
10166 \begin_inset VSpace bigskip
10167 \end_inset
10168
10169
10170 \end_layout
10171
10172 \begin_layout Subsection
10173 Other Options
10174 \begin_inset LatexCommand index
10175 name "Options other"
10176
10177 \end_inset
10178
10179
10180 \end_layout
10181
10182 \begin_layout List
10183 \labelwidthstring 00.00.0000
10184
10185 \series bold
10186 -v\InsetSpace ~
10187 -
10188 \begin_inset ERT
10189 status collapsed
10190
10191 \begin_layout Standard
10192
10193
10194 \backslash
10195 /
10196 \end_layout
10197
10198 \end_inset
10199
10200 -version
10201 \begin_inset LatexCommand index
10202 name "-\\/-version"
10203
10204 \end_inset
10205
10206
10207 \begin_inset LatexCommand index
10208 name "-v"
10209
10210 \end_inset
10211
10212
10213 \series default
10214  displays the sdcc version.
10215 \end_layout
10216
10217 \begin_layout List
10218 \labelwidthstring 00.00.0000
10219
10220 \series bold
10221 -c\InsetSpace ~
10222 -
10223 \begin_inset ERT
10224 status collapsed
10225
10226 \begin_layout Standard
10227
10228
10229 \backslash
10230 /
10231 \end_layout
10232
10233 \end_inset
10234
10235 -compile-only
10236 \begin_inset LatexCommand index
10237 name "-\\/-compile-only"
10238
10239 \end_inset
10240
10241
10242 \begin_inset LatexCommand index
10243 name "-c"
10244
10245 \end_inset
10246
10247
10248 \series default
10249  will compile and assemble the source, but will not call the linkage editor.
10250 \end_layout
10251
10252 \begin_layout List
10253 \labelwidthstring 00.00.0000
10254
10255 \series bold
10256 -
10257 \series default
10258
10259 \begin_inset ERT
10260 status collapsed
10261
10262 \begin_layout Standard
10263
10264
10265 \backslash
10266 /
10267 \end_layout
10268
10269 \end_inset
10270
10271
10272 \series bold
10273 -c1mode
10274 \begin_inset LatexCommand index
10275 name "-\\/-c1mode"
10276
10277 \end_inset
10278
10279
10280 \series default
10281  reads the preprocessed source from standard input and compiles it.
10282  The file name for the assembler output must be specified using the -o option.
10283 \end_layout
10284
10285 \begin_layout List
10286 \labelwidthstring 00.00.0000
10287
10288 \series bold
10289 -E
10290 \begin_inset LatexCommand index
10291 name "-E"
10292
10293 \end_inset
10294
10295
10296 \series default
10297  Run only the C preprocessor.
10298  Preprocess all the C source files specified and output the results to standard
10299  output.
10300 \end_layout
10301
10302 \begin_layout List
10303 \labelwidthstring 00.00.0000
10304
10305 \series bold
10306 -o\InsetSpace ~
10307 <path/file>
10308 \begin_inset LatexCommand index
10309 name "-o <path/file>"
10310
10311 \end_inset
10312
10313
10314 \series default
10315  The output path where everything will be placed or the file name used for
10316  all generated output files.
10317  If the parameter is a path, it must have a trailing slash (or backslash
10318  for the Windows binaries) to be recognized as a path.
10319  Note for Windows users: if the path contains spaces, it should be surrounded
10320  by quotes.
10321  The trailing backslash should be doubled in order to prevent escaping the
10322  final quote, for example: 
10323 \emph on
10324 -o 
10325 \begin_inset Quotes sld
10326 \end_inset
10327
10328 F:
10329 \backslash
10330 Projects
10331 \backslash
10332 test3
10333 \backslash
10334 output 1
10335 \backslash
10336
10337 \backslash
10338
10339 \begin_inset Quotes srd
10340 \end_inset
10341
10342
10343 \emph default
10344  or put after the final quote, for example: 
10345 \emph on
10346 -o 
10347 \begin_inset Quotes sld
10348 \end_inset
10349
10350 F:
10351 \backslash
10352 Projects
10353 \backslash
10354 test3
10355 \backslash
10356 output 1
10357 \begin_inset Quotes srd
10358 \end_inset
10359
10360
10361 \backslash
10362
10363 \emph default
10364 .
10365  The path using slashes for directory delimiters can be used too, for example:
10366  
10367 \emph on
10368 -o 
10369 \begin_inset Quotes sld
10370 \end_inset
10371
10372 F:/Projects/test3/output 1/
10373 \begin_inset Quotes srd
10374 \end_inset
10375
10376
10377 \emph default
10378 .
10379 \end_layout
10380
10381 \begin_layout List
10382 \labelwidthstring 00.00.0000
10383
10384 \series bold
10385 -
10386 \begin_inset ERT
10387 status collapsed
10388
10389 \begin_layout Standard
10390
10391
10392 \backslash
10393 /
10394 \end_layout
10395
10396 \end_inset
10397
10398 -stack-auto
10399 \begin_inset LatexCommand index
10400 name "-\\/-stack-auto"
10401
10402 \end_inset
10403
10404
10405 \series default
10406 \size large
10407  
10408 \size default
10409 All functions in the source file will be compiled as 
10410 \emph on
10411 reentrant
10412 \emph default
10413
10414 \begin_inset LatexCommand index
10415 name "reentrant"
10416
10417 \end_inset
10418
10419 , i.e.
10420  the parameters and local variables will be allocated on the stack
10421 \begin_inset LatexCommand index
10422 name "stack"
10423
10424 \end_inset
10425
10426 .
10427  See section 
10428 \begin_inset LatexCommand ref
10429 reference "sec:Parameters-and-Local-Variables"
10430
10431 \end_inset
10432
10433  Parameters and Local Variables for more details.
10434  If this option is used all source files in the project should be compiled
10435  with this option.
10436  It automatically implies -
10437 \series bold
10438
10439 \begin_inset ERT
10440 status open
10441
10442 \begin_layout Standard
10443
10444
10445 \backslash
10446 /
10447 \end_layout
10448
10449 \end_inset
10450
10451
10452 \series default
10453 -int-long-reent and -
10454 \series bold
10455
10456 \begin_inset ERT
10457 status open
10458
10459 \begin_layout Standard
10460
10461
10462 \backslash
10463 /
10464 \end_layout
10465
10466 \end_inset
10467
10468
10469 \series default
10470 -float-reent.
10471  
10472 \end_layout
10473
10474 \begin_layout List
10475 \labelwidthstring 00.00.0000
10476
10477 \series bold
10478 -
10479 \begin_inset ERT
10480 status collapsed
10481
10482 \begin_layout Standard
10483
10484
10485 \backslash
10486 /
10487 \end_layout
10488
10489 \end_inset
10490
10491 -callee-saves
10492 \begin_inset LatexCommand index
10493 name "-\\/-callee-saves"
10494
10495 \end_inset
10496
10497  
10498 \begin_inset LatexCommand label
10499 name "lyx:--callee-saves-function1[,function2][,function3]..."
10500
10501 \end_inset
10502
10503 function1[,function2][,function3]....
10504
10505 \series default
10506  The compiler by default uses a caller saves convention for register saving
10507  across function calls, however this can cause unnecessary register pushing
10508  and popping when calling small functions from larger functions.
10509  This option can be used to switch the register saving convention for the
10510  function names specified.
10511  The compiler will not save registers when calling these functions, no extra
10512  code will be generated at the entry and exit (function prologue
10513 \series bold
10514
10515 \begin_inset LatexCommand index
10516 name "function prologue"
10517
10518 \end_inset
10519
10520
10521 \series default
10522  and epilogue
10523 \series bold
10524
10525 \begin_inset LatexCommand index
10526 name "function epilogue"
10527
10528 \end_inset
10529
10530
10531 \series default
10532 ) for these functions to save and restore the registers used by these functions,
10533  this can SUBSTANTIALLY reduce code and improve run time performance of
10534  the generated code.
10535  In the future the compiler (with inter procedural analysis) will be able
10536  to determine the appropriate scheme to use for each function call.
10537  DO NOT use this option for built-in functions such as _mulint..., if this
10538  option is used for a library function the appropriate library function
10539  needs to be recompiled with the same option.
10540  If the project consists of multiple source files then all the source file
10541  should be compiled with the same -
10542 \begin_inset ERT
10543 status collapsed
10544
10545 \begin_layout Standard
10546
10547
10548 \backslash
10549 /
10550 \end_layout
10551
10552 \end_inset
10553
10554 -callee-saves option string.
10555  Also see #pragma\InsetSpace ~
10556 callee_saves 
10557 \begin_inset LatexCommand index
10558 name "\\#pragma callee\\_saves"
10559
10560 \end_inset
10561
10562  
10563 \begin_inset LatexCommand vpageref
10564 reference "ite:callee_saves-function1[,function2[,function3...]]--"
10565
10566 \end_inset
10567
10568 .
10569 \end_layout
10570
10571 \begin_layout List
10572 \labelwidthstring 00.00.0000
10573
10574 \series bold
10575 -
10576 \begin_inset ERT
10577 status collapsed
10578
10579 \begin_layout Standard
10580
10581
10582 \backslash
10583 /
10584 \end_layout
10585
10586 \end_inset
10587
10588 -all-callee-saves
10589 \begin_inset LatexCommand index
10590 name "-\\/-all-callee-saves"
10591
10592 \end_inset
10593
10594
10595 \series default
10596  Function of -
10597 \begin_inset ERT
10598 status collapsed
10599
10600 \begin_layout Standard
10601
10602
10603 \backslash
10604 /
10605 \end_layout
10606
10607 \end_inset
10608
10609 -callee-saves will be applied to all functions by default.
10610 \end_layout
10611
10612 \begin_layout List
10613 \labelwidthstring 00.00.0000
10614
10615 \series bold
10616 -
10617 \begin_inset ERT
10618 status collapsed
10619
10620 \begin_layout Standard
10621
10622
10623 \backslash
10624 /
10625 \end_layout
10626
10627 \end_inset
10628
10629 -debug
10630 \begin_inset LatexCommand index
10631 name "-\\/-debug"
10632
10633 \end_inset
10634
10635  
10636 \series default
10637 When this option is used the compiler will generate debug information.
10638  The debug information collected in a file with .cdb extension can be used
10639  with the SDCDB.
10640  For more information see documentation for SDCDB.
10641  Another file with no extension contains debug information in AOMF or AOMF51
10642 \begin_inset LatexCommand index
10643 name "AOMF, AOMF51"
10644
10645 \end_inset
10646
10647  format which is commonly used by third party tools.
10648 \end_layout
10649
10650 \begin_layout List
10651 \labelwidthstring 00.00.0000
10652
10653 \series bold
10654 -S
10655 \begin_inset LatexCommand index
10656 name "-S"
10657
10658 \end_inset
10659
10660
10661 \series default
10662 \size large
10663  
10664 \size default
10665 Stop after the stage of compilation proper; do not assemble.
10666  The output is an assembler code file for the input file specified.
10667 \end_layout
10668
10669 \begin_layout List
10670 \labelwidthstring 00.00.0000
10671
10672 \series bold
10673 -
10674 \begin_inset ERT
10675 status collapsed
10676
10677 \begin_layout Standard
10678
10679
10680 \backslash
10681 /
10682 \end_layout
10683
10684 \end_inset
10685
10686 -int-long-reent
10687 \begin_inset LatexCommand index
10688 name "-\\/-int-long-reent"
10689
10690 \end_inset
10691
10692
10693 \series default
10694  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
10695  Note by default these libraries are compiled as non-reentrant.
10696  See section Installation for more details.
10697 \end_layout
10698
10699 \begin_layout List
10700 \labelwidthstring 00.00.0000
10701
10702 \series bold
10703 -
10704 \begin_inset ERT
10705 status collapsed
10706
10707 \begin_layout Standard
10708
10709
10710 \backslash
10711 /
10712 \end_layout
10713
10714 \end_inset
10715
10716 -cyclomatic
10717 \begin_inset LatexCommand index
10718 name "-\\/-cyclomatic"
10719
10720 \end_inset
10721
10722  
10723 \series default
10724 This option will cause the compiler to generate an information message for
10725  each function in the source file.
10726  The message contains some 
10727 \emph on
10728 important
10729 \emph default
10730  information about the function.
10731  The number of edges and nodes the compiler detected in the control flow
10732  graph of the function, and most importantly the 
10733 \emph on
10734 cyclomatic complexity
10735 \begin_inset LatexCommand index
10736 name "Cyclomatic complexity"
10737
10738 \end_inset
10739
10740
10741 \emph default
10742  see section on Cyclomatic Complexity for more details.
10743 \end_layout
10744
10745 \begin_layout List
10746 \labelwidthstring 00.00.0000
10747
10748 \series bold
10749 -
10750 \begin_inset ERT
10751 status collapsed
10752
10753 \begin_layout Standard
10754
10755
10756 \backslash
10757 /
10758 \end_layout
10759
10760 \end_inset
10761
10762 -float-reent
10763 \begin_inset LatexCommand index
10764 name "-\\/-float-reent"
10765
10766 \end_inset
10767
10768
10769 \series default
10770  Floating point library is compiled as reentrant
10771 \begin_inset LatexCommand index
10772 name "reentrant"
10773
10774 \end_inset
10775
10776 .
10777  See section Installation for more details.
10778 \end_layout
10779
10780 \begin_layout List
10781 \labelwidthstring 00.00.0000
10782
10783 \series bold
10784 -
10785 \begin_inset ERT
10786 status collapsed
10787
10788 \begin_layout Standard
10789
10790
10791 \backslash
10792 /
10793 \end_layout
10794
10795 \end_inset
10796
10797 -funsigned-char
10798 \begin_inset LatexCommand index
10799 name "-\\/-funsigned-char"
10800
10801 \end_inset
10802
10803
10804 \series default
10805  The default signedness for every type is 
10806 \family typewriter
10807 signed
10808 \family default
10809 .
10810  In some embedded environments the default signedness of 
10811 \family typewriter
10812 char
10813 \family default
10814  is 
10815 \family typewriter
10816 unsigned
10817 \family default
10818 .
10819  To set the signess for characters to unsigned, use the option -
10820 \series bold
10821
10822 \begin_inset ERT
10823 status open
10824
10825 \begin_layout Standard
10826
10827
10828 \backslash
10829 /
10830 \end_layout
10831
10832 \end_inset
10833
10834
10835 \series default
10836 -funsigned-char.
10837  If this option is set and no signedness keyword (unsigned/signed) is given,
10838  a char will be signed.
10839  All other types are unaffected.
10840 \end_layout
10841
10842 \begin_layout List
10843 \labelwidthstring 00.00.0000
10844
10845 \series bold
10846 -
10847 \begin_inset ERT
10848 status collapsed
10849
10850 \begin_layout Standard
10851
10852
10853 \backslash
10854 /
10855 \end_layout
10856
10857 \end_inset
10858
10859 -main-return
10860 \begin_inset LatexCommand index
10861 name "-\\/-main-return"
10862
10863 \end_inset
10864
10865
10866 \series default
10867  This option can be used if the code generated is called by a monitor program
10868  or if the main routine includes an endless loop.
10869  This option results in slightly smaller code and saves two bytes of stack
10870  space.
10871  The return from the 'main'
10872 \begin_inset LatexCommand index
10873 name "main return"
10874
10875 \end_inset
10876
10877  function will return to the function calling main.
10878  The default setting is to lock up i.e.
10879  generate a '
10880 \family typewriter
10881 sjmp .
10882 \family default
10883 '.
10884 \end_layout
10885
10886 \begin_layout List
10887 \labelwidthstring 00.00.0000
10888
10889 \series bold
10890 -
10891 \begin_inset ERT
10892 status collapsed
10893
10894 \begin_layout Standard
10895
10896
10897 \backslash
10898 /
10899 \end_layout
10900
10901 \end_inset
10902
10903 -nostdinc
10904 \begin_inset LatexCommand index
10905 name "-\\/-nostdinc"
10906
10907 \end_inset
10908
10909
10910 \series default
10911  This will prevent the compiler from passing on the default include path
10912  to the preprocessor.
10913 \end_layout
10914
10915 \begin_layout List
10916 \labelwidthstring 00.00.0000
10917
10918 \series bold
10919 -
10920 \begin_inset ERT
10921 status collapsed
10922
10923 \begin_layout Standard
10924
10925
10926 \backslash
10927 /
10928 \end_layout
10929
10930 \end_inset
10931
10932 -nostdlib
10933 \begin_inset LatexCommand index
10934 name "-\\/-nostdlib"
10935
10936 \end_inset
10937
10938
10939 \series default
10940  This will prevent the compiler from passing on the default library
10941 \begin_inset LatexCommand index
10942 name "Libraries"
10943
10944 \end_inset
10945
10946  path to the linker.
10947 \end_layout
10948
10949 \begin_layout List
10950 \labelwidthstring 00.00.0000
10951
10952 \series bold
10953 -
10954 \begin_inset ERT
10955 status collapsed
10956
10957 \begin_layout Standard
10958
10959
10960 \backslash
10961 /
10962 \end_layout
10963
10964 \end_inset
10965
10966 -verbose
10967 \begin_inset LatexCommand index
10968 name "-\\/-verbose"
10969
10970 \end_inset
10971
10972
10973 \series default
10974  Shows the various actions the compiler is performing.
10975 \end_layout
10976
10977 \begin_layout List
10978 \labelwidthstring 00.00.0000
10979
10980 \series bold
10981 -V
10982 \begin_inset LatexCommand index
10983 name "-V"
10984
10985 \end_inset
10986
10987
10988 \series default
10989  Shows the actual commands the compiler is executing.
10990 \end_layout
10991
10992 \begin_layout List
10993 \labelwidthstring 00.00.0000
10994
10995 \series bold
10996 -
10997 \begin_inset ERT
10998 status collapsed
10999
11000 \begin_layout Standard
11001
11002
11003 \backslash
11004 /
11005 \end_layout
11006
11007 \end_inset
11008
11009 -no-c-code-in-asm
11010 \begin_inset LatexCommand index
11011 name "-\\/-no-c-code-in-asm"
11012
11013 \end_inset
11014
11015
11016 \series default
11017  Hides your ugly and inefficient c-code from the asm file, so you can always
11018  blame the compiler :)
11019 \end_layout
11020
11021 \begin_layout List
11022 \labelwidthstring 00.00.0000
11023
11024 \series bold
11025 -
11026 \begin_inset ERT
11027 status collapsed
11028
11029 \begin_layout Standard
11030
11031
11032 \backslash
11033 /
11034 \end_layout
11035
11036 \end_inset
11037
11038 -fverbose-asm
11039 \begin_inset LatexCommand index
11040 name "-\\/-no-gen-comments"
11041
11042 \end_inset
11043
11044
11045 \series default
11046  Include code generator and peep-hole comments in the generated asm files.
11047 \end_layout
11048
11049 \begin_layout List
11050 \labelwidthstring 00.00.0000
11051
11052 \series bold
11053 -
11054 \begin_inset ERT
11055 status collapsed
11056
11057 \begin_layout Standard
11058
11059
11060 \backslash
11061 /
11062 \end_layout
11063
11064 \end_inset
11065
11066 -no-peep-comments
11067 \begin_inset LatexCommand index
11068 name "-\\/-no-peep-comments"
11069
11070 \end_inset
11071
11072
11073 \series default
11074  Don't include peep-hole comments in the generated asm files even if -
11075 \series bold
11076
11077 \begin_inset ERT
11078 status open
11079
11080 \begin_layout Standard
11081
11082
11083 \backslash
11084 /
11085 \end_layout
11086
11087 \end_inset
11088
11089
11090 \series default
11091 -fverbose-asm option is specified.
11092 \end_layout
11093
11094 \begin_layout List
11095 \labelwidthstring 00.00.0000
11096
11097 \series bold
11098 -
11099 \begin_inset ERT
11100 status collapsed
11101
11102 \begin_layout Standard
11103
11104
11105 \backslash
11106 /
11107 \end_layout
11108
11109 \end_inset
11110
11111 -i-code-in-asm
11112 \begin_inset LatexCommand index
11113 name "-\\/-i-code-in-asm"
11114
11115 \end_inset
11116
11117
11118 \series default
11119  Include i-codes in the asm file.
11120  Sounds like noise but is most helpful for debugging the compiler itself.
11121 \end_layout
11122
11123 \begin_layout List
11124 \labelwidthstring 00.00.0000
11125
11126 \series bold
11127 -
11128 \begin_inset ERT
11129 status collapsed
11130
11131 \begin_layout Standard
11132
11133
11134 \backslash
11135 /
11136 \end_layout
11137
11138 \end_inset
11139
11140 -less-pedantic
11141 \begin_inset LatexCommand index
11142 name "pedantic"
11143
11144 \end_inset
11145
11146
11147 \begin_inset LatexCommand index
11148 name "-\\/-less-pedantic"
11149
11150 \end_inset
11151
11152
11153 \series default
11154
11155 \begin_inset LatexCommand label
11156 name "lyx:--less-pedantic"
11157
11158 \end_inset
11159
11160  Disable some of the more pedantic warnings
11161 \begin_inset LatexCommand index
11162 name "Warnings"
11163
11164 \end_inset
11165
11166 .
11167  For more details, see the less_pedantic pragma 
11168 \begin_inset LatexCommand vpageref
11169 reference "ite:less_pedantic"
11170
11171 \end_inset
11172
11173 .
11174 \end_layout
11175
11176 \begin_layout List
11177 \labelwidthstring 00.00.0000
11178
11179 \series bold
11180 -
11181 \begin_inset ERT
11182 status collapsed
11183
11184 \begin_layout Standard
11185
11186
11187 \backslash
11188 /
11189 \end_layout
11190
11191 \end_inset
11192
11193 -disable-warning\InsetSpace ~
11194 <nnnn>
11195 \begin_inset LatexCommand index
11196 name "-\\/-disable-warning"
11197
11198 \end_inset
11199
11200
11201 \series default
11202  Disable specific warning with number <nnnn>.
11203 \end_layout
11204
11205 \begin_layout List
11206 \labelwidthstring 00.00.0000
11207
11208 \series bold
11209 -
11210 \begin_inset ERT
11211 status collapsed
11212
11213 \begin_layout Standard
11214
11215
11216 \backslash
11217 /
11218 \end_layout
11219
11220 \end_inset
11221
11222 -Werror
11223 \begin_inset LatexCommand index
11224 name "-\\/-Werror"
11225
11226 \end_inset
11227
11228
11229 \series default
11230  Treat all warnings as errors.
11231 \end_layout
11232
11233 \begin_layout List
11234 \labelwidthstring 00.00.0000
11235
11236 \series bold
11237 -
11238 \begin_inset ERT
11239 status collapsed
11240
11241 \begin_layout Standard
11242
11243
11244 \backslash
11245 /
11246 \end_layout
11247
11248 \end_inset
11249
11250 -print-search-dirs
11251 \begin_inset LatexCommand index
11252 name "-\\/-print-search-dirs"
11253
11254 \end_inset
11255
11256
11257 \series default
11258  Display the directories in the compiler's search path
11259 \end_layout
11260
11261 \begin_layout List
11262 \labelwidthstring 00.00.0000
11263
11264 \series bold
11265 -
11266 \begin_inset ERT
11267 status collapsed
11268
11269 \begin_layout Standard
11270
11271
11272 \backslash
11273 /
11274 \end_layout
11275
11276 \end_inset
11277
11278 -vc
11279 \begin_inset LatexCommand index
11280 name "-\\/-vc"
11281
11282 \end_inset
11283
11284
11285 \series default
11286  Display errors and warnings using MSVC style, so you can use SDCC with
11287  the visual studio IDE
11288 \begin_inset LatexCommand index
11289 name "IDE"
11290
11291 \end_inset
11292
11293 .
11294  With SDCC both offering a GCC-like (the default) and a MSVC-like
11295 \begin_inset LatexCommand index
11296 name "MSVC output style"
11297
11298 \end_inset
11299
11300  output style, integration into most programming editors should be straightforwa
11301 rd.
11302 \end_layout
11303
11304 \begin_layout List
11305 \labelwidthstring 00.00.0000
11306
11307 \series bold
11308 -
11309 \begin_inset ERT
11310 status collapsed
11311
11312 \begin_layout Standard
11313
11314
11315 \backslash
11316 /
11317 \end_layout
11318
11319 \end_inset
11320
11321 -use-stdout
11322 \begin_inset LatexCommand index
11323 name "-\\/-use-stdout"
11324
11325 \end_inset
11326
11327
11328 \series default
11329  Send errors and warnings to stdout instead of stderr.
11330 \end_layout
11331
11332 \begin_layout List
11333 \labelwidthstring 00.00.0000
11334
11335 \series bold
11336 -Wa\InsetSpace ~
11337 asmOption[,asmOption]
11338 \series default
11339
11340 \begin_inset LatexCommand index
11341 name "-Wa asmOption[,asmOption]"
11342
11343 \end_inset
11344
11345 ...
11346  Pass the asmOption to the assembler
11347 \begin_inset LatexCommand index
11348 name "Options assembler"
11349
11350 \end_inset
11351
11352
11353 \begin_inset LatexCommand index
11354 name "Assembler options"
11355
11356 \end_inset
11357
11358 .
11359  See file sdcc/as/doc/asxhtm.html for assembler options.cd
11360 \end_layout
11361
11362 \begin_layout List
11363 \labelwidthstring 00.00.0000
11364
11365 \series bold
11366 -
11367 \begin_inset ERT
11368 status collapsed
11369
11370 \begin_layout Standard
11371
11372
11373 \backslash
11374 /
11375 \end_layout
11376
11377 \end_inset
11378
11379 -std-sdcc89
11380 \begin_inset LatexCommand index
11381 name "-\\/-std-sdcc89"
11382
11383 \end_inset
11384
11385
11386 \series default
11387  Generally follow the C89 standard, but allow SDCC features that conflict
11388  with the standard (default).
11389 \end_layout
11390
11391 \begin_layout List
11392 \labelwidthstring 00.00.0000
11393
11394 \series bold
11395 -
11396 \begin_inset ERT
11397 status collapsed
11398
11399 \begin_layout Standard
11400
11401
11402 \backslash
11403 /
11404 \end_layout
11405
11406 \end_inset
11407
11408 -std-c89
11409 \begin_inset LatexCommand index
11410 name "-\\/-std-c89"
11411
11412 \end_inset
11413
11414
11415 \series default
11416  Follow the C89 standard and disable SDCC features that conflict with the
11417  standard.
11418 \end_layout
11419
11420 \begin_layout List
11421 \labelwidthstring 00.00.0000
11422
11423 \series bold
11424 -
11425 \begin_inset ERT
11426 status collapsed
11427
11428 \begin_layout Standard
11429
11430
11431 \backslash
11432 /
11433 \end_layout
11434
11435 \end_inset
11436
11437 -std-sdcc99
11438 \begin_inset LatexCommand index
11439 name "-\\/-std-sdcc99"
11440
11441 \end_inset
11442
11443
11444 \series default
11445  Generally follow the C99 standard, but allow SDCC features that conflict
11446  with the standard (incomplete support).
11447 \end_layout
11448
11449 \begin_layout List
11450 \labelwidthstring 00.00.0000
11451
11452 \series bold
11453 -
11454 \begin_inset ERT
11455 status collapsed
11456
11457 \begin_layout Standard
11458
11459
11460 \backslash
11461 /
11462 \end_layout
11463
11464 \end_inset
11465
11466 -std-c99
11467 \begin_inset LatexCommand index
11468 name "-\\/-std-sdcc99"
11469
11470 \end_inset
11471
11472
11473 \series default
11474  Follow the C99 standard and disable SDCC features that conflict with the
11475  standard (incomplete support).
11476 \end_layout
11477
11478 \begin_layout List
11479 \labelwidthstring 00.00.0000
11480
11481 \series bold
11482 -
11483 \begin_inset ERT
11484 status collapsed
11485
11486 \begin_layout Standard
11487
11488
11489 \backslash
11490 /
11491 \end_layout
11492
11493 \end_inset
11494
11495 -codeseg
11496 \series default
11497
11498 \begin_inset LatexCommand index
11499 name "-\\/-codeseg <Value>"
11500
11501 \end_inset
11502
11503
11504 \begin_inset LatexCommand label
11505 name "lyx:-codeseg"
11506
11507 \end_inset
11508
11509 \InsetSpace ~
11510 <Name> The name to be used for the code
11511 \begin_inset LatexCommand index
11512 name "code"
11513
11514 \end_inset
11515
11516  segment, default CSEG.
11517  This is useful if you need to tell the compiler to put the code in a special
11518  segment so you can later on tell the linker to put this segment in a special
11519  place in memory.
11520  Can be used for instance when using bank switching to put the code in a
11521  bank.
11522 \end_layout
11523
11524 \begin_layout List
11525 \labelwidthstring 00.00.0000
11526
11527 \series bold
11528 -
11529 \begin_inset ERT
11530 status collapsed
11531
11532 \begin_layout Standard
11533
11534
11535 \backslash
11536 /
11537 \end_layout
11538
11539 \end_inset
11540
11541 -constseg
11542 \series default
11543
11544 \begin_inset LatexCommand index
11545 name "-\\/-constseg <Value>"
11546
11547 \end_inset
11548
11549 \InsetSpace ~
11550 <Name> The name to be used for the const
11551 \begin_inset LatexCommand index
11552 name "const"
11553
11554 \end_inset
11555
11556  segment, default CONST.
11557  This is useful if you need to tell the compiler to put the const data in
11558  a special segment so you can later on tell the linker to put this segment
11559  in a special place in memory.
11560  Can be used for instance when using bank switching to put the const data
11561  in a bank.
11562 \end_layout
11563
11564 \begin_layout List
11565 \labelwidthstring 00.00.0000
11566
11567 \series bold
11568 -
11569 \begin_inset ERT
11570 status collapsed
11571
11572 \begin_layout Standard
11573
11574
11575 \backslash
11576 /
11577 \end_layout
11578
11579 \end_inset
11580
11581 -fdollars-in-identifiers
11582 \begin_inset LatexCommand index
11583 name "-\\/-fdollars-in-identifiers"
11584
11585 \end_inset
11586
11587
11588 \series default
11589  Permit '$' as an identifier character.
11590 \end_layout
11591
11592 \begin_layout List
11593 \labelwidthstring 00.00.0000
11594
11595 \series bold
11596 -
11597 \begin_inset ERT
11598 status collapsed
11599
11600 \begin_layout Standard
11601
11602
11603 \backslash
11604 /
11605 \end_layout
11606
11607 \end_inset
11608
11609 -more-pedantic
11610 \series default
11611
11612 \begin_inset LatexCommand index
11613 name "-\\/-more-pedantic"
11614
11615 \end_inset
11616
11617
11618 \begin_inset LatexCommand index
11619 name "pedantic"
11620
11621 \end_inset
11622
11623  Actually this is 
11624 \series bold
11625 \emph on
11626 not
11627 \series default
11628 \emph default
11629  a SDCC compiler option but if you want 
11630 \emph on
11631 more
11632 \emph default
11633  warnings you can use a separate tool dedicated to syntax checking like
11634  splint
11635 \begin_inset LatexCommand label
11636 name "lyx:more-pedantic-SPLINT"
11637
11638 \end_inset
11639
11640
11641 \begin_inset LatexCommand index
11642 name "lint (syntax checking tool)"
11643
11644 \end_inset
11645
11646  
11647 \begin_inset LatexCommand url
11648 target "http://www.splint.org"
11649
11650 \end_inset
11651
11652 .
11653  To make your source files parseable by splint you will have to include
11654  
11655 \family sans
11656 lint.h
11657 \family default
11658
11659 \begin_inset LatexCommand index
11660 name "splint (syntax checking tool)"
11661
11662 \end_inset
11663
11664  in your source file and add brackets around extended keywords (like 
11665 \family sans
11666
11667 \begin_inset Quotes sld
11668 \end_inset
11669
11670 __at\InsetSpace ~
11671
11672 \series bold
11673 (
11674 \series default
11675 0xab
11676 \series bold
11677 )
11678 \series default
11679
11680 \begin_inset Quotes srd
11681 \end_inset
11682
11683
11684 \family default
11685  and 
11686 \family sans
11687
11688 \begin_inset Quotes sld
11689 \end_inset
11690
11691 __interrupt\InsetSpace ~
11692 (2)
11693 \begin_inset Quotes srd
11694 \end_inset
11695
11696
11697 \family default
11698 ).
11699  
11700 \newline
11701 Splint has an excellent on line manual at 
11702 \begin_inset LatexCommand url
11703 target "http://www.splint.org/manual/"
11704
11705 \end_inset
11706
11707  and it's capabilities go beyond pure syntax checking.
11708  You'll need to tell splint the location of SDCC's include files so a typical
11709  command line could look like this: 
11710 \newline
11711
11712 \family sans
11713 splint\InsetSpace ~
11714 -I\InsetSpace ~
11715 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
11716 \InsetSpace ~
11717 myprogram.c
11718 \end_layout
11719
11720 \begin_layout List
11721 \labelwidthstring 00.00.0000
11722
11723 \series bold
11724 -
11725 \begin_inset ERT
11726 status collapsed
11727
11728 \begin_layout Standard
11729
11730
11731 \backslash
11732 /
11733 \end_layout
11734
11735 \end_inset
11736
11737 -short-is-8bits
11738 \series default
11739
11740 \begin_inset LatexCommand index
11741 name "-\\/-short-is-8bits"
11742
11743 \end_inset
11744
11745
11746 \begin_inset LatexCommand label
11747 name "lyx:--short-is-8bits"
11748
11749 \end_inset
11750
11751  Treat short as 8-bit (for backward compatibility with older versions of
11752  compiler - see section 
11753 \begin_inset LatexCommand ref
11754 reference "sec:Compatibility-with-previous"
11755
11756 \end_inset
11757
11758 )
11759 \end_layout
11760
11761 \begin_layout Standard
11762 \begin_inset VSpace bigskip
11763 \end_inset
11764
11765
11766 \end_layout
11767
11768 \begin_layout Subsection
11769 Intermediate Dump Options
11770 \begin_inset LatexCommand label
11771 name "sub:Intermediate-Dump-Options"
11772
11773 \end_inset
11774
11775
11776 \begin_inset LatexCommand index
11777 name "Options intermediate dump"
11778
11779 \end_inset
11780
11781
11782 \begin_inset LatexCommand index
11783 name "Intermediate dump options"
11784
11785 \end_inset
11786
11787
11788 \end_layout
11789
11790 \begin_layout Standard
11791 The following options are provided for the purpose of retargetting and debugging
11792  the compiler.
11793  They provide a means to dump the intermediate code (iCode
11794 \begin_inset LatexCommand index
11795 name "iCode"
11796
11797 \end_inset
11798
11799 ) generated by the compiler in human readable form at various stages of
11800  the compilation process.
11801  More on iCodes see chapter 
11802 \begin_inset LatexCommand ref
11803 reference "sub:The-anatomy-of"
11804
11805 \end_inset
11806
11807  
11808 \begin_inset Quotes srd
11809 \end_inset
11810
11811 The anatomy of the compiler
11812 \begin_inset Quotes srd
11813 \end_inset
11814
11815 .
11816 \end_layout
11817
11818 \begin_layout List
11819 \labelwidthstring 00.00.0000
11820
11821 \series bold
11822 -
11823 \begin_inset ERT
11824 status collapsed
11825
11826 \begin_layout Standard
11827
11828
11829 \backslash
11830 /
11831 \end_layout
11832
11833 \end_inset
11834
11835 -dumpraw
11836 \begin_inset LatexCommand index
11837 name "-\\/-dumpraw"
11838
11839 \end_inset
11840
11841
11842 \series default
11843  This option will cause the compiler to dump the intermediate code into
11844  a file of named 
11845 \emph on
11846 <source filename>.dumpraw
11847 \emph default
11848  just after the intermediate code has been generated for a function, i.e.
11849  before any optimizations are done.
11850  The basic blocks
11851 \begin_inset LatexCommand index
11852 name "Basic blocks"
11853
11854 \end_inset
11855
11856  at this stage ordered in the depth first number, so they may not be in
11857  sequence of execution.
11858 \end_layout
11859
11860 \begin_layout List
11861 \labelwidthstring 00.00.0000
11862
11863 \series bold
11864 -
11865 \begin_inset ERT
11866 status collapsed
11867
11868 \begin_layout Standard
11869
11870
11871 \backslash
11872 /
11873 \end_layout
11874
11875 \end_inset
11876
11877 -dumpgcse
11878 \begin_inset LatexCommand index
11879 name "-\\/-dumpgcse"
11880
11881 \end_inset
11882
11883
11884 \series default
11885  Will create a dump of iCodes, after global subexpression elimination
11886 \begin_inset LatexCommand index
11887 name "Global subexpression elimination"
11888
11889 \end_inset
11890
11891 , into a file named 
11892 \emph on
11893 <source filename>.dumpgcse.
11894 \end_layout
11895
11896 \begin_layout List
11897 \labelwidthstring 00.00.0000
11898
11899 \series bold
11900 -
11901 \begin_inset ERT
11902 status collapsed
11903
11904 \begin_layout Standard
11905
11906
11907 \backslash
11908 /
11909 \end_layout
11910
11911 \end_inset
11912
11913 -dumpdeadcode
11914 \begin_inset LatexCommand index
11915 name "-\\/-dumpdeadcode"
11916
11917 \end_inset
11918
11919
11920 \series default
11921  Will create a dump of iCodes, after deadcode elimination
11922 \begin_inset LatexCommand index
11923 name "Dead-code elimination"
11924
11925 \end_inset
11926
11927 , into a file named 
11928 \emph on
11929 <source filename>.dumpdeadcode.
11930 \end_layout
11931
11932 \begin_layout List
11933 \labelwidthstring 00.00.0000
11934
11935 \series bold
11936 -
11937 \begin_inset ERT
11938 status collapsed
11939
11940 \begin_layout Standard
11941
11942
11943 \backslash
11944 /
11945 \end_layout
11946
11947 \end_inset
11948
11949 -dumploop
11950 \begin_inset LatexCommand index
11951 name "-\\/-dumploop"
11952
11953 \end_inset
11954
11955
11956 \series default
11957 \size large
11958  
11959 \size default
11960 Will create a dump of iCodes, after loop optimizations
11961 \begin_inset LatexCommand index
11962 name "Loop optimization"
11963
11964 \end_inset
11965
11966 , into a file named 
11967 \emph on
11968 <source filename>.dumploop.
11969 \end_layout
11970
11971 \begin_layout List
11972 \labelwidthstring 00.00.0000
11973
11974 \series bold
11975 -
11976 \begin_inset ERT
11977 status collapsed
11978
11979 \begin_layout Standard
11980
11981
11982 \backslash
11983 /
11984 \end_layout
11985
11986 \end_inset
11987
11988 -dumprange
11989 \begin_inset LatexCommand index
11990 name "-\\/-dumprange"
11991
11992 \end_inset
11993
11994
11995 \series default
11996 \size large
11997  
11998 \size default
11999 Will create a dump of iCodes, after live range analysis
12000 \begin_inset LatexCommand index
12001 name "Live range analysis"
12002
12003 \end_inset
12004
12005 , into a file named 
12006 \emph on
12007 <source filename>.dumprange.
12008 \end_layout
12009
12010 \begin_layout List
12011 \labelwidthstring 00.00.0000
12012
12013 \series bold
12014 -
12015 \begin_inset ERT
12016 status collapsed
12017
12018 \begin_layout Standard
12019
12020
12021 \backslash
12022 /
12023 \end_layout
12024
12025 \end_inset
12026
12027 -dumlrange
12028 \begin_inset LatexCommand index
12029 name "-\\/-dumlrange"
12030
12031 \end_inset
12032
12033
12034 \series default
12035  Will dump the life ranges
12036 \begin_inset LatexCommand index
12037 name "Live range analysis"
12038
12039 \end_inset
12040
12041  for all symbols.
12042 \end_layout
12043
12044 \begin_layout List
12045 \labelwidthstring 00.00.0000
12046
12047 \series bold
12048 -
12049 \begin_inset ERT
12050 status collapsed
12051
12052 \begin_layout Standard
12053
12054
12055 \backslash
12056 /
12057 \end_layout
12058
12059 \end_inset
12060
12061 -dumpregassign
12062 \begin_inset LatexCommand index
12063 name "-\\/-dumpregassign"
12064
12065 \end_inset
12066
12067  
12068 \series default
12069 Will create a dump of iCodes, after register assignment
12070 \begin_inset LatexCommand index
12071 name "Register assignment"
12072
12073 \end_inset
12074
12075 , into a file named 
12076 \emph on
12077 <source filename>.dumprassgn.
12078 \end_layout
12079
12080 \begin_layout List
12081 \labelwidthstring 00.00.0000
12082
12083 \series bold
12084 -
12085 \begin_inset ERT
12086 status collapsed
12087
12088 \begin_layout Standard
12089
12090
12091 \backslash
12092 /
12093 \end_layout
12094
12095 \end_inset
12096
12097 -dumplrange
12098 \begin_inset LatexCommand index
12099 name "-\\/-dumplrange"
12100
12101 \end_inset
12102
12103
12104 \series default
12105  Will create a dump of the live ranges of iTemp's
12106 \end_layout
12107
12108 \begin_layout List
12109 \labelwidthstring 00.00.0000
12110
12111 \series bold
12112 -
12113 \begin_inset ERT
12114 status collapsed
12115
12116 \begin_layout Standard
12117
12118
12119 \backslash
12120 /
12121 \end_layout
12122
12123 \end_inset
12124
12125 -dumpall
12126 \begin_inset LatexCommand index
12127 name "-\\/-dumpall"
12128
12129 \end_inset
12130
12131
12132 \size large
12133  
12134 \series default
12135 \size default
12136 Will cause all the above mentioned dumps to be created.
12137 \end_layout
12138
12139 \begin_layout Standard
12140 \begin_inset VSpace bigskip
12141 \end_inset
12142
12143
12144 \end_layout
12145
12146 \begin_layout Subsection
12147 Redirecting output on Windows Shells
12148 \end_layout
12149
12150 \begin_layout Standard
12151 By default SDCC writes its error messages to 
12152 \begin_inset Quotes sld
12153 \end_inset
12154
12155 standard error
12156 \begin_inset Quotes srd
12157 \end_inset
12158
12159 .
12160  To force all messages to 
12161 \begin_inset Quotes sld
12162 \end_inset
12163
12164 standard output
12165 \begin_inset Quotes srd
12166 \end_inset
12167
12168  use 
12169 \series bold
12170 -
12171 \series default
12172 \emph on
12173
12174 \begin_inset ERT
12175 status collapsed
12176
12177 \begin_layout Standard
12178
12179
12180 \backslash
12181 /
12182 \end_layout
12183
12184 \end_inset
12185
12186
12187 \series bold
12188 \emph default
12189 -
12190 \series default
12191 use-stdout
12192 \begin_inset LatexCommand index
12193 name "-\\/-use-stdout"
12194
12195 \end_inset
12196
12197 .
12198  Additionally, if you happen to have visual studio installed in your windows
12199  machine, you can use it to compile your sources using a custom build and
12200  the SDCC -
12201 \emph on
12202
12203 \begin_inset ERT
12204 status collapsed
12205
12206 \begin_layout Standard
12207
12208
12209 \backslash
12210 /
12211 \end_layout
12212
12213 \end_inset
12214
12215
12216 \emph default
12217 -vc
12218 \begin_inset LatexCommand index
12219 name "-\\/-vc"
12220
12221 \end_inset
12222
12223  option.
12224  Something like this should work:
12225 \newline
12226
12227 \newline
12228
12229 \series bold
12230 c:
12231 \backslash
12232 sdcc
12233 \backslash
12234 bin
12235 \backslash
12236 sdcc.exe -
12237 \series default
12238 \emph on
12239
12240 \begin_inset ERT
12241 status collapsed
12242
12243 \begin_layout Standard
12244
12245
12246 \backslash
12247 /
12248 \end_layout
12249
12250 \end_inset
12251
12252
12253 \series bold
12254 \emph default
12255 -vc -
12256 \series default
12257 \emph on
12258
12259 \begin_inset ERT
12260 status collapsed
12261
12262 \begin_layout Standard
12263
12264
12265 \backslash
12266 /
12267 \end_layout
12268
12269 \end_inset
12270
12271
12272 \series bold
12273 \emph default
12274 -model-large -c $(InputPath)
12275 \series default
12276
12277 \begin_inset VSpace bigskip
12278 \end_inset
12279
12280
12281 \end_layout
12282
12283 \begin_layout Section
12284 Environment variables
12285 \begin_inset LatexCommand index
12286 name "Environment variables"
12287
12288 \end_inset
12289
12290
12291 \end_layout
12292
12293 \begin_layout Standard
12294 SDCC recognizes the following environment variables:
12295 \end_layout
12296
12297 \begin_layout List
12298 \labelwidthstring 00.00.0000
12299
12300 \series bold
12301 SDCC_LEAVE_SIGNALS
12302 \begin_inset LatexCommand index
12303 name "SDCC\\_LEAVE\\_SIGNALS"
12304
12305 \end_inset
12306
12307
12308 \series default
12309  SDCC installs a signal handler
12310 \begin_inset LatexCommand index
12311 name "signal handler"
12312
12313 \end_inset
12314
12315  to be able to delete temporary files after an user break (^C) or an exception.
12316  If this environment variable is set, SDCC won't install the signal handler
12317  in order to be able to debug SDCC.
12318 \end_layout
12319
12320 \begin_layout List
12321 \labelwidthstring 00.00.0000
12322
12323 \series bold
12324 TMP,\InsetSpace ~
12325 TEMP,\InsetSpace ~
12326 TMPDIR
12327 \begin_inset LatexCommand index
12328 name "TMP, TEMP, TMPDIR"
12329
12330 \end_inset
12331
12332
12333 \series default
12334  Path, where temporary files will be created.
12335  The order of the variables is the search order.
12336  In a standard *nix environment these variables are not set, and there's
12337  no need to set them.
12338  On Windows it's recommended to set one of them.
12339 \end_layout
12340
12341 \begin_layout List
12342 \labelwidthstring 00.00.0000
12343
12344 \series bold
12345 SDCC_HOME
12346 \begin_inset LatexCommand index
12347 name "SDCC\\_HOME"
12348
12349 \end_inset
12350
12351
12352 \series default
12353  Path, see section 
12354 \begin_inset LatexCommand ref
12355 reference "sub:Install-paths"
12356
12357 \end_inset
12358
12359 \InsetSpace ~
12360
12361 \begin_inset Quotes sld
12362 \end_inset
12363
12364  Install Paths
12365 \begin_inset Quotes srd
12366 \end_inset
12367
12368 .
12369 \end_layout
12370
12371 \begin_layout List
12372 \labelwidthstring 00.00.0000
12373
12374 \series bold
12375 SDCC_INCLUDE
12376 \begin_inset LatexCommand index
12377 name "SDCC\\_INCLUDE"
12378
12379 \end_inset
12380
12381
12382 \series default
12383  Path, see section 
12384 \begin_inset LatexCommand ref
12385 reference "sub:Search-Paths"
12386
12387 \end_inset
12388
12389 \InsetSpace ~
12390
12391 \begin_inset Quotes sld
12392 \end_inset
12393
12394 Search Paths
12395 \begin_inset Quotes srd
12396 \end_inset
12397
12398 .
12399 \end_layout
12400
12401 \begin_layout List
12402 \labelwidthstring 00.00.0000
12403
12404 \series bold
12405 SDCC_LIB
12406 \begin_inset LatexCommand index
12407 name "SDCC\\_LIB"
12408
12409 \end_inset
12410
12411
12412 \series default
12413  Path, see section 
12414 \begin_inset LatexCommand ref
12415 reference "sub:Search-Paths"
12416
12417 \end_inset
12418
12419 \InsetSpace ~
12420
12421 \begin_inset Quotes sld
12422 \end_inset
12423
12424 Search Paths
12425 \begin_inset Quotes srd
12426 \end_inset
12427
12428 ..
12429 \end_layout
12430
12431 \begin_layout Standard
12432 There are some more environment variables recognized by SDCC, but these
12433  are solely used for debugging purposes.
12434  They can change or disappear very quickly, and will never be documented.
12435 \begin_inset VSpace bigskip
12436 \end_inset
12437
12438
12439 \end_layout
12440
12441 \begin_layout Section
12442 Storage Class Language Extensions
12443 \end_layout
12444
12445 \begin_layout Subsection
12446 MCS51/DS390 Storage Class
12447 \begin_inset LatexCommand index
12448 name "Storage class"
12449
12450 \end_inset
12451
12452  Language Extensions
12453 \end_layout
12454
12455 \begin_layout Standard
12456 In addition to the ANSI storage classes SDCC allows the following MCS51
12457  specific storage classes:
12458 \end_layout
12459
12460 \begin_layout Subsubsection
12461 data
12462 \begin_inset LatexCommand index
12463 name "data (mcs51, ds390 storage class)"
12464
12465 \end_inset
12466
12467
12468 \begin_inset LatexCommand index
12469 name "\\_\\_data (mcs51, ds390 storage class)"
12470
12471 \end_inset
12472
12473  / near
12474 \begin_inset LatexCommand index
12475 name "near (storage class)"
12476
12477 \end_inset
12478
12479
12480 \begin_inset LatexCommand index
12481 name "\\_\\_near (storage class)"
12482
12483 \end_inset
12484
12485
12486 \end_layout
12487
12488 \begin_layout Standard
12489 This is the 
12490 \series bold
12491 default
12492 \series default
12493  storage class for the Small Memory model (
12494 \emph on
12495 data
12496 \emph default
12497  and 
12498 \emph on
12499 near
12500 \emph default
12501  or the more ANSI-C compliant forms 
12502 \emph on
12503 __data
12504 \emph default
12505  and 
12506 \emph on
12507 __near
12508 \emph default
12509  can be used synonymously).
12510  Variables declared with this storage class will be allocated in the directly
12511  addressable portion of the internal RAM of a 8051, e.g.:
12512 \end_layout
12513
12514 \begin_layout Verse
12515
12516 \family typewriter
12517 __data unsigned char test_data;
12518 \end_layout
12519
12520 \begin_layout Standard
12521 Writing 0x01 to this variable generates the assembly code:
12522 \end_layout
12523
12524 \begin_layout Verse
12525
12526 \family typewriter
12527 75*00 01\InsetSpace ~
12528 \InsetSpace ~
12529 \InsetSpace ~
12530 mov\InsetSpace ~
12531 \InsetSpace ~
12532 _test_data,#0x01
12533 \end_layout
12534
12535 \begin_layout Subsubsection
12536 xdata
12537 \begin_inset LatexCommand index
12538 name "xdata (mcs51, ds390 storage class)"
12539
12540 \end_inset
12541
12542
12543 \begin_inset LatexCommand index
12544 name "\\_\\_xdata (mcs51, ds390 storage class)"
12545
12546 \end_inset
12547
12548  / far
12549 \begin_inset LatexCommand index
12550 name "far (storage class)"
12551
12552 \end_inset
12553
12554
12555 \begin_inset LatexCommand index
12556 name "\\_\\_far (storage class)"
12557
12558 \end_inset
12559
12560
12561 \end_layout
12562
12563 \begin_layout Standard
12564 Variables declared with this storage class will be placed in the external
12565  RAM.
12566  This is the 
12567 \series bold
12568 default
12569 \series default
12570  storage class for the Large Memory model, e.g.:
12571 \end_layout
12572
12573 \begin_layout Verse
12574
12575 \family typewriter
12576 __xdata unsigned char test_xdata;
12577 \end_layout
12578
12579 \begin_layout Standard
12580 Writing 0x01 to this variable generates the assembly code:
12581 \end_layout
12582
12583 \begin_layout Verse
12584
12585 \family typewriter
12586 90s00r00\InsetSpace ~
12587 \InsetSpace ~
12588 \InsetSpace ~
12589 mov\InsetSpace ~
12590 \InsetSpace ~
12591 dptr,#_test_xdata 
12592 \newline
12593 74\InsetSpace ~
12594 01\InsetSpace ~
12595 \InsetSpace ~
12596 \InsetSpace ~
12597 \InsetSpace ~
12598 \InsetSpace ~
12599 \InsetSpace ~
12600 mov\InsetSpace ~
12601 \InsetSpace ~
12602 a,#0x01 
12603 \newline
12604 F0\InsetSpace ~
12605 \InsetSpace ~
12606 \InsetSpace ~
12607 \InsetSpace ~
12608 \InsetSpace ~
12609 \InsetSpace ~
12610 \InsetSpace ~
12611 \InsetSpace ~
12612 \InsetSpace ~
12613 movx\InsetSpace ~
12614 @dptr,a 
12615 \end_layout
12616
12617 \begin_layout Subsubsection
12618 idata
12619 \begin_inset LatexCommand index
12620 name "idata (mcs51, ds390 storage class)"
12621
12622 \end_inset
12623
12624
12625 \begin_inset LatexCommand index
12626 name "\\_\\_idata (mcs51, ds390 storage class)"
12627
12628 \end_inset
12629
12630
12631 \end_layout
12632
12633 \begin_layout Standard
12634 Variables declared with this storage class will be allocated into the indirectly
12635  addressable portion of the internal ram of a 8051, e.g.:
12636 \end_layout
12637
12638 \begin_layout Verse
12639
12640 \family typewriter
12641 __idata unsigned char test_idata;
12642 \end_layout
12643
12644 \begin_layout Standard
12645 Writing 0x01 to this variable generates the assembly code:
12646 \end_layout
12647
12648 \begin_layout Verse
12649
12650 \family typewriter
12651 78r00\InsetSpace ~
12652 \InsetSpace ~
12653 \InsetSpace ~
12654 \InsetSpace ~
12655 \InsetSpace ~
12656 \InsetSpace ~
12657 \InsetSpace ~
12658 mov\InsetSpace ~
12659 \InsetSpace ~
12660 r0,#_test_idata
12661 \newline
12662 76\InsetSpace ~
12663 01\InsetSpace ~
12664 \InsetSpace ~
12665 \InsetSpace ~
12666 \InsetSpace ~
12667 \InsetSpace ~
12668 \InsetSpace ~
12669 \InsetSpace ~
12670 mov\InsetSpace ~
12671 \InsetSpace ~
12672 @r0,#0x01
12673 \end_layout
12674
12675 \begin_layout Standard
12676 Please note, the first 128 byte of idata physically access the same RAM
12677  as the data memory.
12678  The original 8051 had 128 byte idata memory, nowadays most devices have
12679  256 byte idata memory.
12680  The stack
12681 \begin_inset LatexCommand index
12682 name "stack"
12683
12684 \end_inset
12685
12686  is located in idata memory.
12687 \end_layout
12688
12689 \begin_layout Subsubsection
12690 pdata
12691 \begin_inset LatexCommand index
12692 name "pdata (mcs51, ds390 storage class)"
12693
12694 \end_inset
12695
12696
12697 \begin_inset LatexCommand index
12698 name "\\_\\_pdata (mcs51, ds390 storage class)"
12699
12700 \end_inset
12701
12702
12703 \end_layout
12704
12705 \begin_layout Standard
12706 Paged xdata access is just as straightforward as using the other addressing
12707  modes of a 8051.
12708  It is typically located at the start of xdata and has a maximum size of
12709  256 bytes.
12710  The following example writes 0x01 to the pdata variable.
12711  Please note, pdata access physically accesses xdata memory.
12712  The high byte of the address is determined by port P2 
12713 \begin_inset LatexCommand index
12714 name "P2 (mcs51 sfr)"
12715
12716 \end_inset
12717
12718 (or in case of some 8051 variants by a separate Special Function Register,
12719  see section 
12720 \begin_inset LatexCommand ref
12721 reference "sub:MCS51-variants"
12722
12723 \end_inset
12724
12725 ).
12726  This is the 
12727 \series bold
12728 default
12729 \series default
12730  storage class for the Medium Memory model, e.g.:
12731 \end_layout
12732
12733 \begin_layout Verse
12734
12735 \family typewriter
12736 __pdata unsigned char test_pdata;
12737 \end_layout
12738
12739 \begin_layout Standard
12740 Writing 0x01 to this variable generates the assembly code:
12741 \end_layout
12742
12743 \begin_layout Verse
12744
12745 \family typewriter
12746 78r00\InsetSpace ~
12747 \InsetSpace ~
12748 \InsetSpace ~
12749 \InsetSpace ~
12750 \InsetSpace ~
12751 \InsetSpace ~
12752 mov r0,#_test_pdata
12753 \newline
12754 74 01\InsetSpace ~
12755 \InsetSpace ~
12756 \InsetSpace ~
12757 \InsetSpace ~
12758 \InsetSpace ~
12759 \InsetSpace ~
12760 mov a,#0x01 
12761 \newline
12762 F2\InsetSpace ~
12763 \InsetSpace ~
12764 \InsetSpace ~
12765 \InsetSpace ~
12766 \InsetSpace ~
12767 \InsetSpace ~
12768 \InsetSpace ~
12769 \InsetSpace ~
12770 \InsetSpace ~
12771 movx @r0,a
12772 \end_layout
12773
12774 \begin_layout Standard
12775 If the -
12776 \begin_inset ERT
12777 status collapsed
12778
12779 \begin_layout Standard
12780
12781
12782 \backslash
12783 /
12784 \end_layout
12785
12786 \end_inset
12787
12788 -xstack
12789 \begin_inset LatexCommand index
12790 name "-\\/-xstack"
12791
12792 \end_inset
12793
12794  option is used the pdata memory area is followed by the xstack memory area
12795  and the sum of their sizes is limited to 256 bytes.
12796 \end_layout
12797
12798 \begin_layout Subsubsection
12799 code
12800 \begin_inset LatexCommand index
12801 name "code"
12802
12803 \end_inset
12804
12805
12806 \begin_inset LatexCommand index
12807 name "\\_\\_code"
12808
12809 \end_inset
12810
12811
12812 \end_layout
12813
12814 \begin_layout Standard
12815 'Variables' declared with this storage class will be placed in the code
12816  memory:
12817 \end_layout
12818
12819 \begin_layout Verse
12820
12821 \family typewriter
12822 __code unsigned char test_code;
12823 \end_layout
12824
12825 \begin_layout Standard
12826 Read access to this variable generates the assembly code:
12827 \end_layout
12828
12829 \begin_layout Verse
12830
12831 \family typewriter
12832 90s00r6F\InsetSpace ~
12833 \InsetSpace ~
12834 \InsetSpace ~
12835 mov dptr,#_test_code
12836 \newline
12837 E4\InsetSpace ~
12838 \InsetSpace ~
12839 \InsetSpace ~
12840 \InsetSpace ~
12841 \InsetSpace ~
12842 \InsetSpace ~
12843 \InsetSpace ~
12844 \InsetSpace ~
12845 \InsetSpace ~
12846 clr a
12847 \newline
12848 93\InsetSpace ~
12849 \InsetSpace ~
12850 \InsetSpace ~
12851 \InsetSpace ~
12852 \InsetSpace ~
12853 \InsetSpace ~
12854 \InsetSpace ~
12855 \InsetSpace ~
12856 \InsetSpace ~
12857 movc a,@a+dptr 
12858 \end_layout
12859
12860 \begin_layout Standard
12861
12862 \family typewriter
12863 char
12864 \family default
12865  indexed arrays of characters in code memory can be accessed efficiently:
12866 \end_layout
12867
12868 \begin_layout Verse
12869
12870 \family typewriter
12871 __code char test_array[] = {'c','h','e','a','p'}; 
12872 \end_layout
12873
12874 \begin_layout Standard
12875 Read access to this array using an 8-bit unsigned index generates the assembly
12876  code:
12877 \end_layout
12878
12879 \begin_layout Verse
12880
12881 \family typewriter
12882 E5*00\InsetSpace ~
12883 \InsetSpace ~
12884 \InsetSpace ~
12885 \InsetSpace ~
12886 \InsetSpace ~
12887 \InsetSpace ~
12888 mov a,_index 
12889 \end_layout
12890
12891 \begin_layout Verse
12892
12893 \family typewriter
12894 90s00r41\InsetSpace ~
12895 \InsetSpace ~
12896 \InsetSpace ~
12897 mov dptr,#_test_array
12898 \end_layout
12899
12900 \begin_layout Verse
12901
12902 \family typewriter
12903 93\InsetSpace ~
12904 \InsetSpace ~
12905 \InsetSpace ~
12906 \InsetSpace ~
12907 \InsetSpace ~
12908 \InsetSpace ~
12909 \InsetSpace ~
12910 \InsetSpace ~
12911 \InsetSpace ~
12912 movc a,@a+dptr 
12913 \end_layout
12914
12915 \begin_layout Subsubsection
12916 bit
12917 \begin_inset LatexCommand index
12918 name "bit"
12919
12920 \end_inset
12921
12922
12923 \begin_inset LatexCommand index
12924 name "\\_\\_bit"
12925
12926 \end_inset
12927
12928
12929 \end_layout
12930
12931 \begin_layout Standard
12932 This is a data-type and a storage class specifier.
12933  When a variable is declared as a bit, it is allocated into the bit addressable
12934  memory of 8051, e.g.:
12935 \end_layout
12936
12937 \begin_layout Verse
12938
12939 \family typewriter
12940 __bit test_bit;
12941 \end_layout
12942
12943 \begin_layout Standard
12944 Writing 1 to this variable generates the assembly code:
12945 \end_layout
12946
12947 \begin_layout Verse
12948
12949 \family typewriter
12950 D2*00\InsetSpace ~
12951 \InsetSpace ~
12952 \InsetSpace ~
12953 \InsetSpace ~
12954 \InsetSpace ~
12955 \InsetSpace ~
12956 \InsetSpace ~
12957 setb\InsetSpace ~
12958 _test_bit
12959 \end_layout
12960
12961 \begin_layout Standard
12962 The bit addressable memory consists of 128 bits which are located from 0x20
12963  to 0x2f in data memory.
12964  
12965 \newline
12966 Apart from this 8051 specific storage class most architectures support
12967  ANSI-C bitfields
12968 \begin_inset LatexCommand index
12969 name "bitfields"
12970
12971 \end_inset
12972
12973
12974 \begin_inset Foot
12975 status open
12976
12977 \begin_layout Standard
12978 Not really meant as examples, but nevertheless showing what bitfields are
12979  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12980 \end_layout
12981
12982 \end_inset
12983
12984 .
12985  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12986  signed modifier are implemented as unsigned.
12987 \end_layout
12988
12989 \begin_layout Subsubsection
12990 sfr
12991 \begin_inset LatexCommand index
12992 name "sfr"
12993
12994 \end_inset
12995
12996
12997 \begin_inset LatexCommand index
12998 name "\\_\\_sfr"
12999
13000 \end_inset
13001
13002  / sfr16
13003 \begin_inset LatexCommand index
13004 name "sfr16"
13005
13006 \end_inset
13007
13008
13009 \begin_inset LatexCommand index
13010 name "\\_\\_sfr16"
13011
13012 \end_inset
13013
13014  / sfr32
13015 \begin_inset LatexCommand index
13016 name "sfr32"
13017
13018 \end_inset
13019
13020
13021 \begin_inset LatexCommand index
13022 name "\\_\\_sfr32"
13023
13024 \end_inset
13025
13026  / sbit
13027 \begin_inset LatexCommand index
13028 name "\\_\\_sbit"
13029
13030 \end_inset
13031
13032
13033 \begin_inset LatexCommand index
13034 name "sbit"
13035
13036 \end_inset
13037
13038
13039 \end_layout
13040
13041 \begin_layout Standard
13042 Like the bit keyword, 
13043 \emph on
13044 sfr / sfr16 / sfr32 / sbit
13045 \emph default
13046  signify both a data-type and storage class, they are used to describe the
13047  
13048 \emph on
13049 s
13050 \emph default
13051 pecial 
13052 \emph on
13053 f
13054 \emph default
13055 unction 
13056 \emph on
13057 r
13058 \emph default
13059 egisters and 
13060 \emph on
13061 s
13062 \emph default
13063 pecial 
13064 \emph on
13065 bit
13066 \emph default
13067  variables of a 8051, eg:
13068 \end_layout
13069
13070 \begin_layout Verse
13071
13072 \family typewriter
13073 __sfr __at
13074 \begin_inset LatexCommand index
13075 name "at"
13076
13077 \end_inset
13078
13079
13080 \begin_inset LatexCommand index
13081 name "\\_\\_at"
13082
13083 \end_inset
13084
13085  (0x80) P0;\InsetSpace ~
13086  /* special function register P0 at location 0x80 */
13087 \newline
13088
13089 \newline
13090 /* 16 bit
13091  special function register combination for timer 0
13092 \newline
13093 \InsetSpace ~
13094 \InsetSpace ~
13095  with the high byte at
13096  location 0x8C and the low byte at location 0x8A */
13097 \newline
13098 __sfr16 __at (0x8C8A)
13099  TMR0;
13100 \newline
13101
13102 \newline
13103 __sbit __at
13104 \begin_inset LatexCommand index
13105 name "at"
13106
13107 \end_inset
13108
13109
13110 \begin_inset LatexCommand index
13111 name "\\_\\_at"
13112
13113 \end_inset
13114
13115  (0xd7) CY;\InsetSpace ~
13116  /* CY (Carry Flag
13117 \begin_inset LatexCommand index
13118 name "Flags"
13119
13120 \end_inset
13121
13122
13123 \begin_inset LatexCommand index
13124 name "Carry flag"
13125
13126 \end_inset
13127
13128 ) */
13129 \end_layout
13130
13131 \begin_layout Standard
13132 Special function registers which are located on an address dividable by
13133  8 are bit-addressable, an 
13134 \emph on
13135 sbit
13136 \emph default
13137  addresses a specific bit within these sfr.
13138 \newline
13139 16 Bit and 32 bit special function
13140  register combinations which require a certain access order are better not
13141  declared using 
13142 \emph on
13143 sfr16
13144 \emph default
13145  or 
13146 \emph on
13147 sfr32.
13148
13149 \emph default
13150  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
13151  this is not guaranteed.
13152 \newline
13153
13154 \end_layout
13155
13156 \begin_layout Standard
13157 Please note, if you use a header file which was written for another compiler
13158  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
13159  likely be 
13160 \emph on
13161 not
13162 \emph default
13163  compatible.
13164  Specifically the syntax 
13165 \family typewriter
13166 \InsetSpace ~
13167 sfr P0 = 0x80;\InsetSpace ~
13168
13169 \family default
13170  is compiled 
13171 \emph on
13172 without warning
13173 \emph default
13174  by SDCC to an assignment of 0x80 to a variable called P0 
13175 \family typewriter
13176
13177 \begin_inset Marginal
13178 status collapsed
13179
13180 \begin_layout Standard
13181
13182 \series bold
13183 \InsetSpace ~
13184 !
13185 \end_layout
13186
13187 \end_inset
13188
13189 .
13190
13191 \family default
13192  
13193 \series bold
13194 Nevertheless it is possible to write header files
13195 \begin_inset LatexCommand index
13196 name "Header files"
13197
13198 \end_inset
13199
13200
13201 \begin_inset LatexCommand index
13202 name "Include files"
13203
13204 \end_inset
13205
13206  which can be shared among different compilers (see section 
13207 \begin_inset LatexCommand ref
13208 reference "sec:Porting-code-to-other-compilers"
13209
13210 \end_inset
13211
13212 ).
13213  
13214 \end_layout
13215
13216 \begin_layout Subsubsection
13217 Pointers
13218 \begin_inset LatexCommand index
13219 name "Pointer"
13220
13221 \end_inset
13222
13223  to MCS51/DS390 specific memory spaces
13224 \end_layout
13225
13226 \begin_layout Standard
13227 SDCC allows (via language extensions) pointers to explicitly point to any
13228  of the memory spaces
13229 \begin_inset LatexCommand index
13230 name "Memory model"
13231
13232 \end_inset
13233
13234  of the 8051.
13235  In addition to the explicit pointers, the compiler uses (by default) generic
13236  pointers which can be used to point to any of the memory spaces.
13237 \newline
13238
13239 \newline
13240 Pointer
13241  declaration examples:
13242 \end_layout
13243
13244 \begin_layout Verse
13245
13246 \family typewriter
13247 /* pointer physically in internal ram pointing to object in external ram
13248  */ 
13249 \newline
13250 __xdata unsigned char * __data p;
13251 \newline
13252
13253 \newline
13254 /* pointer physically in external ram
13255  pointing to object in internal ram */ 
13256 \newline
13257 __data unsigned char * __xdata p;
13258 \newline
13259
13260 \newline
13261 /*
13262  pointer physically in code rom pointing to data in xdata space */ 
13263 \newline
13264 __xdata
13265  unsigned char * __code p;
13266 \newline
13267
13268 \newline
13269 /* pointer physically in code space pointing to
13270  data in code space */ 
13271 \newline
13272 __code unsigned char * __code p;
13273 \newline
13274
13275 \newline
13276 /* generic pointer
13277  physically located in xdata space */
13278 \newline
13279 unsigned char * __xdata p;
13280 \newline
13281
13282 \newline
13283 /* generic
13284  pointer physically located in default memory space */
13285 \newline
13286 unsigned char * p;
13287 \newline
13288
13289 \newline
13290 /*
13291  the following is a function pointer
13292 \begin_inset LatexCommand index
13293 name "function pointer"
13294
13295 \end_inset
13296
13297  physically located in data space */
13298 \newline
13299 char (* __data fp)(void);
13300 \end_layout
13301
13302 \begin_layout Standard
13303 Well you get the idea.
13304  
13305 \newline
13306
13307 \newline
13308 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
13309 \emph on
13310 generic
13311 \emph default
13312  pointers.
13313  
13314 \size small
13315
13316 \newline
13317
13318 \newline
13319
13320 \size default
13321 The highest order byte of the 
13322 \emph on
13323 generic
13324 \emph default
13325  pointers contains the data space information.
13326  Assembler support routines are called whenever data is stored or retrieved
13327  using 
13328 \emph on
13329 generic
13330 \emph default
13331  pointers.
13332  These are useful for developing reusable library
13333 \begin_inset LatexCommand index
13334 name "Libraries"
13335
13336 \end_inset
13337
13338  routines.
13339  Explicitly specifying the pointer
13340 \begin_inset LatexCommand index
13341 name "pointer"
13342
13343 \end_inset
13344
13345  type will generate the most efficient code.
13346 \end_layout
13347
13348 \begin_layout Subsubsection
13349 Notes on MCS51 memory
13350 \begin_inset LatexCommand index
13351 name "MCS51 memory"
13352
13353 \end_inset
13354
13355  layout
13356 \end_layout
13357
13358 \begin_layout Standard
13359 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
13360  RAM memory which is structured as follows:
13361 \newline
13362
13363 \newline
13364 - Bytes 00-1F - 32 bytes to hold
13365  up to 4 banks of the registers R0 to R7, 
13366 \newline
13367 - Bytes 20-2F - 16 bytes to hold
13368  128 bit
13369 \begin_inset LatexCommand index
13370 name "bit"
13371
13372 \end_inset
13373
13374  variables and, 
13375 \newline
13376 - Bytes 30-7F - 80 bytes for general purpose use.
13377 \newline
13378
13379 \end_layout
13380
13381 \begin_layout Standard
13382 Additionally some members of the MCS51 family may have up to 128 bytes of
13383  additional, indirectly addressable, internal RAM memory (
13384 \emph on
13385 idata
13386 \emph default
13387
13388 \begin_inset LatexCommand index
13389 name "idata (mcs51, ds390 storage class)"
13390
13391 \end_inset
13392
13393
13394 \begin_inset LatexCommand index
13395 name "\\_\\_idata (mcs51, ds390 storage class)"
13396
13397 \end_inset
13398
13399 ).
13400  Furthermore, some chips may have some built in external memory (
13401 \emph on
13402 xdata
13403 \emph default
13404
13405 \begin_inset LatexCommand index
13406 name "xdata (mcs51, ds390 storage class)"
13407
13408 \end_inset
13409
13410
13411 \begin_inset LatexCommand index
13412 name "\\_\\_xdata (mcs51, ds390 storage class)"
13413
13414 \end_inset
13415
13416 ) which should not be confused with the internal, directly addressable RAM
13417  memory (
13418 \emph on
13419 data
13420 \emph default
13421
13422 \begin_inset LatexCommand index
13423 name "data (mcs51, ds390 storage class)"
13424
13425 \end_inset
13426
13427
13428 \begin_inset LatexCommand index
13429 name "\\_\\_data (mcs51, ds390 storage class)"
13430
13431 \end_inset
13432
13433 ).
13434  Sometimes this built in 
13435 \emph on
13436 xdata
13437 \emph default
13438  memory has to be activated before using it (you can probably find this
13439  information on the datasheet of the microcontroller your are using, see
13440  also section 
13441 \begin_inset LatexCommand ref
13442 reference "sub:Startup-Code"
13443
13444 \end_inset
13445
13446 \InsetSpace ~
13447 Startup-Code).
13448 \end_layout
13449
13450 \begin_layout Standard
13451 Normally SDCC will only use the first bank
13452 \begin_inset LatexCommand index
13453 name "register bank (mcs51, ds390)"
13454
13455 \end_inset
13456
13457  of registers (register bank 0), but it is possible to specify that other
13458  banks of registers (keyword 
13459 \emph on
13460 using
13461 \emph default
13462  
13463 \emph on
13464
13465 \begin_inset LatexCommand index
13466 name "using (mcs51, ds390 register bank)"
13467
13468 \end_inset
13469
13470
13471 \begin_inset LatexCommand index
13472 name "\\_\\_using (mcs51, ds390 register bank)"
13473
13474 \end_inset
13475
13476
13477 \emph default
13478 ) should be used for example in interrupt
13479 \begin_inset LatexCommand index
13480 name "interrupt"
13481
13482 \end_inset
13483
13484
13485 \begin_inset LatexCommand index
13486 name "\\_\\_interrupt"
13487
13488 \end_inset
13489
13490  routines.
13491  By default, the compiler will place the stack after the last byte of allocated
13492  memory for variables.
13493  For example, if the first 2 banks of registers are used, and only four
13494  bytes are used for 
13495 \emph on
13496 data
13497 \emph default
13498  variables, it will position the base of the internal stack at address 20
13499  (0x14).
13500  This implies that as the stack
13501 \begin_inset LatexCommand index
13502 name "stack"
13503
13504 \end_inset
13505
13506  grows, it will use up the remaining register banks, and the 16 bytes used
13507  by the 128 bit variables, and 80 bytes for general purpose use.
13508  If any bit variables are used, the data variables will be placed in unused
13509  register banks and after the byte holding the last bit variable.
13510  For example, if register banks 0 and 1 are used, and there are 9 bit variables
13511  (two bytes used), 
13512 \emph on
13513 data
13514 \emph default
13515  variables will be placed starting from address 0x10 to 0x20 and continue
13516  at address 0x22.
13517  You can also use -
13518 \begin_inset ERT
13519 status collapsed
13520
13521 \begin_layout Standard
13522
13523
13524 \backslash
13525 /
13526 \end_layout
13527
13528 \end_inset
13529
13530 -data-loc
13531 \begin_inset LatexCommand index
13532 name "-\\/-data-loc <Value>"
13533
13534 \end_inset
13535
13536  to specify the start address of the 
13537 \emph on
13538 data
13539 \emph default
13540  and -
13541 \begin_inset ERT
13542 status collapsed
13543
13544 \begin_layout Standard
13545
13546
13547 \backslash
13548 /
13549 \end_layout
13550
13551 \end_inset
13552
13553 -iram-size
13554 \begin_inset LatexCommand index
13555 name "-\\/-iram-size <Value>"
13556
13557 \end_inset
13558
13559  to specify the size of the total internal RAM (
13560 \emph on
13561 data
13562 \emph default
13563 +
13564 \emph on
13565 idata
13566 \emph default
13567 ).
13568  
13569 \newline
13570
13571 \end_layout
13572
13573 \begin_layout Standard
13574 By default the 8051 linker will place the stack after the last byte of (i)data
13575  variables.
13576  Option -
13577 \begin_inset ERT
13578 status collapsed
13579
13580 \begin_layout Standard
13581
13582
13583 \backslash
13584 /
13585 \end_layout
13586
13587 \end_inset
13588
13589 -stack-loc
13590 \begin_inset LatexCommand index
13591 name "-\\/-stack-loc <Value>"
13592
13593 \end_inset
13594
13595  allows you to specify the start of the stack, i.e.
13596  you could start it after any data in the general purpose area.
13597  If your microcontroller has additional indirectly addressable internal
13598  RAM (
13599 \emph on
13600 idata
13601 \emph default
13602 ) you can place the stack on it.
13603  You may also need to use -
13604 \begin_inset ERT
13605 status collapsed
13606
13607 \begin_layout Standard
13608
13609
13610 \backslash
13611 /
13612 \end_layout
13613
13614 \end_inset
13615
13616 -xdata-loc
13617 \begin_inset LatexCommand index
13618 name "-\\/-xdata-loc<Value>"
13619
13620 \end_inset
13621
13622  to set the start address of the external RAM (
13623 \emph on
13624 xdata
13625 \emph default
13626 ) and -
13627 \begin_inset ERT
13628 status collapsed
13629
13630 \begin_layout Standard
13631
13632
13633 \backslash
13634 /
13635 \end_layout
13636
13637 \end_inset
13638
13639 -xram-size
13640 \begin_inset LatexCommand index
13641 name "-\\/-xram-size <Value>"
13642
13643 \end_inset
13644
13645  to specify its size.
13646  Same goes for the code memory, using -
13647 \begin_inset ERT
13648 status collapsed
13649
13650 \begin_layout Standard
13651
13652
13653 \backslash
13654 /
13655 \end_layout
13656
13657 \end_inset
13658
13659 -code-loc
13660 \begin_inset LatexCommand index
13661 name "-\\/-code-loc <Value>"
13662
13663 \end_inset
13664
13665  and -
13666 \begin_inset ERT
13667 status collapsed
13668
13669 \begin_layout Standard
13670
13671
13672 \backslash
13673 /
13674 \end_layout
13675
13676 \end_inset
13677
13678 -code-size
13679 \begin_inset LatexCommand index
13680 name "-\\/-code-size <Value>"
13681
13682 \end_inset
13683
13684 .
13685  If in doubt, don't specify any options and see if the resulting memory
13686  layout is appropriate, then you can adjust it.
13687 \end_layout
13688
13689 \begin_layout Standard
13690 The linker generates two files with memory allocation information.
13691  The first, with extension .map
13692 \begin_inset LatexCommand index
13693 name "<file>.map"
13694
13695 \end_inset
13696
13697  shows all the variables and segments.
13698  The second with extension .mem
13699 \begin_inset LatexCommand index
13700 name "<file>.mem"
13701
13702 \end_inset
13703
13704  shows the final memory layout.
13705  The linker will complain either if memory segments overlap, there is not
13706  enough memory, or there is not enough space for stack.
13707  If you get any linking warnings and/or errors related to stack or segments
13708  allocation, take a look at either the .map or .mem files to find out what
13709  the problem is.
13710  The .mem file may even suggest a solution to the problem.
13711 \begin_inset VSpace bigskip
13712 \end_inset
13713
13714
13715 \end_layout
13716
13717 \begin_layout Subsection
13718 Z80/Z180 Storage Class
13719 \begin_inset LatexCommand index
13720 name "Z80!Storage class"
13721
13722 \end_inset
13723
13724  Language Extensions
13725 \end_layout
13726
13727 \begin_layout Subsubsection
13728 sfr
13729 \begin_inset LatexCommand index
13730 name "sfr"
13731
13732 \end_inset
13733
13734
13735 \begin_inset LatexCommand index
13736 name "\\_\\_sfr"
13737
13738 \end_inset
13739
13740  (in/out to 8-bit addresses)
13741 \end_layout
13742
13743 \begin_layout Standard
13744 The Z80
13745 \begin_inset LatexCommand index
13746 name "Z80"
13747
13748 \end_inset
13749
13750  family has separate address spaces for memory and 
13751 \emph on
13752 i
13753 \emph default
13754 nput/
13755 \emph on
13756 o
13757 \emph default
13758 utput memory.
13759  I/O memory
13760 \begin_inset LatexCommand index
13761 name "I/O memory (Z80, Z180)"
13762
13763 \end_inset
13764
13765
13766 \begin_inset LatexCommand index
13767 name "Z80!I/O memory"
13768
13769 \end_inset
13770
13771
13772 \begin_inset LatexCommand index
13773 name "Z180!I/O memory"
13774
13775 \end_inset
13776
13777  is accessed with special instructions, e.g.:
13778 \end_layout
13779
13780 \begin_layout Verse
13781
13782 \family typewriter
13783 sfr at 0x78 IoPort;\InsetSpace ~
13784 \InsetSpace ~
13785 /* define a var in I/O space at 78h called IoPort */
13786  
13787 \end_layout
13788
13789 \begin_layout Standard
13790 Writing 0x01 to this variable generates the assembly code:
13791 \end_layout
13792
13793 \begin_layout Verse
13794
13795 \family typewriter
13796 3E 01\InsetSpace ~
13797 \InsetSpace ~
13798 \InsetSpace ~
13799 \InsetSpace ~
13800 \InsetSpace ~
13801 \InsetSpace ~
13802 ld a,#0x01
13803 \newline
13804 D3 78\InsetSpace ~
13805 \InsetSpace ~
13806 \InsetSpace ~
13807 \InsetSpace ~
13808 \InsetSpace ~
13809 \InsetSpace ~
13810 out (_IoPort),a 
13811 \end_layout
13812
13813 \begin_layout Subsubsection
13814 banked sfr
13815 \begin_inset LatexCommand index
13816 name "sfr"
13817
13818 \end_inset
13819
13820
13821 \begin_inset LatexCommand index
13822 name "\\_\\_sfr"
13823
13824 \end_inset
13825
13826  (in/out to 16-bit addresses)
13827 \end_layout
13828
13829 \begin_layout Standard
13830 The keyword 
13831 \emph on
13832 banked
13833 \emph default
13834  is used to support 16 bit addresses in I/O memory e.g.:
13835 \end_layout
13836
13837 \begin_layout Verse
13838
13839 \family typewriter
13840 sfr banked at
13841 \begin_inset LatexCommand index
13842 name "at"
13843
13844 \end_inset
13845
13846
13847 \begin_inset LatexCommand index
13848 name "\\_\\_at"
13849
13850 \end_inset
13851
13852  0x123 IoPort; 
13853 \end_layout
13854
13855 \begin_layout Standard
13856 Writing 0x01 to this variable generates the assembly code:
13857 \end_layout
13858
13859 \begin_layout Verse
13860
13861 \family typewriter
13862 01 23 01\InsetSpace ~
13863 \InsetSpace ~
13864 \InsetSpace ~
13865 ld bc,#_IoPort
13866 \newline
13867 3E 01\InsetSpace ~
13868 \InsetSpace ~
13869 \InsetSpace ~
13870 \InsetSpace ~
13871 \InsetSpace ~
13872 \InsetSpace ~
13873 ld a,#0x01 
13874 \newline
13875 ED 79\InsetSpace ~
13876 \InsetSpace ~
13877 \InsetSpace ~
13878 \InsetSpace ~
13879 \InsetSpace ~
13880 \InsetSpace ~
13881 out (c),a 
13882 \end_layout
13883
13884 \begin_layout Subsubsection
13885 sfr
13886 \begin_inset LatexCommand index
13887 name "sfr"
13888
13889 \end_inset
13890
13891
13892 \begin_inset LatexCommand index
13893 name "\\_\\_sfr"
13894
13895 \end_inset
13896
13897  (in0/out0 to 8 bit addresses on Z180
13898 \begin_inset LatexCommand index
13899 name "Z180"
13900
13901 \end_inset
13902
13903 /HD64180
13904 \begin_inset LatexCommand index
13905 name "HD64180 (see Z180)"
13906
13907 \end_inset
13908
13909 )
13910 \end_layout
13911
13912 \begin_layout Standard
13913 The compiler option -
13914 \begin_inset ERT
13915 status collapsed
13916
13917 \begin_layout Standard
13918
13919
13920 \backslash
13921 /
13922 \end_layout
13923
13924 \end_inset
13925
13926 -portmode
13927 \begin_inset LatexCommand index
13928 name "Z180!Options!-\\/-portmode"
13929
13930 \end_inset
13931
13932 =180 (80) and a compiler #pragma\InsetSpace ~
13933 portmode
13934 \begin_inset LatexCommand index
13935 name "Z180!Pragmas!\\#pragma portmode"
13936
13937 \end_inset
13938
13939  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
13940 ns 
13941 \family typewriter
13942 in0/out0
13943 \family default
13944  instead of 
13945 \family typewriter
13946 in/out
13947 \family default
13948 .
13949  If you include the file z180.h this will be set automatically.
13950 \begin_inset VSpace bigskip
13951 \end_inset
13952
13953
13954 \end_layout
13955
13956 \begin_layout Subsection
13957 HC08 Storage Class
13958 \begin_inset LatexCommand index
13959 name "HC08!Storage class"
13960
13961 \end_inset
13962
13963  Language Extensions
13964 \end_layout
13965
13966 \begin_layout Subsubsection
13967 data
13968 \begin_inset LatexCommand index
13969 name "data (hc08 storage class)"
13970
13971 \end_inset
13972
13973
13974 \begin_inset LatexCommand index
13975 name "\\_\\_data (hc08 storage class)"
13976
13977 \end_inset
13978
13979  
13980 \end_layout
13981
13982 \begin_layout Standard
13983 The data storage class declares a variable that resides in the first 256
13984  bytes of memory (the direct page).
13985  The HC08
13986 \begin_inset LatexCommand index
13987 name "HC08"
13988
13989 \end_inset
13990
13991  is most efficient at accessing variables (especially pointers) stored here.
13992 \end_layout
13993
13994 \begin_layout Subsubsection
13995 xdata
13996 \begin_inset LatexCommand index
13997 name "xdata (hc08 storage class)"
13998
13999 \end_inset
14000
14001
14002 \begin_inset LatexCommand index
14003 name "\\_\\_xdata (hc08 storage class)"
14004
14005 \end_inset
14006
14007  
14008 \end_layout
14009
14010 \begin_layout Standard
14011 The xdata storage class declares a variable that can reside anywhere in
14012  memory.
14013  This is the default if no storage class is specified.
14014  
14015 \begin_inset VSpace bigskip
14016 \end_inset
14017
14018
14019 \end_layout
14020
14021 \begin_layout Section
14022 Other SDCC language extensions
14023 \begin_inset LatexCommand index
14024 name "Other SDCC language extensions"
14025
14026 \end_inset
14027
14028
14029 \end_layout
14030
14031 \begin_layout Subsection
14032 Binary constants
14033 \end_layout
14034
14035 \begin_layout Standard
14036 SDCC supports the use of binary constants, such as 0b01100010.
14037  This feature is only enabled when the compiler is invoked using --std-sdccxx.
14038 \end_layout
14039
14040 \begin_layout Standard
14041 \begin_inset VSpace bigskip
14042 \end_inset
14043
14044
14045 \end_layout
14046
14047 \begin_layout Section
14048 Absolute Addressing
14049 \begin_inset LatexCommand index
14050 name "Absolute addressing"
14051
14052 \end_inset
14053
14054
14055 \end_layout
14056
14057 \begin_layout Standard
14058 Data items can be assigned an absolute address with the 
14059 \emph on
14060 at
14061 \begin_inset LatexCommand index
14062 name "at"
14063
14064 \end_inset
14065
14066
14067 \begin_inset LatexCommand index
14068 name "\\_\\_at"
14069
14070 \end_inset
14071
14072  <address>
14073 \emph default
14074  keyword, in addition to a storage class, e.g.:
14075 \end_layout
14076
14077 \begin_layout Verse
14078
14079 \family typewriter
14080 xdata
14081 \begin_inset LatexCommand index
14082 name "xdata (mcs51, ds390 storage class)"
14083
14084 \end_inset
14085
14086
14087 \begin_inset LatexCommand index
14088 name "\\_\\_xdata (mcs51, ds390 storage class)"
14089
14090 \end_inset
14091
14092  at
14093 \begin_inset LatexCommand index
14094 name "at"
14095
14096 \end_inset
14097
14098
14099 \begin_inset LatexCommand index
14100 name "\\_\\_at"
14101
14102 \end_inset
14103
14104  0x7ffe unsigned int chksum;
14105 \end_layout
14106
14107 \begin_layout Standard
14108 or, better conforming to ISO/IEC 9899 C:
14109 \end_layout
14110
14111 \begin_layout Verse
14112
14113 \family typewriter
14114 __xdata __at (0x7ffe) unsigned int chksum;
14115 \end_layout
14116
14117 \begin_layout Standard
14118 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
14119  of the external ram.
14120  The compiler does 
14121 \emph on
14122 not
14123 \emph default
14124  reserve any space for variables declared in this way
14125 \begin_inset Marginal
14126 status collapsed
14127
14128 \begin_layout Standard
14129
14130 \series bold
14131 \InsetSpace ~
14132 !
14133 \end_layout
14134
14135 \end_inset
14136
14137  (they are implemented with an equate in the assembler).
14138  Thus it is left to the programmer to make sure there are no overlaps with
14139  other variables that are declared without the absolute address.
14140  The assembler listing file (.lst
14141 \begin_inset LatexCommand index
14142 name "<file>.lst"
14143
14144 \end_inset
14145
14146 ) and the linker output files (.rst
14147 \begin_inset LatexCommand index
14148 name "<file>.rst"
14149
14150 \end_inset
14151
14152 ) and (.map
14153 \begin_inset LatexCommand index
14154 name "<file>.map"
14155
14156 \end_inset
14157
14158 ) are good places to look for such overlaps.
14159 \end_layout
14160
14161 \begin_layout Standard
14162 If however you provide an initializer
14163 \begin_inset LatexCommand index
14164 name "Variable initialization"
14165
14166 \end_inset
14167
14168  actual memory allocation will take place and overlaps will be detected
14169  by the linker.
14170  E.g.:
14171 \end_layout
14172
14173 \begin_layout Verse
14174
14175 \family typewriter
14176 __code __at (0x7ff0) char Id[5] = 
14177 \begin_inset Quotes sld
14178 \end_inset
14179
14180 SDCC
14181 \begin_inset Quotes srd
14182 \end_inset
14183
14184 ;
14185 \end_layout
14186
14187 \begin_layout Standard
14188 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
14189  in code memory.
14190 \end_layout
14191
14192 \begin_layout Standard
14193 In case of memory mapped I/O devices the keyword 
14194 \emph on
14195 volatile
14196 \emph default
14197  has to be used to tell the compiler that accesses might not be removed:
14198 \end_layout
14199
14200 \begin_layout Verse
14201
14202 \family typewriter
14203 volatile
14204 \begin_inset LatexCommand index
14205 name "volatile"
14206
14207 \end_inset
14208
14209  __xdata
14210 \begin_inset LatexCommand index
14211 name "xdata (mcs51, ds390 storage class)"
14212
14213 \end_inset
14214
14215  __at
14216 \begin_inset LatexCommand index
14217 name "at"
14218
14219 \end_inset
14220
14221  (0x8000) unsigned char PORTA_8255;
14222 \end_layout
14223
14224 \begin_layout Standard
14225 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
14226 r) array
14227 \family typewriter
14228 \size footnotesize
14229
14230 \begin_inset LatexCommand index
14231 name "Aligned array"
14232
14233 \end_inset
14234
14235
14236 \family default
14237 \size default
14238  starts at a block (256 byte) boundary
14239 \begin_inset LatexCommand index
14240 name "block boundary"
14241
14242 \end_inset
14243
14244  (section 
14245 \begin_inset LatexCommand ref
14246 reference "sub:A-Step-by Assembler Introduction"
14247
14248 \end_inset
14249
14250  has an example).
14251 \newline
14252 Absolute addresses can be specified for variables in all
14253  storage classes, e.g.:
14254 \end_layout
14255
14256 \begin_layout Verse
14257
14258 \family typewriter
14259 __bit
14260 \begin_inset LatexCommand index
14261 name "bit"
14262
14263 \end_inset
14264
14265  __at
14266 \begin_inset LatexCommand index
14267 name "at"
14268
14269 \end_inset
14270
14271  (0x02) bvar;
14272 \end_layout
14273
14274 \begin_layout Standard
14275 The above example will allocate the variable at offset 0x02 in the bit-addressab
14276 le space.
14277  There is no real advantage to assigning absolute addresses to variables
14278  in this manner, unless you want strict control over all the variables allocated.
14279  One possible use would be to write hardware portable code.
14280  For example, if you have a routine that uses one or more of the microcontroller
14281  I/O pins, and such pins are different for two different hardwares, you
14282  can declare the I/O pins in your routine using:
14283 \end_layout
14284
14285 \begin_layout Verse
14286
14287 \family typewriter
14288 extern volatile
14289 \begin_inset LatexCommand index
14290 name "volatile"
14291
14292 \end_inset
14293
14294  __bit MOSI;\InsetSpace ~
14295 \InsetSpace ~
14296 \InsetSpace ~
14297 \InsetSpace ~
14298 /* master out, slave in */
14299 \newline
14300 extern volatile __bit MISO;\InsetSpace ~
14301 \InsetSpace ~
14302 \InsetSpace ~
14303 \InsetSpace ~
14304 /* master
14305  in, slave out */
14306 \newline
14307 extern volatile __bit MCLK;\InsetSpace ~
14308 \InsetSpace ~
14309 \InsetSpace ~
14310 \InsetSpace ~
14311 /* master clock */
14312 \newline
14313
14314 \newline
14315 /* Input and
14316  Output of a byte on a 3-wire serial bus.
14317 \newline
14318 \InsetSpace ~
14319 \InsetSpace ~
14320 \InsetSpace ~
14321 If needed adapt polarity of clock,
14322  polarity of data and bit order
14323 \newline
14324 \InsetSpace ~
14325 */
14326 \newline
14327 unsigned char spi_io(unsigned char out_byte)
14328  
14329 \newline
14330
14331 \newline
14332 \InsetSpace ~
14333 \InsetSpace ~
14334 \InsetSpace ~
14335 \InsetSpace ~
14336 unsigned char i=8;
14337 \newline
14338 \InsetSpace ~
14339 \InsetSpace ~
14340 \InsetSpace ~
14341 \InsetSpace ~
14342 do { 
14343 \newline
14344 \InsetSpace ~
14345 \InsetSpace ~
14346 \InsetSpace ~
14347 \InsetSpace ~
14348 \InsetSpace ~
14349 \InsetSpace ~
14350 \InsetSpace ~
14351 \InsetSpace ~
14352 MOSI = out_byte & 0x80; 
14353 \newline
14354 \InsetSpace ~
14355 \InsetSpace ~
14356 \InsetSpace ~
14357 \InsetSpace ~
14358 \InsetSpace ~
14359 \InsetSpace ~
14360 \InsetSpace ~
14361 \InsetSpace ~
14362 out_byte <<= 1;
14363 \newline
14364 \InsetSpace ~
14365 \InsetSpace ~
14366 \InsetSpace ~
14367 \InsetSpace ~
14368 \InsetSpace ~
14369 \InsetSpace ~
14370 \InsetSpace ~
14371 \InsetSpace ~
14372 MCLK =
14373  1; 
14374 \newline
14375 \InsetSpace ~
14376 \InsetSpace ~
14377 \InsetSpace ~
14378 \InsetSpace ~
14379 \InsetSpace ~
14380 \InsetSpace ~
14381 \InsetSpace ~
14382 \InsetSpace ~
14383 /* _asm nop _endasm; */\InsetSpace ~
14384 \InsetSpace ~
14385 \InsetSpace ~
14386 \InsetSpace ~
14387 \InsetSpace ~
14388 \InsetSpace ~
14389 \InsetSpace ~
14390 \InsetSpace ~
14391 /* for slow peripherals */
14392 \newline
14393 \InsetSpace ~
14394 \InsetSpace ~
14395 \InsetSpace ~
14396 \InsetSpace ~
14397 \InsetSpace ~
14398 \InsetSpace ~
14399 \InsetSpace ~
14400 \InsetSpace ~
14401 if(MISO) 
14402 \newline
14403 \InsetSpace ~
14404 \InsetSpace ~
14405 \InsetSpace ~
14406 \InsetSpace ~
14407 \InsetSpace ~
14408 \InsetSpace ~
14409 \InsetSpace ~
14410 \InsetSpace ~
14411 \InsetSpace ~
14412 \InsetSpace ~
14413 \InsetSpace ~
14414 \InsetSpace ~
14415 out_byte +=
14416  1; 
14417 \newline
14418 \InsetSpace ~
14419 \InsetSpace ~
14420 \InsetSpace ~
14421 \InsetSpace ~
14422 \InsetSpace ~
14423 \InsetSpace ~
14424 \InsetSpace ~
14425 \InsetSpace ~
14426 MCLK = 0; 
14427 \newline
14428 \InsetSpace ~
14429 \InsetSpace ~
14430 \InsetSpace ~
14431 \InsetSpace ~
14432 } while(--i);
14433 \newline
14434 \InsetSpace ~
14435 \InsetSpace ~
14436 \InsetSpace ~
14437 \InsetSpace ~
14438 return out_byte; 
14439 \newline
14440 }
14441 \end_layout
14442
14443 \begin_layout Standard
14444 Then, someplace in the code for the first hardware you would use
14445 \end_layout
14446
14447 \begin_layout Verse
14448
14449 \family typewriter
14450 __bit __at
14451 \begin_inset LatexCommand index
14452 name "at"
14453
14454 \end_inset
14455
14456
14457 \begin_inset LatexCommand index
14458 name "\\_\\_at"
14459
14460 \end_inset
14461
14462  (0x80) MOSI;\InsetSpace ~
14463 \InsetSpace ~
14464 \InsetSpace ~
14465 \InsetSpace ~
14466 /* I/O port 0, bit 0 */
14467 \newline
14468 __bit __at (0x81) MISO;\InsetSpace ~
14469 \InsetSpace ~
14470 \InsetSpace ~
14471 \InsetSpace ~
14472 /* I/O port 0,
14473  bit 1 */
14474 \newline
14475 __bit __at (0x82) MCLK;\InsetSpace ~
14476 \InsetSpace ~
14477 \InsetSpace ~
14478 \InsetSpace ~
14479 /* I/O port 0, bit 2 */
14480 \end_layout
14481
14482 \begin_layout Standard
14483 Similarly, for the second hardware you would use
14484 \end_layout
14485
14486 \begin_layout Verse
14487
14488 \family typewriter
14489 __bit __at (0x83) MOSI;\InsetSpace ~
14490 \InsetSpace ~
14491 \InsetSpace ~
14492 \InsetSpace ~
14493 /* I/O port 0, bit 3 */
14494 \newline
14495 __bit __at (0x91) MISO;\InsetSpace ~
14496 \InsetSpace ~
14497 \InsetSpace ~
14498 \InsetSpace ~
14499 /*
14500  I/O port 1, bit 1 */
14501 \newline
14502 __bit
14503 \begin_inset LatexCommand index
14504 name "bit"
14505
14506 \end_inset
14507
14508  __at (0x92) MCLK;\InsetSpace ~
14509 \InsetSpace ~
14510 \InsetSpace ~
14511 \InsetSpace ~
14512 /* I/O port 1, bit 2 */
14513 \end_layout
14514
14515 \begin_layout Standard
14516 and you can use the same hardware dependent routine without changes, as
14517  for example in a library.
14518  This is somehow similar to sbit, but only one absolute address has to be
14519  specified in the whole project.
14520 \begin_inset VSpace bigskip
14521 \end_inset
14522
14523
14524 \end_layout
14525
14526 \begin_layout Section
14527 Parameters
14528 \begin_inset LatexCommand index
14529 name "Parameters"
14530
14531 \end_inset
14532
14533
14534 \begin_inset LatexCommand index
14535 name "function parameter"
14536
14537 \end_inset
14538
14539  & Local Variables
14540 \begin_inset LatexCommand index
14541 name "local variables"
14542
14543 \end_inset
14544
14545
14546 \begin_inset LatexCommand label
14547 name "sec:Parameters-and-Local-Variables"
14548
14549 \end_inset
14550
14551
14552 \end_layout
14553
14554 \begin_layout Standard
14555 Automatic (local) variables and parameters to functions can either be placed
14556  on the stack or in data-space.
14557  The default action of the compiler is to place these variables in the internal
14558  RAM (for small model) or external RAM (for medium or large model).
14559  This in fact makes them similar to 
14560 \emph on
14561 static
14562 \begin_inset LatexCommand index
14563 name "static"
14564
14565 \end_inset
14566
14567
14568 \emph default
14569  so by default functions are non-reentrant
14570 \begin_inset LatexCommand index
14571 name "reentrant"
14572
14573 \end_inset
14574
14575 .
14576  
14577 \newline
14578
14579 \newline
14580 They can be placed on the stack
14581 \begin_inset LatexCommand index
14582 name "stack"
14583
14584 \end_inset
14585
14586  by using the 
14587 \emph on
14588 -
14589 \begin_inset ERT
14590 status collapsed
14591
14592 \begin_layout Standard
14593
14594
14595 \backslash
14596 /
14597 \end_layout
14598
14599 \end_inset
14600
14601 -stack-auto
14602 \begin_inset LatexCommand index
14603 name "-\\/-stack-auto"
14604
14605 \end_inset
14606
14607
14608 \emph default
14609  option, by using 
14610 \emph on
14611 #pragma\InsetSpace ~
14612 stackauto
14613 \emph default
14614
14615 \begin_inset LatexCommand index
14616 name "\\#pragma stackauto"
14617
14618 \end_inset
14619
14620  or by using the 
14621 \emph on
14622 reentrant
14623 \begin_inset LatexCommand index
14624 name "reentrant"
14625
14626 \end_inset
14627
14628
14629 \emph default
14630  keyword in the function declaration, e.g.:
14631 \end_layout
14632
14633 \begin_layout Verse
14634
14635 \family typewriter
14636 unsigned char foo(char i) __reentrant 
14637 \newline
14638
14639 \newline
14640 \InsetSpace ~
14641 \InsetSpace ~
14642 \InsetSpace ~
14643 \InsetSpace ~
14644 ...
14645  
14646 \newline
14647 }
14648 \end_layout
14649
14650 \begin_layout Standard
14651 Since stack space on 8051 is limited, the 
14652 \emph on
14653 reentrant
14654 \emph default
14655  keyword or the 
14656 \emph on
14657 -
14658 \begin_inset ERT
14659 status collapsed
14660
14661 \begin_layout Standard
14662
14663
14664 \backslash
14665 /
14666 \end_layout
14667
14668 \end_inset
14669
14670 -stack-auto
14671 \emph default
14672  option should be used sparingly.
14673  Note that the reentrant keyword just means that the parameters & local
14674  variables will be allocated to the stack, it 
14675 \emph on
14676 does not
14677 \emph default
14678  mean that the function is register bank
14679 \begin_inset LatexCommand index
14680 name "register bank (mcs51, ds390)"
14681
14682 \end_inset
14683
14684  independent.
14685 \newline
14686
14687 \newline
14688 Local variables
14689 \begin_inset LatexCommand index
14690 name "local variables"
14691
14692 \end_inset
14693
14694  can be assigned storage classes and absolute
14695 \begin_inset LatexCommand index
14696 name "Absolute addressing"
14697
14698 \end_inset
14699
14700  addresses, e.g.: 
14701 \end_layout
14702
14703 \begin_layout Verse
14704
14705 \family typewriter
14706 unsigned char foo() 
14707 \newline
14708 {
14709 \newline
14710 \InsetSpace ~
14711 \InsetSpace ~
14712 \InsetSpace ~
14713 \InsetSpace ~
14714 __xdata unsigned char i;
14715 \newline
14716 \InsetSpace ~
14717 \InsetSpace ~
14718 \InsetSpace ~
14719 \InsetSpace ~
14720 __bit bvar;
14721 \newline
14722 \InsetSpace ~
14723 \InsetSpace ~
14724 \InsetSpace ~
14725 \InsetSpace ~
14726 __data __at
14727 \begin_inset LatexCommand index
14728 name "at"
14729
14730 \end_inset
14731
14732  (0x31) unsigned char j;
14733 \newline
14734 \InsetSpace ~
14735 \InsetSpace ~
14736 \InsetSpace ~
14737 \InsetSpace ~
14738 ...
14739  
14740 \newline
14741 }
14742 \end_layout
14743
14744 \begin_layout Standard
14745 In the above example the variable 
14746 \emph on
14747 i
14748 \emph default
14749  will be allocated in the external ram, 
14750 \emph on
14751 bvar
14752 \emph default
14753  in bit addressable space and 
14754 \emph on
14755 j
14756 \emph default
14757  in internal ram.
14758  When compiled with 
14759 \emph on
14760 -
14761 \begin_inset ERT
14762 status collapsed
14763
14764 \begin_layout Standard
14765
14766
14767 \backslash
14768 /
14769 \end_layout
14770
14771 \end_inset
14772
14773 -stack-auto
14774 \emph default
14775  or when a function is declared as 
14776 \emph on
14777 reentrant
14778 \emph default
14779  this should only be done for static variables.
14780 \end_layout
14781
14782 \begin_layout Standard
14783 Parameters
14784 \begin_inset LatexCommand index
14785 name "function parameter"
14786
14787 \end_inset
14788
14789  however are not allowed any storage class
14790 \begin_inset LatexCommand index
14791 name "Storage class"
14792
14793 \end_inset
14794
14795 , (storage classes for parameters will be ignored), their allocation is
14796  governed by the memory model in use, and the reentrancy options.
14797 \end_layout
14798
14799 \begin_layout Standard
14800 It is however allowed to use bit parameters in reentrant functions and also
14801  non-static local bit variables are supported.
14802  Efficient use is limited to 8 semi-bitregisters in bit space.
14803  They are pushed and popped to stack
14804 \begin_inset LatexCommand index
14805 name "stack"
14806
14807 \end_inset
14808
14809  as a single byte just like the normal registers.
14810 \end_layout
14811
14812 \begin_layout Section
14813 Overlaying
14814 \begin_inset LatexCommand label
14815 name "sub:Overlaying"
14816
14817 \end_inset
14818
14819
14820 \begin_inset LatexCommand index
14821 name "Overlaying"
14822
14823 \end_inset
14824
14825
14826 \end_layout
14827
14828 \begin_layout Standard
14829 For non-reentrant
14830 \begin_inset LatexCommand index
14831 name "reentrant"
14832
14833 \end_inset
14834
14835  functions SDCC will try to reduce internal ram space usage by overlaying
14836  parameters and local variables of a function (if possible).
14837  Parameters and local variables
14838 \begin_inset LatexCommand index
14839 name "local variables"
14840
14841 \end_inset
14842
14843  of a function will be allocated to an overlayable segment if the function
14844  has 
14845 \emph on
14846 no other function calls and the function is non-reentrant and the memory
14847  model
14848 \begin_inset LatexCommand index
14849 name "Memory model"
14850
14851 \end_inset
14852
14853  is small.
14854
14855 \emph default
14856  If an explicit storage class
14857 \begin_inset LatexCommand index
14858 name "Storage class"
14859
14860 \end_inset
14861
14862  is specified for a local variable, it will NOT be overlaid.
14863 \end_layout
14864
14865 \begin_layout Standard
14866 Note that the compiler (not the linkage editor) makes the decision for overlayin
14867 g the data items.
14868  Functions that are called from an interrupt service routine
14869 \begin_inset Marginal
14870 status collapsed
14871
14872 \begin_layout Standard
14873
14874 \series bold
14875 !
14876 \end_layout
14877
14878 \end_inset
14879
14880  should be preceded by a #pragma\InsetSpace ~
14881 nooverlay
14882 \begin_inset LatexCommand index
14883 name "\\#pragma nooverlay"
14884
14885 \end_inset
14886
14887  if they are not reentrant.
14888 \end_layout
14889
14890 \begin_layout Standard
14891 Also note that the compiler does not do any processing of inline assembler
14892  code, so the compiler might incorrectly assign local variables and parameters
14893  of a function into the overlay segment if the inline assembler code calls
14894  other c-functions that might use the overlay.
14895  In that case the #pragma\InsetSpace ~
14896 nooverlay should be used.
14897 \end_layout
14898
14899 \begin_layout Standard
14900 Parameters and local variables of functions that contain 16 or 32 bit multiplica
14901 tion
14902 \begin_inset LatexCommand index
14903 name "Multiplication"
14904
14905 \end_inset
14906
14907  or division
14908 \begin_inset LatexCommand index
14909 name "Division"
14910
14911 \end_inset
14912
14913  will NOT be overlaid since these are implemented using external functions,
14914  e.g.:
14915 \end_layout
14916
14917 \begin_layout Verse
14918
14919 \family typewriter
14920 #pragma save 
14921 \newline
14922 #pragma nooverlay
14923 \begin_inset LatexCommand index
14924 name "\\#pragma nooverlay"
14925
14926 \end_inset
14927
14928  
14929 \newline
14930 void set_error(unsigned char errcd) 
14931 \newline
14932 {
14933 \newline
14934 \InsetSpace ~
14935 \InsetSpace ~
14936 \InsetSpace ~
14937 \InsetSpace ~
14938 P3 = errcd;
14939 \newline
14940
14941 \newline
14942 #pragma restore 
14943 \newline
14944
14945 \newline
14946 void
14947  some_isr () __interrupt
14948 \begin_inset LatexCommand index
14949 name "interrupt"
14950
14951 \end_inset
14952
14953  (2)
14954 \newline
14955 {
14956 \newline
14957 \InsetSpace ~
14958 \InsetSpace ~
14959 \InsetSpace ~
14960 \InsetSpace ~
14961 ...
14962 \newline
14963 \InsetSpace ~
14964 \InsetSpace ~
14965 \InsetSpace ~
14966 \InsetSpace ~
14967 set_error(10);
14968 \newline
14969 \InsetSpace ~
14970 \InsetSpace ~
14971 \InsetSpace ~
14972 \InsetSpace ~
14973 ...
14974  
14975 \newline
14976 }
14977 \end_layout
14978
14979 \begin_layout Standard
14980 In the above example the parameter 
14981 \emph on
14982 errcd
14983 \emph default
14984  for the function 
14985 \emph on
14986 set_error
14987 \emph default
14988  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
14989 nooverlay was
14990  not present, this could cause unpredictable runtime behavior when called
14991  from an interrupt service routine.
14992  The #pragma\InsetSpace ~
14993 nooverlay ensures that the parameters and local variables for
14994  the function are NOT overlaid.
14995 \begin_inset VSpace bigskip
14996 \end_inset
14997
14998
14999 \end_layout
15000
15001 \begin_layout Section
15002 Interrupt Service Routines
15003 \begin_inset LatexCommand label
15004 name "sub:Interrupt-Service-Routines"
15005
15006 \end_inset
15007
15008
15009 \end_layout
15010
15011 \begin_layout Subsection
15012 General Information
15013 \end_layout
15014
15015 \begin_layout Standard
15016 SDCC allows 
15017 \emph on
15018 i
15019 \emph default
15020 nterrupt 
15021 \emph on
15022 s
15023 \emph default
15024 ervice 
15025 \emph on
15026 r
15027 \emph default
15028 outines to be coded in C, with some extended keywords.
15029 \end_layout
15030
15031 \begin_layout Verse
15032
15033 \family typewriter
15034 void timer_isr (void) __interrupt (1) __using (1) 
15035 \newline
15036
15037 \newline
15038 \InsetSpace ~
15039 \InsetSpace ~
15040 \InsetSpace ~
15041 \InsetSpace ~
15042 ...
15043  
15044 \newline
15045 }
15046 \end_layout
15047
15048 \begin_layout Standard
15049 The optional number following the 
15050 \emph on
15051 interrupt
15052 \begin_inset LatexCommand index
15053 name "interrupt"
15054
15055 \end_inset
15056
15057
15058 \begin_inset LatexCommand index
15059 name "\\_\\_interrupt"
15060
15061 \end_inset
15062
15063
15064 \emph default
15065  keyword is the interrupt number this routine will service.
15066  When present, the compiler will insert a call to this routine in the interrupt
15067  vector table
15068 \begin_inset LatexCommand index
15069 name "interrupt vector table"
15070
15071 \end_inset
15072
15073  for the interrupt number specified.
15074  If you have multiple source files in your project, interrupt service routines
15075  can be present in any of them, but a prototype of the isr MUST be present
15076  or included in the file that contains the function 
15077 \emph on
15078 main
15079 \emph default
15080 .
15081  The optional (8051 specific) keyword 
15082 \emph on
15083 using
15084 \begin_inset LatexCommand index
15085 name "using (mcs51, ds390 register bank)"
15086
15087 \end_inset
15088
15089
15090 \begin_inset LatexCommand index
15091 name "\\_\\_using (mcs51, ds390 register bank)"
15092
15093 \end_inset
15094
15095
15096 \emph default
15097  can be used to tell the compiler to use the specified register bank when
15098  generating code for this function.
15099  
15100 \newline
15101 Interrupt service routines open the door for some very interesting bugs:
15102 \end_layout
15103
15104 \begin_layout Subsubsection
15105 \begin_inset LatexCommand label
15106 name "sub:Common-interrupt-pitfall-volatile"
15107
15108 \end_inset
15109
15110 Common interrupt pitfall: variable not declared 
15111 \emph on
15112 volatile
15113 \end_layout
15114
15115 \begin_layout Standard
15116 If an interrupt service routine changes variables which are accessed by
15117  other functions these variables have to be declared 
15118 \emph on
15119 volatile
15120 \emph default
15121
15122 \begin_inset LatexCommand index
15123 name "volatile"
15124
15125 \end_inset
15126
15127 .
15128  See 
15129 \begin_inset LatexCommand url
15130 target "http://en.wikipedia.org/wiki/Volatile_variable"
15131
15132 \end_inset
15133
15134  .
15135 \end_layout
15136
15137 \begin_layout Subsubsection
15138 \begin_inset LatexCommand label
15139 name "sub:Common-interrupt-pitfall-non-atomic"
15140
15141 \end_inset
15142
15143 Common interrupt pitfall: 
15144 \emph on
15145 non-atomic access
15146 \end_layout
15147
15148 \begin_layout Standard
15149 If the access to these variables is not 
15150 \emph on
15151 atomic
15152 \begin_inset LatexCommand index
15153 name "atomic"
15154
15155 \end_inset
15156
15157
15158 \emph default
15159  (i.e.
15160  the processor needs more than one instruction for the access and could
15161  be interrupted while accessing the variable) the interrupt must be disabled
15162  during the access to avoid inconsistent data.
15163  
15164 \newline
15165 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
15166  and should be protected by disabling interrupts.
15167  You're not automatically on the safe side if you use 8 bit variables though.
15168  We need an example here: f.e.
15169  on the 8051 the harmless looking 
15170 \begin_inset Quotes srd
15171 \end_inset
15172
15173
15174 \family typewriter
15175 flags\InsetSpace ~
15176 |=\InsetSpace ~
15177 0x80;
15178 \family default
15179
15180 \begin_inset Quotes sld
15181 \end_inset
15182
15183  is not atomic if 
15184 \family typewriter
15185 flags
15186 \family default
15187  resides in xdata.
15188  Setting 
15189 \begin_inset Quotes srd
15190 \end_inset
15191
15192
15193 \family typewriter
15194 flags\InsetSpace ~
15195 |=\InsetSpace ~
15196 0x40;
15197 \family default
15198
15199 \begin_inset Quotes sld
15200 \end_inset
15201
15202  from within an interrupt routine might get lost if the interrupt occurs
15203  at the wrong time.
15204  
15205 \begin_inset Quotes sld
15206 \end_inset
15207
15208
15209 \family typewriter
15210 counter\InsetSpace ~
15211 +=\InsetSpace ~
15212 8;
15213 \family default
15214
15215 \begin_inset Quotes srd
15216 \end_inset
15217
15218  is not atomic on the 8051 even if 
15219 \family typewriter
15220 counter
15221 \family default
15222  is located in data memory.
15223 \newline
15224 Bugs like these are hard to reproduce and can
15225  cause a lot of trouble.
15226  
15227 \end_layout
15228
15229 \begin_layout Subsubsection
15230 \begin_inset LatexCommand label
15231 name "sub:Common-interrupt-pitfall-stack-overflow"
15232
15233 \end_inset
15234
15235 Common interrupt pitfall: 
15236 \emph on
15237 stack overflow
15238 \end_layout
15239
15240 \begin_layout Standard
15241 The return address and the registers used in the interrupt service routine
15242  are saved on the stack
15243 \begin_inset LatexCommand index
15244 name "stack"
15245
15246 \end_inset
15247
15248  so there must be sufficient stack space.
15249  If there isn't variables or registers (or even the return address itself)
15250  will be corrupted.
15251  This 
15252 \emph on
15253 stack overflow
15254 \emph default
15255
15256 \begin_inset LatexCommand index
15257 name "stack overflow"
15258
15259 \end_inset
15260
15261  is most likely to happen if the interrupt occurs during the 
15262 \begin_inset Quotes sld
15263 \end_inset
15264
15265 deepest
15266 \begin_inset Quotes srd
15267 \end_inset
15268
15269  subroutine when the stack is already in use for f.e.
15270  many return addresses.
15271 \end_layout
15272
15273 \begin_layout Subsubsection
15274 \begin_inset LatexCommand label
15275 name "sub:Common-interrupt-pitfall-non-reentrant"
15276
15277 \end_inset
15278
15279 Common interrupt pitfall: 
15280 \emph on
15281 use of non-reentrant functions
15282 \end_layout
15283
15284 \begin_layout Standard
15285 A special note here, int (16 bit) and long (32 bit) integer division
15286 \begin_inset LatexCommand index
15287 name "Division"
15288
15289 \end_inset
15290
15291 , multiplication
15292 \begin_inset LatexCommand index
15293 name "Multiplication"
15294
15295 \end_inset
15296
15297  & modulus
15298 \begin_inset LatexCommand index
15299 name "Modulus"
15300
15301 \end_inset
15302
15303  and floating-point
15304 \begin_inset LatexCommand index
15305 name "Floating point support"
15306
15307 \end_inset
15308
15309  operations are implemented using external support routines.
15310  If an interrupt service routine needs to do any of these operations then
15311  the support routines (as mentioned in a following section) will have to
15312  be recompiled using the 
15313 \emph on
15314 -
15315 \begin_inset ERT
15316 status collapsed
15317
15318 \begin_layout Standard
15319
15320
15321 \backslash
15322 /
15323 \end_layout
15324
15325 \end_inset
15326
15327 -stack-auto
15328 \begin_inset LatexCommand index
15329 name "-\\/-stack-auto"
15330
15331 \end_inset
15332
15333
15334 \emph default
15335  option and the source file will need to be compiled using the 
15336 \emph on
15337 -
15338 \begin_inset ERT
15339 status collapsed
15340
15341 \begin_layout Standard
15342
15343
15344 \backslash
15345 /
15346 \end_layout
15347
15348 \end_inset
15349
15350 -int-long-reent
15351 \emph default
15352
15353 \begin_inset LatexCommand index
15354 name "-\\/-int-long-reent"
15355
15356 \end_inset
15357
15358  compiler option.
15359  
15360 \newline
15361 Note, the type promotion
15362 \begin_inset LatexCommand index
15363 name "type promotion"
15364
15365 \end_inset
15366
15367  required by ANSI C can cause 16 bit routines to be used
15368 \begin_inset Marginal
15369 status collapsed
15370
15371 \begin_layout Standard
15372
15373 \series bold
15374 \InsetSpace ~
15375 !
15376 \end_layout
15377
15378 \end_inset
15379
15380  without the programmer being aware of it.
15381  See f.e.
15382  the cast 
15383 \family typewriter
15384 \series bold
15385 (unsigned char)(tail-1)
15386 \family default
15387 \series default
15388  
15389 \series bold
15390 within the if clause in section 
15391 \begin_inset LatexCommand ref
15392 reference "sub:A-Step-by Assembler Introduction"
15393
15394 \end_inset
15395
15396 .
15397 \end_layout
15398
15399 \begin_layout Standard
15400 Calling other functions from an interrupt service routine is not recommended,
15401  avoid it if possible.
15402  Note that when some function is called from an interrupt service routine
15403  it should be preceded by a #pragma\InsetSpace ~
15404 nooverlay
15405 \begin_inset LatexCommand index
15406 name "\\#pragma nooverlay"
15407
15408 \end_inset
15409
15410  if it is not reentrant.
15411  Furthermore nonreentrant functions should not be called from the main program
15412  while the interrupt service routine might be active.
15413  They also must not be called from low priority interrupt service routines
15414  while a high priority interrupt service routine might be active.
15415  You could use semaphores or make the function 
15416 \emph on
15417 critical
15418 \emph default
15419  if all parameters are passed in registers.
15420 \newline
15421  Also see section 
15422 \begin_inset LatexCommand ref
15423 reference "sub:Overlaying"
15424
15425 \end_inset
15426
15427 \InsetSpace ~
15428 about Overlaying and section 
15429 \begin_inset LatexCommand ref
15430 reference "sub:Functions-using-private-banks"
15431
15432 \end_inset
15433
15434 \InsetSpace ~
15435 about Functions using private register banks.
15436 \begin_inset VSpace bigskip
15437 \end_inset
15438
15439
15440 \end_layout
15441
15442 \begin_layout Subsection
15443 MCS51/DS390 Interrupt Service Routines
15444 \end_layout
15445
15446 \begin_layout Standard
15447 Interrupt
15448 \begin_inset LatexCommand index
15449 name "interrupt"
15450
15451 \end_inset
15452
15453  numbers and the corresponding address & descriptions for the Standard 8051/8052
15454  are listed below.
15455  SDCC will automatically adjust the 
15456 \begin_inset LatexCommand index
15457 name "interrupt vector table"
15458
15459 \end_inset
15460
15461  to the maximum interrupt number specified.
15462 \newline
15463
15464 \end_layout
15465
15466 \begin_layout Standard
15467 \align center
15468 \begin_inset Tabular
15469 <lyxtabular version="3" rows="9" columns="3">
15470 <features>
15471 <column alignment="center" valignment="top" leftline="true" width="0in">
15472 <column alignment="left" valignment="top" leftline="true" width="0in">
15473 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
15474 <row topline="true" bottomline="true">
15475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15476 \begin_inset Text
15477
15478 \begin_layout Standard
15479 Interrupt #
15480 \end_layout
15481
15482 \end_inset
15483 </cell>
15484 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15485 \begin_inset Text
15486
15487 \begin_layout Standard
15488 Description
15489 \end_layout
15490
15491 \end_inset
15492 </cell>
15493 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15494 \begin_inset Text
15495
15496 \begin_layout Standard
15497 Vector Address
15498 \end_layout
15499
15500 \end_inset
15501 </cell>
15502 </row>
15503 <row topline="true">
15504 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15505 \begin_inset Text
15506
15507 \begin_layout Standard
15508 0
15509 \end_layout
15510
15511 \end_inset
15512 </cell>
15513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15514 \begin_inset Text
15515
15516 \begin_layout Standard
15517 External 0
15518 \end_layout
15519
15520 \end_inset
15521 </cell>
15522 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15523 \begin_inset Text
15524
15525 \begin_layout Standard
15526 0x0003
15527 \end_layout
15528
15529 \end_inset
15530 </cell>
15531 </row>
15532 <row topline="true">
15533 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15534 \begin_inset Text
15535
15536 \begin_layout Standard
15537 1
15538 \end_layout
15539
15540 \end_inset
15541 </cell>
15542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15543 \begin_inset Text
15544
15545 \begin_layout Standard
15546 Timer 0
15547 \end_layout
15548
15549 \end_inset
15550 </cell>
15551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15552 \begin_inset Text
15553
15554 \begin_layout Standard
15555 0x000b
15556 \end_layout
15557
15558 \end_inset
15559 </cell>
15560 </row>
15561 <row topline="true">
15562 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15563 \begin_inset Text
15564
15565 \begin_layout Standard
15566 2
15567 \end_layout
15568
15569 \end_inset
15570 </cell>
15571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15572 \begin_inset Text
15573
15574 \begin_layout Standard
15575 External 1
15576 \end_layout
15577
15578 \end_inset
15579 </cell>
15580 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15581 \begin_inset Text
15582
15583 \begin_layout Standard
15584 0x0013
15585 \end_layout
15586
15587 \end_inset
15588 </cell>
15589 </row>
15590 <row topline="true">
15591 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15592 \begin_inset Text
15593
15594 \begin_layout Standard
15595 3
15596 \end_layout
15597
15598 \end_inset
15599 </cell>
15600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15601 \begin_inset Text
15602
15603 \begin_layout Standard
15604 Timer 1
15605 \end_layout
15606
15607 \end_inset
15608 </cell>
15609 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15610 \begin_inset Text
15611
15612 \begin_layout Standard
15613 0x001b
15614 \end_layout
15615
15616 \end_inset
15617 </cell>
15618 </row>
15619 <row topline="true">
15620 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15621 \begin_inset Text
15622
15623 \begin_layout Standard
15624 4
15625 \end_layout
15626
15627 \end_inset
15628 </cell>
15629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15630 \begin_inset Text
15631
15632 \begin_layout Standard
15633 Serial
15634 \end_layout
15635
15636 \end_inset
15637 </cell>
15638 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15639 \begin_inset Text
15640
15641 \begin_layout Standard
15642 0x0023
15643 \end_layout
15644
15645 \end_inset
15646 </cell>
15647 </row>
15648 <row topline="true">
15649 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15650 \begin_inset Text
15651
15652 \begin_layout Standard
15653 5
15654 \end_layout
15655
15656 \end_inset
15657 </cell>
15658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15659 \begin_inset Text
15660
15661 \begin_layout Standard
15662 Timer 2 (8052)
15663 \end_layout
15664
15665 \end_inset
15666 </cell>
15667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15668 \begin_inset Text
15669
15670 \begin_layout Standard
15671 0x002b
15672 \end_layout
15673
15674 \end_inset
15675 </cell>
15676 </row>
15677 <row topline="true">
15678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15679 \begin_inset Text
15680
15681 \begin_layout Standard
15682 ...
15683 \end_layout
15684
15685 \end_inset
15686 </cell>
15687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15688 \begin_inset Text
15689
15690 \begin_layout Standard
15691
15692 \end_layout
15693
15694 \end_inset
15695 </cell>
15696 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15697 \begin_inset Text
15698
15699 \begin_layout Standard
15700 ...
15701 \end_layout
15702
15703 \end_inset
15704 </cell>
15705 </row>
15706 <row topline="true" bottomline="true">
15707 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15708 \begin_inset Text
15709
15710 \begin_layout Standard
15711 n
15712 \end_layout
15713
15714 \end_inset
15715 </cell>
15716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15717 \begin_inset Text
15718
15719 \begin_layout Standard
15720
15721 \end_layout
15722
15723 \end_inset
15724 </cell>
15725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15726 \begin_inset Text
15727
15728 \begin_layout Standard
15729 0x0003 + 8*n
15730 \end_layout
15731
15732 \end_inset
15733 </cell>
15734 </row>
15735 </lyxtabular>
15736
15737 \end_inset
15738
15739
15740 \newline
15741
15742 \end_layout
15743
15744 \begin_layout Standard
15745 If the interrupt service routine is defined without 
15746 \emph on
15747 using
15748 \begin_inset LatexCommand index
15749 name "using (mcs51, ds390 register bank)"
15750
15751 \end_inset
15752
15753
15754 \begin_inset LatexCommand index
15755 name "\\_\\_using (mcs51, ds390 register bank)"
15756
15757 \end_inset
15758
15759
15760 \emph default
15761  a register bank or with register bank 0 (
15762 \emph on
15763 using
15764 \emph default
15765  0), the compiler will save the registers used by itself on the stack upon
15766  entry and restore them at exit, however if such an interrupt service routine
15767  calls another function then the entire register bank will be saved on the
15768  stack.
15769  This scheme may be advantageous for small interrupt service routines which
15770  have low register usage.
15771 \end_layout
15772
15773 \begin_layout Standard
15774 If the interrupt service routine is defined to be using a specific register
15775  bank then only 
15776 \emph on
15777 a, b, dptr
15778 \emph default
15779  & psw are saved and restored, if such an interrupt service routine calls
15780  another function (using another register bank) then the entire register
15781  bank of the called function will be saved on the stack
15782 \begin_inset LatexCommand index
15783 name "stack"
15784
15785 \end_inset
15786
15787 .
15788  This scheme is recommended for larger interrupt service routines.
15789 \begin_inset VSpace bigskip
15790 \end_inset
15791
15792
15793 \end_layout
15794
15795 \begin_layout Subsection
15796 HC08
15797 \begin_inset LatexCommand index
15798 name "HC08"
15799
15800 \end_inset
15801
15802  Interrupt Service Routines
15803 \end_layout
15804
15805 \begin_layout Standard
15806 Since the number of interrupts
15807 \begin_inset LatexCommand index
15808 name "HC08!interrupt"
15809
15810 \end_inset
15811
15812  available is chip specific and the interrupt vector table always ends at
15813  the last byte of memory, the interrupt numbers corresponds to the interrupt
15814  vectors in reverse order of address.
15815  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
15816  2 will use the interrupt vector at 0xfffa, and so on.
15817  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
15818  this way; instead see section 
15819 \begin_inset LatexCommand ref
15820 reference "sub:Startup-Code"
15821
15822 \end_inset
15823
15824  for details on customizing startup.
15825 \begin_inset VSpace bigskip
15826 \end_inset
15827
15828
15829 \end_layout
15830
15831 \begin_layout Subsection
15832 Z80 Interrupt Service Routines
15833 \end_layout
15834
15835 \begin_layout Standard
15836 The Z80
15837 \begin_inset LatexCommand index
15838 name "Z80"
15839
15840 \end_inset
15841
15842  uses several different methods for determining the correct interrupt
15843 \begin_inset LatexCommand index
15844 name "Z80!interrupt"
15845
15846 \end_inset
15847
15848  vector depending on the hardware implementation.
15849  Therefore, SDCC ignores the optional interrupt number and does not attempt
15850  to generate an interrupt vector table.
15851 \end_layout
15852
15853 \begin_layout Standard
15854 By default, SDCC generates code for a maskable interrupt, which uses a RETI
15855  instruction to return from the interrupt.
15856  To write an interrupt handler for the non-maskable interrupt, which needs
15857  a RETN instruction instead, add the 
15858 \emph on
15859 critical
15860 \emph default
15861  keyword:
15862 \end_layout
15863
15864 \begin_layout Verse
15865
15866 \family typewriter
15867 void nmi_isr (void) critical interrupt
15868 \newline
15869
15870 \newline
15871 \InsetSpace ~
15872 \InsetSpace ~
15873 \InsetSpace ~
15874 \InsetSpace ~
15875 ...
15876  
15877 \newline
15878 }
15879 \end_layout
15880
15881 \begin_layout Standard
15882 However if you need to create a non-interruptable interrupt service routine
15883  you would also require the 
15884 \emph on
15885 critical
15886 \emph default
15887  keyword.
15888  To distinguish between this and an nmi_isr you must provide an interrupt
15889  number.
15890 \begin_inset VSpace bigskip
15891 \end_inset
15892
15893
15894 \end_layout
15895
15896 \begin_layout Section
15897 Enabling and Disabling Interrupts
15898 \end_layout
15899
15900 \begin_layout Subsection
15901 Critical Functions and Critical Statements
15902 \end_layout
15903
15904 \begin_layout Standard
15905 A special keyword may be associated with a block or a function declaring
15906  it as 
15907 \emph on
15908 critical
15909 \emph default
15910 .
15911  SDCC will generate code to disable all interrupts
15912 \begin_inset LatexCommand index
15913 name "interrupt"
15914
15915 \end_inset
15916
15917  upon entry to a critical function and restore the interrupt enable to the
15918  previous state before returning.
15919  Nesting critical functions will need one additional byte on the stack
15920 \begin_inset LatexCommand index
15921 name "stack"
15922
15923 \end_inset
15924
15925  for each call.
15926 \end_layout
15927
15928 \begin_layout Verse
15929
15930 \family typewriter
15931 int foo () __critical
15932 \begin_inset LatexCommand index
15933 name "critical"
15934
15935 \end_inset
15936
15937
15938 \begin_inset LatexCommand index
15939 name "\\_\\_critical"
15940
15941 \end_inset
15942
15943  
15944 \newline
15945
15946 \newline
15947 \InsetSpace ~
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 \InsetSpace ~
15951 ...
15952  
15953 \newline
15954 \InsetSpace ~
15955 \InsetSpace ~
15956 \InsetSpace ~
15957 \InsetSpace ~
15958 ...
15959  
15960 \newline
15961 }
15962 \end_layout
15963
15964 \begin_layout Standard
15965 The critical attribute maybe used with other attributes like 
15966 \emph on
15967 reentrant.
15968 \emph default
15969
15970 \newline
15971 The keyword 
15972 \emph on
15973 critical
15974 \emph default
15975  may also be used to disable interrupts more locally:
15976 \end_layout
15977
15978 \begin_layout Verse
15979
15980 \family typewriter
15981 __critical{ i++; }
15982 \end_layout
15983
15984 \begin_layout Standard
15985 More than one statement could have been included in the block.
15986 \end_layout
15987
15988 \begin_layout Subsection
15989 Enabling and Disabling Interrupts directly
15990 \end_layout
15991
15992 \begin_layout Standard
15993 Interrupts
15994 \begin_inset LatexCommand index
15995 name "interrupt"
15996
15997 \end_inset
15998
15999  can also be disabled and enabled directly (8051):
16000 \end_layout
16001
16002 \begin_layout Verse
16003
16004 \family typewriter
16005 EA = 0;\InsetSpace ~
16006 \InsetSpace ~
16007 \InsetSpace ~
16008 \InsetSpace ~
16009 \InsetSpace ~
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 or:\InsetSpace ~
16018 \InsetSpace ~
16019 \InsetSpace ~
16020 \InsetSpace ~
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 \InsetSpace ~
16027 \InsetSpace ~
16028 EA_SAVE = EA;
16029 \end_layout
16030
16031 \begin_layout Verse
16032
16033 \family typewriter
16034 ...\InsetSpace ~
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 \InsetSpace ~
16040 \InsetSpace ~
16041 \InsetSpace ~
16042 \InsetSpace ~
16043 \InsetSpace ~
16044 \InsetSpace ~
16045 \InsetSpace ~
16046 \InsetSpace ~
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 \InsetSpace ~
16050 \InsetSpace ~
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 \InsetSpace ~
16055 \InsetSpace ~
16056 \InsetSpace ~
16057 \InsetSpace ~
16058 \InsetSpace ~
16059 \InsetSpace ~
16060 \InsetSpace ~
16061 \InsetSpace ~
16062 \InsetSpace ~
16063 \InsetSpace ~
16064 EA = 0;
16065 \end_layout
16066
16067 \begin_layout Verse
16068
16069 \family typewriter
16070 EA = 1;\InsetSpace ~
16071 \InsetSpace ~
16072 \InsetSpace ~
16073 \InsetSpace ~
16074 \InsetSpace ~
16075 \InsetSpace ~
16076 \InsetSpace ~
16077 \InsetSpace ~
16078 \InsetSpace ~
16079 \InsetSpace ~
16080 \InsetSpace ~
16081 \InsetSpace ~
16082 \InsetSpace ~
16083 \InsetSpace ~
16084 \InsetSpace ~
16085 \InsetSpace ~
16086 \InsetSpace ~
16087 \InsetSpace ~
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 \InsetSpace ~
16091 \InsetSpace ~
16092 \InsetSpace ~
16093 \InsetSpace ~
16094 \InsetSpace ~
16095 \InsetSpace ~
16096 ...
16097 \end_layout
16098
16099 \begin_layout Verse
16100
16101 \family typewriter
16102 \InsetSpace ~
16103 \InsetSpace ~
16104 \InsetSpace ~
16105 \InsetSpace ~
16106 \InsetSpace ~
16107 \InsetSpace ~
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 \InsetSpace ~
16112 \InsetSpace ~
16113 \InsetSpace ~
16114 \InsetSpace ~
16115 \InsetSpace ~
16116 \InsetSpace ~
16117 \InsetSpace ~
16118 \InsetSpace ~
16119 \InsetSpace ~
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 \InsetSpace ~
16125 \InsetSpace ~
16126 \InsetSpace ~
16127 \InsetSpace ~
16128 \InsetSpace ~
16129 \InsetSpace ~
16130 \InsetSpace ~
16131 \InsetSpace ~
16132 \InsetSpace ~
16133 \InsetSpace ~
16134 \InsetSpace ~
16135 EA = EA_SAVE;
16136 \end_layout
16137
16138 \begin_layout Standard
16139 On other architectures which have separate opcodes for enabling and disabling
16140  interrupts you might want to make use of defines with inline assembly
16141 \begin_inset LatexCommand index
16142 name "Assembler routines"
16143
16144 \end_inset
16145
16146  (HC08
16147 \begin_inset LatexCommand index
16148 name "HC08!interrupt"
16149
16150 \end_inset
16151
16152 ):
16153 \end_layout
16154
16155 \begin_layout Verse
16156
16157 \family typewriter
16158 #define CLI _asm
16159 \begin_inset LatexCommand index
16160 name "\\_asm"
16161
16162 \end_inset
16163
16164 \InsetSpace ~
16165 \InsetSpace ~
16166 cli\InsetSpace ~
16167 \InsetSpace ~
16168 _endasm
16169 \begin_inset LatexCommand index
16170 name "\\_endasm"
16171
16172 \end_inset
16173
16174
16175 \end_layout
16176
16177 \begin_layout Verse
16178
16179 \family typewriter
16180 #define SEI _asm\InsetSpace ~
16181 \InsetSpace ~
16182 sei\InsetSpace ~
16183 \InsetSpace ~
16184 _endasm; 
16185 \end_layout
16186
16187 \begin_layout Verse
16188
16189 \family typewriter
16190 ...
16191 \end_layout
16192
16193 \begin_layout Standard
16194 Note: it is sometimes sufficient to disable only a specific interrupt source
16195  like f.e.
16196  a timer or serial interrupt by manipulating an 
16197 \emph on
16198 interrupt mask
16199 \begin_inset LatexCommand index
16200 name "interrupt mask"
16201
16202 \end_inset
16203
16204
16205 \emph default
16206  register.
16207  
16208 \end_layout
16209
16210 \begin_layout Standard
16211 Usually the time during which interrupts are disabled should be kept as
16212  short as possible.
16213  This minimizes both 
16214 \emph on
16215 interrupt latency
16216 \emph default
16217
16218 \begin_inset LatexCommand index
16219 name "interrupt latency"
16220
16221 \end_inset
16222
16223  (the time between the occurrence of the interrupt and the execution of
16224  the first code in the interrupt routine) and 
16225 \emph on
16226 interrupt jitter
16227 \emph default
16228
16229 \begin_inset LatexCommand index
16230 name "interrupt jitter"
16231
16232 \end_inset
16233
16234  (the difference between the shortest and the longest interrupt latency).
16235  These really are something different, f.e.
16236  a serial interrupt has to be served before its buffer overruns so it cares
16237  for the maximum interrupt latency, whereas it does not care about jitter.
16238  On a loudspeaker driven via a digital to analog converter which is fed
16239  by an interrupt a latency of a few milliseconds might be tolerable, whereas
16240  a much smaller jitter will be very audible.
16241 \end_layout
16242
16243 \begin_layout Standard
16244 You can reenable interrupts within an interrupt routine and on some architecture
16245 s you can make use of two (or more) levels of 
16246 \emph on
16247 interrupt priorities
16248 \emph default
16249
16250 \begin_inset LatexCommand index
16251 name "interrupt priority"
16252
16253 \end_inset
16254
16255 .
16256  On some architectures which don't support interrupt priorities these can
16257  be implemented by manipulating the interrupt mask and reenabling interrupts
16258  within the interrupt routine.
16259  Check there is sufficient space on the stack
16260 \begin_inset LatexCommand index
16261 name "stack"
16262
16263 \end_inset
16264
16265  and don't add complexity unless you have to.
16266  
16267 \end_layout
16268
16269 \begin_layout Subsection
16270 Semaphore
16271 \begin_inset LatexCommand index
16272 name "semaphore"
16273
16274 \end_inset
16275
16276  locking (mcs51/ds390)
16277 \end_layout
16278
16279 \begin_layout Standard
16280 Some architectures (mcs51/ds390) have an atomic
16281 \begin_inset LatexCommand index
16282 name "atomic"
16283
16284 \end_inset
16285
16286  bit test and clear instruction.
16287  These type of instructions are typically used in preemptive multitasking
16288  systems, where a routine f.e.
16289  claims the use of a data structure ('acquires a lock
16290 \begin_inset LatexCommand index
16291 name "lock"
16292
16293 \end_inset
16294
16295  on it'), makes some modifications and then releases the lock when the data
16296  structure is consistent again.
16297  The instruction may also be used if interrupt and non-interrupt code have
16298  to compete for a resource.
16299  With the atomic bit test and clear instruction interrupts
16300 \begin_inset LatexCommand index
16301 name "interrupt"
16302
16303 \end_inset
16304
16305  don't have to be disabled for the locking operation.
16306  
16307 \end_layout
16308
16309 \begin_layout Standard
16310 SDCC generates this instruction if the source follows this pattern:
16311 \end_layout
16312
16313 \begin_layout Verse
16314
16315 \family typewriter
16316 volatile
16317 \begin_inset LatexCommand index
16318 name "volatile"
16319
16320 \end_inset
16321
16322  bit resource_is_free; 
16323 \newline
16324
16325 \newline
16326 if (resource_is_free) 
16327 \newline
16328 \InsetSpace ~
16329 \InsetSpace ~
16330
16331 \newline
16332 \InsetSpace ~
16333 \InsetSpace ~
16334 \InsetSpace ~
16335 \InsetSpace ~
16336 resource_is_free=0; 
16337 \newline
16338 \InsetSpace ~
16339 \InsetSpace ~
16340 \InsetSpace ~
16341 \InsetSpace ~
16342 ...
16343  
16344 \newline
16345 \InsetSpace ~
16346 \InsetSpace ~
16347 \InsetSpace ~
16348 \InsetSpace ~
16349 resource_is_free=1;
16350 \newline
16351 \InsetSpace ~
16352 \InsetSpace ~
16353
16354 \end_layout
16355
16356 \begin_layout Standard
16357 Note, mcs51 and ds390 support only an atomic
16358 \begin_inset LatexCommand index
16359 name "atomic"
16360
16361 \end_inset
16362
16363  bit test and 
16364 \emph on
16365 clear
16366 \emph default
16367  instruction (as opposed to atomic bit test and 
16368 \emph on
16369 set).
16370 \end_layout
16371
16372 \begin_layout Section
16373 Functions using private register banks
16374 \begin_inset LatexCommand label
16375 name "sub:Functions-using-private-banks"
16376
16377 \end_inset
16378
16379  (mcs51/ds390)
16380 \end_layout
16381
16382 \begin_layout Standard
16383 Some architectures have support for quickly changing register sets.
16384  SDCC supports this feature with the 
16385 \emph on
16386 using
16387 \begin_inset LatexCommand index
16388 name "using (mcs51, ds390 register bank)"
16389
16390 \end_inset
16391
16392
16393 \begin_inset LatexCommand index
16394 name "\\_\\_using (mcs51, ds390 register bank)"
16395
16396 \end_inset
16397
16398
16399 \emph default
16400  attribute (which tells the compiler to use a register bank
16401 \begin_inset LatexCommand index
16402 name "register bank (mcs51, ds390)"
16403
16404 \end_inset
16405
16406  other than the default bank zero).
16407  It should only be applied to 
16408 \emph on
16409 interrupt
16410 \begin_inset LatexCommand index
16411 name "interrupt"
16412
16413 \end_inset
16414
16415
16416 \emph default
16417  functions (see footnote below).
16418  This will in most circumstances make the generated ISR code more efficient
16419  since it will not have to save registers on the stack.
16420 \end_layout
16421
16422 \begin_layout Standard
16423 The 
16424 \emph on
16425 using
16426 \emph default
16427  attribute will have no effect on the generated code for a 
16428 \emph on
16429 non-interrupt
16430 \emph default
16431  function (but may occasionally be useful anyway
16432 \begin_inset Foot
16433 status open
16434
16435 \begin_layout Standard
16436 possible exception: if a function is called ONLY from 'interrupt' functions
16437  using a particular bank, it can be declared with the same 'using' attribute
16438  as the calling 'interrupt' functions.
16439  For instance, if you have several ISRs using bank one, and all of them
16440  call memcpy(), it might make sense to create a specialized version of memcpy()
16441  'using 1', since this would prevent the ISR from having to save bank zero
16442  to the stack on entry and switch to bank zero before calling the function
16443 \end_layout
16444
16445 \end_inset
16446
16447 ).
16448 \newline
16449
16450 \emph on
16451 (pending: Note, nowadays the
16452 \emph default
16453  using 
16454 \emph on
16455 attribute has an effect on
16456 \emph default
16457  
16458 \emph on
16459 the generated code for a
16460 \emph default
16461  non-interrupt 
16462 \emph on
16463 function
16464 \emph default
16465 .
16466 \emph on
16467 )
16468 \end_layout
16469
16470 \begin_layout Standard
16471 An 
16472 \emph on
16473 interrupt
16474 \emph default
16475  function using a non-zero bank will assume that it can trash that register
16476  bank, and will not save it.
16477  Since high-priority interrupts
16478 \begin_inset LatexCommand index
16479 name "interrupts"
16480
16481 \end_inset
16482
16483
16484 \begin_inset LatexCommand index
16485 name "interrupt priority"
16486
16487 \end_inset
16488
16489  can interrupt low-priority ones on the 8051 and friends, this means that
16490  if a high-priority ISR 
16491 \emph on
16492 using
16493 \emph default
16494  a particular bank occurs while processing a low-priority ISR 
16495 \emph on
16496 using
16497 \emph default
16498  the same bank, terrible and bad things can happen.
16499  To prevent this, no single register bank should be 
16500 \emph on
16501 used
16502 \emph default
16503  by both a high priority and a low priority ISR.
16504  This is probably most easily done by having all high priority ISRs use
16505  one bank and all low priority ISRs use another.
16506  If you have an ISR which can change priority at runtime, you're on your
16507  own: I suggest using the default bank zero and taking the small performance
16508  hit.
16509 \end_layout
16510
16511 \begin_layout Standard
16512 It is most efficient if your ISR calls no other functions.
16513  If your ISR must call other functions, it is most efficient if those functions
16514  use the same bank as the ISR (see note 1 below); the next best is if the
16515  called functions use bank zero.
16516  It is very inefficient to call a function using a different, non-zero bank
16517  from an ISR.
16518  
16519 \begin_inset VSpace bigskip
16520 \end_inset
16521
16522
16523 \end_layout
16524
16525 \begin_layout Section
16526 Startup Code
16527 \begin_inset LatexCommand label
16528 name "sub:Startup-Code"
16529
16530 \end_inset
16531
16532
16533 \begin_inset LatexCommand index
16534 name "Startup code"
16535
16536 \end_inset
16537
16538
16539 \end_layout
16540
16541 \begin_layout Subsection
16542 MCS51/DS390 Startup Code
16543 \end_layout
16544
16545 \begin_layout Standard
16546 The compiler triggers the linker to link certain initialization modules
16547  from the runtime library
16548 \begin_inset LatexCommand index
16549 name "Runtime library"
16550
16551 \end_inset
16552
16553  called crt<something>.
16554  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
16555  GSINIT5) is not linked unless the -
16556 \series bold
16557
16558 \begin_inset ERT
16559 status open
16560
16561 \begin_layout Standard
16562
16563
16564 \backslash
16565 /
16566 \end_layout
16567
16568 \end_inset
16569
16570
16571 \series default
16572 -xstack option is used.
16573  These modules are highly entangled by the use of special segments/areas,
16574  but a common layout is shown below:
16575 \end_layout
16576
16577 \begin_layout Verse
16578
16579 \family typewriter
16580 \series bold
16581 \size footnotesize
16582 (main.asm)
16583 \end_layout
16584
16585 \begin_layout Verse
16586
16587 \family typewriter
16588 \size footnotesize
16589 \InsetSpace ~
16590 \InsetSpace ~
16591 \InsetSpace ~
16592 \InsetSpace ~
16593 \InsetSpace ~
16594 \InsetSpace ~
16595 \InsetSpace ~
16596 \InsetSpace ~
16597 .area HOME (CODE)
16598 \newline
16599 __interrupt_vect:
16600 \newline
16601 \InsetSpace ~
16602 \InsetSpace ~
16603 \InsetSpace ~
16604 \InsetSpace ~
16605 \InsetSpace ~
16606 \InsetSpace ~
16607 \InsetSpace ~
16608 \InsetSpace ~
16609 ljmp __sdcc_gsinit_startup
16610 \end_layout
16611
16612 \begin_layout Verse
16613
16614 \family typewriter
16615 \series bold
16616 \size footnotesize
16617 (crtstart.asm)
16618 \end_layout
16619
16620 \begin_layout Verse
16621
16622 \family typewriter
16623 \size footnotesize
16624 \InsetSpace ~
16625 \InsetSpace ~
16626 \InsetSpace ~
16627 \InsetSpace ~
16628 \InsetSpace ~
16629 \InsetSpace ~
16630 \InsetSpace ~
16631 \InsetSpace ~
16632 .area GSINIT0 (CODE)
16633 \newline
16634 __sdcc_gsinit_startup::
16635 \newline
16636 \InsetSpace ~
16637 \InsetSpace ~
16638 \InsetSpace ~
16639 \InsetSpace ~
16640 \InsetSpace ~
16641 \InsetSpace ~
16642 \InsetSpace ~
16643 \InsetSpace ~
16644 mov sp,#__start__stack - 1
16645 \end_layout
16646
16647 \begin_layout Verse
16648
16649 \family typewriter
16650 \series bold
16651 \size footnotesize
16652 (crtxstack.asm)
16653 \end_layout
16654
16655 \begin_layout Verse
16656
16657 \family typewriter
16658 \size footnotesize
16659 \InsetSpace ~
16660 \InsetSpace ~
16661 \InsetSpace ~
16662 \InsetSpace ~
16663 \InsetSpace ~
16664 \InsetSpace ~
16665 \InsetSpace ~
16666 \InsetSpace ~
16667 .area GSINIT1 (CODE)
16668 \newline
16669 __sdcc_init_xstack::
16670 \newline
16671 ; Need to initialize in GSINIT1 in
16672  case the user's __sdcc_external_startup uses the xstack.
16673 \newline
16674 \InsetSpace ~
16675 \InsetSpace ~
16676 \InsetSpace ~
16677 \InsetSpace ~
16678 \InsetSpace ~
16679 \InsetSpace ~
16680 \InsetSpace ~
16681 \InsetSpace ~
16682 mov __XPAGE,#(__start__x
16683 stack >> 8)
16684 \newline
16685 \InsetSpace ~
16686 \InsetSpace ~
16687 \InsetSpace ~
16688 \InsetSpace ~
16689 \InsetSpace ~
16690 \InsetSpace ~
16691 \InsetSpace ~
16692 \InsetSpace ~
16693 mov _spx,#__start__xstack
16694 \end_layout
16695
16696 \begin_layout Verse
16697
16698 \family typewriter
16699 \series bold
16700 \size footnotesize
16701 (crtstart.asm)
16702 \end_layout
16703
16704 \begin_layout Verse
16705
16706 \family typewriter
16707 \size footnotesize
16708 \InsetSpace ~
16709 \InsetSpace ~
16710 \InsetSpace ~
16711 \InsetSpace ~
16712 \InsetSpace ~
16713 \InsetSpace ~
16714 \InsetSpace ~
16715 \InsetSpace ~
16716 .area GSINIT2 (CODE)
16717 \newline
16718 \InsetSpace ~
16719 \InsetSpace ~
16720 \InsetSpace ~
16721 \InsetSpace ~
16722 \InsetSpace ~
16723 \InsetSpace ~
16724 \InsetSpace ~
16725 \InsetSpace ~
16726 lcall __sdcc_external_startup
16727 \newline
16728 \InsetSpace ~
16729 \InsetSpace ~
16730 \InsetSpace ~
16731 \InsetSpace ~
16732 \InsetSpace ~
16733 \InsetSpace ~
16734 \InsetSpace ~
16735 \InsetSpace ~
16736 mov a,dpl
16737 \newline
16738 \InsetSpace ~
16739 \InsetSpace ~
16740 \InsetSpace ~
16741 \InsetSpace ~
16742 \InsetSpace ~
16743 \InsetSpace ~
16744 \InsetSpace ~
16745 \InsetSpace ~
16746 jz __sdcc_init_data
16747 \newline
16748 \InsetSpace ~
16749 \InsetSpace ~
16750 \InsetSpace ~
16751 \InsetSpace ~
16752 \InsetSpace ~
16753 \InsetSpace ~
16754 \InsetSpace ~
16755 \InsetSpace ~
16756 ljmp
16757  __sdcc_program_startup
16758 \newline
16759 __sdcc_init_data:
16760 \end_layout
16761
16762 \begin_layout Verse
16763
16764 \family typewriter
16765 \series bold
16766 \size footnotesize
16767 (crtxinit.asm)
16768 \end_layout
16769
16770 \begin_layout Verse
16771
16772 \family typewriter
16773 \size footnotesize
16774 \InsetSpace ~
16775 \InsetSpace ~
16776 \InsetSpace ~
16777 \InsetSpace ~
16778 \InsetSpace ~
16779 \InsetSpace ~
16780 \InsetSpace ~
16781 \InsetSpace ~
16782 .area GSINIT3 (CODE)
16783 \newline
16784 __mcs51_genXINIT::
16785 \newline
16786 \InsetSpace ~
16787 \InsetSpace ~
16788 \InsetSpace ~
16789 \InsetSpace ~
16790 \InsetSpace ~
16791 \InsetSpace ~
16792 \InsetSpace ~
16793 \InsetSpace ~
16794 mov r1,#l_XINIT
16795 \newline
16796 \InsetSpace ~
16797 \InsetSpace ~
16798 \InsetSpace ~
16799 \InsetSpace ~
16800 \InsetSpace ~
16801 \InsetSpace ~
16802 \InsetSpace ~
16803 \InsetSpace ~
16804 mov a,r1
16805 \newline
16806 \InsetSpace ~
16807 \InsetSpace ~
16808 \InsetSpace ~
16809 \InsetSpace ~
16810 \InsetSpace ~
16811 \InsetSpace ~
16812 \InsetSpace ~
16813 \InsetSpace ~
16814 orl a,#(l_XINIT
16815  >> 8)
16816 \newline
16817 \InsetSpace ~
16818 \InsetSpace ~
16819 \InsetSpace ~
16820 \InsetSpace ~
16821 \InsetSpace ~
16822 \InsetSpace ~
16823 \InsetSpace ~
16824 \InsetSpace ~
16825 jz 00003$
16826 \newline
16827 \InsetSpace ~
16828 \InsetSpace ~
16829 \InsetSpace ~
16830 \InsetSpace ~
16831 \InsetSpace ~
16832 \InsetSpace ~
16833 \InsetSpace ~
16834 \InsetSpace ~
16835 mov r2,#((l_XINIT+255) >> 8)
16836 \newline
16837 \InsetSpace ~
16838 \InsetSpace ~
16839 \InsetSpace ~
16840 \InsetSpace ~
16841 \InsetSpace ~
16842 \InsetSpace ~
16843 \InsetSpace ~
16844 \InsetSpace ~
16845 mov dptr,#s_XINIT
16846 \newline
16847 \InsetSpace ~
16848 \InsetSpace ~
16849 \InsetSpace ~
16850 \InsetSpace ~
16851 \InsetSpace ~
16852 \InsetSpace ~
16853 \InsetSpace ~
16854 \InsetSpace ~
16855 mov r0,#s_XISEG
16856 \newline
16857 \InsetSpace ~
16858 \InsetSpace ~
16859 \InsetSpace ~
16860 \InsetSpace ~
16861 \InsetSpace ~
16862 \InsetSpace ~
16863 \InsetSpace ~
16864 \InsetSpace ~
16865 mov
16866  __XPAGE,#(s_XISEG >> 8)
16867 \newline
16868 00001$:\InsetSpace ~
16869 clr a
16870 \newline
16871 \InsetSpace ~
16872 \InsetSpace ~
16873 \InsetSpace ~
16874 \InsetSpace ~
16875 \InsetSpace ~
16876 \InsetSpace ~
16877 \InsetSpace ~
16878 \InsetSpace ~
16879 movc a,@a+dptr
16880 \newline
16881 \InsetSpace ~
16882 \InsetSpace ~
16883 \InsetSpace ~
16884 \InsetSpace ~
16885 \InsetSpace ~
16886 \InsetSpace ~
16887 \InsetSpace ~
16888 \InsetSpace ~
16889 movx @r0,a
16890 \newline
16891 \InsetSpace ~
16892 \InsetSpace ~
16893 \InsetSpace ~
16894 \InsetSpace ~
16895 \InsetSpace ~
16896 \InsetSpace ~
16897 \InsetSpace ~
16898 \InsetSpace ~
16899 inc dptr
16900 \newline
16901 \InsetSpace ~
16902 \InsetSpace ~
16903 \InsetSpace ~
16904 \InsetSpace ~
16905 \InsetSpace ~
16906 \InsetSpace ~
16907 \InsetSpace ~
16908 \InsetSpace ~
16909 inc
16910  r0
16911 \newline
16912 \InsetSpace ~
16913 \InsetSpace ~
16914 \InsetSpace ~
16915 \InsetSpace ~
16916 \InsetSpace ~
16917 \InsetSpace ~
16918 \InsetSpace ~
16919 \InsetSpace ~
16920 cjne r0,#0,00002$
16921 \newline
16922 \InsetSpace ~
16923 \InsetSpace ~
16924 \InsetSpace ~
16925 \InsetSpace ~
16926 \InsetSpace ~
16927 \InsetSpace ~
16928 \InsetSpace ~
16929 \InsetSpace ~
16930 inc __XPAGE
16931 \newline
16932 00002$:\InsetSpace ~
16933 djnz r1,00001$
16934 \newline
16935 \InsetSpace ~
16936 \InsetSpace ~
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 \InsetSpace ~
16940 \InsetSpace ~
16941 \InsetSpace ~
16942 \InsetSpace ~
16943 djnz r2,00001$
16944 \newline
16945 \InsetSpace ~
16946 \InsetSpace ~
16947 \InsetSpace ~
16948 \InsetSpace ~
16949 \InsetSpace ~
16950 \InsetSpace ~
16951 \InsetSpace ~
16952 \InsetSpace ~
16953 mov __XPAGE,#0
16954 xFF
16955 \newline
16956 00003$:
16957 \end_layout
16958
16959 \begin_layout Verse
16960
16961 \family typewriter
16962 \series bold
16963 \size footnotesize
16964 (crtclear.asm)
16965 \end_layout
16966
16967 \begin_layout Verse
16968
16969 \family typewriter
16970 \size footnotesize
16971 \InsetSpace ~
16972 \InsetSpace ~
16973 \InsetSpace ~
16974 \InsetSpace ~
16975 \InsetSpace ~
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 \InsetSpace ~
16979 .area GSINIT4 (CODE)
16980 \newline
16981 __mcs51_genRAMCLEAR::
16982 \newline
16983 \InsetSpace ~
16984 \InsetSpace ~
16985 \InsetSpace ~
16986 \InsetSpace ~
16987 \InsetSpace ~
16988 \InsetSpace ~
16989 \InsetSpace ~
16990 \InsetSpace ~
16991 clr a
16992 \newline
16993 \InsetSpace ~
16994 \InsetSpace ~
16995 \InsetSpace ~
16996 \InsetSpace ~
16997 \InsetSpace ~
16998 \InsetSpace ~
16999 \InsetSpace ~
17000 \InsetSpace ~
17001 mov r0,#(l_IRAM-1)
17002 \newline
17003 00004$:\InsetSpace ~
17004 mov
17005  @r0,a
17006 \newline
17007 \InsetSpace ~
17008 \InsetSpace ~
17009 \InsetSpace ~
17010 \InsetSpace ~
17011 \InsetSpace ~
17012 \InsetSpace ~
17013 \InsetSpace ~
17014 \InsetSpace ~
17015 djnz r0,00004$
17016 \newline
17017 ; _mcs51_genRAMCLEAR() end
17018 \end_layout
17019
17020 \begin_layout Verse
17021
17022 \family typewriter
17023 \series bold
17024 \size footnotesize
17025 (crtxclear.asm)
17026 \end_layout
17027
17028 \begin_layout Verse
17029
17030 \family typewriter
17031 \size footnotesize
17032 \InsetSpace ~
17033 \InsetSpace ~
17034 \InsetSpace ~
17035 \InsetSpace ~
17036 \InsetSpace ~
17037 \InsetSpace ~
17038 \InsetSpace ~
17039 \InsetSpace ~
17040 .area GSINIT4 (CODE)
17041 \newline
17042 __mcs51_genXRAMCLEAR::
17043 \newline
17044 \InsetSpace ~
17045 \InsetSpace ~
17046 \InsetSpace ~
17047 \InsetSpace ~
17048 \InsetSpace ~
17049 \InsetSpace ~
17050 \InsetSpace ~
17051 \InsetSpace ~
17052 mov r0,#l_PSEG
17053 \newline
17054 \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 \InsetSpace ~
17058 \InsetSpace ~
17059 \InsetSpace ~
17060 \InsetSpace ~
17061 \InsetSpace ~
17062 mov a,r0
17063 \newline
17064 \InsetSpace ~
17065 \InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 \InsetSpace ~
17069 \InsetSpace ~
17070 \InsetSpace ~
17071 \InsetSpace ~
17072 orl a,#(l_PSEG
17073  >> 8)
17074 \newline
17075 \InsetSpace ~
17076 \InsetSpace ~
17077 \InsetSpace ~
17078 \InsetSpace ~
17079 \InsetSpace ~
17080 \InsetSpace ~
17081 \InsetSpace ~
17082 \InsetSpace ~
17083 jz 00006$
17084 \newline
17085 \InsetSpace ~
17086 \InsetSpace ~
17087 \InsetSpace ~
17088 \InsetSpace ~
17089 \InsetSpace ~
17090 \InsetSpace ~
17091 \InsetSpace ~
17092 \InsetSpace ~
17093 mov r1,#s_PSEG
17094 \newline
17095 \InsetSpace ~
17096 \InsetSpace ~
17097 \InsetSpace ~
17098 \InsetSpace ~
17099 \InsetSpace ~
17100 \InsetSpace ~
17101 \InsetSpace ~
17102 \InsetSpace ~
17103 mov __XPAGE,#(s_PSEG >> 8)
17104 \newline
17105 \InsetSpace ~
17106 \InsetSpace ~
17107 \InsetSpace ~
17108 \InsetSpace ~
17109 \InsetSpace ~
17110 \InsetSpace ~
17111 \InsetSpace ~
17112 \InsetSpace ~
17113 clr a
17114 \newline
17115 00005$:\InsetSpace ~
17116 movx
17117  @r1,a
17118 \newline
17119 \InsetSpace ~
17120 \InsetSpace ~
17121 \InsetSpace ~
17122 \InsetSpace ~
17123 \InsetSpace ~
17124 \InsetSpace ~
17125 \InsetSpace ~
17126 \InsetSpace ~
17127 inc r1
17128 \newline
17129 \InsetSpace ~
17130 \InsetSpace ~
17131 \InsetSpace ~
17132 \InsetSpace ~
17133 \InsetSpace ~
17134 \InsetSpace ~
17135 \InsetSpace ~
17136 \InsetSpace ~
17137 djnz r0,00005$
17138 \newline
17139 00006$:
17140 \newline
17141 \InsetSpace ~
17142 \InsetSpace ~
17143 \InsetSpace ~
17144 \InsetSpace ~
17145 \InsetSpace ~
17146 \InsetSpace ~
17147 \InsetSpace ~
17148 \InsetSpace ~
17149 mov r0,#l_XSEG
17150 \newline
17151 \InsetSpace ~
17152 \InsetSpace ~
17153 \InsetSpace ~
17154 \InsetSpace ~
17155 \InsetSpace ~
17156 \InsetSpace ~
17157 \InsetSpace ~
17158 \InsetSpace ~
17159 mov a,r0
17160 \newline
17161 \InsetSpace ~
17162 \InsetSpace ~
17163 \InsetSpace ~
17164 \InsetSpace ~
17165 \InsetSpace ~
17166 \InsetSpace ~
17167 \InsetSpace ~
17168 \InsetSpace ~
17169 orl a,#(l_XSEG >>
17170  8)
17171 \newline
17172 \InsetSpace ~
17173 \InsetSpace ~
17174 \InsetSpace ~
17175 \InsetSpace ~
17176 \InsetSpace ~
17177 \InsetSpace ~
17178 \InsetSpace ~
17179 \InsetSpace ~
17180 jz 00008$
17181 \newline
17182 \InsetSpace ~
17183 \InsetSpace ~
17184 \InsetSpace ~
17185 \InsetSpace ~
17186 \InsetSpace ~
17187 \InsetSpace ~
17188 \InsetSpace ~
17189 \InsetSpace ~
17190 mov r1,#((l_XSEG + 255) >> 8)
17191 \newline
17192 \InsetSpace ~
17193 \InsetSpace ~
17194 \InsetSpace ~
17195 \InsetSpace ~
17196 \InsetSpace ~
17197 \InsetSpace ~
17198 \InsetSpace ~
17199 \InsetSpace ~
17200 mov dptr,#s_XSEG
17201 \newline
17202 \InsetSpace ~
17203 \InsetSpace ~
17204 \InsetSpace ~
17205 \InsetSpace ~
17206 \InsetSpace ~
17207 \InsetSpace ~
17208 \InsetSpace ~
17209 \InsetSpace ~
17210 clr a
17211 \newline
17212 00007$:\InsetSpace ~
17213 movx
17214  @dptr,a
17215 \newline
17216 \InsetSpace ~
17217 \InsetSpace ~
17218 \InsetSpace ~
17219 \InsetSpace ~
17220 \InsetSpace ~
17221 \InsetSpace ~
17222 \InsetSpace ~
17223 \InsetSpace ~
17224 inc dptr
17225 \newline
17226 \InsetSpace ~
17227 \InsetSpace ~
17228 \InsetSpace ~
17229 \InsetSpace ~
17230 \InsetSpace ~
17231 \InsetSpace ~
17232 \InsetSpace ~
17233 \InsetSpace ~
17234 djnz r0,00007$
17235 \newline
17236 \InsetSpace ~
17237 \InsetSpace ~
17238 \InsetSpace ~
17239 \InsetSpace ~
17240 \InsetSpace ~
17241 \InsetSpace ~
17242 \InsetSpace ~
17243 \InsetSpace ~
17244 djnz r1,00007$
17245 \newline
17246 00008$:
17247 \end_layout
17248
17249 \begin_layout Verse
17250
17251 \family typewriter
17252 \series bold
17253 \size footnotesize
17254 (crtxstack.asm)
17255 \end_layout
17256
17257 \begin_layout Verse
17258
17259 \family typewriter
17260 \size footnotesize
17261 \InsetSpace ~
17262 \InsetSpace ~
17263 \InsetSpace ~
17264 \InsetSpace ~
17265 \InsetSpace ~
17266 \InsetSpace ~
17267 \InsetSpace ~
17268 \InsetSpace ~
17269 .area GSINIT5 (CODE)
17270 \newline
17271 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
17272  modifies __XPAGE
17273 \newline
17274 ; and __mcs51_genRAMCLEAR modifies _spx.
17275 \newline
17276 \InsetSpace ~
17277 \InsetSpace ~
17278 \InsetSpace ~
17279 \InsetSpace ~
17280 \InsetSpace ~
17281 \InsetSpace ~
17282 \InsetSpace ~
17283 \InsetSpace ~
17284 mov __XPAGE,#(__start__x
17285 stack >> 8)
17286 \newline
17287 \InsetSpace ~
17288 \InsetSpace ~
17289 \InsetSpace ~
17290 \InsetSpace ~
17291 \InsetSpace ~
17292 \InsetSpace ~
17293 \InsetSpace ~
17294 \InsetSpace ~
17295 mov _spx,#__start__xstack
17296 \end_layout
17297
17298 \begin_layout Verse
17299
17300 \family typewriter
17301 \series bold
17302 \size footnotesize
17303 (application modules)
17304 \end_layout
17305
17306 \begin_layout Verse
17307
17308 \family typewriter
17309 \size footnotesize
17310 \InsetSpace ~
17311 \InsetSpace ~
17312 \InsetSpace ~
17313 \InsetSpace ~
17314 \InsetSpace ~
17315 \InsetSpace ~
17316 \InsetSpace ~
17317 \InsetSpace ~
17318 .area GSINIT (CODE)
17319 \end_layout
17320
17321 \begin_layout Verse
17322
17323 \family typewriter
17324 \series bold
17325 \size footnotesize
17326 (main.asm)
17327 \end_layout
17328
17329 \begin_layout Verse
17330
17331 \family typewriter
17332 \size footnotesize
17333 \InsetSpace ~
17334 \InsetSpace ~
17335 \InsetSpace ~
17336 \InsetSpace ~
17337 \InsetSpace ~
17338 \InsetSpace ~
17339 \InsetSpace ~
17340 \InsetSpace ~
17341 .area GSFINAL (CODE)
17342 \newline
17343 \InsetSpace ~
17344 \InsetSpace ~
17345 \InsetSpace ~
17346 \InsetSpace ~
17347 \InsetSpace ~
17348 \InsetSpace ~
17349 \InsetSpace ~
17350 \InsetSpace ~
17351 ljmp __sdcc_program_startup
17352 \newline
17353 ;---------------------------------
17354 -----------------------
17355 \newline
17356 ; Home
17357 \newline
17358 ;--------------------------------------------------
17359 ------
17360 \newline
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 \InsetSpace ~
17364 \InsetSpace ~
17365 \InsetSpace ~
17366 \InsetSpace ~
17367 \InsetSpace ~
17368 \InsetSpace ~
17369 .area HOME (CODE)
17370 \newline
17371 \InsetSpace ~
17372 \InsetSpace ~
17373 \InsetSpace ~
17374 \InsetSpace ~
17375 \InsetSpace ~
17376 \InsetSpace ~
17377 \InsetSpace ~
17378 \InsetSpace ~
17379 .area CSEG (CODE)
17380 \newline
17381 __sdcc_program_startup:
17382 \newline
17383 \InsetSpace ~
17384 \InsetSpace ~
17385 \InsetSpace ~
17386 \InsetSpace ~
17387 \InsetSpace ~
17388 \InsetSpace ~
17389 \InsetSpace ~
17390 \InsetSpace ~
17391 lcall _main
17392 \newline
17393 ;
17394  return from main will lock up
17395 \newline
17396 \InsetSpace ~
17397 \InsetSpace ~
17398 \InsetSpace ~
17399 \InsetSpace ~
17400 \InsetSpace ~
17401 \InsetSpace ~
17402 \InsetSpace ~
17403 \InsetSpace ~
17404 sjmp .
17405 \end_layout
17406
17407 \begin_layout Standard
17408 One of these modules (crtstart.asm) contains a call to the C routine 
17409 \emph on
17410 _sdcc_external_startup()
17411 \begin_inset LatexCommand index
17412 name "\\_sdcc\\_external\\_startup()"
17413
17414 \end_inset
17415
17416
17417 \emph default
17418  at the start of the CODE area.
17419  This routine is also in the runtime library
17420 \begin_inset LatexCommand index
17421 name "Runtime library"
17422
17423 \end_inset
17424
17425  and returns 0 by default.
17426  If this routine returns a non-zero value, the static & global variable
17427  initialization will be skipped and the function main will be invoked.
17428  Otherwise static & global variables will be initialized before the function
17429  main is invoked.
17430  You could add an 
17431 \emph on
17432 _sdcc_external_startup()
17433 \emph default
17434  routine to your program to override the default if you need to setup hardware
17435  or perform some other critical operation prior to static & global variable
17436  initialization
17437 \begin_inset LatexCommand index
17438 name "Variable initialization"
17439
17440 \end_inset
17441
17442 .
17443  On some mcs51 variants xdata
17444 \begin_inset LatexCommand index
17445 name "xdata (mcs51, ds390 storage class)"
17446
17447 \end_inset
17448
17449  memory has to be explicitly enabled before it can be accessed or if the
17450  watchdog
17451 \begin_inset LatexCommand index
17452 name "watchdog"
17453
17454 \end_inset
17455
17456  needs to be disabled, this is the place to do it.
17457  The startup code clears all internal data memory, 256 bytes by default,
17458  but from 0 to n-1 if 
17459 \emph on
17460 -
17461 \begin_inset ERT
17462 status collapsed
17463
17464 \begin_layout Standard
17465
17466
17467 \backslash
17468 /
17469 \end_layout
17470
17471 \end_inset
17472
17473 -iram-size
17474 \begin_inset LatexCommand index
17475 name "-\\/-iram-size <Value>"
17476
17477 \end_inset
17478
17479 n
17480 \emph default
17481  is used.
17482  (recommended for Chipcon CC1010).
17483 \end_layout
17484
17485 \begin_layout Standard
17486 See also the compiler options 
17487 \emph on
17488 -
17489 \begin_inset ERT
17490 status collapsed
17491
17492 \begin_layout Standard
17493
17494
17495 \backslash
17496 /
17497 \end_layout
17498
17499 \end_inset
17500
17501 -no-xinit
17502 \emph default
17503 -
17504 \emph on
17505 opt
17506 \emph default
17507
17508 \begin_inset LatexCommand index
17509 name "-\\/-no-xinit-opt"
17510
17511 \end_inset
17512
17513
17514 \emph on
17515 -
17516 \begin_inset ERT
17517 status collapsed
17518
17519 \begin_layout Standard
17520
17521
17522 \backslash
17523 /
17524 \end_layout
17525
17526 \end_inset
17527
17528 -main-return
17529 \emph default
17530
17531 \begin_inset LatexCommand index
17532 name "-\\/-main-return"
17533
17534 \end_inset
17535
17536  and section 
17537 \begin_inset LatexCommand ref
17538 reference "sub:MCS51-variants"
17539
17540 \end_inset
17541
17542  about MCS51-variants.
17543 \newline
17544
17545 \end_layout
17546
17547 \begin_layout Standard
17548 While these initialization modules are meant as generic startup code there
17549  might be the need for customization.
17550  Let's assume the return value of 
17551 \emph on
17552 _sdcc_external_startup()
17553 \emph default
17554  in 
17555 \emph on
17556 crtstart.asm
17557 \emph default
17558  should not be checked (or 
17559 \emph on
17560 _sdcc_external_startup()
17561 \emph default
17562  should not be called at all).
17563  The recommended way would be to copy 
17564 \emph on
17565 crtstart.asm
17566 \emph default
17567  (f.e.
17568  from 
17569 \begin_inset LatexCommand url
17570 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm"
17571
17572 \end_inset
17573
17574 ) into the source directory, adapt it there, then assemble it with 
17575 \emph on
17576 asx8051 -plosgff
17577 \begin_inset Foot
17578 status open
17579
17580 \begin_layout Standard
17581 \begin_inset Quotes sld
17582 \end_inset
17583
17584 -plosgff
17585 \begin_inset Quotes srd
17586 \end_inset
17587
17588  are the assembler options used in 
17589 \begin_inset LatexCommand url
17590 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup "
17591
17592 \end_inset
17593
17594
17595 \end_layout
17596
17597 \end_inset
17598
17599  crtstart.asm
17600 \emph default
17601  and when linking your project explicitly specify 
17602 \emph on
17603 crtstart.rel
17604 \emph default
17605 .
17606  As a bonus a listing of the relocated object file 
17607 \emph on
17608 crtstart.rst
17609 \emph default
17610  is generated.
17611 \end_layout
17612
17613 \begin_layout Standard
17614 \begin_inset VSpace bigskip
17615 \end_inset
17616
17617
17618 \end_layout
17619
17620 \begin_layout Subsection
17621 HC08 Startup Code
17622 \end_layout
17623
17624 \begin_layout Standard
17625 The HC08
17626 \begin_inset LatexCommand index
17627 name "HC08"
17628
17629 \end_inset
17630
17631  startup code follows the same scheme as the MCS51 startup code.
17632 \begin_inset VSpace bigskip
17633 \end_inset
17634
17635
17636 \end_layout
17637
17638 \begin_layout Subsection
17639 Z80 Startup Code
17640 \end_layout
17641
17642 \begin_layout Standard
17643 On the Z80
17644 \begin_inset LatexCommand index
17645 name "Z80"
17646
17647 \end_inset
17648
17649  the startup code is inserted by linking with crt0.o which is generated from
17650  sdcc/device/lib/z80/crt0.s.
17651  If you need a different startup code you can use the compiler option 
17652 \emph on
17653 -
17654 \series bold
17655 \emph default
17656
17657 \begin_inset ERT
17658 status collapsed
17659
17660 \begin_layout Standard
17661
17662
17663 \backslash
17664 /
17665 \end_layout
17666
17667 \end_inset
17668
17669
17670 \series default
17671 \emph on
17672 -no-std-crt0
17673 \emph default
17674
17675 \begin_inset LatexCommand index
17676 name "-\\/-no-std-crt0"
17677
17678 \end_inset
17679
17680  and provide your own crt0.o.
17681  
17682 \begin_inset VSpace bigskip
17683 \end_inset
17684
17685
17686 \end_layout
17687
17688 \begin_layout Section
17689 Inline Assembler Code
17690 \begin_inset LatexCommand index
17691 name "Assembler routines"
17692
17693 \end_inset
17694
17695
17696 \end_layout
17697
17698 \begin_layout Subsection
17699 A Step by Step Introduction
17700 \begin_inset LatexCommand label
17701 name "sub:A-Step-by Assembler Introduction"
17702
17703 \end_inset
17704
17705
17706 \end_layout
17707
17708 \begin_layout Standard
17709 Starting from a small snippet of c-code this example shows for the MCS51
17710  how to use inline assembly, access variables, a function parameter and
17711  an array in xdata memory.
17712  The example uses an MCS51 here but is easily adapted for other architectures.
17713  This is a buffer routine which should be optimized:
17714 \end_layout
17715
17716 \begin_layout Verse
17717
17718 \family typewriter
17719 \size footnotesize
17720 unsigned char __far
17721 \begin_inset LatexCommand index
17722 name "far (storage class)"
17723
17724 \end_inset
17725
17726
17727 \begin_inset LatexCommand index
17728 name "\\_\\_far (storage class)"
17729
17730 \end_inset
17731
17732  __at
17733 \begin_inset LatexCommand index
17734 name "at"
17735
17736 \end_inset
17737
17738
17739 \begin_inset LatexCommand index
17740 name "\\_\\_at"
17741
17742 \end_inset
17743
17744 (0x7f00) buf[0x100];
17745 \begin_inset LatexCommand index
17746 name "Aligned array"
17747
17748 \end_inset
17749
17750
17751 \newline
17752 unsigned char head, tail;\InsetSpace ~
17753 \InsetSpace ~
17754 \InsetSpace ~
17755 \InsetSpace ~
17756 \InsetSpace ~
17757 \InsetSpace ~
17758 \InsetSpace ~
17759 \InsetSpace ~
17760 \InsetSpace ~
17761 \InsetSpace ~
17762 \InsetSpace ~
17763 \InsetSpace ~
17764 \InsetSpace ~
17765 \InsetSpace ~
17766 \InsetSpace ~
17767 \InsetSpace ~
17768 \InsetSpace ~
17769 /* if interrupts
17770 \begin_inset LatexCommand index
17771 name "interrupt"
17772
17773 \end_inset
17774
17775  are involved see
17776 \newline
17777 \InsetSpace ~
17778 \InsetSpace ~
17779 \InsetSpace ~
17780 \InsetSpace ~
17781 \InsetSpace ~
17782 \InsetSpace ~
17783 \InsetSpace ~
17784 \InsetSpace ~
17785 \InsetSpace ~
17786 \InsetSpace ~
17787 \InsetSpace ~
17788 \InsetSpace ~
17789 \InsetSpace ~
17790 \InsetSpace ~
17791 \InsetSpace ~
17792 \InsetSpace ~
17793 \InsetSpace ~
17794 \InsetSpace ~
17795 \InsetSpace ~
17796 \InsetSpace ~
17797 \InsetSpace ~
17798 \InsetSpace ~
17799 \InsetSpace ~
17800 \InsetSpace ~
17801 \InsetSpace ~
17802 \InsetSpace ~
17803 \InsetSpace ~
17804 \InsetSpace ~
17805 \InsetSpace ~
17806 \InsetSpace ~
17807 \InsetSpace ~
17808 \InsetSpace ~
17809 \InsetSpace ~
17810 \InsetSpace ~
17811 \InsetSpace ~
17812 \InsetSpace ~
17813 \InsetSpace ~
17814 \InsetSpace ~
17815 \InsetSpace ~
17816 \InsetSpace ~
17817 \InsetSpace ~
17818 \InsetSpace ~
17819 \InsetSpace ~
17820 \InsetSpace ~
17821 \InsetSpace ~
17822 section 
17823 \begin_inset LatexCommand ref
17824 reference "sub:Common-interrupt-pitfall-volatile"
17825
17826 \end_inset
17827
17828  about
17829 \family default
17830  
17831 \family typewriter
17832 \series bold
17833 volatile
17834 \family default
17835 \series default
17836  
17837 \family typewriter
17838 */
17839 \newline
17840
17841 \newline
17842 void to_buffer( unsigned char c ) 
17843 \newline
17844 {
17845 \newline
17846 \InsetSpace ~
17847 \InsetSpace ~
17848 \InsetSpace ~
17849 \InsetSpace ~
17850 if( head != (unsigned char)(tail-1)
17851  )\InsetSpace ~
17852 /* cast
17853 \family default
17854  
17855 \family typewriter
17856 \series bold
17857 needed
17858 \family default
17859 \series default
17860  
17861 \family typewriter
17862 to avoid promotion
17863 \begin_inset LatexCommand index
17864 name "promotion to signed int"
17865
17866 \end_inset
17867
17868
17869 \begin_inset LatexCommand index
17870 name "type promotion"
17871
17872 \end_inset
17873
17874  to integer */
17875 \begin_inset Marginal
17876 status collapsed
17877
17878 \begin_layout Standard
17879
17880 \series bold
17881 \InsetSpace ~
17882 !
17883 \end_layout
17884
17885 \end_inset
17886
17887
17888 \newline
17889 \InsetSpace ~
17890 \InsetSpace ~
17891 \InsetSpace ~
17892 \InsetSpace ~
17893 \InsetSpace ~
17894 \InsetSpace ~
17895 \InsetSpace ~
17896 \InsetSpace ~
17897 buf[ head++ ] = c;\InsetSpace ~
17898 \InsetSpace ~
17899 \InsetSpace ~
17900 \InsetSpace ~
17901 \InsetSpace ~
17902 \InsetSpace ~
17903 \InsetSpace ~
17904 \InsetSpace ~
17905 \InsetSpace ~
17906 \InsetSpace ~
17907 \InsetSpace ~
17908 \InsetSpace ~
17909 \InsetSpace ~
17910 \InsetSpace ~
17911 \InsetSpace ~
17912 \InsetSpace ~
17913 /* access to a 256 byte aligned array */
17914 \newline
17915
17916 \end_layout
17917
17918 \begin_layout Standard
17919 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
17920  then a corresponding buffer.asm file is generated.
17921  We define a new function 
17922 \family typewriter
17923 to_buffer_asm()
17924 \family default
17925  in file buffer.c in which we cut and paste the generated code, removing
17926  unwanted comments and some ':'.
17927  Then add 
17928 \begin_inset Quotes sld
17929 \end_inset
17930
17931
17932 \series bold
17933 _asm
17934 \series default
17935
17936 \begin_inset Quotes srd
17937 \end_inset
17938
17939  and 
17940 \begin_inset Quotes sld
17941 \end_inset
17942
17943
17944 \series bold
17945 _endasm;
17946 \series default
17947
17948 \begin_inset Quotes srd
17949 \end_inset
17950
17951
17952 \begin_inset Foot
17953 status open
17954
17955 \begin_layout Standard
17956 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
17957  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
17958  has to be used.
17959  The latter is also used in the library functions.
17960 \end_layout
17961
17962 \end_inset
17963
17964  to the beginning and the end of the function body:
17965 \end_layout
17966
17967 \begin_layout Verse
17968
17969 \family typewriter
17970 \size footnotesize
17971 /* With a cut and paste from the .asm file, we have something to start with.
17972 \newline
17973 \InsetSpace ~
17974 \InsetSpace ~
17975 \InsetSpace ~
17976 The
17977  function is not yet OK! (registers aren't saved) */ 
17978 \newline
17979 void to_buffer_asm(
17980  unsigned char c ) 
17981 \newline
17982
17983 \newline
17984 \InsetSpace ~
17985 \InsetSpace ~
17986 \InsetSpace ~
17987 \InsetSpace ~
17988 _asm
17989 \begin_inset LatexCommand index
17990 name "\\_asm"
17991
17992 \end_inset
17993
17994
17995 \begin_inset LatexCommand index
17996 name "\\_\\_asm"
17997
17998 \end_inset
17999
18000
18001 \newline
18002 \InsetSpace ~
18003 \InsetSpace ~
18004 \InsetSpace ~
18005 \InsetSpace ~
18006 mov\InsetSpace ~
18007 \InsetSpace ~
18008 r2,dpl 
18009 \newline
18010 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
18011 /* cast
18012 \family default
18013  
18014 \family typewriter
18015 \series bold
18016 needed
18017 \family default
18018 \series default
18019  
18020 \family typewriter
18021 to avoid promotion
18022 \begin_inset LatexCommand index
18023 name "promotion to signed int"
18024
18025 \end_inset
18026
18027
18028 \begin_inset LatexCommand index
18029 name "type promotion"
18030
18031 \end_inset
18032
18033  to integer */
18034 \newline
18035 \InsetSpace ~
18036 \InsetSpace ~
18037 \InsetSpace ~
18038 \InsetSpace ~
18039 mov\InsetSpace ~
18040 \InsetSpace ~
18041 a,_tail 
18042 \newline
18043 \InsetSpace ~
18044 \InsetSpace ~
18045 \InsetSpace ~
18046 \InsetSpace ~
18047 dec\InsetSpace ~
18048 \InsetSpace ~
18049
18050 \newline
18051 \InsetSpace ~
18052 \InsetSpace ~
18053 \InsetSpace ~
18054 \InsetSpace ~
18055 mov\InsetSpace ~
18056 \InsetSpace ~
18057 r3,a 
18058 \newline
18059 \InsetSpace ~
18060 \InsetSpace ~
18061 \InsetSpace ~
18062 \InsetSpace ~
18063 mov\InsetSpace ~
18064 \InsetSpace ~
18065 a,_head 
18066 \newline
18067 \InsetSpace ~
18068 \InsetSpace ~
18069 \InsetSpace ~
18070 \InsetSpace ~
18071 cjne a,ar3,00106$ 
18072 \newline
18073 \InsetSpace ~
18074 \InsetSpace ~
18075 \InsetSpace ~
18076 \InsetSpace ~
18077 ret
18078 \newline
18079 00106$:
18080  
18081 \newline
18082 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
18083 \begin_inset LatexCommand index
18084 name "Aligned array"
18085
18086 \end_inset
18087
18088
18089 \newline
18090 \InsetSpace ~
18091 \InsetSpace ~
18092 \InsetSpace ~
18093 \InsetSpace ~
18094 mov\InsetSpace ~
18095 \InsetSpace ~
18096 r3,_head 
18097 \newline
18098 \InsetSpace ~
18099 \InsetSpace ~
18100 \InsetSpace ~
18101 \InsetSpace ~
18102 inc\InsetSpace ~
18103 \InsetSpace ~
18104 _head 
18105 \newline
18106 \InsetSpace ~
18107 \InsetSpace ~
18108 \InsetSpace ~
18109 \InsetSpace ~
18110 mov\InsetSpace ~
18111 \InsetSpace ~
18112 dpl,r3 
18113 \newline
18114 \InsetSpace ~
18115 \InsetSpace ~
18116 \InsetSpace ~
18117 \InsetSpace ~
18118 mov\InsetSpace ~
18119 \InsetSpace ~
18120 dph,#(_buf >> 8) 
18121 \newline
18122 \InsetSpace ~
18123 \InsetSpace ~
18124 \InsetSpace ~
18125 \InsetSpace ~
18126 mov\InsetSpace ~
18127 \InsetSpace ~
18128 a,r2 
18129 \newline
18130 \InsetSpace ~
18131 \InsetSpace ~
18132 \InsetSpace ~
18133 \InsetSpace ~
18134 movx @dptr,a
18135  
18136 \newline
18137 00103$: 
18138 \newline
18139 \InsetSpace ~
18140 \InsetSpace ~
18141 \InsetSpace ~
18142 \InsetSpace ~
18143 ret
18144 \newline
18145 \InsetSpace ~
18146 \InsetSpace ~
18147 \InsetSpace ~
18148 \InsetSpace ~
18149 _endasm
18150 \begin_inset LatexCommand index
18151 name "\\_endasm"
18152
18153 \end_inset
18154
18155
18156 \begin_inset LatexCommand index
18157 name "\\_\\_endasm"
18158
18159 \end_inset
18160
18161 ;
18162 \newline
18163
18164 \end_layout
18165
18166 \begin_layout Standard
18167 The new file buffer.c should compile with only one warning about the unreferenced
18168  function argument 'c'.
18169  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
18170  (1) and finally have:
18171 \end_layout
18172
18173 \begin_layout Verse
18174
18175 \family typewriter
18176 \size footnotesize
18177 unsigned char __far __at(0x7f00) buf[0x100];
18178 \newline
18179 unsigned char head, tail;
18180 \newline
18181 #define
18182  USE_ASSEMBLY (1)
18183 \newline
18184
18185 \newline
18186 #if !USE_ASSEMBLY
18187 \newline
18188
18189 \newline
18190 void to_buffer( unsigned char c )
18191 \newline
18192 {
18193 \newline
18194 \InsetSpace ~
18195 \InsetSpace ~
18196 \InsetSpace ~
18197 \InsetSpace ~
18198 if(
18199  head != (unsigned char)(tail-1) )
18200 \newline
18201 \InsetSpace ~
18202 \InsetSpace ~
18203 \InsetSpace ~
18204 \InsetSpace ~
18205 \InsetSpace ~
18206 \InsetSpace ~
18207 \InsetSpace ~
18208 \InsetSpace ~
18209 buf[ head++ ] = c;
18210 \newline
18211 }
18212 \newline
18213
18214 \newline
18215 #else
18216 \newline
18217
18218 \newline
18219 void to_buffer(
18220  unsigned char c )
18221 \newline
18222 {
18223 \newline
18224 \InsetSpace ~
18225 \InsetSpace ~
18226 \InsetSpace ~
18227 \InsetSpace ~
18228 c; // to avoid warning: unreferenced function argument
18229 \newline
18230 \InsetSpace ~
18231 \InsetSpace ~
18232 \InsetSpace ~
18233 \InsetSpace ~
18234 _asm
18235 \begin_inset LatexCommand index
18236 name "\\_asm"
18237
18238 \end_inset
18239
18240
18241 \begin_inset LatexCommand index
18242 name "\\_\\_asm"
18243
18244 \end_inset
18245
18246
18247 \newline
18248 \InsetSpace ~
18249 \InsetSpace ~
18250 \InsetSpace ~
18251 \InsetSpace ~
18252 \InsetSpace ~
18253 \InsetSpace ~
18254 \InsetSpace ~
18255 \InsetSpace ~
18256 ; save used registers here.
18257  
18258 \newline
18259 \InsetSpace ~
18260 \InsetSpace ~
18261 \InsetSpace ~
18262 \InsetSpace ~
18263 \InsetSpace ~
18264 \InsetSpace ~
18265 \InsetSpace ~
18266 \InsetSpace ~
18267 ; If we were still using r2,r3 we would have to push them here.
18268  
18269 \newline
18270 ; if( head != (unsigned char)(tail-1) )
18271 \newline
18272 \InsetSpace ~
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 \InsetSpace ~
18276 \InsetSpace ~
18277 \InsetSpace ~
18278 \InsetSpace ~
18279 \InsetSpace ~
18280 mov\InsetSpace ~
18281  a,_tail
18282 \newline
18283 \InsetSpace ~
18284 \InsetSpace ~
18285 \InsetSpace ~
18286 \InsetSpace ~
18287 \InsetSpace ~
18288 \InsetSpace ~
18289 \InsetSpace ~
18290 \InsetSpace ~
18291 dec\InsetSpace ~
18292  a
18293 \newline
18294 \InsetSpace ~
18295 \InsetSpace ~
18296 \InsetSpace ~
18297 \InsetSpace ~
18298 \InsetSpace ~
18299 \InsetSpace ~
18300 \InsetSpace ~
18301 \InsetSpace ~
18302 xrl\InsetSpace ~
18303  a,_head
18304 \newline
18305 \InsetSpace ~
18306 \InsetSpace ~
18307 \InsetSpace ~
18308 \InsetSpace ~
18309 \InsetSpace ~
18310 \InsetSpace ~
18311 \InsetSpace ~
18312 \InsetSpace ~
18313 ; we
18314  could do an ANL a,#0x0f here to use a smaller buffer (see below)
18315 \newline
18316 \InsetSpace ~
18317 \InsetSpace ~
18318 \InsetSpace ~
18319 \InsetSpace ~
18320 \InsetSpace ~
18321 \InsetSpace ~
18322 \InsetSpace ~
18323 \InsetSpace ~
18324 jz\InsetSpace ~
18325 \InsetSpace ~
18326  t_b_end$
18327 \newline
18328 \InsetSpace ~
18329 \InsetSpace ~
18330 \InsetSpace ~
18331 \InsetSpace ~
18332 \InsetSpace ~
18333 \InsetSpace ~
18334 \InsetSpace ~
18335 \InsetSpace ~
18336 ;
18337 \newline
18338 ;
18339  buf[ head++ ] = c;
18340 \newline
18341 \InsetSpace ~
18342 \InsetSpace ~
18343 \InsetSpace ~
18344 \InsetSpace ~
18345 \InsetSpace ~
18346 \InsetSpace ~
18347 \InsetSpace ~
18348 \InsetSpace ~
18349 mov\InsetSpace ~
18350  a,dpl \InsetSpace ~
18351 \InsetSpace ~
18352 \InsetSpace ~
18353 \InsetSpace ~
18354 \InsetSpace ~
18355 \InsetSpace ~
18356 \InsetSpace ~
18357 ; dpl holds lower byte of function argument
18358 \newline
18359 \InsetSpace ~
18360 \InsetSpace ~
18361 \InsetSpace ~
18362 \InsetSpace ~
18363 \InsetSpace ~
18364 \InsetSpace ~
18365 \InsetSpace ~
18366 \InsetSpace ~
18367 mov\InsetSpace ~
18368
18369  dpl,_head \InsetSpace ~
18370 \InsetSpace ~
18371 \InsetSpace ~
18372 ; buf is 0x100 byte aligned so head can be used directly
18373 \newline
18374 \InsetSpace ~
18375 \InsetSpace ~
18376 \InsetSpace ~
18377 \InsetSpace ~
18378 \InsetSpace ~
18379 \InsetSpace ~
18380 \InsetSpace ~
18381 \InsetSpace ~
18382 mov\InsetSpace ~
18383  dph,#(_bu
18384 f>>8)
18385 \newline
18386 \InsetSpace ~
18387 \InsetSpace ~
18388 \InsetSpace ~
18389 \InsetSpace ~
18390 \InsetSpace ~
18391 \InsetSpace ~
18392 \InsetSpace ~
18393 \InsetSpace ~
18394 movx @dptr,a
18395 \newline
18396 \InsetSpace ~
18397 \InsetSpace ~
18398 \InsetSpace ~
18399 \InsetSpace ~
18400 \InsetSpace ~
18401 \InsetSpace ~
18402 \InsetSpace ~
18403 \InsetSpace ~
18404 inc \InsetSpace ~
18405 _head
18406 \newline
18407 \InsetSpace ~
18408 \InsetSpace ~
18409 \InsetSpace ~
18410 \InsetSpace ~
18411 \InsetSpace ~
18412 \InsetSpace ~
18413 \InsetSpace ~
18414 \InsetSpace ~
18415 ; we could do an ANL _head,#0x0f here to use a
18416  smaller buffer (see above)
18417 \newline
18418 t_b_end$:
18419 \newline
18420 \InsetSpace ~
18421 \InsetSpace ~
18422 \InsetSpace ~
18423 \InsetSpace ~
18424 \InsetSpace ~
18425 \InsetSpace ~
18426 \InsetSpace ~
18427 \InsetSpace ~
18428 ; restore used registers here 
18429 \newline
18430 \InsetSpace ~
18431 \InsetSpace ~
18432 \InsetSpace ~
18433 \InsetSpace ~
18434 _endasm
18435 \begin_inset LatexCommand index
18436 name "\\_endasm"
18437
18438 \end_inset
18439
18440
18441 \begin_inset LatexCommand index
18442 name "\\_\\_endasm"
18443
18444 \end_inset
18445
18446 ;
18447 \newline
18448 }
18449 \newline
18450 #endif
18451 \end_layout
18452
18453 \begin_layout Standard
18454 The inline assembler code can contain any valid code understood by the assembler
18455 , this includes any assembler directives and comment lines.
18456  The assembler does not like some characters like ':' or ''' in comments.
18457  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
18458 \begin_inset LatexCommand index
18459 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
18460
18461 \end_inset
18462
18463
18464 \begin_inset LatexCommand index
18465 name "Assembler documentation"
18466
18467 \end_inset
18468
18469  or online at 
18470 \begin_inset LatexCommand url
18471 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
18472
18473 \end_inset
18474
18475 \InsetSpace ~
18476 .
18477 \end_layout
18478
18479 \begin_layout Standard
18480 The compiler does not do any validation of the code within the 
18481 \family typewriter
18482 _asm
18483 \begin_inset LatexCommand index
18484 name "\\_asm"
18485
18486 \end_inset
18487
18488
18489 \begin_inset LatexCommand index
18490 name "\\_\\_asm"
18491
18492 \end_inset
18493
18494  ...
18495  _endasm
18496 \size footnotesize
18497
18498 \begin_inset LatexCommand index
18499 name "\\_endasm"
18500
18501 \end_inset
18502
18503
18504 \begin_inset LatexCommand index
18505 name "\\_\\_endasm"
18506
18507 \end_inset
18508
18509
18510 \size default
18511 ;
18512 \family default
18513  keyword pair.
18514  Specifically it will not know which registers are used and thus register
18515  pushing/popping
18516 \begin_inset LatexCommand index
18517 name "push/pop"
18518
18519 \end_inset
18520
18521  has to be done manually.
18522  
18523 \end_layout
18524
18525 \begin_layout Standard
18526 It is recommended that each assembly instruction (including labels) be placed
18527  in a separate line (as the example shows).
18528  When the -
18529 \begin_inset ERT
18530 status collapsed
18531
18532 \begin_layout Standard
18533
18534
18535 \backslash
18536 /
18537 \end_layout
18538
18539 \end_inset
18540
18541 -
18542 \emph on
18543 peep-asm
18544 \begin_inset LatexCommand index
18545 name "-\\/-peep-asm"
18546
18547 \end_inset
18548
18549
18550 \emph default
18551  command line option is used, the inline assembler code will be passed through
18552  the peephole optimizer
18553 \begin_inset LatexCommand index
18554 name "Peephole optimizer"
18555
18556 \end_inset
18557
18558 .
18559  There are only a few (if any) cases where this option makes sense, it might
18560  cause some unexpected changes in the inline assembler code.
18561  Please go through the peephole optimizer rules defined in file 
18562 \emph on
18563 SDCCpeeph.def
18564 \emph default
18565  before using this option.
18566 \end_layout
18567
18568 \begin_layout Subsection
18569 Naked Functions
18570 \begin_inset LatexCommand label
18571 name "sub:Naked-Functions"
18572
18573 \end_inset
18574
18575
18576 \begin_inset LatexCommand index
18577 name "Naked functions"
18578
18579 \end_inset
18580
18581
18582 \end_layout
18583
18584 \begin_layout Standard
18585 A special keyword may be associated with a function declaring it as 
18586 \emph on
18587 _naked
18588 \begin_inset LatexCommand index
18589 name "\\_naked"
18590
18591 \end_inset
18592
18593
18594 \begin_inset LatexCommand index
18595 name "\\_\\_naked"
18596
18597 \end_inset
18598
18599 .
18600
18601 \emph default
18602  The 
18603 \emph on
18604 _naked
18605 \emph default
18606  function modifier attribute prevents the compiler from generating prologue
18607 \begin_inset LatexCommand index
18608 name "function prologue"
18609
18610 \end_inset
18611
18612  and epilogue
18613 \begin_inset LatexCommand index
18614 name "function epilogue"
18615
18616 \end_inset
18617
18618  code for that function.
18619  This means that the user is entirely responsible for such things as saving
18620  any registers that may need to be preserved, selecting the proper register
18621  bank, generating the 
18622 \emph on
18623 return
18624 \emph default
18625  instruction at the end, etc.
18626  Practically, this means that the contents of the function must be written
18627  in inline assembler.
18628  This is particularly useful for interrupt functions, which can have a large
18629  (and often unnecessary) prologue/epilogue.
18630  For example, compare the code generated by these two functions:
18631 \end_layout
18632
18633 \begin_layout Verse
18634
18635 \family typewriter
18636 volatile
18637 \begin_inset LatexCommand index
18638 name "volatile"
18639
18640 \end_inset
18641
18642  data unsigned char counter;
18643 \newline
18644
18645 \newline
18646 void simpleInterrupt(void) __interrupt
18647 \begin_inset LatexCommand index
18648 name "interrupt"
18649
18650 \end_inset
18651
18652
18653 \begin_inset LatexCommand index
18654 name "\\_\\_interrupt"
18655
18656 \end_inset
18657
18658  (1)
18659 \newline
18660 {
18661 \newline
18662 \InsetSpace ~
18663 \InsetSpace ~
18664 \InsetSpace ~
18665 \InsetSpace ~
18666 counter++;
18667 \newline
18668 }
18669 \newline
18670
18671 \newline
18672 void nakedInterrupt(void) __interrupt (2) __naked
18673 \newline
18674 {
18675 \newline
18676 \InsetSpace ~
18677 \InsetSpace ~
18678 \InsetSpace ~
18679 \InsetSpace ~
18680 _asm
18681 \begin_inset LatexCommand index
18682 name "\\_asm"
18683
18684 \end_inset
18685
18686
18687 \begin_inset LatexCommand index
18688 name "\\_\\_asm"
18689
18690 \end_inset
18691
18692
18693 \newline
18694 \InsetSpace ~
18695 \InsetSpace ~
18696 \InsetSpace ~
18697 \InsetSpace ~
18698 \InsetSpace ~
18699 \InsetSpace ~
18700 inc\InsetSpace ~
18701 \InsetSpace ~
18702 \InsetSpace ~
18703 \InsetSpace ~
18704 \InsetSpace ~
18705 _counter ; does not change flags, no need to save psw
18706 \newline
18707 \InsetSpace ~
18708 \InsetSpace ~
18709 \InsetSpace ~
18710 \InsetSpace ~
18711 \InsetSpace ~
18712 \InsetSpace ~
18713 reti\InsetSpace ~
18714 \InsetSpace ~
18715 \InsetSpace ~
18716 \InsetSpace ~
18717 ; MUST explicitly
18718  include ret or reti in _naked function.
18719 \newline
18720 \InsetSpace ~
18721 \InsetSpace ~
18722 \InsetSpace ~
18723 \InsetSpace ~
18724 _endasm
18725 \begin_inset LatexCommand index
18726 name "\\_endasm"
18727
18728 \end_inset
18729
18730
18731 \begin_inset LatexCommand index
18732 name "\\_\\_endasm"
18733
18734 \end_inset
18735
18736 ;
18737 \newline
18738 }
18739 \end_layout
18740
18741 \begin_layout Standard
18742 For an 8051 target, the generated simpleInterrupt looks like:
18743 \end_layout
18744
18745 \begin_layout Verse
18746
18747 \family typewriter
18748 Note, this is an
18749 \family default
18750  
18751 \family typewriter
18752 \emph on
18753 outdated
18754 \family default
18755 \emph default
18756  
18757 \family typewriter
18758 example, recent versions of SDCC generate
18759 \newline
18760 the
18761 \family default
18762  
18763 \family typewriter
18764 \emph on
18765 same
18766 \family default
18767 \emph default
18768  
18769 \family typewriter
18770 code for simpleInterrupt() and nakedInterrupt()!
18771 \newline
18772
18773 \newline
18774 _simpleInterrupt:
18775 \newline
18776 \InsetSpace ~
18777 \InsetSpace ~
18778 \InsetSpace ~
18779 \InsetSpace ~
18780 push\InsetSpace ~
18781 \InsetSpace ~
18782 \InsetSpace ~
18783 \InsetSpace ~
18784 acc
18785 \newline
18786 \InsetSpace ~
18787 \InsetSpace ~
18788 \InsetSpace ~
18789 \InsetSpace ~
18790 push\InsetSpace ~
18791 \InsetSpace ~
18792 \InsetSpace ~
18793 \InsetSpace ~
18794 b
18795 \newline
18796 \InsetSpace ~
18797 \InsetSpace ~
18798 \InsetSpace ~
18799 \InsetSpace ~
18800 pus
18801 h\InsetSpace ~
18802 \InsetSpace ~
18803 \InsetSpace ~
18804 \InsetSpace ~
18805 dpl
18806 \newline
18807 \InsetSpace ~
18808 \InsetSpace ~
18809 \InsetSpace ~
18810 \InsetSpace ~
18811 push\InsetSpace ~
18812 \InsetSpace ~
18813 \InsetSpace ~
18814 \InsetSpace ~
18815 dph
18816 \newline
18817 \InsetSpace ~
18818 \InsetSpace ~
18819 \InsetSpace ~
18820 \InsetSpace ~
18821 push\InsetSpace ~
18822 \InsetSpace ~
18823 \InsetSpace ~
18824 \InsetSpace ~
18825 psw
18826 \newline
18827 \InsetSpace ~
18828 \InsetSpace ~
18829 \InsetSpace ~
18830 \InsetSpace ~
18831 mov\InsetSpace ~
18832 \InsetSpace ~
18833 \InsetSpace ~
18834 \InsetSpace ~
18835 \InsetSpace ~
18836 psw,#0x00
18837 \newline
18838 \InsetSpace ~
18839 \InsetSpace ~
18840 \InsetSpace ~
18841 \InsetSpace ~
18842 inc\InsetSpace ~
18843 \InsetSpace ~
18844 \InsetSpace ~
18845 \InsetSpace ~
18846 \InsetSpace ~
18847 _counter
18848 \newline
18849 \InsetSpace ~
18850 \InsetSpace ~
18851 \InsetSpace ~
18852 \InsetSpace ~
18853 pop\InsetSpace ~
18854 \InsetSpace ~
18855 \InsetSpace ~
18856 \InsetSpace ~
18857 \InsetSpace ~
18858 psw
18859 \newline
18860 \InsetSpace ~
18861 \InsetSpace ~
18862 \InsetSpace ~
18863 \InsetSpace ~
18864 pop\InsetSpace ~
18865 \InsetSpace ~
18866 \InsetSpace ~
18867 \InsetSpace ~
18868 \InsetSpace ~
18869 dph
18870 \newline
18871 \InsetSpace ~
18872 \InsetSpace ~
18873 \InsetSpace ~
18874 \InsetSpace ~
18875 pop\InsetSpace ~
18876 \InsetSpace ~
18877 \InsetSpace ~
18878 \InsetSpace ~
18879 \InsetSpace ~
18880 dpl
18881 \newline
18882 \InsetSpace ~
18883 \InsetSpace ~
18884 \InsetSpace ~
18885 \InsetSpace ~
18886 pop\InsetSpace ~
18887 \InsetSpace ~
18888 \InsetSpace ~
18889 \InsetSpace ~
18890 \InsetSpace ~
18891 b
18892 \newline
18893 \InsetSpace ~
18894 \InsetSpace ~
18895 \InsetSpace ~
18896 \InsetSpace ~
18897 pop\InsetSpace ~
18898 \InsetSpace ~
18899 \InsetSpace ~
18900 \InsetSpace ~
18901 \InsetSpace ~
18902 acc
18903 \newline
18904 \InsetSpace ~
18905 \InsetSpace ~
18906 \InsetSpace ~
18907 \InsetSpace ~
18908 reti
18909 \end_layout
18910
18911 \begin_layout Standard
18912 whereas nakedInterrupt looks like:
18913 \end_layout
18914
18915 \begin_layout Verse
18916
18917 \family typewriter
18918 _nakedInterrupt:
18919 \newline
18920 \InsetSpace ~
18921 \InsetSpace ~
18922 \InsetSpace ~
18923 \InsetSpace ~
18924 inc\InsetSpace ~
18925 \InsetSpace ~
18926 \InsetSpace ~
18927 \InsetSpace ~
18928 _counter ; does not change flags, no need to save psw
18929 \newline
18930 \InsetSpace ~
18931 \InsetSpace ~
18932 \InsetSpace ~
18933 \InsetSpace ~
18934 reti\InsetSpace ~
18935 \InsetSpace ~
18936 \InsetSpace ~
18937 \InsetSpace ~
18938 \InsetSpace ~
18939 \InsetSpace ~
18940 \InsetSpace ~
18941 \InsetSpace ~
18942 \InsetSpace ~
18943 \InsetSpace ~
18944 \InsetSpace ~
18945 \InsetSpace ~
18946 ;
18947  MUST explicitly include ret or reti in _naked function
18948 \end_layout
18949
18950 \begin_layout Standard
18951 The related directive #pragma exclude
18952 \begin_inset LatexCommand index
18953 name "\\#pragma exclude"
18954
18955 \end_inset
18956
18957  allows a more fine grained control over pushing & popping
18958 \begin_inset LatexCommand index
18959 name "push/pop"
18960
18961 \end_inset
18962
18963  the registers.
18964 \end_layout
18965
18966 \begin_layout Standard
18967 While there is nothing preventing you from writing C code inside a 
18968 \family typewriter
18969 _naked
18970 \family default
18971  function, there are many ways to shoot yourself in the foot doing this,
18972  and it is recommended that you stick to inline assembler.
18973 \end_layout
18974
18975 \begin_layout Subsection
18976 Use of Labels within Inline Assembler
18977 \end_layout
18978
18979 \begin_layout Standard
18980 SDCC allows the use of in-line assembler with a few restrictions regarding
18981  labels.
18982  All labels defined within inline assembler code have to be of the form
18983  
18984 \emph on
18985 nnnnn$
18986 \emph default
18987  where nnnnn is a number less than 100 (which implies a limit of utmost
18988  100 inline assembler labels 
18989 \emph on
18990 per function
18991 \emph default
18992 \noun on
18993 )
18994 \noun default
18995 .
18996 \begin_inset Foot
18997 status open
18998
18999 \begin_layout Standard
19000 This is a slightly more stringent rule than absolutely necessary, but stays
19001  always on the safe side.
19002  Labels in the form of nnnnn$ are local labels in the assembler, locality
19003  of which is confined within two labels of the standard form.
19004  The compiler uses the same form for labels within a function (but starting
19005  from nnnnn=00100); and places always a standard label at the beginning
19006  of a function, thus limiting the locality of labels within the scope of
19007  the function.
19008  So, if the inline assembler part would be embedded into C-code, an improperly
19009  placed non-local label in the assembler would break up the reference space
19010  for labels created by the compiler for the C-code, leading to an assembling
19011  error.
19012 \end_layout
19013
19014 \begin_layout Standard
19015 The numeric part of local labels does not need to have 5 digits (although
19016  this is the form of labels output by the compiler), any valid integer will
19017  do.
19018  Please refer to the assemblers documentation for further details.
19019 \end_layout
19020
19021 \end_inset
19022
19023  
19024 \end_layout
19025
19026 \begin_layout Verse
19027
19028 \family typewriter
19029 _asm
19030 \begin_inset LatexCommand index
19031 name "\\_asm"
19032
19033 \end_inset
19034
19035
19036 \begin_inset LatexCommand index
19037 name "\\_\\_asm"
19038
19039 \end_inset
19040
19041  
19042 \newline
19043 \InsetSpace ~
19044 \InsetSpace ~
19045 \InsetSpace ~
19046 \InsetSpace ~
19047 mov\InsetSpace ~
19048 \InsetSpace ~
19049 \InsetSpace ~
19050 \InsetSpace ~
19051 \InsetSpace ~
19052 b,#10 
19053 \newline
19054 00001$: 
19055 \newline
19056 \InsetSpace ~
19057 \InsetSpace ~
19058 \InsetSpace ~
19059 \InsetSpace ~
19060 djnz\InsetSpace ~
19061 \InsetSpace ~
19062 \InsetSpace ~
19063 \InsetSpace ~
19064 b,00001$ 
19065 \newline
19066 _endasm
19067 \begin_inset LatexCommand index
19068 name "\\_endasm"
19069
19070 \end_inset
19071
19072
19073 \begin_inset LatexCommand index
19074 name "\\_\\_endasm"
19075
19076 \end_inset
19077
19078  ;
19079 \end_layout
19080
19081 \begin_layout Standard
19082 Inline assembler code cannot reference any C-labels, however it can reference
19083  labels
19084 \begin_inset LatexCommand index
19085 name "Labels"
19086
19087 \end_inset
19088
19089  defined by the inline assembler, e.g.:
19090 \end_layout
19091
19092 \begin_layout Verse
19093
19094 \family typewriter
19095 foo() { 
19096 \newline
19097 \InsetSpace ~
19098 \InsetSpace ~
19099 \InsetSpace ~
19100 \InsetSpace ~
19101 /* some c code */ 
19102 \newline
19103 \InsetSpace ~
19104 \InsetSpace ~
19105 \InsetSpace ~
19106 \InsetSpace ~
19107 _asm 
19108 \newline
19109 \InsetSpace ~
19110 \InsetSpace ~
19111 \InsetSpace ~
19112 \InsetSpace ~
19113 \InsetSpace ~
19114 \InsetSpace ~
19115 ; some assembler code 
19116 \newline
19117 \InsetSpace ~
19118 \InsetSpace ~
19119 \InsetSpace ~
19120 \InsetSpace ~
19121 \InsetSpace ~
19122 \InsetSpace ~
19123 ljmp 0003$ 
19124 \newline
19125 \InsetSpace ~
19126 \InsetSpace ~
19127 \InsetSpace ~
19128 \InsetSpace ~
19129 _endasm;
19130  
19131 \newline
19132 \InsetSpace ~
19133 \InsetSpace ~
19134 \InsetSpace ~
19135 \InsetSpace ~
19136 /* some more c code */ 
19137 \newline
19138 clabel:\InsetSpace ~
19139 \InsetSpace ~
19140 /* inline assembler cannot reference this
19141  label */ 
19142 \begin_inset Foot
19143 status open
19144
19145 \begin_layout Standard
19146 Here, the C-label 
19147 \family typewriter
19148 clabel
19149 \family default
19150  is translated by the compiler into a local label, so the locality of labels
19151  within the function is not broken.
19152 \end_layout
19153
19154 \end_inset
19155
19156
19157 \newline
19158 \InsetSpace ~
19159 \InsetSpace ~
19160 \InsetSpace ~
19161 \InsetSpace ~
19162 _asm
19163 \newline
19164 \InsetSpace ~
19165 \InsetSpace ~
19166 \InsetSpace ~
19167 \InsetSpace ~
19168 0003$: ;label (can be referenced by inline assembler only) 
19169 \newline
19170 \InsetSpace ~
19171 \InsetSpace ~
19172 \InsetSpace ~
19173 \InsetSpace ~
19174 _endasm
19175 \begin_inset LatexCommand index
19176 name "\\_endasm"
19177
19178 \end_inset
19179
19180
19181 \begin_inset LatexCommand index
19182 name "\\_\\_endasm"
19183
19184 \end_inset
19185
19186  ; 
19187 \newline
19188 \InsetSpace ~
19189 \InsetSpace ~
19190 \InsetSpace ~
19191 \InsetSpace ~
19192 /* some more c code */
19193 \newline
19194 }
19195 \end_layout
19196
19197 \begin_layout Standard
19198 In other words inline assembly code can access labels defined in inline
19199  assembly within the scope of the function.
19200  The same goes the other way, i.e.
19201  labels defines in inline assembly can not be accessed by C statements.
19202 \end_layout
19203
19204 \begin_layout Section
19205 Interfacing with Assembler Code
19206 \begin_inset LatexCommand index
19207 name "Assembler routines"
19208
19209 \end_inset
19210
19211
19212 \end_layout
19213
19214 \begin_layout Subsection
19215 Global Registers used for Parameter Passing
19216 \begin_inset LatexCommand index
19217 name "Parameter passing"
19218
19219 \end_inset
19220
19221
19222 \end_layout
19223
19224 \begin_layout Standard
19225 The compiler always uses the global registers 
19226 \emph on
19227 DPL, DPH
19228 \begin_inset LatexCommand index
19229 name "DPTR, DPH, DPL"
19230
19231 \end_inset
19232
19233
19234 \begin_inset LatexCommand index
19235 name "DPTR"
19236
19237 \end_inset
19238
19239 , B
19240 \begin_inset LatexCommand index
19241 name "B (mcs51, ds390 register)"
19242
19243 \end_inset
19244
19245
19246 \emph default
19247  and 
19248 \emph on
19249 ACC
19250 \begin_inset LatexCommand index
19251 name "ACC (mcs51, ds390 register)"
19252
19253 \end_inset
19254
19255
19256 \emph default
19257  to pass the first (non-bit) parameter to a function, and also to pass the
19258  return value 
19259 \begin_inset LatexCommand index
19260 name "return value"
19261
19262 \end_inset
19263
19264 of function; according to the following scheme: one byte return value in
19265  
19266 \emph on
19267 DPL
19268 \emph default
19269 , two byte value in 
19270 \emph on
19271 DPL
19272 \emph default
19273  (LSB) and 
19274 \emph on
19275 DPH
19276 \emph default
19277  (MSB).
19278  three byte values (generic pointers) in 
19279 \emph on
19280 DPH
19281 \emph default
19282
19283 \emph on
19284 DPL
19285 \emph default
19286  and 
19287 \emph on
19288 B
19289 \emph default
19290 , and four byte values in 
19291 \emph on
19292 DPH
19293 \emph default
19294
19295 \emph on
19296 DPL
19297 \emph default
19298
19299 \emph on
19300 B
19301 \emph default
19302  and 
19303 \emph on
19304 ACC
19305 \emph default
19306 .
19307  Generic pointers
19308 \begin_inset LatexCommand index
19309 name "generic pointer"
19310
19311 \end_inset
19312
19313  contain type of accessed memory in 
19314 \emph on
19315 B
19316 \emph default
19317
19318 \series bold
19319 0x00
19320 \series default
19321  -- xdata/far, 
19322 \series bold
19323 0x40
19324 \series default
19325  -- idata/near -- , 
19326 \series bold
19327 0x60
19328 \series default
19329  -- pdata, 
19330 \series bold
19331 0x80
19332 \series default
19333  -- code
19334 \begin_inset Note Note
19335 status collapsed
19336
19337 \begin_layout Standard
19338 This might not be the case of certain memory models (medium???)
19339 \end_layout
19340
19341 \end_inset
19342
19343 .
19344 \end_layout
19345
19346 \begin_layout Standard
19347 The second parameter onwards is either allocated on the stack (for reentrant
19348  routines or if -
19349 \begin_inset ERT
19350 status collapsed
19351
19352 \begin_layout Standard
19353
19354
19355 \backslash
19356 /
19357 \end_layout
19358
19359 \end_inset
19360
19361 -stack-auto is used) or in data/xdata memory (depending on the memory model).
19362 \end_layout
19363
19364 \begin_layout Standard
19365 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
19366  space for reentrant functions or allocated directly in bit memory otherwise.
19367 \end_layout
19368
19369 \begin_layout Standard
19370 Functions (with two or more parameters or bit parameters) that are called
19371  through function pointers
19372 \begin_inset LatexCommand index
19373 name "function pointers"
19374
19375 \end_inset
19376
19377  must therefor be reentrant so the compiler knows how to pass the parameters.
19378 \end_layout
19379
19380 \begin_layout Subsection
19381 Registers usage
19382 \end_layout
19383
19384 \begin_layout Standard
19385 Unless the called function is declared as 
19386 \family typewriter
19387 _naked
19388 \family default
19389
19390 \begin_inset LatexCommand index
19391 name "naked"
19392
19393 \end_inset
19394
19395 , or the -
19396 \begin_inset ERT
19397 status collapsed
19398
19399 \begin_layout Standard
19400
19401
19402 \backslash
19403 /
19404 \end_layout
19405
19406 \end_inset
19407
19408 -callee-saves
19409 \begin_inset LatexCommand index
19410 name "-\\/-callee-saves"
19411
19412 \end_inset
19413
19414 /-
19415 \begin_inset ERT
19416 status collapsed
19417
19418 \begin_layout Standard
19419
19420
19421 \backslash
19422 /
19423 \end_layout
19424
19425 \end_inset
19426
19427 -all-callee-saves command line option or the corresponding callee_saves
19428  pragma are used, the caller will save the registers (
19429 \emph on
19430 R0-R7
19431 \emph default
19432 ) around the call, so the called function can destroy they content freely.
19433 \end_layout
19434
19435 \begin_layout Standard
19436 If the called function is not declared as 
19437 \family typewriter
19438 _naked
19439 \family default
19440 , the caller will swap register banks around the call, if caller and callee
19441  use different register banks (having them defined by the 
19442 \family typewriter
19443 _using
19444 \family default
19445  modifier).
19446  
19447 \end_layout
19448
19449 \begin_layout Standard
19450 The called function can also use 
19451 \emph on
19452 DPL
19453 \emph default
19454
19455 \emph on
19456 DPH
19457 \emph default
19458
19459 \emph on
19460 B
19461 \emph default
19462  and 
19463 \emph on
19464 ACC
19465 \emph default
19466  observing that they are used for parameter/return value passing.
19467 \end_layout
19468
19469 \begin_layout Subsection
19470 Assembler Routine (non-reentrant)
19471 \end_layout
19472
19473 \begin_layout Standard
19474 In the following example
19475 \begin_inset LatexCommand index
19476 name "reentrant"
19477
19478 \end_inset
19479
19480
19481 \begin_inset LatexCommand index
19482 name "Assembler routines (non-reentrant)"
19483
19484 \end_inset
19485
19486  the function c_func calls an assembler routine asm_func, which takes two
19487  parameters
19488 \begin_inset LatexCommand index
19489 name "function parameter"
19490
19491 \end_inset
19492
19493 .
19494 \end_layout
19495
19496 \begin_layout Verse
19497
19498 \family typewriter
19499 extern int asm_func(unsigned char, unsigned char);
19500 \newline
19501
19502 \newline
19503 int c_func (unsigned char
19504  i, unsigned char j)
19505 \newline
19506 {
19507 \newline
19508 \InsetSpace ~
19509 \InsetSpace ~
19510 \InsetSpace ~
19511 \InsetSpace ~
19512 return asm_func(i,j);
19513 \newline
19514 }
19515 \newline
19516
19517 \newline
19518 int main()
19519 \newline
19520 {
19521 \newline
19522 \InsetSpace ~
19523 \InsetSpace ~
19524 \InsetSpace ~
19525 \InsetSpace ~
19526 return c_func(10,9);
19527 \newline
19528 }
19529 \end_layout
19530
19531 \begin_layout Standard
19532 The corresponding assembler function is:
19533 \end_layout
19534
19535 \begin_layout Verse
19536
19537 \family typewriter
19538 .globl _asm_func_PARM_2 
19539 \newline
19540 \InsetSpace ~
19541 \InsetSpace ~
19542 \InsetSpace ~
19543 \InsetSpace ~
19544 \InsetSpace ~
19545 \InsetSpace ~
19546 \InsetSpace ~
19547 \InsetSpace ~
19548 .globl _asm_func 
19549 \newline
19550 \InsetSpace ~
19551 \InsetSpace ~
19552 \InsetSpace ~
19553 \InsetSpace ~
19554 \InsetSpace ~
19555 \InsetSpace ~
19556 \InsetSpace ~
19557 \InsetSpace ~
19558 .area OSEG 
19559 \newline
19560 _asm_func_PARM_2:
19561 \newline
19562 \InsetSpace ~
19563 \InsetSpace ~
19564 \InsetSpace ~
19565 \InsetSpace ~
19566 \InsetSpace ~
19567 \InsetSpace ~
19568 \InsetSpace ~
19569 \InsetSpace ~
19570 .ds   
19571  1 
19572 \newline
19573 \InsetSpace ~
19574 \InsetSpace ~
19575 \InsetSpace ~
19576 \InsetSpace ~
19577 \InsetSpace ~
19578 \InsetSpace ~
19579 \InsetSpace ~
19580 \InsetSpace ~
19581 .area CSEG 
19582 \newline
19583 _asm_func: 
19584 \newline
19585 \InsetSpace ~
19586 \InsetSpace ~
19587 \InsetSpace ~
19588 \InsetSpace ~
19589 \InsetSpace ~
19590 \InsetSpace ~
19591 \InsetSpace ~
19592 \InsetSpace ~
19593 mov\InsetSpace ~
19594 \InsetSpace ~
19595 \InsetSpace ~
19596 \InsetSpace ~
19597 a,dpl 
19598 \newline
19599 \InsetSpace ~
19600 \InsetSpace ~
19601 \InsetSpace ~
19602 \InsetSpace ~
19603 \InsetSpace ~
19604 \InsetSpace ~
19605 \InsetSpace ~
19606 \InsetSpace ~
19607 add\InsetSpace ~
19608 \InsetSpace ~
19609 \InsetSpace ~
19610 \InsetSpace ~
19611 a,_asm_func_PARM_2 
19612 \newline
19613 \InsetSpace ~
19614 \InsetSpace ~
19615 \InsetSpace ~
19616 \InsetSpace ~
19617 \InsetSpace ~
19618 \InsetSpace ~
19619 \InsetSpace ~
19620 \InsetSpace ~
19621 mov\InsetSpace ~
19622 \InsetSpace ~
19623 \InsetSpace ~
19624 \InsetSpace ~
19625 dpl,a 
19626 \newline
19627 \InsetSpace ~
19628 \InsetSpace ~
19629 \InsetSpace ~
19630 \InsetSpace ~
19631 \InsetSpace ~
19632 \InsetSpace ~
19633 \InsetSpace ~
19634 \InsetSpace ~
19635 mov\InsetSpace ~
19636 \InsetSpace ~
19637 \InsetSpace ~
19638 \InsetSpace ~
19639 dph
19640 \begin_inset LatexCommand index
19641 name "DPTR, DPH, DPL"
19642
19643 \end_inset
19644
19645 ,#0x00 
19646 \newline
19647 \InsetSpace ~
19648 \InsetSpace ~
19649 \InsetSpace ~
19650 \InsetSpace ~
19651 \InsetSpace ~
19652 \InsetSpace ~
19653 \InsetSpace ~
19654 \InsetSpace ~
19655 ret
19656 \end_layout
19657
19658 \begin_layout Standard
19659 The parameter naming convention is _<function_name>_PARM_<n>, where n is
19660  the parameter number starting from 1, and counting from the left.
19661  The first parameter is passed in 
19662 \emph on
19663 DPH
19664 \emph default
19665
19666 \emph on
19667 DPL
19668 \emph default
19669
19670 \emph on
19671 B
19672 \emph default
19673  and 
19674 \emph on
19675 ACC
19676 \emph default
19677  according to the description above.
19678  The variable name for the second parameter will be _<function_name>_PARM_2.
19679 \newline
19680
19681 \newline
19682 Assem
19683 ble the assembler routine with the following command:
19684 \newline
19685
19686 \newline
19687
19688 \family sans
19689 \series bold
19690 asx8051 -losg asmfunc.asm
19691 \newline
19692
19693 \newline
19694
19695 \family default
19696 \series default
19697 Then compile and link the assembler routine to the C source file with the
19698  following command:
19699 \newline
19700
19701 \newline
19702
19703 \family sans
19704 \series bold
19705 sdcc cfunc.c asmfunc.rel
19706 \end_layout
19707
19708 \begin_layout Subsection
19709 Assembler Routine (reentrant)
19710 \end_layout
19711
19712 \begin_layout Standard
19713 In this case
19714 \begin_inset LatexCommand index
19715 name "reentrant"
19716
19717 \end_inset
19718
19719
19720 \begin_inset LatexCommand index
19721 name "Assembler routines (reentrant)"
19722
19723 \end_inset
19724
19725  the second parameter
19726 \begin_inset LatexCommand index
19727 name "function parameter"
19728
19729 \end_inset
19730
19731  onwards will be passed on the stack, the parameters are pushed from right
19732  to left i.e.
19733  before the call the second leftmost parameter will be on the top of the
19734  stack (the leftmost parameter is passed in registers).
19735  Here is an example:
19736 \end_layout
19737
19738 \begin_layout Verse
19739
19740 \family typewriter
19741 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
19742 \newline
19743
19744 \newline
19745 int
19746  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
19747 \newline
19748 {
19749  
19750 \newline
19751 \InsetSpace ~
19752 \InsetSpace ~
19753 \InsetSpace ~
19754 \InsetSpace ~
19755 return asm_func(i,j,k); 
19756 \newline
19757
19758 \newline
19759
19760 \newline
19761 int main() 
19762 \newline
19763
19764 \newline
19765 \InsetSpace ~
19766 \InsetSpace ~
19767 \InsetSpace ~
19768 \InsetSpace ~
19769 return c_func(10,9,8); 
19770 \newline
19771 }
19772 \end_layout
19773
19774 \begin_layout Standard
19775 The corresponding (unoptimized) assembler routine is:
19776 \end_layout
19777
19778 \begin_layout Verse
19779
19780 \family typewriter
19781 .globl _asm_func 
19782 \newline
19783 _asm_func: 
19784 \newline
19785 \InsetSpace ~
19786 \InsetSpace ~
19787 \InsetSpace ~
19788 \InsetSpace ~
19789 push\InsetSpace ~
19790 _bp 
19791 \newline
19792 \InsetSpace ~
19793 \InsetSpace ~
19794 \InsetSpace ~
19795 \InsetSpace ~
19796 mov\InsetSpace ~
19797 \InsetSpace ~
19798 _bp,sp\InsetSpace ~
19799 \InsetSpace ~
19800 \InsetSpace ~
19801 \InsetSpace ~
19802 \InsetSpace ~
19803 \InsetSpace ~
19804 ;stack contains: _bp, return
19805  address, second parameter, third parameter
19806 \newline
19807 \InsetSpace ~
19808 \InsetSpace ~
19809 \InsetSpace ~
19810 \InsetSpace ~
19811 mov\InsetSpace ~
19812 \InsetSpace ~
19813 r2,dpl
19814 \newline
19815 \InsetSpace ~
19816 \InsetSpace ~
19817 \InsetSpace ~
19818 \InsetSpace ~
19819 mov\InsetSpace ~
19820 \InsetSpace ~
19821 a,_bp
19822 \newline
19823 \InsetSpace ~
19824 \InsetSpace ~
19825 \InsetSpace ~
19826 \InsetSpace ~
19827 add\InsetSpace ~
19828 \InsetSpace ~
19829 a,#0xfd\InsetSpace ~
19830 \InsetSpace ~
19831 \InsetSpace ~
19832 \InsetSpace ~
19833 \InsetSpace ~
19834 ;calculate
19835  pointer to the second parameter
19836 \newline
19837 \InsetSpace ~
19838 \InsetSpace ~
19839 \InsetSpace ~
19840 \InsetSpace ~
19841 mov\InsetSpace ~
19842 \InsetSpace ~
19843 r0,a 
19844 \newline
19845 \InsetSpace ~
19846 \InsetSpace ~
19847 \InsetSpace ~
19848 \InsetSpace ~
19849 mov\InsetSpace ~
19850 \InsetSpace ~
19851 a,_bp 
19852 \newline
19853 \InsetSpace ~
19854 \InsetSpace ~
19855 \InsetSpace ~
19856 \InsetSpace ~
19857 add\InsetSpace ~
19858 \InsetSpace ~
19859 a,#0xfc\InsetSpace ~
19860 \InsetSpace ~
19861 \InsetSpace ~
19862 \InsetSpace ~
19863 \InsetSpace ~
19864 ;calculate pointer
19865  to the rightmost parameter
19866 \newline
19867 \InsetSpace ~
19868 \InsetSpace ~
19869 \InsetSpace ~
19870 \InsetSpace ~
19871 mov\InsetSpace ~
19872 \InsetSpace ~
19873 r1,a 
19874 \newline
19875 \InsetSpace ~
19876 \InsetSpace ~
19877 \InsetSpace ~
19878 \InsetSpace ~
19879 mov\InsetSpace ~
19880 \InsetSpace ~
19881 a,@r0
19882 \newline
19883 \InsetSpace ~
19884 \InsetSpace ~
19885 \InsetSpace ~
19886 \InsetSpace ~
19887 add\InsetSpace ~
19888 \InsetSpace ~
19889 a,@r1
19890 \newline
19891 \InsetSpace ~
19892 \InsetSpace ~
19893 \InsetSpace ~
19894 \InsetSpace ~
19895 add\InsetSpace ~
19896 \InsetSpace ~
19897 a,r2\InsetSpace ~
19898 \InsetSpace ~
19899 \InsetSpace ~
19900 \InsetSpace ~
19901 \InsetSpace ~
19902 \InsetSpace ~
19903 \InsetSpace ~
19904 \InsetSpace ~
19905 ;calculate the
19906  result (= sum of all three parameters)
19907 \newline
19908 \InsetSpace ~
19909 \InsetSpace ~
19910 \InsetSpace ~
19911 \InsetSpace ~
19912 mov\InsetSpace ~
19913 \InsetSpace ~
19914 dpl,a\InsetSpace ~
19915 \InsetSpace ~
19916 \InsetSpace ~
19917 \InsetSpace ~
19918 \InsetSpace ~
19919 \InsetSpace ~
19920 \InsetSpace ~
19921 ;return value goes into dptr
19922  (cast into int)
19923 \newline
19924 \InsetSpace ~
19925 \InsetSpace ~
19926 \InsetSpace ~
19927 \InsetSpace ~
19928 mov\InsetSpace ~
19929 \InsetSpace ~
19930 dph,#0x00 
19931 \newline
19932 \InsetSpace ~
19933 \InsetSpace ~
19934 \InsetSpace ~
19935 \InsetSpace ~
19936 mov\InsetSpace ~
19937 \InsetSpace ~
19938 sp,_bp 
19939 \newline
19940 \InsetSpace ~
19941 \InsetSpace ~
19942 \InsetSpace ~
19943 \InsetSpace ~
19944 pop\InsetSpace ~
19945 \InsetSpace ~
19946 _bp 
19947 \newline
19948 \InsetSpace ~
19949 \InsetSpace ~
19950 \InsetSpace ~
19951 \InsetSpace ~
19952 ret
19953 \end_layout
19954
19955 \begin_layout Standard
19956 The compiling and linking procedure remains the same, however note the extra
19957  entry & exit linkage required for the assembler code, _bp is the stack
19958  frame pointer and is used to compute the offset into the stack for parameters
19959  and local variables.
19960 \begin_inset VSpace bigskip
19961 \end_inset
19962
19963
19964 \end_layout
19965
19966 \begin_layout Section
19967 int (16 bit)
19968 \begin_inset LatexCommand index
19969 name "int (16 bit)"
19970
19971 \end_inset
19972
19973  and long (32 bit)
19974 \begin_inset LatexCommand index
19975 name "long (32 bit)"
19976
19977 \end_inset
19978
19979  Support
19980 \end_layout
19981
19982 \begin_layout Standard
19983 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
19984  multiplication and modulus operations are implemented by support routines.
19985  These support routines are all developed in ANSI-C to facilitate porting
19986  to other MCUs, although some model specific assembler optimizations are
19987  used.
19988  The following files contain the described routines, all of them can be
19989  found in <installdir>/share/sdcc/lib.
19990 \newline
19991
19992 \end_layout
19993
19994 \begin_layout Standard
19995 \align center
19996 \begin_inset Tabular
19997 <lyxtabular version="3" rows="11" columns="2">
19998 <features>
19999 <column alignment="left" valignment="top" leftline="true" width="0">
20000 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
20001 <row topline="true" bottomline="true">
20002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20003 \begin_inset Text
20004
20005 \begin_layout Standard
20006
20007 \series bold
20008 Function
20009 \end_layout
20010
20011 \end_inset
20012 </cell>
20013 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20014 \begin_inset Text
20015
20016 \begin_layout Standard
20017
20018 \series bold
20019 Description
20020 \end_layout
20021
20022 \end_inset
20023 </cell>
20024 </row>
20025 <row topline="true">
20026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20027 \begin_inset Text
20028
20029 \begin_layout Standard
20030 _mulint.c 
20031 \end_layout
20032
20033 \end_inset
20034 </cell>
20035 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20036 \begin_inset Text
20037
20038 \begin_layout Standard
20039 16 bit multiplication
20040 \end_layout
20041
20042 \end_inset
20043 </cell>
20044 </row>
20045 <row topline="true">
20046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20047 \begin_inset Text
20048
20049 \begin_layout Standard
20050 _divsint.c 
20051 \end_layout
20052
20053 \end_inset
20054 </cell>
20055 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20056 \begin_inset Text
20057
20058 \begin_layout Standard
20059  signed 16 bit division (calls _divuint)
20060 \end_layout
20061
20062 \end_inset
20063 </cell>
20064 </row>
20065 <row topline="true">
20066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20067 \begin_inset Text
20068
20069 \begin_layout Standard
20070 _divuint.c 
20071 \end_layout
20072
20073 \end_inset
20074 </cell>
20075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20076 \begin_inset Text
20077
20078 \begin_layout Standard
20079  unsigned 16 bit division
20080 \end_layout
20081
20082 \end_inset
20083 </cell>
20084 </row>
20085 <row topline="true">
20086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20087 \begin_inset Text
20088
20089 \begin_layout Standard
20090 _modsint.c
20091 \end_layout
20092
20093 \end_inset
20094 </cell>
20095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20096 \begin_inset Text
20097
20098 \begin_layout Standard
20099 signed 16 bit modulus (calls _moduint)
20100 \end_layout
20101
20102 \end_inset
20103 </cell>
20104 </row>
20105 <row topline="true">
20106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20107 \begin_inset Text
20108
20109 \begin_layout Standard
20110 _moduint.c
20111 \end_layout
20112
20113 \end_inset
20114 </cell>
20115 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20116 \begin_inset Text
20117
20118 \begin_layout Standard
20119 unsigned 16 bit modulus
20120 \end_layout
20121
20122 \end_inset
20123 </cell>
20124 </row>
20125 <row topline="true">
20126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20127 \begin_inset Text
20128
20129 \begin_layout Standard
20130 _mullong.c
20131 \end_layout
20132
20133 \end_inset
20134 </cell>
20135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20136 \begin_inset Text
20137
20138 \begin_layout Standard
20139 32 bit multiplication
20140 \end_layout
20141
20142 \end_inset
20143 </cell>
20144 </row>
20145 <row topline="true">
20146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20147 \begin_inset Text
20148
20149 \begin_layout Standard
20150 _divslong.c 
20151 \end_layout
20152
20153 \end_inset
20154 </cell>
20155 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20156 \begin_inset Text
20157
20158 \begin_layout Standard
20159  signed 32 division (calls _divulong)
20160 \end_layout
20161
20162 \end_inset
20163 </cell>
20164 </row>
20165 <row topline="true">
20166 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20167 \begin_inset Text
20168
20169 \begin_layout Standard
20170 _divulong.c 
20171 \end_layout
20172
20173 \end_inset
20174 </cell>
20175 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20176 \begin_inset Text
20177
20178 \begin_layout Standard
20179 unsigned 32 division
20180 \end_layout
20181
20182 \end_inset
20183 </cell>
20184 </row>
20185 <row topline="true">
20186 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20187 \begin_inset Text
20188
20189 \begin_layout Standard
20190 _modslong.c
20191 \end_layout
20192
20193 \end_inset
20194 </cell>
20195 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20196 \begin_inset Text
20197
20198 \begin_layout Standard
20199  signed 32 bit modulus (calls _modulong)
20200 \end_layout
20201
20202 \end_inset
20203 </cell>
20204 </row>
20205 <row topline="true" bottomline="true">
20206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20207 \begin_inset Text
20208
20209 \begin_layout Standard
20210 _modulong.c
20211 \end_layout
20212
20213 \end_inset
20214 </cell>
20215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20216 \begin_inset Text
20217
20218 \begin_layout Standard
20219 unsigned 32 bit modulus
20220 \end_layout
20221
20222 \end_inset
20223 </cell>
20224 </row>
20225 </lyxtabular>
20226
20227 \end_inset
20228
20229
20230 \newline
20231
20232 \end_layout
20233
20234 \begin_layout Standard
20235 Since they are compiled as 
20236 \emph on
20237 non-reentrant
20238 \emph default
20239
20240 \begin_inset LatexCommand index
20241 name "reentrant"
20242
20243 \end_inset
20244
20245 , interrupt
20246 \begin_inset LatexCommand index
20247 name "interrupt"
20248
20249 \end_inset
20250
20251  service routines should not do any of the above operations.
20252  If this is unavoidable then the above routines will need to be compiled
20253  with the 
20254 \emph on
20255 -
20256 \begin_inset ERT
20257 status collapsed
20258
20259 \begin_layout Standard
20260
20261
20262 \backslash
20263 /
20264 \end_layout
20265
20266 \end_inset
20267
20268 -stack-auto
20269 \begin_inset LatexCommand index
20270 name "-\\/-stack-auto"
20271
20272 \end_inset
20273
20274
20275 \emph default
20276  option, after which the source program will have to be compiled with 
20277 \emph on
20278 -
20279 \begin_inset ERT
20280 status collapsed
20281
20282 \begin_layout Standard
20283
20284
20285 \backslash
20286 /
20287 \end_layout
20288
20289 \end_inset
20290
20291 -int-long-reent
20292 \begin_inset LatexCommand index
20293 name "-\\/-int-long-reent"
20294
20295 \end_inset
20296
20297
20298 \emph default
20299  option.
20300  Notice that you don't have to call these routines directly.
20301  The compiler will use them automatically every time an integer operation
20302  is required.
20303 \end_layout
20304
20305 \begin_layout Section
20306 Floating Point Support
20307 \begin_inset LatexCommand index
20308 name "Floating point support"
20309
20310 \end_inset
20311
20312
20313 \end_layout
20314
20315 \begin_layout Standard
20316 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
20317  The floating point support routines are derived from gcc's floatlib.c and
20318  consist of the following routines:
20319 \newline
20320
20321 \end_layout
20322
20323 \begin_layout Standard
20324 \align center
20325
20326 \size footnotesize
20327 \begin_inset Tabular
20328 <lyxtabular version="3" rows="17" columns="2">
20329 <features>
20330 <column alignment="left" valignment="top" leftline="true" width="0">
20331 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
20332 <row topline="true" bottomline="true">
20333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20334 \begin_inset Text
20335
20336 \begin_layout Standard
20337
20338 \family roman
20339 \series medium
20340 \shape up
20341 \size normal
20342 \emph off
20343 \bar no
20344 \noun off
20345 \color none
20346 Function 
20347 \end_layout
20348
20349 \end_inset
20350 </cell>
20351 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20352 \begin_inset Text
20353
20354 \begin_layout Standard
20355 Description
20356 \end_layout
20357
20358 \end_inset
20359 </cell>
20360 </row>
20361 <row topline="true">
20362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20363 \begin_inset Text
20364
20365 \begin_layout Standard
20366
20367 \family roman
20368 \series medium
20369 \shape up
20370 \size normal
20371 \emph off
20372 \bar no
20373 \noun off
20374 \color none
20375 _fsadd.c
20376 \end_layout
20377
20378 \end_inset
20379 </cell>
20380 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20381 \begin_inset Text
20382
20383 \begin_layout Standard
20384
20385 \family roman
20386 \series medium
20387 \shape up
20388 \size normal
20389 \emph off
20390 \bar no
20391 \noun off
20392 \color none
20393 add floating point numbers
20394 \end_layout
20395
20396 \end_inset
20397 </cell>
20398 </row>
20399 <row topline="true">
20400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20401 \begin_inset Text
20402
20403 \begin_layout Standard
20404
20405 \family roman
20406 \series medium
20407 \shape up
20408 \size normal
20409 \emph off
20410 \bar no
20411 \noun off
20412 \color none
20413 _fssub.c 
20414 \end_layout
20415
20416 \end_inset
20417 </cell>
20418 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20419 \begin_inset Text
20420
20421 \begin_layout Standard
20422
20423 \family roman
20424 \series medium
20425 \shape up
20426 \size normal
20427 \emph off
20428 \bar no
20429 \noun off
20430 \color none
20431 subtract floating point numbers 
20432 \end_layout
20433
20434 \end_inset
20435 </cell>
20436 </row>
20437 <row topline="true">
20438 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20439 \begin_inset Text
20440
20441 \begin_layout Standard
20442
20443 \family roman
20444 \series medium
20445 \shape up
20446 \size normal
20447 \emph off
20448 \bar no
20449 \noun off
20450 \color none
20451 _fsdiv.c 
20452 \end_layout
20453
20454 \end_inset
20455 </cell>
20456 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20457 \begin_inset Text
20458
20459 \begin_layout Standard
20460
20461 \family roman
20462 \series medium
20463 \shape up
20464 \size normal
20465 \emph off
20466 \bar no
20467 \noun off
20468 \color none
20469 divide floating point numbers 
20470 \end_layout
20471
20472 \end_inset
20473 </cell>
20474 </row>
20475 <row topline="true">
20476 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20477 \begin_inset Text
20478
20479 \begin_layout Standard
20480
20481 \family roman
20482 \series medium
20483 \shape up
20484 \size normal
20485 \emph off
20486 \bar no
20487 \noun off
20488 \color none
20489 _fsmul.c 
20490 \end_layout
20491
20492 \end_inset
20493 </cell>
20494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20495 \begin_inset Text
20496
20497 \begin_layout Standard
20498
20499 \family roman
20500 \series medium
20501 \shape up
20502 \size normal
20503 \emph off
20504 \bar no
20505 \noun off
20506 \color none
20507 multiply floating point numbers 
20508 \end_layout
20509
20510 \end_inset
20511 </cell>
20512 </row>
20513 <row topline="true">
20514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20515 \begin_inset Text
20516
20517 \begin_layout Standard
20518
20519 \family roman
20520 \series medium
20521 \shape up
20522 \size normal
20523 \emph off
20524 \bar no
20525 \noun off
20526 \color none
20527 _fs2uchar.c
20528 \end_layout
20529
20530 \end_inset
20531 </cell>
20532 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20533 \begin_inset Text
20534
20535 \begin_layout Standard
20536
20537 \family roman
20538 \series medium
20539 \shape up
20540 \size normal
20541 \emph off
20542 \bar no
20543 \noun off
20544 \color none
20545 convert floating point to unsigned char
20546 \end_layout
20547
20548 \end_inset
20549 </cell>
20550 </row>
20551 <row topline="true">
20552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20553 \begin_inset Text
20554
20555 \begin_layout Standard
20556
20557 \family roman
20558 \series medium
20559 \shape up
20560 \size normal
20561 \emph off
20562 \bar no
20563 \noun off
20564 \color none
20565 _fs2char.c
20566 \end_layout
20567
20568 \end_inset
20569 </cell>
20570 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20571 \begin_inset Text
20572
20573 \begin_layout Standard
20574
20575 \family roman
20576 \series medium
20577 \shape up
20578 \size normal
20579 \emph off
20580 \bar no
20581 \noun off
20582 \color none
20583 convert floating point to signed char
20584 \end_layout
20585
20586 \end_inset
20587 </cell>
20588 </row>
20589 <row topline="true">
20590 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20591 \begin_inset Text
20592
20593 \begin_layout Standard
20594
20595 \family roman
20596 \series medium
20597 \shape up
20598 \size normal
20599 \emph off
20600 \bar no
20601 \noun off
20602 \color none
20603 _fs2uint.c
20604 \end_layout
20605
20606 \end_inset
20607 </cell>
20608 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20609 \begin_inset Text
20610
20611 \begin_layout Standard
20612
20613 \family roman
20614 \series medium
20615 \shape up
20616 \size normal
20617 \emph off
20618 \bar no
20619 \noun off
20620 \color none
20621 convert floating point to unsigned int
20622 \end_layout
20623
20624 \end_inset
20625 </cell>
20626 </row>
20627 <row topline="true">
20628 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20629 \begin_inset Text
20630
20631 \begin_layout Standard
20632
20633 \family roman
20634 \series medium
20635 \shape up
20636 \size normal
20637 \emph off
20638 \bar no
20639 \noun off
20640 \color none
20641 _fs2int.c
20642 \end_layout
20643
20644 \end_inset
20645 </cell>
20646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20647 \begin_inset Text
20648
20649 \begin_layout Standard
20650
20651 \family roman
20652 \series medium
20653 \shape up
20654 \size normal
20655 \emph off
20656 \bar no
20657 \noun off
20658 \color none
20659 convert floating point to signed int
20660 \end_layout
20661
20662 \end_inset
20663 </cell>
20664 </row>
20665 <row topline="true">
20666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20667 \begin_inset Text
20668
20669 \begin_layout Standard
20670
20671 \family roman
20672 \series medium
20673 \shape up
20674 \size normal
20675 \emph off
20676 \bar no
20677 \noun off
20678 \color none
20679 _fs2ulong.
20680 \family default
20681 \series default
20682 \shape default
20683 \size default
20684 \emph default
20685 \bar default
20686 \noun default
20687 c
20688 \end_layout
20689
20690 \end_inset
20691 </cell>
20692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20693 \begin_inset Text
20694
20695 \begin_layout Standard
20696
20697 \family roman
20698 \series medium
20699 \shape up
20700 \size normal
20701 \emph off
20702 \bar no
20703 \noun off
20704 \color none
20705 convert floating point to unsigned long
20706 \end_layout
20707
20708 \end_inset
20709 </cell>
20710 </row>
20711 <row topline="true">
20712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20713 \begin_inset Text
20714
20715 \begin_layout Standard
20716
20717 \family roman
20718 \series medium
20719 \shape up
20720 \size normal
20721 \emph off
20722 \bar no
20723 \noun off
20724 \color none
20725 _fs2long.c
20726 \end_layout
20727
20728 \end_inset
20729 </cell>
20730 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20731 \begin_inset Text
20732
20733 \begin_layout Standard
20734
20735 \family roman
20736 \series medium
20737 \shape up
20738 \size normal
20739 \emph off
20740 \bar no
20741 \noun off
20742 \color none
20743 convert floating point to signed long
20744 \end_layout
20745
20746 \end_inset
20747 </cell>
20748 </row>
20749 <row topline="true">
20750 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20751 \begin_inset Text
20752
20753 \begin_layout Standard
20754
20755 \family roman
20756 \series medium
20757 \shape up
20758 \size normal
20759 \emph off
20760 \bar no
20761 \noun off
20762 \color none
20763 _uchar2fs.c
20764 \end_layout
20765
20766 \end_inset
20767 </cell>
20768 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20769 \begin_inset Text
20770
20771 \begin_layout Standard
20772
20773 \family roman
20774 \series medium
20775 \shape up
20776 \size normal
20777 \emph off
20778 \bar no
20779 \noun off
20780 \color none
20781 convert unsigned char to floating point
20782 \end_layout
20783
20784 \end_inset
20785 </cell>
20786 </row>
20787 <row topline="true">
20788 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20789 \begin_inset Text
20790
20791 \begin_layout Standard
20792
20793 \family roman
20794 \series medium
20795 \shape up
20796 \size normal
20797 \emph off
20798 \bar no
20799 \noun off
20800 \color none
20801 _char2fs.c
20802 \end_layout
20803
20804 \end_inset
20805 </cell>
20806 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20807 \begin_inset Text
20808
20809 \begin_layout Standard
20810
20811 \family roman
20812 \series medium
20813 \shape up
20814 \size normal
20815 \emph off
20816 \bar no
20817 \noun off
20818 \color none
20819 convert char to floating point number
20820 \end_layout
20821
20822 \end_inset
20823 </cell>
20824 </row>
20825 <row topline="true">
20826 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20827 \begin_inset Text
20828
20829 \begin_layout Standard
20830
20831 \family roman
20832 \series medium
20833 \shape up
20834 \size normal
20835 \emph off
20836 \bar no
20837 \noun off
20838 \color none
20839 _uint2fs.c
20840 \end_layout
20841
20842 \end_inset
20843 </cell>
20844 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20845 \begin_inset Text
20846
20847 \begin_layout Standard
20848
20849 \family roman
20850 \series medium
20851 \shape up
20852 \size normal
20853 \emph off
20854 \bar no
20855 \noun off
20856 \color none
20857 convert unsigned int to floating point
20858 \end_layout
20859
20860 \end_inset
20861 </cell>
20862 </row>
20863 <row topline="true">
20864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20865 \begin_inset Text
20866
20867 \begin_layout Standard
20868
20869 \family roman
20870 \series medium
20871 \shape up
20872 \size normal
20873 \emph off
20874 \bar no
20875 \noun off
20876 \color none
20877 _int2fs.c
20878 \end_layout
20879
20880 \end_inset
20881 </cell>
20882 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20883 \begin_inset Text
20884
20885 \begin_layout Standard
20886
20887 \family roman
20888 \series medium
20889 \shape up
20890 \size normal
20891 \emph off
20892 \bar no
20893 \noun off
20894 \color none
20895 convert int to floating point numbers
20896 \end_layout
20897
20898 \end_inset
20899 </cell>
20900 </row>
20901 <row topline="true">
20902 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20903 \begin_inset Text
20904
20905 \begin_layout Standard
20906
20907 \family roman
20908 \series medium
20909 \shape up
20910 \size normal
20911 \emph off
20912 \bar no
20913 \noun off
20914 \color none
20915 _ulong2fs.c
20916 \end_layout
20917
20918 \end_inset
20919 </cell>
20920 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20921 \begin_inset Text
20922
20923 \begin_layout Standard
20924
20925 \family roman
20926 \series medium
20927 \shape up
20928 \size normal
20929 \emph off
20930 \bar no
20931 \noun off
20932 \color none
20933 convert unsigned long to floating point number
20934 \end_layout
20935
20936 \end_inset
20937 </cell>
20938 </row>
20939 <row topline="true" bottomline="true">
20940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20941 \begin_inset Text
20942
20943 \begin_layout Standard
20944
20945 \family roman
20946 \series medium
20947 \shape up
20948 \size normal
20949 \emph off
20950 \bar no
20951 \noun off
20952 \color none
20953 _long2fs.c
20954 \end_layout
20955
20956 \end_inset
20957 </cell>
20958 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20959 \begin_inset Text
20960
20961 \begin_layout Standard
20962
20963 \family roman
20964 \series medium
20965 \shape up
20966 \size normal
20967 \emph off
20968 \bar no
20969 \noun off
20970 \color none
20971 convert long to floating point number
20972 \end_layout
20973
20974 \end_inset
20975 </cell>
20976 </row>
20977 </lyxtabular>
20978
20979 \end_inset
20980
20981
20982 \newline
20983
20984 \end_layout
20985
20986 \begin_layout Standard
20987 These support routines are developed in ANSI-C so there is room for space
20988  and speed improvement
20989 \begin_inset Foot
20990 status open
20991
20992 \begin_layout Standard
20993 These floating point routines (
20994 \emph on
20995 not
20996 \emph default
20997  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
20998  
20999 \end_layout
21000
21001 \end_inset
21002
21003 .
21004  Note if all these routines are used simultaneously the data space might
21005  overflow.
21006  For serious floating point usage the large model might be needed.
21007  Also notice that you don't have to call this routines directly.
21008  The compiler will use them automatically every time a floating point operation
21009  is required.
21010 \begin_inset VSpace bigskip
21011 \end_inset
21012
21013
21014 \end_layout
21015
21016 \begin_layout Section
21017 Library Routines
21018 \begin_inset LatexCommand index
21019 name "Libraries"
21020
21021 \end_inset
21022
21023
21024 \end_layout
21025
21026 \begin_layout Standard
21027
21028 \emph on
21029 <pending: this is messy and incomplete - a little more information is in
21030  sdcc/doc/libdoc.txt
21031 \emph default
21032  >
21033 \end_layout
21034
21035 \begin_layout Subsection
21036 Compiler support routines (_gptrget, _mulint etc.)
21037 \end_layout
21038
21039 \begin_layout Subsection
21040 Stdclib functions (puts, printf, strcat etc.)
21041 \end_layout
21042
21043 \begin_layout Subsubsection
21044 <stdio.h>
21045 \end_layout
21046
21047 \begin_layout Paragraph
21048 getchar(), putchar()
21049 \end_layout
21050
21051 \begin_layout Standard
21052 \begin_inset LatexCommand index
21053 name "<stdio.h>"
21054
21055 \end_inset
21056
21057 As usual on embedded systems you have to provide your own 
21058 \family typewriter
21059 getchar()
21060 \begin_inset LatexCommand index
21061 name "getchar()"
21062
21063 \end_inset
21064
21065
21066 \family default
21067  and 
21068 \family typewriter
21069 putchar()
21070 \begin_inset LatexCommand index
21071 name "putchar()"
21072
21073 \end_inset
21074
21075
21076 \family default
21077  routines.
21078  SDCC does not know whether the system connects to a serial line with or
21079  without handshake, LCD, keyboard or other device.
21080  And whether a 
21081 \family typewriter
21082 lf
21083 \family default
21084  to 
21085 \family typewriter
21086 crlf
21087 \family default
21088  conversion within 
21089 \family typewriter
21090 putchar()
21091 \family default
21092  is intended.
21093  You'll find examples for serial routines f.e.
21094  in sdcc/device/lib.
21095  For the mcs51 this minimalistic polling 
21096 \family typewriter
21097 putchar()
21098 \family default
21099  routine might be a start:
21100 \end_layout
21101
21102 \begin_layout Verse
21103
21104 \family typewriter
21105 void putchar (char c) { 
21106 \newline
21107 \InsetSpace ~
21108 \InsetSpace ~
21109 \InsetSpace ~
21110 \InsetSpace ~
21111 while (!TI)\InsetSpace ~
21112 \InsetSpace ~
21113 \InsetSpace ~
21114  /* assumes UART is initialized */
21115 \newline
21116 \InsetSpace ~
21117 \InsetSpace ~
21118 \InsetSpace ~
21119 \InsetSpace ~
21120 \InsetSpace ~
21121 \InsetSpace ~
21122 \InsetSpace ~
21123 \InsetSpace ~
21124 ;
21125 \newline
21126 \InsetSpace ~
21127 \InsetSpace ~
21128 \InsetSpace ~
21129 \InsetSpace ~
21130 TI
21131  = 0;
21132 \newline
21133 \InsetSpace ~
21134 \InsetSpace ~
21135 \InsetSpace ~
21136 \InsetSpace ~
21137 SBUF = c;
21138 \newline
21139 }
21140 \end_layout
21141
21142 \begin_layout Paragraph
21143 printf()
21144 \end_layout
21145
21146 \begin_layout Standard
21147 The default 
21148 \family typewriter
21149 printf()
21150 \begin_inset LatexCommand index
21151 name "printf()"
21152
21153 \end_inset
21154
21155
21156 \family default
21157  implementation in 
21158 \family typewriter
21159 printf_large.c
21160 \family default
21161  does not support float
21162 \begin_inset LatexCommand index
21163 name "Floating point support"
21164
21165 \end_inset
21166
21167  (except on ds390), only <NO FLOAT>
21168 \begin_inset LatexCommand index
21169 name "<NO FLOAT>"
21170
21171 \end_inset
21172
21173
21174 \begin_inset LatexCommand index
21175 name "printf floating point support"
21176
21177 \end_inset
21178
21179  will be printed instead of the value.
21180  To enable floating point output, recompile it with the option 
21181 \emph on
21182 -
21183 \begin_inset ERT
21184 status collapsed
21185
21186 \begin_layout Standard
21187
21188
21189 \backslash
21190 /
21191 \end_layout
21192
21193 \end_inset
21194
21195 DUSE_FLOATS=1
21196 \begin_inset LatexCommand index
21197 name "USE\\_FLOATS"
21198
21199 \end_inset
21200
21201
21202 \emph default
21203  on the command line.
21204  Use 
21205 \emph on
21206 -
21207 \begin_inset ERT
21208 status open
21209
21210 \begin_layout Standard
21211
21212
21213 \backslash
21214 /
21215 \end_layout
21216
21217 \end_inset
21218
21219 -model-large
21220 \begin_inset LatexCommand index
21221 name "-\\/-model-large"
21222
21223 \end_inset
21224
21225
21226 \emph default
21227  for the mcs51 port, since this uses a lot of memory.
21228  To enable float support for the pic16 targets, see 
21229 \begin_inset LatexCommand ref
21230 reference "sub:pic16Libraries"
21231
21232 \end_inset
21233
21234 .
21235 \end_layout
21236
21237 \begin_layout Standard
21238 If you're short on code memory you might want to use 
21239 \family typewriter
21240 printf_small()
21241 \begin_inset LatexCommand index
21242 name "printf\\_small()"
21243
21244 \end_inset
21245
21246
21247 \family default
21248  
21249 \emph on
21250 instead
21251 \emph default
21252  of 
21253 \family typewriter
21254 printf().
21255
21256 \family default
21257  For the mcs51 there additionally are assembly versions 
21258 \family typewriter
21259 printf_tiny()
21260 \begin_inset LatexCommand index
21261 name "printf\\_tiny() (mcs51)"
21262
21263 \end_inset
21264
21265
21266 \family default
21267  (subset of printf using less than 270 bytes) and 
21268 \family typewriter
21269 printf_fast()
21270 \begin_inset LatexCommand index
21271 name "printf\\_fast() (mcs51)"
21272
21273 \end_inset
21274
21275
21276 \family default
21277  and 
21278 \family typewriter
21279 printf_fast_f()
21280 \begin_inset LatexCommand index
21281 name "printf\\_fast\\_f() (mcs51)"
21282
21283 \end_inset
21284
21285
21286 \family default
21287  (floating-point aware version of printf_fast) which should fit the requirements
21288  of many embedded systems (printf_fast() can be customized by unsetting
21289  #defines to 
21290 \emph on
21291 not
21292 \emph default
21293  support long variables and field widths).
21294  Be sure to use only one of these printf options within a project.
21295 \newline
21296
21297 \end_layout
21298
21299 \begin_layout Standard
21300 Feature matrix of different 
21301 \emph on
21302 printf
21303 \emph default
21304  options on mcs51.
21305 \end_layout
21306
21307 \begin_layout Standard
21308 \begin_inset Tabular
21309 <lyxtabular version="3" rows="14" columns="7">
21310 <features islongtable="true">
21311 <column alignment="left" valignment="middle" leftline="true" width="14col%">
21312 <column alignment="center" valignment="top" leftline="true" width="0">
21313 <column alignment="center" valignment="top" leftline="true" width="12col%">
21314 <column alignment="center" valignment="top" leftline="true" width="10col%">
21315 <column alignment="center" valignment="top" leftline="true" width="0">
21316 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
21317 <column alignment="center" valignment="top" rightline="true" width="0">
21318 <row topline="true" bottomline="true" endhead="true">
21319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21320 \begin_inset Text
21321
21322 \begin_layout Standard
21323
21324 \series bold
21325 \size large
21326 mcs51
21327 \end_layout
21328
21329 \end_inset
21330 </cell>
21331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21332 \begin_inset Text
21333
21334 \begin_layout Standard
21335 printf
21336 \begin_inset LatexCommand index
21337 name "printf()"
21338
21339 \end_inset
21340
21341
21342 \end_layout
21343
21344 \end_inset
21345 </cell>
21346 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21347 \begin_inset Text
21348
21349 \begin_layout Standard
21350 printf 
21351 \size scriptsize
21352 USE_FLOATS=1
21353 \end_layout
21354
21355 \end_inset
21356 </cell>
21357 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21358 \begin_inset Text
21359
21360 \begin_layout Standard
21361 printf_small
21362 \end_layout
21363
21364 \end_inset
21365 </cell>
21366 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21367 \begin_inset Text
21368
21369 \begin_layout Standard
21370 printf_fast
21371 \end_layout
21372
21373 \end_inset
21374 </cell>
21375 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21376 \begin_inset Text
21377
21378 \begin_layout Standard
21379 printf_fast_f
21380 \end_layout
21381
21382 \end_inset
21383 </cell>
21384 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21385 \begin_inset Text
21386
21387 \begin_layout Standard
21388 printf_tiny
21389 \end_layout
21390
21391 \end_inset
21392 </cell>
21393 </row>
21394 <row topline="true" endhead="true">
21395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21396 \begin_inset Text
21397
21398 \begin_layout Standard
21399 filename
21400 \end_layout
21401
21402 \end_inset
21403 </cell>
21404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21405 \begin_inset Text
21406
21407 \begin_layout Standard
21408
21409 \size scriptsize
21410 printf_large.c
21411 \end_layout
21412
21413 \end_inset
21414 </cell>
21415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21416 \begin_inset Text
21417
21418 \begin_layout Standard
21419
21420 \size scriptsize
21421 printf_large.c
21422 \end_layout
21423
21424 \end_inset
21425 </cell>
21426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21427 \begin_inset Text
21428
21429 \begin_layout Standard
21430
21431 \size scriptsize
21432 printfl.c
21433 \end_layout
21434
21435 \end_inset
21436 </cell>
21437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21438 \begin_inset Text
21439
21440 \begin_layout Standard
21441
21442 \size scriptsize
21443 printf_fast.c
21444 \end_layout
21445
21446 \end_inset
21447 </cell>
21448 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21449 \begin_inset Text
21450
21451 \begin_layout Standard
21452
21453 \size scriptsize
21454 printf_fast_f.c
21455 \end_layout
21456
21457 \end_inset
21458 </cell>
21459 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21460 \begin_inset Text
21461
21462 \begin_layout Standard
21463
21464 \size scriptsize
21465 printf_tiny.c
21466 \end_layout
21467
21468 \end_inset
21469 </cell>
21470 </row>
21471 <row topline="true" endhead="true">
21472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21473 \begin_inset Text
21474
21475 \begin_layout Standard
21476 \begin_inset Quotes sld
21477 \end_inset
21478
21479 Hello World
21480 \begin_inset Quotes srd
21481 \end_inset
21482
21483  size
21484 \end_layout
21485
21486 \begin_layout Standard
21487 small / large
21488 \end_layout
21489
21490 \end_inset
21491 </cell>
21492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21493 \begin_inset Text
21494
21495 \begin_layout Standard
21496 1.7k / 2.4k
21497 \end_layout
21498
21499 \end_inset
21500 </cell>
21501 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21502 \begin_inset Text
21503
21504 \begin_layout Standard
21505 4.3k / 5.6k
21506 \end_layout
21507
21508 \end_inset
21509 </cell>
21510 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21511 \begin_inset Text
21512
21513 \begin_layout Standard
21514 1.2k / 1.8k
21515 \end_layout
21516
21517 \end_inset
21518 </cell>
21519 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21520 \begin_inset Text
21521
21522 \begin_layout Standard
21523 1.3k / 1.3k
21524 \end_layout
21525
21526 \end_inset
21527 </cell>
21528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21529 \begin_inset Text
21530
21531 \begin_layout Standard
21532 1.9k / 1.9k
21533 \end_layout
21534
21535 \end_inset
21536 </cell>
21537 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21538 \begin_inset Text
21539
21540 \begin_layout Standard
21541 0.44k / 0.44k
21542 \end_layout
21543
21544 \end_inset
21545 </cell>
21546 </row>
21547 <row topline="true" endhead="true">
21548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21549 \begin_inset Text
21550
21551 \begin_layout Standard
21552 code size
21553 \end_layout
21554
21555 \begin_layout Standard
21556 small / large
21557 \end_layout
21558
21559 \end_inset
21560 </cell>
21561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21562 \begin_inset Text
21563
21564 \begin_layout Standard
21565 1.4k / 2.0k
21566 \end_layout
21567
21568 \end_inset
21569 </cell>
21570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21571 \begin_inset Text
21572
21573 \begin_layout Standard
21574 2.8k / 3.7k
21575 \end_layout
21576
21577 \end_inset
21578 </cell>
21579 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21580 \begin_inset Text
21581
21582 \begin_layout Standard
21583 0.45k / 0.47k (+ _ltoa)
21584 \end_layout
21585
21586 \end_inset
21587 </cell>
21588 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21589 \begin_inset Text
21590
21591 \begin_layout Standard
21592 1.2k / 1.2k
21593 \end_layout
21594
21595 \end_inset
21596 </cell>
21597 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21598 \begin_inset Text
21599
21600 \begin_layout Standard
21601 1.6k / 1.6k
21602 \end_layout
21603
21604 \end_inset
21605 </cell>
21606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21607 \begin_inset Text
21608
21609 \begin_layout Standard
21610 0.26k / 0.26k
21611 \end_layout
21612
21613 \end_inset
21614 </cell>
21615 </row>
21616 <row topline="true">
21617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21618 \begin_inset Text
21619
21620 \begin_layout Standard
21621 formats
21622 \end_layout
21623
21624 \end_inset
21625 </cell>
21626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21627 \begin_inset Text
21628
21629 \begin_layout Standard
21630 cdi
21631 \emph on
21632 o
21633 \emph default
21634 psux
21635 \end_layout
21636
21637 \end_inset
21638 </cell>
21639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21640 \begin_inset Text
21641
21642 \begin_layout Standard
21643
21644 \family roman
21645 \series medium
21646 \shape up
21647 \size normal
21648 \emph off
21649 \bar no
21650 \noun off
21651 \color none
21652 cd
21653 \family default
21654 \series default
21655 \shape default
21656 \size default
21657 \emph default
21658 \bar default
21659 \noun default
21660 f
21661 \family roman
21662 \series medium
21663 \shape up
21664 \size normal
21665 \emph off
21666 \bar no
21667 \noun off
21668 i
21669 \family default
21670 \series default
21671 \shape default
21672 \size default
21673 \emph on
21674 \bar default
21675 \noun default
21676 o
21677 \family roman
21678 \series medium
21679 \shape up
21680 \size normal
21681 \emph off
21682 \bar no
21683 \noun off
21684 psux
21685 \end_layout
21686
21687 \end_inset
21688 </cell>
21689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21690 \begin_inset Text
21691
21692 \begin_layout Standard
21693 c
21694 \family roman
21695 \series medium
21696 \shape up
21697 \size normal
21698 \emph off
21699 \bar no
21700 \noun off
21701 \color none
21702 d
21703 \family default
21704 \series default
21705 \shape default
21706 \size default
21707 \emph on
21708 \bar default
21709 \noun default
21710 o
21711 \family roman
21712 \series medium
21713 \shape up
21714 \size normal
21715 \emph off
21716 \bar no
21717 \noun off
21718 s
21719 \family default
21720 \series default
21721 \shape default
21722 \size default
21723 \emph default
21724 \bar default
21725 \noun default
21726 x
21727 \end_layout
21728
21729 \end_inset
21730 </cell>
21731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21732 \begin_inset Text
21733
21734 \begin_layout Standard
21735 cdsux
21736 \end_layout
21737
21738 \end_inset
21739 </cell>
21740 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21741 \begin_inset Text
21742
21743 \begin_layout Standard
21744 cdfsux
21745 \end_layout
21746
21747 \end_inset
21748 </cell>
21749 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21750 \begin_inset Text
21751
21752 \begin_layout Standard
21753 cdsux
21754 \end_layout
21755
21756 \end_inset
21757 </cell>
21758 </row>
21759 <row topline="true">
21760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21761 \begin_inset Text
21762
21763 \begin_layout Standard
21764 long (32 bit) support
21765 \end_layout
21766
21767 \end_inset
21768 </cell>
21769 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21770 \begin_inset Text
21771
21772 \begin_layout Standard
21773 x
21774 \end_layout
21775
21776 \end_inset
21777 </cell>
21778 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21779 \begin_inset Text
21780
21781 \begin_layout Standard
21782 x
21783 \end_layout
21784
21785 \end_inset
21786 </cell>
21787 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21788 \begin_inset Text
21789
21790 \begin_layout Standard
21791 x
21792 \end_layout
21793
21794 \end_inset
21795 </cell>
21796 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21797 \begin_inset Text
21798
21799 \begin_layout Standard
21800 x
21801 \end_layout
21802
21803 \end_inset
21804 </cell>
21805 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21806 \begin_inset Text
21807
21808 \begin_layout Standard
21809
21810 \family roman
21811 \series medium
21812 \shape up
21813 \size normal
21814 \emph off
21815 \bar no
21816 \noun off
21817 \color none
21818 x
21819 \end_layout
21820
21821 \end_inset
21822 </cell>
21823 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21824 \begin_inset Text
21825
21826 \begin_layout Standard
21827 -
21828 \end_layout
21829
21830 \end_inset
21831 </cell>
21832 </row>
21833 <row topline="true">
21834 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21835 \begin_inset Text
21836
21837 \begin_layout Standard
21838 byte arguments on stack
21839 \end_layout
21840
21841 \end_inset
21842 </cell>
21843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21844 \begin_inset Text
21845
21846 \begin_layout Standard
21847 b
21848 \end_layout
21849
21850 \end_inset
21851 </cell>
21852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21853 \begin_inset Text
21854
21855 \begin_layout Standard
21856 b
21857 \end_layout
21858
21859 \end_inset
21860 </cell>
21861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21862 \begin_inset Text
21863
21864 \begin_layout Standard
21865 -
21866 \end_layout
21867
21868 \end_inset
21869 </cell>
21870 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21871 \begin_inset Text
21872
21873 \begin_layout Standard
21874 -
21875 \end_layout
21876
21877 \end_inset
21878 </cell>
21879 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21880 \begin_inset Text
21881
21882 \begin_layout Standard
21883 -
21884 \end_layout
21885
21886 \end_inset
21887 </cell>
21888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21889 \begin_inset Text
21890
21891 \begin_layout Standard
21892 -
21893 \end_layout
21894
21895 \end_inset
21896 </cell>
21897 </row>
21898 <row topline="true">
21899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21900 \begin_inset Text
21901
21902 \begin_layout Standard
21903 float format
21904 \begin_inset LatexCommand index
21905 name "Floating point support"
21906
21907 \end_inset
21908
21909
21910 \end_layout
21911
21912 \end_inset
21913 </cell>
21914 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21915 \begin_inset Text
21916
21917 \begin_layout Standard
21918 -
21919 \end_layout
21920
21921 \end_inset
21922 </cell>
21923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21924 \begin_inset Text
21925
21926 \begin_layout Standard
21927 %f
21928 \end_layout
21929
21930 \end_inset
21931 </cell>
21932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21933 \begin_inset Text
21934
21935 \begin_layout Standard
21936 -
21937 \end_layout
21938
21939 \end_inset
21940 </cell>
21941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21942 \begin_inset Text
21943
21944 \begin_layout Standard
21945 -
21946 \end_layout
21947
21948 \end_inset
21949 </cell>
21950 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21951 \begin_inset Text
21952
21953 \begin_layout Standard
21954 %f
21955 \begin_inset Foot
21956 status collapsed
21957
21958 \begin_layout Standard
21959 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
21960 \end_layout
21961
21962 \end_inset
21963
21964
21965 \end_layout
21966
21967 \end_inset
21968 </cell>
21969 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21970 \begin_inset Text
21971
21972 \begin_layout Standard
21973 -
21974 \end_layout
21975
21976 \end_inset
21977 </cell>
21978 </row>
21979 <row topline="true">
21980 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21981 \begin_inset Text
21982
21983 \begin_layout Standard
21984 float formats %e %g
21985 \end_layout
21986
21987 \end_inset
21988 </cell>
21989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21990 \begin_inset Text
21991
21992 \begin_layout Standard
21993 -
21994 \end_layout
21995
21996 \end_inset
21997 </cell>
21998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21999 \begin_inset Text
22000
22001 \begin_layout Standard
22002 -
22003 \end_layout
22004
22005 \end_inset
22006 </cell>
22007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22008 \begin_inset Text
22009
22010 \begin_layout Standard
22011 -
22012 \end_layout
22013
22014 \end_inset
22015 </cell>
22016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22017 \begin_inset Text
22018
22019 \begin_layout Standard
22020 -
22021 \end_layout
22022
22023 \end_inset
22024 </cell>
22025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22026 \begin_inset Text
22027
22028 \begin_layout Standard
22029 -
22030 \end_layout
22031
22032 \end_inset
22033 </cell>
22034 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22035 \begin_inset Text
22036
22037 \begin_layout Standard
22038 -
22039 \end_layout
22040
22041 \end_inset
22042 </cell>
22043 </row>
22044 <row topline="true" bottomline="true">
22045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22046 \begin_inset Text
22047
22048 \begin_layout Standard
22049 field width
22050 \end_layout
22051
22052 \end_inset
22053 </cell>
22054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22055 \begin_inset Text
22056
22057 \begin_layout Standard
22058 x
22059 \end_layout
22060
22061 \end_inset
22062 </cell>
22063 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22064 \begin_inset Text
22065
22066 \begin_layout Standard
22067 x
22068 \end_layout
22069
22070 \end_inset
22071 </cell>
22072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22073 \begin_inset Text
22074
22075 \begin_layout Standard
22076 -
22077 \end_layout
22078
22079 \end_inset
22080 </cell>
22081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22082 \begin_inset Text
22083
22084 \begin_layout Standard
22085 x
22086 \end_layout
22087
22088 \end_inset
22089 </cell>
22090 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22091 \begin_inset Text
22092
22093 \begin_layout Standard
22094 x
22095 \end_layout
22096
22097 \end_inset
22098 </cell>
22099 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22100 \begin_inset Text
22101
22102 \begin_layout Standard
22103 -
22104 \end_layout
22105
22106 \end_inset
22107 </cell>
22108 </row>
22109 <row bottomline="true">
22110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22111 \begin_inset Text
22112
22113 \begin_layout Standard
22114 string speed
22115 \begin_inset Foot
22116 status collapsed
22117
22118 \begin_layout Standard
22119 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
22120 \backslash
22121 r', '
22122 \backslash
22123 n'); standard 8051 @ 22.1184 MHz, empty putchar()
22124 \end_layout
22125
22126 \end_inset
22127
22128 ,
22129 \end_layout
22130
22131 \begin_layout Standard
22132 small / large
22133 \end_layout
22134
22135 \end_inset
22136 </cell>
22137 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22138 \begin_inset Text
22139
22140 \begin_layout Standard
22141 1.52 / 2.59 ms
22142 \end_layout
22143
22144 \end_inset
22145 </cell>
22146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22147 \begin_inset Text
22148
22149 \begin_layout Standard
22150 1.53 / 2.62 ms
22151 \end_layout
22152
22153 \end_inset
22154 </cell>
22155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22156 \begin_inset Text
22157
22158 \begin_layout Standard
22159 0.92 / 0.93 ms
22160 \end_layout
22161
22162 \end_inset
22163 </cell>
22164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22165 \begin_inset Text
22166
22167 \begin_layout Standard
22168 0.45 / 0.45 ms
22169 \end_layout
22170
22171 \end_inset
22172 </cell>
22173 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22174 \begin_inset Text
22175
22176 \begin_layout Standard
22177 0.46 / 0.46 ms
22178 \end_layout
22179
22180 \end_inset
22181 </cell>
22182 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22183 \begin_inset Text
22184
22185 \begin_layout Standard
22186 0.45 / 0.45 ms
22187 \end_layout
22188
22189 \end_inset
22190 </cell>
22191 </row>
22192 <row bottomline="true">
22193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22194 \begin_inset Text
22195
22196 \begin_layout Standard
22197 int speed
22198 \begin_inset Foot
22199 status collapsed
22200
22201 \begin_layout Standard
22202 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
22203  putchar()
22204 \end_layout
22205
22206 \end_inset
22207
22208 ,
22209 \end_layout
22210
22211 \begin_layout Standard
22212 small / large
22213 \end_layout
22214
22215 \end_inset
22216 </cell>
22217 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22218 \begin_inset Text
22219
22220 \begin_layout Standard
22221 3.01 / 3.61 ms
22222 \end_layout
22223
22224 \end_inset
22225 </cell>
22226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22227 \begin_inset Text
22228
22229 \begin_layout Standard
22230 3.01 / 3.61 ms
22231 \end_layout
22232
22233 \end_inset
22234 </cell>
22235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22236 \begin_inset Text
22237
22238 \begin_layout Standard
22239 3.51 / 18.13 ms
22240 \end_layout
22241
22242 \end_inset
22243 </cell>
22244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22245 \begin_inset Text
22246
22247 \begin_layout Standard
22248 0.22 / 0.22 ms
22249 \end_layout
22250
22251 \end_inset
22252 </cell>
22253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22254 \begin_inset Text
22255
22256 \begin_layout Standard
22257 0.23 / 0.23 ms
22258 \end_layout
22259
22260 \end_inset
22261 </cell>
22262 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22263 \begin_inset Text
22264
22265 \begin_layout Standard
22266 0.25 / 0.25 ms
22267 \begin_inset Foot
22268 status collapsed
22269
22270 \begin_layout Standard
22271 printf_tiny integer speed is data dependent, worst case is 0.33 ms
22272 \end_layout
22273
22274 \end_inset
22275
22276
22277 \end_layout
22278
22279 \end_inset
22280 </cell>
22281 </row>
22282 <row bottomline="true">
22283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22284 \begin_inset Text
22285
22286 \begin_layout Standard
22287 long speed
22288 \begin_inset Foot
22289 status collapsed
22290
22291 \begin_layout Standard
22292 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
22293  empty putchar()
22294 \end_layout
22295
22296 \end_inset
22297
22298 ,
22299 \end_layout
22300
22301 \begin_layout Standard
22302 small / large
22303 \end_layout
22304
22305 \end_inset
22306 </cell>
22307 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22308 \begin_inset Text
22309
22310 \begin_layout Standard
22311 5.37 / 6.31 ms
22312 \end_layout
22313
22314 \end_inset
22315 </cell>
22316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22317 \begin_inset Text
22318
22319 \begin_layout Standard
22320 5.37 / 6.31 ms
22321 \end_layout
22322
22323 \end_inset
22324 </cell>
22325 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22326 \begin_inset Text
22327
22328 \begin_layout Standard
22329 8.71 / 40.65 ms
22330 \end_layout
22331
22332 \end_inset
22333 </cell>
22334 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22335 \begin_inset Text
22336
22337 \begin_layout Standard
22338 0.40 / 0.40 ms
22339 \end_layout
22340
22341 \end_inset
22342 </cell>
22343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22344 \begin_inset Text
22345
22346 \begin_layout Standard
22347 0.40 / 0.40 ms
22348 \end_layout
22349
22350 \end_inset
22351 </cell>
22352 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22353 \begin_inset Text
22354
22355 \begin_layout Standard
22356 -
22357 \end_layout
22358
22359 \end_inset
22360 </cell>
22361 </row>
22362 <row bottomline="true">
22363 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22364 \begin_inset Text
22365
22366 \begin_layout Standard
22367 float speed
22368 \begin_inset Foot
22369 status collapsed
22370
22371 \begin_layout Standard
22372 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
22373  empty putchar()
22374 \end_layout
22375
22376 \end_inset
22377
22378 ,
22379 \end_layout
22380
22381 \begin_layout Standard
22382 small / large
22383 \end_layout
22384
22385 \end_inset
22386 </cell>
22387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22388 \begin_inset Text
22389
22390 \begin_layout Standard
22391 -
22392 \end_layout
22393
22394 \end_inset
22395 </cell>
22396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22397 \begin_inset Text
22398
22399 \begin_layout Standard
22400 7.49 / 22.47 ms
22401 \end_layout
22402
22403 \end_inset
22404 </cell>
22405 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22406 \begin_inset Text
22407
22408 \begin_layout Standard
22409 -
22410 \end_layout
22411
22412 \end_inset
22413 </cell>
22414 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22415 \begin_inset Text
22416
22417 \begin_layout Standard
22418 -
22419 \end_layout
22420
22421 \end_inset
22422 </cell>
22423 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22424 \begin_inset Text
22425
22426 \begin_layout Standard
22427 1.04 / 1.04 ms
22428 \end_layout
22429
22430 \end_inset
22431 </cell>
22432 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22433 \begin_inset Text
22434
22435 \begin_layout Standard
22436 -
22437 \end_layout
22438
22439 \end_inset
22440 </cell>
22441 </row>
22442 </lyxtabular>
22443
22444 \end_inset
22445
22446
22447 \end_layout
22448
22449 \begin_layout Subsubsection
22450 <malloc.h>
22451 \begin_inset LatexCommand index
22452 name "malloc.h"
22453
22454 \end_inset
22455
22456
22457 \end_layout
22458
22459 \begin_layout Standard
22460 As of SDCC 2.6.2 you no longer need to call an initialization routine before
22461  using dynamic memory allocation
22462 \begin_inset LatexCommand index
22463 name "dynamic memory allocation (malloc)"
22464
22465 \end_inset
22466
22467  and a default heap
22468 \begin_inset LatexCommand index
22469 name "heap (malloc)"
22470
22471 \end_inset
22472
22473  space of 1024 bytes is provided for malloc to allocate memory from.
22474  If you need a different heap size you need to recompile _heap.c with the
22475  required size defined in HEAP_SIZE.
22476  It is recommended to make a copy of this file into your project directory
22477  and compile it there with:
22478 \end_layout
22479
22480 \begin_layout Verse
22481
22482 \family typewriter
22483 sdcc -c _heap.c -D HEAP_SIZE=2048
22484 \end_layout
22485
22486 \begin_layout Standard
22487 And then link it with:
22488 \end_layout
22489
22490 \begin_layout Verse
22491
22492 \family typewriter
22493 sdcc main.rel _heap.rel
22494 \end_layout
22495
22496 \begin_layout Subsection
22497 Math functions (sinf, powf, sqrtf etc.)
22498 \end_layout
22499
22500 \begin_layout Subsubsection
22501 <math.h>
22502 \end_layout
22503
22504 \begin_layout Standard
22505 See definitions in file <math.h>.
22506 \end_layout
22507
22508 \begin_layout Subsection
22509 Other libraries
22510 \end_layout
22511
22512 \begin_layout Standard
22513 Libraries
22514 \begin_inset LatexCommand index
22515 name "Libraries"
22516
22517 \end_inset
22518
22519  included in SDCC should have a license at least as liberal as the GNU Lesser
22520  General Public License
22521 \begin_inset LatexCommand index
22522 name "GNU Lesser General Public License, LGPL"
22523
22524 \end_inset
22525
22526  
22527 \emph on
22528 LGPL
22529 \emph default
22530 .
22531 \end_layout
22532
22533 \begin_layout Standard
22534 \begin_inset Note Note
22535 status collapsed
22536
22537 \begin_layout Standard
22538 license statements for the libraries are missing.
22539  sdcc/device/lib/ser_ir.c
22540 \end_layout
22541
22542 \begin_layout Standard
22543 or _decdptr f.e.
22544  come with a GPL (as opposed to LGPL) License - this will not be liberal
22545  enough for many embedded programmers.
22546 \end_layout
22547
22548 \end_inset
22549
22550
22551 \end_layout
22552
22553 \begin_layout Standard
22554 If you have ported some library or want to share experience about some code
22555  which f.e.
22556  falls into any of these categories Busses (I
22557 \begin_inset Formula $^{\textrm{2}}$
22558 \end_inset
22559
22560 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
22561  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
22562  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
22563 \begin_inset LatexCommand url
22564 target "http://sourceforge.net/mail/?group_id=599"
22565
22566 \end_inset
22567
22568 \InsetSpace ~
22569 would certainly like to hear about it.
22570 \end_layout
22571
22572 \begin_layout Standard
22573 Programmers coding for embedded systems are not especially famous for being
22574  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
22575 e these references are very valuable.
22576  Let's help to create a climate where information is shared.
22577 \begin_inset VSpace bigskip
22578 \end_inset
22579
22580
22581 \end_layout
22582
22583 \begin_layout Section
22584 Memory Models
22585 \end_layout
22586
22587 \begin_layout Subsection
22588 MCS51 Memory Models
22589 \begin_inset LatexCommand index
22590 name "Memory model"
22591
22592 \end_inset
22593
22594
22595 \begin_inset LatexCommand index
22596 name "MCS51 memory model"
22597
22598 \end_inset
22599
22600
22601 \end_layout
22602
22603 \begin_layout Subsubsection
22604 Small, Medium and Large
22605 \end_layout
22606
22607 \begin_layout Standard
22608 SDCC allows three memory models for MCS51 code, 
22609 \shape slanted
22610 small, medium
22611 \shape default
22612  and 
22613 \shape slanted
22614 large
22615 \shape default
22616 .
22617  Modules compiled with different memory models should 
22618 \emph on
22619 never
22620 \emph default
22621  be combined together or the results would be unpredictable.
22622  The library routines supplied with the compiler are compiled as small,
22623  medium and large.
22624  The compiled library modules are contained in separate directories as small,
22625  medium and large so that you can link to the appropriate set.
22626 \end_layout
22627
22628 \begin_layout Standard
22629 When the medium or large model is used all variables declared without a
22630  storage class will be allocated into the external ram, this includes all
22631  parameters and local variables (for non-reentrant
22632 \begin_inset LatexCommand index
22633 name "reentrant"
22634
22635 \end_inset
22636
22637  functions).
22638  When the small model is used variables without storage class are allocated
22639  in the internal ram.
22640 \end_layout
22641
22642 \begin_layout Standard
22643 Judicious usage of the processor specific storage classes
22644 \begin_inset LatexCommand index
22645 name "Storage class"
22646
22647 \end_inset
22648
22649  and the 'reentrant' function type will yield much more efficient code,
22650  than using the large model.
22651  Several optimizations are disabled when the program is compiled using the
22652  large model, it is therefore recommended that the small model be used unless
22653  absolutely required.
22654 \end_layout
22655
22656 \begin_layout Subsubsection
22657 External Stack
22658 \begin_inset LatexCommand label
22659 name "sub:External-Stack"
22660
22661 \end_inset
22662
22663
22664 \begin_inset LatexCommand index
22665 name "stack"
22666
22667 \end_inset
22668
22669
22670 \begin_inset LatexCommand index
22671 name "External stack (mcs51)"
22672
22673 \end_inset
22674
22675
22676 \end_layout
22677
22678 \begin_layout Standard
22679 The external stack (-
22680 \begin_inset ERT
22681 status collapsed
22682
22683 \begin_layout Standard
22684
22685
22686 \backslash
22687 /
22688 \end_layout
22689
22690 \end_inset
22691
22692 -xstack option
22693 \begin_inset LatexCommand index
22694 name "-\\/-xstack"
22695
22696 \end_inset
22697
22698 ) is located in pdata
22699 \begin_inset LatexCommand index
22700 name "pdata (mcs51, ds390 storage class)"
22701
22702 \end_inset
22703
22704  memory (usually at the start of the external ram segment) and uses all
22705  unused space in pdata (max.
22706  256 bytes).
22707  When -
22708 \begin_inset ERT
22709 status collapsed
22710
22711 \begin_layout Standard
22712
22713
22714 \backslash
22715 /
22716 \end_layout
22717
22718 \end_inset
22719
22720 -xstack option is used to compile the program, the parameters and local
22721  variables
22722 \begin_inset LatexCommand index
22723 name "local variables"
22724
22725 \end_inset
22726
22727  of all reentrant functions are allocated in this area.
22728  This option is provided for programs with large stack space requirements.
22729  When used with the -
22730 \begin_inset ERT
22731 status collapsed
22732
22733 \begin_layout Standard
22734
22735
22736 \backslash
22737 /
22738 \end_layout
22739
22740 \end_inset
22741
22742 -stack-auto
22743 \begin_inset LatexCommand index
22744 name "-\\/-stack-auto"
22745
22746 \end_inset
22747
22748  option, all parameters and local variables are allocated on the external
22749  stack (note: support libraries will need to be recompiled with the same
22750  options.
22751  There is a predefined target in the library makefile).
22752 \end_layout
22753
22754 \begin_layout Standard
22755 The compiler outputs the higher order address byte of the external ram segment
22756  into port P2
22757 \begin_inset LatexCommand index
22758 name "P2 (mcs51 sfr)"
22759
22760 \end_inset
22761
22762  (see also section 
22763 \begin_inset LatexCommand ref
22764 reference "sub:MCS51-variants"
22765
22766 \end_inset
22767
22768 ), therefore when using the External Stack option, this port 
22769 \emph on
22770 may not
22771 \emph default
22772  be used by the application program.
22773 \end_layout
22774
22775 \begin_layout Subsection
22776 DS390 Memory Model
22777 \begin_inset LatexCommand index
22778 name "Memory model"
22779
22780 \end_inset
22781
22782
22783 \begin_inset LatexCommand index
22784 name "DS390 memory model"
22785
22786 \end_inset
22787
22788
22789 \end_layout
22790
22791 \begin_layout Standard
22792 The only model supported is Flat 24
22793 \begin_inset LatexCommand index
22794 name "Flat 24 (DS390 memory model)"
22795
22796 \end_inset
22797
22798 .
22799  This generates code for the 24 bit contiguous addressing mode of the Dallas
22800  DS80C390 part.
22801  In this mode, up to four meg of external RAM or code space can be directly
22802  addressed.
22803  See the data sheets at www.dalsemi.com for further information on this part.
22804 \newline
22805
22806 \newline
22807 Note
22808  that the compiler does not generate any code to place the processor into
22809  24 bitmode (although 
22810 \emph on
22811 tinibios
22812 \emph default
22813  in the ds390 libraries will do that for you).
22814  If you don't use 
22815 \emph on
22816 tinibios
22817 \emph default
22818
22819 \begin_inset LatexCommand index
22820 name "Tinibios (DS390)"
22821
22822 \end_inset
22823
22824 , the boot loader or similar code must ensure that the processor is in 24
22825  bit contiguous addressing mode before calling the SDCC startup code.
22826 \newline
22827
22828 \newline
22829 Like
22830  the 
22831 \emph on
22832 -
22833 \begin_inset ERT
22834 status collapsed
22835
22836 \begin_layout Standard
22837
22838
22839 \backslash
22840 /
22841 \end_layout
22842
22843 \end_inset
22844
22845 -model-large
22846 \emph default
22847  option, variables will by default be placed into the XDATA segment.
22848  
22849 \newline
22850
22851 \newline
22852 Segments may be placed anywhere in the 4 meg address space using the usual
22853  -
22854 \begin_inset ERT
22855 status collapsed
22856
22857 \begin_layout Standard
22858
22859
22860 \backslash
22861 /
22862 \end_layout
22863
22864 \end_inset
22865
22866 -*-loc options.
22867  Note that if any segments are located above 64K, the -r flag must be passed
22868  to the linker to generate the proper segment relocations, and the Intel
22869  HEX output format must be used.
22870  The -r flag can be passed to the linker by using the option 
22871 \emph on
22872 -Wl-r
22873 \emph default
22874  on the SDCC command line.
22875  However, currently the linker can not handle code segments > 64k.
22876 \end_layout
22877
22878 \begin_layout Section
22879 Pragmas
22880 \begin_inset LatexCommand label
22881 name "sec:Pragmas"
22882
22883 \end_inset
22884
22885
22886 \begin_inset LatexCommand index
22887 name "Pragmas"
22888
22889 \end_inset
22890
22891
22892 \end_layout
22893
22894 \begin_layout Standard
22895 Pragmas are used to turn on and/or off certain compiler options.
22896  Some of them are closely related to corresponding command-line options
22897  (see section 
22898 \begin_inset LatexCommand vref
22899 reference "sec:Command-Line-Options"
22900
22901 \end_inset
22902
22903 ).
22904 \newline
22905 Pragmas should be placed before and/or after a function, placing pragmas
22906  inside a function body could have unpredictable results.
22907 \newline
22908
22909 \newline
22910 SDCC supports the
22911  following #pragma directives:
22912 \end_layout
22913
22914 \begin_layout Itemize
22915
22916 \series bold
22917 save
22918 \series default
22919
22920 \begin_inset LatexCommand index
22921 name "\\#pragma save"
22922
22923 \end_inset
22924
22925  - this will save most current options to the save/restore stack.
22926  See #pragma\InsetSpace ~
22927 restore.
22928 \end_layout
22929
22930 \begin_layout Itemize
22931
22932 \series bold
22933 restore
22934 \series default
22935
22936 \begin_inset LatexCommand index
22937 name "\\#pragma restore"
22938
22939 \end_inset
22940
22941  - will restore saved options from the last save.
22942  saves & restores can be nested.
22943  SDCC uses a save/restore stack: save pushes current options to the stack,
22944  restore pulls current options from the stack.
22945  See #pragma\InsetSpace ~
22946 save.
22947 \newline
22948
22949 \end_layout
22950
22951 \begin_layout Itemize
22952
22953 \series bold
22954 callee_saves
22955 \series default
22956
22957 \begin_inset LatexCommand index
22958 name "\\#pragma callee\\_saves"
22959
22960 \end_inset
22961
22962
22963 \begin_inset LatexCommand index
22964 name "function prologue"
22965
22966 \end_inset
22967
22968  function1[,function2[,function3...]] 
22969 \begin_inset LatexCommand label
22970 name "ite:callee_saves-function1[,function2[,function3...]]--"
22971
22972 \end_inset
22973
22974 - The compiler by default uses a caller saves convention for register saving
22975  across function calls, however this can cause unnecessary register pushing
22976  and popping
22977 \begin_inset LatexCommand index
22978 name "push/pop"
22979
22980 \end_inset
22981
22982  when calling small functions from larger functions.
22983  This option can be used to switch off the register saving convention for
22984  the function names specified.
22985  The compiler will not save registers when calling these functions, extra
22986  code need to be manually inserted at the entry and exit for these functions
22987  to save and restore the registers used by these functions, this can SUBSTANTIAL
22988 LY reduce code and improve run time performance of the generated code.
22989  In the future the compiler (with inter procedural analysis) may be able
22990  to determine the appropriate scheme to use for each function call.
22991  If -
22992 \begin_inset ERT
22993 status collapsed
22994
22995 \begin_layout Standard
22996
22997
22998 \backslash
22999 /
23000 \end_layout
23001
23002 \end_inset
23003
23004 -callee-saves command line option is used (see page 
23005 \begin_inset LatexCommand vpageref
23006 reference "lyx:--callee-saves-function1[,function2][,function3]..."
23007
23008 \end_inset
23009
23010 ), the function names specified in #pragma\InsetSpace ~
23011 callee_saves
23012 \begin_inset LatexCommand index
23013 name "\\#pragma callee\\_saves"
23014
23015 \end_inset
23016
23017  is appended to the list of functions specified in the command line.
23018 \end_layout
23019
23020 \begin_layout Itemize
23021
23022 \series bold
23023 exclude
23024 \series default
23025
23026 \begin_inset LatexCommand index
23027 name "\\#pragma exclude"
23028
23029 \end_inset
23030
23031  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
23032  of pairs of push/pop
23033 \begin_inset LatexCommand index
23034 name "push/pop"
23035
23036 \end_inset
23037
23038  instructions in 
23039 \emph on
23040 I
23041 \emph default
23042 nterrupt
23043 \begin_inset LatexCommand index
23044 name "interrupt"
23045
23046 \end_inset
23047
23048  
23049 \emph on
23050 S
23051 \emph default
23052 ervice 
23053 \emph on
23054 R
23055 \emph default
23056 outines.
23057  The directive should be placed immediately before the ISR function definition
23058  and it affects ALL ISR functions following it.
23059  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
23060 exclude\InsetSpace ~
23061 none
23062 \begin_inset LatexCommand index
23063 name "\\#pragma exclude"
23064
23065 \end_inset
23066
23067 .
23068  See also the related keyword _naked
23069 \begin_inset LatexCommand index
23070 name "\\_naked"
23071
23072 \end_inset
23073
23074
23075 \begin_inset LatexCommand index
23076 name "\\_\\_naked"
23077
23078 \end_inset
23079
23080 .
23081 \end_layout
23082
23083 \begin_layout Itemize
23084
23085 \series bold
23086 less_pedantic
23087 \series default
23088
23089 \begin_inset LatexCommand index
23090 name "pedantic"
23091
23092 \end_inset
23093
23094
23095 \begin_inset LatexCommand index
23096 name "\\#pragma less\\_pedantic"
23097
23098 \end_inset
23099
23100  
23101 \begin_inset LatexCommand label
23102 name "ite:less_pedantic"
23103
23104 \end_inset
23105
23106 - the compiler will not warn you anymore for obvious mistakes, you're on
23107  your own now ;-( .
23108  See also the command line option -
23109 \begin_inset ERT
23110 status collapsed
23111
23112 \begin_layout Standard
23113
23114
23115 \backslash
23116 /
23117 \end_layout
23118
23119 \end_inset
23120
23121 -less-pedantic 
23122 \begin_inset LatexCommand vpageref
23123 reference "lyx:--less-pedantic"
23124
23125 \end_inset
23126
23127 .
23128  
23129 \newline
23130 More specifically, the following warnings will be disabled: 
23131 \shape italic
23132 comparison is always [true/false] due to limited range of data type
23133 \shape default
23134  (94); 
23135 \shape italic
23136 overflow in implicit constant conversion
23137 \shape default
23138  (158); [the (in)famous] 
23139 \shape italic
23140 conditional flow changed by optimizer: so said EVELYN the modified DOG
23141 \shape default
23142  (110); 
23143 \shape italic
23144 function '[function name]' must return value
23145 \shape default
23146  (59).
23147  
23148 \newline
23149 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
23150  level) are disabled, too, namely: 
23151 \shape italic
23152 constant value '[
23153 \begin_inset Note Note
23154 status collapsed
23155
23156 \begin_layout Standard
23157 dunno what comes here - this warning appears to be unused altogether
23158 \end_layout
23159
23160 \end_inset
23161
23162 ]', out of range
23163 \shape default
23164  (81); 
23165 \shape italic
23166 [left/right] shifting more than size of object changed to zero
23167 \shape default
23168  (116); 
23169 \shape italic
23170 unreachable code
23171 \shape default
23172  (126); 
23173 \shape italic
23174 integer overflow in expression
23175 \shape default
23176  (165); 
23177 \shape italic
23178 unmatched #pragma save and #pragma restore
23179 \shape default
23180  (170); 
23181 \shape italic
23182 comparison of 'signed char' with 'unsigned char' requires promotion to int
23183 \shape default
23184  (185); 
23185 \shape italic
23186 ISO C90 does not support flexible array members
23187 \shape default
23188  (187); 
23189 \shape italic
23190 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
23191 nam
23192 e]':\InsetSpace ~
23193 [
23194 \begin_inset Note Note
23195 status collapsed
23196
23197 \begin_layout Standard
23198 appears to be always blank - what was supposed to be here?
23199 \end_layout
23200
23201 \end_inset
23202
23203 ]
23204 \shape default
23205  (114); 
23206 \shape italic
23207 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
23208  complexity [number]
23209 \shape default
23210  (121).
23211 \end_layout
23212
23213 \begin_layout Itemize
23214
23215 \series bold
23216 disable_warning
23217 \series default
23218  <nnnn>
23219 \begin_inset LatexCommand index
23220 name "\\#pragma disable\\_warning"
23221
23222 \end_inset
23223
23224  - the compiler will not warn you anymore about warning number <nnnn>.
23225 \end_layout
23226
23227 \begin_layout Itemize
23228
23229 \series bold
23230 nogcse
23231 \series default
23232
23233 \begin_inset LatexCommand index
23234 name "\\#pragma nogcse"
23235
23236 \end_inset
23237
23238  - will stop global common subexpression elimination.
23239 \end_layout
23240
23241 \begin_layout Itemize
23242
23243 \series bold
23244 noinduction
23245 \series default
23246
23247 \begin_inset LatexCommand index
23248 name "\\#pragma noinduction"
23249
23250 \end_inset
23251
23252  - will stop loop induction optimizations.
23253 \end_layout
23254
23255 \begin_layout Itemize
23256
23257 \series bold
23258 noinvariant
23259 \series default
23260
23261 \begin_inset LatexCommand index
23262 name "\\#pragma noinvariant"
23263
23264 \end_inset
23265
23266  - will not do loop invariant optimizations.
23267  For more details see Loop Invariants in section
23268 \begin_inset LatexCommand ref
23269 reference "sub:Loop-Optimizations"
23270
23271 \end_inset
23272
23273 .
23274 \end_layout
23275
23276 \begin_layout Itemize
23277
23278 \series bold
23279 noiv
23280 \series default
23281
23282 \begin_inset LatexCommand index
23283 name "\\#pragma noiv"
23284
23285 \end_inset
23286
23287  - Do not generate interrupt
23288 \begin_inset LatexCommand index
23289 name "interrupt"
23290
23291 \end_inset
23292
23293  vector table
23294 \begin_inset LatexCommand index
23295 name "interrupt vector table"
23296
23297 \end_inset
23298
23299  entries for all ISR functions defined after the pragma.
23300  This is useful in cases where the interrupt vector table must be defined
23301  manually, or when there is a secondary, manually defined interrupt vector
23302  table (e.g.
23303  for the autovector feature of the Cypress EZ-USB FX2).
23304  More elegantly this can be achieved by omitting the optional interrupt
23305  number after the interrupt keyword, see section 
23306 \begin_inset LatexCommand ref
23307 reference "sub:Interrupt-Service-Routines"
23308
23309 \end_inset
23310
23311 \InsetSpace ~
23312 about interrupts.
23313 \end_layout
23314
23315 \begin_layout Itemize
23316
23317 \series bold
23318 nojtbound
23319 \series default
23320
23321 \begin_inset LatexCommand index
23322 name "\\#pragma nojtbound"
23323
23324 \end_inset
23325
23326  - will not generate code for boundary value checking, when switch statements
23327  are turned into jump-tables (dangerous).
23328  For more details see section 
23329 \begin_inset LatexCommand ref
23330 reference "sub:'switch'-Statements"
23331
23332 \end_inset
23333
23334 .
23335 \end_layout
23336
23337 \begin_layout Itemize
23338
23339 \series bold
23340 noloopreverse
23341 \series default
23342
23343 \begin_inset LatexCommand index
23344 name "\\#pragma noloopreverse"
23345
23346 \end_inset
23347
23348  - Will not do loop reversal optimization
23349 \end_layout
23350
23351 \begin_layout Itemize
23352
23353 \series bold
23354 nooverlay
23355 \series default
23356
23357 \begin_inset LatexCommand index
23358 name "\\#pragma nooverlay"
23359
23360 \end_inset
23361
23362  - the compiler will not overlay the parameters and local variables of a
23363  function.
23364 \end_layout
23365
23366 \begin_layout Itemize
23367
23368 \series bold
23369 stackauto
23370 \series default
23371
23372 \begin_inset LatexCommand index
23373 name "\\#pragma stackauto"
23374
23375 \end_inset
23376
23377 - See option -
23378 \begin_inset ERT
23379 status collapsed
23380
23381 \begin_layout Standard
23382
23383
23384 \backslash
23385 /
23386 \end_layout
23387
23388 \end_inset
23389
23390 -stack-auto
23391 \begin_inset LatexCommand index
23392 name "-\\/-stack-auto"
23393
23394 \end_inset
23395
23396  and section 
23397 \begin_inset LatexCommand ref
23398 reference "sec:Parameters-and-Local-Variables"
23399
23400 \end_inset
23401
23402  Parameters and Local Variables.
23403 \end_layout
23404
23405 \begin_layout Itemize
23406
23407 \series bold
23408 opt_code_speed
23409 \series default
23410  
23411 \begin_inset LatexCommand index
23412 name "\\#pragma opt\\_code\\_speed"
23413
23414 \end_inset
23415
23416 - The compiler will optimize code generation towards fast code, possibly
23417  at the expense of code size.
23418  Currently this has little effect.
23419 \end_layout
23420
23421 \begin_layout Itemize
23422
23423 \series bold
23424 opt_code_size
23425 \series default
23426  
23427 \begin_inset LatexCommand index
23428 name "\\#pragma opt\\_code\\_size"
23429
23430 \end_inset
23431
23432 - The compiler will optimize code generation towards compact code, possibly
23433  at the expense of code speed.
23434  Currently this has little effect.
23435 \end_layout
23436
23437 \begin_layout Itemize
23438
23439 \series bold
23440 opt_code_balanced
23441 \series default
23442  
23443 \begin_inset LatexCommand index
23444 name "\\#pragma opt\\_code\\_balanced"
23445
23446 \end_inset
23447
23448 - The compiler will attempt to generate code that is both compact and fast,
23449  as long as meeting one goal is not a detriment to the other (this is the
23450  default).
23451  
23452 \end_layout
23453
23454 \begin_layout Itemize
23455
23456 \series bold
23457 std_sdcc89
23458 \series default
23459  
23460 \begin_inset LatexCommand index
23461 name "\\#pragma std\\_sdcc89"
23462
23463 \end_inset
23464
23465 - Generally follow the C89 standard, but allow SDCC features that conflict
23466  with the standard (default).
23467 \end_layout
23468
23469 \begin_layout Itemize
23470
23471 \series bold
23472 std_c89
23473 \series default
23474  
23475 \begin_inset LatexCommand index
23476 name "\\#pragma std\\_c89"
23477
23478 \end_inset
23479
23480 - Follow the C89 standard and disable SDCC features that conflict with the
23481  standard.
23482 \end_layout
23483
23484 \begin_layout Itemize
23485
23486 \series bold
23487 std_sdcc99
23488 \series default
23489  
23490 \begin_inset LatexCommand index
23491 name "\\#pragma std\\_sdcc99"
23492
23493 \end_inset
23494
23495 - Generally follow the C99 standard, but allow SDCC features that conflict
23496  with the standard (incomplete support).
23497 \end_layout
23498
23499 \begin_layout Itemize
23500
23501 \series bold
23502 std_c99
23503 \series default
23504  
23505 \begin_inset LatexCommand index
23506 name "\\#pragma std\\_c99"
23507
23508 \end_inset
23509
23510 - Follow the C99 standard and disable SDCC features that conflict with the
23511  standard (incomplete support).
23512 \end_layout
23513
23514 \begin_layout Itemize
23515
23516 \series bold
23517 codeseg
23518 \series default
23519  <name>
23520 \begin_inset LatexCommand index
23521 name "\\#pragma codeseg"
23522
23523 \end_inset
23524
23525 - Use this name (max.
23526  8 characters) for the code segment.
23527  See option -
23528 \begin_inset ERT
23529 status collapsed
23530
23531 \begin_layout Standard
23532
23533
23534 \backslash
23535 /
23536 \end_layout
23537
23538 \end_inset
23539
23540 -codeseg.
23541 \end_layout
23542
23543 \begin_layout Itemize
23544
23545 \series bold
23546 constseg
23547 \series default
23548  <name>
23549 \begin_inset LatexCommand index
23550 name "\\#pragma constseg"
23551
23552 \end_inset
23553
23554 - Use this name (max.
23555  8 characters) for the const segment.
23556  See option -
23557 \begin_inset ERT
23558 status collapsed
23559
23560 \begin_layout Standard
23561
23562
23563 \backslash
23564 /
23565 \end_layout
23566
23567 \end_inset
23568
23569 -constseg.
23570 \end_layout
23571
23572 \begin_layout Standard
23573 The preprocessor SDCPP
23574 \begin_inset LatexCommand index
23575 name "sdcpp (preprocessor)"
23576
23577 \end_inset
23578
23579  supports the following #pragma directives:
23580 \end_layout
23581
23582 \begin_layout Itemize
23583
23584 \series bold
23585 pedantic_parse_number
23586 \series default
23587
23588 \begin_inset LatexCommand index
23589 name "pedantic"
23590
23591 \end_inset
23592
23593
23594 \begin_inset LatexCommand index
23595 name "\\#pragma pedantic\\_parse\\_number"
23596
23597 \end_inset
23598
23599  (+ | -) 
23600 \begin_inset LatexCommand label
23601 name "ite:pedantic_parse_number"
23602
23603 \end_inset
23604
23605 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
23606  properly and the macro LO_B(3) gets expanded.
23607  Default is off.
23608  See also the -
23609 \begin_inset ERT
23610 status collapsed
23611
23612 \begin_layout Standard
23613
23614
23615 \backslash
23616 /
23617 \end_layout
23618
23619 \end_inset
23620
23621 -pedantic-parse-number command line option 
23622 \begin_inset LatexCommand vpageref
23623 reference "lyx:-pedantic-parse-number"
23624
23625 \end_inset
23626
23627 .
23628  
23629 \newline
23630 Below is an example on how to use this pragma.
23631  
23632 \emph on
23633 Note: this functionality is not in conformance with standard!
23634 \end_layout
23635
23636 \begin_layout Verse
23637
23638 \family typewriter
23639 #pragma pedantic_parse_number +
23640 \begin_inset LatexCommand index
23641 name "\\#pragma pedantic\\_parse\\_number"
23642
23643 \end_inset
23644
23645
23646 \newline
23647
23648 \newline
23649 #define LO_B(x) ((x) & 0xff)
23650 \newline
23651
23652 \newline
23653 unsigned char foo(void)
23654 \newline
23655 {
23656 \newline
23657 \InsetSpace ~
23658 \InsetSpace ~
23659 \InsetSpace ~
23660 unsigned char c=0xfe-LO_B(3)
23661 ;
23662 \newline
23663
23664 \newline
23665 \InsetSpace ~
23666 \InsetSpace ~
23667 \InsetSpace ~
23668 return c;
23669 \newline
23670 }
23671 \newline
23672
23673 \end_layout
23674
23675 \begin_layout Itemize
23676
23677 \series bold
23678 preproc_asm
23679 \series default
23680
23681 \begin_inset LatexCommand index
23682 name "\\#pragma preproc\\_asm"
23683
23684 \end_inset
23685
23686  (+ | -) - switch _asm _endasm block preprocessing on / off.
23687  Default is on.
23688  You use this pragma to define multilines of assembly code.
23689  This will prevent the preprocessor from changing the formatting required
23690  by assembly code.
23691  Below is an example on how to use this pragma.
23692 \end_layout
23693
23694 \begin_layout Verse
23695
23696 \family typewriter
23697 #pragma preproc_asm -
23698 \begin_inset LatexCommand index
23699 name "\\#pragma preproc\\_asm"
23700
23701 \end_inset
23702
23703
23704 \newline
23705 #define MYDELAY _asm
23706 \newline
23707 \InsetSpace ~
23708 \InsetSpace ~
23709 \InsetSpace ~
23710 nop ;my assembly comment...
23711 \newline
23712 \InsetSpace ~
23713 \InsetSpace ~
23714 \InsetSpace ~
23715 nop
23716 \newline
23717 \InsetSpace ~
23718 \InsetSpace ~
23719 \InsetSpace ~
23720 nop
23721 \newline
23722 _endasm
23723 \newline
23724 #pragma preproc_asm
23725  +
23726 \newline
23727
23728 \newline
23729 void foo (void) 
23730 \newline
23731
23732 \newline
23733 \InsetSpace ~
23734 \InsetSpace ~
23735 \InsetSpace ~
23736  ...
23737  
23738 \newline
23739 \InsetSpace ~
23740 \InsetSpace ~
23741 \InsetSpace ~
23742  MYDELAY;
23743 \newline
23744 \InsetSpace ~
23745 \InsetSpace ~
23746 \InsetSpace ~
23747  ...
23748  
23749 \newline
23750
23751 \newline
23752
23753 \end_layout
23754
23755 \begin_layout Itemize
23756
23757 \series bold
23758 sdcc_hash
23759 \series default
23760
23761 \begin_inset LatexCommand index
23762 name "\\#pragma sdcc\\_hash"
23763
23764 \end_inset
23765
23766  (+ | -) - Allow "naked" hash in macro definition, for example:
23767 \newline
23768
23769 \family typewriter
23770 #define DIR_LO(x) #(x & 0xff)
23771 \family default
23772
23773 \newline
23774 Default is off.
23775  Below is an example on how to use this pragma.
23776 \end_layout
23777
23778 \begin_layout Verse
23779
23780 \family typewriter
23781 #pragma preproc_asm +
23782 \newline
23783 #pragma sdcc_hash +
23784 \begin_inset LatexCommand index
23785 name "\\#pragma sdcc\\_hash"
23786
23787 \end_inset
23788
23789
23790 \newline
23791
23792 \newline
23793 #define ROMCALL(x) 
23794 \backslash
23795
23796 \newline
23797 \InsetSpace ~
23798 \InsetSpace ~
23799 \InsetSpace ~
23800 mov R6_B3, #(x & 0xff) 
23801 \backslash
23802
23803 \newline
23804 \InsetSpace ~
23805 \InsetSpace ~
23806 \InsetSpace ~
23807 mov R7_B3, #((x >> 8) & 0xff) 
23808 \backslash
23809
23810 \newline
23811 \InsetSpace ~
23812 \InsetSpace ~
23813 \InsetSpace ~
23814 lcall __romcall
23815 \newline
23816
23817 \newline
23818 ...
23819 \newline
23820 _asm
23821 \newline
23822 ROMCALL(72)
23823 \newline
23824 _endasm;
23825 \newline
23826 ...
23827 \newline
23828
23829 \end_layout
23830
23831 \begin_layout Standard
23832 Some of the pragmas are intended to be used to turn-on or off certain optimizati
23833 ons which might cause the compiler to generate extra stack and/or data space
23834  to store compiler generated temporary variables.
23835  This usually happens in large functions.
23836  Pragma directives should be used as shown in the following example, they
23837  are used to control options and optimizations for a given function.
23838  
23839 \end_layout
23840
23841 \begin_layout Verse
23842
23843 \family typewriter
23844 #pragma save
23845 \begin_inset LatexCommand index
23846 name "\\#pragma save"
23847
23848 \end_inset
23849
23850  \InsetSpace ~
23851 \InsetSpace ~
23852 \InsetSpace ~
23853 \InsetSpace ~
23854 \InsetSpace ~
23855 \InsetSpace ~
23856 \InsetSpace ~
23857 /* save the current settings */ 
23858 \newline
23859 #pragma nogcse
23860 \begin_inset LatexCommand index
23861 name "\\#pragma nogcse"
23862
23863 \end_inset
23864
23865  \InsetSpace ~
23866 \InsetSpace ~
23867 \InsetSpace ~
23868 \InsetSpace ~
23869 \InsetSpace ~
23870 /* turnoff global subexpression elimination */ 
23871 \newline
23872 #pragma noinduction
23873 \begin_inset LatexCommand index
23874 name "\\#pragma noinduction"
23875
23876 \end_inset
23877
23878  /* turn off induction optimizations */ 
23879 \newline
23880 int foo () 
23881 \newline
23882
23883 \newline
23884 \InsetSpace ~
23885  \InsetSpace ~
23886  ...
23887  
23888 \newline
23889 \InsetSpace ~
23890  \InsetSpace ~
23891  /* large code */ 
23892 \newline
23893 \InsetSpace ~
23894  \InsetSpace ~
23895  ...
23896  
23897 \newline
23898
23899 \newline
23900 #pragma restore
23901 \begin_inset LatexCommand index
23902 name "\\#pragma restore"
23903
23904 \end_inset
23905
23906  /* turn the optimizations back on */
23907 \end_layout
23908
23909 \begin_layout Standard
23910 The compiler will generate a warning message when extra space is allocated.
23911  It is strongly recommended that the save and restore pragmas be used when
23912  changing options for a function.
23913 \newline
23914
23915 \newline
23916
23917 \newline
23918
23919 \end_layout
23920
23921 \begin_layout Section
23922 Defines Created by the Compiler
23923 \end_layout
23924
23925 \begin_layout Standard
23926 The compiler creates the following #defines
23927 \begin_inset LatexCommand index
23928 name "\\#defines"
23929
23930 \end_inset
23931
23932
23933 \begin_inset LatexCommand index
23934 name "Defines created by the compiler"
23935
23936 \end_inset
23937
23938 :
23939 \newline
23940
23941 \end_layout
23942
23943 \begin_layout Standard
23944 \begin_inset Tabular
23945 <lyxtabular version="3" rows="15" columns="2">
23946 <features>
23947 <column alignment="left" valignment="top" leftline="true" width="3in">
23948 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
23949 <row topline="true" bottomline="true">
23950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23951 \begin_inset Text
23952
23953 \begin_layout Standard
23954
23955 \series bold
23956 #define
23957 \end_layout
23958
23959 \end_inset
23960 </cell>
23961 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23962 \begin_inset Text
23963
23964 \begin_layout Standard
23965
23966 \series bold
23967 Description
23968 \end_layout
23969
23970 \end_inset
23971 </cell>
23972 </row>
23973 <row topline="true">
23974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23975 \begin_inset Text
23976
23977 \begin_layout Standard
23978 SDCC
23979 \begin_inset LatexCommand index
23980 name "SDCC"
23981
23982 \end_inset
23983
23984  
23985 \end_layout
23986
23987 \end_inset
23988 </cell>
23989 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23990 \begin_inset Text
23991
23992 \begin_layout Standard
23993 Always defined.
23994  Since version 2.5.6 the version number as an int (ex.
23995  256)
23996 \end_layout
23997
23998 \end_inset
23999 </cell>
24000 </row>
24001 <row topline="true">
24002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24003 \begin_inset Text
24004
24005 \begin_layout Standard
24006 SDCC_mcs51
24007 \begin_inset LatexCommand index
24008 name "SDCC\\_mcs51"
24009
24010 \end_inset
24011
24012  or SDCC_ds390
24013 \begin_inset LatexCommand index
24014 name "SDCC\\_ds390"
24015
24016 \end_inset
24017
24018  or SDCC_z80
24019 \begin_inset LatexCommand index
24020 name "SDCC\\_z80"
24021
24022 \end_inset
24023
24024 , etc.
24025 \end_layout
24026
24027 \end_inset
24028 </cell>
24029 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24030 \begin_inset Text
24031
24032 \begin_layout Standard
24033 depending on the model used (e.g.: -mds390)
24034 \end_layout
24035
24036 \end_inset
24037 </cell>
24038 </row>
24039 <row topline="true">
24040 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24041 \begin_inset Text
24042
24043 \begin_layout Standard
24044 __mcs51
24045 \begin_inset LatexCommand index
24046 name "\\_\\_mcs51"
24047
24048 \end_inset
24049
24050 , __ds390
24051 \begin_inset LatexCommand index
24052 name "\\_\\_ds390"
24053
24054 \end_inset
24055
24056 , __hc08
24057 \begin_inset LatexCommand index
24058 name "\\_\\_hc08"
24059
24060 \end_inset
24061
24062 , __z80
24063 \begin_inset LatexCommand index
24064 name "\\_\\_z80"
24065
24066 \end_inset
24067
24068 , etc
24069 \end_layout
24070
24071 \end_inset
24072 </cell>
24073 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24074 \begin_inset Text
24075
24076 \begin_layout Standard
24077 depending on the model used (e.g.
24078  -mz80)
24079 \end_layout
24080
24081 \end_inset
24082 </cell>
24083 </row>
24084 <row topline="true">
24085 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24086 \begin_inset Text
24087
24088 \begin_layout Standard
24089 SDCC_STACK_AUTO
24090 \begin_inset LatexCommand index
24091 name "SDCC\\_STACK\\_AUTO"
24092
24093 \end_inset
24094
24095
24096 \end_layout
24097
24098 \end_inset
24099 </cell>
24100 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24101 \begin_inset Text
24102
24103 \begin_layout Standard
24104 when 
24105 \emph on
24106 -
24107 \begin_inset ERT
24108 status collapsed
24109
24110 \begin_layout Standard
24111
24112
24113 \backslash
24114 /
24115 \end_layout
24116
24117 \end_inset
24118
24119 -stack-auto
24120 \emph default
24121  option is used
24122 \end_layout
24123
24124 \end_inset
24125 </cell>
24126 </row>
24127 <row topline="true">
24128 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24129 \begin_inset Text
24130
24131 \begin_layout Standard
24132 SDCC_MODEL_SMALL
24133 \begin_inset LatexCommand index
24134 name "SDCC\\_MODEL\\_SMALL"
24135
24136 \end_inset
24137
24138
24139 \end_layout
24140
24141 \end_inset
24142 </cell>
24143 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24144 \begin_inset Text
24145
24146 \begin_layout Standard
24147 when 
24148 \emph on
24149 -
24150 \begin_inset ERT
24151 status collapsed
24152
24153 \begin_layout Standard
24154
24155
24156 \backslash
24157 /
24158 \end_layout
24159
24160 \end_inset
24161
24162 -model-small
24163 \emph default
24164  is used
24165 \end_layout
24166
24167 \end_inset
24168 </cell>
24169 </row>
24170 <row topline="true">
24171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24172 \begin_inset Text
24173
24174 \begin_layout Standard
24175 SDCC_MODEL_MEDIUM
24176 \begin_inset LatexCommand index
24177 name "SDCC\\_MODEL\\_MEDIUM"
24178
24179 \end_inset
24180
24181
24182 \end_layout
24183
24184 \end_inset
24185 </cell>
24186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24187 \begin_inset Text
24188
24189 \begin_layout Standard
24190 when 
24191 \emph on
24192 -
24193 \begin_inset ERT
24194 status collapsed
24195
24196 \begin_layout Standard
24197
24198
24199 \backslash
24200 /
24201 \end_layout
24202
24203 \end_inset
24204
24205 -model-medium
24206 \emph default
24207  is used
24208 \end_layout
24209
24210 \end_inset
24211 </cell>
24212 </row>
24213 <row topline="true">
24214 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24215 \begin_inset Text
24216
24217 \begin_layout Standard
24218 SDCC_MODEL_LARGE
24219 \begin_inset LatexCommand index
24220 name "SDCC\\_MODEL\\_LARGE"
24221
24222 \end_inset
24223
24224
24225 \end_layout
24226
24227 \end_inset
24228 </cell>
24229 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24230 \begin_inset Text
24231
24232 \begin_layout Standard
24233 when 
24234 \emph on
24235 -
24236 \begin_inset ERT
24237 status collapsed
24238
24239 \begin_layout Standard
24240
24241
24242 \backslash
24243 /
24244 \end_layout
24245
24246 \end_inset
24247
24248 -model-large
24249 \emph default
24250  is used
24251 \end_layout
24252
24253 \end_inset
24254 </cell>
24255 </row>
24256 <row topline="true">
24257 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24258 \begin_inset Text
24259
24260 \begin_layout Standard
24261 SDCC_USE_XSTACK
24262 \begin_inset LatexCommand index
24263 name "SDCC\\_USE\\_XSTACK"
24264
24265 \end_inset
24266
24267
24268 \end_layout
24269
24270 \end_inset
24271 </cell>
24272 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24273 \begin_inset Text
24274
24275 \begin_layout Standard
24276 when 
24277 \emph on
24278 -
24279 \begin_inset ERT
24280 status collapsed
24281
24282 \begin_layout Standard
24283
24284
24285 \backslash
24286 /
24287 \end_layout
24288
24289 \end_inset
24290
24291 -xstack
24292 \emph default
24293  option is used
24294 \end_layout
24295
24296 \end_inset
24297 </cell>
24298 </row>
24299 <row topline="true">
24300 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24301 \begin_inset Text
24302
24303 \begin_layout Standard
24304 SDCC_STACK_TENBIT
24305 \begin_inset LatexCommand index
24306 name "SDCC\\_STACK\\_TENBIT"
24307
24308 \end_inset
24309
24310  
24311 \end_layout
24312
24313 \end_inset
24314 </cell>
24315 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24316 \begin_inset Text
24317
24318 \begin_layout Standard
24319 when 
24320 \emph on
24321 -mds390
24322 \emph default
24323  is used
24324 \end_layout
24325
24326 \end_inset
24327 </cell>
24328 </row>
24329 <row topline="true">
24330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24331 \begin_inset Text
24332
24333 \begin_layout Standard
24334 SDCC_MODEL_FLAT24
24335 \begin_inset LatexCommand index
24336 name "SDCC\\_MODEL\\_FLAT24"
24337
24338 \end_inset
24339
24340
24341 \end_layout
24342
24343 \end_inset
24344 </cell>
24345 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24346 \begin_inset Text
24347
24348 \begin_layout Standard
24349 when 
24350 \emph on
24351 -mds390
24352 \emph default
24353  is used
24354 \end_layout
24355
24356 \end_inset
24357 </cell>
24358 </row>
24359 <row topline="true">
24360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24361 \begin_inset Text
24362
24363 \begin_layout Standard
24364 SDCC_REVISION
24365 \begin_inset LatexCommand index
24366 name "SDCC\\_REVISION"
24367
24368 \end_inset
24369
24370
24371 \end_layout
24372
24373 \end_inset
24374 </cell>
24375 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24376 \begin_inset Text
24377
24378 \begin_layout Standard
24379 Always defined.
24380  SDCC svn revision number
24381 \end_layout
24382
24383 \end_inset
24384 </cell>
24385 </row>
24386 <row topline="true">
24387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24388 \begin_inset Text
24389
24390 \begin_layout Standard
24391 SDCC_PARMS_IN_BANK1
24392 \begin_inset LatexCommand index
24393 name "SDCC\\_PARMS\\_IN\\_BANK1"
24394
24395 \end_inset
24396
24397
24398 \end_layout
24399
24400 \end_inset
24401 </cell>
24402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24403 \begin_inset Text
24404
24405 \begin_layout Standard
24406 when 
24407 \emph on
24408 -
24409 \begin_inset ERT
24410 status collapsed
24411
24412 \begin_layout Standard
24413
24414
24415 \backslash
24416 /
24417 \end_layout
24418
24419 \end_inset
24420
24421 -parms-in-bank1
24422 \emph default
24423  is used
24424 \end_layout
24425
24426 \end_inset
24427 </cell>
24428 </row>
24429 <row topline="true">
24430 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24431 \begin_inset Text
24432
24433 \begin_layout Standard
24434 SDCC_FLOAT_REENT
24435 \begin_inset LatexCommand index
24436 name "SDCC\\_MODEL\\_FLAT24"
24437
24438 \end_inset
24439
24440
24441 \end_layout
24442
24443 \end_inset
24444 </cell>
24445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24446 \begin_inset Text
24447
24448 \begin_layout Standard
24449 when 
24450 \emph on
24451 -
24452 \begin_inset ERT
24453 status collapsed
24454
24455 \begin_layout Standard
24456
24457
24458 \backslash
24459 /
24460 \end_layout
24461
24462 \end_inset
24463
24464 -float-reent
24465 \emph default
24466  is used
24467 \end_layout
24468
24469 \end_inset
24470 </cell>
24471 </row>
24472 <row topline="true" bottomline="true">
24473 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24474 \begin_inset Text
24475
24476 \begin_layout Standard
24477 SDCC_INT_LONG_REENT
24478 \begin_inset LatexCommand index
24479 name "SDCC\\_INT\\_LONG\\_REENT"
24480
24481 \end_inset
24482
24483
24484 \end_layout
24485
24486 \end_inset
24487 </cell>
24488 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24489 \begin_inset Text
24490
24491 \begin_layout Standard
24492 when 
24493 \emph on
24494 -
24495 \begin_inset ERT
24496 status collapsed
24497
24498 \begin_layout Standard
24499
24500
24501 \backslash
24502 /
24503 \end_layout
24504
24505 \end_inset
24506
24507 -int-long-reent
24508 \emph default
24509  is used
24510 \end_layout
24511
24512 \end_inset
24513 </cell>
24514 </row>
24515 </lyxtabular>
24516
24517 \end_inset
24518
24519
24520 \end_layout
24521
24522 \begin_layout Chapter
24523 Notes on supported Processors
24524 \end_layout
24525
24526 \begin_layout Section
24527 MCS51 variants
24528 \begin_inset LatexCommand label
24529 name "sub:MCS51-variants"
24530
24531 \end_inset
24532
24533
24534 \begin_inset LatexCommand index
24535 name "MCS51 variants"
24536
24537 \end_inset
24538
24539
24540 \end_layout
24541
24542 \begin_layout Standard
24543 MCS51 processors are available from many vendors and come in many different
24544  flavours.
24545  While they might differ considerably in respect to Special Function Registers
24546  the core MCS51 is usually not modified or is kept compatible.
24547  
24548 \end_layout
24549
24550 \begin_layout Subsection
24551 pdata access by SFR 
24552 \end_layout
24553
24554 \begin_layout Standard
24555 With the upcome of devices with internal xdata and flash memory devices
24556  using port P2
24557 \begin_inset LatexCommand index
24558 name "P2 (mcs51 sfr)"
24559
24560 \end_inset
24561
24562  as dedicated I/O port is becoming more popular.
24563  Switching the high byte for pdata
24564 \begin_inset LatexCommand index
24565 name "pdata (mcs51, ds390 storage class)"
24566
24567 \end_inset
24568
24569  access which was formerly done by port P2 is then achieved by a Special
24570  Function Register
24571 \begin_inset LatexCommand index
24572 name "sfr"
24573
24574 \end_inset
24575
24576 .
24577  In well-established MCS51 tradition the address of this 
24578 \emph on
24579 sfr
24580 \emph default
24581  is where the chip designers decided to put it.
24582  Needless to say that they didn't agree on a common name either.
24583  So that the startup code can correctly initialize xdata variables, you
24584  should define an sfr with the name _XPAGE
24585 \family typewriter
24586
24587 \begin_inset LatexCommand index
24588 name "\\_XPAGE (mcs51)"
24589
24590 \end_inset
24591
24592
24593 \family default
24594  at the appropriate location if the default, port P2, is not used for this.
24595  Some examples are:
24596 \end_layout
24597
24598 \begin_layout Verse
24599
24600 \family typewriter
24601 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
24602  MPAGE */
24603 \end_layout
24604
24605 \begin_layout Verse
24606
24607 \family typewriter
24608 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
24609  a.k.a.
24610  MPAGE */
24611 \end_layout
24612
24613 \begin_layout Verse
24614
24615 \family typewriter
24616 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
24617  XPAGE */
24618 \end_layout
24619
24620 \begin_layout Verse
24621
24622 \family typewriter
24623 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24624  EMI0CN */
24625 \end_layout
24626
24627 \begin_layout Verse
24628
24629 \family typewriter
24630 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24631  EMI0CN */
24632 \end_layout
24633
24634 \begin_layout Standard
24635 For more exotic implementations further customizations may be needed.
24636  See section 
24637 \begin_inset LatexCommand ref
24638 reference "sub:Startup-Code"
24639
24640 \end_inset
24641
24642  for other possibilities.
24643 \end_layout
24644
24645 \begin_layout Subsection
24646 Other Features available by SFR
24647 \end_layout
24648
24649 \begin_layout Standard
24650 Some MCS51 variants offer features like Double DPTR
24651 \begin_inset LatexCommand index
24652 name "DPTR"
24653
24654 \end_inset
24655
24656 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
24657  These are currently not used for the MCS51 port.
24658  If you absolutely need them you can fall back to inline assembly or submit
24659  a patch to SDCC.
24660 \end_layout
24661
24662 \begin_layout Subsection
24663 Bankswitching
24664 \end_layout
24665
24666 \begin_layout Standard
24667 Bankswitching
24668 \begin_inset LatexCommand index
24669 name "Bankswitching"
24670
24671 \end_inset
24672
24673  (a.k.a.
24674  code banking
24675 \begin_inset LatexCommand index
24676 name "code banking"
24677
24678 \end_inset
24679
24680 ) is a technique to increase the code space above the 64k limit of the 8051.
24681 \end_layout
24682
24683 \begin_layout Subsubsection
24684 Hardware
24685 \end_layout
24686
24687 \begin_layout Standard
24688 \begin_inset Tabular
24689 <lyxtabular version="3" rows="3" columns="4">
24690 <features>
24691 <column alignment="center" valignment="top" width="0">
24692 <column alignment="center" valignment="top" leftline="true" width="0">
24693 <column alignment="center" valignment="top" leftline="true" width="0">
24694 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24695 <row topline="true" bottomline="true">
24696 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24697 \begin_inset Text
24698
24699 \begin_layout Standard
24700 8000-FFFF
24701 \end_layout
24702
24703 \end_inset
24704 </cell>
24705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24706 \begin_inset Text
24707
24708 \begin_layout Standard
24709 bank1
24710 \end_layout
24711
24712 \end_inset
24713 </cell>
24714 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24715 \begin_inset Text
24716
24717 \begin_layout Standard
24718 bank2
24719 \end_layout
24720
24721 \end_inset
24722 </cell>
24723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24724 \begin_inset Text
24725
24726 \begin_layout Standard
24727 bank3
24728 \end_layout
24729
24730 \end_inset
24731 </cell>
24732 </row>
24733 <row topline="true" bottomline="true">
24734 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24735 \begin_inset Text
24736
24737 \begin_layout Standard
24738 0000-7FFF
24739 \end_layout
24740
24741 \end_inset
24742 </cell>
24743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24744 \begin_inset Text
24745
24746 \begin_layout Standard
24747 common
24748 \end_layout
24749
24750 \end_inset
24751 </cell>
24752 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24753 \begin_inset Text
24754
24755 \begin_layout Standard
24756
24757 \end_layout
24758
24759 \end_inset
24760 </cell>
24761 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24762 \begin_inset Text
24763
24764 \begin_layout Standard
24765
24766 \end_layout
24767
24768 \end_inset
24769 </cell>
24770 </row>
24771 <row>
24772 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24773 \begin_inset Text
24774
24775 \begin_layout Standard
24776 SiLabs C8051F120 example
24777 \end_layout
24778
24779 \end_inset
24780 </cell>
24781 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
24782 \begin_inset Text
24783
24784 \begin_layout Standard
24785
24786 \end_layout
24787
24788 \end_inset
24789 </cell>
24790 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24791 \begin_inset Text
24792
24793 \begin_layout Standard
24794
24795 \end_layout
24796
24797 \end_inset
24798 </cell>
24799 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24800 \begin_inset Text
24801
24802 \begin_layout Standard
24803
24804 \end_layout
24805
24806 \end_inset
24807 </cell>
24808 </row>
24809 </lyxtabular>
24810
24811 \end_inset
24812
24813
24814 \newline
24815
24816 \newline
24817 Usually the hardware uses some sfr (an output port or an internal sfr) to
24818  select a bank and put it in the banked area of the memory map.
24819  The selected bank usually becomes active immediately upon assignment to
24820  this sfr and when running inside a bank it will switch out this code it
24821  is currently running.
24822  Therefor you cannot jump or call directly from one bank to another and
24823  need to use a so-called trampoline in the common area.
24824  For SDCC an example trampoline is in crtbank.asm and you may need to change
24825  it to your 8051 derivative or schematic.
24826  The presented code is written for the C8051F120.
24827 \newline
24828
24829 \newline
24830 When calling a banked function
24831  SDCC will put the LSB of the functions address in register R0, the MSB
24832  in R1 and the bank in R2 and then call this trampoline 
24833 \emph on
24834 __sdcc_banked_call
24835 \emph default
24836 .
24837  The current selected bank is saved on the stack, the new bank is selected
24838  and an indirect jump is made.
24839  When the banked function returns it jumps to 
24840 \emph on
24841 __sdcc_banked_ret
24842 \emph default
24843  which restores the previous bank and returns to the caller.
24844 \end_layout
24845
24846 \begin_layout Subsubsection
24847 Software
24848 \end_layout
24849
24850 \begin_layout Standard
24851 When writing banked software using SDCC you need to use some special keywords
24852  and options.
24853  You also need to take over a bit of work from the linker.
24854 \newline
24855
24856 \newline
24857 To create a function
24858  that can be called from another bank it requires the keyword 
24859 \emph on
24860 banked
24861 \emph default
24862
24863 \begin_inset LatexCommand index
24864 name "banked"
24865
24866 \end_inset
24867
24868 .
24869  The caller must see this in the prototype of the callee and the callee
24870  needs it for a proper return.
24871  Called functions within the same bank as the caller do not need the 
24872 \emph on
24873 banked
24874 \emph default
24875  keyword nor do functions in the common area.
24876  Beware: SDCC does not know or check if functions are in the same bank.
24877  This is your responsibility!
24878 \newline
24879
24880 \newline
24881 Normally all functions you write end up in
24882  the segment CSEG.
24883  If you want a function explicitly to reside in the common area put it in
24884  segment HOME.
24885  This applies for instance to interrupt service routines as they should
24886  not be banked.
24887 \end_layout
24888
24889 \begin_layout Standard
24890 Functions that need to be in a switched bank must be put in a named segment.
24891  The name can be mostly anything up to eight characters (e.g.
24892  BANK1).
24893  To do this you either use -
24894 \begin_inset ERT
24895 status collapsed
24896
24897 \begin_layout Standard
24898
24899
24900 \backslash
24901 /
24902 \end_layout
24903
24904 \end_inset
24905
24906 -codeseg BANK1 (See 
24907 \begin_inset LatexCommand ref
24908 reference "lyx:-codeseg"
24909
24910 \end_inset
24911
24912 ) on the command line when compiling or #pragma codeseg BANK1 (See 
24913 \begin_inset LatexCommand ref
24914 reference "sec:Pragmas"
24915
24916 \end_inset
24917
24918 ) at the top of the C source file.
24919  The segment name always applies to the whole source file and generated
24920  object so functions for different banks need to be defined in different
24921  source files.
24922 \newline
24923
24924 \newline
24925 When linking your objects you need to tell the linker where
24926  to put your segments.
24927  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
24928 00 (See 
24929 \begin_inset LatexCommand ref
24930 reference "lyx:-Wl option"
24931
24932 \end_inset
24933
24934 ).
24935  This sets the virtual start address of this segment.
24936  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
24937  The linker will not check for overflows, again this is your responsibility.
24938 \end_layout
24939
24940 \begin_layout Standard
24941 \begin_inset VSpace bigskip
24942 \end_inset
24943
24944
24945 \end_layout
24946
24947 \begin_layout Section
24948 DS400 port
24949 \end_layout
24950
24951 \begin_layout Standard
24952 The DS80C400
24953 \begin_inset LatexCommand index
24954 name "DS80C400"
24955
24956 \end_inset
24957
24958
24959 \begin_inset LatexCommand index
24960 name "DS400"
24961
24962 \end_inset
24963
24964  microcontroller has a rich set of peripherals.
24965  In its built-in ROM library it includes functions to access some of the
24966  features, among them is a TCP stack with IP4 and IP6 support.
24967  Library headers (currently in beta status) and other files are provided
24968  at 
24969 \size footnotesize
24970
24971 \begin_inset LatexCommand url
24972 target "ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html"
24973
24974 \end_inset
24975
24976 .
24977  
24978 \begin_inset VSpace bigskip
24979 \end_inset
24980
24981
24982 \end_layout
24983
24984 \begin_layout Section
24985 The Z80 and gbz80 port
24986 \end_layout
24987
24988 \begin_layout Standard
24989 SDCC can target both the Zilog Z80
24990 \begin_inset LatexCommand index
24991 name "Z80"
24992
24993 \end_inset
24994
24995  and the Nintendo Gameboy's Z80-like gbz80
24996 \begin_inset LatexCommand index
24997 name "gbz80 (GameBoy Z80)"
24998
24999 \end_inset
25000
25001 .
25002  The Z80 port is passed through the same 
25003 \emph on
25004 regressions tests
25005 \begin_inset LatexCommand index
25006 name "Regression test"
25007
25008 \end_inset
25009
25010
25011 \emph default
25012  (see section 
25013 \begin_inset LatexCommand ref
25014 reference "sec:Quality-control"
25015
25016 \end_inset
25017
25018 ) as the MCS51 and DS390 ports, so floating point support, support for long
25019  variables and bitfield support is fine.
25020  See mailing lists and forums about interrupt routines.
25021 \end_layout
25022
25023 \begin_layout Standard
25024 As always, the code is the authoritative reference - see z80/ralloc.c and
25025  z80/gen.c.
25026  The stack
25027 \begin_inset LatexCommand index
25028 name "Z80!stack"
25029
25030 \end_inset
25031
25032  frame is similar to that generated by the IAR Z80 compiler.
25033  IX is used as the base pointer, HL and IY are used as a temporary registers,
25034  and BC and DE are available for holding variables.
25035  Return values
25036 \begin_inset LatexCommand index
25037 name "Z80!return value"
25038
25039 \end_inset
25040
25041  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
25042  bytes).
25043  The gbz80 port use the same set of registers for the return values, but
25044  in a different order of significance: E (one byte), DE (two bytes), or
25045  HLDE (four bytes).
25046 \begin_inset VSpace bigskip
25047 \end_inset
25048
25049
25050 \end_layout
25051
25052 \begin_layout Section
25053 The HC08 port
25054 \end_layout
25055
25056 \begin_layout Standard
25057 The port to the Freescale/Motorola HC08
25058 \begin_inset LatexCommand index
25059 name "HC08"
25060
25061 \end_inset
25062
25063  family has been added in October 2003, and is still undergoing some basic
25064  development.
25065  The code generator is complete, but the register allocation is still quite
25066  unoptimized.
25067  Some of the SDCC's standard C library functions have embedded non-HC08
25068  inline assembly and so are not yet usable.
25069 \end_layout
25070
25071 \begin_layout Standard
25072 The HC08 port passes the regression test suite (see section 
25073 \begin_inset LatexCommand ref
25074 reference "sec:Quality-control"
25075
25076 \end_inset
25077
25078 ).
25079 \begin_inset VSpace bigskip
25080 \end_inset
25081
25082
25083 \end_layout
25084
25085 \begin_layout Section
25086 The PIC14
25087 \begin_inset LatexCommand index
25088 name "PIC14"
25089
25090 \end_inset
25091
25092  port
25093 \end_layout
25094
25095 \begin_layout Standard
25096 The PIC14 port adds support for Microchip
25097 \begin_inset LatexCommand index
25098 name "Microchip"
25099
25100 \end_inset
25101
25102
25103 \begin_inset Formula $^{\text{TM}}$
25104 \end_inset
25105
25106  PIC
25107 \begin_inset LatexCommand index
25108 name "PIC14"
25109
25110 \end_inset
25111
25112
25113 \begin_inset Formula $^{\text{TM}}$
25114 \end_inset
25115
25116  MCUs with 14 bit wide instructions.
25117  This port is not yet mature and still lacks many features.
25118  However, it can work for simple code.
25119 \end_layout
25120
25121 \begin_layout Standard
25122 \noindent
25123 Currently supported devices include:
25124 \end_layout
25125
25126 \begin_layout Standard
25127 12F: 629, 635, 675, 683
25128 \end_layout
25129
25130 \begin_layout Standard
25131 16C: 432, 433
25132 \end_layout
25133
25134 \begin_layout Standard
25135 16C: 554, 557, 558
25136 \end_layout
25137
25138 \begin_layout Standard
25139 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
25140 \end_layout
25141
25142 \begin_layout Standard
25143 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
25144  781, 782
25145 \end_layout
25146
25147 \begin_layout Standard
25148 16C: 925, 926
25149 \end_layout
25150
25151 \begin_layout Standard
25152 16CR: 620a, 73, 74, 76, 77
25153 \end_layout
25154
25155 \begin_layout Standard
25156 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
25157  687, 688, 689, 690
25158 \end_layout
25159
25160 \begin_layout Standard
25161 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
25162 \end_layout
25163
25164 \begin_layout Standard
25165 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
25166  877, 877a, 88, 886, 887
25167 \end_layout
25168
25169 \begin_layout Standard
25170 16F: 913, 914, 916, 917, 946
25171 \end_layout
25172
25173 \begin_layout Standard
25174 26HV: 626, 785
25175 \end_layout
25176
25177 \begin_layout Standard
25178 \noindent
25179 An up-to-date list of currently supported devices can be obtained via 
25180 \family typewriter
25181 sdcc -mpic14 -phelp foo.c
25182 \family default
25183  (foo.c must exist...).
25184 \end_layout
25185
25186 \begin_layout Subsection
25187 PIC Code Pages
25188 \begin_inset LatexCommand index
25189 name "code page (pic14)"
25190
25191 \end_inset
25192
25193  and Memory Banks
25194 \begin_inset LatexCommand index
25195 name "Memory bank (pic14)"
25196
25197 \end_inset
25198
25199
25200 \end_layout
25201
25202 \begin_layout Standard
25203 The linker organizes allocation for the code page and RAM banks.
25204  It does not have intimate knowledge of the code flow.
25205  It will put all the code section of a single .asm file into a single code
25206  page.
25207  In order to make use of multiple code pages, separate asm files must be
25208  used.
25209  The compiler assigns all 
25210 \emph on
25211 static
25212 \emph default
25213  functions of a single .c file into the same code page.
25214 \newline
25215
25216 \newline
25217 To get the best results,
25218  follow these guidelines:
25219 \end_layout
25220
25221 \begin_layout Enumerate
25222 Make local functions static, as non static functions require code page selection
25223  overhead.
25224 \newline
25225 Due to the way sdcc handles functions, place called functions prior
25226  to calling functions in the file wherever possible: Otherwise sdcc will
25227  insert unnecessary pagesel directives around the call, believing that the
25228  called function is externally defined.
25229 \end_layout
25230
25231 \begin_layout Enumerate
25232 For devices that have multiple code pages it is more efficient to use the
25233  same number of files as pages: Use up to 4 separate .c files for the 16F877,
25234  but only 2 files for the 16F874.
25235  This way the linker can put the code for each file into different code
25236  pages and there will be less page selection overhead.
25237 \end_layout
25238
25239 \begin_layout Enumerate
25240 And as for any 8 bit micro (especially for PIC14 as they have a very simple
25241  instruction set), use `unsigned char' wherever possible instead of `int'.
25242 \end_layout
25243
25244 \begin_layout Subsection
25245 Adding New Devices to the Port 
25246 \end_layout
25247
25248 \begin_layout Standard
25249 Adding support for a new 14
25250 \begin_inset ERT
25251 status open
25252
25253 \begin_layout Standard
25254
25255
25256 \backslash
25257 ,
25258 \end_layout
25259
25260 \end_inset
25261
25262 bit PIC MCU requires the following steps:
25263 \end_layout
25264
25265 \begin_layout Enumerate
25266 Create a new device description.
25267 \newline
25268 Each device is described in two files: pic16f*.h
25269  and pic16f*.c.
25270  These files primarily define SFRs, structs to access their bits, and symbolic
25271  configuration options.
25272  Both files can be generated from gputils' .inc files using the perl script
25273  
25274 \family typewriter
25275 support/scripts/inc2h.pl
25276 \family default
25277 .
25278  This file also contains further instructions on how to proceed.
25279 \end_layout
25280
25281 \begin_layout Enumerate
25282 Copy the .h file into SDCC's include path and either add the .c file to your
25283  project or copy it to 
25284 \family typewriter
25285 device/lib/pic/libdev
25286 \family default
25287 .
25288  Afterwards, rebuild and install the libraries.
25289 \end_layout
25290
25291 \begin_layout Enumerate
25292 Edit pic14devices.txt in SDCC's include path (
25293 \family typewriter
25294 device/include/pic/
25295 \family default
25296  in the source tree or 
25297 \family typewriter
25298 /usr/local/share/sdcc/include/pic
25299 \family default
25300  after installation).
25301 \newline
25302 You need to add a device specification here to make
25303  the memory layout (code banks, RAM, aliased memory regions, ...) known to
25304  the compiler.
25305  Probably you can copy and modify an existing entry.
25306  The file format is documented at the top of the file.
25307 \end_layout
25308
25309 \begin_layout Subsection
25310 Interrupt Code
25311 \end_layout
25312
25313 \begin_layout Standard
25314 For the interrupt function, use the keyword `__interrupt'
25315 \begin_inset LatexCommand index
25316 name "PIC14!interrupt"
25317
25318 \end_inset
25319
25320  with level number of 0 (PIC14 only has 1 interrupt so this number is only
25321  there to avoid a syntax error - it ought to be fixed).
25322  E.g.:
25323 \end_layout
25324
25325 \begin_layout Verse
25326
25327 \family typewriter
25328 void Intr(void) __interrupt 0
25329 \newline
25330 {
25331 \newline
25332 \InsetSpace ~
25333 \InsetSpace ~
25334 T0IF = 0; /* Clear timer interrupt */
25335 \newline
25336 }
25337 \end_layout
25338
25339 \begin_layout Subsection
25340 Linking and Assembling
25341 \end_layout
25342
25343 \begin_layout Standard
25344 For assembling you can use either GPUTILS'
25345 \begin_inset LatexCommand index
25346 name "gputils (pic tools)"
25347
25348 \end_inset
25349
25350  gpasm.exe or MPLAB's mpasmwin.exe.
25351  GPUTILS are available from 
25352 \begin_inset LatexCommand url
25353 target "http://sourceforge.net/projects/gputils"
25354
25355 \end_inset
25356
25357 .
25358  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
25359  If you use MPLAB and an interrupt function then the linker script file
25360  vectors section will need to be enlarged to link with mplink.
25361 \newline
25362
25363 \newline
25364 Here is a 
25365 \family typewriter
25366 Makefile
25367 \family default
25368  using GPUTILS:
25369 \end_layout
25370
25371 \begin_layout Verse
25372
25373 \family typewriter
25374 .c.o:
25375 \newline
25376 \InsetSpace ~
25377 \InsetSpace ~
25378 \InsetSpace ~
25379 \InsetSpace ~
25380 \InsetSpace ~
25381 \InsetSpace ~
25382 \InsetSpace ~
25383 \InsetSpace ~
25384 sdcc -V -mpic14 -p16f877 -c $< 
25385 \newline
25386
25387 \newline
25388 $(PRJ).hex: $(OBJS) 
25389 \newline
25390 \InsetSpace ~
25391 \InsetSpace ~
25392 \InsetSpace ~
25393 \InsetSpace ~
25394 \InsetSpace ~
25395 \InsetSpace ~
25396 \InsetSpace ~
25397 \InsetSpace ~
25398 gplink -m -s $(PRJ).lkr
25399  -o $(PRJ).hex $(OBJS) libsdcc.lib
25400 \end_layout
25401
25402 \begin_layout Standard
25403 Here is a 
25404 \family typewriter
25405 Makefile
25406 \family default
25407  using MPLAB:
25408 \end_layout
25409
25410 \begin_layout Verse
25411
25412 \family typewriter
25413 .c.o: 
25414 \newline
25415 \InsetSpace ~
25416 \InsetSpace ~
25417 \InsetSpace ~
25418 \InsetSpace ~
25419 \InsetSpace ~
25420 \InsetSpace ~
25421 \InsetSpace ~
25422 \InsetSpace ~
25423 sdcc -S -V -mpic14 -p16f877 $< 
25424 \newline
25425 \InsetSpace ~
25426 \InsetSpace ~
25427 \InsetSpace ~
25428 \InsetSpace ~
25429 \InsetSpace ~
25430 \InsetSpace ~
25431 \InsetSpace ~
25432 \InsetSpace ~
25433 mpasmwin /q /o $*.asm
25434 \newline
25435
25436 \newline
25437 $(PRJ).hex: $(OBJS)
25438  
25439 \newline
25440 \InsetSpace ~
25441 \InsetSpace ~
25442 \InsetSpace ~
25443 \InsetSpace ~
25444 \InsetSpace ~
25445 \InsetSpace ~
25446 \InsetSpace ~
25447 \InsetSpace ~
25448 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
25449 \end_layout
25450
25451 \begin_layout Standard
25452 Please note that indentations within a 
25453 \family typewriter
25454 Makefile
25455 \family default
25456  have to be done with a tabulator character.
25457 \end_layout
25458
25459 \begin_layout Subsection
25460 Command-Line Options
25461 \end_layout
25462
25463 \begin_layout Standard
25464 Besides the switches common to all SDCC backends, the PIC14 port accepts
25465  the following options (for an updated list see sdcc -
25466 \begin_inset ERT
25467 status collapsed
25468
25469 \begin_layout Standard
25470
25471
25472 \backslash
25473 /
25474 \end_layout
25475
25476 \end_inset
25477
25478 -help):
25479 \end_layout
25480
25481 \begin_layout Description
25482 -
25483 \begin_inset ERT
25484 status collapsed
25485
25486 \begin_layout Standard
25487
25488
25489 \backslash
25490 /
25491 \end_layout
25492
25493 \end_inset
25494
25495 -debug-xtra
25496 \begin_inset LatexCommand index
25497 name "PIC14!Options!-\\/-debug-extra"
25498
25499 \end_inset
25500
25501  emit debug info in assembly output
25502 \end_layout
25503
25504 \begin_layout Description
25505 -
25506 \begin_inset ERT
25507 status collapsed
25508
25509 \begin_layout Standard
25510
25511
25512 \backslash
25513 /
25514 \end_layout
25515
25516 \end_inset
25517
25518 -no-pcode-opt
25519 \begin_inset LatexCommand index
25520 name "PIC14!Options!-\\/-no-pcode-opt"
25521
25522 \end_inset
25523
25524  disable (slightly faulty) optimization on pCode
25525 \end_layout
25526
25527 \begin_layout Description
25528 -
25529 \begin_inset ERT
25530 status collapsed
25531
25532 \begin_layout Standard
25533
25534
25535 \backslash
25536 /
25537 \end_layout
25538
25539 \end_inset
25540
25541 -stack-loc
25542 \begin_inset LatexCommand index
25543 name "PIC14!Options!-\\/-stack-loc"
25544
25545 \end_inset
25546
25547  sets the lowest address of the argument passing stack (defaults to a suitably
25548  large shared databank to reduce BANKSEL overhead)
25549 \end_layout
25550
25551 \begin_layout Description
25552 -
25553 \begin_inset ERT
25554 status collapsed
25555
25556 \begin_layout Standard
25557
25558
25559 \backslash
25560 /
25561 \end_layout
25562
25563 \end_inset
25564
25565 -stack-size
25566 \begin_inset LatexCommand index
25567 name "PIC14!Options!-\\/-stack-size"
25568
25569 \end_inset
25570
25571  sets the size if the argument passing stack (default: 16, minimum: 4)
25572 \end_layout
25573
25574 \begin_layout Subsection
25575 Environment Variables
25576 \end_layout
25577
25578 \begin_layout Standard
25579 The PIC14 port recognizes the following environment variables:
25580 \end_layout
25581
25582 \begin_layout Description
25583 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
25584  register (the ones called r0xNNNN) in a section of its own.
25585  By default (if this variable is unset), sdcc tries to cluster registers
25586  in sections in order to reduce the BANKSEL overhead when accessing them.
25587 \end_layout
25588
25589 \begin_layout Subsection
25590 The Library
25591 \end_layout
25592
25593 \begin_layout Standard
25594 The PIC14 library currently only contains support routines required by the
25595  compiler to implement multiplication, division, and floating point support.
25596  No libc-like replacement is available at the moment, though many of the
25597  common sdcc library sources (in 
25598 \family typewriter
25599 device/lib
25600 \family default
25601 ) should also compile with the PIC14 port.
25602 \end_layout
25603
25604 \begin_layout Subsubsection
25605 error: missing definition for symbol ``__gptrget1''
25606 \end_layout
25607
25608 \begin_layout Standard
25609 The PIC14 port uses library routines to provide more complex operations
25610  like multiplication, division/modulus and (generic) pointer dereferencing.
25611  In order to add these routines to your project, you must link with PIC14's
25612  
25613 \family typewriter
25614 libsdcc.lib
25615 \family default
25616 .
25617  For single source file projects this is done automatically, more complex
25618  projects must add 
25619 \family typewriter
25620 libsdcc.lib
25621 \family default
25622  to the linker's arguments.
25623  Make sure you also add an include path for the library (using the -I switch
25624  to the linker)!
25625 \end_layout
25626
25627 \begin_layout Subsubsection
25628 Processor mismatch in file ``XXX''.
25629 \end_layout
25630
25631 \begin_layout Standard
25632 This warning can usually be ignored due to the very good compatibility amongst
25633  14
25634 \begin_inset ERT
25635 status open
25636
25637 \begin_layout Standard
25638
25639
25640 \backslash
25641 ,
25642 \end_layout
25643
25644 \end_inset
25645
25646 bit PIC
25647 \begin_inset LatexCommand index
25648 name "PIC14"
25649
25650 \end_inset
25651
25652  devices.
25653 \end_layout
25654
25655 \begin_layout Standard
25656 You might also consider recompiling the library for your specific device
25657  by changing the ARCH=p16f877 (default target) entry in 
25658 \family typewriter
25659 device/lib/pic/Makefile.in
25660 \family default
25661  and 
25662 \family typewriter
25663 device/lib/pic/Makefile
25664 \family default
25665  to reflect your device.
25666  This might even improve performance for smaller devices as unnecessary
25667  BANKSELs might be removed.
25668 \end_layout
25669
25670 \begin_layout Subsection
25671 Known Bugs
25672 \end_layout
25673
25674 \begin_layout Subsubsection
25675 Function arguments
25676 \end_layout
25677
25678 \begin_layout Standard
25679 Functions with variable argument lists (like printf) are not yet supported.
25680  Similarly, taking the address of the first argument passed into a function
25681  does not work: It is currently passed in WREG and has no address...
25682 \end_layout
25683
25684 \begin_layout Subsubsection
25685 Regression tests fail
25686 \end_layout
25687
25688 \begin_layout Standard
25689 Though the small subset of regression tests in src/regression passes, SDCC
25690  regression test suite does not, indicating that there are still major bugs
25691  in the port.
25692  However, many smaller projects have successfully used SDCC in the past...
25693 \end_layout
25694
25695 \begin_layout Standard
25696
25697 \size footnotesize
25698
25699 \newpage
25700
25701 \end_layout
25702
25703 \begin_layout Section
25704 The PIC16
25705 \begin_inset LatexCommand index
25706 name "PIC16"
25707
25708 \end_inset
25709
25710  port
25711 \end_layout
25712
25713 \begin_layout Standard
25714 The PIC16 port adds support for Microchip
25715 \begin_inset LatexCommand index
25716 name "Microchip"
25717
25718 \end_inset
25719
25720
25721 \begin_inset Formula $^{\text{TM}}$
25722 \end_inset
25723
25724  PIC
25725 \begin_inset LatexCommand index
25726 name "PIC"
25727
25728 \end_inset
25729
25730
25731 \begin_inset Formula $^{\text{TM}}$
25732 \end_inset
25733
25734  MCUs with 16 bit wide instructions.
25735  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
25736 ; devices supported by the port include:
25737 \end_layout
25738
25739 \begin_layout Standard
25740 18F: 242, 248, 252, 258, 442, 448, 452, 458
25741 \end_layout
25742
25743 \begin_layout Standard
25744 18F: 1220, 1320
25745 \end_layout
25746
25747 \begin_layout Standard
25748 18F: 2220, 2221, 2320, 2321, 2331, 23k20
25749 \end_layout
25750
25751 \begin_layout Standard
25752 18F: 2410, 2420, 2423, 2431, 2450, 2455, 2480, 24j10, 24k20
25753 \end_layout
25754
25755 \begin_layout Standard
25756 18F: 2510, 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 25k20
25757 \end_layout
25758
25759 \begin_layout Standard
25760 18F: 2610, 2620, 2680, 2682, 2685
25761 \end_layout
25762
25763 \begin_layout Standard
25764 18F: 4220, 4221, 4320, 4321, 4331, 43k20
25765 \end_layout
25766
25767 \begin_layout Standard
25768 18F: 4410, 4420, 4423, 4431, 4450, 4455, 4480, 44j10, 44k20
25769 \end_layout
25770
25771 \begin_layout Standard
25772 18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 45k20
25773 \end_layout
25774
25775 \begin_layout Standard
25776 18F: 4610, 4620, 4680, 4682, 4685, 46k20
25777 \end_layout
25778
25779 \begin_layout Standard
25780 18F: 6520, 6585, 65j50, 6620, 6680, 66j50, 66j55, 66j60, 66j65, 6720, 67j50,
25781  67j60
25782 \end_layout
25783
25784 \begin_layout Standard
25785 18F: 8520, 8585, 85j50, 8620, 8680, 86j50, 86j55, 86j60, 86j65, 8720, 87j50,
25786  87j60
25787 \end_layout
25788
25789 \begin_layout Standard
25790 18F: 96j60, 96j65, 97j60
25791 \end_layout
25792
25793 \begin_layout Standard
25794 \noindent
25795 An up-to-date list of supported devices is also available via '
25796 \family typewriter
25797 sdcc -mpic16 -plist
25798 \family default
25799 '.
25800 \end_layout
25801
25802 \begin_layout Subsection
25803 Global Options
25804 \end_layout
25805
25806 \begin_layout Standard
25807 PIC16 port supports the standard command line arguments as supposed, with
25808  the exception of certain cases that will be mentioned in the following
25809  list:
25810 \end_layout
25811
25812 \begin_layout Description
25813 -
25814 \begin_inset ERT
25815 status collapsed
25816
25817 \begin_layout Standard
25818
25819
25820 \backslash
25821 /
25822 \end_layout
25823
25824 \end_inset
25825
25826 -callee-saves
25827 \begin_inset LatexCommand index
25828 name "PIC16!Options!-\\/-callee-saves"
25829
25830 \end_inset
25831
25832  See -
25833 \begin_inset ERT
25834 status collapsed
25835
25836 \begin_layout Standard
25837
25838
25839 \backslash
25840 /
25841 \end_layout
25842
25843 \end_inset
25844
25845 -all-callee-saves
25846 \end_layout
25847
25848 \begin_layout Description
25849 -
25850 \begin_inset ERT
25851 status collapsed
25852
25853 \begin_layout Standard
25854
25855
25856 \backslash
25857 /
25858 \end_layout
25859
25860 \end_inset
25861
25862 -fommit-frame-pointer
25863 \begin_inset LatexCommand index
25864 name "PIC16!Options!-\\/-fommit-frame-pointer"
25865
25866 \end_inset
25867
25868  Frame pointer will be omitted when the function uses no local variables.
25869 \end_layout
25870
25871 \begin_layout Subsection
25872 Port Specific Options
25873 \begin_inset LatexCommand index
25874 name "Options PIC16"
25875
25876 \end_inset
25877
25878
25879 \end_layout
25880
25881 \begin_layout Standard
25882 The port specific options appear after the global options in the sdcc -
25883 \begin_inset ERT
25884 status collapsed
25885
25886 \begin_layout Standard
25887
25888
25889 \backslash
25890 /
25891 \end_layout
25892
25893 \end_inset
25894
25895 -help output.
25896 \end_layout
25897
25898 \begin_layout Subsubsection
25899 Code Generation Options
25900 \end_layout
25901
25902 \begin_layout Standard
25903 These options influence the generated assembler code.
25904 \end_layout
25905
25906 \begin_layout Description
25907 -
25908 \begin_inset ERT
25909 status collapsed
25910
25911 \begin_layout Standard
25912
25913
25914 \backslash
25915 /
25916 \end_layout
25917
25918 \end_inset
25919
25920 -pstack-model=[model] Used in conjunction with the command above.
25921  Defines the stack model to be used, valid stack models are:
25922 \end_layout
25923
25924 \begin_deeper
25925 \begin_layout List
25926 \labelwidthstring 00.00.0000
25927
25928 \emph on
25929 small
25930 \emph default
25931  Selects small stack model.
25932  8 bit stack and frame pointers.
25933  Supports 256 bytes stack size.
25934 \end_layout
25935
25936 \begin_layout List
25937 \labelwidthstring 00.00.0000
25938
25939 \emph on
25940 large
25941 \emph default
25942  Selects large stack model.
25943  16 bit stack and frame pointers.
25944  Supports 65536 bytes stack size.
25945 \end_layout
25946
25947 \end_deeper
25948 \begin_layout Description
25949 -
25950 \begin_inset ERT
25951 status collapsed
25952
25953 \begin_layout Standard
25954
25955
25956 \backslash
25957 /
25958 \end_layout
25959
25960 \end_inset
25961
25962 -pno-banksel Do not generate BANKSEL assembler directives.
25963 \end_layout
25964
25965 \begin_layout Description
25966 -
25967 \begin_inset ERT
25968 status collapsed
25969
25970 \begin_layout Standard
25971
25972
25973 \backslash
25974 /
25975 \end_layout
25976
25977 \end_inset
25978
25979 -extended Enable extended instruction set/literal offset addressing mode.
25980  Use with care!
25981 \end_layout
25982
25983 \begin_layout Subsubsection
25984 Optimization Options
25985 \end_layout
25986
25987 \begin_layout Description
25988 -
25989 \begin_inset ERT
25990 status collapsed
25991
25992 \begin_layout Standard
25993
25994
25995 \backslash
25996 /
25997 \end_layout
25998
25999 \end_inset
26000
26001 -obanksel=n Set optimization level for inserting BANKSELs.
26002 \newline
26003
26004 \end_layout
26005
26006 \begin_deeper
26007 \begin_layout List
26008 \labelwidthstring 00.00.0000
26009 0 no optimization
26010 \end_layout
26011
26012 \begin_layout List
26013 \labelwidthstring 00.00.0000
26014 1 checks previous used register and if it is the same then does not emit
26015  BANKSEL, accounts only for labels.
26016 \end_layout
26017
26018 \begin_layout List
26019 \labelwidthstring 00.00.0000
26020 2 tries to check the location of (even different) symbols and removes BANKSELs
26021  if they are in the same bank.
26022  
26023 \newline
26024
26025 \emph on
26026 Important: There might be problems if the linker script has data sections
26027  across bank borders!
26028 \end_layout
26029
26030 \end_deeper
26031 \begin_layout Description
26032 -
26033 \begin_inset ERT
26034 status collapsed
26035
26036 \begin_layout Standard
26037
26038
26039 \backslash
26040 /
26041 \end_layout
26042
26043 \end_inset
26044
26045 -denable-peeps Force the usage of peepholes.
26046  Use with care.
26047 \end_layout
26048
26049 \begin_layout Description
26050 -
26051 \begin_inset ERT
26052 status collapsed
26053
26054 \begin_layout Standard
26055
26056
26057 \backslash
26058 /
26059 \end_layout
26060
26061 \end_inset
26062
26063 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
26064 \end_layout
26065
26066 \begin_layout Description
26067 -
26068 \begin_inset ERT
26069 status collapsed
26070
26071 \begin_layout Standard
26072
26073
26074 \backslash
26075 /
26076 \end_layout
26077
26078 \end_inset
26079
26080 -optimize-cmp Try to optimize some compares.
26081 \end_layout
26082
26083 \begin_layout Description
26084 -
26085 \begin_inset ERT
26086 status collapsed
26087
26088 \begin_layout Standard
26089
26090
26091 \backslash
26092 /
26093 \end_layout
26094
26095 \end_inset
26096
26097 -optimize-df Analyze the dataflow of the generated code and improve it.
26098 \end_layout
26099
26100 \begin_layout Subsubsection
26101 Assembling Options
26102 \end_layout
26103
26104 \begin_layout Description
26105 -
26106 \begin_inset ERT
26107 status collapsed
26108
26109 \begin_layout Standard
26110
26111
26112 \backslash
26113 /
26114 \end_layout
26115
26116 \end_inset
26117
26118 -asm= Sets the full path and name of an external assembler to call.
26119 \end_layout
26120
26121 \begin_layout Description
26122 -
26123 \begin_inset ERT
26124 status collapsed
26125
26126 \begin_layout Standard
26127
26128
26129 \backslash
26130 /
26131 \end_layout
26132
26133 \end_inset
26134
26135 -mplab-comp MPLAB
26136 \begin_inset LatexCommand index
26137 name "PIC16!MPLAB"
26138
26139 \end_inset
26140
26141  compatibility option.
26142  Currently only suppresses special gpasm directives.
26143 \end_layout
26144
26145 \begin_layout Subsubsection
26146 Linking Options
26147 \end_layout
26148
26149 \begin_layout Description
26150 -
26151 \begin_inset ERT
26152 status collapsed
26153
26154 \begin_layout Standard
26155
26156
26157 \backslash
26158 /
26159 \end_layout
26160
26161 \end_inset
26162
26163 -link= Sets the full path and name of an external linker to call.
26164 \end_layout
26165
26166 \begin_layout Description
26167 -
26168 \begin_inset ERT
26169 status collapsed
26170
26171 \begin_layout Standard
26172
26173
26174 \backslash
26175 /
26176 \end_layout
26177
26178 \end_inset
26179
26180 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
26181  unitialized data variables with [kword].
26182  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
26183 \end_layout
26184
26185 \begin_layout Description
26186 -
26187 \begin_inset ERT
26188 status collapsed
26189
26190 \begin_layout Standard
26191
26192
26193 \backslash
26194 /
26195 \end_layout
26196
26197 \end_inset
26198
26199 -ivt-loc=n Place the interrupt vector table at address 
26200 \emph on
26201 n
26202 \emph default
26203 .
26204  Useful for bootloaders.
26205 \end_layout
26206
26207 \begin_layout Description
26208 -
26209 \begin_inset ERT
26210 status collapsed
26211
26212 \begin_layout Standard
26213
26214
26215 \backslash
26216 /
26217 \end_layout
26218
26219 \end_inset
26220
26221 -nodefaultlibs Do not link default libraries when linking.
26222 \end_layout
26223
26224 \begin_layout Description
26225 -
26226 \begin_inset ERT
26227 status collapsed
26228
26229 \begin_layout Standard
26230
26231
26232 \backslash
26233 /
26234 \end_layout
26235
26236 \end_inset
26237
26238 -use-crt= Use a custom run-time module instead of the defaults.
26239 \end_layout
26240
26241 \begin_layout Description
26242 -
26243 \begin_inset ERT
26244 status collapsed
26245
26246 \begin_layout Standard
26247
26248
26249 \backslash
26250 /
26251 \end_layout
26252
26253 \end_inset
26254
26255 -no-crt Don't link the default run-time modules
26256 \end_layout
26257
26258 \begin_layout Subsubsection
26259 Debugging Options
26260 \end_layout
26261
26262 \begin_layout Standard
26263 Debugging options enable extra debugging information in the output files.
26264 \end_layout
26265
26266 \begin_layout Description
26267 -
26268 \begin_inset ERT
26269 status collapsed
26270
26271 \begin_layout Standard
26272
26273
26274 \backslash
26275 /
26276 \end_layout
26277
26278 \end_inset
26279
26280 -debug-xtra Similar to -
26281 \begin_inset ERT
26282 status collapsed
26283
26284 \begin_layout Standard
26285
26286
26287 \backslash
26288 /
26289 \end_layout
26290
26291 \end_inset
26292
26293 -debug
26294 \begin_inset LatexCommand index
26295 name "-\\/-debug"
26296
26297 \end_inset
26298
26299 , but dumps more information.
26300 \end_layout
26301
26302 \begin_layout Description
26303 -
26304 \begin_inset ERT
26305 status collapsed
26306
26307 \begin_layout Standard
26308
26309
26310 \backslash
26311 /
26312 \end_layout
26313
26314 \end_inset
26315
26316 -debug-ralloc Force register allocator to dump <source>.d file with debugging
26317  information.
26318  <source> is the name of the file being compiled.
26319 \end_layout
26320
26321 \begin_layout Description
26322 -
26323 \begin_inset ERT
26324 status collapsed
26325
26326 \begin_layout Standard
26327
26328
26329 \backslash
26330 /
26331 \end_layout
26332
26333 \end_inset
26334
26335 -pcode-verbose Enable pcode debugging information in translation.
26336 \end_layout
26337
26338 \begin_layout Description
26339 -
26340 \begin_inset ERT
26341 status collapsed
26342
26343 \begin_layout Standard
26344
26345
26346 \backslash
26347 /
26348 \end_layout
26349
26350 \end_inset
26351
26352 -calltree Dump call tree in .calltree file.
26353 \end_layout
26354
26355 \begin_layout Description
26356 -
26357 \begin_inset ERT
26358 status collapsed
26359
26360 \begin_layout Standard
26361
26362
26363 \backslash
26364 /
26365 \end_layout
26366
26367 \end_inset
26368
26369 -gstack Trace push/pops for stack pointer overflow.
26370 \end_layout
26371
26372 \begin_layout Subsection
26373 Environment Variables
26374 \end_layout
26375
26376 \begin_layout Standard
26377 There is a number of environmental variables that can be used when running
26378  SDCC to enable certain optimizations or force a specific program behaviour.
26379  these variables are primarily for debugging purposes so they can be enabled/dis
26380 abled at will.
26381 \end_layout
26382
26383 \begin_layout Standard
26384 Currently there is only two such variables available:
26385 \end_layout
26386
26387 \begin_layout Description
26388 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
26389  bitfields is optimized by directly loading FSR0 with the address of the
26390  bitfield structure.
26391  Normally SDCC will cast the bitfield structure to a bitfield pointer and
26392  then load FSR0.
26393  This step saves data ram and code space for functions that make heavy use
26394  of bitfields.
26395  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
26396  option).
26397  
26398 \end_layout
26399
26400 \begin_layout Description
26401 NO_REG_OPT Do not perform pCode registers optimization.
26402  This should be used for debugging purposes.
26403  If bugs in the pcode optimizer are found, users can benefit from temporarily
26404  disabling the optimizer until the bug is fixed.
26405 \end_layout
26406
26407 \begin_layout Subsection
26408 Preprocessor Macros
26409 \end_layout
26410
26411 \begin_layout Standard
26412 PIC16
26413 \begin_inset LatexCommand index
26414 name "PIC16"
26415
26416 \end_inset
26417
26418  port defines the following preprocessor macros while translating a source.
26419 \end_layout
26420
26421 \begin_layout Standard
26422 \align center
26423 \begin_inset Tabular
26424 <lyxtabular version="3" rows="6" columns="2">
26425 <features>
26426 <column alignment="center" valignment="top" leftline="true" width="0">
26427 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26428 <row topline="true" bottomline="true">
26429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26430 \begin_inset Text
26431
26432 \begin_layout Standard
26433 Macro
26434 \end_layout
26435
26436 \end_inset
26437 </cell>
26438 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26439 \begin_inset Text
26440
26441 \begin_layout Standard
26442 Description
26443 \end_layout
26444
26445 \end_inset
26446 </cell>
26447 </row>
26448 <row topline="true">
26449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26450 \begin_inset Text
26451
26452 \begin_layout Standard
26453 SDCC_pic16
26454 \end_layout
26455
26456 \end_inset
26457 </cell>
26458 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26459 \begin_inset Text
26460
26461 \begin_layout Standard
26462 Port identification
26463 \end_layout
26464
26465 \end_inset
26466 </cell>
26467 </row>
26468 <row topline="true">
26469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26470 \begin_inset Text
26471
26472 \begin_layout Standard
26473 _
26474 \begin_inset ERT
26475 status collapsed
26476
26477 \begin_layout Standard
26478
26479
26480 \backslash
26481 /
26482 \end_layout
26483
26484 \end_inset
26485
26486 _pic16
26487 \end_layout
26488
26489 \end_inset
26490 </cell>
26491 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26492 \begin_inset Text
26493
26494 \begin_layout Standard
26495 Port identification (same as above)
26496 \end_layout
26497
26498 \end_inset
26499 </cell>
26500 </row>
26501 <row topline="true">
26502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26503 \begin_inset Text
26504
26505 \begin_layout Standard
26506 pic18fxxxx
26507 \end_layout
26508
26509 \end_inset
26510 </cell>
26511 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26512 \begin_inset Text
26513
26514 \begin_layout Standard
26515 MCU Identification.
26516  
26517 \emph on
26518 xxxx
26519 \emph default
26520  is the microcontrol identification number, i.e.
26521  452, 6620, etc
26522 \end_layout
26523
26524 \end_inset
26525 </cell>
26526 </row>
26527 <row topline="true">
26528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26529 \begin_inset Text
26530
26531 \begin_layout Standard
26532 _
26533 \begin_inset ERT
26534 status collapsed
26535
26536 \begin_layout Standard
26537
26538
26539 \backslash
26540 /
26541 \end_layout
26542
26543 \end_inset
26544
26545 _18Fxxxx
26546 \end_layout
26547
26548 \end_inset
26549 </cell>
26550 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26551 \begin_inset Text
26552
26553 \begin_layout Standard
26554 MCU Identification (same as above)
26555 \end_layout
26556
26557 \end_inset
26558 </cell>
26559 </row>
26560 <row topline="true" bottomline="true">
26561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26562 \begin_inset Text
26563
26564 \begin_layout Standard
26565 STACK_MODEL_nnn
26566 \end_layout
26567
26568 \end_inset
26569 </cell>
26570 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26571 \begin_inset Text
26572
26573 \begin_layout Standard
26574 nnn = SMALL or LARGE respectively according to the stack model used
26575 \end_layout
26576
26577 \end_inset
26578 </cell>
26579 </row>
26580 </lyxtabular>
26581
26582 \end_inset
26583
26584
26585 \end_layout
26586
26587 \begin_layout Standard
26588 \noindent
26589 In addition the following macros are defined when calling assembler:
26590 \end_layout
26591
26592 \begin_layout Standard
26593 \align center
26594 \begin_inset Tabular
26595 <lyxtabular version="3" rows="4" columns="2">
26596 <features>
26597 <column alignment="center" valignment="top" leftline="true" width="0">
26598 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26599 <row topline="true" bottomline="true">
26600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26601 \begin_inset Text
26602
26603 \begin_layout Standard
26604 Macro
26605 \end_layout
26606
26607 \end_inset
26608 </cell>
26609 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26610 \begin_inset Text
26611
26612 \begin_layout Standard
26613 Description
26614 \end_layout
26615
26616 \end_inset
26617 </cell>
26618 </row>
26619 <row topline="true">
26620 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26621 \begin_inset Text
26622
26623 \begin_layout Standard
26624 __18Fxxxx
26625 \end_layout
26626
26627 \end_inset
26628 </cell>
26629 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26630 \begin_inset Text
26631
26632 \begin_layout Standard
26633 MCU Identification.
26634  
26635 \emph on
26636 xxxx
26637 \emph default
26638  is the microcontrol identification number, i.e.
26639  452, 6620, etc
26640 \end_layout
26641
26642 \end_inset
26643 </cell>
26644 </row>
26645 <row topline="true">
26646 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26647 \begin_inset Text
26648
26649 \begin_layout Standard
26650 SDCC_MODEL_nnn
26651 \end_layout
26652
26653 \end_inset
26654 </cell>
26655 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26656 \begin_inset Text
26657
26658 \begin_layout Standard
26659 nnn = SMALL or LARGE respectively according to the memory model used for
26660  SDCC
26661 \end_layout
26662
26663 \end_inset
26664 </cell>
26665 </row>
26666 <row topline="true" bottomline="true">
26667 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26668 \begin_inset Text
26669
26670 \begin_layout Standard
26671 STACK_MODEL_nnn
26672 \end_layout
26673
26674 \end_inset
26675 </cell>
26676 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26677 \begin_inset Text
26678
26679 \begin_layout Standard
26680 nnn = SMALL or LARGE respectively according to the stack model used
26681 \end_layout
26682
26683 \end_inset
26684 </cell>
26685 </row>
26686 </lyxtabular>
26687
26688 \end_inset
26689
26690
26691 \end_layout
26692
26693 \begin_layout Subsection
26694 Directories
26695 \end_layout
26696
26697 \begin_layout Standard
26698 PIC16
26699 \begin_inset LatexCommand index
26700 name "PIC16"
26701
26702 \end_inset
26703
26704  port uses the following directories for searching header files and libraries.
26705 \end_layout
26706
26707 \begin_layout Standard
26708 \align center
26709 \begin_inset Tabular
26710 <lyxtabular version="3" rows="3" columns="4">
26711 <features>
26712 <column alignment="center" valignment="top" leftline="true" width="0">
26713 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26714 <column alignment="center" valignment="top" width="0">
26715 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26716 <row topline="true" bottomline="true">
26717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26718 \begin_inset Text
26719
26720 \begin_layout Standard
26721 Directory
26722 \end_layout
26723
26724 \end_inset
26725 </cell>
26726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26727 \begin_inset Text
26728
26729 \begin_layout Standard
26730 Description
26731 \end_layout
26732
26733 \end_inset
26734 </cell>
26735 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26736 \begin_inset Text
26737
26738 \begin_layout Standard
26739 Target
26740 \end_layout
26741
26742 \end_inset
26743 </cell>
26744 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26745 \begin_inset Text
26746
26747 \begin_layout Standard
26748 Command prefix
26749 \end_layout
26750
26751 \end_inset
26752 </cell>
26753 </row>
26754 <row topline="true">
26755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26756 \begin_inset Text
26757
26758 \begin_layout Standard
26759 PREFIX/sdcc/include/pic16
26760 \end_layout
26761
26762 \end_inset
26763 </cell>
26764 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26765 \begin_inset Text
26766
26767 \begin_layout Standard
26768 PIC16 specific headers
26769 \end_layout
26770
26771 \end_inset
26772 </cell>
26773 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26774 \begin_inset Text
26775
26776 \begin_layout Standard
26777 Compiler
26778 \end_layout
26779
26780 \end_inset
26781 </cell>
26782 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26783 \begin_inset Text
26784
26785 \begin_layout Standard
26786 -I
26787 \end_layout
26788
26789 \end_inset
26790 </cell>
26791 </row>
26792 <row topline="true" bottomline="true">
26793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26794 \begin_inset Text
26795
26796 \begin_layout Standard
26797 PREFIX/sdcc/lib/pic16
26798 \end_layout
26799
26800 \end_inset
26801 </cell>
26802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26803 \begin_inset Text
26804
26805 \begin_layout Standard
26806 PIC16 specific libraries
26807 \end_layout
26808
26809 \end_inset
26810 </cell>
26811 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26812 \begin_inset Text
26813
26814 \begin_layout Standard
26815 Linker
26816 \end_layout
26817
26818 \end_inset
26819 </cell>
26820 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26821 \begin_inset Text
26822
26823 \begin_layout Standard
26824 -L
26825 \end_layout
26826
26827 \end_inset
26828 </cell>
26829 </row>
26830 </lyxtabular>
26831
26832 \end_inset
26833
26834
26835 \end_layout
26836
26837 \begin_layout Subsection
26838 Pragmas
26839 \begin_inset LatexCommand label
26840 name "sub:PIC16_Pragmas"
26841
26842 \end_inset
26843
26844
26845 \end_layout
26846
26847 \begin_layout Standard
26848 The PIC16
26849 \begin_inset LatexCommand index
26850 name "PIC16"
26851
26852 \end_inset
26853
26854  port currently supports the following pragmas:
26855 \end_layout
26856
26857 \begin_layout Description
26858 stack
26859 \begin_inset LatexCommand index
26860 name "PIC16!Pragmas!\\#pragma stack"
26861
26862 \end_inset
26863
26864  This forces the code generator to initialize the stack & frame pointers
26865  at a specific address.
26866  This is an ad hoc solution for cases where no STACK directive is available
26867  in the linker script or gplink is not instructed to create a stack section.
26868 \newline
26869 The
26870  stack pragma should be used only once in a project.
26871  Multiple pragmas may result in indeterminate behaviour of the program.
26872 \begin_inset Foot
26873 status open
26874
26875 \begin_layout Standard
26876 The old format (ie.
26877  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
26878  cross page boundaries (or even exceed the available data RAM) and crash
26879  the program.
26880  Make sure that stack does not cross page boundaries when using the SMALL
26881  stack model.
26882 \end_layout
26883
26884 \end_inset
26885
26886
26887 \newline
26888 The format is as follows:
26889 \newline
26890
26891 \end_layout
26892
26893 \begin_layout LyX-Code
26894 #pragma stack bottom_address [stack_size]
26895 \newline
26896
26897 \end_layout
26898
26899 \begin_layout Standard
26900
26901 \emph on
26902 bottom_address
26903 \emph default
26904  is the lower bound of the stack section.
26905  The stack pointer initially will point at address (bottom_address+stack_size-1).
26906 \end_layout
26907
26908 \begin_layout LyX-Code
26909 Example:
26910 \end_layout
26911
26912 \begin_layout LyX-Code
26913
26914 \end_layout
26915
26916 \begin_layout LyX-Code
26917 /* initializes stack of 100 bytes at RAM address 0x200 */
26918 \end_layout
26919
26920 \begin_layout LyX-Code
26921 #pragma stack 0x200 100
26922 \end_layout
26923
26924 \begin_layout Standard
26925 If the stack_size field is omitted then a stack is created with the default
26926  size of 64.
26927  This size might be enough for most programs, but its not enough for operations
26928  with deep function nesting or excessive stack usage.
26929 \end_layout
26930
26931 \begin_layout Description
26932 code
26933 \begin_inset LatexCommand index
26934 name "PIC16!Pragmas!\\#pragma code"
26935
26936 \end_inset
26937
26938  Force a function to a static FLASH address.
26939 \end_layout
26940
26941 \begin_layout LyX-Code
26942 Example:
26943 \end_layout
26944
26945 \begin_layout LyX-Code
26946
26947 \end_layout
26948
26949 \begin_layout LyX-Code
26950 /* place function test_func at 0x4000 */
26951 \end_layout
26952
26953 \begin_layout LyX-Code
26954 #pragma code test_func 0x4000
26955 \end_layout
26956
26957 \begin_layout LyX-Code
26958
26959 \end_layout
26960
26961 \begin_layout Description
26962 library instructs the linker to use a library module.
26963 \newline
26964 Usage:
26965 \end_layout
26966
26967 \begin_layout LyX-Code
26968 #pragma library module_name
26969 \end_layout
26970
26971 \begin_layout Standard
26972
26973 \emph on
26974 module_name
26975 \emph default
26976  can be any library or object file (including its path).
26977  Note that there are four reserved keywords which have special meaning.
26978  These are:
26979 \end_layout
26980
26981 \begin_layout Standard
26982 \align center
26983 \begin_inset Tabular
26984 <lyxtabular version="3" rows="6" columns="3">
26985 <features>
26986 <column alignment="center" valignment="top" leftline="true" width="0">
26987 <column alignment="block" valignment="top" leftline="true" width="20page%">
26988 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
26989 <row topline="true" bottomline="true">
26990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26991 \begin_inset Text
26992
26993 \begin_layout Standard
26994 Keyword
26995 \end_layout
26996
26997 \end_inset
26998 </cell>
26999 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27000 \begin_inset Text
27001
27002 \begin_layout Standard
27003 Description
27004 \end_layout
27005
27006 \end_inset
27007 </cell>
27008 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27009 \begin_inset Text
27010
27011 \begin_layout Standard
27012 Module to link
27013 \end_layout
27014
27015 \end_inset
27016 </cell>
27017 </row>
27018 <row topline="true">
27019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27020 \begin_inset Text
27021
27022 \begin_layout Standard
27023
27024 \series bold
27025 ignore
27026 \end_layout
27027
27028 \end_inset
27029 </cell>
27030 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27031 \begin_inset Text
27032
27033 \begin_layout Standard
27034 ignore all library pragmas
27035 \end_layout
27036
27037 \end_inset
27038 </cell>
27039 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27040 \begin_inset Text
27041
27042 \begin_layout Standard
27043
27044 \emph on
27045 (none)
27046 \end_layout
27047
27048 \end_inset
27049 </cell>
27050 </row>
27051 <row topline="true">
27052 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27053 \begin_inset Text
27054
27055 \begin_layout Standard
27056
27057 \series bold
27058 c
27059 \end_layout
27060
27061 \end_inset
27062 </cell>
27063 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27064 \begin_inset Text
27065
27066 \begin_layout Standard
27067 link the C library
27068 \end_layout
27069
27070 \end_inset
27071 </cell>
27072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27073 \begin_inset Text
27074
27075 \begin_layout Standard
27076
27077 \emph on
27078 libc18f
27079 \emph default
27080 .lib
27081 \end_layout
27082
27083 \end_inset
27084 </cell>
27085 </row>
27086 <row topline="true">
27087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27088 \begin_inset Text
27089
27090 \begin_layout Standard
27091
27092 \series bold
27093 math
27094 \end_layout
27095
27096 \end_inset
27097 </cell>
27098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27099 \begin_inset Text
27100
27101 \begin_layout Standard
27102 link the Math libarary
27103 \end_layout
27104
27105 \end_inset
27106 </cell>
27107 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27108 \begin_inset Text
27109
27110 \begin_layout Standard
27111
27112 \emph on
27113 libm18f
27114 \emph default
27115 .lib
27116 \end_layout
27117
27118 \end_inset
27119 </cell>
27120 </row>
27121 <row topline="true">
27122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27123 \begin_inset Text
27124
27125 \begin_layout Standard
27126
27127 \series bold
27128 io
27129 \end_layout
27130
27131 \end_inset
27132 </cell>
27133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27134 \begin_inset Text
27135
27136 \begin_layout Standard
27137 link the I/O library
27138 \end_layout
27139
27140 \end_inset
27141 </cell>
27142 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27143 \begin_inset Text
27144
27145 \begin_layout Standard
27146
27147 \emph on
27148 libio18f*
27149 \emph default
27150 .lib
27151 \end_layout
27152
27153 \end_inset
27154 </cell>
27155 </row>
27156 <row topline="true" bottomline="true">
27157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27158 \begin_inset Text
27159
27160 \begin_layout Standard
27161
27162 \series bold
27163 debug
27164 \end_layout
27165
27166 \end_inset
27167 </cell>
27168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27169 \begin_inset Text
27170
27171 \begin_layout Standard
27172 link the debug library
27173 \end_layout
27174
27175 \end_inset
27176 </cell>
27177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27178 \begin_inset Text
27179
27180 \begin_layout Standard
27181
27182 \emph on
27183 libdebug
27184 \emph default
27185 .lib
27186 \end_layout
27187
27188 \end_inset
27189 </cell>
27190 </row>
27191 </lyxtabular>
27192
27193 \end_inset
27194
27195
27196 \newline
27197 * is the device number, i.e.
27198  452 for PIC18F452 MCU.
27199 \end_layout
27200
27201 \begin_layout Standard
27202 \noindent
27203 This feature allows for linking with specific libraries without having to
27204  explicit name them in the command line.
27205  Note that the 
27206 \noun on
27207 ignore
27208 \noun default
27209  keyword will reject all modules specified by the library pragma.
27210 \end_layout
27211
27212 \begin_layout Description
27213 udata The pragma udata instructs the compiler to emit code so that linker
27214  will place a variable at a specific memory bank.
27215 \end_layout
27216
27217 \begin_layout LyX-Code
27218 Example:
27219 \end_layout
27220
27221 \begin_layout LyX-Code
27222
27223 \end_layout
27224
27225 \begin_layout LyX-Code
27226 /* places variable foo at bank2 */
27227 \end_layout
27228
27229 \begin_layout LyX-Code
27230 #pragma udata bank2 foo
27231 \end_layout
27232
27233 \begin_layout LyX-Code
27234 char foo;
27235 \end_layout
27236
27237 \begin_layout Standard
27238 In order for this pragma to work extra SECTION directives should be added
27239  in the .lkr script.
27240  In the following example a sample .lkr file is shown:
27241 \end_layout
27242
27243 \begin_layout LyX-Code
27244
27245 \end_layout
27246
27247 \begin_layout LyX-Code
27248 // Sample linker script for the PIC18F452 processor
27249 \end_layout
27250
27251 \begin_layout LyX-Code
27252 LIBPATH .
27253 \end_layout
27254
27255 \begin_layout LyX-Code
27256 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
27257 \end_layout
27258
27259 \begin_layout LyX-Code
27260 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
27261 \end_layout
27262
27263 \begin_layout LyX-Code
27264 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
27265 \end_layout
27266
27267 \begin_layout LyX-Code
27268 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
27269 \end_layout
27270
27271 \begin_layout LyX-Code
27272 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
27273 \end_layout
27274
27275 \begin_layout LyX-Code
27276 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
27277 \end_layout
27278
27279 \begin_layout LyX-Code
27280 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
27281 \end_layout
27282
27283 \begin_layout LyX-Code
27284
27285 \end_layout
27286
27287 \begin_layout LyX-Code
27288 DATABANK   NAME=gpr0       START=0x80           END=0xFF
27289 \end_layout
27290
27291 \begin_layout LyX-Code
27292 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
27293 \end_layout
27294
27295 \begin_layout LyX-Code
27296 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
27297 \end_layout
27298
27299 \begin_layout LyX-Code
27300 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
27301 \end_layout
27302
27303 \begin_layout LyX-Code
27304 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
27305 \end_layout
27306
27307 \begin_layout LyX-Code
27308 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
27309 \end_layout
27310
27311 \begin_layout LyX-Code
27312 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
27313 \end_layout
27314
27315 \begin_layout LyX-Code
27316
27317 \end_layout
27318
27319 \begin_layout LyX-Code
27320 SECTION    NAME=CONFIG     ROM=config
27321 \end_layout
27322
27323 \begin_layout LyX-Code
27324
27325 \end_layout
27326
27327 \begin_layout LyX-Code
27328 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
27329 \end_layout
27330
27331 \begin_layout LyX-Code
27332 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
27333 \end_layout
27334
27335 \begin_layout LyX-Code
27336 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
27337 \end_layout
27338
27339 \begin_layout LyX-Code
27340 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
27341 \end_layout
27342
27343 \begin_layout LyX-Code
27344 SECTION    NAME=bank4      RAM=gpr4
27345 \end_layout
27346
27347 \begin_layout LyX-Code
27348 SECTION    NAME=bank5      RAM=gpr5
27349 \end_layout
27350
27351 \begin_layout Standard
27352 The linker will recognise the section name set in the pragma statement and
27353  will position the variable at the memory bank set with the RAM field at
27354  the SECTION line in the linker script file.
27355 \end_layout
27356
27357 \begin_layout Subsection
27358 Header Files
27359 \begin_inset LatexCommand label
27360 name "sub:PIC16_Header-Files"
27361
27362 \end_inset
27363
27364
27365 \end_layout
27366
27367 \begin_layout Standard
27368 There is one main header file
27369 \begin_inset LatexCommand index
27370 name "PIC16!Header files"
27371
27372 \end_inset
27373
27374  that can be included to the source files using the pic16
27375 \begin_inset LatexCommand index
27376 name "PIC16"
27377
27378 \end_inset
27379
27380  port.
27381  That file is the 
27382 \series bold
27383 pic18fregs.h
27384 \series default
27385 .
27386  This header file contains the definitions for the processor special registers,
27387  so it is necessary if the source accesses them.
27388  It can be included by adding the following line in the beginning of the
27389  file:
27390 \end_layout
27391
27392 \begin_layout LyX-Code
27393 #include <pic18fregs.h>
27394 \end_layout
27395
27396 \begin_layout Standard
27397 The specific microcontroller is selected within the pic18fregs.h automatically,
27398  so the same source can be used with a variety of devices.
27399 \end_layout
27400
27401 \begin_layout Subsection
27402 Libraries
27403 \begin_inset LatexCommand label
27404 name "sub:pic16Libraries"
27405
27406 \end_inset
27407
27408
27409 \end_layout
27410
27411 \begin_layout Standard
27412 The libraries
27413 \begin_inset LatexCommand index
27414 name "PIC16!Libraries"
27415
27416 \end_inset
27417
27418  that PIC16
27419 \begin_inset LatexCommand index
27420 name "PIC16"
27421
27422 \end_inset
27423
27424  port depends on are the microcontroller device libraries which contain
27425  the symbol definitions for the microcontroller special function registers.
27426  These libraries have the format pic18fxxxx.lib, where 
27427 \emph on
27428 xxxx
27429 \emph default
27430  is the microcontroller identification number.
27431  The specific library is selected automatically by the compiler at link
27432  stage according to the selected device.
27433 \end_layout
27434
27435 \begin_layout Standard
27436 \noindent
27437 Libraries are created with gplib which is part of the gputils package 
27438 \begin_inset LatexCommand url
27439 target "http://sourceforge.net/projects/gputils"
27440
27441 \end_inset
27442
27443 .
27444 \end_layout
27445
27446 \begin_layout Subsubsection*
27447 Building the libraries
27448 \end_layout
27449
27450 \begin_layout Standard
27451 Before using SDCC/pic16 there are some libraries that need to be compiled.
27452  This process is done automatically if gputils are found at SDCC's compile
27453  time.
27454  Should you require to rebuild the pic16 libraries manually (e.g.
27455  in order to enable output of float values
27456 \begin_inset LatexCommand index
27457 name "Floating point support"
27458
27459 \end_inset
27460
27461  via 
27462 \family typewriter
27463 printf()
27464 \family default
27465 , see below), these are the steps required to do so under Linux or Mac OS
27466  X (cygwin might work as well, but is untested):
27467 \end_layout
27468
27469 \begin_layout LyX-Code
27470 cd device/lib/pic16
27471 \end_layout
27472
27473 \begin_layout LyX-Code
27474 ./configure.gnu
27475 \end_layout
27476
27477 \begin_layout LyX-Code
27478 cd ..
27479 \end_layout
27480
27481 \begin_layout LyX-Code
27482 make model-pic16
27483 \end_layout
27484
27485 \begin_layout LyX-Code
27486 su -c 'make install'     # install the libraries, you need the root password
27487 \end_layout
27488
27489 \begin_layout LyX-Code
27490 cd ../..
27491 \end_layout
27492
27493 \begin_layout Standard
27494 If you need to install the headers too, do:
27495 \end_layout
27496
27497 \begin_layout LyX-Code
27498 cd device/include
27499 \end_layout
27500
27501 \begin_layout LyX-Code
27502 su -c 'make install'     # install the headers, you need the root password
27503 \end_layout
27504
27505 \begin_layout Subsubsection*
27506 Output of float values via printf()
27507 \end_layout
27508
27509 \begin_layout Standard
27510 The library is normally built without support for displaying float values,
27511  only <NO FLOAT>
27512 \begin_inset LatexCommand index
27513 name "<NO FLOAT>"
27514
27515 \end_inset
27516
27517
27518 \begin_inset LatexCommand index
27519 name "printf floating point support"
27520
27521 \end_inset
27522
27523  will appear instead of the value.
27524  To change this, rebuild the library as stated above, but call 
27525 \family typewriter
27526 ./configure.gnu --enable-floats 
27527 \family default
27528 instead of just 
27529 \family typewriter
27530 ./configure.gnu
27531 \family default
27532 .
27533  Also make sure that at least 
27534 \family typewriter
27535 libc/stdio/vfprintf.c
27536 \family default
27537  is actually recompiled, e.g.
27538  by 
27539 \family typewriter
27540 touch
27541 \family default
27542 ing it after the 
27543 \family typewriter
27544 configure
27545 \family default
27546  run or deleting its 
27547 \family typewriter
27548 .o
27549 \family default
27550  file.
27551 \end_layout
27552
27553 \begin_layout Standard
27554 The more common appraoch of compiling 
27555 \family typewriter
27556 vfprintf.c
27557 \family default
27558  manually with 
27559 \family typewriter
27560 -DUSE_FLOATS=1
27561 \family default
27562  should also work, but is untested.
27563 \end_layout
27564
27565 \begin_layout Subsection
27566 Adding New Devices to the Port
27567 \end_layout
27568
27569 \begin_layout Standard
27570 Adding support for a new 16
27571 \begin_inset ERT
27572 status collapsed
27573
27574 \begin_layout Standard
27575
27576
27577 \backslash
27578 ,
27579 \end_layout
27580
27581 \end_inset
27582
27583 bit PIC MCU requires the following steps:
27584 \end_layout
27585
27586 \begin_layout Enumerate
27587 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
27588 \newline
27589
27590 \family typewriter
27591 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
27592 inc
27593 \end_layout
27594
27595 \begin_layout Enumerate
27596
27597 \family typewriter
27598 mv picDEVICE.h /path/to/sdcc/device/include/pic16
27599 \end_layout
27600
27601 \begin_layout Enumerate
27602
27603 \family typewriter
27604 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
27605 \end_layout
27606
27607 \begin_layout Enumerate
27608 Add DEVICE to 
27609 \family typewriter
27610 /path/to/sdcc/device/lib/pic16/pics.all
27611 \family default
27612
27613 \newline
27614 Note: No 18f prefix here!
27615 \end_layout
27616
27617 \begin_layout Enumerate
27618 Edit 
27619 \family typewriter
27620 /path/to/sdcc/device/include/pic16/adc.h
27621 \newline
27622
27623 \family default
27624 Add the new devices to the correct ADC style class (depending on the number
27625  of ADC channels).
27626 \newline
27627 Do not touch 
27628 \family typewriter
27629 adc.h
27630 \family default
27631  if the device does not offer any ADC at all.
27632 \end_layout
27633
27634 \begin_layout Enumerate
27635 Edit 
27636 \family typewriter
27637 /path/to/sdcc/device/include/pic16/pic18fregs.h
27638 \family default
27639
27640 \newline
27641 The file format is self-explanatory, just add
27642 \newline
27643
27644 \family typewriter
27645 #elif defined(picDEVICE)
27646 \newline
27647 #
27648 \begin_inset ERT
27649 status collapsed
27650
27651 \begin_layout Standard
27652
27653
27654 \backslash
27655  
27656 \backslash
27657  
27658 \end_layout
27659
27660 \end_inset
27661
27662 include <picDEVICE.h>
27663 \family default
27664
27665 \newline
27666 at the right place (keep the file sorted, please).
27667 \end_layout
27668
27669 \begin_layout Enumerate
27670 Edit 
27671 \family typewriter
27672 /path/to/sdcc/device/include/pic16devices.txt
27673 \newline
27674
27675 \family default
27676 Copy and modify an existing entry or create a new one and insert it at the
27677  correct place (keep the file sorted, please).
27678 \end_layout
27679
27680 \begin_layout Enumerate
27681 Add the device to 
27682 \family typewriter
27683 /path/to/sdcc/device/lib/pic16/libdev/Makefile.am
27684 \family default
27685
27686 \newline
27687 Copy an existing entry and adjust the device name.
27688 \end_layout
27689
27690 \begin_layout Enumerate
27691 Add the device to 
27692 \family typewriter
27693 /path/to/sdcc/device/lib/pic16/libio/Makefile.am
27694 \family default
27695
27696 \newline
27697 Copy the record from the 18f2220 and adjust the device name.
27698 \newline
27699 If the new device
27700  does not offer ADC, I
27701 \begin_inset Formula $^{\text{2}}$
27702 \end_inset
27703
27704 C, and/or (E)USART functionality as assumed by the library, remove the lines
27705  with references to 
27706 \family typewriter
27707 adc/*.c
27708 \family default
27709
27710 \family typewriter
27711 usart/*.c
27712 \family default
27713 , or 
27714 \family typewriter
27715 usart/*.c
27716 \family default
27717 , respectively.
27718 \end_layout
27719
27720 \begin_layout Enumerate
27721 Update 
27722 \family typewriter
27723 libdev/Makefile.in
27724 \family default
27725  and 
27726 \family typewriter
27727 libio/Makefile.in
27728 \family default
27729  using
27730 \newline
27731
27732 \family typewriter
27733 ./bootstrap.sh
27734 \family default
27735
27736 \newline
27737 in 
27738 \family typewriter
27739 /path/to/sdcc/device/lib/pic16
27740 \family default
27741 .
27742 \end_layout
27743
27744 \begin_layout Enumerate
27745 Recompile the pic16 libraries as described in 
27746 \begin_inset LatexCommand ref
27747 reference "sub:pic16Libraries"
27748
27749 \end_inset
27750
27751 .
27752 \end_layout
27753
27754 \begin_layout Subsection
27755 Memory Models
27756 \end_layout
27757
27758 \begin_layout Standard
27759 The following memory models are supported by the PIC16 port:
27760 \end_layout
27761
27762 \begin_layout Itemize
27763 small model
27764 \end_layout
27765
27766 \begin_layout Itemize
27767 large model
27768 \end_layout
27769
27770 \begin_layout Standard
27771 Memory model affects the default size of pointers within the source.
27772  The sizes are shown in the next table:
27773 \end_layout
27774
27775 \begin_layout Standard
27776 \align center
27777 \begin_inset Tabular
27778 <lyxtabular version="3" rows="3" columns="3">
27779 <features>
27780 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27781 <column alignment="center" valignment="top" leftline="true" width="0">
27782 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27783 <row topline="true" bottomline="true">
27784 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27785 \begin_inset Text
27786
27787 \begin_layout Standard
27788 Pointer sizes according to memory model
27789 \end_layout
27790
27791 \end_inset
27792 </cell>
27793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27794 \begin_inset Text
27795
27796 \begin_layout Standard
27797 small model
27798 \end_layout
27799
27800 \end_inset
27801 </cell>
27802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27803 \begin_inset Text
27804
27805 \begin_layout Standard
27806 large model
27807 \end_layout
27808
27809 \end_inset
27810 </cell>
27811 </row>
27812 <row topline="true" bottomline="true">
27813 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27814 \begin_inset Text
27815
27816 \begin_layout Standard
27817 code pointers
27818 \end_layout
27819
27820 \end_inset
27821 </cell>
27822 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27823 \begin_inset Text
27824
27825 \begin_layout Standard
27826 16-bits
27827 \end_layout
27828
27829 \end_inset
27830 </cell>
27831 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27832 \begin_inset Text
27833
27834 \begin_layout Standard
27835 24-bits
27836 \end_layout
27837
27838 \end_inset
27839 </cell>
27840 </row>
27841 <row topline="true" bottomline="true">
27842 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27843 \begin_inset Text
27844
27845 \begin_layout Standard
27846 data pointers
27847 \end_layout
27848
27849 \end_inset
27850 </cell>
27851 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
27852 \begin_inset Text
27853
27854 \begin_layout Standard
27855 16-bits
27856 \end_layout
27857
27858 \end_inset
27859 </cell>
27860 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27861 \begin_inset Text
27862
27863 \begin_layout Standard
27864 16-bits
27865 \end_layout
27866
27867 \end_inset
27868 </cell>
27869 </row>
27870 </lyxtabular>
27871
27872 \end_inset
27873
27874
27875 \end_layout
27876
27877 \begin_layout Standard
27878 It is advisable that all sources within a project are compiled with the
27879  same memory model.
27880  If one wants to override the default memory model, this can be done by
27881  declaring a pointer as 
27882 \series bold
27883 far
27884 \series default
27885  or 
27886 \series bold
27887 near
27888 \series default
27889 .
27890  Far selects large memory model's pointers, while near selects small memory
27891  model's pointers.
27892 \end_layout
27893
27894 \begin_layout Standard
27895 The standard device libraries (see 
27896 \begin_inset LatexCommand ref
27897 reference "sub:PIC16_Header-Files"
27898
27899 \end_inset
27900
27901 ) contain no reference to pointers, so they can be used with both memory
27902  models.
27903 \end_layout
27904
27905 \begin_layout Subsection
27906 Stack
27907 \end_layout
27908
27909 \begin_layout Standard
27910 The stack
27911 \begin_inset LatexCommand index
27912 name "PIC16!stack"
27913
27914 \end_inset
27915
27916  implementation for the PIC16 port uses two indirect registers, FSR1 and
27917  FSR2.
27918 \end_layout
27919
27920 \begin_layout Description
27921 FSR1 is assigned as stack pointer
27922 \end_layout
27923
27924 \begin_layout Description
27925 FSR2 is assigned as frame pointer
27926 \end_layout
27927
27928 \begin_layout Standard
27929 The following stack models are supported by the PIC16 port
27930 \end_layout
27931
27932 \begin_layout Itemize
27933
27934 \noun on
27935 small
27936 \noun default
27937  model
27938 \end_layout
27939
27940 \begin_layout Itemize
27941
27942 \noun on
27943 large
27944 \noun default
27945  model
27946 \end_layout
27947
27948 \begin_layout Standard
27949
27950 \noun on
27951 Small
27952 \noun default
27953  model means that only the FSRxL byte is used to access stack and frame,
27954  while 
27955 \emph on
27956 \noun on
27957 large
27958 \emph default
27959 \noun default
27960  uses both FSRxL and FSRxH registers.
27961  The following table shows the stack/frame pointers sizes according to stack
27962  model and the maximum space they can address:
27963 \end_layout
27964
27965 \begin_layout Standard
27966 \align center
27967 \begin_inset Tabular
27968 <lyxtabular version="3" rows="3" columns="3">
27969 <features>
27970 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27971 <column alignment="center" valignment="top" leftline="true" width="0">
27972 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27973 <row topline="true" bottomline="true">
27974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27975 \begin_inset Text
27976
27977 \begin_layout Standard
27978 Stack & Frame pointer sizes according to stack model
27979 \end_layout
27980
27981 \end_inset
27982 </cell>
27983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27984 \begin_inset Text
27985
27986 \begin_layout Standard
27987 small
27988 \end_layout
27989
27990 \end_inset
27991 </cell>
27992 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27993 \begin_inset Text
27994
27995 \begin_layout Standard
27996 large
27997 \end_layout
27998
27999 \end_inset
28000 </cell>
28001 </row>
28002 <row topline="true">
28003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28004 \begin_inset Text
28005
28006 \begin_layout Standard
28007 Stack pointer FSR1
28008 \end_layout
28009
28010 \end_inset
28011 </cell>
28012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28013 \begin_inset Text
28014
28015 \begin_layout Standard
28016 8-bits
28017 \end_layout
28018
28019 \end_inset
28020 </cell>
28021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28022 \begin_inset Text
28023
28024 \begin_layout Standard
28025 16-bits
28026 \end_layout
28027
28028 \end_inset
28029 </cell>
28030 </row>
28031 <row topline="true" bottomline="true">
28032 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28033 \begin_inset Text
28034
28035 \begin_layout Standard
28036 Frame pointer FSR2
28037 \end_layout
28038
28039 \end_inset
28040 </cell>
28041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28042 \begin_inset Text
28043
28044 \begin_layout Standard
28045 8-bits
28046 \end_layout
28047
28048 \end_inset
28049 </cell>
28050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28051 \begin_inset Text
28052
28053 \begin_layout Standard
28054 16-bits
28055 \end_layout
28056
28057 \end_inset
28058 </cell>
28059 </row>
28060 </lyxtabular>
28061
28062 \end_inset
28063
28064
28065 \end_layout
28066
28067 \begin_layout Standard
28068 \noindent
28069
28070 \noun on
28071 Large 
28072 \noun default
28073 stack model is currently not working properly throughout the code generator.
28074  So its use is not advised.
28075  Also there are some other points that need special care:
28076 \newline
28077
28078 \end_layout
28079
28080 \begin_layout Enumerate
28081 Do not create stack sections with size more than one physical bank (that
28082  is 256 bytes)
28083 \end_layout
28084
28085 \begin_layout Enumerate
28086 Stack sections should no cross physical bank limits (i.e.
28087  #pragma stack 0x50 0x100)
28088 \end_layout
28089
28090 \begin_layout Standard
28091 These limitations are caused by the fact that only FSRxL is modified when
28092  using SMALL stack model, so no more than 256 bytes of stack can be used.
28093  This problem will disappear after LARGE model is fully implemented.
28094 \end_layout
28095
28096 \begin_layout Subsection
28097 Functions
28098 \end_layout
28099
28100 \begin_layout Standard
28101 In addition to the standard SDCC function keywords, PIC16
28102 \begin_inset LatexCommand index
28103 name "PIC16"
28104
28105 \end_inset
28106
28107  port makes available two more:
28108 \end_layout
28109
28110 \begin_layout Description
28111 wparam
28112 \begin_inset LatexCommand index
28113 name "PIC16!wparam"
28114
28115 \end_inset
28116
28117  Use the WREG to pass one byte of the first function argument.
28118  This improves speed but you may not use this for functions with arguments
28119  that are called via function pointers, otherwise the first byte of the
28120  first parameter will get lost.
28121  Usage:
28122 \end_layout
28123
28124 \begin_layout LyX-Code
28125 void func_wparam(int a) wparam
28126 \end_layout
28127
28128 \begin_layout LyX-Code
28129 {
28130 \end_layout
28131
28132 \begin_layout LyX-Code
28133     /* WREG hold the lower part of a */
28134 \end_layout
28135
28136 \begin_layout LyX-Code
28137     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
28138  */
28139 \end_layout
28140
28141 \begin_layout LyX-Code
28142 ...
28143 \end_layout
28144
28145 \begin_layout LyX-Code
28146 }
28147 \end_layout
28148
28149 \begin_layout Description
28150 shadowregs
28151 \begin_inset LatexCommand index
28152 name "PIC16!shadowregs"
28153
28154 \end_inset
28155
28156  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
28157  hardware shadow registers which hold the values of WREG, STATUS and BSR
28158  registers.
28159  This can be done by adding the keyword 
28160 \emph on
28161 shadowregs
28162 \emph default
28163  before the 
28164 \emph on
28165 interrupt
28166 \emph default
28167  keyword in the function's header.
28168 \end_layout
28169
28170 \begin_layout LyX-Code
28171 void isr_shadow(void) shadowregs interrupt 1
28172 \end_layout
28173
28174 \begin_layout LyX-Code
28175 {
28176 \end_layout
28177
28178 \begin_layout LyX-Code
28179 ...
28180 \end_layout
28181
28182 \begin_layout LyX-Code
28183 }
28184 \end_layout
28185
28186 \begin_layout Standard
28187
28188 \emph on
28189 shadowregs
28190 \emph default
28191  instructs the code generator not to store/restore WREG, STATUS, BSR when
28192  entering/exiting the ISR.
28193 \end_layout
28194
28195 \begin_layout Subsection
28196 Function return values
28197 \end_layout
28198
28199 \begin_layout Standard
28200 Return values from functions are placed to the appropriate registers following
28201  a modified Microchip policy optimized for SDCC.
28202  The following table shows these registers:
28203 \end_layout
28204
28205 \begin_layout Standard
28206 \align center
28207 \begin_inset Tabular
28208 <lyxtabular version="3" rows="6" columns="2">
28209 <features>
28210 <column alignment="center" valignment="top" leftline="true" width="0">
28211 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28212 <row topline="true" bottomline="true">
28213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28214 \begin_inset Text
28215
28216 \begin_layout Standard
28217 size
28218 \end_layout
28219
28220 \end_inset
28221 </cell>
28222 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28223 \begin_inset Text
28224
28225 \begin_layout Standard
28226 destination register
28227 \end_layout
28228
28229 \end_inset
28230 </cell>
28231 </row>
28232 <row topline="true">
28233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28234 \begin_inset Text
28235
28236 \begin_layout Standard
28237 8 bits
28238 \end_layout
28239
28240 \end_inset
28241 </cell>
28242 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28243 \begin_inset Text
28244
28245 \begin_layout Standard
28246 WREG
28247 \end_layout
28248
28249 \end_inset
28250 </cell>
28251 </row>
28252 <row topline="true">
28253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28254 \begin_inset Text
28255
28256 \begin_layout Standard
28257 16 bits
28258 \end_layout
28259
28260 \end_inset
28261 </cell>
28262 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28263 \begin_inset Text
28264
28265 \begin_layout Standard
28266 PRODL:WREG
28267 \end_layout
28268
28269 \end_inset
28270 </cell>
28271 </row>
28272 <row topline="true">
28273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28274 \begin_inset Text
28275
28276 \begin_layout Standard
28277 24 bits
28278 \end_layout
28279
28280 \end_inset
28281 </cell>
28282 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28283 \begin_inset Text
28284
28285 \begin_layout Standard
28286 PRODH:PRODL:WREG
28287 \end_layout
28288
28289 \end_inset
28290 </cell>
28291 </row>
28292 <row topline="true">
28293 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28294 \begin_inset Text
28295
28296 \begin_layout Standard
28297 32 bits
28298 \end_layout
28299
28300 \end_inset
28301 </cell>
28302 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28303 \begin_inset Text
28304
28305 \begin_layout Standard
28306 FSR0L:PRODH:PRODL:WREG
28307 \end_layout
28308
28309 \end_inset
28310 </cell>
28311 </row>
28312 <row topline="true" bottomline="true">
28313 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28314 \begin_inset Text
28315
28316 \begin_layout Standard
28317 >32 bits
28318 \end_layout
28319
28320 \end_inset
28321 </cell>
28322 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28323 \begin_inset Text
28324
28325 \begin_layout Standard
28326 on stack, FSR0 points to the beginning
28327 \end_layout
28328
28329 \end_inset
28330 </cell>
28331 </row>
28332 </lyxtabular>
28333
28334 \end_inset
28335
28336
28337 \end_layout
28338
28339 \begin_layout Subsection
28340 Interrupts
28341 \end_layout
28342
28343 \begin_layout Standard
28344 An interrupt
28345 \begin_inset LatexCommand index
28346 name "PIC16!interrupt"
28347
28348 \end_inset
28349
28350  service routine (ISR) is declared using the 
28351 \emph on
28352 interrupt
28353 \emph default
28354  keyword.
28355 \end_layout
28356
28357 \begin_layout LyX-Code
28358 void isr(void) interrupt 
28359 \emph on
28360 n
28361 \end_layout
28362
28363 \begin_layout LyX-Code
28364 {
28365 \end_layout
28366
28367 \begin_layout LyX-Code
28368 ...
28369 \end_layout
28370
28371 \begin_layout LyX-Code
28372 }
28373 \end_layout
28374
28375 \begin_layout Standard
28376
28377 \emph on
28378 n
28379 \emph default
28380  is the interrupt number, which for PIC18F devices can be:
28381 \end_layout
28382
28383 \begin_layout Standard
28384 \align center
28385 \begin_inset Tabular
28386 <lyxtabular version="3" rows="4" columns="3">
28387 <features>
28388 <column alignment="center" valignment="top" leftline="true" width="0">
28389 <column alignment="center" valignment="top" leftline="true" width="0">
28390 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28391 <row topline="true" bottomline="true">
28392 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28393 \begin_inset Text
28394
28395 \begin_layout Standard
28396
28397 \emph on
28398 n
28399 \end_layout
28400
28401 \end_inset
28402 </cell>
28403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28404 \begin_inset Text
28405
28406 \begin_layout Standard
28407 Interrupt Vector
28408 \end_layout
28409
28410 \end_inset
28411 </cell>
28412 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28413 \begin_inset Text
28414
28415 \begin_layout Standard
28416 Interrupt Vector Address
28417 \end_layout
28418
28419 \end_inset
28420 </cell>
28421 </row>
28422 <row topline="true">
28423 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28424 \begin_inset Text
28425
28426 \begin_layout Standard
28427 0
28428 \end_layout
28429
28430 \end_inset
28431 </cell>
28432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28433 \begin_inset Text
28434
28435 \begin_layout Standard
28436 RESET vector
28437 \end_layout
28438
28439 \end_inset
28440 </cell>
28441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28442 \begin_inset Text
28443
28444 \begin_layout Standard
28445 0x000000
28446 \end_layout
28447
28448 \end_inset
28449 </cell>
28450 </row>
28451 <row topline="true">
28452 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28453 \begin_inset Text
28454
28455 \begin_layout Standard
28456
28457 \family roman
28458 \series medium
28459 \shape up
28460 \size normal
28461 \emph off
28462 \bar no
28463 \noun off
28464 \color none
28465 1
28466 \end_layout
28467
28468 \end_inset
28469 </cell>
28470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28471 \begin_inset Text
28472
28473 \begin_layout Standard
28474
28475 \family roman
28476 \series medium
28477 \shape up
28478 \size normal
28479 \emph off
28480 \bar no
28481 \noun off
28482 \color none
28483 HIGH priority interrupts
28484 \end_layout
28485
28486 \end_inset
28487 </cell>
28488 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28489 \begin_inset Text
28490
28491 \begin_layout Standard
28492 0x000008
28493 \end_layout
28494
28495 \end_inset
28496 </cell>
28497 </row>
28498 <row topline="true" bottomline="true">
28499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28500 \begin_inset Text
28501
28502 \begin_layout Standard
28503 2
28504 \end_layout
28505
28506 \end_inset
28507 </cell>
28508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28509 \begin_inset Text
28510
28511 \begin_layout Standard
28512 LOW priority interrupts
28513 \end_layout
28514
28515 \end_inset
28516 </cell>
28517 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28518 \begin_inset Text
28519
28520 \begin_layout Standard
28521 0x000018
28522 \end_layout
28523
28524 \end_inset
28525 </cell>
28526 </row>
28527 </lyxtabular>
28528
28529 \end_inset
28530
28531
28532 \end_layout
28533
28534 \begin_layout Standard
28535 When generating assembly code for ISR the code generator places a 
28536 \noun on
28537 goto 
28538 \noun default
28539 instruction at the 
28540 \emph on
28541 Interrupt Vector Address
28542 \emph default
28543  which points at the generated ISR.
28544  This single GOTO instruction is part of an automatically generated 
28545 \emph on
28546 interrupt entry point
28547 \emph default
28548  function.
28549  The actuall ISR code is placed as normally would in the code space.
28550  Upon interrupt request, the GOTO instruction is executed which jumps to
28551  the ISR code.
28552  When declaring interrupt functions as _naked this GOTO instruction is 
28553 \series bold
28554 not
28555 \series default
28556  generated.
28557  The whole interrupt functions is therefore placed at the Interrupt Vector
28558  Address of the specific interrupt.
28559  This is not a problem for the LOW priority interrupts, but it is a problem
28560  for the RESET and the HIGH priority interrupts because code may be written
28561  at the next interrupt's vector address and cause indeterminate program
28562  behaviour if that interrupt is raised.
28563 \begin_inset Foot
28564 status open
28565
28566 \begin_layout Standard
28567 This is not a problem when
28568 \end_layout
28569
28570 \begin_layout Enumerate
28571 this is a HIGH interrupt ISR and LOW interrupts are 
28572 \emph on
28573 disabled
28574 \emph default
28575  or not used.
28576 \end_layout
28577
28578 \begin_layout Enumerate
28579 when the ISR is small enough not to reach the next interrupt's vector address.
28580 \end_layout
28581
28582 \end_inset
28583
28584
28585 \end_layout
28586
28587 \begin_layout Standard
28588
28589 \emph on
28590 n
28591 \emph default
28592  may be omitted.
28593  This way a function is generated similar to an ISR, but it is not assigned
28594  to any interrupt.
28595 \end_layout
28596
28597 \begin_layout Standard
28598 When entering an interrupt, currently the PIC16
28599 \begin_inset LatexCommand index
28600 name "PIC16"
28601
28602 \end_inset
28603
28604  port automatically saves the following registers:
28605 \end_layout
28606
28607 \begin_layout Itemize
28608 WREG
28609 \end_layout
28610
28611 \begin_layout Itemize
28612 STATUS
28613 \end_layout
28614
28615 \begin_layout Itemize
28616 BSR
28617 \end_layout
28618
28619 \begin_layout Itemize
28620 PROD (PRODL and PRODH)
28621 \end_layout
28622
28623 \begin_layout Itemize
28624 FSR0 (FSR0L and FSR0H)
28625 \end_layout
28626
28627 \begin_layout Standard
28628 These registers are restored upon return from the interrupt routine.
28629 \begin_inset Foot
28630 status open
28631
28632 \begin_layout Standard
28633 NOTE that when the _naked attribute is specified for an interrupt routine,
28634  then NO registers are stored or restored.
28635 \end_layout
28636
28637 \end_inset
28638
28639
28640 \end_layout
28641
28642 \begin_layout Subsection
28643 Generic Pointers
28644 \end_layout
28645
28646 \begin_layout Standard
28647 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
28648  There are 3 types of generic pointers currently implemented data, code
28649  and eeprom pointers.
28650  They are differentiated by the value of the 7th and 6th bits of the upper
28651  byte:
28652 \end_layout
28653
28654 \begin_layout Standard
28655 \align center
28656 \begin_inset Tabular
28657 <lyxtabular version="3" rows="5" columns="5">
28658 <features>
28659 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28660 <column alignment="center" valignment="top" width="0">
28661 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28662 <column alignment="center" valignment="top" width="0">
28663 <column alignment="left" valignment="top" rightline="true" width="0">
28664 <row topline="true" bottomline="true">
28665 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28666 \begin_inset Text
28667
28668 \begin_layout Standard
28669 pointer type
28670 \end_layout
28671
28672 \end_inset
28673 </cell>
28674 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28675 \begin_inset Text
28676
28677 \begin_layout Standard
28678 7th bit
28679 \end_layout
28680
28681 \end_inset
28682 </cell>
28683 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28684 \begin_inset Text
28685
28686 \begin_layout Standard
28687 6th bit
28688 \end_layout
28689
28690 \end_inset
28691 </cell>
28692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28693 \begin_inset Text
28694
28695 \begin_layout Standard
28696 rest of the pointer
28697 \end_layout
28698
28699 \end_inset
28700 </cell>
28701 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28702 \begin_inset Text
28703
28704 \begin_layout Standard
28705 description
28706 \end_layout
28707
28708 \end_inset
28709 </cell>
28710 </row>
28711 <row topline="true" bottomline="true">
28712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28713 \begin_inset Text
28714
28715 \begin_layout Standard
28716 data 
28717 \end_layout
28718
28719 \end_inset
28720 </cell>
28721 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28722 \begin_inset Text
28723
28724 \begin_layout Standard
28725 1
28726 \end_layout
28727
28728 \end_inset
28729 </cell>
28730 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28731 \begin_inset Text
28732
28733 \begin_layout Standard
28734 0
28735 \end_layout
28736
28737 \end_inset
28738 </cell>
28739 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28740 \begin_inset Text
28741
28742 \begin_layout Standard
28743
28744 \family typewriter
28745 \shape slanted
28746 \emph on
28747 uuuuuu uuuuxxxx xxxxxxxx
28748 \end_layout
28749
28750 \end_inset
28751 </cell>
28752 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28753 \begin_inset Text
28754
28755 \begin_layout Standard
28756 a 12-bit data pointer in data RAM memory
28757 \end_layout
28758
28759 \end_inset
28760 </cell>
28761 </row>
28762 <row bottomline="true">
28763 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28764 \begin_inset Text
28765
28766 \begin_layout Standard
28767 code
28768 \end_layout
28769
28770 \end_inset
28771 </cell>
28772 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28773 \begin_inset Text
28774
28775 \begin_layout Standard
28776 0
28777 \end_layout
28778
28779 \end_inset
28780 </cell>
28781 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28782 \begin_inset Text
28783
28784 \begin_layout Standard
28785 0
28786 \end_layout
28787
28788 \end_inset
28789 </cell>
28790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28791 \begin_inset Text
28792
28793 \begin_layout Standard
28794
28795 \family typewriter
28796 \shape slanted
28797 \emph on
28798 uxxxxx xxxxxxxx xxxxxxxx
28799 \end_layout
28800
28801 \end_inset
28802 </cell>
28803 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28804 \begin_inset Text
28805
28806 \begin_layout Standard
28807 a 21-bit code pointer in FLASH memory
28808 \end_layout
28809
28810 \end_inset
28811 </cell>
28812 </row>
28813 <row bottomline="true">
28814 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28815 \begin_inset Text
28816
28817 \begin_layout Standard
28818 eeprom
28819 \end_layout
28820
28821 \end_inset
28822 </cell>
28823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28824 \begin_inset Text
28825
28826 \begin_layout Standard
28827 0
28828 \end_layout
28829
28830 \end_inset
28831 </cell>
28832 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28833 \begin_inset Text
28834
28835 \begin_layout Standard
28836 1
28837 \end_layout
28838
28839 \end_inset
28840 </cell>
28841 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28842 \begin_inset Text
28843
28844 \begin_layout Standard
28845
28846 \family typewriter
28847 \shape slanted
28848 \emph on
28849 uuuuuu uuuuuuxx xxxxxxxx
28850 \end_layout
28851
28852 \end_inset
28853 </cell>
28854 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28855 \begin_inset Text
28856
28857 \begin_layout Standard
28858 a 10-bit eeprom pointer in EEPROM memory
28859 \end_layout
28860
28861 \end_inset
28862 </cell>
28863 </row>
28864 <row bottomline="true">
28865 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28866 \begin_inset Text
28867
28868 \begin_layout Standard
28869 (unimplemented)
28870 \end_layout
28871
28872 \end_inset
28873 </cell>
28874 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28875 \begin_inset Text
28876
28877 \begin_layout Standard
28878 1
28879 \end_layout
28880
28881 \end_inset
28882 </cell>
28883 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28884 \begin_inset Text
28885
28886 \begin_layout Standard
28887 1
28888 \end_layout
28889
28890 \end_inset
28891 </cell>
28892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28893 \begin_inset Text
28894
28895 \begin_layout Standard
28896
28897 \family typewriter
28898 \shape slanted
28899 \emph on
28900 xxxxxx xxxxxxxx xxxxxxxx
28901 \end_layout
28902
28903 \end_inset
28904 </cell>
28905 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28906 \begin_inset Text
28907
28908 \begin_layout Standard
28909 unimplemented pointer type
28910 \end_layout
28911
28912 \end_inset
28913 </cell>
28914 </row>
28915 </lyxtabular>
28916
28917 \end_inset
28918
28919
28920 \end_layout
28921
28922 \begin_layout Standard
28923 \noindent
28924 Generic pointer are read and written with a set of library functions which
28925  read/write 1, 2, 3, 4 bytes.
28926 \end_layout
28927
28928 \begin_layout Subsection
28929 PIC16 C Libraries
28930 \end_layout
28931
28932 \begin_layout Subsubsection
28933 Standard I/O Streams
28934 \end_layout
28935
28936 \begin_layout Standard
28937 In the 
28938 \emph on
28939 stdio.h
28940 \emph default
28941  the type FILE is defined as:
28942 \end_layout
28943
28944 \begin_layout LyX-Code
28945 typedef char * FILE;
28946 \end_layout
28947
28948 \begin_layout Standard
28949 This type is the stream type implemented I/O in the PIC18F devices.
28950  Also the standard input and output streams are declared in stdio.h:
28951 \end_layout
28952
28953 \begin_layout LyX-Code
28954 extern FILE * stdin;
28955 \end_layout
28956
28957 \begin_layout LyX-Code
28958 extern FILE * stdout;
28959 \end_layout
28960
28961 \begin_layout Standard
28962 The FILE type is actually a generic pointer which defines one more type
28963  of generic pointers, the 
28964 \emph on
28965 stream
28966 \emph default
28967  pointer.
28968  This new type has the format:
28969 \end_layout
28970
28971 \begin_layout Standard
28972 \noindent
28973 \align center
28974 \begin_inset Tabular
28975 <lyxtabular version="3" rows="2" columns="7">
28976 <features>
28977 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28978 <column alignment="center" valignment="top" width="0">
28979 <column alignment="center" valignment="top" leftline="true" width="0">
28980 <column alignment="center" valignment="top" leftline="true" width="0">
28981 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28982 <column alignment="center" valignment="top" width="0">
28983 <column alignment="left" valignment="top" rightline="true" width="0">
28984 <row topline="true" bottomline="true">
28985 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28986 \begin_inset Text
28987
28988 \begin_layout Standard
28989 pointer type
28990 \end_layout
28991
28992 \end_inset
28993 </cell>
28994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28995 \begin_inset Text
28996
28997 \begin_layout Standard
28998 <7:6>
28999 \end_layout
29000
29001 \end_inset
29002 </cell>
29003 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29004 \begin_inset Text
29005
29006 \begin_layout Standard
29007 <5>
29008 \end_layout
29009
29010 \end_inset
29011 </cell>
29012 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29013 \begin_inset Text
29014
29015 \begin_layout Standard
29016 <4>
29017 \end_layout
29018
29019 \end_inset
29020 </cell>
29021 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29022 \begin_inset Text
29023
29024 \begin_layout Standard
29025 <3:0>
29026 \end_layout
29027
29028 \end_inset
29029 </cell>
29030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29031 \begin_inset Text
29032
29033 \begin_layout Standard
29034 rest of the pointer
29035 \end_layout
29036
29037 \end_inset
29038 </cell>
29039 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29040 \begin_inset Text
29041
29042 \begin_layout Standard
29043 descrption
29044 \end_layout
29045
29046 \end_inset
29047 </cell>
29048 </row>
29049 <row topline="true" bottomline="true">
29050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29051 \begin_inset Text
29052
29053 \begin_layout Standard
29054 stream
29055 \end_layout
29056
29057 \end_inset
29058 </cell>
29059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29060 \begin_inset Text
29061
29062 \begin_layout Standard
29063 00
29064 \end_layout
29065
29066 \end_inset
29067 </cell>
29068 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29069 \begin_inset Text
29070
29071 \begin_layout Standard
29072 1
29073 \end_layout
29074
29075 \end_inset
29076 </cell>
29077 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29078 \begin_inset Text
29079
29080 \begin_layout Standard
29081 0
29082 \end_layout
29083
29084 \end_inset
29085 </cell>
29086 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29087 \begin_inset Text
29088
29089 \begin_layout Standard
29090 nnnn
29091 \end_layout
29092
29093 \end_inset
29094 </cell>
29095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29096 \begin_inset Text
29097
29098 \begin_layout Standard
29099
29100 \family typewriter
29101 \shape slanted
29102 \emph on
29103 uuuuuuuu uuuuuuuu
29104 \end_layout
29105
29106 \end_inset
29107 </cell>
29108 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29109 \begin_inset Text
29110
29111 \begin_layout Standard
29112 upper byte high nubble is 0x2n, the rest are zeroes
29113 \end_layout
29114
29115 \end_inset
29116 </cell>
29117 </row>
29118 </lyxtabular>
29119
29120 \end_inset
29121
29122
29123 \end_layout
29124
29125 \begin_layout Standard
29126 \noindent
29127 Currently implemented there are 3 types of streams defined:
29128 \end_layout
29129
29130 \begin_layout Standard
29131 \noindent
29132 \align center
29133 \begin_inset Tabular
29134 <lyxtabular version="3" rows="4" columns="4">
29135 <features>
29136 <column alignment="center" valignment="top" leftline="true" width="0">
29137 <column alignment="center" valignment="top" leftline="true" width="0">
29138 <column alignment="center" valignment="top" leftline="true" width="0">
29139 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29140 <row topline="true" bottomline="true">
29141 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29142 \begin_inset Text
29143
29144 \begin_layout Standard
29145 stream type
29146 \end_layout
29147
29148 \end_inset
29149 </cell>
29150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29151 \begin_inset Text
29152
29153 \begin_layout Standard
29154 value
29155 \end_layout
29156
29157 \end_inset
29158 </cell>
29159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29160 \begin_inset Text
29161
29162 \begin_layout Standard
29163 module
29164 \end_layout
29165
29166 \end_inset
29167 </cell>
29168 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29169 \begin_inset Text
29170
29171 \begin_layout Standard
29172 description
29173 \end_layout
29174
29175 \end_inset
29176 </cell>
29177 </row>
29178 <row topline="true">
29179 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29180 \begin_inset Text
29181
29182 \begin_layout Standard
29183 STREAM_USART
29184 \end_layout
29185
29186 \end_inset
29187 </cell>
29188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29189 \begin_inset Text
29190
29191 \begin_layout Standard
29192
29193 \family typewriter
29194 0x200000UL
29195 \end_layout
29196
29197 \end_inset
29198 </cell>
29199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29200 \begin_inset Text
29201
29202 \begin_layout Standard
29203 USART
29204 \end_layout
29205
29206 \end_inset
29207 </cell>
29208 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29209 \begin_inset Text
29210
29211 \begin_layout Standard
29212 Writes/Reads characters via the USART peripheral
29213 \end_layout
29214
29215 \end_inset
29216 </cell>
29217 </row>
29218 <row topline="true">
29219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29220 \begin_inset Text
29221
29222 \begin_layout Standard
29223 STREAM_MSSP
29224 \end_layout
29225
29226 \end_inset
29227 </cell>
29228 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29229 \begin_inset Text
29230
29231 \begin_layout Standard
29232
29233 \family typewriter
29234 0x210000UL
29235 \end_layout
29236
29237 \end_inset
29238 </cell>
29239 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29240 \begin_inset Text
29241
29242 \begin_layout Standard
29243 MSSP
29244 \end_layout
29245
29246 \end_inset
29247 </cell>
29248 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29249 \begin_inset Text
29250
29251 \begin_layout Standard
29252 Writes/Reads characters via the MSSP peripheral
29253 \end_layout
29254
29255 \end_inset
29256 </cell>
29257 </row>
29258 <row topline="true" bottomline="true">
29259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29260 \begin_inset Text
29261
29262 \begin_layout Standard
29263 STREAM_USER
29264 \end_layout
29265
29266 \end_inset
29267 </cell>
29268 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29269 \begin_inset Text
29270
29271 \begin_layout Standard
29272
29273 \family typewriter
29274 0x2f0000UL
29275 \end_layout
29276
29277 \end_inset
29278 </cell>
29279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29280 \begin_inset Text
29281
29282 \begin_layout Standard
29283 (none)
29284 \end_layout
29285
29286 \end_inset
29287 </cell>
29288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29289 \begin_inset Text
29290
29291 \begin_layout Standard
29292 Writes/Reads characters via used defined functions
29293 \end_layout
29294
29295 \end_inset
29296 </cell>
29297 </row>
29298 </lyxtabular>
29299
29300 \end_inset
29301
29302
29303 \end_layout
29304
29305 \begin_layout Standard
29306 \noindent
29307 The stream identifiers are declared as macros in the stdio.h header.
29308 \end_layout
29309
29310 \begin_layout Standard
29311 \noindent
29312 In the libc library there exist the functions that are used to write to
29313  each of the above streams.
29314  These are
29315 \end_layout
29316
29317 \begin_layout Description
29318 _
29319 \begin_inset ERT
29320 status collapsed
29321
29322 \begin_layout Standard
29323
29324
29325 \backslash
29326 /
29327 \end_layout
29328
29329 \end_inset
29330
29331 _stream_usart_putchar writes a character at the USART stream
29332 \end_layout
29333
29334 \begin_layout Description
29335 _
29336 \begin_inset ERT
29337 status collapsed
29338
29339 \begin_layout Standard
29340
29341
29342 \backslash
29343 /
29344 \end_layout
29345
29346 \end_inset
29347
29348 _stream_mssp_putchar writes a character at the MSSP stream
29349 \end_layout
29350
29351 \begin_layout Description
29352 putchar dummy function.
29353  This writes a character to a user specified manner.
29354 \end_layout
29355
29356 \begin_layout Standard
29357 In order to increase performance 
29358 \emph on
29359 putchar
29360 \emph default
29361  is declared in stdio.h as having its parameter in WREG (it has the wparam
29362  keyword).
29363  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
29364  in a user-friendly way.
29365  
29366 \emph on
29367 arg
29368 \emph default
29369  is the name of the variable that holds the character to print.
29370  An example follows:
29371 \end_layout
29372
29373 \begin_layout LyX-Code
29374 #include <pic18fregs.h>
29375 \newline
29376 #include <stdio.h>
29377 \newline
29378
29379 \newline
29380 PUTCHAR( c )
29381 \end_layout
29382
29383 \begin_layout LyX-Code
29384 {
29385 \end_layout
29386
29387 \begin_layout LyX-Code
29388     PORTA = c;    /* dump character c to PORTA */
29389 \end_layout
29390
29391 \begin_layout LyX-Code
29392
29393 \newline
29394
29395 \newline
29396 void main(void)
29397 \end_layout
29398
29399 \begin_layout LyX-Code
29400 {
29401 \end_layout
29402
29403 \begin_layout LyX-Code
29404     stdout = STREAM_USER;    /* this is not necessary, since stdout points
29405 \end_layout
29406
29407 \begin_layout LyX-Code
29408                               * by default to STREAM_USER */
29409 \end_layout
29410
29411 \begin_layout LyX-Code
29412     printf (
29413 \begin_inset Quotes sld
29414 \end_inset
29415
29416 This is a printf test
29417 \backslash
29418 n
29419 \begin_inset Quotes srd
29420 \end_inset
29421
29422 );
29423 \end_layout
29424
29425 \begin_layout LyX-Code
29426 }
29427 \end_layout
29428
29429 \begin_layout LyX-Code
29430
29431 \end_layout
29432
29433 \begin_layout Subsubsection
29434 Printing functions
29435 \end_layout
29436
29437 \begin_layout Standard
29438 PIC16 contains an implementation of the printf-family of functions.
29439  There exist the following functions:
29440 \end_layout
29441
29442 \begin_layout LyX-Code
29443 extern unsigned int sprintf(char *buf, char *fmt, ...);
29444 \end_layout
29445
29446 \begin_layout LyX-Code
29447 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
29448 \end_layout
29449
29450 \begin_layout LyX-Code
29451
29452 \end_layout
29453
29454 \begin_layout LyX-Code
29455 extern unsigned int printf(char *fmt, ...);
29456 \end_layout
29457
29458 \begin_layout LyX-Code
29459 extern unsigned int vprintf(char *fmt, va_lista ap);
29460 \end_layout
29461
29462 \begin_layout LyX-Code
29463
29464 \end_layout
29465
29466 \begin_layout LyX-Code
29467 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
29468 \end_layout
29469
29470 \begin_layout LyX-Code
29471 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
29472 \end_layout
29473
29474 \begin_layout Standard
29475 For sprintf and vsprintf 
29476 \emph on
29477 buf
29478 \emph default
29479  should normally be a data pointer where the resulting string will be placed.
29480  No range checking is done so the user should allocate the necessary buffer.
29481  For fprintf and vfprintf 
29482 \emph on
29483 fp
29484 \emph default
29485  should be a stream pointer (i.e.
29486  stdout, STREAM_MSSP, etc...).
29487 \end_layout
29488
29489 \begin_layout Subsubsection
29490 Signals
29491 \end_layout
29492
29493 \begin_layout Standard
29494 The PIC18F family of microcontrollers supports a number of interrupt sources.
29495  A list of these interrupts is shown in the following table:
29496 \end_layout
29497
29498 \begin_layout Standard
29499 \align center
29500 \begin_inset Tabular
29501 <lyxtabular version="3" rows="11" columns="4">
29502 <features>
29503 <column alignment="left" valignment="top" leftline="true" width="0">
29504 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29505 <column alignment="left" valignment="top" leftline="true" width="0">
29506 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29507 <row topline="true" bottomline="true">
29508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29509 \begin_inset Text
29510
29511 \begin_layout Standard
29512 signal name
29513 \end_layout
29514
29515 \end_inset
29516 </cell>
29517 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29518 \begin_inset Text
29519
29520 \begin_layout Standard
29521 description
29522 \end_layout
29523
29524 \end_inset
29525 </cell>
29526 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29527 \begin_inset Text
29528
29529 \begin_layout Standard
29530 signal name
29531 \end_layout
29532
29533 \end_inset
29534 </cell>
29535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29536 \begin_inset Text
29537
29538 \begin_layout Standard
29539 description
29540 \end_layout
29541
29542 \end_inset
29543 </cell>
29544 </row>
29545 <row topline="true">
29546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29547 \begin_inset Text
29548
29549 \begin_layout Standard
29550 SIG_RB
29551 \end_layout
29552
29553 \end_inset
29554 </cell>
29555 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29556 \begin_inset Text
29557
29558 \begin_layout Standard
29559 PORTB change interrupt
29560 \end_layout
29561
29562 \end_inset
29563 </cell>
29564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29565 \begin_inset Text
29566
29567 \begin_layout Standard
29568 SIG_EE
29569 \end_layout
29570
29571 \end_inset
29572 </cell>
29573 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29574 \begin_inset Text
29575
29576 \begin_layout Standard
29577 EEPROM/FLASH write complete interrupt
29578 \end_layout
29579
29580 \end_inset
29581 </cell>
29582 </row>
29583 <row topline="true">
29584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29585 \begin_inset Text
29586
29587 \begin_layout Standard
29588 SIG_INT0
29589 \end_layout
29590
29591 \end_inset
29592 </cell>
29593 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29594 \begin_inset Text
29595
29596 \begin_layout Standard
29597 INT0 external interrupt
29598 \end_layout
29599
29600 \end_inset
29601 </cell>
29602 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29603 \begin_inset Text
29604
29605 \begin_layout Standard
29606 SIG_BCOL
29607 \end_layout
29608
29609 \end_inset
29610 </cell>
29611 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29612 \begin_inset Text
29613
29614 \begin_layout Standard
29615 Bus collision interrupt
29616 \end_layout
29617
29618 \end_inset
29619 </cell>
29620 </row>
29621 <row topline="true">
29622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29623 \begin_inset Text
29624
29625 \begin_layout Standard
29626 SIG_INT1
29627 \end_layout
29628
29629 \end_inset
29630 </cell>
29631 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29632 \begin_inset Text
29633
29634 \begin_layout Standard
29635 INT1 external interrupt
29636 \end_layout
29637
29638 \end_inset
29639 </cell>
29640 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29641 \begin_inset Text
29642
29643 \begin_layout Standard
29644 SIG_LVD
29645 \end_layout
29646
29647 \end_inset
29648 </cell>
29649 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29650 \begin_inset Text
29651
29652 \begin_layout Standard
29653 Low voltage detect interrupt
29654 \end_layout
29655
29656 \end_inset
29657 </cell>
29658 </row>
29659 <row topline="true">
29660 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29661 \begin_inset Text
29662
29663 \begin_layout Standard
29664 SIG_INT2
29665 \end_layout
29666
29667 \end_inset
29668 </cell>
29669 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29670 \begin_inset Text
29671
29672 \begin_layout Standard
29673 INT2 external interrupt
29674 \end_layout
29675
29676 \end_inset
29677 </cell>
29678 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29679 \begin_inset Text
29680
29681 \begin_layout Standard
29682 SIG_PSP
29683 \end_layout
29684
29685 \end_inset
29686 </cell>
29687 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29688 \begin_inset Text
29689
29690 \begin_layout Standard
29691 Parallel slave port interrupt
29692 \end_layout
29693
29694 \end_inset
29695 </cell>
29696 </row>
29697 <row topline="true">
29698 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29699 \begin_inset Text
29700
29701 \begin_layout Standard
29702 SIG_CCP1
29703 \end_layout
29704
29705 \end_inset
29706 </cell>
29707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29708 \begin_inset Text
29709
29710 \begin_layout Standard
29711 CCP1 module interrupt
29712 \end_layout
29713
29714 \end_inset
29715 </cell>
29716 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29717 \begin_inset Text
29718
29719 \begin_layout Standard
29720 SIG_AD
29721 \end_layout
29722
29723 \end_inset
29724 </cell>
29725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29726 \begin_inset Text
29727
29728 \begin_layout Standard
29729 AD convertion complete interrupt
29730 \end_layout
29731
29732 \end_inset
29733 </cell>
29734 </row>
29735 <row topline="true">
29736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29737 \begin_inset Text
29738
29739 \begin_layout Standard
29740 SIG_CCP2
29741 \end_layout
29742
29743 \end_inset
29744 </cell>
29745 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29746 \begin_inset Text
29747
29748 \begin_layout Standard
29749 CCP2 module interrupt
29750 \end_layout
29751
29752 \end_inset
29753 </cell>
29754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29755 \begin_inset Text
29756
29757 \begin_layout Standard
29758 SIG_RC
29759 \end_layout
29760
29761 \end_inset
29762 </cell>
29763 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29764 \begin_inset Text
29765
29766 \begin_layout Standard
29767 USART receive interrupt
29768 \end_layout
29769
29770 \end_inset
29771 </cell>
29772 </row>
29773 <row topline="true">
29774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29775 \begin_inset Text
29776
29777 \begin_layout Standard
29778 SIG_TMR0
29779 \end_layout
29780
29781 \end_inset
29782 </cell>
29783 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29784 \begin_inset Text
29785
29786 \begin_layout Standard
29787 TMR0 overflow interrupt
29788 \end_layout
29789
29790 \end_inset
29791 </cell>
29792 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29793 \begin_inset Text
29794
29795 \begin_layout Standard
29796 SIG_TX
29797 \end_layout
29798
29799 \end_inset
29800 </cell>
29801 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29802 \begin_inset Text
29803
29804 \begin_layout Standard
29805 USART transmit interrupt
29806 \end_layout
29807
29808 \end_inset
29809 </cell>
29810 </row>
29811 <row topline="true">
29812 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29813 \begin_inset Text
29814
29815 \begin_layout Standard
29816 SIG_TMR1
29817 \end_layout
29818
29819 \end_inset
29820 </cell>
29821 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29822 \begin_inset Text
29823
29824 \begin_layout Standard
29825 TMR1 overflow interrupt
29826 \end_layout
29827
29828 \end_inset
29829 </cell>
29830 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29831 \begin_inset Text
29832
29833 \begin_layout Standard
29834 SIG_MSSP
29835 \end_layout
29836
29837 \end_inset
29838 </cell>
29839 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29840 \begin_inset Text
29841
29842 \begin_layout Standard
29843 SSP receive/transmit interrupt
29844 \end_layout
29845
29846 \end_inset
29847 </cell>
29848 </row>
29849 <row topline="true">
29850 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29851 \begin_inset Text
29852
29853 \begin_layout Standard
29854 SIG_TMR2
29855 \end_layout
29856
29857 \end_inset
29858 </cell>
29859 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29860 \begin_inset Text
29861
29862 \begin_layout Standard
29863 TMR2 matches PR2 interrupt
29864 \end_layout
29865
29866 \end_inset
29867 </cell>
29868 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29869 \begin_inset Text
29870
29871 \begin_layout Standard
29872
29873 \end_layout
29874
29875 \end_inset
29876 </cell>
29877 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29878 \begin_inset Text
29879
29880 \begin_layout Standard
29881
29882 \end_layout
29883
29884 \end_inset
29885 </cell>
29886 </row>
29887 <row topline="true" bottomline="true">
29888 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29889 \begin_inset Text
29890
29891 \begin_layout Standard
29892 SIG_TMR3
29893 \end_layout
29894
29895 \end_inset
29896 </cell>
29897 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29898 \begin_inset Text
29899
29900 \begin_layout Standard
29901 TMR3 overflow interrupt
29902 \end_layout
29903
29904 \end_inset
29905 </cell>
29906 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29907 \begin_inset Text
29908
29909 \begin_layout Standard
29910
29911 \end_layout
29912
29913 \end_inset
29914 </cell>
29915 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29916 \begin_inset Text
29917
29918 \begin_layout Standard
29919
29920 \end_layout
29921
29922 \end_inset
29923 </cell>
29924 </row>
29925 </lyxtabular>
29926
29927 \end_inset
29928
29929
29930 \end_layout
29931
29932 \begin_layout Standard
29933 \noindent
29934 The prototypes for these names are defined in the header file 
29935 \emph on
29936 signal.h
29937 \emph default
29938  .
29939 \end_layout
29940
29941 \begin_layout Standard
29942 \noindent
29943 In order to simplify signal handling, a number of macros is provided:
29944 \end_layout
29945
29946 \begin_layout List
29947 \labelwidthstring 00.00.0000
29948 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
29949  high priority interrupts.
29950  
29951 \emph on
29952 name
29953 \emph default
29954  is the function name to use.
29955 \end_layout
29956
29957 \begin_layout List
29958 \labelwidthstring 00.00.0000
29959 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
29960  low priority interrupt.
29961  
29962 \emph on
29963 name
29964 \emph default
29965  is the function name to use.
29966 \end_layout
29967
29968 \begin_layout List
29969 \labelwidthstring 00.00.0000
29970 DEF_HANDLER(sig,handler) define a handler for signal 
29971 \emph on
29972 sig.
29973 \end_layout
29974
29975 \begin_layout List
29976 \labelwidthstring 00.00.0000
29977 END_DEF end the declaration of the dispatch table.
29978 \end_layout
29979
29980 \begin_layout Standard
29981 Additionally there are two more macros to simplify the declaration of the
29982  signal handler:
29983 \end_layout
29984
29985 \begin_layout List
29986 \labelwidthstring 00.00.0000
29987
29988 \series medium
29989 SIGHANDLER(handler)
29990 \series default
29991  this declares the function prototype for the 
29992 \emph on
29993 handler
29994 \emph default
29995  function.
29996 \end_layout
29997
29998 \begin_layout List
29999 \labelwidthstring 00.00.0000
30000 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
30001 \end_layout
30002
30003 \begin_layout Standard
30004 An example of using the macros above is shown below:
30005 \end_layout
30006
30007 \begin_layout LyX-Code
30008 #include <pic18fregs.h>
30009 \end_layout
30010
30011 \begin_layout LyX-Code
30012 #include <signal.h>
30013 \newline
30014
30015 \newline
30016 DEF_INTHIGH(high_int)
30017 \end_layout
30018
30019 \begin_layout LyX-Code
30020 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
30021 \end_layout
30022
30023 \begin_layout LyX-Code
30024 DEF_HANDLER(SIG_BCOL, _bcol_handler)
30025 \end_layout
30026
30027 \begin_layout LyX-Code
30028 END_DEF
30029 \newline
30030
30031 \newline
30032 SIGHANDLER(_tmr0_handler)
30033 \end_layout
30034
30035 \begin_layout LyX-Code
30036 {
30037 \end_layout
30038
30039 \begin_layout LyX-Code
30040   /* action to be taken when timer 0 overflows */
30041 \end_layout
30042
30043 \begin_layout LyX-Code
30044 }
30045 \newline
30046
30047 \newline
30048 SIGHANDLERNAKED(_bcol_handler)
30049 \end_layout
30050
30051 \begin_layout LyX-Code
30052 {
30053 \end_layout
30054
30055 \begin_layout LyX-Code
30056   _asm
30057 \end_layout
30058
30059 \begin_layout LyX-Code
30060     /* action to be taken when bus collision occurs */
30061 \end_layout
30062
30063 \begin_layout LyX-Code
30064     retfie
30065 \end_layout
30066
30067 \begin_layout LyX-Code
30068  _endasm;
30069 \end_layout
30070
30071 \begin_layout LyX-Code
30072 }
30073 \end_layout
30074
30075 \begin_layout Standard
30076
30077 \series bold
30078 NOTES:
30079 \series default
30080  Special care should be taken when using the above scheme:
30081 \end_layout
30082
30083 \begin_layout Itemize
30084 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
30085 \end_layout
30086
30087 \begin_layout Itemize
30088 when declaring SIGHANDLERNAKED handler never forget to use 
30089 \emph on
30090 retfie
30091 \emph default
30092  for proper returning.
30093 \end_layout
30094
30095 \begin_layout Subsection
30096 PIC16 Port -- Tips
30097 \end_layout
30098
30099 \begin_layout Standard
30100 Here you can find some general tips for compiling programs with SDCC/pic16.
30101 \end_layout
30102
30103 \begin_layout Subsubsection
30104 Stack size
30105 \end_layout
30106
30107 \begin_layout Standard
30108 The default stack
30109 \begin_inset LatexCommand index
30110 name "PIC16!stack"
30111
30112 \end_inset
30113
30114  size (that is 64 bytes) probably is enough for many programs.
30115  One must take care that when there are many levels of function nesting,
30116  or there is excessive usage of stack, its size should be extended.
30117  An example of such a case is the printf/sprintf family of functions.
30118  If you encounter problems like not being able to print integers, then you
30119  need to set the stack size around the maximum (256 for small stack model).
30120  The following diagram shows what happens when calling printf to print an
30121  integer:
30122 \end_layout
30123
30124 \begin_layout LyX-Code
30125 printf () --> ltoa () --> ultoa () --> divschar ()
30126 \end_layout
30127
30128 \begin_layout Standard
30129 It is should be understood that stack is easily consumed when calling complicate
30130 d functions.
30131  Using command line arguments like -
30132 \begin_inset ERT
30133 status collapsed
30134
30135 \begin_layout Standard
30136
30137
30138 \backslash
30139 /
30140 \end_layout
30141
30142 \end_inset
30143
30144 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
30145  stack frames.
30146  Other ways to reduce stack usage may exist.
30147 \end_layout
30148
30149 \begin_layout Subsection
30150 Known Bugs
30151 \end_layout
30152
30153 \begin_layout Subsubsection
30154 Extended Instruction Set
30155 \end_layout
30156
30157 \begin_layout Standard
30158 The PIC16 port emits code which is incompatible with the extended instruction
30159  set available with many newer devices.
30160  Make sure to always explicitly disable it, usually using
30161 \end_layout
30162
30163 \begin_layout Standard
30164
30165 \family typewriter
30166 static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
30167 \end_layout
30168
30169 \begin_layout Standard
30170 \noindent
30171 Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
30172  instead of _XINST_OFF_4L.
30173 \end_layout
30174
30175 \begin_layout Subsubsection
30176 Regression Tests
30177 \end_layout
30178
30179 \begin_layout Standard
30180 The PIC16 port currently passes most but not all of the tests in SDCC's
30181  regression test
30182 \begin_inset LatexCommand index
30183 name "Regression test (PIC16)"
30184
30185 \end_inset
30186
30187  suite (see section 
30188 \begin_inset LatexCommand ref
30189 reference "sec:Quality-control"
30190
30191 \end_inset
30192
30193 ), thus no automatic regression tests are currently performed for the PIC16
30194  target.
30195 \end_layout
30196
30197 \begin_layout Chapter
30198 Debugging
30199 \end_layout
30200
30201 \begin_layout Standard
30202 There are several approaches to debugging your code.
30203  This chapter is meant to show your options and to give detail on some of
30204  them:
30205 \newline
30206
30207 \newline
30208 When writing your code:
30209 \end_layout
30210
30211 \begin_layout Itemize
30212 write your code with debugging in mind (avoid duplicating code, put conceptually
30213  similar variables into structs, use structured code, have strategic points
30214  within your code where all variables are consistent, ...)
30215 \end_layout
30216
30217 \begin_layout Itemize
30218 run a syntax-checking tool like splint
30219 \begin_inset LatexCommand index
30220 name "splint (syntax checking tool)"
30221
30222 \end_inset
30223
30224
30225 \begin_inset LatexCommand index
30226 name "lint (syntax checking tool)"
30227
30228 \end_inset
30229
30230  (see -
30231 \begin_inset ERT
30232 status collapsed
30233
30234 \begin_layout Standard
30235
30236
30237 \backslash
30238 /
30239 \end_layout
30240
30241 \end_inset
30242
30243 -more-pedantic 
30244 \begin_inset LatexCommand ref
30245 reference "lyx:more-pedantic-SPLINT"
30246
30247 \end_inset
30248
30249 ) over the code.
30250 \end_layout
30251
30252 \begin_layout Itemize
30253 for the high level code use a C-compiler (like f.e.
30254  GCC) to compile run and debug the code on your host.
30255  See (see -
30256 \begin_inset ERT
30257 status collapsed
30258
30259 \begin_layout Standard
30260
30261
30262 \backslash
30263 /
30264 \end_layout
30265
30266 \end_inset
30267
30268 -more-pedantic 
30269 \begin_inset LatexCommand ref
30270 reference "lyx:more-pedantic-SPLINT"
30271
30272 \end_inset
30273
30274 ) on how to handle syntax extensions like __xdata, __at(), ...
30275  
30276 \end_layout
30277
30278 \begin_layout Itemize
30279 use another C-compiler to compile code for your target.
30280  Always an option but not recommended:) And not very likely to help you.
30281  If you seriously consider walking this path you should at least occasionally
30282  check portability of your code.
30283  Most commercial compiler vendors will offer an evaluation version so you
30284  can test compile your code or snippets of your code.
30285 \end_layout
30286
30287 \begin_layout Standard
30288 Debugging on a simulator:
30289 \end_layout
30290
30291 \begin_layout Itemize
30292 there is a separate section about SDCDB (section 
30293 \begin_inset LatexCommand ref
30294 reference "cha:Debugging-with-SDCDB"
30295
30296 \end_inset
30297
30298 ) below.
30299 \end_layout
30300
30301 \begin_layout Itemize
30302 or (8051 specific) use a freeware/commercial simulator which interfaces
30303  to the AOMF
30304 \begin_inset LatexCommand index
30305 name "AOMF, AOMF51"
30306
30307 \end_inset
30308
30309  file (see 
30310 \begin_inset LatexCommand ref
30311 reference "OMF file"
30312
30313 \end_inset
30314
30315 ) optionally generated by SDCC.
30316 \end_layout
30317
30318 \begin_layout Standard
30319 Debugging On-target: 
30320 \end_layout
30321
30322 \begin_layout Itemize
30323 use a MCU port pin to serially output debug data to the RS232 port of your
30324  host.
30325  You'll probably want some level shifting device typically involving a MAX232
30326  or similar IC.
30327  If the hardware serial port of the MCU is not available search for 'Software
30328  UART' in your favourite search machine.
30329 \end_layout
30330
30331 \begin_layout Itemize
30332 use an on-target monitor.
30333  In this context a monitor is a small program which usually accepts commands
30334  via a serial line and allows to set program counter, to single step through
30335  a program and read/write memory locations.
30336  For the 8051 good examples of monitors are paulmon and cmon51 (see section
30337  
30338 \begin_inset LatexCommand ref
30339 reference "sec:Related-open-source-tools"
30340
30341 \end_inset
30342
30343 ).
30344 \end_layout
30345
30346 \begin_layout Itemize
30347 toggle MCU port pins at strategic points within your code and use an oscilloscop
30348 e.
30349  A 
30350 \emph on
30351 digital oscilloscope
30352 \emph default
30353
30354 \begin_inset LatexCommand index
30355 name "Oscilloscope"
30356
30357 \end_inset
30358
30359  with deep trace memory is really helpful especially if you have to debug
30360  a realtime application.
30361  If you need to monitor more pins than your oscilloscope provides you can
30362  sometimes get away with a small R-2R network.
30363  On a single channel oscilloscope you could f.e.
30364  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
30365 k
30366 \begin_inset Formula $\Omega$
30367 \end_inset
30368
30369  resistor and the other one by a 5\InsetSpace ~
30370 k
30371 \begin_inset Formula $\Omega$
30372 \end_inset
30373
30374  resistor to the oscilloscope probe (check output drive capability of the
30375  pins you want to monitor).
30376  If you need to monitor many more pins a 
30377 \emph on
30378 logic analyzer
30379 \emph default
30380  will be handy.
30381 \end_layout
30382
30383 \begin_layout Itemize
30384 use an ICE (
30385 \emph on
30386 i
30387 \emph default
30388
30389 \emph on
30390 c
30391 \emph default
30392 ircuit 
30393 \emph on
30394 e
30395 \emph default
30396 mulator
30397 \begin_inset LatexCommand index
30398 name "ICE (in circuit emulator)"
30399
30400 \end_inset
30401
30402 ).
30403  Usually very expensive.
30404  And very nice to have too.
30405  And usually locks you (for years...) to the devices the ICE can emulate.
30406  
30407 \end_layout
30408
30409 \begin_layout Itemize
30410 use a remote debugger.
30411  In most 8-bit systems the symbol information is not available on the target,
30412  and a complete debugger is too bulky for the target system.
30413  Therefore usually a debugger on the host system connects to an on-target
30414  debugging stub which accepts only primitive commands.
30415  
30416 \newline
30417 Terms to enter into your favourite search engine could be 'remote debugging',
30418  'gdb stub' or 'inferior debugger'.
30419  (is there one?)
30420 \end_layout
30421
30422 \begin_layout Itemize
30423 use an on target hardware debugger.
30424  Some of the more modern MCUs include hardware support for setting break
30425  points and monitoring/changing variables by using dedicated hardware pins.
30426  This facility doesn't require additional code to run on the target and
30427  
30428 \emph on
30429 usually
30430 \emph default
30431  doesn't affect runtime behaviour until a breakpoint is hit.
30432  For the mcs51 most hardware debuggers use the AOMF
30433 \begin_inset LatexCommand index
30434 name "AOMF, AOMF51"
30435
30436 \end_inset
30437
30438  file (see 
30439 \begin_inset LatexCommand ref
30440 reference "OMF file"
30441
30442 \end_inset
30443
30444 ) as input file.
30445  
30446 \end_layout
30447
30448 \begin_layout Standard
30449 Last not least:
30450 \end_layout
30451
30452 \begin_layout Itemize
30453 if you are not familiar with any of the following terms you're likely to
30454  run into problems rather sooner than later: 
30455 \emph on
30456 volatile
30457 \emph default
30458
30459 \emph on
30460 atomic
30461 \emph default
30462
30463 \emph on
30464 memory map
30465 \emph default
30466
30467 \emph on
30468 overlay
30469 \emph default
30470 .
30471  As an embedded programmer you 
30472 \emph on
30473 have
30474 \emph default
30475  to know them so why not look them up 
30476 \emph on
30477 before
30478 \emph default
30479  you have problems?)
30480 \end_layout
30481
30482 \begin_layout Itemize
30483 tell someone else about your problem (actually this is a surprisingly effective
30484  means to hunt down the bug even if the listener is not familiar with your
30485  environment).
30486  As 'failure to communicate' is probably one of the job-induced deformations
30487  of an embedded programmer this is highly encouraged.
30488 \end_layout
30489
30490 \begin_layout Section
30491 Debugging with SDCDB
30492 \begin_inset LatexCommand label
30493 name "cha:Debugging-with-SDCDB"
30494
30495 \end_inset
30496
30497
30498 \begin_inset LatexCommand index
30499 name "SDCDB (debugger)"
30500
30501 \end_inset
30502
30503  
30504 \end_layout
30505
30506 \begin_layout Standard
30507 SDCC is distributed with a source level debugger
30508 \begin_inset LatexCommand index
30509 name "Debugger"
30510
30511 \end_inset
30512
30513 .
30514  The debugger uses a command line interface, the command repertoire of the
30515  debugger has been kept as close to gdb
30516 \begin_inset LatexCommand index
30517 name "gdb"
30518
30519 \end_inset
30520
30521  (the GNU debugger) as possible.
30522  The configuration and build process is part of the standard compiler installati
30523 on, which also builds and installs the debugger in the target directory
30524  specified during configuration.
30525  The debugger allows you debug BOTH at the C source and at the ASM source
30526  level.
30527 \end_layout
30528
30529 \begin_layout Subsection
30530 Compiling for Debugging
30531 \end_layout
30532
30533 \begin_layout Standard
30534 The -
30535 \begin_inset ERT
30536 status collapsed
30537
30538 \begin_layout Standard
30539
30540
30541 \backslash
30542 /
30543 \end_layout
30544
30545 \end_inset
30546
30547 -debug
30548 \begin_inset LatexCommand index
30549 name "-\\/-debug"
30550
30551 \end_inset
30552
30553  option must be specified for all files for which debug information is to
30554  be generated.
30555  The compiler generates a .adb file for each of these files.
30556  The linker creates the .cdb
30557 \begin_inset LatexCommand index
30558 name "<file>.cdb"
30559
30560 \end_inset
30561
30562  file from the .adb
30563 \begin_inset LatexCommand index
30564 name "<file>.adb"
30565
30566 \end_inset
30567
30568  files and the address information.
30569  This .cdb is used by the debugger.
30570 \end_layout
30571
30572 \begin_layout Subsection
30573 How the Debugger Works
30574 \end_layout
30575
30576 \begin_layout Standard
30577 When the -
30578 \begin_inset ERT
30579 status collapsed
30580
30581 \begin_layout Standard
30582
30583
30584 \backslash
30585 /
30586 \end_layout
30587
30588 \end_inset
30589
30590 -debug option is specified the compiler generates extra symbol information
30591  some of which are put into the assembler source and some are put into the
30592  .adb file.
30593  Then the linker creates the .cdb file from the individual .adb files with
30594  the address information for the symbols.
30595  The debugger reads the symbolic information generated by the compiler &
30596  the address information generated by the linker.
30597  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
30598  execution is controlled by the debugger.
30599  When a command is issued for the debugger, it translates it into appropriate
30600  commands for the simulator.
30601  (Currently SDCDM only connects to the simulator but 
30602 \emph on
30603 newcdb
30604 \emph default
30605  at 
30606 \begin_inset LatexCommand url
30607 target "http://ec2drv.sf.net/"
30608
30609 \end_inset
30610
30611  is an effort to connect directly to the hardware.) 
30612 \end_layout
30613
30614 \begin_layout Subsection
30615 Starting the Debugger SDCDB
30616 \end_layout
30617
30618 \begin_layout Standard
30619 The debugger can be started using the following command line.
30620  (Assume the file you are debugging has the file name foo).
30621 \newline
30622
30623 \newline
30624
30625 \family sans
30626 \series bold
30627 sdcdb foo
30628 \newline
30629
30630 \family default
30631 \series default
30632
30633 \newline
30634 The debugger will look for the following files.
30635 \end_layout
30636
30637 \begin_layout Itemize
30638 foo.c - the source file.
30639 \end_layout
30640
30641 \begin_layout Itemize
30642 foo.cdb - the debugger symbol information file.
30643 \end_layout
30644
30645 \begin_layout Itemize
30646 foo.ihx - the Intel hex format
30647 \begin_inset LatexCommand index
30648 name "Intel hex format"
30649
30650 \end_inset
30651
30652  object file.
30653 \end_layout
30654
30655 \begin_layout Subsection
30656 SDCDB Command Line Options
30657 \end_layout
30658
30659 \begin_layout Itemize
30660 -
30661 \begin_inset ERT
30662 status collapsed
30663
30664 \begin_layout Standard
30665
30666
30667 \backslash
30668 /
30669 \end_layout
30670
30671 \end_inset
30672
30673 -directory=<source file directory> this option can used to specify the directory
30674  search list.
30675  The debugger will look into the directory list specified for source, cdb
30676  & ihx files.
30677  The items in the directory list must be separated by ':', e.g.
30678  if the source files can be in the directories /home/src1 and /home/src2,
30679  the -
30680 \begin_inset ERT
30681 status collapsed
30682
30683 \begin_layout Standard
30684
30685
30686 \backslash
30687 /
30688 \end_layout
30689
30690 \end_inset
30691
30692 -directory option should be -
30693 \begin_inset ERT
30694 status collapsed
30695
30696 \begin_layout Standard
30697
30698
30699 \backslash
30700 /
30701 \end_layout
30702
30703 \end_inset
30704
30705 -directory=/home/src1:/home/src2.
30706  Note there can be no spaces in the option.
30707  
30708 \end_layout
30709
30710 \begin_layout Itemize
30711 -cd <directory> - change to the <directory>.
30712 \end_layout
30713
30714 \begin_layout Itemize
30715 -fullname - used by GUI front ends.
30716 \end_layout
30717
30718 \begin_layout Itemize
30719 -cpu <cpu-type> - this argument is passed to the simulator please see the
30720  simulator docs for details.
30721 \end_layout
30722
30723 \begin_layout Itemize
30724 -X <Clock frequency > this options is passed to the simulator please see
30725  the simulator docs for details.
30726 \end_layout
30727
30728 \begin_layout Itemize
30729 -s <serial port file> passed to simulator see the simulator docs for details.
30730 \end_layout
30731
30732 \begin_layout Itemize
30733 -S <serial in,out> passed to simulator see the simulator docs for details.
30734 \end_layout
30735
30736 \begin_layout Itemize
30737 -k <port number> passed to simulator see the simulator docs for details.
30738 \end_layout
30739
30740 \begin_layout Subsection
30741 SDCDB Debugger Commands
30742 \end_layout
30743
30744 \begin_layout Standard
30745 As mentioned earlier the command interface for the debugger has been deliberatel
30746 y kept as close the GNU debugger gdb, as possible.
30747  This will help the integration with existing graphical user interfaces
30748  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
30749  If you use a graphical user interface for the debugger you can skip this
30750  section.
30751 \end_layout
30752
30753 \begin_layout Subsubsection*
30754 break [line | file:line | function | file:function]
30755 \end_layout
30756
30757 \begin_layout Standard
30758 Set breakpoint at specified line or function:
30759 \newline
30760
30761 \newline
30762
30763 \family sans
30764 \series bold
30765 sdcdb>break 100 
30766 \newline
30767 sdcdb>break foo.c:100
30768 \newline
30769 sdcdb>break funcfoo
30770 \newline
30771 sdcdb>break foo.c:funcfoo
30772 \end_layout
30773
30774 \begin_layout Subsubsection*
30775 clear [line | file:line | function | file:function ]
30776 \end_layout
30777
30778 \begin_layout Standard
30779 Clear breakpoint at specified line or function:
30780 \newline
30781
30782 \newline
30783
30784 \family sans
30785 \series bold
30786 sdcdb>clear 100
30787 \newline
30788 sdcdb>clear foo.c:100
30789 \newline
30790 sdcdb>clear funcfoo
30791 \newline
30792 sdcdb>clear foo.c:funcfoo
30793 \end_layout
30794
30795 \begin_layout Subsubsection*
30796 continue
30797 \end_layout
30798
30799 \begin_layout Standard
30800 Continue program being debugged, after breakpoint.
30801 \end_layout
30802
30803 \begin_layout Subsubsection*
30804 finish
30805 \end_layout
30806
30807 \begin_layout Standard
30808 Execute till the end of the current function.
30809 \end_layout
30810
30811 \begin_layout Subsubsection*
30812 delete [n]
30813 \end_layout
30814
30815 \begin_layout Standard
30816 Delete breakpoint number 'n'.
30817  If used without any option clear ALL user defined break points.
30818 \end_layout
30819
30820 \begin_layout Subsubsection*
30821 info [break | stack | frame | registers ]
30822 \end_layout
30823
30824 \begin_layout Itemize
30825 info break - list all breakpoints
30826 \end_layout
30827
30828 \begin_layout Itemize
30829 info stack - show the function call stack.
30830 \end_layout
30831
30832 \begin_layout Itemize
30833 info frame - show information about the current execution frame.
30834 \end_layout
30835
30836 \begin_layout Itemize
30837 info registers - show content of all registers.
30838 \end_layout
30839
30840 \begin_layout Subsubsection*
30841 step
30842 \end_layout
30843
30844 \begin_layout Standard
30845 Step program until it reaches a different source line.
30846  Note: pressing <return> repeats the last command.
30847 \end_layout
30848
30849 \begin_layout Subsubsection*
30850 next
30851 \end_layout
30852
30853 \begin_layout Standard
30854 Step program, proceeding through subroutine calls.
30855 \end_layout
30856
30857 \begin_layout Subsubsection*
30858 run
30859 \end_layout
30860
30861 \begin_layout Standard
30862 Start debugged program.
30863 \end_layout
30864
30865 \begin_layout Subsubsection*
30866 ptype variable 
30867 \end_layout
30868
30869 \begin_layout Standard
30870 Print type information of the variable.
30871 \end_layout
30872
30873 \begin_layout Subsubsection*
30874 print variable
30875 \end_layout
30876
30877 \begin_layout Standard
30878 print value of variable.
30879 \end_layout
30880
30881 \begin_layout Subsubsection*
30882 file filename
30883 \end_layout
30884
30885 \begin_layout Standard
30886 load the given file name.
30887  Note this is an alternate method of loading file for debugging.
30888 \end_layout
30889
30890 \begin_layout Subsubsection*
30891 frame
30892 \end_layout
30893
30894 \begin_layout Standard
30895 print information about current frame.
30896 \end_layout
30897
30898 \begin_layout Subsubsection*
30899 set srcmode
30900 \end_layout
30901
30902 \begin_layout Standard
30903 Toggle between C source & assembly source.
30904 \end_layout
30905
30906 \begin_layout Subsubsection*
30907 ! simulator command
30908 \end_layout
30909
30910 \begin_layout Standard
30911 Send the string following '!' to the simulator, the simulator response is
30912  displayed.
30913  Note the debugger does not interpret the command being sent to the simulator,
30914  so if a command like 'go' is sent the debugger can loose its execution
30915  context and may display incorrect values.
30916 \end_layout
30917
30918 \begin_layout Subsubsection*
30919 quit
30920 \end_layout
30921
30922 \begin_layout Standard
30923 "Watch me now.
30924  Iam going Down.
30925  My name is Bobby Brown"
30926 \end_layout
30927
30928 \begin_layout Subsection
30929 Interfacing SDCDB with DDD
30930 \end_layout
30931
30932 \begin_layout Standard
30933 \begin_inset Note Note
30934 status collapsed
30935
30936 \begin_layout Standard
30937 The screenshot was converted from png to eps with: 
30938 \begin_inset Quotes sld
30939 \end_inset
30940
30941 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
30942 \begin_inset Quotes srd
30943 \end_inset
30944
30945  which produces a pretty compact eps file which is free from compression
30946  artifacts.
30947 \end_layout
30948
30949 \begin_layout Standard
30950 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
30951  as this broke the build system on Sourceforge (pdf-file was broken.
30952  pdflatex does not accept eps files).
30953 \end_layout
30954
30955 \end_inset
30956
30957
30958 \end_layout
30959
30960 \begin_layout Standard
30961 The 
30962 \emph on
30963 p
30964 \emph default
30965 ortable 
30966 \emph on
30967 n
30968 \emph default
30969 etwork 
30970 \emph on
30971 g
30972 \emph default
30973 raphics File 
30974 \size footnotesize
30975
30976 \begin_inset LatexCommand url
30977 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png"
30978
30979 \end_inset
30980
30981
30982 \size default
30983  shows a screenshot of a debugging session with DDD
30984 \begin_inset LatexCommand index
30985 name "DDD (debugger)"
30986
30987 \end_inset
30988
30989  (Unix only) on a simulated 8032.
30990  The debugging session might not run as smoothly as the screenshot suggests.
30991  The debugger allows setting of breakpoints, displaying and changing variables,
30992  single stepping through C and assembler code.
30993  
30994 \newline
30995 The source was compiled with 
30996 \family sans
30997 \series bold
30998
30999 \newline
31000
31001 \newline
31002 sdcc -
31003 \family default
31004 \series default
31005
31006 \begin_inset ERT
31007 status collapsed
31008
31009 \begin_layout Standard
31010
31011
31012 \backslash
31013 /
31014 \end_layout
31015
31016 \end_inset
31017
31018
31019 \family sans
31020 \series bold
31021 -debug ddd_example.c
31022 \family default
31023 \series default
31024  
31025 \family sans
31026 \series bold
31027
31028 \newline
31029
31030 \family default
31031 \series default
31032
31033 \newline
31034 and DDD was invoked with 
31035 \family sans
31036 \series bold
31037
31038 \newline
31039
31040 \newline
31041 ddd -debugger "sdcdb -cpu 8032 ddd_example"
31042 \end_layout
31043
31044 \begin_layout Standard
31045 \begin_inset Note Note
31046 status open
31047
31048 \begin_layout Standard
31049 Check that the double quotes or an apostrophe within the command line survive
31050  the LyX tool chain.
31051  Previously the apostrophes got slanted in the PDF output so a cut and paste
31052  did not work.
31053 \end_layout
31054
31055 \end_inset
31056
31057
31058 \end_layout
31059
31060 \begin_layout Subsection
31061 Interfacing SDCDB with XEmacs
31062 \begin_inset LatexCommand index
31063 name "XEmacs"
31064
31065 \end_inset
31066
31067
31068 \begin_inset LatexCommand index
31069 name "Emacs"
31070
31071 \end_inset
31072
31073
31074 \end_layout
31075
31076 \begin_layout Standard
31077 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
31078  sdcdb.el and sdcdbsrc.el.
31079  These two files can be found in the $(prefix)/bin directory after the installat
31080 ion is complete.
31081  These files need to be loaded into XEmacs for the interface to work.
31082  This can be done at XEmacs startup time by inserting the following into
31083  your '.xemacs' file (which can be found in your HOME directory): 
31084 \newline
31085
31086 \newline
31087
31088 \family typewriter
31089 (load-file sdcdbsrc.el)
31090 \family default
31091  
31092 \newline
31093
31094 \newline
31095 .xemacs is a lisp file so the () around the command is REQUIRED.
31096  The files can also be loaded dynamically while XEmacs is running, set the
31097  environment variable 'EMACSLOADPATH' to the installation bin directory
31098  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
31099  To start the interface enter the following command: 
31100 \newline
31101
31102 \newline
31103
31104 \family sans
31105 \series bold
31106 ESC-x sdcdbsrc
31107 \family default
31108 \series default
31109
31110 \newline
31111
31112 \newline
31113 You will prompted to enter the file name to be debugged.
31114  
31115 \newline
31116
31117 \newline
31118 The command line options that are passed to the simulator directly are
31119  bound to default values in the file sdcdbsrc.el.
31120  The variables are listed below, these values maybe changed as required.
31121 \end_layout
31122
31123 \begin_layout Itemize
31124 sdcdbsrc-cpu-type '51
31125 \end_layout
31126
31127 \begin_layout Itemize
31128 sdcdbsrc-frequency '11059200
31129 \end_layout
31130
31131 \begin_layout Itemize
31132 sdcdbsrc-serial nil
31133 \end_layout
31134
31135 \begin_layout Standard
31136 The following is a list of key mapping for the debugger interface.
31137 \end_layout
31138
31139 \begin_layout Standard
31140 \InsetSpace ~
31141
31142 \family typewriter
31143
31144 \newline
31145 ;;\InsetSpace ~
31146 Current Listing :: 
31147 \newline
31148 ;;key\InsetSpace ~
31149 \InsetSpace ~
31150 \InsetSpace ~
31151 \InsetSpace ~
31152 \InsetSpace ~
31153 \InsetSpace ~
31154 \InsetSpace ~
31155 \InsetSpace ~
31156 \InsetSpace ~
31157 \InsetSpace ~
31158 \InsetSpace ~
31159 \InsetSpace ~
31160 \InsetSpace ~
31161 \InsetSpace ~
31162 binding\InsetSpace ~
31163 \InsetSpace ~
31164 \InsetSpace ~
31165 \InsetSpace ~
31166 \InsetSpace ~
31167 \InsetSpace ~
31168 \InsetSpace ~
31169 \InsetSpace ~
31170 \InsetSpace ~
31171 \InsetSpace ~
31172 \InsetSpace ~
31173 \InsetSpace ~
31174 \InsetSpace ~
31175 \InsetSpace ~
31176 \InsetSpace ~
31177 \InsetSpace ~
31178 \InsetSpace ~
31179 \InsetSpace ~
31180 \InsetSpace ~
31181 \InsetSpace ~
31182 \InsetSpace ~
31183 \InsetSpace ~
31184 Comment 
31185 \newline
31186 ;;---\InsetSpace ~
31187 \InsetSpace ~
31188 \InsetSpace ~
31189 \InsetSpace ~
31190 \InsetSpace ~
31191 \InsetSpace ~
31192 \InsetSpace ~
31193 \InsetSpace ~
31194 \InsetSpace ~
31195 \InsetSpace ~
31196 \InsetSpace ~
31197 \InsetSpace ~
31198 \InsetSpace ~
31199 \InsetSpace ~
31200 -------\InsetSpace ~
31201 \InsetSpace ~
31202 \InsetSpace ~
31203 \InsetSpace ~
31204 \InsetSpace ~
31205 \InsetSpace ~
31206 \InsetSpace ~
31207 \InsetSpace ~
31208 \InsetSpace ~
31209 \InsetSpace ~
31210 \InsetSpace ~
31211 \InsetSpace ~
31212 \InsetSpace ~
31213 \InsetSpace ~
31214 \InsetSpace ~
31215 \InsetSpace ~
31216 \InsetSpace ~
31217 \InsetSpace ~
31218 \InsetSpace ~
31219 \InsetSpace ~
31220 \InsetSpace ~
31221 \InsetSpace ~
31222 -------
31223 \newline
31224 ;; 
31225 \newline
31226 ;;\InsetSpace ~
31227 n\InsetSpace ~
31228 \InsetSpace ~
31229 \InsetSpace ~
31230 \InsetSpace ~
31231 \InsetSpace ~
31232 \InsetSpace ~
31233 \InsetSpace ~
31234 \InsetSpace ~
31235 \InsetSpace ~
31236 \InsetSpace ~
31237 \InsetSpace ~
31238 \InsetSpace ~
31239 \InsetSpace ~
31240 \InsetSpace ~
31241 \InsetSpace ~
31242 sdcdb-next-fro
31243 m-src\InsetSpace ~
31244 \InsetSpace ~
31245 \InsetSpace ~
31246 \InsetSpace ~
31247 \InsetSpace ~
31248 \InsetSpace ~
31249 \InsetSpace ~
31250 \InsetSpace ~
31251 \InsetSpace ~
31252 \InsetSpace ~
31253 SDCDB next command 
31254 \newline
31255 ;;\InsetSpace ~
31256 b\InsetSpace ~
31257 \InsetSpace ~
31258 \InsetSpace ~
31259 \InsetSpace ~
31260 \InsetSpace ~
31261 \InsetSpace ~
31262 \InsetSpace ~
31263 \InsetSpace ~
31264 \InsetSpace ~
31265 \InsetSpace ~
31266 \InsetSpace ~
31267 \InsetSpace ~
31268 \InsetSpace ~
31269 \InsetSpace ~
31270 \InsetSpace ~
31271 sdcdb-back-from-src\InsetSpace ~
31272 \InsetSpace ~
31273 \InsetSpace ~
31274 \InsetSpace ~
31275 \InsetSpace ~
31276 \InsetSpace ~
31277 \InsetSpace ~
31278 \InsetSpace ~
31279 \InsetSpace ~
31280 \InsetSpace ~
31281 SDCDB back command 
31282 \newline
31283 ;;\InsetSpace ~
31284 c\InsetSpace ~
31285 \InsetSpace ~
31286 \InsetSpace ~
31287 \InsetSpace ~
31288 \InsetSpace ~
31289 \InsetSpace ~
31290 \InsetSpace ~
31291 \InsetSpace ~
31292 \InsetSpace ~
31293 \InsetSpace ~
31294 \InsetSpace ~
31295 \InsetSpace ~
31296 \InsetSpace ~
31297 \InsetSpace ~
31298 \InsetSpace ~
31299 sdcdb-cont-f
31300 rom-src\InsetSpace ~
31301 \InsetSpace ~
31302 \InsetSpace ~
31303 \InsetSpace ~
31304 \InsetSpace ~
31305 \InsetSpace ~
31306 \InsetSpace ~
31307 \InsetSpace ~
31308 \InsetSpace ~
31309 \InsetSpace ~
31310 SDCDB continue command
31311 \newline
31312 ;;\InsetSpace ~
31313 s\InsetSpace ~
31314 \InsetSpace ~
31315 \InsetSpace ~
31316 \InsetSpace ~
31317 \InsetSpace ~
31318 \InsetSpace ~
31319 \InsetSpace ~
31320 \InsetSpace ~
31321 \InsetSpace ~
31322 \InsetSpace ~
31323 \InsetSpace ~
31324 \InsetSpace ~
31325 \InsetSpace ~
31326 \InsetSpace ~
31327 \InsetSpace ~
31328 sdcdb-step-from-src\InsetSpace ~
31329 \InsetSpace ~
31330 \InsetSpace ~
31331 \InsetSpace ~
31332 \InsetSpace ~
31333 \InsetSpace ~
31334 \InsetSpace ~
31335 \InsetSpace ~
31336 \InsetSpace ~
31337 \InsetSpace ~
31338 SDCDB step command 
31339 \newline
31340 ;;\InsetSpace ~
31341 ?\InsetSpace ~
31342 \InsetSpace ~
31343 \InsetSpace ~
31344 \InsetSpace ~
31345 \InsetSpace ~
31346 \InsetSpace ~
31347 \InsetSpace ~
31348 \InsetSpace ~
31349 \InsetSpace ~
31350 \InsetSpace ~
31351 \InsetSpace ~
31352 \InsetSpace ~
31353 \InsetSpace ~
31354 \InsetSpace ~
31355 \InsetSpace ~
31356 sdcdb-w
31357 hatis-c-sexp\InsetSpace ~
31358 \InsetSpace ~
31359 \InsetSpace ~
31360 \InsetSpace ~
31361 \InsetSpace ~
31362 \InsetSpace ~
31363 \InsetSpace ~
31364 \InsetSpace ~
31365 \InsetSpace ~
31366 \InsetSpace ~
31367 SDCDB ptypecommand for data at 
31368 \newline
31369 ;;\InsetSpace ~
31370 \InsetSpace ~
31371 \InsetSpace ~
31372 \InsetSpace ~
31373 \InsetSpace ~
31374 \InsetSpace ~
31375 \InsetSpace ~
31376 \InsetSpace ~
31377 \InsetSpace ~
31378 \InsetSpace ~
31379 \InsetSpace ~
31380 \InsetSpace ~
31381 \InsetSpace ~
31382 \InsetSpace ~
31383 \InsetSpace ~
31384 \InsetSpace ~
31385 \InsetSpace ~
31386 \InsetSpace ~
31387 \InsetSpace ~
31388 \InsetSpace ~
31389 \InsetSpace ~
31390 \InsetSpace ~
31391 \InsetSpace ~
31392 \InsetSpace ~
31393 \InsetSpace ~
31394 \InsetSpace ~
31395 \InsetSpace ~
31396 \InsetSpace ~
31397 \InsetSpace ~
31398 \InsetSpace ~
31399 \InsetSpace ~
31400 \InsetSpace ~
31401 \InsetSpace ~
31402 \InsetSpace ~
31403 \InsetSpace ~
31404 \InsetSpace ~
31405 \InsetSpace ~
31406 \InsetSpace ~
31407 \InsetSpace ~
31408 \InsetSpace ~
31409 \InsetSpace ~
31410 \InsetSpace ~
31411 \InsetSpace ~
31412 \InsetSpace ~
31413 \InsetSpace ~
31414 \InsetSpace ~
31415 \InsetSpace ~
31416 buffer point 
31417 \newline
31418 ;;\InsetSpace ~
31419 x\InsetSpace ~
31420 \InsetSpace ~
31421 \InsetSpace ~
31422 \InsetSpace ~
31423 \InsetSpace ~
31424 \InsetSpace ~
31425 \InsetSpace ~
31426 \InsetSpace ~
31427 \InsetSpace ~
31428 \InsetSpace ~
31429 \InsetSpace ~
31430 \InsetSpace ~
31431 \InsetSpace ~
31432 \InsetSpace ~
31433 \InsetSpace ~
31434 sdcdbsrc-delete\InsetSpace ~
31435 \InsetSpace ~
31436 \InsetSpace ~
31437 \InsetSpace ~
31438 \InsetSpace ~
31439 \InsetSpace ~
31440 \InsetSpace ~
31441 \InsetSpace ~
31442 \InsetSpace ~
31443 \InsetSpace ~
31444 \InsetSpace ~
31445 \InsetSpace ~
31446 \InsetSpace ~
31447 \InsetSpace ~
31448 SDCD
31449 B Delete all breakpoints if no arg 
31450 \newline
31451 ;;\InsetSpace ~
31452 \InsetSpace ~
31453 \InsetSpace ~
31454 \InsetSpace ~
31455 \InsetSpace ~
31456 \InsetSpace ~
31457 \InsetSpace ~
31458 \InsetSpace ~
31459 \InsetSpace ~
31460 \InsetSpace ~
31461 \InsetSpace ~
31462 \InsetSpace ~
31463 \InsetSpace ~
31464 \InsetSpace ~
31465 \InsetSpace ~
31466 \InsetSpace ~
31467 \InsetSpace ~
31468 \InsetSpace ~
31469 \InsetSpace ~
31470 \InsetSpace ~
31471 \InsetSpace ~
31472 \InsetSpace ~
31473 \InsetSpace ~
31474 \InsetSpace ~
31475 \InsetSpace ~
31476 \InsetSpace ~
31477 \InsetSpace ~
31478 \InsetSpace ~
31479 \InsetSpace ~
31480 \InsetSpace ~
31481 \InsetSpace ~
31482 \InsetSpace ~
31483 \InsetSpace ~
31484 \InsetSpace ~
31485 \InsetSpace ~
31486 \InsetSpace ~
31487 \InsetSpace ~
31488 \InsetSpace ~
31489 \InsetSpace ~
31490 \InsetSpace ~
31491 \InsetSpace ~
31492 \InsetSpace ~
31493 \InsetSpace ~
31494 \InsetSpace ~
31495 \InsetSpace ~
31496 \InsetSpace ~
31497 \InsetSpace ~
31498 given or delete arg (C-u arg x) 
31499 \newline
31500 ;;\InsetSpace ~
31501 m\InsetSpace ~
31502 \InsetSpace ~
31503 \InsetSpace ~
31504 \InsetSpace ~
31505 \InsetSpace ~
31506 \InsetSpace ~
31507 \InsetSpace ~
31508 \InsetSpace ~
31509 \InsetSpace ~
31510 \InsetSpace ~
31511 \InsetSpace ~
31512 \InsetSpace ~
31513 \InsetSpace ~
31514 \InsetSpace ~
31515 \InsetSpace ~
31516 sdcdbsrc
31517 -frame\InsetSpace ~
31518 \InsetSpace ~
31519 \InsetSpace ~
31520 \InsetSpace ~
31521 \InsetSpace ~
31522 \InsetSpace ~
31523 \InsetSpace ~
31524 \InsetSpace ~
31525 \InsetSpace ~
31526 \InsetSpace ~
31527 \InsetSpace ~
31528 \InsetSpace ~
31529 \InsetSpace ~
31530 \InsetSpace ~
31531 \InsetSpace ~
31532 SDCDB Display current frame if no arg, 
31533 \newline
31534 ;;\InsetSpace ~
31535 \InsetSpace ~
31536 \InsetSpace ~
31537 \InsetSpace ~
31538 \InsetSpace ~
31539 \InsetSpace ~
31540 \InsetSpace ~
31541 \InsetSpace ~
31542 \InsetSpace ~
31543 \InsetSpace ~
31544 \InsetSpace ~
31545 \InsetSpace ~
31546 \InsetSpace ~
31547 \InsetSpace ~
31548 \InsetSpace ~
31549 \InsetSpace ~
31550 \InsetSpace ~
31551 \InsetSpace ~
31552 \InsetSpace ~
31553 \InsetSpace ~
31554 \InsetSpace ~
31555 \InsetSpace ~
31556 \InsetSpace ~
31557 \InsetSpace ~
31558 \InsetSpace ~
31559 \InsetSpace ~
31560 \InsetSpace ~
31561 \InsetSpace ~
31562 \InsetSpace ~
31563 \InsetSpace ~
31564 \InsetSpace ~
31565 \InsetSpace ~
31566 \InsetSpace ~
31567 \InsetSpace ~
31568 \InsetSpace ~
31569 \InsetSpace ~
31570 \InsetSpace ~
31571 \InsetSpace ~
31572 \InsetSpace ~
31573 \InsetSpace ~
31574 \InsetSpace ~
31575 \InsetSpace ~
31576 \InsetSpace ~
31577 \InsetSpace ~
31578 \InsetSpace ~
31579 \InsetSpace ~
31580 \InsetSpace ~
31581 given or display frame arg
31582  
31583 \newline
31584 ;;\InsetSpace ~
31585 \InsetSpace ~
31586 \InsetSpace ~
31587 \InsetSpace ~
31588 \InsetSpace ~
31589 \InsetSpace ~
31590 \InsetSpace ~
31591 \InsetSpace ~
31592 \InsetSpace ~
31593 \InsetSpace ~
31594 \InsetSpace ~
31595 \InsetSpace ~
31596 \InsetSpace ~
31597 \InsetSpace ~
31598 \InsetSpace ~
31599 \InsetSpace ~
31600 \InsetSpace ~
31601 \InsetSpace ~
31602 \InsetSpace ~
31603 \InsetSpace ~
31604 \InsetSpace ~
31605 \InsetSpace ~
31606 \InsetSpace ~
31607 \InsetSpace ~
31608 \InsetSpace ~
31609 \InsetSpace ~
31610 \InsetSpace ~
31611 \InsetSpace ~
31612 \InsetSpace ~
31613 \InsetSpace ~
31614 \InsetSpace ~
31615 \InsetSpace ~
31616 \InsetSpace ~
31617 \InsetSpace ~
31618 \InsetSpace ~
31619 \InsetSpace ~
31620 \InsetSpace ~
31621 \InsetSpace ~
31622 \InsetSpace ~
31623 \InsetSpace ~
31624 \InsetSpace ~
31625 \InsetSpace ~
31626 \InsetSpace ~
31627 \InsetSpace ~
31628 \InsetSpace ~
31629 \InsetSpace ~
31630 \InsetSpace ~
31631 buffer point 
31632 \newline
31633 ;;\InsetSpace ~
31634 !\InsetSpace ~
31635 \InsetSpace ~
31636 \InsetSpace ~
31637 \InsetSpace ~
31638 \InsetSpace ~
31639 \InsetSpace ~
31640 \InsetSpace ~
31641 \InsetSpace ~
31642 \InsetSpace ~
31643 \InsetSpace ~
31644 \InsetSpace ~
31645 \InsetSpace ~
31646 \InsetSpace ~
31647 \InsetSpace ~
31648 \InsetSpace ~
31649 sdcdbsrc-goto-sdcdb\InsetSpace ~
31650 \InsetSpace ~
31651 \InsetSpace ~
31652 \InsetSpace ~
31653 \InsetSpace ~
31654 \InsetSpace ~
31655 \InsetSpace ~
31656 \InsetSpace ~
31657 \InsetSpace ~
31658 \InsetSpace ~
31659 Goto the SDCDB output buffer 
31660 \newline
31661 ;;\InsetSpace ~
31662 p\InsetSpace ~
31663 \InsetSpace ~
31664 \InsetSpace ~
31665 \InsetSpace ~
31666 \InsetSpace ~
31667 \InsetSpace ~
31668 \InsetSpace ~
31669 \InsetSpace ~
31670 \InsetSpace ~
31671 \InsetSpace ~
31672 \InsetSpace ~
31673 \InsetSpace ~
31674 \InsetSpace ~
31675 \InsetSpace ~
31676 \InsetSpace ~
31677 sdcdb-prin
31678 t-c-sexp\InsetSpace ~
31679 \InsetSpace ~
31680 \InsetSpace ~
31681 \InsetSpace ~
31682 \InsetSpace ~
31683 \InsetSpace ~
31684 \InsetSpace ~
31685 \InsetSpace ~
31686 \InsetSpace ~
31687 \InsetSpace ~
31688 \InsetSpace ~
31689 SDCDB print command for data at 
31690 \newline
31691 ;;\InsetSpace ~
31692 \InsetSpace ~
31693 \InsetSpace ~
31694 \InsetSpace ~
31695 \InsetSpace ~
31696 \InsetSpace ~
31697 \InsetSpace ~
31698 \InsetSpace ~
31699 \InsetSpace ~
31700 \InsetSpace ~
31701 \InsetSpace ~
31702 \InsetSpace ~
31703 \InsetSpace ~
31704 \InsetSpace ~
31705 \InsetSpace ~
31706 \InsetSpace ~
31707 \InsetSpace ~
31708 \InsetSpace ~
31709 \InsetSpace ~
31710 \InsetSpace ~
31711 \InsetSpace ~
31712 \InsetSpace ~
31713 \InsetSpace ~
31714 \InsetSpace ~
31715 \InsetSpace ~
31716 \InsetSpace ~
31717 \InsetSpace ~
31718 \InsetSpace ~
31719 \InsetSpace ~
31720 \InsetSpace ~
31721 \InsetSpace ~
31722 \InsetSpace ~
31723 \InsetSpace ~
31724 \InsetSpace ~
31725 \InsetSpace ~
31726 \InsetSpace ~
31727 \InsetSpace ~
31728 \InsetSpace ~
31729 \InsetSpace ~
31730 \InsetSpace ~
31731 \InsetSpace ~
31732 \InsetSpace ~
31733 \InsetSpace ~
31734 \InsetSpace ~
31735 \InsetSpace ~
31736 \InsetSpace ~
31737 \InsetSpace ~
31738 buffer point 
31739 \newline
31740 ;;\InsetSpace ~
31741 g\InsetSpace ~
31742 \InsetSpace ~
31743 \InsetSpace ~
31744 \InsetSpace ~
31745 \InsetSpace ~
31746 \InsetSpace ~
31747 \InsetSpace ~
31748 \InsetSpace ~
31749 \InsetSpace ~
31750 \InsetSpace ~
31751 \InsetSpace ~
31752 \InsetSpace ~
31753 \InsetSpace ~
31754 \InsetSpace ~
31755 \InsetSpace ~
31756 sdcdbsrc-goto-sdcdb\InsetSpace ~
31757 \InsetSpace ~
31758 \InsetSpace ~
31759 \InsetSpace ~
31760 \InsetSpace ~
31761 \InsetSpace ~
31762 \InsetSpace ~
31763 \InsetSpace ~
31764 \InsetSpace ~
31765 \InsetSpace ~
31766 Got
31767 o the SDCDB output buffer 
31768 \newline
31769 ;;\InsetSpace ~
31770 t\InsetSpace ~
31771 \InsetSpace ~
31772 \InsetSpace ~
31773 \InsetSpace ~
31774 \InsetSpace ~
31775 \InsetSpace ~
31776 \InsetSpace ~
31777 \InsetSpace ~
31778 \InsetSpace ~
31779 \InsetSpace ~
31780 \InsetSpace ~
31781 \InsetSpace ~
31782 \InsetSpace ~
31783 \InsetSpace ~
31784 \InsetSpace ~
31785 sdcdbsrc-mode\InsetSpace ~
31786 \InsetSpace ~
31787 \InsetSpace ~
31788 \InsetSpace ~
31789 \InsetSpace ~
31790 \InsetSpace ~
31791 \InsetSpace ~
31792 \InsetSpace ~
31793 \InsetSpace ~
31794 \InsetSpace ~
31795 \InsetSpace ~
31796 \InsetSpace ~
31797 \InsetSpace ~
31798 \InsetSpace ~
31799 \InsetSpace ~
31800 \InsetSpace ~
31801 Toggles Sdcdbsrc mode (turns it
31802  off) 
31803 \newline
31804 ;; 
31805 \newline
31806 ;;\InsetSpace ~
31807 C-c\InsetSpace ~
31808 C-f\InsetSpace ~
31809 \InsetSpace ~
31810 \InsetSpace ~
31811 \InsetSpace ~
31812 \InsetSpace ~
31813 \InsetSpace ~
31814 \InsetSpace ~
31815 \InsetSpace ~
31816 \InsetSpace ~
31817 sdcdb-finish-from-src\InsetSpace ~
31818 \InsetSpace ~
31819 \InsetSpace ~
31820 \InsetSpace ~
31821 \InsetSpace ~
31822 \InsetSpace ~
31823 \InsetSpace ~
31824 \InsetSpace ~
31825 SDCDB finish command 
31826 \newline
31827 ;; 
31828 \newline
31829 ;;\InsetSpace ~
31830 C-x\InsetSpace ~
31831 SPC\InsetSpace ~
31832 \InsetSpace ~
31833 \InsetSpace ~
31834 \InsetSpace ~
31835 \InsetSpace ~
31836 \InsetSpace ~
31837 \InsetSpace ~
31838 \InsetSpace ~
31839 \InsetSpace ~
31840 sdcdb-brea
31841 k\InsetSpace ~
31842 \InsetSpace ~
31843 \InsetSpace ~
31844 \InsetSpace ~
31845 \InsetSpace ~
31846 \InsetSpace ~
31847 \InsetSpace ~
31848 \InsetSpace ~
31849 \InsetSpace ~
31850 \InsetSpace ~
31851 \InsetSpace ~
31852 \InsetSpace ~
31853 \InsetSpace ~
31854 \InsetSpace ~
31855 \InsetSpace ~
31856 \InsetSpace ~
31857 \InsetSpace ~
31858 \InsetSpace ~
31859 Set break for line with point 
31860 \newline
31861 ;;\InsetSpace ~
31862 ESC\InsetSpace ~
31863 t\InsetSpace ~
31864 \InsetSpace ~
31865 \InsetSpace ~
31866 \InsetSpace ~
31867 \InsetSpace ~
31868 \InsetSpace ~
31869 \InsetSpace ~
31870 \InsetSpace ~
31871 \InsetSpace ~
31872 \InsetSpace ~
31873 \InsetSpace ~
31874 sdcdbsrc-mode\InsetSpace ~
31875 \InsetSpace ~
31876 \InsetSpace ~
31877 \InsetSpace ~
31878 \InsetSpace ~
31879 \InsetSpace ~
31880 \InsetSpace ~
31881 \InsetSpace ~
31882 \InsetSpace ~
31883 \InsetSpace ~
31884 \InsetSpace ~
31885 \InsetSpace ~
31886 \InsetSpace ~
31887 \InsetSpace ~
31888 \InsetSpace ~
31889 \InsetSpace ~
31890 Toggle Sdcdbsrc mode 
31891 \newline
31892 ;;\InsetSpace ~
31893 ESC\InsetSpace ~
31894 m\InsetSpace ~
31895 \InsetSpace ~
31896 \InsetSpace ~
31897 \InsetSpace ~
31898 \InsetSpace ~
31899 \InsetSpace ~
31900 \InsetSpace ~
31901 \InsetSpace ~
31902 \InsetSpace ~
31903 \InsetSpace ~
31904 \InsetSpace ~
31905 sdc
31906 dbsrc-srcmode\InsetSpace ~
31907 \InsetSpace ~
31908 \InsetSpace ~
31909 \InsetSpace ~
31910 \InsetSpace ~
31911 \InsetSpace ~
31912 \InsetSpace ~
31913 \InsetSpace ~
31914 \InsetSpace ~
31915 \InsetSpace ~
31916 \InsetSpace ~
31917 \InsetSpace ~
31918 \InsetSpace ~
31919 Toggle list mode 
31920 \newline
31921 ;; 
31922 \newline
31923
31924 \family default
31925
31926 \newpage
31927
31928 \end_layout
31929
31930 \begin_layout Chapter
31931 TIPS
31932 \end_layout
31933
31934 \begin_layout Standard
31935 Here are a few guidelines that will help the compiler generate more efficient
31936  code, some of the tips are specific to this compiler others are generally
31937  good programming practice.
31938 \end_layout
31939
31940 \begin_layout Itemize
31941 Use the smallest data type to represent your data-value.
31942  If it is known in advance that the value is going to be less than 256 then
31943  use an 'unsigned char' instead of a 'short' or 'int'.
31944  Please note, that ANSI C requires both signed and unsigned chars to be
31945  promoted to 'signed int'
31946 \begin_inset LatexCommand index
31947 name "promotion to signed int"
31948
31949 \end_inset
31950
31951
31952 \begin_inset Marginal
31953 status collapsed
31954
31955 \begin_layout Standard
31956
31957 \series bold
31958 \InsetSpace ~
31959 !
31960 \end_layout
31961
31962 \end_inset
31963
31964  before doing any operation.
31965  This promotion
31966 \begin_inset LatexCommand index
31967 name "type promotion"
31968
31969 \end_inset
31970
31971
31972 \begin_inset LatexCommand label
31973 name "type promotion"
31974
31975 \end_inset
31976
31977  can be omitted, if the result is the same.
31978  The effect of the promotion rules together with the sign-extension is often
31979  surprising:
31980 \end_layout
31981
31982 \begin_deeper
31983 \begin_layout Verse
31984
31985 \family typewriter
31986 unsigned char uc = 0xfe;
31987 \newline
31988 if (uc * uc < 0) /* this is true! */
31989 \newline
31990 {
31991 \newline
31992 \InsetSpace ~
31993 \InsetSpace ~
31994 \InsetSpace ~
31995 \InsetSpace ~
31996 ....
31997 \newline
31998 }
31999 \end_layout
32000
32001 \begin_layout Standard
32002
32003 \family typewriter
32004 uc * uc
32005 \family default
32006  is evaluated as 
32007 \family typewriter
32008 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
32009 \family default
32010 .
32011  
32012 \newline
32013 Another one:
32014 \end_layout
32015
32016 \begin_layout Verse
32017
32018 \family typewriter
32019 (unsigned char) -12 / (signed char) -3 = ...
32020 \end_layout
32021
32022 \begin_layout Standard
32023 No, the result is not 4:
32024 \end_layout
32025
32026 \begin_layout Verse
32027
32028 \family typewriter
32029 (int) (unsigned char) -12 / (int) (signed char) -3 =
32030 \newline
32031 (int) (unsigned char)
32032  0xf4 / (int) (signed char) 0xfd =
32033 \newline
32034 (int) 0x00f4 / (int) 0xfffd =
32035 \newline
32036 (int) 0x00f4
32037  / (int) 0xfffd =
32038 \newline
32039 (int) 244 / (int) -3 =
32040 \newline
32041 (int) -81 = (int) 0xffaf;
32042 \end_layout
32043
32044 \begin_layout Standard
32045 Don't complain, that gcc gives you a different result.
32046  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
32047  Therefore the results are different.
32048 \newline
32049 From 
32050 \begin_inset Quotes sld
32051 \end_inset
32052
32053 comp.lang.c FAQ
32054 \begin_inset Quotes srd
32055 \end_inset
32056
32057 :
32058 \end_layout
32059
32060 \begin_layout Quote
32061
32062 \emph on
32063 If well-defined overflow characteristics are important and negative values
32064  are not, or if you want to steer clear of sign-extension problems when
32065  manipulating bits or bytes, use one of the corresponding unsigned types.
32066  (Beware when mixing signed and unsigned values in expressions, though.)
32067 \newline
32068 Although
32069  character types (especially unsigned char) can be used as "tiny" integers,
32070  doing so is sometimes more trouble than it's worth, due to unpredictable
32071  sign extension and increased code size.
32072 \end_layout
32073
32074 \end_deeper
32075 \begin_layout Itemize
32076 Use unsigned when it is known in advance that the value is not going to
32077  be negative.
32078  This helps especially if you are doing division or multiplication, bit-shifting
32079  or are using an array index.
32080 \end_layout
32081
32082 \begin_layout Itemize
32083 NEVER jump into a LOOP.
32084 \end_layout
32085
32086 \begin_layout Itemize
32087 Declare the variables to be local
32088 \begin_inset LatexCommand index
32089 name "local variables"
32090
32091 \end_inset
32092
32093  whenever possible, especially loop control variables (induction).
32094 \end_layout
32095
32096 \begin_layout Itemize
32097 Have a look at the assembly listing to get a 
32098 \begin_inset Quotes sld
32099 \end_inset
32100
32101 feeling
32102 \begin_inset Quotes srd
32103 \end_inset
32104
32105  for the code generation.
32106 \end_layout
32107
32108 \begin_layout Section
32109 Porting code from or to other compilers
32110 \begin_inset LatexCommand label
32111 name "sec:Porting-code-to-other-compilers"
32112
32113 \end_inset
32114
32115
32116 \end_layout
32117
32118 \begin_layout Itemize
32119 check whether endianness of the compilers differs and adapt where needed.
32120 \end_layout
32121
32122 \begin_layout Itemize
32123 check the device specific header files
32124 \begin_inset LatexCommand index
32125 name "Header files"
32126
32127 \end_inset
32128
32129
32130 \begin_inset LatexCommand index
32131 name "Include files"
32132
32133 \end_inset
32134
32135  for compiler specific syntax.
32136  Eventually include the file <compiler.h
32137 \begin_inset LatexCommand index
32138 name "compiler.h (include file)"
32139
32140 \end_inset
32141
32142
32143 \begin_inset LatexCommand url
32144 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup"
32145
32146 \end_inset
32147
32148  to allow using common header files.
32149  (see f.e.
32150  cc2510fx.h 
32151 \begin_inset LatexCommand url
32152 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup"
32153
32154 \end_inset
32155
32156 ).
32157 \end_layout
32158
32159 \begin_layout Itemize
32160 check whether the startup code contains the correct initialization (watchdog,
32161  peripherals).
32162 \end_layout
32163
32164 \begin_layout Itemize
32165 check whether the sizes of short, int, long match.
32166 \end_layout
32167
32168 \begin_layout Itemize
32169 check if some 16 or 32 bit hardware registers require a specific addressing
32170  order (least significant or most significant byte first) and adapt if needed
32171  (
32172 \emph on
32173 first
32174 \emph default
32175  and 
32176 \emph on
32177 last
32178 \emph default
32179  relate to time and not to lower/upper memory location here, so this is
32180  
32181 \emph on
32182 not
32183 \emph default
32184  the same as endianness).
32185 \end_layout
32186
32187 \begin_layout Itemize
32188 check whether the keyword 
32189 \emph on
32190 volatile
32191 \emph default
32192  is used where needed.
32193  The compilers might differ in their optimization characteristics (as different
32194  versions of the same compiler might also use more clever optimizations
32195  this is good idea anyway).
32196  See section 
32197 \begin_inset LatexCommand ref
32198 reference "sub:Common-interrupt-pitfall-volatile"
32199
32200 \end_inset
32201
32202 .
32203 \end_layout
32204
32205 \begin_layout Itemize
32206 check that the compilers are not told to suppress warnings.
32207 \end_layout
32208
32209 \begin_layout Itemize
32210 check and convert compiler specific extensions (interrupts, memory areas,
32211  pragmas etc.).
32212 \end_layout
32213
32214 \begin_layout Itemize
32215 check for differences in type promotion.
32216  Especially check for math operations on 
32217 \family typewriter
32218 char
32219 \family default
32220  or 
32221 \family typewriter
32222 unsigned char
32223 \family default
32224  variables.
32225  For the sake of C99 compatibility SDCC will probably promote these to 
32226 \family typewriter
32227 int
32228 \family default
32229  more often than other compilers.
32230  Eventually insert explicit casts to 
32231 \family typewriter
32232 (char)
32233 \family default
32234  or 
32235 \family typewriter
32236 (unsigned char)
32237 \family default
32238 .
32239  Also check that the ~\InsetSpace ~
32240 operator
32241 \begin_inset LatexCommand index
32242 name "\\~\\/ Operator"
32243
32244 \end_inset
32245
32246  is not used on 
32247 \family typewriter
32248 bit
32249 \begin_inset LatexCommand index
32250 name "bit"
32251
32252 \end_inset
32253
32254
32255 \family default
32256  variables, use the !\InsetSpace ~
32257 operator instead.
32258  See sections 
32259 \begin_inset LatexCommand ref
32260 reference "type promotion"
32261
32262 \end_inset
32263
32264  and 
32265 \begin_inset LatexCommand ref
32266 reference "sec:Compatibility-with-previous"
32267
32268 \end_inset
32269
32270 .
32271 \end_layout
32272
32273 \begin_layout Itemize
32274 check the assembly code generated for interrupt routines (f.e.
32275  for calls to possibly non-reentrant library functions).
32276 \end_layout
32277
32278 \begin_layout Itemize
32279 check whether timing loops result in proper timing (or preferably consider
32280  a rewrite of the code with timer based delays instead).
32281 \end_layout
32282
32283 \begin_layout Itemize
32284 check for differences in printf parameters (some compilers push (va_arg
32285 \begin_inset LatexCommand index
32286 name "vararg, va\\_arg"
32287
32288 \end_inset
32289
32290 ) char variables as 
32291 \family typewriter
32292 int
32293 \family default
32294  others push them as 
32295 \family typewriter
32296 char
32297 \family default
32298 .
32299  See section 
32300 \begin_inset LatexCommand ref
32301 reference "sec:Compatibility-with-previous"
32302
32303 \end_inset
32304
32305 ).
32306 \end_layout
32307
32308 \begin_layout Itemize
32309 check the resulting memory map
32310 \begin_inset LatexCommand index
32311 name "Memory map"
32312
32313 \end_inset
32314
32315 .
32316  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
32317 ly idata, pdata, xdata).
32318  Eventually check if unexpected library functions are included.
32319 \end_layout
32320
32321 \begin_layout Section
32322 Tools
32323 \begin_inset LatexCommand index
32324 name "Tools"
32325
32326 \end_inset
32327
32328  included in the distribution
32329 \end_layout
32330
32331 \begin_layout Standard
32332 \align left
32333 \begin_inset Tabular
32334 <lyxtabular version="3" rows="12" columns="3">
32335 <features>
32336 <column alignment="left" valignment="top" leftline="true" width="0pt">
32337 <column alignment="left" valignment="top" leftline="true" width="0pt">
32338 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32339 <row topline="true" bottomline="true">
32340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32341 \begin_inset Text
32342
32343 \begin_layout Standard
32344
32345 \series bold
32346 Name
32347 \end_layout
32348
32349 \end_inset
32350 </cell>
32351 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32352 \begin_inset Text
32353
32354 \begin_layout Standard
32355
32356 \series bold
32357 Purpose
32358 \end_layout
32359
32360 \end_inset
32361 </cell>
32362 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32363 \begin_inset Text
32364
32365 \begin_layout Standard
32366
32367 \series bold
32368 Directory
32369 \end_layout
32370
32371 \end_inset
32372 </cell>
32373 </row>
32374 <row topline="true">
32375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32376 \begin_inset Text
32377
32378 \begin_layout Standard
32379 uCsim
32380 \begin_inset LatexCommand index
32381 name "uCsim"
32382
32383 \end_inset
32384
32385
32386 \end_layout
32387
32388 \end_inset
32389 </cell>
32390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32391 \begin_inset Text
32392
32393 \begin_layout Standard
32394 Simulator for various architectures
32395 \end_layout
32396
32397 \end_inset
32398 </cell>
32399 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32400 \begin_inset Text
32401
32402 \begin_layout Standard
32403 sdcc/sim/ucsim
32404 \end_layout
32405
32406 \end_inset
32407 </cell>
32408 </row>
32409 <row topline="true">
32410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32411 \begin_inset Text
32412
32413 \begin_layout Standard
32414 keil2sdcc.pl
32415 \end_layout
32416
32417 \end_inset
32418 </cell>
32419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32420 \begin_inset Text
32421
32422 \begin_layout Standard
32423 header file
32424 \begin_inset LatexCommand index
32425 name "Header files"
32426
32427 \end_inset
32428
32429
32430 \begin_inset LatexCommand index
32431 name "Include files"
32432
32433 \end_inset
32434
32435  conversion
32436 \end_layout
32437
32438 \end_inset
32439 </cell>
32440 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32441 \begin_inset Text
32442
32443 \begin_layout Standard
32444 sdcc/support/scripts
32445 \end_layout
32446
32447 \end_inset
32448 </cell>
32449 </row>
32450 <row topline="true">
32451 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32452 \begin_inset Text
32453
32454 \begin_layout Standard
32455 mh2h.c
32456 \end_layout
32457
32458 \end_inset
32459 </cell>
32460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32461 \begin_inset Text
32462
32463 \begin_layout Standard
32464 header file conversion
32465 \end_layout
32466
32467 \end_inset
32468 </cell>
32469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32470 \begin_inset Text
32471
32472 \begin_layout Standard
32473 sdcc/support/scripts
32474 \end_layout
32475
32476 \end_inset
32477 </cell>
32478 </row>
32479 <row topline="true">
32480 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32481 \begin_inset Text
32482
32483 \begin_layout Standard
32484 as-gbz80
32485 \end_layout
32486
32487 \end_inset
32488 </cell>
32489 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32490 \begin_inset Text
32491
32492 \begin_layout Standard
32493 Assembler
32494 \end_layout
32495
32496 \end_inset
32497 </cell>
32498 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32499 \begin_inset Text
32500
32501 \begin_layout Standard
32502
32503 \family roman
32504 \series medium
32505 \shape up
32506 \size normal
32507 \emph off
32508 \bar no
32509 \noun off
32510 \color none
32511 sdcc/bin
32512 \end_layout
32513
32514 \end_inset
32515 </cell>
32516 </row>
32517 <row topline="true">
32518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32519 \begin_inset Text
32520
32521 \begin_layout Standard
32522 as-z80
32523 \end_layout
32524
32525 \end_inset
32526 </cell>
32527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32528 \begin_inset Text
32529
32530 \begin_layout Standard
32531 Assembler
32532 \end_layout
32533
32534 \end_inset
32535 </cell>
32536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32537 \begin_inset Text
32538
32539 \begin_layout Standard
32540
32541 \family roman
32542 \series medium
32543 \shape up
32544 \size normal
32545 \emph off
32546 \bar no
32547 \noun off
32548 \color none
32549 sdcc/bin
32550 \end_layout
32551
32552 \end_inset
32553 </cell>
32554 </row>
32555 <row topline="true">
32556 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32557 \begin_inset Text
32558
32559 \begin_layout Standard
32560 asx8051
32561 \end_layout
32562
32563 \end_inset
32564 </cell>
32565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32566 \begin_inset Text
32567
32568 \begin_layout Standard
32569 Assembler
32570 \end_layout
32571
32572 \end_inset
32573 </cell>
32574 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32575 \begin_inset Text
32576
32577 \begin_layout Standard
32578
32579 \family roman
32580 \series medium
32581 \shape up
32582 \size normal
32583 \emph off
32584 \bar no
32585 \noun off
32586 \color none
32587 sdcc/bin
32588 \end_layout
32589
32590 \end_inset
32591 </cell>
32592 </row>
32593 <row topline="true">
32594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32595 \begin_inset Text
32596
32597 \begin_layout Standard
32598 SDCDB
32599 \end_layout
32600
32601 \end_inset
32602 </cell>
32603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32604 \begin_inset Text
32605
32606 \begin_layout Standard
32607 Simulator
32608 \end_layout
32609
32610 \end_inset
32611 </cell>
32612 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32613 \begin_inset Text
32614
32615 \begin_layout Standard
32616
32617 \family roman
32618 \series medium
32619 \shape up
32620 \size normal
32621 \emph off
32622 \bar no
32623 \noun off
32624 \color none
32625 sdcc/bin
32626 \end_layout
32627
32628 \end_inset
32629 </cell>
32630 </row>
32631 <row topline="true">
32632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32633 \begin_inset Text
32634
32635 \begin_layout Standard
32636 aslink
32637 \end_layout
32638
32639 \end_inset
32640 </cell>
32641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32642 \begin_inset Text
32643
32644 \begin_layout Standard
32645 Linker
32646 \end_layout
32647
32648 \end_inset
32649 </cell>
32650 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32651 \begin_inset Text
32652
32653 \begin_layout Standard
32654
32655 \family roman
32656 \series medium
32657 \shape up
32658 \size normal
32659 \emph off
32660 \bar no
32661 \noun off
32662 \color none
32663 sdcc/bin
32664 \end_layout
32665
32666 \end_inset
32667 </cell>
32668 </row>
32669 <row topline="true">
32670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32671 \begin_inset Text
32672
32673 \begin_layout Standard
32674 link-z80
32675 \end_layout
32676
32677 \end_inset
32678 </cell>
32679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32680 \begin_inset Text
32681
32682 \begin_layout Standard
32683 Linker
32684 \end_layout
32685
32686 \end_inset
32687 </cell>
32688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32689 \begin_inset Text
32690
32691 \begin_layout Standard
32692
32693 \family roman
32694 \series medium
32695 \shape up
32696 \size normal
32697 \emph off
32698 \bar no
32699 \noun off
32700 \color none
32701 sdcc/bin
32702 \end_layout
32703
32704 \end_inset
32705 </cell>
32706 </row>
32707 <row topline="true">
32708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32709 \begin_inset Text
32710
32711 \begin_layout Standard
32712 link-gbz80
32713 \end_layout
32714
32715 \end_inset
32716 </cell>
32717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32718 \begin_inset Text
32719
32720 \begin_layout Standard
32721 Linker
32722 \end_layout
32723
32724 \end_inset
32725 </cell>
32726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32727 \begin_inset Text
32728
32729 \begin_layout Standard
32730
32731 \family roman
32732 \series medium
32733 \shape up
32734 \size normal
32735 \emph off
32736 \bar no
32737 \noun off
32738 \color none
32739 sdcc/bin
32740 \end_layout
32741
32742 \end_inset
32743 </cell>
32744 </row>
32745 <row topline="true" bottomline="true">
32746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32747 \begin_inset Text
32748
32749 \begin_layout Standard
32750 packihx
32751 \end_layout
32752
32753 \end_inset
32754 </cell>
32755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32756 \begin_inset Text
32757
32758 \begin_layout Standard
32759 Intel Hex packer 
32760 \begin_inset LatexCommand index
32761 name "packihx (tool)"
32762
32763 \end_inset
32764
32765
32766 \end_layout
32767
32768 \end_inset
32769 </cell>
32770 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32771 \begin_inset Text
32772
32773 \begin_layout Standard
32774
32775 \family roman
32776 \series medium
32777 \shape up
32778 \size normal
32779 \emph off
32780 \bar no
32781 \noun off
32782 \color none
32783 sdcc/bin
32784 \end_layout
32785
32786 \end_inset
32787 </cell>
32788 </row>
32789 </lyxtabular>
32790
32791 \end_inset
32792
32793
32794 \newline
32795
32796 \end_layout
32797
32798 \begin_layout Section
32799 Documentation
32800 \begin_inset LatexCommand index
32801 name "Documentation"
32802
32803 \end_inset
32804
32805  included in the distribution
32806 \end_layout
32807
32808 \begin_layout Standard
32809 \align left
32810 \begin_inset Tabular
32811 <lyxtabular version="3" rows="10" columns="2">
32812 <features>
32813 <column alignment="block" valignment="top" leftline="true" width="40col%">
32814 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
32815 <row topline="true" bottomline="true" endhead="true">
32816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32817 \begin_inset Text
32818
32819 \begin_layout Standard
32820
32821 \series bold
32822 Subject / Title
32823 \end_layout
32824
32825 \end_inset
32826 </cell>
32827 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32828 \begin_inset Text
32829
32830 \begin_layout Standard
32831
32832 \series bold
32833 Filename / Where to get
32834 \end_layout
32835
32836 \end_inset
32837 </cell>
32838 </row>
32839 <row topline="true">
32840 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32841 \begin_inset Text
32842
32843 \begin_layout Standard
32844 SDCC Compiler User Guide
32845 \end_layout
32846
32847 \end_inset
32848 </cell>
32849 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32850 \begin_inset Text
32851
32852 \begin_layout Standard
32853 You're reading it right now 
32854 \emph on
32855 \InsetSpace ~
32856 \InsetSpace ~
32857 \InsetSpace ~
32858
32859 \hfill
32860 online at:
32861 \emph default
32862
32863 \newline
32864
32865 \begin_inset LatexCommand url
32866 target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
32867
32868 \end_inset
32869
32870
32871 \end_layout
32872
32873 \end_inset
32874 </cell>
32875 </row>
32876 <row topline="true">
32877 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32878 \begin_inset Text
32879
32880 \begin_layout Standard
32881 Changelog of SDCC
32882 \end_layout
32883
32884 \end_inset
32885 </cell>
32886 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32887 \begin_inset Text
32888
32889 \begin_layout Standard
32890 sdcc/Changelog 
32891 \emph on
32892 \InsetSpace ~
32893 \InsetSpace ~
32894 \InsetSpace ~
32895
32896 \hfill
32897 online at:
32898 \emph default
32899
32900 \newline
32901
32902 \begin_inset LatexCommand url
32903 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog"
32904
32905 \end_inset
32906
32907
32908 \end_layout
32909
32910 \end_inset
32911 </cell>
32912 </row>
32913 <row topline="true">
32914 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32915 \begin_inset Text
32916
32917 \begin_layout Standard
32918 ASXXXX
32919 \begin_inset LatexCommand index
32920 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
32921
32922 \end_inset
32923
32924
32925 \begin_inset LatexCommand index
32926 name "Assembler documentation"
32927
32928 \end_inset
32929
32930  Assemblers and
32931 \newline
32932 ASLINK
32933 \begin_inset LatexCommand index
32934 name "aslink"
32935
32936 \end_inset
32937
32938
32939 \begin_inset LatexCommand index
32940 name "Linker documentation"
32941
32942 \end_inset
32943
32944  Relocating Linker
32945 \end_layout
32946
32947 \end_inset
32948 </cell>
32949 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32950 \begin_inset Text
32951
32952 \begin_layout Standard
32953 sdcc/as/doc/asxhtm.html 
32954 \emph on
32955 \InsetSpace ~
32956 \InsetSpace ~
32957 \InsetSpace ~
32958
32959 \hfill
32960 online at:
32961 \emph default
32962
32963 \newline
32964
32965 \begin_inset LatexCommand url
32966 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
32967
32968 \end_inset
32969
32970
32971 \end_layout
32972
32973 \end_inset
32974 </cell>
32975 </row>
32976 <row topline="true">
32977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32978 \begin_inset Text
32979
32980 \begin_layout Standard
32981 SDCC regression test
32982 \begin_inset LatexCommand index
32983 name "Regression test"
32984
32985 \end_inset
32986
32987
32988 \end_layout
32989
32990 \end_inset
32991 </cell>
32992 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32993 \begin_inset Text
32994
32995 \begin_layout Standard
32996 sdcc/doc/test_suite_spec.pdf 
32997 \emph on
32998 \InsetSpace ~
32999 \InsetSpace ~
33000 \InsetSpace ~
33001
33002 \hfill
33003 online at:
33004 \emph default
33005
33006 \newline
33007
33008 \begin_inset LatexCommand url
33009 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
33010
33011 \end_inset
33012
33013
33014 \end_layout
33015
33016 \end_inset
33017 </cell>
33018 </row>
33019 <row topline="true">
33020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33021 \begin_inset Text
33022
33023 \begin_layout Standard
33024 Various notes
33025 \end_layout
33026
33027 \end_inset
33028 </cell>
33029 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33030 \begin_inset Text
33031
33032 \begin_layout Standard
33033 sdcc/doc/* 
33034 \emph on
33035 \InsetSpace ~
33036 \InsetSpace ~
33037 \InsetSpace ~
33038
33039 \hfill
33040 online at:
33041 \emph default
33042
33043 \newline
33044
33045 \begin_inset LatexCommand url
33046 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/"
33047
33048 \end_inset
33049
33050
33051 \end_layout
33052
33053 \end_inset
33054 </cell>
33055 </row>
33056 <row topline="true">
33057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33058 \begin_inset Text
33059
33060 \begin_layout Standard
33061 Notes on debugging with SDCDB
33062 \begin_inset LatexCommand index
33063 name "SDCDB (debugger)"
33064
33065 \end_inset
33066
33067
33068 \end_layout
33069
33070 \end_inset
33071 </cell>
33072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33073 \begin_inset Text
33074
33075 \begin_layout Standard
33076 sdcc/debugger/README 
33077 \emph on
33078 \InsetSpace ~
33079 \InsetSpace ~
33080 \InsetSpace ~
33081
33082 \hfill
33083 online at
33084 \emph default
33085 :
33086 \newline
33087
33088 \begin_inset LatexCommand url
33089 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README"
33090
33091 \end_inset
33092
33093
33094 \end_layout
33095
33096 \end_inset
33097 </cell>
33098 </row>
33099 <row topline="true">
33100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33101 \begin_inset Text
33102
33103 \begin_layout Standard
33104 uCsim
33105 \begin_inset LatexCommand index
33106 name "uCsim"
33107
33108 \end_inset
33109
33110  Software simulator for microcontrollers
33111 \end_layout
33112
33113 \end_inset
33114 </cell>
33115 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33116 \begin_inset Text
33117
33118 \begin_layout Standard
33119
33120 \family roman
33121 \series medium
33122 \shape up
33123 \size normal
33124 \emph off
33125 \bar no
33126 \noun off
33127 \color none
33128 sdcc/sim/ucsim/doc
33129 \family default
33130 \series default
33131 \shape default
33132 \size default
33133 \emph default
33134 \bar default
33135 \noun default
33136 /index.html 
33137 \emph on
33138 \InsetSpace ~
33139 \InsetSpace ~
33140 \InsetSpace ~
33141
33142 \hfill
33143 online at:
33144 \emph default
33145
33146 \newline
33147
33148 \begin_inset LatexCommand url
33149 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html"
33150
33151 \end_inset
33152
33153
33154 \end_layout
33155
33156 \end_inset
33157 </cell>
33158 </row>
33159 <row topline="true">
33160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33161 \begin_inset Text
33162
33163 \begin_layout Standard
33164 Temporary notes on the pic16
33165 \begin_inset LatexCommand index
33166 name "PIC16"
33167
33168 \end_inset
33169
33170  port
33171 \end_layout
33172
33173 \end_inset
33174 </cell>
33175 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33176 \begin_inset Text
33177
33178 \begin_layout Standard
33179 sdcc/src/pic16/NOTES 
33180 \emph on
33181 \InsetSpace ~
33182 \InsetSpace ~
33183 \InsetSpace ~
33184
33185 \hfill
33186 online at:
33187 \newline
33188
33189 \emph default
33190
33191 \begin_inset LatexCommand url
33192 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES"
33193
33194 \end_inset
33195
33196
33197 \end_layout
33198
33199 \end_inset
33200 </cell>
33201 </row>
33202 <row topline="true" bottomline="true">
33203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33204 \begin_inset Text
33205
33206 \begin_layout Standard
33207 SDCC internal documentation (debugging file format)
33208 \end_layout
33209
33210 \end_inset
33211 </cell>
33212 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33213 \begin_inset Text
33214
33215 \begin_layout Standard
33216 sdcc/doc/
33217 \family roman
33218 \series medium
33219 \shape up
33220 \size normal
33221 \emph off
33222 \bar no
33223 \noun off
33224 \color none
33225 cdbfileformat.pd
33226 \family default
33227 \series default
33228 \shape default
33229 \size default
33230 \emph default
33231 \bar default
33232 \noun default
33233
33234 \emph on
33235 \InsetSpace ~
33236 \InsetSpace ~
33237 \InsetSpace ~
33238
33239 \hfill
33240 online at:
33241 \emph default
33242
33243 \newline
33244
33245 \begin_inset LatexCommand url
33246 target "http://sdcc.sourceforge.net/doc/cdbfileformat.pdf"
33247
33248 \end_inset
33249
33250
33251 \end_layout
33252
33253 \end_inset
33254 </cell>
33255 </row>
33256 </lyxtabular>
33257
33258 \end_inset
33259
33260
33261 \newline
33262
33263 \end_layout
33264
33265 \begin_layout Section
33266 Related open source tools
33267 \begin_inset LatexCommand label
33268 name "sec:Related-open-source-tools"
33269
33270 \end_inset
33271
33272
33273 \begin_inset LatexCommand index
33274 name "Related tools"
33275
33276 \end_inset
33277
33278
33279 \end_layout
33280
33281 \begin_layout Standard
33282 \align left
33283 \begin_inset Tabular
33284 <lyxtabular version="3" rows="16" columns="3">
33285 <features>
33286 <column alignment="left" valignment="top" leftline="true" width="0pt">
33287 <column alignment="block" valignment="top" leftline="true" width="30line%">
33288 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
33289 <row topline="true" bottomline="true">
33290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33291 \begin_inset Text
33292
33293 \begin_layout Standard
33294
33295 \series bold
33296 Name
33297 \end_layout
33298
33299 \end_inset
33300 </cell>
33301 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33302 \begin_inset Text
33303
33304 \begin_layout Standard
33305
33306 \series bold
33307 Purpose
33308 \end_layout
33309
33310 \end_inset
33311 </cell>
33312 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33313 \begin_inset Text
33314
33315 \begin_layout Standard
33316
33317 \series bold
33318 Where to get
33319 \end_layout
33320
33321 \end_inset
33322 </cell>
33323 </row>
33324 <row topline="true">
33325 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33326 \begin_inset Text
33327
33328 \begin_layout Standard
33329 gpsim
33330 \begin_inset LatexCommand index
33331 name "gpsim (pic simulator)"
33332
33333 \end_inset
33334
33335
33336 \end_layout
33337
33338 \end_inset
33339 </cell>
33340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33341 \begin_inset Text
33342
33343 \begin_layout Standard
33344 PIC simulator
33345 \end_layout
33346
33347 \end_inset
33348 </cell>
33349 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33350 \begin_inset Text
33351
33352 \begin_layout Standard
33353 \begin_inset LatexCommand url
33354 target "http://www.dattalo.com/gnupic/gpsim.html"
33355
33356 \end_inset
33357
33358
33359 \end_layout
33360
33361 \end_inset
33362 </cell>
33363 </row>
33364 <row topline="true">
33365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33366 \begin_inset Text
33367
33368 \begin_layout Standard
33369 gputils
33370 \begin_inset LatexCommand index
33371 name "gputils (pic tools)"
33372
33373 \end_inset
33374
33375
33376 \end_layout
33377
33378 \end_inset
33379 </cell>
33380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33381 \begin_inset Text
33382
33383 \begin_layout Standard
33384 GNU PIC utilities
33385 \end_layout
33386
33387 \end_inset
33388 </cell>
33389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33390 \begin_inset Text
33391
33392 \begin_layout Standard
33393 \begin_inset LatexCommand url
33394 target "http://sourceforge.net/projects/gputils"
33395
33396 \end_inset
33397
33398
33399 \end_layout
33400
33401 \end_inset
33402 </cell>
33403 </row>
33404 <row topline="true">
33405 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33406 \begin_inset Text
33407
33408 \begin_layout Standard
33409 flP5
33410 \end_layout
33411
33412 \end_inset
33413 </cell>
33414 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33415 \begin_inset Text
33416
33417 \begin_layout Standard
33418 PIC programmer
33419 \end_layout
33420
33421 \end_inset
33422 </cell>
33423 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33424 \begin_inset Text
33425
33426 \begin_layout Standard
33427 \begin_inset LatexCommand url
33428 target "http://freshmeat.net/projects/flp5/"
33429
33430 \end_inset
33431
33432
33433 \end_layout
33434
33435 \end_inset
33436 </cell>
33437 </row>
33438 <row topline="true">
33439 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33440 \begin_inset Text
33441
33442 \begin_layout Standard
33443 ec2drv/newcdb
33444 \end_layout
33445
33446 \end_inset
33447 </cell>
33448 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33449 \begin_inset Text
33450
33451 \begin_layout Standard
33452 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
33453  (Unix only)
33454 \end_layout
33455
33456 \end_inset
33457 </cell>
33458 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33459 \begin_inset Text
33460
33461 \begin_layout Standard
33462 \begin_inset LatexCommand url
33463 target "http://sourceforge.net/projects/ec2drv"
33464
33465 \end_inset
33466
33467
33468 \end_layout
33469
33470 \end_inset
33471 </cell>
33472 </row>
33473 <row topline="true">
33474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33475 \begin_inset Text
33476
33477 \begin_layout Standard
33478 indent
33479 \begin_inset LatexCommand index
33480 name "indent (source formatting tool)"
33481
33482 \end_inset
33483
33484
33485 \end_layout
33486
33487 \end_inset
33488 </cell>
33489 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33490 \begin_inset Text
33491
33492 \begin_layout Standard
33493 Formats C source - Master of the white spaces
33494 \end_layout
33495
33496 \end_inset
33497 </cell>
33498 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33499 \begin_inset Text
33500
33501 \begin_layout Standard
33502 \begin_inset LatexCommand url
33503 target "http://directory.fsf.org/GNU/indent.html"
33504
33505 \end_inset
33506
33507
33508 \end_layout
33509
33510 \end_inset
33511 </cell>
33512 </row>
33513 <row topline="true">
33514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33515 \begin_inset Text
33516
33517 \begin_layout Standard
33518 srecord
33519 \begin_inset LatexCommand index
33520 name "srecord (bin, hex, ... tool)"
33521
33522 \end_inset
33523
33524
33525 \end_layout
33526
33527 \end_inset
33528 </cell>
33529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33530 \begin_inset Text
33531
33532 \begin_layout Standard
33533 Object file conversion, checksumming, ...
33534 \end_layout
33535
33536 \end_inset
33537 </cell>
33538 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33539 \begin_inset Text
33540
33541 \begin_layout Standard
33542 \begin_inset LatexCommand url
33543 target "http://sourceforge.net/projects/srecord"
33544
33545 \end_inset
33546
33547
33548 \end_layout
33549
33550 \end_inset
33551 </cell>
33552 </row>
33553 <row topline="true">
33554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33555 \begin_inset Text
33556
33557 \begin_layout Standard
33558 objdump
33559 \begin_inset LatexCommand index
33560 name "objdump (tool)"
33561
33562 \end_inset
33563
33564
33565 \end_layout
33566
33567 \end_inset
33568 </cell>
33569 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33570 \begin_inset Text
33571
33572 \begin_layout Standard
33573 Object file conversion, ...
33574 \end_layout
33575
33576 \end_inset
33577 </cell>
33578 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33579 \begin_inset Text
33580
33581 \begin_layout Standard
33582 Part of binutils (should be there anyway)
33583 \end_layout
33584
33585 \end_inset
33586 </cell>
33587 </row>
33588 <row topline="true">
33589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33590 \begin_inset Text
33591
33592 \begin_layout Standard
33593 cmon51
33594 \end_layout
33595
33596 \end_inset
33597 </cell>
33598 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33599 \begin_inset Text
33600
33601 \begin_layout Standard
33602 8051 monitor (hex up-/download, single step, disassemble)
33603 \end_layout
33604
33605 \end_inset
33606 </cell>
33607 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33608 \begin_inset Text
33609
33610 \begin_layout Standard
33611 \begin_inset LatexCommand url
33612 target "http://sourceforge.net/projects/cmon51"
33613
33614 \end_inset
33615
33616
33617 \end_layout
33618
33619 \end_inset
33620 </cell>
33621 </row>
33622 <row topline="true">
33623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33624 \begin_inset Text
33625
33626 \begin_layout Standard
33627 doxygen
33628 \begin_inset LatexCommand index
33629 name "doxygen (source documentation tool)"
33630
33631 \end_inset
33632
33633
33634 \end_layout
33635
33636 \end_inset
33637 </cell>
33638 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33639 \begin_inset Text
33640
33641 \begin_layout Standard
33642 Source code documentation system
33643 \end_layout
33644
33645 \end_inset
33646 </cell>
33647 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33648 \begin_inset Text
33649
33650 \begin_layout Standard
33651 \begin_inset LatexCommand url
33652 target "http://www.doxygen.org"
33653
33654 \end_inset
33655
33656
33657 \end_layout
33658
33659 \end_inset
33660 </cell>
33661 </row>
33662 <row topline="true">
33663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33664 \begin_inset Text
33665
33666 \begin_layout Standard
33667 kdevelop
33668 \end_layout
33669
33670 \end_inset
33671 </cell>
33672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33673 \begin_inset Text
33674
33675 \begin_layout Standard
33676 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
33677 \end_layout
33678
33679 \end_inset
33680 </cell>
33681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33682 \begin_inset Text
33683
33684 \begin_layout Standard
33685 \begin_inset LatexCommand url
33686 target "http://www.kdevelop.org"
33687
33688 \end_inset
33689
33690
33691 \end_layout
33692
33693 \end_inset
33694 </cell>
33695 </row>
33696 <row topline="true">
33697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33698 \begin_inset Text
33699
33700 \begin_layout Standard
33701 paulmon
33702 \end_layout
33703
33704 \end_inset
33705 </cell>
33706 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33707 \begin_inset Text
33708
33709 \begin_layout Standard
33710 8051 monitor (hex up-/download, single step, disassemble)
33711 \end_layout
33712
33713 \end_inset
33714 </cell>
33715 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33716 \begin_inset Text
33717
33718 \begin_layout Standard
33719 \begin_inset LatexCommand url
33720 target "http://www.pjrc.com/tech/8051/paulmon2.html"
33721
33722 \end_inset
33723
33724
33725 \end_layout
33726
33727 \end_inset
33728 </cell>
33729 </row>
33730 <row topline="true">
33731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33732 \begin_inset Text
33733
33734 \begin_layout Standard
33735 splint
33736 \begin_inset LatexCommand index
33737 name "splint (syntax checking tool)"
33738
33739 \end_inset
33740
33741
33742 \end_layout
33743
33744 \end_inset
33745 </cell>
33746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33747 \begin_inset Text
33748
33749 \begin_layout Standard
33750 Statically checks c sources (see 
33751 \begin_inset LatexCommand ref
33752 reference "lyx:more-pedantic-SPLINT"
33753
33754 \end_inset
33755
33756 )
33757 \end_layout
33758
33759 \end_inset
33760 </cell>
33761 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33762 \begin_inset Text
33763
33764 \begin_layout Standard
33765 \begin_inset LatexCommand url
33766 target "http://www.splint.org"
33767
33768 \end_inset
33769
33770
33771 \end_layout
33772
33773 \end_inset
33774 </cell>
33775 </row>
33776 <row topline="true" bottomline="true">
33777 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33778 \begin_inset Text
33779
33780 \begin_layout Standard
33781 ddd
33782 \begin_inset LatexCommand index
33783 name "DDD (debugger)"
33784
33785 \end_inset
33786
33787
33788 \end_layout
33789
33790 \end_inset
33791 </cell>
33792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33793 \begin_inset Text
33794
33795 \begin_layout Standard
33796 Debugger, serves nicely as GUI to SDCDB
33797 \begin_inset LatexCommand index
33798 name "SDCDB (debugger)"
33799
33800 \end_inset
33801
33802  (Unix only)
33803 \end_layout
33804
33805 \end_inset
33806 </cell>
33807 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33808 \begin_inset Text
33809
33810 \begin_layout Standard
33811 \begin_inset LatexCommand url
33812 target "http://www.gnu.org/software/ddd/"
33813
33814 \end_inset
33815
33816
33817 \end_layout
33818
33819 \end_inset
33820 </cell>
33821 </row>
33822 <row bottomline="true">
33823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33824 \begin_inset Text
33825
33826 \begin_layout Standard
33827 d52
33828 \begin_inset LatexCommand index
33829 name "d52"
33830
33831 \end_inset
33832
33833
33834 \begin_inset LatexCommand index
33835 name "d52 (disassembler)"
33836
33837 \end_inset
33838
33839
33840 \end_layout
33841
33842 \end_inset
33843 </cell>
33844 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33845 \begin_inset Text
33846
33847 \begin_layout Standard
33848 Disassembler, can count instruction cycles
33849 \begin_inset LatexCommand index
33850 name "instruction cycles (count)"
33851
33852 \end_inset
33853
33854 , use with options -pnd
33855 \end_layout
33856
33857 \end_inset
33858 </cell>
33859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33860 \begin_inset Text
33861
33862 \begin_layout Standard
33863 \begin_inset LatexCommand url
33864 target "http://www.8052.com/users/disasm/"
33865
33866 \end_inset
33867
33868
33869 \end_layout
33870
33871 \end_inset
33872 </cell>
33873 </row>
33874 <row bottomline="true">
33875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33876 \begin_inset Text
33877
33878 \begin_layout Standard
33879 cmake
33880 \begin_inset LatexCommand index
33881 name "cmake"
33882
33883 \end_inset
33884
33885
33886 \end_layout
33887
33888 \end_inset
33889 </cell>
33890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33891 \begin_inset Text
33892
33893 \begin_layout Standard
33894 Cross platform build system, generates Makefiles
33895 \begin_inset LatexCommand index
33896 name "Makefile"
33897
33898 \end_inset
33899
33900  and project workspaces
33901 \begin_inset LatexCommand index
33902 name "project workspace"
33903
33904 \end_inset
33905
33906
33907 \end_layout
33908
33909 \end_inset
33910 </cell>
33911 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33912 \begin_inset Text
33913
33914 \begin_layout Standard
33915 \begin_inset LatexCommand url
33916 target "http://www.cmake.org"
33917
33918 \end_inset
33919
33920  \InsetSpace ~
33921 \InsetSpace ~
33922 \InsetSpace ~
33923 \InsetSpace ~
33924 and a dedicated wiki entry: 
33925 \begin_inset LatexCommand url
33926 target "http://www.cmake.org/Wiki/CmakeSdcc"
33927
33928 \end_inset
33929
33930
33931 \end_layout
33932
33933 \end_inset
33934 </cell>
33935 </row>
33936 </lyxtabular>
33937
33938 \end_inset
33939
33940
33941 \newline
33942
33943 \end_layout
33944
33945 \begin_layout Section
33946 Related documentation / recommended reading
33947 \end_layout
33948
33949 \begin_layout Standard
33950 \align left
33951 \begin_inset Tabular
33952 <lyxtabular version="3" rows="7" columns="3">
33953 <features>
33954 <column alignment="left" valignment="top" leftline="true" width="0pt">
33955 <column alignment="left" valignment="top" leftline="true" width="0">
33956 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
33957 <row topline="true" bottomline="true">
33958 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33959 \begin_inset Text
33960
33961 \begin_layout Standard
33962
33963 \series bold
33964 Name
33965 \end_layout
33966
33967 \end_inset
33968 </cell>
33969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33970 \begin_inset Text
33971
33972 \begin_layout Standard
33973
33974 \series bold
33975 Subject / Title
33976 \end_layout
33977
33978 \end_inset
33979 </cell>
33980 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33981 \begin_inset Text
33982
33983 \begin_layout Standard
33984
33985 \series bold
33986 Where to get
33987 \end_layout
33988
33989 \end_inset
33990 </cell>
33991 </row>
33992 <row topline="true">
33993 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33994 \begin_inset Text
33995
33996 \begin_layout Standard
33997
33998 \family roman
33999 \series medium
34000 \shape up
34001 \size normal
34002 \emph off
34003 \bar no
34004 \noun off
34005 \color none
34006 c-refcard.pdf
34007 \end_layout
34008
34009 \end_inset
34010 </cell>
34011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34012 \begin_inset Text
34013
34014 \begin_layout Standard
34015 C Reference Card
34016 \begin_inset LatexCommand index
34017 name "C Reference card"
34018
34019 \end_inset
34020
34021 , 2 pages
34022 \end_layout
34023
34024 \end_inset
34025 </cell>
34026 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34027 \begin_inset Text
34028
34029 \begin_layout Standard
34030 \begin_inset LatexCommand url
34031 target "http://refcards.com/refcards/c/index.html"
34032
34033 \end_inset
34034
34035
34036 \end_layout
34037
34038 \end_inset
34039 </cell>
34040 </row>
34041 <row topline="true">
34042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34043 \begin_inset Text
34044
34045 \begin_layout Standard
34046 c-faq
34047 \end_layout
34048
34049 \end_inset
34050 </cell>
34051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34052 \begin_inset Text
34053
34054 \begin_layout Standard
34055 C-FAQ
34056 \begin_inset LatexCommand index
34057 name "C FAQ"
34058
34059 \end_inset
34060
34061
34062 \end_layout
34063
34064 \end_inset
34065 </cell>
34066 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34067 \begin_inset Text
34068
34069 \begin_layout Standard
34070 \begin_inset LatexCommand url
34071 target "http://www.c-faq.com"
34072
34073 \end_inset
34074
34075
34076 \end_layout
34077
34078 \end_inset
34079 </cell>
34080 </row>
34081 <row topline="true">
34082 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34083 \begin_inset Text
34084
34085 \begin_layout Standard
34086 ISO/IEC 9899:TC2
34087 \end_layout
34088
34089 \end_inset
34090 </cell>
34091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34092 \begin_inset Text
34093
34094 \begin_layout Standard
34095 \begin_inset Quotes sld
34096 \end_inset
34097
34098 C-Standard
34099 \begin_inset Quotes srd
34100 \end_inset
34101
34102
34103 \end_layout
34104
34105 \end_inset
34106 </cell>
34107 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34108 \begin_inset Text
34109
34110 \begin_layout Standard
34111
34112 \size footnotesize
34113 \begin_inset LatexCommand url
34114 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
34115
34116 \end_inset
34117
34118
34119 \end_layout
34120
34121 \end_inset
34122 </cell>
34123 </row>
34124 <row topline="true">
34125 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34126 \begin_inset Text
34127
34128 \begin_layout Standard
34129 ISO/IEC DTR 18037
34130 \end_layout
34131
34132 \end_inset
34133 </cell>
34134 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34135 \begin_inset Text
34136
34137 \begin_layout Standard
34138 \begin_inset Quotes sld
34139 \end_inset
34140
34141 Extensions for Embedded C
34142 \begin_inset Quotes srd
34143 \end_inset
34144
34145
34146 \end_layout
34147
34148 \end_inset
34149 </cell>
34150 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34151 \begin_inset Text
34152
34153 \begin_layout Standard
34154
34155 \size footnotesize
34156 \begin_inset LatexCommand url
34157 target "http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf"
34158
34159 \end_inset
34160
34161
34162 \end_layout
34163
34164 \end_inset
34165 </cell>
34166 </row>
34167 <row topline="true">
34168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34169 \begin_inset Text
34170
34171 \begin_layout Standard
34172
34173 \end_layout
34174
34175 \end_inset
34176 </cell>
34177 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34178 \begin_inset Text
34179
34180 \begin_layout Standard
34181 Latest datasheet of target CPU
34182 \end_layout
34183
34184 \end_inset
34185 </cell>
34186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34187 \begin_inset Text
34188
34189 \begin_layout Standard
34190 vendor
34191 \end_layout
34192
34193 \end_inset
34194 </cell>
34195 </row>
34196 <row topline="true" bottomline="true">
34197 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34198 \begin_inset Text
34199
34200 \begin_layout Standard
34201
34202 \end_layout
34203
34204 \end_inset
34205 </cell>
34206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34207 \begin_inset Text
34208
34209 \begin_layout Standard
34210 Revision history of datasheet
34211 \end_layout
34212
34213 \end_inset
34214 </cell>
34215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34216 \begin_inset Text
34217
34218 \begin_layout Standard
34219 vendor
34220 \end_layout
34221
34222 \end_inset
34223 </cell>
34224 </row>
34225 </lyxtabular>
34226
34227 \end_inset
34228
34229
34230 \newline
34231
34232 \end_layout
34233
34234 \begin_layout Section
34235 Application notes specifically for SDCC
34236 \end_layout
34237
34238 \begin_layout Standard
34239 SDCC makes no claims about the completeness of this list and about up-to-datenes
34240 s or correctness of the application notes
34241 \begin_inset LatexCommand index
34242 name "Application notes"
34243
34244 \end_inset
34245
34246 .
34247 \end_layout
34248
34249 \begin_layout Standard
34250 \align left
34251
34252 \size footnotesize
34253 \begin_inset Tabular
34254 <lyxtabular version="3" rows="7" columns="3">
34255 <features>
34256 <column alignment="block" valignment="top" leftline="true" width="17col%">
34257 <column alignment="block" valignment="top" leftline="true" width="27col%">
34258 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
34259 <row topline="true" bottomline="true">
34260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34261 \begin_inset Text
34262
34263 \begin_layout Standard
34264
34265 \series bold
34266 \size footnotesize
34267 Vendor
34268 \end_layout
34269
34270 \end_inset
34271 </cell>
34272 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
34273 \begin_inset Text
34274
34275 \begin_layout Standard
34276
34277 \series bold
34278 \size footnotesize
34279 Subject / Title
34280 \end_layout
34281
34282 \end_inset
34283 </cell>
34284 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34285 \begin_inset Text
34286
34287 \begin_layout Standard
34288
34289 \series bold
34290 \size footnotesize
34291 Where to get
34292 \end_layout
34293
34294 \end_inset
34295 </cell>
34296 </row>
34297 <row topline="true">
34298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34299 \begin_inset Text
34300
34301 \begin_layout Standard
34302
34303 \size footnotesize
34304 Maxim / Dallas
34305 \end_layout
34306
34307 \end_inset
34308 </cell>
34309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34310 \begin_inset Text
34311
34312 \begin_layout Standard
34313
34314 \size footnotesize
34315 Using the SDCC Compiler for the DS80C400
34316 \begin_inset LatexCommand index
34317 name "DS80C400"
34318
34319 \end_inset
34320
34321
34322 \end_layout
34323
34324 \end_inset
34325 </cell>
34326 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34327 \begin_inset Text
34328
34329 \begin_layout Standard
34330
34331 \size footnotesize
34332 \begin_inset LatexCommand url
34333 target "http://pdfserv.maxim-ic.com/en/an/AN3346.pdf"
34334
34335 \end_inset
34336
34337
34338 \end_layout
34339
34340 \end_inset
34341 </cell>
34342 </row>
34343 <row topline="true">
34344 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34345 \begin_inset Text
34346
34347 \begin_layout Standard
34348
34349 \size footnotesize
34350 Maxim / Dallas
34351 \end_layout
34352
34353 \end_inset
34354 </cell>
34355 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
34356 \begin_inset Text
34357
34358 \begin_layout Standard
34359
34360 \size footnotesize
34361 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
34362 \begin_inset LatexCommand index
34363 name "DS89C4x0"
34364
34365 \end_inset
34366
34367  Family of Microcontrollers
34368 \end_layout
34369
34370 \end_inset
34371 </cell>
34372 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34373 \begin_inset Text
34374
34375 \begin_layout Standard
34376
34377 \size footnotesize
34378 \begin_inset LatexCommand url
34379 target "http://pdfserv.maxim-ic.com/en/an/AN3477.pdf"
34380
34381 \end_inset
34382
34383
34384 \end_layout
34385
34386 \end_inset
34387 </cell>
34388 </row>
34389 <row topline="true">
34390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34391 \begin_inset Text
34392
34393 \begin_layout Standard
34394
34395 \size footnotesize
34396 Silicon Laboratories / Cygnal
34397 \end_layout
34398
34399 \end_inset
34400 </cell>
34401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34402 \begin_inset Text
34403
34404 \begin_layout Standard
34405
34406 \size footnotesize
34407 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
34408 \begin_inset LatexCommand index
34409 name "IDE"
34410
34411 \end_inset
34412
34413
34414 \end_layout
34415
34416 \end_inset
34417 </cell>
34418 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34419 \begin_inset Text
34420
34421 \begin_layout Standard
34422
34423 \size footnotesize
34424 \begin_inset LatexCommand url
34425 target "http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf"
34426
34427 \end_inset
34428
34429
34430 \end_layout
34431
34432 \end_inset
34433 </cell>
34434 </row>
34435 <row topline="true">
34436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34437 \begin_inset Text
34438
34439 \begin_layout Standard
34440
34441 \size footnotesize
34442 Ramtron / Goal Semiconductor
34443 \end_layout
34444
34445 \end_inset
34446 </cell>
34447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34448 \begin_inset Text
34449
34450 \begin_layout Standard
34451
34452 \size footnotesize
34453 Interfacing SDCC to Syn and Textpad
34454 \end_layout
34455
34456 \end_inset
34457 </cell>
34458 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34459 \begin_inset Text
34460
34461 \begin_layout Standard
34462
34463 \size footnotesize
34464 \begin_inset LatexCommand url
34465 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34466
34467 \end_inset
34468
34469
34470 \end_layout
34471
34472 \end_inset
34473 </cell>
34474 </row>
34475 <row topline="true">
34476 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34477 \begin_inset Text
34478
34479 \begin_layout Standard
34480
34481 \size footnotesize
34482 Ramtron / Goal Semiconductor
34483 \end_layout
34484
34485 \end_inset
34486 </cell>
34487 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34488 \begin_inset Text
34489
34490 \begin_layout Standard
34491
34492 \size footnotesize
34493 Installing and Configuring SDCC and Crimson Editor 
34494 \end_layout
34495
34496 \end_inset
34497 </cell>
34498 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34499 \begin_inset Text
34500
34501 \begin_layout Standard
34502
34503 \size footnotesize
34504 \begin_inset LatexCommand url
34505 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34506
34507 \end_inset
34508
34509
34510 \end_layout
34511
34512 \end_inset
34513 </cell>
34514 </row>
34515 <row topline="true" bottomline="true">
34516 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34517 \begin_inset Text
34518
34519 \begin_layout Standard
34520
34521 \size footnotesize
34522 Texas Instruments
34523 \end_layout
34524
34525 \end_inset
34526 </cell>
34527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34528 \begin_inset Text
34529
34530 \begin_layout Standard
34531
34532 \size footnotesize
34533 MSC12xx Programming with SDCC
34534 \end_layout
34535
34536 \end_inset
34537 </cell>
34538 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34539 \begin_inset Text
34540
34541 \begin_layout Standard
34542
34543 \size footnotesize
34544 \begin_inset LatexCommand url
34545 target "http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf"
34546
34547 \end_inset
34548
34549
34550 \end_layout
34551
34552 \end_inset
34553 </cell>
34554 </row>
34555 </lyxtabular>
34556
34557 \end_inset
34558
34559
34560 \end_layout
34561
34562 \begin_layout Section
34563 Some Questions
34564 \end_layout
34565
34566 \begin_layout Standard
34567 Some questions answered, some pointers given - it might be time to in turn
34568  ask 
34569 \emph on
34570 you
34571 \emph default
34572  some questions: 
34573 \end_layout
34574
34575 \begin_layout Itemize
34576 can you solve your project with the selected microcontroller? Would you
34577  find out early or rather late that your target is too small/slow/whatever?
34578  Can you switch to a slightly better device if it doesn't fit?
34579 \end_layout
34580
34581 \begin_layout Itemize
34582 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
34583  and/or another programming language be more adequate? Would an operating
34584  system on the target device help?
34585 \end_layout
34586
34587 \begin_layout Itemize
34588 if you solved the problem, will the marketing department be happy?
34589 \end_layout
34590
34591 \begin_layout Itemize
34592 if the marketing department is happy, will customers be happy?
34593 \end_layout
34594
34595 \begin_layout Itemize
34596 if you're the project manager, marketing department and maybe even the customer
34597  in one person, have you tried to see the project from the outside?
34598 \end_layout
34599
34600 \begin_layout Itemize
34601 is the project done if you think it is done? Or is just that other interface/pro
34602 tocol/feature/configuration/option missing? How about website, manual(s),
34603  internationali(z|s)ation, packaging, labels, 2nd source for components,
34604  electromagnetic compatability/interference, documentation for production,
34605  production test software, update mechanism, patent issues?
34606 \end_layout
34607
34608 \begin_layout Itemize
34609 is your project adequately positioned in that magic triangle: fame, fortune,
34610  fun?
34611 \end_layout
34612
34613 \begin_layout Standard
34614 Maybe not all answers to these questions are known and some answers may
34615  even be 
34616 \emph on
34617 no
34618 \emph default
34619 , nevertheless knowing these questions may help you to avoid burnout
34620 \begin_inset Foot
34621 status open
34622
34623 \begin_layout Standard
34624 burnout is bad for electronic devices, programmers and motorcycle tyres
34625 \end_layout
34626
34627 \end_inset
34628
34629 .
34630  Chances are you didn't want to hear some of them...
34631 \end_layout
34632
34633 \begin_layout Chapter
34634 Support
34635 \begin_inset LatexCommand index
34636 name "Support"
34637
34638 \end_inset
34639
34640
34641 \end_layout
34642
34643 \begin_layout Standard
34644 SDCC has grown to be a large project.
34645  The compiler alone (without the preprocessor, assembler and linker) is
34646  well over 150,000 lines of code (blank stripped).
34647  The open source nature of this project is a key to its continued growth
34648  and support.
34649  You gain the benefit and support of many active software developers and
34650  end users.
34651  Is SDCC perfect? No, that's why we need your help.
34652  The developers take pride in fixing reported bugs.
34653  You can help by reporting the bugs and helping other SDCC users.
34654  There are lots of ways to contribute, and we encourage you to take part
34655  in making SDCC a great software package.
34656  
34657 \end_layout
34658
34659 \begin_layout Standard
34660 The SDCC project is hosted on the SDCC sourceforge site at 
34661 \begin_inset LatexCommand htmlurl
34662 target "http://sourceforge.net/projects/sdcc"
34663
34664 \end_inset
34665
34666 .
34667  You'll find the complete set of mailing lists
34668 \begin_inset LatexCommand index
34669 name "Mailing list(s)"
34670
34671 \end_inset
34672
34673 , forums, bug reporting system, patch submission
34674 \begin_inset LatexCommand index
34675 name "Patch submission"
34676
34677 \end_inset
34678
34679  system, download
34680 \begin_inset LatexCommand index
34681 name "download"
34682
34683 \end_inset
34684
34685  area and Subversion code repository
34686 \begin_inset LatexCommand index
34687 name "Subversion code repository"
34688
34689 \end_inset
34690
34691  there.
34692 \end_layout
34693
34694 \begin_layout Section
34695 Reporting Bugs
34696 \begin_inset LatexCommand index
34697 name "Bug reporting"
34698
34699 \end_inset
34700
34701
34702 \begin_inset LatexCommand index
34703 name "Reporting bugs"
34704
34705 \end_inset
34706
34707
34708 \end_layout
34709
34710 \begin_layout Standard
34711 The recommended way of reporting bugs is using the infrastructure of the
34712  sourceforge site.
34713  You can follow the status of bug reports there and have an overview about
34714  the known bugs.
34715 \end_layout
34716
34717 \begin_layout Standard
34718 Bug reports are automatically forwarded to the developer mailing list and
34719  will be fixed ASAP.
34720  When reporting a bug, it is very useful to include a small test program
34721  (the smaller the better) which reproduces the problem.
34722  If you can isolate the problem by looking at the generated assembly code,
34723  this can be very helpful.
34724  Compiling your program with the -
34725 \begin_inset ERT
34726 status collapsed
34727
34728 \begin_layout Standard
34729
34730
34731 \backslash
34732 /
34733 \end_layout
34734
34735 \end_inset
34736
34737 -dumpall
34738 \begin_inset LatexCommand index
34739 name "-\\/-dumpall"
34740
34741 \end_inset
34742
34743  option can sometimes be useful in locating optimization problems.
34744  When reporting a bug please make sure you:
34745 \end_layout
34746
34747 \begin_layout Enumerate
34748 Attach the code you are compiling with SDCC.
34749  
34750 \end_layout
34751
34752 \begin_layout Enumerate
34753 Specify the exact command you use to run SDCC, or attach your Makefile.
34754  
34755 \end_layout
34756
34757 \begin_layout Enumerate
34758 Specify the SDCC version (type "
34759 \family sans
34760 \series bold
34761 sdcc -v
34762 \family default
34763 \series default
34764 "), your platform, and operating system.
34765  
34766 \end_layout
34767
34768 \begin_layout Enumerate
34769 Provide an exact copy of any error message or incorrect output.
34770  
34771 \end_layout
34772
34773 \begin_layout Enumerate
34774 Put something meaningful in the subject of your message.
34775 \end_layout
34776
34777 \begin_layout Standard
34778 Please attempt to include these 5 important parts, as applicable, in all
34779  requests for support or when reporting any problems or bugs with SDCC.
34780  Though this will make your message lengthy, it will greatly improve your
34781  chance that SDCC users and developers will be able to help you.
34782  Some SDCC developers are frustrated by bug reports without code provided
34783  that they can use to reproduce and ultimately fix the problem, so please
34784  be sure to provide sample code if you are reporting a bug! 
34785 \end_layout
34786
34787 \begin_layout Standard
34788 Please have a short check that you are using a recent version of SDCC and
34789  the bug is not yet known.
34790  This is the link for reporting bugs: 
34791 \begin_inset LatexCommand htmlurl
34792 target "http://sourceforge.net/tracker/?group_id=599&atid=100599"
34793
34794 \end_inset
34795
34796 .
34797  With SDCC on average having more than 200 downloads
34798 \begin_inset LatexCommand index
34799 name "download"
34800
34801 \end_inset
34802
34803  on sourceforge per day
34804 \begin_inset Foot
34805 status open
34806
34807 \begin_layout Standard
34808 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
34809  between 2002 and 2005.
34810  This does not include other methods of distribution.
34811 \end_layout
34812
34813 \end_inset
34814
34815  there must be some users.
34816  So it's not exactly easy to find a new bug.
34817  If you find one we need it: 
34818 \emph on
34819 reporting bugs is good
34820 \emph default
34821 .
34822 \end_layout
34823
34824 \begin_layout Section
34825 Requesting Features
34826 \begin_inset LatexCommand label
34827 name "sub:Requesting-Features"
34828
34829 \end_inset
34830
34831
34832 \begin_inset LatexCommand index
34833 name "Feature request"
34834
34835 \end_inset
34836
34837
34838 \begin_inset LatexCommand index
34839 name "Requesting features"
34840
34841 \end_inset
34842
34843
34844 \end_layout
34845
34846 \begin_layout Standard
34847 Like bug reports feature requests are forwarded to the developer mailing
34848  list.
34849  This is the link for requesting features: 
34850 \begin_inset LatexCommand htmlurl
34851 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
34852
34853 \end_inset
34854
34855 .
34856 \end_layout
34857
34858 \begin_layout Section
34859 Submitting patches
34860 \end_layout
34861
34862 \begin_layout Standard
34863 Like bug reports contributed patches are forwarded to the developer mailing
34864  list.
34865  This is the link for submitting patches
34866 \begin_inset LatexCommand index
34867 name "Patch submission"
34868
34869 \end_inset
34870
34871
34872 \begin_inset LatexCommand url
34873 target "http://sourceforge.net/tracker/?group_id=599&atid=300599"
34874
34875 \end_inset
34876
34877 .
34878 \end_layout
34879
34880 \begin_layout Standard
34881 You need to specify some parameters to the 
34882 \family typewriter
34883 diff
34884 \family default
34885  command for the patches to be useful.
34886  If you modified more than one file a patch created f.e.
34887  with 
34888 \family sans
34889 \series bold
34890
34891 \begin_inset Quotes sld
34892 \end_inset
34893
34894 diff -Naur unmodified_directory modified_directory >my_changes.patch
34895 \begin_inset Quotes srd
34896 \end_inset
34897
34898
34899 \family default
34900 \series default
34901  will be fine, otherwise 
34902 \family sans
34903 \series bold
34904
34905 \begin_inset Quotes sld
34906 \end_inset
34907
34908 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
34909 \begin_inset Quotes srd
34910 \end_inset
34911
34912
34913 \family default
34914 \series default
34915  will do.
34916 \end_layout
34917
34918 \begin_layout Section
34919 Getting Help
34920 \end_layout
34921
34922 \begin_layout Standard
34923 These links should take you directly to the 
34924 \begin_inset LatexCommand url
34925 name "Mailing lists"
34926 target "http://sourceforge.net/mail/?group_id=599"
34927
34928 \end_inset
34929
34930
34931 \begin_inset Foot
34932 status open
34933
34934 \begin_layout Standard
34935 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
34936  automated messages (mid 2003)
34937 \end_layout
34938
34939 \end_inset
34940
34941  and the 
34942 \begin_inset LatexCommand url
34943 name "Forums"
34944 target "http://sourceforge.net/forum/?group_id=599"
34945
34946 \end_inset
34947
34948 , lists
34949 \begin_inset LatexCommand index
34950 name "Mailing list(s)"
34951
34952 \end_inset
34953
34954  and forums are archived and searchable so if you are lucky someone already
34955  had a similar problem.
34956  While mails to the lists themselves are delivered promptly their web front
34957  end on sourceforge sometimes shows a severe time lag (up to several weeks),
34958  if you're seriously using SDCC please consider subscribing to the lists.
34959 \end_layout
34960
34961 \begin_layout Section
34962 ChangeLog
34963 \end_layout
34964
34965 \begin_layout Standard
34966 You can follow the status of the Subversion version
34967 \begin_inset LatexCommand index
34968 name "version"
34969
34970 \end_inset
34971
34972  of SDCC by watching the Changelog
34973 \begin_inset LatexCommand index
34974 name "Changelog"
34975
34976 \end_inset
34977
34978  in the Subversion repository
34979 \size footnotesize
34980  
34981 \begin_inset LatexCommand htmlurl
34982 target "http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog"
34983
34984 \end_inset
34985
34986 .
34987 \end_layout
34988
34989 \begin_layout Section
34990 Subversion Source Code Repository
34991 \end_layout
34992
34993 \begin_layout Standard
34994 The output of 
34995 \family sans
34996 \series bold
34997 sdcc -
34998 \family default
34999
35000 \begin_inset ERT
35001 status open
35002
35003 \begin_layout Standard
35004
35005
35006 \backslash
35007 /
35008 \end_layout
35009
35010 \end_inset
35011
35012
35013 \family sans
35014 -version
35015 \family default
35016 \series default
35017  or the filenames of the snapshot versions of SDCC include date and its
35018  Subversion
35019 \begin_inset LatexCommand index
35020 name "Subversion code repository"
35021
35022 \end_inset
35023
35024  number.
35025  Subversion allows to download the source of recent or previous versions
35026  
35027 \begin_inset LatexCommand url
35028 target "http://sourceforge.net/svn/?group_id=599"
35029
35030 \end_inset
35031
35032  (by number or by date).
35033  An on-line source code browser and detailled instructions are also available
35034  there.
35035  SDCC versions starting from 1999 up to now are available (currently the
35036  versions prior to the conversion from cvs
35037 \begin_inset LatexCommand index
35038 name "cvs|see{Subversion}"
35039
35040 \end_inset
35041
35042  to Subversion (April 2006) are either by accessible by Subversion or by
35043  cvs).
35044 \end_layout
35045
35046 \begin_layout Section
35047 Release policy
35048 \begin_inset LatexCommand index
35049 name "Release policy"
35050
35051 \end_inset
35052
35053
35054 \end_layout
35055
35056 \begin_layout Standard
35057 Historically there often were long delays between official releases and
35058  the sourceforge download area tends to get not updated at all.
35059  Excuses in the past might have referred to problems with live range analysis,
35060  but as this was fixed a while ago, the current problem is that another
35061  excuse has to be found.
35062  Kidding aside, we have to get better there! On the other hand there are
35063  daily snapshots available at 
35064 \begin_inset LatexCommand htmlurl
35065 name "snap"
35066 target "http://sdcc.sourceforge.net/snap.php"
35067
35068 \end_inset
35069
35070 , and you can always build the very last version (hopefully with many bugs
35071  fixed, and features added) from the source code available at 
35072 \begin_inset LatexCommand htmlurl
35073 name "Source"
35074 target "http://sdcc.sourceforge.net/snap.php#Source"
35075
35076 \end_inset
35077
35078 .
35079  The SDCC Wiki
35080 \begin_inset LatexCommand index
35081 name "wiki"
35082
35083 \end_inset
35084
35085
35086 \begin_inset LatexCommand index
35087 name "SDCC Wiki"
35088
35089 \end_inset
35090
35091  at 
35092 \begin_inset LatexCommand url
35093 target "http://sdcc.wiki.sourceforge.net/"
35094
35095 \end_inset
35096
35097  also holds some information about past and future releases.
35098 \end_layout
35099
35100 \begin_layout Section
35101 Examples
35102 \begin_inset LatexCommand index
35103 name "Examples"
35104
35105 \end_inset
35106
35107
35108 \end_layout
35109
35110 \begin_layout Standard
35111 You'll find some small examples in the directory 
35112 \emph on
35113 sdcc/device/examples/.
35114
35115 \emph default
35116  More examples and libraries are available at 
35117 \emph on
35118 The SDCC Open Knowledge Resource 
35119 \begin_inset LatexCommand url
35120 target "http://sdccokr.dl9sec.de/"
35121
35122 \end_inset
35123
35124
35125 \emph default
35126  web site or at 
35127 \begin_inset LatexCommand url
35128 target "http://www.pjrc.com/tech/8051/"
35129
35130 \end_inset
35131
35132 .
35133 \end_layout
35134
35135 \begin_layout Standard
35136 \begin_inset Note Note
35137 status collapsed
35138
35139 \begin_layout Standard
35140 I did insert a reference to Paul's web site here although it seems rather
35141  dedicated to a specific 8032 board (I think it's okay because it f.e.
35142  shows LCD/Harddisc interface and has a free 8051 monitor.
35143  Independent 8032 board vendors face hard competition of heavily subsidized
35144  development boards anyway).
35145 \end_layout
35146
35147 \begin_layout Standard
35148 Maybe we should include some links to real world applications.
35149  Preferably pointer to pointers (one for each architecture) so this stays
35150  manageable here?
35151 \end_layout
35152
35153 \end_inset
35154
35155
35156 \end_layout
35157
35158 \begin_layout Section
35159 Quality control
35160 \begin_inset LatexCommand label
35161 name "sec:Quality-control"
35162
35163 \end_inset
35164
35165
35166 \begin_inset LatexCommand index
35167 name "Quality control"
35168
35169 \end_inset
35170
35171
35172 \end_layout
35173
35174 \begin_layout Standard
35175 The compiler is passed through snaphot build compile and build checks.
35176  The so called 
35177 \shape italic
35178 regression tests
35179 \shape default
35180
35181 \begin_inset LatexCommand index
35182 name "Regression test"
35183
35184 \end_inset
35185
35186  check that SDCC itself compiles flawlessly on several host platforms (i386,
35187  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
35188  and checks the quality of the code generated by SDCC by running the code
35189  for several target platforms through simulators.
35190  The regression test suite comprises more than 100 files which expand to
35191  more than 500 test cases which include more than 4500 tests.
35192  The results of these tests are published daily on SDCC's snapshot page
35193  (click on the red or green symbols on the right side of 
35194 \begin_inset LatexCommand url
35195 target "http://sdcc.sourceforge.net/snap.php"
35196
35197 \end_inset
35198
35199 ).
35200 \end_layout
35201
35202 \begin_layout Standard
35203 There is a separate document 
35204 \shape italic
35205 test_suite.pdf 
35206 \begin_inset LatexCommand index
35207 name "Test suite"
35208
35209 \end_inset
35210
35211
35212 \shape default
35213  
35214 \begin_inset LatexCommand url
35215 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
35216
35217 \end_inset
35218
35219  about the regression test suite.
35220 \end_layout
35221
35222 \begin_layout Standard
35223 You'll find the test code in the directory 
35224 \shape italic
35225 sdcc/support/regression
35226 \shape default
35227 .
35228  You can run these tests manually by running 
35229 \family sans
35230 make
35231 \family default
35232  in this directory (or f.e.
35233  
35234 \family sans
35235 \series bold
35236
35237 \begin_inset Quotes sld
35238 \end_inset
35239
35240 make test-mcs51
35241 \begin_inset Quotes srd
35242 \end_inset
35243
35244
35245 \family default
35246 \series default
35247  if you don't want to run the complete tests).
35248  The test code might also be interesting if you want to look for examples
35249 \begin_inset LatexCommand index
35250 name "Examples"
35251
35252 \end_inset
35253
35254  checking corner cases of SDCC or if you plan to submit patches
35255 \begin_inset LatexCommand index
35256 name "Patch submission"
35257
35258 \end_inset
35259
35260 .
35261 \end_layout
35262
35263 \begin_layout Standard
35264 The PIC14 port uses a different set of regression tests 
35265 \begin_inset LatexCommand index
35266 name "Regression test (PIC14)"
35267
35268 \end_inset
35269
35270 , you'll find them in the directory 
35271 \shape italic
35272 sdcc/src/regression
35273 \shape default
35274 .
35275 \end_layout
35276
35277 \begin_layout Section
35278 Use of SDCC in Education
35279 \end_layout
35280
35281 \begin_layout Standard
35282 In short: 
35283 \emph on
35284 highly
35285 \emph default
35286  encouraged
35287 \begin_inset Foot
35288 status open
35289
35290 \begin_layout Standard
35291 the phrase "use in education" might evoke the association "
35292 \emph on
35293 only
35294 \emph default
35295  fit for use in education".
35296  This connotation is not intended but nevertheless risked as the licensing
35297  of SDCC makes it difficult to offer educational discounts
35298 \end_layout
35299
35300 \end_inset
35301
35302 .
35303  If your rationales are to:
35304 \end_layout
35305
35306 \begin_layout Enumerate
35307 give students a chance to understand the 
35308 \emph on
35309 complete
35310 \emph default
35311  steps of code generation
35312 \end_layout
35313
35314 \begin_layout Enumerate
35315 have a curriculum that can be extended for years.
35316  Then you could use an fpga board as target and your curriculum will seamlessly
35317  extend from logic synthesis (
35318 \begin_inset LatexCommand url
35319 name "http://www.opencores.org"
35320 target "opencores.org"
35321
35322 \end_inset
35323
35324
35325 \begin_inset LatexCommand url
35326 name "Oregano"
35327 target "http://www.oregano.at/ip/ip01.htm"
35328
35329 \end_inset
35330
35331 ), over assembly programming, to C to FPGA compilers (
35332 \begin_inset LatexCommand url
35333 name "FPGAC"
35334 target "http://sf.net/projects/fpgac"
35335
35336 \end_inset
35337
35338 ) and to C.
35339 \end_layout
35340
35341 \begin_layout Enumerate
35342 be able to insert excursions about skills like using a revision control
35343  system, submitting/applying patches, using a type-setting (as opposed to
35344  word-processing) engine LyX/LaTeX, using 
35345 \begin_inset LatexCommand url
35346 name "SourceForge"
35347 target "http://www.sf.net"
35348
35349 \end_inset
35350
35351 , following some 
35352 \begin_inset LatexCommand url
35353 name "netiquette"
35354 target "http://en.wikipedia.org/wiki/Netiquette"
35355
35356 \end_inset
35357
35358 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
35359  Source Software, CPU simulation, compiler regression tests
35360 \begin_inset LatexCommand index
35361 name "Regression test"
35362
35363 \end_inset
35364
35365 .
35366  
35367 \newline
35368 And if there should be a shortage of ideas then you can always point students
35369  to the ever-growing feature request list 
35370 \begin_inset LatexCommand htmlurl
35371 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
35372
35373 \end_inset
35374
35375 .
35376 \end_layout
35377
35378 \begin_layout Enumerate
35379 not tie students to a specific host platform and instead allow them to use
35380  a host platform of 
35381 \emph on
35382 their
35383 \emph default
35384  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
35385  and eventually 
35386 \begin_inset LatexCommand url
35387 name "OLPC"
35388 target "http://www.laptop.org"
35389
35390 \end_inset
35391
35392 )
35393 \end_layout
35394
35395 \begin_layout Enumerate
35396 not encourage students to use illegal copies of educational software
35397 \end_layout
35398
35399 \begin_layout Enumerate
35400 be immune to licensing/availability/price changes of the chosen tool chain
35401 \end_layout
35402
35403 \begin_layout Enumerate
35404 be able to change to a new target platform without having to adopt a new
35405  tool chain
35406 \end_layout
35407
35408 \begin_layout Enumerate
35409 have complete control over and insight into the tool chain
35410 \end_layout
35411
35412 \begin_layout Enumerate
35413 make your students aware about the pros and cons of open source software
35414  development
35415 \end_layout
35416
35417 \begin_layout Enumerate
35418 give back to the public as you are probably at least partially publicly
35419  funded
35420 \end_layout
35421
35422 \begin_layout Enumerate
35423 give students a chance to publicly prove their skills and to possibly see
35424  a world wide impact
35425 \end_layout
35426
35427 \begin_layout Standard
35428 then SDCC is probably among the first choices.
35429  Well, probably SDCC might be the only choice.
35430 \newpage
35431
35432 \end_layout
35433
35434 \begin_layout Chapter
35435 SDCC Technical Data
35436 \end_layout
35437
35438 \begin_layout Section
35439 Optimizations
35440 \begin_inset LatexCommand index
35441 name "Optimizations"
35442
35443 \end_inset
35444
35445
35446 \end_layout
35447
35448 \begin_layout Standard
35449 SDCC performs a host of standard optimizations in addition to some MCU specific
35450  optimizations.
35451  
35452 \end_layout
35453
35454 \begin_layout Subsection
35455 Sub-expression Elimination
35456 \begin_inset LatexCommand index
35457 name "Subexpression elimination"
35458
35459 \end_inset
35460
35461
35462 \end_layout
35463
35464 \begin_layout Standard
35465 The compiler does local and 
35466 \emph on
35467 g
35468 \emph default
35469 lobal 
35470 \emph on
35471 c
35472 \emph default
35473 ommon 
35474 \emph on
35475 s
35476 \emph default
35477 ubexpression 
35478 \emph on
35479 e
35480 \emph default
35481 limination, e.g.: 
35482 \end_layout
35483
35484 \begin_layout Verse
35485
35486 \family typewriter
35487 i = x + y + 1; 
35488 \newline
35489 j = x + y;
35490 \end_layout
35491
35492 \begin_layout Standard
35493 will be translated to
35494 \end_layout
35495
35496 \begin_layout Verse
35497
35498 \family typewriter
35499 iTemp = x + y; 
35500 \newline
35501 i = iTemp + 1; 
35502 \newline
35503 j = iTemp;
35504 \end_layout
35505
35506 \begin_layout Standard
35507 Some subexpressions are not as obvious as the above example, e.g.:
35508 \end_layout
35509
35510 \begin_layout Verse
35511
35512 \family typewriter
35513 a->b[i].c = 10; 
35514 \newline
35515 a->b[i].d = 11;
35516 \end_layout
35517
35518 \begin_layout Standard
35519 In this case the address arithmetic a->b[i] will be computed only once;
35520  the equivalent code in C would be.
35521 \end_layout
35522
35523 \begin_layout Verse
35524
35525 \family typewriter
35526 iTemp = a->b[i]; 
35527 \newline
35528 iTemp.c = 10; 
35529 \newline
35530 iTemp.d = 11;
35531 \end_layout
35532
35533 \begin_layout Standard
35534 The compiler will try to keep these temporary variables in registers.
35535 \end_layout
35536
35537 \begin_layout Subsection
35538 Dead-Code Elimination
35539 \begin_inset LatexCommand index
35540 name "Dead-code elimination"
35541
35542 \end_inset
35543
35544
35545 \end_layout
35546
35547 \begin_layout Verse
35548
35549 \family typewriter
35550 int global;
35551 \newline
35552
35553 \newline
35554 void f () { 
35555 \newline
35556 \InsetSpace ~
35557 \InsetSpace ~
35558 int i; 
35559 \newline
35560 \InsetSpace ~
35561 \InsetSpace ~
35562 i = 1; \InsetSpace ~
35563 \InsetSpace ~
35564 \InsetSpace ~
35565 \InsetSpace ~
35566 \InsetSpace ~
35567 /* dead store */ 
35568 \newline
35569 \InsetSpace ~
35570 \InsetSpace ~
35571 global = 1;\InsetSpace ~
35572 /* dead
35573  store */ 
35574 \newline
35575 \InsetSpace ~
35576 \InsetSpace ~
35577 global = 2; 
35578 \newline
35579 \InsetSpace ~
35580 \InsetSpace ~
35581 return; 
35582 \newline
35583 \InsetSpace ~
35584 \InsetSpace ~
35585 global = 3;\InsetSpace ~
35586 /* unreachable */ 
35587 \newline
35588 }
35589 \end_layout
35590
35591 \begin_layout Standard
35592 will be changed to
35593 \end_layout
35594
35595 \begin_layout Verse
35596
35597 \family typewriter
35598 int global;
35599 \newline
35600
35601 \newline
35602 void f () {
35603 \newline
35604 \InsetSpace ~
35605 \InsetSpace ~
35606 global = 2; 
35607 \newline
35608 }
35609 \end_layout
35610
35611 \begin_layout Subsection
35612 Copy-Propagation
35613 \begin_inset LatexCommand index
35614 name "Copy propagation"
35615
35616 \end_inset
35617
35618
35619 \end_layout
35620
35621 \begin_layout Verse
35622
35623 \family typewriter
35624 int f() { 
35625 \newline
35626 \InsetSpace ~
35627 \InsetSpace ~
35628 int i, j; 
35629 \newline
35630 \InsetSpace ~
35631 \InsetSpace ~
35632 i = 10; 
35633 \newline
35634 \InsetSpace ~
35635 \InsetSpace ~
35636 j = i; 
35637 \newline
35638 \InsetSpace ~
35639 \InsetSpace ~
35640 return j; 
35641 \newline
35642 }
35643 \end_layout
35644
35645 \begin_layout Standard
35646 will be changed to 
35647 \end_layout
35648
35649 \begin_layout Verse
35650
35651 \family typewriter
35652 int f() { 
35653 \newline
35654 \InsetSpace ~
35655 \InsetSpace ~
35656 int i, j; 
35657 \newline
35658 \InsetSpace ~
35659 \InsetSpace ~
35660 i = 10; 
35661 \newline
35662 \InsetSpace ~
35663 \InsetSpace ~
35664 j = 10; 
35665 \newline
35666 \InsetSpace ~
35667 \InsetSpace ~
35668 return 10; 
35669 \newline
35670 }
35671 \end_layout
35672
35673 \begin_layout Standard
35674 Note: the dead stores created by this copy propagation will be eliminated
35675  by dead-code elimination.
35676 \end_layout
35677
35678 \begin_layout Subsection
35679 Loop Optimizations
35680 \begin_inset LatexCommand index
35681 name "Loop optimization"
35682
35683 \end_inset
35684
35685
35686 \begin_inset LatexCommand label
35687 name "sub:Loop-Optimizations"
35688
35689 \end_inset
35690
35691
35692 \end_layout
35693
35694 \begin_layout Standard
35695 Two types of loop optimizations are done by SDCC 
35696 \emph on
35697 loop invariant
35698 \emph default
35699  lifting and 
35700 \emph on
35701 strength reduction
35702 \emph default
35703  of loop induction variables.
35704  In addition to the strength reduction the optimizer marks the induction
35705  variables and the register allocator tries to keep the induction variables
35706  in registers for the duration of the loop.
35707  Because of this preference of the register allocator
35708 \begin_inset LatexCommand index
35709 name "Register allocation"
35710
35711 \end_inset
35712
35713 , loop induction optimization causes an increase in register pressure, which
35714  may cause unwanted spilling of other temporary variables into the stack
35715 \begin_inset LatexCommand index
35716 name "stack"
35717
35718 \end_inset
35719
35720  / data space.
35721  The compiler will generate a warning message when it is forced to allocate
35722  extra space either on the stack or data space.
35723  If this extra space allocation is undesirable then induction optimization
35724  can be eliminated either for the entire source file (with -
35725 \begin_inset ERT
35726 status collapsed
35727
35728 \begin_layout Standard
35729
35730
35731 \backslash
35732 /
35733 \end_layout
35734
35735 \end_inset
35736
35737 -noinduction option) or for a given function only using #pragma\InsetSpace ~
35738 noinduction
35739 \begin_inset LatexCommand index
35740 name "\\#pragma noinduction"
35741
35742 \end_inset
35743
35744 .
35745 \newline
35746
35747 \newline
35748 Loop Invariant:
35749 \end_layout
35750
35751 \begin_layout Verse
35752
35753 \family typewriter
35754 for (i = 0 ; i < 100 ; i ++) 
35755 \newline
35756 \InsetSpace ~
35757 \InsetSpace ~
35758 \InsetSpace ~
35759 \InsetSpace ~
35760 f += k + l;
35761 \end_layout
35762
35763 \begin_layout Standard
35764 changed to
35765 \end_layout
35766
35767 \begin_layout Verse
35768
35769 \family typewriter
35770 itemp = k + l; 
35771 \newline
35772 for (i = 0; i < 100; i++) 
35773 \newline
35774 \InsetSpace ~
35775 \InsetSpace ~
35776 \InsetSpace ~
35777 \InsetSpace ~
35778 f += itemp;
35779 \end_layout
35780
35781 \begin_layout Standard
35782 As mentioned previously some loop invariants are not as apparent, all static
35783  address computations are also moved out of the loop.
35784 \newline
35785
35786 \newline
35787 Strength Reduction
35788 \begin_inset LatexCommand index
35789 name "Strength reduction"
35790
35791 \end_inset
35792
35793 , this optimization substitutes an expression by a cheaper expression:
35794 \end_layout
35795
35796 \begin_layout Verse
35797
35798 \family typewriter
35799 for (i=0;i < 100; i++)
35800 \newline
35801 \InsetSpace ~
35802 \InsetSpace ~
35803 \InsetSpace ~
35804 \InsetSpace ~
35805 ar[i*5] = i*3;
35806 \end_layout
35807
35808 \begin_layout Standard
35809 changed to
35810 \end_layout
35811
35812 \begin_layout Verse
35813
35814 \family typewriter
35815 itemp1 = 0; 
35816 \newline
35817 itemp2 = 0; 
35818 \newline
35819 for (i=0;i< 100;i++) { 
35820 \newline
35821 \InsetSpace ~
35822 \InsetSpace ~
35823 \InsetSpace ~
35824 \InsetSpace ~
35825 ar[itemp1] = itemp2; 
35826 \newline
35827 \InsetSpace ~
35828 \InsetSpace ~
35829 \InsetSpace ~
35830 \InsetSpace ~
35831 itemp1
35832  += 5; 
35833 \newline
35834 \InsetSpace ~
35835 \InsetSpace ~
35836 \InsetSpace ~
35837 \InsetSpace ~
35838 itemp2 += 3; 
35839 \newline
35840 }
35841 \end_layout
35842
35843 \begin_layout Standard
35844 The more expensive multiplication
35845 \begin_inset LatexCommand index
35846 name "Multiplication"
35847
35848 \end_inset
35849
35850  is changed to a less expensive addition.
35851 \end_layout
35852
35853 \begin_layout Subsection
35854 Loop Reversing
35855 \begin_inset LatexCommand index
35856 name "Loop reversing"
35857
35858 \end_inset
35859
35860
35861 \end_layout
35862
35863 \begin_layout Standard
35864 This optimization is done to reduce the overhead of checking loop boundaries
35865  for every iteration.
35866  Some simple loops can be reversed and implemented using a 
35867 \begin_inset Quotes eld
35868 \end_inset
35869
35870 decrement and jump if not zero
35871 \begin_inset Quotes erd
35872 \end_inset
35873
35874  instruction.
35875  SDCC checks for the following criterion to determine if a loop is reversible
35876  (note: more sophisticated compilers use data-dependency analysis to make
35877  this determination, SDCC uses a more simple minded analysis).
35878 \end_layout
35879
35880 \begin_layout Itemize
35881 The 'for' loop is of the form 
35882 \newline
35883
35884 \newline
35885
35886 \family typewriter
35887 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
35888  += 1])
35889 \newline
35890 \InsetSpace ~
35891 \InsetSpace ~
35892 \InsetSpace ~
35893 \InsetSpace ~
35894 <for body>
35895 \end_layout
35896
35897 \begin_layout Itemize
35898 The <for body> does not contain 
35899 \begin_inset Quotes eld
35900 \end_inset
35901
35902 continue
35903 \begin_inset Quotes erd
35904 \end_inset
35905
35906  or 'break
35907 \begin_inset Quotes erd
35908 \end_inset
35909
35910 .
35911 \end_layout
35912
35913 \begin_layout Itemize
35914 All goto's are contained within the loop.
35915 \end_layout
35916
35917 \begin_layout Itemize
35918 No function calls within the loop.
35919 \end_layout
35920
35921 \begin_layout Itemize
35922 The loop control variable <sym> is not assigned any value within the loop
35923 \end_layout
35924
35925 \begin_layout Itemize
35926 The loop control variable does NOT participate in any arithmetic operation
35927  within the loop.
35928 \end_layout
35929
35930 \begin_layout Itemize
35931 There are NO switch statements in the loop.
35932 \end_layout
35933
35934 \begin_layout Subsection
35935 Algebraic Simplifications
35936 \end_layout
35937
35938 \begin_layout Standard
35939 SDCC does numerous algebraic simplifications, the following is a small sub-set
35940  of these optimizations.
35941 \end_layout
35942
35943 \begin_layout Verse
35944
35945 \family typewriter
35946 i = j + 0;\InsetSpace ~
35947 \InsetSpace ~
35948 \InsetSpace ~
35949 \InsetSpace ~
35950  /* changed to: */\InsetSpace ~
35951 \InsetSpace ~
35952 \InsetSpace ~
35953 \InsetSpace ~
35954  i = j; 
35955 \newline
35956 i /= 2;\InsetSpace ~
35957 \InsetSpace ~
35958 \InsetSpace ~
35959 \InsetSpace ~
35960 \InsetSpace ~
35961 \InsetSpace ~
35962 \InsetSpace ~
35963  /* changed to: */\InsetSpace ~
35964 \InsetSpace ~
35965 \InsetSpace ~
35966 \InsetSpace ~
35967  i >>= 1; 
35968 \newline
35969 i
35970  = j - j;\InsetSpace ~
35971 \InsetSpace ~
35972 \InsetSpace ~
35973 \InsetSpace ~
35974  /* changed to: */\InsetSpace ~
35975 \InsetSpace ~
35976 \InsetSpace ~
35977 \InsetSpace ~
35978  i = 0; 
35979 \newline
35980 i = j / 1;\InsetSpace ~
35981 \InsetSpace ~
35982 \InsetSpace ~
35983 \InsetSpace ~
35984  /* changed to: */\InsetSpace ~
35985 \InsetSpace ~
35986 \InsetSpace ~
35987 \InsetSpace ~
35988  i = j;
35989 \end_layout
35990
35991 \begin_layout Standard
35992 Note the subexpressions
35993 \begin_inset LatexCommand index
35994 name "Subexpression"
35995
35996 \end_inset
35997
35998  given above are generally introduced by macro expansions or as a result
35999  of copy/constant propagation.
36000 \end_layout
36001
36002 \begin_layout Subsection
36003 'switch' Statements
36004 \begin_inset LatexCommand label
36005 name "sub:'switch'-Statements"
36006
36007 \end_inset
36008
36009
36010 \begin_inset LatexCommand index
36011 name "switch statement"
36012
36013 \end_inset
36014
36015
36016 \end_layout
36017
36018 \begin_layout Standard
36019 SDCC can optimize switch statements to jump tables
36020 \begin_inset LatexCommand index
36021 name "jump tables"
36022
36023 \end_inset
36024
36025 .
36026  It makes the decision based on an estimate of the generated code size.
36027  SDCC is quite liberal in the requirements for jump table generation: 
36028 \end_layout
36029
36030 \begin_layout Itemize
36031 The labels need not be in order, and the starting number need not be one
36032  or zero, the case labels are in numerical sequence or not too many case
36033  labels are missing.
36034 \end_layout
36035
36036 \begin_deeper
36037 \begin_layout Verse
36038
36039 \family typewriter
36040 switch(i) {\InsetSpace ~
36041 \InsetSpace ~
36042 \InsetSpace ~
36043 \InsetSpace ~
36044 \InsetSpace ~
36045 \InsetSpace ~
36046 \InsetSpace ~
36047 \InsetSpace ~
36048 \InsetSpace ~
36049 \InsetSpace ~
36050 \InsetSpace ~
36051 \InsetSpace ~
36052 \InsetSpace ~
36053 \InsetSpace ~
36054 \InsetSpace ~
36055 \InsetSpace ~
36056 \InsetSpace ~
36057 \InsetSpace ~
36058 \InsetSpace ~
36059 \InsetSpace ~
36060 \InsetSpace ~
36061 \InsetSpace ~
36062 \InsetSpace ~
36063 \InsetSpace ~
36064 \InsetSpace ~
36065 \InsetSpace ~
36066 switch (i) { 
36067 \newline
36068 \InsetSpace ~
36069 \InsetSpace ~
36070 \InsetSpace ~
36071 case 4: ...\InsetSpace ~
36072 \InsetSpace ~
36073 \InsetSpace ~
36074 \InsetSpace ~
36075 \InsetSpace ~
36076 \InsetSpace ~
36077 \InsetSpace ~
36078 \InsetSpace ~
36079 \InsetSpace ~
36080 \InsetSpace ~
36081 \InsetSpace ~
36082 \InsetSpace ~
36083 \InsetSpace ~
36084 \InsetSpace ~
36085 \InsetSpace ~
36086 \InsetSpace ~
36087 \InsetSpace ~
36088 \InsetSpace ~
36089 \InsetSpace ~
36090 \InsetSpace ~
36091 \InsetSpace ~
36092 \InsetSpace ~
36093 \InsetSpace ~
36094 \InsetSpace ~
36095 \InsetSpace ~
36096 \InsetSpace ~
36097 case 0: ...
36098  
36099 \newline
36100 \InsetSpace ~
36101 \InsetSpace ~
36102 \InsetSpace ~
36103 case 5: ...\InsetSpace ~
36104 \InsetSpace ~
36105 \InsetSpace ~
36106 \InsetSpace ~
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110 \InsetSpace ~
36111 \InsetSpace ~
36112 \InsetSpace ~
36113 \InsetSpace ~
36114 \InsetSpace ~
36115 \InsetSpace ~
36116 \InsetSpace ~
36117 \InsetSpace ~
36118 \InsetSpace ~
36119 \InsetSpace ~
36120 \InsetSpace ~
36121 \InsetSpace ~
36122 \InsetSpace ~
36123 \InsetSpace ~
36124 \InsetSpace ~
36125 \InsetSpace ~
36126 \InsetSpace ~
36127 \InsetSpace ~
36128 \InsetSpace ~
36129 case 1: ...
36130  
36131 \newline
36132 \InsetSpace ~
36133 \InsetSpace ~
36134 \InsetSpace ~
36135 case 3: ...\InsetSpace ~
36136 \InsetSpace ~
36137 \InsetSpace ~
36138 \InsetSpace ~
36139 \InsetSpace ~
36140 \InsetSpace ~
36141 \InsetSpace ~
36142 \InsetSpace ~
36143 \InsetSpace ~
36144 \InsetSpace ~
36145 \InsetSpace ~
36146 \InsetSpace ~
36147 \InsetSpace ~
36148 \InsetSpace ~
36149 \InsetSpace ~
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 \InsetSpace ~
36153 \InsetSpace ~
36154 \InsetSpace ~
36155 \InsetSpace ~
36156 \InsetSpace ~
36157 \InsetSpace ~
36158 \InsetSpace ~
36159 \InsetSpace ~
36160 \InsetSpace ~
36161
36162 \newline
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 case 6: ...\InsetSpace ~
36167 \InsetSpace ~
36168 \InsetSpace ~
36169 \InsetSpace ~
36170 \InsetSpace ~
36171 \InsetSpace ~
36172 \InsetSpace ~
36173 \InsetSpace ~
36174 \InsetSpace ~
36175 \InsetSpace ~
36176 \InsetSpace ~
36177 \InsetSpace ~
36178 \InsetSpace ~
36179 \InsetSpace ~
36180 \InsetSpace ~
36181 \InsetSpace ~
36182 \InsetSpace ~
36183 \InsetSpace ~
36184 \InsetSpace ~
36185 \InsetSpace ~
36186 \InsetSpace ~
36187 \InsetSpace ~
36188 \InsetSpace ~
36189 \InsetSpace ~
36190 \InsetSpace ~
36191 \InsetSpace ~
36192 case 3: ...
36193  
36194 \newline
36195 \InsetSpace ~
36196 \InsetSpace ~
36197 \InsetSpace ~
36198 case 7: ...\InsetSpace ~
36199 \InsetSpace ~
36200 \InsetSpace ~
36201 \InsetSpace ~
36202 \InsetSpace ~
36203 \InsetSpace ~
36204 \InsetSpace ~
36205 \InsetSpace ~
36206 \InsetSpace ~
36207 \InsetSpace ~
36208 \InsetSpace ~
36209 \InsetSpace ~
36210 \InsetSpace ~
36211 \InsetSpace ~
36212 \InsetSpace ~
36213 \InsetSpace ~
36214 \InsetSpace ~
36215 \InsetSpace ~
36216 \InsetSpace ~
36217 \InsetSpace ~
36218 \InsetSpace ~
36219 \InsetSpace ~
36220 \InsetSpace ~
36221 \InsetSpace ~
36222 \InsetSpace ~
36223 \InsetSpace ~
36224 case 4: ...
36225  
36226 \newline
36227 \InsetSpace ~
36228 \InsetSpace ~
36229 \InsetSpace ~
36230 case 8: ...\InsetSpace ~
36231 \InsetSpace ~
36232 \InsetSpace ~
36233 \InsetSpace ~
36234 \InsetSpace ~
36235 \InsetSpace ~
36236 \InsetSpace ~
36237 \InsetSpace ~
36238 \InsetSpace ~
36239 \InsetSpace ~
36240 \InsetSpace ~
36241 \InsetSpace ~
36242 \InsetSpace ~
36243 \InsetSpace ~
36244 \InsetSpace ~
36245 \InsetSpace ~
36246 \InsetSpace ~
36247 \InsetSpace ~
36248 \InsetSpace ~
36249 \InsetSpace ~
36250 \InsetSpace ~
36251 \InsetSpace ~
36252 \InsetSpace ~
36253 \InsetSpace ~
36254 \InsetSpace ~
36255 \InsetSpace ~
36256 case 5: ...
36257  
36258 \newline
36259 \InsetSpace ~
36260 \InsetSpace ~
36261 \InsetSpace ~
36262 case 9: ...\InsetSpace ~
36263 \InsetSpace ~
36264 \InsetSpace ~
36265 \InsetSpace ~
36266 \InsetSpace ~
36267 \InsetSpace ~
36268 \InsetSpace ~
36269 \InsetSpace ~
36270 \InsetSpace ~
36271 \InsetSpace ~
36272 \InsetSpace ~
36273 \InsetSpace ~
36274 \InsetSpace ~
36275 \InsetSpace ~
36276 \InsetSpace ~
36277 \InsetSpace ~
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 \InsetSpace ~
36281 \InsetSpace ~
36282 \InsetSpace ~
36283 \InsetSpace ~
36284 \InsetSpace ~
36285 \InsetSpace ~
36286 \InsetSpace ~
36287 \InsetSpace ~
36288 case 6: ...
36289  
36290 \newline
36291 \InsetSpace ~
36292 \InsetSpace ~
36293 \InsetSpace ~
36294 case 10: ...\InsetSpace ~
36295 \InsetSpace ~
36296 \InsetSpace ~
36297 \InsetSpace ~
36298 \InsetSpace ~
36299 \InsetSpace ~
36300 \InsetSpace ~
36301 \InsetSpace ~
36302 \InsetSpace ~
36303 \InsetSpace ~
36304 \InsetSpace ~
36305 \InsetSpace ~
36306 \InsetSpace ~
36307 \InsetSpace ~
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 \InsetSpace ~
36312 \InsetSpace ~
36313 \InsetSpace ~
36314 \InsetSpace ~
36315 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318 \InsetSpace ~
36319 case 7: ...
36320  
36321 \newline
36322 \InsetSpace ~
36323 \InsetSpace ~
36324 \InsetSpace ~
36325 case 11: ...\InsetSpace ~
36326 \InsetSpace ~
36327 \InsetSpace ~
36328 \InsetSpace ~
36329 \InsetSpace ~
36330 \InsetSpace ~
36331 \InsetSpace ~
36332 \InsetSpace ~
36333 \InsetSpace ~
36334 \InsetSpace ~
36335 \InsetSpace ~
36336 \InsetSpace ~
36337 \InsetSpace ~
36338 \InsetSpace ~
36339 \InsetSpace ~
36340 \InsetSpace ~
36341 \InsetSpace ~
36342 \InsetSpace ~
36343 \InsetSpace ~
36344 \InsetSpace ~
36345 \InsetSpace ~
36346 \InsetSpace ~
36347 \InsetSpace ~
36348 \InsetSpace ~
36349 \InsetSpace ~
36350 case 8: ...
36351  
36352 \newline
36353 }\InsetSpace ~
36354 \InsetSpace ~
36355 \InsetSpace ~
36356 \InsetSpace ~
36357 \InsetSpace ~
36358 \InsetSpace ~
36359 \InsetSpace ~
36360 \InsetSpace ~
36361 \InsetSpace ~
36362 \InsetSpace ~
36363 \InsetSpace ~
36364 \InsetSpace ~
36365 \InsetSpace ~
36366 \InsetSpace ~
36367 \InsetSpace ~
36368 \InsetSpace ~
36369 \InsetSpace ~
36370 \InsetSpace ~
36371 \InsetSpace ~
36372 \InsetSpace ~
36373 \InsetSpace ~
36374 \InsetSpace ~
36375 \InsetSpace ~
36376 \InsetSpace ~
36377 \InsetSpace ~
36378 \InsetSpace ~
36379 \InsetSpace ~
36380 \InsetSpace ~
36381 \InsetSpace ~
36382 \InsetSpace ~
36383 \InsetSpace ~
36384 \InsetSpace ~
36385 \InsetSpace ~
36386 \InsetSpace ~
36387 \InsetSpace ~
36388 \InsetSpace ~
36389 }
36390 \end_layout
36391
36392 \begin_layout Standard
36393 Both the above switch statements will be implemented using a jump-table.
36394  The example to the right side is slightly more efficient as the check for
36395  the lower boundary of the jump-table is not needed.
36396 \end_layout
36397
36398 \end_deeper
36399 \begin_layout Itemize
36400 The number of case labels is not larger than supported by the target architectur
36401 e.
36402 \end_layout
36403
36404 \begin_layout Itemize
36405 If the case labels are not in numerical sequence ('gaps' between cases)
36406  SDCC checks whether a jump table with additionally inserted dummy cases
36407  is still attractive.
36408  
36409 \end_layout
36410
36411 \begin_layout Itemize
36412 If the starting number is not zero and a check for the lower boundary of
36413  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
36414  ...
36415  .
36416 \end_layout
36417
36418 \begin_layout Standard
36419 Switch statements which have large gaps in the numeric sequence or those
36420  that have too many case labels can be split into more than one switch statement
36421  for efficient code generation, e.g.:
36422 \end_layout
36423
36424 \begin_layout Verse
36425
36426 \family typewriter
36427 switch (i) { 
36428 \newline
36429 \InsetSpace ~
36430 \InsetSpace ~
36431 case 1: ...
36432  
36433 \newline
36434 \InsetSpace ~
36435 \InsetSpace ~
36436 case 2: ...
36437  
36438 \newline
36439 \InsetSpace ~
36440 \InsetSpace ~
36441 case 3: ...
36442  
36443 \newline
36444 \InsetSpace ~
36445 \InsetSpace ~
36446 case 4: ...
36447  
36448 \newline
36449 \InsetSpace ~
36450 \InsetSpace ~
36451 case 5: ...
36452  
36453 \newline
36454 \InsetSpace ~
36455 \InsetSpace ~
36456 case 6: ...
36457  
36458 \newline
36459 \InsetSpace ~
36460 \InsetSpace ~
36461 case 7: ...
36462  
36463 \newline
36464 \InsetSpace ~
36465 \InsetSpace ~
36466 case 101: ...
36467  
36468 \newline
36469 \InsetSpace ~
36470 \InsetSpace ~
36471 case 102: ...
36472  
36473 \newline
36474 \InsetSpace ~
36475 \InsetSpace ~
36476 case 103: ...
36477  
36478 \newline
36479 \InsetSpace ~
36480 \InsetSpace ~
36481 case 104: ...
36482  
36483 \newline
36484 \InsetSpace ~
36485 \InsetSpace ~
36486 case 105: ...
36487  
36488 \newline
36489 \InsetSpace ~
36490 \InsetSpace ~
36491 case 106: ...
36492  
36493 \newline
36494 \InsetSpace ~
36495 \InsetSpace ~
36496 case 107: ...
36497  
36498 \newline
36499 }
36500 \end_layout
36501
36502 \begin_layout Standard
36503 If the above switch statement is broken down into two switch statements
36504 \end_layout
36505
36506 \begin_layout Verse
36507
36508 \family typewriter
36509 switch (i) { 
36510 \newline
36511 \InsetSpace ~
36512 \InsetSpace ~
36513 case 1: ...
36514  
36515 \newline
36516 \InsetSpace ~
36517 \InsetSpace ~
36518 case 2: ...
36519  
36520 \newline
36521 \InsetSpace ~
36522 \InsetSpace ~
36523 case 3: ...
36524  
36525 \newline
36526 \InsetSpace ~
36527 \InsetSpace ~
36528 case 4: ...
36529  
36530 \newline
36531 \InsetSpace ~
36532 \InsetSpace ~
36533 case 5: ...
36534  
36535 \newline
36536 \InsetSpace ~
36537 \InsetSpace ~
36538 case 6: ...
36539  
36540 \newline
36541 \InsetSpace ~
36542 \InsetSpace ~
36543 case 7: ...
36544  
36545 \newline
36546 }
36547 \end_layout
36548
36549 \begin_layout Standard
36550 and
36551 \end_layout
36552
36553 \begin_layout Verse
36554
36555 \family typewriter
36556 switch (i) { 
36557 \newline
36558 \InsetSpace ~
36559 \InsetSpace ~
36560 case 101: ...
36561  
36562 \newline
36563 \InsetSpace ~
36564 \InsetSpace ~
36565 case 102: ...
36566  
36567 \newline
36568 \InsetSpace ~
36569 \InsetSpace ~
36570 case 103: ...
36571  
36572 \newline
36573 \InsetSpace ~
36574 \InsetSpace ~
36575 case 104: ...
36576  
36577 \newline
36578 \InsetSpace ~
36579 \InsetSpace ~
36580 case 105: ...
36581  
36582 \newline
36583 \InsetSpace ~
36584 \InsetSpace ~
36585 case 106: ...
36586  
36587 \newline
36588 \InsetSpace ~
36589 \InsetSpace ~
36590 case 107: ...
36591  
36592 \newline
36593 }
36594 \end_layout
36595
36596 \begin_layout Standard
36597 then both the switch statements will be implemented using jump-tables whereas
36598  the unmodified switch statement will not be.
36599 \end_layout
36600
36601 \begin_layout Standard
36602 \begin_inset Note Note
36603 status collapsed
36604
36605 \begin_layout Standard
36606 There might be reasons which SDCC cannot know about to either favour or
36607  not favour jump tables.
36608  If the target system has to be as quick for the last switch case as for
36609  the first (pro jump table), or if the switch argument is known to be zero
36610  in the majority of the cases (contra jump table).
36611 \end_layout
36612
36613 \end_inset
36614
36615
36616 \end_layout
36617
36618 \begin_layout Standard
36619 The pragma nojtbound
36620 \begin_inset LatexCommand index
36621 name "\\#pragma nojtbound"
36622
36623 \end_inset
36624
36625  can be used to turn off checking the 
36626 \emph on
36627 j
36628 \emph default
36629 ump 
36630 \emph on
36631 t
36632 \emph default
36633 able 
36634 \emph on
36635 bound
36636 \emph default
36637 aries.
36638  It has no effect if a default label is supplied.
36639  Use of this pragma is dangerous: if the switch
36640 \begin_inset LatexCommand index
36641 name "switch statement"
36642
36643 \end_inset
36644
36645  argument is not matched by a case statement the processor will happily
36646  jump into Nirvana.
36647 \end_layout
36648
36649 \begin_layout Subsection
36650 Bit-shifting Operations
36651 \begin_inset LatexCommand index
36652 name "Bit shifting"
36653
36654 \end_inset
36655
36656 .
36657 \end_layout
36658
36659 \begin_layout Standard
36660 Bit shifting is one of the most frequently used operation in embedded programmin
36661 g.
36662  SDCC tries to implement bit-shift operations in the most efficient way
36663  possible, e.g.:
36664 \end_layout
36665
36666 \begin_layout Verse
36667
36668 \family typewriter
36669 unsigned char i;
36670 \newline
36671 ...
36672  
36673 \newline
36674 i >>= 4; 
36675 \newline
36676 ...
36677 \end_layout
36678
36679 \begin_layout Standard
36680 generates the following code:
36681 \end_layout
36682
36683 \begin_layout Verse
36684
36685 \family typewriter
36686 mov\InsetSpace ~
36687  a,_i 
36688 \newline
36689 swap a 
36690 \newline
36691 anl\InsetSpace ~
36692  a,#0x0f 
36693 \newline
36694 mov\InsetSpace ~
36695  _i,a
36696 \end_layout
36697
36698 \begin_layout Standard
36699 In general SDCC will never setup a loop if the shift count is known.
36700  Another example:
36701 \end_layout
36702
36703 \begin_layout Verse
36704
36705 \family typewriter
36706 unsigned int i; 
36707 \newline
36708 ...
36709  
36710 \newline
36711 i >>= 9; 
36712 \newline
36713 ...
36714 \end_layout
36715
36716 \begin_layout Standard
36717 will generate:
36718 \end_layout
36719
36720 \begin_layout Verse
36721
36722 \family typewriter
36723 mov\InsetSpace ~
36724 \InsetSpace ~
36725 a,(_i + 1) 
36726 \newline
36727 mov\InsetSpace ~
36728 \InsetSpace ~
36729 (_i + 1),#0x00 
36730 \newline
36731 clr\InsetSpace ~
36732 \InsetSpace ~
36733
36734 \newline
36735 rrc\InsetSpace ~
36736 \InsetSpace ~
36737
36738 \newline
36739 mov\InsetSpace ~
36740 \InsetSpace ~
36741 _i,a
36742 \end_layout
36743
36744 \begin_layout Subsection
36745 Bit-rotation
36746 \begin_inset LatexCommand index
36747 name "Bit rotation"
36748
36749 \end_inset
36750
36751
36752 \end_layout
36753
36754 \begin_layout Standard
36755 A special case of the bit-shift operation is bit rotation
36756 \begin_inset LatexCommand index
36757 name "rotating bits"
36758
36759 \end_inset
36760
36761 , SDCC recognizes the following expression to be a left bit-rotation:
36762 \end_layout
36763
36764 \begin_layout Verse
36765
36766 \family typewriter
36767 \series bold
36768 unsigned
36769 \series default
36770 \InsetSpace ~
36771 \InsetSpace ~
36772 char i;\InsetSpace ~
36773 \InsetSpace ~
36774 \InsetSpace ~
36775 \InsetSpace ~
36776 \InsetSpace ~
36777 \InsetSpace ~
36778 \InsetSpace ~
36779 \InsetSpace ~
36780 \InsetSpace ~
36781 \InsetSpace ~
36782 \InsetSpace ~
36783 /* unsigned is needed for rotation */ 
36784 \newline
36785 ...
36786  
36787 \newline
36788 i = ((i << 1) | (i >> 7));
36789 \family default
36790  
36791 \newline
36792
36793 \family typewriter
36794 ...
36795 \end_layout
36796
36797 \begin_layout Standard
36798 will generate the following code:
36799 \end_layout
36800
36801 \begin_layout Verse
36802
36803 \family typewriter
36804 mov\InsetSpace ~
36805 \InsetSpace ~
36806 a,_i 
36807 \newline
36808 rl\InsetSpace ~
36809 \InsetSpace ~
36810 \InsetSpace ~
36811
36812 \newline
36813 mov\InsetSpace ~
36814 \InsetSpace ~
36815 _i,a
36816 \end_layout
36817
36818 \begin_layout Standard
36819 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
36820 ns of this case will also be recognized as bit-rotation, i.e.: 
36821 \end_layout
36822
36823 \begin_layout Verse
36824
36825 \family typewriter
36826 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
36827 \end_layout
36828
36829 \begin_layout Subsection
36830 Nibble and Byte Swapping
36831 \end_layout
36832
36833 \begin_layout Standard
36834 Other special cases of the bit-shift operations are nibble or byte swapping
36835 \begin_inset LatexCommand index
36836 name "swapping nibbles/bytes"
36837
36838 \end_inset
36839
36840 , SDCC recognizes the following expressions:
36841 \end_layout
36842
36843 \begin_layout Verse
36844
36845 \family typewriter
36846 \series bold
36847 unsigned
36848 \series default
36849 \InsetSpace ~
36850 \InsetSpace ~
36851 char i; 
36852 \newline
36853
36854 \series bold
36855 unsigned
36856 \series default
36857 \InsetSpace ~
36858 \InsetSpace ~
36859 int j; 
36860 \newline
36861 ...
36862  
36863 \newline
36864 i = ((i << 4) | (i >> 4));
36865 \family default
36866  
36867 \newline
36868
36869 \family typewriter
36870 j = ((j << 8) | (j >> 8)); 
36871 \end_layout
36872
36873 \begin_layout Standard
36874 and generates a swap instruction for the nibble swapping
36875 \begin_inset LatexCommand index
36876 name "Nibble swapping"
36877
36878 \end_inset
36879
36880  or move instructions for the byte swapping
36881 \begin_inset LatexCommand index
36882 name "Byte swapping"
36883
36884 \end_inset
36885
36886 .
36887  The 
36888 \begin_inset Quotes sld
36889 \end_inset
36890
36891 j
36892 \begin_inset Quotes srd
36893 \end_inset
36894
36895  example can be used to convert from little to big-endian or vice versa.
36896  If you want to change the endianness of a 
36897 \emph on
36898 signed
36899 \emph default
36900  integer you have to cast to 
36901 \family typewriter
36902 (unsigned int)
36903 \family default
36904  first.
36905 \end_layout
36906
36907 \begin_layout Standard
36908 Note that SDCC stores numbers in little-endian
36909 \begin_inset Foot
36910 status open
36911
36912 \begin_layout Standard
36913 Usually 8-bit processors don't care much about endianness.
36914  This is not the case for the standard 8051 which only has an instruction
36915  to increment its 
36916 \emph on
36917 dptr
36918 \emph default
36919
36920 \begin_inset LatexCommand index
36921 name "DPTR"
36922
36923 \end_inset
36924
36925 -datapointer so little-endian is the more efficient byte order.
36926 \end_layout
36927
36928 \end_inset
36929
36930
36931 \begin_inset LatexCommand index
36932 name "little-endian"
36933
36934 \end_inset
36935
36936
36937 \begin_inset LatexCommand index
36938 name "Endianness"
36939
36940 \end_inset
36941
36942  format (i.e.
36943  lowest order first).
36944 \end_layout
36945
36946 \begin_layout Subsection
36947 Highest Order Bit
36948 \begin_inset LatexCommand index
36949 name "Highest Order Bit"
36950
36951 \end_inset
36952
36953  / Any Order Bit
36954 \begin_inset LatexCommand index
36955 name "Any Order Bit"
36956
36957 \end_inset
36958
36959
36960 \end_layout
36961
36962 \begin_layout Standard
36963 It is frequently required to obtain the highest order bit of an integral
36964  type (long, int, short or char types).
36965  Also obtaining any other order bit is not uncommon.
36966  SDCC recognizes the following expressions to yield the highest order bit
36967  and generates optimized code for it, e.g.:
36968 \end_layout
36969
36970 \begin_layout Verse
36971
36972 \family typewriter
36973 unsigned int gint; 
36974 \newline
36975
36976 \newline
36977 foo () { 
36978 \newline
36979 \InsetSpace ~
36980 \InsetSpace ~
36981 unsigned char hob1, aob1; 
36982 \newline
36983 \InsetSpace ~
36984 \InsetSpace ~
36985 bit hob2, hob3, aob2,
36986  aob3; 
36987 \newline
36988 \InsetSpace ~
36989 \InsetSpace ~
36990 ...
36991  
36992 \newline
36993 \InsetSpace ~
36994 \InsetSpace ~
36995 hob1 = (gint >> 15) & 1; 
36996 \newline
36997 \InsetSpace ~
36998 \InsetSpace ~
36999 hob2 = (gint >> 15) & 1; 
37000 \newline
37001 \InsetSpace ~
37002 \InsetSpace ~
37003 hob3 = gint & 0x8000;
37004  
37005 \newline
37006 \InsetSpace ~
37007 \InsetSpace ~
37008 aob1 = (gint >> 9) & 1; 
37009 \newline
37010 \InsetSpace ~
37011 \InsetSpace ~
37012 aob2 = (gint >> 8) & 1; 
37013 \newline
37014 \InsetSpace ~
37015 \InsetSpace ~
37016 aob3 = gint & 0x0800; 
37017 \newline
37018 \InsetSpace ~
37019 \InsetSpace ~
37020 ..
37021  
37022 \newline
37023 }
37024 \end_layout
37025
37026 \begin_layout Standard
37027 will generate the following code:
37028 \end_layout
37029
37030 \begin_layout Verse
37031
37032 \family typewriter
37033 \InsetSpace ~
37034 \InsetSpace ~
37035 \InsetSpace ~
37036 \InsetSpace ~
37037 \InsetSpace ~
37038 \InsetSpace ~
37039 \InsetSpace ~
37040 \InsetSpace ~
37041 \InsetSpace ~
37042 \InsetSpace ~
37043 \InsetSpace ~
37044 \InsetSpace ~
37045 \InsetSpace ~
37046 \InsetSpace ~
37047 \InsetSpace ~
37048 \InsetSpace ~
37049 \InsetSpace ~
37050 \InsetSpace ~
37051 \InsetSpace ~
37052 \InsetSpace ~
37053 \InsetSpace ~
37054 \InsetSpace ~
37055 \InsetSpace ~
37056 \InsetSpace ~
37057 \InsetSpace ~
37058  61 ;\InsetSpace ~
37059  hob.c 7 
37060 \newline
37061 000A E5*01\InsetSpace ~
37062 \InsetSpace ~
37063 \InsetSpace ~
37064 \InsetSpace ~
37065 \InsetSpace ~
37066 \InsetSpace ~
37067 \InsetSpace ~
37068 \InsetSpace ~
37069 \InsetSpace ~
37070 \InsetSpace ~
37071 \InsetSpace ~
37072 \InsetSpace ~
37073 \InsetSpace ~
37074 \InsetSpace ~
37075 \InsetSpace ~
37076  62\InsetSpace ~
37077 \InsetSpace ~
37078 \InsetSpace ~
37079 \InsetSpace ~
37080 \InsetSpace ~
37081 \InsetSpace ~
37082 \InsetSpace ~
37083 \InsetSpace ~
37084  mov\InsetSpace ~
37085 \InsetSpace ~
37086  a,(_gint + 1) 
37087 \newline
37088 000C 23\InsetSpace ~
37089 \InsetSpace ~
37090 \InsetSpace ~
37091 \InsetSpace ~
37092 \InsetSpace ~
37093 \InsetSpace ~
37094 \InsetSpace ~
37095 \InsetSpace ~
37096 \InsetSpace ~
37097 \InsetSpace ~
37098 \InsetSpace ~
37099 \InsetSpace ~
37100 \InsetSpace ~
37101 \InsetSpace ~
37102 \InsetSpace ~
37103 \InsetSpace ~
37104 \InsetSpace ~
37105 \InsetSpace ~
37106  63\InsetSpace ~
37107 \InsetSpace ~
37108 \InsetSpace ~
37109 \InsetSpace ~
37110 \InsetSpace ~
37111 \InsetSpace ~
37112 \InsetSpace ~
37113 \InsetSpace ~
37114  rl\InsetSpace ~
37115 \InsetSpace ~
37116 \InsetSpace ~
37117  a 
37118 \newline
37119 000D 54 01\InsetSpace ~
37120 \InsetSpace ~
37121 \InsetSpace ~
37122 \InsetSpace ~
37123 \InsetSpace ~
37124 \InsetSpace ~
37125 \InsetSpace ~
37126 \InsetSpace ~
37127 \InsetSpace ~
37128 \InsetSpace ~
37129 \InsetSpace ~
37130 \InsetSpace ~
37131 \InsetSpace ~
37132 \InsetSpace ~
37133 \InsetSpace ~
37134
37135  64\InsetSpace ~
37136 \InsetSpace ~
37137 \InsetSpace ~
37138 \InsetSpace ~
37139 \InsetSpace ~
37140 \InsetSpace ~
37141 \InsetSpace ~
37142 \InsetSpace ~
37143  anl\InsetSpace ~
37144 \InsetSpace ~
37145  a,#0x01 
37146 \newline
37147 000F F5*02\InsetSpace ~
37148 \InsetSpace ~
37149 \InsetSpace ~
37150 \InsetSpace ~
37151 \InsetSpace ~
37152 \InsetSpace ~
37153 \InsetSpace ~
37154 \InsetSpace ~
37155 \InsetSpace ~
37156 \InsetSpace ~
37157 \InsetSpace ~
37158 \InsetSpace ~
37159 \InsetSpace ~
37160 \InsetSpace ~
37161 \InsetSpace ~
37162  65\InsetSpace ~
37163 \InsetSpace ~
37164 \InsetSpace ~
37165 \InsetSpace ~
37166 \InsetSpace ~
37167 \InsetSpace ~
37168 \InsetSpace ~
37169 \InsetSpace ~
37170  mov\InsetSpace ~
37171 \InsetSpace ~
37172  _foo_hob1_1_1,a 
37173 \newline
37174 \InsetSpace ~
37175 \InsetSpace ~
37176 \InsetSpace ~
37177 \InsetSpace ~
37178 \InsetSpace ~
37179 \InsetSpace ~
37180 \InsetSpace ~
37181 \InsetSpace ~
37182 \InsetSpace ~
37183 \InsetSpace ~
37184 \InsetSpace ~
37185 \InsetSpace ~
37186 \InsetSpace ~
37187 \InsetSpace ~
37188 \InsetSpace ~
37189 \InsetSpace ~
37190 \InsetSpace ~
37191 \InsetSpace ~
37192 \InsetSpace ~
37193 \InsetSpace ~
37194 \InsetSpace ~
37195 \InsetSpace ~
37196 \InsetSpace ~
37197 \InsetSpace ~
37198 \InsetSpace ~
37199  66 ;\InsetSpace ~
37200  hob.c 8 
37201 \newline
37202 0011 E5*01\InsetSpace ~
37203 \InsetSpace ~
37204 \InsetSpace ~
37205 \InsetSpace ~
37206 \InsetSpace ~
37207 \InsetSpace ~
37208 \InsetSpace ~
37209 \InsetSpace ~
37210 \InsetSpace ~
37211 \InsetSpace ~
37212 \InsetSpace ~
37213 \InsetSpace ~
37214 \InsetSpace ~
37215 \InsetSpace ~
37216 \InsetSpace ~
37217
37218  67\InsetSpace ~
37219 \InsetSpace ~
37220 \InsetSpace ~
37221 \InsetSpace ~
37222 \InsetSpace ~
37223 \InsetSpace ~
37224 \InsetSpace ~
37225 \InsetSpace ~
37226  mov\InsetSpace ~
37227 \InsetSpace ~
37228  a,(_gint + 1) 
37229 \newline
37230 0013 33\InsetSpace ~
37231 \InsetSpace ~
37232 \InsetSpace ~
37233 \InsetSpace ~
37234 \InsetSpace ~
37235 \InsetSpace ~
37236 \InsetSpace ~
37237 \InsetSpace ~
37238 \InsetSpace ~
37239 \InsetSpace ~
37240 \InsetSpace ~
37241 \InsetSpace ~
37242 \InsetSpace ~
37243 \InsetSpace ~
37244 \InsetSpace ~
37245 \InsetSpace ~
37246 \InsetSpace ~
37247 \InsetSpace ~
37248  68\InsetSpace ~
37249 \InsetSpace ~
37250 \InsetSpace ~
37251 \InsetSpace ~
37252 \InsetSpace ~
37253 \InsetSpace ~
37254 \InsetSpace ~
37255 \InsetSpace ~
37256  rlc\InsetSpace ~
37257 \InsetSpace ~
37258  a 
37259 \newline
37260 0014 92*00\InsetSpace ~
37261 \InsetSpace ~
37262 \InsetSpace ~
37263 \InsetSpace ~
37264 \InsetSpace ~
37265 \InsetSpace ~
37266 \InsetSpace ~
37267 \InsetSpace ~
37268 \InsetSpace ~
37269 \InsetSpace ~
37270 \InsetSpace ~
37271 \InsetSpace ~
37272 \InsetSpace ~
37273 \InsetSpace ~
37274 \InsetSpace ~
37275  69\InsetSpace ~
37276 \InsetSpace ~
37277 \InsetSpace ~
37278 \InsetSpace ~
37279 \InsetSpace ~
37280 \InsetSpace ~
37281 \InsetSpace ~
37282 \InsetSpace ~
37283  mov\InsetSpace ~
37284 \InsetSpace ~
37285  _foo_hob2_1_1,c
37286  
37287 \newline
37288 \InsetSpace ~
37289 \InsetSpace ~
37290 \InsetSpace ~
37291 \InsetSpace ~
37292 \InsetSpace ~
37293 \InsetSpace ~
37294 \InsetSpace ~
37295 \InsetSpace ~
37296 \InsetSpace ~
37297 \InsetSpace ~
37298 \InsetSpace ~
37299 \InsetSpace ~
37300 \InsetSpace ~
37301 \InsetSpace ~
37302 \InsetSpace ~
37303 \InsetSpace ~
37304 \InsetSpace ~
37305 \InsetSpace ~
37306 \InsetSpace ~
37307 \InsetSpace ~
37308 \InsetSpace ~
37309 \InsetSpace ~
37310 \InsetSpace ~
37311 \InsetSpace ~
37312 \InsetSpace ~
37313  66 ;\InsetSpace ~
37314  hob.c 9 
37315 \newline
37316 0016 E5*01\InsetSpace ~
37317 \InsetSpace ~
37318 \InsetSpace ~
37319 \InsetSpace ~
37320 \InsetSpace ~
37321 \InsetSpace ~
37322 \InsetSpace ~
37323 \InsetSpace ~
37324 \InsetSpace ~
37325 \InsetSpace ~
37326 \InsetSpace ~
37327 \InsetSpace ~
37328 \InsetSpace ~
37329 \InsetSpace ~
37330 \InsetSpace ~
37331  67\InsetSpace ~
37332 \InsetSpace ~
37333 \InsetSpace ~
37334 \InsetSpace ~
37335 \InsetSpace ~
37336 \InsetSpace ~
37337 \InsetSpace ~
37338 \InsetSpace ~
37339  mov\InsetSpace ~
37340 \InsetSpace ~
37341  a,(_gint + 1) 
37342 \newline
37343 0018 33\InsetSpace ~
37344 \InsetSpace ~
37345 \InsetSpace ~
37346 \InsetSpace ~
37347 \InsetSpace ~
37348 \InsetSpace ~
37349 \InsetSpace ~
37350 \InsetSpace ~
37351 \InsetSpace ~
37352 \InsetSpace ~
37353 \InsetSpace ~
37354 \InsetSpace ~
37355 \InsetSpace ~
37356 \InsetSpace ~
37357 \InsetSpace ~
37358 \InsetSpace ~
37359 \InsetSpace ~
37360 \InsetSpace ~
37361  68\InsetSpace ~
37362 \InsetSpace ~
37363 \InsetSpace ~
37364 \InsetSpace ~
37365 \InsetSpace ~
37366 \InsetSpace ~
37367 \InsetSpace ~
37368 \InsetSpace ~
37369  rlc\InsetSpace ~
37370 \InsetSpace ~
37371  a 
37372 \newline
37373 0019 92*01\InsetSpace ~
37374 \InsetSpace ~
37375 \InsetSpace ~
37376 \InsetSpace ~
37377 \InsetSpace ~
37378 \InsetSpace ~
37379 \InsetSpace ~
37380 \InsetSpace ~
37381 \InsetSpace ~
37382 \InsetSpace ~
37383 \InsetSpace ~
37384 \InsetSpace ~
37385 \InsetSpace ~
37386 \InsetSpace ~
37387 \InsetSpace ~
37388
37389  69\InsetSpace ~
37390 \InsetSpace ~
37391 \InsetSpace ~
37392 \InsetSpace ~
37393 \InsetSpace ~
37394 \InsetSpace ~
37395 \InsetSpace ~
37396 \InsetSpace ~
37397  mov\InsetSpace ~
37398 \InsetSpace ~
37399  _foo_hob3_1_1,c 
37400 \newline
37401 \InsetSpace ~
37402 \InsetSpace ~
37403 \InsetSpace ~
37404 \InsetSpace ~
37405 \InsetSpace ~
37406 \InsetSpace ~
37407 \InsetSpace ~
37408 \InsetSpace ~
37409 \InsetSpace ~
37410 \InsetSpace ~
37411 \InsetSpace ~
37412 \InsetSpace ~
37413 \InsetSpace ~
37414 \InsetSpace ~
37415 \InsetSpace ~
37416 \InsetSpace ~
37417 \InsetSpace ~
37418 \InsetSpace ~
37419 \InsetSpace ~
37420 \InsetSpace ~
37421 \InsetSpace ~
37422 \InsetSpace ~
37423 \InsetSpace ~
37424 \InsetSpace ~
37425 \InsetSpace ~
37426  70 ;\InsetSpace ~
37427  hob.c 10 
37428 \newline
37429 001B E5*01\InsetSpace ~
37430 \InsetSpace ~
37431 \InsetSpace ~
37432 \InsetSpace ~
37433 \InsetSpace ~
37434 \InsetSpace ~
37435 \InsetSpace ~
37436 \InsetSpace ~
37437 \InsetSpace ~
37438 \InsetSpace ~
37439 \InsetSpace ~
37440 \InsetSpace ~
37441 \InsetSpace ~
37442 \InsetSpace ~
37443 \InsetSpace ~
37444  71\InsetSpace ~
37445 \InsetSpace ~
37446 \InsetSpace ~
37447 \InsetSpace ~
37448 \InsetSpace ~
37449 \InsetSpace ~
37450 \InsetSpace ~
37451 \InsetSpace ~
37452  mov\InsetSpace ~
37453 \InsetSpace ~
37454  a,(_gint + 1) 
37455 \newline
37456 001D
37457  03\InsetSpace ~
37458 \InsetSpace ~
37459 \InsetSpace ~
37460 \InsetSpace ~
37461 \InsetSpace ~
37462 \InsetSpace ~
37463 \InsetSpace ~
37464 \InsetSpace ~
37465 \InsetSpace ~
37466 \InsetSpace ~
37467 \InsetSpace ~
37468 \InsetSpace ~
37469 \InsetSpace ~
37470 \InsetSpace ~
37471 \InsetSpace ~
37472 \InsetSpace ~
37473 \InsetSpace ~
37474 \InsetSpace ~
37475  72\InsetSpace ~
37476 \InsetSpace ~
37477 \InsetSpace ~
37478 \InsetSpace ~
37479 \InsetSpace ~
37480 \InsetSpace ~
37481 \InsetSpace ~
37482 \InsetSpace ~
37483  rr\InsetSpace ~
37484 \InsetSpace ~
37485 \InsetSpace ~
37486  a 
37487 \newline
37488 001E 54 01\InsetSpace ~
37489 \InsetSpace ~
37490 \InsetSpace ~
37491 \InsetSpace ~
37492 \InsetSpace ~
37493 \InsetSpace ~
37494 \InsetSpace ~
37495 \InsetSpace ~
37496 \InsetSpace ~
37497 \InsetSpace ~
37498 \InsetSpace ~
37499 \InsetSpace ~
37500 \InsetSpace ~
37501 \InsetSpace ~
37502 \InsetSpace ~
37503  73\InsetSpace ~
37504 \InsetSpace ~
37505 \InsetSpace ~
37506 \InsetSpace ~
37507 \InsetSpace ~
37508 \InsetSpace ~
37509 \InsetSpace ~
37510 \InsetSpace ~
37511  anl\InsetSpace ~
37512 \InsetSpace ~
37513  a,#0x01 
37514 \newline
37515 0020 F5*03\InsetSpace ~
37516 \InsetSpace ~
37517 \InsetSpace ~
37518 \InsetSpace ~
37519 \InsetSpace ~
37520 \InsetSpace ~
37521 \InsetSpace ~
37522 \InsetSpace ~
37523 \InsetSpace ~
37524 \InsetSpace ~
37525 \InsetSpace ~
37526 \InsetSpace ~
37527 \InsetSpace ~
37528 \InsetSpace ~
37529 \InsetSpace ~
37530  74\InsetSpace ~
37531 \InsetSpace ~
37532 \InsetSpace ~
37533 \InsetSpace ~
37534 \InsetSpace ~
37535 \InsetSpace ~
37536 \InsetSpace ~
37537 \InsetSpace ~
37538  mov\InsetSpace ~
37539 \InsetSpace ~
37540  _foo_aob1_1_1,a
37541  
37542 \newline
37543 \InsetSpace ~
37544 \InsetSpace ~
37545 \InsetSpace ~
37546 \InsetSpace ~
37547 \InsetSpace ~
37548 \InsetSpace ~
37549 \InsetSpace ~
37550 \InsetSpace ~
37551 \InsetSpace ~
37552 \InsetSpace ~
37553 \InsetSpace ~
37554 \InsetSpace ~
37555 \InsetSpace ~
37556 \InsetSpace ~
37557 \InsetSpace ~
37558 \InsetSpace ~
37559 \InsetSpace ~
37560 \InsetSpace ~
37561 \InsetSpace ~
37562 \InsetSpace ~
37563 \InsetSpace ~
37564 \InsetSpace ~
37565 \InsetSpace ~
37566 \InsetSpace ~
37567 \InsetSpace ~
37568  75 ;\InsetSpace ~
37569  hob.c 11 
37570 \newline
37571 0022 E5*01\InsetSpace ~
37572 \InsetSpace ~
37573 \InsetSpace ~
37574 \InsetSpace ~
37575 \InsetSpace ~
37576 \InsetSpace ~
37577 \InsetSpace ~
37578 \InsetSpace ~
37579 \InsetSpace ~
37580 \InsetSpace ~
37581 \InsetSpace ~
37582 \InsetSpace ~
37583 \InsetSpace ~
37584 \InsetSpace ~
37585 \InsetSpace ~
37586  76\InsetSpace ~
37587 \InsetSpace ~
37588 \InsetSpace ~
37589 \InsetSpace ~
37590 \InsetSpace ~
37591 \InsetSpace ~
37592 \InsetSpace ~
37593 \InsetSpace ~
37594  mov\InsetSpace ~
37595 \InsetSpace ~
37596  a,(_gint + 1) 
37597 \newline
37598 0024 13\InsetSpace ~
37599 \InsetSpace ~
37600 \InsetSpace ~
37601 \InsetSpace ~
37602 \InsetSpace ~
37603 \InsetSpace ~
37604 \InsetSpace ~
37605 \InsetSpace ~
37606 \InsetSpace ~
37607 \InsetSpace ~
37608 \InsetSpace ~
37609 \InsetSpace ~
37610 \InsetSpace ~
37611 \InsetSpace ~
37612 \InsetSpace ~
37613 \InsetSpace ~
37614 \InsetSpace ~
37615 \InsetSpace ~
37616  77\InsetSpace ~
37617 \InsetSpace ~
37618 \InsetSpace ~
37619 \InsetSpace ~
37620 \InsetSpace ~
37621 \InsetSpace ~
37622 \InsetSpace ~
37623 \InsetSpace ~
37624  rrc\InsetSpace ~
37625 \InsetSpace ~
37626  a 
37627 \newline
37628 0025 92*02\InsetSpace ~
37629 \InsetSpace ~
37630 \InsetSpace ~
37631 \InsetSpace ~
37632 \InsetSpace ~
37633 \InsetSpace ~
37634 \InsetSpace ~
37635 \InsetSpace ~
37636 \InsetSpace ~
37637 \InsetSpace ~
37638 \InsetSpace ~
37639 \InsetSpace ~
37640 \InsetSpace ~
37641 \InsetSpace ~
37642 \InsetSpace ~
37643
37644  78\InsetSpace ~
37645 \InsetSpace ~
37646 \InsetSpace ~
37647 \InsetSpace ~
37648 \InsetSpace ~
37649 \InsetSpace ~
37650 \InsetSpace ~
37651 \InsetSpace ~
37652  mov\InsetSpace ~
37653 \InsetSpace ~
37654  _foo_aob2_1_1,c 
37655 \newline
37656 \InsetSpace ~
37657 \InsetSpace ~
37658 \InsetSpace ~
37659 \InsetSpace ~
37660 \InsetSpace ~
37661 \InsetSpace ~
37662 \InsetSpace ~
37663 \InsetSpace ~
37664 \InsetSpace ~
37665 \InsetSpace ~
37666 \InsetSpace ~
37667 \InsetSpace ~
37668 \InsetSpace ~
37669 \InsetSpace ~
37670 \InsetSpace ~
37671 \InsetSpace ~
37672 \InsetSpace ~
37673 \InsetSpace ~
37674 \InsetSpace ~
37675 \InsetSpace ~
37676 \InsetSpace ~
37677 \InsetSpace ~
37678 \InsetSpace ~
37679 \InsetSpace ~
37680 \InsetSpace ~
37681  79 ;\InsetSpace ~
37682  hob.c 12 
37683 \newline
37684 0027 E5*01\InsetSpace ~
37685 \InsetSpace ~
37686 \InsetSpace ~
37687 \InsetSpace ~
37688 \InsetSpace ~
37689 \InsetSpace ~
37690 \InsetSpace ~
37691 \InsetSpace ~
37692 \InsetSpace ~
37693 \InsetSpace ~
37694 \InsetSpace ~
37695 \InsetSpace ~
37696 \InsetSpace ~
37697 \InsetSpace ~
37698 \InsetSpace ~
37699  80\InsetSpace ~
37700 \InsetSpace ~
37701 \InsetSpace ~
37702 \InsetSpace ~
37703 \InsetSpace ~
37704 \InsetSpace ~
37705 \InsetSpace ~
37706 \InsetSpace ~
37707  mov\InsetSpace ~
37708 \InsetSpace ~
37709  a,(_gint + 1) 
37710 \newline
37711 0029
37712  A2 E3\InsetSpace ~
37713 \InsetSpace ~
37714 \InsetSpace ~
37715 \InsetSpace ~
37716 \InsetSpace ~
37717 \InsetSpace ~
37718 \InsetSpace ~
37719 \InsetSpace ~
37720 \InsetSpace ~
37721 \InsetSpace ~
37722 \InsetSpace ~
37723 \InsetSpace ~
37724 \InsetSpace ~
37725 \InsetSpace ~
37726 \InsetSpace ~
37727  81\InsetSpace ~
37728 \InsetSpace ~
37729 \InsetSpace ~
37730 \InsetSpace ~
37731 \InsetSpace ~
37732 \InsetSpace ~
37733 \InsetSpace ~
37734 \InsetSpace ~
37735  mov\InsetSpace ~
37736 \InsetSpace ~
37737  c,acc[3] 
37738 \newline
37739 002B 92*03\InsetSpace ~
37740 \InsetSpace ~
37741 \InsetSpace ~
37742 \InsetSpace ~
37743 \InsetSpace ~
37744 \InsetSpace ~
37745 \InsetSpace ~
37746 \InsetSpace ~
37747 \InsetSpace ~
37748 \InsetSpace ~
37749 \InsetSpace ~
37750 \InsetSpace ~
37751 \InsetSpace ~
37752 \InsetSpace ~
37753 \InsetSpace ~
37754  82\InsetSpace ~
37755 \InsetSpace ~
37756 \InsetSpace ~
37757 \InsetSpace ~
37758 \InsetSpace ~
37759 \InsetSpace ~
37760 \InsetSpace ~
37761 \InsetSpace ~
37762  mov\InsetSpace ~
37763 \InsetSpace ~
37764  _foo_aob3_1_1,c 
37765 \end_layout
37766
37767 \begin_layout Standard
37768 Other variations of these cases however will 
37769 \emph on
37770 not
37771 \emph default
37772  be recognized.
37773  They are standard C expressions, so I heartily recommend these be the only
37774  way to get the highest order bit, (it is portable).
37775  Of course it will be recognized even if it is embedded in other expressions,
37776  e.g.:
37777 \end_layout
37778
37779 \begin_layout Verse
37780
37781 \family typewriter
37782 xyz = gint + ((gint >> 15) & 1);
37783 \end_layout
37784
37785 \begin_layout Standard
37786 will still be recognized.
37787 \end_layout
37788
37789 \begin_layout Subsection
37790 Higher Order Byte
37791 \begin_inset LatexCommand index
37792 name "Higher Order Byte"
37793
37794 \end_inset
37795
37796  / Higher Order Word
37797 \begin_inset LatexCommand index
37798 name "Higher Order Word"
37799
37800 \end_inset
37801
37802
37803 \end_layout
37804
37805 \begin_layout Standard
37806 It is also frequently required to obtain a higher order byte or word of
37807  a larger integral type (long, int or short types).
37808  SDCC recognizes the following expressions to yield the higher order byte
37809  or word and generates optimized code for it, e.g.:
37810 \end_layout
37811
37812 \begin_layout Verse
37813
37814 \family typewriter
37815 unsigned int gint; 
37816 \newline
37817 unsigned long int glong; 
37818 \newline
37819
37820 \newline
37821 foo () { 
37822 \newline
37823 \InsetSpace ~
37824 \InsetSpace ~
37825 unsigned char hob1,
37826  hob2; 
37827 \newline
37828 \InsetSpace ~
37829 \InsetSpace ~
37830 unsigned int how1, how2; 
37831 \newline
37832 \InsetSpace ~
37833 \InsetSpace ~
37834 ...
37835  
37836 \newline
37837 \InsetSpace ~
37838 \InsetSpace ~
37839 hob1 = (gint >> 8) & 0xFF; 
37840 \newline
37841 \InsetSpace ~
37842 \InsetSpace ~
37843 hob2 = glong >> 24; 
37844 \newline
37845 \InsetSpace ~
37846 \InsetSpace ~
37847 how1 = (glong >> 16) & 0xFFFF;
37848  
37849 \newline
37850 \InsetSpace ~
37851 \InsetSpace ~
37852 how2 = glong >> 8; 
37853 \newline
37854 \InsetSpace ~
37855 \InsetSpace ~
37856 ..
37857  
37858 \newline
37859 }
37860 \end_layout
37861
37862 \begin_layout Standard
37863 will generate the following code:
37864 \end_layout
37865
37866 \begin_layout Verse
37867
37868 \family typewriter
37869 \InsetSpace ~
37870 \InsetSpace ~
37871 \InsetSpace ~
37872 \InsetSpace ~
37873 \InsetSpace ~
37874 \InsetSpace ~
37875 \InsetSpace ~
37876 \InsetSpace ~
37877 \InsetSpace ~
37878 \InsetSpace ~
37879 \InsetSpace ~
37880 \InsetSpace ~
37881 \InsetSpace ~
37882 \InsetSpace ~
37883 \InsetSpace ~
37884 \InsetSpace ~
37885 \InsetSpace ~
37886 \InsetSpace ~
37887 \InsetSpace ~
37888 \InsetSpace ~
37889 \InsetSpace ~
37890 \InsetSpace ~
37891 \InsetSpace ~
37892 \InsetSpace ~
37893 \InsetSpace ~
37894  91 ;\InsetSpace ~
37895  hob.c 15 
37896 \newline
37897 0037 85*01*06\InsetSpace ~
37898 \InsetSpace ~
37899 \InsetSpace ~
37900 \InsetSpace ~
37901 \InsetSpace ~
37902 \InsetSpace ~
37903 \InsetSpace ~
37904 \InsetSpace ~
37905 \InsetSpace ~
37906 \InsetSpace ~
37907 \InsetSpace ~
37908 \InsetSpace ~
37909  92\InsetSpace ~
37910 \InsetSpace ~
37911 \InsetSpace ~
37912 \InsetSpace ~
37913 \InsetSpace ~
37914 \InsetSpace ~
37915 \InsetSpace ~
37916 \InsetSpace ~
37917  mov\InsetSpace ~
37918 \InsetSpace ~
37919  _foo_hob1_1_1,(_gint + 1) 
37920 \newline
37921 \InsetSpace ~
37922 \InsetSpace ~
37923 \InsetSpace ~
37924 \InsetSpace ~
37925 \InsetSpace ~
37926 \InsetSpace ~
37927 \InsetSpace ~
37928 \InsetSpace ~
37929 \InsetSpace ~
37930 \InsetSpace ~
37931 \InsetSpace ~
37932 \InsetSpace ~
37933 \InsetSpace ~
37934 \InsetSpace ~
37935 \InsetSpace ~
37936 \InsetSpace ~
37937 \InsetSpace ~
37938 \InsetSpace ~
37939 \InsetSpace ~
37940 \InsetSpace ~
37941 \InsetSpace ~
37942 \InsetSpace ~
37943 \InsetSpace ~
37944 \InsetSpace ~
37945 \InsetSpace ~
37946  93 ;\InsetSpace ~
37947  hob.c
37948  16 
37949 \newline
37950 003A 85*05*07\InsetSpace ~
37951 \InsetSpace ~
37952 \InsetSpace ~
37953 \InsetSpace ~
37954 \InsetSpace ~
37955 \InsetSpace ~
37956 \InsetSpace ~
37957 \InsetSpace ~
37958 \InsetSpace ~
37959 \InsetSpace ~
37960 \InsetSpace ~
37961 \InsetSpace ~
37962  94\InsetSpace ~
37963 \InsetSpace ~
37964 \InsetSpace ~
37965 \InsetSpace ~
37966 \InsetSpace ~
37967 \InsetSpace ~
37968 \InsetSpace ~
37969 \InsetSpace ~
37970  mov\InsetSpace ~
37971 \InsetSpace ~
37972  _foo_hob2_1_1,(_glong + 3) 
37973 \newline
37974 \InsetSpace ~
37975 \InsetSpace ~
37976 \InsetSpace ~
37977 \InsetSpace ~
37978 \InsetSpace ~
37979 \InsetSpace ~
37980 \InsetSpace ~
37981 \InsetSpace ~
37982 \InsetSpace ~
37983 \InsetSpace ~
37984 \InsetSpace ~
37985 \InsetSpace ~
37986 \InsetSpace ~
37987 \InsetSpace ~
37988 \InsetSpace ~
37989 \InsetSpace ~
37990 \InsetSpace ~
37991 \InsetSpace ~
37992 \InsetSpace ~
37993 \InsetSpace ~
37994 \InsetSpace ~
37995 \InsetSpace ~
37996 \InsetSpace ~
37997 \InsetSpace ~
37998 \InsetSpace ~
37999  95 ;\InsetSpace ~
38000  hob.c 17 
38001 \newline
38002 003D 85*04*08\InsetSpace ~
38003 \InsetSpace ~
38004 \InsetSpace ~
38005 \InsetSpace ~
38006 \InsetSpace ~
38007 \InsetSpace ~
38008 \InsetSpace ~
38009 \InsetSpace ~
38010 \InsetSpace ~
38011 \InsetSpace ~
38012 \InsetSpace ~
38013 \InsetSpace ~
38014
38015  96\InsetSpace ~
38016 \InsetSpace ~
38017 \InsetSpace ~
38018 \InsetSpace ~
38019 \InsetSpace ~
38020 \InsetSpace ~
38021 \InsetSpace ~
38022 \InsetSpace ~
38023  mov\InsetSpace ~
38024 \InsetSpace ~
38025  _foo_how1_1_1,(_glong + 2) 
38026 \newline
38027 0040 85*05*09\InsetSpace ~
38028 \InsetSpace ~
38029 \InsetSpace ~
38030 \InsetSpace ~
38031 \InsetSpace ~
38032 \InsetSpace ~
38033 \InsetSpace ~
38034 \InsetSpace ~
38035 \InsetSpace ~
38036 \InsetSpace ~
38037 \InsetSpace ~
38038 \InsetSpace ~
38039  97\InsetSpace ~
38040 \InsetSpace ~
38041 \InsetSpace ~
38042 \InsetSpace ~
38043 \InsetSpace ~
38044 \InsetSpace ~
38045 \InsetSpace ~
38046 \InsetSpace ~
38047  mov\InsetSpace ~
38048 \InsetSpace ~
38049  (_foo_how1_1_1 +
38050  1),(_glong + 3) 
38051 \newline
38052 0043 85*03*0A\InsetSpace ~
38053 \InsetSpace ~
38054 \InsetSpace ~
38055 \InsetSpace ~
38056 \InsetSpace ~
38057 \InsetSpace ~
38058 \InsetSpace ~
38059 \InsetSpace ~
38060 \InsetSpace ~
38061 \InsetSpace ~
38062 \InsetSpace ~
38063 \InsetSpace ~
38064  98\InsetSpace ~
38065 \InsetSpace ~
38066 \InsetSpace ~
38067 \InsetSpace ~
38068 \InsetSpace ~
38069 \InsetSpace ~
38070 \InsetSpace ~
38071 \InsetSpace ~
38072  mov\InsetSpace ~
38073 \InsetSpace ~
38074  _foo_how2_1_1,(_glong + 1) 
38075 \newline
38076 0046 85*04*0B\InsetSpace ~
38077 \InsetSpace ~
38078 \InsetSpace ~
38079 \InsetSpace ~
38080 \InsetSpace ~
38081 \InsetSpace ~
38082 \InsetSpace ~
38083 \InsetSpace ~
38084 \InsetSpace ~
38085 \InsetSpace ~
38086 \InsetSpace ~
38087 \InsetSpace ~
38088
38089  99\InsetSpace ~
38090 \InsetSpace ~
38091 \InsetSpace ~
38092 \InsetSpace ~
38093 \InsetSpace ~
38094 \InsetSpace ~
38095 \InsetSpace ~
38096 \InsetSpace ~
38097  mov\InsetSpace ~
38098 \InsetSpace ~
38099  (_foo_how2_1_1 + 1),(_glong + 2) 
38100 \end_layout
38101
38102 \begin_layout Standard
38103 Again, variations of these cases may 
38104 \emph on
38105 not
38106 \emph default
38107  be recognized.
38108  They are standard C expressions, so I heartily recommend these be the only
38109  way to get the higher order byte/word, (it is portable).
38110  Of course it will be recognized even if it is embedded in other expressions,
38111  e.g.:
38112 \end_layout
38113
38114 \begin_layout Verse
38115
38116 \family typewriter
38117 xyz = gint + ((gint >> 8) & 0xFF);
38118 \end_layout
38119
38120 \begin_layout Standard
38121 will still be recognized.
38122 \end_layout
38123
38124 \begin_layout Subsection
38125 Peephole Optimizer
38126 \begin_inset LatexCommand label
38127 name "sub:Peephole-Optimizer"
38128
38129 \end_inset
38130
38131
38132 \begin_inset LatexCommand index
38133 name "Peephole optimizer"
38134
38135 \end_inset
38136
38137
38138 \end_layout
38139
38140 \begin_layout Standard
38141 The compiler uses a rule based, pattern matching and re-writing mechanism
38142  for peep-hole optimization.
38143  It is inspired by 
38144 \emph on
38145 copt
38146 \emph default
38147  a peep-hole optimizer by Christopher W.
38148  Fraser (cwfraser\InsetSpace ~
38149 @\InsetSpace ~
38150 microsoft.com).
38151  A default set of rules are compiled into the compiler, additional rules
38152  may be added with the 
38153 \emph on
38154 -
38155 \begin_inset ERT
38156 status collapsed
38157
38158 \begin_layout Standard
38159
38160
38161 \backslash
38162 /
38163 \end_layout
38164
38165 \end_inset
38166
38167 -peep-file
38168 \begin_inset LatexCommand index
38169 name "-\\/-peep-file"
38170
38171 \end_inset
38172
38173  <filename>
38174 \emph default
38175  option.
38176  The rule language is best illustrated with examples.
38177 \end_layout
38178
38179 \begin_layout Verse
38180
38181 \family typewriter
38182 replace { 
38183 \newline
38184 \InsetSpace ~
38185 \InsetSpace ~
38186 mov %1,a 
38187 \newline
38188 \InsetSpace ~
38189 \InsetSpace ~
38190 mov a,%1
38191 \newline
38192 } by {
38193 \newline
38194 \InsetSpace ~
38195 \InsetSpace ~
38196 mov %1,a
38197 \newline
38198 }
38199 \end_layout
38200
38201 \begin_layout Standard
38202 The above rule will change the following assembly
38203 \begin_inset LatexCommand index
38204 name "Assembler routines"
38205
38206 \end_inset
38207
38208  sequence:
38209 \end_layout
38210
38211 \begin_layout Verse
38212
38213 \family typewriter
38214 mov r1,a 
38215 \newline
38216 mov a,r1
38217 \end_layout
38218
38219 \begin_layout Standard
38220 to
38221 \end_layout
38222
38223 \begin_layout Verse
38224
38225 \family typewriter
38226 mov r1,a
38227 \end_layout
38228
38229 \begin_layout Standard
38230 Note: All occurrences of a 
38231 \emph on
38232 %n
38233 \emph default
38234  (pattern variable) must denote the same string.
38235  With the above rule, the assembly sequence:
38236 \end_layout
38237
38238 \begin_layout Verse
38239
38240 \family typewriter
38241 mov r1,a 
38242 \newline
38243 mov a,r2
38244 \end_layout
38245
38246 \begin_layout Standard
38247 will remain unmodified.
38248 \newline
38249
38250 \newline
38251 Other special case optimizations may be added by the
38252  user (via 
38253 \emph on
38254 -
38255 \begin_inset ERT
38256 status collapsed
38257
38258 \begin_layout Standard
38259
38260
38261 \backslash
38262 /
38263 \end_layout
38264
38265 \end_inset
38266
38267 -peep-file option
38268 \emph default
38269 ).
38270  E.g.
38271  some variants of the 8051 MCU
38272 \begin_inset LatexCommand index
38273 name "MCS51 variants"
38274
38275 \end_inset
38276
38277  allow only 
38278 \family typewriter
38279 ajmp
38280 \family default
38281  and 
38282 \family typewriter
38283 acall
38284 \family default
38285 .
38286  The following two rules will change all 
38287 \family typewriter
38288 ljmp
38289 \family default
38290  and 
38291 \family typewriter
38292 lcall
38293 \family default
38294  to 
38295 \family typewriter
38296 ajmp
38297 \family default
38298  and 
38299 \family typewriter
38300 acall
38301 \end_layout
38302
38303 \begin_layout Verse
38304
38305 \family typewriter
38306 replace { lcall %1 } by { acall %1 } 
38307 \newline
38308 replace { ljmp %1 } by { ajmp %1 }
38309 \end_layout
38310
38311 \begin_layout Standard
38312 (NOTE: from version 2.7.3 on, you can use option -
38313 \emph on
38314
38315 \begin_inset ERT
38316 status collapsed
38317
38318 \begin_layout Standard
38319
38320
38321 \backslash
38322 /
38323 \end_layout
38324
38325 \end_inset
38326
38327
38328 \emph default
38329 -acall-ajmp
38330 \begin_inset LatexCommand index
38331 name "-\\/-acall-ajmp"
38332
38333 \end_inset
38334
38335 , which also takes care of aligning the interrupt vectors properly.)
38336 \newline
38337
38338 \end_layout
38339
38340 \begin_layout Standard
38341 The 
38342 \emph on
38343 inline-assembler code
38344 \emph default
38345  is also passed through the peep hole optimizer, thus the peephole optimizer
38346  can also be used as an assembly level macro expander.
38347  The rules themselves are MCU dependent whereas the rule language infra-structur
38348 e is MCU independent.
38349  Peephole optimization rules for other MCU can be easily programmed using
38350  the rule language.
38351 \newline
38352
38353 \newline
38354 The syntax for a rule is as follows:
38355 \end_layout
38356
38357 \begin_layout Verse
38358
38359 \family typewriter
38360 rule := replace [ restart ] '{' <assembly sequence> '
38361 \backslash
38362 n' 
38363 \newline
38364 \InsetSpace ~
38365  \InsetSpace ~
38366  \InsetSpace ~
38367  \InsetSpace ~
38368  \InsetSpace ~
38369  \InsetSpace ~
38370  \InsetSpace ~
38371  \InsetSpace ~
38372  \InsetSpace ~
38373  \InsetSpace ~
38374  \InsetSpace ~
38375  \InsetSpace ~
38376  \InsetSpace ~
38377  \InsetSpace ~
38378  '}' by '{' '
38379 \backslash
38380 n' 
38381 \newline
38382 \InsetSpace ~
38383  \InsetSpace ~
38384  \InsetSpace ~
38385  \InsetSpace ~
38386  \InsetSpace ~
38387  \InsetSpace ~
38388  \InsetSpace ~
38389  \InsetSpace ~
38390  \InsetSpace ~
38391  \InsetSpace ~
38392  \InsetSpace ~
38393  \InsetSpace ~
38394  \InsetSpace ~
38395  \InsetSpace ~
38396  \InsetSpace ~
38397  \InsetSpace ~
38398  <assembly sequence> '
38399 \backslash
38400 n' 
38401 \newline
38402 \InsetSpace ~
38403  \InsetSpace ~
38404  \InsetSpace ~
38405  \InsetSpace ~
38406  \InsetSpace ~
38407  \InsetSpace ~
38408  \InsetSpace ~
38409  \InsetSpace ~
38410  \InsetSpace ~
38411  \InsetSpace ~
38412  \InsetSpace ~
38413  \InsetSpace ~
38414  \InsetSpace ~
38415  \InsetSpace ~
38416  '}' [if <functionName> ] '
38417 \backslash
38418 n' 
38419 \end_layout
38420
38421 \begin_layout Standard
38422 <assembly sequence> := assembly instruction (each instruction including
38423  labels must be on a separate line).
38424 \newline
38425
38426 \newline
38427 The optimizer will apply to the rules
38428  one by one from the top in the sequence of their appearance, it will terminate
38429  when all rules are exhausted.
38430  If the 'restart' option is specified, then the optimizer will start matching
38431  the rules again from the top, this option for a rule is expensive (performance)
38432 , it is intended to be used in situations where a transformation will trigger
38433  the same rule again.
38434  An example of this (not a good one, it has side effects) is the following
38435  rule:
38436 \end_layout
38437
38438 \begin_layout Verse
38439
38440 \family typewriter
38441 replace restart { 
38442 \newline
38443 \InsetSpace ~
38444 \InsetSpace ~
38445 pop %1 
38446 \newline
38447 \InsetSpace ~
38448 \InsetSpace ~
38449 push %1 } by { 
38450 \newline
38451 \InsetSpace ~
38452 \InsetSpace ~
38453 ; nop 
38454 \newline
38455 }
38456 \end_layout
38457
38458 \begin_layout Standard
38459 Note that the replace pattern cannot be a blank, but can be a comment line.
38460  Without the 'restart' option only the innermost 'pop' 'push' pair would
38461  be eliminated, i.e.:
38462 \end_layout
38463
38464 \begin_layout Verse
38465
38466 \family typewriter
38467 pop ar1 
38468 \newline
38469 pop ar2 
38470 \newline
38471 push ar2 
38472 \newline
38473 push ar1
38474 \end_layout
38475
38476 \begin_layout Standard
38477 would result in:
38478 \end_layout
38479
38480 \begin_layout Verse
38481
38482 \family typewriter
38483 pop ar1 
38484 \newline
38485 ; nop 
38486 \newline
38487 push ar1
38488 \end_layout
38489
38490 \begin_layout Standard
38491
38492 \emph on
38493 with
38494 \emph default
38495  the restart option the rule will be applied again to the resulting code
38496  and then all the pop-push pairs will be eliminated to yield:
38497 \end_layout
38498
38499 \begin_layout Verse
38500
38501 \family typewriter
38502 ; nop 
38503 \newline
38504 ; nop
38505 \end_layout
38506
38507 \begin_layout Standard
38508 A conditional function can be attached to a rule.
38509  Attaching rules are somewhat more involved, let me illustrate this with
38510  an example.
38511 \end_layout
38512
38513 \begin_layout Verse
38514
38515 \family typewriter
38516 replace { 
38517 \newline
38518 \InsetSpace ~
38519  \InsetSpace ~
38520  \InsetSpace ~
38521 ljmp %5 
38522 \newline
38523 %2:
38524 \newline
38525 } by { 
38526 \newline
38527 \InsetSpace ~
38528  \InsetSpace ~
38529  \InsetSpace ~
38530 sjmp %5 
38531 \newline
38532 %2:
38533 \newline
38534 } if labelInRange
38535 \end_layout
38536
38537 \begin_layout Standard
38538 The optimizer does a look-up of a function name table defined in function
38539  
38540 \emph on
38541 callFuncByName
38542 \emph default
38543  in the source file SDCCpeeph.c, with the name 
38544 \emph on
38545 labelInRange
38546 \emph default
38547 .
38548  If it finds a corresponding entry the function is called.
38549  Note there can be no parameters specified for these functions, in this
38550  case the use of 
38551 \emph on
38552 %5
38553 \emph default
38554  is crucial, since the function 
38555 \emph on
38556 labelInRange
38557 \emph default
38558  expects to find the label in that particular variable (the hash table containin
38559 g the variable bindings is passed as a parameter).
38560  If you want to code more such functions, take a close look at the function
38561  labelInRange and the calling mechanism in source file SDCCpeeph.c.
38562  Currently implemented are 
38563 \emph on
38564 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
38565  24bitMode, portIsDS390, 24bitModeAndPortDS390
38566 \emph default
38567  and 
38568 \emph on
38569 notVolatile
38570 \emph default
38571 .
38572 \end_layout
38573
38574 \begin_layout Standard
38575 I know this whole thing is a little kludgey, but maybe some day we will
38576  have some better means.
38577  If you are looking at this file, you will see the default rules that are
38578  compiled into the compiler, you can add your own rules in the default set
38579  there if you get tired of specifying the -
38580 \begin_inset ERT
38581 status collapsed
38582
38583 \begin_layout Standard
38584
38585
38586 \backslash
38587 /
38588 \end_layout
38589
38590 \end_inset
38591
38592 -peep-file option.
38593 \end_layout
38594
38595 \begin_layout Section
38596 ANSI-Compliance
38597 \begin_inset LatexCommand index
38598 name "ANSI-compliance"
38599
38600 \end_inset
38601
38602
38603 \begin_inset LatexCommand label
38604 name "sub:ANSI-Compliance"
38605
38606 \end_inset
38607
38608
38609 \end_layout
38610
38611 \begin_layout Standard
38612 The latest publicly available version of the standard 
38613 \emph on
38614 ISO/IEC 9899 - Programming languages - C
38615 \emph default
38616  should be available at: 
38617 \begin_inset LatexCommand url
38618 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
38619
38620 \end_inset
38621
38622 .
38623 \newline
38624
38625 \end_layout
38626
38627 \begin_layout Standard
38628 Deviations from the compliance:
38629 \end_layout
38630
38631 \begin_layout Itemize
38632 functions are not reentrant
38633 \begin_inset LatexCommand index
38634 name "reentrant"
38635
38636 \end_inset
38637
38638  unless explicitly declared as such or the 
38639 \series bold
38640 -
38641 \begin_inset ERT
38642 status collapsed
38643
38644 \begin_layout Standard
38645
38646
38647 \backslash
38648 /
38649 \end_layout
38650
38651 \end_inset
38652
38653 -stack-auto
38654 \begin_inset LatexCommand index
38655 name "-\\/-stack-auto"
38656
38657 \end_inset
38658
38659
38660 \series default
38661  command line option is specified.
38662 \end_layout
38663
38664 \begin_layout Itemize
38665 structures
38666 \begin_inset LatexCommand index
38667 name "struct"
38668
38669 \end_inset
38670
38671  and unions
38672 \begin_inset LatexCommand index
38673 name "union"
38674
38675 \end_inset
38676
38677  cannot be assigned values directly, cannot be passed as function parameters
38678  or assigned to each other and cannot be a return value
38679 \begin_inset LatexCommand index
38680 name "return value"
38681
38682 \end_inset
38683
38684  from a function, e.g.:
38685 \end_layout
38686
38687 \begin_deeper
38688 \begin_layout Verse
38689
38690 \family typewriter
38691 struct s { ...
38692  }; 
38693 \newline
38694 struct s s1, s2; 
38695 \newline
38696 foo() 
38697 \newline
38698
38699 \newline
38700 \InsetSpace ~
38701 \InsetSpace ~
38702 \InsetSpace ~
38703 \InsetSpace ~
38704 ...
38705  
38706 \newline
38707 \InsetSpace ~
38708 \InsetSpace ~
38709 \InsetSpace ~
38710 \InsetSpace ~
38711 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
38712 \newline
38713 \InsetSpace ~
38714 \InsetSpace ~
38715 \InsetSpace ~
38716 \InsetSpace ~
38717 ...
38718  
38719 \newline
38720 }
38721 \newline
38722
38723 \series bold
38724 struct
38725 \family default
38726 \series default
38727  
38728 \family typewriter
38729 s foo1 (
38730 \series bold
38731 struct
38732 \family default
38733 \series default
38734  
38735 \family typewriter
38736 s parms) /* invalid in SDCC although allowed in ANSI */
38737 \newline
38738
38739 \newline
38740 \InsetSpace ~
38741 \InsetSpace ~
38742 \InsetSpace ~
38743 \InsetSpace ~
38744 struct s rets;
38745  
38746 \newline
38747 \InsetSpace ~
38748 \InsetSpace ~
38749 \InsetSpace ~
38750 \InsetSpace ~
38751 ...
38752  
38753 \newline
38754 \InsetSpace ~
38755 \InsetSpace ~
38756 \InsetSpace ~
38757 \InsetSpace ~
38758 return rets; /* is invalid in SDCC although allowed in ANSI */ 
38759 \newline
38760 }
38761 \end_layout
38762
38763 \end_deeper
38764 \begin_layout Itemize
38765 initialization of structure arrays must be fully braced.
38766 \end_layout
38767
38768 \begin_deeper
38769 \begin_layout Verse
38770
38771 \family typewriter
38772 struct s { char x } a[] = {1, 2};\InsetSpace ~
38773 \InsetSpace ~
38774 \InsetSpace ~
38775 \InsetSpace ~
38776 \InsetSpace ~
38777 /* invalid in SDCC */
38778 \newline
38779 struct s { char x
38780  } a[] = {{1}, {2}}; /* OK */
38781 \end_layout
38782
38783 \end_deeper
38784 \begin_layout Itemize
38785 'long long
38786 \begin_inset LatexCommand index
38787 name "long long (not supported)"
38788
38789 \end_inset
38790
38791 ' (64 bit integers
38792 \begin_inset LatexCommand index
38793 name "int (64 bit) (not supported)"
38794
38795 \end_inset
38796
38797 ) not supported.
38798 \end_layout
38799
38800 \begin_layout Itemize
38801 'double
38802 \begin_inset LatexCommand index
38803 name "double (not supported)"
38804
38805 \end_inset
38806
38807 ' precision floating point 
38808 \begin_inset LatexCommand index
38809 name "Floating point support"
38810
38811 \end_inset
38812
38813 not supported.
38814 \end_layout
38815
38816 \begin_layout Itemize
38817 Old K&R style
38818 \begin_inset LatexCommand index
38819 name "K\\&R style"
38820
38821 \end_inset
38822
38823  function declarations are NOT allowed.
38824 \end_layout
38825
38826 \begin_deeper
38827 \begin_layout Verse
38828
38829 \family typewriter
38830 foo(i,j) /* this old style of function declarations */ 
38831 \newline
38832 int i,j; /* is valid
38833  in ANSI but not valid in SDCC */ 
38834 \newline
38835
38836 \newline
38837 \InsetSpace ~
38838 \InsetSpace ~
38839 \InsetSpace ~
38840 \InsetSpace ~
38841 ...
38842  
38843 \newline
38844 }
38845 \end_layout
38846
38847 \end_deeper
38848 \begin_layout Itemize
38849 Most enhancements in C99 are not supported, e.g.:
38850 \end_layout
38851
38852 \begin_deeper
38853 \begin_layout Verse
38854
38855 \family typewriter
38856 for (
38857 \series bold
38858 int
38859 \family default
38860 \series default
38861  
38862 \family typewriter
38863 i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
38864 \end_layout
38865
38866 \end_deeper
38867 \begin_layout Itemize
38868 But some have been added recently in SDCC 2.7.0.
38869  They must be considered alpha quality however.
38870 \end_layout
38871
38872 \begin_deeper
38873 \begin_layout Verse
38874
38875 \family typewriter
38876 \series bold
38877 inline
38878 \begin_inset LatexCommand index
38879 name "inline (not supported)"
38880
38881 \end_inset
38882
38883
38884 \family default
38885 \series default
38886  
38887 \family typewriter
38888 int increment (int a) { return a+1; } /* inlines the increment without function
38889  call overhead */
38890 \newline
38891 int *
38892 \family default
38893  
38894 \family typewriter
38895 \series bold
38896 restrict
38897 \begin_inset LatexCommand index
38898 name "inline (not supported)"
38899
38900 \end_inset
38901
38902
38903 \family default
38904 \series default
38905  
38906 \family typewriter
38907 p; /* accepted but ignored */
38908 \end_layout
38909
38910 \end_deeper
38911 \begin_layout Itemize
38912 Certain words that are valid identifiers in the standard may be reserved
38913  words in SDCC unless the 
38914 \series bold
38915 -
38916 \begin_inset ERT
38917 status collapsed
38918
38919 \begin_layout Standard
38920
38921
38922 \backslash
38923 /
38924 \end_layout
38925
38926 \end_inset
38927
38928 -std-c89
38929 \begin_inset LatexCommand index
38930 name "-\\/-std-c89"
38931
38932 \end_inset
38933
38934
38935 \series default
38936  or 
38937 \series bold
38938 -
38939 \begin_inset ERT
38940 status collapsed
38941
38942 \begin_layout Standard
38943
38944
38945 \backslash
38946 /
38947 \end_layout
38948
38949 \end_inset
38950
38951 -std-c99
38952 \begin_inset LatexCommand index
38953 name "-\\/-std-c99"
38954
38955 \end_inset
38956
38957
38958 \series default
38959  command line options are used.
38960  These may include (depending on the selected processor): 'at', 'banked',
38961  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
38962 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
38963  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
38964  '_naked'.
38965  Compliant equivalents of these keywords are always available in a form
38966  that begin with two underscores
38967 \begin_inset LatexCommand index
38968 name "\\_\\_ (prefix for extended keywords)"
38969
38970 \end_inset
38971
38972 , f.e.
38973  '__data' instead of 'data'.
38974 \end_layout
38975
38976 \begin_layout Itemize
38977 Integer promotion of variable arguments is not performed if the argument
38978  is explicitly taypecasted unless the 
38979 \series bold
38980 -
38981 \begin_inset ERT
38982 status collapsed
38983
38984 \begin_layout Standard
38985
38986
38987 \backslash
38988 /
38989 \end_layout
38990
38991 \end_inset
38992
38993 -std-c89
38994 \begin_inset LatexCommand index
38995 name "-\\/-std-c89"
38996
38997 \end_inset
38998
38999
39000 \series default
39001  or 
39002 \series bold
39003 -
39004 \begin_inset ERT
39005 status collapsed
39006
39007 \begin_layout Standard
39008
39009
39010 \backslash
39011 /
39012 \end_layout
39013
39014 \end_inset
39015
39016 -std-c99
39017 \begin_inset LatexCommand index
39018 name "-\\/-std-c99"
39019
39020 \end_inset
39021
39022
39023 \series default
39024  command line options are used.
39025 \end_layout
39026
39027 \begin_deeper
39028 \begin_layout Verse
39029
39030 \family typewriter
39031 void vararg_func (char *str, ...) { str; }
39032 \newline
39033
39034 \newline
39035 void main (void)
39036 \newline
39037 {
39038 \newline
39039 \InsetSpace ~
39040 \InsetSpace ~
39041 char c = 10;
39042 \newline
39043
39044 \newline
39045 \InsetSpace ~
39046 \InsetSpace ~
39047 /* argument
39048  u is promoted to int before
39049 \newline
39050 \InsetSpace ~
39051 \InsetSpace ~
39052 \InsetSpace ~
39053 * passing to function */
39054 \newline
39055 \InsetSpace ~
39056 \InsetSpace ~
39057 vararg_func ("%c", c);
39058 \newline
39059
39060 \newline
39061 \InsetSpace ~
39062 \InsetSpace ~
39063 /*
39064  argument u is not promoted to int,
39065 \newline
39066 \InsetSpace ~
39067 \InsetSpace ~
39068 \InsetSpace ~
39069 * it is passed as char to function
39070 \newline
39071 \InsetSpace ~
39072 \InsetSpace ~
39073 \InsetSpace ~
39074 * if
39075  --std-cXX is not defined;
39076 \newline
39077 \InsetSpace ~
39078 \InsetSpace ~
39079 \InsetSpace ~
39080 * is promoted to int before passing
39081 \newline
39082 \InsetSpace ~
39083 \InsetSpace ~
39084 \InsetSpace ~
39085 * to function
39086  if --std-cXX is defined */
39087 \newline
39088 \InsetSpace ~
39089 \InsetSpace ~
39090 vararg_func ("%bc", (char)u);
39091 \newline
39092 }
39093 \end_layout
39094
39095 \end_deeper
39096 \begin_layout Section
39097 Cyclomatic Complexity
39098 \begin_inset LatexCommand index
39099 name "Cyclomatic complexity"
39100
39101 \end_inset
39102
39103
39104 \end_layout
39105
39106 \begin_layout Standard
39107 Cyclomatic complexity of a function is defined as the number of independent
39108  paths the program can take during execution of the function.
39109  This is an important number since it defines the number test cases you
39110  have to generate to validate the function.
39111  The accepted industry standard for complexity number is 10, if the cyclomatic
39112  complexity reported by SDCC exceeds 10 you should think about simplification
39113  of the function logic.
39114  Note that the complexity level is not related to the number of lines of
39115  code in a function.
39116  Large functions can have low complexity, and small functions can have large
39117  complexity levels.
39118  
39119 \newline
39120
39121 \newline
39122 SDCC uses the following formula to compute the complexity:
39123 \newline
39124
39125 \end_layout
39126
39127 \begin_layout Standard
39128 complexity = (number of edges in control flow graph) - (number of nodes
39129  in control flow graph) + 2;
39130 \newline
39131
39132 \newline
39133 Having said that the industry standard is 10,
39134  you should be aware that in some cases it be may unavoidable to have a
39135  complexity level of less than 10.
39136  For example if you have switch statement with more than 10 case labels,
39137  each case label adds one to the complexity level.
39138  The complexity level is by no means an absolute measure of the algorithmic
39139  complexity of the function, it does however provide a good starting point
39140  for which functions you might look at for further optimization.
39141 \end_layout
39142
39143 \begin_layout Section
39144 Retargetting for other Processors
39145 \end_layout
39146
39147 \begin_layout Standard
39148 The issues for retargetting the compiler are far too numerous to be covered
39149  by this document.
39150  What follows is a brief description of each of the seven phases of the
39151  compiler and its MCU dependency.
39152 \end_layout
39153
39154 \begin_layout Itemize
39155 Parsing the source and building the annotated parse tree.
39156  This phase is largely MCU independent (except for the language extensions).
39157  Syntax & semantic checks are also done in this phase, along with some initial
39158  optimizations like back patching labels and the pattern matching optimizations
39159  like bit-rotation etc.
39160 \end_layout
39161
39162 \begin_layout Itemize
39163 The second phase involves generating an intermediate code which can be easy
39164  manipulated during the later phases.
39165  This phase is entirely MCU independent.
39166  The intermediate code generation assumes the target machine has unlimited
39167  number of registers, and designates them with the name iTemp.
39168  The compiler can be made to dump a human readable form of the code generated
39169  by using the -
39170 \begin_inset ERT
39171 status collapsed
39172
39173 \begin_layout Standard
39174
39175
39176 \backslash
39177 /
39178 \end_layout
39179
39180 \end_inset
39181
39182 -dumpraw option.
39183 \end_layout
39184
39185 \begin_layout Itemize
39186 This phase does the bulk of the standard optimizations and is also MCU independe
39187 nt.
39188  This phase can be broken down into several sub-phases:
39189 \newline
39190
39191 \newline
39192 Break down intermediate
39193  code (iCode) into basic blocks.
39194 \newline
39195 Do control flow & data flow analysis on the
39196  basic blocks.
39197 \newline
39198 Do local common subexpression elimination, then global subexpressio
39199 n elimination
39200 \newline
39201 Dead code elimination
39202 \newline
39203 Loop optimizations
39204 \newline
39205 If loop optimizations
39206  caused any changes then do 'global subexpression elimination' and 'dead
39207  code elimination' again.
39208 \end_layout
39209
39210 \begin_layout Itemize
39211 This phase determines the live-ranges; by live range I mean those iTemp
39212  variables defined by the compiler that still survive after all the optimization
39213 s.
39214  Live range analysis
39215 \begin_inset LatexCommand index
39216 name "Live range analysis"
39217
39218 \end_inset
39219
39220  is essential for register allocation, since these computation determines
39221  which of these iTemps will be assigned to registers, and for how long.
39222 \end_layout
39223
39224 \begin_layout Itemize
39225 Phase five is register allocation.
39226  There are two parts to this process.
39227 \newline
39228
39229 \newline
39230 The first part I call 'register packing'
39231  (for lack of a better term).
39232  In this case several MCU specific expression folding is done to reduce
39233  register pressure.
39234 \newline
39235
39236 \newline
39237 The second part is more MCU independent and deals with
39238  allocating registers to the remaining live ranges.
39239  A lot of MCU specific code does creep into this phase because of the limited
39240  number of index registers available in the 8051.
39241 \end_layout
39242
39243 \begin_layout Itemize
39244 The Code generation phase is (unhappily), entirely MCU dependent and very
39245  little (if any at all) of this code can be reused for other MCU.
39246  However the scheme for allocating a homogenized assembler operand for each
39247  iCode operand may be reused.
39248 \end_layout
39249
39250 \begin_layout Itemize
39251 As mentioned in the optimization section the peep-hole optimizer is rule
39252  based system, which can reprogrammed for other MCUs.
39253 \end_layout
39254
39255 \begin_layout Standard
39256 More information is available on SDCC Wiki
39257 \begin_inset LatexCommand index
39258 name "wiki"
39259
39260 \end_inset
39261
39262  (preliminary link 
39263 \begin_inset LatexCommand url
39264 target "http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting"
39265
39266 \end_inset
39267
39268 ) and in the thread 
39269 \begin_inset LatexCommand url
39270 target "http://sf.net/mailarchive/message.php?msg_id=13954144"
39271
39272 \end_inset
39273
39274  .
39275 \end_layout
39276
39277 \begin_layout Chapter
39278 Compiler internals
39279 \begin_inset LatexCommand index
39280 name "Compiler internals"
39281
39282 \end_inset
39283
39284
39285 \end_layout
39286
39287 \begin_layout Section
39288 The anatomy of the compiler
39289 \begin_inset LatexCommand label
39290 name "sub:The-anatomy-of"
39291
39292 \end_inset
39293
39294
39295 \end_layout
39296
39297 \begin_layout Standard
39298
39299 \shape italic
39300 This is an excerpt from an article published in Circuit Cellar Magazine
39301  in
39302 \shape default
39303  
39304 \series bold
39305 \shape italic
39306 August 2000
39307 \series default
39308 .
39309  It's a little outdated (the compiler is much more efficient now and user/develo
39310 per friendly), but pretty well exposes the guts of it all.
39311 \shape default
39312
39313 \newline
39314
39315 \newline
39316 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
39317  It is fairly easy to retarget for other 8-bit MCU.
39318  Here we take a look at some of the internals of the compiler.
39319  
39320 \end_layout
39321
39322 \begin_layout Paragraph*
39323 Parsing
39324 \begin_inset LatexCommand index
39325 name "Parsing"
39326
39327 \end_inset
39328
39329  
39330 \end_layout
39331
39332 \begin_layout Standard
39333 Parsing the input source file and creating an AST (Annotated Syntax Tree
39334 \begin_inset LatexCommand index
39335 name "Annotated syntax tree"
39336
39337 \end_inset
39338
39339 ).
39340  This phase also involves propagating types (annotating each node of the
39341  parse tree with type information) and semantic analysis.
39342  There are some MCU specific parsing rules.
39343  For example the storage classes, the extended storage classes are MCU specific
39344  while there may be a xdata storage class for 8051 there is no such storage
39345  class for z80 or Atmel AVR.
39346  SDCC allows MCU specific storage class extensions, i.e.
39347  xdata will be treated as a storage class specifier when parsing 8051 C
39348  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
39349  C code.
39350 \end_layout
39351
39352 \begin_layout Paragraph*
39353 Generating iCode
39354 \begin_inset LatexCommand index
39355 name "iCode"
39356
39357 \end_inset
39358
39359
39360 \end_layout
39361
39362 \begin_layout Standard
39363 Intermediate code generation.
39364  In this phase the AST is broken down into three-operand form (iCode).
39365  These three operand forms are represented as doubly linked lists.
39366  ICode is the term given to the intermediate form generated by the compiler.
39367  ICode example section shows some examples of iCode generated for some simple
39368  C source functions.
39369 \end_layout
39370
39371 \begin_layout Paragraph*
39372 Optimizations
39373 \begin_inset LatexCommand index
39374 name "Optimizations"
39375
39376 \end_inset
39377
39378 .
39379 \end_layout
39380
39381 \begin_layout Standard
39382 Bulk of the target independent optimizations is performed in this phase.
39383  The optimizations include constant propagation, common sub-expression eliminati
39384 on, loop invariant code movement, strength reduction of loop induction variables
39385  and dead-code elimination.
39386 \end_layout
39387
39388 \begin_layout Paragraph*
39389 Live range analysis
39390 \begin_inset LatexCommand index
39391 name "Live range analysis"
39392
39393 \end_inset
39394
39395
39396 \end_layout
39397
39398 \begin_layout Standard
39399 During intermediate code generation phase, the compiler assumes the target
39400  machine has infinite number of registers and generates a lot of temporary
39401  variables.
39402  The live range computation determines the lifetime of each of these compiler-ge
39403 nerated temporaries.
39404  A picture speaks a thousand words.
39405  ICode example sections show the live range annotations for each of the
39406  operand.
39407  It is important to note here, each iCode is assigned a number in the order
39408  of its execution in the function.
39409  The live ranges are computed in terms of these numbers.
39410  The from number is the number of the iCode which first defines the operand
39411  and the to number signifies the iCode which uses this operand last.
39412 \end_layout
39413
39414 \begin_layout Paragraph*
39415 Register Allocation
39416 \begin_inset LatexCommand index
39417 name "Register allocation"
39418
39419 \end_inset
39420
39421
39422 \end_layout
39423
39424 \begin_layout Standard
39425 The register allocation determines the type and number of registers needed
39426  by each operand.
39427  In most MCUs only a few registers can be used for indirect addressing.
39428  In case of 8051 for example the registers R0 & R1 can be used to indirectly
39429  address the internal ram and DPTR to indirectly address the external ram.
39430  The compiler will try to allocate the appropriate register to pointer variables
39431  if it can.
39432  ICode example section shows the operands annotated with the registers assigned
39433  to them.
39434  The compiler will try to keep operands in registers as much as possible;
39435  there are several schemes the compiler uses to do achieve this.
39436  When the compiler runs out of registers the compiler will check to see
39437  if there are any live operands which is not used or defined in the current
39438  basic block being processed, if there are any found then it will push that
39439  operand and use the registers in this block, the operand will then be popped
39440  at the end of the basic block.
39441  
39442 \end_layout
39443
39444 \begin_layout Standard
39445 There are other MCU specific considerations in this phase.
39446  Some MCUs have an accumulator; very short-lived operands could be assigned
39447  to the accumulator instead of a general-purpose register.
39448 \end_layout
39449
39450 \begin_layout Paragraph*
39451 Code generation
39452 \end_layout
39453
39454 \begin_layout Standard
39455 Figure II gives a table of iCode
39456 \begin_inset LatexCommand index
39457 name "iCode"
39458
39459 \end_inset
39460
39461  operations supported by the compiler.
39462  The code generation involves translating these operations into corresponding
39463  assembly code for the processor.
39464  This sounds overly simple but that is the essence of code generation.
39465  Some of the iCode operations are generated on a MCU specific manner for
39466  example, the z80 port does not use registers to pass parameters so the
39467  SEND and RECV iCode operations will not be generated, and it also does
39468  not support JUMPTABLES.
39469  
39470 \newline
39471
39472 \end_layout
39473
39474 \begin_layout Standard
39475
39476 \size footnotesize
39477 Figure II 
39478 \begin_inset Tabular
39479 <lyxtabular version="3" rows="39" columns="4">
39480 <features islongtable="true" headBottomDL="true">
39481 <column alignment="block" valignment="top" leftline="true" width="13col%">
39482 <column alignment="left" valignment="top" leftline="true" width="13col%">
39483 <column alignment="block" valignment="top" leftline="true" width="22col%">
39484 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
39485 <row topline="true" bottomline="true" endhead="true">
39486 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39487 \begin_inset Text
39488
39489 \begin_layout Standard
39490
39491 \series bold
39492 iCode
39493 \series default
39494
39495 \begin_inset LatexCommand index
39496 name "iCode"
39497
39498 \end_inset
39499
39500
39501 \end_layout
39502
39503 \end_inset
39504 </cell>
39505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39506 \begin_inset Text
39507
39508 \begin_layout Standard
39509
39510 \series bold
39511 Operands
39512 \end_layout
39513
39514 \end_inset
39515 </cell>
39516 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39517 \begin_inset Text
39518
39519 \begin_layout Standard
39520
39521 \series bold
39522 Description
39523 \end_layout
39524
39525 \end_inset
39526 </cell>
39527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39528 \begin_inset Text
39529
39530 \begin_layout Standard
39531
39532 \series bold
39533 C Equivalent
39534 \end_layout
39535
39536 \end_inset
39537 </cell>
39538 </row>
39539 <row topline="true">
39540 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39541 \begin_inset Text
39542
39543 \begin_layout Standard
39544
39545 \size footnotesize
39546 '!'
39547 \end_layout
39548
39549 \end_inset
39550 </cell>
39551 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39552 \begin_inset Text
39553
39554 \begin_layout Standard
39555
39556 \size footnotesize
39557 IC_LEFT() IC_RESULT()
39558 \end_layout
39559
39560 \end_inset
39561 </cell>
39562 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39563 \begin_inset Text
39564
39565 \begin_layout Standard
39566
39567 \size footnotesize
39568 NOT operation 
39569 \end_layout
39570
39571 \end_inset
39572 </cell>
39573 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39574 \begin_inset Text
39575
39576 \begin_layout Standard
39577
39578 \size footnotesize
39579 IC_RESULT = ! IC_LEFT;
39580 \end_layout
39581
39582 \end_inset
39583 </cell>
39584 </row>
39585 <row topline="true">
39586 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39587 \begin_inset Text
39588
39589 \begin_layout Standard
39590
39591 \size footnotesize
39592 '~'
39593 \end_layout
39594
39595 \end_inset
39596 </cell>
39597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39598 \begin_inset Text
39599
39600 \begin_layout Standard
39601
39602 \size footnotesize
39603 IC_LEFT() IC_RESULT()
39604 \end_layout
39605
39606 \end_inset
39607 </cell>
39608 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39609 \begin_inset Text
39610
39611 \begin_layout Standard
39612
39613 \size footnotesize
39614 Bitwise complement of 
39615 \end_layout
39616
39617 \end_inset
39618 </cell>
39619 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39620 \begin_inset Text
39621
39622 \begin_layout Standard
39623
39624 \size footnotesize
39625 IC_RESULT = ~IC_LEFT;
39626 \end_layout
39627
39628 \end_inset
39629 </cell>
39630 </row>
39631 <row topline="true">
39632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39633 \begin_inset Text
39634
39635 \begin_layout Standard
39636
39637 \size footnotesize
39638 RRC
39639 \end_layout
39640
39641 \end_inset
39642 </cell>
39643 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39644 \begin_inset Text
39645
39646 \begin_layout Standard
39647
39648 \size footnotesize
39649 IC_LEFT() IC_RESULT()
39650 \end_layout
39651
39652 \end_inset
39653 </cell>
39654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39655 \begin_inset Text
39656
39657 \begin_layout Standard
39658
39659 \size footnotesize
39660 Rotate right with carry
39661 \end_layout
39662
39663 \end_inset
39664 </cell>
39665 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39666 \begin_inset Text
39667
39668 \begin_layout Standard
39669
39670 \size footnotesize
39671 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
39672 \end_layout
39673
39674 \end_inset
39675 </cell>
39676 </row>
39677 <row topline="true">
39678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39679 \begin_inset Text
39680
39681 \begin_layout Standard
39682
39683 \size footnotesize
39684 RLC
39685 \end_layout
39686
39687 \end_inset
39688 </cell>
39689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39690 \begin_inset Text
39691
39692 \begin_layout Standard
39693
39694 \size footnotesize
39695 IC_LEFT() IC_RESULT()
39696 \end_layout
39697
39698 \end_inset
39699 </cell>
39700 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39701 \begin_inset Text
39702
39703 \begin_layout Standard
39704
39705 \size footnotesize
39706 Rotate left with carry
39707 \end_layout
39708
39709 \end_inset
39710 </cell>
39711 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39712 \begin_inset Text
39713
39714 \begin_layout Standard
39715
39716 \size footnotesize
39717 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
39718 \end_layout
39719
39720 \end_inset
39721 </cell>
39722 </row>
39723 <row topline="true">
39724 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39725 \begin_inset Text
39726
39727 \begin_layout Standard
39728
39729 \size footnotesize
39730 GETHBIT
39731 \end_layout
39732
39733 \end_inset
39734 </cell>
39735 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39736 \begin_inset Text
39737
39738 \begin_layout Standard
39739
39740 \size footnotesize
39741 IC_LEFT() IC_RESULT()
39742 \end_layout
39743
39744 \end_inset
39745 </cell>
39746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39747 \begin_inset Text
39748
39749 \begin_layout Standard
39750
39751 \size footnotesize
39752 Get the highest order bit of IC_LEFT
39753 \end_layout
39754
39755 \end_inset
39756 </cell>
39757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39758 \begin_inset Text
39759
39760 \begin_layout Standard
39761
39762 \size footnotesize
39763 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
39764 \end_layout
39765
39766 \end_inset
39767 </cell>
39768 </row>
39769 <row topline="true">
39770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39771 \begin_inset Text
39772
39773 \begin_layout Standard
39774
39775 \size footnotesize
39776 UNARYMINUS
39777 \end_layout
39778
39779 \end_inset
39780 </cell>
39781 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39782 \begin_inset Text
39783
39784 \begin_layout Standard
39785
39786 \size footnotesize
39787 IC_LEFT() IC_RESULT()
39788 \end_layout
39789
39790 \end_inset
39791 </cell>
39792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39793 \begin_inset Text
39794
39795 \begin_layout Standard
39796
39797 \size footnotesize
39798 Unary minus
39799 \end_layout
39800
39801 \end_inset
39802 </cell>
39803 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39804 \begin_inset Text
39805
39806 \begin_layout Standard
39807
39808 \size footnotesize
39809 IC_RESULT = - IC_LEFT;
39810 \end_layout
39811
39812 \end_inset
39813 </cell>
39814 </row>
39815 <row topline="true">
39816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39817 \begin_inset Text
39818
39819 \begin_layout Standard
39820
39821 \size footnotesize
39822 IPUSH
39823 \end_layout
39824
39825 \end_inset
39826 </cell>
39827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39828 \begin_inset Text
39829
39830 \begin_layout Standard
39831
39832 \size footnotesize
39833 IC_LEFT()
39834 \end_layout
39835
39836 \end_inset
39837 </cell>
39838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39839 \begin_inset Text
39840
39841 \begin_layout Standard
39842
39843 \size footnotesize
39844 Push the operand into stack
39845 \end_layout
39846
39847 \end_inset
39848 </cell>
39849 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39850 \begin_inset Text
39851
39852 \begin_layout Standard
39853
39854 \size footnotesize
39855 NONE
39856 \end_layout
39857
39858 \end_inset
39859 </cell>
39860 </row>
39861 <row topline="true">
39862 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39863 \begin_inset Text
39864
39865 \begin_layout Standard
39866
39867 \size footnotesize
39868 IPOP
39869 \end_layout
39870
39871 \end_inset
39872 </cell>
39873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39874 \begin_inset Text
39875
39876 \begin_layout Standard
39877
39878 \size footnotesize
39879 IC_LEFT()
39880 \end_layout
39881
39882 \end_inset
39883 </cell>
39884 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39885 \begin_inset Text
39886
39887 \begin_layout Standard
39888
39889 \size footnotesize
39890 Pop the operand from the stack 
39891 \end_layout
39892
39893 \end_inset
39894 </cell>
39895 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39896 \begin_inset Text
39897
39898 \begin_layout Standard
39899
39900 \size footnotesize
39901 NONE
39902 \end_layout
39903
39904 \end_inset
39905 </cell>
39906 </row>
39907 <row topline="true">
39908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39909 \begin_inset Text
39910
39911 \begin_layout Standard
39912
39913 \size footnotesize
39914 CALL
39915 \end_layout
39916
39917 \end_inset
39918 </cell>
39919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39920 \begin_inset Text
39921
39922 \begin_layout Standard
39923
39924 \size footnotesize
39925 IC_LEFT() IC_RESULT()
39926 \end_layout
39927
39928 \end_inset
39929 </cell>
39930 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39931 \begin_inset Text
39932
39933 \begin_layout Standard
39934
39935 \size footnotesize
39936 Call the function represented by IC_LEFT 
39937 \end_layout
39938
39939 \end_inset
39940 </cell>
39941 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39942 \begin_inset Text
39943
39944 \begin_layout Standard
39945
39946 \size footnotesize
39947 IC_RESULT = IC_LEFT();
39948 \end_layout
39949
39950 \end_inset
39951 </cell>
39952 </row>
39953 <row topline="true">
39954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39955 \begin_inset Text
39956
39957 \begin_layout Standard
39958
39959 \size footnotesize
39960 PCALL
39961 \end_layout
39962
39963 \end_inset
39964 </cell>
39965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39966 \begin_inset Text
39967
39968 \begin_layout Standard
39969
39970 \size footnotesize
39971 IC_LEFT() IC_RESULT()
39972 \end_layout
39973
39974 \end_inset
39975 </cell>
39976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39977 \begin_inset Text
39978
39979 \begin_layout Standard
39980
39981 \size footnotesize
39982 Call via function pointer
39983 \end_layout
39984
39985 \end_inset
39986 </cell>
39987 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39988 \begin_inset Text
39989
39990 \begin_layout Standard
39991
39992 \size footnotesize
39993 IC_RESULT = (*IC_LEFT)();
39994 \end_layout
39995
39996 \end_inset
39997 </cell>
39998 </row>
39999 <row topline="true">
40000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40001 \begin_inset Text
40002
40003 \begin_layout Standard
40004
40005 \size footnotesize
40006 RETURN
40007 \end_layout
40008
40009 \end_inset
40010 </cell>
40011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40012 \begin_inset Text
40013
40014 \begin_layout Standard
40015
40016 \size footnotesize
40017 IC_LEFT()
40018 \end_layout
40019
40020 \end_inset
40021 </cell>
40022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40023 \begin_inset Text
40024
40025 \begin_layout Standard
40026
40027 \size footnotesize
40028 Return the value in operand IC_LEFT 
40029 \end_layout
40030
40031 \end_inset
40032 </cell>
40033 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40034 \begin_inset Text
40035
40036 \begin_layout Standard
40037
40038 \size footnotesize
40039 return IC_LEFT;
40040 \end_layout
40041
40042 \end_inset
40043 </cell>
40044 </row>
40045 <row topline="true">
40046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40047 \begin_inset Text
40048
40049 \begin_layout Standard
40050
40051 \size footnotesize
40052 LABEL
40053 \end_layout
40054
40055 \end_inset
40056 </cell>
40057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40058 \begin_inset Text
40059
40060 \begin_layout Standard
40061
40062 \size footnotesize
40063 IC_LABEL() 
40064 \end_layout
40065
40066 \end_inset
40067 </cell>
40068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40069 \begin_inset Text
40070
40071 \begin_layout Standard
40072
40073 \size footnotesize
40074 Label
40075 \end_layout
40076
40077 \end_inset
40078 </cell>
40079 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40080 \begin_inset Text
40081
40082 \begin_layout Standard
40083
40084 \size footnotesize
40085 IC_LABEL:
40086 \end_layout
40087
40088 \end_inset
40089 </cell>
40090 </row>
40091 <row topline="true">
40092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40093 \begin_inset Text
40094
40095 \begin_layout Standard
40096
40097 \size footnotesize
40098 GOTO
40099 \end_layout
40100
40101 \end_inset
40102 </cell>
40103 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40104 \begin_inset Text
40105
40106 \begin_layout Standard
40107
40108 \size footnotesize
40109 IC_LABEL() 
40110 \end_layout
40111
40112 \end_inset
40113 </cell>
40114 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40115 \begin_inset Text
40116
40117 \begin_layout Standard
40118
40119 \size footnotesize
40120 Goto label
40121 \end_layout
40122
40123 \end_inset
40124 </cell>
40125 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40126 \begin_inset Text
40127
40128 \begin_layout Standard
40129
40130 \size footnotesize
40131 goto IC_LABEL();
40132 \end_layout
40133
40134 \end_inset
40135 </cell>
40136 </row>
40137 <row topline="true">
40138 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40139 \begin_inset Text
40140
40141 \begin_layout Standard
40142
40143 \size footnotesize
40144 '+'
40145 \end_layout
40146
40147 \end_inset
40148 </cell>
40149 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40150 \begin_inset Text
40151
40152 \begin_layout Standard
40153
40154 \size footnotesize
40155 IC_LEFT() IC_RIGHT() IC_RESULT()
40156 \end_layout
40157
40158 \end_inset
40159 </cell>
40160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40161 \begin_inset Text
40162
40163 \begin_layout Standard
40164
40165 \size footnotesize
40166 Addition
40167 \end_layout
40168
40169 \end_inset
40170 </cell>
40171 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40172 \begin_inset Text
40173
40174 \begin_layout Standard
40175
40176 \size footnotesize
40177 IC_RESULT = IC_LEFT + IC_RIGHT
40178 \end_layout
40179
40180 \end_inset
40181 </cell>
40182 </row>
40183 <row topline="true">
40184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40185 \begin_inset Text
40186
40187 \begin_layout Standard
40188
40189 \size footnotesize
40190 '-'
40191 \end_layout
40192
40193 \end_inset
40194 </cell>
40195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40196 \begin_inset Text
40197
40198 \begin_layout Standard
40199
40200 \size footnotesize
40201 IC_LEFT() IC_RIGHT() IC_RESULT()
40202 \end_layout
40203
40204 \end_inset
40205 </cell>
40206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40207 \begin_inset Text
40208
40209 \begin_layout Standard
40210
40211 \size footnotesize
40212 Subtraction
40213 \end_layout
40214
40215 \end_inset
40216 </cell>
40217 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40218 \begin_inset Text
40219
40220 \begin_layout Standard
40221
40222 \size footnotesize
40223 IC_RESULT = IC_LEFT - IC_RIGHT 
40224 \end_layout
40225
40226 \end_inset
40227 </cell>
40228 </row>
40229 <row topline="true">
40230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40231 \begin_inset Text
40232
40233 \begin_layout Standard
40234
40235 \size footnotesize
40236 '*'
40237 \end_layout
40238
40239 \end_inset
40240 </cell>
40241 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40242 \begin_inset Text
40243
40244 \begin_layout Standard
40245
40246 \size footnotesize
40247 IC_LEFT() IC_RIGHT() IC_RESULT()
40248 \end_layout
40249
40250 \end_inset
40251 </cell>
40252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40253 \begin_inset Text
40254
40255 \begin_layout Standard
40256
40257 \size footnotesize
40258 Multiplication 
40259 \end_layout
40260
40261 \end_inset
40262 </cell>
40263 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40264 \begin_inset Text
40265
40266 \begin_layout Standard
40267
40268 \size footnotesize
40269 IC_RESULT = IC_LEFT * IC_RIGHT;
40270 \end_layout
40271
40272 \end_inset
40273 </cell>
40274 </row>
40275 <row topline="true">
40276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40277 \begin_inset Text
40278
40279 \begin_layout Standard
40280
40281 \size footnotesize
40282 '/'
40283 \end_layout
40284
40285 \end_inset
40286 </cell>
40287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40288 \begin_inset Text
40289
40290 \begin_layout Standard
40291
40292 \size footnotesize
40293 IC_LEFT() IC_RIGHT() IC_RESULT()
40294 \end_layout
40295
40296 \end_inset
40297 </cell>
40298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40299 \begin_inset Text
40300
40301 \begin_layout Standard
40302
40303 \size footnotesize
40304 Division
40305 \end_layout
40306
40307 \end_inset
40308 </cell>
40309 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40310 \begin_inset Text
40311
40312 \begin_layout Standard
40313
40314 \size footnotesize
40315 IC_RESULT = IC_LEFT / IC_RIGHT;
40316 \end_layout
40317
40318 \end_inset
40319 </cell>
40320 </row>
40321 <row topline="true">
40322 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40323 \begin_inset Text
40324
40325 \begin_layout Standard
40326
40327 \size footnotesize
40328 '%'
40329 \end_layout
40330
40331 \end_inset
40332 </cell>
40333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40334 \begin_inset Text
40335
40336 \begin_layout Standard
40337
40338 \size footnotesize
40339 IC_LEFT() IC_RIGHT() IC_RESULT()
40340 \end_layout
40341
40342 \end_inset
40343 </cell>
40344 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40345 \begin_inset Text
40346
40347 \begin_layout Standard
40348
40349 \size footnotesize
40350 Modulus
40351 \end_layout
40352
40353 \end_inset
40354 </cell>
40355 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40356 \begin_inset Text
40357
40358 \begin_layout Standard
40359
40360 \size footnotesize
40361 IC_RESULT = IC_LEFT % IC_RIGHT;
40362 \end_layout
40363
40364 \end_inset
40365 </cell>
40366 </row>
40367 <row topline="true">
40368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40369 \begin_inset Text
40370
40371 \begin_layout Standard
40372
40373 \size footnotesize
40374 '<'
40375 \end_layout
40376
40377 \end_inset
40378 </cell>
40379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40380 \begin_inset Text
40381
40382 \begin_layout Standard
40383
40384 \size footnotesize
40385 IC_LEFT() IC_RIGHT() IC_RESULT()
40386 \end_layout
40387
40388 \end_inset
40389 </cell>
40390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40391 \begin_inset Text
40392
40393 \begin_layout Standard
40394
40395 \size footnotesize
40396 Less than
40397 \end_layout
40398
40399 \end_inset
40400 </cell>
40401 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40402 \begin_inset Text
40403
40404 \begin_layout Standard
40405
40406 \size footnotesize
40407 IC_RESULT = IC_LEFT < IC_RIGHT;
40408 \end_layout
40409
40410 \end_inset
40411 </cell>
40412 </row>
40413 <row topline="true">
40414 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40415 \begin_inset Text
40416
40417 \begin_layout Standard
40418
40419 \size footnotesize
40420 '>'
40421 \end_layout
40422
40423 \end_inset
40424 </cell>
40425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40426 \begin_inset Text
40427
40428 \begin_layout Standard
40429
40430 \size footnotesize
40431 IC_LEFT() IC_RIGHT() IC_RESULT()
40432 \end_layout
40433
40434 \end_inset
40435 </cell>
40436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40437 \begin_inset Text
40438
40439 \begin_layout Standard
40440
40441 \size footnotesize
40442 Greater than 
40443 \end_layout
40444
40445 \end_inset
40446 </cell>
40447 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40448 \begin_inset Text
40449
40450 \begin_layout Standard
40451
40452 \size footnotesize
40453 IC_RESULT = IC_LEFT > IC_RIGHT;
40454 \end_layout
40455
40456 \end_inset
40457 </cell>
40458 </row>
40459 <row topline="true">
40460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40461 \begin_inset Text
40462
40463 \begin_layout Standard
40464
40465 \size footnotesize
40466 EQ_OP
40467 \end_layout
40468
40469 \end_inset
40470 </cell>
40471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40472 \begin_inset Text
40473
40474 \begin_layout Standard
40475
40476 \size footnotesize
40477 IC_LEFT() IC_RIGHT() IC_RESULT()
40478 \end_layout
40479
40480 \end_inset
40481 </cell>
40482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40483 \begin_inset Text
40484
40485 \begin_layout Standard
40486
40487 \size footnotesize
40488 Equal to 
40489 \end_layout
40490
40491 \end_inset
40492 </cell>
40493 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40494 \begin_inset Text
40495
40496 \begin_layout Standard
40497
40498 \size footnotesize
40499 IC_RESULT = IC_LEFT == IC_RIGHT;
40500 \end_layout
40501
40502 \end_inset
40503 </cell>
40504 </row>
40505 <row topline="true">
40506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40507 \begin_inset Text
40508
40509 \begin_layout Standard
40510
40511 \size footnotesize
40512 AND_OP
40513 \end_layout
40514
40515 \end_inset
40516 </cell>
40517 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40518 \begin_inset Text
40519
40520 \begin_layout Standard
40521
40522 \size footnotesize
40523 IC_LEFT() IC_RIGHT() IC_RESULT() 
40524 \end_layout
40525
40526 \end_inset
40527 </cell>
40528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40529 \begin_inset Text
40530
40531 \begin_layout Standard
40532
40533 \size footnotesize
40534 Logical and operation
40535 \end_layout
40536
40537 \end_inset
40538 </cell>
40539 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40540 \begin_inset Text
40541
40542 \begin_layout Standard
40543
40544 \size footnotesize
40545 IC_RESULT = IC_LEFT && IC_RIGHT; 
40546 \end_layout
40547
40548 \end_inset
40549 </cell>
40550 </row>
40551 <row topline="true">
40552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40553 \begin_inset Text
40554
40555 \begin_layout Standard
40556
40557 \size footnotesize
40558 OR_OP
40559 \end_layout
40560
40561 \end_inset
40562 </cell>
40563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40564 \begin_inset Text
40565
40566 \begin_layout Standard
40567
40568 \size footnotesize
40569 IC_LEFT() IC_RIGHT() IC_RESULT() 
40570 \end_layout
40571
40572 \end_inset
40573 </cell>
40574 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40575 \begin_inset Text
40576
40577 \begin_layout Standard
40578
40579 \size footnotesize
40580 Logical or operation 
40581 \end_layout
40582
40583 \end_inset
40584 </cell>
40585 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40586 \begin_inset Text
40587
40588 \begin_layout Standard
40589
40590 \size footnotesize
40591 IC_RESULT = IC_LEFT || IC_RIGHT; 
40592 \end_layout
40593
40594 \end_inset
40595 </cell>
40596 </row>
40597 <row topline="true">
40598 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40599 \begin_inset Text
40600
40601 \begin_layout Standard
40602
40603 \size footnotesize
40604 '^'
40605 \end_layout
40606
40607 \end_inset
40608 </cell>
40609 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40610 \begin_inset Text
40611
40612 \begin_layout Standard
40613
40614 \size footnotesize
40615 IC_LEFT() IC_RIGHT() IC_RESULT() 
40616 \end_layout
40617
40618 \end_inset
40619 </cell>
40620 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40621 \begin_inset Text
40622
40623 \begin_layout Standard
40624
40625 \size footnotesize
40626 Exclusive OR
40627 \end_layout
40628
40629 \end_inset
40630 </cell>
40631 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40632 \begin_inset Text
40633
40634 \begin_layout Standard
40635
40636 \size footnotesize
40637 IC_RESULT = IC_LEFT ^ IC_RIGHT;
40638 \end_layout
40639
40640 \end_inset
40641 </cell>
40642 </row>
40643 <row topline="true">
40644 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40645 \begin_inset Text
40646
40647 \begin_layout Standard
40648
40649 \size footnotesize
40650 '|'
40651 \end_layout
40652
40653 \end_inset
40654 </cell>
40655 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40656 \begin_inset Text
40657
40658 \begin_layout Standard
40659
40660 \size footnotesize
40661 IC_LEFT() IC_RIGHT() IC_RESULT() 
40662 \end_layout
40663
40664 \end_inset
40665 </cell>
40666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40667 \begin_inset Text
40668
40669 \begin_layout Standard
40670
40671 \size footnotesize
40672 Bitwise OR 
40673 \end_layout
40674
40675 \end_inset
40676 </cell>
40677 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40678 \begin_inset Text
40679
40680 \begin_layout Standard
40681
40682 \size footnotesize
40683 IC_RESULT = IC_LEFT | IC_RIGHT;
40684 \end_layout
40685
40686 \end_inset
40687 </cell>
40688 </row>
40689 <row topline="true">
40690 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40691 \begin_inset Text
40692
40693 \begin_layout Standard
40694
40695 \size footnotesize
40696 BITWISEAND
40697 \end_layout
40698
40699 \end_inset
40700 </cell>
40701 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40702 \begin_inset Text
40703
40704 \begin_layout Standard
40705
40706 \size footnotesize
40707 IC_LEFT() IC_RIGHT() IC_RESULT()
40708 \end_layout
40709
40710 \end_inset
40711 </cell>
40712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40713 \begin_inset Text
40714
40715 \begin_layout Standard
40716
40717 \size footnotesize
40718 Bitwise AND 
40719 \end_layout
40720
40721 \end_inset
40722 </cell>
40723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40724 \begin_inset Text
40725
40726 \begin_layout Standard
40727
40728 \size footnotesize
40729 IC_RESULT = IC_LEFT & IC_RIGHT;
40730 \end_layout
40731
40732 \end_inset
40733 </cell>
40734 </row>
40735 <row topline="true">
40736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40737 \begin_inset Text
40738
40739 \begin_layout Standard
40740
40741 \size footnotesize
40742 LEFT_OP
40743 \end_layout
40744
40745 \end_inset
40746 </cell>
40747 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40748 \begin_inset Text
40749
40750 \begin_layout Standard
40751
40752 \size footnotesize
40753 IC_LEFT() IC_RIGHT() IC_RESULT()
40754 \end_layout
40755
40756 \end_inset
40757 </cell>
40758 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40759 \begin_inset Text
40760
40761 \begin_layout Standard
40762
40763 \size footnotesize
40764 Left shift 
40765 \end_layout
40766
40767 \end_inset
40768 </cell>
40769 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40770 \begin_inset Text
40771
40772 \begin_layout Standard
40773
40774 \size footnotesize
40775 IC_RESULT = IC_LEFT << IC_RIGHT 
40776 \end_layout
40777
40778 \end_inset
40779 </cell>
40780 </row>
40781 <row topline="true">
40782 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40783 \begin_inset Text
40784
40785 \begin_layout Standard
40786
40787 \size footnotesize
40788 RIGHT_OP
40789 \end_layout
40790
40791 \end_inset
40792 </cell>
40793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40794 \begin_inset Text
40795
40796 \begin_layout Standard
40797
40798 \size footnotesize
40799 IC_LEFT() IC_RIGHT() IC_RESULT()
40800 \end_layout
40801
40802 \end_inset
40803 </cell>
40804 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40805 \begin_inset Text
40806
40807 \begin_layout Standard
40808
40809 \size footnotesize
40810 Right shift
40811 \end_layout
40812
40813 \end_inset
40814 </cell>
40815 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40816 \begin_inset Text
40817
40818 \begin_layout Standard
40819
40820 \size footnotesize
40821 IC_RESULT = IC_LEFT >> IC_RIGHT 
40822 \end_layout
40823
40824 \end_inset
40825 </cell>
40826 </row>
40827 <row topline="true">
40828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40829 \begin_inset Text
40830
40831 \begin_layout Standard
40832
40833 \size footnotesize
40834 GET_VALUE_
40835 \newline
40836 AT_ ADDRESS
40837 \end_layout
40838
40839 \end_inset
40840 </cell>
40841 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40842 \begin_inset Text
40843
40844 \begin_layout Standard
40845
40846 \size footnotesize
40847 IC_LEFT() IC_RESULT()
40848 \end_layout
40849
40850 \end_inset
40851 </cell>
40852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40853 \begin_inset Text
40854
40855 \begin_layout Standard
40856
40857 \size footnotesize
40858 Indirect fetch 
40859 \end_layout
40860
40861 \end_inset
40862 </cell>
40863 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40864 \begin_inset Text
40865
40866 \begin_layout Standard
40867
40868 \size footnotesize
40869 IC_RESULT = (*IC_LEFT);
40870 \end_layout
40871
40872 \end_inset
40873 </cell>
40874 </row>
40875 <row topline="true">
40876 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40877 \begin_inset Text
40878
40879 \begin_layout Standard
40880
40881 \size footnotesize
40882 POINTER_SET
40883 \end_layout
40884
40885 \end_inset
40886 </cell>
40887 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40888 \begin_inset Text
40889
40890 \begin_layout Standard
40891
40892 \size footnotesize
40893 IC_RIGHT() IC_RESULT() 
40894 \end_layout
40895
40896 \end_inset
40897 </cell>
40898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40899 \begin_inset Text
40900
40901 \begin_layout Standard
40902
40903 \size footnotesize
40904 Indirect set
40905 \end_layout
40906
40907 \end_inset
40908 </cell>
40909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40910 \begin_inset Text
40911
40912 \begin_layout Standard
40913
40914 \size footnotesize
40915 (*IC_RESULT) = IC_RIGHT;
40916 \end_layout
40917
40918 \end_inset
40919 </cell>
40920 </row>
40921 <row topline="true">
40922 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40923 \begin_inset Text
40924
40925 \begin_layout Standard
40926
40927 \size footnotesize
40928 '='
40929 \end_layout
40930
40931 \end_inset
40932 </cell>
40933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40934 \begin_inset Text
40935
40936 \begin_layout Standard
40937
40938 \size footnotesize
40939 IC_RIGHT() IC_RESULT()
40940 \end_layout
40941
40942 \end_inset
40943 </cell>
40944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40945 \begin_inset Text
40946
40947 \begin_layout Standard
40948
40949 \size footnotesize
40950 Assignment
40951 \end_layout
40952
40953 \end_inset
40954 </cell>
40955 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40956 \begin_inset Text
40957
40958 \begin_layout Standard
40959
40960 \size footnotesize
40961 IC_RESULT = IC_RIGHT;
40962 \end_layout
40963
40964 \end_inset
40965 </cell>
40966 </row>
40967 <row topline="true">
40968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40969 \begin_inset Text
40970
40971 \begin_layout Standard
40972
40973 \size footnotesize
40974 IFX
40975 \end_layout
40976
40977 \end_inset
40978 </cell>
40979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40980 \begin_inset Text
40981
40982 \begin_layout Standard
40983
40984 \size footnotesize
40985 IC_COND IC_TRUE IC_LABEL
40986 \end_layout
40987
40988 \end_inset
40989 </cell>
40990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40991 \begin_inset Text
40992
40993 \begin_layout Standard
40994
40995 \size footnotesize
40996 Conditional jump.
40997  If true label is present then jump to true label if condition is true else
40998  jump to false label if condition is false 
40999 \end_layout
41000
41001 \end_inset
41002 </cell>
41003 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41004 \begin_inset Text
41005
41006 \begin_layout Standard
41007
41008 \size footnotesize
41009 if (IC_COND) goto IC_TRUE; 
41010 \newline
41011 \InsetSpace ~
41012 \InsetSpace ~
41013 Or 
41014 \newline
41015 If (!IC_COND) goto IC_FALSE;
41016 \end_layout
41017
41018 \end_inset
41019 </cell>
41020 </row>
41021 <row topline="true">
41022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41023 \begin_inset Text
41024
41025 \begin_layout Standard
41026
41027 \size footnotesize
41028 ADDRESS_OF
41029 \end_layout
41030
41031 \end_inset
41032 </cell>
41033 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41034 \begin_inset Text
41035
41036 \begin_layout Standard
41037
41038 \size footnotesize
41039 IC_LEFT() IC_RESULT()
41040 \end_layout
41041
41042 \end_inset
41043 </cell>
41044 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41045 \begin_inset Text
41046
41047 \begin_layout Standard
41048
41049 \size footnotesize
41050 Address of 
41051 \end_layout
41052
41053 \end_inset
41054 </cell>
41055 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41056 \begin_inset Text
41057
41058 \begin_layout Standard
41059
41060 \size footnotesize
41061 IC_RESULT = &IC_LEFT();
41062 \end_layout
41063
41064 \end_inset
41065 </cell>
41066 </row>
41067 <row topline="true">
41068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41069 \begin_inset Text
41070
41071 \begin_layout Standard
41072
41073 \size footnotesize
41074 JUMPTABLE
41075 \end_layout
41076
41077 \end_inset
41078 </cell>
41079 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41080 \begin_inset Text
41081
41082 \begin_layout Standard
41083
41084 \size footnotesize
41085 IC_JTCOND IC_JTLABELS
41086 \end_layout
41087
41088 \end_inset
41089 </cell>
41090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41091 \begin_inset Text
41092
41093 \begin_layout Standard
41094
41095 \size footnotesize
41096 Jump to list of labels depending on the value of JTCOND
41097 \end_layout
41098
41099 \end_inset
41100 </cell>
41101 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41102 \begin_inset Text
41103
41104 \begin_layout Standard
41105
41106 \size footnotesize
41107 Switch statement
41108 \end_layout
41109
41110 \end_inset
41111 </cell>
41112 </row>
41113 <row topline="true">
41114 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41115 \begin_inset Text
41116
41117 \begin_layout Standard
41118
41119 \size footnotesize
41120 CAST
41121 \end_layout
41122
41123 \end_inset
41124 </cell>
41125 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41126 \begin_inset Text
41127
41128 \begin_layout Standard
41129
41130 \size footnotesize
41131 IC_RIGHT() IC_LEFT() IC_RESULT()
41132 \end_layout
41133
41134 \end_inset
41135 </cell>
41136 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41137 \begin_inset Text
41138
41139 \begin_layout Standard
41140
41141 \size footnotesize
41142 Cast types 
41143 \end_layout
41144
41145 \end_inset
41146 </cell>
41147 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41148 \begin_inset Text
41149
41150 \begin_layout Standard
41151
41152 \size footnotesize
41153 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
41154 \end_layout
41155
41156 \end_inset
41157 </cell>
41158 </row>
41159 <row topline="true">
41160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41161 \begin_inset Text
41162
41163 \begin_layout Standard
41164
41165 \size footnotesize
41166 SEND
41167 \end_layout
41168
41169 \end_inset
41170 </cell>
41171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41172 \begin_inset Text
41173
41174 \begin_layout Standard
41175
41176 \size footnotesize
41177 IC_LEFT()
41178 \end_layout
41179
41180 \end_inset
41181 </cell>
41182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41183 \begin_inset Text
41184
41185 \begin_layout Standard
41186
41187 \size footnotesize
41188 This is used for passing parameters in registers; 
41189 \newline
41190 move IC_LEFT to the next
41191  available parameter register.
41192 \end_layout
41193
41194 \end_inset
41195 </cell>
41196 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41197 \begin_inset Text
41198
41199 \begin_layout Standard
41200
41201 \size footnotesize
41202 None
41203 \end_layout
41204
41205 \end_inset
41206 </cell>
41207 </row>
41208 <row topline="true">
41209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41210 \begin_inset Text
41211
41212 \begin_layout Standard
41213
41214 \size footnotesize
41215 RECV
41216 \end_layout
41217
41218 \end_inset
41219 </cell>
41220 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41221 \begin_inset Text
41222
41223 \begin_layout Standard
41224
41225 \size footnotesize
41226 IC_RESULT()
41227 \end_layout
41228
41229 \end_inset
41230 </cell>
41231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41232 \begin_inset Text
41233
41234 \begin_layout Standard
41235
41236 \size footnotesize
41237 This is used for receiving parameters passed in registers;
41238 \newline
41239 Move the values
41240  in the next parameter register to IC_RESULT 
41241 \end_layout
41242
41243 \end_inset
41244 </cell>
41245 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41246 \begin_inset Text
41247
41248 \begin_layout Standard
41249
41250 \size footnotesize
41251 None
41252 \end_layout
41253
41254 \end_inset
41255 </cell>
41256 </row>
41257 <row topline="true" bottomline="true">
41258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41259 \begin_inset Text
41260
41261 \begin_layout Standard
41262
41263 \shape slanted
41264 \size footnotesize
41265 (some more have been added)
41266 \end_layout
41267
41268 \end_inset
41269 </cell>
41270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41271 \begin_inset Text
41272
41273 \begin_layout Standard
41274
41275 \end_layout
41276
41277 \end_inset
41278 </cell>
41279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41280 \begin_inset Text
41281
41282 \begin_layout Standard
41283
41284 \end_layout
41285
41286 \end_inset
41287 </cell>
41288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41289 \begin_inset Text
41290
41291 \begin_layout Standard
41292
41293 \shape slanted
41294 \size footnotesize
41295 see f.e.
41296
41297 \shape default
41298  
41299 \family typewriter
41300 \shape slanted
41301 gen51Code()
41302 \family default
41303 \shape default
41304  
41305 \shape slanted
41306 in
41307 \shape default
41308  
41309 \family typewriter
41310 \shape slanted
41311 src/mcs51/gen.c
41312 \end_layout
41313
41314 \end_inset
41315 </cell>
41316 </row>
41317 </lyxtabular>
41318
41319 \end_inset
41320
41321
41322 \end_layout
41323
41324 \begin_layout Standard
41325 \begin_inset Note Note
41326 status collapsed
41327
41328 \begin_layout Standard
41329 In the original article Figure II was announced to be downloadable on 
41330 \shape italic
41331 Circuit Cellar
41332 \shape default
41333 's web site.
41334  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
41335 \end_layout
41336
41337 \end_inset
41338
41339
41340 \end_layout
41341
41342 \begin_layout Paragraph*
41343 ICode Example
41344 \begin_inset LatexCommand index
41345 name "iCode"
41346
41347 \end_inset
41348
41349
41350 \end_layout
41351
41352 \begin_layout Standard
41353 This section shows some details of iCode.
41354  The example C code does not do anything useful; it is used as an example
41355  to illustrate the intermediate code generated by the compiler.
41356 \end_layout
41357
41358 \begin_layout Verse
41359
41360 \family typewriter
41361 1.\InsetSpace ~
41362 xdata int * p;
41363 \newline
41364 2.\InsetSpace ~
41365 int gint;
41366 \newline
41367 3.\InsetSpace ~
41368 /* This function does nothing useful.
41369  It is used
41370 \newline
41371 4.\InsetSpace ~
41372 \InsetSpace ~
41373 \InsetSpace ~
41374 \InsetSpace ~
41375 for the purpose of explaining iCode */
41376 \newline
41377 5.\InsetSpace ~
41378 short function (data
41379  int *x)
41380 \newline
41381 6.\InsetSpace ~
41382 {
41383 \newline
41384 7.\InsetSpace ~
41385 \InsetSpace ~
41386 \InsetSpace ~
41387 short i=10; \InsetSpace ~
41388 \InsetSpace ~
41389 /* dead initialization eliminated */
41390 \newline
41391 8.\InsetSpace ~
41392 \InsetSpace ~
41393 \InsetSpace ~
41394 short sum=10;
41395  /* dead initialization eliminated */
41396 \newline
41397 9.\InsetSpace ~
41398 \InsetSpace ~
41399 \InsetSpace ~
41400 short mul;
41401 \newline
41402 10.\InsetSpace ~
41403 \InsetSpace ~
41404 int j ;
41405 \newline
41406 11.\InsetSpace ~
41407 \InsetSpace ~
41408 while (*x) *x++
41409  = *p++; 
41410 \newline
41411 12.\InsetSpace ~
41412 \InsetSpace ~
41413 \InsetSpace ~
41414 \InsetSpace ~
41415 sum = 0 ; 
41416 \newline
41417 13.\InsetSpace ~
41418 \InsetSpace ~
41419 mul = 0;
41420 \newline
41421 14.\InsetSpace ~
41422 \InsetSpace ~
41423 /* compiler detects i,j to be induction
41424  variables */
41425 \newline
41426 15.\InsetSpace ~
41427 \InsetSpace ~
41428 for (i = 0, j = 10 ; i < 10 ; i++, j
41429 \family default
41430 -
41431 \begin_inset ERT
41432 status collapsed
41433
41434 \begin_layout Standard
41435
41436
41437 \backslash
41438 /
41439 \end_layout
41440
41441 \end_inset
41442
41443 -
41444 \family typewriter
41445 ) {
41446 \newline
41447 16.\InsetSpace ~
41448 \InsetSpace ~
41449 \InsetSpace ~
41450 \InsetSpace ~
41451 sum += i;
41452 \newline
41453 17.\InsetSpace ~
41454 \InsetSpace ~
41455 \InsetSpace ~
41456 \InsetSpace ~
41457 mul += i * 3; \InsetSpace ~
41458 \InsetSpace ~
41459 /* this multiplication remains */
41460 \newline
41461 18.\InsetSpace ~
41462 \InsetSpace ~
41463 \InsetSpace ~
41464 \InsetSpace ~
41465 gint +=
41466  j * 3;\InsetSpace ~
41467 \InsetSpace ~
41468 /* this multiplication changed to addition */
41469 \newline
41470 19.\InsetSpace ~
41471 \InsetSpace ~
41472 }
41473 \newline
41474 20.\InsetSpace ~
41475 \InsetSpace ~
41476 return sum+mul;
41477 \newline
41478 21.\InsetSpace ~
41479 }
41480 \end_layout
41481
41482 \begin_layout Standard
41483 In addition to the operands each iCode contains information about the filename
41484  and line it corresponds to in the source file.
41485  The first field in the listing should be interpreted as follows:
41486 \newline
41487
41488 \shape italic
41489 \size footnotesize
41490 Filename(linenumber: iCode Execution sequence number : ICode hash table
41491  key : loop depth of the iCode).
41492 \shape default
41493 \size default
41494
41495 \newline
41496 Then follows the human readable form of the ICode operation.
41497  Each operand of this triplet form can be of three basic types a) compiler
41498  generated temporary b) user defined variable c) a constant value.
41499  Note that local variables and parameters are replaced by compiler generated
41500  temporaries.
41501  Live ranges
41502 \begin_inset LatexCommand index
41503 name "Live range analysis"
41504
41505 \end_inset
41506
41507  are computed only for temporaries (i.e.
41508  live ranges are not computed for global variables).
41509  Registers
41510 \begin_inset LatexCommand index
41511 name "Register allocation"
41512
41513 \end_inset
41514
41515  are allocated for temporaries only.
41516  Operands are formatted in the following manner:
41517 \newline
41518
41519 \shape italic
41520 \size footnotesize
41521 Operand Name [lr live-from : live-to ] { type information } [ registers
41522  allocated ].
41523 \shape default
41524 \size default
41525
41526 \newline
41527 As mentioned earlier the live ranges are computed in terms of the execution
41528  sequence number of the iCodes, for example 
41529 \newline
41530 the iTemp0 is live from (i.e.
41531  first defined in iCode with execution sequence number 3, and is last used
41532  in the iCode with sequence number 5).
41533  For induction variables such as iTemp21 the live range computation extends
41534  the lifetime from the start to the end of the loop.
41535 \newline
41536 The register allocator
41537  used the live range information to allocate registers, the same registers
41538  may be used for different temporaries if their live ranges do not overlap,
41539  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
41540  ranges do not overlap.
41541  In addition the allocator also takes into consideration the type and usage
41542  of a temporary, for example itemp6 is a pointer to near space and is used
41543  as to fetch data from (i.e.
41544  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
41545  Some short lived temporaries are allocated to special registers which have
41546  meaning to the code generator e.g.
41547  iTemp13 is allocated to a pseudo register CC which tells the back end that
41548  the temporary is used only for a conditional jump the code generation makes
41549  use of this information to optimize a compare and jump ICode.
41550 \newline
41551 There are several
41552  loop optimizations
41553 \begin_inset LatexCommand index
41554 name "Loop optimization"
41555
41556 \end_inset
41557
41558  performed by the compiler.
41559  It can detect induction variables iTemp21(i) and iTemp23(j).
41560  Also note the compiler does selective strength reduction
41561 \begin_inset LatexCommand index
41562 name "Strength reduction"
41563
41564 \end_inset
41565
41566 , i.e.
41567  the multiplication of an induction variable in line 18 (gint = j * 3) is
41568  changed to addition, a new temporary iTemp17 is allocated and assigned
41569  a initial value, a constant 3 is then added for each iteration of the loop.
41570  The compiler does not change the multiplication
41571 \begin_inset LatexCommand index
41572 name "Multiplication"
41573
41574 \end_inset
41575
41576  in line 17 however since the processor does support an 8 * 8 bit multiplication.
41577 \newline
41578
41579 Note the dead code elimination
41580 \begin_inset LatexCommand index
41581 name "Dead-code elimination"
41582
41583 \end_inset
41584
41585  optimization eliminated the dead assignments in line 7 & 8 to I and sum
41586  respectively.
41587 \newline
41588
41589 \end_layout
41590
41591 \begin_layout Standard
41592
41593 \size footnotesize
41594 Sample.c (5:1:0:0) _entry($9) :
41595 \end_layout
41596
41597 \begin_layout Standard
41598
41599 \size footnotesize
41600 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
41601 \end_layout
41602
41603 \begin_layout Standard
41604
41605 \size footnotesize
41606 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
41607 \end_layout
41608
41609 \begin_layout Standard
41610
41611 \size footnotesize
41612 Sample.c(11:4:53:0) preHeaderLbl0($11) :
41613 \end_layout
41614
41615 \begin_layout Standard
41616
41617 \size footnotesize
41618 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
41619  * int}[r2]
41620 \end_layout
41621
41622 \begin_layout Standard
41623
41624 \size footnotesize
41625 Sample.c(11:6:5:1) _whilecontinue_0($1) :
41626 \end_layout
41627
41628 \begin_layout Standard
41629
41630 \size footnotesize
41631 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
41632  int}[r0]]
41633 \end_layout
41634
41635 \begin_layout Standard
41636
41637 \size footnotesize
41638 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41639 \end_layout
41640
41641 \begin_layout Standard
41642
41643 \size footnotesize
41644 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
41645  * int}
41646 \end_layout
41647
41648 \begin_layout Standard
41649
41650 \size footnotesize
41651 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
41652  {short}
41653 \end_layout
41654
41655 \begin_layout Standard
41656
41657 \size footnotesize
41658 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
41659  * int}[DPTR]]
41660 \end_layout
41661
41662 \begin_layout Standard
41663
41664 \size footnotesize
41665 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
41666 }[r2 r3]
41667 \end_layout
41668
41669 \begin_layout Standard
41670
41671 \size footnotesize
41672 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
41673  * int}[r0] + 0x2 {short}
41674 \end_layout
41675
41676 \begin_layout Standard
41677
41678 \size footnotesize
41679 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
41680 \end_layout
41681
41682 \begin_layout Standard
41683
41684 \size footnotesize
41685 Sample.c(11:17:21:0)_whilebreak_0($3) :
41686 \end_layout
41687
41688 \begin_layout Standard
41689
41690 \size footnotesize
41691 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
41692 \end_layout
41693
41694 \begin_layout Standard
41695
41696 \size footnotesize
41697 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
41698 \end_layout
41699
41700 \begin_layout Standard
41701
41702 \size footnotesize
41703 Sample.c(15:20:54:0)preHeaderLbl1($13) :
41704 \end_layout
41705
41706 \begin_layout Standard
41707
41708 \size footnotesize
41709 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
41710 \end_layout
41711
41712 \begin_layout Standard
41713
41714 \size footnotesize
41715 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
41716 \end_layout
41717
41718 \begin_layout Standard
41719
41720 \size footnotesize
41721 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
41722 \end_layout
41723
41724 \begin_layout Standard
41725
41726 \size footnotesize
41727 Sample.c(15:24:26:1)_forcond_0($4) :
41728 \end_layout
41729
41730 \begin_layout Standard
41731
41732 \size footnotesize
41733 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
41734  < 0xa {short}
41735 \end_layout
41736
41737 \begin_layout Standard
41738
41739 \size footnotesize
41740 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
41741 \end_layout
41742
41743 \begin_layout Standard
41744
41745 \size footnotesize
41746 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
41747  + ITemp21 [lr21:38]{short}[r4]
41748 \end_layout
41749
41750 \begin_layout Standard
41751
41752 \size footnotesize
41753 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
41754  * 0x3 {short}
41755 \end_layout
41756
41757 \begin_layout Standard
41758
41759 \size footnotesize
41760 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
41761  + iTemp15 [lr29:30]{short}[r1]
41762 \end_layout
41763
41764 \begin_layout Standard
41765
41766 \size footnotesize
41767 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
41768  r0]- 0x3 {short}
41769 \end_layout
41770
41771 \begin_layout Standard
41772
41773 \size footnotesize
41774 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
41775 int}[r7 r0]
41776 \end_layout
41777
41778 \begin_layout Standard
41779
41780 \size footnotesize
41781 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
41782  + 0x1 {short}
41783 \end_layout
41784
41785 \begin_layout Standard
41786
41787 \size footnotesize
41788 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
41789  r6]- 0x1 {short}
41790 \end_layout
41791
41792 \begin_layout Standard
41793
41794 \size footnotesize
41795 Sample.c(19:38:47:1) goto _forcond_0($4)
41796 \end_layout
41797
41798 \begin_layout Standard
41799
41800 \size footnotesize
41801 Sample.c(19:39:48:0)_forbreak_0($7) :
41802 \end_layout
41803
41804 \begin_layout Standard
41805
41806 \size footnotesize
41807 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
41808  + ITemp11 [lr19:40]{short}[r3]
41809 \end_layout
41810
41811 \begin_layout Standard
41812
41813 \size footnotesize
41814 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
41815 \end_layout
41816
41817 \begin_layout Standard
41818
41819 \size footnotesize
41820 Sample.c(20:42:51:0)_return($8) :
41821 \end_layout
41822
41823 \begin_layout Standard
41824
41825 \size footnotesize
41826 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
41827 \size default
41828
41829 \newline
41830
41831 \newline
41832 Finally the code generated for this function:
41833 \newline
41834
41835 \end_layout
41836
41837 \begin_layout Standard
41838
41839 \size footnotesize
41840 .area DSEG (DATA)
41841 \end_layout
41842
41843 \begin_layout Standard
41844
41845 \size footnotesize
41846 _p::
41847 \end_layout
41848
41849 \begin_layout Standard
41850
41851 \size footnotesize
41852 \InsetSpace ~
41853 \InsetSpace ~
41854 .ds 2
41855 \end_layout
41856
41857 \begin_layout Standard
41858
41859 \size footnotesize
41860 _gint::
41861 \end_layout
41862
41863 \begin_layout Standard
41864
41865 \size footnotesize
41866 \InsetSpace ~
41867 \InsetSpace ~
41868 .ds 2
41869 \end_layout
41870
41871 \begin_layout Standard
41872
41873 \size footnotesize
41874 ; sample.c 5
41875 \end_layout
41876
41877 \begin_layout Standard
41878
41879 \size footnotesize
41880 ; ----------------------------------------------
41881 \end_layout
41882
41883 \begin_layout Standard
41884
41885 \size footnotesize
41886 ; function function
41887 \end_layout
41888
41889 \begin_layout Standard
41890
41891 \size footnotesize
41892 ; ----------------------------------------------
41893 \end_layout
41894
41895 \begin_layout Standard
41896
41897 \size footnotesize
41898 _function:
41899 \end_layout
41900
41901 \begin_layout Standard
41902
41903 \size footnotesize
41904 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
41905 \end_layout
41906
41907 \begin_layout Standard
41908
41909 \size footnotesize
41910 \InsetSpace ~
41911 \InsetSpace ~
41912 mov r2,dpl
41913 \end_layout
41914
41915 \begin_layout Standard
41916
41917 \size footnotesize
41918 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
41919 \end_layout
41920
41921 \begin_layout Standard
41922
41923 \size footnotesize
41924 \InsetSpace ~
41925 \InsetSpace ~
41926 mov ar0,r2
41927 \end_layout
41928
41929 \begin_layout Standard
41930
41931 \size footnotesize
41932 ;_whilecontinue_0($1) :
41933 \end_layout
41934
41935 \begin_layout Standard
41936
41937 \size footnotesize
41938 00101$:
41939 \end_layout
41940
41941 \begin_layout Standard
41942
41943 \size footnotesize
41944 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
41945 \end_layout
41946
41947 \begin_layout Standard
41948
41949 \size footnotesize
41950 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41951 \end_layout
41952
41953 \begin_layout Standard
41954
41955 \size footnotesize
41956 \InsetSpace ~
41957 \InsetSpace ~
41958 mov ar2,@r0
41959 \end_layout
41960
41961 \begin_layout Standard
41962
41963 \size footnotesize
41964 \InsetSpace ~
41965 \InsetSpace ~
41966 inc r0
41967 \end_layout
41968
41969 \begin_layout Standard
41970
41971 \size footnotesize
41972 \InsetSpace ~
41973 \InsetSpace ~
41974 mov ar3,@r0
41975 \end_layout
41976
41977 \begin_layout Standard
41978
41979 \size footnotesize
41980 \InsetSpace ~
41981 \InsetSpace ~
41982 dec r0
41983 \end_layout
41984
41985 \begin_layout Standard
41986
41987 \size footnotesize
41988 \InsetSpace ~
41989 \InsetSpace ~
41990 mov a,r2
41991 \end_layout
41992
41993 \begin_layout Standard
41994
41995 \size footnotesize
41996 \InsetSpace ~
41997 \InsetSpace ~
41998 orl a,r3
41999 \end_layout
42000
42001 \begin_layout Standard
42002
42003 \size footnotesize
42004 \InsetSpace ~
42005 \InsetSpace ~
42006 jz 00103$
42007 \end_layout
42008
42009 \begin_layout Standard
42010
42011 \size footnotesize
42012 00114$:
42013 \end_layout
42014
42015 \begin_layout Standard
42016
42017 \size footnotesize
42018 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
42019 \end_layout
42020
42021 \begin_layout Standard
42022
42023 \size footnotesize
42024 \InsetSpace ~
42025 \InsetSpace ~
42026 mov dpl,_p
42027 \end_layout
42028
42029 \begin_layout Standard
42030
42031 \size footnotesize
42032 \InsetSpace ~
42033 \InsetSpace ~
42034 mov dph,(_p + 1)
42035 \end_layout
42036
42037 \begin_layout Standard
42038
42039 \size footnotesize
42040 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
42041 \end_layout
42042
42043 \begin_layout Standard
42044
42045 \size footnotesize
42046 \InsetSpace ~
42047 \InsetSpace ~
42048 mov a,#0x02
42049 \end_layout
42050
42051 \begin_layout Standard
42052
42053 \size footnotesize
42054 \InsetSpace ~
42055 \InsetSpace ~
42056 add a,_p
42057 \end_layout
42058
42059 \begin_layout Standard
42060
42061 \size footnotesize
42062 \InsetSpace ~
42063 \InsetSpace ~
42064 mov _p,a
42065 \end_layout
42066
42067 \begin_layout Standard
42068
42069 \size footnotesize
42070 \InsetSpace ~
42071 \InsetSpace ~
42072 clr a
42073 \end_layout
42074
42075 \begin_layout Standard
42076
42077 \size footnotesize
42078 \InsetSpace ~
42079 \InsetSpace ~
42080 addc a,(_p + 1)
42081 \end_layout
42082
42083 \begin_layout Standard
42084
42085 \size footnotesize
42086 \InsetSpace ~
42087 \InsetSpace ~
42088 mov (_p + 1),a
42089 \end_layout
42090
42091 \begin_layout Standard
42092
42093 \size footnotesize
42094 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
42095 \end_layout
42096
42097 \begin_layout Standard
42098
42099 \size footnotesize
42100 \InsetSpace ~
42101 \InsetSpace ~
42102 movx a,@dptr
42103 \end_layout
42104
42105 \begin_layout Standard
42106
42107 \size footnotesize
42108 \InsetSpace ~
42109 \InsetSpace ~
42110 mov r2,a
42111 \end_layout
42112
42113 \begin_layout Standard
42114
42115 \size footnotesize
42116 \InsetSpace ~
42117 \InsetSpace ~
42118 inc dptr
42119 \end_layout
42120
42121 \begin_layout Standard
42122
42123 \size footnotesize
42124 \InsetSpace ~
42125 \InsetSpace ~
42126 movx a,@dptr
42127 \end_layout
42128
42129 \begin_layout Standard
42130
42131 \size footnotesize
42132 \InsetSpace ~
42133 \InsetSpace ~
42134 mov r3,a
42135 \end_layout
42136
42137 \begin_layout Standard
42138
42139 \size footnotesize
42140 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
42141 \end_layout
42142
42143 \begin_layout Standard
42144
42145 \size footnotesize
42146 \InsetSpace ~
42147 \InsetSpace ~
42148 mov @r0,ar2
42149 \end_layout
42150
42151 \begin_layout Standard
42152
42153 \size footnotesize
42154 \InsetSpace ~
42155 \InsetSpace ~
42156 inc r0
42157 \end_layout
42158
42159 \begin_layout Standard
42160
42161 \size footnotesize
42162 \InsetSpace ~
42163 \InsetSpace ~
42164 mov @r0,ar3
42165 \end_layout
42166
42167 \begin_layout Standard
42168
42169 \size footnotesize
42170 ; iTemp6 [lr5:16]{_near * int}[r0] = 
42171 \end_layout
42172
42173 \begin_layout Standard
42174
42175 \size footnotesize
42176 ; iTemp6 [lr5:16]{_near * int}[r0] + 
42177 \end_layout
42178
42179 \begin_layout Standard
42180
42181 \size footnotesize
42182 ; 0x2 {short}
42183 \end_layout
42184
42185 \begin_layout Standard
42186
42187 \size footnotesize
42188 \InsetSpace ~
42189 \InsetSpace ~
42190 inc r0
42191 \end_layout
42192
42193 \begin_layout Standard
42194
42195 \size footnotesize
42196 ; goto _whilecontinue_0($1)
42197 \end_layout
42198
42199 \begin_layout Standard
42200
42201 \size footnotesize
42202 \InsetSpace ~
42203 \InsetSpace ~
42204 sjmp 00101$
42205 \end_layout
42206
42207 \begin_layout Standard
42208
42209 \size footnotesize
42210 ; _whilebreak_0($3) :
42211 \end_layout
42212
42213 \begin_layout Standard
42214
42215 \size footnotesize
42216 00103$:
42217 \end_layout
42218
42219 \begin_layout Standard
42220
42221 \size footnotesize
42222 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
42223 \end_layout
42224
42225 \begin_layout Standard
42226
42227 \size footnotesize
42228 \InsetSpace ~
42229 \InsetSpace ~
42230 mov r2,#0x00
42231 \end_layout
42232
42233 \begin_layout Standard
42234
42235 \size footnotesize
42236 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
42237 \end_layout
42238
42239 \begin_layout Standard
42240
42241 \size footnotesize
42242 \InsetSpace ~
42243 \InsetSpace ~
42244 mov r3,#0x00
42245 \end_layout
42246
42247 \begin_layout Standard
42248
42249 \size footnotesize
42250 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
42251 \end_layout
42252
42253 \begin_layout Standard
42254
42255 \size footnotesize
42256 \InsetSpace ~
42257 \InsetSpace ~
42258 mov r4,#0x00
42259 \end_layout
42260
42261 \begin_layout Standard
42262
42263 \size footnotesize
42264 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
42265 \end_layout
42266
42267 \begin_layout Standard
42268
42269 \size footnotesize
42270 \InsetSpace ~
42271 \InsetSpace ~
42272 mov r5,#0x0A
42273 \end_layout
42274
42275 \begin_layout Standard
42276
42277 \size footnotesize
42278 \InsetSpace ~
42279 \InsetSpace ~
42280 mov r6,#0x00
42281 \end_layout
42282
42283 \begin_layout Standard
42284
42285 \size footnotesize
42286 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
42287 \end_layout
42288
42289 \begin_layout Standard
42290
42291 \size footnotesize
42292 \InsetSpace ~
42293 \InsetSpace ~
42294 mov r7,#0x1E
42295 \end_layout
42296
42297 \begin_layout Standard
42298
42299 \size footnotesize
42300 \InsetSpace ~
42301 \InsetSpace ~
42302 mov r0,#0x00
42303 \end_layout
42304
42305 \begin_layout Standard
42306
42307 \size footnotesize
42308 ; _forcond_0($4) :
42309 \end_layout
42310
42311 \begin_layout Standard
42312
42313 \size footnotesize
42314 00104$:
42315 \end_layout
42316
42317 \begin_layout Standard
42318
42319 \size footnotesize
42320 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
42321 \end_layout
42322
42323 \begin_layout Standard
42324
42325 \size footnotesize
42326 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
42327 \end_layout
42328
42329 \begin_layout Standard
42330
42331 \size footnotesize
42332 \InsetSpace ~
42333 \InsetSpace ~
42334 clr c
42335 \end_layout
42336
42337 \begin_layout Standard
42338
42339 \size footnotesize
42340 \InsetSpace ~
42341 \InsetSpace ~
42342 mov a,r4
42343 \end_layout
42344
42345 \begin_layout Standard
42346
42347 \size footnotesize
42348 \InsetSpace ~
42349 \InsetSpace ~
42350 xrl a,#0x80
42351 \end_layout
42352
42353 \begin_layout Standard
42354
42355 \size footnotesize
42356 \InsetSpace ~
42357 \InsetSpace ~
42358 subb a,#0x8a
42359 \end_layout
42360
42361 \begin_layout Standard
42362
42363 \size footnotesize
42364 \InsetSpace ~
42365 \InsetSpace ~
42366 jnc 00107$
42367 \end_layout
42368
42369 \begin_layout Standard
42370
42371 \size footnotesize
42372 00115$:
42373 \end_layout
42374
42375 \begin_layout Standard
42376
42377 \size footnotesize
42378 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
42379 \end_layout
42380
42381 \begin_layout Standard
42382
42383 \size footnotesize
42384 ; iTemp21 [lr21:38]{short}[r4]
42385 \end_layout
42386
42387 \begin_layout Standard
42388
42389 \size footnotesize
42390 \InsetSpace ~
42391 \InsetSpace ~
42392 mov a,r4
42393 \end_layout
42394
42395 \begin_layout Standard
42396
42397 \size footnotesize
42398 \InsetSpace ~
42399 \InsetSpace ~
42400 add a,r2
42401 \end_layout
42402
42403 \begin_layout Standard
42404
42405 \size footnotesize
42406 \InsetSpace ~
42407 \InsetSpace ~
42408 mov r2,a
42409 \end_layout
42410
42411 \begin_layout Standard
42412
42413 \size footnotesize
42414 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
42415 \end_layout
42416
42417 \begin_layout Standard
42418
42419 \size footnotesize
42420 \InsetSpace ~
42421 \InsetSpace ~
42422 mov b,#0x03
42423 \end_layout
42424
42425 \begin_layout Standard
42426
42427 \size footnotesize
42428 \InsetSpace ~
42429 \InsetSpace ~
42430 mov a,r4
42431 \end_layout
42432
42433 \begin_layout Standard
42434
42435 \size footnotesize
42436 \InsetSpace ~
42437 \InsetSpace ~
42438 mul ab
42439 \end_layout
42440
42441 \begin_layout Standard
42442
42443 \size footnotesize
42444 \InsetSpace ~
42445 \InsetSpace ~
42446 mov r1,a
42447 \end_layout
42448
42449 \begin_layout Standard
42450
42451 \size footnotesize
42452 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
42453 \end_layout
42454
42455 \begin_layout Standard
42456
42457 \size footnotesize
42458 ; iTemp15 [lr29:30]{short}[r1]
42459 \end_layout
42460
42461 \begin_layout Standard
42462
42463 \size footnotesize
42464 \InsetSpace ~
42465 \InsetSpace ~
42466 add a,r3
42467 \end_layout
42468
42469 \begin_layout Standard
42470
42471 \size footnotesize
42472 \InsetSpace ~
42473 \InsetSpace ~
42474 mov r3,a
42475 \end_layout
42476
42477 \begin_layout Standard
42478
42479 \size footnotesize
42480 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
42481 \end_layout
42482
42483 \begin_layout Standard
42484
42485 \size footnotesize
42486 \InsetSpace ~
42487 \InsetSpace ~
42488 mov a,r7
42489 \end_layout
42490
42491 \begin_layout Standard
42492
42493 \size footnotesize
42494 \InsetSpace ~
42495 \InsetSpace ~
42496 add a,#0xfd
42497 \end_layout
42498
42499 \begin_layout Standard
42500
42501 \size footnotesize
42502 \InsetSpace ~
42503 \InsetSpace ~
42504 mov r7,a
42505 \end_layout
42506
42507 \begin_layout Standard
42508
42509 \size footnotesize
42510 \InsetSpace ~
42511 \InsetSpace ~
42512 mov a,r0
42513 \end_layout
42514
42515 \begin_layout Standard
42516
42517 \size footnotesize
42518 \InsetSpace ~
42519 \InsetSpace ~
42520 addc a,#0xff
42521 \end_layout
42522
42523 \begin_layout Standard
42524
42525 \size footnotesize
42526 \InsetSpace ~
42527 \InsetSpace ~
42528 mov r0,a
42529 \end_layout
42530
42531 \begin_layout Standard
42532
42533 \size footnotesize
42534 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
42535 \end_layout
42536
42537 \begin_layout Standard
42538
42539 \size footnotesize
42540 \InsetSpace ~
42541 \InsetSpace ~
42542 mov a,r7
42543 \end_layout
42544
42545 \begin_layout Standard
42546
42547 \size footnotesize
42548 \InsetSpace ~
42549 \InsetSpace ~
42550 add a,_gint
42551 \end_layout
42552
42553 \begin_layout Standard
42554
42555 \size footnotesize
42556 \InsetSpace ~
42557 \InsetSpace ~
42558 mov _gint,a
42559 \end_layout
42560
42561 \begin_layout Standard
42562
42563 \size footnotesize
42564 \InsetSpace ~
42565 \InsetSpace ~
42566 mov a,r0
42567 \end_layout
42568
42569 \begin_layout Standard
42570
42571 \size footnotesize
42572 \InsetSpace ~
42573 \InsetSpace ~
42574 addc a,(_gint + 1)
42575 \end_layout
42576
42577 \begin_layout Standard
42578
42579 \size footnotesize
42580 \InsetSpace ~
42581 \InsetSpace ~
42582 mov (_gint + 1),a
42583 \end_layout
42584
42585 \begin_layout Standard
42586
42587 \size footnotesize
42588 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
42589 \end_layout
42590
42591 \begin_layout Standard
42592
42593 \size footnotesize
42594 \InsetSpace ~
42595 \InsetSpace ~
42596 inc r4
42597 \end_layout
42598
42599 \begin_layout Standard
42600
42601 \size footnotesize
42602 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
42603 \end_layout
42604
42605 \begin_layout Standard
42606
42607 \size footnotesize
42608 \InsetSpace ~
42609 \InsetSpace ~
42610 dec r5
42611 \end_layout
42612
42613 \begin_layout Standard
42614
42615 \size footnotesize
42616 \InsetSpace ~
42617 \InsetSpace ~
42618 cjne r5,#0xff,00104$
42619 \end_layout
42620
42621 \begin_layout Standard
42622
42623 \size footnotesize
42624 \InsetSpace ~
42625 \InsetSpace ~
42626 dec r6
42627 \end_layout
42628
42629 \begin_layout Standard
42630
42631 \size footnotesize
42632 ; goto _forcond_0($4)
42633 \end_layout
42634
42635 \begin_layout Standard
42636
42637 \size footnotesize
42638 \InsetSpace ~
42639 \InsetSpace ~
42640 sjmp 00104$
42641 \end_layout
42642
42643 \begin_layout Standard
42644
42645 \size footnotesize
42646 ; _forbreak_0($7) :
42647 \end_layout
42648
42649 \begin_layout Standard
42650
42651 \size footnotesize
42652 00107$:
42653 \end_layout
42654
42655 \begin_layout Standard
42656
42657 \size footnotesize
42658 ; ret iTemp24 [lr40:41]{short}
42659 \end_layout
42660
42661 \begin_layout Standard
42662
42663 \size footnotesize
42664 \InsetSpace ~
42665 \InsetSpace ~
42666 mov a,r3
42667 \end_layout
42668
42669 \begin_layout Standard
42670
42671 \size footnotesize
42672 \InsetSpace ~
42673 \InsetSpace ~
42674 add a,r2
42675 \end_layout
42676
42677 \begin_layout Standard
42678
42679 \size footnotesize
42680 \InsetSpace ~
42681 \InsetSpace ~
42682 mov dpl,a
42683 \end_layout
42684
42685 \begin_layout Standard
42686
42687 \size footnotesize
42688 ; _return($8) :
42689 \end_layout
42690
42691 \begin_layout Standard
42692
42693 \size footnotesize
42694 00108$:
42695 \end_layout
42696
42697 \begin_layout Standard
42698
42699 \size footnotesize
42700 \InsetSpace ~
42701 \InsetSpace ~
42702 ret
42703 \newline
42704
42705 \end_layout
42706
42707 \begin_layout Section
42708 A few words about basic block successors, predecessors and dominators
42709 \end_layout
42710
42711 \begin_layout Standard
42712 Successors are basic blocks
42713 \begin_inset LatexCommand index
42714 name "Basic blocks"
42715
42716 \end_inset
42717
42718  that might execute after this basic block.
42719 \newline
42720 Predecessors are basic blocks
42721  that might execute before reaching this basic block.
42722 \newline
42723 Dominators are basic
42724  blocks that WILL execute before reaching this basic block.
42725 \newline
42726
42727 \end_layout
42728
42729 \begin_layout Standard
42730 [basic block 1]
42731 \end_layout
42732
42733 \begin_layout Standard
42734 if (something)
42735 \end_layout
42736
42737 \begin_layout Standard
42738 \InsetSpace ~
42739 \InsetSpace ~
42740 \InsetSpace ~
42741 \InsetSpace ~
42742 [basic block 2]
42743 \end_layout
42744
42745 \begin_layout Standard
42746 else
42747 \end_layout
42748
42749 \begin_layout Standard
42750 \InsetSpace ~
42751 \InsetSpace ~
42752 \InsetSpace ~
42753 \InsetSpace ~
42754 [basic block 3]
42755 \end_layout
42756
42757 \begin_layout Standard
42758 [basic block 4]
42759 \newline
42760
42761 \end_layout
42762
42763 \begin_layout Standard
42764 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
42765 \end_layout
42766
42767 \begin_layout Standard
42768 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
42769 \end_layout
42770
42771 \begin_layout Standard
42772 c) domVect of [BB4] = BB1 ...
42773  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
42774  was executed.
42775 \end_layout
42776
42777 \begin_layout Chapter
42778 Acknowledgments
42779 \end_layout
42780
42781 \begin_layout Standard
42782 \begin_inset LatexCommand url
42783 target "http://sdcc.sourceforge.net/#Who"
42784
42785 \end_inset
42786
42787
42788 \newline
42789
42790 \newline
42791
42792 \emph on
42793 Thanks to all the other volunteer developers who have helped with coding,
42794  testing, web-page creation, distribution sets, etc.
42795  You know who you are :-)
42796 \emph default
42797
42798 \newline
42799
42800 \newline
42801
42802 \emph on
42803 Thanks to Sourceforge 
42804 \begin_inset LatexCommand url
42805 target "http://www.sf.net"
42806
42807 \end_inset
42808
42809  which has hosted the project since 1999 and donates significant download
42810  bandwidth.
42811 \emph default
42812
42813 \newline
42814
42815 \newline
42816
42817 \emph on
42818 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
42819  cycles and bandwidth for snapshot builds.
42820 \newline
42821
42822 \end_layout
42823
42824 \begin_layout Standard
42825 This document was initially written by Sandeep Dutta
42826 \end_layout
42827
42828 \begin_layout Standard
42829 All product names mentioned herein may be trademarks
42830 \begin_inset LatexCommand index
42831 name "Trademarks"
42832
42833 \end_inset
42834
42835  of their respective companies.
42836  
42837 \end_layout
42838
42839 \begin_layout Section*
42840 Alphabetical index
42841 \end_layout
42842
42843 \begin_layout Standard
42844 To avoid confusion, the installation and building options for SDCC itself
42845  (chapter 2) are not part of the index.
42846 \end_layout
42847
42848 \begin_layout Standard
42849 \begin_inset LatexCommand printindex
42850
42851 \end_inset
42852
42853
42854 \end_layout
42855
42856 \end_body
42857 \end_document