e60f1343e79cc7748165e7c1f4d6e5e10f2a1905
[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.8.9
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 HEAD_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, 2410, 2420, 2423, 2431, 2450, 2455, 2480,
25749  24j10
25750 \end_layout
25751
25752 \begin_layout Standard
25753 18F: (2510,) 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 2610, 2620,
25754  2680, 2682, 2685
25755 \end_layout
25756
25757 \begin_layout Standard
25758 18F: 4220, 4221, 4320, 4321, 4331, 4410, 4420, 4423, 4431, 4450, 4455, 4480,
25759  44j10
25760 \end_layout
25761
25762 \begin_layout Standard
25763 18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 4610, 4620,
25764  4680, 4682, 4685
25765 \end_layout
25766
25767 \begin_layout Standard
25768 18F: 6520, 6585, 6620, 6680, 66j60, 66j65, 6720, 67j60
25769 \end_layout
25770
25771 \begin_layout Standard
25772 18F: 8520, 8585, 8620, 8680, 86j60, 86j65, 8720, 87j60
25773 \end_layout
25774
25775 \begin_layout Standard
25776 18F: 96j60, 96j65, 97j60
25777 \end_layout
25778
25779 \begin_layout Standard
25780 \noindent
25781 An up-to-date list of supported devices is also available via '
25782 \family typewriter
25783 sdcc -mpic16 -plist
25784 \family default
25785 '.
25786 \end_layout
25787
25788 \begin_layout Subsection
25789 Global Options
25790 \end_layout
25791
25792 \begin_layout Standard
25793 PIC16 port supports the standard command line arguments as supposed, with
25794  the exception of certain cases that will be mentioned in the following
25795  list:
25796 \end_layout
25797
25798 \begin_layout Description
25799 -
25800 \begin_inset ERT
25801 status collapsed
25802
25803 \begin_layout Standard
25804
25805
25806 \backslash
25807 /
25808 \end_layout
25809
25810 \end_inset
25811
25812 -callee-saves
25813 \begin_inset LatexCommand index
25814 name "PIC16!Options!-\\/-callee-saves"
25815
25816 \end_inset
25817
25818  See -
25819 \begin_inset ERT
25820 status collapsed
25821
25822 \begin_layout Standard
25823
25824
25825 \backslash
25826 /
25827 \end_layout
25828
25829 \end_inset
25830
25831 -all-callee-saves
25832 \end_layout
25833
25834 \begin_layout Description
25835 -
25836 \begin_inset ERT
25837 status collapsed
25838
25839 \begin_layout Standard
25840
25841
25842 \backslash
25843 /
25844 \end_layout
25845
25846 \end_inset
25847
25848 -fommit-frame-pointer
25849 \begin_inset LatexCommand index
25850 name "PIC16!Options!-\\/-fommit-frame-pointer"
25851
25852 \end_inset
25853
25854  Frame pointer will be omitted when the function uses no local variables.
25855 \end_layout
25856
25857 \begin_layout Subsection
25858 Port Specific Options
25859 \begin_inset LatexCommand index
25860 name "Options PIC16"
25861
25862 \end_inset
25863
25864
25865 \end_layout
25866
25867 \begin_layout Standard
25868 The port specific options appear after the global options in the sdcc -
25869 \begin_inset ERT
25870 status collapsed
25871
25872 \begin_layout Standard
25873
25874
25875 \backslash
25876 /
25877 \end_layout
25878
25879 \end_inset
25880
25881 -help output.
25882 \end_layout
25883
25884 \begin_layout Subsubsection
25885 Code Generation Options
25886 \end_layout
25887
25888 \begin_layout Standard
25889 These options influence the generated assembler code.
25890 \end_layout
25891
25892 \begin_layout Description
25893 -
25894 \begin_inset ERT
25895 status collapsed
25896
25897 \begin_layout Standard
25898
25899
25900 \backslash
25901 /
25902 \end_layout
25903
25904 \end_inset
25905
25906 -pstack-model=[model] Used in conjunction with the command above.
25907  Defines the stack model to be used, valid stack models are:
25908 \end_layout
25909
25910 \begin_deeper
25911 \begin_layout List
25912 \labelwidthstring 00.00.0000
25913
25914 \emph on
25915 small
25916 \emph default
25917  Selects small stack model.
25918  8 bit stack and frame pointers.
25919  Supports 256 bytes stack size.
25920 \end_layout
25921
25922 \begin_layout List
25923 \labelwidthstring 00.00.0000
25924
25925 \emph on
25926 large
25927 \emph default
25928  Selects large stack model.
25929  16 bit stack and frame pointers.
25930  Supports 65536 bytes stack size.
25931 \end_layout
25932
25933 \end_deeper
25934 \begin_layout Description
25935 -
25936 \begin_inset ERT
25937 status collapsed
25938
25939 \begin_layout Standard
25940
25941
25942 \backslash
25943 /
25944 \end_layout
25945
25946 \end_inset
25947
25948 -pno-banksel Do not generate BANKSEL assembler directives.
25949 \end_layout
25950
25951 \begin_layout Description
25952 -
25953 \begin_inset ERT
25954 status collapsed
25955
25956 \begin_layout Standard
25957
25958
25959 \backslash
25960 /
25961 \end_layout
25962
25963 \end_inset
25964
25965 -extended Enable extended instruction set/literal offset addressing mode.
25966  Use with care!
25967 \end_layout
25968
25969 \begin_layout Subsubsection
25970 Optimization Options
25971 \end_layout
25972
25973 \begin_layout Description
25974 -
25975 \begin_inset ERT
25976 status collapsed
25977
25978 \begin_layout Standard
25979
25980
25981 \backslash
25982 /
25983 \end_layout
25984
25985 \end_inset
25986
25987 -obanksel=n Set optimization level for inserting BANKSELs.
25988 \newline
25989
25990 \end_layout
25991
25992 \begin_deeper
25993 \begin_layout List
25994 \labelwidthstring 00.00.0000
25995 0 no optimization
25996 \end_layout
25997
25998 \begin_layout List
25999 \labelwidthstring 00.00.0000
26000 1 checks previous used register and if it is the same then does not emit
26001  BANKSEL, accounts only for labels.
26002 \end_layout
26003
26004 \begin_layout List
26005 \labelwidthstring 00.00.0000
26006 2 tries to check the location of (even different) symbols and removes BANKSELs
26007  if they are in the same bank.
26008  
26009 \newline
26010
26011 \emph on
26012 Important: There might be problems if the linker script has data sections
26013  across bank borders!
26014 \end_layout
26015
26016 \end_deeper
26017 \begin_layout Description
26018 -
26019 \begin_inset ERT
26020 status collapsed
26021
26022 \begin_layout Standard
26023
26024
26025 \backslash
26026 /
26027 \end_layout
26028
26029 \end_inset
26030
26031 -denable-peeps Force the usage of peepholes.
26032  Use with care.
26033 \end_layout
26034
26035 \begin_layout Description
26036 -
26037 \begin_inset ERT
26038 status collapsed
26039
26040 \begin_layout Standard
26041
26042
26043 \backslash
26044 /
26045 \end_layout
26046
26047 \end_inset
26048
26049 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
26050 \end_layout
26051
26052 \begin_layout Description
26053 -
26054 \begin_inset ERT
26055 status collapsed
26056
26057 \begin_layout Standard
26058
26059
26060 \backslash
26061 /
26062 \end_layout
26063
26064 \end_inset
26065
26066 -optimize-cmp Try to optimize some compares.
26067 \end_layout
26068
26069 \begin_layout Description
26070 -
26071 \begin_inset ERT
26072 status collapsed
26073
26074 \begin_layout Standard
26075
26076
26077 \backslash
26078 /
26079 \end_layout
26080
26081 \end_inset
26082
26083 -optimize-df Analyze the dataflow of the generated code and improve it.
26084 \end_layout
26085
26086 \begin_layout Subsubsection
26087 Assembling Options
26088 \end_layout
26089
26090 \begin_layout Description
26091 -
26092 \begin_inset ERT
26093 status collapsed
26094
26095 \begin_layout Standard
26096
26097
26098 \backslash
26099 /
26100 \end_layout
26101
26102 \end_inset
26103
26104 -asm= Sets the full path and name of an external assembler to call.
26105 \end_layout
26106
26107 \begin_layout Description
26108 -
26109 \begin_inset ERT
26110 status collapsed
26111
26112 \begin_layout Standard
26113
26114
26115 \backslash
26116 /
26117 \end_layout
26118
26119 \end_inset
26120
26121 -mplab-comp MPLAB
26122 \begin_inset LatexCommand index
26123 name "PIC16!MPLAB"
26124
26125 \end_inset
26126
26127  compatibility option.
26128  Currently only suppresses special gpasm directives.
26129 \end_layout
26130
26131 \begin_layout Subsubsection
26132 Linking Options
26133 \end_layout
26134
26135 \begin_layout Description
26136 -
26137 \begin_inset ERT
26138 status collapsed
26139
26140 \begin_layout Standard
26141
26142
26143 \backslash
26144 /
26145 \end_layout
26146
26147 \end_inset
26148
26149 -link= Sets the full path and name of an external linker to call.
26150 \end_layout
26151
26152 \begin_layout Description
26153 -
26154 \begin_inset ERT
26155 status collapsed
26156
26157 \begin_layout Standard
26158
26159
26160 \backslash
26161 /
26162 \end_layout
26163
26164 \end_inset
26165
26166 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
26167  unitialized data variables with [kword].
26168  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
26169 \end_layout
26170
26171 \begin_layout Description
26172 -
26173 \begin_inset ERT
26174 status collapsed
26175
26176 \begin_layout Standard
26177
26178
26179 \backslash
26180 /
26181 \end_layout
26182
26183 \end_inset
26184
26185 -ivt-loc=n Place the interrupt vector table at address 
26186 \emph on
26187 n
26188 \emph default
26189 .
26190  Useful for bootloaders.
26191 \end_layout
26192
26193 \begin_layout Description
26194 -
26195 \begin_inset ERT
26196 status collapsed
26197
26198 \begin_layout Standard
26199
26200
26201 \backslash
26202 /
26203 \end_layout
26204
26205 \end_inset
26206
26207 -nodefaultlibs Do not link default libraries when linking.
26208 \end_layout
26209
26210 \begin_layout Description
26211 -
26212 \begin_inset ERT
26213 status collapsed
26214
26215 \begin_layout Standard
26216
26217
26218 \backslash
26219 /
26220 \end_layout
26221
26222 \end_inset
26223
26224 -use-crt= Use a custom run-time module instead of the defaults.
26225 \end_layout
26226
26227 \begin_layout Description
26228 -
26229 \begin_inset ERT
26230 status collapsed
26231
26232 \begin_layout Standard
26233
26234
26235 \backslash
26236 /
26237 \end_layout
26238
26239 \end_inset
26240
26241 -no-crt Don't link the default run-time modules
26242 \end_layout
26243
26244 \begin_layout Subsubsection
26245 Debugging Options
26246 \end_layout
26247
26248 \begin_layout Standard
26249 Debugging options enable extra debugging information in the output files.
26250 \end_layout
26251
26252 \begin_layout Description
26253 -
26254 \begin_inset ERT
26255 status collapsed
26256
26257 \begin_layout Standard
26258
26259
26260 \backslash
26261 /
26262 \end_layout
26263
26264 \end_inset
26265
26266 -debug-xtra Similar to -
26267 \begin_inset ERT
26268 status collapsed
26269
26270 \begin_layout Standard
26271
26272
26273 \backslash
26274 /
26275 \end_layout
26276
26277 \end_inset
26278
26279 -debug
26280 \begin_inset LatexCommand index
26281 name "-\\/-debug"
26282
26283 \end_inset
26284
26285 , but dumps more information.
26286 \end_layout
26287
26288 \begin_layout Description
26289 -
26290 \begin_inset ERT
26291 status collapsed
26292
26293 \begin_layout Standard
26294
26295
26296 \backslash
26297 /
26298 \end_layout
26299
26300 \end_inset
26301
26302 -debug-ralloc Force register allocator to dump <source>.d file with debugging
26303  information.
26304  <source> is the name of the file being compiled.
26305 \end_layout
26306
26307 \begin_layout Description
26308 -
26309 \begin_inset ERT
26310 status collapsed
26311
26312 \begin_layout Standard
26313
26314
26315 \backslash
26316 /
26317 \end_layout
26318
26319 \end_inset
26320
26321 -pcode-verbose Enable pcode debugging information in translation.
26322 \end_layout
26323
26324 \begin_layout Description
26325 -
26326 \begin_inset ERT
26327 status collapsed
26328
26329 \begin_layout Standard
26330
26331
26332 \backslash
26333 /
26334 \end_layout
26335
26336 \end_inset
26337
26338 -calltree Dump call tree in .calltree file.
26339 \end_layout
26340
26341 \begin_layout Description
26342 -
26343 \begin_inset ERT
26344 status collapsed
26345
26346 \begin_layout Standard
26347
26348
26349 \backslash
26350 /
26351 \end_layout
26352
26353 \end_inset
26354
26355 -gstack Trace push/pops for stack pointer overflow.
26356 \end_layout
26357
26358 \begin_layout Subsection
26359 Environment Variables
26360 \end_layout
26361
26362 \begin_layout Standard
26363 There is a number of environmental variables that can be used when running
26364  SDCC to enable certain optimizations or force a specific program behaviour.
26365  these variables are primarily for debugging purposes so they can be enabled/dis
26366 abled at will.
26367 \end_layout
26368
26369 \begin_layout Standard
26370 Currently there is only two such variables available:
26371 \end_layout
26372
26373 \begin_layout Description
26374 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
26375  bitfields is optimized by directly loading FSR0 with the address of the
26376  bitfield structure.
26377  Normally SDCC will cast the bitfield structure to a bitfield pointer and
26378  then load FSR0.
26379  This step saves data ram and code space for functions that make heavy use
26380  of bitfields.
26381  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
26382  option).
26383  
26384 \end_layout
26385
26386 \begin_layout Description
26387 NO_REG_OPT Do not perform pCode registers optimization.
26388  This should be used for debugging purposes.
26389  If bugs in the pcode optimizer are found, users can benefit from temporarily
26390  disabling the optimizer until the bug is fixed.
26391 \end_layout
26392
26393 \begin_layout Subsection
26394 Preprocessor Macros
26395 \end_layout
26396
26397 \begin_layout Standard
26398 PIC16
26399 \begin_inset LatexCommand index
26400 name "PIC16"
26401
26402 \end_inset
26403
26404  port defines the following preprocessor macros while translating a source.
26405 \end_layout
26406
26407 \begin_layout Standard
26408 \align center
26409 \begin_inset Tabular
26410 <lyxtabular version="3" rows="6" columns="2">
26411 <features>
26412 <column alignment="center" valignment="top" leftline="true" width="0">
26413 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26414 <row topline="true" bottomline="true">
26415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26416 \begin_inset Text
26417
26418 \begin_layout Standard
26419 Macro
26420 \end_layout
26421
26422 \end_inset
26423 </cell>
26424 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26425 \begin_inset Text
26426
26427 \begin_layout Standard
26428 Description
26429 \end_layout
26430
26431 \end_inset
26432 </cell>
26433 </row>
26434 <row topline="true">
26435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26436 \begin_inset Text
26437
26438 \begin_layout Standard
26439 SDCC_pic16
26440 \end_layout
26441
26442 \end_inset
26443 </cell>
26444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26445 \begin_inset Text
26446
26447 \begin_layout Standard
26448 Port identification
26449 \end_layout
26450
26451 \end_inset
26452 </cell>
26453 </row>
26454 <row topline="true">
26455 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26456 \begin_inset Text
26457
26458 \begin_layout Standard
26459 _
26460 \begin_inset ERT
26461 status collapsed
26462
26463 \begin_layout Standard
26464
26465
26466 \backslash
26467 /
26468 \end_layout
26469
26470 \end_inset
26471
26472 _pic16
26473 \end_layout
26474
26475 \end_inset
26476 </cell>
26477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26478 \begin_inset Text
26479
26480 \begin_layout Standard
26481 Port identification (same as above)
26482 \end_layout
26483
26484 \end_inset
26485 </cell>
26486 </row>
26487 <row topline="true">
26488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26489 \begin_inset Text
26490
26491 \begin_layout Standard
26492 pic18fxxxx
26493 \end_layout
26494
26495 \end_inset
26496 </cell>
26497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26498 \begin_inset Text
26499
26500 \begin_layout Standard
26501 MCU Identification.
26502  
26503 \emph on
26504 xxxx
26505 \emph default
26506  is the microcontrol identification number, i.e.
26507  452, 6620, etc
26508 \end_layout
26509
26510 \end_inset
26511 </cell>
26512 </row>
26513 <row topline="true">
26514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26515 \begin_inset Text
26516
26517 \begin_layout Standard
26518 _
26519 \begin_inset ERT
26520 status collapsed
26521
26522 \begin_layout Standard
26523
26524
26525 \backslash
26526 /
26527 \end_layout
26528
26529 \end_inset
26530
26531 _18Fxxxx
26532 \end_layout
26533
26534 \end_inset
26535 </cell>
26536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26537 \begin_inset Text
26538
26539 \begin_layout Standard
26540 MCU Identification (same as above)
26541 \end_layout
26542
26543 \end_inset
26544 </cell>
26545 </row>
26546 <row topline="true" bottomline="true">
26547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26548 \begin_inset Text
26549
26550 \begin_layout Standard
26551 STACK_MODEL_nnn
26552 \end_layout
26553
26554 \end_inset
26555 </cell>
26556 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26557 \begin_inset Text
26558
26559 \begin_layout Standard
26560 nnn = SMALL or LARGE respectively according to the stack model used
26561 \end_layout
26562
26563 \end_inset
26564 </cell>
26565 </row>
26566 </lyxtabular>
26567
26568 \end_inset
26569
26570
26571 \end_layout
26572
26573 \begin_layout Standard
26574 \noindent
26575 In addition the following macros are defined when calling assembler:
26576 \end_layout
26577
26578 \begin_layout Standard
26579 \align center
26580 \begin_inset Tabular
26581 <lyxtabular version="3" rows="4" columns="2">
26582 <features>
26583 <column alignment="center" valignment="top" leftline="true" width="0">
26584 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26585 <row topline="true" bottomline="true">
26586 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26587 \begin_inset Text
26588
26589 \begin_layout Standard
26590 Macro
26591 \end_layout
26592
26593 \end_inset
26594 </cell>
26595 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26596 \begin_inset Text
26597
26598 \begin_layout Standard
26599 Description
26600 \end_layout
26601
26602 \end_inset
26603 </cell>
26604 </row>
26605 <row topline="true">
26606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26607 \begin_inset Text
26608
26609 \begin_layout Standard
26610 __18Fxxxx
26611 \end_layout
26612
26613 \end_inset
26614 </cell>
26615 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26616 \begin_inset Text
26617
26618 \begin_layout Standard
26619 MCU Identification.
26620  
26621 \emph on
26622 xxxx
26623 \emph default
26624  is the microcontrol identification number, i.e.
26625  452, 6620, etc
26626 \end_layout
26627
26628 \end_inset
26629 </cell>
26630 </row>
26631 <row topline="true">
26632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26633 \begin_inset Text
26634
26635 \begin_layout Standard
26636 SDCC_MODEL_nnn
26637 \end_layout
26638
26639 \end_inset
26640 </cell>
26641 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26642 \begin_inset Text
26643
26644 \begin_layout Standard
26645 nnn = SMALL or LARGE respectively according to the memory model used for
26646  SDCC
26647 \end_layout
26648
26649 \end_inset
26650 </cell>
26651 </row>
26652 <row topline="true" bottomline="true">
26653 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26654 \begin_inset Text
26655
26656 \begin_layout Standard
26657 STACK_MODEL_nnn
26658 \end_layout
26659
26660 \end_inset
26661 </cell>
26662 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26663 \begin_inset Text
26664
26665 \begin_layout Standard
26666 nnn = SMALL or LARGE respectively according to the stack model used
26667 \end_layout
26668
26669 \end_inset
26670 </cell>
26671 </row>
26672 </lyxtabular>
26673
26674 \end_inset
26675
26676
26677 \end_layout
26678
26679 \begin_layout Subsection
26680 Directories
26681 \end_layout
26682
26683 \begin_layout Standard
26684 PIC16
26685 \begin_inset LatexCommand index
26686 name "PIC16"
26687
26688 \end_inset
26689
26690  port uses the following directories for searching header files and libraries.
26691 \end_layout
26692
26693 \begin_layout Standard
26694 \align center
26695 \begin_inset Tabular
26696 <lyxtabular version="3" rows="3" columns="4">
26697 <features>
26698 <column alignment="center" valignment="top" leftline="true" width="0">
26699 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26700 <column alignment="center" valignment="top" width="0">
26701 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26702 <row topline="true" bottomline="true">
26703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26704 \begin_inset Text
26705
26706 \begin_layout Standard
26707 Directory
26708 \end_layout
26709
26710 \end_inset
26711 </cell>
26712 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26713 \begin_inset Text
26714
26715 \begin_layout Standard
26716 Description
26717 \end_layout
26718
26719 \end_inset
26720 </cell>
26721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26722 \begin_inset Text
26723
26724 \begin_layout Standard
26725 Target
26726 \end_layout
26727
26728 \end_inset
26729 </cell>
26730 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26731 \begin_inset Text
26732
26733 \begin_layout Standard
26734 Command prefix
26735 \end_layout
26736
26737 \end_inset
26738 </cell>
26739 </row>
26740 <row topline="true">
26741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26742 \begin_inset Text
26743
26744 \begin_layout Standard
26745 PREFIX/sdcc/include/pic16
26746 \end_layout
26747
26748 \end_inset
26749 </cell>
26750 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26751 \begin_inset Text
26752
26753 \begin_layout Standard
26754 PIC16 specific headers
26755 \end_layout
26756
26757 \end_inset
26758 </cell>
26759 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26760 \begin_inset Text
26761
26762 \begin_layout Standard
26763 Compiler
26764 \end_layout
26765
26766 \end_inset
26767 </cell>
26768 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26769 \begin_inset Text
26770
26771 \begin_layout Standard
26772 -I
26773 \end_layout
26774
26775 \end_inset
26776 </cell>
26777 </row>
26778 <row topline="true" bottomline="true">
26779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26780 \begin_inset Text
26781
26782 \begin_layout Standard
26783 PREFIX/sdcc/lib/pic16
26784 \end_layout
26785
26786 \end_inset
26787 </cell>
26788 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26789 \begin_inset Text
26790
26791 \begin_layout Standard
26792 PIC16 specific libraries
26793 \end_layout
26794
26795 \end_inset
26796 </cell>
26797 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26798 \begin_inset Text
26799
26800 \begin_layout Standard
26801 Linker
26802 \end_layout
26803
26804 \end_inset
26805 </cell>
26806 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26807 \begin_inset Text
26808
26809 \begin_layout Standard
26810 -L
26811 \end_layout
26812
26813 \end_inset
26814 </cell>
26815 </row>
26816 </lyxtabular>
26817
26818 \end_inset
26819
26820
26821 \end_layout
26822
26823 \begin_layout Subsection
26824 Pragmas
26825 \begin_inset LatexCommand label
26826 name "sub:PIC16_Pragmas"
26827
26828 \end_inset
26829
26830
26831 \end_layout
26832
26833 \begin_layout Standard
26834 The PIC16
26835 \begin_inset LatexCommand index
26836 name "PIC16"
26837
26838 \end_inset
26839
26840  port currently supports the following pragmas:
26841 \end_layout
26842
26843 \begin_layout Description
26844 stack
26845 \begin_inset LatexCommand index
26846 name "PIC16!Pragmas!\\#pragma stack"
26847
26848 \end_inset
26849
26850  This forces the code generator to initialize the stack & frame pointers
26851  at a specific address.
26852  This is an ad hoc solution for cases where no STACK directive is available
26853  in the linker script or gplink is not instructed to create a stack section.
26854 \newline
26855 The
26856  stack pragma should be used only once in a project.
26857  Multiple pragmas may result in indeterminate behaviour of the program.
26858 \begin_inset Foot
26859 status open
26860
26861 \begin_layout Standard
26862 The old format (ie.
26863  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
26864  cross page boundaries (or even exceed the available data RAM) and crash
26865  the program.
26866  Make sure that stack does not cross page boundaries when using the SMALL
26867  stack model.
26868 \end_layout
26869
26870 \end_inset
26871
26872
26873 \newline
26874 The format is as follows:
26875 \newline
26876
26877 \end_layout
26878
26879 \begin_layout LyX-Code
26880 #pragma stack bottom_address [stack_size]
26881 \newline
26882
26883 \end_layout
26884
26885 \begin_layout Standard
26886
26887 \emph on
26888 bottom_address
26889 \emph default
26890  is the lower bound of the stack section.
26891  The stack pointer initially will point at address (bottom_address+stack_size-1).
26892 \end_layout
26893
26894 \begin_layout LyX-Code
26895 Example:
26896 \end_layout
26897
26898 \begin_layout LyX-Code
26899
26900 \end_layout
26901
26902 \begin_layout LyX-Code
26903 /* initializes stack of 100 bytes at RAM address 0x200 */
26904 \end_layout
26905
26906 \begin_layout LyX-Code
26907 #pragma stack 0x200 100
26908 \end_layout
26909
26910 \begin_layout Standard
26911 If the stack_size field is omitted then a stack is created with the default
26912  size of 64.
26913  This size might be enough for most programs, but its not enough for operations
26914  with deep function nesting or excessive stack usage.
26915 \end_layout
26916
26917 \begin_layout Description
26918 code
26919 \begin_inset LatexCommand index
26920 name "PIC16!Pragmas!\\#pragma code"
26921
26922 \end_inset
26923
26924  Force a function to a static FLASH address.
26925 \end_layout
26926
26927 \begin_layout LyX-Code
26928 Example:
26929 \end_layout
26930
26931 \begin_layout LyX-Code
26932
26933 \end_layout
26934
26935 \begin_layout LyX-Code
26936 /* place function test_func at 0x4000 */
26937 \end_layout
26938
26939 \begin_layout LyX-Code
26940 #pragma code test_func 0x4000
26941 \end_layout
26942
26943 \begin_layout LyX-Code
26944
26945 \end_layout
26946
26947 \begin_layout Description
26948 library instructs the linker to use a library module.
26949 \newline
26950 Usage:
26951 \end_layout
26952
26953 \begin_layout LyX-Code
26954 #pragma library module_name
26955 \end_layout
26956
26957 \begin_layout Standard
26958
26959 \emph on
26960 module_name
26961 \emph default
26962  can be any library or object file (including its path).
26963  Note that there are four reserved keywords which have special meaning.
26964  These are:
26965 \end_layout
26966
26967 \begin_layout Standard
26968 \align center
26969 \begin_inset Tabular
26970 <lyxtabular version="3" rows="6" columns="3">
26971 <features>
26972 <column alignment="center" valignment="top" leftline="true" width="0">
26973 <column alignment="block" valignment="top" leftline="true" width="20page%">
26974 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
26975 <row topline="true" bottomline="true">
26976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26977 \begin_inset Text
26978
26979 \begin_layout Standard
26980 Keyword
26981 \end_layout
26982
26983 \end_inset
26984 </cell>
26985 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26986 \begin_inset Text
26987
26988 \begin_layout Standard
26989 Description
26990 \end_layout
26991
26992 \end_inset
26993 </cell>
26994 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26995 \begin_inset Text
26996
26997 \begin_layout Standard
26998 Module to link
26999 \end_layout
27000
27001 \end_inset
27002 </cell>
27003 </row>
27004 <row topline="true">
27005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27006 \begin_inset Text
27007
27008 \begin_layout Standard
27009
27010 \series bold
27011 ignore
27012 \end_layout
27013
27014 \end_inset
27015 </cell>
27016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27017 \begin_inset Text
27018
27019 \begin_layout Standard
27020 ignore all library pragmas
27021 \end_layout
27022
27023 \end_inset
27024 </cell>
27025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27026 \begin_inset Text
27027
27028 \begin_layout Standard
27029
27030 \emph on
27031 (none)
27032 \end_layout
27033
27034 \end_inset
27035 </cell>
27036 </row>
27037 <row topline="true">
27038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27039 \begin_inset Text
27040
27041 \begin_layout Standard
27042
27043 \series bold
27044 c
27045 \end_layout
27046
27047 \end_inset
27048 </cell>
27049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27050 \begin_inset Text
27051
27052 \begin_layout Standard
27053 link the C library
27054 \end_layout
27055
27056 \end_inset
27057 </cell>
27058 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27059 \begin_inset Text
27060
27061 \begin_layout Standard
27062
27063 \emph on
27064 libc18f
27065 \emph default
27066 .lib
27067 \end_layout
27068
27069 \end_inset
27070 </cell>
27071 </row>
27072 <row topline="true">
27073 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27074 \begin_inset Text
27075
27076 \begin_layout Standard
27077
27078 \series bold
27079 math
27080 \end_layout
27081
27082 \end_inset
27083 </cell>
27084 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27085 \begin_inset Text
27086
27087 \begin_layout Standard
27088 link the Math libarary
27089 \end_layout
27090
27091 \end_inset
27092 </cell>
27093 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27094 \begin_inset Text
27095
27096 \begin_layout Standard
27097
27098 \emph on
27099 libm18f
27100 \emph default
27101 .lib
27102 \end_layout
27103
27104 \end_inset
27105 </cell>
27106 </row>
27107 <row topline="true">
27108 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27109 \begin_inset Text
27110
27111 \begin_layout Standard
27112
27113 \series bold
27114 io
27115 \end_layout
27116
27117 \end_inset
27118 </cell>
27119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27120 \begin_inset Text
27121
27122 \begin_layout Standard
27123 link the I/O library
27124 \end_layout
27125
27126 \end_inset
27127 </cell>
27128 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27129 \begin_inset Text
27130
27131 \begin_layout Standard
27132
27133 \emph on
27134 libio18f*
27135 \emph default
27136 .lib
27137 \end_layout
27138
27139 \end_inset
27140 </cell>
27141 </row>
27142 <row topline="true" bottomline="true">
27143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27144 \begin_inset Text
27145
27146 \begin_layout Standard
27147
27148 \series bold
27149 debug
27150 \end_layout
27151
27152 \end_inset
27153 </cell>
27154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27155 \begin_inset Text
27156
27157 \begin_layout Standard
27158 link the debug library
27159 \end_layout
27160
27161 \end_inset
27162 </cell>
27163 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27164 \begin_inset Text
27165
27166 \begin_layout Standard
27167
27168 \emph on
27169 libdebug
27170 \emph default
27171 .lib
27172 \end_layout
27173
27174 \end_inset
27175 </cell>
27176 </row>
27177 </lyxtabular>
27178
27179 \end_inset
27180
27181
27182 \newline
27183 * is the device number, i.e.
27184  452 for PIC18F452 MCU.
27185 \end_layout
27186
27187 \begin_layout Standard
27188 \noindent
27189 This feature allows for linking with specific libraries without having to
27190  explicit name them in the command line.
27191  Note that the 
27192 \noun on
27193 ignore
27194 \noun default
27195  keyword will reject all modules specified by the library pragma.
27196 \end_layout
27197
27198 \begin_layout Description
27199 udata The pragma udata instructs the compiler to emit code so that linker
27200  will place a variable at a specific memory bank.
27201 \end_layout
27202
27203 \begin_layout LyX-Code
27204 Example:
27205 \end_layout
27206
27207 \begin_layout LyX-Code
27208
27209 \end_layout
27210
27211 \begin_layout LyX-Code
27212 /* places variable foo at bank2 */
27213 \end_layout
27214
27215 \begin_layout LyX-Code
27216 #pragma udata bank2 foo
27217 \end_layout
27218
27219 \begin_layout LyX-Code
27220 char foo;
27221 \end_layout
27222
27223 \begin_layout Standard
27224 In order for this pragma to work extra SECTION directives should be added
27225  in the .lkr script.
27226  In the following example a sample .lkr file is shown:
27227 \end_layout
27228
27229 \begin_layout LyX-Code
27230
27231 \end_layout
27232
27233 \begin_layout LyX-Code
27234 // Sample linker script for the PIC18F452 processor
27235 \end_layout
27236
27237 \begin_layout LyX-Code
27238 LIBPATH .
27239 \end_layout
27240
27241 \begin_layout LyX-Code
27242 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
27243 \end_layout
27244
27245 \begin_layout LyX-Code
27246 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
27247 \end_layout
27248
27249 \begin_layout LyX-Code
27250 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
27251 \end_layout
27252
27253 \begin_layout LyX-Code
27254 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
27255 \end_layout
27256
27257 \begin_layout LyX-Code
27258 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
27259 \end_layout
27260
27261 \begin_layout LyX-Code
27262 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
27263 \end_layout
27264
27265 \begin_layout LyX-Code
27266 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
27267 \end_layout
27268
27269 \begin_layout LyX-Code
27270
27271 \end_layout
27272
27273 \begin_layout LyX-Code
27274 DATABANK   NAME=gpr0       START=0x80           END=0xFF
27275 \end_layout
27276
27277 \begin_layout LyX-Code
27278 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
27279 \end_layout
27280
27281 \begin_layout LyX-Code
27282 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
27283 \end_layout
27284
27285 \begin_layout LyX-Code
27286 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
27287 \end_layout
27288
27289 \begin_layout LyX-Code
27290 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
27291 \end_layout
27292
27293 \begin_layout LyX-Code
27294 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
27295 \end_layout
27296
27297 \begin_layout LyX-Code
27298 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
27299 \end_layout
27300
27301 \begin_layout LyX-Code
27302
27303 \end_layout
27304
27305 \begin_layout LyX-Code
27306 SECTION    NAME=CONFIG     ROM=config
27307 \end_layout
27308
27309 \begin_layout LyX-Code
27310
27311 \end_layout
27312
27313 \begin_layout LyX-Code
27314 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
27315 \end_layout
27316
27317 \begin_layout LyX-Code
27318 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
27319 \end_layout
27320
27321 \begin_layout LyX-Code
27322 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
27323 \end_layout
27324
27325 \begin_layout LyX-Code
27326 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
27327 \end_layout
27328
27329 \begin_layout LyX-Code
27330 SECTION    NAME=bank4      RAM=gpr4
27331 \end_layout
27332
27333 \begin_layout LyX-Code
27334 SECTION    NAME=bank5      RAM=gpr5
27335 \end_layout
27336
27337 \begin_layout Standard
27338 The linker will recognise the section name set in the pragma statement and
27339  will position the variable at the memory bank set with the RAM field at
27340  the SECTION line in the linker script file.
27341 \end_layout
27342
27343 \begin_layout Subsection
27344 Header Files
27345 \begin_inset LatexCommand label
27346 name "sub:PIC16_Header-Files"
27347
27348 \end_inset
27349
27350
27351 \end_layout
27352
27353 \begin_layout Standard
27354 There is one main header file
27355 \begin_inset LatexCommand index
27356 name "PIC16!Header files"
27357
27358 \end_inset
27359
27360  that can be included to the source files using the pic16
27361 \begin_inset LatexCommand index
27362 name "PIC16"
27363
27364 \end_inset
27365
27366  port.
27367  That file is the 
27368 \series bold
27369 pic18fregs.h
27370 \series default
27371 .
27372  This header file contains the definitions for the processor special registers,
27373  so it is necessary if the source accesses them.
27374  It can be included by adding the following line in the beginning of the
27375  file:
27376 \end_layout
27377
27378 \begin_layout LyX-Code
27379 #include <pic18fregs.h>
27380 \end_layout
27381
27382 \begin_layout Standard
27383 The specific microcontroller is selected within the pic18fregs.h automatically,
27384  so the same source can be used with a variety of devices.
27385 \end_layout
27386
27387 \begin_layout Subsection
27388 Libraries
27389 \begin_inset LatexCommand label
27390 name "sub:pic16Libraries"
27391
27392 \end_inset
27393
27394
27395 \end_layout
27396
27397 \begin_layout Standard
27398 The libraries
27399 \begin_inset LatexCommand index
27400 name "PIC16!Libraries"
27401
27402 \end_inset
27403
27404  that PIC16
27405 \begin_inset LatexCommand index
27406 name "PIC16"
27407
27408 \end_inset
27409
27410  port depends on are the microcontroller device libraries which contain
27411  the symbol definitions for the microcontroller special function registers.
27412  These libraries have the format pic18fxxxx.lib, where 
27413 \emph on
27414 xxxx
27415 \emph default
27416  is the microcontroller identification number.
27417  The specific library is selected automatically by the compiler at link
27418  stage according to the selected device.
27419 \end_layout
27420
27421 \begin_layout Standard
27422 \noindent
27423 Libraries are created with gplib which is part of the gputils package 
27424 \begin_inset LatexCommand url
27425 target "http://sourceforge.net/projects/gputils"
27426
27427 \end_inset
27428
27429 .
27430 \end_layout
27431
27432 \begin_layout Subsubsection*
27433 Building the libraries
27434 \end_layout
27435
27436 \begin_layout Standard
27437 Before using SDCC/pic16 there are some libraries that need to be compiled.
27438  This process is done automatically if gputils are found at SDCC's compile
27439  time.
27440  Should you require to rebuild the pic16 libraries manually (e.g.
27441  in order to enable output of float values
27442 \begin_inset LatexCommand index
27443 name "Floating point support"
27444
27445 \end_inset
27446
27447  via 
27448 \family typewriter
27449 printf()
27450 \family default
27451 , see below), these are the steps required to do so under Linux or Mac OS
27452  X (cygwin might work as well, but is untested):
27453 \end_layout
27454
27455 \begin_layout LyX-Code
27456 cd device/lib/pic16
27457 \end_layout
27458
27459 \begin_layout LyX-Code
27460 ./configure.gnu
27461 \end_layout
27462
27463 \begin_layout LyX-Code
27464 cd ..
27465 \end_layout
27466
27467 \begin_layout LyX-Code
27468 make model-pic16
27469 \end_layout
27470
27471 \begin_layout LyX-Code
27472 su -c 'make install'     # install the libraries, you need the root password
27473 \end_layout
27474
27475 \begin_layout LyX-Code
27476 cd ../..
27477 \end_layout
27478
27479 \begin_layout Standard
27480 If you need to install the headers too, do:
27481 \end_layout
27482
27483 \begin_layout LyX-Code
27484 cd device/include
27485 \end_layout
27486
27487 \begin_layout LyX-Code
27488 su -c 'make install'     # install the headers, you need the root password
27489 \end_layout
27490
27491 \begin_layout Subsubsection*
27492 Output of float values via printf()
27493 \end_layout
27494
27495 \begin_layout Standard
27496 The library is normally built without support for displaying float values,
27497  only <NO FLOAT>
27498 \begin_inset LatexCommand index
27499 name "<NO FLOAT>"
27500
27501 \end_inset
27502
27503
27504 \begin_inset LatexCommand index
27505 name "printf floating point support"
27506
27507 \end_inset
27508
27509  will appear instead of the value.
27510  To change this, rebuild the library as stated above, but call 
27511 \family typewriter
27512 ./configure.gnu --enable-floats 
27513 \family default
27514 instead of just 
27515 \family typewriter
27516 ./configure.gnu
27517 \family default
27518 .
27519  Also make sure that at least 
27520 \family typewriter
27521 libc/stdio/vfprintf.c
27522 \family default
27523  is actually recompiled, e.g.
27524  by 
27525 \family typewriter
27526 touch
27527 \family default
27528 ing it after the 
27529 \family typewriter
27530 configure
27531 \family default
27532  run or deleting its 
27533 \family typewriter
27534 .o
27535 \family default
27536  file.
27537 \end_layout
27538
27539 \begin_layout Standard
27540 The more common appraoch of compiling 
27541 \family typewriter
27542 vfprintf.c
27543 \family default
27544  manually with 
27545 \family typewriter
27546 -DUSE_FLOATS=1
27547 \family default
27548  should also work, but is untested.
27549 \end_layout
27550
27551 \begin_layout Subsection
27552 Adding New Devices to the Port
27553 \end_layout
27554
27555 \begin_layout Standard
27556 Adding support for a new 16
27557 \begin_inset ERT
27558 status collapsed
27559
27560 \begin_layout Standard
27561
27562
27563 \backslash
27564 ,
27565 \end_layout
27566
27567 \end_inset
27568
27569 bit PIC MCU requires the following steps:
27570 \end_layout
27571
27572 \begin_layout Enumerate
27573 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
27574 \newline
27575
27576 \family typewriter
27577 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
27578 inc
27579 \end_layout
27580
27581 \begin_layout Enumerate
27582
27583 \family typewriter
27584 mv picDEVICE.h /path/to/sdcc/device/include/pic16
27585 \end_layout
27586
27587 \begin_layout Enumerate
27588
27589 \family typewriter
27590 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
27591 \end_layout
27592
27593 \begin_layout Enumerate
27594 Add DEVICE to 
27595 \family typewriter
27596 /path/to/sdcc/device/lib/pic16/pics.all
27597 \family default
27598
27599 \newline
27600 Note: No 18f prefix here!
27601 \end_layout
27602
27603 \begin_layout Enumerate
27604 Edit 
27605 \family typewriter
27606 /path/to/sdcc/device/include/pic16/adc.h
27607 \newline
27608
27609 \family default
27610 Add the new devices to the correct ADC style class (depending on the number
27611  of ADC channels).
27612 \newline
27613 Do not touch 
27614 \family typewriter
27615 adc.h
27616 \family default
27617  if the device does not offer any ADC at all.
27618 \end_layout
27619
27620 \begin_layout Enumerate
27621 Edit 
27622 \family typewriter
27623 /path/to/sdcc/device/include/pic16/pic18fregs.h
27624 \family default
27625
27626 \newline
27627 The file format is self-explanatory, just add
27628 \newline
27629
27630 \family typewriter
27631 #elif defined(picDEVICE)
27632 \newline
27633 #
27634 \begin_inset ERT
27635 status collapsed
27636
27637 \begin_layout Standard
27638
27639
27640 \backslash
27641  
27642 \backslash
27643  
27644 \end_layout
27645
27646 \end_inset
27647
27648 include <picDEVICE.h>
27649 \family default
27650
27651 \newline
27652 at the right place (keep the file sorted, please).
27653 \end_layout
27654
27655 \begin_layout Enumerate
27656 Edit 
27657 \family typewriter
27658 /path/to/sdcc/device/include/pic16devices.txt
27659 \newline
27660
27661 \family default
27662 Copy and modify an existing entry or create a new one and insert it at the
27663  correct place (keep the file sorted, please).
27664 \end_layout
27665
27666 \begin_layout Enumerate
27667 Add the device to 
27668 \family typewriter
27669 /path/to/sdcc/device/lib/pic16/libdev/Makefile.am
27670 \family default
27671
27672 \newline
27673 Copy an existing entry and adjust the device name.
27674 \end_layout
27675
27676 \begin_layout Enumerate
27677 Add the device to 
27678 \family typewriter
27679 /path/to/sdcc/device/lib/pic16/libio/Makefile.am
27680 \family default
27681
27682 \newline
27683 Copy the record from the 18f2220 and adjust the device name.
27684 \newline
27685 If the new device
27686  does not offer ADC, I
27687 \begin_inset Formula $^{\text{2}}$
27688 \end_inset
27689
27690 C, and/or (E)USART functionality as assumed by the library, remove the lines
27691  with references to 
27692 \family typewriter
27693 adc/*.c
27694 \family default
27695
27696 \family typewriter
27697 usart/*.c
27698 \family default
27699 , or 
27700 \family typewriter
27701 usart/*.c
27702 \family default
27703 , respectively.
27704 \end_layout
27705
27706 \begin_layout Enumerate
27707 Update 
27708 \family typewriter
27709 libdev/Makefile.in
27710 \family default
27711  and 
27712 \family typewriter
27713 libio/Makefile.in
27714 \family default
27715  using
27716 \newline
27717
27718 \family typewriter
27719 ./bootstrap.sh
27720 \family default
27721
27722 \newline
27723 in 
27724 \family typewriter
27725 /path/to/sdcc/device/lib/pic16
27726 \family default
27727 .
27728 \end_layout
27729
27730 \begin_layout Enumerate
27731 Recompile the pic16 libraries as described in 
27732 \begin_inset LatexCommand ref
27733 reference "sub:pic16Libraries"
27734
27735 \end_inset
27736
27737 .
27738 \end_layout
27739
27740 \begin_layout Subsection
27741 Memory Models
27742 \end_layout
27743
27744 \begin_layout Standard
27745 The following memory models are supported by the PIC16 port:
27746 \end_layout
27747
27748 \begin_layout Itemize
27749 small model
27750 \end_layout
27751
27752 \begin_layout Itemize
27753 large model
27754 \end_layout
27755
27756 \begin_layout Standard
27757 Memory model affects the default size of pointers within the source.
27758  The sizes are shown in the next table:
27759 \end_layout
27760
27761 \begin_layout Standard
27762 \align center
27763 \begin_inset Tabular
27764 <lyxtabular version="3" rows="3" columns="3">
27765 <features>
27766 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27767 <column alignment="center" valignment="top" leftline="true" width="0">
27768 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27769 <row topline="true" bottomline="true">
27770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27771 \begin_inset Text
27772
27773 \begin_layout Standard
27774 Pointer sizes according to memory model
27775 \end_layout
27776
27777 \end_inset
27778 </cell>
27779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27780 \begin_inset Text
27781
27782 \begin_layout Standard
27783 small model
27784 \end_layout
27785
27786 \end_inset
27787 </cell>
27788 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27789 \begin_inset Text
27790
27791 \begin_layout Standard
27792 large model
27793 \end_layout
27794
27795 \end_inset
27796 </cell>
27797 </row>
27798 <row topline="true" bottomline="true">
27799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27800 \begin_inset Text
27801
27802 \begin_layout Standard
27803 code pointers
27804 \end_layout
27805
27806 \end_inset
27807 </cell>
27808 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27809 \begin_inset Text
27810
27811 \begin_layout Standard
27812 16-bits
27813 \end_layout
27814
27815 \end_inset
27816 </cell>
27817 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27818 \begin_inset Text
27819
27820 \begin_layout Standard
27821 24-bits
27822 \end_layout
27823
27824 \end_inset
27825 </cell>
27826 </row>
27827 <row topline="true" bottomline="true">
27828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27829 \begin_inset Text
27830
27831 \begin_layout Standard
27832 data pointers
27833 \end_layout
27834
27835 \end_inset
27836 </cell>
27837 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
27838 \begin_inset Text
27839
27840 \begin_layout Standard
27841 16-bits
27842 \end_layout
27843
27844 \end_inset
27845 </cell>
27846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27847 \begin_inset Text
27848
27849 \begin_layout Standard
27850 16-bits
27851 \end_layout
27852
27853 \end_inset
27854 </cell>
27855 </row>
27856 </lyxtabular>
27857
27858 \end_inset
27859
27860
27861 \end_layout
27862
27863 \begin_layout Standard
27864 It is advisable that all sources within a project are compiled with the
27865  same memory model.
27866  If one wants to override the default memory model, this can be done by
27867  declaring a pointer as 
27868 \series bold
27869 far
27870 \series default
27871  or 
27872 \series bold
27873 near
27874 \series default
27875 .
27876  Far selects large memory model's pointers, while near selects small memory
27877  model's pointers.
27878 \end_layout
27879
27880 \begin_layout Standard
27881 The standard device libraries (see 
27882 \begin_inset LatexCommand ref
27883 reference "sub:PIC16_Header-Files"
27884
27885 \end_inset
27886
27887 ) contain no reference to pointers, so they can be used with both memory
27888  models.
27889 \end_layout
27890
27891 \begin_layout Subsection
27892 Stack
27893 \end_layout
27894
27895 \begin_layout Standard
27896 The stack
27897 \begin_inset LatexCommand index
27898 name "PIC16!stack"
27899
27900 \end_inset
27901
27902  implementation for the PIC16 port uses two indirect registers, FSR1 and
27903  FSR2.
27904 \end_layout
27905
27906 \begin_layout Description
27907 FSR1 is assigned as stack pointer
27908 \end_layout
27909
27910 \begin_layout Description
27911 FSR2 is assigned as frame pointer
27912 \end_layout
27913
27914 \begin_layout Standard
27915 The following stack models are supported by the PIC16 port
27916 \end_layout
27917
27918 \begin_layout Itemize
27919
27920 \noun on
27921 small
27922 \noun default
27923  model
27924 \end_layout
27925
27926 \begin_layout Itemize
27927
27928 \noun on
27929 large
27930 \noun default
27931  model
27932 \end_layout
27933
27934 \begin_layout Standard
27935
27936 \noun on
27937 Small
27938 \noun default
27939  model means that only the FSRxL byte is used to access stack and frame,
27940  while 
27941 \emph on
27942 \noun on
27943 large
27944 \emph default
27945 \noun default
27946  uses both FSRxL and FSRxH registers.
27947  The following table shows the stack/frame pointers sizes according to stack
27948  model and the maximum space they can address:
27949 \end_layout
27950
27951 \begin_layout Standard
27952 \align center
27953 \begin_inset Tabular
27954 <lyxtabular version="3" rows="3" columns="3">
27955 <features>
27956 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27957 <column alignment="center" valignment="top" leftline="true" width="0">
27958 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27959 <row topline="true" bottomline="true">
27960 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27961 \begin_inset Text
27962
27963 \begin_layout Standard
27964 Stack & Frame pointer sizes according to stack model
27965 \end_layout
27966
27967 \end_inset
27968 </cell>
27969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27970 \begin_inset Text
27971
27972 \begin_layout Standard
27973 small
27974 \end_layout
27975
27976 \end_inset
27977 </cell>
27978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27979 \begin_inset Text
27980
27981 \begin_layout Standard
27982 large
27983 \end_layout
27984
27985 \end_inset
27986 </cell>
27987 </row>
27988 <row topline="true">
27989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27990 \begin_inset Text
27991
27992 \begin_layout Standard
27993 Stack pointer FSR1
27994 \end_layout
27995
27996 \end_inset
27997 </cell>
27998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27999 \begin_inset Text
28000
28001 \begin_layout Standard
28002 8-bits
28003 \end_layout
28004
28005 \end_inset
28006 </cell>
28007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28008 \begin_inset Text
28009
28010 \begin_layout Standard
28011 16-bits
28012 \end_layout
28013
28014 \end_inset
28015 </cell>
28016 </row>
28017 <row topline="true" bottomline="true">
28018 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28019 \begin_inset Text
28020
28021 \begin_layout Standard
28022 Frame pointer FSR2
28023 \end_layout
28024
28025 \end_inset
28026 </cell>
28027 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28028 \begin_inset Text
28029
28030 \begin_layout Standard
28031 8-bits
28032 \end_layout
28033
28034 \end_inset
28035 </cell>
28036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28037 \begin_inset Text
28038
28039 \begin_layout Standard
28040 16-bits
28041 \end_layout
28042
28043 \end_inset
28044 </cell>
28045 </row>
28046 </lyxtabular>
28047
28048 \end_inset
28049
28050
28051 \end_layout
28052
28053 \begin_layout Standard
28054 \noindent
28055
28056 \noun on
28057 Large 
28058 \noun default
28059 stack model is currently not working properly throughout the code generator.
28060  So its use is not advised.
28061  Also there are some other points that need special care:
28062 \newline
28063
28064 \end_layout
28065
28066 \begin_layout Enumerate
28067 Do not create stack sections with size more than one physical bank (that
28068  is 256 bytes)
28069 \end_layout
28070
28071 \begin_layout Enumerate
28072 Stack sections should no cross physical bank limits (i.e.
28073  #pragma stack 0x50 0x100)
28074 \end_layout
28075
28076 \begin_layout Standard
28077 These limitations are caused by the fact that only FSRxL is modified when
28078  using SMALL stack model, so no more than 256 bytes of stack can be used.
28079  This problem will disappear after LARGE model is fully implemented.
28080 \end_layout
28081
28082 \begin_layout Subsection
28083 Functions
28084 \end_layout
28085
28086 \begin_layout Standard
28087 In addition to the standard SDCC function keywords, PIC16
28088 \begin_inset LatexCommand index
28089 name "PIC16"
28090
28091 \end_inset
28092
28093  port makes available two more:
28094 \end_layout
28095
28096 \begin_layout Description
28097 wparam
28098 \begin_inset LatexCommand index
28099 name "PIC16!wparam"
28100
28101 \end_inset
28102
28103  Use the WREG to pass one byte of the first function argument.
28104  This improves speed but you may not use this for functions with arguments
28105  that are called via function pointers, otherwise the first byte of the
28106  first parameter will get lost.
28107  Usage:
28108 \end_layout
28109
28110 \begin_layout LyX-Code
28111 void func_wparam(int a) wparam
28112 \end_layout
28113
28114 \begin_layout LyX-Code
28115 {
28116 \end_layout
28117
28118 \begin_layout LyX-Code
28119     /* WREG hold the lower part of a */
28120 \end_layout
28121
28122 \begin_layout LyX-Code
28123     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
28124  */
28125 \end_layout
28126
28127 \begin_layout LyX-Code
28128 ...
28129 \end_layout
28130
28131 \begin_layout LyX-Code
28132 }
28133 \end_layout
28134
28135 \begin_layout Description
28136 shadowregs
28137 \begin_inset LatexCommand index
28138 name "PIC16!shadowregs"
28139
28140 \end_inset
28141
28142  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
28143  hardware shadow registers which hold the values of WREG, STATUS and BSR
28144  registers.
28145  This can be done by adding the keyword 
28146 \emph on
28147 shadowregs
28148 \emph default
28149  before the 
28150 \emph on
28151 interrupt
28152 \emph default
28153  keyword in the function's header.
28154 \end_layout
28155
28156 \begin_layout LyX-Code
28157 void isr_shadow(void) shadowregs interrupt 1
28158 \end_layout
28159
28160 \begin_layout LyX-Code
28161 {
28162 \end_layout
28163
28164 \begin_layout LyX-Code
28165 ...
28166 \end_layout
28167
28168 \begin_layout LyX-Code
28169 }
28170 \end_layout
28171
28172 \begin_layout Standard
28173
28174 \emph on
28175 shadowregs
28176 \emph default
28177  instructs the code generator not to store/restore WREG, STATUS, BSR when
28178  entering/exiting the ISR.
28179 \end_layout
28180
28181 \begin_layout Subsection
28182 Function return values
28183 \end_layout
28184
28185 \begin_layout Standard
28186 Return values from functions are placed to the appropriate registers following
28187  a modified Microchip policy optimized for SDCC.
28188  The following table shows these registers:
28189 \end_layout
28190
28191 \begin_layout Standard
28192 \align center
28193 \begin_inset Tabular
28194 <lyxtabular version="3" rows="6" columns="2">
28195 <features>
28196 <column alignment="center" valignment="top" leftline="true" width="0">
28197 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28198 <row topline="true" bottomline="true">
28199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28200 \begin_inset Text
28201
28202 \begin_layout Standard
28203 size
28204 \end_layout
28205
28206 \end_inset
28207 </cell>
28208 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28209 \begin_inset Text
28210
28211 \begin_layout Standard
28212 destination register
28213 \end_layout
28214
28215 \end_inset
28216 </cell>
28217 </row>
28218 <row topline="true">
28219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28220 \begin_inset Text
28221
28222 \begin_layout Standard
28223 8 bits
28224 \end_layout
28225
28226 \end_inset
28227 </cell>
28228 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28229 \begin_inset Text
28230
28231 \begin_layout Standard
28232 WREG
28233 \end_layout
28234
28235 \end_inset
28236 </cell>
28237 </row>
28238 <row topline="true">
28239 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28240 \begin_inset Text
28241
28242 \begin_layout Standard
28243 16 bits
28244 \end_layout
28245
28246 \end_inset
28247 </cell>
28248 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28249 \begin_inset Text
28250
28251 \begin_layout Standard
28252 PRODL:WREG
28253 \end_layout
28254
28255 \end_inset
28256 </cell>
28257 </row>
28258 <row topline="true">
28259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28260 \begin_inset Text
28261
28262 \begin_layout Standard
28263 24 bits
28264 \end_layout
28265
28266 \end_inset
28267 </cell>
28268 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28269 \begin_inset Text
28270
28271 \begin_layout Standard
28272 PRODH:PRODL:WREG
28273 \end_layout
28274
28275 \end_inset
28276 </cell>
28277 </row>
28278 <row topline="true">
28279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28280 \begin_inset Text
28281
28282 \begin_layout Standard
28283 32 bits
28284 \end_layout
28285
28286 \end_inset
28287 </cell>
28288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28289 \begin_inset Text
28290
28291 \begin_layout Standard
28292 FSR0L:PRODH:PRODL:WREG
28293 \end_layout
28294
28295 \end_inset
28296 </cell>
28297 </row>
28298 <row topline="true" bottomline="true">
28299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28300 \begin_inset Text
28301
28302 \begin_layout Standard
28303 >32 bits
28304 \end_layout
28305
28306 \end_inset
28307 </cell>
28308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28309 \begin_inset Text
28310
28311 \begin_layout Standard
28312 on stack, FSR0 points to the beginning
28313 \end_layout
28314
28315 \end_inset
28316 </cell>
28317 </row>
28318 </lyxtabular>
28319
28320 \end_inset
28321
28322
28323 \end_layout
28324
28325 \begin_layout Subsection
28326 Interrupts
28327 \end_layout
28328
28329 \begin_layout Standard
28330 An interrupt
28331 \begin_inset LatexCommand index
28332 name "PIC16!interrupt"
28333
28334 \end_inset
28335
28336  service routine (ISR) is declared using the 
28337 \emph on
28338 interrupt
28339 \emph default
28340  keyword.
28341 \end_layout
28342
28343 \begin_layout LyX-Code
28344 void isr(void) interrupt 
28345 \emph on
28346 n
28347 \end_layout
28348
28349 \begin_layout LyX-Code
28350 {
28351 \end_layout
28352
28353 \begin_layout LyX-Code
28354 ...
28355 \end_layout
28356
28357 \begin_layout LyX-Code
28358 }
28359 \end_layout
28360
28361 \begin_layout Standard
28362
28363 \emph on
28364 n
28365 \emph default
28366  is the interrupt number, which for PIC18F devices can be:
28367 \end_layout
28368
28369 \begin_layout Standard
28370 \align center
28371 \begin_inset Tabular
28372 <lyxtabular version="3" rows="4" columns="3">
28373 <features>
28374 <column alignment="center" valignment="top" leftline="true" width="0">
28375 <column alignment="center" valignment="top" leftline="true" width="0">
28376 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28377 <row topline="true" bottomline="true">
28378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28379 \begin_inset Text
28380
28381 \begin_layout Standard
28382
28383 \emph on
28384 n
28385 \end_layout
28386
28387 \end_inset
28388 </cell>
28389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28390 \begin_inset Text
28391
28392 \begin_layout Standard
28393 Interrupt Vector
28394 \end_layout
28395
28396 \end_inset
28397 </cell>
28398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28399 \begin_inset Text
28400
28401 \begin_layout Standard
28402 Interrupt Vector Address
28403 \end_layout
28404
28405 \end_inset
28406 </cell>
28407 </row>
28408 <row topline="true">
28409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28410 \begin_inset Text
28411
28412 \begin_layout Standard
28413 0
28414 \end_layout
28415
28416 \end_inset
28417 </cell>
28418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28419 \begin_inset Text
28420
28421 \begin_layout Standard
28422 RESET vector
28423 \end_layout
28424
28425 \end_inset
28426 </cell>
28427 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28428 \begin_inset Text
28429
28430 \begin_layout Standard
28431 0x000000
28432 \end_layout
28433
28434 \end_inset
28435 </cell>
28436 </row>
28437 <row topline="true">
28438 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28439 \begin_inset Text
28440
28441 \begin_layout Standard
28442
28443 \family roman
28444 \series medium
28445 \shape up
28446 \size normal
28447 \emph off
28448 \bar no
28449 \noun off
28450 \color none
28451 1
28452 \end_layout
28453
28454 \end_inset
28455 </cell>
28456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28457 \begin_inset Text
28458
28459 \begin_layout Standard
28460
28461 \family roman
28462 \series medium
28463 \shape up
28464 \size normal
28465 \emph off
28466 \bar no
28467 \noun off
28468 \color none
28469 HIGH priority interrupts
28470 \end_layout
28471
28472 \end_inset
28473 </cell>
28474 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28475 \begin_inset Text
28476
28477 \begin_layout Standard
28478 0x000008
28479 \end_layout
28480
28481 \end_inset
28482 </cell>
28483 </row>
28484 <row topline="true" bottomline="true">
28485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28486 \begin_inset Text
28487
28488 \begin_layout Standard
28489 2
28490 \end_layout
28491
28492 \end_inset
28493 </cell>
28494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28495 \begin_inset Text
28496
28497 \begin_layout Standard
28498 LOW priority interrupts
28499 \end_layout
28500
28501 \end_inset
28502 </cell>
28503 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28504 \begin_inset Text
28505
28506 \begin_layout Standard
28507 0x000018
28508 \end_layout
28509
28510 \end_inset
28511 </cell>
28512 </row>
28513 </lyxtabular>
28514
28515 \end_inset
28516
28517
28518 \end_layout
28519
28520 \begin_layout Standard
28521 When generating assembly code for ISR the code generator places a 
28522 \noun on
28523 goto 
28524 \noun default
28525 instruction at the 
28526 \emph on
28527 Interrupt Vector Address
28528 \emph default
28529  which points at the generated ISR.
28530  This single GOTO instruction is part of an automatically generated 
28531 \emph on
28532 interrupt entry point
28533 \emph default
28534  function.
28535  The actuall ISR code is placed as normally would in the code space.
28536  Upon interrupt request, the GOTO instruction is executed which jumps to
28537  the ISR code.
28538  When declaring interrupt functions as _naked this GOTO instruction is 
28539 \series bold
28540 not
28541 \series default
28542  generated.
28543  The whole interrupt functions is therefore placed at the Interrupt Vector
28544  Address of the specific interrupt.
28545  This is not a problem for the LOW priority interrupts, but it is a problem
28546  for the RESET and the HIGH priority interrupts because code may be written
28547  at the next interrupt's vector address and cause indeterminate program
28548  behaviour if that interrupt is raised.
28549 \begin_inset Foot
28550 status open
28551
28552 \begin_layout Standard
28553 This is not a problem when
28554 \end_layout
28555
28556 \begin_layout Enumerate
28557 this is a HIGH interrupt ISR and LOW interrupts are 
28558 \emph on
28559 disabled
28560 \emph default
28561  or not used.
28562 \end_layout
28563
28564 \begin_layout Enumerate
28565 when the ISR is small enough not to reach the next interrupt's vector address.
28566 \end_layout
28567
28568 \end_inset
28569
28570
28571 \end_layout
28572
28573 \begin_layout Standard
28574
28575 \emph on
28576 n
28577 \emph default
28578  may be omitted.
28579  This way a function is generated similar to an ISR, but it is not assigned
28580  to any interrupt.
28581 \end_layout
28582
28583 \begin_layout Standard
28584 When entering an interrupt, currently the PIC16
28585 \begin_inset LatexCommand index
28586 name "PIC16"
28587
28588 \end_inset
28589
28590  port automatically saves the following registers:
28591 \end_layout
28592
28593 \begin_layout Itemize
28594 WREG
28595 \end_layout
28596
28597 \begin_layout Itemize
28598 STATUS
28599 \end_layout
28600
28601 \begin_layout Itemize
28602 BSR
28603 \end_layout
28604
28605 \begin_layout Itemize
28606 PROD (PRODL and PRODH)
28607 \end_layout
28608
28609 \begin_layout Itemize
28610 FSR0 (FSR0L and FSR0H)
28611 \end_layout
28612
28613 \begin_layout Standard
28614 These registers are restored upon return from the interrupt routine.
28615 \begin_inset Foot
28616 status open
28617
28618 \begin_layout Standard
28619 NOTE that when the _naked attribute is specified for an interrupt routine,
28620  then NO registers are stored or restored.
28621 \end_layout
28622
28623 \end_inset
28624
28625
28626 \end_layout
28627
28628 \begin_layout Subsection
28629 Generic Pointers
28630 \end_layout
28631
28632 \begin_layout Standard
28633 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
28634  There are 3 types of generic pointers currently implemented data, code
28635  and eeprom pointers.
28636  They are differentiated by the value of the 7th and 6th bits of the upper
28637  byte:
28638 \end_layout
28639
28640 \begin_layout Standard
28641 \align center
28642 \begin_inset Tabular
28643 <lyxtabular version="3" rows="5" columns="5">
28644 <features>
28645 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28646 <column alignment="center" valignment="top" width="0">
28647 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28648 <column alignment="center" valignment="top" width="0">
28649 <column alignment="left" valignment="top" rightline="true" width="0">
28650 <row topline="true" bottomline="true">
28651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28652 \begin_inset Text
28653
28654 \begin_layout Standard
28655 pointer type
28656 \end_layout
28657
28658 \end_inset
28659 </cell>
28660 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28661 \begin_inset Text
28662
28663 \begin_layout Standard
28664 7th bit
28665 \end_layout
28666
28667 \end_inset
28668 </cell>
28669 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28670 \begin_inset Text
28671
28672 \begin_layout Standard
28673 6th bit
28674 \end_layout
28675
28676 \end_inset
28677 </cell>
28678 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28679 \begin_inset Text
28680
28681 \begin_layout Standard
28682 rest of the pointer
28683 \end_layout
28684
28685 \end_inset
28686 </cell>
28687 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28688 \begin_inset Text
28689
28690 \begin_layout Standard
28691 description
28692 \end_layout
28693
28694 \end_inset
28695 </cell>
28696 </row>
28697 <row topline="true" bottomline="true">
28698 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28699 \begin_inset Text
28700
28701 \begin_layout Standard
28702 data 
28703 \end_layout
28704
28705 \end_inset
28706 </cell>
28707 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28708 \begin_inset Text
28709
28710 \begin_layout Standard
28711 1
28712 \end_layout
28713
28714 \end_inset
28715 </cell>
28716 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28717 \begin_inset Text
28718
28719 \begin_layout Standard
28720 0
28721 \end_layout
28722
28723 \end_inset
28724 </cell>
28725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28726 \begin_inset Text
28727
28728 \begin_layout Standard
28729
28730 \family typewriter
28731 \shape slanted
28732 \emph on
28733 uuuuuu uuuuxxxx xxxxxxxx
28734 \end_layout
28735
28736 \end_inset
28737 </cell>
28738 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28739 \begin_inset Text
28740
28741 \begin_layout Standard
28742 a 12-bit data pointer in data RAM memory
28743 \end_layout
28744
28745 \end_inset
28746 </cell>
28747 </row>
28748 <row bottomline="true">
28749 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28750 \begin_inset Text
28751
28752 \begin_layout Standard
28753 code
28754 \end_layout
28755
28756 \end_inset
28757 </cell>
28758 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28759 \begin_inset Text
28760
28761 \begin_layout Standard
28762 0
28763 \end_layout
28764
28765 \end_inset
28766 </cell>
28767 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28768 \begin_inset Text
28769
28770 \begin_layout Standard
28771 0
28772 \end_layout
28773
28774 \end_inset
28775 </cell>
28776 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28777 \begin_inset Text
28778
28779 \begin_layout Standard
28780
28781 \family typewriter
28782 \shape slanted
28783 \emph on
28784 uxxxxx xxxxxxxx xxxxxxxx
28785 \end_layout
28786
28787 \end_inset
28788 </cell>
28789 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28790 \begin_inset Text
28791
28792 \begin_layout Standard
28793 a 21-bit code pointer in FLASH memory
28794 \end_layout
28795
28796 \end_inset
28797 </cell>
28798 </row>
28799 <row bottomline="true">
28800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28801 \begin_inset Text
28802
28803 \begin_layout Standard
28804 eeprom
28805 \end_layout
28806
28807 \end_inset
28808 </cell>
28809 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28810 \begin_inset Text
28811
28812 \begin_layout Standard
28813 0
28814 \end_layout
28815
28816 \end_inset
28817 </cell>
28818 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28819 \begin_inset Text
28820
28821 \begin_layout Standard
28822 1
28823 \end_layout
28824
28825 \end_inset
28826 </cell>
28827 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28828 \begin_inset Text
28829
28830 \begin_layout Standard
28831
28832 \family typewriter
28833 \shape slanted
28834 \emph on
28835 uuuuuu uuuuuuxx xxxxxxxx
28836 \end_layout
28837
28838 \end_inset
28839 </cell>
28840 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28841 \begin_inset Text
28842
28843 \begin_layout Standard
28844 a 10-bit eeprom pointer in EEPROM memory
28845 \end_layout
28846
28847 \end_inset
28848 </cell>
28849 </row>
28850 <row bottomline="true">
28851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28852 \begin_inset Text
28853
28854 \begin_layout Standard
28855 (unimplemented)
28856 \end_layout
28857
28858 \end_inset
28859 </cell>
28860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28861 \begin_inset Text
28862
28863 \begin_layout Standard
28864 1
28865 \end_layout
28866
28867 \end_inset
28868 </cell>
28869 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28870 \begin_inset Text
28871
28872 \begin_layout Standard
28873 1
28874 \end_layout
28875
28876 \end_inset
28877 </cell>
28878 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28879 \begin_inset Text
28880
28881 \begin_layout Standard
28882
28883 \family typewriter
28884 \shape slanted
28885 \emph on
28886 xxxxxx xxxxxxxx xxxxxxxx
28887 \end_layout
28888
28889 \end_inset
28890 </cell>
28891 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28892 \begin_inset Text
28893
28894 \begin_layout Standard
28895 unimplemented pointer type
28896 \end_layout
28897
28898 \end_inset
28899 </cell>
28900 </row>
28901 </lyxtabular>
28902
28903 \end_inset
28904
28905
28906 \end_layout
28907
28908 \begin_layout Standard
28909 \noindent
28910 Generic pointer are read and written with a set of library functions which
28911  read/write 1, 2, 3, 4 bytes.
28912 \end_layout
28913
28914 \begin_layout Subsection
28915 PIC16 C Libraries
28916 \end_layout
28917
28918 \begin_layout Subsubsection
28919 Standard I/O Streams
28920 \end_layout
28921
28922 \begin_layout Standard
28923 In the 
28924 \emph on
28925 stdio.h
28926 \emph default
28927  the type FILE is defined as:
28928 \end_layout
28929
28930 \begin_layout LyX-Code
28931 typedef char * FILE;
28932 \end_layout
28933
28934 \begin_layout Standard
28935 This type is the stream type implemented I/O in the PIC18F devices.
28936  Also the standard input and output streams are declared in stdio.h:
28937 \end_layout
28938
28939 \begin_layout LyX-Code
28940 extern FILE * stdin;
28941 \end_layout
28942
28943 \begin_layout LyX-Code
28944 extern FILE * stdout;
28945 \end_layout
28946
28947 \begin_layout Standard
28948 The FILE type is actually a generic pointer which defines one more type
28949  of generic pointers, the 
28950 \emph on
28951 stream
28952 \emph default
28953  pointer.
28954  This new type has the format:
28955 \end_layout
28956
28957 \begin_layout Standard
28958 \noindent
28959 \align center
28960 \begin_inset Tabular
28961 <lyxtabular version="3" rows="2" columns="7">
28962 <features>
28963 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28964 <column alignment="center" valignment="top" width="0">
28965 <column alignment="center" valignment="top" leftline="true" width="0">
28966 <column alignment="center" valignment="top" leftline="true" width="0">
28967 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28968 <column alignment="center" valignment="top" width="0">
28969 <column alignment="left" valignment="top" rightline="true" width="0">
28970 <row topline="true" bottomline="true">
28971 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28972 \begin_inset Text
28973
28974 \begin_layout Standard
28975 pointer type
28976 \end_layout
28977
28978 \end_inset
28979 </cell>
28980 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28981 \begin_inset Text
28982
28983 \begin_layout Standard
28984 <7:6>
28985 \end_layout
28986
28987 \end_inset
28988 </cell>
28989 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28990 \begin_inset Text
28991
28992 \begin_layout Standard
28993 <5>
28994 \end_layout
28995
28996 \end_inset
28997 </cell>
28998 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28999 \begin_inset Text
29000
29001 \begin_layout Standard
29002 <4>
29003 \end_layout
29004
29005 \end_inset
29006 </cell>
29007 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29008 \begin_inset Text
29009
29010 \begin_layout Standard
29011 <3:0>
29012 \end_layout
29013
29014 \end_inset
29015 </cell>
29016 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29017 \begin_inset Text
29018
29019 \begin_layout Standard
29020 rest of the pointer
29021 \end_layout
29022
29023 \end_inset
29024 </cell>
29025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29026 \begin_inset Text
29027
29028 \begin_layout Standard
29029 descrption
29030 \end_layout
29031
29032 \end_inset
29033 </cell>
29034 </row>
29035 <row topline="true" bottomline="true">
29036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29037 \begin_inset Text
29038
29039 \begin_layout Standard
29040 stream
29041 \end_layout
29042
29043 \end_inset
29044 </cell>
29045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29046 \begin_inset Text
29047
29048 \begin_layout Standard
29049 00
29050 \end_layout
29051
29052 \end_inset
29053 </cell>
29054 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29055 \begin_inset Text
29056
29057 \begin_layout Standard
29058 1
29059 \end_layout
29060
29061 \end_inset
29062 </cell>
29063 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29064 \begin_inset Text
29065
29066 \begin_layout Standard
29067 0
29068 \end_layout
29069
29070 \end_inset
29071 </cell>
29072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29073 \begin_inset Text
29074
29075 \begin_layout Standard
29076 nnnn
29077 \end_layout
29078
29079 \end_inset
29080 </cell>
29081 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29082 \begin_inset Text
29083
29084 \begin_layout Standard
29085
29086 \family typewriter
29087 \shape slanted
29088 \emph on
29089 uuuuuuuu uuuuuuuu
29090 \end_layout
29091
29092 \end_inset
29093 </cell>
29094 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29095 \begin_inset Text
29096
29097 \begin_layout Standard
29098 upper byte high nubble is 0x2n, the rest are zeroes
29099 \end_layout
29100
29101 \end_inset
29102 </cell>
29103 </row>
29104 </lyxtabular>
29105
29106 \end_inset
29107
29108
29109 \end_layout
29110
29111 \begin_layout Standard
29112 \noindent
29113 Currently implemented there are 3 types of streams defined:
29114 \end_layout
29115
29116 \begin_layout Standard
29117 \noindent
29118 \align center
29119 \begin_inset Tabular
29120 <lyxtabular version="3" rows="4" columns="4">
29121 <features>
29122 <column alignment="center" valignment="top" leftline="true" width="0">
29123 <column alignment="center" valignment="top" leftline="true" width="0">
29124 <column alignment="center" valignment="top" leftline="true" width="0">
29125 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29126 <row topline="true" bottomline="true">
29127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29128 \begin_inset Text
29129
29130 \begin_layout Standard
29131 stream type
29132 \end_layout
29133
29134 \end_inset
29135 </cell>
29136 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29137 \begin_inset Text
29138
29139 \begin_layout Standard
29140 value
29141 \end_layout
29142
29143 \end_inset
29144 </cell>
29145 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29146 \begin_inset Text
29147
29148 \begin_layout Standard
29149 module
29150 \end_layout
29151
29152 \end_inset
29153 </cell>
29154 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29155 \begin_inset Text
29156
29157 \begin_layout Standard
29158 description
29159 \end_layout
29160
29161 \end_inset
29162 </cell>
29163 </row>
29164 <row topline="true">
29165 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29166 \begin_inset Text
29167
29168 \begin_layout Standard
29169 STREAM_USART
29170 \end_layout
29171
29172 \end_inset
29173 </cell>
29174 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29175 \begin_inset Text
29176
29177 \begin_layout Standard
29178
29179 \family typewriter
29180 0x200000UL
29181 \end_layout
29182
29183 \end_inset
29184 </cell>
29185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29186 \begin_inset Text
29187
29188 \begin_layout Standard
29189 USART
29190 \end_layout
29191
29192 \end_inset
29193 </cell>
29194 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29195 \begin_inset Text
29196
29197 \begin_layout Standard
29198 Writes/Reads characters via the USART peripheral
29199 \end_layout
29200
29201 \end_inset
29202 </cell>
29203 </row>
29204 <row topline="true">
29205 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29206 \begin_inset Text
29207
29208 \begin_layout Standard
29209 STREAM_MSSP
29210 \end_layout
29211
29212 \end_inset
29213 </cell>
29214 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29215 \begin_inset Text
29216
29217 \begin_layout Standard
29218
29219 \family typewriter
29220 0x210000UL
29221 \end_layout
29222
29223 \end_inset
29224 </cell>
29225 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29226 \begin_inset Text
29227
29228 \begin_layout Standard
29229 MSSP
29230 \end_layout
29231
29232 \end_inset
29233 </cell>
29234 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29235 \begin_inset Text
29236
29237 \begin_layout Standard
29238 Writes/Reads characters via the MSSP peripheral
29239 \end_layout
29240
29241 \end_inset
29242 </cell>
29243 </row>
29244 <row topline="true" bottomline="true">
29245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29246 \begin_inset Text
29247
29248 \begin_layout Standard
29249 STREAM_USER
29250 \end_layout
29251
29252 \end_inset
29253 </cell>
29254 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29255 \begin_inset Text
29256
29257 \begin_layout Standard
29258
29259 \family typewriter
29260 0x2f0000UL
29261 \end_layout
29262
29263 \end_inset
29264 </cell>
29265 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29266 \begin_inset Text
29267
29268 \begin_layout Standard
29269 (none)
29270 \end_layout
29271
29272 \end_inset
29273 </cell>
29274 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29275 \begin_inset Text
29276
29277 \begin_layout Standard
29278 Writes/Reads characters via used defined functions
29279 \end_layout
29280
29281 \end_inset
29282 </cell>
29283 </row>
29284 </lyxtabular>
29285
29286 \end_inset
29287
29288
29289 \end_layout
29290
29291 \begin_layout Standard
29292 \noindent
29293 The stream identifiers are declared as macros in the stdio.h header.
29294 \end_layout
29295
29296 \begin_layout Standard
29297 \noindent
29298 In the libc library there exist the functions that are used to write to
29299  each of the above streams.
29300  These are
29301 \end_layout
29302
29303 \begin_layout Description
29304 _
29305 \begin_inset ERT
29306 status collapsed
29307
29308 \begin_layout Standard
29309
29310
29311 \backslash
29312 /
29313 \end_layout
29314
29315 \end_inset
29316
29317 _stream_usart_putchar writes a character at the USART stream
29318 \end_layout
29319
29320 \begin_layout Description
29321 _
29322 \begin_inset ERT
29323 status collapsed
29324
29325 \begin_layout Standard
29326
29327
29328 \backslash
29329 /
29330 \end_layout
29331
29332 \end_inset
29333
29334 _stream_mssp_putchar writes a character at the MSSP stream
29335 \end_layout
29336
29337 \begin_layout Description
29338 putchar dummy function.
29339  This writes a character to a user specified manner.
29340 \end_layout
29341
29342 \begin_layout Standard
29343 In order to increase performance 
29344 \emph on
29345 putchar
29346 \emph default
29347  is declared in stdio.h as having its parameter in WREG (it has the wparam
29348  keyword).
29349  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
29350  in a user-friendly way.
29351  
29352 \emph on
29353 arg
29354 \emph default
29355  is the name of the variable that holds the character to print.
29356  An example follows:
29357 \end_layout
29358
29359 \begin_layout LyX-Code
29360 #include <pic18fregs.h>
29361 \newline
29362 #include <stdio.h>
29363 \newline
29364
29365 \newline
29366 PUTCHAR( c )
29367 \end_layout
29368
29369 \begin_layout LyX-Code
29370 {
29371 \end_layout
29372
29373 \begin_layout LyX-Code
29374     PORTA = c;    /* dump character c to PORTA */
29375 \end_layout
29376
29377 \begin_layout LyX-Code
29378
29379 \newline
29380
29381 \newline
29382 void main(void)
29383 \end_layout
29384
29385 \begin_layout LyX-Code
29386 {
29387 \end_layout
29388
29389 \begin_layout LyX-Code
29390     stdout = STREAM_USER;    /* this is not necessary, since stdout points
29391 \end_layout
29392
29393 \begin_layout LyX-Code
29394                               * by default to STREAM_USER */
29395 \end_layout
29396
29397 \begin_layout LyX-Code
29398     printf (
29399 \begin_inset Quotes sld
29400 \end_inset
29401
29402 This is a printf test
29403 \backslash
29404 n
29405 \begin_inset Quotes srd
29406 \end_inset
29407
29408 );
29409 \end_layout
29410
29411 \begin_layout LyX-Code
29412 }
29413 \end_layout
29414
29415 \begin_layout LyX-Code
29416
29417 \end_layout
29418
29419 \begin_layout Subsubsection
29420 Printing functions
29421 \end_layout
29422
29423 \begin_layout Standard
29424 PIC16 contains an implementation of the printf-family of functions.
29425  There exist the following functions:
29426 \end_layout
29427
29428 \begin_layout LyX-Code
29429 extern unsigned int sprintf(char *buf, char *fmt, ...);
29430 \end_layout
29431
29432 \begin_layout LyX-Code
29433 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
29434 \end_layout
29435
29436 \begin_layout LyX-Code
29437
29438 \end_layout
29439
29440 \begin_layout LyX-Code
29441 extern unsigned int printf(char *fmt, ...);
29442 \end_layout
29443
29444 \begin_layout LyX-Code
29445 extern unsigned int vprintf(char *fmt, va_lista ap);
29446 \end_layout
29447
29448 \begin_layout LyX-Code
29449
29450 \end_layout
29451
29452 \begin_layout LyX-Code
29453 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
29454 \end_layout
29455
29456 \begin_layout LyX-Code
29457 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
29458 \end_layout
29459
29460 \begin_layout Standard
29461 For sprintf and vsprintf 
29462 \emph on
29463 buf
29464 \emph default
29465  should normally be a data pointer where the resulting string will be placed.
29466  No range checking is done so the user should allocate the necessary buffer.
29467  For fprintf and vfprintf 
29468 \emph on
29469 fp
29470 \emph default
29471  should be a stream pointer (i.e.
29472  stdout, STREAM_MSSP, etc...).
29473 \end_layout
29474
29475 \begin_layout Subsubsection
29476 Signals
29477 \end_layout
29478
29479 \begin_layout Standard
29480 The PIC18F family of microcontrollers supports a number of interrupt sources.
29481  A list of these interrupts is shown in the following table:
29482 \end_layout
29483
29484 \begin_layout Standard
29485 \align center
29486 \begin_inset Tabular
29487 <lyxtabular version="3" rows="11" columns="4">
29488 <features>
29489 <column alignment="left" valignment="top" leftline="true" width="0">
29490 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29491 <column alignment="left" valignment="top" leftline="true" width="0">
29492 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29493 <row topline="true" bottomline="true">
29494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29495 \begin_inset Text
29496
29497 \begin_layout Standard
29498 signal name
29499 \end_layout
29500
29501 \end_inset
29502 </cell>
29503 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29504 \begin_inset Text
29505
29506 \begin_layout Standard
29507 description
29508 \end_layout
29509
29510 \end_inset
29511 </cell>
29512 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29513 \begin_inset Text
29514
29515 \begin_layout Standard
29516 signal name
29517 \end_layout
29518
29519 \end_inset
29520 </cell>
29521 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29522 \begin_inset Text
29523
29524 \begin_layout Standard
29525 description
29526 \end_layout
29527
29528 \end_inset
29529 </cell>
29530 </row>
29531 <row topline="true">
29532 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29533 \begin_inset Text
29534
29535 \begin_layout Standard
29536 SIG_RB
29537 \end_layout
29538
29539 \end_inset
29540 </cell>
29541 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29542 \begin_inset Text
29543
29544 \begin_layout Standard
29545 PORTB change interrupt
29546 \end_layout
29547
29548 \end_inset
29549 </cell>
29550 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29551 \begin_inset Text
29552
29553 \begin_layout Standard
29554 SIG_EE
29555 \end_layout
29556
29557 \end_inset
29558 </cell>
29559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29560 \begin_inset Text
29561
29562 \begin_layout Standard
29563 EEPROM/FLASH write complete interrupt
29564 \end_layout
29565
29566 \end_inset
29567 </cell>
29568 </row>
29569 <row topline="true">
29570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29571 \begin_inset Text
29572
29573 \begin_layout Standard
29574 SIG_INT0
29575 \end_layout
29576
29577 \end_inset
29578 </cell>
29579 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29580 \begin_inset Text
29581
29582 \begin_layout Standard
29583 INT0 external interrupt
29584 \end_layout
29585
29586 \end_inset
29587 </cell>
29588 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29589 \begin_inset Text
29590
29591 \begin_layout Standard
29592 SIG_BCOL
29593 \end_layout
29594
29595 \end_inset
29596 </cell>
29597 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29598 \begin_inset Text
29599
29600 \begin_layout Standard
29601 Bus collision interrupt
29602 \end_layout
29603
29604 \end_inset
29605 </cell>
29606 </row>
29607 <row topline="true">
29608 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29609 \begin_inset Text
29610
29611 \begin_layout Standard
29612 SIG_INT1
29613 \end_layout
29614
29615 \end_inset
29616 </cell>
29617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29618 \begin_inset Text
29619
29620 \begin_layout Standard
29621 INT1 external interrupt
29622 \end_layout
29623
29624 \end_inset
29625 </cell>
29626 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29627 \begin_inset Text
29628
29629 \begin_layout Standard
29630 SIG_LVD
29631 \end_layout
29632
29633 \end_inset
29634 </cell>
29635 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29636 \begin_inset Text
29637
29638 \begin_layout Standard
29639 Low voltage detect interrupt
29640 \end_layout
29641
29642 \end_inset
29643 </cell>
29644 </row>
29645 <row topline="true">
29646 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29647 \begin_inset Text
29648
29649 \begin_layout Standard
29650 SIG_INT2
29651 \end_layout
29652
29653 \end_inset
29654 </cell>
29655 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29656 \begin_inset Text
29657
29658 \begin_layout Standard
29659 INT2 external interrupt
29660 \end_layout
29661
29662 \end_inset
29663 </cell>
29664 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29665 \begin_inset Text
29666
29667 \begin_layout Standard
29668 SIG_PSP
29669 \end_layout
29670
29671 \end_inset
29672 </cell>
29673 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29674 \begin_inset Text
29675
29676 \begin_layout Standard
29677 Parallel slave port interrupt
29678 \end_layout
29679
29680 \end_inset
29681 </cell>
29682 </row>
29683 <row topline="true">
29684 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29685 \begin_inset Text
29686
29687 \begin_layout Standard
29688 SIG_CCP1
29689 \end_layout
29690
29691 \end_inset
29692 </cell>
29693 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29694 \begin_inset Text
29695
29696 \begin_layout Standard
29697 CCP1 module interrupt
29698 \end_layout
29699
29700 \end_inset
29701 </cell>
29702 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29703 \begin_inset Text
29704
29705 \begin_layout Standard
29706 SIG_AD
29707 \end_layout
29708
29709 \end_inset
29710 </cell>
29711 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29712 \begin_inset Text
29713
29714 \begin_layout Standard
29715 AD convertion complete interrupt
29716 \end_layout
29717
29718 \end_inset
29719 </cell>
29720 </row>
29721 <row topline="true">
29722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29723 \begin_inset Text
29724
29725 \begin_layout Standard
29726 SIG_CCP2
29727 \end_layout
29728
29729 \end_inset
29730 </cell>
29731 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29732 \begin_inset Text
29733
29734 \begin_layout Standard
29735 CCP2 module interrupt
29736 \end_layout
29737
29738 \end_inset
29739 </cell>
29740 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29741 \begin_inset Text
29742
29743 \begin_layout Standard
29744 SIG_RC
29745 \end_layout
29746
29747 \end_inset
29748 </cell>
29749 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29750 \begin_inset Text
29751
29752 \begin_layout Standard
29753 USART receive interrupt
29754 \end_layout
29755
29756 \end_inset
29757 </cell>
29758 </row>
29759 <row topline="true">
29760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29761 \begin_inset Text
29762
29763 \begin_layout Standard
29764 SIG_TMR0
29765 \end_layout
29766
29767 \end_inset
29768 </cell>
29769 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29770 \begin_inset Text
29771
29772 \begin_layout Standard
29773 TMR0 overflow interrupt
29774 \end_layout
29775
29776 \end_inset
29777 </cell>
29778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29779 \begin_inset Text
29780
29781 \begin_layout Standard
29782 SIG_TX
29783 \end_layout
29784
29785 \end_inset
29786 </cell>
29787 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29788 \begin_inset Text
29789
29790 \begin_layout Standard
29791 USART transmit interrupt
29792 \end_layout
29793
29794 \end_inset
29795 </cell>
29796 </row>
29797 <row topline="true">
29798 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29799 \begin_inset Text
29800
29801 \begin_layout Standard
29802 SIG_TMR1
29803 \end_layout
29804
29805 \end_inset
29806 </cell>
29807 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29808 \begin_inset Text
29809
29810 \begin_layout Standard
29811 TMR1 overflow interrupt
29812 \end_layout
29813
29814 \end_inset
29815 </cell>
29816 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29817 \begin_inset Text
29818
29819 \begin_layout Standard
29820 SIG_MSSP
29821 \end_layout
29822
29823 \end_inset
29824 </cell>
29825 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29826 \begin_inset Text
29827
29828 \begin_layout Standard
29829 SSP receive/transmit interrupt
29830 \end_layout
29831
29832 \end_inset
29833 </cell>
29834 </row>
29835 <row topline="true">
29836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29837 \begin_inset Text
29838
29839 \begin_layout Standard
29840 SIG_TMR2
29841 \end_layout
29842
29843 \end_inset
29844 </cell>
29845 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29846 \begin_inset Text
29847
29848 \begin_layout Standard
29849 TMR2 matches PR2 interrupt
29850 \end_layout
29851
29852 \end_inset
29853 </cell>
29854 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29855 \begin_inset Text
29856
29857 \begin_layout Standard
29858
29859 \end_layout
29860
29861 \end_inset
29862 </cell>
29863 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29864 \begin_inset Text
29865
29866 \begin_layout Standard
29867
29868 \end_layout
29869
29870 \end_inset
29871 </cell>
29872 </row>
29873 <row topline="true" bottomline="true">
29874 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29875 \begin_inset Text
29876
29877 \begin_layout Standard
29878 SIG_TMR3
29879 \end_layout
29880
29881 \end_inset
29882 </cell>
29883 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29884 \begin_inset Text
29885
29886 \begin_layout Standard
29887 TMR3 overflow interrupt
29888 \end_layout
29889
29890 \end_inset
29891 </cell>
29892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29893 \begin_inset Text
29894
29895 \begin_layout Standard
29896
29897 \end_layout
29898
29899 \end_inset
29900 </cell>
29901 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29902 \begin_inset Text
29903
29904 \begin_layout Standard
29905
29906 \end_layout
29907
29908 \end_inset
29909 </cell>
29910 </row>
29911 </lyxtabular>
29912
29913 \end_inset
29914
29915
29916 \end_layout
29917
29918 \begin_layout Standard
29919 \noindent
29920 The prototypes for these names are defined in the header file 
29921 \emph on
29922 signal.h
29923 \emph default
29924  .
29925 \end_layout
29926
29927 \begin_layout Standard
29928 \noindent
29929 In order to simplify signal handling, a number of macros is provided:
29930 \end_layout
29931
29932 \begin_layout List
29933 \labelwidthstring 00.00.0000
29934 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
29935  high priority interrupts.
29936  
29937 \emph on
29938 name
29939 \emph default
29940  is the function name to use.
29941 \end_layout
29942
29943 \begin_layout List
29944 \labelwidthstring 00.00.0000
29945 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
29946  low priority interrupt.
29947  
29948 \emph on
29949 name
29950 \emph default
29951  is the function name to use.
29952 \end_layout
29953
29954 \begin_layout List
29955 \labelwidthstring 00.00.0000
29956 DEF_HANDLER(sig,handler) define a handler for signal 
29957 \emph on
29958 sig.
29959 \end_layout
29960
29961 \begin_layout List
29962 \labelwidthstring 00.00.0000
29963 END_DEF end the declaration of the dispatch table.
29964 \end_layout
29965
29966 \begin_layout Standard
29967 Additionally there are two more macros to simplify the declaration of the
29968  signal handler:
29969 \end_layout
29970
29971 \begin_layout List
29972 \labelwidthstring 00.00.0000
29973
29974 \series medium
29975 SIGHANDLER(handler)
29976 \series default
29977  this declares the function prototype for the 
29978 \emph on
29979 handler
29980 \emph default
29981  function.
29982 \end_layout
29983
29984 \begin_layout List
29985 \labelwidthstring 00.00.0000
29986 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
29987 \end_layout
29988
29989 \begin_layout Standard
29990 An example of using the macros above is shown below:
29991 \end_layout
29992
29993 \begin_layout LyX-Code
29994 #include <pic18fregs.h>
29995 \end_layout
29996
29997 \begin_layout LyX-Code
29998 #include <signal.h>
29999 \newline
30000
30001 \newline
30002 DEF_INTHIGH(high_int)
30003 \end_layout
30004
30005 \begin_layout LyX-Code
30006 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
30007 \end_layout
30008
30009 \begin_layout LyX-Code
30010 DEF_HANDLER(SIG_BCOL, _bcol_handler)
30011 \end_layout
30012
30013 \begin_layout LyX-Code
30014 END_DEF
30015 \newline
30016
30017 \newline
30018 SIGHANDLER(_tmr0_handler)
30019 \end_layout
30020
30021 \begin_layout LyX-Code
30022 {
30023 \end_layout
30024
30025 \begin_layout LyX-Code
30026   /* action to be taken when timer 0 overflows */
30027 \end_layout
30028
30029 \begin_layout LyX-Code
30030 }
30031 \newline
30032
30033 \newline
30034 SIGHANDLERNAKED(_bcol_handler)
30035 \end_layout
30036
30037 \begin_layout LyX-Code
30038 {
30039 \end_layout
30040
30041 \begin_layout LyX-Code
30042   _asm
30043 \end_layout
30044
30045 \begin_layout LyX-Code
30046     /* action to be taken when bus collision occurs */
30047 \end_layout
30048
30049 \begin_layout LyX-Code
30050     retfie
30051 \end_layout
30052
30053 \begin_layout LyX-Code
30054  _endasm;
30055 \end_layout
30056
30057 \begin_layout LyX-Code
30058 }
30059 \end_layout
30060
30061 \begin_layout Standard
30062
30063 \series bold
30064 NOTES:
30065 \series default
30066  Special care should be taken when using the above scheme:
30067 \end_layout
30068
30069 \begin_layout Itemize
30070 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
30071 \end_layout
30072
30073 \begin_layout Itemize
30074 when declaring SIGHANDLERNAKED handler never forget to use 
30075 \emph on
30076 retfie
30077 \emph default
30078  for proper returning.
30079 \end_layout
30080
30081 \begin_layout Subsection
30082 PIC16 Port -- Tips
30083 \end_layout
30084
30085 \begin_layout Standard
30086 Here you can find some general tips for compiling programs with SDCC/pic16.
30087 \end_layout
30088
30089 \begin_layout Subsubsection
30090 Stack size
30091 \end_layout
30092
30093 \begin_layout Standard
30094 The default stack
30095 \begin_inset LatexCommand index
30096 name "PIC16!stack"
30097
30098 \end_inset
30099
30100  size (that is 64 bytes) probably is enough for many programs.
30101  One must take care that when there are many levels of function nesting,
30102  or there is excessive usage of stack, its size should be extended.
30103  An example of such a case is the printf/sprintf family of functions.
30104  If you encounter problems like not being able to print integers, then you
30105  need to set the stack size around the maximum (256 for small stack model).
30106  The following diagram shows what happens when calling printf to print an
30107  integer:
30108 \end_layout
30109
30110 \begin_layout LyX-Code
30111 printf () --> ltoa () --> ultoa () --> divschar ()
30112 \end_layout
30113
30114 \begin_layout Standard
30115 It is should be understood that stack is easily consumed when calling complicate
30116 d functions.
30117  Using command line arguments like -
30118 \begin_inset ERT
30119 status collapsed
30120
30121 \begin_layout Standard
30122
30123
30124 \backslash
30125 /
30126 \end_layout
30127
30128 \end_inset
30129
30130 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
30131  stack frames.
30132  Other ways to reduce stack usage may exist.
30133 \end_layout
30134
30135 \begin_layout Subsection
30136 Known Bugs
30137 \end_layout
30138
30139 \begin_layout Subsubsection
30140 Extended Instruction Set
30141 \end_layout
30142
30143 \begin_layout Standard
30144 The PIC16 port emits code which is incompatible with the extended instruction
30145  set available with many newer devices.
30146  Make sure to always explicitly disable it, usually using
30147 \end_layout
30148
30149 \begin_layout Standard
30150
30151 \family typewriter
30152 static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
30153 \end_layout
30154
30155 \begin_layout Standard
30156 \noindent
30157 Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
30158  instead of _XINST_OFF_4L.
30159 \end_layout
30160
30161 \begin_layout Subsubsection
30162 Regression Tests
30163 \end_layout
30164
30165 \begin_layout Standard
30166 The PIC16 port currently passes most but not all of the tests in SDCC's
30167  regression test
30168 \begin_inset LatexCommand index
30169 name "Regression test (PIC16)"
30170
30171 \end_inset
30172
30173  suite (see section 
30174 \begin_inset LatexCommand ref
30175 reference "sec:Quality-control"
30176
30177 \end_inset
30178
30179 ), thus no automatic regression tests are currently performed for the PIC16
30180  target.
30181 \end_layout
30182
30183 \begin_layout Chapter
30184 Debugging
30185 \end_layout
30186
30187 \begin_layout Standard
30188 There are several approaches to debugging your code.
30189  This chapter is meant to show your options and to give detail on some of
30190  them:
30191 \newline
30192
30193 \newline
30194 When writing your code:
30195 \end_layout
30196
30197 \begin_layout Itemize
30198 write your code with debugging in mind (avoid duplicating code, put conceptually
30199  similar variables into structs, use structured code, have strategic points
30200  within your code where all variables are consistent, ...)
30201 \end_layout
30202
30203 \begin_layout Itemize
30204 run a syntax-checking tool like splint
30205 \begin_inset LatexCommand index
30206 name "splint (syntax checking tool)"
30207
30208 \end_inset
30209
30210
30211 \begin_inset LatexCommand index
30212 name "lint (syntax checking tool)"
30213
30214 \end_inset
30215
30216  (see -
30217 \begin_inset ERT
30218 status collapsed
30219
30220 \begin_layout Standard
30221
30222
30223 \backslash
30224 /
30225 \end_layout
30226
30227 \end_inset
30228
30229 -more-pedantic 
30230 \begin_inset LatexCommand ref
30231 reference "lyx:more-pedantic-SPLINT"
30232
30233 \end_inset
30234
30235 ) over the code.
30236 \end_layout
30237
30238 \begin_layout Itemize
30239 for the high level code use a C-compiler (like f.e.
30240  GCC) to compile run and debug the code on your host.
30241  See (see -
30242 \begin_inset ERT
30243 status collapsed
30244
30245 \begin_layout Standard
30246
30247
30248 \backslash
30249 /
30250 \end_layout
30251
30252 \end_inset
30253
30254 -more-pedantic 
30255 \begin_inset LatexCommand ref
30256 reference "lyx:more-pedantic-SPLINT"
30257
30258 \end_inset
30259
30260 ) on how to handle syntax extensions like __xdata, __at(), ...
30261  
30262 \end_layout
30263
30264 \begin_layout Itemize
30265 use another C-compiler to compile code for your target.
30266  Always an option but not recommended:) And not very likely to help you.
30267  If you seriously consider walking this path you should at least occasionally
30268  check portability of your code.
30269  Most commercial compiler vendors will offer an evaluation version so you
30270  can test compile your code or snippets of your code.
30271 \end_layout
30272
30273 \begin_layout Standard
30274 Debugging on a simulator:
30275 \end_layout
30276
30277 \begin_layout Itemize
30278 there is a separate section about SDCDB (section 
30279 \begin_inset LatexCommand ref
30280 reference "cha:Debugging-with-SDCDB"
30281
30282 \end_inset
30283
30284 ) below.
30285 \end_layout
30286
30287 \begin_layout Itemize
30288 or (8051 specific) use a freeware/commercial simulator which interfaces
30289  to the AOMF
30290 \begin_inset LatexCommand index
30291 name "AOMF, AOMF51"
30292
30293 \end_inset
30294
30295  file (see 
30296 \begin_inset LatexCommand ref
30297 reference "OMF file"
30298
30299 \end_inset
30300
30301 ) optionally generated by SDCC.
30302 \end_layout
30303
30304 \begin_layout Standard
30305 Debugging On-target: 
30306 \end_layout
30307
30308 \begin_layout Itemize
30309 use a MCU port pin to serially output debug data to the RS232 port of your
30310  host.
30311  You'll probably want some level shifting device typically involving a MAX232
30312  or similar IC.
30313  If the hardware serial port of the MCU is not available search for 'Software
30314  UART' in your favourite search machine.
30315 \end_layout
30316
30317 \begin_layout Itemize
30318 use an on-target monitor.
30319  In this context a monitor is a small program which usually accepts commands
30320  via a serial line and allows to set program counter, to single step through
30321  a program and read/write memory locations.
30322  For the 8051 good examples of monitors are paulmon and cmon51 (see section
30323  
30324 \begin_inset LatexCommand ref
30325 reference "sec:Related-open-source-tools"
30326
30327 \end_inset
30328
30329 ).
30330 \end_layout
30331
30332 \begin_layout Itemize
30333 toggle MCU port pins at strategic points within your code and use an oscilloscop
30334 e.
30335  A 
30336 \emph on
30337 digital oscilloscope
30338 \emph default
30339
30340 \begin_inset LatexCommand index
30341 name "Oscilloscope"
30342
30343 \end_inset
30344
30345  with deep trace memory is really helpful especially if you have to debug
30346  a realtime application.
30347  If you need to monitor more pins than your oscilloscope provides you can
30348  sometimes get away with a small R-2R network.
30349  On a single channel oscilloscope you could f.e.
30350  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
30351 k
30352 \begin_inset Formula $\Omega$
30353 \end_inset
30354
30355  resistor and the other one by a 5\InsetSpace ~
30356 k
30357 \begin_inset Formula $\Omega$
30358 \end_inset
30359
30360  resistor to the oscilloscope probe (check output drive capability of the
30361  pins you want to monitor).
30362  If you need to monitor many more pins a 
30363 \emph on
30364 logic analyzer
30365 \emph default
30366  will be handy.
30367 \end_layout
30368
30369 \begin_layout Itemize
30370 use an ICE (
30371 \emph on
30372 i
30373 \emph default
30374
30375 \emph on
30376 c
30377 \emph default
30378 ircuit 
30379 \emph on
30380 e
30381 \emph default
30382 mulator
30383 \begin_inset LatexCommand index
30384 name "ICE (in circuit emulator)"
30385
30386 \end_inset
30387
30388 ).
30389  Usually very expensive.
30390  And very nice to have too.
30391  And usually locks you (for years...) to the devices the ICE can emulate.
30392  
30393 \end_layout
30394
30395 \begin_layout Itemize
30396 use a remote debugger.
30397  In most 8-bit systems the symbol information is not available on the target,
30398  and a complete debugger is too bulky for the target system.
30399  Therefore usually a debugger on the host system connects to an on-target
30400  debugging stub which accepts only primitive commands.
30401  
30402 \newline
30403 Terms to enter into your favourite search engine could be 'remote debugging',
30404  'gdb stub' or 'inferior debugger'.
30405  (is there one?)
30406 \end_layout
30407
30408 \begin_layout Itemize
30409 use an on target hardware debugger.
30410  Some of the more modern MCUs include hardware support for setting break
30411  points and monitoring/changing variables by using dedicated hardware pins.
30412  This facility doesn't require additional code to run on the target and
30413  
30414 \emph on
30415 usually
30416 \emph default
30417  doesn't affect runtime behaviour until a breakpoint is hit.
30418  For the mcs51 most hardware debuggers use the AOMF
30419 \begin_inset LatexCommand index
30420 name "AOMF, AOMF51"
30421
30422 \end_inset
30423
30424  file (see 
30425 \begin_inset LatexCommand ref
30426 reference "OMF file"
30427
30428 \end_inset
30429
30430 ) as input file.
30431  
30432 \end_layout
30433
30434 \begin_layout Standard
30435 Last not least:
30436 \end_layout
30437
30438 \begin_layout Itemize
30439 if you are not familiar with any of the following terms you're likely to
30440  run into problems rather sooner than later: 
30441 \emph on
30442 volatile
30443 \emph default
30444
30445 \emph on
30446 atomic
30447 \emph default
30448
30449 \emph on
30450 memory map
30451 \emph default
30452
30453 \emph on
30454 overlay
30455 \emph default
30456 .
30457  As an embedded programmer you 
30458 \emph on
30459 have
30460 \emph default
30461  to know them so why not look them up 
30462 \emph on
30463 before
30464 \emph default
30465  you have problems?)
30466 \end_layout
30467
30468 \begin_layout Itemize
30469 tell someone else about your problem (actually this is a surprisingly effective
30470  means to hunt down the bug even if the listener is not familiar with your
30471  environment).
30472  As 'failure to communicate' is probably one of the job-induced deformations
30473  of an embedded programmer this is highly encouraged.
30474 \end_layout
30475
30476 \begin_layout Section
30477 Debugging with SDCDB
30478 \begin_inset LatexCommand label
30479 name "cha:Debugging-with-SDCDB"
30480
30481 \end_inset
30482
30483
30484 \begin_inset LatexCommand index
30485 name "SDCDB (debugger)"
30486
30487 \end_inset
30488
30489  
30490 \end_layout
30491
30492 \begin_layout Standard
30493 SDCC is distributed with a source level debugger
30494 \begin_inset LatexCommand index
30495 name "Debugger"
30496
30497 \end_inset
30498
30499 .
30500  The debugger uses a command line interface, the command repertoire of the
30501  debugger has been kept as close to gdb
30502 \begin_inset LatexCommand index
30503 name "gdb"
30504
30505 \end_inset
30506
30507  (the GNU debugger) as possible.
30508  The configuration and build process is part of the standard compiler installati
30509 on, which also builds and installs the debugger in the target directory
30510  specified during configuration.
30511  The debugger allows you debug BOTH at the C source and at the ASM source
30512  level.
30513 \end_layout
30514
30515 \begin_layout Subsection
30516 Compiling for Debugging
30517 \end_layout
30518
30519 \begin_layout Standard
30520 The -
30521 \begin_inset ERT
30522 status collapsed
30523
30524 \begin_layout Standard
30525
30526
30527 \backslash
30528 /
30529 \end_layout
30530
30531 \end_inset
30532
30533 -debug
30534 \begin_inset LatexCommand index
30535 name "-\\/-debug"
30536
30537 \end_inset
30538
30539  option must be specified for all files for which debug information is to
30540  be generated.
30541  The compiler generates a .adb file for each of these files.
30542  The linker creates the .cdb
30543 \begin_inset LatexCommand index
30544 name "<file>.cdb"
30545
30546 \end_inset
30547
30548  file from the .adb
30549 \begin_inset LatexCommand index
30550 name "<file>.adb"
30551
30552 \end_inset
30553
30554  files and the address information.
30555  This .cdb is used by the debugger.
30556 \end_layout
30557
30558 \begin_layout Subsection
30559 How the Debugger Works
30560 \end_layout
30561
30562 \begin_layout Standard
30563 When the -
30564 \begin_inset ERT
30565 status collapsed
30566
30567 \begin_layout Standard
30568
30569
30570 \backslash
30571 /
30572 \end_layout
30573
30574 \end_inset
30575
30576 -debug option is specified the compiler generates extra symbol information
30577  some of which are put into the assembler source and some are put into the
30578  .adb file.
30579  Then the linker creates the .cdb file from the individual .adb files with
30580  the address information for the symbols.
30581  The debugger reads the symbolic information generated by the compiler &
30582  the address information generated by the linker.
30583  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
30584  execution is controlled by the debugger.
30585  When a command is issued for the debugger, it translates it into appropriate
30586  commands for the simulator.
30587  (Currently SDCDM only connects to the simulator but 
30588 \emph on
30589 newcdb
30590 \emph default
30591  at 
30592 \begin_inset LatexCommand url
30593 target "http://ec2drv.sf.net/"
30594
30595 \end_inset
30596
30597  is an effort to connect directly to the hardware.) 
30598 \end_layout
30599
30600 \begin_layout Subsection
30601 Starting the Debugger SDCDB
30602 \end_layout
30603
30604 \begin_layout Standard
30605 The debugger can be started using the following command line.
30606  (Assume the file you are debugging has the file name foo).
30607 \newline
30608
30609 \newline
30610
30611 \family sans
30612 \series bold
30613 sdcdb foo
30614 \newline
30615
30616 \family default
30617 \series default
30618
30619 \newline
30620 The debugger will look for the following files.
30621 \end_layout
30622
30623 \begin_layout Itemize
30624 foo.c - the source file.
30625 \end_layout
30626
30627 \begin_layout Itemize
30628 foo.cdb - the debugger symbol information file.
30629 \end_layout
30630
30631 \begin_layout Itemize
30632 foo.ihx - the Intel hex format
30633 \begin_inset LatexCommand index
30634 name "Intel hex format"
30635
30636 \end_inset
30637
30638  object file.
30639 \end_layout
30640
30641 \begin_layout Subsection
30642 SDCDB Command Line Options
30643 \end_layout
30644
30645 \begin_layout Itemize
30646 -
30647 \begin_inset ERT
30648 status collapsed
30649
30650 \begin_layout Standard
30651
30652
30653 \backslash
30654 /
30655 \end_layout
30656
30657 \end_inset
30658
30659 -directory=<source file directory> this option can used to specify the directory
30660  search list.
30661  The debugger will look into the directory list specified for source, cdb
30662  & ihx files.
30663  The items in the directory list must be separated by ':', e.g.
30664  if the source files can be in the directories /home/src1 and /home/src2,
30665  the -
30666 \begin_inset ERT
30667 status collapsed
30668
30669 \begin_layout Standard
30670
30671
30672 \backslash
30673 /
30674 \end_layout
30675
30676 \end_inset
30677
30678 -directory option should be -
30679 \begin_inset ERT
30680 status collapsed
30681
30682 \begin_layout Standard
30683
30684
30685 \backslash
30686 /
30687 \end_layout
30688
30689 \end_inset
30690
30691 -directory=/home/src1:/home/src2.
30692  Note there can be no spaces in the option.
30693  
30694 \end_layout
30695
30696 \begin_layout Itemize
30697 -cd <directory> - change to the <directory>.
30698 \end_layout
30699
30700 \begin_layout Itemize
30701 -fullname - used by GUI front ends.
30702 \end_layout
30703
30704 \begin_layout Itemize
30705 -cpu <cpu-type> - this argument is passed to the simulator please see the
30706  simulator docs for details.
30707 \end_layout
30708
30709 \begin_layout Itemize
30710 -X <Clock frequency > this options is passed to the simulator please see
30711  the simulator docs for details.
30712 \end_layout
30713
30714 \begin_layout Itemize
30715 -s <serial port file> passed to simulator see the simulator docs for details.
30716 \end_layout
30717
30718 \begin_layout Itemize
30719 -S <serial in,out> passed to simulator see the simulator docs for details.
30720 \end_layout
30721
30722 \begin_layout Itemize
30723 -k <port number> passed to simulator see the simulator docs for details.
30724 \end_layout
30725
30726 \begin_layout Subsection
30727 SDCDB Debugger Commands
30728 \end_layout
30729
30730 \begin_layout Standard
30731 As mentioned earlier the command interface for the debugger has been deliberatel
30732 y kept as close the GNU debugger gdb, as possible.
30733  This will help the integration with existing graphical user interfaces
30734  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
30735  If you use a graphical user interface for the debugger you can skip this
30736  section.
30737 \end_layout
30738
30739 \begin_layout Subsubsection*
30740 break [line | file:line | function | file:function]
30741 \end_layout
30742
30743 \begin_layout Standard
30744 Set breakpoint at specified line or function:
30745 \newline
30746
30747 \newline
30748
30749 \family sans
30750 \series bold
30751 sdcdb>break 100 
30752 \newline
30753 sdcdb>break foo.c:100
30754 \newline
30755 sdcdb>break funcfoo
30756 \newline
30757 sdcdb>break foo.c:funcfoo
30758 \end_layout
30759
30760 \begin_layout Subsubsection*
30761 clear [line | file:line | function | file:function ]
30762 \end_layout
30763
30764 \begin_layout Standard
30765 Clear breakpoint at specified line or function:
30766 \newline
30767
30768 \newline
30769
30770 \family sans
30771 \series bold
30772 sdcdb>clear 100
30773 \newline
30774 sdcdb>clear foo.c:100
30775 \newline
30776 sdcdb>clear funcfoo
30777 \newline
30778 sdcdb>clear foo.c:funcfoo
30779 \end_layout
30780
30781 \begin_layout Subsubsection*
30782 continue
30783 \end_layout
30784
30785 \begin_layout Standard
30786 Continue program being debugged, after breakpoint.
30787 \end_layout
30788
30789 \begin_layout Subsubsection*
30790 finish
30791 \end_layout
30792
30793 \begin_layout Standard
30794 Execute till the end of the current function.
30795 \end_layout
30796
30797 \begin_layout Subsubsection*
30798 delete [n]
30799 \end_layout
30800
30801 \begin_layout Standard
30802 Delete breakpoint number 'n'.
30803  If used without any option clear ALL user defined break points.
30804 \end_layout
30805
30806 \begin_layout Subsubsection*
30807 info [break | stack | frame | registers ]
30808 \end_layout
30809
30810 \begin_layout Itemize
30811 info break - list all breakpoints
30812 \end_layout
30813
30814 \begin_layout Itemize
30815 info stack - show the function call stack.
30816 \end_layout
30817
30818 \begin_layout Itemize
30819 info frame - show information about the current execution frame.
30820 \end_layout
30821
30822 \begin_layout Itemize
30823 info registers - show content of all registers.
30824 \end_layout
30825
30826 \begin_layout Subsubsection*
30827 step
30828 \end_layout
30829
30830 \begin_layout Standard
30831 Step program until it reaches a different source line.
30832  Note: pressing <return> repeats the last command.
30833 \end_layout
30834
30835 \begin_layout Subsubsection*
30836 next
30837 \end_layout
30838
30839 \begin_layout Standard
30840 Step program, proceeding through subroutine calls.
30841 \end_layout
30842
30843 \begin_layout Subsubsection*
30844 run
30845 \end_layout
30846
30847 \begin_layout Standard
30848 Start debugged program.
30849 \end_layout
30850
30851 \begin_layout Subsubsection*
30852 ptype variable 
30853 \end_layout
30854
30855 \begin_layout Standard
30856 Print type information of the variable.
30857 \end_layout
30858
30859 \begin_layout Subsubsection*
30860 print variable
30861 \end_layout
30862
30863 \begin_layout Standard
30864 print value of variable.
30865 \end_layout
30866
30867 \begin_layout Subsubsection*
30868 file filename
30869 \end_layout
30870
30871 \begin_layout Standard
30872 load the given file name.
30873  Note this is an alternate method of loading file for debugging.
30874 \end_layout
30875
30876 \begin_layout Subsubsection*
30877 frame
30878 \end_layout
30879
30880 \begin_layout Standard
30881 print information about current frame.
30882 \end_layout
30883
30884 \begin_layout Subsubsection*
30885 set srcmode
30886 \end_layout
30887
30888 \begin_layout Standard
30889 Toggle between C source & assembly source.
30890 \end_layout
30891
30892 \begin_layout Subsubsection*
30893 ! simulator command
30894 \end_layout
30895
30896 \begin_layout Standard
30897 Send the string following '!' to the simulator, the simulator response is
30898  displayed.
30899  Note the debugger does not interpret the command being sent to the simulator,
30900  so if a command like 'go' is sent the debugger can loose its execution
30901  context and may display incorrect values.
30902 \end_layout
30903
30904 \begin_layout Subsubsection*
30905 quit
30906 \end_layout
30907
30908 \begin_layout Standard
30909 "Watch me now.
30910  Iam going Down.
30911  My name is Bobby Brown"
30912 \end_layout
30913
30914 \begin_layout Subsection
30915 Interfacing SDCDB with DDD
30916 \end_layout
30917
30918 \begin_layout Standard
30919 \begin_inset Note Note
30920 status collapsed
30921
30922 \begin_layout Standard
30923 The screenshot was converted from png to eps with: 
30924 \begin_inset Quotes sld
30925 \end_inset
30926
30927 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
30928 \begin_inset Quotes srd
30929 \end_inset
30930
30931  which produces a pretty compact eps file which is free from compression
30932  artifacts.
30933 \end_layout
30934
30935 \begin_layout Standard
30936 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
30937  as this broke the build system on Sourceforge (pdf-file was broken.
30938  pdflatex does not accept eps files).
30939 \end_layout
30940
30941 \end_inset
30942
30943
30944 \end_layout
30945
30946 \begin_layout Standard
30947 The 
30948 \emph on
30949 p
30950 \emph default
30951 ortable 
30952 \emph on
30953 n
30954 \emph default
30955 etwork 
30956 \emph on
30957 g
30958 \emph default
30959 raphics File 
30960 \size footnotesize
30961
30962 \begin_inset LatexCommand url
30963 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png"
30964
30965 \end_inset
30966
30967
30968 \size default
30969  shows a screenshot of a debugging session with DDD
30970 \begin_inset LatexCommand index
30971 name "DDD (debugger)"
30972
30973 \end_inset
30974
30975  (Unix only) on a simulated 8032.
30976  The debugging session might not run as smoothly as the screenshot suggests.
30977  The debugger allows setting of breakpoints, displaying and changing variables,
30978  single stepping through C and assembler code.
30979  
30980 \newline
30981 The source was compiled with 
30982 \family sans
30983 \series bold
30984
30985 \newline
30986
30987 \newline
30988 sdcc -
30989 \family default
30990 \series default
30991
30992 \begin_inset ERT
30993 status collapsed
30994
30995 \begin_layout Standard
30996
30997
30998 \backslash
30999 /
31000 \end_layout
31001
31002 \end_inset
31003
31004
31005 \family sans
31006 \series bold
31007 -debug ddd_example.c
31008 \family default
31009 \series default
31010  
31011 \family sans
31012 \series bold
31013
31014 \newline
31015
31016 \family default
31017 \series default
31018
31019 \newline
31020 and DDD was invoked with 
31021 \family sans
31022 \series bold
31023
31024 \newline
31025
31026 \newline
31027 ddd -debugger "sdcdb -cpu 8032 ddd_example"
31028 \end_layout
31029
31030 \begin_layout Standard
31031 \begin_inset Note Note
31032 status open
31033
31034 \begin_layout Standard
31035 Check that the double quotes or an apostrophe within the command line survive
31036  the LyX tool chain.
31037  Previously the apostrophes got slanted in the PDF output so a cut and paste
31038  did not work.
31039 \end_layout
31040
31041 \end_inset
31042
31043
31044 \end_layout
31045
31046 \begin_layout Subsection
31047 Interfacing SDCDB with XEmacs
31048 \begin_inset LatexCommand index
31049 name "XEmacs"
31050
31051 \end_inset
31052
31053
31054 \begin_inset LatexCommand index
31055 name "Emacs"
31056
31057 \end_inset
31058
31059
31060 \end_layout
31061
31062 \begin_layout Standard
31063 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
31064  sdcdb.el and sdcdbsrc.el.
31065  These two files can be found in the $(prefix)/bin directory after the installat
31066 ion is complete.
31067  These files need to be loaded into XEmacs for the interface to work.
31068  This can be done at XEmacs startup time by inserting the following into
31069  your '.xemacs' file (which can be found in your HOME directory): 
31070 \newline
31071
31072 \newline
31073
31074 \family typewriter
31075 (load-file sdcdbsrc.el)
31076 \family default
31077  
31078 \newline
31079
31080 \newline
31081 .xemacs is a lisp file so the () around the command is REQUIRED.
31082  The files can also be loaded dynamically while XEmacs is running, set the
31083  environment variable 'EMACSLOADPATH' to the installation bin directory
31084  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
31085  To start the interface enter the following command: 
31086 \newline
31087
31088 \newline
31089
31090 \family sans
31091 \series bold
31092 ESC-x sdcdbsrc
31093 \family default
31094 \series default
31095
31096 \newline
31097
31098 \newline
31099 You will prompted to enter the file name to be debugged.
31100  
31101 \newline
31102
31103 \newline
31104 The command line options that are passed to the simulator directly are
31105  bound to default values in the file sdcdbsrc.el.
31106  The variables are listed below, these values maybe changed as required.
31107 \end_layout
31108
31109 \begin_layout Itemize
31110 sdcdbsrc-cpu-type '51
31111 \end_layout
31112
31113 \begin_layout Itemize
31114 sdcdbsrc-frequency '11059200
31115 \end_layout
31116
31117 \begin_layout Itemize
31118 sdcdbsrc-serial nil
31119 \end_layout
31120
31121 \begin_layout Standard
31122 The following is a list of key mapping for the debugger interface.
31123 \end_layout
31124
31125 \begin_layout Standard
31126 \InsetSpace ~
31127
31128 \family typewriter
31129
31130 \newline
31131 ;;\InsetSpace ~
31132 Current Listing :: 
31133 \newline
31134 ;;key\InsetSpace ~
31135 \InsetSpace ~
31136 \InsetSpace ~
31137 \InsetSpace ~
31138 \InsetSpace ~
31139 \InsetSpace ~
31140 \InsetSpace ~
31141 \InsetSpace ~
31142 \InsetSpace ~
31143 \InsetSpace ~
31144 \InsetSpace ~
31145 \InsetSpace ~
31146 \InsetSpace ~
31147 \InsetSpace ~
31148 binding\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 \InsetSpace ~
31163 \InsetSpace ~
31164 \InsetSpace ~
31165 \InsetSpace ~
31166 \InsetSpace ~
31167 \InsetSpace ~
31168 \InsetSpace ~
31169 \InsetSpace ~
31170 Comment 
31171 \newline
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 \InsetSpace ~
31185 \InsetSpace ~
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 -------
31209 \newline
31210 ;; 
31211 \newline
31212 ;;\InsetSpace ~
31213 n\InsetSpace ~
31214 \InsetSpace ~
31215 \InsetSpace ~
31216 \InsetSpace ~
31217 \InsetSpace ~
31218 \InsetSpace ~
31219 \InsetSpace ~
31220 \InsetSpace ~
31221 \InsetSpace ~
31222 \InsetSpace ~
31223 \InsetSpace ~
31224 \InsetSpace ~
31225 \InsetSpace ~
31226 \InsetSpace ~
31227 \InsetSpace ~
31228 sdcdb-next-fro
31229 m-src\InsetSpace ~
31230 \InsetSpace ~
31231 \InsetSpace ~
31232 \InsetSpace ~
31233 \InsetSpace ~
31234 \InsetSpace ~
31235 \InsetSpace ~
31236 \InsetSpace ~
31237 \InsetSpace ~
31238 \InsetSpace ~
31239 SDCDB next command 
31240 \newline
31241 ;;\InsetSpace ~
31242 b\InsetSpace ~
31243 \InsetSpace ~
31244 \InsetSpace ~
31245 \InsetSpace ~
31246 \InsetSpace ~
31247 \InsetSpace ~
31248 \InsetSpace ~
31249 \InsetSpace ~
31250 \InsetSpace ~
31251 \InsetSpace ~
31252 \InsetSpace ~
31253 \InsetSpace ~
31254 \InsetSpace ~
31255 \InsetSpace ~
31256 \InsetSpace ~
31257 sdcdb-back-from-src\InsetSpace ~
31258 \InsetSpace ~
31259 \InsetSpace ~
31260 \InsetSpace ~
31261 \InsetSpace ~
31262 \InsetSpace ~
31263 \InsetSpace ~
31264 \InsetSpace ~
31265 \InsetSpace ~
31266 \InsetSpace ~
31267 SDCDB back command 
31268 \newline
31269 ;;\InsetSpace ~
31270 c\InsetSpace ~
31271 \InsetSpace ~
31272 \InsetSpace ~
31273 \InsetSpace ~
31274 \InsetSpace ~
31275 \InsetSpace ~
31276 \InsetSpace ~
31277 \InsetSpace ~
31278 \InsetSpace ~
31279 \InsetSpace ~
31280 \InsetSpace ~
31281 \InsetSpace ~
31282 \InsetSpace ~
31283 \InsetSpace ~
31284 \InsetSpace ~
31285 sdcdb-cont-f
31286 rom-src\InsetSpace ~
31287 \InsetSpace ~
31288 \InsetSpace ~
31289 \InsetSpace ~
31290 \InsetSpace ~
31291 \InsetSpace ~
31292 \InsetSpace ~
31293 \InsetSpace ~
31294 \InsetSpace ~
31295 \InsetSpace ~
31296 SDCDB continue command
31297 \newline
31298 ;;\InsetSpace ~
31299 s\InsetSpace ~
31300 \InsetSpace ~
31301 \InsetSpace ~
31302 \InsetSpace ~
31303 \InsetSpace ~
31304 \InsetSpace ~
31305 \InsetSpace ~
31306 \InsetSpace ~
31307 \InsetSpace ~
31308 \InsetSpace ~
31309 \InsetSpace ~
31310 \InsetSpace ~
31311 \InsetSpace ~
31312 \InsetSpace ~
31313 \InsetSpace ~
31314 sdcdb-step-from-src\InsetSpace ~
31315 \InsetSpace ~
31316 \InsetSpace ~
31317 \InsetSpace ~
31318 \InsetSpace ~
31319 \InsetSpace ~
31320 \InsetSpace ~
31321 \InsetSpace ~
31322 \InsetSpace ~
31323 \InsetSpace ~
31324 SDCDB step command 
31325 \newline
31326 ;;\InsetSpace ~
31327 ?\InsetSpace ~
31328 \InsetSpace ~
31329 \InsetSpace ~
31330 \InsetSpace ~
31331 \InsetSpace ~
31332 \InsetSpace ~
31333 \InsetSpace ~
31334 \InsetSpace ~
31335 \InsetSpace ~
31336 \InsetSpace ~
31337 \InsetSpace ~
31338 \InsetSpace ~
31339 \InsetSpace ~
31340 \InsetSpace ~
31341 \InsetSpace ~
31342 sdcdb-w
31343 hatis-c-sexp\InsetSpace ~
31344 \InsetSpace ~
31345 \InsetSpace ~
31346 \InsetSpace ~
31347 \InsetSpace ~
31348 \InsetSpace ~
31349 \InsetSpace ~
31350 \InsetSpace ~
31351 \InsetSpace ~
31352 \InsetSpace ~
31353 SDCDB ptypecommand for data at 
31354 \newline
31355 ;;\InsetSpace ~
31356 \InsetSpace ~
31357 \InsetSpace ~
31358 \InsetSpace ~
31359 \InsetSpace ~
31360 \InsetSpace ~
31361 \InsetSpace ~
31362 \InsetSpace ~
31363 \InsetSpace ~
31364 \InsetSpace ~
31365 \InsetSpace ~
31366 \InsetSpace ~
31367 \InsetSpace ~
31368 \InsetSpace ~
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 buffer point 
31403 \newline
31404 ;;\InsetSpace ~
31405 x\InsetSpace ~
31406 \InsetSpace ~
31407 \InsetSpace ~
31408 \InsetSpace ~
31409 \InsetSpace ~
31410 \InsetSpace ~
31411 \InsetSpace ~
31412 \InsetSpace ~
31413 \InsetSpace ~
31414 \InsetSpace ~
31415 \InsetSpace ~
31416 \InsetSpace ~
31417 \InsetSpace ~
31418 \InsetSpace ~
31419 \InsetSpace ~
31420 sdcdbsrc-delete\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 SDCD
31435 B Delete all breakpoints if no arg 
31436 \newline
31437 ;;\InsetSpace ~
31438 \InsetSpace ~
31439 \InsetSpace ~
31440 \InsetSpace ~
31441 \InsetSpace ~
31442 \InsetSpace ~
31443 \InsetSpace ~
31444 \InsetSpace ~
31445 \InsetSpace ~
31446 \InsetSpace ~
31447 \InsetSpace ~
31448 \InsetSpace ~
31449 \InsetSpace ~
31450 \InsetSpace ~
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 given or delete arg (C-u arg x) 
31485 \newline
31486 ;;\InsetSpace ~
31487 m\InsetSpace ~
31488 \InsetSpace ~
31489 \InsetSpace ~
31490 \InsetSpace ~
31491 \InsetSpace ~
31492 \InsetSpace ~
31493 \InsetSpace ~
31494 \InsetSpace ~
31495 \InsetSpace ~
31496 \InsetSpace ~
31497 \InsetSpace ~
31498 \InsetSpace ~
31499 \InsetSpace ~
31500 \InsetSpace ~
31501 \InsetSpace ~
31502 sdcdbsrc
31503 -frame\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 \InsetSpace ~
31517 \InsetSpace ~
31518 SDCDB Display current frame if no arg, 
31519 \newline
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 \InsetSpace ~
31533 \InsetSpace ~
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 given or display frame arg
31568  
31569 \newline
31570 ;;\InsetSpace ~
31571 \InsetSpace ~
31572 \InsetSpace ~
31573 \InsetSpace ~
31574 \InsetSpace ~
31575 \InsetSpace ~
31576 \InsetSpace ~
31577 \InsetSpace ~
31578 \InsetSpace ~
31579 \InsetSpace ~
31580 \InsetSpace ~
31581 \InsetSpace ~
31582 \InsetSpace ~
31583 \InsetSpace ~
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 buffer point 
31618 \newline
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 \InsetSpace ~
31632 \InsetSpace ~
31633 \InsetSpace ~
31634 \InsetSpace ~
31635 sdcdbsrc-goto-sdcdb\InsetSpace ~
31636 \InsetSpace ~
31637 \InsetSpace ~
31638 \InsetSpace ~
31639 \InsetSpace ~
31640 \InsetSpace ~
31641 \InsetSpace ~
31642 \InsetSpace ~
31643 \InsetSpace ~
31644 \InsetSpace ~
31645 Goto the SDCDB output buffer 
31646 \newline
31647 ;;\InsetSpace ~
31648 p\InsetSpace ~
31649 \InsetSpace ~
31650 \InsetSpace ~
31651 \InsetSpace ~
31652 \InsetSpace ~
31653 \InsetSpace ~
31654 \InsetSpace ~
31655 \InsetSpace ~
31656 \InsetSpace ~
31657 \InsetSpace ~
31658 \InsetSpace ~
31659 \InsetSpace ~
31660 \InsetSpace ~
31661 \InsetSpace ~
31662 \InsetSpace ~
31663 sdcdb-prin
31664 t-c-sexp\InsetSpace ~
31665 \InsetSpace ~
31666 \InsetSpace ~
31667 \InsetSpace ~
31668 \InsetSpace ~
31669 \InsetSpace ~
31670 \InsetSpace ~
31671 \InsetSpace ~
31672 \InsetSpace ~
31673 \InsetSpace ~
31674 \InsetSpace ~
31675 SDCDB print command for data at 
31676 \newline
31677 ;;\InsetSpace ~
31678 \InsetSpace ~
31679 \InsetSpace ~
31680 \InsetSpace ~
31681 \InsetSpace ~
31682 \InsetSpace ~
31683 \InsetSpace ~
31684 \InsetSpace ~
31685 \InsetSpace ~
31686 \InsetSpace ~
31687 \InsetSpace ~
31688 \InsetSpace ~
31689 \InsetSpace ~
31690 \InsetSpace ~
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 buffer point 
31725 \newline
31726 ;;\InsetSpace ~
31727 g\InsetSpace ~
31728 \InsetSpace ~
31729 \InsetSpace ~
31730 \InsetSpace ~
31731 \InsetSpace ~
31732 \InsetSpace ~
31733 \InsetSpace ~
31734 \InsetSpace ~
31735 \InsetSpace ~
31736 \InsetSpace ~
31737 \InsetSpace ~
31738 \InsetSpace ~
31739 \InsetSpace ~
31740 \InsetSpace ~
31741 \InsetSpace ~
31742 sdcdbsrc-goto-sdcdb\InsetSpace ~
31743 \InsetSpace ~
31744 \InsetSpace ~
31745 \InsetSpace ~
31746 \InsetSpace ~
31747 \InsetSpace ~
31748 \InsetSpace ~
31749 \InsetSpace ~
31750 \InsetSpace ~
31751 \InsetSpace ~
31752 Got
31753 o the SDCDB output buffer 
31754 \newline
31755 ;;\InsetSpace ~
31756 t\InsetSpace ~
31757 \InsetSpace ~
31758 \InsetSpace ~
31759 \InsetSpace ~
31760 \InsetSpace ~
31761 \InsetSpace ~
31762 \InsetSpace ~
31763 \InsetSpace ~
31764 \InsetSpace ~
31765 \InsetSpace ~
31766 \InsetSpace ~
31767 \InsetSpace ~
31768 \InsetSpace ~
31769 \InsetSpace ~
31770 \InsetSpace ~
31771 sdcdbsrc-mode\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 \InsetSpace ~
31786 \InsetSpace ~
31787 Toggles Sdcdbsrc mode (turns it
31788  off) 
31789 \newline
31790 ;; 
31791 \newline
31792 ;;\InsetSpace ~
31793 C-c\InsetSpace ~
31794 C-f\InsetSpace ~
31795 \InsetSpace ~
31796 \InsetSpace ~
31797 \InsetSpace ~
31798 \InsetSpace ~
31799 \InsetSpace ~
31800 \InsetSpace ~
31801 \InsetSpace ~
31802 \InsetSpace ~
31803 sdcdb-finish-from-src\InsetSpace ~
31804 \InsetSpace ~
31805 \InsetSpace ~
31806 \InsetSpace ~
31807 \InsetSpace ~
31808 \InsetSpace ~
31809 \InsetSpace ~
31810 \InsetSpace ~
31811 SDCDB finish command 
31812 \newline
31813 ;; 
31814 \newline
31815 ;;\InsetSpace ~
31816 C-x\InsetSpace ~
31817 SPC\InsetSpace ~
31818 \InsetSpace ~
31819 \InsetSpace ~
31820 \InsetSpace ~
31821 \InsetSpace ~
31822 \InsetSpace ~
31823 \InsetSpace ~
31824 \InsetSpace ~
31825 \InsetSpace ~
31826 sdcdb-brea
31827 k\InsetSpace ~
31828 \InsetSpace ~
31829 \InsetSpace ~
31830 \InsetSpace ~
31831 \InsetSpace ~
31832 \InsetSpace ~
31833 \InsetSpace ~
31834 \InsetSpace ~
31835 \InsetSpace ~
31836 \InsetSpace ~
31837 \InsetSpace ~
31838 \InsetSpace ~
31839 \InsetSpace ~
31840 \InsetSpace ~
31841 \InsetSpace ~
31842 \InsetSpace ~
31843 \InsetSpace ~
31844 \InsetSpace ~
31845 Set break for line with point 
31846 \newline
31847 ;;\InsetSpace ~
31848 ESC\InsetSpace ~
31849 t\InsetSpace ~
31850 \InsetSpace ~
31851 \InsetSpace ~
31852 \InsetSpace ~
31853 \InsetSpace ~
31854 \InsetSpace ~
31855 \InsetSpace ~
31856 \InsetSpace ~
31857 \InsetSpace ~
31858 \InsetSpace ~
31859 \InsetSpace ~
31860 sdcdbsrc-mode\InsetSpace ~
31861 \InsetSpace ~
31862 \InsetSpace ~
31863 \InsetSpace ~
31864 \InsetSpace ~
31865 \InsetSpace ~
31866 \InsetSpace ~
31867 \InsetSpace ~
31868 \InsetSpace ~
31869 \InsetSpace ~
31870 \InsetSpace ~
31871 \InsetSpace ~
31872 \InsetSpace ~
31873 \InsetSpace ~
31874 \InsetSpace ~
31875 \InsetSpace ~
31876 Toggle Sdcdbsrc mode 
31877 \newline
31878 ;;\InsetSpace ~
31879 ESC\InsetSpace ~
31880 m\InsetSpace ~
31881 \InsetSpace ~
31882 \InsetSpace ~
31883 \InsetSpace ~
31884 \InsetSpace ~
31885 \InsetSpace ~
31886 \InsetSpace ~
31887 \InsetSpace ~
31888 \InsetSpace ~
31889 \InsetSpace ~
31890 \InsetSpace ~
31891 sdc
31892 dbsrc-srcmode\InsetSpace ~
31893 \InsetSpace ~
31894 \InsetSpace ~
31895 \InsetSpace ~
31896 \InsetSpace ~
31897 \InsetSpace ~
31898 \InsetSpace ~
31899 \InsetSpace ~
31900 \InsetSpace ~
31901 \InsetSpace ~
31902 \InsetSpace ~
31903 \InsetSpace ~
31904 \InsetSpace ~
31905 Toggle list mode 
31906 \newline
31907 ;; 
31908 \newline
31909
31910 \family default
31911
31912 \newpage
31913
31914 \end_layout
31915
31916 \begin_layout Chapter
31917 TIPS
31918 \end_layout
31919
31920 \begin_layout Standard
31921 Here are a few guidelines that will help the compiler generate more efficient
31922  code, some of the tips are specific to this compiler others are generally
31923  good programming practice.
31924 \end_layout
31925
31926 \begin_layout Itemize
31927 Use the smallest data type to represent your data-value.
31928  If it is known in advance that the value is going to be less than 256 then
31929  use an 'unsigned char' instead of a 'short' or 'int'.
31930  Please note, that ANSI C requires both signed and unsigned chars to be
31931  promoted to 'signed int'
31932 \begin_inset LatexCommand index
31933 name "promotion to signed int"
31934
31935 \end_inset
31936
31937
31938 \begin_inset Marginal
31939 status collapsed
31940
31941 \begin_layout Standard
31942
31943 \series bold
31944 \InsetSpace ~
31945 !
31946 \end_layout
31947
31948 \end_inset
31949
31950  before doing any operation.
31951  This promotion
31952 \begin_inset LatexCommand index
31953 name "type promotion"
31954
31955 \end_inset
31956
31957
31958 \begin_inset LatexCommand label
31959 name "type promotion"
31960
31961 \end_inset
31962
31963  can be omitted, if the result is the same.
31964  The effect of the promotion rules together with the sign-extension is often
31965  surprising:
31966 \end_layout
31967
31968 \begin_deeper
31969 \begin_layout Verse
31970
31971 \family typewriter
31972 unsigned char uc = 0xfe;
31973 \newline
31974 if (uc * uc < 0) /* this is true! */
31975 \newline
31976 {
31977 \newline
31978 \InsetSpace ~
31979 \InsetSpace ~
31980 \InsetSpace ~
31981 \InsetSpace ~
31982 ....
31983 \newline
31984 }
31985 \end_layout
31986
31987 \begin_layout Standard
31988
31989 \family typewriter
31990 uc * uc
31991 \family default
31992  is evaluated as 
31993 \family typewriter
31994 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
31995 \family default
31996 .
31997  
31998 \newline
31999 Another one:
32000 \end_layout
32001
32002 \begin_layout Verse
32003
32004 \family typewriter
32005 (unsigned char) -12 / (signed char) -3 = ...
32006 \end_layout
32007
32008 \begin_layout Standard
32009 No, the result is not 4:
32010 \end_layout
32011
32012 \begin_layout Verse
32013
32014 \family typewriter
32015 (int) (unsigned char) -12 / (int) (signed char) -3 =
32016 \newline
32017 (int) (unsigned char)
32018  0xf4 / (int) (signed char) 0xfd =
32019 \newline
32020 (int) 0x00f4 / (int) 0xfffd =
32021 \newline
32022 (int) 0x00f4
32023  / (int) 0xfffd =
32024 \newline
32025 (int) 244 / (int) -3 =
32026 \newline
32027 (int) -81 = (int) 0xffaf;
32028 \end_layout
32029
32030 \begin_layout Standard
32031 Don't complain, that gcc gives you a different result.
32032  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
32033  Therefore the results are different.
32034 \newline
32035 From 
32036 \begin_inset Quotes sld
32037 \end_inset
32038
32039 comp.lang.c FAQ
32040 \begin_inset Quotes srd
32041 \end_inset
32042
32043 :
32044 \end_layout
32045
32046 \begin_layout Quote
32047
32048 \emph on
32049 If well-defined overflow characteristics are important and negative values
32050  are not, or if you want to steer clear of sign-extension problems when
32051  manipulating bits or bytes, use one of the corresponding unsigned types.
32052  (Beware when mixing signed and unsigned values in expressions, though.)
32053 \newline
32054 Although
32055  character types (especially unsigned char) can be used as "tiny" integers,
32056  doing so is sometimes more trouble than it's worth, due to unpredictable
32057  sign extension and increased code size.
32058 \end_layout
32059
32060 \end_deeper
32061 \begin_layout Itemize
32062 Use unsigned when it is known in advance that the value is not going to
32063  be negative.
32064  This helps especially if you are doing division or multiplication, bit-shifting
32065  or are using an array index.
32066 \end_layout
32067
32068 \begin_layout Itemize
32069 NEVER jump into a LOOP.
32070 \end_layout
32071
32072 \begin_layout Itemize
32073 Declare the variables to be local
32074 \begin_inset LatexCommand index
32075 name "local variables"
32076
32077 \end_inset
32078
32079  whenever possible, especially loop control variables (induction).
32080 \end_layout
32081
32082 \begin_layout Itemize
32083 Have a look at the assembly listing to get a 
32084 \begin_inset Quotes sld
32085 \end_inset
32086
32087 feeling
32088 \begin_inset Quotes srd
32089 \end_inset
32090
32091  for the code generation.
32092 \end_layout
32093
32094 \begin_layout Section
32095 Porting code from or to other compilers
32096 \begin_inset LatexCommand label
32097 name "sec:Porting-code-to-other-compilers"
32098
32099 \end_inset
32100
32101
32102 \end_layout
32103
32104 \begin_layout Itemize
32105 check whether endianness of the compilers differs and adapt where needed.
32106 \end_layout
32107
32108 \begin_layout Itemize
32109 check the device specific header files
32110 \begin_inset LatexCommand index
32111 name "Header files"
32112
32113 \end_inset
32114
32115
32116 \begin_inset LatexCommand index
32117 name "Include files"
32118
32119 \end_inset
32120
32121  for compiler specific syntax.
32122  Eventually include the file <compiler.h
32123 \begin_inset LatexCommand index
32124 name "compiler.h (include file)"
32125
32126 \end_inset
32127
32128
32129 \begin_inset LatexCommand url
32130 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup"
32131
32132 \end_inset
32133
32134  to allow using common header files.
32135  (see f.e.
32136  cc2510fx.h 
32137 \begin_inset LatexCommand url
32138 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup"
32139
32140 \end_inset
32141
32142 ).
32143 \end_layout
32144
32145 \begin_layout Itemize
32146 check whether the startup code contains the correct initialization (watchdog,
32147  peripherals).
32148 \end_layout
32149
32150 \begin_layout Itemize
32151 check whether the sizes of short, int, long match.
32152 \end_layout
32153
32154 \begin_layout Itemize
32155 check if some 16 or 32 bit hardware registers require a specific addressing
32156  order (least significant or most significant byte first) and adapt if needed
32157  (
32158 \emph on
32159 first
32160 \emph default
32161  and 
32162 \emph on
32163 last
32164 \emph default
32165  relate to time and not to lower/upper memory location here, so this is
32166  
32167 \emph on
32168 not
32169 \emph default
32170  the same as endianness).
32171 \end_layout
32172
32173 \begin_layout Itemize
32174 check whether the keyword 
32175 \emph on
32176 volatile
32177 \emph default
32178  is used where needed.
32179  The compilers might differ in their optimization characteristics (as different
32180  versions of the same compiler might also use more clever optimizations
32181  this is good idea anyway).
32182  See section 
32183 \begin_inset LatexCommand ref
32184 reference "sub:Common-interrupt-pitfall-volatile"
32185
32186 \end_inset
32187
32188 .
32189 \end_layout
32190
32191 \begin_layout Itemize
32192 check that the compilers are not told to suppress warnings.
32193 \end_layout
32194
32195 \begin_layout Itemize
32196 check and convert compiler specific extensions (interrupts, memory areas,
32197  pragmas etc.).
32198 \end_layout
32199
32200 \begin_layout Itemize
32201 check for differences in type promotion.
32202  Especially check for math operations on 
32203 \family typewriter
32204 char
32205 \family default
32206  or 
32207 \family typewriter
32208 unsigned char
32209 \family default
32210  variables.
32211  For the sake of C99 compatibility SDCC will probably promote these to 
32212 \family typewriter
32213 int
32214 \family default
32215  more often than other compilers.
32216  Eventually insert explicit casts to 
32217 \family typewriter
32218 (char)
32219 \family default
32220  or 
32221 \family typewriter
32222 (unsigned char)
32223 \family default
32224 .
32225  Also check that the ~\InsetSpace ~
32226 operator
32227 \begin_inset LatexCommand index
32228 name "\\~\\/ Operator"
32229
32230 \end_inset
32231
32232  is not used on 
32233 \family typewriter
32234 bit
32235 \begin_inset LatexCommand index
32236 name "bit"
32237
32238 \end_inset
32239
32240
32241 \family default
32242  variables, use the !\InsetSpace ~
32243 operator instead.
32244  See sections 
32245 \begin_inset LatexCommand ref
32246 reference "type promotion"
32247
32248 \end_inset
32249
32250  and 
32251 \begin_inset LatexCommand ref
32252 reference "sec:Compatibility-with-previous"
32253
32254 \end_inset
32255
32256 .
32257 \end_layout
32258
32259 \begin_layout Itemize
32260 check the assembly code generated for interrupt routines (f.e.
32261  for calls to possibly non-reentrant library functions).
32262 \end_layout
32263
32264 \begin_layout Itemize
32265 check whether timing loops result in proper timing (or preferably consider
32266  a rewrite of the code with timer based delays instead).
32267 \end_layout
32268
32269 \begin_layout Itemize
32270 check for differences in printf parameters (some compilers push (va_arg
32271 \begin_inset LatexCommand index
32272 name "vararg, va\\_arg"
32273
32274 \end_inset
32275
32276 ) char variables as 
32277 \family typewriter
32278 int
32279 \family default
32280  others push them as 
32281 \family typewriter
32282 char
32283 \family default
32284 .
32285  See section 
32286 \begin_inset LatexCommand ref
32287 reference "sec:Compatibility-with-previous"
32288
32289 \end_inset
32290
32291 ).
32292 \end_layout
32293
32294 \begin_layout Itemize
32295 check the resulting memory map
32296 \begin_inset LatexCommand index
32297 name "Memory map"
32298
32299 \end_inset
32300
32301 .
32302  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
32303 ly idata, pdata, xdata).
32304  Eventually check if unexpected library functions are included.
32305 \end_layout
32306
32307 \begin_layout Section
32308 Tools
32309 \begin_inset LatexCommand index
32310 name "Tools"
32311
32312 \end_inset
32313
32314  included in the distribution
32315 \end_layout
32316
32317 \begin_layout Standard
32318 \align left
32319 \begin_inset Tabular
32320 <lyxtabular version="3" rows="12" columns="3">
32321 <features>
32322 <column alignment="left" valignment="top" leftline="true" width="0pt">
32323 <column alignment="left" valignment="top" leftline="true" width="0pt">
32324 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32325 <row topline="true" bottomline="true">
32326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32327 \begin_inset Text
32328
32329 \begin_layout Standard
32330
32331 \series bold
32332 Name
32333 \end_layout
32334
32335 \end_inset
32336 </cell>
32337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32338 \begin_inset Text
32339
32340 \begin_layout Standard
32341
32342 \series bold
32343 Purpose
32344 \end_layout
32345
32346 \end_inset
32347 </cell>
32348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32349 \begin_inset Text
32350
32351 \begin_layout Standard
32352
32353 \series bold
32354 Directory
32355 \end_layout
32356
32357 \end_inset
32358 </cell>
32359 </row>
32360 <row topline="true">
32361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32362 \begin_inset Text
32363
32364 \begin_layout Standard
32365 uCsim
32366 \begin_inset LatexCommand index
32367 name "uCsim"
32368
32369 \end_inset
32370
32371
32372 \end_layout
32373
32374 \end_inset
32375 </cell>
32376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32377 \begin_inset Text
32378
32379 \begin_layout Standard
32380 Simulator for various architectures
32381 \end_layout
32382
32383 \end_inset
32384 </cell>
32385 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32386 \begin_inset Text
32387
32388 \begin_layout Standard
32389 sdcc/sim/ucsim
32390 \end_layout
32391
32392 \end_inset
32393 </cell>
32394 </row>
32395 <row topline="true">
32396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32397 \begin_inset Text
32398
32399 \begin_layout Standard
32400 keil2sdcc.pl
32401 \end_layout
32402
32403 \end_inset
32404 </cell>
32405 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32406 \begin_inset Text
32407
32408 \begin_layout Standard
32409 header file
32410 \begin_inset LatexCommand index
32411 name "Header files"
32412
32413 \end_inset
32414
32415
32416 \begin_inset LatexCommand index
32417 name "Include files"
32418
32419 \end_inset
32420
32421  conversion
32422 \end_layout
32423
32424 \end_inset
32425 </cell>
32426 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32427 \begin_inset Text
32428
32429 \begin_layout Standard
32430 sdcc/support/scripts
32431 \end_layout
32432
32433 \end_inset
32434 </cell>
32435 </row>
32436 <row topline="true">
32437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32438 \begin_inset Text
32439
32440 \begin_layout Standard
32441 mh2h.c
32442 \end_layout
32443
32444 \end_inset
32445 </cell>
32446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32447 \begin_inset Text
32448
32449 \begin_layout Standard
32450 header file conversion
32451 \end_layout
32452
32453 \end_inset
32454 </cell>
32455 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32456 \begin_inset Text
32457
32458 \begin_layout Standard
32459 sdcc/support/scripts
32460 \end_layout
32461
32462 \end_inset
32463 </cell>
32464 </row>
32465 <row topline="true">
32466 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32467 \begin_inset Text
32468
32469 \begin_layout Standard
32470 as-gbz80
32471 \end_layout
32472
32473 \end_inset
32474 </cell>
32475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32476 \begin_inset Text
32477
32478 \begin_layout Standard
32479 Assembler
32480 \end_layout
32481
32482 \end_inset
32483 </cell>
32484 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32485 \begin_inset Text
32486
32487 \begin_layout Standard
32488
32489 \family roman
32490 \series medium
32491 \shape up
32492 \size normal
32493 \emph off
32494 \bar no
32495 \noun off
32496 \color none
32497 sdcc/bin
32498 \end_layout
32499
32500 \end_inset
32501 </cell>
32502 </row>
32503 <row topline="true">
32504 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32505 \begin_inset Text
32506
32507 \begin_layout Standard
32508 as-z80
32509 \end_layout
32510
32511 \end_inset
32512 </cell>
32513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32514 \begin_inset Text
32515
32516 \begin_layout Standard
32517 Assembler
32518 \end_layout
32519
32520 \end_inset
32521 </cell>
32522 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32523 \begin_inset Text
32524
32525 \begin_layout Standard
32526
32527 \family roman
32528 \series medium
32529 \shape up
32530 \size normal
32531 \emph off
32532 \bar no
32533 \noun off
32534 \color none
32535 sdcc/bin
32536 \end_layout
32537
32538 \end_inset
32539 </cell>
32540 </row>
32541 <row topline="true">
32542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32543 \begin_inset Text
32544
32545 \begin_layout Standard
32546 asx8051
32547 \end_layout
32548
32549 \end_inset
32550 </cell>
32551 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32552 \begin_inset Text
32553
32554 \begin_layout Standard
32555 Assembler
32556 \end_layout
32557
32558 \end_inset
32559 </cell>
32560 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32561 \begin_inset Text
32562
32563 \begin_layout Standard
32564
32565 \family roman
32566 \series medium
32567 \shape up
32568 \size normal
32569 \emph off
32570 \bar no
32571 \noun off
32572 \color none
32573 sdcc/bin
32574 \end_layout
32575
32576 \end_inset
32577 </cell>
32578 </row>
32579 <row topline="true">
32580 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32581 \begin_inset Text
32582
32583 \begin_layout Standard
32584 SDCDB
32585 \end_layout
32586
32587 \end_inset
32588 </cell>
32589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32590 \begin_inset Text
32591
32592 \begin_layout Standard
32593 Simulator
32594 \end_layout
32595
32596 \end_inset
32597 </cell>
32598 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32599 \begin_inset Text
32600
32601 \begin_layout Standard
32602
32603 \family roman
32604 \series medium
32605 \shape up
32606 \size normal
32607 \emph off
32608 \bar no
32609 \noun off
32610 \color none
32611 sdcc/bin
32612 \end_layout
32613
32614 \end_inset
32615 </cell>
32616 </row>
32617 <row topline="true">
32618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32619 \begin_inset Text
32620
32621 \begin_layout Standard
32622 aslink
32623 \end_layout
32624
32625 \end_inset
32626 </cell>
32627 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32628 \begin_inset Text
32629
32630 \begin_layout Standard
32631 Linker
32632 \end_layout
32633
32634 \end_inset
32635 </cell>
32636 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32637 \begin_inset Text
32638
32639 \begin_layout Standard
32640
32641 \family roman
32642 \series medium
32643 \shape up
32644 \size normal
32645 \emph off
32646 \bar no
32647 \noun off
32648 \color none
32649 sdcc/bin
32650 \end_layout
32651
32652 \end_inset
32653 </cell>
32654 </row>
32655 <row topline="true">
32656 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32657 \begin_inset Text
32658
32659 \begin_layout Standard
32660 link-z80
32661 \end_layout
32662
32663 \end_inset
32664 </cell>
32665 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32666 \begin_inset Text
32667
32668 \begin_layout Standard
32669 Linker
32670 \end_layout
32671
32672 \end_inset
32673 </cell>
32674 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32675 \begin_inset Text
32676
32677 \begin_layout Standard
32678
32679 \family roman
32680 \series medium
32681 \shape up
32682 \size normal
32683 \emph off
32684 \bar no
32685 \noun off
32686 \color none
32687 sdcc/bin
32688 \end_layout
32689
32690 \end_inset
32691 </cell>
32692 </row>
32693 <row topline="true">
32694 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32695 \begin_inset Text
32696
32697 \begin_layout Standard
32698 link-gbz80
32699 \end_layout
32700
32701 \end_inset
32702 </cell>
32703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32704 \begin_inset Text
32705
32706 \begin_layout Standard
32707 Linker
32708 \end_layout
32709
32710 \end_inset
32711 </cell>
32712 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32713 \begin_inset Text
32714
32715 \begin_layout Standard
32716
32717 \family roman
32718 \series medium
32719 \shape up
32720 \size normal
32721 \emph off
32722 \bar no
32723 \noun off
32724 \color none
32725 sdcc/bin
32726 \end_layout
32727
32728 \end_inset
32729 </cell>
32730 </row>
32731 <row topline="true" bottomline="true">
32732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32733 \begin_inset Text
32734
32735 \begin_layout Standard
32736 packihx
32737 \end_layout
32738
32739 \end_inset
32740 </cell>
32741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32742 \begin_inset Text
32743
32744 \begin_layout Standard
32745 Intel Hex packer 
32746 \begin_inset LatexCommand index
32747 name "packihx (tool)"
32748
32749 \end_inset
32750
32751
32752 \end_layout
32753
32754 \end_inset
32755 </cell>
32756 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32757 \begin_inset Text
32758
32759 \begin_layout Standard
32760
32761 \family roman
32762 \series medium
32763 \shape up
32764 \size normal
32765 \emph off
32766 \bar no
32767 \noun off
32768 \color none
32769 sdcc/bin
32770 \end_layout
32771
32772 \end_inset
32773 </cell>
32774 </row>
32775 </lyxtabular>
32776
32777 \end_inset
32778
32779
32780 \newline
32781
32782 \end_layout
32783
32784 \begin_layout Section
32785 Documentation
32786 \begin_inset LatexCommand index
32787 name "Documentation"
32788
32789 \end_inset
32790
32791  included in the distribution
32792 \end_layout
32793
32794 \begin_layout Standard
32795 \align left
32796 \begin_inset Tabular
32797 <lyxtabular version="3" rows="10" columns="2">
32798 <features>
32799 <column alignment="block" valignment="top" leftline="true" width="40col%">
32800 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
32801 <row topline="true" bottomline="true" endhead="true">
32802 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32803 \begin_inset Text
32804
32805 \begin_layout Standard
32806
32807 \series bold
32808 Subject / Title
32809 \end_layout
32810
32811 \end_inset
32812 </cell>
32813 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32814 \begin_inset Text
32815
32816 \begin_layout Standard
32817
32818 \series bold
32819 Filename / Where to get
32820 \end_layout
32821
32822 \end_inset
32823 </cell>
32824 </row>
32825 <row topline="true">
32826 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32827 \begin_inset Text
32828
32829 \begin_layout Standard
32830 SDCC Compiler User Guide
32831 \end_layout
32832
32833 \end_inset
32834 </cell>
32835 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32836 \begin_inset Text
32837
32838 \begin_layout Standard
32839 You're reading it right now 
32840 \emph on
32841 \InsetSpace ~
32842 \InsetSpace ~
32843 \InsetSpace ~
32844
32845 \hfill
32846 online at:
32847 \emph default
32848
32849 \newline
32850
32851 \begin_inset LatexCommand url
32852 target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
32853
32854 \end_inset
32855
32856
32857 \end_layout
32858
32859 \end_inset
32860 </cell>
32861 </row>
32862 <row topline="true">
32863 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32864 \begin_inset Text
32865
32866 \begin_layout Standard
32867 Changelog of SDCC
32868 \end_layout
32869
32870 \end_inset
32871 </cell>
32872 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32873 \begin_inset Text
32874
32875 \begin_layout Standard
32876 sdcc/Changelog 
32877 \emph on
32878 \InsetSpace ~
32879 \InsetSpace ~
32880 \InsetSpace ~
32881
32882 \hfill
32883 online at:
32884 \emph default
32885
32886 \newline
32887
32888 \begin_inset LatexCommand url
32889 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog"
32890
32891 \end_inset
32892
32893
32894 \end_layout
32895
32896 \end_inset
32897 </cell>
32898 </row>
32899 <row topline="true">
32900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32901 \begin_inset Text
32902
32903 \begin_layout Standard
32904 ASXXXX
32905 \begin_inset LatexCommand index
32906 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
32907
32908 \end_inset
32909
32910
32911 \begin_inset LatexCommand index
32912 name "Assembler documentation"
32913
32914 \end_inset
32915
32916  Assemblers and
32917 \newline
32918 ASLINK
32919 \begin_inset LatexCommand index
32920 name "aslink"
32921
32922 \end_inset
32923
32924
32925 \begin_inset LatexCommand index
32926 name "Linker documentation"
32927
32928 \end_inset
32929
32930  Relocating Linker
32931 \end_layout
32932
32933 \end_inset
32934 </cell>
32935 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32936 \begin_inset Text
32937
32938 \begin_layout Standard
32939 sdcc/as/doc/asxhtm.html 
32940 \emph on
32941 \InsetSpace ~
32942 \InsetSpace ~
32943 \InsetSpace ~
32944
32945 \hfill
32946 online at:
32947 \emph default
32948
32949 \newline
32950
32951 \begin_inset LatexCommand url
32952 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
32953
32954 \end_inset
32955
32956
32957 \end_layout
32958
32959 \end_inset
32960 </cell>
32961 </row>
32962 <row topline="true">
32963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32964 \begin_inset Text
32965
32966 \begin_layout Standard
32967 SDCC regression test
32968 \begin_inset LatexCommand index
32969 name "Regression test"
32970
32971 \end_inset
32972
32973
32974 \end_layout
32975
32976 \end_inset
32977 </cell>
32978 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32979 \begin_inset Text
32980
32981 \begin_layout Standard
32982 sdcc/doc/test_suite_spec.pdf 
32983 \emph on
32984 \InsetSpace ~
32985 \InsetSpace ~
32986 \InsetSpace ~
32987
32988 \hfill
32989 online at:
32990 \emph default
32991
32992 \newline
32993
32994 \begin_inset LatexCommand url
32995 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
32996
32997 \end_inset
32998
32999
33000 \end_layout
33001
33002 \end_inset
33003 </cell>
33004 </row>
33005 <row topline="true">
33006 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33007 \begin_inset Text
33008
33009 \begin_layout Standard
33010 Various notes
33011 \end_layout
33012
33013 \end_inset
33014 </cell>
33015 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33016 \begin_inset Text
33017
33018 \begin_layout Standard
33019 sdcc/doc/* 
33020 \emph on
33021 \InsetSpace ~
33022 \InsetSpace ~
33023 \InsetSpace ~
33024
33025 \hfill
33026 online at:
33027 \emph default
33028
33029 \newline
33030
33031 \begin_inset LatexCommand url
33032 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/"
33033
33034 \end_inset
33035
33036
33037 \end_layout
33038
33039 \end_inset
33040 </cell>
33041 </row>
33042 <row topline="true">
33043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33044 \begin_inset Text
33045
33046 \begin_layout Standard
33047 Notes on debugging with SDCDB
33048 \begin_inset LatexCommand index
33049 name "SDCDB (debugger)"
33050
33051 \end_inset
33052
33053
33054 \end_layout
33055
33056 \end_inset
33057 </cell>
33058 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33059 \begin_inset Text
33060
33061 \begin_layout Standard
33062 sdcc/debugger/README 
33063 \emph on
33064 \InsetSpace ~
33065 \InsetSpace ~
33066 \InsetSpace ~
33067
33068 \hfill
33069 online at
33070 \emph default
33071 :
33072 \newline
33073
33074 \begin_inset LatexCommand url
33075 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README"
33076
33077 \end_inset
33078
33079
33080 \end_layout
33081
33082 \end_inset
33083 </cell>
33084 </row>
33085 <row topline="true">
33086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33087 \begin_inset Text
33088
33089 \begin_layout Standard
33090 uCsim
33091 \begin_inset LatexCommand index
33092 name "uCsim"
33093
33094 \end_inset
33095
33096  Software simulator for microcontrollers
33097 \end_layout
33098
33099 \end_inset
33100 </cell>
33101 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33102 \begin_inset Text
33103
33104 \begin_layout Standard
33105
33106 \family roman
33107 \series medium
33108 \shape up
33109 \size normal
33110 \emph off
33111 \bar no
33112 \noun off
33113 \color none
33114 sdcc/sim/ucsim/doc
33115 \family default
33116 \series default
33117 \shape default
33118 \size default
33119 \emph default
33120 \bar default
33121 \noun default
33122 /index.html 
33123 \emph on
33124 \InsetSpace ~
33125 \InsetSpace ~
33126 \InsetSpace ~
33127
33128 \hfill
33129 online at:
33130 \emph default
33131
33132 \newline
33133
33134 \begin_inset LatexCommand url
33135 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html"
33136
33137 \end_inset
33138
33139
33140 \end_layout
33141
33142 \end_inset
33143 </cell>
33144 </row>
33145 <row topline="true">
33146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33147 \begin_inset Text
33148
33149 \begin_layout Standard
33150 Temporary notes on the pic16
33151 \begin_inset LatexCommand index
33152 name "PIC16"
33153
33154 \end_inset
33155
33156  port
33157 \end_layout
33158
33159 \end_inset
33160 </cell>
33161 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33162 \begin_inset Text
33163
33164 \begin_layout Standard
33165 sdcc/src/pic16/NOTES 
33166 \emph on
33167 \InsetSpace ~
33168 \InsetSpace ~
33169 \InsetSpace ~
33170
33171 \hfill
33172 online at:
33173 \newline
33174
33175 \emph default
33176
33177 \begin_inset LatexCommand url
33178 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES"
33179
33180 \end_inset
33181
33182
33183 \end_layout
33184
33185 \end_inset
33186 </cell>
33187 </row>
33188 <row topline="true" bottomline="true">
33189 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33190 \begin_inset Text
33191
33192 \begin_layout Standard
33193 SDCC internal documentation (debugging file format)
33194 \end_layout
33195
33196 \end_inset
33197 </cell>
33198 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33199 \begin_inset Text
33200
33201 \begin_layout Standard
33202 sdcc/doc/
33203 \family roman
33204 \series medium
33205 \shape up
33206 \size normal
33207 \emph off
33208 \bar no
33209 \noun off
33210 \color none
33211 cdbfileformat.pd
33212 \family default
33213 \series default
33214 \shape default
33215 \size default
33216 \emph default
33217 \bar default
33218 \noun default
33219
33220 \emph on
33221 \InsetSpace ~
33222 \InsetSpace ~
33223 \InsetSpace ~
33224
33225 \hfill
33226 online at:
33227 \emph default
33228
33229 \newline
33230
33231 \begin_inset LatexCommand url
33232 target "http://sdcc.sourceforge.net/doc/cdbfileformat.pdf"
33233
33234 \end_inset
33235
33236
33237 \end_layout
33238
33239 \end_inset
33240 </cell>
33241 </row>
33242 </lyxtabular>
33243
33244 \end_inset
33245
33246
33247 \newline
33248
33249 \end_layout
33250
33251 \begin_layout Section
33252 Related open source tools
33253 \begin_inset LatexCommand label
33254 name "sec:Related-open-source-tools"
33255
33256 \end_inset
33257
33258
33259 \begin_inset LatexCommand index
33260 name "Related tools"
33261
33262 \end_inset
33263
33264
33265 \end_layout
33266
33267 \begin_layout Standard
33268 \align left
33269 \begin_inset Tabular
33270 <lyxtabular version="3" rows="16" columns="3">
33271 <features>
33272 <column alignment="left" valignment="top" leftline="true" width="0pt">
33273 <column alignment="block" valignment="top" leftline="true" width="30line%">
33274 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
33275 <row topline="true" bottomline="true">
33276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33277 \begin_inset Text
33278
33279 \begin_layout Standard
33280
33281 \series bold
33282 Name
33283 \end_layout
33284
33285 \end_inset
33286 </cell>
33287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33288 \begin_inset Text
33289
33290 \begin_layout Standard
33291
33292 \series bold
33293 Purpose
33294 \end_layout
33295
33296 \end_inset
33297 </cell>
33298 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33299 \begin_inset Text
33300
33301 \begin_layout Standard
33302
33303 \series bold
33304 Where to get
33305 \end_layout
33306
33307 \end_inset
33308 </cell>
33309 </row>
33310 <row topline="true">
33311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33312 \begin_inset Text
33313
33314 \begin_layout Standard
33315 gpsim
33316 \begin_inset LatexCommand index
33317 name "gpsim (pic simulator)"
33318
33319 \end_inset
33320
33321
33322 \end_layout
33323
33324 \end_inset
33325 </cell>
33326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33327 \begin_inset Text
33328
33329 \begin_layout Standard
33330 PIC simulator
33331 \end_layout
33332
33333 \end_inset
33334 </cell>
33335 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33336 \begin_inset Text
33337
33338 \begin_layout Standard
33339 \begin_inset LatexCommand url
33340 target "http://www.dattalo.com/gnupic/gpsim.html"
33341
33342 \end_inset
33343
33344
33345 \end_layout
33346
33347 \end_inset
33348 </cell>
33349 </row>
33350 <row topline="true">
33351 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33352 \begin_inset Text
33353
33354 \begin_layout Standard
33355 gputils
33356 \begin_inset LatexCommand index
33357 name "gputils (pic tools)"
33358
33359 \end_inset
33360
33361
33362 \end_layout
33363
33364 \end_inset
33365 </cell>
33366 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33367 \begin_inset Text
33368
33369 \begin_layout Standard
33370 GNU PIC utilities
33371 \end_layout
33372
33373 \end_inset
33374 </cell>
33375 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33376 \begin_inset Text
33377
33378 \begin_layout Standard
33379 \begin_inset LatexCommand url
33380 target "http://sourceforge.net/projects/gputils"
33381
33382 \end_inset
33383
33384
33385 \end_layout
33386
33387 \end_inset
33388 </cell>
33389 </row>
33390 <row topline="true">
33391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33392 \begin_inset Text
33393
33394 \begin_layout Standard
33395 flP5
33396 \end_layout
33397
33398 \end_inset
33399 </cell>
33400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33401 \begin_inset Text
33402
33403 \begin_layout Standard
33404 PIC programmer
33405 \end_layout
33406
33407 \end_inset
33408 </cell>
33409 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33410 \begin_inset Text
33411
33412 \begin_layout Standard
33413 \begin_inset LatexCommand url
33414 target "http://freshmeat.net/projects/flp5/"
33415
33416 \end_inset
33417
33418
33419 \end_layout
33420
33421 \end_inset
33422 </cell>
33423 </row>
33424 <row topline="true">
33425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33426 \begin_inset Text
33427
33428 \begin_layout Standard
33429 ec2drv/newcdb
33430 \end_layout
33431
33432 \end_inset
33433 </cell>
33434 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33435 \begin_inset Text
33436
33437 \begin_layout Standard
33438 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
33439  (Unix only)
33440 \end_layout
33441
33442 \end_inset
33443 </cell>
33444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33445 \begin_inset Text
33446
33447 \begin_layout Standard
33448 \begin_inset LatexCommand url
33449 target "http://sourceforge.net/projects/ec2drv"
33450
33451 \end_inset
33452
33453
33454 \end_layout
33455
33456 \end_inset
33457 </cell>
33458 </row>
33459 <row topline="true">
33460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33461 \begin_inset Text
33462
33463 \begin_layout Standard
33464 indent
33465 \begin_inset LatexCommand index
33466 name "indent (source formatting tool)"
33467
33468 \end_inset
33469
33470
33471 \end_layout
33472
33473 \end_inset
33474 </cell>
33475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33476 \begin_inset Text
33477
33478 \begin_layout Standard
33479 Formats C source - Master of the white spaces
33480 \end_layout
33481
33482 \end_inset
33483 </cell>
33484 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33485 \begin_inset Text
33486
33487 \begin_layout Standard
33488 \begin_inset LatexCommand url
33489 target "http://directory.fsf.org/GNU/indent.html"
33490
33491 \end_inset
33492
33493
33494 \end_layout
33495
33496 \end_inset
33497 </cell>
33498 </row>
33499 <row topline="true">
33500 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33501 \begin_inset Text
33502
33503 \begin_layout Standard
33504 srecord
33505 \begin_inset LatexCommand index
33506 name "srecord (bin, hex, ... tool)"
33507
33508 \end_inset
33509
33510
33511 \end_layout
33512
33513 \end_inset
33514 </cell>
33515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33516 \begin_inset Text
33517
33518 \begin_layout Standard
33519 Object file conversion, checksumming, ...
33520 \end_layout
33521
33522 \end_inset
33523 </cell>
33524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33525 \begin_inset Text
33526
33527 \begin_layout Standard
33528 \begin_inset LatexCommand url
33529 target "http://sourceforge.net/projects/srecord"
33530
33531 \end_inset
33532
33533
33534 \end_layout
33535
33536 \end_inset
33537 </cell>
33538 </row>
33539 <row topline="true">
33540 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33541 \begin_inset Text
33542
33543 \begin_layout Standard
33544 objdump
33545 \begin_inset LatexCommand index
33546 name "objdump (tool)"
33547
33548 \end_inset
33549
33550
33551 \end_layout
33552
33553 \end_inset
33554 </cell>
33555 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33556 \begin_inset Text
33557
33558 \begin_layout Standard
33559 Object file conversion, ...
33560 \end_layout
33561
33562 \end_inset
33563 </cell>
33564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33565 \begin_inset Text
33566
33567 \begin_layout Standard
33568 Part of binutils (should be there anyway)
33569 \end_layout
33570
33571 \end_inset
33572 </cell>
33573 </row>
33574 <row topline="true">
33575 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33576 \begin_inset Text
33577
33578 \begin_layout Standard
33579 cmon51
33580 \end_layout
33581
33582 \end_inset
33583 </cell>
33584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33585 \begin_inset Text
33586
33587 \begin_layout Standard
33588 8051 monitor (hex up-/download, single step, disassemble)
33589 \end_layout
33590
33591 \end_inset
33592 </cell>
33593 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33594 \begin_inset Text
33595
33596 \begin_layout Standard
33597 \begin_inset LatexCommand url
33598 target "http://sourceforge.net/projects/cmon51"
33599
33600 \end_inset
33601
33602
33603 \end_layout
33604
33605 \end_inset
33606 </cell>
33607 </row>
33608 <row topline="true">
33609 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33610 \begin_inset Text
33611
33612 \begin_layout Standard
33613 doxygen
33614 \begin_inset LatexCommand index
33615 name "doxygen (source documentation tool)"
33616
33617 \end_inset
33618
33619
33620 \end_layout
33621
33622 \end_inset
33623 </cell>
33624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33625 \begin_inset Text
33626
33627 \begin_layout Standard
33628 Source code documentation system
33629 \end_layout
33630
33631 \end_inset
33632 </cell>
33633 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33634 \begin_inset Text
33635
33636 \begin_layout Standard
33637 \begin_inset LatexCommand url
33638 target "http://www.doxygen.org"
33639
33640 \end_inset
33641
33642
33643 \end_layout
33644
33645 \end_inset
33646 </cell>
33647 </row>
33648 <row topline="true">
33649 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33650 \begin_inset Text
33651
33652 \begin_layout Standard
33653 kdevelop
33654 \end_layout
33655
33656 \end_inset
33657 </cell>
33658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33659 \begin_inset Text
33660
33661 \begin_layout Standard
33662 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
33663 \end_layout
33664
33665 \end_inset
33666 </cell>
33667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33668 \begin_inset Text
33669
33670 \begin_layout Standard
33671 \begin_inset LatexCommand url
33672 target "http://www.kdevelop.org"
33673
33674 \end_inset
33675
33676
33677 \end_layout
33678
33679 \end_inset
33680 </cell>
33681 </row>
33682 <row topline="true">
33683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33684 \begin_inset Text
33685
33686 \begin_layout Standard
33687 paulmon
33688 \end_layout
33689
33690 \end_inset
33691 </cell>
33692 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33693 \begin_inset Text
33694
33695 \begin_layout Standard
33696 8051 monitor (hex up-/download, single step, disassemble)
33697 \end_layout
33698
33699 \end_inset
33700 </cell>
33701 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33702 \begin_inset Text
33703
33704 \begin_layout Standard
33705 \begin_inset LatexCommand url
33706 target "http://www.pjrc.com/tech/8051/paulmon2.html"
33707
33708 \end_inset
33709
33710
33711 \end_layout
33712
33713 \end_inset
33714 </cell>
33715 </row>
33716 <row topline="true">
33717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33718 \begin_inset Text
33719
33720 \begin_layout Standard
33721 splint
33722 \begin_inset LatexCommand index
33723 name "splint (syntax checking tool)"
33724
33725 \end_inset
33726
33727
33728 \end_layout
33729
33730 \end_inset
33731 </cell>
33732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33733 \begin_inset Text
33734
33735 \begin_layout Standard
33736 Statically checks c sources (see 
33737 \begin_inset LatexCommand ref
33738 reference "lyx:more-pedantic-SPLINT"
33739
33740 \end_inset
33741
33742 )
33743 \end_layout
33744
33745 \end_inset
33746 </cell>
33747 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33748 \begin_inset Text
33749
33750 \begin_layout Standard
33751 \begin_inset LatexCommand url
33752 target "http://www.splint.org"
33753
33754 \end_inset
33755
33756
33757 \end_layout
33758
33759 \end_inset
33760 </cell>
33761 </row>
33762 <row topline="true" bottomline="true">
33763 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33764 \begin_inset Text
33765
33766 \begin_layout Standard
33767 ddd
33768 \begin_inset LatexCommand index
33769 name "DDD (debugger)"
33770
33771 \end_inset
33772
33773
33774 \end_layout
33775
33776 \end_inset
33777 </cell>
33778 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33779 \begin_inset Text
33780
33781 \begin_layout Standard
33782 Debugger, serves nicely as GUI to SDCDB
33783 \begin_inset LatexCommand index
33784 name "SDCDB (debugger)"
33785
33786 \end_inset
33787
33788  (Unix only)
33789 \end_layout
33790
33791 \end_inset
33792 </cell>
33793 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33794 \begin_inset Text
33795
33796 \begin_layout Standard
33797 \begin_inset LatexCommand url
33798 target "http://www.gnu.org/software/ddd/"
33799
33800 \end_inset
33801
33802
33803 \end_layout
33804
33805 \end_inset
33806 </cell>
33807 </row>
33808 <row bottomline="true">
33809 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33810 \begin_inset Text
33811
33812 \begin_layout Standard
33813 d52
33814 \begin_inset LatexCommand index
33815 name "d52"
33816
33817 \end_inset
33818
33819
33820 \begin_inset LatexCommand index
33821 name "d52 (disassembler)"
33822
33823 \end_inset
33824
33825
33826 \end_layout
33827
33828 \end_inset
33829 </cell>
33830 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33831 \begin_inset Text
33832
33833 \begin_layout Standard
33834 Disassembler, can count instruction cycles
33835 \begin_inset LatexCommand index
33836 name "instruction cycles (count)"
33837
33838 \end_inset
33839
33840 , use with options -pnd
33841 \end_layout
33842
33843 \end_inset
33844 </cell>
33845 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33846 \begin_inset Text
33847
33848 \begin_layout Standard
33849 \begin_inset LatexCommand url
33850 target "http://www.8052.com/users/disasm/"
33851
33852 \end_inset
33853
33854
33855 \end_layout
33856
33857 \end_inset
33858 </cell>
33859 </row>
33860 <row bottomline="true">
33861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33862 \begin_inset Text
33863
33864 \begin_layout Standard
33865 cmake
33866 \begin_inset LatexCommand index
33867 name "cmake"
33868
33869 \end_inset
33870
33871
33872 \end_layout
33873
33874 \end_inset
33875 </cell>
33876 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33877 \begin_inset Text
33878
33879 \begin_layout Standard
33880 Cross platform build system, generates Makefiles
33881 \begin_inset LatexCommand index
33882 name "Makefile"
33883
33884 \end_inset
33885
33886  and project workspaces
33887 \begin_inset LatexCommand index
33888 name "project workspace"
33889
33890 \end_inset
33891
33892
33893 \end_layout
33894
33895 \end_inset
33896 </cell>
33897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33898 \begin_inset Text
33899
33900 \begin_layout Standard
33901 \begin_inset LatexCommand url
33902 target "http://www.cmake.org"
33903
33904 \end_inset
33905
33906  \InsetSpace ~
33907 \InsetSpace ~
33908 \InsetSpace ~
33909 \InsetSpace ~
33910 and a dedicated wiki entry: 
33911 \begin_inset LatexCommand url
33912 target "http://www.cmake.org/Wiki/CmakeSdcc"
33913
33914 \end_inset
33915
33916
33917 \end_layout
33918
33919 \end_inset
33920 </cell>
33921 </row>
33922 </lyxtabular>
33923
33924 \end_inset
33925
33926
33927 \newline
33928
33929 \end_layout
33930
33931 \begin_layout Section
33932 Related documentation / recommended reading
33933 \end_layout
33934
33935 \begin_layout Standard
33936 \align left
33937 \begin_inset Tabular
33938 <lyxtabular version="3" rows="7" columns="3">
33939 <features>
33940 <column alignment="left" valignment="top" leftline="true" width="0pt">
33941 <column alignment="left" valignment="top" leftline="true" width="0">
33942 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
33943 <row topline="true" bottomline="true">
33944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33945 \begin_inset Text
33946
33947 \begin_layout Standard
33948
33949 \series bold
33950 Name
33951 \end_layout
33952
33953 \end_inset
33954 </cell>
33955 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33956 \begin_inset Text
33957
33958 \begin_layout Standard
33959
33960 \series bold
33961 Subject / Title
33962 \end_layout
33963
33964 \end_inset
33965 </cell>
33966 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33967 \begin_inset Text
33968
33969 \begin_layout Standard
33970
33971 \series bold
33972 Where to get
33973 \end_layout
33974
33975 \end_inset
33976 </cell>
33977 </row>
33978 <row topline="true">
33979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33980 \begin_inset Text
33981
33982 \begin_layout Standard
33983
33984 \family roman
33985 \series medium
33986 \shape up
33987 \size normal
33988 \emph off
33989 \bar no
33990 \noun off
33991 \color none
33992 c-refcard.pdf
33993 \end_layout
33994
33995 \end_inset
33996 </cell>
33997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33998 \begin_inset Text
33999
34000 \begin_layout Standard
34001 C Reference Card
34002 \begin_inset LatexCommand index
34003 name "C Reference card"
34004
34005 \end_inset
34006
34007 , 2 pages
34008 \end_layout
34009
34010 \end_inset
34011 </cell>
34012 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34013 \begin_inset Text
34014
34015 \begin_layout Standard
34016 \begin_inset LatexCommand url
34017 target "http://refcards.com/refcards/c/index.html"
34018
34019 \end_inset
34020
34021
34022 \end_layout
34023
34024 \end_inset
34025 </cell>
34026 </row>
34027 <row topline="true">
34028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34029 \begin_inset Text
34030
34031 \begin_layout Standard
34032 c-faq
34033 \end_layout
34034
34035 \end_inset
34036 </cell>
34037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34038 \begin_inset Text
34039
34040 \begin_layout Standard
34041 C-FAQ
34042 \begin_inset LatexCommand index
34043 name "C FAQ"
34044
34045 \end_inset
34046
34047
34048 \end_layout
34049
34050 \end_inset
34051 </cell>
34052 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34053 \begin_inset Text
34054
34055 \begin_layout Standard
34056 \begin_inset LatexCommand url
34057 target "http://www.c-faq.com"
34058
34059 \end_inset
34060
34061
34062 \end_layout
34063
34064 \end_inset
34065 </cell>
34066 </row>
34067 <row topline="true">
34068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34069 \begin_inset Text
34070
34071 \begin_layout Standard
34072 ISO/IEC 9899:TC2
34073 \end_layout
34074
34075 \end_inset
34076 </cell>
34077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34078 \begin_inset Text
34079
34080 \begin_layout Standard
34081 \begin_inset Quotes sld
34082 \end_inset
34083
34084 C-Standard
34085 \begin_inset Quotes srd
34086 \end_inset
34087
34088
34089 \end_layout
34090
34091 \end_inset
34092 </cell>
34093 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34094 \begin_inset Text
34095
34096 \begin_layout Standard
34097
34098 \size footnotesize
34099 \begin_inset LatexCommand url
34100 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
34101
34102 \end_inset
34103
34104
34105 \end_layout
34106
34107 \end_inset
34108 </cell>
34109 </row>
34110 <row topline="true">
34111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34112 \begin_inset Text
34113
34114 \begin_layout Standard
34115 ISO/IEC DTR 18037
34116 \end_layout
34117
34118 \end_inset
34119 </cell>
34120 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34121 \begin_inset Text
34122
34123 \begin_layout Standard
34124 \begin_inset Quotes sld
34125 \end_inset
34126
34127 Extensions for Embedded C
34128 \begin_inset Quotes srd
34129 \end_inset
34130
34131
34132 \end_layout
34133
34134 \end_inset
34135 </cell>
34136 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34137 \begin_inset Text
34138
34139 \begin_layout Standard
34140
34141 \size footnotesize
34142 \begin_inset LatexCommand url
34143 target "http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf"
34144
34145 \end_inset
34146
34147
34148 \end_layout
34149
34150 \end_inset
34151 </cell>
34152 </row>
34153 <row topline="true">
34154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34155 \begin_inset Text
34156
34157 \begin_layout Standard
34158
34159 \end_layout
34160
34161 \end_inset
34162 </cell>
34163 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34164 \begin_inset Text
34165
34166 \begin_layout Standard
34167 Latest datasheet of target CPU
34168 \end_layout
34169
34170 \end_inset
34171 </cell>
34172 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34173 \begin_inset Text
34174
34175 \begin_layout Standard
34176 vendor
34177 \end_layout
34178
34179 \end_inset
34180 </cell>
34181 </row>
34182 <row topline="true" bottomline="true">
34183 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34184 \begin_inset Text
34185
34186 \begin_layout Standard
34187
34188 \end_layout
34189
34190 \end_inset
34191 </cell>
34192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34193 \begin_inset Text
34194
34195 \begin_layout Standard
34196 Revision history of datasheet
34197 \end_layout
34198
34199 \end_inset
34200 </cell>
34201 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34202 \begin_inset Text
34203
34204 \begin_layout Standard
34205 vendor
34206 \end_layout
34207
34208 \end_inset
34209 </cell>
34210 </row>
34211 </lyxtabular>
34212
34213 \end_inset
34214
34215
34216 \newline
34217
34218 \end_layout
34219
34220 \begin_layout Section
34221 Application notes specifically for SDCC
34222 \end_layout
34223
34224 \begin_layout Standard
34225 SDCC makes no claims about the completeness of this list and about up-to-datenes
34226 s or correctness of the application notes
34227 \begin_inset LatexCommand index
34228 name "Application notes"
34229
34230 \end_inset
34231
34232 .
34233 \end_layout
34234
34235 \begin_layout Standard
34236 \align left
34237
34238 \size footnotesize
34239 \begin_inset Tabular
34240 <lyxtabular version="3" rows="7" columns="3">
34241 <features>
34242 <column alignment="block" valignment="top" leftline="true" width="17col%">
34243 <column alignment="block" valignment="top" leftline="true" width="27col%">
34244 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
34245 <row topline="true" bottomline="true">
34246 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34247 \begin_inset Text
34248
34249 \begin_layout Standard
34250
34251 \series bold
34252 \size footnotesize
34253 Vendor
34254 \end_layout
34255
34256 \end_inset
34257 </cell>
34258 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
34259 \begin_inset Text
34260
34261 \begin_layout Standard
34262
34263 \series bold
34264 \size footnotesize
34265 Subject / Title
34266 \end_layout
34267
34268 \end_inset
34269 </cell>
34270 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34271 \begin_inset Text
34272
34273 \begin_layout Standard
34274
34275 \series bold
34276 \size footnotesize
34277 Where to get
34278 \end_layout
34279
34280 \end_inset
34281 </cell>
34282 </row>
34283 <row topline="true">
34284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34285 \begin_inset Text
34286
34287 \begin_layout Standard
34288
34289 \size footnotesize
34290 Maxim / Dallas
34291 \end_layout
34292
34293 \end_inset
34294 </cell>
34295 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34296 \begin_inset Text
34297
34298 \begin_layout Standard
34299
34300 \size footnotesize
34301 Using the SDCC Compiler for the DS80C400
34302 \begin_inset LatexCommand index
34303 name "DS80C400"
34304
34305 \end_inset
34306
34307
34308 \end_layout
34309
34310 \end_inset
34311 </cell>
34312 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34313 \begin_inset Text
34314
34315 \begin_layout Standard
34316
34317 \size footnotesize
34318 \begin_inset LatexCommand url
34319 target "http://pdfserv.maxim-ic.com/en/an/AN3346.pdf"
34320
34321 \end_inset
34322
34323
34324 \end_layout
34325
34326 \end_inset
34327 </cell>
34328 </row>
34329 <row topline="true">
34330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34331 \begin_inset Text
34332
34333 \begin_layout Standard
34334
34335 \size footnotesize
34336 Maxim / Dallas
34337 \end_layout
34338
34339 \end_inset
34340 </cell>
34341 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
34342 \begin_inset Text
34343
34344 \begin_layout Standard
34345
34346 \size footnotesize
34347 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
34348 \begin_inset LatexCommand index
34349 name "DS89C4x0"
34350
34351 \end_inset
34352
34353  Family of Microcontrollers
34354 \end_layout
34355
34356 \end_inset
34357 </cell>
34358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34359 \begin_inset Text
34360
34361 \begin_layout Standard
34362
34363 \size footnotesize
34364 \begin_inset LatexCommand url
34365 target "http://pdfserv.maxim-ic.com/en/an/AN3477.pdf"
34366
34367 \end_inset
34368
34369
34370 \end_layout
34371
34372 \end_inset
34373 </cell>
34374 </row>
34375 <row topline="true">
34376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34377 \begin_inset Text
34378
34379 \begin_layout Standard
34380
34381 \size footnotesize
34382 Silicon Laboratories / Cygnal
34383 \end_layout
34384
34385 \end_inset
34386 </cell>
34387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34388 \begin_inset Text
34389
34390 \begin_layout Standard
34391
34392 \size footnotesize
34393 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
34394 \begin_inset LatexCommand index
34395 name "IDE"
34396
34397 \end_inset
34398
34399
34400 \end_layout
34401
34402 \end_inset
34403 </cell>
34404 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34405 \begin_inset Text
34406
34407 \begin_layout Standard
34408
34409 \size footnotesize
34410 \begin_inset LatexCommand url
34411 target "http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf"
34412
34413 \end_inset
34414
34415
34416 \end_layout
34417
34418 \end_inset
34419 </cell>
34420 </row>
34421 <row topline="true">
34422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34423 \begin_inset Text
34424
34425 \begin_layout Standard
34426
34427 \size footnotesize
34428 Ramtron / Goal Semiconductor
34429 \end_layout
34430
34431 \end_inset
34432 </cell>
34433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34434 \begin_inset Text
34435
34436 \begin_layout Standard
34437
34438 \size footnotesize
34439 Interfacing SDCC to Syn and Textpad
34440 \end_layout
34441
34442 \end_inset
34443 </cell>
34444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34445 \begin_inset Text
34446
34447 \begin_layout Standard
34448
34449 \size footnotesize
34450 \begin_inset LatexCommand url
34451 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34452
34453 \end_inset
34454
34455
34456 \end_layout
34457
34458 \end_inset
34459 </cell>
34460 </row>
34461 <row topline="true">
34462 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34463 \begin_inset Text
34464
34465 \begin_layout Standard
34466
34467 \size footnotesize
34468 Ramtron / Goal Semiconductor
34469 \end_layout
34470
34471 \end_inset
34472 </cell>
34473 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34474 \begin_inset Text
34475
34476 \begin_layout Standard
34477
34478 \size footnotesize
34479 Installing and Configuring SDCC and Crimson Editor 
34480 \end_layout
34481
34482 \end_inset
34483 </cell>
34484 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34485 \begin_inset Text
34486
34487 \begin_layout Standard
34488
34489 \size footnotesize
34490 \begin_inset LatexCommand url
34491 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34492
34493 \end_inset
34494
34495
34496 \end_layout
34497
34498 \end_inset
34499 </cell>
34500 </row>
34501 <row topline="true" bottomline="true">
34502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34503 \begin_inset Text
34504
34505 \begin_layout Standard
34506
34507 \size footnotesize
34508 Texas Instruments
34509 \end_layout
34510
34511 \end_inset
34512 </cell>
34513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34514 \begin_inset Text
34515
34516 \begin_layout Standard
34517
34518 \size footnotesize
34519 MSC12xx Programming with SDCC
34520 \end_layout
34521
34522 \end_inset
34523 </cell>
34524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34525 \begin_inset Text
34526
34527 \begin_layout Standard
34528
34529 \size footnotesize
34530 \begin_inset LatexCommand url
34531 target "http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf"
34532
34533 \end_inset
34534
34535
34536 \end_layout
34537
34538 \end_inset
34539 </cell>
34540 </row>
34541 </lyxtabular>
34542
34543 \end_inset
34544
34545
34546 \end_layout
34547
34548 \begin_layout Section
34549 Some Questions
34550 \end_layout
34551
34552 \begin_layout Standard
34553 Some questions answered, some pointers given - it might be time to in turn
34554  ask 
34555 \emph on
34556 you
34557 \emph default
34558  some questions: 
34559 \end_layout
34560
34561 \begin_layout Itemize
34562 can you solve your project with the selected microcontroller? Would you
34563  find out early or rather late that your target is too small/slow/whatever?
34564  Can you switch to a slightly better device if it doesn't fit?
34565 \end_layout
34566
34567 \begin_layout Itemize
34568 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
34569  and/or another programming language be more adequate? Would an operating
34570  system on the target device help?
34571 \end_layout
34572
34573 \begin_layout Itemize
34574 if you solved the problem, will the marketing department be happy?
34575 \end_layout
34576
34577 \begin_layout Itemize
34578 if the marketing department is happy, will customers be happy?
34579 \end_layout
34580
34581 \begin_layout Itemize
34582 if you're the project manager, marketing department and maybe even the customer
34583  in one person, have you tried to see the project from the outside?
34584 \end_layout
34585
34586 \begin_layout Itemize
34587 is the project done if you think it is done? Or is just that other interface/pro
34588 tocol/feature/configuration/option missing? How about website, manual(s),
34589  internationali(z|s)ation, packaging, labels, 2nd source for components,
34590  electromagnetic compatability/interference, documentation for production,
34591  production test software, update mechanism, patent issues?
34592 \end_layout
34593
34594 \begin_layout Itemize
34595 is your project adequately positioned in that magic triangle: fame, fortune,
34596  fun?
34597 \end_layout
34598
34599 \begin_layout Standard
34600 Maybe not all answers to these questions are known and some answers may
34601  even be 
34602 \emph on
34603 no
34604 \emph default
34605 , nevertheless knowing these questions may help you to avoid burnout
34606 \begin_inset Foot
34607 status open
34608
34609 \begin_layout Standard
34610 burnout is bad for electronic devices, programmers and motorcycle tyres
34611 \end_layout
34612
34613 \end_inset
34614
34615 .
34616  Chances are you didn't want to hear some of them...
34617 \end_layout
34618
34619 \begin_layout Chapter
34620 Support
34621 \begin_inset LatexCommand index
34622 name "Support"
34623
34624 \end_inset
34625
34626
34627 \end_layout
34628
34629 \begin_layout Standard
34630 SDCC has grown to be a large project.
34631  The compiler alone (without the preprocessor, assembler and linker) is
34632  well over 150,000 lines of code (blank stripped).
34633  The open source nature of this project is a key to its continued growth
34634  and support.
34635  You gain the benefit and support of many active software developers and
34636  end users.
34637  Is SDCC perfect? No, that's why we need your help.
34638  The developers take pride in fixing reported bugs.
34639  You can help by reporting the bugs and helping other SDCC users.
34640  There are lots of ways to contribute, and we encourage you to take part
34641  in making SDCC a great software package.
34642  
34643 \end_layout
34644
34645 \begin_layout Standard
34646 The SDCC project is hosted on the SDCC sourceforge site at 
34647 \begin_inset LatexCommand htmlurl
34648 target "http://sourceforge.net/projects/sdcc"
34649
34650 \end_inset
34651
34652 .
34653  You'll find the complete set of mailing lists
34654 \begin_inset LatexCommand index
34655 name "Mailing list(s)"
34656
34657 \end_inset
34658
34659 , forums, bug reporting system, patch submission
34660 \begin_inset LatexCommand index
34661 name "Patch submission"
34662
34663 \end_inset
34664
34665  system, download
34666 \begin_inset LatexCommand index
34667 name "download"
34668
34669 \end_inset
34670
34671  area and Subversion code repository
34672 \begin_inset LatexCommand index
34673 name "Subversion code repository"
34674
34675 \end_inset
34676
34677  there.
34678 \end_layout
34679
34680 \begin_layout Section
34681 Reporting Bugs
34682 \begin_inset LatexCommand index
34683 name "Bug reporting"
34684
34685 \end_inset
34686
34687
34688 \begin_inset LatexCommand index
34689 name "Reporting bugs"
34690
34691 \end_inset
34692
34693
34694 \end_layout
34695
34696 \begin_layout Standard
34697 The recommended way of reporting bugs is using the infrastructure of the
34698  sourceforge site.
34699  You can follow the status of bug reports there and have an overview about
34700  the known bugs.
34701 \end_layout
34702
34703 \begin_layout Standard
34704 Bug reports are automatically forwarded to the developer mailing list and
34705  will be fixed ASAP.
34706  When reporting a bug, it is very useful to include a small test program
34707  (the smaller the better) which reproduces the problem.
34708  If you can isolate the problem by looking at the generated assembly code,
34709  this can be very helpful.
34710  Compiling your program with the -
34711 \begin_inset ERT
34712 status collapsed
34713
34714 \begin_layout Standard
34715
34716
34717 \backslash
34718 /
34719 \end_layout
34720
34721 \end_inset
34722
34723 -dumpall
34724 \begin_inset LatexCommand index
34725 name "-\\/-dumpall"
34726
34727 \end_inset
34728
34729  option can sometimes be useful in locating optimization problems.
34730  When reporting a bug please make sure you:
34731 \end_layout
34732
34733 \begin_layout Enumerate
34734 Attach the code you are compiling with SDCC.
34735  
34736 \end_layout
34737
34738 \begin_layout Enumerate
34739 Specify the exact command you use to run SDCC, or attach your Makefile.
34740  
34741 \end_layout
34742
34743 \begin_layout Enumerate
34744 Specify the SDCC version (type "
34745 \family sans
34746 \series bold
34747 sdcc -v
34748 \family default
34749 \series default
34750 "), your platform, and operating system.
34751  
34752 \end_layout
34753
34754 \begin_layout Enumerate
34755 Provide an exact copy of any error message or incorrect output.
34756  
34757 \end_layout
34758
34759 \begin_layout Enumerate
34760 Put something meaningful in the subject of your message.
34761 \end_layout
34762
34763 \begin_layout Standard
34764 Please attempt to include these 5 important parts, as applicable, in all
34765  requests for support or when reporting any problems or bugs with SDCC.
34766  Though this will make your message lengthy, it will greatly improve your
34767  chance that SDCC users and developers will be able to help you.
34768  Some SDCC developers are frustrated by bug reports without code provided
34769  that they can use to reproduce and ultimately fix the problem, so please
34770  be sure to provide sample code if you are reporting a bug! 
34771 \end_layout
34772
34773 \begin_layout Standard
34774 Please have a short check that you are using a recent version of SDCC and
34775  the bug is not yet known.
34776  This is the link for reporting bugs: 
34777 \begin_inset LatexCommand htmlurl
34778 target "http://sourceforge.net/tracker/?group_id=599&atid=100599"
34779
34780 \end_inset
34781
34782 .
34783  With SDCC on average having more than 200 downloads
34784 \begin_inset LatexCommand index
34785 name "download"
34786
34787 \end_inset
34788
34789  on sourceforge per day
34790 \begin_inset Foot
34791 status open
34792
34793 \begin_layout Standard
34794 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
34795  between 2002 and 2005.
34796  This does not include other methods of distribution.
34797 \end_layout
34798
34799 \end_inset
34800
34801  there must be some users.
34802  So it's not exactly easy to find a new bug.
34803  If you find one we need it: 
34804 \emph on
34805 reporting bugs is good
34806 \emph default
34807 .
34808 \end_layout
34809
34810 \begin_layout Section
34811 Requesting Features
34812 \begin_inset LatexCommand label
34813 name "sub:Requesting-Features"
34814
34815 \end_inset
34816
34817
34818 \begin_inset LatexCommand index
34819 name "Feature request"
34820
34821 \end_inset
34822
34823
34824 \begin_inset LatexCommand index
34825 name "Requesting features"
34826
34827 \end_inset
34828
34829
34830 \end_layout
34831
34832 \begin_layout Standard
34833 Like bug reports feature requests are forwarded to the developer mailing
34834  list.
34835  This is the link for requesting features: 
34836 \begin_inset LatexCommand htmlurl
34837 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
34838
34839 \end_inset
34840
34841 .
34842 \end_layout
34843
34844 \begin_layout Section
34845 Submitting patches
34846 \end_layout
34847
34848 \begin_layout Standard
34849 Like bug reports contributed patches are forwarded to the developer mailing
34850  list.
34851  This is the link for submitting patches
34852 \begin_inset LatexCommand index
34853 name "Patch submission"
34854
34855 \end_inset
34856
34857
34858 \begin_inset LatexCommand url
34859 target "http://sourceforge.net/tracker/?group_id=599&atid=300599"
34860
34861 \end_inset
34862
34863 .
34864 \end_layout
34865
34866 \begin_layout Standard
34867 You need to specify some parameters to the 
34868 \family typewriter
34869 diff
34870 \family default
34871  command for the patches to be useful.
34872  If you modified more than one file a patch created f.e.
34873  with 
34874 \family sans
34875 \series bold
34876
34877 \begin_inset Quotes sld
34878 \end_inset
34879
34880 diff -Naur unmodified_directory modified_directory >my_changes.patch
34881 \begin_inset Quotes srd
34882 \end_inset
34883
34884
34885 \family default
34886 \series default
34887  will be fine, otherwise 
34888 \family sans
34889 \series bold
34890
34891 \begin_inset Quotes sld
34892 \end_inset
34893
34894 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
34895 \begin_inset Quotes srd
34896 \end_inset
34897
34898
34899 \family default
34900 \series default
34901  will do.
34902 \end_layout
34903
34904 \begin_layout Section
34905 Getting Help
34906 \end_layout
34907
34908 \begin_layout Standard
34909 These links should take you directly to the 
34910 \begin_inset LatexCommand url
34911 name "Mailing lists"
34912 target "http://sourceforge.net/mail/?group_id=599"
34913
34914 \end_inset
34915
34916
34917 \begin_inset Foot
34918 status open
34919
34920 \begin_layout Standard
34921 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
34922  automated messages (mid 2003)
34923 \end_layout
34924
34925 \end_inset
34926
34927  and the 
34928 \begin_inset LatexCommand url
34929 name "Forums"
34930 target "http://sourceforge.net/forum/?group_id=599"
34931
34932 \end_inset
34933
34934 , lists
34935 \begin_inset LatexCommand index
34936 name "Mailing list(s)"
34937
34938 \end_inset
34939
34940  and forums are archived and searchable so if you are lucky someone already
34941  had a similar problem.
34942  While mails to the lists themselves are delivered promptly their web front
34943  end on sourceforge sometimes shows a severe time lag (up to several weeks),
34944  if you're seriously using SDCC please consider subscribing to the lists.
34945 \end_layout
34946
34947 \begin_layout Section
34948 ChangeLog
34949 \end_layout
34950
34951 \begin_layout Standard
34952 You can follow the status of the Subversion version
34953 \begin_inset LatexCommand index
34954 name "version"
34955
34956 \end_inset
34957
34958  of SDCC by watching the Changelog
34959 \begin_inset LatexCommand index
34960 name "Changelog"
34961
34962 \end_inset
34963
34964  in the Subversion repository
34965 \size footnotesize
34966  
34967 \begin_inset LatexCommand htmlurl
34968 target "http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog"
34969
34970 \end_inset
34971
34972 .
34973 \end_layout
34974
34975 \begin_layout Section
34976 Subversion Source Code Repository
34977 \end_layout
34978
34979 \begin_layout Standard
34980 The output of 
34981 \family sans
34982 \series bold
34983 sdcc -
34984 \family default
34985
34986 \begin_inset ERT
34987 status open
34988
34989 \begin_layout Standard
34990
34991
34992 \backslash
34993 /
34994 \end_layout
34995
34996 \end_inset
34997
34998
34999 \family sans
35000 -version
35001 \family default
35002 \series default
35003  or the filenames of the snapshot versions of SDCC include date and its
35004  Subversion
35005 \begin_inset LatexCommand index
35006 name "Subversion code repository"
35007
35008 \end_inset
35009
35010  number.
35011  Subversion allows to download the source of recent or previous versions
35012  
35013 \begin_inset LatexCommand url
35014 target "http://sourceforge.net/svn/?group_id=599"
35015
35016 \end_inset
35017
35018  (by number or by date).
35019  An on-line source code browser and detailled instructions are also available
35020  there.
35021  SDCC versions starting from 1999 up to now are available (currently the
35022  versions prior to the conversion from cvs
35023 \begin_inset LatexCommand index
35024 name "cvs|see{Subversion}"
35025
35026 \end_inset
35027
35028  to Subversion (April 2006) are either by accessible by Subversion or by
35029  cvs).
35030 \end_layout
35031
35032 \begin_layout Section
35033 Release policy
35034 \begin_inset LatexCommand index
35035 name "Release policy"
35036
35037 \end_inset
35038
35039
35040 \end_layout
35041
35042 \begin_layout Standard
35043 Historically there often were long delays between official releases and
35044  the sourceforge download area tends to get not updated at all.
35045  Excuses in the past might have referred to problems with live range analysis,
35046  but as this was fixed a while ago, the current problem is that another
35047  excuse has to be found.
35048  Kidding aside, we have to get better there! On the other hand there are
35049  daily snapshots available at 
35050 \begin_inset LatexCommand htmlurl
35051 name "snap"
35052 target "http://sdcc.sourceforge.net/snap.php"
35053
35054 \end_inset
35055
35056 , and you can always build the very last version (hopefully with many bugs
35057  fixed, and features added) from the source code available at 
35058 \begin_inset LatexCommand htmlurl
35059 name "Source"
35060 target "http://sdcc.sourceforge.net/snap.php#Source"
35061
35062 \end_inset
35063
35064 .
35065  The SDCC Wiki
35066 \begin_inset LatexCommand index
35067 name "wiki"
35068
35069 \end_inset
35070
35071
35072 \begin_inset LatexCommand index
35073 name "SDCC Wiki"
35074
35075 \end_inset
35076
35077  at 
35078 \begin_inset LatexCommand url
35079 target "http://sdcc.wiki.sourceforge.net/"
35080
35081 \end_inset
35082
35083  also holds some information about past and future releases.
35084 \end_layout
35085
35086 \begin_layout Section
35087 Examples
35088 \begin_inset LatexCommand index
35089 name "Examples"
35090
35091 \end_inset
35092
35093
35094 \end_layout
35095
35096 \begin_layout Standard
35097 You'll find some small examples in the directory 
35098 \emph on
35099 sdcc/device/examples/.
35100
35101 \emph default
35102  More examples and libraries are available at 
35103 \emph on
35104 The SDCC Open Knowledge Resource 
35105 \begin_inset LatexCommand url
35106 target "http://sdccokr.dl9sec.de/"
35107
35108 \end_inset
35109
35110
35111 \emph default
35112  web site or at 
35113 \begin_inset LatexCommand url
35114 target "http://www.pjrc.com/tech/8051/"
35115
35116 \end_inset
35117
35118 .
35119 \end_layout
35120
35121 \begin_layout Standard
35122 \begin_inset Note Note
35123 status collapsed
35124
35125 \begin_layout Standard
35126 I did insert a reference to Paul's web site here although it seems rather
35127  dedicated to a specific 8032 board (I think it's okay because it f.e.
35128  shows LCD/Harddisc interface and has a free 8051 monitor.
35129  Independent 8032 board vendors face hard competition of heavily subsidized
35130  development boards anyway).
35131 \end_layout
35132
35133 \begin_layout Standard
35134 Maybe we should include some links to real world applications.
35135  Preferably pointer to pointers (one for each architecture) so this stays
35136  manageable here?
35137 \end_layout
35138
35139 \end_inset
35140
35141
35142 \end_layout
35143
35144 \begin_layout Section
35145 Quality control
35146 \begin_inset LatexCommand label
35147 name "sec:Quality-control"
35148
35149 \end_inset
35150
35151
35152 \begin_inset LatexCommand index
35153 name "Quality control"
35154
35155 \end_inset
35156
35157
35158 \end_layout
35159
35160 \begin_layout Standard
35161 The compiler is passed through snaphot build compile and build checks.
35162  The so called 
35163 \shape italic
35164 regression tests
35165 \shape default
35166
35167 \begin_inset LatexCommand index
35168 name "Regression test"
35169
35170 \end_inset
35171
35172  check that SDCC itself compiles flawlessly on several host platforms (i386,
35173  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
35174  and checks the quality of the code generated by SDCC by running the code
35175  for several target platforms through simulators.
35176  The regression test suite comprises more than 100 files which expand to
35177  more than 500 test cases which include more than 4500 tests.
35178  The results of these tests are published daily on SDCC's snapshot page
35179  (click on the red or green symbols on the right side of 
35180 \begin_inset LatexCommand url
35181 target "http://sdcc.sourceforge.net/snap.php"
35182
35183 \end_inset
35184
35185 ).
35186 \end_layout
35187
35188 \begin_layout Standard
35189 There is a separate document 
35190 \shape italic
35191 test_suite.pdf 
35192 \begin_inset LatexCommand index
35193 name "Test suite"
35194
35195 \end_inset
35196
35197
35198 \shape default
35199  
35200 \begin_inset LatexCommand url
35201 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
35202
35203 \end_inset
35204
35205  about the regression test suite.
35206 \end_layout
35207
35208 \begin_layout Standard
35209 You'll find the test code in the directory 
35210 \shape italic
35211 sdcc/support/regression
35212 \shape default
35213 .
35214  You can run these tests manually by running 
35215 \family sans
35216 make
35217 \family default
35218  in this directory (or f.e.
35219  
35220 \family sans
35221 \series bold
35222
35223 \begin_inset Quotes sld
35224 \end_inset
35225
35226 make test-mcs51
35227 \begin_inset Quotes srd
35228 \end_inset
35229
35230
35231 \family default
35232 \series default
35233  if you don't want to run the complete tests).
35234  The test code might also be interesting if you want to look for examples
35235 \begin_inset LatexCommand index
35236 name "Examples"
35237
35238 \end_inset
35239
35240  checking corner cases of SDCC or if you plan to submit patches
35241 \begin_inset LatexCommand index
35242 name "Patch submission"
35243
35244 \end_inset
35245
35246 .
35247 \end_layout
35248
35249 \begin_layout Standard
35250 The PIC14 port uses a different set of regression tests 
35251 \begin_inset LatexCommand index
35252 name "Regression test (PIC14)"
35253
35254 \end_inset
35255
35256 , you'll find them in the directory 
35257 \shape italic
35258 sdcc/src/regression
35259 \shape default
35260 .
35261 \end_layout
35262
35263 \begin_layout Section
35264 Use of SDCC in Education
35265 \end_layout
35266
35267 \begin_layout Standard
35268 In short: 
35269 \emph on
35270 highly
35271 \emph default
35272  encouraged
35273 \begin_inset Foot
35274 status open
35275
35276 \begin_layout Standard
35277 the phrase "use in education" might evoke the association "
35278 \emph on
35279 only
35280 \emph default
35281  fit for use in education".
35282  This connotation is not intended but nevertheless risked as the licensing
35283  of SDCC makes it difficult to offer educational discounts
35284 \end_layout
35285
35286 \end_inset
35287
35288 .
35289  If your rationales are to:
35290 \end_layout
35291
35292 \begin_layout Enumerate
35293 give students a chance to understand the 
35294 \emph on
35295 complete
35296 \emph default
35297  steps of code generation
35298 \end_layout
35299
35300 \begin_layout Enumerate
35301 have a curriculum that can be extended for years.
35302  Then you could use an fpga board as target and your curriculum will seamlessly
35303  extend from logic synthesis (
35304 \begin_inset LatexCommand url
35305 name "http://www.opencores.org"
35306 target "opencores.org"
35307
35308 \end_inset
35309
35310
35311 \begin_inset LatexCommand url
35312 name "Oregano"
35313 target "http://www.oregano.at/ip/ip01.htm"
35314
35315 \end_inset
35316
35317 ), over assembly programming, to C to FPGA compilers (
35318 \begin_inset LatexCommand url
35319 name "FPGAC"
35320 target "http://sf.net/projects/fpgac"
35321
35322 \end_inset
35323
35324 ) and to C.
35325 \end_layout
35326
35327 \begin_layout Enumerate
35328 be able to insert excursions about skills like using a revision control
35329  system, submitting/applying patches, using a type-setting (as opposed to
35330  word-processing) engine LyX/LaTeX, using 
35331 \begin_inset LatexCommand url
35332 name "SourceForge"
35333 target "http://www.sf.net"
35334
35335 \end_inset
35336
35337 , following some 
35338 \begin_inset LatexCommand url
35339 name "netiquette"
35340 target "http://en.wikipedia.org/wiki/Netiquette"
35341
35342 \end_inset
35343
35344 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
35345  Source Software, CPU simulation, compiler regression tests
35346 \begin_inset LatexCommand index
35347 name "Regression test"
35348
35349 \end_inset
35350
35351 .
35352  
35353 \newline
35354 And if there should be a shortage of ideas then you can always point students
35355  to the ever-growing feature request list 
35356 \begin_inset LatexCommand htmlurl
35357 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
35358
35359 \end_inset
35360
35361 .
35362 \end_layout
35363
35364 \begin_layout Enumerate
35365 not tie students to a specific host platform and instead allow them to use
35366  a host platform of 
35367 \emph on
35368 their
35369 \emph default
35370  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
35371  and eventually 
35372 \begin_inset LatexCommand url
35373 name "OLPC"
35374 target "http://www.laptop.org"
35375
35376 \end_inset
35377
35378 )
35379 \end_layout
35380
35381 \begin_layout Enumerate
35382 not encourage students to use illegal copies of educational software
35383 \end_layout
35384
35385 \begin_layout Enumerate
35386 be immune to licensing/availability/price changes of the chosen tool chain
35387 \end_layout
35388
35389 \begin_layout Enumerate
35390 be able to change to a new target platform without having to adopt a new
35391  tool chain
35392 \end_layout
35393
35394 \begin_layout Enumerate
35395 have complete control over and insight into the tool chain
35396 \end_layout
35397
35398 \begin_layout Enumerate
35399 make your students aware about the pros and cons of open source software
35400  development
35401 \end_layout
35402
35403 \begin_layout Enumerate
35404 give back to the public as you are probably at least partially publicly
35405  funded
35406 \end_layout
35407
35408 \begin_layout Enumerate
35409 give students a chance to publicly prove their skills and to possibly see
35410  a world wide impact
35411 \end_layout
35412
35413 \begin_layout Standard
35414 then SDCC is probably among the first choices.
35415  Well, probably SDCC might be the only choice.
35416 \newpage
35417
35418 \end_layout
35419
35420 \begin_layout Chapter
35421 SDCC Technical Data
35422 \end_layout
35423
35424 \begin_layout Section
35425 Optimizations
35426 \begin_inset LatexCommand index
35427 name "Optimizations"
35428
35429 \end_inset
35430
35431
35432 \end_layout
35433
35434 \begin_layout Standard
35435 SDCC performs a host of standard optimizations in addition to some MCU specific
35436  optimizations.
35437  
35438 \end_layout
35439
35440 \begin_layout Subsection
35441 Sub-expression Elimination
35442 \begin_inset LatexCommand index
35443 name "Subexpression elimination"
35444
35445 \end_inset
35446
35447
35448 \end_layout
35449
35450 \begin_layout Standard
35451 The compiler does local and 
35452 \emph on
35453 g
35454 \emph default
35455 lobal 
35456 \emph on
35457 c
35458 \emph default
35459 ommon 
35460 \emph on
35461 s
35462 \emph default
35463 ubexpression 
35464 \emph on
35465 e
35466 \emph default
35467 limination, e.g.: 
35468 \end_layout
35469
35470 \begin_layout Verse
35471
35472 \family typewriter
35473 i = x + y + 1; 
35474 \newline
35475 j = x + y;
35476 \end_layout
35477
35478 \begin_layout Standard
35479 will be translated to
35480 \end_layout
35481
35482 \begin_layout Verse
35483
35484 \family typewriter
35485 iTemp = x + y; 
35486 \newline
35487 i = iTemp + 1; 
35488 \newline
35489 j = iTemp;
35490 \end_layout
35491
35492 \begin_layout Standard
35493 Some subexpressions are not as obvious as the above example, e.g.:
35494 \end_layout
35495
35496 \begin_layout Verse
35497
35498 \family typewriter
35499 a->b[i].c = 10; 
35500 \newline
35501 a->b[i].d = 11;
35502 \end_layout
35503
35504 \begin_layout Standard
35505 In this case the address arithmetic a->b[i] will be computed only once;
35506  the equivalent code in C would be.
35507 \end_layout
35508
35509 \begin_layout Verse
35510
35511 \family typewriter
35512 iTemp = a->b[i]; 
35513 \newline
35514 iTemp.c = 10; 
35515 \newline
35516 iTemp.d = 11;
35517 \end_layout
35518
35519 \begin_layout Standard
35520 The compiler will try to keep these temporary variables in registers.
35521 \end_layout
35522
35523 \begin_layout Subsection
35524 Dead-Code Elimination
35525 \begin_inset LatexCommand index
35526 name "Dead-code elimination"
35527
35528 \end_inset
35529
35530
35531 \end_layout
35532
35533 \begin_layout Verse
35534
35535 \family typewriter
35536 int global;
35537 \newline
35538
35539 \newline
35540 void f () { 
35541 \newline
35542 \InsetSpace ~
35543 \InsetSpace ~
35544 int i; 
35545 \newline
35546 \InsetSpace ~
35547 \InsetSpace ~
35548 i = 1; \InsetSpace ~
35549 \InsetSpace ~
35550 \InsetSpace ~
35551 \InsetSpace ~
35552 \InsetSpace ~
35553 /* dead store */ 
35554 \newline
35555 \InsetSpace ~
35556 \InsetSpace ~
35557 global = 1;\InsetSpace ~
35558 /* dead
35559  store */ 
35560 \newline
35561 \InsetSpace ~
35562 \InsetSpace ~
35563 global = 2; 
35564 \newline
35565 \InsetSpace ~
35566 \InsetSpace ~
35567 return; 
35568 \newline
35569 \InsetSpace ~
35570 \InsetSpace ~
35571 global = 3;\InsetSpace ~
35572 /* unreachable */ 
35573 \newline
35574 }
35575 \end_layout
35576
35577 \begin_layout Standard
35578 will be changed to
35579 \end_layout
35580
35581 \begin_layout Verse
35582
35583 \family typewriter
35584 int global;
35585 \newline
35586
35587 \newline
35588 void f () {
35589 \newline
35590 \InsetSpace ~
35591 \InsetSpace ~
35592 global = 2; 
35593 \newline
35594 }
35595 \end_layout
35596
35597 \begin_layout Subsection
35598 Copy-Propagation
35599 \begin_inset LatexCommand index
35600 name "Copy propagation"
35601
35602 \end_inset
35603
35604
35605 \end_layout
35606
35607 \begin_layout Verse
35608
35609 \family typewriter
35610 int f() { 
35611 \newline
35612 \InsetSpace ~
35613 \InsetSpace ~
35614 int i, j; 
35615 \newline
35616 \InsetSpace ~
35617 \InsetSpace ~
35618 i = 10; 
35619 \newline
35620 \InsetSpace ~
35621 \InsetSpace ~
35622 j = i; 
35623 \newline
35624 \InsetSpace ~
35625 \InsetSpace ~
35626 return j; 
35627 \newline
35628 }
35629 \end_layout
35630
35631 \begin_layout Standard
35632 will be changed to 
35633 \end_layout
35634
35635 \begin_layout Verse
35636
35637 \family typewriter
35638 int f() { 
35639 \newline
35640 \InsetSpace ~
35641 \InsetSpace ~
35642 int i, j; 
35643 \newline
35644 \InsetSpace ~
35645 \InsetSpace ~
35646 i = 10; 
35647 \newline
35648 \InsetSpace ~
35649 \InsetSpace ~
35650 j = 10; 
35651 \newline
35652 \InsetSpace ~
35653 \InsetSpace ~
35654 return 10; 
35655 \newline
35656 }
35657 \end_layout
35658
35659 \begin_layout Standard
35660 Note: the dead stores created by this copy propagation will be eliminated
35661  by dead-code elimination.
35662 \end_layout
35663
35664 \begin_layout Subsection
35665 Loop Optimizations
35666 \begin_inset LatexCommand index
35667 name "Loop optimization"
35668
35669 \end_inset
35670
35671
35672 \begin_inset LatexCommand label
35673 name "sub:Loop-Optimizations"
35674
35675 \end_inset
35676
35677
35678 \end_layout
35679
35680 \begin_layout Standard
35681 Two types of loop optimizations are done by SDCC 
35682 \emph on
35683 loop invariant
35684 \emph default
35685  lifting and 
35686 \emph on
35687 strength reduction
35688 \emph default
35689  of loop induction variables.
35690  In addition to the strength reduction the optimizer marks the induction
35691  variables and the register allocator tries to keep the induction variables
35692  in registers for the duration of the loop.
35693  Because of this preference of the register allocator
35694 \begin_inset LatexCommand index
35695 name "Register allocation"
35696
35697 \end_inset
35698
35699 , loop induction optimization causes an increase in register pressure, which
35700  may cause unwanted spilling of other temporary variables into the stack
35701 \begin_inset LatexCommand index
35702 name "stack"
35703
35704 \end_inset
35705
35706  / data space.
35707  The compiler will generate a warning message when it is forced to allocate
35708  extra space either on the stack or data space.
35709  If this extra space allocation is undesirable then induction optimization
35710  can be eliminated either for the entire source file (with -
35711 \begin_inset ERT
35712 status collapsed
35713
35714 \begin_layout Standard
35715
35716
35717 \backslash
35718 /
35719 \end_layout
35720
35721 \end_inset
35722
35723 -noinduction option) or for a given function only using #pragma\InsetSpace ~
35724 noinduction
35725 \begin_inset LatexCommand index
35726 name "\\#pragma noinduction"
35727
35728 \end_inset
35729
35730 .
35731 \newline
35732
35733 \newline
35734 Loop Invariant:
35735 \end_layout
35736
35737 \begin_layout Verse
35738
35739 \family typewriter
35740 for (i = 0 ; i < 100 ; i ++) 
35741 \newline
35742 \InsetSpace ~
35743 \InsetSpace ~
35744 \InsetSpace ~
35745 \InsetSpace ~
35746 f += k + l;
35747 \end_layout
35748
35749 \begin_layout Standard
35750 changed to
35751 \end_layout
35752
35753 \begin_layout Verse
35754
35755 \family typewriter
35756 itemp = k + l; 
35757 \newline
35758 for (i = 0; i < 100; i++) 
35759 \newline
35760 \InsetSpace ~
35761 \InsetSpace ~
35762 \InsetSpace ~
35763 \InsetSpace ~
35764 f += itemp;
35765 \end_layout
35766
35767 \begin_layout Standard
35768 As mentioned previously some loop invariants are not as apparent, all static
35769  address computations are also moved out of the loop.
35770 \newline
35771
35772 \newline
35773 Strength Reduction
35774 \begin_inset LatexCommand index
35775 name "Strength reduction"
35776
35777 \end_inset
35778
35779 , this optimization substitutes an expression by a cheaper expression:
35780 \end_layout
35781
35782 \begin_layout Verse
35783
35784 \family typewriter
35785 for (i=0;i < 100; i++)
35786 \newline
35787 \InsetSpace ~
35788 \InsetSpace ~
35789 \InsetSpace ~
35790 \InsetSpace ~
35791 ar[i*5] = i*3;
35792 \end_layout
35793
35794 \begin_layout Standard
35795 changed to
35796 \end_layout
35797
35798 \begin_layout Verse
35799
35800 \family typewriter
35801 itemp1 = 0; 
35802 \newline
35803 itemp2 = 0; 
35804 \newline
35805 for (i=0;i< 100;i++) { 
35806 \newline
35807 \InsetSpace ~
35808 \InsetSpace ~
35809 \InsetSpace ~
35810 \InsetSpace ~
35811 ar[itemp1] = itemp2; 
35812 \newline
35813 \InsetSpace ~
35814 \InsetSpace ~
35815 \InsetSpace ~
35816 \InsetSpace ~
35817 itemp1
35818  += 5; 
35819 \newline
35820 \InsetSpace ~
35821 \InsetSpace ~
35822 \InsetSpace ~
35823 \InsetSpace ~
35824 itemp2 += 3; 
35825 \newline
35826 }
35827 \end_layout
35828
35829 \begin_layout Standard
35830 The more expensive multiplication
35831 \begin_inset LatexCommand index
35832 name "Multiplication"
35833
35834 \end_inset
35835
35836  is changed to a less expensive addition.
35837 \end_layout
35838
35839 \begin_layout Subsection
35840 Loop Reversing
35841 \begin_inset LatexCommand index
35842 name "Loop reversing"
35843
35844 \end_inset
35845
35846
35847 \end_layout
35848
35849 \begin_layout Standard
35850 This optimization is done to reduce the overhead of checking loop boundaries
35851  for every iteration.
35852  Some simple loops can be reversed and implemented using a 
35853 \begin_inset Quotes eld
35854 \end_inset
35855
35856 decrement and jump if not zero
35857 \begin_inset Quotes erd
35858 \end_inset
35859
35860  instruction.
35861  SDCC checks for the following criterion to determine if a loop is reversible
35862  (note: more sophisticated compilers use data-dependency analysis to make
35863  this determination, SDCC uses a more simple minded analysis).
35864 \end_layout
35865
35866 \begin_layout Itemize
35867 The 'for' loop is of the form 
35868 \newline
35869
35870 \newline
35871
35872 \family typewriter
35873 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
35874  += 1])
35875 \newline
35876 \InsetSpace ~
35877 \InsetSpace ~
35878 \InsetSpace ~
35879 \InsetSpace ~
35880 <for body>
35881 \end_layout
35882
35883 \begin_layout Itemize
35884 The <for body> does not contain 
35885 \begin_inset Quotes eld
35886 \end_inset
35887
35888 continue
35889 \begin_inset Quotes erd
35890 \end_inset
35891
35892  or 'break
35893 \begin_inset Quotes erd
35894 \end_inset
35895
35896 .
35897 \end_layout
35898
35899 \begin_layout Itemize
35900 All goto's are contained within the loop.
35901 \end_layout
35902
35903 \begin_layout Itemize
35904 No function calls within the loop.
35905 \end_layout
35906
35907 \begin_layout Itemize
35908 The loop control variable <sym> is not assigned any value within the loop
35909 \end_layout
35910
35911 \begin_layout Itemize
35912 The loop control variable does NOT participate in any arithmetic operation
35913  within the loop.
35914 \end_layout
35915
35916 \begin_layout Itemize
35917 There are NO switch statements in the loop.
35918 \end_layout
35919
35920 \begin_layout Subsection
35921 Algebraic Simplifications
35922 \end_layout
35923
35924 \begin_layout Standard
35925 SDCC does numerous algebraic simplifications, the following is a small sub-set
35926  of these optimizations.
35927 \end_layout
35928
35929 \begin_layout Verse
35930
35931 \family typewriter
35932 i = j + 0;\InsetSpace ~
35933 \InsetSpace ~
35934 \InsetSpace ~
35935 \InsetSpace ~
35936  /* changed to: */\InsetSpace ~
35937 \InsetSpace ~
35938 \InsetSpace ~
35939 \InsetSpace ~
35940  i = j; 
35941 \newline
35942 i /= 2;\InsetSpace ~
35943 \InsetSpace ~
35944 \InsetSpace ~
35945 \InsetSpace ~
35946 \InsetSpace ~
35947 \InsetSpace ~
35948 \InsetSpace ~
35949  /* changed to: */\InsetSpace ~
35950 \InsetSpace ~
35951 \InsetSpace ~
35952 \InsetSpace ~
35953  i >>= 1; 
35954 \newline
35955 i
35956  = j - j;\InsetSpace ~
35957 \InsetSpace ~
35958 \InsetSpace ~
35959 \InsetSpace ~
35960  /* changed to: */\InsetSpace ~
35961 \InsetSpace ~
35962 \InsetSpace ~
35963 \InsetSpace ~
35964  i = 0; 
35965 \newline
35966 i = j / 1;\InsetSpace ~
35967 \InsetSpace ~
35968 \InsetSpace ~
35969 \InsetSpace ~
35970  /* changed to: */\InsetSpace ~
35971 \InsetSpace ~
35972 \InsetSpace ~
35973 \InsetSpace ~
35974  i = j;
35975 \end_layout
35976
35977 \begin_layout Standard
35978 Note the subexpressions
35979 \begin_inset LatexCommand index
35980 name "Subexpression"
35981
35982 \end_inset
35983
35984  given above are generally introduced by macro expansions or as a result
35985  of copy/constant propagation.
35986 \end_layout
35987
35988 \begin_layout Subsection
35989 'switch' Statements
35990 \begin_inset LatexCommand label
35991 name "sub:'switch'-Statements"
35992
35993 \end_inset
35994
35995
35996 \begin_inset LatexCommand index
35997 name "switch statement"
35998
35999 \end_inset
36000
36001
36002 \end_layout
36003
36004 \begin_layout Standard
36005 SDCC can optimize switch statements to jump tables
36006 \begin_inset LatexCommand index
36007 name "jump tables"
36008
36009 \end_inset
36010
36011 .
36012  It makes the decision based on an estimate of the generated code size.
36013  SDCC is quite liberal in the requirements for jump table generation: 
36014 \end_layout
36015
36016 \begin_layout Itemize
36017 The labels need not be in order, and the starting number need not be one
36018  or zero, the case labels are in numerical sequence or not too many case
36019  labels are missing.
36020 \end_layout
36021
36022 \begin_deeper
36023 \begin_layout Verse
36024
36025 \family typewriter
36026 switch(i) {\InsetSpace ~
36027 \InsetSpace ~
36028 \InsetSpace ~
36029 \InsetSpace ~
36030 \InsetSpace ~
36031 \InsetSpace ~
36032 \InsetSpace ~
36033 \InsetSpace ~
36034 \InsetSpace ~
36035 \InsetSpace ~
36036 \InsetSpace ~
36037 \InsetSpace ~
36038 \InsetSpace ~
36039 \InsetSpace ~
36040 \InsetSpace ~
36041 \InsetSpace ~
36042 \InsetSpace ~
36043 \InsetSpace ~
36044 \InsetSpace ~
36045 \InsetSpace ~
36046 \InsetSpace ~
36047 \InsetSpace ~
36048 \InsetSpace ~
36049 \InsetSpace ~
36050 \InsetSpace ~
36051 \InsetSpace ~
36052 switch (i) { 
36053 \newline
36054 \InsetSpace ~
36055 \InsetSpace ~
36056 \InsetSpace ~
36057 case 4: ...\InsetSpace ~
36058 \InsetSpace ~
36059 \InsetSpace ~
36060 \InsetSpace ~
36061 \InsetSpace ~
36062 \InsetSpace ~
36063 \InsetSpace ~
36064 \InsetSpace ~
36065 \InsetSpace ~
36066 \InsetSpace ~
36067 \InsetSpace ~
36068 \InsetSpace ~
36069 \InsetSpace ~
36070 \InsetSpace ~
36071 \InsetSpace ~
36072 \InsetSpace ~
36073 \InsetSpace ~
36074 \InsetSpace ~
36075 \InsetSpace ~
36076 \InsetSpace ~
36077 \InsetSpace ~
36078 \InsetSpace ~
36079 \InsetSpace ~
36080 \InsetSpace ~
36081 \InsetSpace ~
36082 \InsetSpace ~
36083 case 0: ...
36084  
36085 \newline
36086 \InsetSpace ~
36087 \InsetSpace ~
36088 \InsetSpace ~
36089 case 5: ...\InsetSpace ~
36090 \InsetSpace ~
36091 \InsetSpace ~
36092 \InsetSpace ~
36093 \InsetSpace ~
36094 \InsetSpace ~
36095 \InsetSpace ~
36096 \InsetSpace ~
36097 \InsetSpace ~
36098 \InsetSpace ~
36099 \InsetSpace ~
36100 \InsetSpace ~
36101 \InsetSpace ~
36102 \InsetSpace ~
36103 \InsetSpace ~
36104 \InsetSpace ~
36105 \InsetSpace ~
36106 \InsetSpace ~
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110 \InsetSpace ~
36111 \InsetSpace ~
36112 \InsetSpace ~
36113 \InsetSpace ~
36114 \InsetSpace ~
36115 case 1: ...
36116  
36117 \newline
36118 \InsetSpace ~
36119 \InsetSpace ~
36120 \InsetSpace ~
36121 case 3: ...\InsetSpace ~
36122 \InsetSpace ~
36123 \InsetSpace ~
36124 \InsetSpace ~
36125 \InsetSpace ~
36126 \InsetSpace ~
36127 \InsetSpace ~
36128 \InsetSpace ~
36129 \InsetSpace ~
36130 \InsetSpace ~
36131 \InsetSpace ~
36132 \InsetSpace ~
36133 \InsetSpace ~
36134 \InsetSpace ~
36135 \InsetSpace ~
36136 \InsetSpace ~
36137 \InsetSpace ~
36138 \InsetSpace ~
36139 \InsetSpace ~
36140 \InsetSpace ~
36141 \InsetSpace ~
36142 \InsetSpace ~
36143 \InsetSpace ~
36144 \InsetSpace ~
36145 \InsetSpace ~
36146 \InsetSpace ~
36147
36148 \newline
36149 \InsetSpace ~
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 case 6: ...\InsetSpace ~
36153 \InsetSpace ~
36154 \InsetSpace ~
36155 \InsetSpace ~
36156 \InsetSpace ~
36157 \InsetSpace ~
36158 \InsetSpace ~
36159 \InsetSpace ~
36160 \InsetSpace ~
36161 \InsetSpace ~
36162 \InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 \InsetSpace ~
36167 \InsetSpace ~
36168 \InsetSpace ~
36169 \InsetSpace ~
36170 \InsetSpace ~
36171 \InsetSpace ~
36172 \InsetSpace ~
36173 \InsetSpace ~
36174 \InsetSpace ~
36175 \InsetSpace ~
36176 \InsetSpace ~
36177 \InsetSpace ~
36178 case 3: ...
36179  
36180 \newline
36181 \InsetSpace ~
36182 \InsetSpace ~
36183 \InsetSpace ~
36184 case 7: ...\InsetSpace ~
36185 \InsetSpace ~
36186 \InsetSpace ~
36187 \InsetSpace ~
36188 \InsetSpace ~
36189 \InsetSpace ~
36190 \InsetSpace ~
36191 \InsetSpace ~
36192 \InsetSpace ~
36193 \InsetSpace ~
36194 \InsetSpace ~
36195 \InsetSpace ~
36196 \InsetSpace ~
36197 \InsetSpace ~
36198 \InsetSpace ~
36199 \InsetSpace ~
36200 \InsetSpace ~
36201 \InsetSpace ~
36202 \InsetSpace ~
36203 \InsetSpace ~
36204 \InsetSpace ~
36205 \InsetSpace ~
36206 \InsetSpace ~
36207 \InsetSpace ~
36208 \InsetSpace ~
36209 \InsetSpace ~
36210 case 4: ...
36211  
36212 \newline
36213 \InsetSpace ~
36214 \InsetSpace ~
36215 \InsetSpace ~
36216 case 8: ...\InsetSpace ~
36217 \InsetSpace ~
36218 \InsetSpace ~
36219 \InsetSpace ~
36220 \InsetSpace ~
36221 \InsetSpace ~
36222 \InsetSpace ~
36223 \InsetSpace ~
36224 \InsetSpace ~
36225 \InsetSpace ~
36226 \InsetSpace ~
36227 \InsetSpace ~
36228 \InsetSpace ~
36229 \InsetSpace ~
36230 \InsetSpace ~
36231 \InsetSpace ~
36232 \InsetSpace ~
36233 \InsetSpace ~
36234 \InsetSpace ~
36235 \InsetSpace ~
36236 \InsetSpace ~
36237 \InsetSpace ~
36238 \InsetSpace ~
36239 \InsetSpace ~
36240 \InsetSpace ~
36241 \InsetSpace ~
36242 case 5: ...
36243  
36244 \newline
36245 \InsetSpace ~
36246 \InsetSpace ~
36247 \InsetSpace ~
36248 case 9: ...\InsetSpace ~
36249 \InsetSpace ~
36250 \InsetSpace ~
36251 \InsetSpace ~
36252 \InsetSpace ~
36253 \InsetSpace ~
36254 \InsetSpace ~
36255 \InsetSpace ~
36256 \InsetSpace ~
36257 \InsetSpace ~
36258 \InsetSpace ~
36259 \InsetSpace ~
36260 \InsetSpace ~
36261 \InsetSpace ~
36262 \InsetSpace ~
36263 \InsetSpace ~
36264 \InsetSpace ~
36265 \InsetSpace ~
36266 \InsetSpace ~
36267 \InsetSpace ~
36268 \InsetSpace ~
36269 \InsetSpace ~
36270 \InsetSpace ~
36271 \InsetSpace ~
36272 \InsetSpace ~
36273 \InsetSpace ~
36274 case 6: ...
36275  
36276 \newline
36277 \InsetSpace ~
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 case 10: ...\InsetSpace ~
36281 \InsetSpace ~
36282 \InsetSpace ~
36283 \InsetSpace ~
36284 \InsetSpace ~
36285 \InsetSpace ~
36286 \InsetSpace ~
36287 \InsetSpace ~
36288 \InsetSpace ~
36289 \InsetSpace ~
36290 \InsetSpace ~
36291 \InsetSpace ~
36292 \InsetSpace ~
36293 \InsetSpace ~
36294 \InsetSpace ~
36295 \InsetSpace ~
36296 \InsetSpace ~
36297 \InsetSpace ~
36298 \InsetSpace ~
36299 \InsetSpace ~
36300 \InsetSpace ~
36301 \InsetSpace ~
36302 \InsetSpace ~
36303 \InsetSpace ~
36304 \InsetSpace ~
36305 case 7: ...
36306  
36307 \newline
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 case 11: ...\InsetSpace ~
36312 \InsetSpace ~
36313 \InsetSpace ~
36314 \InsetSpace ~
36315 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318 \InsetSpace ~
36319 \InsetSpace ~
36320 \InsetSpace ~
36321 \InsetSpace ~
36322 \InsetSpace ~
36323 \InsetSpace ~
36324 \InsetSpace ~
36325 \InsetSpace ~
36326 \InsetSpace ~
36327 \InsetSpace ~
36328 \InsetSpace ~
36329 \InsetSpace ~
36330 \InsetSpace ~
36331 \InsetSpace ~
36332 \InsetSpace ~
36333 \InsetSpace ~
36334 \InsetSpace ~
36335 \InsetSpace ~
36336 case 8: ...
36337  
36338 \newline
36339 }\InsetSpace ~
36340 \InsetSpace ~
36341 \InsetSpace ~
36342 \InsetSpace ~
36343 \InsetSpace ~
36344 \InsetSpace ~
36345 \InsetSpace ~
36346 \InsetSpace ~
36347 \InsetSpace ~
36348 \InsetSpace ~
36349 \InsetSpace ~
36350 \InsetSpace ~
36351 \InsetSpace ~
36352 \InsetSpace ~
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 }
36376 \end_layout
36377
36378 \begin_layout Standard
36379 Both the above switch statements will be implemented using a jump-table.
36380  The example to the right side is slightly more efficient as the check for
36381  the lower boundary of the jump-table is not needed.
36382 \end_layout
36383
36384 \end_deeper
36385 \begin_layout Itemize
36386 The number of case labels is not larger than supported by the target architectur
36387 e.
36388 \end_layout
36389
36390 \begin_layout Itemize
36391 If the case labels are not in numerical sequence ('gaps' between cases)
36392  SDCC checks whether a jump table with additionally inserted dummy cases
36393  is still attractive.
36394  
36395 \end_layout
36396
36397 \begin_layout Itemize
36398 If the starting number is not zero and a check for the lower boundary of
36399  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
36400  ...
36401  .
36402 \end_layout
36403
36404 \begin_layout Standard
36405 Switch statements which have large gaps in the numeric sequence or those
36406  that have too many case labels can be split into more than one switch statement
36407  for efficient code generation, e.g.:
36408 \end_layout
36409
36410 \begin_layout Verse
36411
36412 \family typewriter
36413 switch (i) { 
36414 \newline
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 case 1: ...
36418  
36419 \newline
36420 \InsetSpace ~
36421 \InsetSpace ~
36422 case 2: ...
36423  
36424 \newline
36425 \InsetSpace ~
36426 \InsetSpace ~
36427 case 3: ...
36428  
36429 \newline
36430 \InsetSpace ~
36431 \InsetSpace ~
36432 case 4: ...
36433  
36434 \newline
36435 \InsetSpace ~
36436 \InsetSpace ~
36437 case 5: ...
36438  
36439 \newline
36440 \InsetSpace ~
36441 \InsetSpace ~
36442 case 6: ...
36443  
36444 \newline
36445 \InsetSpace ~
36446 \InsetSpace ~
36447 case 7: ...
36448  
36449 \newline
36450 \InsetSpace ~
36451 \InsetSpace ~
36452 case 101: ...
36453  
36454 \newline
36455 \InsetSpace ~
36456 \InsetSpace ~
36457 case 102: ...
36458  
36459 \newline
36460 \InsetSpace ~
36461 \InsetSpace ~
36462 case 103: ...
36463  
36464 \newline
36465 \InsetSpace ~
36466 \InsetSpace ~
36467 case 104: ...
36468  
36469 \newline
36470 \InsetSpace ~
36471 \InsetSpace ~
36472 case 105: ...
36473  
36474 \newline
36475 \InsetSpace ~
36476 \InsetSpace ~
36477 case 106: ...
36478  
36479 \newline
36480 \InsetSpace ~
36481 \InsetSpace ~
36482 case 107: ...
36483  
36484 \newline
36485 }
36486 \end_layout
36487
36488 \begin_layout Standard
36489 If the above switch statement is broken down into two switch statements
36490 \end_layout
36491
36492 \begin_layout Verse
36493
36494 \family typewriter
36495 switch (i) { 
36496 \newline
36497 \InsetSpace ~
36498 \InsetSpace ~
36499 case 1: ...
36500  
36501 \newline
36502 \InsetSpace ~
36503 \InsetSpace ~
36504 case 2: ...
36505  
36506 \newline
36507 \InsetSpace ~
36508 \InsetSpace ~
36509 case 3: ...
36510  
36511 \newline
36512 \InsetSpace ~
36513 \InsetSpace ~
36514 case 4: ...
36515  
36516 \newline
36517 \InsetSpace ~
36518 \InsetSpace ~
36519 case 5: ...
36520  
36521 \newline
36522 \InsetSpace ~
36523 \InsetSpace ~
36524 case 6: ...
36525  
36526 \newline
36527 \InsetSpace ~
36528 \InsetSpace ~
36529 case 7: ...
36530  
36531 \newline
36532 }
36533 \end_layout
36534
36535 \begin_layout Standard
36536 and
36537 \end_layout
36538
36539 \begin_layout Verse
36540
36541 \family typewriter
36542 switch (i) { 
36543 \newline
36544 \InsetSpace ~
36545 \InsetSpace ~
36546 case 101: ...
36547  
36548 \newline
36549 \InsetSpace ~
36550 \InsetSpace ~
36551 case 102: ...
36552  
36553 \newline
36554 \InsetSpace ~
36555 \InsetSpace ~
36556 case 103: ...
36557  
36558 \newline
36559 \InsetSpace ~
36560 \InsetSpace ~
36561 case 104: ...
36562  
36563 \newline
36564 \InsetSpace ~
36565 \InsetSpace ~
36566 case 105: ...
36567  
36568 \newline
36569 \InsetSpace ~
36570 \InsetSpace ~
36571 case 106: ...
36572  
36573 \newline
36574 \InsetSpace ~
36575 \InsetSpace ~
36576 case 107: ...
36577  
36578 \newline
36579 }
36580 \end_layout
36581
36582 \begin_layout Standard
36583 then both the switch statements will be implemented using jump-tables whereas
36584  the unmodified switch statement will not be.
36585 \end_layout
36586
36587 \begin_layout Standard
36588 \begin_inset Note Note
36589 status collapsed
36590
36591 \begin_layout Standard
36592 There might be reasons which SDCC cannot know about to either favour or
36593  not favour jump tables.
36594  If the target system has to be as quick for the last switch case as for
36595  the first (pro jump table), or if the switch argument is known to be zero
36596  in the majority of the cases (contra jump table).
36597 \end_layout
36598
36599 \end_inset
36600
36601
36602 \end_layout
36603
36604 \begin_layout Standard
36605 The pragma nojtbound
36606 \begin_inset LatexCommand index
36607 name "\\#pragma nojtbound"
36608
36609 \end_inset
36610
36611  can be used to turn off checking the 
36612 \emph on
36613 j
36614 \emph default
36615 ump 
36616 \emph on
36617 t
36618 \emph default
36619 able 
36620 \emph on
36621 bound
36622 \emph default
36623 aries.
36624  It has no effect if a default label is supplied.
36625  Use of this pragma is dangerous: if the switch
36626 \begin_inset LatexCommand index
36627 name "switch statement"
36628
36629 \end_inset
36630
36631  argument is not matched by a case statement the processor will happily
36632  jump into Nirvana.
36633 \end_layout
36634
36635 \begin_layout Subsection
36636 Bit-shifting Operations
36637 \begin_inset LatexCommand index
36638 name "Bit shifting"
36639
36640 \end_inset
36641
36642 .
36643 \end_layout
36644
36645 \begin_layout Standard
36646 Bit shifting is one of the most frequently used operation in embedded programmin
36647 g.
36648  SDCC tries to implement bit-shift operations in the most efficient way
36649  possible, e.g.:
36650 \end_layout
36651
36652 \begin_layout Verse
36653
36654 \family typewriter
36655 unsigned char i;
36656 \newline
36657 ...
36658  
36659 \newline
36660 i >>= 4; 
36661 \newline
36662 ...
36663 \end_layout
36664
36665 \begin_layout Standard
36666 generates the following code:
36667 \end_layout
36668
36669 \begin_layout Verse
36670
36671 \family typewriter
36672 mov\InsetSpace ~
36673  a,_i 
36674 \newline
36675 swap a 
36676 \newline
36677 anl\InsetSpace ~
36678  a,#0x0f 
36679 \newline
36680 mov\InsetSpace ~
36681  _i,a
36682 \end_layout
36683
36684 \begin_layout Standard
36685 In general SDCC will never setup a loop if the shift count is known.
36686  Another example:
36687 \end_layout
36688
36689 \begin_layout Verse
36690
36691 \family typewriter
36692 unsigned int i; 
36693 \newline
36694 ...
36695  
36696 \newline
36697 i >>= 9; 
36698 \newline
36699 ...
36700 \end_layout
36701
36702 \begin_layout Standard
36703 will generate:
36704 \end_layout
36705
36706 \begin_layout Verse
36707
36708 \family typewriter
36709 mov\InsetSpace ~
36710 \InsetSpace ~
36711 a,(_i + 1) 
36712 \newline
36713 mov\InsetSpace ~
36714 \InsetSpace ~
36715 (_i + 1),#0x00 
36716 \newline
36717 clr\InsetSpace ~
36718 \InsetSpace ~
36719
36720 \newline
36721 rrc\InsetSpace ~
36722 \InsetSpace ~
36723
36724 \newline
36725 mov\InsetSpace ~
36726 \InsetSpace ~
36727 _i,a
36728 \end_layout
36729
36730 \begin_layout Subsection
36731 Bit-rotation
36732 \begin_inset LatexCommand index
36733 name "Bit rotation"
36734
36735 \end_inset
36736
36737
36738 \end_layout
36739
36740 \begin_layout Standard
36741 A special case of the bit-shift operation is bit rotation
36742 \begin_inset LatexCommand index
36743 name "rotating bits"
36744
36745 \end_inset
36746
36747 , SDCC recognizes the following expression to be a left bit-rotation:
36748 \end_layout
36749
36750 \begin_layout Verse
36751
36752 \family typewriter
36753 \series bold
36754 unsigned
36755 \series default
36756 \InsetSpace ~
36757 \InsetSpace ~
36758 char i;\InsetSpace ~
36759 \InsetSpace ~
36760 \InsetSpace ~
36761 \InsetSpace ~
36762 \InsetSpace ~
36763 \InsetSpace ~
36764 \InsetSpace ~
36765 \InsetSpace ~
36766 \InsetSpace ~
36767 \InsetSpace ~
36768 \InsetSpace ~
36769 /* unsigned is needed for rotation */ 
36770 \newline
36771 ...
36772  
36773 \newline
36774 i = ((i << 1) | (i >> 7));
36775 \family default
36776  
36777 \newline
36778
36779 \family typewriter
36780 ...
36781 \end_layout
36782
36783 \begin_layout Standard
36784 will generate the following code:
36785 \end_layout
36786
36787 \begin_layout Verse
36788
36789 \family typewriter
36790 mov\InsetSpace ~
36791 \InsetSpace ~
36792 a,_i 
36793 \newline
36794 rl\InsetSpace ~
36795 \InsetSpace ~
36796 \InsetSpace ~
36797
36798 \newline
36799 mov\InsetSpace ~
36800 \InsetSpace ~
36801 _i,a
36802 \end_layout
36803
36804 \begin_layout Standard
36805 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
36806 ns of this case will also be recognized as bit-rotation, i.e.: 
36807 \end_layout
36808
36809 \begin_layout Verse
36810
36811 \family typewriter
36812 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
36813 \end_layout
36814
36815 \begin_layout Subsection
36816 Nibble and Byte Swapping
36817 \end_layout
36818
36819 \begin_layout Standard
36820 Other special cases of the bit-shift operations are nibble or byte swapping
36821 \begin_inset LatexCommand index
36822 name "swapping nibbles/bytes"
36823
36824 \end_inset
36825
36826 , SDCC recognizes the following expressions:
36827 \end_layout
36828
36829 \begin_layout Verse
36830
36831 \family typewriter
36832 \series bold
36833 unsigned
36834 \series default
36835 \InsetSpace ~
36836 \InsetSpace ~
36837 char i; 
36838 \newline
36839
36840 \series bold
36841 unsigned
36842 \series default
36843 \InsetSpace ~
36844 \InsetSpace ~
36845 int j; 
36846 \newline
36847 ...
36848  
36849 \newline
36850 i = ((i << 4) | (i >> 4));
36851 \family default
36852  
36853 \newline
36854
36855 \family typewriter
36856 j = ((j << 8) | (j >> 8)); 
36857 \end_layout
36858
36859 \begin_layout Standard
36860 and generates a swap instruction for the nibble swapping
36861 \begin_inset LatexCommand index
36862 name "Nibble swapping"
36863
36864 \end_inset
36865
36866  or move instructions for the byte swapping
36867 \begin_inset LatexCommand index
36868 name "Byte swapping"
36869
36870 \end_inset
36871
36872 .
36873  The 
36874 \begin_inset Quotes sld
36875 \end_inset
36876
36877 j
36878 \begin_inset Quotes srd
36879 \end_inset
36880
36881  example can be used to convert from little to big-endian or vice versa.
36882  If you want to change the endianness of a 
36883 \emph on
36884 signed
36885 \emph default
36886  integer you have to cast to 
36887 \family typewriter
36888 (unsigned int)
36889 \family default
36890  first.
36891 \end_layout
36892
36893 \begin_layout Standard
36894 Note that SDCC stores numbers in little-endian
36895 \begin_inset Foot
36896 status open
36897
36898 \begin_layout Standard
36899 Usually 8-bit processors don't care much about endianness.
36900  This is not the case for the standard 8051 which only has an instruction
36901  to increment its 
36902 \emph on
36903 dptr
36904 \emph default
36905
36906 \begin_inset LatexCommand index
36907 name "DPTR"
36908
36909 \end_inset
36910
36911 -datapointer so little-endian is the more efficient byte order.
36912 \end_layout
36913
36914 \end_inset
36915
36916
36917 \begin_inset LatexCommand index
36918 name "little-endian"
36919
36920 \end_inset
36921
36922
36923 \begin_inset LatexCommand index
36924 name "Endianness"
36925
36926 \end_inset
36927
36928  format (i.e.
36929  lowest order first).
36930 \end_layout
36931
36932 \begin_layout Subsection
36933 Highest Order Bit
36934 \begin_inset LatexCommand index
36935 name "Highest Order Bit"
36936
36937 \end_inset
36938
36939  / Any Order Bit
36940 \begin_inset LatexCommand index
36941 name "Any Order Bit"
36942
36943 \end_inset
36944
36945
36946 \end_layout
36947
36948 \begin_layout Standard
36949 It is frequently required to obtain the highest order bit of an integral
36950  type (long, int, short or char types).
36951  Also obtaining any other order bit is not uncommon.
36952  SDCC recognizes the following expressions to yield the highest order bit
36953  and generates optimized code for it, e.g.:
36954 \end_layout
36955
36956 \begin_layout Verse
36957
36958 \family typewriter
36959 unsigned int gint; 
36960 \newline
36961
36962 \newline
36963 foo () { 
36964 \newline
36965 \InsetSpace ~
36966 \InsetSpace ~
36967 unsigned char hob1, aob1; 
36968 \newline
36969 \InsetSpace ~
36970 \InsetSpace ~
36971 bit hob2, hob3, aob2,
36972  aob3; 
36973 \newline
36974 \InsetSpace ~
36975 \InsetSpace ~
36976 ...
36977  
36978 \newline
36979 \InsetSpace ~
36980 \InsetSpace ~
36981 hob1 = (gint >> 15) & 1; 
36982 \newline
36983 \InsetSpace ~
36984 \InsetSpace ~
36985 hob2 = (gint >> 15) & 1; 
36986 \newline
36987 \InsetSpace ~
36988 \InsetSpace ~
36989 hob3 = gint & 0x8000;
36990  
36991 \newline
36992 \InsetSpace ~
36993 \InsetSpace ~
36994 aob1 = (gint >> 9) & 1; 
36995 \newline
36996 \InsetSpace ~
36997 \InsetSpace ~
36998 aob2 = (gint >> 8) & 1; 
36999 \newline
37000 \InsetSpace ~
37001 \InsetSpace ~
37002 aob3 = gint & 0x0800; 
37003 \newline
37004 \InsetSpace ~
37005 \InsetSpace ~
37006 ..
37007  
37008 \newline
37009 }
37010 \end_layout
37011
37012 \begin_layout Standard
37013 will generate the following code:
37014 \end_layout
37015
37016 \begin_layout Verse
37017
37018 \family typewriter
37019 \InsetSpace ~
37020 \InsetSpace ~
37021 \InsetSpace ~
37022 \InsetSpace ~
37023 \InsetSpace ~
37024 \InsetSpace ~
37025 \InsetSpace ~
37026 \InsetSpace ~
37027 \InsetSpace ~
37028 \InsetSpace ~
37029 \InsetSpace ~
37030 \InsetSpace ~
37031 \InsetSpace ~
37032 \InsetSpace ~
37033 \InsetSpace ~
37034 \InsetSpace ~
37035 \InsetSpace ~
37036 \InsetSpace ~
37037 \InsetSpace ~
37038 \InsetSpace ~
37039 \InsetSpace ~
37040 \InsetSpace ~
37041 \InsetSpace ~
37042 \InsetSpace ~
37043 \InsetSpace ~
37044  61 ;\InsetSpace ~
37045  hob.c 7 
37046 \newline
37047 000A E5*01\InsetSpace ~
37048 \InsetSpace ~
37049 \InsetSpace ~
37050 \InsetSpace ~
37051 \InsetSpace ~
37052 \InsetSpace ~
37053 \InsetSpace ~
37054 \InsetSpace ~
37055 \InsetSpace ~
37056 \InsetSpace ~
37057 \InsetSpace ~
37058 \InsetSpace ~
37059 \InsetSpace ~
37060 \InsetSpace ~
37061 \InsetSpace ~
37062  62\InsetSpace ~
37063 \InsetSpace ~
37064 \InsetSpace ~
37065 \InsetSpace ~
37066 \InsetSpace ~
37067 \InsetSpace ~
37068 \InsetSpace ~
37069 \InsetSpace ~
37070  mov\InsetSpace ~
37071 \InsetSpace ~
37072  a,(_gint + 1) 
37073 \newline
37074 000C 23\InsetSpace ~
37075 \InsetSpace ~
37076 \InsetSpace ~
37077 \InsetSpace ~
37078 \InsetSpace ~
37079 \InsetSpace ~
37080 \InsetSpace ~
37081 \InsetSpace ~
37082 \InsetSpace ~
37083 \InsetSpace ~
37084 \InsetSpace ~
37085 \InsetSpace ~
37086 \InsetSpace ~
37087 \InsetSpace ~
37088 \InsetSpace ~
37089 \InsetSpace ~
37090 \InsetSpace ~
37091 \InsetSpace ~
37092  63\InsetSpace ~
37093 \InsetSpace ~
37094 \InsetSpace ~
37095 \InsetSpace ~
37096 \InsetSpace ~
37097 \InsetSpace ~
37098 \InsetSpace ~
37099 \InsetSpace ~
37100  rl\InsetSpace ~
37101 \InsetSpace ~
37102 \InsetSpace ~
37103  a 
37104 \newline
37105 000D 54 01\InsetSpace ~
37106 \InsetSpace ~
37107 \InsetSpace ~
37108 \InsetSpace ~
37109 \InsetSpace ~
37110 \InsetSpace ~
37111 \InsetSpace ~
37112 \InsetSpace ~
37113 \InsetSpace ~
37114 \InsetSpace ~
37115 \InsetSpace ~
37116 \InsetSpace ~
37117 \InsetSpace ~
37118 \InsetSpace ~
37119 \InsetSpace ~
37120
37121  64\InsetSpace ~
37122 \InsetSpace ~
37123 \InsetSpace ~
37124 \InsetSpace ~
37125 \InsetSpace ~
37126 \InsetSpace ~
37127 \InsetSpace ~
37128 \InsetSpace ~
37129  anl\InsetSpace ~
37130 \InsetSpace ~
37131  a,#0x01 
37132 \newline
37133 000F F5*02\InsetSpace ~
37134 \InsetSpace ~
37135 \InsetSpace ~
37136 \InsetSpace ~
37137 \InsetSpace ~
37138 \InsetSpace ~
37139 \InsetSpace ~
37140 \InsetSpace ~
37141 \InsetSpace ~
37142 \InsetSpace ~
37143 \InsetSpace ~
37144 \InsetSpace ~
37145 \InsetSpace ~
37146 \InsetSpace ~
37147 \InsetSpace ~
37148  65\InsetSpace ~
37149 \InsetSpace ~
37150 \InsetSpace ~
37151 \InsetSpace ~
37152 \InsetSpace ~
37153 \InsetSpace ~
37154 \InsetSpace ~
37155 \InsetSpace ~
37156  mov\InsetSpace ~
37157 \InsetSpace ~
37158  _foo_hob1_1_1,a 
37159 \newline
37160 \InsetSpace ~
37161 \InsetSpace ~
37162 \InsetSpace ~
37163 \InsetSpace ~
37164 \InsetSpace ~
37165 \InsetSpace ~
37166 \InsetSpace ~
37167 \InsetSpace ~
37168 \InsetSpace ~
37169 \InsetSpace ~
37170 \InsetSpace ~
37171 \InsetSpace ~
37172 \InsetSpace ~
37173 \InsetSpace ~
37174 \InsetSpace ~
37175 \InsetSpace ~
37176 \InsetSpace ~
37177 \InsetSpace ~
37178 \InsetSpace ~
37179 \InsetSpace ~
37180 \InsetSpace ~
37181 \InsetSpace ~
37182 \InsetSpace ~
37183 \InsetSpace ~
37184 \InsetSpace ~
37185  66 ;\InsetSpace ~
37186  hob.c 8 
37187 \newline
37188 0011 E5*01\InsetSpace ~
37189 \InsetSpace ~
37190 \InsetSpace ~
37191 \InsetSpace ~
37192 \InsetSpace ~
37193 \InsetSpace ~
37194 \InsetSpace ~
37195 \InsetSpace ~
37196 \InsetSpace ~
37197 \InsetSpace ~
37198 \InsetSpace ~
37199 \InsetSpace ~
37200 \InsetSpace ~
37201 \InsetSpace ~
37202 \InsetSpace ~
37203
37204  67\InsetSpace ~
37205 \InsetSpace ~
37206 \InsetSpace ~
37207 \InsetSpace ~
37208 \InsetSpace ~
37209 \InsetSpace ~
37210 \InsetSpace ~
37211 \InsetSpace ~
37212  mov\InsetSpace ~
37213 \InsetSpace ~
37214  a,(_gint + 1) 
37215 \newline
37216 0013 33\InsetSpace ~
37217 \InsetSpace ~
37218 \InsetSpace ~
37219 \InsetSpace ~
37220 \InsetSpace ~
37221 \InsetSpace ~
37222 \InsetSpace ~
37223 \InsetSpace ~
37224 \InsetSpace ~
37225 \InsetSpace ~
37226 \InsetSpace ~
37227 \InsetSpace ~
37228 \InsetSpace ~
37229 \InsetSpace ~
37230 \InsetSpace ~
37231 \InsetSpace ~
37232 \InsetSpace ~
37233 \InsetSpace ~
37234  68\InsetSpace ~
37235 \InsetSpace ~
37236 \InsetSpace ~
37237 \InsetSpace ~
37238 \InsetSpace ~
37239 \InsetSpace ~
37240 \InsetSpace ~
37241 \InsetSpace ~
37242  rlc\InsetSpace ~
37243 \InsetSpace ~
37244  a 
37245 \newline
37246 0014 92*00\InsetSpace ~
37247 \InsetSpace ~
37248 \InsetSpace ~
37249 \InsetSpace ~
37250 \InsetSpace ~
37251 \InsetSpace ~
37252 \InsetSpace ~
37253 \InsetSpace ~
37254 \InsetSpace ~
37255 \InsetSpace ~
37256 \InsetSpace ~
37257 \InsetSpace ~
37258 \InsetSpace ~
37259 \InsetSpace ~
37260 \InsetSpace ~
37261  69\InsetSpace ~
37262 \InsetSpace ~
37263 \InsetSpace ~
37264 \InsetSpace ~
37265 \InsetSpace ~
37266 \InsetSpace ~
37267 \InsetSpace ~
37268 \InsetSpace ~
37269  mov\InsetSpace ~
37270 \InsetSpace ~
37271  _foo_hob2_1_1,c
37272  
37273 \newline
37274 \InsetSpace ~
37275 \InsetSpace ~
37276 \InsetSpace ~
37277 \InsetSpace ~
37278 \InsetSpace ~
37279 \InsetSpace ~
37280 \InsetSpace ~
37281 \InsetSpace ~
37282 \InsetSpace ~
37283 \InsetSpace ~
37284 \InsetSpace ~
37285 \InsetSpace ~
37286 \InsetSpace ~
37287 \InsetSpace ~
37288 \InsetSpace ~
37289 \InsetSpace ~
37290 \InsetSpace ~
37291 \InsetSpace ~
37292 \InsetSpace ~
37293 \InsetSpace ~
37294 \InsetSpace ~
37295 \InsetSpace ~
37296 \InsetSpace ~
37297 \InsetSpace ~
37298 \InsetSpace ~
37299  66 ;\InsetSpace ~
37300  hob.c 9 
37301 \newline
37302 0016 E5*01\InsetSpace ~
37303 \InsetSpace ~
37304 \InsetSpace ~
37305 \InsetSpace ~
37306 \InsetSpace ~
37307 \InsetSpace ~
37308 \InsetSpace ~
37309 \InsetSpace ~
37310 \InsetSpace ~
37311 \InsetSpace ~
37312 \InsetSpace ~
37313 \InsetSpace ~
37314 \InsetSpace ~
37315 \InsetSpace ~
37316 \InsetSpace ~
37317  67\InsetSpace ~
37318 \InsetSpace ~
37319 \InsetSpace ~
37320 \InsetSpace ~
37321 \InsetSpace ~
37322 \InsetSpace ~
37323 \InsetSpace ~
37324 \InsetSpace ~
37325  mov\InsetSpace ~
37326 \InsetSpace ~
37327  a,(_gint + 1) 
37328 \newline
37329 0018 33\InsetSpace ~
37330 \InsetSpace ~
37331 \InsetSpace ~
37332 \InsetSpace ~
37333 \InsetSpace ~
37334 \InsetSpace ~
37335 \InsetSpace ~
37336 \InsetSpace ~
37337 \InsetSpace ~
37338 \InsetSpace ~
37339 \InsetSpace ~
37340 \InsetSpace ~
37341 \InsetSpace ~
37342 \InsetSpace ~
37343 \InsetSpace ~
37344 \InsetSpace ~
37345 \InsetSpace ~
37346 \InsetSpace ~
37347  68\InsetSpace ~
37348 \InsetSpace ~
37349 \InsetSpace ~
37350 \InsetSpace ~
37351 \InsetSpace ~
37352 \InsetSpace ~
37353 \InsetSpace ~
37354 \InsetSpace ~
37355  rlc\InsetSpace ~
37356 \InsetSpace ~
37357  a 
37358 \newline
37359 0019 92*01\InsetSpace ~
37360 \InsetSpace ~
37361 \InsetSpace ~
37362 \InsetSpace ~
37363 \InsetSpace ~
37364 \InsetSpace ~
37365 \InsetSpace ~
37366 \InsetSpace ~
37367 \InsetSpace ~
37368 \InsetSpace ~
37369 \InsetSpace ~
37370 \InsetSpace ~
37371 \InsetSpace ~
37372 \InsetSpace ~
37373 \InsetSpace ~
37374
37375  69\InsetSpace ~
37376 \InsetSpace ~
37377 \InsetSpace ~
37378 \InsetSpace ~
37379 \InsetSpace ~
37380 \InsetSpace ~
37381 \InsetSpace ~
37382 \InsetSpace ~
37383  mov\InsetSpace ~
37384 \InsetSpace ~
37385  _foo_hob3_1_1,c 
37386 \newline
37387 \InsetSpace ~
37388 \InsetSpace ~
37389 \InsetSpace ~
37390 \InsetSpace ~
37391 \InsetSpace ~
37392 \InsetSpace ~
37393 \InsetSpace ~
37394 \InsetSpace ~
37395 \InsetSpace ~
37396 \InsetSpace ~
37397 \InsetSpace ~
37398 \InsetSpace ~
37399 \InsetSpace ~
37400 \InsetSpace ~
37401 \InsetSpace ~
37402 \InsetSpace ~
37403 \InsetSpace ~
37404 \InsetSpace ~
37405 \InsetSpace ~
37406 \InsetSpace ~
37407 \InsetSpace ~
37408 \InsetSpace ~
37409 \InsetSpace ~
37410 \InsetSpace ~
37411 \InsetSpace ~
37412  70 ;\InsetSpace ~
37413  hob.c 10 
37414 \newline
37415 001B E5*01\InsetSpace ~
37416 \InsetSpace ~
37417 \InsetSpace ~
37418 \InsetSpace ~
37419 \InsetSpace ~
37420 \InsetSpace ~
37421 \InsetSpace ~
37422 \InsetSpace ~
37423 \InsetSpace ~
37424 \InsetSpace ~
37425 \InsetSpace ~
37426 \InsetSpace ~
37427 \InsetSpace ~
37428 \InsetSpace ~
37429 \InsetSpace ~
37430  71\InsetSpace ~
37431 \InsetSpace ~
37432 \InsetSpace ~
37433 \InsetSpace ~
37434 \InsetSpace ~
37435 \InsetSpace ~
37436 \InsetSpace ~
37437 \InsetSpace ~
37438  mov\InsetSpace ~
37439 \InsetSpace ~
37440  a,(_gint + 1) 
37441 \newline
37442 001D
37443  03\InsetSpace ~
37444 \InsetSpace ~
37445 \InsetSpace ~
37446 \InsetSpace ~
37447 \InsetSpace ~
37448 \InsetSpace ~
37449 \InsetSpace ~
37450 \InsetSpace ~
37451 \InsetSpace ~
37452 \InsetSpace ~
37453 \InsetSpace ~
37454 \InsetSpace ~
37455 \InsetSpace ~
37456 \InsetSpace ~
37457 \InsetSpace ~
37458 \InsetSpace ~
37459 \InsetSpace ~
37460 \InsetSpace ~
37461  72\InsetSpace ~
37462 \InsetSpace ~
37463 \InsetSpace ~
37464 \InsetSpace ~
37465 \InsetSpace ~
37466 \InsetSpace ~
37467 \InsetSpace ~
37468 \InsetSpace ~
37469  rr\InsetSpace ~
37470 \InsetSpace ~
37471 \InsetSpace ~
37472  a 
37473 \newline
37474 001E 54 01\InsetSpace ~
37475 \InsetSpace ~
37476 \InsetSpace ~
37477 \InsetSpace ~
37478 \InsetSpace ~
37479 \InsetSpace ~
37480 \InsetSpace ~
37481 \InsetSpace ~
37482 \InsetSpace ~
37483 \InsetSpace ~
37484 \InsetSpace ~
37485 \InsetSpace ~
37486 \InsetSpace ~
37487 \InsetSpace ~
37488 \InsetSpace ~
37489  73\InsetSpace ~
37490 \InsetSpace ~
37491 \InsetSpace ~
37492 \InsetSpace ~
37493 \InsetSpace ~
37494 \InsetSpace ~
37495 \InsetSpace ~
37496 \InsetSpace ~
37497  anl\InsetSpace ~
37498 \InsetSpace ~
37499  a,#0x01 
37500 \newline
37501 0020 F5*03\InsetSpace ~
37502 \InsetSpace ~
37503 \InsetSpace ~
37504 \InsetSpace ~
37505 \InsetSpace ~
37506 \InsetSpace ~
37507 \InsetSpace ~
37508 \InsetSpace ~
37509 \InsetSpace ~
37510 \InsetSpace ~
37511 \InsetSpace ~
37512 \InsetSpace ~
37513 \InsetSpace ~
37514 \InsetSpace ~
37515 \InsetSpace ~
37516  74\InsetSpace ~
37517 \InsetSpace ~
37518 \InsetSpace ~
37519 \InsetSpace ~
37520 \InsetSpace ~
37521 \InsetSpace ~
37522 \InsetSpace ~
37523 \InsetSpace ~
37524  mov\InsetSpace ~
37525 \InsetSpace ~
37526  _foo_aob1_1_1,a
37527  
37528 \newline
37529 \InsetSpace ~
37530 \InsetSpace ~
37531 \InsetSpace ~
37532 \InsetSpace ~
37533 \InsetSpace ~
37534 \InsetSpace ~
37535 \InsetSpace ~
37536 \InsetSpace ~
37537 \InsetSpace ~
37538 \InsetSpace ~
37539 \InsetSpace ~
37540 \InsetSpace ~
37541 \InsetSpace ~
37542 \InsetSpace ~
37543 \InsetSpace ~
37544 \InsetSpace ~
37545 \InsetSpace ~
37546 \InsetSpace ~
37547 \InsetSpace ~
37548 \InsetSpace ~
37549 \InsetSpace ~
37550 \InsetSpace ~
37551 \InsetSpace ~
37552 \InsetSpace ~
37553 \InsetSpace ~
37554  75 ;\InsetSpace ~
37555  hob.c 11 
37556 \newline
37557 0022 E5*01\InsetSpace ~
37558 \InsetSpace ~
37559 \InsetSpace ~
37560 \InsetSpace ~
37561 \InsetSpace ~
37562 \InsetSpace ~
37563 \InsetSpace ~
37564 \InsetSpace ~
37565 \InsetSpace ~
37566 \InsetSpace ~
37567 \InsetSpace ~
37568 \InsetSpace ~
37569 \InsetSpace ~
37570 \InsetSpace ~
37571 \InsetSpace ~
37572  76\InsetSpace ~
37573 \InsetSpace ~
37574 \InsetSpace ~
37575 \InsetSpace ~
37576 \InsetSpace ~
37577 \InsetSpace ~
37578 \InsetSpace ~
37579 \InsetSpace ~
37580  mov\InsetSpace ~
37581 \InsetSpace ~
37582  a,(_gint + 1) 
37583 \newline
37584 0024 13\InsetSpace ~
37585 \InsetSpace ~
37586 \InsetSpace ~
37587 \InsetSpace ~
37588 \InsetSpace ~
37589 \InsetSpace ~
37590 \InsetSpace ~
37591 \InsetSpace ~
37592 \InsetSpace ~
37593 \InsetSpace ~
37594 \InsetSpace ~
37595 \InsetSpace ~
37596 \InsetSpace ~
37597 \InsetSpace ~
37598 \InsetSpace ~
37599 \InsetSpace ~
37600 \InsetSpace ~
37601 \InsetSpace ~
37602  77\InsetSpace ~
37603 \InsetSpace ~
37604 \InsetSpace ~
37605 \InsetSpace ~
37606 \InsetSpace ~
37607 \InsetSpace ~
37608 \InsetSpace ~
37609 \InsetSpace ~
37610  rrc\InsetSpace ~
37611 \InsetSpace ~
37612  a 
37613 \newline
37614 0025 92*02\InsetSpace ~
37615 \InsetSpace ~
37616 \InsetSpace ~
37617 \InsetSpace ~
37618 \InsetSpace ~
37619 \InsetSpace ~
37620 \InsetSpace ~
37621 \InsetSpace ~
37622 \InsetSpace ~
37623 \InsetSpace ~
37624 \InsetSpace ~
37625 \InsetSpace ~
37626 \InsetSpace ~
37627 \InsetSpace ~
37628 \InsetSpace ~
37629
37630  78\InsetSpace ~
37631 \InsetSpace ~
37632 \InsetSpace ~
37633 \InsetSpace ~
37634 \InsetSpace ~
37635 \InsetSpace ~
37636 \InsetSpace ~
37637 \InsetSpace ~
37638  mov\InsetSpace ~
37639 \InsetSpace ~
37640  _foo_aob2_1_1,c 
37641 \newline
37642 \InsetSpace ~
37643 \InsetSpace ~
37644 \InsetSpace ~
37645 \InsetSpace ~
37646 \InsetSpace ~
37647 \InsetSpace ~
37648 \InsetSpace ~
37649 \InsetSpace ~
37650 \InsetSpace ~
37651 \InsetSpace ~
37652 \InsetSpace ~
37653 \InsetSpace ~
37654 \InsetSpace ~
37655 \InsetSpace ~
37656 \InsetSpace ~
37657 \InsetSpace ~
37658 \InsetSpace ~
37659 \InsetSpace ~
37660 \InsetSpace ~
37661 \InsetSpace ~
37662 \InsetSpace ~
37663 \InsetSpace ~
37664 \InsetSpace ~
37665 \InsetSpace ~
37666 \InsetSpace ~
37667  79 ;\InsetSpace ~
37668  hob.c 12 
37669 \newline
37670 0027 E5*01\InsetSpace ~
37671 \InsetSpace ~
37672 \InsetSpace ~
37673 \InsetSpace ~
37674 \InsetSpace ~
37675 \InsetSpace ~
37676 \InsetSpace ~
37677 \InsetSpace ~
37678 \InsetSpace ~
37679 \InsetSpace ~
37680 \InsetSpace ~
37681 \InsetSpace ~
37682 \InsetSpace ~
37683 \InsetSpace ~
37684 \InsetSpace ~
37685  80\InsetSpace ~
37686 \InsetSpace ~
37687 \InsetSpace ~
37688 \InsetSpace ~
37689 \InsetSpace ~
37690 \InsetSpace ~
37691 \InsetSpace ~
37692 \InsetSpace ~
37693  mov\InsetSpace ~
37694 \InsetSpace ~
37695  a,(_gint + 1) 
37696 \newline
37697 0029
37698  A2 E3\InsetSpace ~
37699 \InsetSpace ~
37700 \InsetSpace ~
37701 \InsetSpace ~
37702 \InsetSpace ~
37703 \InsetSpace ~
37704 \InsetSpace ~
37705 \InsetSpace ~
37706 \InsetSpace ~
37707 \InsetSpace ~
37708 \InsetSpace ~
37709 \InsetSpace ~
37710 \InsetSpace ~
37711 \InsetSpace ~
37712 \InsetSpace ~
37713  81\InsetSpace ~
37714 \InsetSpace ~
37715 \InsetSpace ~
37716 \InsetSpace ~
37717 \InsetSpace ~
37718 \InsetSpace ~
37719 \InsetSpace ~
37720 \InsetSpace ~
37721  mov\InsetSpace ~
37722 \InsetSpace ~
37723  c,acc[3] 
37724 \newline
37725 002B 92*03\InsetSpace ~
37726 \InsetSpace ~
37727 \InsetSpace ~
37728 \InsetSpace ~
37729 \InsetSpace ~
37730 \InsetSpace ~
37731 \InsetSpace ~
37732 \InsetSpace ~
37733 \InsetSpace ~
37734 \InsetSpace ~
37735 \InsetSpace ~
37736 \InsetSpace ~
37737 \InsetSpace ~
37738 \InsetSpace ~
37739 \InsetSpace ~
37740  82\InsetSpace ~
37741 \InsetSpace ~
37742 \InsetSpace ~
37743 \InsetSpace ~
37744 \InsetSpace ~
37745 \InsetSpace ~
37746 \InsetSpace ~
37747 \InsetSpace ~
37748  mov\InsetSpace ~
37749 \InsetSpace ~
37750  _foo_aob3_1_1,c 
37751 \end_layout
37752
37753 \begin_layout Standard
37754 Other variations of these cases however will 
37755 \emph on
37756 not
37757 \emph default
37758  be recognized.
37759  They are standard C expressions, so I heartily recommend these be the only
37760  way to get the highest order bit, (it is portable).
37761  Of course it will be recognized even if it is embedded in other expressions,
37762  e.g.:
37763 \end_layout
37764
37765 \begin_layout Verse
37766
37767 \family typewriter
37768 xyz = gint + ((gint >> 15) & 1);
37769 \end_layout
37770
37771 \begin_layout Standard
37772 will still be recognized.
37773 \end_layout
37774
37775 \begin_layout Subsection
37776 Higher Order Byte
37777 \begin_inset LatexCommand index
37778 name "Higher Order Byte"
37779
37780 \end_inset
37781
37782  / Higher Order Word
37783 \begin_inset LatexCommand index
37784 name "Higher Order Word"
37785
37786 \end_inset
37787
37788
37789 \end_layout
37790
37791 \begin_layout Standard
37792 It is also frequently required to obtain a higher order byte or word of
37793  a larger integral type (long, int or short types).
37794  SDCC recognizes the following expressions to yield the higher order byte
37795  or word and generates optimized code for it, e.g.:
37796 \end_layout
37797
37798 \begin_layout Verse
37799
37800 \family typewriter
37801 unsigned int gint; 
37802 \newline
37803 unsigned long int glong; 
37804 \newline
37805
37806 \newline
37807 foo () { 
37808 \newline
37809 \InsetSpace ~
37810 \InsetSpace ~
37811 unsigned char hob1,
37812  hob2; 
37813 \newline
37814 \InsetSpace ~
37815 \InsetSpace ~
37816 unsigned int how1, how2; 
37817 \newline
37818 \InsetSpace ~
37819 \InsetSpace ~
37820 ...
37821  
37822 \newline
37823 \InsetSpace ~
37824 \InsetSpace ~
37825 hob1 = (gint >> 8) & 0xFF; 
37826 \newline
37827 \InsetSpace ~
37828 \InsetSpace ~
37829 hob2 = glong >> 24; 
37830 \newline
37831 \InsetSpace ~
37832 \InsetSpace ~
37833 how1 = (glong >> 16) & 0xFFFF;
37834  
37835 \newline
37836 \InsetSpace ~
37837 \InsetSpace ~
37838 how2 = glong >> 8; 
37839 \newline
37840 \InsetSpace ~
37841 \InsetSpace ~
37842 ..
37843  
37844 \newline
37845 }
37846 \end_layout
37847
37848 \begin_layout Standard
37849 will generate the following code:
37850 \end_layout
37851
37852 \begin_layout Verse
37853
37854 \family typewriter
37855 \InsetSpace ~
37856 \InsetSpace ~
37857 \InsetSpace ~
37858 \InsetSpace ~
37859 \InsetSpace ~
37860 \InsetSpace ~
37861 \InsetSpace ~
37862 \InsetSpace ~
37863 \InsetSpace ~
37864 \InsetSpace ~
37865 \InsetSpace ~
37866 \InsetSpace ~
37867 \InsetSpace ~
37868 \InsetSpace ~
37869 \InsetSpace ~
37870 \InsetSpace ~
37871 \InsetSpace ~
37872 \InsetSpace ~
37873 \InsetSpace ~
37874 \InsetSpace ~
37875 \InsetSpace ~
37876 \InsetSpace ~
37877 \InsetSpace ~
37878 \InsetSpace ~
37879 \InsetSpace ~
37880  91 ;\InsetSpace ~
37881  hob.c 15 
37882 \newline
37883 0037 85*01*06\InsetSpace ~
37884 \InsetSpace ~
37885 \InsetSpace ~
37886 \InsetSpace ~
37887 \InsetSpace ~
37888 \InsetSpace ~
37889 \InsetSpace ~
37890 \InsetSpace ~
37891 \InsetSpace ~
37892 \InsetSpace ~
37893 \InsetSpace ~
37894 \InsetSpace ~
37895  92\InsetSpace ~
37896 \InsetSpace ~
37897 \InsetSpace ~
37898 \InsetSpace ~
37899 \InsetSpace ~
37900 \InsetSpace ~
37901 \InsetSpace ~
37902 \InsetSpace ~
37903  mov\InsetSpace ~
37904 \InsetSpace ~
37905  _foo_hob1_1_1,(_gint + 1) 
37906 \newline
37907 \InsetSpace ~
37908 \InsetSpace ~
37909 \InsetSpace ~
37910 \InsetSpace ~
37911 \InsetSpace ~
37912 \InsetSpace ~
37913 \InsetSpace ~
37914 \InsetSpace ~
37915 \InsetSpace ~
37916 \InsetSpace ~
37917 \InsetSpace ~
37918 \InsetSpace ~
37919 \InsetSpace ~
37920 \InsetSpace ~
37921 \InsetSpace ~
37922 \InsetSpace ~
37923 \InsetSpace ~
37924 \InsetSpace ~
37925 \InsetSpace ~
37926 \InsetSpace ~
37927 \InsetSpace ~
37928 \InsetSpace ~
37929 \InsetSpace ~
37930 \InsetSpace ~
37931 \InsetSpace ~
37932  93 ;\InsetSpace ~
37933  hob.c
37934  16 
37935 \newline
37936 003A 85*05*07\InsetSpace ~
37937 \InsetSpace ~
37938 \InsetSpace ~
37939 \InsetSpace ~
37940 \InsetSpace ~
37941 \InsetSpace ~
37942 \InsetSpace ~
37943 \InsetSpace ~
37944 \InsetSpace ~
37945 \InsetSpace ~
37946 \InsetSpace ~
37947 \InsetSpace ~
37948  94\InsetSpace ~
37949 \InsetSpace ~
37950 \InsetSpace ~
37951 \InsetSpace ~
37952 \InsetSpace ~
37953 \InsetSpace ~
37954 \InsetSpace ~
37955 \InsetSpace ~
37956  mov\InsetSpace ~
37957 \InsetSpace ~
37958  _foo_hob2_1_1,(_glong + 3) 
37959 \newline
37960 \InsetSpace ~
37961 \InsetSpace ~
37962 \InsetSpace ~
37963 \InsetSpace ~
37964 \InsetSpace ~
37965 \InsetSpace ~
37966 \InsetSpace ~
37967 \InsetSpace ~
37968 \InsetSpace ~
37969 \InsetSpace ~
37970 \InsetSpace ~
37971 \InsetSpace ~
37972 \InsetSpace ~
37973 \InsetSpace ~
37974 \InsetSpace ~
37975 \InsetSpace ~
37976 \InsetSpace ~
37977 \InsetSpace ~
37978 \InsetSpace ~
37979 \InsetSpace ~
37980 \InsetSpace ~
37981 \InsetSpace ~
37982 \InsetSpace ~
37983 \InsetSpace ~
37984 \InsetSpace ~
37985  95 ;\InsetSpace ~
37986  hob.c 17 
37987 \newline
37988 003D 85*04*08\InsetSpace ~
37989 \InsetSpace ~
37990 \InsetSpace ~
37991 \InsetSpace ~
37992 \InsetSpace ~
37993 \InsetSpace ~
37994 \InsetSpace ~
37995 \InsetSpace ~
37996 \InsetSpace ~
37997 \InsetSpace ~
37998 \InsetSpace ~
37999 \InsetSpace ~
38000
38001  96\InsetSpace ~
38002 \InsetSpace ~
38003 \InsetSpace ~
38004 \InsetSpace ~
38005 \InsetSpace ~
38006 \InsetSpace ~
38007 \InsetSpace ~
38008 \InsetSpace ~
38009  mov\InsetSpace ~
38010 \InsetSpace ~
38011  _foo_how1_1_1,(_glong + 2) 
38012 \newline
38013 0040 85*05*09\InsetSpace ~
38014 \InsetSpace ~
38015 \InsetSpace ~
38016 \InsetSpace ~
38017 \InsetSpace ~
38018 \InsetSpace ~
38019 \InsetSpace ~
38020 \InsetSpace ~
38021 \InsetSpace ~
38022 \InsetSpace ~
38023 \InsetSpace ~
38024 \InsetSpace ~
38025  97\InsetSpace ~
38026 \InsetSpace ~
38027 \InsetSpace ~
38028 \InsetSpace ~
38029 \InsetSpace ~
38030 \InsetSpace ~
38031 \InsetSpace ~
38032 \InsetSpace ~
38033  mov\InsetSpace ~
38034 \InsetSpace ~
38035  (_foo_how1_1_1 +
38036  1),(_glong + 3) 
38037 \newline
38038 0043 85*03*0A\InsetSpace ~
38039 \InsetSpace ~
38040 \InsetSpace ~
38041 \InsetSpace ~
38042 \InsetSpace ~
38043 \InsetSpace ~
38044 \InsetSpace ~
38045 \InsetSpace ~
38046 \InsetSpace ~
38047 \InsetSpace ~
38048 \InsetSpace ~
38049 \InsetSpace ~
38050  98\InsetSpace ~
38051 \InsetSpace ~
38052 \InsetSpace ~
38053 \InsetSpace ~
38054 \InsetSpace ~
38055 \InsetSpace ~
38056 \InsetSpace ~
38057 \InsetSpace ~
38058  mov\InsetSpace ~
38059 \InsetSpace ~
38060  _foo_how2_1_1,(_glong + 1) 
38061 \newline
38062 0046 85*04*0B\InsetSpace ~
38063 \InsetSpace ~
38064 \InsetSpace ~
38065 \InsetSpace ~
38066 \InsetSpace ~
38067 \InsetSpace ~
38068 \InsetSpace ~
38069 \InsetSpace ~
38070 \InsetSpace ~
38071 \InsetSpace ~
38072 \InsetSpace ~
38073 \InsetSpace ~
38074
38075  99\InsetSpace ~
38076 \InsetSpace ~
38077 \InsetSpace ~
38078 \InsetSpace ~
38079 \InsetSpace ~
38080 \InsetSpace ~
38081 \InsetSpace ~
38082 \InsetSpace ~
38083  mov\InsetSpace ~
38084 \InsetSpace ~
38085  (_foo_how2_1_1 + 1),(_glong + 2) 
38086 \end_layout
38087
38088 \begin_layout Standard
38089 Again, variations of these cases may 
38090 \emph on
38091 not
38092 \emph default
38093  be recognized.
38094  They are standard C expressions, so I heartily recommend these be the only
38095  way to get the higher order byte/word, (it is portable).
38096  Of course it will be recognized even if it is embedded in other expressions,
38097  e.g.:
38098 \end_layout
38099
38100 \begin_layout Verse
38101
38102 \family typewriter
38103 xyz = gint + ((gint >> 8) & 0xFF);
38104 \end_layout
38105
38106 \begin_layout Standard
38107 will still be recognized.
38108 \end_layout
38109
38110 \begin_layout Subsection
38111 Peephole Optimizer
38112 \begin_inset LatexCommand label
38113 name "sub:Peephole-Optimizer"
38114
38115 \end_inset
38116
38117
38118 \begin_inset LatexCommand index
38119 name "Peephole optimizer"
38120
38121 \end_inset
38122
38123
38124 \end_layout
38125
38126 \begin_layout Standard
38127 The compiler uses a rule based, pattern matching and re-writing mechanism
38128  for peep-hole optimization.
38129  It is inspired by 
38130 \emph on
38131 copt
38132 \emph default
38133  a peep-hole optimizer by Christopher W.
38134  Fraser (cwfraser\InsetSpace ~
38135 @\InsetSpace ~
38136 microsoft.com).
38137  A default set of rules are compiled into the compiler, additional rules
38138  may be added with the 
38139 \emph on
38140 -
38141 \begin_inset ERT
38142 status collapsed
38143
38144 \begin_layout Standard
38145
38146
38147 \backslash
38148 /
38149 \end_layout
38150
38151 \end_inset
38152
38153 -peep-file
38154 \begin_inset LatexCommand index
38155 name "-\\/-peep-file"
38156
38157 \end_inset
38158
38159  <filename>
38160 \emph default
38161  option.
38162  The rule language is best illustrated with examples.
38163 \end_layout
38164
38165 \begin_layout Verse
38166
38167 \family typewriter
38168 replace { 
38169 \newline
38170 \InsetSpace ~
38171 \InsetSpace ~
38172 mov %1,a 
38173 \newline
38174 \InsetSpace ~
38175 \InsetSpace ~
38176 mov a,%1
38177 \newline
38178 } by {
38179 \newline
38180 \InsetSpace ~
38181 \InsetSpace ~
38182 mov %1,a
38183 \newline
38184 }
38185 \end_layout
38186
38187 \begin_layout Standard
38188 The above rule will change the following assembly
38189 \begin_inset LatexCommand index
38190 name "Assembler routines"
38191
38192 \end_inset
38193
38194  sequence:
38195 \end_layout
38196
38197 \begin_layout Verse
38198
38199 \family typewriter
38200 mov r1,a 
38201 \newline
38202 mov a,r1
38203 \end_layout
38204
38205 \begin_layout Standard
38206 to
38207 \end_layout
38208
38209 \begin_layout Verse
38210
38211 \family typewriter
38212 mov r1,a
38213 \end_layout
38214
38215 \begin_layout Standard
38216 Note: All occurrences of a 
38217 \emph on
38218 %n
38219 \emph default
38220  (pattern variable) must denote the same string.
38221  With the above rule, the assembly sequence:
38222 \end_layout
38223
38224 \begin_layout Verse
38225
38226 \family typewriter
38227 mov r1,a 
38228 \newline
38229 mov a,r2
38230 \end_layout
38231
38232 \begin_layout Standard
38233 will remain unmodified.
38234 \newline
38235
38236 \newline
38237 Other special case optimizations may be added by the
38238  user (via 
38239 \emph on
38240 -
38241 \begin_inset ERT
38242 status collapsed
38243
38244 \begin_layout Standard
38245
38246
38247 \backslash
38248 /
38249 \end_layout
38250
38251 \end_inset
38252
38253 -peep-file option
38254 \emph default
38255 ).
38256  E.g.
38257  some variants of the 8051 MCU
38258 \begin_inset LatexCommand index
38259 name "MCS51 variants"
38260
38261 \end_inset
38262
38263  allow only 
38264 \family typewriter
38265 ajmp
38266 \family default
38267  and 
38268 \family typewriter
38269 acall
38270 \family default
38271 .
38272  The following two rules will change all 
38273 \family typewriter
38274 ljmp
38275 \family default
38276  and 
38277 \family typewriter
38278 lcall
38279 \family default
38280  to 
38281 \family typewriter
38282 ajmp
38283 \family default
38284  and 
38285 \family typewriter
38286 acall
38287 \end_layout
38288
38289 \begin_layout Verse
38290
38291 \family typewriter
38292 replace { lcall %1 } by { acall %1 } 
38293 \newline
38294 replace { ljmp %1 } by { ajmp %1 }
38295 \end_layout
38296
38297 \begin_layout Standard
38298 (NOTE: from version 2.7.3 on, you can use option -
38299 \emph on
38300
38301 \begin_inset ERT
38302 status collapsed
38303
38304 \begin_layout Standard
38305
38306
38307 \backslash
38308 /
38309 \end_layout
38310
38311 \end_inset
38312
38313
38314 \emph default
38315 -acall-ajmp
38316 \begin_inset LatexCommand index
38317 name "-\\/-acall-ajmp"
38318
38319 \end_inset
38320
38321 , which also takes care of aligning the interrupt vectors properly.)
38322 \newline
38323
38324 \end_layout
38325
38326 \begin_layout Standard
38327 The 
38328 \emph on
38329 inline-assembler code
38330 \emph default
38331  is also passed through the peep hole optimizer, thus the peephole optimizer
38332  can also be used as an assembly level macro expander.
38333  The rules themselves are MCU dependent whereas the rule language infra-structur
38334 e is MCU independent.
38335  Peephole optimization rules for other MCU can be easily programmed using
38336  the rule language.
38337 \newline
38338
38339 \newline
38340 The syntax for a rule is as follows:
38341 \end_layout
38342
38343 \begin_layout Verse
38344
38345 \family typewriter
38346 rule := replace [ restart ] '{' <assembly sequence> '
38347 \backslash
38348 n' 
38349 \newline
38350 \InsetSpace ~
38351  \InsetSpace ~
38352  \InsetSpace ~
38353  \InsetSpace ~
38354  \InsetSpace ~
38355  \InsetSpace ~
38356  \InsetSpace ~
38357  \InsetSpace ~
38358  \InsetSpace ~
38359  \InsetSpace ~
38360  \InsetSpace ~
38361  \InsetSpace ~
38362  \InsetSpace ~
38363  \InsetSpace ~
38364  '}' by '{' '
38365 \backslash
38366 n' 
38367 \newline
38368 \InsetSpace ~
38369  \InsetSpace ~
38370  \InsetSpace ~
38371  \InsetSpace ~
38372  \InsetSpace ~
38373  \InsetSpace ~
38374  \InsetSpace ~
38375  \InsetSpace ~
38376  \InsetSpace ~
38377  \InsetSpace ~
38378  \InsetSpace ~
38379  \InsetSpace ~
38380  \InsetSpace ~
38381  \InsetSpace ~
38382  \InsetSpace ~
38383  \InsetSpace ~
38384  <assembly sequence> '
38385 \backslash
38386 n' 
38387 \newline
38388 \InsetSpace ~
38389  \InsetSpace ~
38390  \InsetSpace ~
38391  \InsetSpace ~
38392  \InsetSpace ~
38393  \InsetSpace ~
38394  \InsetSpace ~
38395  \InsetSpace ~
38396  \InsetSpace ~
38397  \InsetSpace ~
38398  \InsetSpace ~
38399  \InsetSpace ~
38400  \InsetSpace ~
38401  \InsetSpace ~
38402  '}' [if <functionName> ] '
38403 \backslash
38404 n' 
38405 \end_layout
38406
38407 \begin_layout Standard
38408 <assembly sequence> := assembly instruction (each instruction including
38409  labels must be on a separate line).
38410 \newline
38411
38412 \newline
38413 The optimizer will apply to the rules
38414  one by one from the top in the sequence of their appearance, it will terminate
38415  when all rules are exhausted.
38416  If the 'restart' option is specified, then the optimizer will start matching
38417  the rules again from the top, this option for a rule is expensive (performance)
38418 , it is intended to be used in situations where a transformation will trigger
38419  the same rule again.
38420  An example of this (not a good one, it has side effects) is the following
38421  rule:
38422 \end_layout
38423
38424 \begin_layout Verse
38425
38426 \family typewriter
38427 replace restart { 
38428 \newline
38429 \InsetSpace ~
38430 \InsetSpace ~
38431 pop %1 
38432 \newline
38433 \InsetSpace ~
38434 \InsetSpace ~
38435 push %1 } by { 
38436 \newline
38437 \InsetSpace ~
38438 \InsetSpace ~
38439 ; nop 
38440 \newline
38441 }
38442 \end_layout
38443
38444 \begin_layout Standard
38445 Note that the replace pattern cannot be a blank, but can be a comment line.
38446  Without the 'restart' option only the innermost 'pop' 'push' pair would
38447  be eliminated, i.e.:
38448 \end_layout
38449
38450 \begin_layout Verse
38451
38452 \family typewriter
38453 pop ar1 
38454 \newline
38455 pop ar2 
38456 \newline
38457 push ar2 
38458 \newline
38459 push ar1
38460 \end_layout
38461
38462 \begin_layout Standard
38463 would result in:
38464 \end_layout
38465
38466 \begin_layout Verse
38467
38468 \family typewriter
38469 pop ar1 
38470 \newline
38471 ; nop 
38472 \newline
38473 push ar1
38474 \end_layout
38475
38476 \begin_layout Standard
38477
38478 \emph on
38479 with
38480 \emph default
38481  the restart option the rule will be applied again to the resulting code
38482  and then all the pop-push pairs will be eliminated to yield:
38483 \end_layout
38484
38485 \begin_layout Verse
38486
38487 \family typewriter
38488 ; nop 
38489 \newline
38490 ; nop
38491 \end_layout
38492
38493 \begin_layout Standard
38494 A conditional function can be attached to a rule.
38495  Attaching rules are somewhat more involved, let me illustrate this with
38496  an example.
38497 \end_layout
38498
38499 \begin_layout Verse
38500
38501 \family typewriter
38502 replace { 
38503 \newline
38504 \InsetSpace ~
38505  \InsetSpace ~
38506  \InsetSpace ~
38507 ljmp %5 
38508 \newline
38509 %2:
38510 \newline
38511 } by { 
38512 \newline
38513 \InsetSpace ~
38514  \InsetSpace ~
38515  \InsetSpace ~
38516 sjmp %5 
38517 \newline
38518 %2:
38519 \newline
38520 } if labelInRange
38521 \end_layout
38522
38523 \begin_layout Standard
38524 The optimizer does a look-up of a function name table defined in function
38525  
38526 \emph on
38527 callFuncByName
38528 \emph default
38529  in the source file SDCCpeeph.c, with the name 
38530 \emph on
38531 labelInRange
38532 \emph default
38533 .
38534  If it finds a corresponding entry the function is called.
38535  Note there can be no parameters specified for these functions, in this
38536  case the use of 
38537 \emph on
38538 %5
38539 \emph default
38540  is crucial, since the function 
38541 \emph on
38542 labelInRange
38543 \emph default
38544  expects to find the label in that particular variable (the hash table containin
38545 g the variable bindings is passed as a parameter).
38546  If you want to code more such functions, take a close look at the function
38547  labelInRange and the calling mechanism in source file SDCCpeeph.c.
38548  Currently implemented are 
38549 \emph on
38550 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
38551  24bitMode, portIsDS390, 24bitModeAndPortDS390
38552 \emph default
38553  and 
38554 \emph on
38555 notVolatile
38556 \emph default
38557 .
38558 \end_layout
38559
38560 \begin_layout Standard
38561 I know this whole thing is a little kludgey, but maybe some day we will
38562  have some better means.
38563  If you are looking at this file, you will see the default rules that are
38564  compiled into the compiler, you can add your own rules in the default set
38565  there if you get tired of specifying the -
38566 \begin_inset ERT
38567 status collapsed
38568
38569 \begin_layout Standard
38570
38571
38572 \backslash
38573 /
38574 \end_layout
38575
38576 \end_inset
38577
38578 -peep-file option.
38579 \end_layout
38580
38581 \begin_layout Section
38582 ANSI-Compliance
38583 \begin_inset LatexCommand index
38584 name "ANSI-compliance"
38585
38586 \end_inset
38587
38588
38589 \begin_inset LatexCommand label
38590 name "sub:ANSI-Compliance"
38591
38592 \end_inset
38593
38594
38595 \end_layout
38596
38597 \begin_layout Standard
38598 The latest publicly available version of the standard 
38599 \emph on
38600 ISO/IEC 9899 - Programming languages - C
38601 \emph default
38602  should be available at: 
38603 \begin_inset LatexCommand url
38604 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
38605
38606 \end_inset
38607
38608 .
38609 \newline
38610
38611 \end_layout
38612
38613 \begin_layout Standard
38614 Deviations from the compliance:
38615 \end_layout
38616
38617 \begin_layout Itemize
38618 functions are not reentrant
38619 \begin_inset LatexCommand index
38620 name "reentrant"
38621
38622 \end_inset
38623
38624  unless explicitly declared as such or the 
38625 \series bold
38626 -
38627 \begin_inset ERT
38628 status collapsed
38629
38630 \begin_layout Standard
38631
38632
38633 \backslash
38634 /
38635 \end_layout
38636
38637 \end_inset
38638
38639 -stack-auto
38640 \begin_inset LatexCommand index
38641 name "-\\/-stack-auto"
38642
38643 \end_inset
38644
38645
38646 \series default
38647  command line option is specified.
38648 \end_layout
38649
38650 \begin_layout Itemize
38651 structures
38652 \begin_inset LatexCommand index
38653 name "struct"
38654
38655 \end_inset
38656
38657  and unions
38658 \begin_inset LatexCommand index
38659 name "union"
38660
38661 \end_inset
38662
38663  cannot be assigned values directly, cannot be passed as function parameters
38664  or assigned to each other and cannot be a return value
38665 \begin_inset LatexCommand index
38666 name "return value"
38667
38668 \end_inset
38669
38670  from a function, e.g.:
38671 \end_layout
38672
38673 \begin_deeper
38674 \begin_layout Verse
38675
38676 \family typewriter
38677 struct s { ...
38678  }; 
38679 \newline
38680 struct s s1, s2; 
38681 \newline
38682 foo() 
38683 \newline
38684
38685 \newline
38686 \InsetSpace ~
38687 \InsetSpace ~
38688 \InsetSpace ~
38689 \InsetSpace ~
38690 ...
38691  
38692 \newline
38693 \InsetSpace ~
38694 \InsetSpace ~
38695 \InsetSpace ~
38696 \InsetSpace ~
38697 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
38698 \newline
38699 \InsetSpace ~
38700 \InsetSpace ~
38701 \InsetSpace ~
38702 \InsetSpace ~
38703 ...
38704  
38705 \newline
38706 }
38707 \newline
38708
38709 \series bold
38710 struct
38711 \family default
38712 \series default
38713  
38714 \family typewriter
38715 s foo1 (
38716 \series bold
38717 struct
38718 \family default
38719 \series default
38720  
38721 \family typewriter
38722 s parms) /* invalid in SDCC although allowed in ANSI */
38723 \newline
38724
38725 \newline
38726 \InsetSpace ~
38727 \InsetSpace ~
38728 \InsetSpace ~
38729 \InsetSpace ~
38730 struct s rets;
38731  
38732 \newline
38733 \InsetSpace ~
38734 \InsetSpace ~
38735 \InsetSpace ~
38736 \InsetSpace ~
38737 ...
38738  
38739 \newline
38740 \InsetSpace ~
38741 \InsetSpace ~
38742 \InsetSpace ~
38743 \InsetSpace ~
38744 return rets; /* is invalid in SDCC although allowed in ANSI */ 
38745 \newline
38746 }
38747 \end_layout
38748
38749 \end_deeper
38750 \begin_layout Itemize
38751 initialization of structure arrays must be fully braced.
38752 \end_layout
38753
38754 \begin_deeper
38755 \begin_layout Verse
38756
38757 \family typewriter
38758 struct s { char x } a[] = {1, 2};\InsetSpace ~
38759 \InsetSpace ~
38760 \InsetSpace ~
38761 \InsetSpace ~
38762 \InsetSpace ~
38763 /* invalid in SDCC */
38764 \newline
38765 struct s { char x
38766  } a[] = {{1}, {2}}; /* OK */
38767 \end_layout
38768
38769 \end_deeper
38770 \begin_layout Itemize
38771 'long long
38772 \begin_inset LatexCommand index
38773 name "long long (not supported)"
38774
38775 \end_inset
38776
38777 ' (64 bit integers
38778 \begin_inset LatexCommand index
38779 name "int (64 bit) (not supported)"
38780
38781 \end_inset
38782
38783 ) not supported.
38784 \end_layout
38785
38786 \begin_layout Itemize
38787 'double
38788 \begin_inset LatexCommand index
38789 name "double (not supported)"
38790
38791 \end_inset
38792
38793 ' precision floating point 
38794 \begin_inset LatexCommand index
38795 name "Floating point support"
38796
38797 \end_inset
38798
38799 not supported.
38800 \end_layout
38801
38802 \begin_layout Itemize
38803 Old K&R style
38804 \begin_inset LatexCommand index
38805 name "K\\&R style"
38806
38807 \end_inset
38808
38809  function declarations are NOT allowed.
38810 \end_layout
38811
38812 \begin_deeper
38813 \begin_layout Verse
38814
38815 \family typewriter
38816 foo(i,j) /* this old style of function declarations */ 
38817 \newline
38818 int i,j; /* is valid
38819  in ANSI but not valid in SDCC */ 
38820 \newline
38821
38822 \newline
38823 \InsetSpace ~
38824 \InsetSpace ~
38825 \InsetSpace ~
38826 \InsetSpace ~
38827 ...
38828  
38829 \newline
38830 }
38831 \end_layout
38832
38833 \end_deeper
38834 \begin_layout Itemize
38835 Most enhancements in C99 are not supported, e.g.:
38836 \end_layout
38837
38838 \begin_deeper
38839 \begin_layout Verse
38840
38841 \family typewriter
38842 for (
38843 \series bold
38844 int
38845 \family default
38846 \series default
38847  
38848 \family typewriter
38849 i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
38850 \end_layout
38851
38852 \end_deeper
38853 \begin_layout Itemize
38854 But some have been added recently in SDCC 2.7.0.
38855  They must be considered alpha quality however.
38856 \end_layout
38857
38858 \begin_deeper
38859 \begin_layout Verse
38860
38861 \family typewriter
38862 \series bold
38863 inline
38864 \begin_inset LatexCommand index
38865 name "inline (not supported)"
38866
38867 \end_inset
38868
38869
38870 \family default
38871 \series default
38872  
38873 \family typewriter
38874 int increment (int a) { return a+1; } /* inlines the increment without function
38875  call overhead */
38876 \newline
38877 int *
38878 \family default
38879  
38880 \family typewriter
38881 \series bold
38882 restrict
38883 \begin_inset LatexCommand index
38884 name "inline (not supported)"
38885
38886 \end_inset
38887
38888
38889 \family default
38890 \series default
38891  
38892 \family typewriter
38893 p; /* accepted but ignored */
38894 \end_layout
38895
38896 \end_deeper
38897 \begin_layout Itemize
38898 Certain words that are valid identifiers in the standard may be reserved
38899  words in SDCC unless the 
38900 \series bold
38901 -
38902 \begin_inset ERT
38903 status collapsed
38904
38905 \begin_layout Standard
38906
38907
38908 \backslash
38909 /
38910 \end_layout
38911
38912 \end_inset
38913
38914 -std-c89
38915 \begin_inset LatexCommand index
38916 name "-\\/-std-c89"
38917
38918 \end_inset
38919
38920
38921 \series default
38922  or 
38923 \series bold
38924 -
38925 \begin_inset ERT
38926 status collapsed
38927
38928 \begin_layout Standard
38929
38930
38931 \backslash
38932 /
38933 \end_layout
38934
38935 \end_inset
38936
38937 -std-c99
38938 \begin_inset LatexCommand index
38939 name "-\\/-std-c99"
38940
38941 \end_inset
38942
38943
38944 \series default
38945  command line options are used.
38946  These may include (depending on the selected processor): 'at', 'banked',
38947  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
38948 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
38949  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
38950  '_naked'.
38951  Compliant equivalents of these keywords are always available in a form
38952  that begin with two underscores
38953 \begin_inset LatexCommand index
38954 name "\\_\\_ (prefix for extended keywords)"
38955
38956 \end_inset
38957
38958 , f.e.
38959  '__data' instead of 'data'.
38960 \end_layout
38961
38962 \begin_layout Itemize
38963 Integer promotion of variable arguments is not performed if the argument
38964  is explicitly taypecasted unless the 
38965 \series bold
38966 -
38967 \begin_inset ERT
38968 status collapsed
38969
38970 \begin_layout Standard
38971
38972
38973 \backslash
38974 /
38975 \end_layout
38976
38977 \end_inset
38978
38979 -std-c89
38980 \begin_inset LatexCommand index
38981 name "-\\/-std-c89"
38982
38983 \end_inset
38984
38985
38986 \series default
38987  or 
38988 \series bold
38989 -
38990 \begin_inset ERT
38991 status collapsed
38992
38993 \begin_layout Standard
38994
38995
38996 \backslash
38997 /
38998 \end_layout
38999
39000 \end_inset
39001
39002 -std-c99
39003 \begin_inset LatexCommand index
39004 name "-\\/-std-c99"
39005
39006 \end_inset
39007
39008
39009 \series default
39010  command line options are used.
39011 \end_layout
39012
39013 \begin_deeper
39014 \begin_layout Verse
39015
39016 \family typewriter
39017 void vararg_func (char *str, ...) { str; }
39018 \newline
39019
39020 \newline
39021 void main (void)
39022 \newline
39023 {
39024 \newline
39025 \InsetSpace ~
39026 \InsetSpace ~
39027 char c = 10;
39028 \newline
39029
39030 \newline
39031 \InsetSpace ~
39032 \InsetSpace ~
39033 /* argument
39034  u is promoted to int before
39035 \newline
39036 \InsetSpace ~
39037 \InsetSpace ~
39038 \InsetSpace ~
39039 * passing to function */
39040 \newline
39041 \InsetSpace ~
39042 \InsetSpace ~
39043 vararg_func ("%c", c);
39044 \newline
39045
39046 \newline
39047 \InsetSpace ~
39048 \InsetSpace ~
39049 /*
39050  argument u is not promoted to int,
39051 \newline
39052 \InsetSpace ~
39053 \InsetSpace ~
39054 \InsetSpace ~
39055 * it is passed as char to function
39056 \newline
39057 \InsetSpace ~
39058 \InsetSpace ~
39059 \InsetSpace ~
39060 * if
39061  --std-cXX is not defined;
39062 \newline
39063 \InsetSpace ~
39064 \InsetSpace ~
39065 \InsetSpace ~
39066 * is promoted to int before passing
39067 \newline
39068 \InsetSpace ~
39069 \InsetSpace ~
39070 \InsetSpace ~
39071 * to function
39072  if --std-cXX is defined */
39073 \newline
39074 \InsetSpace ~
39075 \InsetSpace ~
39076 vararg_func ("%bc", (char)u);
39077 \newline
39078 }
39079 \end_layout
39080
39081 \end_deeper
39082 \begin_layout Section
39083 Cyclomatic Complexity
39084 \begin_inset LatexCommand index
39085 name "Cyclomatic complexity"
39086
39087 \end_inset
39088
39089
39090 \end_layout
39091
39092 \begin_layout Standard
39093 Cyclomatic complexity of a function is defined as the number of independent
39094  paths the program can take during execution of the function.
39095  This is an important number since it defines the number test cases you
39096  have to generate to validate the function.
39097  The accepted industry standard for complexity number is 10, if the cyclomatic
39098  complexity reported by SDCC exceeds 10 you should think about simplification
39099  of the function logic.
39100  Note that the complexity level is not related to the number of lines of
39101  code in a function.
39102  Large functions can have low complexity, and small functions can have large
39103  complexity levels.
39104  
39105 \newline
39106
39107 \newline
39108 SDCC uses the following formula to compute the complexity:
39109 \newline
39110
39111 \end_layout
39112
39113 \begin_layout Standard
39114 complexity = (number of edges in control flow graph) - (number of nodes
39115  in control flow graph) + 2;
39116 \newline
39117
39118 \newline
39119 Having said that the industry standard is 10,
39120  you should be aware that in some cases it be may unavoidable to have a
39121  complexity level of less than 10.
39122  For example if you have switch statement with more than 10 case labels,
39123  each case label adds one to the complexity level.
39124  The complexity level is by no means an absolute measure of the algorithmic
39125  complexity of the function, it does however provide a good starting point
39126  for which functions you might look at for further optimization.
39127 \end_layout
39128
39129 \begin_layout Section
39130 Retargetting for other Processors
39131 \end_layout
39132
39133 \begin_layout Standard
39134 The issues for retargetting the compiler are far too numerous to be covered
39135  by this document.
39136  What follows is a brief description of each of the seven phases of the
39137  compiler and its MCU dependency.
39138 \end_layout
39139
39140 \begin_layout Itemize
39141 Parsing the source and building the annotated parse tree.
39142  This phase is largely MCU independent (except for the language extensions).
39143  Syntax & semantic checks are also done in this phase, along with some initial
39144  optimizations like back patching labels and the pattern matching optimizations
39145  like bit-rotation etc.
39146 \end_layout
39147
39148 \begin_layout Itemize
39149 The second phase involves generating an intermediate code which can be easy
39150  manipulated during the later phases.
39151  This phase is entirely MCU independent.
39152  The intermediate code generation assumes the target machine has unlimited
39153  number of registers, and designates them with the name iTemp.
39154  The compiler can be made to dump a human readable form of the code generated
39155  by using the -
39156 \begin_inset ERT
39157 status collapsed
39158
39159 \begin_layout Standard
39160
39161
39162 \backslash
39163 /
39164 \end_layout
39165
39166 \end_inset
39167
39168 -dumpraw option.
39169 \end_layout
39170
39171 \begin_layout Itemize
39172 This phase does the bulk of the standard optimizations and is also MCU independe
39173 nt.
39174  This phase can be broken down into several sub-phases:
39175 \newline
39176
39177 \newline
39178 Break down intermediate
39179  code (iCode) into basic blocks.
39180 \newline
39181 Do control flow & data flow analysis on the
39182  basic blocks.
39183 \newline
39184 Do local common subexpression elimination, then global subexpressio
39185 n elimination
39186 \newline
39187 Dead code elimination
39188 \newline
39189 Loop optimizations
39190 \newline
39191 If loop optimizations
39192  caused any changes then do 'global subexpression elimination' and 'dead
39193  code elimination' again.
39194 \end_layout
39195
39196 \begin_layout Itemize
39197 This phase determines the live-ranges; by live range I mean those iTemp
39198  variables defined by the compiler that still survive after all the optimization
39199 s.
39200  Live range analysis
39201 \begin_inset LatexCommand index
39202 name "Live range analysis"
39203
39204 \end_inset
39205
39206  is essential for register allocation, since these computation determines
39207  which of these iTemps will be assigned to registers, and for how long.
39208 \end_layout
39209
39210 \begin_layout Itemize
39211 Phase five is register allocation.
39212  There are two parts to this process.
39213 \newline
39214
39215 \newline
39216 The first part I call 'register packing'
39217  (for lack of a better term).
39218  In this case several MCU specific expression folding is done to reduce
39219  register pressure.
39220 \newline
39221
39222 \newline
39223 The second part is more MCU independent and deals with
39224  allocating registers to the remaining live ranges.
39225  A lot of MCU specific code does creep into this phase because of the limited
39226  number of index registers available in the 8051.
39227 \end_layout
39228
39229 \begin_layout Itemize
39230 The Code generation phase is (unhappily), entirely MCU dependent and very
39231  little (if any at all) of this code can be reused for other MCU.
39232  However the scheme for allocating a homogenized assembler operand for each
39233  iCode operand may be reused.
39234 \end_layout
39235
39236 \begin_layout Itemize
39237 As mentioned in the optimization section the peep-hole optimizer is rule
39238  based system, which can reprogrammed for other MCUs.
39239 \end_layout
39240
39241 \begin_layout Standard
39242 More information is available on SDCC Wiki
39243 \begin_inset LatexCommand index
39244 name "wiki"
39245
39246 \end_inset
39247
39248  (preliminary link 
39249 \begin_inset LatexCommand url
39250 target "http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting"
39251
39252 \end_inset
39253
39254 ) and in the thread 
39255 \begin_inset LatexCommand url
39256 target "http://sf.net/mailarchive/message.php?msg_id=13954144"
39257
39258 \end_inset
39259
39260  .
39261 \end_layout
39262
39263 \begin_layout Chapter
39264 Compiler internals
39265 \begin_inset LatexCommand index
39266 name "Compiler internals"
39267
39268 \end_inset
39269
39270
39271 \end_layout
39272
39273 \begin_layout Section
39274 The anatomy of the compiler
39275 \begin_inset LatexCommand label
39276 name "sub:The-anatomy-of"
39277
39278 \end_inset
39279
39280
39281 \end_layout
39282
39283 \begin_layout Standard
39284
39285 \shape italic
39286 This is an excerpt from an article published in Circuit Cellar Magazine
39287  in
39288 \shape default
39289  
39290 \series bold
39291 \shape italic
39292 August 2000
39293 \series default
39294 .
39295  It's a little outdated (the compiler is much more efficient now and user/develo
39296 per friendly), but pretty well exposes the guts of it all.
39297 \shape default
39298
39299 \newline
39300
39301 \newline
39302 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
39303  It is fairly easy to retarget for other 8-bit MCU.
39304  Here we take a look at some of the internals of the compiler.
39305  
39306 \end_layout
39307
39308 \begin_layout Paragraph*
39309 Parsing
39310 \begin_inset LatexCommand index
39311 name "Parsing"
39312
39313 \end_inset
39314
39315  
39316 \end_layout
39317
39318 \begin_layout Standard
39319 Parsing the input source file and creating an AST (Annotated Syntax Tree
39320 \begin_inset LatexCommand index
39321 name "Annotated syntax tree"
39322
39323 \end_inset
39324
39325 ).
39326  This phase also involves propagating types (annotating each node of the
39327  parse tree with type information) and semantic analysis.
39328  There are some MCU specific parsing rules.
39329  For example the storage classes, the extended storage classes are MCU specific
39330  while there may be a xdata storage class for 8051 there is no such storage
39331  class for z80 or Atmel AVR.
39332  SDCC allows MCU specific storage class extensions, i.e.
39333  xdata will be treated as a storage class specifier when parsing 8051 C
39334  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
39335  C code.
39336 \end_layout
39337
39338 \begin_layout Paragraph*
39339 Generating iCode
39340 \begin_inset LatexCommand index
39341 name "iCode"
39342
39343 \end_inset
39344
39345
39346 \end_layout
39347
39348 \begin_layout Standard
39349 Intermediate code generation.
39350  In this phase the AST is broken down into three-operand form (iCode).
39351  These three operand forms are represented as doubly linked lists.
39352  ICode is the term given to the intermediate form generated by the compiler.
39353  ICode example section shows some examples of iCode generated for some simple
39354  C source functions.
39355 \end_layout
39356
39357 \begin_layout Paragraph*
39358 Optimizations
39359 \begin_inset LatexCommand index
39360 name "Optimizations"
39361
39362 \end_inset
39363
39364 .
39365 \end_layout
39366
39367 \begin_layout Standard
39368 Bulk of the target independent optimizations is performed in this phase.
39369  The optimizations include constant propagation, common sub-expression eliminati
39370 on, loop invariant code movement, strength reduction of loop induction variables
39371  and dead-code elimination.
39372 \end_layout
39373
39374 \begin_layout Paragraph*
39375 Live range analysis
39376 \begin_inset LatexCommand index
39377 name "Live range analysis"
39378
39379 \end_inset
39380
39381
39382 \end_layout
39383
39384 \begin_layout Standard
39385 During intermediate code generation phase, the compiler assumes the target
39386  machine has infinite number of registers and generates a lot of temporary
39387  variables.
39388  The live range computation determines the lifetime of each of these compiler-ge
39389 nerated temporaries.
39390  A picture speaks a thousand words.
39391  ICode example sections show the live range annotations for each of the
39392  operand.
39393  It is important to note here, each iCode is assigned a number in the order
39394  of its execution in the function.
39395  The live ranges are computed in terms of these numbers.
39396  The from number is the number of the iCode which first defines the operand
39397  and the to number signifies the iCode which uses this operand last.
39398 \end_layout
39399
39400 \begin_layout Paragraph*
39401 Register Allocation
39402 \begin_inset LatexCommand index
39403 name "Register allocation"
39404
39405 \end_inset
39406
39407
39408 \end_layout
39409
39410 \begin_layout Standard
39411 The register allocation determines the type and number of registers needed
39412  by each operand.
39413  In most MCUs only a few registers can be used for indirect addressing.
39414  In case of 8051 for example the registers R0 & R1 can be used to indirectly
39415  address the internal ram and DPTR to indirectly address the external ram.
39416  The compiler will try to allocate the appropriate register to pointer variables
39417  if it can.
39418  ICode example section shows the operands annotated with the registers assigned
39419  to them.
39420  The compiler will try to keep operands in registers as much as possible;
39421  there are several schemes the compiler uses to do achieve this.
39422  When the compiler runs out of registers the compiler will check to see
39423  if there are any live operands which is not used or defined in the current
39424  basic block being processed, if there are any found then it will push that
39425  operand and use the registers in this block, the operand will then be popped
39426  at the end of the basic block.
39427  
39428 \end_layout
39429
39430 \begin_layout Standard
39431 There are other MCU specific considerations in this phase.
39432  Some MCUs have an accumulator; very short-lived operands could be assigned
39433  to the accumulator instead of a general-purpose register.
39434 \end_layout
39435
39436 \begin_layout Paragraph*
39437 Code generation
39438 \end_layout
39439
39440 \begin_layout Standard
39441 Figure II gives a table of iCode
39442 \begin_inset LatexCommand index
39443 name "iCode"
39444
39445 \end_inset
39446
39447  operations supported by the compiler.
39448  The code generation involves translating these operations into corresponding
39449  assembly code for the processor.
39450  This sounds overly simple but that is the essence of code generation.
39451  Some of the iCode operations are generated on a MCU specific manner for
39452  example, the z80 port does not use registers to pass parameters so the
39453  SEND and RECV iCode operations will not be generated, and it also does
39454  not support JUMPTABLES.
39455  
39456 \newline
39457
39458 \end_layout
39459
39460 \begin_layout Standard
39461
39462 \size footnotesize
39463 Figure II 
39464 \begin_inset Tabular
39465 <lyxtabular version="3" rows="39" columns="4">
39466 <features islongtable="true" headBottomDL="true">
39467 <column alignment="block" valignment="top" leftline="true" width="13col%">
39468 <column alignment="left" valignment="top" leftline="true" width="13col%">
39469 <column alignment="block" valignment="top" leftline="true" width="22col%">
39470 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
39471 <row topline="true" bottomline="true" endhead="true">
39472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39473 \begin_inset Text
39474
39475 \begin_layout Standard
39476
39477 \series bold
39478 iCode
39479 \series default
39480
39481 \begin_inset LatexCommand index
39482 name "iCode"
39483
39484 \end_inset
39485
39486
39487 \end_layout
39488
39489 \end_inset
39490 </cell>
39491 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39492 \begin_inset Text
39493
39494 \begin_layout Standard
39495
39496 \series bold
39497 Operands
39498 \end_layout
39499
39500 \end_inset
39501 </cell>
39502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39503 \begin_inset Text
39504
39505 \begin_layout Standard
39506
39507 \series bold
39508 Description
39509 \end_layout
39510
39511 \end_inset
39512 </cell>
39513 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39514 \begin_inset Text
39515
39516 \begin_layout Standard
39517
39518 \series bold
39519 C Equivalent
39520 \end_layout
39521
39522 \end_inset
39523 </cell>
39524 </row>
39525 <row topline="true">
39526 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39527 \begin_inset Text
39528
39529 \begin_layout Standard
39530
39531 \size footnotesize
39532 '!'
39533 \end_layout
39534
39535 \end_inset
39536 </cell>
39537 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39538 \begin_inset Text
39539
39540 \begin_layout Standard
39541
39542 \size footnotesize
39543 IC_LEFT() IC_RESULT()
39544 \end_layout
39545
39546 \end_inset
39547 </cell>
39548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39549 \begin_inset Text
39550
39551 \begin_layout Standard
39552
39553 \size footnotesize
39554 NOT operation 
39555 \end_layout
39556
39557 \end_inset
39558 </cell>
39559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39560 \begin_inset Text
39561
39562 \begin_layout Standard
39563
39564 \size footnotesize
39565 IC_RESULT = ! IC_LEFT;
39566 \end_layout
39567
39568 \end_inset
39569 </cell>
39570 </row>
39571 <row topline="true">
39572 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39573 \begin_inset Text
39574
39575 \begin_layout Standard
39576
39577 \size footnotesize
39578 '~'
39579 \end_layout
39580
39581 \end_inset
39582 </cell>
39583 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39584 \begin_inset Text
39585
39586 \begin_layout Standard
39587
39588 \size footnotesize
39589 IC_LEFT() IC_RESULT()
39590 \end_layout
39591
39592 \end_inset
39593 </cell>
39594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39595 \begin_inset Text
39596
39597 \begin_layout Standard
39598
39599 \size footnotesize
39600 Bitwise complement of 
39601 \end_layout
39602
39603 \end_inset
39604 </cell>
39605 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39606 \begin_inset Text
39607
39608 \begin_layout Standard
39609
39610 \size footnotesize
39611 IC_RESULT = ~IC_LEFT;
39612 \end_layout
39613
39614 \end_inset
39615 </cell>
39616 </row>
39617 <row topline="true">
39618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39619 \begin_inset Text
39620
39621 \begin_layout Standard
39622
39623 \size footnotesize
39624 RRC
39625 \end_layout
39626
39627 \end_inset
39628 </cell>
39629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39630 \begin_inset Text
39631
39632 \begin_layout Standard
39633
39634 \size footnotesize
39635 IC_LEFT() IC_RESULT()
39636 \end_layout
39637
39638 \end_inset
39639 </cell>
39640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39641 \begin_inset Text
39642
39643 \begin_layout Standard
39644
39645 \size footnotesize
39646 Rotate right with carry
39647 \end_layout
39648
39649 \end_inset
39650 </cell>
39651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39652 \begin_inset Text
39653
39654 \begin_layout Standard
39655
39656 \size footnotesize
39657 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
39658 \end_layout
39659
39660 \end_inset
39661 </cell>
39662 </row>
39663 <row topline="true">
39664 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39665 \begin_inset Text
39666
39667 \begin_layout Standard
39668
39669 \size footnotesize
39670 RLC
39671 \end_layout
39672
39673 \end_inset
39674 </cell>
39675 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39676 \begin_inset Text
39677
39678 \begin_layout Standard
39679
39680 \size footnotesize
39681 IC_LEFT() IC_RESULT()
39682 \end_layout
39683
39684 \end_inset
39685 </cell>
39686 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39687 \begin_inset Text
39688
39689 \begin_layout Standard
39690
39691 \size footnotesize
39692 Rotate left with carry
39693 \end_layout
39694
39695 \end_inset
39696 </cell>
39697 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39698 \begin_inset Text
39699
39700 \begin_layout Standard
39701
39702 \size footnotesize
39703 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
39704 \end_layout
39705
39706 \end_inset
39707 </cell>
39708 </row>
39709 <row topline="true">
39710 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39711 \begin_inset Text
39712
39713 \begin_layout Standard
39714
39715 \size footnotesize
39716 GETHBIT
39717 \end_layout
39718
39719 \end_inset
39720 </cell>
39721 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39722 \begin_inset Text
39723
39724 \begin_layout Standard
39725
39726 \size footnotesize
39727 IC_LEFT() IC_RESULT()
39728 \end_layout
39729
39730 \end_inset
39731 </cell>
39732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39733 \begin_inset Text
39734
39735 \begin_layout Standard
39736
39737 \size footnotesize
39738 Get the highest order bit of IC_LEFT
39739 \end_layout
39740
39741 \end_inset
39742 </cell>
39743 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39744 \begin_inset Text
39745
39746 \begin_layout Standard
39747
39748 \size footnotesize
39749 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
39750 \end_layout
39751
39752 \end_inset
39753 </cell>
39754 </row>
39755 <row topline="true">
39756 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39757 \begin_inset Text
39758
39759 \begin_layout Standard
39760
39761 \size footnotesize
39762 UNARYMINUS
39763 \end_layout
39764
39765 \end_inset
39766 </cell>
39767 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39768 \begin_inset Text
39769
39770 \begin_layout Standard
39771
39772 \size footnotesize
39773 IC_LEFT() IC_RESULT()
39774 \end_layout
39775
39776 \end_inset
39777 </cell>
39778 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39779 \begin_inset Text
39780
39781 \begin_layout Standard
39782
39783 \size footnotesize
39784 Unary minus
39785 \end_layout
39786
39787 \end_inset
39788 </cell>
39789 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39790 \begin_inset Text
39791
39792 \begin_layout Standard
39793
39794 \size footnotesize
39795 IC_RESULT = - IC_LEFT;
39796 \end_layout
39797
39798 \end_inset
39799 </cell>
39800 </row>
39801 <row topline="true">
39802 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39803 \begin_inset Text
39804
39805 \begin_layout Standard
39806
39807 \size footnotesize
39808 IPUSH
39809 \end_layout
39810
39811 \end_inset
39812 </cell>
39813 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39814 \begin_inset Text
39815
39816 \begin_layout Standard
39817
39818 \size footnotesize
39819 IC_LEFT()
39820 \end_layout
39821
39822 \end_inset
39823 </cell>
39824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39825 \begin_inset Text
39826
39827 \begin_layout Standard
39828
39829 \size footnotesize
39830 Push the operand into stack
39831 \end_layout
39832
39833 \end_inset
39834 </cell>
39835 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39836 \begin_inset Text
39837
39838 \begin_layout Standard
39839
39840 \size footnotesize
39841 NONE
39842 \end_layout
39843
39844 \end_inset
39845 </cell>
39846 </row>
39847 <row topline="true">
39848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39849 \begin_inset Text
39850
39851 \begin_layout Standard
39852
39853 \size footnotesize
39854 IPOP
39855 \end_layout
39856
39857 \end_inset
39858 </cell>
39859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39860 \begin_inset Text
39861
39862 \begin_layout Standard
39863
39864 \size footnotesize
39865 IC_LEFT()
39866 \end_layout
39867
39868 \end_inset
39869 </cell>
39870 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39871 \begin_inset Text
39872
39873 \begin_layout Standard
39874
39875 \size footnotesize
39876 Pop the operand from the stack 
39877 \end_layout
39878
39879 \end_inset
39880 </cell>
39881 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39882 \begin_inset Text
39883
39884 \begin_layout Standard
39885
39886 \size footnotesize
39887 NONE
39888 \end_layout
39889
39890 \end_inset
39891 </cell>
39892 </row>
39893 <row topline="true">
39894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39895 \begin_inset Text
39896
39897 \begin_layout Standard
39898
39899 \size footnotesize
39900 CALL
39901 \end_layout
39902
39903 \end_inset
39904 </cell>
39905 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39906 \begin_inset Text
39907
39908 \begin_layout Standard
39909
39910 \size footnotesize
39911 IC_LEFT() IC_RESULT()
39912 \end_layout
39913
39914 \end_inset
39915 </cell>
39916 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39917 \begin_inset Text
39918
39919 \begin_layout Standard
39920
39921 \size footnotesize
39922 Call the function represented by IC_LEFT 
39923 \end_layout
39924
39925 \end_inset
39926 </cell>
39927 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39928 \begin_inset Text
39929
39930 \begin_layout Standard
39931
39932 \size footnotesize
39933 IC_RESULT = IC_LEFT();
39934 \end_layout
39935
39936 \end_inset
39937 </cell>
39938 </row>
39939 <row topline="true">
39940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39941 \begin_inset Text
39942
39943 \begin_layout Standard
39944
39945 \size footnotesize
39946 PCALL
39947 \end_layout
39948
39949 \end_inset
39950 </cell>
39951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39952 \begin_inset Text
39953
39954 \begin_layout Standard
39955
39956 \size footnotesize
39957 IC_LEFT() IC_RESULT()
39958 \end_layout
39959
39960 \end_inset
39961 </cell>
39962 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39963 \begin_inset Text
39964
39965 \begin_layout Standard
39966
39967 \size footnotesize
39968 Call via function pointer
39969 \end_layout
39970
39971 \end_inset
39972 </cell>
39973 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39974 \begin_inset Text
39975
39976 \begin_layout Standard
39977
39978 \size footnotesize
39979 IC_RESULT = (*IC_LEFT)();
39980 \end_layout
39981
39982 \end_inset
39983 </cell>
39984 </row>
39985 <row topline="true">
39986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39987 \begin_inset Text
39988
39989 \begin_layout Standard
39990
39991 \size footnotesize
39992 RETURN
39993 \end_layout
39994
39995 \end_inset
39996 </cell>
39997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39998 \begin_inset Text
39999
40000 \begin_layout Standard
40001
40002 \size footnotesize
40003 IC_LEFT()
40004 \end_layout
40005
40006 \end_inset
40007 </cell>
40008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40009 \begin_inset Text
40010
40011 \begin_layout Standard
40012
40013 \size footnotesize
40014 Return the value in operand IC_LEFT 
40015 \end_layout
40016
40017 \end_inset
40018 </cell>
40019 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40020 \begin_inset Text
40021
40022 \begin_layout Standard
40023
40024 \size footnotesize
40025 return IC_LEFT;
40026 \end_layout
40027
40028 \end_inset
40029 </cell>
40030 </row>
40031 <row topline="true">
40032 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40033 \begin_inset Text
40034
40035 \begin_layout Standard
40036
40037 \size footnotesize
40038 LABEL
40039 \end_layout
40040
40041 \end_inset
40042 </cell>
40043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40044 \begin_inset Text
40045
40046 \begin_layout Standard
40047
40048 \size footnotesize
40049 IC_LABEL() 
40050 \end_layout
40051
40052 \end_inset
40053 </cell>
40054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40055 \begin_inset Text
40056
40057 \begin_layout Standard
40058
40059 \size footnotesize
40060 Label
40061 \end_layout
40062
40063 \end_inset
40064 </cell>
40065 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40066 \begin_inset Text
40067
40068 \begin_layout Standard
40069
40070 \size footnotesize
40071 IC_LABEL:
40072 \end_layout
40073
40074 \end_inset
40075 </cell>
40076 </row>
40077 <row topline="true">
40078 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40079 \begin_inset Text
40080
40081 \begin_layout Standard
40082
40083 \size footnotesize
40084 GOTO
40085 \end_layout
40086
40087 \end_inset
40088 </cell>
40089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40090 \begin_inset Text
40091
40092 \begin_layout Standard
40093
40094 \size footnotesize
40095 IC_LABEL() 
40096 \end_layout
40097
40098 \end_inset
40099 </cell>
40100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40101 \begin_inset Text
40102
40103 \begin_layout Standard
40104
40105 \size footnotesize
40106 Goto label
40107 \end_layout
40108
40109 \end_inset
40110 </cell>
40111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40112 \begin_inset Text
40113
40114 \begin_layout Standard
40115
40116 \size footnotesize
40117 goto IC_LABEL();
40118 \end_layout
40119
40120 \end_inset
40121 </cell>
40122 </row>
40123 <row topline="true">
40124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40125 \begin_inset Text
40126
40127 \begin_layout Standard
40128
40129 \size footnotesize
40130 '+'
40131 \end_layout
40132
40133 \end_inset
40134 </cell>
40135 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40136 \begin_inset Text
40137
40138 \begin_layout Standard
40139
40140 \size footnotesize
40141 IC_LEFT() IC_RIGHT() IC_RESULT()
40142 \end_layout
40143
40144 \end_inset
40145 </cell>
40146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40147 \begin_inset Text
40148
40149 \begin_layout Standard
40150
40151 \size footnotesize
40152 Addition
40153 \end_layout
40154
40155 \end_inset
40156 </cell>
40157 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40158 \begin_inset Text
40159
40160 \begin_layout Standard
40161
40162 \size footnotesize
40163 IC_RESULT = IC_LEFT + IC_RIGHT
40164 \end_layout
40165
40166 \end_inset
40167 </cell>
40168 </row>
40169 <row topline="true">
40170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40171 \begin_inset Text
40172
40173 \begin_layout Standard
40174
40175 \size footnotesize
40176 '-'
40177 \end_layout
40178
40179 \end_inset
40180 </cell>
40181 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40182 \begin_inset Text
40183
40184 \begin_layout Standard
40185
40186 \size footnotesize
40187 IC_LEFT() IC_RIGHT() IC_RESULT()
40188 \end_layout
40189
40190 \end_inset
40191 </cell>
40192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40193 \begin_inset Text
40194
40195 \begin_layout Standard
40196
40197 \size footnotesize
40198 Subtraction
40199 \end_layout
40200
40201 \end_inset
40202 </cell>
40203 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40204 \begin_inset Text
40205
40206 \begin_layout Standard
40207
40208 \size footnotesize
40209 IC_RESULT = IC_LEFT - IC_RIGHT 
40210 \end_layout
40211
40212 \end_inset
40213 </cell>
40214 </row>
40215 <row topline="true">
40216 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40217 \begin_inset Text
40218
40219 \begin_layout Standard
40220
40221 \size footnotesize
40222 '*'
40223 \end_layout
40224
40225 \end_inset
40226 </cell>
40227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40228 \begin_inset Text
40229
40230 \begin_layout Standard
40231
40232 \size footnotesize
40233 IC_LEFT() IC_RIGHT() IC_RESULT()
40234 \end_layout
40235
40236 \end_inset
40237 </cell>
40238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40239 \begin_inset Text
40240
40241 \begin_layout Standard
40242
40243 \size footnotesize
40244 Multiplication 
40245 \end_layout
40246
40247 \end_inset
40248 </cell>
40249 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40250 \begin_inset Text
40251
40252 \begin_layout Standard
40253
40254 \size footnotesize
40255 IC_RESULT = IC_LEFT * IC_RIGHT;
40256 \end_layout
40257
40258 \end_inset
40259 </cell>
40260 </row>
40261 <row topline="true">
40262 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40263 \begin_inset Text
40264
40265 \begin_layout Standard
40266
40267 \size footnotesize
40268 '/'
40269 \end_layout
40270
40271 \end_inset
40272 </cell>
40273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40274 \begin_inset Text
40275
40276 \begin_layout Standard
40277
40278 \size footnotesize
40279 IC_LEFT() IC_RIGHT() IC_RESULT()
40280 \end_layout
40281
40282 \end_inset
40283 </cell>
40284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40285 \begin_inset Text
40286
40287 \begin_layout Standard
40288
40289 \size footnotesize
40290 Division
40291 \end_layout
40292
40293 \end_inset
40294 </cell>
40295 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40296 \begin_inset Text
40297
40298 \begin_layout Standard
40299
40300 \size footnotesize
40301 IC_RESULT = IC_LEFT / IC_RIGHT;
40302 \end_layout
40303
40304 \end_inset
40305 </cell>
40306 </row>
40307 <row topline="true">
40308 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40309 \begin_inset Text
40310
40311 \begin_layout Standard
40312
40313 \size footnotesize
40314 '%'
40315 \end_layout
40316
40317 \end_inset
40318 </cell>
40319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40320 \begin_inset Text
40321
40322 \begin_layout Standard
40323
40324 \size footnotesize
40325 IC_LEFT() IC_RIGHT() IC_RESULT()
40326 \end_layout
40327
40328 \end_inset
40329 </cell>
40330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40331 \begin_inset Text
40332
40333 \begin_layout Standard
40334
40335 \size footnotesize
40336 Modulus
40337 \end_layout
40338
40339 \end_inset
40340 </cell>
40341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40342 \begin_inset Text
40343
40344 \begin_layout Standard
40345
40346 \size footnotesize
40347 IC_RESULT = IC_LEFT % IC_RIGHT;
40348 \end_layout
40349
40350 \end_inset
40351 </cell>
40352 </row>
40353 <row topline="true">
40354 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40355 \begin_inset Text
40356
40357 \begin_layout Standard
40358
40359 \size footnotesize
40360 '<'
40361 \end_layout
40362
40363 \end_inset
40364 </cell>
40365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40366 \begin_inset Text
40367
40368 \begin_layout Standard
40369
40370 \size footnotesize
40371 IC_LEFT() IC_RIGHT() IC_RESULT()
40372 \end_layout
40373
40374 \end_inset
40375 </cell>
40376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40377 \begin_inset Text
40378
40379 \begin_layout Standard
40380
40381 \size footnotesize
40382 Less than
40383 \end_layout
40384
40385 \end_inset
40386 </cell>
40387 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40388 \begin_inset Text
40389
40390 \begin_layout Standard
40391
40392 \size footnotesize
40393 IC_RESULT = IC_LEFT < IC_RIGHT;
40394 \end_layout
40395
40396 \end_inset
40397 </cell>
40398 </row>
40399 <row topline="true">
40400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40401 \begin_inset Text
40402
40403 \begin_layout Standard
40404
40405 \size footnotesize
40406 '>'
40407 \end_layout
40408
40409 \end_inset
40410 </cell>
40411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40412 \begin_inset Text
40413
40414 \begin_layout Standard
40415
40416 \size footnotesize
40417 IC_LEFT() IC_RIGHT() IC_RESULT()
40418 \end_layout
40419
40420 \end_inset
40421 </cell>
40422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40423 \begin_inset Text
40424
40425 \begin_layout Standard
40426
40427 \size footnotesize
40428 Greater than 
40429 \end_layout
40430
40431 \end_inset
40432 </cell>
40433 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40434 \begin_inset Text
40435
40436 \begin_layout Standard
40437
40438 \size footnotesize
40439 IC_RESULT = IC_LEFT > IC_RIGHT;
40440 \end_layout
40441
40442 \end_inset
40443 </cell>
40444 </row>
40445 <row topline="true">
40446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40447 \begin_inset Text
40448
40449 \begin_layout Standard
40450
40451 \size footnotesize
40452 EQ_OP
40453 \end_layout
40454
40455 \end_inset
40456 </cell>
40457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40458 \begin_inset Text
40459
40460 \begin_layout Standard
40461
40462 \size footnotesize
40463 IC_LEFT() IC_RIGHT() IC_RESULT()
40464 \end_layout
40465
40466 \end_inset
40467 </cell>
40468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40469 \begin_inset Text
40470
40471 \begin_layout Standard
40472
40473 \size footnotesize
40474 Equal to 
40475 \end_layout
40476
40477 \end_inset
40478 </cell>
40479 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40480 \begin_inset Text
40481
40482 \begin_layout Standard
40483
40484 \size footnotesize
40485 IC_RESULT = IC_LEFT == IC_RIGHT;
40486 \end_layout
40487
40488 \end_inset
40489 </cell>
40490 </row>
40491 <row topline="true">
40492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40493 \begin_inset Text
40494
40495 \begin_layout Standard
40496
40497 \size footnotesize
40498 AND_OP
40499 \end_layout
40500
40501 \end_inset
40502 </cell>
40503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40504 \begin_inset Text
40505
40506 \begin_layout Standard
40507
40508 \size footnotesize
40509 IC_LEFT() IC_RIGHT() IC_RESULT() 
40510 \end_layout
40511
40512 \end_inset
40513 </cell>
40514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40515 \begin_inset Text
40516
40517 \begin_layout Standard
40518
40519 \size footnotesize
40520 Logical and operation
40521 \end_layout
40522
40523 \end_inset
40524 </cell>
40525 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40526 \begin_inset Text
40527
40528 \begin_layout Standard
40529
40530 \size footnotesize
40531 IC_RESULT = IC_LEFT && IC_RIGHT; 
40532 \end_layout
40533
40534 \end_inset
40535 </cell>
40536 </row>
40537 <row topline="true">
40538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40539 \begin_inset Text
40540
40541 \begin_layout Standard
40542
40543 \size footnotesize
40544 OR_OP
40545 \end_layout
40546
40547 \end_inset
40548 </cell>
40549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40550 \begin_inset Text
40551
40552 \begin_layout Standard
40553
40554 \size footnotesize
40555 IC_LEFT() IC_RIGHT() IC_RESULT() 
40556 \end_layout
40557
40558 \end_inset
40559 </cell>
40560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40561 \begin_inset Text
40562
40563 \begin_layout Standard
40564
40565 \size footnotesize
40566 Logical or operation 
40567 \end_layout
40568
40569 \end_inset
40570 </cell>
40571 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40572 \begin_inset Text
40573
40574 \begin_layout Standard
40575
40576 \size footnotesize
40577 IC_RESULT = IC_LEFT || IC_RIGHT; 
40578 \end_layout
40579
40580 \end_inset
40581 </cell>
40582 </row>
40583 <row topline="true">
40584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40585 \begin_inset Text
40586
40587 \begin_layout Standard
40588
40589 \size footnotesize
40590 '^'
40591 \end_layout
40592
40593 \end_inset
40594 </cell>
40595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40596 \begin_inset Text
40597
40598 \begin_layout Standard
40599
40600 \size footnotesize
40601 IC_LEFT() IC_RIGHT() IC_RESULT() 
40602 \end_layout
40603
40604 \end_inset
40605 </cell>
40606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40607 \begin_inset Text
40608
40609 \begin_layout Standard
40610
40611 \size footnotesize
40612 Exclusive OR
40613 \end_layout
40614
40615 \end_inset
40616 </cell>
40617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40618 \begin_inset Text
40619
40620 \begin_layout Standard
40621
40622 \size footnotesize
40623 IC_RESULT = IC_LEFT ^ IC_RIGHT;
40624 \end_layout
40625
40626 \end_inset
40627 </cell>
40628 </row>
40629 <row topline="true">
40630 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40631 \begin_inset Text
40632
40633 \begin_layout Standard
40634
40635 \size footnotesize
40636 '|'
40637 \end_layout
40638
40639 \end_inset
40640 </cell>
40641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40642 \begin_inset Text
40643
40644 \begin_layout Standard
40645
40646 \size footnotesize
40647 IC_LEFT() IC_RIGHT() IC_RESULT() 
40648 \end_layout
40649
40650 \end_inset
40651 </cell>
40652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40653 \begin_inset Text
40654
40655 \begin_layout Standard
40656
40657 \size footnotesize
40658 Bitwise OR 
40659 \end_layout
40660
40661 \end_inset
40662 </cell>
40663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40664 \begin_inset Text
40665
40666 \begin_layout Standard
40667
40668 \size footnotesize
40669 IC_RESULT = IC_LEFT | IC_RIGHT;
40670 \end_layout
40671
40672 \end_inset
40673 </cell>
40674 </row>
40675 <row topline="true">
40676 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40677 \begin_inset Text
40678
40679 \begin_layout Standard
40680
40681 \size footnotesize
40682 BITWISEAND
40683 \end_layout
40684
40685 \end_inset
40686 </cell>
40687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40688 \begin_inset Text
40689
40690 \begin_layout Standard
40691
40692 \size footnotesize
40693 IC_LEFT() IC_RIGHT() IC_RESULT()
40694 \end_layout
40695
40696 \end_inset
40697 </cell>
40698 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40699 \begin_inset Text
40700
40701 \begin_layout Standard
40702
40703 \size footnotesize
40704 Bitwise AND 
40705 \end_layout
40706
40707 \end_inset
40708 </cell>
40709 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40710 \begin_inset Text
40711
40712 \begin_layout Standard
40713
40714 \size footnotesize
40715 IC_RESULT = IC_LEFT & IC_RIGHT;
40716 \end_layout
40717
40718 \end_inset
40719 </cell>
40720 </row>
40721 <row topline="true">
40722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40723 \begin_inset Text
40724
40725 \begin_layout Standard
40726
40727 \size footnotesize
40728 LEFT_OP
40729 \end_layout
40730
40731 \end_inset
40732 </cell>
40733 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40734 \begin_inset Text
40735
40736 \begin_layout Standard
40737
40738 \size footnotesize
40739 IC_LEFT() IC_RIGHT() IC_RESULT()
40740 \end_layout
40741
40742 \end_inset
40743 </cell>
40744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40745 \begin_inset Text
40746
40747 \begin_layout Standard
40748
40749 \size footnotesize
40750 Left shift 
40751 \end_layout
40752
40753 \end_inset
40754 </cell>
40755 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40756 \begin_inset Text
40757
40758 \begin_layout Standard
40759
40760 \size footnotesize
40761 IC_RESULT = IC_LEFT << IC_RIGHT 
40762 \end_layout
40763
40764 \end_inset
40765 </cell>
40766 </row>
40767 <row topline="true">
40768 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40769 \begin_inset Text
40770
40771 \begin_layout Standard
40772
40773 \size footnotesize
40774 RIGHT_OP
40775 \end_layout
40776
40777 \end_inset
40778 </cell>
40779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40780 \begin_inset Text
40781
40782 \begin_layout Standard
40783
40784 \size footnotesize
40785 IC_LEFT() IC_RIGHT() IC_RESULT()
40786 \end_layout
40787
40788 \end_inset
40789 </cell>
40790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40791 \begin_inset Text
40792
40793 \begin_layout Standard
40794
40795 \size footnotesize
40796 Right shift
40797 \end_layout
40798
40799 \end_inset
40800 </cell>
40801 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40802 \begin_inset Text
40803
40804 \begin_layout Standard
40805
40806 \size footnotesize
40807 IC_RESULT = IC_LEFT >> IC_RIGHT 
40808 \end_layout
40809
40810 \end_inset
40811 </cell>
40812 </row>
40813 <row topline="true">
40814 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40815 \begin_inset Text
40816
40817 \begin_layout Standard
40818
40819 \size footnotesize
40820 GET_VALUE_
40821 \newline
40822 AT_ ADDRESS
40823 \end_layout
40824
40825 \end_inset
40826 </cell>
40827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40828 \begin_inset Text
40829
40830 \begin_layout Standard
40831
40832 \size footnotesize
40833 IC_LEFT() IC_RESULT()
40834 \end_layout
40835
40836 \end_inset
40837 </cell>
40838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40839 \begin_inset Text
40840
40841 \begin_layout Standard
40842
40843 \size footnotesize
40844 Indirect fetch 
40845 \end_layout
40846
40847 \end_inset
40848 </cell>
40849 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40850 \begin_inset Text
40851
40852 \begin_layout Standard
40853
40854 \size footnotesize
40855 IC_RESULT = (*IC_LEFT);
40856 \end_layout
40857
40858 \end_inset
40859 </cell>
40860 </row>
40861 <row topline="true">
40862 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40863 \begin_inset Text
40864
40865 \begin_layout Standard
40866
40867 \size footnotesize
40868 POINTER_SET
40869 \end_layout
40870
40871 \end_inset
40872 </cell>
40873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40874 \begin_inset Text
40875
40876 \begin_layout Standard
40877
40878 \size footnotesize
40879 IC_RIGHT() IC_RESULT() 
40880 \end_layout
40881
40882 \end_inset
40883 </cell>
40884 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40885 \begin_inset Text
40886
40887 \begin_layout Standard
40888
40889 \size footnotesize
40890 Indirect set
40891 \end_layout
40892
40893 \end_inset
40894 </cell>
40895 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40896 \begin_inset Text
40897
40898 \begin_layout Standard
40899
40900 \size footnotesize
40901 (*IC_RESULT) = IC_RIGHT;
40902 \end_layout
40903
40904 \end_inset
40905 </cell>
40906 </row>
40907 <row topline="true">
40908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40909 \begin_inset Text
40910
40911 \begin_layout Standard
40912
40913 \size footnotesize
40914 '='
40915 \end_layout
40916
40917 \end_inset
40918 </cell>
40919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40920 \begin_inset Text
40921
40922 \begin_layout Standard
40923
40924 \size footnotesize
40925 IC_RIGHT() IC_RESULT()
40926 \end_layout
40927
40928 \end_inset
40929 </cell>
40930 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40931 \begin_inset Text
40932
40933 \begin_layout Standard
40934
40935 \size footnotesize
40936 Assignment
40937 \end_layout
40938
40939 \end_inset
40940 </cell>
40941 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40942 \begin_inset Text
40943
40944 \begin_layout Standard
40945
40946 \size footnotesize
40947 IC_RESULT = IC_RIGHT;
40948 \end_layout
40949
40950 \end_inset
40951 </cell>
40952 </row>
40953 <row topline="true">
40954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40955 \begin_inset Text
40956
40957 \begin_layout Standard
40958
40959 \size footnotesize
40960 IFX
40961 \end_layout
40962
40963 \end_inset
40964 </cell>
40965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40966 \begin_inset Text
40967
40968 \begin_layout Standard
40969
40970 \size footnotesize
40971 IC_COND IC_TRUE IC_LABEL
40972 \end_layout
40973
40974 \end_inset
40975 </cell>
40976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40977 \begin_inset Text
40978
40979 \begin_layout Standard
40980
40981 \size footnotesize
40982 Conditional jump.
40983  If true label is present then jump to true label if condition is true else
40984  jump to false label if condition is false 
40985 \end_layout
40986
40987 \end_inset
40988 </cell>
40989 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40990 \begin_inset Text
40991
40992 \begin_layout Standard
40993
40994 \size footnotesize
40995 if (IC_COND) goto IC_TRUE; 
40996 \newline
40997 \InsetSpace ~
40998 \InsetSpace ~
40999 Or 
41000 \newline
41001 If (!IC_COND) goto IC_FALSE;
41002 \end_layout
41003
41004 \end_inset
41005 </cell>
41006 </row>
41007 <row topline="true">
41008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41009 \begin_inset Text
41010
41011 \begin_layout Standard
41012
41013 \size footnotesize
41014 ADDRESS_OF
41015 \end_layout
41016
41017 \end_inset
41018 </cell>
41019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41020 \begin_inset Text
41021
41022 \begin_layout Standard
41023
41024 \size footnotesize
41025 IC_LEFT() IC_RESULT()
41026 \end_layout
41027
41028 \end_inset
41029 </cell>
41030 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41031 \begin_inset Text
41032
41033 \begin_layout Standard
41034
41035 \size footnotesize
41036 Address of 
41037 \end_layout
41038
41039 \end_inset
41040 </cell>
41041 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41042 \begin_inset Text
41043
41044 \begin_layout Standard
41045
41046 \size footnotesize
41047 IC_RESULT = &IC_LEFT();
41048 \end_layout
41049
41050 \end_inset
41051 </cell>
41052 </row>
41053 <row topline="true">
41054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41055 \begin_inset Text
41056
41057 \begin_layout Standard
41058
41059 \size footnotesize
41060 JUMPTABLE
41061 \end_layout
41062
41063 \end_inset
41064 </cell>
41065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41066 \begin_inset Text
41067
41068 \begin_layout Standard
41069
41070 \size footnotesize
41071 IC_JTCOND IC_JTLABELS
41072 \end_layout
41073
41074 \end_inset
41075 </cell>
41076 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41077 \begin_inset Text
41078
41079 \begin_layout Standard
41080
41081 \size footnotesize
41082 Jump to list of labels depending on the value of JTCOND
41083 \end_layout
41084
41085 \end_inset
41086 </cell>
41087 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41088 \begin_inset Text
41089
41090 \begin_layout Standard
41091
41092 \size footnotesize
41093 Switch statement
41094 \end_layout
41095
41096 \end_inset
41097 </cell>
41098 </row>
41099 <row topline="true">
41100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41101 \begin_inset Text
41102
41103 \begin_layout Standard
41104
41105 \size footnotesize
41106 CAST
41107 \end_layout
41108
41109 \end_inset
41110 </cell>
41111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41112 \begin_inset Text
41113
41114 \begin_layout Standard
41115
41116 \size footnotesize
41117 IC_RIGHT() IC_LEFT() IC_RESULT()
41118 \end_layout
41119
41120 \end_inset
41121 </cell>
41122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41123 \begin_inset Text
41124
41125 \begin_layout Standard
41126
41127 \size footnotesize
41128 Cast types 
41129 \end_layout
41130
41131 \end_inset
41132 </cell>
41133 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41134 \begin_inset Text
41135
41136 \begin_layout Standard
41137
41138 \size footnotesize
41139 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
41140 \end_layout
41141
41142 \end_inset
41143 </cell>
41144 </row>
41145 <row topline="true">
41146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41147 \begin_inset Text
41148
41149 \begin_layout Standard
41150
41151 \size footnotesize
41152 SEND
41153 \end_layout
41154
41155 \end_inset
41156 </cell>
41157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41158 \begin_inset Text
41159
41160 \begin_layout Standard
41161
41162 \size footnotesize
41163 IC_LEFT()
41164 \end_layout
41165
41166 \end_inset
41167 </cell>
41168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41169 \begin_inset Text
41170
41171 \begin_layout Standard
41172
41173 \size footnotesize
41174 This is used for passing parameters in registers; 
41175 \newline
41176 move IC_LEFT to the next
41177  available parameter register.
41178 \end_layout
41179
41180 \end_inset
41181 </cell>
41182 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41183 \begin_inset Text
41184
41185 \begin_layout Standard
41186
41187 \size footnotesize
41188 None
41189 \end_layout
41190
41191 \end_inset
41192 </cell>
41193 </row>
41194 <row topline="true">
41195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41196 \begin_inset Text
41197
41198 \begin_layout Standard
41199
41200 \size footnotesize
41201 RECV
41202 \end_layout
41203
41204 \end_inset
41205 </cell>
41206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41207 \begin_inset Text
41208
41209 \begin_layout Standard
41210
41211 \size footnotesize
41212 IC_RESULT()
41213 \end_layout
41214
41215 \end_inset
41216 </cell>
41217 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41218 \begin_inset Text
41219
41220 \begin_layout Standard
41221
41222 \size footnotesize
41223 This is used for receiving parameters passed in registers;
41224 \newline
41225 Move the values
41226  in the next parameter register to IC_RESULT 
41227 \end_layout
41228
41229 \end_inset
41230 </cell>
41231 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41232 \begin_inset Text
41233
41234 \begin_layout Standard
41235
41236 \size footnotesize
41237 None
41238 \end_layout
41239
41240 \end_inset
41241 </cell>
41242 </row>
41243 <row topline="true" bottomline="true">
41244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41245 \begin_inset Text
41246
41247 \begin_layout Standard
41248
41249 \shape slanted
41250 \size footnotesize
41251 (some more have been added)
41252 \end_layout
41253
41254 \end_inset
41255 </cell>
41256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41257 \begin_inset Text
41258
41259 \begin_layout Standard
41260
41261 \end_layout
41262
41263 \end_inset
41264 </cell>
41265 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41266 \begin_inset Text
41267
41268 \begin_layout Standard
41269
41270 \end_layout
41271
41272 \end_inset
41273 </cell>
41274 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41275 \begin_inset Text
41276
41277 \begin_layout Standard
41278
41279 \shape slanted
41280 \size footnotesize
41281 see f.e.
41282
41283 \shape default
41284  
41285 \family typewriter
41286 \shape slanted
41287 gen51Code()
41288 \family default
41289 \shape default
41290  
41291 \shape slanted
41292 in
41293 \shape default
41294  
41295 \family typewriter
41296 \shape slanted
41297 src/mcs51/gen.c
41298 \end_layout
41299
41300 \end_inset
41301 </cell>
41302 </row>
41303 </lyxtabular>
41304
41305 \end_inset
41306
41307
41308 \end_layout
41309
41310 \begin_layout Standard
41311 \begin_inset Note Note
41312 status collapsed
41313
41314 \begin_layout Standard
41315 In the original article Figure II was announced to be downloadable on 
41316 \shape italic
41317 Circuit Cellar
41318 \shape default
41319 's web site.
41320  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
41321 \end_layout
41322
41323 \end_inset
41324
41325
41326 \end_layout
41327
41328 \begin_layout Paragraph*
41329 ICode Example
41330 \begin_inset LatexCommand index
41331 name "iCode"
41332
41333 \end_inset
41334
41335
41336 \end_layout
41337
41338 \begin_layout Standard
41339 This section shows some details of iCode.
41340  The example C code does not do anything useful; it is used as an example
41341  to illustrate the intermediate code generated by the compiler.
41342 \end_layout
41343
41344 \begin_layout Verse
41345
41346 \family typewriter
41347 1.\InsetSpace ~
41348 xdata int * p;
41349 \newline
41350 2.\InsetSpace ~
41351 int gint;
41352 \newline
41353 3.\InsetSpace ~
41354 /* This function does nothing useful.
41355  It is used
41356 \newline
41357 4.\InsetSpace ~
41358 \InsetSpace ~
41359 \InsetSpace ~
41360 \InsetSpace ~
41361 for the purpose of explaining iCode */
41362 \newline
41363 5.\InsetSpace ~
41364 short function (data
41365  int *x)
41366 \newline
41367 6.\InsetSpace ~
41368 {
41369 \newline
41370 7.\InsetSpace ~
41371 \InsetSpace ~
41372 \InsetSpace ~
41373 short i=10; \InsetSpace ~
41374 \InsetSpace ~
41375 /* dead initialization eliminated */
41376 \newline
41377 8.\InsetSpace ~
41378 \InsetSpace ~
41379 \InsetSpace ~
41380 short sum=10;
41381  /* dead initialization eliminated */
41382 \newline
41383 9.\InsetSpace ~
41384 \InsetSpace ~
41385 \InsetSpace ~
41386 short mul;
41387 \newline
41388 10.\InsetSpace ~
41389 \InsetSpace ~
41390 int j ;
41391 \newline
41392 11.\InsetSpace ~
41393 \InsetSpace ~
41394 while (*x) *x++
41395  = *p++; 
41396 \newline
41397 12.\InsetSpace ~
41398 \InsetSpace ~
41399 \InsetSpace ~
41400 \InsetSpace ~
41401 sum = 0 ; 
41402 \newline
41403 13.\InsetSpace ~
41404 \InsetSpace ~
41405 mul = 0;
41406 \newline
41407 14.\InsetSpace ~
41408 \InsetSpace ~
41409 /* compiler detects i,j to be induction
41410  variables */
41411 \newline
41412 15.\InsetSpace ~
41413 \InsetSpace ~
41414 for (i = 0, j = 10 ; i < 10 ; i++, j
41415 \family default
41416 -
41417 \begin_inset ERT
41418 status collapsed
41419
41420 \begin_layout Standard
41421
41422
41423 \backslash
41424 /
41425 \end_layout
41426
41427 \end_inset
41428
41429 -
41430 \family typewriter
41431 ) {
41432 \newline
41433 16.\InsetSpace ~
41434 \InsetSpace ~
41435 \InsetSpace ~
41436 \InsetSpace ~
41437 sum += i;
41438 \newline
41439 17.\InsetSpace ~
41440 \InsetSpace ~
41441 \InsetSpace ~
41442 \InsetSpace ~
41443 mul += i * 3; \InsetSpace ~
41444 \InsetSpace ~
41445 /* this multiplication remains */
41446 \newline
41447 18.\InsetSpace ~
41448 \InsetSpace ~
41449 \InsetSpace ~
41450 \InsetSpace ~
41451 gint +=
41452  j * 3;\InsetSpace ~
41453 \InsetSpace ~
41454 /* this multiplication changed to addition */
41455 \newline
41456 19.\InsetSpace ~
41457 \InsetSpace ~
41458 }
41459 \newline
41460 20.\InsetSpace ~
41461 \InsetSpace ~
41462 return sum+mul;
41463 \newline
41464 21.\InsetSpace ~
41465 }
41466 \end_layout
41467
41468 \begin_layout Standard
41469 In addition to the operands each iCode contains information about the filename
41470  and line it corresponds to in the source file.
41471  The first field in the listing should be interpreted as follows:
41472 \newline
41473
41474 \shape italic
41475 \size footnotesize
41476 Filename(linenumber: iCode Execution sequence number : ICode hash table
41477  key : loop depth of the iCode).
41478 \shape default
41479 \size default
41480
41481 \newline
41482 Then follows the human readable form of the ICode operation.
41483  Each operand of this triplet form can be of three basic types a) compiler
41484  generated temporary b) user defined variable c) a constant value.
41485  Note that local variables and parameters are replaced by compiler generated
41486  temporaries.
41487  Live ranges
41488 \begin_inset LatexCommand index
41489 name "Live range analysis"
41490
41491 \end_inset
41492
41493  are computed only for temporaries (i.e.
41494  live ranges are not computed for global variables).
41495  Registers
41496 \begin_inset LatexCommand index
41497 name "Register allocation"
41498
41499 \end_inset
41500
41501  are allocated for temporaries only.
41502  Operands are formatted in the following manner:
41503 \newline
41504
41505 \shape italic
41506 \size footnotesize
41507 Operand Name [lr live-from : live-to ] { type information } [ registers
41508  allocated ].
41509 \shape default
41510 \size default
41511
41512 \newline
41513 As mentioned earlier the live ranges are computed in terms of the execution
41514  sequence number of the iCodes, for example 
41515 \newline
41516 the iTemp0 is live from (i.e.
41517  first defined in iCode with execution sequence number 3, and is last used
41518  in the iCode with sequence number 5).
41519  For induction variables such as iTemp21 the live range computation extends
41520  the lifetime from the start to the end of the loop.
41521 \newline
41522 The register allocator
41523  used the live range information to allocate registers, the same registers
41524  may be used for different temporaries if their live ranges do not overlap,
41525  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
41526  ranges do not overlap.
41527  In addition the allocator also takes into consideration the type and usage
41528  of a temporary, for example itemp6 is a pointer to near space and is used
41529  as to fetch data from (i.e.
41530  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
41531  Some short lived temporaries are allocated to special registers which have
41532  meaning to the code generator e.g.
41533  iTemp13 is allocated to a pseudo register CC which tells the back end that
41534  the temporary is used only for a conditional jump the code generation makes
41535  use of this information to optimize a compare and jump ICode.
41536 \newline
41537 There are several
41538  loop optimizations
41539 \begin_inset LatexCommand index
41540 name "Loop optimization"
41541
41542 \end_inset
41543
41544  performed by the compiler.
41545  It can detect induction variables iTemp21(i) and iTemp23(j).
41546  Also note the compiler does selective strength reduction
41547 \begin_inset LatexCommand index
41548 name "Strength reduction"
41549
41550 \end_inset
41551
41552 , i.e.
41553  the multiplication of an induction variable in line 18 (gint = j * 3) is
41554  changed to addition, a new temporary iTemp17 is allocated and assigned
41555  a initial value, a constant 3 is then added for each iteration of the loop.
41556  The compiler does not change the multiplication
41557 \begin_inset LatexCommand index
41558 name "Multiplication"
41559
41560 \end_inset
41561
41562  in line 17 however since the processor does support an 8 * 8 bit multiplication.
41563 \newline
41564
41565 Note the dead code elimination
41566 \begin_inset LatexCommand index
41567 name "Dead-code elimination"
41568
41569 \end_inset
41570
41571  optimization eliminated the dead assignments in line 7 & 8 to I and sum
41572  respectively.
41573 \newline
41574
41575 \end_layout
41576
41577 \begin_layout Standard
41578
41579 \size footnotesize
41580 Sample.c (5:1:0:0) _entry($9) :
41581 \end_layout
41582
41583 \begin_layout Standard
41584
41585 \size footnotesize
41586 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
41587 \end_layout
41588
41589 \begin_layout Standard
41590
41591 \size footnotesize
41592 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
41593 \end_layout
41594
41595 \begin_layout Standard
41596
41597 \size footnotesize
41598 Sample.c(11:4:53:0) preHeaderLbl0($11) :
41599 \end_layout
41600
41601 \begin_layout Standard
41602
41603 \size footnotesize
41604 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
41605  * int}[r2]
41606 \end_layout
41607
41608 \begin_layout Standard
41609
41610 \size footnotesize
41611 Sample.c(11:6:5:1) _whilecontinue_0($1) :
41612 \end_layout
41613
41614 \begin_layout Standard
41615
41616 \size footnotesize
41617 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
41618  int}[r0]]
41619 \end_layout
41620
41621 \begin_layout Standard
41622
41623 \size footnotesize
41624 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41625 \end_layout
41626
41627 \begin_layout Standard
41628
41629 \size footnotesize
41630 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
41631  * int}
41632 \end_layout
41633
41634 \begin_layout Standard
41635
41636 \size footnotesize
41637 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
41638  {short}
41639 \end_layout
41640
41641 \begin_layout Standard
41642
41643 \size footnotesize
41644 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
41645  * int}[DPTR]]
41646 \end_layout
41647
41648 \begin_layout Standard
41649
41650 \size footnotesize
41651 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
41652 }[r2 r3]
41653 \end_layout
41654
41655 \begin_layout Standard
41656
41657 \size footnotesize
41658 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
41659  * int}[r0] + 0x2 {short}
41660 \end_layout
41661
41662 \begin_layout Standard
41663
41664 \size footnotesize
41665 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
41666 \end_layout
41667
41668 \begin_layout Standard
41669
41670 \size footnotesize
41671 Sample.c(11:17:21:0)_whilebreak_0($3) :
41672 \end_layout
41673
41674 \begin_layout Standard
41675
41676 \size footnotesize
41677 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
41678 \end_layout
41679
41680 \begin_layout Standard
41681
41682 \size footnotesize
41683 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
41684 \end_layout
41685
41686 \begin_layout Standard
41687
41688 \size footnotesize
41689 Sample.c(15:20:54:0)preHeaderLbl1($13) :
41690 \end_layout
41691
41692 \begin_layout Standard
41693
41694 \size footnotesize
41695 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
41696 \end_layout
41697
41698 \begin_layout Standard
41699
41700 \size footnotesize
41701 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
41702 \end_layout
41703
41704 \begin_layout Standard
41705
41706 \size footnotesize
41707 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
41708 \end_layout
41709
41710 \begin_layout Standard
41711
41712 \size footnotesize
41713 Sample.c(15:24:26:1)_forcond_0($4) :
41714 \end_layout
41715
41716 \begin_layout Standard
41717
41718 \size footnotesize
41719 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
41720  < 0xa {short}
41721 \end_layout
41722
41723 \begin_layout Standard
41724
41725 \size footnotesize
41726 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
41727 \end_layout
41728
41729 \begin_layout Standard
41730
41731 \size footnotesize
41732 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
41733  + ITemp21 [lr21:38]{short}[r4]
41734 \end_layout
41735
41736 \begin_layout Standard
41737
41738 \size footnotesize
41739 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
41740  * 0x3 {short}
41741 \end_layout
41742
41743 \begin_layout Standard
41744
41745 \size footnotesize
41746 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
41747  + iTemp15 [lr29:30]{short}[r1]
41748 \end_layout
41749
41750 \begin_layout Standard
41751
41752 \size footnotesize
41753 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
41754  r0]- 0x3 {short}
41755 \end_layout
41756
41757 \begin_layout Standard
41758
41759 \size footnotesize
41760 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
41761 int}[r7 r0]
41762 \end_layout
41763
41764 \begin_layout Standard
41765
41766 \size footnotesize
41767 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
41768  + 0x1 {short}
41769 \end_layout
41770
41771 \begin_layout Standard
41772
41773 \size footnotesize
41774 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
41775  r6]- 0x1 {short}
41776 \end_layout
41777
41778 \begin_layout Standard
41779
41780 \size footnotesize
41781 Sample.c(19:38:47:1) goto _forcond_0($4)
41782 \end_layout
41783
41784 \begin_layout Standard
41785
41786 \size footnotesize
41787 Sample.c(19:39:48:0)_forbreak_0($7) :
41788 \end_layout
41789
41790 \begin_layout Standard
41791
41792 \size footnotesize
41793 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
41794  + ITemp11 [lr19:40]{short}[r3]
41795 \end_layout
41796
41797 \begin_layout Standard
41798
41799 \size footnotesize
41800 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
41801 \end_layout
41802
41803 \begin_layout Standard
41804
41805 \size footnotesize
41806 Sample.c(20:42:51:0)_return($8) :
41807 \end_layout
41808
41809 \begin_layout Standard
41810
41811 \size footnotesize
41812 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
41813 \size default
41814
41815 \newline
41816
41817 \newline
41818 Finally the code generated for this function:
41819 \newline
41820
41821 \end_layout
41822
41823 \begin_layout Standard
41824
41825 \size footnotesize
41826 .area DSEG (DATA)
41827 \end_layout
41828
41829 \begin_layout Standard
41830
41831 \size footnotesize
41832 _p::
41833 \end_layout
41834
41835 \begin_layout Standard
41836
41837 \size footnotesize
41838 \InsetSpace ~
41839 \InsetSpace ~
41840 .ds 2
41841 \end_layout
41842
41843 \begin_layout Standard
41844
41845 \size footnotesize
41846 _gint::
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 ; sample.c 5
41861 \end_layout
41862
41863 \begin_layout Standard
41864
41865 \size footnotesize
41866 ; ----------------------------------------------
41867 \end_layout
41868
41869 \begin_layout Standard
41870
41871 \size footnotesize
41872 ; function function
41873 \end_layout
41874
41875 \begin_layout Standard
41876
41877 \size footnotesize
41878 ; ----------------------------------------------
41879 \end_layout
41880
41881 \begin_layout Standard
41882
41883 \size footnotesize
41884 _function:
41885 \end_layout
41886
41887 \begin_layout Standard
41888
41889 \size footnotesize
41890 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
41891 \end_layout
41892
41893 \begin_layout Standard
41894
41895 \size footnotesize
41896 \InsetSpace ~
41897 \InsetSpace ~
41898 mov r2,dpl
41899 \end_layout
41900
41901 \begin_layout Standard
41902
41903 \size footnotesize
41904 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
41905 \end_layout
41906
41907 \begin_layout Standard
41908
41909 \size footnotesize
41910 \InsetSpace ~
41911 \InsetSpace ~
41912 mov ar0,r2
41913 \end_layout
41914
41915 \begin_layout Standard
41916
41917 \size footnotesize
41918 ;_whilecontinue_0($1) :
41919 \end_layout
41920
41921 \begin_layout Standard
41922
41923 \size footnotesize
41924 00101$:
41925 \end_layout
41926
41927 \begin_layout Standard
41928
41929 \size footnotesize
41930 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
41931 \end_layout
41932
41933 \begin_layout Standard
41934
41935 \size footnotesize
41936 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41937 \end_layout
41938
41939 \begin_layout Standard
41940
41941 \size footnotesize
41942 \InsetSpace ~
41943 \InsetSpace ~
41944 mov ar2,@r0
41945 \end_layout
41946
41947 \begin_layout Standard
41948
41949 \size footnotesize
41950 \InsetSpace ~
41951 \InsetSpace ~
41952 inc r0
41953 \end_layout
41954
41955 \begin_layout Standard
41956
41957 \size footnotesize
41958 \InsetSpace ~
41959 \InsetSpace ~
41960 mov ar3,@r0
41961 \end_layout
41962
41963 \begin_layout Standard
41964
41965 \size footnotesize
41966 \InsetSpace ~
41967 \InsetSpace ~
41968 dec r0
41969 \end_layout
41970
41971 \begin_layout Standard
41972
41973 \size footnotesize
41974 \InsetSpace ~
41975 \InsetSpace ~
41976 mov a,r2
41977 \end_layout
41978
41979 \begin_layout Standard
41980
41981 \size footnotesize
41982 \InsetSpace ~
41983 \InsetSpace ~
41984 orl a,r3
41985 \end_layout
41986
41987 \begin_layout Standard
41988
41989 \size footnotesize
41990 \InsetSpace ~
41991 \InsetSpace ~
41992 jz 00103$
41993 \end_layout
41994
41995 \begin_layout Standard
41996
41997 \size footnotesize
41998 00114$:
41999 \end_layout
42000
42001 \begin_layout Standard
42002
42003 \size footnotesize
42004 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
42005 \end_layout
42006
42007 \begin_layout Standard
42008
42009 \size footnotesize
42010 \InsetSpace ~
42011 \InsetSpace ~
42012 mov dpl,_p
42013 \end_layout
42014
42015 \begin_layout Standard
42016
42017 \size footnotesize
42018 \InsetSpace ~
42019 \InsetSpace ~
42020 mov dph,(_p + 1)
42021 \end_layout
42022
42023 \begin_layout Standard
42024
42025 \size footnotesize
42026 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
42027 \end_layout
42028
42029 \begin_layout Standard
42030
42031 \size footnotesize
42032 \InsetSpace ~
42033 \InsetSpace ~
42034 mov a,#0x02
42035 \end_layout
42036
42037 \begin_layout Standard
42038
42039 \size footnotesize
42040 \InsetSpace ~
42041 \InsetSpace ~
42042 add a,_p
42043 \end_layout
42044
42045 \begin_layout Standard
42046
42047 \size footnotesize
42048 \InsetSpace ~
42049 \InsetSpace ~
42050 mov _p,a
42051 \end_layout
42052
42053 \begin_layout Standard
42054
42055 \size footnotesize
42056 \InsetSpace ~
42057 \InsetSpace ~
42058 clr a
42059 \end_layout
42060
42061 \begin_layout Standard
42062
42063 \size footnotesize
42064 \InsetSpace ~
42065 \InsetSpace ~
42066 addc a,(_p + 1)
42067 \end_layout
42068
42069 \begin_layout Standard
42070
42071 \size footnotesize
42072 \InsetSpace ~
42073 \InsetSpace ~
42074 mov (_p + 1),a
42075 \end_layout
42076
42077 \begin_layout Standard
42078
42079 \size footnotesize
42080 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
42081 \end_layout
42082
42083 \begin_layout Standard
42084
42085 \size footnotesize
42086 \InsetSpace ~
42087 \InsetSpace ~
42088 movx a,@dptr
42089 \end_layout
42090
42091 \begin_layout Standard
42092
42093 \size footnotesize
42094 \InsetSpace ~
42095 \InsetSpace ~
42096 mov r2,a
42097 \end_layout
42098
42099 \begin_layout Standard
42100
42101 \size footnotesize
42102 \InsetSpace ~
42103 \InsetSpace ~
42104 inc dptr
42105 \end_layout
42106
42107 \begin_layout Standard
42108
42109 \size footnotesize
42110 \InsetSpace ~
42111 \InsetSpace ~
42112 movx a,@dptr
42113 \end_layout
42114
42115 \begin_layout Standard
42116
42117 \size footnotesize
42118 \InsetSpace ~
42119 \InsetSpace ~
42120 mov r3,a
42121 \end_layout
42122
42123 \begin_layout Standard
42124
42125 \size footnotesize
42126 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
42127 \end_layout
42128
42129 \begin_layout Standard
42130
42131 \size footnotesize
42132 \InsetSpace ~
42133 \InsetSpace ~
42134 mov @r0,ar2
42135 \end_layout
42136
42137 \begin_layout Standard
42138
42139 \size footnotesize
42140 \InsetSpace ~
42141 \InsetSpace ~
42142 inc r0
42143 \end_layout
42144
42145 \begin_layout Standard
42146
42147 \size footnotesize
42148 \InsetSpace ~
42149 \InsetSpace ~
42150 mov @r0,ar3
42151 \end_layout
42152
42153 \begin_layout Standard
42154
42155 \size footnotesize
42156 ; iTemp6 [lr5:16]{_near * int}[r0] = 
42157 \end_layout
42158
42159 \begin_layout Standard
42160
42161 \size footnotesize
42162 ; iTemp6 [lr5:16]{_near * int}[r0] + 
42163 \end_layout
42164
42165 \begin_layout Standard
42166
42167 \size footnotesize
42168 ; 0x2 {short}
42169 \end_layout
42170
42171 \begin_layout Standard
42172
42173 \size footnotesize
42174 \InsetSpace ~
42175 \InsetSpace ~
42176 inc r0
42177 \end_layout
42178
42179 \begin_layout Standard
42180
42181 \size footnotesize
42182 ; goto _whilecontinue_0($1)
42183 \end_layout
42184
42185 \begin_layout Standard
42186
42187 \size footnotesize
42188 \InsetSpace ~
42189 \InsetSpace ~
42190 sjmp 00101$
42191 \end_layout
42192
42193 \begin_layout Standard
42194
42195 \size footnotesize
42196 ; _whilebreak_0($3) :
42197 \end_layout
42198
42199 \begin_layout Standard
42200
42201 \size footnotesize
42202 00103$:
42203 \end_layout
42204
42205 \begin_layout Standard
42206
42207 \size footnotesize
42208 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
42209 \end_layout
42210
42211 \begin_layout Standard
42212
42213 \size footnotesize
42214 \InsetSpace ~
42215 \InsetSpace ~
42216 mov r2,#0x00
42217 \end_layout
42218
42219 \begin_layout Standard
42220
42221 \size footnotesize
42222 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
42223 \end_layout
42224
42225 \begin_layout Standard
42226
42227 \size footnotesize
42228 \InsetSpace ~
42229 \InsetSpace ~
42230 mov r3,#0x00
42231 \end_layout
42232
42233 \begin_layout Standard
42234
42235 \size footnotesize
42236 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
42237 \end_layout
42238
42239 \begin_layout Standard
42240
42241 \size footnotesize
42242 \InsetSpace ~
42243 \InsetSpace ~
42244 mov r4,#0x00
42245 \end_layout
42246
42247 \begin_layout Standard
42248
42249 \size footnotesize
42250 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
42251 \end_layout
42252
42253 \begin_layout Standard
42254
42255 \size footnotesize
42256 \InsetSpace ~
42257 \InsetSpace ~
42258 mov r5,#0x0A
42259 \end_layout
42260
42261 \begin_layout Standard
42262
42263 \size footnotesize
42264 \InsetSpace ~
42265 \InsetSpace ~
42266 mov r6,#0x00
42267 \end_layout
42268
42269 \begin_layout Standard
42270
42271 \size footnotesize
42272 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
42273 \end_layout
42274
42275 \begin_layout Standard
42276
42277 \size footnotesize
42278 \InsetSpace ~
42279 \InsetSpace ~
42280 mov r7,#0x1E
42281 \end_layout
42282
42283 \begin_layout Standard
42284
42285 \size footnotesize
42286 \InsetSpace ~
42287 \InsetSpace ~
42288 mov r0,#0x00
42289 \end_layout
42290
42291 \begin_layout Standard
42292
42293 \size footnotesize
42294 ; _forcond_0($4) :
42295 \end_layout
42296
42297 \begin_layout Standard
42298
42299 \size footnotesize
42300 00104$:
42301 \end_layout
42302
42303 \begin_layout Standard
42304
42305 \size footnotesize
42306 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
42307 \end_layout
42308
42309 \begin_layout Standard
42310
42311 \size footnotesize
42312 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
42313 \end_layout
42314
42315 \begin_layout Standard
42316
42317 \size footnotesize
42318 \InsetSpace ~
42319 \InsetSpace ~
42320 clr c
42321 \end_layout
42322
42323 \begin_layout Standard
42324
42325 \size footnotesize
42326 \InsetSpace ~
42327 \InsetSpace ~
42328 mov a,r4
42329 \end_layout
42330
42331 \begin_layout Standard
42332
42333 \size footnotesize
42334 \InsetSpace ~
42335 \InsetSpace ~
42336 xrl a,#0x80
42337 \end_layout
42338
42339 \begin_layout Standard
42340
42341 \size footnotesize
42342 \InsetSpace ~
42343 \InsetSpace ~
42344 subb a,#0x8a
42345 \end_layout
42346
42347 \begin_layout Standard
42348
42349 \size footnotesize
42350 \InsetSpace ~
42351 \InsetSpace ~
42352 jnc 00107$
42353 \end_layout
42354
42355 \begin_layout Standard
42356
42357 \size footnotesize
42358 00115$:
42359 \end_layout
42360
42361 \begin_layout Standard
42362
42363 \size footnotesize
42364 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
42365 \end_layout
42366
42367 \begin_layout Standard
42368
42369 \size footnotesize
42370 ; iTemp21 [lr21:38]{short}[r4]
42371 \end_layout
42372
42373 \begin_layout Standard
42374
42375 \size footnotesize
42376 \InsetSpace ~
42377 \InsetSpace ~
42378 mov a,r4
42379 \end_layout
42380
42381 \begin_layout Standard
42382
42383 \size footnotesize
42384 \InsetSpace ~
42385 \InsetSpace ~
42386 add a,r2
42387 \end_layout
42388
42389 \begin_layout Standard
42390
42391 \size footnotesize
42392 \InsetSpace ~
42393 \InsetSpace ~
42394 mov r2,a
42395 \end_layout
42396
42397 \begin_layout Standard
42398
42399 \size footnotesize
42400 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
42401 \end_layout
42402
42403 \begin_layout Standard
42404
42405 \size footnotesize
42406 \InsetSpace ~
42407 \InsetSpace ~
42408 mov b,#0x03
42409 \end_layout
42410
42411 \begin_layout Standard
42412
42413 \size footnotesize
42414 \InsetSpace ~
42415 \InsetSpace ~
42416 mov a,r4
42417 \end_layout
42418
42419 \begin_layout Standard
42420
42421 \size footnotesize
42422 \InsetSpace ~
42423 \InsetSpace ~
42424 mul ab
42425 \end_layout
42426
42427 \begin_layout Standard
42428
42429 \size footnotesize
42430 \InsetSpace ~
42431 \InsetSpace ~
42432 mov r1,a
42433 \end_layout
42434
42435 \begin_layout Standard
42436
42437 \size footnotesize
42438 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
42439 \end_layout
42440
42441 \begin_layout Standard
42442
42443 \size footnotesize
42444 ; iTemp15 [lr29:30]{short}[r1]
42445 \end_layout
42446
42447 \begin_layout Standard
42448
42449 \size footnotesize
42450 \InsetSpace ~
42451 \InsetSpace ~
42452 add a,r3
42453 \end_layout
42454
42455 \begin_layout Standard
42456
42457 \size footnotesize
42458 \InsetSpace ~
42459 \InsetSpace ~
42460 mov r3,a
42461 \end_layout
42462
42463 \begin_layout Standard
42464
42465 \size footnotesize
42466 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
42467 \end_layout
42468
42469 \begin_layout Standard
42470
42471 \size footnotesize
42472 \InsetSpace ~
42473 \InsetSpace ~
42474 mov a,r7
42475 \end_layout
42476
42477 \begin_layout Standard
42478
42479 \size footnotesize
42480 \InsetSpace ~
42481 \InsetSpace ~
42482 add a,#0xfd
42483 \end_layout
42484
42485 \begin_layout Standard
42486
42487 \size footnotesize
42488 \InsetSpace ~
42489 \InsetSpace ~
42490 mov r7,a
42491 \end_layout
42492
42493 \begin_layout Standard
42494
42495 \size footnotesize
42496 \InsetSpace ~
42497 \InsetSpace ~
42498 mov a,r0
42499 \end_layout
42500
42501 \begin_layout Standard
42502
42503 \size footnotesize
42504 \InsetSpace ~
42505 \InsetSpace ~
42506 addc a,#0xff
42507 \end_layout
42508
42509 \begin_layout Standard
42510
42511 \size footnotesize
42512 \InsetSpace ~
42513 \InsetSpace ~
42514 mov r0,a
42515 \end_layout
42516
42517 \begin_layout Standard
42518
42519 \size footnotesize
42520 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
42521 \end_layout
42522
42523 \begin_layout Standard
42524
42525 \size footnotesize
42526 \InsetSpace ~
42527 \InsetSpace ~
42528 mov a,r7
42529 \end_layout
42530
42531 \begin_layout Standard
42532
42533 \size footnotesize
42534 \InsetSpace ~
42535 \InsetSpace ~
42536 add a,_gint
42537 \end_layout
42538
42539 \begin_layout Standard
42540
42541 \size footnotesize
42542 \InsetSpace ~
42543 \InsetSpace ~
42544 mov _gint,a
42545 \end_layout
42546
42547 \begin_layout Standard
42548
42549 \size footnotesize
42550 \InsetSpace ~
42551 \InsetSpace ~
42552 mov a,r0
42553 \end_layout
42554
42555 \begin_layout Standard
42556
42557 \size footnotesize
42558 \InsetSpace ~
42559 \InsetSpace ~
42560 addc a,(_gint + 1)
42561 \end_layout
42562
42563 \begin_layout Standard
42564
42565 \size footnotesize
42566 \InsetSpace ~
42567 \InsetSpace ~
42568 mov (_gint + 1),a
42569 \end_layout
42570
42571 \begin_layout Standard
42572
42573 \size footnotesize
42574 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
42575 \end_layout
42576
42577 \begin_layout Standard
42578
42579 \size footnotesize
42580 \InsetSpace ~
42581 \InsetSpace ~
42582 inc r4
42583 \end_layout
42584
42585 \begin_layout Standard
42586
42587 \size footnotesize
42588 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
42589 \end_layout
42590
42591 \begin_layout Standard
42592
42593 \size footnotesize
42594 \InsetSpace ~
42595 \InsetSpace ~
42596 dec r5
42597 \end_layout
42598
42599 \begin_layout Standard
42600
42601 \size footnotesize
42602 \InsetSpace ~
42603 \InsetSpace ~
42604 cjne r5,#0xff,00104$
42605 \end_layout
42606
42607 \begin_layout Standard
42608
42609 \size footnotesize
42610 \InsetSpace ~
42611 \InsetSpace ~
42612 dec r6
42613 \end_layout
42614
42615 \begin_layout Standard
42616
42617 \size footnotesize
42618 ; goto _forcond_0($4)
42619 \end_layout
42620
42621 \begin_layout Standard
42622
42623 \size footnotesize
42624 \InsetSpace ~
42625 \InsetSpace ~
42626 sjmp 00104$
42627 \end_layout
42628
42629 \begin_layout Standard
42630
42631 \size footnotesize
42632 ; _forbreak_0($7) :
42633 \end_layout
42634
42635 \begin_layout Standard
42636
42637 \size footnotesize
42638 00107$:
42639 \end_layout
42640
42641 \begin_layout Standard
42642
42643 \size footnotesize
42644 ; ret iTemp24 [lr40:41]{short}
42645 \end_layout
42646
42647 \begin_layout Standard
42648
42649 \size footnotesize
42650 \InsetSpace ~
42651 \InsetSpace ~
42652 mov a,r3
42653 \end_layout
42654
42655 \begin_layout Standard
42656
42657 \size footnotesize
42658 \InsetSpace ~
42659 \InsetSpace ~
42660 add a,r2
42661 \end_layout
42662
42663 \begin_layout Standard
42664
42665 \size footnotesize
42666 \InsetSpace ~
42667 \InsetSpace ~
42668 mov dpl,a
42669 \end_layout
42670
42671 \begin_layout Standard
42672
42673 \size footnotesize
42674 ; _return($8) :
42675 \end_layout
42676
42677 \begin_layout Standard
42678
42679 \size footnotesize
42680 00108$:
42681 \end_layout
42682
42683 \begin_layout Standard
42684
42685 \size footnotesize
42686 \InsetSpace ~
42687 \InsetSpace ~
42688 ret
42689 \newline
42690
42691 \end_layout
42692
42693 \begin_layout Section
42694 A few words about basic block successors, predecessors and dominators
42695 \end_layout
42696
42697 \begin_layout Standard
42698 Successors are basic blocks
42699 \begin_inset LatexCommand index
42700 name "Basic blocks"
42701
42702 \end_inset
42703
42704  that might execute after this basic block.
42705 \newline
42706 Predecessors are basic blocks
42707  that might execute before reaching this basic block.
42708 \newline
42709 Dominators are basic
42710  blocks that WILL execute before reaching this basic block.
42711 \newline
42712
42713 \end_layout
42714
42715 \begin_layout Standard
42716 [basic block 1]
42717 \end_layout
42718
42719 \begin_layout Standard
42720 if (something)
42721 \end_layout
42722
42723 \begin_layout Standard
42724 \InsetSpace ~
42725 \InsetSpace ~
42726 \InsetSpace ~
42727 \InsetSpace ~
42728 [basic block 2]
42729 \end_layout
42730
42731 \begin_layout Standard
42732 else
42733 \end_layout
42734
42735 \begin_layout Standard
42736 \InsetSpace ~
42737 \InsetSpace ~
42738 \InsetSpace ~
42739 \InsetSpace ~
42740 [basic block 3]
42741 \end_layout
42742
42743 \begin_layout Standard
42744 [basic block 4]
42745 \newline
42746
42747 \end_layout
42748
42749 \begin_layout Standard
42750 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
42751 \end_layout
42752
42753 \begin_layout Standard
42754 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
42755 \end_layout
42756
42757 \begin_layout Standard
42758 c) domVect of [BB4] = BB1 ...
42759  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
42760  was executed.
42761 \end_layout
42762
42763 \begin_layout Chapter
42764 Acknowledgments
42765 \end_layout
42766
42767 \begin_layout Standard
42768 \begin_inset LatexCommand url
42769 target "http://sdcc.sourceforge.net/#Who"
42770
42771 \end_inset
42772
42773
42774 \newline
42775
42776 \newline
42777
42778 \emph on
42779 Thanks to all the other volunteer developers who have helped with coding,
42780  testing, web-page creation, distribution sets, etc.
42781  You know who you are :-)
42782 \emph default
42783
42784 \newline
42785
42786 \newline
42787
42788 \emph on
42789 Thanks to Sourceforge 
42790 \begin_inset LatexCommand url
42791 target "http://www.sf.net"
42792
42793 \end_inset
42794
42795  which has hosted the project since 1999 and donates significant download
42796  bandwidth.
42797 \emph default
42798
42799 \newline
42800
42801 \newline
42802
42803 \emph on
42804 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
42805  cycles and bandwidth for snapshot builds.
42806 \newline
42807
42808 \end_layout
42809
42810 \begin_layout Standard
42811 This document was initially written by Sandeep Dutta
42812 \end_layout
42813
42814 \begin_layout Standard
42815 All product names mentioned herein may be trademarks
42816 \begin_inset LatexCommand index
42817 name "Trademarks"
42818
42819 \end_inset
42820
42821  of their respective companies.
42822  
42823 \end_layout
42824
42825 \begin_layout Section*
42826 Alphabetical index
42827 \end_layout
42828
42829 \begin_layout Standard
42830 To avoid confusion, the installation and building options for SDCC itself
42831  (chapter 2) are not part of the index.
42832 \end_layout
42833
42834 \begin_layout Standard
42835 \begin_inset LatexCommand printindex
42836
42837 \end_inset
42838
42839
42840 \end_layout
42841
42842 \end_body
42843 \end_document